@exploratory/cli 1.0.0-rc.1 → 1.0.0

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 CHANGED
@@ -46,7 +46,7 @@ Create a token once, on a computer where you are signed in:
46
46
  expl server token create --name ci
47
47
  ```
48
48
 
49
- Store it as a secret and pass it as `EXPL_SERVER_TOKEN` (or `--token`). A GitHub Actions step looks like this; the full files are in [examples](https://github.com/exploratory-io/exploratory-cli/tree/main/examples).
49
+ Store it as a secret and pass it as `EXPL_SERVER_TOKEN`. An API key from Account Settings > API Keys works the same way. A GitHub Actions step looks like this; the full files are in [examples](https://github.com/exploratory-io/exploratory-cli/tree/main/examples).
50
50
 
51
51
  ```yaml
52
52
  - uses: actions/setup-node@v4
@@ -59,7 +59,7 @@ Store it as a secret and pass it as `EXPL_SERVER_TOKEN` (or `--token`). A GitHub
59
59
 
60
60
  ## Use with Exploratory Desktop
61
61
 
62
- Commands such as `expl project list` and `expl chart get` talk to the Exploratory Desktop running on the same computer. Desktop must be running and signed in. If it is not running, `expl` exits with code 3; if you are signed out or lack permission, with code 4. See the [Desktop guide](https://github.com/exploratory-io/exploratory-cli/blob/main/docs/desktop.md) for arguments, confirmations and flags.
62
+ Commands such as `expl project list` and `expl chart get` talk to the Exploratory Desktop running on the same computer. Desktop must be running and signed in. If it is not running, `expl` exits with code 3; if you are signed out, lack permission, or the CLI is turned off in Desktop, with code 4. See the [Desktop guide](https://github.com/exploratory-io/exploratory-cli/blob/main/docs/desktop.md) for arguments, confirmations and flags.
63
63
 
64
64
  ## Use from AI agents
65
65
 
@@ -1 +1 @@
1
- (()=>{var e={755(e,t,n){const r=n(317),o=n(982),i=n(896),s=n(928),a="credential.dpapi",c=/^[A-Za-z0-9_.-]{16,200}$/,l=/^[A-Za-z0-9+/]{16,4096}={0,2}$/,u="powershell.exe",p=["-NoProfile","-NonInteractive","-Command","-"];function d(){}function f(e,t,n){const o=n||{};return new Promise(function(n,i){let a;try{a=r.execFile(e,t,{encoding:"utf8",timeout:3e4,maxBuffer:1048576,windowsHide:!0},function(t,r){if(t){const n=new Error("Command failed: "+s.basename(e));return n.code=t.code,void i(n)}n({stdout:r})})}catch(t){const n=new Error("Command could not start: "+s.basename(e));return n.code=t&&t.code,void i(n)}a.stdin.on("error",d),a.stdin.end(void 0===o.input?void 0:o.input)})}function m(e){for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);if(n<=31||127===n)return!0}return!1}function h(e){return'"'+e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'}function g(e,t,n){try{const r=e.fs.readFileSync(t,"utf8").trim();return n.test(r)?r:null}catch(e){return null}}function _(e,t,n){const r=t+"."+o.randomBytes(4).toString("hex")+".tmp";try{e.fs.mkdirSync(e.agentDir,{recursive:!0,mode:448}),e.fs.writeFileSync(r,n,{mode:384}),e.fs.renameSync(r,t)}catch(n){try{e.fs.unlinkSync(r)}catch(e){}throw new Error("Could not write "+t+" ("+(n&&n.code||"error")+")")}}function E(e,t){try{e.fs.unlinkSync(t)}catch(e){if(!e||"ENOENT"!==e.code)throw new Error("Could not remove "+t+" ("+(e&&e.code||"error")+")")}}function w(e){return["$ErrorActionPreference = 'Stop'","Add-Type -AssemblyName System.Security","$plain = '"+e+"'","$bytes = [Security.Cryptography.ProtectedData]::Protect([Text.Encoding]::UTF8.GetBytes($plain), $null, [Security.Cryptography.DataProtectionScope]::CurrentUser)","[Convert]::ToBase64String($bytes)"].join("\n")+"\n"}function y(e){return["$ErrorActionPreference = 'Stop'","Add-Type -AssemblyName System.Security","$blob = [Convert]::FromBase64String('"+e+"')","$bytes = [Security.Cryptography.ProtectedData]::Unprotect($blob, $null, [Security.Cryptography.DataProtectionScope]::CurrentUser)","[Text.Encoding]::UTF8.GetString($bytes)"].join("\n")+"\n"}const N={darwin:{name:"security",set:function(e,t){const n="add-generic-password -U -s "+h(e.service)+" -a "+h(e.account)+" -w "+h(t)+"\n";return e.execFile("security",["-i"],{input:n}).then(d)},get:function(e){return e.execFile("security",["find-generic-password","-s",e.service,"-a",e.account,"-w"],{}).then(function(e){return e.stdout})},remove:function(e){return e.execFile("security",["delete-generic-password","-s",e.service,"-a",e.account],{}).then(d)}},linux:{name:"secret-tool",set:function(e,t){return e.execFile("secret-tool",["store","--label="+e.service,"service",e.service,"account",e.account],{input:t}).then(d)},get:function(e){return e.execFile("secret-tool",["lookup","service",e.service,"account",e.account],{}).then(function(e){return e.stdout})},remove:function(e){return e.execFile("secret-tool",["clear","service",e.service,"account",e.account],{}).then(d)}},win32:{name:"dpapi",set:function(e,t){return e.execFile(u,p,{input:w(t)}).then(function(t){const n=String(t.stdout).trim();if(!l.test(n))throw new Error("DPAPI did not return a protected blob");_(e,s.join(e.agentDir,a),n+"\n")})},get:function(e){const t=g(e,s.join(e.agentDir,a),l);return null===t?Promise.resolve(null):e.execFile(u,p,{input:y(t)}).then(function(e){return e.stdout})},remove:function(e){try{return E(e,s.join(e.agentDir,a)),Promise.resolve()}catch(e){return Promise.reject(e)}}}};e.exports={create:function(e){const t=e||{},n=void 0===t.service||null===t.service?"Exploratory MCP":t.service;if("string"!=typeof n||""===n||m(n))throw new Error("service must be a non-empty string without control characters");if("string"!=typeof t.account||""===t.account||m(t.account))throw new Error("account must be a non-empty string without control characters");if("string"!=typeof t.agentDir||""===t.agentDir)throw new Error("agentDir is required");const r=t.platform||process.platform,o=N[r]||null,a={service:n,account:t.account,agentDir:t.agentDir,fs:t.fs||i,execFile:t.execFile||f},l=s.join(a.agentDir,"credential");return{get:async function(){if(o)try{const e=await o.get(a),t=null==e?"":String(e).trim();if(c.test(t))return t}catch(e){}return g(a,l,c)},set:async function(e){!function(e){if("string"!=typeof e||!c.test(e))throw new Error("The credential is not in the expected format (16 to 200 characters of A-Z a-z 0-9 _ . -)")}(e);let t=!1;if(o)try{return await o.set(a,e),function(e,t){try{E(e,t)}catch(e){}}(a,l),{where:"keychain"}}catch(e){n=e,t=Boolean(n)&&"ENOENT"===n.code}var n;return _(a,l,e+"\n"),o&&!t&&await o.remove(a).catch(d),{where:"file"}},remove:async function(){o&&await o.remove(a).catch(d),E(a,l)},isSecure:async function(){return null===g(a,l,c)},describe:function(){return{backend:o?o.name:"file",service:a.service,account:a.account,file:l}}}}}},548(e,t,n){n(439);const r=["metadata","aggregates","sample","row_level"];e.exports={normalize:function(e){return r.indexOf(e)>=0?e:"row_level"}}},439(e,t,n){const r=n(515),o=-32001,i={DESKTOP_NOT_RUNNING:!0,NOT_SIGNED_IN:!0,UNAUTHORIZED:!0,CHANNEL_DISABLED:!0,PAIRING_PENDING:!0,PAIRING_REQUIRED:!0,PROJECT_NOT_OPEN:!0,NOT_FOUND:!0,PERMISSION_DENIED:!0,CONFIRMATION_REQUIRED:!0,CONFIRMATION_DECLINED:!0,INVALID_PARAMETER:!0,INVALID_COLUMN:!0,INVALID_COLUMN_TYPE:!0,REVISION_CONFLICT:!0,EXECUTION_FAILED:!0,EXECUTION_TIMEOUT:!0,R_REQUIRED:!0,PDF_EXPORT_FAILED:!0,PDF_EXPORT_TIMEOUT:!0,RESOURCE_BUSY:!0,DATA_EGRESS_LIMIT:!0,UNSUPPORTED_OPERATION:!0,VERSION_MISMATCH:!0};class s extends Error{constructor(e,t,n){if(!i[e])throw new Error("Unknown agent error code: "+e);super(t||r.t("en",e+".message")),this.name="AgentError",this.code=e,this.details=n||{},Object.defineProperty(this,"isDefaultMessage",{value:!t,writable:!0}),Object.defineProperty(this,"actionKey",{value:e+".action",writable:!0})}toJSON(e){const t=Object.assign({},this.details,{error_code:this.code,message:this.isDefaultMessage?r.t(e,this.code+".message"):this.message});return t.suggested_actions||(t.suggested_actions=[r.t(e,this.actionKey)]),t}toJsonRpcResponse(e,t){const n=this.toJSON(t);return{jsonrpc:"2.0",id:void 0===e?null:e,error:{code:o,message:n.message,data:n}}}}s.parseToolErrorText=function(e){const t=e||"",n=t.split("\n"),r=n[0]||"",o=/^([A-Z][A-Z0-9_]+): ([\s\S]*)$/.exec(r);if(o&&i[o[1]]){let e=null;const t=[];let r=n.findIndex(function(e,t){return t>0&&0===e.indexOf("Details: ")});r<0&&(r=n.findIndex(function(e,t){return t>0&&0===e.indexOf("- ")})),r<0&&(r=n.length),o[2]=n.slice(0,r).join("\n").slice(o[1].length+2);for(let r=1;r<n.length;r++){const o=n[r];if(0===o.indexOf("Details: "))try{e=JSON.parse(o.slice(9))}catch(e){}else 0===o.indexOf("- ")&&t.push(o.slice(2))}return{errorCode:o[1],message:o[2],details:e,suggestedActions:t}}return/^Input validation error/.test(t)?{errorCode:"INVALID_PARAMETER",message:t,details:null,suggestedActions:[]}:(/^Output validation error/.test(t),{errorCode:"EXECUTION_FAILED",message:t,details:null,suggestedActions:[]})},s.markRBusy=function(e){return e.details.retryable=!0,e.actionKey="RESOURCE_BUSY.r_busy.action",e},s.from=function(e){const t=e&&e.message?String(e.message):String(e);return"There is another R process running."!==t||e instanceof s&&"EXECUTION_FAILED"!==e.code?e instanceof s?e:new s("EXECUTION_FAILED",t):s.markRBusy(new s("RESOURCE_BUSY",t,Object.assign({},e&&e.details)))},s.CODES=Object.freeze(Object.keys(i)),s.JSON_RPC_AGENT_ERROR_CODE=o,e.exports=s},515(e,t,n){const r={en:n(169),ja:n(719)};e.exports={t:function(e,t){const n=r["ja"===e?"ja":"en"][t];if("string"!=typeof n)throw new Error("Unknown agent error message key: "+t);return n}}},85(e){e.exports={MAX_OPERATION_WAIT_MS:25e3}},823(e,t,n){n(896);const r=n(928);n(548),e.exports={agentDir:function(e){return r.join(e,"agent")}}},495(e,t,n){const{ExplError:r}=n(877),{t:o}=n(42),i=[{key:"project",names:["--project"],value:!0},{key:"json",names:["--json"],value:!1},{key:"yes",names:["--yes","-y"],value:!1},{key:"noWait",names:["--no-wait"],value:!1},{key:"timeoutSec",names:["--timeout"],value:!0},{key:"quiet",names:["--quiet","-q"],value:!1},{key:"verbose",names:["--verbose"],value:!1},{key:"input",names:["--input"],value:!0},{key:"output",names:["--output"],value:!0},{key:"help",names:["--help","-h"],value:!1},{key:"version",names:["--version"],value:!1}];function s(e,t){const n=String(e),r=String(t),o=n.length,i=r.length;if(!o)return i;if(!i)return o;const s=new Array(i+1);for(let e=0;e<=i;e++)s[e]=e;for(let e=1;e<=o;e++){let t=s[0];s[0]=e;for(let o=1;o<=i;o++){const i=s[o];s[o]=n[e-1]===r[o-1]?t:1+Math.min(t,s[o],s[o-1]),t=i}}return s[i]}function a(e,t){return t.map(function(t){return{name:t,d:s(e,t)}}).filter(function(e){return e.d<=2}).sort(function(e,t){return e.d-t.d||e.name.localeCompare(t.name)}).slice(0,3).map(function(e){return e.name})}function c(e,t,n,s){const a=s||i;for(let i=0;i<a.length;i++){const s=a[i];for(let i=0;i<s.names.length;i++){const a=s.names[i];if(e===a){if(s.value){const e=t[n+1];if(void 0===e)throw new r("USAGE",o("args.missing_value",{name:a}));return{key:s.key,value:e,nextIndex:n+2}}return{key:s.key,value:!0,nextIndex:n+1}}if(0===a.indexOf("--")&&0===e.indexOf(a+"="))return{key:s.key,value:e.slice(a.length+1),nextIndex:n+1}}}return null}function l(e,t,n){if("url"!==t&&"token"!==t&&"output"!==t)if("noBrowser"!==t){if("timeoutSec"===t){const t=Number(n);if(!Number.isFinite(t))throw new r("USAGE",o("args.invalid_timeout"));return void(e.timeoutSec=t)}e[t]="project"!==t&&"input"!==t&&"output"!==t||n}else e.noBrowser=!0;else e[t]=n}function u(e,t,n){return n&&0===e.indexOf("@")&&e.length>1?t.readFile(e.slice(1)):e}function p(e,t){const n=0===e.indexOf("@")&&e.length>1?t.readFile(e.slice(1)):e;try{return JSON.parse(n)}catch(e){throw new r("USAGE",o("args.json_parse",{error:e.message}))}}function d(e,t){const n=t.unionTypes||[];if("null"===e&&n.indexOf("null")>=0)return null;if(("true"===e||"false"===e)&&n.indexOf("boolean")>=0)return"true"===e;const i=Number(e);if(""!==e&&Number.isFinite(i)&&(n.indexOf("number")>=0||n.indexOf("integer")>=0&&Number.isInteger(i)))return i;if(n.indexOf("string")>=0)return e;throw new r("USAGE",o("args.invalid_value_types",{flag:t.name,types:n.join(" or ")}))}function f(e,t,n){if("boolean"===t.itemKind){if("true"!==e&&"false"!==e)throw new r("USAGE",o("args.invalid_boolean",{flag:t.name}));return"true"===e}if("number"===t.itemKind||"integer"===t.itemKind){const n=Number(e);if(""===e||!("integer"===t.itemKind?Number.isInteger(n):Number.isFinite(n)))throw new r("USAGE",o("args.invalid_item",{kind:t.itemKind,flag:t.name}));return n}return u(e,n,!0)}function m(e,t,n,i){const s=a(t,n.map(function(e){return e.name}));let c=o("args.unknown_flag",{prefix:i,flag:t,noun:e.noun,verb:e.verb});return s.length&&(c+=o("args.did_you_mean_flag",{flag:s[0]})),new r("USAGE",c)}e.exports={SERVER_FLAG_SPECS:[{key:"url",names:["--url"],value:!0},{key:"token",names:["--token"],value:!0},{key:"output",names:["--output","-o"],value:!0},{key:"noBrowser",names:["--no-browser"],value:!1}],splitGlobals:function(e,t){const n=t?i.concat(t):i,r={project:null,json:!1,yes:!1,noWait:!1,timeoutSec:null,quiet:!1,verbose:!1,input:null,output:null,help:!1,version:!1};t&&t.forEach(function(e){r[e.key]=!!e.value&&null});const o=e.indexOf("--"),s=o>=0?e.slice(0,o):e.slice(),a=o>=0?e.slice(o+1):[],u=[];let p=0;for(;p<s.length;){const e=c(s[p],s,p,n);e?(l(r,e.key,e.value),p=e.nextIndex):(u.push(s[p]),p++)}for(let e=0;e<a.length;e++)u.push(a[e]);return{globals:r,rest:u}},toToolArgs:function(e,t,n,i,s){s=s||"expl";const a=Object.assign({},i||{}),c=Object.create(null);e.flags.forEach(function(e){c[e.name]=e});let l=!1,h=0;for(;h<t.length;){const i=t[h];if(0!==i.indexOf("--")){if(!e.positional)throw new r("USAGE",o("args.unexpected_argument",{prefix:s,token:i,noun:e.noun,verb:e.verb}));if(l)throw new r("USAGE",o("args.too_many_positional"));a[e.positional]=i,l=!0,h++;continue}let g=i.slice(2),_=null;const E=g.indexOf("=");E>=0&&(_=g.slice(E+1),g=g.slice(0,E));let w=null,y=!0;if(0===g.indexOf("no-")){const e=g.slice(3),t=c[e];t&&"boolean"===t.kind&&(w=t,y=!1,g=e)}if(w||(w=c[g]),!w)throw m(e,g,e.flags,s);if("boolean"===w.kind){a[w.prop]=y,h++;continue}let N=_;if(null===N){if(N=t[h+1],void 0===N)throw new r("USAGE",o("args.missing_value",{name:"--"+w.name}));h+=2}else h++;if("string"===w.kind){const e=u(N,n,!0);if(w.enumValues&&w.enumValues.indexOf(e)<0)throw new r("USAGE",o("args.invalid_enum",{flag:w.name,values:w.enumValues.join(", ")}));a[w.prop]=e;continue}if("number"===w.kind){const e=Number(N);if(!Number.isFinite(e))throw new r("USAGE",o("args.invalid_number",{flag:w.name}));a[w.prop]=e;continue}if("integer"===w.kind){const e=Number(N);if(!Number.isInteger(e))throw new r("USAGE",o("args.invalid_integer",{flag:w.name}));a[w.prop]=e;continue}if(w.enumValues&&w.enumValues.indexOf(N)<0)throw new r("USAGE",o("args.invalid_enum",{flag:w.name,values:w.enumValues.join(", ")}));if("scalarArray"===w.kind){const e=f(N,w,n);Array.isArray(a[w.prop])||(a[w.prop]=[]),a[w.prop].push(e);continue}"json"!==w.kind?"scalarUnion"!==w.kind?a[w.prop]=p(N,n):a[w.prop]=d(N,w):a[w.prop]=p(N,n)}return a},suggest:a}},965(e,t,n){const r=n(982),o=n(262),i=n(287),s=n(755),a=n(439),{ExplError:c,fromJsonRpcError:l,fromToolResult:u}=n(877),{t:p,getLang:d}=n(42),f="expl",m="x-exploratory-include-tool-meta",h="x-exploratory-tool-timeout-sec";e.exports={create:function(e){const t=e.agentDir,n=e.env||{},g=e.sessionId,_=e.clientVersion,E=e.onTrace;let w=0;const y=e.credentials||i.create({env:n,channel:"cli",store:s.create({agentDir:t,account:"cli-"+r.createHash("sha256").update(t).digest("hex").slice(0,12)}),pair:function(e){const n=o.readEndpoint(t);return n?o.requestPairing({socketPath:n.socket,channel:"cli",name:e}):Promise.resolve(null)}});let N=!1;function O(n,r,i){const s=o.readEndpoint(t);return s?y.resolve(f,{maxWaitMs:12e4,onPending:function(){!N&&e.onPairingWait&&(N=!0,e.onPairingWait())}}).then(function(e){if(e.token)return e;if("pending"===e.pairing)throw new c("PAIRING_PENDING");if("declined"===e.pairing)throw new c("PAIRING_REQUIRED");if("error"===e.pairing&&e.error)throw new c(e.error,null,null,new a(e.error).toJSON("en").suggested_actions);throw new c("DESKTOP_NOT_RUNNING")}).then(function(e){return function(e,t,n,r,i){const s=++w,a={jsonrpc:"2.0",id:s,method:n,params:r},u=JSON.stringify(a),m=function(e,t){const n={Host:"localhost",Accept:"application/json, text/event-stream","Content-Type":"application/json","x-exploratory-client-name":f,"x-exploratory-client-version":_,"x-exploratory-guide-session":g,"x-exploratory-ui-lang":d()};return t&&(n.Authorization="Bearer "+t),e&&Object.assign(n,e),n["x-exploratory-channel"]="cli",n}(i,t.token);m["Content-Length"]=Buffer.byteLength(u);let h=null;const N=[];return o.post({socketPath:e.socket,headers:m,body:u,onMessage:function(e){N.push(e),e&&e.id===s&&(h=e)}}).then(function(e){if(E&&E(JSON.stringify({method:n,params:r,id:s,messages:N})),e.connectError||!e.complete)throw new c("DESKTOP_NOT_RUNNING");if(!h)throw new c("EXECUTION_FAILED",p("client.no_response"));if(h.error){const e=l(h.error);throw"UNAUTHORIZED"===e.errorCode&&y.forget(t),e}return h.result})}(s,e,n,r,i)}):Promise.reject(new c("DESKTOP_NOT_RUNNING"))}return{listTools:function(){const e=[];let t=null;const n=function(){return O("tools/list",t?{cursor:t}:{},{[m]:"true"}).then(function(r){return r&&r.tools&&e.push.apply(e,r.tools),t=r&&r.nextCursor?r.nextCursor:null,t?n():e})};return n()},callTool:function(e,t,n){return O("tools/call",{name:e,arguments:t||{}},n&&n.timeoutSec>0?{[h]:String(n.timeoutSec)}:void 0).then(function(e){if(e&&e.isError)throw u(e);return e})},initialize:function(){return O("initialize",{protocolVersion:"2025-11-25",capabilities:{},clientInfo:{name:f,version:_}}).then(function(e){return{instructions:"string"==typeof e.instructions?e.instructions:null,serverInfo:e.serverInfo||{}}})}}}}},213(e){const t=["project","json","yes","no-wait","timeout","quiet","verbose","input","help","version"],n="confirmed_by_user";function r(e){return String(e).replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}function o(e){return!(!e||"object"!=typeof e)&&("string"===e.type||"number"===e.type||"integer"===e.type||"boolean"===e.type||"null"===e.type||(Array.isArray(e.type)?e.type.every(function(e){return"string"===e||"number"===e||"integer"===e||"boolean"===e||"null"===e}):!!Array.isArray(e.anyOf)&&e.anyOf.length>0&&e.anyOf.every(o)))}function i(e){return Array.isArray(e.anyOf)?e.anyOf.reduce(function(e,t){return e.concat(i(t))},[]):[].concat(e.type)}function s(e){return("id"===e||/(_id|[a-z]Id)$/.test(e))&&"project_id"!==e}function a(e){return String(e).replace(/(_id|Id)$/,"").replace(/_/g,"").toLowerCase()}function c(e,c){const l=c||t,u=e._meta&&e._meta["exploratory/capability_id"];if(!u)throw new Error("Tool "+e.name+" is missing exploratory/capability_id");let p,d;if(u.indexOf(".")<0)p=u,d="";else{const e=u.indexOf(".");p=u.slice(0,e),d=r(u.slice(e+1))}const f=e.inputSchema||{},m=f.properties||{},h=f.required||[],g=h.filter(s),_=Object.prototype.hasOwnProperty.call(m,"project_id"),E=e._meta&&e._meta["exploratory/positional"];let w=null;if(E&&Object.prototype.hasOwnProperty.call(m,E))w=E;else if(1===g.length)w=g[0];else if(0===g.length){const e=Object.keys(m).filter(function(e){return s(e)&&a(e)===p});1===e.length&&(w=e[0])}"project"===p&&_&&0===g.length&&(w="project_id");const y=[],N=[],O=new Set;return Object.keys(m).forEach(function(t){if("project_id"===t||t===n)return;const s=r(t);if(l.indexOf(s)>=0)return void y.push(t);if(O.has(s))throw new Error("Duplicate flag "+s+" on tool "+e.name);O.add(s);const a=function(e){if("boolean"===e.type)return{kind:"boolean",itemKind:null,enumValues:null};if("string"===e.type||"number"===e.type||"integer"===e.type)return{kind:e.type,itemKind:null,enumValues:e.enum||null};if("array"===e.type&&e.items){const t=e.items.type;return"string"===t||"number"===t||"integer"===t||"boolean"===t?{kind:"scalarArray",itemKind:t,enumValues:null}:{kind:"json",itemKind:null,enumValues:null}}return"object"===e.type?{kind:"json",itemKind:null,enumValues:null}:o(e)?{kind:"scalarUnion",itemKind:null,enumValues:null,unionTypes:i(e)}:{kind:"json",itemKind:null,enumValues:null}}(m[t]);N.push(Object.assign({name:s,prop:t,required:h.indexOf(t)>=0,description:m[t].description||""},a))}),{noun:p,verb:d,toolName:e.name,capabilityId:u,risk:e._meta["exploratory/risk"]||"LOW",readOnly:!(!e.annotations||!e.annotations.readOnlyHint),description:e.description||"",inputSchema:f,positional:w,flags:N,jsonOnly:y,requiresProject:_,projectOptional:_&&h.indexOf("project_id")<0,confirmsByUser:Object.prototype.hasOwnProperty.call(m,n)}}e.exports={GLOBAL_FLAGS:t,SERVER_FLAGS:["url","token","output","no-browser"],kebab:r,isEntityIdProp:s,entityOfIdProp:a,build:function(e,n){const r=(n=n||{}).globalFlags||t,o=[],i=Object.create(null),s=Object.create(null);return e.forEach(function(e){const t=c(e,r),n=t.noun+"\0"+t.verb;if(i[n])throw new Error("Duplicate command "+t.noun+" "+t.verb+" for tools "+i[n].toolName+" and "+e.name);i[n]=t,s[e.name]=t,o.push(t)}),{commands:o,find:function(e,t){return i[e+"\0"+t]||null},byToolName:function(e){return s[e]||null}}}}},648(e,t,n){const r=n(213),o={bash:['# expl completion for bash. Add to ~/.bashrc: eval "$(expl completion bash)"',"_expl() {"," # Slice the words before IFS changes: bash 3.2 (the macOS default) joins a quoted ${a[@]:1:n} slice into one word",' # when IFS has no space, so `expl dashboard pu` would reach __complete as the single argument "dashboard pu".',' local words=("${COMP_WORDS[@]:1:COMP_CWORD}")'," local IFS=$'\\n'",' COMPREPLY=($(expl __complete "${words[@]}" 2>/dev/null))',"}","complete -o default -F _expl expl"],zsh:['# expl completion for zsh. Add to ~/.zshrc: eval "$(expl completion zsh)"',"_expl() {"," local -a candidates",' candidates=("${(@f)$(expl __complete "${(@)words[2,CURRENT]}" 2>/dev/null)}")'," compadd -a candidates","}","compdef _expl expl"],powershell:["# expl completion for PowerShell. Add to $PROFILE: expl completion powershell | Out-String | Invoke-Expression","Register-ArgumentCompleter -Native -CommandName expl -ScriptBlock {"," param($wordToComplete, $commandAst, $cursorPosition)"," $words = @($commandAst.CommandElements | Select-Object -Skip 1 | ForEach-Object { $_.ToString() })"," if ($wordToComplete -eq '') { $words += '' }"," expl __complete @words 2>$null | ForEach-Object {"," [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)"," }","}"]},i={tools:["describe","list"],completion:["bash","powershell","zsh"],token:["create","list","revoke"]},s=["call","completion","help","lang","skill","status","tools"],a=["call","help","login","logout","skill","status","token","tools"];e.exports={script:function(e){return o[e]?o[e].join("\n")+"\n":null},complete:function(e,t,n){if("server"===e[0])return function(e,t){const n=t?t.commands:[],o=e.length?e[e.length-1]:"",s=e.slice(0,-1);let c=[];if(0===s.length)c=a.concat(n.map(function(e){return e.noun}));else if(1===s.length){const e=s[0];c=(i[e]||[]).concat(n.filter(function(t){return t.noun===e}).map(function(e){return e.verb}).filter(Boolean)),"call"===e&&(c=n.map(function(e){return e.toolName}))}else if(0===o.indexOf("-")){const e="call"===s[0]?t&&t.byToolName(s[1]):t&&t.find(s[0],s[1]||""),n=e?e.flags.map(function(e){return"boolean"===e.kind?["--"+e.name,"--no-"+e.name]:["--"+e.name]}):[];c=[].concat.apply([],n).concat(r.SERVER_FLAGS.map(function(e){return"--"+e}))}return c.filter(function(e,t){return c.indexOf(e)===t&&0===e.indexOf(o)}).sort()}(e.slice(1),n);const o=t?t.commands:[],c=e.length?e[e.length-1]:"",l=e.slice(0,-1);let u=[];if(0===l.length)u=s.concat(["server"]).concat(o.map(function(e){return e.noun}));else if(1===l.length){const e=l[0];u=(i[e]||[]).concat(o.filter(function(t){return t.noun===e}).map(function(e){return e.verb})),"project"===e&&u.push("use"),"call"===e&&(u=o.map(function(e){return e.toolName}))}else if(0===c.indexOf("-")){const e="call"===l[0]?t&&t.byToolName(l[1]):t&&t.find(l[0],l[1]),n=e?e.flags.map(function(e){return"boolean"===e.kind?["--"+e.name,"--no-"+e.name]:["--"+e.name]}):[];u=[].concat.apply([],n).concat(r.GLOBAL_FLAGS.map(function(e){return"--"+e}))}return u.filter(function(e,t){return u.indexOf(e)===t&&0===e.indexOf(c)}).sort()}}},877(e,t,n){const r=n(439),o=n(42);class i extends Error{constructor(e,t,n,i){const s=o.localizeErrorDefaults(e,t,i||[]);let a=s.message;if(!a)try{a=new r(e).message}catch(t){a=e}super(a),this.name="ExplError",this.errorCode=e,this.details=n||null,this.suggestedActions=s.actions}}e.exports={ExplError:i,exitCodeFor:function(e){return"USAGE"===e?2:"INTERRUPTED"===e?130:"BROKEN_PIPE"===e?0:"SERVER_UNREACHABLE"===e||"DESKTOP_NOT_RUNNING"===e?3:"NOT_LOGGED_IN"===e||"NOT_SIGNED_IN"===e||"UNAUTHORIZED"===e||"PERMISSION_DENIED"===e||"PAIRING_REQUIRED"===e||"CHANNEL_DISABLED"===e?4:1},fromJsonRpcError:function(e){const t=e&&e.data?e.data:{},n=t.error_code||"EXECUTION_FAILED",r=t.suggested_actions||[],o=Object.assign({},t);delete o.error_code,delete o.message,delete o.suggested_actions;const s=Object.keys(o);return new i(n,e.message||t.message,s.length?o:null,r)},fromToolResult:function(e){const t=e&&e.content&&e.content[0]&&e.content[0].text,n=e&&e.structuredContent||function(e){if("string"!=typeof e||"{"!==e.charAt(0))return null;try{const t=JSON.parse(e);return t&&"object"==typeof t?t:null}catch(e){return null}}(t),o=n&&n.error;if(o&&"object"==typeof o&&"string"==typeof o.code){const e=Object.assign({},o);return delete e.code,delete e.message,new i(o.code,o.message||o.code,Object.keys(e).length?e:null,[])}if(n&&"string"==typeof n.error_code){const e=Object.assign({},n);delete e.error_code,delete e.message,delete e.suggested_actions;const t=Object.keys(e);return new i(n.error_code,n.message||n.error_code,t.length?e:null,n.suggested_actions||[])}const s=r.parseToolErrorText(t||"");return new i(s.errorCode,s.message,s.details,s.suggestedActions)},fromHttpAuthError:function(e){const t="login"===e.source?"NOT_LOGGED_IN":"UNAUTHORIZED";let n="The server rejected the token.";const r=e.wwwAuthenticate||"",o=r.match(/error_description="([^"]*)"/i)||r.match(/error_description=([^,\s]+)/i);return o&&o[1]&&(n=o[1].replace(/\\"/g,'"')),new i(t,n,{source:e.source},[])}}},736(e,t,n){const r=n(896),o=n(928),i="ja",s="en";e.exports={readUILang:function(e,t){try{const n=(t||r).readFileSync(o.join(e,"..","userconf.json"),"utf8");return JSON.parse(n).ui_lang===i?i:s}catch(e){return s}},JAPANESE:i,ENGLISH:s}},107(e,t,n){const r=n(495),o=n(213),i=n(648),s=n(351),a=n(876),c=n(821),l=n(677),u=n(947),{ExplError:p,exitCodeFor:d}=n(877),{t:f,setLang:m}=n(42),h={status:!0,tools:!0,call:!0,help:!0,skill:!0,completion:!0,lang:!0},g=["en","ja"];function _(e,t){t.stdout&&e.stdout.write(t.stdout),t.stderr&&e.stderr.write(t.stderr)}function E(e,t,n){const r=e instanceof p?e:new p("EXECUTION_FAILED",e&&e.message?e.message:String(e));return"BROKEN_PIPE"===r.errorCode||_(t,s.renderError(r,{json:n})),d(r.errorCode)}function w(e){return o.build(e)}async function y(e){try{return(await e.callTool("get_environment",{})).structuredContent||null}catch(e){return null}}function N(e){return e.noun+(e.verb?" "+e.verb:"")}function O(e,t){return e.commands.filter(function(e){return e.noun===t}).map(function(e){return e.verb||"(default)"})}function x(e,t){const n=[(t=t||"expl")+" "+N(e)+" -- "+e.description,"",f("main.describe_tool",{tool:e.toolName}),f("main.describe_risk",{risk:e.risk})];return e.positional&&n.push(f("main.describe_positional",{positional:e.positional})),e.requiresProject&&n.push(f("main.describe_project")),e.jsonOnly.length&&n.push(f("main.describe_json_only",{props:e.jsonOnly.join(", ")})),e.flags.forEach(function(e){let t=" --"+e.name+" ("+e.kind+")"+(e.required?f("main.describe_required"):"");e.enumValues&&(t+=" enum: "+e.enumValues.join(", ")),e.description&&(t+=" -- "+e.description),n.push(t)}),n.push("",f("main.describe_example",{prefix:t,noun:e.noun,verb:e.verb,positional:e.positional?" <"+e.positional+">":""})),n.join("\n")+"\n"}function I(e){const t=e.tree,n=[f("main.help_usage",{prefix:e.prefix||"expl"}),"",f("main.help_builtin")];if((e.builtinHelp||[" expl status"," expl tools list|describe"," expl project use <id|name>"," expl call <tool_name>"," expl skill"," expl completion bash|zsh|powershell"," expl lang [en|ja]"," expl help"]).forEach(function(e){n.push(e)}),n.push(""),t.commands.length){const e=[];t.commands.forEach(function(t){e.indexOf(t.noun)<0&&e.push(t.noun)}),e.sort(),n.push(f("main.help_nouns",{nouns:e.join(", ")}))}else e.up||n.push(e.downHint||f("main.help_start_desktop"));return n.join("\n")+"\n"}async function v(e,t){const n=(await e.callTool("list_projects",{})).structuredContent||{},r=n.projects||n.items||[];return l.resolveProject(t,r)}async function T(e,t){const n=t.project||e.env.EXPL_PROJECT||e.state.readDefaultProject();if(n)return(await v(e.client,n)).project_id;const r=await y(e.client),o=r&&r.open_projects||[];if(!o.length)throw new p("USAGE",f("main.no_project"));return o[0].project_id}async function S(e,t){const n=e.deps,o=e.globals,i=e.json,s=e.tree,a=e.prefix||"expl";if(o.help&&0===t.length)return _(n,{stdout:I(e),stderr:""}),0;const c=t.slice(),l=c.shift();if(!l)return _(n,{stdout:I(e),stderr:""}),0;if("tools"===l){const t=c.shift();if("list"===t)return _(n,function(e,t){if(t){const t=e.commands.map(function(e){return{command:N(e),tool:e.toolName,read_only:e.readOnly,risk:e.risk}});return{stdout:JSON.stringify(t,null,2)+"\n",stderr:""}}const n=["COMMAND\tTOOL\tREAD_ONLY\tRISK"];return e.commands.forEach(function(e){n.push([N(e),e.toolName,String(e.readOnly),e.risk].join("\t"))}),{stdout:n.join("\n")+"\n",stderr:""}}(s,i)),0;if("describe"===t){const t=c.shift();if(!t)throw new p("USAGE",f("main.usage_tools_describe",{prefix:a}));let r=s.byToolName(t);if(!r&&t.indexOf(" ")<0){const e=s.commands.filter(function(e){return e.noun===t});1===e.length&&(r=e[0])}if(!r&&t.indexOf(" ")>0){const e=t.split(/\s+/);r=s.find(e[0],e[1]||"")}if(!r){if(!e.up)throw e.downError;throw new p("USAGE",f("main.unknown_command_or_tool",{ref:t}))}return _(n,{stdout:x(r,a),stderr:""}),0}throw new p("USAGE",f("main.usage_tools",{prefix:a}))}if("call"===l){const t=c.shift();if(!t)throw new p("USAGE",f("main.usage_call",{prefix:a}));const n=s.byToolName(t);if(!n){if(!e.up)throw e.downError;throw new p("USAGE",f("main.unknown_tool",{name:t}))}return await R(e,n,c)}if("help"===l)return _(n,{stdout:I(e),stderr:""}),0;if(h[l])throw new p("USAGE",f("main.unknown_command_noun",{prefix:a,noun:l}));let u="",d=s.find(l,"");if(d){if(o.help)return _(n,{stdout:x(d,a),stderr:""}),0}else{if(u=c.shift(),!u){if(o.help)return _(n,{stdout:f("main.verbs_for",{noun:l,verbs:O(s,l).join(", ")})+"\n",stderr:""}),0;let e=f("main.usage_noun_verb",{prefix:a,noun:l});const t=O(s,l);throw t.length&&(e+="\n"+f("main.verbs_for",{noun:l,verbs:t.join(", ")})),new p("USAGE",e)}if(o.help){if(d=s.find(l,u),!d){if(!e.up)throw e.downError;throw new p("USAGE",f("main.unknown_command_noun_verb",{prefix:a,noun:l,verb:u}))}return _(n,{stdout:x(d,a),stderr:""}),0}d=s.find(l,u)}if(!d){if(!e.up)throw e.downError;const t=s.commands.map(function(e){return N(e)}),n=r.suggest(l+(u?" "+u:""),t);let o=f("main.unknown_command_hint",{prefix:a});throw n.length&&(o+=f("main.did_you_mean",{prefix:a,candidate:n[0]})),new p("USAGE",o)}return await R(e,d,c)}async function R(e,t,n){if(!e.up)throw e.downError;const i=e.deps,a=e.globals,c=e.json,l=e.prefix||"expl";let d=null;if(a.input){const e="-"===a.input?i.readStdin():i.readFile(a.input);try{d=JSON.parse(e)}catch(e){throw new p("USAGE",f("main.input_parse",{error:e.message}))}}const m={readFile:i.readFile,readStdin:i.readStdin};let h=r.toToolArgs(t,n,m,d,l);e.resolveProject&&(h=await async function(e,t,n,r){if(!e.requiresProject)return r;const o="project_id"===e.positional?r.project_id:null;if(!o&&!t.project&&r.project_id)return r;if(e.projectOptional&&!o&&!t.project)return r;const i=o||t.project||n.env.EXPL_PROJECT||n.state.readDefaultProject();if(!i)throw new p("USAGE",f("main.no_project"));return r.project_id=(await v(n.client,i)).project_id,r}(t,a,i,h)),await async function(e,t,n,r,i,a){const c=(n.inputSchema.required||[]).filter(o.isEntityIdProp).filter(function(e){return void 0===r[e]||null===r[e]});if(!c.length)return;const l=c[0],u="--"+o.kebab(l),d=t.find(o.entityOfIdProp(l),"list"),m=d?(d.inputSchema.required||[]).filter(function(e){return"project_id"!==e}):[];if(d&&d.toolName!==n.toolName&&!m.length){const t=d.requiresProject&&r.project_id?{project_id:r.project_id}:{};try{const n=await e.callTool(d.toolName,t,{}),r=s.renderResult(n,{json:!1});i.stderr.write(f("main.candidates",{noun:d.noun})+"\n"+r.stdout+r.stderr)}catch(e){}}throw new p("USAGE",f("main.missing_id",{prefix:a,flag:u,noun:n.noun,verb:n.verb}))}(e.client,e.tree,t,h,i,l);let g=await async function(e,t,n,r,o,i){await async function(e,t,n,r){if("HIGH"!==e.risk||t.yes)return;if(!n.stdinIsTTY||!n.stdoutIsTTY)throw new p("USAGE",f("main.hard_to_undo"));n.stderr.write(f("main.confirm_prompt",{prefix:r,noun:e.noun,verb:e.verb,tool:e.toolName})+"\n");const o=(await n.readLine()).trim().toLowerCase();if("y"!==o&&"yes"!==o)throw new p("EXECUTION_FAILED",f("main.cancelled"))}(r,n,t,i),r.confirmsByUser&&(o.confirmed_by_user=!0);let s=await e.callTool(r.toolName,o,{timeoutSec:n.timeoutSec});return s&&s.structuredContent&&"running"===s.structuredContent.status&&!n.noWait&&(s=await u.waitFor(e,s,{projectId:o.project_id||null,timeoutSec:n.timeoutSec,onProgress:function(e){n.quiet||t.stderr.write(e+"\n")},isInterrupted:t.isInterrupted,interrupt:t.interrupt||null,now:function(){return Date.now()}})),s}(e.client,i,a,t,h,l);if(e.onResult){const n=await e.onResult(g,t);if(n)return _(i,n),0}const E=function(e,t,n){const r=(n&&n.content||[]).find(function(e){return e&&"image"===e.type&&"string"==typeof e.data});if(!r)return null;const o=n.structuredContent&&n.structuredContent.chart_id,i=t.output||e.pathJoin(e.makeTmpDir(),String(o||"image").replace(/[^A-Za-z0-9_-]/g,"_")+".png");return e.writeFile(i,Buffer.from(r.data,"base64")),i}(i,a,g);return E&&c&&(g=Object.assign({},g,{structuredContent:Object.assign({},g.structuredContent,{image_path:E})})),_(i,s.renderResult(g,{json:c})),E&&!c&&_(i,{stdout:f("main.image_saved",{path:E})+"\n",stderr:""}),0}e.exports={run:async function(e,t){if("__complete"===e[0]){const n=t.state.readToolsCache();let r=null;if(t.server&&t.server.state){const e=t.server.state.lastServerUrl();if(e){const n=t.server.state.readToolsCache(e);n&&n.length&&(r=w(n))}}const o=i.complete(e.slice(1),n&&n.length?w(n):null,r);return o.length&&t.stdout.write(o.join("\n")+"\n"),0}let n;try{n=r.splitGlobals(e)}catch(n){return E(n,t,e.indexOf("--json")>=0)}const o=n.globals,s=o.json;try{if(o.version)return await async function(e,t){const n=["expl "+e.version],r=await y(e.client);n.push(r&&r.app_version?"Exploratory "+r.app_version:f("main.version_not_running"));const o=n.join("\n")+"\n";return _(e,t?{stdout:JSON.stringify({expl:e.version,exploratory:r},null,2)+"\n",stderr:""}:{stdout:o,stderr:""}),0}(t,s);if("server"===n.rest[0])return await a.run(n.rest.slice(1),o,t);if("status"===n.rest[0])return await async function(e,t){const n=(await e.client.callTool("get_environment",{})).structuredContent||{};return t?(_(e,{stdout:JSON.stringify(n,null,2)+"\n",stderr:""}),0):(_(e,{stdout:["Exploratory "+(n.app_version||"?"),f("main.status_user",{user:n.user&&(n.user.display_name||n.user.username)||"?"})].join("\n")+"\n",stderr:""}),0)}(t,s);if("skill"===n.rest[0])return await async function(e){let t=null;try{t=(await e.client.initialize()).instructions}catch(e){t=null}return _(e,{stdout:c.render({instructions:t,version:e.version}),stderr:""}),0}(t);if("completion"===n.rest[0]){const e=i.script(n.rest[1]);if(!e)throw new p("USAGE",f("main.usage_completion"));return _(t,{stdout:e,stderr:""}),0}if("lang"===n.rest[0])return await async function(e,t,n,r){const o=r.shift();if(void 0!==o&&g.indexOf(o)<0)throw new p("USAGE",f("main.usage_lang"));const i={project_id:await T(e,t)};let s;void 0===o?(i.keys=["ui_lang"],s=await e.client.callTool("get_system_settings",i,{timeoutSec:t.timeoutSec})):(i.settings={ui_lang:o},s=await e.client.callTool("update_system_settings",i,{timeoutSec:t.timeoutSec}));const a=s.structuredContent||{},c=void 0===o?(a.settings||{}).ui_lang:o;if(void 0!==o&&(a.skipped||[]).length)throw new p("EXECUTION_FAILED",f("main.lang_not_changed",{reason:JSON.stringify(a.skipped)}));return void 0!==o&&m(o),_(e,n?{stdout:JSON.stringify({ui_lang:c},null,2)+"\n",stderr:""}:{stdout:f(void 0===o?"main.lang_current":"main.lang_changed",{lang:c})+"\n",stderr:""}),0}(t,o,s,n.rest.slice(1));const e=await async function(e,t){try{const n=await e.listTools();return t.writeToolsCache(n),{tools:n,desktopUp:!0}}catch(e){if(!(e instanceof p)||"DESKTOP_NOT_RUNNING"!==e.errorCode)throw e;return{tools:t.readToolsCache()||[],desktopUp:!1}}}(t.client,t.state),r=e.tools.length?w(e.tools):{commands:[],find:function(){return null},byToolName:function(){return null}},l=n.rest.slice();if("project"===l[0]&&"use"===l[1]){l.shift(),l.shift();const n=l.shift();if(!n)throw new p("USAGE",f("main.usage_project_use"));if(!e.desktopUp)throw new p("DESKTOP_NOT_RUNNING");const r=await v(t.client,n);return t.state.writeDefaultProject(r.project_id),_(t,{stdout:f("main.default_project",{name:r.name,projectId:r.project_id})+"\n",stderr:""}),0}return await S({prefix:"expl",client:t.client,tree:r,up:e.desktopUp,downError:new p("DESKTOP_NOT_RUNNING"),downHint:f("main.help_start_desktop"),globals:o,json:s,deps:t,resolveProject:!0,onResult:null,builtinHelp:null},l)}catch(e){return E(e,t,s)}},dispatchTree:S,describeCommand:x,topHelp:I}},42(e,t,n){const r=n(439),o=n(736),i={en:n(174),ja:n(980)};let s=o.ENGLISH;e.exports={setLang:function(e){s=e===o.JAPANESE?o.JAPANESE:o.ENGLISH},getLang:function(){return s},t:function(e,t){const n=i[s][e];if("string"!=typeof n)throw new Error("Unknown expl message key: "+e);return n.replace(/\{(\w+)\}/g,function(e,n){return t&&void 0!==t[n]?String(t[n]):e})},localizeErrorDefaults:function(e,t,n){const a=i.ja;if(s!==o.JAPANESE||r.CODES.indexOf(e)<0)return{message:t,actions:n};const c=new r(e),l=function(e){const t=c.toJSON(e).suggested_actions;return n.length===t.length&&n.every(function(e,n){return e===t[n]})},u=l("en")||l("ja");return{message:t&&t!==c.message&&t!==c.toJSON("ja").message?t:a["error."+e+".message"],actions:u?[a["error."+e+".action"]]:n}}}},351(e,t,n){const r=n(896),o=n(18),{ExplError:i}=n(877),{t:s}=n(42);function a(e){if(!e||"object"!=typeof e)return null;let t=null;const n=Object.keys(e);for(let r=0;r<n.length;r++){const o=e[n[r]];if(Array.isArray(o)&&o.length&&"object"==typeof o[0]&&null!==o[0]&&!Array.isArray(o[0])){if(t)return null;t=o}}return t}const c=[[4352,4447],[11904,42191],[44032,55203],[63744,64255],[65072,65103],[65280,65376],[65504,65510],[127744,128591],[131072,262141]],l=".pivot.measure.cell";function u(e){let t=0;for(const n of e){const e=n.codePointAt(0);t+=c.some(function(t){return e>=t[0]&&e<=t[1]})?2:1}return t}const p=/[\u0000-\u001F\u007F-\u009F]/g,d={"\n":"\\n","\r":"\\r","\t":"\\t"};function f(e){return null==e?"":("object"==typeof e?JSON.stringify(e):String(e)).replace(p,function(e){return d[e]||"\\u"+e.charCodeAt(0).toString(16).padStart(4,"0")})}function m(e){return String(e).replace(p,function(e){return"\n"===e||"\t"===e?e:d[e]||"\\u"+e.charCodeAt(0).toString(16).padStart(4,"0")})}function h(e,t){const n=[e.map(f)].concat(t.map(function(t){return e.map(function(e,n){return f(t[n])})})),r=e.map(function(e,t){return Math.max.apply(null,n.map(function(e){return u(e[t])}))});return n.map(function(e){return e.map(function(t,n){return n===e.length-1?t:t+" ".repeat(r[n]-u(t))}).join(" ").replace(/ +$/,"")}).join("\n")+"\n"}function g(e){const t=Object.keys(e[0]).filter(function(t){return null===(n=e[0][t])||"string"==typeof n||"number"==typeof n||"boolean"==typeof n;var n}).slice(0,6);return t.length?h(t.map(function(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toUpperCase()}),e.map(function(e){return t.map(function(t){return e[t]})})):""}function _(e){const t=e.function&&"none"!==e.function?e.function:"";return e.column?t?e.column+" ("+t+")":e.column:t}function E(e){const t=e.rows;if(!Array.isArray(t)||!t.length||!Array.isArray(t[0]))return null;let n;if(e.definition&&Array.isArray(e.column_headers))n=function(e){const t=e.definition,n=e.rows,r=e.value_separator||"|||",o=e.column_headers.slice(0,n[0].length),i=o.filter(function(e){return/^r\d+$/.test(e)}).length,a=(t.rows||[]).map(function(e){return e.column||""}),c=i-a.length,u=(t.values||[]).map(_).join(r),p=o.map(function(e,t){return t<i?c>=0&&t>=c?a[t-c]:e:e===l?u:e}),d=e.totals||{},m=!1!==t.show_row_totals&&Array.isArray(d.row_totals)?d.row_totals:null,g=n.map(function(e,t){return m?e.concat([m[t]]):e});m&&p.push(s("output.total"));const E=d.column_totals;if(!1!==t.show_totals&&Array.isArray(E)&&i>0&&E.length===o.length-i){const t=[s("output.total")].concat(new Array(i-1).fill(null),E),n=e.total_row_count;m&&t.push(m.length===n+1?m[n]:null),g.push(t)}let w=h(p,g);return(t.values||[]).length>1&&o.indexOf(l)<0&&(w+=s("output.each_cell",{measure:f(u)})+"\n"),w}(e);else{const r=e.columns||[];n=h(t[0].map(function(e,t){return function(e){if(!e||"object"!=typeof e)return f(e);const t=e.column||e.name||"";return e.function&&"none"!==e.function?t+" ("+e.function+")":t}(r[t])}),t)}const r="number"==typeof e.total_row_count?e.total_row_count:e.row_count;return"number"==typeof r&&r>t.length&&(n+=s("output.showing_rows",{shown:t.length,total:r})+"\n"),n}const w=["title","displayName","display_name","name"],y=/(^id|_id|Id)$/;function N(e,t){if(void 0!==e)return e;if("string"!=typeof t)return null;try{return JSON.parse(t)}catch(e){return t}}e.exports={createWriter:function(e){const t=e.fsModule||r,n=e.ttyModule||o;let s=null,a=0,c=[];const l=function(){if(a--,a>0)return;const e=c;c=[],e.forEach(function(e){e()})};return e.isTTY&&(s=new n.WriteStream(e.fd),s.on("error",function(){})),{write:function(n){try{if(s)return a++,void s.write(n,l);t.writeSync(e.fd,n,"utf8")}catch(e){if(e&&"EPIPE"===e.code)throw new i("BROKEN_PIPE");throw e}},flush:function(){return 0===a?Promise.resolve():new Promise(function(e){c.push(e)})}}},renderResult:function(e,t){const n=e&&e.structuredContent;let r=(o=n&&n.warnings,Array.isArray(o)&&o.length?o.map(function(e){return s("output.warning",{text:m((t=e,"string"==typeof t?t:t&&"string"==typeof t.message?t.message:JSON.stringify(t)))})+"\n";var t}).join(""):"");var o;const i=e&&e.content&&e.content[0]&&e.content[0].text;if(t.json)return{stdout:JSON.stringify(N(n,i),null,2)+"\n",stderr:r};const c=function(e){if("string"!=typeof e||!/^\s*\{/.test(e))return null;try{const t=JSON.parse(e);return t&&"object"==typeof t&&!Array.isArray(t)?t:null}catch(e){return null}}(i),l=void 0!==n?n:c;let u="";!c&&"string"==typeof i&&i.length&&(u+=m(i)+(i.endsWith("\n")?"":"\n")),u+=function(e){if(!e||"object"!=typeof e)return"";const t=E(e);if(null!==t)return t;const n=e.result&&"object"==typeof e.result&&!Array.isArray(e.result)?e.result:null,r=n?E(n):null;if(null!==r)return r;const o=n?a(n):null;if(o)return g(o);if("string"==typeof e.text&&e.text.length)return m(e.text)+(e.text.endsWith("\n")?"":"\n");const i=a(e);if(i)return g(i);if(Object.keys(e).filter(function(e){return"warnings"!==e}).some(function(t){return null!==e[t]&&"object"==typeof e[t]}))return JSON.stringify(e,null,2)+"\n";if("string"==typeof e.body&&e.body.length)return m(e.body)+(e.body.endsWith("\n")?"":"\n");const s=function(e){const t=w.find(function(t){return"string"==typeof e[t]&&e[t]}),n=Object.keys(e).find(function(t){return y.test(t)&&"string"==typeof e[t]&&e[t]});return t&&n?f(e[t])+" ("+f(e[n])+")":""}(e);return s?s+"\n":""}(l);const p=function(e){if(!e||"object"!=typeof e)return null;const t=Object.keys(e).find(function(t){return/(^url|Url|_url)$/.test(t)&&"string"==typeof e[t]&&/^https?:\/\//.test(e[t])});return t?e[t]:null}(l);return p&&(u+="URL: "+m(p)+"\n"),{stdout:u,stderr:r}},jsonPayload:N,renderError:function(e,t){let n="";t.json&&(n=JSON.stringify({success:!1,error_code:e.errorCode,message:e.message,details:e.details,suggested_actions:e.suggestedActions},null,2)+"\n");let r=(e.suggestedActions||[]).slice();"DESKTOP_NOT_RUNNING"!==e.errorCode||r.length||r.push(s("output.start_desktop")),"NOT_LOGGED_IN"!==e.errorCode||r.length||r.push('Run "expl server login".'),"UNAUTHORIZED"===e.errorCode&&!r.length&&e.details&&"env"===e.details.source&&r.push('Create a new token with "expl server token create" and set EXPL_SERVER_TOKEN.');let o=s("output.error",{text:m(e.message)});return"USAGE"!==e.errorCode&&(o+=" ("+m(e.errorCode)+")"),o+="\n",r.forEach(function(e){o+=m(e)+"\n"}),{stdout:n,stderr:o}}}},587(e,t,n){const r=n(982),o=n(611),i=n(692),{URL:s,URLSearchParams:a}=n(16),{ExplError:c}=n(877);function l(e){return e.replace(/\/+$/,"")+"/oauth/clients/expl.json"}function u(e,t,n){return(n.request||p)(e,t,n)}function p(e,t,n){return new Promise(function(r,a){const l=new s(e.replace(/\/+$/,"")+t),u=("https:"===l.protocol?i:o).request({hostname:l.hostname,port:l.port||("https:"===l.protocol?443:80),path:l.pathname+l.search,method:n.method||"GET",headers:n.headers||{},agent:!1},function(e){let t="";e.setEncoding("utf8"),e.on("data",function(e){t+=e}),e.on("end",function(){r({statusCode:e.statusCode,body:t,headers:e.headers})})});u.setTimeout(n.timeoutMs||3e4,function(){u.destroy(Object.assign(new Error("timed out"),{code:"ETIMEDOUT"}))}),u.on("error",function(e){a(new c("SERVER_UNREACHABLE","Cannot reach "+l.origin+": "+(e.code||e.message)))}),n.body&&u.write(n.body),u.end()})}async function d(e,t,n){n=n||{};const r=e.replace(/\/+$/,""),o=new a(t);o.set("client_id",l(r)),o.set("resource",r+"/mcp");const i=await u(r,"/oauth/token",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","Content-Length":Buffer.byteLength(o.toString())},body:o.toString(),request:n.request});let s=null;try{s=JSON.parse(i.body)}catch(e){s=null}if(i.statusCode>=400){if(s&&"invalid_grant"===s.error)throw new c("NOT_LOGGED_IN",s.error_description||s.error);throw new c("SERVER_UNREACHABLE","HTTP "+i.statusCode+" from "+r+"/oauth/token")}if(!s||!s.access_token)throw new c("SERVER_UNREACHABLE","HTTP "+i.statusCode+" from "+r+"/oauth/token");return s}async function f(e){const t=e.serverUrl.replace(/\/+$/,""),n=await u(t,"/oauth/userinfo",{method:"GET",headers:{Authorization:"Bearer "+e.accessToken},request:e.request});if(401===n.statusCode||403===n.statusCode)throw new c("NOT_LOGGED_IN","The server rejected the login token.");if(n.statusCode>=400)throw new c("SERVER_UNREACHABLE","HTTP "+n.statusCode+" from "+t+"/oauth/userinfo");let r;try{r=JSON.parse(n.body)}catch(e){throw new c("SERVER_UNREACHABLE","HTTP "+n.statusCode+" from "+t+"/oauth/userinfo")}return{email:r.email||"?",display_name:r.display_name||null}}e.exports={refresh:function(e){return d(e.serverUrl,{grant_type:"refresh_token",refresh_token:e.refreshToken},{request:e.request})},revoke:async function(e){const t=e.serverUrl.replace(/\/+$/,""),n=new a({token:e.token,client_id:l(t)});try{await u(t,"/oauth/revoke",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","Content-Length":Buffer.byteLength(n.toString())},body:n.toString(),request:e.request})}catch(e){}},userinfo:f,login:async function(e){const t=e.serverUrl.replace(/\/+$/,""),i=function(e){const t=(e||r.randomBytes)(32).toString("base64url");return{verifier:t,challenge:r.createHash("sha256").update(t).digest("base64url")}}(),u=r.randomBytes(16).toString("hex");let p,m=null;e.noBrowser?p="http://127.0.0.1/callback":(m=await function(e){const t=e.httpModule||o;let n=null,r=null,i=null;const a=new Promise(function(e,t){r=e,i=t});a.catch(function(){});let l=!1,u=null;const p=function(){l||(l=!0,clearTimeout(u),n&&n.close())};return n=t.createServer(function(t,n){const o=new s(t.url,"http://127.0.0.1");if("/callback"!==o.pathname)return n.writeHead(404),void n.end();if(o.searchParams.get("state")!==e.state)return n.writeHead(400),void n.end("Invalid state.");const a=o.searchParams.get("error");if(a)return n.writeHead(400),n.end("Login failed."),i("access_denied"===a?new c("PERMISSION_DENIED","Login was denied in the browser."):new c("EXECUTION_FAILED","Login failed: "+(o.searchParams.get("error_description")||a))),void p();const l=o.searchParams.get("code");if(!l)return n.writeHead(400),void n.end("Missing code.");n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end("You can close this window and return to the terminal."),r(l),p()}),new Promise(function(t,r){n.listen(0,"127.0.0.1",function(){const r=n.address().port;u=setTimeout(function(){i(new c("EXECUTION_FAILED","Login timed out.")),p()},e.timeoutMs),t({port:r,redirectUri:"http://127.0.0.1:"+r+"/callback",code:a,close:p})}),n.on("error",r)})}({state:u,timeoutMs:6e5,httpModule:e.httpModule}),p=m.redirectUri);const h=function(e){const t=e.serverUrl.replace(/\/+$/,"");return t+"/oauth/authorize?"+new a({response_type:"code",client_id:l(t),redirect_uri:e.redirectUri,code_challenge:e.challenge,code_challenge_method:"S256",state:e.state,scope:"content:read",resource:t+"/mcp"}).toString()}({serverUrl:t,redirectUri:p,challenge:i.challenge,state:u});let g;!e.noBrowser&&e.interactive&&function(e,t){const r=t.spawn||n(317).spawn;let o,i;"darwin"===t.platform?(o="open",i=[e]):"win32"===t.platform?(o="rundll32",i=["url.dll,FileProtocolHandler",e]):(o="xdg-open",i=[e]);try{const e=r(o,i,{detached:!0,stdio:"ignore"});return e.on("error",function(){}),e.unref(),!0}catch(e){return!1}}(h,{platform:e.platform,spawn:e.spawn})?e.stderr.write("Opening "+h+" in your browser.\nIf the browser does not open, visit the URL above.\n"):e.stderr.write("Open this URL in your browser to log in:\n"+h+"\n"),e.noBrowser?(e.stderr.write("Paste the URL you were redirected to:\n"),g=function(e,t){let n;try{n=new s(e.trim())}catch(e){throw new c("USAGE","Paste the full redirect URL from your browser.")}if(n.searchParams.get("state")!==t)throw new c("USAGE","The redirect URL does not match this login attempt.");const r=n.searchParams.get("code");if(!r)throw new c("USAGE","The redirect URL has no authorization code.");return r}(await e.readLine(),u)):g=await m.code;const _=await function(e){return d(e.serverUrl,{grant_type:"authorization_code",code:e.code,redirect_uri:e.redirectUri,code_verifier:e.verifier},{request:e.request})}({serverUrl:t,code:g,verifier:i.verifier,redirectUri:p,request:e.request}),E=await f({serverUrl:t,accessToken:_.access_token,request:e.request}),w=new Date(Date.now()+1e3*(_.expires_in||3600)).toISOString();return{server_url:t,client_id:l(t),access_token:_.access_token,refresh_token:_.refresh_token,expires_at:w,email:E.email,saved_at:(new Date).toISOString()}},httpRequest:u}},654(e,t,n){const r=n(611),o=n(692),i=n(262),s=n(587),{ExplError:a,fromJsonRpcError:c,fromToolResult:l,fromHttpAuthError:u}=n(877),p="expl",d="x-exploratory-include-tool-meta",f=3e5;e.exports={create:function(e){const t=e.serverUrl.replace(/\/+$/,""),n=t+"/mcp",m=e.state;let h=e.auth;const g=e.sessionId,_=e.clientVersion,E=e.timeoutMs||f,w=e.onTrace,y=e.post||i.post,N=e.refresh||s.refresh,O=e.request;let x=0;async function I(){if(!h||"login"!==h.source||!h.credentials)return;const e=Date.parse(h.credentials.expires_at||"");Number.isFinite(e)&&e>Date.now()+6e4||await v()}async function v(){await m.withLock(t,async function(){const e=m.readCredentials(t);if(e&&e.access_token!==h.credentials.access_token)return h.credentials=e,void(h.token=e.access_token);const n=await N({serverUrl:t,refreshToken:h.credentials.refresh_token}),r=Object.assign({},h.credentials,{access_token:n.access_token,refresh_token:n.refresh_token||h.credentials.refresh_token,expires_at:new Date(Date.now()+1e3*(n.expires_in||3600)).toISOString(),saved_at:(new Date).toISOString()});m.writeCredentials(t,r),h.credentials=r,h.token=r.access_token})}async function T(e,r,o){if(!h)throw new a("NOT_LOGGED_IN","Not logged in to "+t+'. Run "expl server login".');async function i(s){const l=++x,d={jsonrpc:"2.0",id:l,method:e,params:r},f=JSON.stringify(d),m=function(e){const n={Host:new URL(t).host,Accept:"application/json, text/event-stream","Content-Type":"application/json","x-exploratory-client-name":p,"x-exploratory-client-version":_,"x-exploratory-guide-session":g};return h&&(n.Authorization="Bearer "+h.token),e&&Object.assign(n,e),n}(o);m["Content-Length"]=Buffer.byteLength(f);let N=null;const O=[],I=await y({url:n,headers:m,body:f,timeoutMs:E,onMessage:function(e){O.push(e),e&&e.id===l&&(N=e)}});w&&w(JSON.stringify({method:e,params:r,id:l,statusCode:I.statusCode,messages:O}));const T=function(e,n){if(e.connectError)throw new a("SERVER_UNREACHABLE","Cannot reach "+t+": "+e.connectError);if(e.rawBody)throw new a("SERVER_UNREACHABLE","Cannot reach "+t+": HTTP "+e.statusCode);if(401===e.statusCode&&h){if("login"===h.source&&n)return v().then(function(){return n()});throw u({statusCode:401,wwwAuthenticate:null,source:h.source})}if(!e.complete)throw new a("SERVER_UNREACHABLE","Cannot reach "+t+": incomplete response");return null}(I,s?function(){return i(!1)}:null);if(T)return T;if(!N)throw new a("EXECUTION_FAILED","No JSON-RPC response from "+t);if(N.error)throw c(N.error);return N.result}await I();try{return await i(!0)}catch(e){return async function(e){if(!h)throw e;if("login"!==h.source)throw e;if(!(e instanceof a)||"NOT_LOGGED_IN"!==e.errorCode)throw e;const n=m.readCredentials(t);if(n&&n.access_token!==h.token)return h.credentials=n,h.token=n.access_token,i(!1);throw e}(e)}}return{auth:h,listTools:async function(){const e=[];let t=null;for(;;){const n=t?{cursor:t}:{},r=await T("tools/list",n,{[d]:"true"});if(r&&r.tools&&e.push.apply(e,r.tools),t=r&&r.nextCursor?r.nextCursor:null,!t)break}return e},callTool:async function(e,t){const n=await T("tools/call",{name:e,arguments:t||{}});if(n&&n.isError)throw l(n);return n},initialize:async function(){const e=await T("initialize",{protocolVersion:"2025-11-25",capabilities:{},clientInfo:{name:p,version:_}});return{instructions:"string"==typeof e.instructions?e.instructions:null,serverInfo:e.serverInfo||{}}},download:async function(e){if(!h)throw new a("NOT_LOGGED_IN","Not logged in to "+t+'. Run "expl server login".');await I();const n=new URL(e);if(n.origin!==new URL(t).origin)throw new a("EXECUTION_FAILED","The download URL is not on "+t+": "+e);const i="https:"===n.protocol?o:r;return new Promise(function(r,o){const s=i.request({hostname:n.hostname,port:n.port||("https:"===n.protocol?443:80),path:n.pathname+n.search,method:"GET",headers:{Authorization:"Bearer "+h.token},agent:!1},function(t){const n=[];t.on("data",function(e){n.push(e)}),t.on("end",function(){200===t.statusCode?r(Buffer.concat(n)):o(new a("EXECUTION_FAILED","HTTP "+t.statusCode+" from "+e))})});s.setTimeout(E,function(){s.destroy(Object.assign(new Error("timed out"),{code:"ETIMEDOUT"}))}),s.on("error",function(e){o(new a("SERVER_UNREACHABLE","Cannot reach "+t+": "+(e.code||e.message)))}),s.end()})},serverRequest:async function(e,n,r,o){if(!h)throw new a("NOT_LOGGED_IN","Not logged in to "+t+'. Run "expl server login".');await I();const i=function(){return s.httpRequest(t,n,{method:e,headers:Object.assign({Authorization:"Bearer "+h.token},o||{}),body:r,request:O})};let c=await i();if(401===c.statusCode&&"login"===h.source&&(await v(),c=await i()),401===c.statusCode)throw u({statusCode:401,wwwAuthenticate:c.headers&&c.headers["www-authenticate"],source:h.source});return c}}},resolveToken:function(e){let t=null,n=null;if(e.flag)t="-"===e.flag?(e.readStdin().split(/\r?\n/)[0]||"").trim():e.flag,n="flag";else{if(!e.env||!e.env.EXPL_SERVER_TOKEN){const t=e.state.readCredentials(e.serverUrl);return t&&t.access_token?{source:"login",credentials:t,token:t.access_token}:null}t=e.env.EXPL_SERVER_TOKEN.trim(),n="env"}return t?{source:n,credentials:null,token:t}:null},DEFAULT_TIMEOUT_MS:f}},876(e,t,n){const r=n(495),o=n(213),i=n(351),s=n(654),a=n(134),{ExplError:c,exitCodeFor:l}=n(877),u=["expl server login [--url <server>] [--no-browser]","expl server logout","expl server status","expl server token create|list|revoke","expl server tools list|describe","expl server call <tool_name>","expl server skill"];function p(e,t){t.stdout&&e.stdout.write(t.stdout),t.stderr&&e.stderr.write(t.stderr)}function d(e,t,n){const r=e instanceof c?e:new c("EXECUTION_FAILED",e&&e.message?e.message:String(e));return"BROKEN_PIPE"===r.errorCode||p(t,i.renderError(r,{json:n})),l(r.errorCode)}const f={400:"USAGE",403:"PERMISSION_DENIED",404:"NOT_FOUND",409:"CONFLICT"};function m(e,t){let n=null;try{n=JSON.parse(e.body)}catch(e){n=null}if(e.statusCode>=200&&e.statusCode<300&&n)return n;const r=f[e.statusCode];if(r)throw new c(r,n&&n.error_description||"HTTP "+e.statusCode);throw new c("SERVER_UNREACHABLE","HTTP "+e.statusCode+" from "+t+"/oauth/cli-tokens")}e.exports={run:async function(e,t,l){const f=t.json;try{let h;try{h=r.splitGlobals(e,r.SERVER_FLAG_SPECS)}catch(e){return d(e,l,f)}if(t.project)throw new c("USAGE","--project is not used with expl server.");const g=Object.assign({},t,{url:h.globals.url||t.url||null,token:h.globals.token||t.token||null,output:h.globals.output||t.output||null,noBrowser:h.globals.noBrowser||t.noBrowser||!1});e=h.rest;const _=l.server.state,E=a.resolveServerUrl({flag:g.url,env:l.env,state:_}),w=t.timeoutSec?1e3*t.timeoutSec:s.DEFAULT_TIMEOUT_MS,y=e[0];if("login"===y){const e=await l.server.login({serverUrl:E,noBrowser:g.noBrowser,interactive:l.stdinIsTTY&&l.stdoutIsTTY,platform:l.server.platform,stderr:l.stderr,readLine:l.readLine,request:l.server.request,httpModule:l.server.httpModule,spawn:l.server.spawn});return _.writeCredentials(E,e),p(l,{stdout:"Logged in to "+new URL(E).host+" as "+e.email+".\n",stderr:""}),0}if("logout"===y){const e=_.readCredentials(E);return e?(await l.server.revoke({serverUrl:E,token:e.refresh_token,request:l.server.request}),_.deleteCredentials(E),p(l,{stdout:"Logged out of "+new URL(E).host+".\n",stderr:""}),0):(p(l,{stdout:"Not logged in.\n",stderr:""}),0)}const N=s.resolveToken({flag:g.token,env:l.env,state:_,serverUrl:E,readStdin:l.readStdin}),O=l.server.createClient({serverUrl:E,auth:N,state:_,sessionId:l.sessionId,clientVersion:l.version,timeoutMs:w,onTrace:l.onTrace,post:l.server.post,refresh:l.server.refresh,request:l.server.request});if("status"===y){if(!N)throw new c("NOT_LOGGED_IN","Not logged in to "+E+'. Run "expl server login".');return await async function(e,t,n,r,o){try{const i=await n.initialize(),s=i.serverInfo&&i.serverInfo.version?i.serverInfo.version:"?";let a="?";r&&(a=(await e.server.userinfo({serverUrl:o,accessToken:r.token,request:e.server.request})).email);let c="not logged in";if(r)if("login"===r.source&&r.credentials){const e=r.credentials.saved_at?r.credentials.saved_at.slice(0,10):"?",t=new Date(r.credentials.expires_at||"");c="login (refresh token saved "+e+", access token valid until "+(Number.isFinite(t.getTime())?t.toTimeString().slice(0,5):"?")+")"}else c="env"===r.source?"EXPL_SERVER_TOKEN":"--token";const l={server:o,version:s,user:a,auth:c};return p(e,t?{stdout:JSON.stringify(l,null,2)+"\n",stderr:""}:{stdout:"Server: "+o+" (Exploratory "+s+")\nUser: "+a+"\nAuth: "+c+"\n",stderr:""}),0}catch(n){return d(n,e,t)}}(l,f,O,N,E)}if("token"===y)return await async function(e,t,n,r,o,s){const a=e[0];if("create"===a){if(!o||"login"!==o.source)throw new c("NOT_LOGGED_IN",'Log in with "expl server login" to create tokens.');const i=function(e){const t=new c("USAGE","Usage: expl server token create --name <name> [--expires <days>]");let n=null,r=null;for(let o=0;o<e.length;o++){const i=e[o].indexOf("="),s=i>0?e[o].slice(0,i):e[o];if("--name"!==s&&"--expires"!==s)throw t;const a=i>0?e[o].slice(i+1):e[++o];if(void 0===a||""===a)throw t;"--name"===s?n=a:r=a}if(!n)throw t;if(null===r)return{name:n,expiresDays:null};if(!/^[0-9]+$/.test(r))throw new c("USAGE","--expires must be a number of days.");return{name:n,expiresDays:Number(r)}}(e.slice(1)),a=JSON.stringify(null===i.expiresDays?{name:i.name}:{name:i.name,expires_days:i.expiresDays}),l=m(await r.serverRequest("POST","/oauth/cli-tokens",a,{"Content-Type":"application/json"}),s);return p(t,n?{stdout:JSON.stringify(l,null,2)+"\n",stderr:""}:{stdout:l.token+"\n",stderr:"Token name: "+l.name+"\nExpires: "+l.expires_at+"\nSave this token; it will not be shown again.\nSet EXPL_SERVER_TOKEN for CI.\n"}),0}if("list"===a){if(e.length>1)throw new c("USAGE","Usage: expl server token list");if(!o)throw new c("NOT_LOGGED_IN","Not logged in to "+s+'. Run "expl server login".');const a=m(await r.serverRequest("GET","/oauth/cli-tokens",null,{}),s);return n||(a.tokens||[]).length?(p(t,i.renderResult({structuredContent:a},{json:n})),0):(p(t,{stdout:"No tokens.\n",stderr:""}),0)}if("revoke"===a){const i=e[1];if(!i||e.length>2)throw new c("USAGE","Usage: expl server token revoke <name>");if(!o)throw new c("NOT_LOGGED_IN","Not logged in to "+s+'. Run "expl server login".');return m(await r.serverRequest("DELETE","/oauth/cli-tokens/"+encodeURIComponent(i),null,{}),s),p(t,{stdout:n?JSON.stringify({success:!0})+"\n":"Revoked "+i+".\n",stderr:""}),0}throw new c("USAGE","Usage: expl server token create|list|revoke")}(e.slice(1),l,f,O,N,E);if("skill"===y){let e=null;try{e=(await O.initialize()).instructions}catch(t){e=null}return p(l,{stdout:n(821).render({instructions:null,version:l.version,server:{instructions:e},serverOnly:!0}),stderr:""}),0}const x=await async function(e,t,n){try{const r=await e.listTools();return n.writeToolsCache(t,r),{tools:r,up:!0,downError:null}}catch(e){if(!(e instanceof c))throw e;if("SERVER_UNREACHABLE"!==e.errorCode&&"NOT_LOGGED_IN"!==e.errorCode&&"UNAUTHORIZED"!==e.errorCode)throw e;return{tools:n.readToolsCache(t)||[],up:!1,downError:e}}}(O,E,_),I=o.GLOBAL_FLAGS.concat(o.SERVER_FLAGS),v=x.tools.length?o.build(x.tools,{globalFlags:I}):{commands:[],find:function(){return null},byToolName:function(){return null}},T=g.output?function(e,t,n,r){return async function(o){const s=n.output;let a=null;o.content&&o.content.forEach(function(e){"image"===e.type&&e.data&&(a=Buffer.from(e.data,"base64"))});const l=function(e){const t=e&&e.content&&e.content[0]&&e.content[0].text,n=i.jsonPayload(e&&e.structuredContent,t);return n&&"object"==typeof n&&(n.download_url||n.result&&n.result.download_url)||null}(o);if(!a&&!l)throw new c("USAGE","This command returns no file. --output works with dataframe export and chart get-image.");const u=a||await t.download(l);return"-"===s?(e.writeStdoutBytes(u),{stdout:"",stderr:""}):(e.writeFileBytes(s,u),r?{stdout:JSON.stringify({saved:s,bytes:u.length},null,2)+"\n",stderr:""}:{stdout:"Saved "+u.length+" bytes to "+s+"\n",stderr:""})}}(l,O,g,f):null;return await n(107).dispatchTree({prefix:"expl server",client:O,tree:v,up:x.up,downError:x.downError||new c("NOT_LOGGED_IN"),downHint:'Log in with "expl server login" to list its commands.',globals:t,serverGlobals:g,json:f,deps:l,resolveProject:!1,builtinHelp:u,onResult:T},e)}catch(e){return d(e,l,f)}}}},134(e,t,n){const r=n(896),o=n(928),i=n(677),{ExplError:s}=n(877);function a(e){if("string"!=typeof e||!e)throw new s("USAGE","Server URL is required.");const t=e.trim().replace(/\/+$/,"");if(!/^https?:\/\//i.test(t))throw new s("USAGE","Server URL must start with http:// or https://.");return t}function c(e){const t=new URL(a(e)),n=t.hostname.replace(/[^a-zA-Z0-9.-]/g,"_"),r=t.port||("https:"===t.protocol?"443":"80");return r===("https:"===t.protocol?"443":"80")?n:n+"_"+r}e.exports={create:function(e){const t=e.rootDir,n=e.fsModule||r,l=o.join(t,"expl/server");function u(e){return o.join(l,c(e)+".json")}function p(){n.mkdirSync(l,{recursive:!0,mode:448}),n.chmodSync(l,448)}return{readCredentials:function(e){const t=i.readJsonFile(l,c(e)+".json",n);return t&&"string"==typeof t.access_token&&"string"==typeof t.server_url&&function(e,t){try{return new URL(a(e)).origin===new URL(a(t)).origin}catch(e){return!1}}(t.server_url,e)?t:null},writeCredentials:function(e,t){p(),i.writeJsonFile(l,c(e)+".json",t,n)},deleteCredentials:function(e){try{n.unlinkSync(u(e))}catch(e){if("ENOENT"!==e.code)throw e}},readToolsCache:function(e){const t=i.readJsonFile(l,c(e)+".tools.json",n);return t&&Array.isArray(t.tools)?t.tools:null},writeToolsCache:function(e,t){p(),i.writeJsonFile(l,c(e)+".tools.json",{tools:t},n)},lastServerUrl:function(){let e=null,t="";try{n.readdirSync(l).forEach(function(r){if(!r.endsWith(".json")||r.endsWith(".tools.json")||r.endsWith(".lock"))return;const o=i.readJsonFile(l,r,n);o&&"string"==typeof o.server_url&&"string"==typeof o.saved_at&&(!t||o.saved_at>t)&&(t=o.saved_at,e=o.server_url)})}catch(e){if("ENOENT"!==e.code)throw e}return e},withLock:async function(e,t){p();const r=function(e){return u(e)+".lock"}(e),o=Date.now();for(;;)try{n.writeFileSync(r,String(process.pid),{flag:"wx",mode:384});break}catch(e){if("EEXIST"!==e.code)throw e;try{if(Date.now()-n.statSync(r).mtimeMs>6e4){n.unlinkSync(r);continue}}catch(e){if("ENOENT"!==e.code)throw e;continue}if(Date.now()-o>=7e4)throw new s("EXECUTION_FAILED","Another expl process is still refreshing the login. Try again.");await new Promise(function(e){setTimeout(e,50)})}try{return await t()}finally{try{n.unlinkSync(r)}catch(e){}}}}},resolveServerUrl:function(e){if(e.flag)return a(e.flag);if(e.env&&e.env.EXPL_SERVER_URL)return a(e.env.EXPL_SERVER_URL);const t=e.state.lastServerUrl();return t?a(t):"https://exploratory.io"}}},821(e){const t=["# Exploratory from the shell: expl","","expl calls the same operations the Exploratory MCP server offers. Exploratory Desktop must be running and","the user signed in.","","## How to work","","1. Find the command: `expl tools list --json` lists every command with its MCP tool name, whether it only"," reads, and its risk (LOW, MEDIUM, HIGH).","2. Read its arguments before calling it: `expl <noun> <verb> --help` (same as `expl tools describe`).","3. Always pass `--json` and read the result from stdout. Warnings go to stderr: read them too.","4. Pass a project with `--project <id|name>`, or set one once with `expl project use <id|name>`.","5. Pass complex input as JSON: `--input file.json` or `--input -` (stdin). Flags override its fields.","6. HIGH-risk commands (publish, delete, ...) refuse to run without `--yes` when not on a terminal."," Ask the user before you add `--yes`.","7. Long operations wait by default. With `--no-wait`, poll with `expl execution get <execution_id>`.","8. `expl call <tool_name>` runs a tool by its MCP name.","","## Exit codes","","| Code | Meaning |","|---|---|","| 0 | Success |","| 1 | The operation failed (NOT_FOUND, INVALID_PARAMETER, EXECUTION_FAILED, ...) |","| 2 | Usage error: unknown flag, unreadable JSON, or `--yes` missing |","| 3 | Exploratory Desktop is not running |","| 4 | Not signed in, unauthorized, or permission denied |","| 130 | Interrupted |","",'With `--json`, a failure prints `{"success": false, "error_code", "message", "suggested_actions"}` on stdout.'].join("\n"),n=["## Exploratory Server: expl server","","expl server calls the same operations as the Exploratory Server MCP. Run `expl server login` once on","each machine (or set EXPL_SERVER_TOKEN from `expl server token create` for CI).","","List commands: `expl server tools list --json`. Exit code 3 means the server is unreachable;","exit code 4 means not logged in or the token was rejected."].join("\n");e.exports={render:function(e){const r=!!e.serverOnly,o=["---","name: "+(r?"exploratory-expl-server":"exploratory-expl"),"description: "+(r?"Use expl server to search and read the data, charts, dashboards, notes and analytics published on Exploratory Server from the shell.":"Use the expl command to read and change Exploratory projects, dashboards, notes, charts and data frames from the shell."),"---","","\x3c!-- Generated by expl "+e.version+" --\x3e",""];return r||o.push(t),e.server&&(o.push("",n),e.server.instructions&&o.push("",e.server.instructions.trim())),e.instructions&&o.push("","## Exploratory guidance","",e.instructions.trim()),o.join("\n")+"\n"}}},677(e,t,n){const r=n(896),o=n(928),{ExplError:i}=n(877),{t:s,getLang:a}=n(42),c="expl.json",l="expl-tools.json";function u(e,t,n){try{const r=n.readFileSync(o.join(e,t),"utf8");return JSON.parse(r)}catch(e){return null}}function p(e,t,n,r){const i=o.join(e,t),s=i+"."+process.pid+".tmp";r.writeFileSync(s,JSON.stringify(n),{mode:384,encoding:"utf8"}),r.renameSync(s,i)}e.exports={create:function(e){const t=e.agentDir,n=e.fsModule||r;return{readDefaultProject:function(){const e=u(t,c,n);return e&&"string"==typeof e.default_project_id?e.default_project_id:null},writeDefaultProject:function(e){p(t,c,{default_project_id:e},n)},readToolsCache:function(){const e=u(t,l,n);return e&&Array.isArray(e.tools)&&e.lang===a()?e.tools:null},writeToolsCache:function(e){p(t,l,{lang:a(),tools:e},n)}}},resolveProject:function(e,t){const n=t.filter(function(t){return t.project_id===e});if(1===n.length)return n[0];const r=t.filter(function(t){return t.name===e});if(1===r.length)return r[0];if(0===r.length)throw new i("USAGE",s("state.no_project_named",{ref:e}));const o=r.map(function(e){return e.updated_at?e.project_id+" ("+e.updated_at+")":e.project_id});throw new i("USAGE",s("state.multiple_projects",{ref:e,ids:o.join("\n")}))},readJsonFile:u,writeJsonFile:p}},947(e,t,n){const r=n(85),{ExplError:o}=n(877),{t:i}=n(42);e.exports={waitFor:async function(e,t,n){const s=t&&t.structuredContent;if(!s||"running"!==s.status)return t;const a=s.execution_id,c=s.operation_id,l=s.capability||"operation",u=n.now(),p=null!=n.timeoutSec?u+1e3*n.timeoutSec:null,d=r.MAX_OPERATION_WAIT_MS,f=n.interrupt||null,m={},h=async function(){const t={execution_id:a,operation_id:c};throw n.projectId&&(t.project_id=n.projectId),await e.callTool("cancel_execution",t).catch(function(){}),new o("INTERRUPTED")};f&&(f.waiting=!0);try{for(;;){n.isInterrupted()&&await h(),n.onProgress(i("wait.waiting",{capability:l,operationId:c}));let t=d;if(null!=p&&(t=Math.min(t,Math.max(0,p-n.now())),0===t))throw new o("EXECUTION_TIMEOUT",i("wait.timed_out",{executionId:a,operationId:c}));const r=e.callTool("get_execution",{execution_id:a,operation_id:c,wait_ms:t}),s=f?await Promise.race([r,f.promise.then(function(){return m})]):await r;s===m&&await h();const u=s&&s.structuredContent&&s.structuredContent.operations,g=u&&u[0];if(!g||"running"!==g.status){if(g&&"failed"===g.status){const e=g.error||{};throw new o(e.error_code||"EXECUTION_FAILED",e.message,null,e.suggested_actions)}return s}}}finally{f&&(f.waiting=!1)}}}},287(e,t,n){const r=n(439),o=/^expc_[0-9a-f]{64}$/;e.exports={create:function(e){const t=e.env||{},n=e.now||Date.now;let i=null;function s(t,o){return i||(i=async function(){const i=n();for(;;){const s=await e.pair(t);if(!s)return{pairing:"unavailable"};if("approved"===s.status&&"string"==typeof s.credential){try{await e.store.set(s.credential)}catch(e){}return{token:s.credential,source:"paired"}}if(s.error){const t="string"==typeof s.error&&r.CODES.indexOf(s.error)>=0;return!t&&e.log&&e.log("pair reply not understood: "+String(JSON.stringify(s.error)).slice(0,200)),{pairing:"error",error:t?s.error:"VERSION_MISMATCH"}}if("pending"!==s.status)return{pairing:"declined"};if(n()-i>=(o.maxWaitMs||0))return{pairing:"pending"};o.onPending&&o.onPending()}}().then(function(e){return i=null,e},function(e){throw i=null,e}),i)}return{resolve:async function(n,r){const i="string"==typeof t.EXPLORATORY_AGENT_TOKEN?t.EXPLORATORY_AGENT_TOKEN.trim():"";if(i&&o.test(i))return e.log&&e.log("credential source=environment paired_format=true"),{token:i,source:"env"};i&&e.log&&e.log("credential source=environment paired_format=false; trying stored credential");let a=null;try{a=await e.store.get()}catch(e){a=null}if(a){if(e.log&&e.log("credential source=store paired_format="+o.test(a)),!o.test(a)){try{await e.store.remove()}catch(e){}return s(String(n||"").slice(0,100),r||{})}return{token:a,source:"store"}}return e.log&&e.log("credential source=pairing"),s(String(n||"").slice(0,100),r||{})},forget:async function(t){if(t&&("store"===t.source||"paired"===t.source))try{await e.store.remove()}catch(e){}}}}}},262(e,t,n){const r=n(896),o=n(611),i=n(692),s=n(928);function a(e){return new Promise(function(t){let n=!1,r=!1,s=!1;const a=function(e){s||(s=!0,p&&clearTimeout(p),t(e))};let c,l;if(e.url){const t=new URL(e.url);l="https:"===t.protocol?i:o;const n="https:"===t.protocol?443:80;c={hostname:t.hostname,port:t.port?Number(t.port):n,path:t.pathname+t.search,method:"POST",headers:e.headers,agent:!1}}else l=o,c={socketPath:e.socketPath,path:e.path||"/mcp",method:"POST",headers:e.headers,agent:!1};const u=l.request(c,function(t){n=!0,function(e,t,n){const r=e.headers["content-type"]||"",o=/^text\/event-stream/i.test(r),i=/^application\/json/i.test(r),s=function(e,t){let n="";return{push:function(r){n+=r;let o=n.search(/\r?\n\r?\n/);for(;o>=0;){const r=n.slice(0,o);n=n.slice(o).replace(/^\r?\n\r?\n/,"");const i=r.split(/\r?\n/).filter(function(e){return 0===e.indexOf("data:")}).map(function(e){return e.slice(5).replace(/^ /,"")}).join("\n");if(i)try{e(JSON.parse(i))}catch(e){t&&t("unreadable event from Exploratory: "+e.message)}o=n.search(/\r?\n\r?\n/)}}}}(t.onMessage,t.onParseError);let a="";e.setEncoding("utf8"),e.on("data",function(e){o?s.push(e):a+=e}),e.on("error",function(){}),e.on("close",function(){let s=null;if(!o&&a.trim())try{t.onMessage(JSON.parse(a))}catch(n){i?t.onParseError&&t.onParseError("unreadable response from Exploratory: HTTP "+e.statusCode):s=a.slice(0,1024)}n({complete:!!e.complete,statusCode:e.statusCode,connectError:null,contentType:r||null,rawBody:s})})}(t,e,a)});let p=null;e.timeoutMs&&e.timeoutMs>0&&(p=setTimeout(function(){u.destroy(),n||a({complete:!1,statusCode:null,connectError:"ETIMEDOUT",requestSent:r,contentType:null,rawBody:null})},e.timeoutMs)),u.on("socket",function(e){e.connecting||(r=!0),e.once("connect",function(){r=!0})}),u.on("error",function(e){n||a({complete:!1,statusCode:null,connectError:e.code||"CONNECTION_FAILED",requestSent:r,contentType:null,rawBody:null})}),u.end(e.body)})}e.exports={requestPairing:function(e){const t=JSON.stringify({name:e.name});let n=null;return a({socketPath:e.socketPath,path:"/pair",headers:{"Content-Type":"application/json",Accept:"application/json","Content-Length":Buffer.byteLength(t),Host:"localhost","x-exploratory-channel":e.channel},body:t,timeoutMs:4e4,onMessage:function(e){n=e}}).then(function(e){return e.connectError||!n?null:n})},readEndpoint:function(e){try{const t=JSON.parse(r.readFileSync(s.join(e,"endpoint.json"),"utf8"));return t&&"string"==typeof t.socket?t:null}catch(e){return null}},post:a}},49(e,t,n){const r=n(896),o=n(857),i=n(928),s=n(713),a=o.homedir()||process.env.HOME||process.env.HOMEPATH||process.env.USERPROFILE;function c(e){return s.hasUTF8Multibyte(e)||/\s/.test(e)}e.exports={getUserAccountRootDir:function(){const e=function(){let e=null;try{e=r.readFileSync(i.resolve(a,".exploratory_home")).toString().trim()}catch(e){}return e}();if(e||process.env.EXPLORATORY_HOME){const t=e||process.env.EXPLORATORY_HOME;return{userAccountRootDir:t,hasMultiByteInEXPLORATORY_HOME:c(t)}}return{userAccountRootDir:c(a)?"win32"===o.platform()?"\\exploratory":"/exploratory":i.resolve(a,".exploratory"),hasMultiByteInEXPLORATORY_HOME:!1}}}},713(e,t,n){const r={};var o,i=n(857);global.currentVariablesMap?o=global.currentVariablesMap:(o={},global.currentVariablesMap=o),r.registerExploratoryVariable=function(e){o[e]=!0},r.unregisterExploratoryVariable=function(e){delete o[e]},r.clearExploratoryVariables=function(){Object.keys(o).forEach(function(e){delete o[e]})},r.translateVariablePlaceholders=function(e,t){return e.replace(/\@\{([^\}\]]+)(?:\[([^\}\]]+)\])?\}/g,function(e,n,i){const s=r.extractQuoteParameterValue(n);let a=n;if(s&&(a=a.split(",")[0].trim()),t&&!o[a]){var c=new Error("EXP-PARAM-1 :: "+JSON.stringify([a])+" :: Parameter "+a+" is not defined.");throw c.VAR_EXISTENCE_ERROR=!0,c.isR=!0,c}return i?"exploratory_env$`"+n+"`["+i+"]":["FALSE","F"].includes(s)?"!!rlang::sym(exploratory_env$`"+a+"`)":"exploratory_env$`"+a+"`"})};const s=/quote\s*=\s*(TRUE|FALSE|T|F)/i;r.extractQuoteParameterValue=function(e){const t=e.match(s);return t?t[1].toUpperCase():null},r.checkVariableExistence=function(e){if(!o[e]){var t=new Error("EXP-PARAM-1 :: "+JSON.stringify([e])+" :: Parameter "+e+" is not defined.");throw t.VAR_EXISTENCE_ERROR=!0,t.isR=!0,t}},r.escapeForQuotedStringInR=function(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')},r.escapeForSingleQuotedStringInR=function(e){return e.replace(/\\/g,"\\\\").replace(/'/g,"\\'")},r.validateRObjectName=function(e){if(!e)return!1;if(e.length>1&&46===e.charCodeAt(0)&&e.charCodeAt(1)>=48&&e.charCodeAt(1)<=57)return!1;for(var t=0,n=e.length;t<n;t++){var r=e.charCodeAt(t);if(0===t&&r>=48&&r<=57)return!1;if(0===t&&95===r)return!1;if(r>=0&&r<=31)return!1;if(r>=32&&r<=45||47===r)return!1;if(r>=58&&r<=64)return!1;if(r>=91&&r<=94||96===r)return!1;if(r>=123&&r<=127)return!1}return!0},r.hasUTF8Multibyte=function(e){for(var t=0;t<e.length;t++)if(e.charCodeAt(t)>=128)return!0;return!1},r.escapeRegExp=function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},r.escapeHTMLTags=function(e){return"string"!=typeof e?e:e.replace(/[&'`"<>]/g,function(e){return{"&":"&amp;","'":"&#x27;","`":"&#x60;",'"':"&quot;","<":"&lt;",">":"&gt;"}[e]})},r.translateVariablePlaceholdersWithDummy=function(e){return e.replace(/@{[^}]*}/g,function(e){return"c("+e.replace(/./g,"X").slice(2,-1)+")"}).replace(/\bai\s*\(\s*(@[\p{L}\p{N}_-]+)/gu,function(e){return'ai(""'})},r.compareVersionStr=function(e,t,n){var r=n&&n.lexicographical,o=n&&n.zeroExtend,i=e.split("."),s=t.split(".");function a(e){return(r?/^\d+[A-Za-z]*$/:/^\d+$/).test(e)}if(!i.every(a)||!s.every(a))return NaN;if(o){for(;i.length<s.length;)i.push("0");for(;s.length<i.length;)s.push("0")}r||(i=i.map(Number),s=s.map(Number));for(var c=0;c<i.length;++c){if(s.length===c)return 1;if(i[c]!==s[c])return i[c]>s[c]?1:-1}return i.length!=s.length?-1:0},r.getValueAtPath=function(e,t,n){if(e&&t){var r=e;if(Array.isArray(t)){if(0===t.length)return;t.forEach(function(e){r=r?r[e]:void 0})}else r=r[t];return n&&(void 0!==n[r]&&null!==n[r]?r=n[r]:n["*"]&&(r=r?n["*"]:void 0)),r}},r.isTestMode=function(){return!!process.env.EXPLORATORY_TEST_RUNNER_ENABLED||!!process.env.EXPECTED_RESULT_DIR},r.generateRandomStr=function(){var e=function(){var e=(52*(1+Math.random())|0)%52;return e>=26?String.fromCharCode(97+e-26):String.fromCharCode(65+e)},t=function(){return e()+e()+e()+(10*(1+Math.random())|0)%10};return t()+t()},r.generateIdStr=function(e){var t="";return e&&(t=(t=e.replace(/[^0-9a-zA-Z ]/g," ").trim().replace(/[ ]{2,}/g," ")).replace(/ /g,"-")),t?t+"-"+r.generateRandomStr():r.generateRandomStr()},r.isAdhocChart=function(){return!!window?.parent?.exploratory?.adc},r.isIgnorableWarning=function(e){return["Warning: ReactDOM.unstable_renderSubtreeIntoContainer() is no longer supported in React 18.",'Warning: [react-bootstrap] Specifying only the `"hover"` trigger limits the visibilty of the overlay to just mouse users.'].some(t=>e.startsWith(t))},r.escapeSpecialCharacterForRegex=function(e){return["\\\\","\\$","\\*","\\+","\\.","\\?","\\[","\\]","\\^","\\{","\\}","\\|","\\(","\\)"].reduce(function(e,t){return e.replace(new RegExp(t,"g"),t)},e)},r.escapePathForR=function(e){return"win32"===i.platform()?(e=e.replace(/"/g,"")).replace(/\\/g,"\\\\"):e},r.isWin32bit=function(){return"win32"===i.platform()&&"x64"!==process.arch},e.exports=r},317(e){"use strict";e.exports=require("child_process")},982(e){"use strict";e.exports=require("crypto")},896(e){"use strict";e.exports=require("fs")},611(e){"use strict";e.exports=require("http")},692(e){"use strict";e.exports=require("https")},857(e){"use strict";e.exports=require("os")},928(e){"use strict";e.exports=require("path")},18(e){"use strict";e.exports=require("tty")},16(e){"use strict";e.exports=require("url")},169(e){"use strict";e.exports=JSON.parse('{"DESKTOP_NOT_RUNNING.message":"Exploratory Desktop is not running.","DESKTOP_NOT_RUNNING.action":"Ask the user to start Exploratory Desktop; this connection will work once it is running, without reconnecting","NOT_SIGNED_IN.message":"No user is signed in to Exploratory.","NOT_SIGNED_IN.action":"Sign in to Exploratory, then retry","UNAUTHORIZED.message":"This application has not been approved in Exploratory, or its access was removed.","UNAUTHORIZED.action":"Retry: Exploratory asks the user to approve this application; do not ask the user for a token or password","PAIRING_PENDING.message":"Exploratory is waiting for the user to approve this application.","PAIRING_PENDING.action":"Ask the user to answer the request shown in Exploratory, then retry","CHANNEL_DISABLED.message":"This way of connecting to Exploratory (MCP or CLI) is turned off in the Exploratory settings.","CHANNEL_DISABLED.action":"Ask the user to turn it on in Exploratory: Preferences > MCP / CLI (the Japanese UI shows the same item as 環境設定 > MCP / CLI), then retry","PAIRING_REQUIRED.message":"This connection was not accepted.","PAIRING_REQUIRED.action":"Tell the user the connection was not accepted; do not ask them to approve it","PROJECT_NOT_OPEN.message":"The project exists but is not open in Exploratory.","PROJECT_NOT_OPEN.action":"Open the project in Exploratory, then retry","NOT_FOUND.message":"The requested object was not found.","NOT_FOUND.action":"Call list_created_artifacts, list_charts or list_analytics to see available artifacts","PERMISSION_DENIED.message":"This application is not permitted to perform the operation.","PERMISSION_DENIED.action":"Tell the user this operation is not permitted for this connection","CONFIRMATION_REQUIRED.message":"The operation needs the user\'s confirmation.","CONFIRMATION_REQUIRED.action":"Ask the user to confirm in Exploratory","CONFIRMATION_DECLINED.message":"The user declined the operation in Exploratory.","CONFIRMATION_DECLINED.action":"Do not try again or look for another way to do the same thing; tell the user it was declined","INVALID_PARAMETER.message":"A parameter is invalid.","INVALID_PARAMETER.action":"Read the tool\'s description and input schema, fix the parameter the message names, then call the tool again","INVALID_COLUMN.message":"The column does not exist in the data frame.","INVALID_COLUMN.action":"Call get_data_frame to see the columns","INVALID_COLUMN_TYPE.message":"The column has the wrong type for the operation.","INVALID_COLUMN_TYPE.action":"Add a converted column with create_wrangling_step (a calculation, for example as.character(<column>), cut(<column>, ...) or <column> == \\"<value>\\"), then use that column","REVISION_CONFLICT.message":"The artifact changed since it was last read.","REVISION_CONFLICT.action":"Re-read the artifact and reconcile before updating","EXECUTION_FAILED.message":"The operation failed in Exploratory.","EXECUTION_FAILED.action":"Fix the cause the message names, then call the tool again; if it fails the same way twice, tell the user what failed","EXECUTION_TIMEOUT.message":"The operation took longer than allowed.","EXECUTION_TIMEOUT.action":"Retry, or use get_execution for the result","R_REQUIRED.message":"The document has no rendered output to export yet.","R_REQUIRED.action":"Ask the user to open it in Exploratory once so it renders, then call the tool again","PDF_EXPORT_FAILED.message":"Exploratory could not make the PDF.","PDF_EXPORT_FAILED.action":"Fix the cause the message names, then call the tool again; if it fails the same way twice, tell the user what failed","PDF_EXPORT_TIMEOUT.message":"Making the PDF took longer than allowed.","PDF_EXPORT_TIMEOUT.action":"Call the tool once more; if it times out again, tell the user","RESOURCE_BUSY.message":"Exploratory is busy with another operation.","RESOURCE_BUSY.action":"Retry shortly","DATA_EGRESS_LIMIT.message":"The result is larger than the amount that can be returned.","DATA_EGRESS_LIMIT.action":"Ask again for fewer rows or columns","UNSUPPORTED_OPERATION.message":"The operation is not supported.","UNSUPPORTED_OPERATION.action":"Do it with another tool if one fits; otherwise tell the user it is not supported","RESOURCE_BUSY.r_busy.action":"Wait for the current R operation to finish, then retry the same tool with the same arguments.","next.unknown_client_tool":"Call only the tools in your tool list.","next.not_found":"Find the right id with the list or get tool for that kind of object (for example list_data_frames, list_charts, list_analytics, list_notes or list_dashboards), then call again with it.","next.invalid":"Read this tool\'s description and input schema, fix the argument the message names, then call the tool again.","next.not_ready":"Wait a moment, then call the tool again.","next.not_allowed":"Use an object this conversation created or read, or ask the user to allow it.","next.other":"Fix the cause the message names, then call the tool again; if it fails the same way twice, tell the user what failed.","VERSION_MISMATCH.message":"The running Exploratory is not compatible with the version of this app (the MCP helper or expl), so it cannot connect.","VERSION_MISMATCH.action":"Ask the user to start the version of Exploratory that matches this app; for the MCP helper, reconnect the MCP helper from the running Exploratory. Then retry"}')},719(e){"use strict";e.exports=JSON.parse('{"DESKTOP_NOT_RUNNING.message":"Exploratory Desktop が起動していません。","DESKTOP_NOT_RUNNING.action":"利用者に Exploratory Desktop を起動するよう伝えてください。起動すれば、接続し直さなくても、この接続が使えるようになります","NOT_SIGNED_IN.message":"Exploratory にサインインしているユーザーがいません。","NOT_SIGNED_IN.action":"Exploratory にサインインしてから、もう一度実行してください","UNAUTHORIZED.message":"このアプリケーションは Exploratory で承認されていないか、アクセスが取り消されています。","UNAUTHORIZED.action":"もう一度実行してください。Exploratory が利用者にこのアプリケーションの承認を求めます。利用者にトークンやパスワードを尋ねないでください","PAIRING_PENDING.message":"Exploratory は、利用者がこのアプリケーションを承認するのを待っています。","PAIRING_PENDING.action":"Exploratory に表示された確認に答えるよう、利用者に伝えてから、もう一度実行してください","CHANNEL_DISABLED.message":"Exploratory の設定で、この接続方法(MCP または CLI)が無効になっています。","CHANNEL_DISABLED.action":"利用者に、Exploratory の 環境設定 > MCP / CLI で有効にするよう伝えてから、もう一度実行してください","PAIRING_REQUIRED.message":"この接続は受け付けられませんでした。","PAIRING_REQUIRED.action":"接続が受け付けられなかったことを利用者に伝えてください。承認を依頼しないでください","PROJECT_NOT_OPEN.message":"プロジェクトはありますが、Exploratory で開かれていません。","PROJECT_NOT_OPEN.action":"Exploratory でプロジェクトを開いてから、もう一度実行してください","NOT_FOUND.message":"指定されたオブジェクトが見つかりません。","NOT_FOUND.action":"list_created_artifacts、list_charts、list_analytics を呼んで、使えるものを確認してください","PERMISSION_DENIED.message":"このアプリケーションにはこの操作を行う権限がありません。","PERMISSION_DENIED.action":"この操作はこの接続では許可されていないことを、利用者に伝えてください","CONFIRMATION_REQUIRED.message":"この操作にはユーザーの確認が必要です。","CONFIRMATION_REQUIRED.action":"Exploratory で確認するよう、利用者に伝えてください","CONFIRMATION_DECLINED.message":"利用者が Exploratory でこの操作を断りました。","CONFIRMATION_DECLINED.action":"もう一度実行したり、同じことをする別の方法を探したりせず、断られたことを利用者に伝えてください","INVALID_PARAMETER.message":"パラメータが正しくありません。","INVALID_PARAMETER.action":"ツールの説明と入力スキーマを読み、メッセージに出ているパラメータを直してから、もう一度ツールを呼んでください","INVALID_COLUMN.message":"指定された列がデータフレームにありません。","INVALID_COLUMN.action":"get_data_frame を呼んで、列を確認してください","INVALID_COLUMN_TYPE.message":"この操作には列の型が合いません。","INVALID_COLUMN_TYPE.action":"create_wrangling_step で変換した列を追加し(計算で as.character(<列>)、cut(<列>, ...)、<列> == \\"<値>\\" など)、その列を使ってください","REVISION_CONFLICT.message":"最後に読み込んだあとで、このオブジェクトが変更されました。","REVISION_CONFLICT.action":"もう一度読み込んで内容を確認してから、更新してください","EXECUTION_FAILED.message":"Exploratory で操作に失敗しました。","EXECUTION_FAILED.action":"メッセージに出ている原因を直してから、もう一度ツールを呼んでください。同じ失敗が2回続くときは、失敗した内容を利用者に伝えてください","EXECUTION_TIMEOUT.message":"操作が許容時間を超えました。","EXECUTION_TIMEOUT.action":"もう一度実行するか、get_execution で結果を確認してください","R_REQUIRED.message":"書き出すための描画結果がまだありません。","R_REQUIRED.action":"Exploratory で一度開いて描画するよう利用者に伝えてから、もう一度ツールを呼んでください","PDF_EXPORT_FAILED.message":"Exploratory で PDF を作成できませんでした。","PDF_EXPORT_FAILED.action":"メッセージに出ている原因を直してから、もう一度ツールを呼んでください。同じ失敗が2回続くときは、失敗した内容を利用者に伝えてください","PDF_EXPORT_TIMEOUT.message":"PDF の作成が制限時間を超えました。","PDF_EXPORT_TIMEOUT.action":"もう一度ツールを呼んでください。再び時間切れになるときは、利用者に伝えてください","RESOURCE_BUSY.message":"Exploratory が別の操作を実行中です。","RESOURCE_BUSY.action":"しばらくしてから、もう一度実行してください","DATA_EGRESS_LIMIT.message":"結果が、返せる量を超えています。","DATA_EGRESS_LIMIT.action":"行数や列数を減らして、もう一度頼み直してください","UNSUPPORTED_OPERATION.message":"この操作には対応していません。","UNSUPPORTED_OPERATION.action":"ほかのツールで代用できる場合はそちらを使ってください。できない場合は、対応していないことを利用者に伝えてください","RESOURCE_BUSY.r_busy.action":"いま実行中の R の処理が終わるのを待ってから、同じツールを同じ引数でもう一度呼んでください。","next.unknown_client_tool":"ツール一覧にあるツールだけを呼んでください。","next.not_found":"その種類のオブジェクトの list か get のツール(たとえば list_data_frames、list_charts、list_analytics、list_notes、list_dashboards)で正しい id を調べてから、もう一度呼んでください。","next.invalid":"このツールの説明と入力スキーマを読み、メッセージに出ている引数を直してから、もう一度ツールを呼んでください。","next.not_ready":"少し待ってから、もう一度ツールを呼んでください。","next.not_allowed":"この会話で作成または読み込んだオブジェクトを使うか、利用者に許可を求めてください。","next.other":"メッセージに出ている原因を直してから、もう一度ツールを呼んでください。同じ失敗が2回続くときは、失敗した内容を利用者に伝えてください。","VERSION_MISMATCH.message":"起動している Exploratory と、このアプリ(MCP ヘルパーまたは expl)のバージョンに互換性がないため、接続できません。","VERSION_MISMATCH.action":"このアプリと同じバージョンの Exploratory を起動するよう、利用者に伝えてください。MCP ヘルパーの場合は、起動している Exploratory から MCP ヘルパーを接続し直すよう伝えてください。そのあと、もう一度実行してください"}')},174(e){"use strict";e.exports=JSON.parse('{"args.missing_value":"Missing value for {name}.","args.invalid_timeout":"Invalid value for --timeout.","args.json_parse":"Could not parse JSON: {error}","args.invalid_value_types":"Invalid value for --{flag}. Expected {types}.","args.invalid_boolean":"Invalid boolean for --{flag}.","args.invalid_item":"Invalid {kind} for --{flag}.","args.unknown_flag":"Unknown flag --{flag} for \\"{prefix} {noun} {verb}\\".","args.did_you_mean_flag":" Did you mean --{flag}?","args.unexpected_argument":"Unexpected argument \\"{token}\\" for \\"{prefix} {noun} {verb}\\".","args.too_many_positional":"Too many positional arguments.","args.invalid_enum":"Invalid value for --{flag}. Expected one of: {values}.","args.invalid_number":"Invalid number for --{flag}.","args.invalid_integer":"Invalid integer for --{flag}.","client.no_response":"Exploratory returned no response to this request.","client.pairing_wait":"Waiting for you to approve expl in Exploratory (a request is shown there)...","output.each_cell":"Each cell: {measure}","output.total":"Total","output.showing_rows":"Showing {shown} of {total} rows.","output.warning":"Warning: {text}","output.error":"Error: {text}","output.start_desktop":"Start Exploratory Desktop, then try again.","state.no_project_named":"No project named \\"{ref}\\". Run \\"expl project list\\".","state.multiple_projects":"Multiple projects named \\"{ref}\\". Use the project id (id and last updated):\\n{ids}","wait.waiting":"Waiting for {capability} ({operationId})...","wait.timed_out":"Timed out. Check progress with: expl execution get {executionId} --operation-id {operationId}","main.version_not_running":"Exploratory: not running","main.status_user":"User: {user}","main.describe_tool":"Tool: {tool}","main.describe_risk":"Risk: {risk}","main.describe_positional":"Positional: {positional}","main.describe_project":"Project: pass --project or set a default with expl project use","main.describe_json_only":"JSON-only properties: {props}","main.describe_required":" [required]","main.describe_example":"Example: {prefix} {noun} {verb}{positional} --json","main.help_usage":"Usage: {prefix} <noun> <verb> [args]","main.help_builtin":"Built-in commands:","main.help_nouns":"Nouns: {nouns}","main.help_start_desktop":"Start Exploratory to list its commands.","main.no_project":"No project. Pass --project <id|name> or run \\"expl project use <id|name>\\".","main.hard_to_undo":"This command is hard to undo. Pass --yes to run it.","main.confirm_prompt":"About to run \\"{prefix} {noun} {verb}\\" ({tool}, risk HIGH). Continue? [y/N]","main.cancelled":"Cancelled.","main.usage_completion":"Usage: expl completion bash|zsh|powershell","main.usage_tools_describe":"Usage: {prefix} tools describe <command|tool_name>","main.unknown_command_or_tool":"Unknown command or tool: {ref}","main.usage_tools":"Usage: {prefix} tools list|describe","main.usage_project_use":"Usage: expl project use <id|name>","main.default_project":"Default project: {name} ({projectId})","main.usage_call":"Usage: {prefix} call <tool_name>","main.unknown_tool":"Unknown tool: {name}","main.unknown_command_noun":"Unknown command: {prefix} {noun}","main.verbs_for":"Verbs for {noun}: {verbs}","main.usage_noun_verb":"Usage: {prefix} {noun} <verb>","main.unknown_command_noun_verb":"Unknown command: {prefix} {noun} {verb}","main.unknown_command_hint":"Unknown command. Run \\"{prefix} tools list\\".","main.did_you_mean":" Did you mean: {prefix} {candidate}?","main.input_parse":"Could not parse --input JSON: {error}","main.image_saved":"Image saved: {path}","main.missing_id":"Missing {flag} <id>. Pass it to \\"{prefix} {noun} {verb}\\", or give the id as the first argument.","main.usage_lang":"Usage: expl lang [en|ja]","main.lang_current":"UI language: {lang}","main.lang_changed":"UI language changed to {lang}.","main.lang_not_changed":"The UI language was not changed: {reason}","main.candidates":"Available {noun} (pick an id):"}')},980(e){"use strict";e.exports=JSON.parse('{"args.missing_value":"{name} の値がありません。","args.invalid_timeout":"--timeout の値が正しくありません。","args.json_parse":"JSON を解析できませんでした: {error}","args.invalid_value_types":"--{flag} の値が正しくありません。{types} を指定してください。","args.invalid_boolean":"--{flag} は true か false で指定してください。","args.invalid_item":"--{flag} の {kind} の値が正しくありません。","args.unknown_flag":"\\"{prefix} {noun} {verb}\\" に --{flag} というフラグはありません。","args.did_you_mean_flag":" --{flag} のことですか?","args.unexpected_argument":"\\"{prefix} {noun} {verb}\\" に不要な引数 \\"{token}\\" があります。","args.too_many_positional":"位置引数が多すぎます。","args.invalid_enum":"--{flag} の値が正しくありません。次のいずれかを指定してください: {values}。","args.invalid_number":"--{flag} は数値で指定してください。","args.invalid_integer":"--{flag} は整数で指定してください。","client.no_response":"Exploratory からこのリクエストへの応答がありません。","client.pairing_wait":"Exploratory で expl の承認を待っています(確認が表示されています)...","output.each_cell":"各セル: {measure}","output.total":"合計","output.showing_rows":"{total} 行中 {shown} 行を表示しています。","output.warning":"警告: {text}","output.error":"エラー: {text}","output.start_desktop":"Exploratory デスクトップを起動してから、もう一度実行してください。","state.no_project_named":"\\"{ref}\\" という名前のプロジェクトはありません。\\"expl project list\\" で確認してください。","state.multiple_projects":"\\"{ref}\\" という名前のプロジェクトが複数あります。プロジェクト ID (ID と最終更新日時) で指定してください:\\n{ids}","wait.waiting":"{capability} ({operationId}) を待っています...","wait.timed_out":"タイムアウトしました。進捗は次のコマンドで確認できます: expl execution get {executionId} --operation-id {operationId}","main.version_not_running":"Exploratory: 起動していません","main.status_user":"ユーザー: {user}","main.describe_tool":"ツール: {tool}","main.describe_risk":"リスク: {risk}","main.describe_positional":"位置引数: {positional}","main.describe_project":"プロジェクト: --project で指定するか、expl project use で既定を設定してください","main.describe_json_only":"JSON のみで指定できる項目: {props}","main.describe_required":" [必須]","main.describe_example":"例: {prefix} {noun} {verb}{positional} --json","main.help_usage":"使い方: {prefix} <名詞> <動詞> [引数]","main.help_builtin":"組み込みコマンド:","main.help_nouns":"名詞: {nouns}","main.help_start_desktop":"コマンド一覧を表示するには Exploratory を起動してください。","main.no_project":"プロジェクトが指定されていません。--project <id|name> を付けるか、\\"expl project use <id|name>\\" を実行してください。","main.hard_to_undo":"このコマンドは元に戻しにくい操作です。実行するには --yes を付けてください。","main.confirm_prompt":"\\"{prefix} {noun} {verb}\\" ({tool}、リスク HIGH) を実行します。続けますか? [y/N]","main.cancelled":"キャンセルしました。","main.usage_completion":"使い方: expl completion bash|zsh|powershell","main.usage_tools_describe":"使い方: {prefix} tools describe <command|tool_name>","main.unknown_command_or_tool":"コマンドまたはツールが見つかりません: {ref}","main.usage_tools":"使い方: {prefix} tools list|describe","main.usage_project_use":"使い方: expl project use <id|name>","main.default_project":"デフォルトのプロジェクト: {name} ({projectId})","main.usage_call":"使い方: {prefix} call <tool_name>","main.unknown_tool":"ツールが見つかりません: {name}","main.unknown_command_noun":"コマンドが見つかりません: {prefix} {noun}","main.verbs_for":"{noun} の動詞: {verbs}","main.usage_noun_verb":"使い方: {prefix} {noun} <動詞>","main.unknown_command_noun_verb":"コマンドが見つかりません: {prefix} {noun} {verb}","main.unknown_command_hint":"コマンドが見つかりません。\\"{prefix} tools list\\" で一覧を確認してください。","main.did_you_mean":" {prefix} {candidate} のことですか?","main.image_saved":"画像を保存しました: {path}","main.input_parse":"--input の JSON を解析できませんでした: {error}","error.DESKTOP_NOT_RUNNING.message":"Exploratory が起動していません。","error.DESKTOP_NOT_RUNNING.action":"Exploratory を起動してから、もう一度実行してください","error.CHANNEL_DISABLED.message":"環境設定で、この接続方法(MCP または CLI)が無効になっています。","error.CHANNEL_DISABLED.action":"Exploratory の 環境設定 > MCP / CLI で有効にしてから、もう一度実行してください","error.NOT_SIGNED_IN.message":"Exploratory にサインインしているユーザーがいません。","error.NOT_SIGNED_IN.action":"Exploratory にサインインしてから、もう一度実行してください","error.UNAUTHORIZED.message":"このアプリケーションは Exploratory で承認されていないか、アクセスが取り消されています。","error.UNAUTHORIZED.action":"もう一度実行してください。Exploratory が承認を求めます(トークンやパスワードを利用者に聞かないでください)","error.PAIRING_PENDING.message":"Exploratory が、このアプリケーションの承認を待っています。","error.PAIRING_PENDING.action":"Exploratory に表示された確認に答えてから、もう一度実行してください","error.PAIRING_REQUIRED.message":"この接続は受け付けられませんでした。","error.PAIRING_REQUIRED.action":"接続が受け付けられなかったことを利用者に伝えてください","error.PROJECT_NOT_OPEN.message":"プロジェクトはありますが、Exploratory で開かれていません。","error.PROJECT_NOT_OPEN.action":"Exploratory でプロジェクトを開いてから、もう一度実行してください","error.NOT_FOUND.message":"指定されたオブジェクトが見つかりません。","error.NOT_FOUND.action":"list_created_artifacts、list_charts、list_analytics で使えるものを確認してください","error.PERMISSION_DENIED.message":"このアプリケーションにはこの操作を行う権限がありません。","error.PERMISSION_DENIED.action":"この操作はこの接続では許可されていないことをユーザーに伝えてください","error.CONFIRMATION_REQUIRED.message":"この操作にはユーザーの確認が必要です。","error.CONFIRMATION_REQUIRED.action":"Exploratory で確認してください","error.CONFIRMATION_DECLINED.message":"ユーザーが Exploratory でこの操作を断りました。","error.CONFIRMATION_DECLINED.action":"同じ操作を繰り返さず、断られたことをユーザーに伝えてください","error.INVALID_PARAMETER.message":"パラメータが正しくありません。","error.INVALID_PARAMETER.action":"expl <名詞> <動詞> --help で指定できる値を確認し、メッセージに出ているパラメータを直して、もう一度実行してください","error.INVALID_COLUMN.message":"指定された列がデータフレームにありません。","error.INVALID_COLUMN.action":"get_data_frame で列を確認してください","error.INVALID_COLUMN_TYPE.message":"この操作には列の型が合いません。","error.INVALID_COLUMN_TYPE.action":"create_wrangling_step で変換した列を追加し (計算で as.character(<列>)、cut(<列>, ...)、<列> == \\"<値>\\" など)、その列を使ってください","error.REVISION_CONFLICT.message":"最後に読み込んだあとで、このオブジェクトが変更されました。","error.REVISION_CONFLICT.action":"もう一度読み込んで内容を確認してから、更新してください","error.EXECUTION_FAILED.message":"Exploratory で操作に失敗しました。","error.EXECUTION_FAILED.action":"メッセージに出ている原因を直して、もう一度実行してください。同じ失敗が続くときは、失敗した内容を確認してください","error.EXECUTION_TIMEOUT.message":"操作が許容時間を超えました。","error.EXECUTION_TIMEOUT.action":"もう一度実行するか、get_execution で結果を確認してください","error.RESOURCE_BUSY.message":"Exploratory が別の操作を実行中です。","error.RESOURCE_BUSY.action":"しばらくしてから、もう一度実行してください","error.DATA_EGRESS_LIMIT.message":"結果が、返せる量を超えています。","error.DATA_EGRESS_LIMIT.action":"行数や列数を減らして、もう一度頼み直してください","error.UNSUPPORTED_OPERATION.message":"この操作には対応していません。","error.UNSUPPORTED_OPERATION.action":"ほかのコマンドで代用できる場合はそちらを使ってください。できない場合は未対応の操作です","main.missing_id":"{flag} <id> が指定されていません。\\"{prefix} {noun} {verb}\\" に渡すか、最初の引数に id を指定してください。","main.usage_lang":"使い方: expl lang [en|ja]","main.lang_current":"UI の言語: {lang}","main.lang_changed":"UI の言語を {lang} に変えました。","main.lang_not_changed":"UI の言語を変えられませんでした: {reason}","main.candidates":"指定できる {noun} (id を選んでください):","error.PDF_EXPORT_FAILED.message":"PDF を作成できませんでした。","error.PDF_EXPORT_FAILED.action":"メッセージに示された原因を直して再実行し、同じ失敗が2回続く場合は失敗内容を利用者に伝えてください","error.PDF_EXPORT_TIMEOUT.message":"PDF の作成が制限時間を超えました。","error.PDF_EXPORT_TIMEOUT.action":"もう一度実行し、再び時間切れになる場合は利用者に伝えてください","error.R_REQUIRED.message":"書き出すための描画結果がまだありません。","error.R_REQUIRED.action":"Exploratory で一度開いて描画してから、もう一度実行してください","error.VERSION_MISMATCH.message":"起動している Exploratory とこの expl のバージョンに互換性がないため、接続できません。","error.VERSION_MISMATCH.action":"この expl と同じバージョンの Exploratory を起動してから、もう一度実行してください"}')}};const t={};function n(r){const o=t[r];if(void 0!==o)return o.exports;const i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}const r=n(982),o=n(896),i=n(857),s=n(928),a=n(18),c=n(49),l=n(823),u=n(965),p=n(736),d=n(107),f=n(42),m=n(351),h=n(587),g=n(654),_=n(134),E=n(677),w=m.createWriter({fd:1,isTTY:a.isatty(1)}),y=m.createWriter({fd:2,isTTY:a.isatty(2)});function N(e){const t=function(){process.exit(e)};Promise.all([w.flush(),y.flush()]).then(t).catch(t)}function O(e){try{y.write(f.t("output.error",{text:e&&e.message?e.message:String(e)})+"\n")}catch(e){}N(1)}process.on("beforeExit",function(){process.exit(process.exitCode||0)}),process.on("uncaughtException",O),process.on("unhandledRejection",O);let x=null;const I={promise:new Promise(function(e){x=e}),waiting:!1};let v=!1;process.on("SIGINT",function(){v=!0,x(),I.waiting||N(130)});const T=process.argv.slice(2),S=c.getUserAccountRootDir().userAccountRootDir,R=l.agentDir(S),A=function(){try{return JSON.parse(o.readFileSync(s.join(__dirname,"..","package.json"),"utf8")).version||"unknown"}catch(e){return"unknown"}}();f.setLang(p.readUILang(R));const b=r.randomBytes(16).toString("hex"),U=T.indexOf("--verbose")>=0?function(e){y.write(e+"\n")}:null,C=_.create({rootDir:S});d.run(T,{client:u.create({agentDir:R,env:process.env,sessionId:b,clientVersion:A,onTrace:U,onPairingWait:function(){y.write(f.t("client.pairing_wait")+"\n")}}),state:E.create({agentDir:R}),rootDir:S,sessionId:b,onTrace:U,server:{state:C,platform:process.platform,createClient:g.create,login:h.login,revoke:h.revoke,userinfo:h.userinfo,refresh:h.refresh,request:null,post:null,httpModule:null,spawn:null},writeFileBytes:function(e,t){o.writeFileSync(e,t)},writeStdoutBytes:function(e){let t=0;for(;t<e.length;)t+=o.writeSync(1,e,t,e.length-t)},stdout:w,stderr:y,stdinIsTTY:a.isatty(0),stdoutIsTTY:a.isatty(1),readStdin:function(){return o.readFileSync(0,"utf8")},readLine:function(){const e=Buffer.alloc(1),t=[];for(;;){let n;try{n=o.readSync(0,e,0,1,null)}catch(e){if("EAGAIN"===e.code)continue;if("EOF"===e.code)break;throw e}if(0===n||10===e[0])break;t.push(e[0])}return Buffer.from(t).toString("utf8").replace(/\r$/,"")},readFile:function(e){return o.readFileSync(e,"utf8")},writeFile:function(e,t){o.writeFileSync(e,t)},makeTmpDir:function(){return o.mkdtempSync(s.join(i.tmpdir(),"expl-"))},pathJoin:s.join,env:process.env,isInterrupted:function(){return v},interrupt:I,version:A}).then(N).catch(O)})();
1
+ (()=>{var e={361(e){const t="modify",n="code",r=[t,n],o=["execute_r_script","add_r_package","ai_wrangle","ask_note_ai"],i={modify:"agent_allow_modify",code:"agent_allow_code"},s="agent_always_allow";e.exports={GROUP_MODIFY:t,GROUP_CODE:n,GROUPS:r,CODE_TOOLS:o,PREF_KEY:i,LEGACY_KEY:s,groupOf:function(e){return o.indexOf(e)>=0?n:t},isAllowed:function(e,t){const n=e?e[i[t]]:void 0;return void 0!==n?!0===n:!!e&&!0===e[s]}}},755(e,t,n){const r=n(317),o=n(982),i=n(896),s=n(928),a="Exploratory MCP",l="credential",c="credential.dpapi",u=/^[A-Za-z0-9_.-]{16,200}$/,p=/^[A-Za-z0-9+/]{16,4096}={0,2}$/,d="powershell.exe",f=["-NoProfile","-NonInteractive","-Command","-"];function m(){}function h(e,t,n){const o=n||{};return new Promise(function(n,i){let a;try{a=r.execFile(e,t,{encoding:"utf8",timeout:3e4,maxBuffer:1048576,windowsHide:!0},function(t,r){if(t){const n=new Error("Command failed: "+s.basename(e));return n.code=t.code,void i(n)}n({stdout:r})})}catch(t){const n=new Error("Command could not start: "+s.basename(e));return n.code=t&&t.code,void i(n)}a.stdin.on("error",m),a.stdin.end(void 0===o.input?void 0:o.input)})}function g(e){for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);if(n<=31||127===n)return!0}return!1}function _(e){return'"'+e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'}function E(e,t,n){try{const r=e.fs.readFileSync(t,"utf8").trim();return n.test(r)?r:null}catch(e){return null}}function w(e,t,n){const r=t+"."+o.randomBytes(4).toString("hex")+".tmp";try{e.fs.mkdirSync(e.agentDir,{recursive:!0,mode:448}),e.fs.writeFileSync(r,n,{mode:384}),e.fs.renameSync(r,t)}catch(n){try{e.fs.unlinkSync(r)}catch(e){}throw new Error("Could not write "+t+" ("+(n&&n.code||"error")+")")}}function y(e,t){try{e.fs.unlinkSync(t)}catch(e){if(!e||"ENOENT"!==e.code)throw new Error("Could not remove "+t+" ("+(e&&e.code||"error")+")")}}function x(e){return["$ErrorActionPreference = 'Stop'","Add-Type -AssemblyName System.Security","$plain = '"+e+"'","$bytes = [Security.Cryptography.ProtectedData]::Protect([Text.Encoding]::UTF8.GetBytes($plain), $null, [Security.Cryptography.DataProtectionScope]::CurrentUser)","[Convert]::ToBase64String($bytes)"].join("\n")+"\n"}function O(e){return["$ErrorActionPreference = 'Stop'","Add-Type -AssemblyName System.Security","$blob = [Convert]::FromBase64String('"+e+"')","$bytes = [Security.Cryptography.ProtectedData]::Unprotect($blob, $null, [Security.Cryptography.DataProtectionScope]::CurrentUser)","[Text.Encoding]::UTF8.GetString($bytes)"].join("\n")+"\n"}const I={darwin:{name:"security",set:function(e,t){const n="add-generic-password -U -s "+_(e.service)+" -a "+_(e.account)+" -w "+_(t)+"\n";return e.execFile("security",["-i"],{input:n}).then(m)},get:function(e){return e.execFile("security",["find-generic-password","-s",e.service,"-a",e.account,"-w"],{}).then(function(e){return e.stdout})},remove:function(e){return e.execFile("security",["delete-generic-password","-s",e.service,"-a",e.account],{}).then(m)}},linux:{name:"secret-tool",set:function(e,t){return e.execFile("secret-tool",["store","--label="+e.service,"service",e.service,"account",e.account],{input:t}).then(m)},get:function(e){return e.execFile("secret-tool",["lookup","service",e.service,"account",e.account],{}).then(function(e){return e.stdout})},remove:function(e){return e.execFile("secret-tool",["clear","service",e.service,"account",e.account],{}).then(m)}},win32:{name:"dpapi",set:function(e,t){return e.execFile(d,f,{input:x(t)}).then(function(t){const n=String(t.stdout).trim();if(!p.test(n))throw new Error("DPAPI did not return a protected blob");w(e,s.join(e.agentDir,c),n+"\n")})},get:function(e){const t=E(e,s.join(e.agentDir,c),p);return null===t?Promise.resolve(null):e.execFile(d,f,{input:O(t)}).then(function(e){return e.stdout})},remove:function(e){try{return y(e,s.join(e.agentDir,c)),Promise.resolve()}catch(e){return Promise.reject(e)}}}};e.exports={create:function(e){const t=e||{},n=void 0===t.service||null===t.service?a:t.service;if("string"!=typeof n||""===n||g(n))throw new Error("service must be a non-empty string without control characters");if("string"!=typeof t.account||""===t.account||g(t.account))throw new Error("account must be a non-empty string without control characters");if("string"!=typeof t.agentDir||""===t.agentDir)throw new Error("agentDir is required");const r=t.platform||process.platform,o=I[r]||null,c={service:n,account:t.account,agentDir:t.agentDir,fs:t.fs||i,execFile:t.execFile||h},p=s.join(c.agentDir,l);return{get:async function(){if(o)try{const e=await o.get(c),t=null==e?"":String(e).trim();if(u.test(t))return t}catch(e){}return E(c,p,u)},set:async function(e){!function(e){if("string"!=typeof e||!u.test(e))throw new Error("The credential is not in the expected format (16 to 200 characters of A-Z a-z 0-9 _ . -)")}(e);let t=!1;if(o)try{return await o.set(c,e),function(e,t){try{y(e,t)}catch(e){}}(c,p),{where:"keychain"}}catch(e){n=e,t=Boolean(n)&&"ENOENT"===n.code}var n;return w(c,p,e+"\n"),o&&!t&&await o.remove(c).catch(m),{where:"file"}},remove:async function(){o&&await o.remove(c).catch(m),y(c,p)},isSecure:async function(){return null===E(c,p,u)},describe:function(){return{backend:o?o.name:"file",service:c.service,account:c.account,file:p}}}},defaultExecFile:h,SECRET_PATTERN:u,DEFAULT_SERVICE:a,CREDENTIAL_FILE:l,CREDENTIAL_DPAPI_FILE:c}},548(e,t,n){const r=n(439),o=["metadata","aggregates","sample","row_level"],i="row_level",s=100,a={"data:sample":"sample","data:row_level":"row_level"},l=["pivot","definition"],c=["data","firstStepSample","lastStepSample"];function u(e,t){let n=e.egress_level||a[e.permission]||"metadata";const r=e.egress_level_by_param||{};return Object.keys(r).forEach(function(e){t&&void 0!==t[e]&&o.indexOf(r[e])>o.indexOf(n)&&(n=r[e])}),n}function p(e,t){return o.indexOf(e)>=o.indexOf(t)}function d(e,t){return Array.isArray(e)?e.forEach(function(e){d(e,t)}):e&&"object"==typeof e&&Object.keys(e).forEach(function(n){const r=e[n];l.indexOf(n)>-1||(c.indexOf(n)>-1&&"string"==typeof r?function(e,t){const n=e.split("\n").filter(function(e){return""!==e});n.length<2||(t.rows+=n.length-1,t.columns=Math.max(t.columns,n[0].split(",").length))}(r,t):"rows"===n&&Array.isArray(r)?(t.rows+=r.length,r.forEach(function(e){const n=Array.isArray(e)?e.length:e&&"object"==typeof e?Object.keys(e).length:1;t.columns=Math.max(t.columns,n)})):d(r,t))}),t}e.exports={normalize:function(e){return o.indexOf(e)>=0?e:i},check:function(e,t,n){if("row_level"===n)return;const o=u(e,t);if(!p(n,o))throw new r("DATA_EGRESS_LIMIT","This application may receive "+n+" only; "+e.capability_id+" returns "+o+" data.",{current_level:n,required_level:o,suggested_actions:[]});if(t&&"number"==typeof t.limit&&"sample"===o&&t.limit>s)throw new r("DATA_EGRESS_LIMIT","At most 100 sample rows can be returned.",{field:"limit",max_rows:s,suggested_actions:["Retry with limit 100 or less"]})},measure:function(e,t,n){const o=d(t,{rows:0,columns:0});if("row_level"===n||0===o.rows)return o;const i=t&&!0===t.row_level?"sample":u(e);if("metadata"===i)throw new r("DATA_EGRESS_LIMIT",e.capability_id+" returned row-level values it is not cleared for.");if(!p(n,i))throw new r("DATA_EGRESS_LIMIT","This application may receive "+n+" only; this result is "+i+" data.",{current_level:n,required_level:i,suggested_actions:[]});const a="sample"===i?s:1e3;if(o.rows>a)throw new r("DATA_EGRESS_LIMIT","The result has "+o.rows+" rows; at most "+a+" may be returned.",{max_rows:a});return o},LEVELS:o,DEFAULT_LEVEL:i,DEFAULT_SAMPLE_ROWS:20,MAX_SAMPLE_ROWS:s,MAX_AGGREGATE_ROWS:1e3,DEFINITION_KEYS:l}},439(e,t,n){const r=n(515),o=-32001,i={DESKTOP_NOT_RUNNING:!0,NOT_SIGNED_IN:!0,UNAUTHORIZED:!0,CHANNEL_DISABLED:!0,PAIRING_PENDING:!0,PAIRING_REQUIRED:!0,PROJECT_NOT_OPEN:!0,NOT_FOUND:!0,PERMISSION_DENIED:!0,CONFIRMATION_REQUIRED:!0,CONFIRMATION_DECLINED:!0,INVALID_PARAMETER:!0,INVALID_COLUMN:!0,INVALID_COLUMN_TYPE:!0,REVISION_CONFLICT:!0,EXECUTION_FAILED:!0,EXECUTION_TIMEOUT:!0,R_REQUIRED:!0,PDF_EXPORT_FAILED:!0,PDF_EXPORT_TIMEOUT:!0,RESOURCE_BUSY:!0,PARTIALLY_CREATED:!0,DATA_EGRESS_LIMIT:!0,UNSUPPORTED_OPERATION:!0,VERSION_MISMATCH:!0,PREVIEW_STALE:!0,GUIDE_REQUIRED:!0};class s extends Error{constructor(e,t,n){if(!i[e])throw new Error("Unknown agent error code: "+e);super(t||r.t("en",e+".message")),this.name="AgentError",this.code=e,this.details=n||{},Object.defineProperty(this,"isDefaultMessage",{value:!t,writable:!0}),Object.defineProperty(this,"actionKey",{value:e+".action",writable:!0})}toJSON(e){const t=Object.assign({},this.details,{error_code:this.code,message:this.isDefaultMessage?r.t(e,this.code+".message"):this.message});return t.suggested_actions||(t.suggested_actions=[r.t(e,this.actionKey)]),t}toJsonRpcResponse(e,t){const n=this.toJSON(t);return{jsonrpc:"2.0",id:void 0===e?null:e,error:{code:o,message:n.message,data:n}}}}s.parseToolErrorText=function(e){const t=e||"",n=t.split("\n"),r=n[0]||"",o=/^([A-Z][A-Z0-9_]+): ([\s\S]*)$/.exec(r);if(o&&i[o[1]]){let e=null;const t=[];let r=n.findIndex(function(e,t){return t>0&&0===e.indexOf("Details: ")});r<0&&(r=n.findIndex(function(e,t){return t>0&&0===e.indexOf("- ")})),r<0&&(r=n.length),o[2]=n.slice(0,r).join("\n").slice(o[1].length+2);for(let r=1;r<n.length;r++){const o=n[r];if(0===o.indexOf("Details: "))try{e=JSON.parse(o.slice(9))}catch(e){}else 0===o.indexOf("- ")&&t.push(o.slice(2))}return{errorCode:o[1],message:o[2],details:e,suggestedActions:t}}return/^Input validation error/.test(t)?{errorCode:"INVALID_PARAMETER",message:t,details:null,suggestedActions:[]}:(/^Output validation error/.test(t),{errorCode:"EXECUTION_FAILED",message:t,details:null,suggestedActions:[]})},s.markRBusy=function(e){return e.details.retryable=!0,e.actionKey="RESOURCE_BUSY.r_busy.action",e},s.markCancelled=function(e){return e.actionKey="EXECUTION_FAILED.cancelled.action",e},s.from=function(e){const t=e&&e.message?String(e.message):String(e);return"There is another R process running."!==t||e instanceof s&&"EXECUTION_FAILED"!==e.code?e instanceof s?e:new s("EXECUTION_FAILED",t):s.markRBusy(new s("RESOURCE_BUSY",t,Object.assign({},e&&e.details)))},s.CODES=Object.freeze(Object.keys(i)),s.JSON_RPC_AGENT_ERROR_CODE=o,s.CONFIRMATION_PENDING_MESSAGE="This operation needs the user's answer in Exploratory: a request is waiting there. Nothing was done.",s.CONFIRMATION_PENDING_ACTION="Tell the user to answer the request in the Exploratory window, then call this tool again with the same arguments",e.exports=s},515(e,t,n){const r={en:n(169),ja:n(719)};e.exports={t:function(e,t){const n=r["ja"===e?"ja":"en"][t];if("string"!=typeof n)throw new Error("Unknown agent error message key: "+t);return n},CATALOGS:r}},85(e){e.exports={PROFILE_MAX_COLUMNS:100,TRANSFORM_OPERATIONS:["filter","create_calculation","summarize"],FILTER_OPERATORS_BY_TYPE:{character:["equalTo","notEqualTo","in","notIn","contains","notContain","startsWith","endsWith","isNA","isNotNA"],numeric:["equalTo","notEqualTo","in","notIn","lessThan","lessThanOrEqualTo","greaterThan","greaterThanOrEqualTo","isNA","isNotNA"]},SUMMARIZE_FUNCTIONS:["count","sum","mean","median","min","max","sd","var","n_distinct","NUM_NA","NUM_NON_NA","first","last"],NUMERIC_SUMMARIZE_FUNCTIONS:["sum","mean","median","sd","var"],ANALYTICS_TYPES:["do_cor","exp_chisq","build_lm.fast","logistic"],ANALYTICS_RESULT_TABLES:{do_cor:["analysis_conditions","heatmap"],exp_chisq:["chisq_table","residual_table","contrib_table"],"build_lm.fast":["summary_table","coefficient_table","feature_importance_bar"],logistic:["summary_table","model_fit_table","coefficient_table","confusion_matrix"]},CHART_TYPES:["bar","line","scatter","hist","boxplot"],PIVOT_MARKER:"pivot",DEFAULT_RESULT_ROWS:200,LONG_RUNNING_TIMEOUT_MS:18e5,WINDOW_BUSY_WAIT_MS:3e4,MAX_OPERATION_WAIT_MS:25e3,toolTimeoutMsFromSeconds:function(e){const t=Number(e);return null==e||""===e||!Number.isFinite(t)||t<=0?null:Math.min(Math.round(1e3*t),18e5)}}},823(e,t,n){const r=n(896),o=n(928),i=n(548),s=n(361),a={};e.exports={read:function(e){const t=o.join(e,"userconf.json");let n;try{n=JSON.parse(r.readFileSync(t,"utf8")),a[t]=n}catch(e){n=a[t]||{}}const l="string"==typeof n.user&&""!==n.user;return{uiLang:n.ui_lang||"en",traceAllowed:!1!==n.enable_ai_features,allow:{modify:s.isAllowed(n,s.GROUP_MODIFY),code:s.isAllowed(n,s.GROUP_CODE)},channels:{mcp:{enabled:!0===n.agent_mcp_enabled,write:!0===n.agent_mcp_write,egress:i.normalize(n.agent_mcp_egress)},cli:{enabled:!0===n.agent_cli_enabled,write:!0===n.agent_cli_write,egress:i.normalize(n.agent_cli_egress)}},user:l?{username:n.user,firstname:"string"==typeof n.firstname?n.firstname:"",lastname:"string"==typeof n.lastname?n.lastname:""}:null}},agentDir:function(e){return o.join(e,"agent")}}},495(e,t,n){const r=n(213),{ExplError:o}=n(877),{t:i}=n(42),s=[{key:"project",names:["--project"],value:!0},{key:"json",names:["--json"],value:!1},{key:"yes",names:["--yes","-y"],value:!1},{key:"noWait",names:["--no-wait"],value:!1},{key:"timeoutSec",names:["--timeout"],value:!0},{key:"quiet",names:["--quiet","-q"],value:!1},{key:"verbose",names:["--verbose"],value:!1},{key:"input",names:["--input"],value:!0},{key:"output",names:["--output"],value:!0},{key:"help",names:["--help","-h"],value:!1},{key:"version",names:["--version"],value:!1}];function a(e,t){const n=String(e),r=String(t),o=n.length,i=r.length;if(!o)return i;if(!i)return o;const s=new Array(i+1);for(let e=0;e<=i;e++)s[e]=e;for(let e=1;e<=o;e++){let t=s[0];s[0]=e;for(let o=1;o<=i;o++){const i=s[o];s[o]=n[e-1]===r[o-1]?t:1+Math.min(t,s[o],s[o-1]),t=i}}return s[i]}function l(e,t){return t.map(function(t){return{name:t,d:a(e,t)}}).filter(function(e){return e.d<=2}).sort(function(e,t){return e.d-t.d||e.name.localeCompare(t.name)}).slice(0,3).map(function(e){return e.name})}function c(e,t,n,r){const a=r||s;for(let r=0;r<a.length;r++){const s=a[r];for(let r=0;r<s.names.length;r++){const a=s.names[r];if(e===a){if(s.value){const e=t[n+1];if(void 0===e)throw new o("USAGE",i("args.missing_value",{name:a}));return{key:s.key,value:e,nextIndex:n+2}}if("json"===s.key&&"string"==typeof t[n+1]&&"{"===t[n+1].charAt(0))throw new o("USAGE",i("args.json_is_output"));return{key:s.key,value:!0,nextIndex:n+1}}if(0===a.indexOf("--")&&0===e.indexOf(a+"="))return{key:s.key,value:e.slice(a.length+1),nextIndex:n+1}}}return null}function u(e,t,n){if("url"!==t&&"output"!==t)if("noBrowser"!==t)if("withToken"!==t){if("timeoutSec"===t){const t=Number(n);if(!Number.isFinite(t))throw new o("USAGE",i("args.invalid_timeout"));return void(e.timeoutSec=t)}e[t]="project"!==t&&"input"!==t&&"output"!==t||n}else e.withToken=!0;else e.noBrowser=!0;else e[t]=n}function p(e,t,n){return n&&0===e.indexOf("@")&&e.length>1?t.readFile(e.slice(1)):e}function d(e,t){const n=0===e.indexOf("@")&&e.length>1?t.readFile(e.slice(1)):e;try{return JSON.parse(n)}catch(e){throw new o("USAGE",i("args.json_parse",{error:e.message}))}}function f(e,t){const n=t.unionTypes||[];if("null"===e&&n.indexOf("null")>=0)return null;if(("true"===e||"false"===e)&&n.indexOf("boolean")>=0)return"true"===e;const r=Number(e);if(""!==e&&Number.isFinite(r)&&(n.indexOf("number")>=0||n.indexOf("integer")>=0&&Number.isInteger(r)))return r;if(n.indexOf("string")>=0)return e;throw new o("USAGE",i("args.invalid_value_types",{flag:t.name,types:n.join(" or ")}))}function m(e){const t=e.trim();if("["===t.charAt(0)&&"]"===t.charAt(t.length-1))return!0;const n=e.split(",");return n.length>1&&n.every(function(e){return""!==e.trim()})}function h(e,t,n){if("boolean"===t.itemKind){if("true"!==e&&"false"!==e)throw new o("USAGE",i("args.invalid_boolean",{flag:t.name}));return"true"===e}if("number"===t.itemKind||"integer"===t.itemKind){const n=Number(e);if(""===e||!("integer"===t.itemKind?Number.isInteger(n):Number.isFinite(n)))throw new o("USAGE",i("args.invalid_item",{kind:t.itemKind,flag:t.name}));return n}return p(e,n,!0)}function g(e,t,n,r){const s=l(t,n.map(function(e){return e.name}));let a=i("args.unknown_flag",{prefix:r,flag:t,noun:e.noun,verb:e.verb});return s.length&&(a+=i("args.did_you_mean_flag",{flag:s[0]})),new o("USAGE",a)}function _(e,t,n,s,a,l){const c={prefix:a,token:t,noun:e.noun,verb:e.verb},u=l>=1?n[l-1]:"",p=0===u.indexOf("--")&&u.indexOf("=")>0?u.slice(2,u.indexOf("=")):l>=2&&0===n[l-2].indexOf("--")&&n[l-2].indexOf("=")<0?n[l-2].slice(2):null,d=e.flags.filter(function(e){return"scalarArray"===e.kind&&e.name===p})[0];if(d)return new o("USAGE",i("args.array_extra_value",Object.assign({flag:d.name},c)));const f=e.flags.filter(function(e){return!(void 0!==s[e.prop]||n.some(function(t){return t==="--"+e.name||0===t.indexOf("--"+e.name+"=")}))}),m=function(e){return"string"===e.kind&&!e.enumValues},h=f.filter(function(e){return e.required});let g=[];return 1===h.length?g=h.filter(m):e.flags.some(function(e){return e.required})||(g=f.filter(function(e){return m(e)&&r.isEntityIdProp(e.prop)})),1!==g.length?new o("USAGE",i("args.unexpected_argument",c)):(c.flag=g[0].name,c.shape=r.isEntityIdProp(g[0].prop)?"id":"value",new o("USAGE",i("args.unexpected_argument_flag",c)))}e.exports={GLOBAL_FLAG_SPECS:s,SERVER_FLAG_SPECS:[{key:"url",names:["--url"],value:!0},{key:"withToken",names:["--with-token"],value:!1},{key:"output",names:["--output","-o"],value:!0},{key:"noBrowser",names:["--no-browser"],value:!1}],splitGlobals:function(e,t){const n=t?s.concat(t):s,r={project:null,json:!1,yes:!1,noWait:!1,timeoutSec:null,quiet:!1,verbose:!1,input:null,output:null,help:!1,version:!1};t&&t.forEach(function(e){r[e.key]=!!e.value&&null});const o=e.indexOf("--"),i=o>=0?e.slice(0,o):e.slice(),a=o>=0?e.slice(o+1):[],l=[];let p=0;for(;p<i.length;){const e=c(i[p],i,p,n);e?(u(r,e.key,e.value),p=e.nextIndex):(l.push(i[p]),p++)}for(let e=0;e<a.length;e++)l.push(a[e]);return{globals:r,rest:l}},toToolArgs:function(e,t,n,r,s){s=s||"expl";const a=Object.assign({},r||{}),l=Object.create(null);e.flags.forEach(function(e){l[e.name]=e});let c=!1,u=0;for(;u<t.length;){const r=t[u];if(0!==r.indexOf("--")){if(!e.positional)throw _(e,r,t,a,s,u);if(c)throw new o("USAGE",i("args.too_many_positional"));a[e.positional]=r,c=!0,u++;continue}let E=r.slice(2),w=null;const y=E.indexOf("=");y>=0&&(w=E.slice(y+1),E=E.slice(0,y));let x=null,O=!0;if(0===E.indexOf("no-")){const e=E.slice(3),t=l[e];t&&"boolean"===t.kind&&(x=t,O=!1,E=e)}if(x||(x=l[E]),!x)throw g(e,E,e.flags,s);if("boolean"===x.kind){const e=null!==w?w:t[u+1];if(u++,"true"===e||"false"===e)O=O&&"true"===e,null===w&&u++;else if(null!==w||/^(yes|no|on|off|1|0|true|false)$/i.test(e||""))throw new o("USAGE",i("args.bool_value",{flag:x.name,value:e}));a[x.prop]=O;continue}let I=w;if(null===I){if(I=t[u+1],void 0===I)throw new o("USAGE",i("args.missing_value",{name:"--"+x.name}));u+=2}else u++;if("string"===x.kind){const e=p(I,n,!0);if(x.enumValues&&x.enumValues.indexOf(e)<0)throw new o("USAGE",i("args.invalid_enum",{flag:x.name,values:x.enumValues.join(", ")}));a[x.prop]=e;continue}if("number"===x.kind){const e=Number(I);if(!Number.isFinite(e))throw new o("USAGE",i("args.invalid_number",{flag:x.name}));a[x.prop]=e;continue}if("integer"===x.kind){const e=Number(I);if(!Number.isInteger(e))throw new o("USAGE",i("args.invalid_integer",{flag:x.name}));a[x.prop]=e;continue}if(x.enumValues&&x.enumValues.indexOf(I)<0)throw new o("USAGE",i("args.invalid_enum",{flag:x.name,values:x.enumValues.join(", ")}));if("scalarArray"===x.kind){if("@"!==I.charAt(0)&&m(I))throw new o("USAGE",i("args.array_as_list",{flag:x.name,prop:x.prop}));const e=h(I,x,n);Array.isArray(a[x.prop])||(a[x.prop]=[]),a[x.prop].push(e);continue}"json"!==x.kind?"scalarUnion"!==x.kind?a[x.prop]=d(I,n):a[x.prop]=f(I,x):a[x.prop]=d(I,n)}return function(e,t,n,r){e.flags.forEach(function(s){if(void 0!==t[s.prop]){if(s.insteadOf&&(n||e.positional&&void 0!==t[e.positional])){const t=r+" "+e.noun+(e.verb?" "+e.verb:"")+" --"+s.name+" '"+(s.example||"<value>")+"'";throw new o("USAGE",i("args.instead_of_positional",{flag:s.name,positional:s.insteadOf,example:t}))}if(s.requiredWhen&&t[s.requiredWhen.prop]!==s.requiredWhen.value){const t=e.flags.filter(function(e){return e.prop===s.requiredWhen.prop})[0];throw new o("USAGE",i("args.needs_flag_value",{flag:s.name,other:t?t.name:s.requiredWhen.prop,value:s.requiredWhen.value}))}}})}(e,a,c,s),a},suggest:l}},965(e,t,n){const r=n(982),o=n(262),i=n(287),s=n(755),a=n(439),{ExplError:l,fromJsonRpcError:c,fromToolResult:u}=n(877),{t:p,getLang:d}=n(42),f="expl",m="x-exploratory-include-tool-meta",h="x-exploratory-tool-timeout-sec";e.exports={create:function(e){const t=e.agentDir,n=e.env||{},g=e.sessionId,_=e.clientVersion,E=e.onTrace;let w=0;const y=e.credentials||i.create({env:n,channel:"cli",store:s.create({agentDir:t,account:"cli-"+r.createHash("sha256").update(t).digest("hex").slice(0,12)}),pair:function(e){const n=o.readEndpoint(t);return n?o.requestPairing({socketPath:n.socket,channel:"cli",name:e}):Promise.resolve(null)}});let x=!1;function O(n,r,i){const s=o.readEndpoint(t);return s?y.resolve(f,{maxWaitMs:12e4,onPending:function(){!x&&e.onPairingWait&&(x=!0,e.onPairingWait())}}).then(function(e){if(e.token)return e;if("pending"===e.pairing)throw new l("PAIRING_PENDING");if("declined"===e.pairing)throw new l("PAIRING_REQUIRED");if("error"===e.pairing&&e.error)throw new l(e.error,null,null,new a(e.error).toJSON("en").suggested_actions);throw new l("DESKTOP_NOT_RUNNING")}).then(function(e){return function(e,t,n,r,i){const s=++w,a={jsonrpc:"2.0",id:s,method:n,params:r},u=JSON.stringify(a),m=function(e,t){const n={Host:"localhost",Accept:"application/json, text/event-stream","Content-Type":"application/json","x-exploratory-client-name":f,"x-exploratory-client-version":_,"x-exploratory-guide-session":g,"x-exploratory-ui-lang":d()};return t&&(n.Authorization="Bearer "+t),e&&Object.assign(n,e),n["x-exploratory-channel"]="cli",n}(i,t.token);m["Content-Length"]=Buffer.byteLength(u);let h=null;const x=[];return o.post({socketPath:e.socket,headers:m,body:u,onMessage:function(e){x.push(e),e&&e.id===s&&(h=e)}}).then(function(e){if(E&&E(JSON.stringify({method:n,params:r,id:s,messages:x})),e.connectError||!e.complete)throw new l("DESKTOP_NOT_RUNNING");if(!h)throw new l("EXECUTION_FAILED",p("client.no_response"));if(h.error){const e=c(h.error);throw"UNAUTHORIZED"===e.errorCode&&y.forget(t),e}return h.result})}(s,e,n,r,i)}):Promise.reject(new l("DESKTOP_NOT_RUNNING"))}return{listTools:function(){const e=[];let t=null;const n=function(){return O("tools/list",t?{cursor:t}:{},{[m]:"true"}).then(function(r){return r&&r.tools&&e.push.apply(e,r.tools),t=r&&r.nextCursor?r.nextCursor:null,t?n():e})};return n()},callTool:function(e,t,n){return O("tools/call",{name:e,arguments:t||{}},n&&n.timeoutSec>0?{[h]:String(n.timeoutSec)}:void 0).then(function(e){if(e&&e.isError)throw u(e);return e})},initialize:function(){return O("initialize",{protocolVersion:"2025-11-25",capabilities:{},clientInfo:{name:f,version:_}}).then(function(e){return{instructions:"string"==typeof e.instructions?e.instructions:null,serverInfo:e.serverInfo||{}}})}}}}},213(e,t,n){const r=n(484),o=["project","json","yes","no-wait","timeout","quiet","verbose","input","help","version"],i="confirmed_by_user";function s(e){return String(e).replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}function a(e){return!(!e||"object"!=typeof e)&&("string"===e.type||"number"===e.type||"integer"===e.type||"boolean"===e.type||"null"===e.type||(Array.isArray(e.type)?e.type.every(function(e){return"string"===e||"number"===e||"integer"===e||"boolean"===e||"null"===e}):!!Array.isArray(e.anyOf)&&e.anyOf.length>0&&e.anyOf.every(a)))}function l(e){return Array.isArray(e.anyOf)?e.anyOf.reduce(function(e,t){return e.concat(l(t))},[]):[].concat(e.type)}function c(e){if("boolean"===e.type)return{kind:"boolean",itemKind:null,enumValues:null};if("string"===e.type||"number"===e.type||"integer"===e.type)return{kind:e.type,itemKind:null,enumValues:e.enum||null};if("array"===e.type&&e.items){const t=e.items.type;return"string"===t||"number"===t||"integer"===t||"boolean"===t?{kind:"scalarArray",itemKind:t,enumValues:null}:{kind:"json",itemKind:null,enumValues:null}}return"object"===e.type?{kind:"json",itemKind:null,enumValues:null}:a(e)?{kind:"scalarUnion",itemKind:null,enumValues:null,unionTypes:l(e)}:{kind:"json",itemKind:null,enumValues:null}}function u(e){return("id"===e||/(_id|[a-z]Id)$/.test(e))&&"project_id"!==e}function p(e){return String(e).replace(/(_id|Id)$/,"").replace(/_/g,"").toLowerCase()}function d(e,t){const n=t||o,a=e._meta&&e._meta["exploratory/capability_id"];if(!a)throw new Error("Tool "+e.name+" is missing exploratory/capability_id");let l,d;if(a.indexOf(".")<0)l=a,d="";else{const e=a.indexOf(".");l=a.slice(0,e),d=s(a.slice(e+1))}const f=e.inputSchema||{},m=f.properties||{},h=f.required||[],g=h.filter(u),_=Object.prototype.hasOwnProperty.call(m,"project_id"),E=e._meta&&e._meta["exploratory/positional"];let w=null;if(E&&Object.prototype.hasOwnProperty.call(m,E))w=E;else if(1===g.length)w=g[0];else if(0===g.length){const e=Object.keys(m).filter(function(e){return u(e)&&p(e)===l});1===e.length&&(w=e[0])}"project"===l&&_&&0===g.length&&(w="project_id");const y=[],x=[],O=new Set;return Object.keys(m).forEach(function(t){if("project_id"===t||t===i)return;const o=s(t);if(n.indexOf(o)>=0)return void y.push(t);if(O.has(o))throw new Error("Duplicate flag "+o+" on tool "+e.name);O.add(o);const a=c(m[t]);"json"===a.kind&&(a.shape=r.shapeLines(m[t],f),a.example=r.exampleJson(m[t],f,t));const l=m[t].description||"",u=/INSTEAD of (\w+)/.exec(l),p=/required when (\w+)=(\w+)/.exec(l);x.push(Object.assign({name:o,prop:t,required:h.indexOf(t)>=0,description:l,insteadOf:u&&u[1]===w?w:null,requiredWhen:p&&Object.prototype.hasOwnProperty.call(m,p[1])?{prop:p[1],value:p[2]}:null},a))}),{noun:l,verb:d,toolName:e.name,capabilityId:a,risk:e._meta["exploratory/risk"]||"LOW",readOnly:!(!e.annotations||!e.annotations.readOnlyHint),description:String(e.description||"").replace(/ Exploratory tool definitions version: [0-9a-f]{8}\.$/,""),summary:r.firstSentence(e.description),inputSchema:f,positional:w,flags:x,jsonOnly:y,requiresProject:_,projectOptional:_&&h.indexOf("project_id")<0,confirmsByUser:Object.prototype.hasOwnProperty.call(m,i)}}e.exports={GLOBAL_FLAGS:o,SERVER_FLAGS:["url","output","no-browser","with-token"],RESERVED_NOUNS:["call","status","tools","help","version","completion","skill","lang"],RESERVED_COMMANDS:["project use"],kebab:s,isEntityIdProp:u,commandFromTool:d,entityOfIdProp:p,build:function(e,t){const n=(t=t||{}).globalFlags||o,r=[],i=Object.create(null),s=Object.create(null);return e.forEach(function(e){const t=d(e,n),o=t.noun+"\0"+t.verb;if(i[o])throw new Error("Duplicate command "+t.noun+" "+t.verb+" for tools "+i[o].toolName+" and "+e.name);i[o]=t,s[e.name]=t,r.push(t)}),{commands:r,find:function(e,t){return i[e+"\0"+t]||null},byToolName:function(e){return s[e]||null}}},classifyFlag:c}},648(e,t,n){const r=n(213),o={bash:['# expl completion for bash. Add to ~/.bashrc: eval "$(expl completion bash)"',"_expl() {"," # Slice the words before IFS changes: bash 3.2 (the macOS default) joins a quoted ${a[@]:1:n} slice into one word",' # when IFS has no space, so `expl dashboard pu` would reach __complete as the single argument "dashboard pu".',' local words=("${COMP_WORDS[@]:1:COMP_CWORD}")'," local IFS=$'\\n'",' COMPREPLY=($(expl __complete "${words[@]}" 2>/dev/null))',"}","complete -o default -F _expl expl"],zsh:['# expl completion for zsh. Add to ~/.zshrc: eval "$(expl completion zsh)"',"_expl() {"," local -a candidates",' candidates=("${(@f)$(expl __complete "${(@)words[2,CURRENT]}" 2>/dev/null)}")'," compadd -a candidates","}","compdef _expl expl"],powershell:["# expl completion for PowerShell. Add to $PROFILE: expl completion powershell | Out-String | Invoke-Expression","Register-ArgumentCompleter -Native -CommandName expl -ScriptBlock {"," param($wordToComplete, $commandAst, $cursorPosition)"," $words = @($commandAst.CommandElements | Select-Object -Skip 1 | ForEach-Object { $_.ToString() })"," if ($wordToComplete -eq '') { $words += '' }"," expl __complete @words 2>$null | ForEach-Object {"," [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)"," }","}"]},i={tools:["describe","list"],completion:["bash","powershell","zsh"],token:["create","list","revoke"]},s=["call","completion","help","lang","skill","status","tools"],a=["call","help","login","logout","skill","status","token","tools"];e.exports={script:function(e){return o[e]?o[e].join("\n")+"\n":null},complete:function(e,t,n){if("server"===e[0])return function(e,t){const n=t?t.commands:[],o=e.length?e[e.length-1]:"",s=e.slice(0,-1);let l=[];if(0===s.length)l=a.concat(n.map(function(e){return e.noun}));else if(1===s.length){const e=s[0];l=(i[e]||[]).concat(n.filter(function(t){return t.noun===e}).map(function(e){return e.verb}).filter(Boolean)),"call"===e&&(l=n.map(function(e){return e.toolName}))}else if(0===o.indexOf("-")){const e="call"===s[0]?t&&t.byToolName(s[1]):t&&t.find(s[0],s[1]||""),n=e?e.flags.map(function(e){return"boolean"===e.kind?["--"+e.name,"--no-"+e.name]:["--"+e.name]}):[];l=[].concat.apply([],n).concat(r.SERVER_FLAGS.map(function(e){return"--"+e}))}return l.filter(function(e,t){return l.indexOf(e)===t&&0===e.indexOf(o)}).sort()}(e.slice(1),n);const o=t?t.commands:[],l=e.length?e[e.length-1]:"",c=e.slice(0,-1);let u=[];if(0===c.length)u=s.concat(["server"]).concat(o.map(function(e){return e.noun}));else if(1===c.length){const e=c[0];u=(i[e]||[]).concat(o.filter(function(t){return t.noun===e}).map(function(e){return e.verb})),"project"===e&&u.push("use"),"call"===e&&(u=o.map(function(e){return e.toolName}))}else if(0===l.indexOf("-")){const e="call"===c[0]?t&&t.byToolName(c[1]):t&&t.find(c[0],c[1]),n=e?e.flags.map(function(e){return"boolean"===e.kind?["--"+e.name,"--no-"+e.name]:["--"+e.name]}):[];u=[].concat.apply([],n).concat(r.GLOBAL_FLAGS.map(function(e){return"--"+e}))}return u.filter(function(e,t){return u.indexOf(e)===t&&0===e.indexOf(l)}).sort()},BUILTIN_TOP:s,BUILTIN_VERBS:i}},440(e){function t(e,t){return[e.map(function(e){return e&&"object"==typeof e?e.name:e})].concat(t).map(function(e){return e.map(function(e){return t=null==(n=e)?"":"object"==typeof n?JSON.stringify(n):String(n),/[",\r\n]/.test(t)?'"'+t.replace(/"/g,'""')+'"':t;var t,n}).join(",")+"\n"}).join("")}e.exports={rowsToCsv:t,queryResultToCsv:function(e){return e&&"object"==typeof e&&Array.isArray(e.columns)&&Array.isArray(e.rows)&&e.rows.every(Array.isArray)?t(e.columns,e.rows):null},UTF8_BOM:"\ufeff"}},877(e,t,n){const r=n(439),o=n(42);class i extends Error{constructor(e,t,n,i){const s=o.localizeErrorDefaults(e,t,i||[]);let a=s.message;if(!a)try{a=new r(e).message}catch(t){a=e}super(a),this.name="ExplError",this.errorCode=e,this.details=n||null,this.suggestedActions=s.actions}}e.exports={ExplError:i,exitCodeFor:function(e){return"USAGE"===e?2:"INTERRUPTED"===e?130:"BROKEN_PIPE"===e?0:"SERVER_UNREACHABLE"===e||"DESKTOP_NOT_RUNNING"===e?3:"NOT_LOGGED_IN"===e||"NOT_SIGNED_IN"===e||"UNAUTHORIZED"===e||"PERMISSION_DENIED"===e||"PAIRING_REQUIRED"===e||"CHANNEL_DISABLED"===e?4:1},fromJsonRpcError:function(e){const t=e&&e.data?e.data:{},n=t.error_code||"EXECUTION_FAILED",r=t.suggested_actions||[],o=Object.assign({},t);delete o.error_code,delete o.message,delete o.suggested_actions;const s=Object.keys(o);return new i(n,e.message||t.message,s.length?o:null,r)},fromToolResult:function(e){const t=e&&e.content&&e.content[0]&&e.content[0].text,n=e&&e.structuredContent||function(e){if("string"!=typeof e||"{"!==e.charAt(0))return null;try{const t=JSON.parse(e);return t&&"object"==typeof t?t:null}catch(e){return null}}(t),o=n&&n.error;if(o&&"object"==typeof o&&"string"==typeof o.code){const e=Object.assign({},o);return delete e.code,delete e.message,new i(o.code,o.message||o.code,Object.keys(e).length?e:null,[])}if(n&&"string"==typeof n.error_code){const e=Object.assign({},n);delete e.error_code,delete e.message,delete e.suggested_actions;const t=Object.keys(e);return new i(n.error_code,n.message||n.error_code,t.length?e:null,n.suggested_actions||[])}const s=r.parseToolErrorText(t||"");return new i(s.errorCode,s.message,s.details,s.suggestedActions)},fromHttpAuthError:function(e){const t=403===e.statusCode?"PERMISSION_DENIED":"login"===e.source?"NOT_LOGGED_IN":"UNAUTHORIZED";let n="The server rejected the token.";const r=e.wwwAuthenticate||"",o=r.match(/error_description="([^"]*)"/i)||r.match(/error_description=([^,\s]+)/i);return o&&o[1]&&(n=o[1].replace(/\\"/g,'"')),new i(t,n,{source:e.source},[])},fromHttpRateLimit:function(e){let t=e;if("string"==typeof e||null==e)try{t=JSON.parse(e||"")}catch(e){t=null}const n=t&&"string"==typeof t.error_description?t.error_description:"";return new i("RATE_LIMITED",n||"The server is limiting requests from this address. Try again later.")}}},736(e,t,n){const r=n(896),o=n(928),i="ja",s="en";e.exports={readUILang:function(e,t){try{const n=(t||r).readFileSync(o.join(e,"..","userconf.json"),"utf8");return JSON.parse(n).ui_lang===i?i:s}catch(e){return s}},JAPANESE:i,ENGLISH:s}},107(e,t,n){const r=n(439),o=n(495),i=n(213),s=n(648),a=n(351),l=n(876),c=n(821),u=n(677),p=n(947),{ExplError:d,exitCodeFor:f}=n(877),{t:m,setLang:h}=n(42),g={status:!0,tools:!0,call:!0,help:!0,skill:!0,completion:!0,lang:!0},_=["en","ja"];function E(e,t){t.stdout&&e.stdout.write(t.stdout),t.stderr&&e.stderr.write(t.stderr)}function w(e,t,n){const r=e instanceof d?e:new d("EXECUTION_FAILED",e&&e.message?e.message:String(e));return"BROKEN_PIPE"===r.errorCode||E(t,a.renderError(r,{json:n})),f(r.errorCode)}function y(e){return i.build(e)}async function x(e){try{return(await e.callTool("get_environment",{})).structuredContent||null}catch(e){return null}}function O(e){return e.noun+(e.verb?" "+e.verb:"")}function I(e){return"--"+e.name+" <value> --"+e.name+" <value>"}function v(e){const t=e.flags.filter(function(t){return t.prop!==e.positional}).map(function(e){return"--"+e.name+("scalarArray"===e.kind?" <value>...":"")});return(e.positional?" <"+e.positional+">":"")+(t.length?" ["+t.join(" ")+"]":"")}function N(e,t){return e.commands.filter(function(e){return e.noun===t}).map(function(e){return e.verb||"(default)"})}function T(e){return e.reduce(function(e,t){return e||t.flags.filter(function(e){return"scalarArray"===e.kind})[0]},null)}function S(e,t){const n=[(t=t||"expl")+" "+O(e)+" -- "+e.description,"",m("main.describe_tool",{tool:e.toolName}),m("HIGH"===e.risk&&"expl"===t?"main.describe_risk_high":"main.describe_risk",{risk:e.risk}),m("main.call_args_note")];return e.positional&&n.push(m("main.describe_positional",{positional:e.positional})),e.requiresProject&&n.push(m("main.describe_project")),e.jsonOnly.length&&n.push(m("main.describe_json_only",{props:e.jsonOnly.join(", ")})),e.flags.forEach(function(e){let t=" --"+e.name+" ("+e.kind+")"+(e.required?m("main.describe_required"):"");e.enumValues&&(t+=" enum: "+e.enumValues.join(", ")),e.description&&(t+=" -- "+e.description),n.push(t),"scalarArray"===e.kind&&n.push(" "+m("main.describe_array_repeat",{repeat:I(e)})),e.shape&&(n.push(" "+m("main.describe_shape")),e.shape.forEach(function(e){n.push(" "+e)}),n.push(" "+m("main.describe_flag_example",{example:e.example})))}),e.flags.filter(function(e){return e.insteadOf&&e.example}).forEach(function(r){n.push("",m("main.describe_example_instead",{prefix:t,noun:e.noun,verb:e.verb,flag:r.name,example:r.example,positional:r.insteadOf}))}),n.push("",m("main.describe_example",{prefix:t,noun:e.noun,verb:e.verb,positional:e.positional?" <"+e.positional+">":""})),n.join("\n")+"\n"}function A(e,t,n){return e.compactHelp?function(e,t,n){const r=e.commands.filter(function(e){return e.noun===t}),o=[m("main.verbs_of_noun",{noun:t})];r.forEach(function(e){o.push(" "+O(e)+v(e)," "+e.summary)});const i=T(r);return i&&o.push("",m("main.help_array_note",{repeat:I(i)})),o.push("",m("main.verbs_detail",{prefix:n,noun:t})),o.join("\n")}(e.tree,t,n):m("main.verbs_for",{noun:t,verbs:N(e.tree,t).join(", ")})}function R(e){const t=e.tree,n=[m("main.help_usage",{prefix:e.prefix||"expl"}),""];if(e.guidance&&n.push(e.guidance.instructions?e.guidance.instructions.trim():m(e.guidanceMissingKey||"main.guidance_missing",{reason:e.guidance.error}),""),n.push(m("main.help_builtin")),(e.builtinHelp||[" expl status"," expl tools list|describe"," expl project use <id|name>"," expl call <tool_name>"," expl skill"," expl completion bash|zsh|powershell"," expl lang [en|ja]"," expl help"]).forEach(function(e){n.push(e)}),n.push(""),t.commands.length){const r=[];if(t.commands.forEach(function(e){r.indexOf(e.noun)<0&&r.push(e.noun)}),r.sort(),e.compactHelp)n.push(m("main.help_commands_compact",{prefix:e.prefix||"expl"})),r.forEach(function(e){n.push(e+":"),t.commands.filter(function(t){return t.noun===e}).forEach(function(e){n.push(" "+(e.verb||"(default)")+" "+function(e){if(e=e.replace(/^(?:できること|What it can do):\s*/,""),a.displayWidth(e)<=50)return e;let t="";for(const n of e){if(a.displayWidth(t+n)>49)break;t+=n}return t+"…"}(e.summary))})}),n.push("",m("main.help_more",{prefix:e.prefix||"expl"}));else if(n.push(m("main.help_nouns",{nouns:r.join(", ")})),e.commandSummaries){n.push("",m("main.help_commands")),t.commands.forEach(function(e){n.push(" "+O(e)+v(e)," "+e.summary)});const e=T(t.commands);e&&n.push("",m("main.help_array_note",{repeat:I(e)}))}}else e.up||n.push(e.downHint||m("main.help_start_desktop"));return n.join("\n")+"\n"}async function b(e,t){const n=(await e.callTool("list_projects",{})).structuredContent||{},r=n.projects||n.items||[];return u.resolveProject(t,r)}async function U(e,t){const n=t.project||e.env.EXPL_PROJECT||e.state.readDefaultProject();if(n)return(await b(e.client,n)).project_id;const r=await x(e.client),o=r&&r.open_projects||[];if(!o.length)throw new d("USAGE",m("main.no_project"));return o[0].project_id}async function C(e,t){const n=e.deps,r=e.globals,i=e.json,s=e.tree,a=e.prefix||"expl";if(r.help&&0===t.length)return E(n,{stdout:R(e),stderr:""}),0;const l=t.slice(),c=l.shift();if(!c)return E(n,{stdout:R(e),stderr:""}),0;if("tools"===c){const t=l.shift();if("list"===t)return E(n,function(e,t){if(t){const t=e.commands.map(function(e){return{command:O(e),summary:e.summary,tool:e.toolName,read_only:e.readOnly,risk:e.risk}});return{stdout:JSON.stringify(t,null,2)+"\n",stderr:""}}const n=["COMMAND\tTOOL\tREAD_ONLY\tRISK\tSUMMARY"];return e.commands.forEach(function(e){n.push([O(e),e.toolName,String(e.readOnly),e.risk,e.summary].join("\t"))}),{stdout:n.join("\n")+"\n",stderr:""}}(s,i)),0;if("describe"===t){const t=l.shift();if(!t)throw new d("USAGE",m("main.usage_tools_describe",{prefix:a}));let r=s.byToolName(t);if(!r&&t.indexOf(" ")<0){const e=s.commands.filter(function(e){return e.noun===t});1===e.length&&(r=e[0])}if(!r&&t.indexOf(" ")>0){const e=t.split(/\s+/);r=s.find(e[0],e[1]||"")}if(!r){if(!e.up)throw e.downError;throw new d("USAGE",m("main.unknown_command_or_tool",{ref:t}))}return E(n,{stdout:S(r,a),stderr:""}),0}throw new d("USAGE",m("main.usage_tools",{prefix:a}))}if("call"===c){const t=l.shift();if(!t&&r.help)return E(n,{stdout:m("main.usage_call",{prefix:a})+"\n"+m("main.call_args_note")+"\n",stderr:""}),0;if(!t)throw new d("USAGE",m("main.usage_call",{prefix:a}));const o=s.byToolName(t);if(!o){if(!e.up)throw e.downError;throw new d("USAGE",m("main.unknown_tool",{name:t}))}return r.help?(E(n,{stdout:S(o,a),stderr:""}),0):await D(e,o,l)}if("help"===c)return E(n,{stdout:R(e),stderr:""}),0;if(g[c])throw new d("USAGE",m("main.unknown_command_noun",{prefix:a,noun:c}));let u="",p=s.find(c,"");if(p){if(r.help)return E(n,{stdout:S(p,a),stderr:""}),0}else{if(u=l.shift(),!u){if(r.help)return E(n,{stdout:A(e,c,a)+"\n",stderr:""}),0;let t=m("main.usage_noun_verb",{prefix:a,noun:c});throw s.commands.some(function(e){return e.noun===c})&&(t+="\n"+A(e,c,a)),new d("USAGE",t)}if(r.help){if(p=s.find(c,u),!p){if(!e.up)throw e.downError;throw new d("USAGE",m("main.unknown_command_noun_verb",{prefix:a,noun:c,verb:u}))}return E(n,{stdout:S(p,a),stderr:""}),0}p=s.find(c,u)}if(!p){if(!e.up)throw e.downError;const t=s.commands.map(function(e){return O(e)}),n=o.suggest(c+(u?" "+u:""),t);let r=m("main.unknown_command_hint",{prefix:a});throw n.length&&(r+=m("main.did_you_mean",{prefix:a,candidate:n[0]})),new d("USAGE",r)}return await D(e,p,l)}async function D(e,t,n){if(!e.up)throw e.downError;const s=e.deps,l=e.globals,c=e.json,u=e.prefix||"expl";let f=null;if(l.input){const e="-"===l.input?s.readStdin():s.readFile(l.input);try{f=JSON.parse(e)}catch(e){throw new d("USAGE",m("main.input_parse",{error:e.message}))}}const h={readFile:s.readFile,readStdin:s.readStdin};let g=o.toToolArgs(t,n,h,f,u);e.resolveProject&&(g=await async function(e,t,n,r){if(!e.requiresProject)return r;const o="project_id"===e.positional?r.project_id:null;if(!o&&!t.project&&r.project_id)return r;if(e.projectOptional&&!o&&!t.project)return r;const i=o||t.project||n.env.EXPL_PROJECT||n.state.readDefaultProject();if(!i)throw new d("USAGE",m("main.no_project"));return r.project_id=(await b(n.client,i)).project_id,r}(t,l,s,g)),await async function(e,t,n,r,o,s){const l=(n.inputSchema.required||[]).filter(i.isEntityIdProp).filter(function(e){return void 0===r[e]||null===r[e]});if(!l.length)return;const c=l[0],u="--"+i.kebab(c),p=t.find(i.entityOfIdProp(c),"list"),f=p?(p.inputSchema.required||[]).filter(function(e){return"project_id"!==e}):[];if(p&&p.toolName!==n.toolName&&!f.length){const t=p.requiresProject&&r.project_id?{project_id:r.project_id}:{};try{const n=await e.callTool(p.toolName,t,{}),r=a.renderResult(n,{json:!1});o.stderr.write(m("main.candidates",{noun:p.noun})+"\n"+r.stdout+r.stderr)}catch(e){}}throw new d("USAGE",m("main.missing_id",{prefix:s,flag:u,prop:c,noun:n.noun,verb:n.verb}))}(e.client,e.tree,t,g,s,u);let _=await async function(e,t,n,o,i,s){let a;await async function(e,t,n,r){if("HIGH"!==e.risk||t.yes)return;if(!n.stdinIsTTY||!n.stdoutIsTTY)throw new d("USAGE",m("expl"===r?"main.hard_to_undo_desktop":"main.hard_to_undo"));n.stderr.write(m("main.confirm_prompt",{prefix:r,noun:e.noun,verb:e.verb,tool:e.toolName})+"\n");const o=(await n.readLine()).trim().toLowerCase();if("y"!==o&&"yes"!==o)throw new d("EXECUTION_FAILED",m("main.cancelled"))}(o,n,t,s),o.confirmsByUser&&(i.confirmed_by_user=!0);try{a=await e.callTool(o.toolName,i,{timeoutSec:n.timeoutSec})}catch(e){throw"expl"===s?function(e,t){return e instanceof d&&"CONFIRMATION_REQUIRED"===e.errorCode&&(e.details&&"pending"===e.details.status||e.message===r.CONFIRMATION_PENDING_MESSAGE)?(e.suggestedActions=e.suggestedActions.concat([m("main.confirm_yes_not_enough")]),"dataframe.run_r"===t.capabilityId&&e.suggestedActions.push(m("main.confirm_run_r_alternative")),e):e}(e,o):e}return a&&a.structuredContent&&"running"===a.structuredContent.status&&!n.noWait&&(a=await p.waitFor(e,a,{projectId:i.project_id||null,timeoutSec:n.timeoutSec,onProgress:function(e){n.quiet||t.stderr.write(e+"\n")},isInterrupted:t.isInterrupted,interrupt:t.interrupt||null,now:function(){return Date.now()}})),a}(e.client,s,l,t,g,u);if(e.onResult){const n=await e.onResult(_,t);if(n)return E(s,n),0}const w=function(e,t,n){const r=(n&&n.content||[]).find(function(e){return e&&"image"===e.type&&"string"==typeof e.data});if(!r)return null;const o=n.structuredContent&&n.structuredContent.chart_id,i=t.output||e.pathJoin(e.makeTmpDir(),String(o||"image").replace(/[^A-Za-z0-9_-]/g,"_")+".png");return e.writeFile(i,Buffer.from(r.data,"base64")),i}(s,l,_);return w&&c&&(_=Object.assign({},_,{structuredContent:Object.assign({},_.structuredContent,{image_path:w})})),E(s,a.renderResult(_,{json:c})),w&&!c&&E(s,{stdout:m("main.image_saved",{path:w})+"\n",stderr:""}),0}e.exports={run:async function(e,t){if("__complete"===e[0]){const n=t.state.readToolsCache();let r=null;if(t.server&&t.server.state){const e=t.server.state.lastServerUrl();if(e){const n=t.server.state.readToolsCache(e);n&&n.length&&(r=y(n))}}const o=s.complete(e.slice(1),n&&n.length?y(n):null,r);return o.length&&t.stdout.write(o.join("\n")+"\n"),0}let n;try{n=o.splitGlobals(e)}catch(n){return w(n,t,e.indexOf("--json")>=0)}const r=n.globals,i=r.json;try{if(r.version)return await async function(e,t){const n=["expl "+e.version],r=await x(e.client);n.push(r&&r.app_version?"Exploratory "+r.app_version:m("main.version_not_running"));const o=n.join("\n")+"\n";return E(e,t?{stdout:JSON.stringify({expl:e.version,exploratory:r},null,2)+"\n",stderr:""}:{stdout:o,stderr:""}),0}(t,i);if("server"===n.rest[0])return await l.run(n.rest.slice(1),r,t);if("status"===n.rest[0])return await async function(e,t){const n=(await e.client.callTool("get_environment",{})).structuredContent||{};return t?(E(e,{stdout:JSON.stringify(n,null,2)+"\n",stderr:""}),0):(E(e,{stdout:["Exploratory "+(n.app_version||"?"),m("main.status_user",{user:n.user&&(n.user.display_name||n.user.username)||"?"})].join("\n")+"\n",stderr:""}),0)}(t,i);if("skill"===n.rest[0])return await async function(e){let t=null;try{t=(await e.client.initialize()).instructions}catch(e){t=null}return E(e,{stdout:c.render({instructions:t,version:e.version}),stderr:""}),0}(t);if("completion"===n.rest[0]){const e=s.script(n.rest[1]);if(!e)throw new d("USAGE",m("main.usage_completion"));return E(t,{stdout:e,stderr:""}),0}if("lang"===n.rest[0])return await async function(e,t,n,r){const o=r.shift();if(void 0!==o&&_.indexOf(o)<0)throw new d("USAGE",m("main.usage_lang"));const i={project_id:await U(e,t)};let s;void 0===o?(i.keys=["ui_lang"],s=await e.client.callTool("get_system_settings",i,{timeoutSec:t.timeoutSec})):(i.settings={ui_lang:o},s=await e.client.callTool("update_system_settings",i,{timeoutSec:t.timeoutSec}));const a=s.structuredContent||{},l=void 0===o?(a.settings||{}).ui_lang:o;if(void 0!==o&&(a.skipped||[]).length)throw new d("EXECUTION_FAILED",m("main.lang_not_changed",{reason:JSON.stringify(a.skipped)}));return void 0!==o&&h(o),E(e,n?{stdout:JSON.stringify({ui_lang:l},null,2)+"\n",stderr:""}:{stdout:m(void 0===o?"main.lang_current":"main.lang_changed",{lang:l})+"\n",stderr:""}),0}(t,r,i,n.rest.slice(1));const e=await async function(e,t){try{const n=await e.listTools();return t.writeToolsCache(n),{tools:n,desktopUp:!0}}catch(e){if(!(e instanceof d)||"DESKTOP_NOT_RUNNING"!==e.errorCode)throw e;return{tools:t.readToolsCache()||[],desktopUp:!1}}}(t.client,t.state),o=e.tools.length?y(e.tools):{commands:[],find:function(){return null},byToolName:function(){return null}},a=n.rest.slice();if("project"===a[0]&&"use"===a[1]){a.shift(),a.shift();const n=a.shift();if(!n)throw new d("USAGE",m("main.usage_project_use"));if(!e.desktopUp)throw new d("DESKTOP_NOT_RUNNING");const r=await b(t.client,n);return t.state.writeDefaultProject(r.project_id),E(t,{stdout:m("main.default_project",{name:r.name,projectId:r.project_id})+"\n",stderr:""}),0}return await C({prefix:"expl",client:t.client,tree:o,up:e.desktopUp,downError:new d("DESKTOP_NOT_RUNNING"),downHint:m("main.help_start_desktop"),globals:r,json:i,deps:t,resolveProject:!0,onResult:null,builtinHelp:null,commandSummaries:!0,compactHelp:!0,guidance:0===a.length||"help"===a[0]?await c.readGuidance(t.client,"desktop"):null,guidanceMissingKey:"main.desktop_guidance_missing"},a)}catch(e){return w(e,t,i)}},dispatchTree:C,describeCommand:S,topHelp:R}},42(e,t,n){const r=n(439),o=n(736),i={en:n(174),ja:n(980)};let s=o.ENGLISH;e.exports={setLang:function(e){s=e===o.JAPANESE?o.JAPANESE:o.ENGLISH},getLang:function(){return s},t:function(e,t){const n=i[s][e];if("string"!=typeof n)throw new Error("Unknown expl message key: "+e);return n.replace(/\{(\w+)\}/g,function(e,n){return t&&void 0!==t[n]?String(t[n]):e})},localizeErrorDefaults:function(e,t,n){const a=i.ja;if(s!==o.JAPANESE||r.CODES.indexOf(e)<0)return{message:t,actions:n};const l=new r(e),c=function(e){const t=l.toJSON(e).suggested_actions;return n.length===t.length&&n.every(function(e,n){return e===t[n]})},u=c("en")||c("ja"),p="CONFIRMATION_REQUIRED"===e,d=p&&1===n.length&&n[0]===r.CONFIRMATION_PENDING_ACTION;return{message:!t||t===l.message||t===l.toJSON("ja").message||p&&t===r.CONFIRMATION_PENDING_MESSAGE?a["error."+e+".message"]:t,actions:u?[a["error."+e+".action"]]:d?[a["error.CONFIRMATION_REQUIRED.pending_action"]]:n}},CATALOGS:i}},351(e,t,n){const r=n(896),o=n(18),{ExplError:i}=n(877),{t:s}=n(42);function a(e){if(!e||"object"!=typeof e)return null;let t=null;const n=Object.keys(e);for(let r=0;r<n.length;r++){const o=e[n[r]];if(Array.isArray(o)&&o.length&&"object"==typeof o[0]&&null!==o[0]&&!Array.isArray(o[0])){if(t)return null;t=o}}return t}const l=[[4352,4447],[11904,42191],[44032,55203],[63744,64255],[65072,65103],[65280,65376],[65504,65510],[127744,128591],[131072,262141]],c=".pivot.measure.cell";function u(e){let t=0;for(const n of e){const e=n.codePointAt(0);t+=l.some(function(t){return e>=t[0]&&e<=t[1]})?2:1}return t}const p=/[\u0000-\u001F\u007F-\u009F]/g,d={"\n":"\\n","\r":"\\r","\t":"\\t"};function f(e){return null==e?"":("object"==typeof e?JSON.stringify(e):String(e)).replace(p,function(e){return d[e]||"\\u"+e.charCodeAt(0).toString(16).padStart(4,"0")})}function m(e){return String(e).replace(p,function(e){return"\n"===e||"\t"===e?e:d[e]||"\\u"+e.charCodeAt(0).toString(16).padStart(4,"0")})}function h(e,t){const n=[e.map(f)].concat(t.map(function(t){return e.map(function(e,n){return f(t[n])})})),r=e.map(function(e,t){return Math.max.apply(null,n.map(function(e){return u(e[t])}))});return n.map(function(e){return e.map(function(t,n){return n===e.length-1?t:t+" ".repeat(r[n]-u(t))}).join(" ").replace(/ +$/,"")}).join("\n")+"\n"}function g(e){const t=Object.keys(e[0]).filter(function(t){return null===(n=e[0][t])||"string"==typeof n||"number"==typeof n||"boolean"==typeof n;var n}).slice(0,6);if(!t.length)return"";const n=e.some(function(e){return Array.isArray(e.top_values)}),r=t.map(function(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toUpperCase()});return h(n?r.concat(["TOP_VALUES"]):r,e.map(function(e){const r=t.map(function(t){return e[t]});return n?r.concat([(o=e.top_values,Array.isArray(o)?o.slice(0,5).map(function(e){return f(e.value)+"("+f(e.count)+")"}).join(", ")+(o.length>5?", ...":""):"")]):r;var o}))}function _(e){const t=e.function&&"none"!==e.function?e.function:"";return e.column?t?e.column+" ("+t+")":e.column:t}function E(e){const t=e.rows;if(!Array.isArray(t)||!t.length||!Array.isArray(t[0]))return null;let n;if(e.definition&&Array.isArray(e.column_headers))n=function(e){const t=e.definition,n=e.rows,r=e.value_separator||"|||",o=e.column_headers.slice(0,n[0].length),i=o.filter(function(e){return/^r\d+$/.test(e)}).length,a=(t.rows||[]).map(function(e){return e.column||""}),l=i-a.length,u=(t.values||[]).map(_).join(r),p=o.map(function(e,t){return t<i?l>=0&&t>=l?a[t-l]:e:e===c?u:e}),d=e.totals||{},m=!1!==t.show_row_totals&&Array.isArray(d.row_totals)?d.row_totals:null,g=n.map(function(e,t){return m?e.concat([m[t]]):e});m&&p.push(s("output.total"));const E=d.column_totals;if(!1!==t.show_totals&&Array.isArray(E)&&i>0&&E.length===o.length-i){const t=[s("output.total")].concat(new Array(i-1).fill(null),E),n=e.total_row_count;m&&t.push(m.length===n+1?m[n]:null),g.push(t)}let w=h(p,g);return(t.values||[]).length>1&&o.indexOf(c)<0&&(w+=s("output.each_cell",{measure:f(u)})+"\n"),w}(e);else{const r=e.columns||[];n=h(t[0].map(function(e,t){return function(e){if(!e||"object"!=typeof e)return f(e);const t=e.column||e.name||"";return e.function&&"none"!==e.function?t+" ("+e.function+")":t}(r[t])}),t)}const r="number"==typeof e.total_row_count?e.total_row_count:e.row_count;return"number"==typeof r&&r>t.length&&(n+=s("output.showing_rows",{shown:t.length,total:r})+"\n"),n}const w=["title","displayName","display_name","name"],y=/(^id|_id|Id)$/;function x(e){const t=w.find(function(t){return"string"==typeof e[t]&&e[t]}),n=Object.keys(e).find(function(t){return y.test(t)&&"string"==typeof e[t]&&e[t]});return t&&n?f(e[t])+" ("+f(e[n])+")":""}function O(e){return Array.isArray(e)&&e.length?e.map(function(e){return s("output.warning",{text:m((t=e,"string"==typeof t?t:t&&"string"==typeof t.message?t.message:JSON.stringify(t)))})+"\n";var t}).join(""):""}function I(e,t){if(void 0!==e)return e;if("string"!=typeof t)return null;try{return JSON.parse(t)}catch(e){return t}}e.exports={createWriter:function(e){const t=e.fsModule||r,n=e.ttyModule||o;let s=null,a=0,l=[];const c=function(){if(a--,a>0)return;const e=l;l=[],e.forEach(function(e){e()})};return e.isTTY&&(s=new n.WriteStream(e.fd),s.on("error",function(){})),{write:function(n){try{if(s)return a++,void s.write(n,c);t.writeSync(e.fd,n,"utf8")}catch(e){if(e&&"EPIPE"===e.code)throw new i("BROKEN_PIPE");throw e}},flush:function(){return 0===a?Promise.resolve():new Promise(function(e){l.push(e)})}}},renderResult:function(e,t){const n=e&&e.structuredContent;let r=O(n&&n.warnings);const o=e&&e.content&&e.content[0]&&e.content[0].text;if(t.json)return{stdout:JSON.stringify(I(n,o),null,2)+"\n",stderr:r};const i=function(e){if("string"!=typeof e||!/^\s*\{/.test(e))return null;try{const t=JSON.parse(e);return t&&"object"==typeof t&&!Array.isArray(t)?t:null}catch(e){return null}}(o),s=void 0!==n?n:i;let l="";!i&&"string"==typeof o&&o.length&&(l+=m(o)+(o.endsWith("\n")?"":"\n")),l+=function(e){if(!e||"object"!=typeof e)return"";const t=E(e);if(null!==t)return t;const n=e.result&&"object"==typeof e.result&&!Array.isArray(e.result)?e.result:null,r=n?E(n):null;if(null!==r)return r;const o=n?a(n):null;if(o)return g(o);if("string"==typeof e.text&&e.text.length)return m(e.text)+(e.text.endsWith("\n")?"":"\n");const i=a(e);if(i){const t=x(e);return(t?t+"\n":"")+g(i)}if(Object.keys(e).filter(function(e){return"warnings"!==e}).some(function(t){return null!==e[t]&&"object"==typeof e[t]}))return JSON.stringify(e,null,2)+"\n";if("string"==typeof e.body&&e.body.length)return m(e.body)+(e.body.endsWith("\n")?"":"\n");const s=x(e);return s?s+"\n":""}(s);const c=function(e){if(!e||"object"!=typeof e)return null;const t=Object.keys(e).find(function(t){return/(^url|Url|_url)$/.test(t)&&"string"==typeof e[t]&&/^https?:\/\//.test(e[t])});return t?e[t]:null}(s);return c&&(l+="URL: "+m(c)+"\n"),{stdout:l,stderr:r}},jsonPayload:I,renderError:function(e,t){let n="";t.json&&(n=JSON.stringify({success:!1,error_code:e.errorCode,message:e.message,details:e.details,suggested_actions:e.suggestedActions},null,2)+"\n");let r=(e.suggestedActions||[]).slice();"DESKTOP_NOT_RUNNING"!==e.errorCode||r.length||r.push(s("output.start_desktop")),"NOT_LOGGED_IN"!==e.errorCode||r.length||r.push('Run "expl server login".');const o=e.details&&("env"===e.details.source||"saved-token"===e.details.source);"UNAUTHORIZED"===e.errorCode&&!r.length&&o&&r.push('Create a new API key in Account Settings > API Keys and set EXPL_SERVER_TOKEN (or run "expl server login --with-token").');let i=s("output.error",{text:m(e.message)});return"USAGE"!==e.errorCode&&(i+=" ("+m(e.errorCode)+")"),i+="\n",r.forEach(function(e){i+=m(e)+"\n"}),{stdout:n,stderr:i}},tableRows:a,displayWidth:u,formatWarnings:O}},484(e){function t(e,t,n){let r=null,o=e||{};const i=[];for(;o.$ref;){if(r=String(o.$ref).split("/").pop(),n.indexOf(r)>=0||i.indexOf(r)>=0)return{schema:null,name:r,recursive:!0};i.push(r),o=(t.definitions||t.$defs||{})[r]||{}}return{schema:o,name:r,recursive:!1}}function n(e){if(!e)return!1;if(e.anyOf||e.oneOf)return!1;const t=[].concat(e.type||[]);return t.indexOf("object")<0&&t.indexOf("array")<0&&!e.properties}function r(e){const t=[[].concat(e.type||"any").join("|")];return e.enum&&t.push("enum: "+e.enum.join("|")),e.pattern&&t.push("pattern "+e.pattern),["minLength","maxLength","minimum","maximum"].forEach(function(n){void 0!==e[n]&&t.push(n+" "+e[n])}),t.join(", ")}function o(e,t){return[].concat(e.type||[]).indexOf("null")>=0?t+" or null":t}function i(e){const t=[].concat(e.type||[]);return t.indexOf("array")>=0?o(e,"array"):t.indexOf("object")>=0||e.properties?o(e,"object"):t.length?t.join("|"):"any"}function s(e){const t=o(e,"array");return void 0===e.minItems&&void 0===e.maxItems?t:t+" ["+(void 0===e.minItems?"0":e.minItems)+".."+(void 0===e.maxItems?"":e.maxItems)+"]"}function a(e,l,c,u){const p=t(e,l,[]);if(p.recursive)return[(p.name||"object")+" (same as above)"];if(p.name&&c[p.name])return[i(p.schema)+" "+p.name+" (same as above)"];p.name&&(c[p.name]=!0);const d=p.schema,f=c;if(u>5)return["..."];const m=d.anyOf||d.oneOf;if(m){const e=m.map(function(e){return t(e,l,[])});if(e.every(function(e){return n(e.schema)}))return[e.map(function(e){return r(e.schema)}).join(" or ")];const o=["one of:"];return m.forEach(function(e){a(e,l,f,u+1).forEach(function(e,t){o.push((0===t?" | ":" ")+e)})}),o}if([].concat(d.type||[]).indexOf("array")>=0&&d.items){const e=a(d.items,l,f,u+1);return[s(d)+" of "+e[0]].concat(e.slice(1))}if(d.properties){const e=d.required||[],n=[p.name?o(d,"object")+" "+p.name:o(d,"object")];return Object.keys(d.properties).forEach(function(r){const o=d.properties[r],i=a(o,l,f,u+1),s=t(o,l,[]).schema,c=(o.description||s&&s.description||"").replace(/\s+/g," "),p=r+(e.indexOf(r)>=0?" (required): ":": ")+i[0]+(c?" -- "+c:"");n.push(" "+p),i.slice(1).forEach(function(e){n.push(" "+e)})}),n}return[r(d)]}function l(e,r,o,i,s){s=s||0;const a=t(e,r,i=i||[]);if(a.recursive||s>5)return null;const c=a.schema,u=a.name?i.concat(a.name):i,p=c.anyOf||c.oneOf;if(p)return l(p[0],r,o,u,s+1);if(c.enum)return c.enum[0];const d=[].concat(c.type||"string")[0];if("array"===d){const e=Math.min(Math.max(c.minItems||1,1),3),t=[];for(let n=0;n<e;n++)t.push(l(c.items||{},r,o,u,s+1));return t}if("object"===d||c.properties){const e={},o=c.properties||{},i=c.required||[];i.forEach(function(t){o[t]&&(e[t]=l(o[t],r,t,u,s+1))});const a=i.some(function(e){return o[e]&&o[e].enum}),p=Object.keys(o).find(function(e){const s=t(o[e],r,u).schema;return i.indexOf(e)<0&&s&&n(s)&&!s.enum});return a&&p&&(e[p]=l(o[p],r,p,u,s+1)),e}return"integer"===d||"number"===d?void 0!==c.minimum?c.minimum:1:"boolean"===d||(c.pattern?o:"<"+o+">")}e.exports={shapeLines:function(e,t){return a(e,t||{},{},0)},exampleJson:function(e,t,n){return JSON.stringify(l(e,t||{},n))},exampleValue:l,firstSentence:function(e){const t=String(e||"").replace(/\s+/g," ").trim(),n=/\.(?=\s|$)|。/g;let r,o=t,i=!1,s=null;for(;r=n.exec(t);){const e=t.slice(0,r.index);if((e.match(/[((]/g)||[]).length>(e.match(/[))]/g)||[]).length){null===s&&(s=r.index+1);continue}const n=e.match(/\S*$/)[0];if("."!==r[0]||!/^(?:[A-Za-z]\.)*[A-Za-z]$/.test(n)){o=t.slice(0,r.index+1),i=!0;break}}return i||null===s||(o=t.slice(0,s)),o.length>160?o.slice(0,159)+"…":o}}},587(e,t,n){const r=n(982),o=n(611),i=n(692),{URL:s,URLSearchParams:a}=n(16),{ExplError:l,fromHttpAuthError:c,fromHttpRateLimit:u}=n(877),p="/oauth/clients/expl.json",d=6e5;function f(e){return e.replace(/\/+$/,"")+p}function m(e){const t=(e||r.randomBytes)(32).toString("base64url");return{verifier:t,challenge:r.createHash("sha256").update(t).digest("base64url")}}function h(e){const t=e.serverUrl.replace(/\/+$/,"");return t+"/oauth/authorize?"+new a({response_type:"code",client_id:f(t),redirect_uri:e.redirectUri,code_challenge:e.challenge,code_challenge_method:"S256",state:e.state,scope:"content:read",resource:t+"/mcp"}).toString()}function g(e,t,n){return(n.request||_)(e,t,n)}function _(e,t,n){return new Promise(function(r,a){const c=new s(e.replace(/\/+$/,"")+t),u=("https:"===c.protocol?i:o).request({hostname:c.hostname,port:c.port||("https:"===c.protocol?443:80),path:c.pathname+c.search,method:n.method||"GET",headers:n.headers||{},agent:!1},function(e){let t="";e.setEncoding("utf8"),e.on("data",function(e){t+=e}),e.on("end",function(){r({statusCode:e.statusCode,body:t,headers:e.headers})})});u.setTimeout(n.timeoutMs||3e4,function(){u.destroy(Object.assign(new Error("timed out"),{code:"ETIMEDOUT"}))}),u.on("error",function(e){a(new l("SERVER_UNREACHABLE","Cannot reach "+c.origin+": "+(e.code||e.message)))}),n.body&&u.write(n.body),u.end()})}function E(e){const t=e.httpModule||o;let n=null,r=null,i=null;const a=new Promise(function(e,t){r=e,i=t});a.catch(function(){});let c=!1,u=null;const p=function(){c||(c=!0,clearTimeout(u),n&&n.close())};return n=t.createServer(function(t,n){const o=new s(t.url,"http://127.0.0.1");if("/callback"!==o.pathname)return n.writeHead(404),void n.end();if(o.searchParams.get("state")!==e.state)return n.writeHead(400),void n.end("Invalid state.");const a=o.searchParams.get("error");if(a)return n.writeHead(400),n.end("Login failed."),i("access_denied"===a?new l("PERMISSION_DENIED","Login was denied in the browser."):new l("EXECUTION_FAILED","Login failed: "+(o.searchParams.get("error_description")||a))),void p();const c=o.searchParams.get("code");if(!c)return n.writeHead(400),void n.end("Missing code.");n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end("You can close this window and return to the terminal."),r(c),p()}),new Promise(function(t,r){n.listen(0,"127.0.0.1",function(){const r=n.address().port;u=setTimeout(function(){i(new l("EXECUTION_FAILED","Login timed out.")),p()},e.timeoutMs),t({port:r,redirectUri:"http://127.0.0.1:"+r+"/callback",code:a,close:p})}),n.on("error",r)})}function w(e,t){let n;try{n=new s(e.trim())}catch(e){throw new l("USAGE","Paste the full redirect URL from your browser.")}if(n.searchParams.get("state")!==t)throw new l("USAGE","The redirect URL does not match this login attempt.");const r=n.searchParams.get("code");if(!r)throw new l("USAGE","The redirect URL has no authorization code.");return r}async function y(e,t,n){n=n||{};const r=e.replace(/\/+$/,""),o=new a(t);o.set("client_id",f(r)),o.set("resource",r+"/mcp");const i=await g(r,"/oauth/token",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","Content-Length":Buffer.byteLength(o.toString())},body:o.toString(),request:n.request});let s=null;try{s=JSON.parse(i.body)}catch(e){s=null}if(i.statusCode>=400){if(s&&"invalid_grant"===s.error)throw new l("NOT_LOGGED_IN",s.error_description||s.error);throw new l("SERVER_UNREACHABLE","HTTP "+i.statusCode+" from "+r+"/oauth/token")}if(!s||!s.access_token)throw new l("SERVER_UNREACHABLE","HTTP "+i.statusCode+" from "+r+"/oauth/token");return s}function x(e){return y(e.serverUrl,{grant_type:"authorization_code",code:e.code,redirect_uri:e.redirectUri,code_verifier:e.verifier},{request:e.request})}async function O(e){const t=e.serverUrl.replace(/\/+$/,""),n=await g(t,"/oauth/userinfo",{method:"GET",headers:{Authorization:"Bearer "+e.accessToken},request:e.request});if(401===n.statusCode||403===n.statusCode){if(e.source&&"login"!==e.source)throw c({statusCode:n.statusCode,wwwAuthenticate:n.headers&&n.headers["www-authenticate"],source:e.source});throw new l("NOT_LOGGED_IN","The server rejected the login token.")}if(429===n.statusCode)throw u(n.body);if(n.statusCode>=400)throw new l("SERVER_UNREACHABLE","HTTP "+n.statusCode+" from "+t+"/oauth/userinfo");let r;try{r=JSON.parse(n.body)}catch(e){throw new l("SERVER_UNREACHABLE","HTTP "+n.statusCode+" from "+t+"/oauth/userinfo")}return{email:r.email||"?",display_name:r.display_name||null,credential:r.credential||null}}function I(e,t){const r=t.spawn||n(317).spawn;let o,i;"darwin"===t.platform?(o="open",i=[e]):"win32"===t.platform?(o="rundll32",i=["url.dll,FileProtocolHandler",e]):(o="xdg-open",i=[e]);try{const e=r(o,i,{detached:!0,stdio:"ignore"});return e.on("error",function(){}),e.unref(),!0}catch(e){return!1}}e.exports={CLIENT_DOCUMENT_PATH:p,LOGIN_TIMEOUT_MS:d,REQUEST_TIMEOUT_MS:3e4,clientIdFor:f,createPkce:m,authorizeUrl:h,listenForCode:E,codeFromPastedUrl:w,exchangeCode:x,refresh:function(e){return y(e.serverUrl,{grant_type:"refresh_token",refresh_token:e.refreshToken},{request:e.request})},revoke:async function(e){const t=e.serverUrl.replace(/\/+$/,""),n=new a({token:e.token,client_id:f(t)});try{await g(t,"/oauth/revoke",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","Content-Length":Buffer.byteLength(n.toString())},body:n.toString(),request:e.request})}catch(e){}},userinfo:O,openBrowser:I,login:async function(e){const t=e.serverUrl.replace(/\/+$/,""),n=m(),o=r.randomBytes(16).toString("hex");let i,s=null;e.noBrowser?i="http://127.0.0.1/callback":(s=await E({state:o,timeoutMs:d,httpModule:e.httpModule}),i=s.redirectUri);const a=h({serverUrl:t,redirectUri:i,challenge:n.challenge,state:o});let l;!e.noBrowser&&e.interactive&&I(a,{platform:e.platform,spawn:e.spawn})?e.stderr.write("Opening "+a+" in your browser.\nIf the browser does not open, visit the URL above.\n"):e.stderr.write("Open this URL in your browser to log in:\n"+a+"\n"),e.noBrowser?(e.stderr.write("Paste the URL you were redirected to:\n"),l=w(await e.readLine(),o)):l=await s.code;const c=await x({serverUrl:t,code:l,verifier:n.verifier,redirectUri:i,request:e.request}),u=await O({serverUrl:t,accessToken:c.access_token,request:e.request}),p=new Date(Date.now()+1e3*(c.expires_in||3600)).toISOString();return{server_url:t,client_id:f(t),access_token:c.access_token,refresh_token:c.refresh_token,expires_at:p,email:u.email,saved_at:(new Date).toISOString()}},httpRequest:g}},654(e,t,n){const r=n(611),o=n(692),i=n(262),s=n(587),{ExplError:a,fromJsonRpcError:l,fromToolResult:c,fromHttpAuthError:u,fromHttpRateLimit:p}=n(877),d="expl",f="x-exploratory-include-tool-meta",m=3e5;e.exports={create:function(e){const t=e.serverUrl.replace(/\/+$/,""),n=t+"/mcp",h=e.state;let g=e.auth;const _=e.sessionId,E=e.clientVersion,w=e.timeoutMs||m,y=e.onTrace,x=e.post||i.post,O=e.refresh||s.refresh,I=e.request;let v=0;async function N(){if(!g||"login"!==g.source||!g.credentials)return;const e=Date.parse(g.credentials.expires_at||"");Number.isFinite(e)&&e>Date.now()+6e4||await T()}async function T(){await h.withLock(t,async function(){const e=h.readCredentials(t);if(e&&e.access_token!==g.credentials.access_token)return g.credentials=e,void(g.token=e.access_token);const n=await O({serverUrl:t,refreshToken:g.credentials.refresh_token}),r=Object.assign({},g.credentials,{access_token:n.access_token,refresh_token:n.refresh_token||g.credentials.refresh_token,expires_at:new Date(Date.now()+1e3*(n.expires_in||3600)).toISOString(),saved_at:(new Date).toISOString()});h.writeCredentials(t,r),g.credentials=r,g.token=r.access_token})}async function S(e,r,o){if(!g)throw new a("NOT_LOGGED_IN","Not logged in to "+t+'. Run "expl server login".');async function i(s){const c=++v,f={jsonrpc:"2.0",id:c,method:e,params:r},m=JSON.stringify(f),h=function(e){const n={Host:new URL(t).host,Accept:"application/json, text/event-stream","Content-Type":"application/json","x-exploratory-client-name":d,"x-exploratory-client-version":E,"x-exploratory-guide-session":_};return g&&(n.Authorization="Bearer "+g.token),e&&Object.assign(n,e),n}(o);h["Content-Length"]=Buffer.byteLength(m);let O=null;const I=[],N=await x({url:n,headers:h,body:m,timeoutMs:w,onMessage:function(e){I.push(e),e&&e.id===c&&(O=e)}});y&&y(JSON.stringify({method:e,params:r,id:c,statusCode:N.statusCode,messages:I}));const S=function(e,n,r){if(e.connectError)throw new a("SERVER_UNREACHABLE","Cannot reach "+t+": "+e.connectError);if(401===e.statusCode&&g){if("login"===g.source&&n)return T().then(function(){return n()});throw u({statusCode:401,wwwAuthenticate:e.wwwAuthenticate||null,source:g.source})}if(403===e.statusCode&&g)throw u({statusCode:403,wwwAuthenticate:e.wwwAuthenticate||null,source:g.source});if(429===e.statusCode)throw p(e.rawBody||r&&r[0]||null);if(e.rawBody)throw new a("SERVER_UNREACHABLE","Cannot reach "+t+": HTTP "+e.statusCode);if(!e.complete)throw new a("SERVER_UNREACHABLE","Cannot reach "+t+": incomplete response");return null}(N,s?function(){return i(!1)}:null,I);if(S)return S;if(!O)throw new a("EXECUTION_FAILED","No JSON-RPC response from "+t);if(O.error)throw l(O.error);return O.result}await N();try{return await i(!0)}catch(e){return async function(e){if(!g)throw e;if("login"!==g.source)throw e;if(!(e instanceof a)||"NOT_LOGGED_IN"!==e.errorCode)throw e;const n=h.readCredentials(t);if(n&&n.access_token!==g.token)return g.credentials=n,g.token=n.access_token,i(!1);throw e}(e)}}return{auth:g,listTools:async function(){const e=[];let t=null;for(;;){const n=t?{cursor:t}:{},r=await S("tools/list",n,{[f]:"true"});if(r&&r.tools&&e.push.apply(e,r.tools),t=r&&r.nextCursor?r.nextCursor:null,!t)break}return e},callTool:async function(e,t){const n=await S("tools/call",{name:e,arguments:t||{}});if(n&&n.isError)throw c(n);return n},initialize:async function(){const e=await S("initialize",{protocolVersion:"2025-11-25",capabilities:{},clientInfo:{name:d,version:E}});return{instructions:"string"==typeof e.instructions?e.instructions:null,serverInfo:e.serverInfo||{}}},download:async function(e){if(!g)throw new a("NOT_LOGGED_IN","Not logged in to "+t+'. Run "expl server login".');await N();const n=new URL(e);if(n.origin!==new URL(t).origin)throw new a("EXECUTION_FAILED","The download URL is not on "+t+": "+e);const i="https:"===n.protocol?o:r;return new Promise(function(r,o){const s=i.request({hostname:n.hostname,port:n.port||("https:"===n.protocol?443:80),path:n.pathname+n.search,method:"GET",headers:{Authorization:"Bearer "+g.token},agent:!1},function(t){const n=[];t.on("data",function(e){n.push(e)}),t.on("end",function(){200===t.statusCode?r(Buffer.concat(n)):o(new a("EXECUTION_FAILED","HTTP "+t.statusCode+" from "+e))})});s.setTimeout(w,function(){s.destroy(Object.assign(new Error("timed out"),{code:"ETIMEDOUT"}))}),s.on("error",function(e){o(new a("SERVER_UNREACHABLE","Cannot reach "+t+": "+(e.code||e.message)))}),s.end()})},serverRequest:async function(e,n,r,o){if(!g)throw new a("NOT_LOGGED_IN","Not logged in to "+t+'. Run "expl server login".');await N();const i=function(){return s.httpRequest(t,n,{method:e,headers:Object.assign({Authorization:"Bearer "+g.token},o||{}),body:r,request:I})};let l=await i();401===l.statusCode&&"login"===g.source&&(await T(),l=await i());const c=l.headers&&l.headers["www-authenticate"];if(401===l.statusCode||403===l.statusCode&&c)throw u({statusCode:l.statusCode,wwwAuthenticate:c,source:g.source});return l}}},resolveToken:function(e){if(e.env&&e.env.EXPL_SERVER_TOKEN&&e.env.EXPL_SERVER_TOKEN.trim())return{source:"env",credentials:null,token:e.env.EXPL_SERVER_TOKEN.trim()};const t=e.state.readCredentials(e.serverUrl);return t&&t.access_token?{source:"pat"===t.type?"saved-token":"login",credentials:t,token:t.access_token}:null},DEFAULT_TIMEOUT_MS:m,TOOL_META_HEADER:f}},876(e,t,n){const r=n(495),o=n(213),i=n(440),s=n(351),{t:a}=n(42),l=n(654),c=n(134),{ExplError:u,exitCodeFor:p}=n(877),d=["expl server login [--url <server>] [--no-browser | --with-token]","expl server logout","expl server status","expl server token create|list|revoke","expl server tools list|describe","expl server call <tool_name>","expl server skill"];function f(e,t){t.stdout&&e.stdout.write(t.stdout),t.stderr&&e.stderr.write(t.stderr)}function m(e,t,n){const r=e instanceof u?e:new u("EXECUTION_FAILED",e&&e.message?e.message:String(e));return"BROKEN_PIPE"===r.errorCode||f(t,s.renderError(r,{json:n})),p(r.errorCode)}const h=/^(exp_pat_|expl_srv_)\S+$/;function g(e){const t=e&&e.content&&e.content[0]&&e.content[0].text,n=s.jsonPayload(e&&e.structuredContent,t);return n&&"object"==typeof n&&(n.download_url||n.result&&n.result.download_url)||null}const _={400:"USAGE",403:"PERMISSION_DENIED",404:"NOT_FOUND",409:"CONFLICT"};function E(e,t){let n=null;try{n=JSON.parse(e.body)}catch(e){n=null}if(e.statusCode>=200&&e.statusCode<300&&n)return n;const r=_[e.statusCode];if(r)throw new u(r,n&&n.error_description||"HTTP "+e.statusCode);throw new u("SERVER_UNREACHABLE","HTTP "+e.statusCode+" from "+t+"/oauth/cli-tokens")}e.exports={run:async function(e,t,p){const _=t.json;try{if(e.some(function(e){return"--token"===e||0===e.indexOf("--token=")}))throw new u("USAGE",'--token was removed. Set EXPL_SERVER_TOKEN, or run "expl server login --with-token" (reads the API key from stdin).');let w;try{w=r.splitGlobals(e,r.SERVER_FLAG_SPECS)}catch(e){return m(e,p,_)}if(t.project)throw new u("USAGE","--project is not used with expl server.");const y=Object.assign({},t,{url:w.globals.url||t.url||null,output:w.globals.output||t.output||null,noBrowser:w.globals.noBrowser||t.noBrowser||!1,withToken:w.globals.withToken||!1});e=w.rest;const x=p.server.state,O=c.resolveServerUrl({flag:y.url,env:p.env,state:x}),I=t.timeoutSec?1e3*t.timeoutSec:l.DEFAULT_TIMEOUT_MS,v=e[0];if("login"===v&&y.withToken)return await async function(e,t,n,r){if(r.noBrowser)throw new u("USAGE","--with-token and --no-browser cannot be used together.");const o=e.stdinIsTTY?await e.readSecret("API key: "):e.readStdin(),i=(String(o||"").split(/\r?\n/)[0]||"").trim();if(!h.test(i))throw new u("USAGE",'Paste an API key (it starts with exp_pat_) when "expl server login --with-token" asks for it, or pipe one in. Create one in Account Settings > API Keys.');const s=await e.server.userinfo({serverUrl:n,accessToken:i,request:e.server.request,source:"saved-token"});t.writeCredentials(n,{server_url:n,type:"pat",access_token:i,email:s.email,credential:s.credential||null,saved_at:(new Date).toISOString()});const a=s.credential&&s.credential.name?' with API key "'+s.credential.name+'"':" with an API key";return f(e,{stdout:"Logged in to "+new URL(n).host+" as "+s.email+a+".\n",stderr:""}),0}(p,x,O,y);if("login"===v){const e=await p.server.login({serverUrl:O,noBrowser:y.noBrowser,interactive:p.stdinIsTTY&&p.stdoutIsTTY,platform:p.server.platform,stderr:p.stderr,readLine:p.readLine,request:p.server.request,httpModule:p.server.httpModule,spawn:p.server.spawn});return x.writeCredentials(O,e),f(p,{stdout:"Logged in to "+new URL(O).host+" as "+e.email+".\n",stderr:""}),0}if("logout"===v){const e=x.readCredentials(O);return e?"pat"===e.type?(x.deleteCredentials(O),f(p,{stdout:"Logged out of "+new URL(O).host+". The API key itself still works; revoke it in Account Settings > API Keys if you no longer need it.\n",stderr:""}),0):(await p.server.revoke({serverUrl:O,token:e.refresh_token,request:p.server.request}),x.deleteCredentials(O),f(p,{stdout:"Logged out of "+new URL(O).host+".\n",stderr:""}),0):(f(p,{stdout:"Not logged in.\n",stderr:""}),0)}const N=l.resolveToken({env:p.env,state:x,serverUrl:O}),T=p.server.createClient({serverUrl:O,auth:N,state:x,sessionId:p.sessionId,clientVersion:p.version,timeoutMs:I,onTrace:p.onTrace,post:p.server.post,refresh:p.server.refresh,request:p.server.request});if("status"===v){if(!N)throw new u("NOT_LOGGED_IN","Not logged in to "+O+'. Run "expl server login".');return await async function(e,t,n,r,o){try{const i=await n.initialize(),s=i.serverInfo&&i.serverInfo.version?i.serverInfo.version:"?";let a="?",l=null;r&&(l=await e.server.userinfo({serverUrl:o,accessToken:r.token,request:e.server.request,source:r.source}),a=l.email);let c="not logged in",u=null;if(r){const e="env"===r.source?"from EXPL_SERVER_TOKEN":"saved by login --with-token",t=l&&l.credential&&"pat"===l.credential.type?l.credential:null;if("login"===r.source&&r.credentials){const e=r.credentials.saved_at?r.credentials.saved_at.slice(0,10):"?",t=new Date(r.credentials.expires_at||"");c="login (refresh token saved "+e+", access token valid until "+(Number.isFinite(t.getTime())?t.toTimeString().slice(0,5):"?")+")"}else t?(c='API key "'+t.name+'" '+e+", "+(t.expires_at?"expires "+String(t.expires_at).slice(0,10):"never expires"),u={type:"pat",source:r.source,name:t.name,expires_at:t.expires_at||null}):c="env"===r.source?"EXPL_SERVER_TOKEN":"API key "+e}const p={server:o,version:s,user:a,auth:c};return u&&(p.credential=u),f(e,t?{stdout:JSON.stringify(p,null,2)+"\n",stderr:""}:{stdout:"Server: "+o+" (Exploratory "+s+")\nUser: "+a+"\nAuth: "+c+"\n",stderr:""}),0}catch(n){return m(n,e,t)}}(p,_,T,N,O)}if("token"===v)return await async function(e,t,n,r,o,i){const a=e[0];if("create"===a){if(!o||"login"!==o.source)throw new u("NOT_LOGGED_IN",'Log in with "expl server login" to create tokens.');const s=function(e){const t=new u("USAGE","Usage: expl server token create --name <name> [--expires <days>]");let n=null,r=null;for(let o=0;o<e.length;o++){const i=e[o].indexOf("="),s=i>0?e[o].slice(0,i):e[o];if("--name"!==s&&"--expires"!==s)throw t;const a=i>0?e[o].slice(i+1):e[++o];if(void 0===a||""===a)throw t;"--name"===s?n=a:r=a}if(!n)throw t;if(null===r)return{name:n,expiresDays:null};if(!/^[0-9]+$/.test(r))throw new u("USAGE","--expires must be a number of days.");return{name:n,expiresDays:Number(r)}}(e.slice(1)),a=JSON.stringify(null===s.expiresDays?{name:s.name}:{name:s.name,expires_days:s.expiresDays}),l=E(await r.serverRequest("POST","/oauth/cli-tokens",a,{"Content-Type":"application/json"}),i);return f(t,n?{stdout:JSON.stringify(l,null,2)+"\n",stderr:""}:{stdout:l.token+"\n",stderr:"Token name: "+l.name+"\nExpires: "+l.expires_at+"\nSave this token; it will not be shown again.\nSet EXPL_SERVER_TOKEN for CI.\n"}),0}if("list"===a){if(e.length>1)throw new u("USAGE","Usage: expl server token list");if(!o)throw new u("NOT_LOGGED_IN","Not logged in to "+i+'. Run "expl server login".');const a=E(await r.serverRequest("GET","/oauth/cli-tokens",null,{}),i);return n||(a.tokens||[]).length?(f(t,s.renderResult({structuredContent:a},{json:n})),0):(f(t,{stdout:"No tokens.\n",stderr:""}),0)}if("revoke"===a){const s=e[1];if(!s||e.length>2)throw new u("USAGE","Usage: expl server token revoke <name>");if(!o)throw new u("NOT_LOGGED_IN","Not logged in to "+i+'. Run "expl server login".');return E(await r.serverRequest("DELETE","/oauth/cli-tokens/"+encodeURIComponent(s),null,{}),i),f(t,{stdout:n?JSON.stringify({success:!0})+"\n":"Revoked "+s+".\n",stderr:""}),0}throw new u("USAGE","Usage: expl server token create|list|revoke")}(e.slice(1),p,_,T,N,O);if("skill"===v)return f(p,{stdout:n(821).render({instructions:null,version:p.version,server:{instructions:(await n(821).readGuidance(T)).instructions},serverOnly:!0}),stderr:""}),0;const S=await async function(e,t,n){try{const r=await e.listTools();return n.writeToolsCache(t,r),{tools:r,up:!0,downError:null}}catch(e){if(!(e instanceof u))throw e;if("SERVER_UNREACHABLE"!==e.errorCode&&"NOT_LOGGED_IN"!==e.errorCode&&"UNAUTHORIZED"!==e.errorCode)throw e;return{tools:n.readToolsCache(t)||[],up:!1,downError:e}}}(T,O,x),A=o.GLOBAL_FLAGS.concat(o.SERVER_FLAGS),R=S.tools.length?o.build(S.tools,{globalFlags:A}):{commands:[],find:function(){return null},byToolName:function(){return null}},b=y.output?function(e,t,n,r){return async function(o,l){const c=n.output;let p=null;o.content&&o.content.forEach(function(e){"image"===e.type&&e.data&&(p=Buffer.from(e.data,"base64"))});const d=g(o),f=function(e){const t=e&&e.content&&e.content[0]&&e.content[0].text,n=s.jsonPayload(e&&e.structuredContent,t);return n&&"object"==typeof n?n:null}(o),m=p||d||!f?null:i.queryResultToCsv(f);if(!p&&!d&&null===m)throw new u("USAGE",a(f&&f.batch?"server.output_batch":"server.output_no_file"));const h="-"===c?"":i.UTF8_BOM,_=p||(null!==m?Buffer.from(h+m,"utf8"):await t.download(d)),E=null!==m?function(e,t){let n=s.formatWarnings(e.warnings);return e.result&&e.result.has_more&&(n+=a("chart_query"===t?"server.query_cut_chart":"server.query_cut_dataset")+"\n"),n}(f,l&&l.toolName):"";if("-"===c)return e.writeStdoutBytes(_),{stdout:"",stderr:E};if(e.writeFileBytes(c,_),r){const e={saved:c,bytes:_.length};return null!==m&&(f.warnings&&f.warnings.length&&(e.warnings=f.warnings),f.result&&f.result.has_more&&(e.has_more=!0)),{stdout:JSON.stringify(e,null,2)+"\n",stderr:E}}return{stdout:a("server.saved",{bytes:_.length,path:c})+"\n",stderr:E}}}(p,T,y,_):null;return await n(107).dispatchTree({prefix:"expl server",client:T,tree:R,up:S.up,downError:S.downError||new u("NOT_LOGGED_IN"),downHint:'Log in with "expl server login" to list its commands.',globals:t,serverGlobals:y,json:_,deps:p,resolveProject:!1,builtinHelp:d,commandSummaries:!0,guidance:0===e.length?await n(821).readGuidance(T):null,onResult:b},e)}catch(e){return m(e,p,_)}},resultDownloadUrl:g}},134(e,t,n){const r=n(896),o=n(928),i=n(677),{ExplError:s}=n(877);function a(e){if("string"!=typeof e||!e)throw new s("USAGE","Server URL is required.");const t=e.trim().replace(/\/+$/,"");if(!/^https?:\/\//i.test(t))throw new s("USAGE","Server URL must start with http:// or https://.");return t}function l(e){const t=new URL(a(e)),n=t.hostname.replace(/[^a-zA-Z0-9.-]/g,"_"),r=t.port||("https:"===t.protocol?"443":"80");return r===("https:"===t.protocol?"443":"80")?n:n+"_"+r}e.exports={create:function(e){const t=e.rootDir,n=e.fsModule||r,c=o.join(t,"expl/server");function u(e){return o.join(c,l(e)+".json")}function p(){n.mkdirSync(c,{recursive:!0,mode:448}),n.chmodSync(c,448)}return{readCredentials:function(e){const t=i.readJsonFile(c,l(e)+".json",n);return t&&"string"==typeof t.access_token&&"string"==typeof t.server_url&&function(e,t){try{return new URL(a(e)).origin===new URL(a(t)).origin}catch(e){return!1}}(t.server_url,e)?t:null},writeCredentials:function(e,t){p(),i.writeJsonFile(c,l(e)+".json",t,n)},deleteCredentials:function(e){try{n.unlinkSync(u(e))}catch(e){if("ENOENT"!==e.code)throw e}},readToolsCache:function(e){const t=i.readJsonFile(c,l(e)+".tools.json",n);return t&&Array.isArray(t.tools)?t.tools:null},writeToolsCache:function(e,t){p(),i.writeJsonFile(c,l(e)+".tools.json",{tools:t},n)},lastServerUrl:function(){let e=null,t="";try{n.readdirSync(c).forEach(function(r){if(!r.endsWith(".json")||r.endsWith(".tools.json")||r.endsWith(".lock"))return;const o=i.readJsonFile(c,r,n);o&&"string"==typeof o.server_url&&"string"==typeof o.saved_at&&(!t||o.saved_at>t)&&(t=o.saved_at,e=o.server_url)})}catch(e){if("ENOENT"!==e.code)throw e}return e},withLock:async function(e,t){p();const r=function(e){return u(e)+".lock"}(e),o=Date.now();for(;;)try{n.writeFileSync(r,String(process.pid),{flag:"wx",mode:384});break}catch(e){if("EEXIST"!==e.code)throw e;try{if(Date.now()-n.statSync(r).mtimeMs>6e4){n.unlinkSync(r);continue}}catch(e){if("ENOENT"!==e.code)throw e;continue}if(Date.now()-o>=7e4)throw new s("EXECUTION_FAILED","Another expl process is still refreshing the login. Try again.");await new Promise(function(e){setTimeout(e,50)})}try{return await t()}finally{try{n.unlinkSync(r)}catch(e){}}}}},hostKey:l,normalizeUrl:a,resolveServerUrl:function(e){if(e.flag)return a(e.flag);if(e.env&&e.env.EXPL_SERVER_URL)return a(e.env.EXPL_SERVER_URL);const t=e.state.lastServerUrl();return t?a(t):"https://exploratory.io"}}},821(e){const t=["# Exploratory from the shell: expl","","expl calls the same operations the Exploratory MCP server offers. Exploratory Desktop must be running and","the user signed in.","","## How to work","","1. Find the command: `expl tools list --json` lists every command with its MCP tool name, whether it only"," reads, and its risk (LOW, MEDIUM, HIGH).","2. Read its arguments before calling it: `expl <noun> <verb> --help` (same as `expl tools describe`).","3. Always pass `--json` and read the result from stdout. Warnings go to stderr: read them too.","4. Pass a project with `--project <id|name>`, or set one once with `expl project use <id|name>`.","5. Pass complex input as JSON: `--input file.json` or `--input -` (stdin). Flags override its fields.","6. HIGH-risk commands (publish, delete, ...) refuse to run without `--yes` when not on a terminal."," Ask the user before you add `--yes`.","7. Long operations wait by default. With `--no-wait`, poll with `expl execution get <execution_id>`.","8. `expl call <tool_name>` runs a tool by its MCP name.","","## Exit codes","","| Code | Meaning |","|---|---|","| 0 | Success |","| 1 | The operation failed (NOT_FOUND, INVALID_PARAMETER, EXECUTION_FAILED, ...) |","| 2 | Usage error: unknown flag, unreadable JSON, or `--yes` missing |","| 3 | Exploratory Desktop is not running |","| 4 | Not signed in, unauthorized, or permission denied |","| 130 | Interrupted |","",'With `--json`, a failure prints `{"success": false, "error_code", "message", "suggested_actions"}` on stdout.'].join("\n"),n=["## Exploratory Server: expl server","","expl server calls the same operations as the Exploratory Server MCP. Run `expl server login` once on","each machine (or set EXPL_SERVER_TOKEN from `expl server token create` for CI).","","Use expl server when you have a shell and files; use the Remote MCP when you only have a chat client.","Save large results to a file with --output (for example `expl server dataset query ... --output out.csv`)","and read only the part you need, instead of printing them into the conversation.","Published content: expl server. Local projects: the Desktop expl.","","List commands: `expl server tools list --json`. Exit code 3 means the server is unreachable;","exit code 4 means not logged in or the token was rejected."].join("\n");e.exports={render:function(e){const r=!!e.serverOnly,o=["---","name: "+(r?"exploratory-expl-server":"exploratory-expl"),"description: "+(r?"Use expl server to search and read the data, charts, dashboards, notes and analytics published on Exploratory Server from the shell.":"Use the expl command to read and change Exploratory projects, dashboards, notes, charts and data frames from the shell."),"---","","\x3c!-- Generated by expl "+e.version+" --\x3e",""];return r||o.push(t),e.server&&(o.push("",n),e.server.instructions&&o.push("",e.server.instructions.trim())),e.instructions&&o.push("","## Exploratory guidance","",e.instructions.trim()),o.join("\n")+"\n"},readGuidance:async function(e,t){try{const n=(await e.initialize()).instructions;return n?{instructions:n,error:null}:{instructions:null,error:"the "+(t||"server")+" sent none"}}catch(e){return{instructions:null,error:e.message||String(e)}}}}},677(e,t,n){const r=n(896),o=n(928),{ExplError:i}=n(877),{t:s,getLang:a}=n(42),l="expl.json",c="expl-tools.json";function u(e,t,n){try{const r=n.readFileSync(o.join(e,t),"utf8");return JSON.parse(r)}catch(e){return null}}function p(e,t,n,r){const i=o.join(e,t),s=i+"."+process.pid+".tmp";r.writeFileSync(s,JSON.stringify(n),{mode:384,encoding:"utf8"}),r.renameSync(s,i)}e.exports={create:function(e){const t=e.agentDir,n=e.fsModule||r;return{readDefaultProject:function(){const e=u(t,l,n);return e&&"string"==typeof e.default_project_id?e.default_project_id:null},writeDefaultProject:function(e){p(t,l,{default_project_id:e},n)},readToolsCache:function(){const e=u(t,c,n);return e&&Array.isArray(e.tools)&&e.lang===a()?e.tools:null},writeToolsCache:function(e){p(t,c,{lang:a(),tools:e},n)}}},resolveProject:function(e,t){const n=t.filter(function(t){return t.project_id===e});if(1===n.length)return n[0];const r=t.filter(function(t){return t.name===e});if(1===r.length)return r[0];if(0===r.length)throw new i("USAGE",s("state.no_project_named",{ref:e}));const o=r.map(function(e){return e.updated_at?e.project_id+" ("+e.updated_at+")":e.project_id});throw new i("USAGE",s("state.multiple_projects",{ref:e,ids:o.join("\n")}))},readJsonFile:u,writeJsonFile:p,FILE_MODE:384}},947(e,t,n){const r=n(85),{ExplError:o}=n(877),{t:i}=n(42);e.exports={waitFor:async function(e,t,n){const s=t&&t.structuredContent;if(!s||"running"!==s.status)return t;const a=s.execution_id,l=s.operation_id,c=s.capability||"operation",u=n.now(),p=null!=n.timeoutSec?u+1e3*n.timeoutSec:null,d=r.MAX_OPERATION_WAIT_MS,f=n.interrupt||null,m={},h=async function(){const t={execution_id:a,operation_id:l};throw n.projectId&&(t.project_id=n.projectId),await e.callTool("cancel_execution",t).catch(function(){}),new o("INTERRUPTED")};f&&(f.waiting=!0);try{for(;;){n.isInterrupted()&&await h(),n.onProgress(i("wait.waiting",{capability:c,operationId:l}));let t=d;if(null!=p&&(t=Math.min(t,Math.max(0,p-n.now())),0===t))throw new o("EXECUTION_TIMEOUT",i("wait.timed_out",{executionId:a,operationId:l}));const r=e.callTool("get_execution",{execution_id:a,operation_id:l,wait_ms:t}),s=f?await Promise.race([r,f.promise.then(function(){return m})]):await r;s===m&&await h();const u=s&&s.structuredContent&&s.structuredContent.operations,g=u&&u[0];if(!g||"running"!==g.status){if(g&&"failed"===g.status){const e=g.error||{};throw new o(e.error_code||"EXECUTION_FAILED",e.message,null,e.suggested_actions)}return s}}}finally{f&&(f.waiting=!1)}}}},287(e,t,n){const r=n(439),o=/^expc_[0-9a-f]{64}$/;e.exports={create:function(e){const t=e.env||{},n=e.now||Date.now;let i=null;function s(t,o){return i||(i=async function(){const i=n();for(;;){const s=await e.pair(t);if(!s)return{pairing:"unavailable"};if("approved"===s.status&&"string"==typeof s.credential){try{await e.store.set(s.credential)}catch(e){}return{token:s.credential,source:"paired"}}if(s.error){const t="string"==typeof s.error&&r.CODES.indexOf(s.error)>=0;return!t&&e.log&&e.log("pair reply not understood: "+String(JSON.stringify(s.error)).slice(0,200)),{pairing:"error",error:t?s.error:"VERSION_MISMATCH"}}if("pending"!==s.status)return{pairing:"declined"};if(n()-i>=(o.maxWaitMs||0))return{pairing:"pending"};o.onPending&&o.onPending()}}().then(function(e){return i=null,e},function(e){throw i=null,e}),i)}return{resolve:async function(n,r){const i="string"==typeof t.EXPLORATORY_AGENT_TOKEN?t.EXPLORATORY_AGENT_TOKEN.trim():"";if(i&&o.test(i))return e.log&&e.log("credential source=environment paired_format=true"),{token:i,source:"env"};i&&e.log&&e.log("credential source=environment paired_format=false; trying stored credential");let a=null;try{a=await e.store.get()}catch(e){a=null}if(a){if(e.log&&e.log("credential source=store paired_format="+o.test(a)),!o.test(a)){try{await e.store.remove()}catch(e){}return s(String(n||"").slice(0,100),r||{})}return{token:a,source:"store"}}return e.log&&e.log("credential source=pairing"),s(String(n||"").slice(0,100),r||{})},forget:async function(t){if(t&&("store"===t.source||"paired"===t.source))try{await e.store.remove()}catch(e){}}}}}},262(e,t,n){const r=n(896),o=n(611),i=n(692),s=n(928);function a(e,t){let n="";return{push:function(r){n+=r;let o=n.search(/\r?\n\r?\n/);for(;o>=0;){const r=n.slice(0,o);n=n.slice(o).replace(/^\r?\n\r?\n/,"");const i=r.split(/\r?\n/).filter(function(e){return 0===e.indexOf("data:")}).map(function(e){return e.slice(5).replace(/^ /,"")}).join("\n");if(i)try{e(JSON.parse(i))}catch(e){t&&t("unreadable event from Exploratory: "+e.message)}o=n.search(/\r?\n\r?\n/)}}}}function l(e){return new Promise(function(t){let n=!1,r=!1,s=!1;const l=function(e){s||(s=!0,d&&clearTimeout(d),t(e))};let c,u;if(e.url){const t=new URL(e.url);u="https:"===t.protocol?i:o;const n="https:"===t.protocol?443:80;c={hostname:t.hostname,port:t.port?Number(t.port):n,path:t.pathname+t.search,method:"POST",headers:e.headers,agent:!1}}else u=o,c={socketPath:e.socketPath,path:e.path||"/mcp",method:"POST",headers:e.headers,agent:!1};const p=u.request(c,function(t){n=!0,function(e,t,n){const r=e.headers["content-type"]||"",o=/^text\/event-stream/i.test(r),i=/^application\/json/i.test(r),s=a(t.onMessage,t.onParseError);let l="";e.setEncoding("utf8"),e.on("data",function(e){o?s.push(e):l+=e}),e.on("error",function(){}),e.on("close",function(){let s=null;if(!o&&l.trim())try{t.onMessage(JSON.parse(l))}catch(n){i?t.onParseError&&t.onParseError("unreadable response from Exploratory: HTTP "+e.statusCode):s=l.slice(0,1024)}n({complete:!!e.complete,statusCode:e.statusCode,connectError:null,contentType:r||null,rawBody:s,wwwAuthenticate:e.headers["www-authenticate"]||null})})}(t,e,l)});let d=null;e.timeoutMs&&e.timeoutMs>0&&(d=setTimeout(function(){p.destroy(),n||l({complete:!1,statusCode:null,connectError:"ETIMEDOUT",requestSent:r,contentType:null,rawBody:null})},e.timeoutMs)),p.on("socket",function(e){e.connecting||(r=!0),e.once("connect",function(){r=!0})}),p.on("error",function(e){n||l({complete:!1,statusCode:null,connectError:e.code||"CONNECTION_FAILED",requestSent:r,contentType:null,rawBody:null})}),p.end(e.body)})}e.exports={requestPairing:function(e){const t=JSON.stringify({name:e.name});let n=null;return l({socketPath:e.socketPath,path:"/pair",headers:{"Content-Type":"application/json",Accept:"application/json","Content-Length":Buffer.byteLength(t),Host:"localhost","x-exploratory-channel":e.channel},body:t,timeoutMs:4e4,onMessage:function(e){n=e}}).then(function(e){return e.connectError||!n?null:n})},readEndpoint:function(e){try{const t=JSON.parse(r.readFileSync(s.join(e,"endpoint.json"),"utf8"));return t&&"string"==typeof t.socket?t:null}catch(e){return null}},post:l,createEventStreamParser:a}},49(e,t,n){const r=n(896),o=n(857),i=n(928),s=n(713),a=o.homedir()||process.env.HOME||process.env.HOMEPATH||process.env.USERPROFILE;function l(e){return s.hasUTF8Multibyte(e)||/\s/.test(e)}function c(){let e=null;try{e=r.readFileSync(i.resolve(a,".exploratory_home")).toString().trim()}catch(e){}return e}function u(){return l(a)?"win32"===o.platform()?"\\exploratory":"/exploratory":i.resolve(a,".exploratory")}e.exports={homeDir:a,hasInvalidCharForRepoPath:l,readExploratoryHomeFile:c,getDefaultUserAccountRootDir:u,getUserAccountRootDir:function(){const e=c();if(e||process.env.EXPLORATORY_HOME){const t=e||process.env.EXPLORATORY_HOME;return{userAccountRootDir:t,hasMultiByteInEXPLORATORY_HOME:l(t)}}return{userAccountRootDir:u(),hasMultiByteInEXPLORATORY_HOME:!1}}}},713(e,t,n){const r={};var o,i=n(857);global.currentVariablesMap?o=global.currentVariablesMap:(o={},global.currentVariablesMap=o),r.registerExploratoryVariable=function(e){o[e]=!0},r.unregisterExploratoryVariable=function(e){delete o[e]},r.clearExploratoryVariables=function(){Object.keys(o).forEach(function(e){delete o[e]})},r.translateVariablePlaceholders=function(e,t){return e.replace(/\@\{([^\}\]]+)(?:\[([^\}\]]+)\])?\}/g,function(e,n,i){const s=r.extractQuoteParameterValue(n);let a=n;if(s&&(a=a.split(",")[0].trim()),t&&!o[a]){var l=new Error("EXP-PARAM-1 :: "+JSON.stringify([a])+" :: Parameter "+a+" is not defined.");throw l.VAR_EXISTENCE_ERROR=!0,l.isR=!0,l}return i?"exploratory_env$`"+n+"`["+i+"]":["FALSE","F"].includes(s)?"!!rlang::sym(exploratory_env$`"+a+"`)":"exploratory_env$`"+a+"`"})};const s=/quote\s*=\s*(TRUE|FALSE|T|F)/i;r.extractQuoteParameterValue=function(e){const t=e.match(s);return t?t[1].toUpperCase():null},r.checkVariableExistence=function(e){if(!o[e]){var t=new Error("EXP-PARAM-1 :: "+JSON.stringify([e])+" :: Parameter "+e+" is not defined.");throw t.VAR_EXISTENCE_ERROR=!0,t.isR=!0,t}},r.escapeForQuotedStringInR=function(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')},r.escapeForSingleQuotedStringInR=function(e){return e.replace(/\\/g,"\\\\").replace(/'/g,"\\'")},r.validateRObjectName=function(e){if(!e)return!1;if(e.length>1&&46===e.charCodeAt(0)&&e.charCodeAt(1)>=48&&e.charCodeAt(1)<=57)return!1;for(var t=0,n=e.length;t<n;t++){var r=e.charCodeAt(t);if(0===t&&r>=48&&r<=57)return!1;if(0===t&&95===r)return!1;if(r>=0&&r<=31)return!1;if(r>=32&&r<=45||47===r)return!1;if(r>=58&&r<=64)return!1;if(r>=91&&r<=94||96===r)return!1;if(r>=123&&r<=127)return!1}return!0},r.hasUTF8Multibyte=function(e){for(var t=0;t<e.length;t++)if(e.charCodeAt(t)>=128)return!0;return!1},r.escapeRegExp=function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},r.escapeHTMLTags=function(e){return"string"!=typeof e?e:e.replace(/[&'`"<>]/g,function(e){return{"&":"&amp;","'":"&#x27;","`":"&#x60;",'"':"&quot;","<":"&lt;",">":"&gt;"}[e]})},r.translateVariablePlaceholdersWithDummy=function(e){return e.replace(/@{[^}]*}/g,function(e){return"c("+e.replace(/./g,"X").slice(2,-1)+")"}).replace(/\bai\s*\(\s*(@[\p{L}\p{N}_-]+)/gu,function(e){return'ai(""'})},r.compareVersionStr=function(e,t,n){var r=n&&n.lexicographical,o=n&&n.zeroExtend,i=e.split("."),s=t.split(".");function a(e){return(r?/^\d+[A-Za-z]*$/:/^\d+$/).test(e)}if(!i.every(a)||!s.every(a))return NaN;if(o){for(;i.length<s.length;)i.push("0");for(;s.length<i.length;)s.push("0")}r||(i=i.map(Number),s=s.map(Number));for(var l=0;l<i.length;++l){if(s.length===l)return 1;if(i[l]!==s[l])return i[l]>s[l]?1:-1}return i.length!=s.length?-1:0},r.getValueAtPath=function(e,t,n){if(e&&t){var r=e;if(Array.isArray(t)){if(0===t.length)return;t.forEach(function(e){r=r?r[e]:void 0})}else r=r[t];return n&&(void 0!==n[r]&&null!==n[r]?r=n[r]:n["*"]&&(r=r?n["*"]:void 0)),r}},r.isTestMode=function(){return!!process.env.EXPLORATORY_TEST_RUNNER_ENABLED||!!process.env.EXPECTED_RESULT_DIR},r.generateRandomStr=function(){var e=function(){var e=(52*(1+Math.random())|0)%52;return e>=26?String.fromCharCode(97+e-26):String.fromCharCode(65+e)},t=function(){return e()+e()+e()+(10*(1+Math.random())|0)%10};return t()+t()},r.generateIdStr=function(e){var t="";return e&&(t=(t=e.replace(/[^0-9a-zA-Z ]/g," ").trim().replace(/[ ]{2,}/g," ")).replace(/ /g,"-")),t?t+"-"+r.generateRandomStr():r.generateRandomStr()},r.isAdhocChart=function(){return!!window?.parent?.exploratory?.adc},r.isIgnorableWarning=function(e){return["Warning: ReactDOM.unstable_renderSubtreeIntoContainer() is no longer supported in React 18.",'Warning: [react-bootstrap] Specifying only the `"hover"` trigger limits the visibilty of the overlay to just mouse users.'].some(t=>e.startsWith(t))},r.escapeSpecialCharacterForRegex=function(e){return["\\\\","\\$","\\*","\\+","\\.","\\?","\\[","\\]","\\^","\\{","\\}","\\|","\\(","\\)"].reduce(function(e,t){return e.replace(new RegExp(t,"g"),t)},e)},r.escapePathForR=function(e){return"win32"===i.platform()?(e=e.replace(/"/g,"")).replace(/\\/g,"\\\\"):e},r.isWin32bit=function(){return"win32"===i.platform()&&"x64"!==process.arch},e.exports=r},317(e){"use strict";e.exports=require("child_process")},982(e){"use strict";e.exports=require("crypto")},896(e){"use strict";e.exports=require("fs")},611(e){"use strict";e.exports=require("http")},692(e){"use strict";e.exports=require("https")},857(e){"use strict";e.exports=require("os")},928(e){"use strict";e.exports=require("path")},18(e){"use strict";e.exports=require("tty")},16(e){"use strict";e.exports=require("url")},169(e){"use strict";e.exports=JSON.parse('{"PARTIALLY_CREATED.message":"The create failed and a partial artifact remains.","PARTIALLY_CREATED.action":"Do not create it again; update or delete the remaining artifact using the returned id.","DESKTOP_NOT_RUNNING.message":"Exploratory Desktop is not running.","DESKTOP_NOT_RUNNING.action":"Ask the user to start Exploratory Desktop; this connection will work once it is running, without reconnecting","NOT_SIGNED_IN.message":"No user is signed in to Exploratory.","NOT_SIGNED_IN.action":"Sign in to Exploratory, then retry","UNAUTHORIZED.message":"This application has not been approved in Exploratory, or its access was removed.","UNAUTHORIZED.action":"Retry: Exploratory asks the user to approve this application; do not ask the user for a token or password","PAIRING_PENDING.message":"Exploratory is waiting for the user to approve this application.","PAIRING_PENDING.action":"Ask the user to answer the request shown in Exploratory, then retry","CHANNEL_DISABLED.message":"This way of connecting to Exploratory (MCP or CLI) is turned off in the Exploratory settings.","CHANNEL_DISABLED.action":"Ask the user to turn it on in Exploratory: System Settings > MCP / CLI (the Japanese UI shows the same item as システム設定 > MCP / CLI), then retry","PAIRING_REQUIRED.message":"This connection was not accepted.","PAIRING_REQUIRED.action":"Tell the user the connection was not accepted; do not ask them to approve it","PROJECT_NOT_OPEN.message":"The project exists but is not open in Exploratory.","PROJECT_NOT_OPEN.action":"Open the project in Exploratory, then retry","NOT_FOUND.message":"The requested object was not found.","NOT_FOUND.action":"Call list_created_artifacts, list_charts or list_analytics to see available artifacts","PERMISSION_DENIED.message":"This application is not permitted to perform the operation.","PERMISSION_DENIED.action":"Tell the user this operation is not permitted for this connection","CONFIRMATION_REQUIRED.message":"The operation needs the user\'s confirmation.","CONFIRMATION_REQUIRED.action":"Ask the user to confirm in Exploratory","CONFIRMATION_DECLINED.message":"The user declined the operation in Exploratory.","CONFIRMATION_DECLINED.action":"Do not try again or look for another way to do the same thing; tell the user it was declined","INVALID_PARAMETER.message":"A parameter is invalid.","INVALID_PARAMETER.action":"Read the tool\'s description and input schema, fix the parameter the message names, then call the tool again","INVALID_COLUMN.message":"The column does not exist in the data frame.","INVALID_COLUMN.action":"Call get_data_frame to see the columns","INVALID_COLUMN_TYPE.message":"The column has the wrong type for the operation.","INVALID_COLUMN_TYPE.action":"Add a converted column with create_wrangling_step (a calculation, for example as.character(<column>), cut(<column>, ...) or <column> == \\"<value>\\"), then use that column","REVISION_CONFLICT.message":"The artifact changed since it was last read.","REVISION_CONFLICT.action":"Re-read the artifact and reconcile before updating","EXECUTION_FAILED.message":"The operation failed in Exploratory.","EXECUTION_FAILED.action":"Fix the cause the message names, then call the tool again; if it fails the same way twice, tell the user what failed","EXECUTION_TIMEOUT.message":"The operation took longer than allowed.","EXECUTION_TIMEOUT.action":"Retry, or use get_execution for the result","R_REQUIRED.message":"The document has no rendered output to export yet.","R_REQUIRED.action":"Ask the user to open it in Exploratory once so it renders, then call the tool again","PDF_EXPORT_FAILED.message":"Exploratory could not make the PDF.","PDF_EXPORT_FAILED.action":"Fix the cause the message names, then call the tool again; if it fails the same way twice, tell the user what failed","PDF_EXPORT_TIMEOUT.message":"Making the PDF took longer than allowed.","PDF_EXPORT_TIMEOUT.action":"Call the tool once more; if it times out again, tell the user","RESOURCE_BUSY.message":"Exploratory is busy with another operation.","RESOURCE_BUSY.action":"Retry shortly","DATA_EGRESS_LIMIT.message":"The result is larger than the amount that can be returned.","DATA_EGRESS_LIMIT.action":"Ask again for fewer rows or columns","UNSUPPORTED_OPERATION.message":"The operation is not supported.","UNSUPPORTED_OPERATION.action":"Do it with another tool if one fits; otherwise tell the user it is not supported","RESOURCE_BUSY.r_busy.action":"Wait for the current R operation to finish, then retry the same tool with the same arguments.","EXECUTION_FAILED.cancelled.action":"The call was cancelled as asked; do not call the tool again unless the user asks, and tell the user it was cancelled","next.unknown_client_tool":"Call only the tools in your tool list.","next.not_found":"Find the right id with the list or get tool for that kind of object (for example list_data_frames, list_charts, list_analytics, list_notes or list_dashboards), then call again with it.","next.invalid":"Read this tool\'s description and input schema, fix the argument the message names, then call the tool again.","next.not_ready":"Wait a moment, then call the tool again.","next.not_allowed":"Use an object this conversation created or read, or ask the user to allow it.","next.other":"Fix the cause the message names, then call the tool again; if it fails the same way twice, tell the user what failed.","VERSION_MISMATCH.message":"The running Exploratory is not compatible with the version of this app (the MCP helper or expl), so it cannot connect.","VERSION_MISMATCH.action":"Ask the user to start the version of Exploratory that matches this app; for the MCP helper, reconnect the MCP helper from the running Exploratory. Then retry","PREVIEW_STALE.message":"The preview no longer holds: it expired, or the steps or the data changed after it. Nothing was applied.","PREVIEW_STALE.action":"Run preview_wrangling_steps again with the same changes, check the new result, then call apply_wrangling_preview with the new preview_token","GUIDE_REQUIRED.message":"Nothing was written. The guide for this tool has not been read in this connection.","GUIDE_REQUIRED.action":"Call get_guide with the topic and tool named in this error, then call the tool again with the same arguments"}')},719(e){"use strict";e.exports=JSON.parse('{"PARTIALLY_CREATED.message":"作成に失敗し、作りかけのものが残っています。","PARTIALLY_CREATED.action":"同じものを作り直さず、返された id を update または delete に使ってください。","DESKTOP_NOT_RUNNING.message":"Exploratory Desktop が起動していません。","DESKTOP_NOT_RUNNING.action":"利用者に Exploratory Desktop を起動するよう伝えてください。起動すれば、接続し直さなくても、この接続が使えるようになります","NOT_SIGNED_IN.message":"Exploratory にサインインしているユーザーがいません。","NOT_SIGNED_IN.action":"Exploratory にサインインしてから、もう一度実行してください","UNAUTHORIZED.message":"このアプリケーションは Exploratory で承認されていないか、アクセスが取り消されています。","UNAUTHORIZED.action":"もう一度実行してください。Exploratory が利用者にこのアプリケーションの承認を求めます。利用者にトークンやパスワードを尋ねないでください","PAIRING_PENDING.message":"Exploratory は、利用者がこのアプリケーションを承認するのを待っています。","PAIRING_PENDING.action":"Exploratory に表示された確認に答えるよう、利用者に伝えてから、もう一度実行してください","CHANNEL_DISABLED.message":"Exploratory の設定で、この接続方法(MCP または CLI)が無効になっています。","CHANNEL_DISABLED.action":"利用者に、Exploratory の システム設定 > MCP / CLI で有効にするよう伝えてから、もう一度実行してください","PAIRING_REQUIRED.message":"この接続は受け付けられませんでした。","PAIRING_REQUIRED.action":"接続が受け付けられなかったことを利用者に伝えてください。承認を依頼しないでください","PROJECT_NOT_OPEN.message":"プロジェクトはありますが、Exploratory で開かれていません。","PROJECT_NOT_OPEN.action":"Exploratory でプロジェクトを開いてから、もう一度実行してください","NOT_FOUND.message":"指定されたオブジェクトが見つかりません。","NOT_FOUND.action":"list_created_artifacts、list_charts、list_analytics を呼んで、使えるものを確認してください","PERMISSION_DENIED.message":"このアプリケーションにはこの操作を行う権限がありません。","PERMISSION_DENIED.action":"この操作はこの接続では許可されていないことを、利用者に伝えてください","CONFIRMATION_REQUIRED.message":"この操作にはユーザーの確認が必要です。","CONFIRMATION_REQUIRED.action":"Exploratory で確認するよう、利用者に伝えてください","CONFIRMATION_DECLINED.message":"利用者が Exploratory でこの操作を断りました。","CONFIRMATION_DECLINED.action":"もう一度実行したり、同じことをする別の方法を探したりせず、断られたことを利用者に伝えてください","INVALID_PARAMETER.message":"パラメータが正しくありません。","INVALID_PARAMETER.action":"ツールの説明と入力スキーマを読み、メッセージに出ているパラメータを直してから、もう一度ツールを呼んでください","INVALID_COLUMN.message":"指定された列がデータフレームにありません。","INVALID_COLUMN.action":"get_data_frame を呼んで、列を確認してください","INVALID_COLUMN_TYPE.message":"この操作には列の型が合いません。","INVALID_COLUMN_TYPE.action":"create_wrangling_step で変換した列を追加し(計算で as.character(<列>)、cut(<列>, ...)、<列> == \\"<値>\\" など)、その列を使ってください","REVISION_CONFLICT.message":"最後に読み込んだあとで、このオブジェクトが変更されました。","REVISION_CONFLICT.action":"もう一度読み込んで内容を確認してから、更新してください","EXECUTION_FAILED.message":"Exploratory で操作に失敗しました。","EXECUTION_FAILED.action":"メッセージに出ている原因を直してから、もう一度ツールを呼んでください。同じ失敗が2回続くときは、失敗した内容を利用者に伝えてください","EXECUTION_TIMEOUT.message":"操作が許容時間を超えました。","EXECUTION_TIMEOUT.action":"もう一度実行するか、get_execution で結果を確認してください","R_REQUIRED.message":"書き出すための描画結果がまだありません。","R_REQUIRED.action":"Exploratory で一度開いて描画するよう利用者に伝えてから、もう一度ツールを呼んでください","PDF_EXPORT_FAILED.message":"Exploratory で PDF を作成できませんでした。","PDF_EXPORT_FAILED.action":"メッセージに出ている原因を直してから、もう一度ツールを呼んでください。同じ失敗が2回続くときは、失敗した内容を利用者に伝えてください","PDF_EXPORT_TIMEOUT.message":"PDF の作成が制限時間を超えました。","PDF_EXPORT_TIMEOUT.action":"もう一度ツールを呼んでください。再び時間切れになるときは、利用者に伝えてください","RESOURCE_BUSY.message":"Exploratory が別の操作を実行中です。","RESOURCE_BUSY.action":"しばらくしてから、もう一度実行してください","DATA_EGRESS_LIMIT.message":"結果が、返せる量を超えています。","DATA_EGRESS_LIMIT.action":"行数や列数を減らして、もう一度頼み直してください","UNSUPPORTED_OPERATION.message":"この操作には対応していません。","UNSUPPORTED_OPERATION.action":"ほかのツールで代用できる場合はそちらを使ってください。できない場合は、対応していないことを利用者に伝えてください","RESOURCE_BUSY.r_busy.action":"いま実行中の R の処理が終わるのを待ってから、同じツールを同じ引数でもう一度呼んでください。","EXECUTION_FAILED.cancelled.action":"頼まれたとおりにキャンセルしました。利用者に頼まれない限りツールを呼び直さず、キャンセルしたことを利用者に伝えてください","next.unknown_client_tool":"ツール一覧にあるツールだけを呼んでください。","next.not_found":"その種類のオブジェクトの list か get のツール(たとえば list_data_frames、list_charts、list_analytics、list_notes、list_dashboards)で正しい id を調べてから、もう一度呼んでください。","next.invalid":"このツールの説明と入力スキーマを読み、メッセージに出ている引数を直してから、もう一度ツールを呼んでください。","next.not_ready":"少し待ってから、もう一度ツールを呼んでください。","next.not_allowed":"この会話で作成または読み込んだオブジェクトを使うか、利用者に許可を求めてください。","next.other":"メッセージに出ている原因を直してから、もう一度ツールを呼んでください。同じ失敗が2回続くときは、失敗した内容を利用者に伝えてください。","VERSION_MISMATCH.message":"起動している Exploratory と、このアプリ(MCP ヘルパーまたは expl)のバージョンに互換性がないため、接続できません。","VERSION_MISMATCH.action":"このアプリと同じバージョンの Exploratory を起動するよう、利用者に伝えてください。MCP ヘルパーの場合は、起動している Exploratory から MCP ヘルパーを接続し直すよう伝えてください。そのあと、もう一度実行してください","PREVIEW_STALE.message":"試し実行の内容がもう成り立っていません。期限が切れたか、試したあとにステップやデータが変わりました。何も確定していません。","PREVIEW_STALE.action":"同じ変更でもう一度 preview_wrangling_steps を実行し、新しい結果を確かめてから、新しい preview_token で apply_wrangling_preview を呼んでください","GUIDE_REQUIRED.message":"何も書き込んでいません。この接続では、この道具のガイドをまだ読んでいません。","GUIDE_REQUIRED.action":"このエラーにある topic と tool で get_guide を呼び、同じ引数でもう一度この道具を呼んでください"}')},174(e){"use strict";e.exports=JSON.parse('{"args.missing_value":"Missing value for {name}.","args.invalid_timeout":"Invalid value for --timeout.","args.json_is_output":"--json only changes the output format to JSON. Pass arguments as flags (--name x) or as JSON with --input <file|->, not as --json \'{...}\'. To pass a value that starts with { as an argument, write it after --.","args.json_parse":"Could not parse JSON: {error}","args.invalid_value_types":"Invalid value for --{flag}. Expected {types}.","args.invalid_boolean":"Invalid boolean for --{flag}.","args.array_as_list":"--{flag} takes one item per flag, but this value is a list (a JSON array or comma-separated). Repeat the flag: --{flag} <value> --{flag} <value>. To pass a value that holds a comma as is, give {prop} as a JSON array in --input.","args.bool_value":"--{flag} is a switch. Write --{flag}, --{flag}=true, --{flag} true or --{flag} false (not {value}).","args.instead_of_positional":"Give either {positional} or --{flag}, not both: --{flag} stands in for {positional}, so write no positional with it. Example: {example}","args.needs_flag_value":"--{flag} is used only with --{other} {value}. Add --{other} {value}.","args.invalid_item":"Invalid {kind} for --{flag}.","args.unknown_flag":"Unknown flag --{flag} for \\"{prefix} {noun} {verb}\\".","args.did_you_mean_flag":" Did you mean --{flag}?","args.unexpected_argument":"Unexpected argument \\"{token}\\" for \\"{prefix} {noun} {verb}\\".","args.too_many_positional":"Too many positional arguments.","args.invalid_enum":"Invalid value for --{flag}. Expected one of: {values}.","args.invalid_number":"Invalid number for --{flag}.","args.invalid_integer":"Invalid integer for --{flag}.","client.no_response":"Exploratory returned no response to this request.","client.pairing_wait":"Waiting for you to approve expl in Exploratory (a request is shown there)...","output.each_cell":"Each cell: {measure}","output.total":"Total","output.showing_rows":"Showing {shown} of {total} rows.","output.warning":"Warning: {text}","output.error":"Error: {text}","output.start_desktop":"Start Exploratory Desktop, then try again.","state.no_project_named":"No project named \\"{ref}\\". Run \\"expl project list\\".","state.multiple_projects":"Multiple projects named \\"{ref}\\". Use the project id (id and last updated):\\n{ids}","wait.waiting":"Waiting for {capability} ({operationId})...","wait.timed_out":"Timed out. Check progress with: expl execution get {executionId} --operation-id {operationId}","main.version_not_running":"Exploratory: not running","main.status_user":"User: {user}","main.describe_tool":"Tool: {tool}","main.describe_risk":"Risk: {risk}","main.describe_positional":"Positional: {positional}","main.describe_project":"Project: pass --project or set a default with expl project use","main.describe_json_only":"JSON-only properties: {props}","main.describe_shape":"Shape of the value:","main.describe_flag_example":"Example: {example}","main.describe_array_repeat":"Give one item per flag, repeated: {repeat}","main.help_array_note":"A flag shown as --x <value>... takes one item per flag; repeat it for several items, e.g. {repeat}","main.guidance_missing":"Server guidance could not be loaded: {reason}","main.desktop_guidance_missing":"Desktop guidance could not be loaded: {reason}","main.describe_example_instead":"Example with --{flag} instead of <{positional}>: {prefix} {noun} {verb} --{flag} \'{example}\'","main.help_commands":"Commands:","main.describe_required":" [required]","main.describe_example":"Example: {prefix} {noun} {verb}{positional} --json","main.help_usage":"Usage: {prefix} <noun> <verb> [args]","main.help_builtin":"Built-in commands:","main.help_nouns":"Nouns: {nouns}","main.help_start_desktop":"Start Exploratory to list its commands.","main.no_project":"No project. Pass --project <id|name> or run \\"expl project use <id|name>\\".","main.hard_to_undo":"This command is hard to undo. Pass --yes to run it.","main.confirm_prompt":"About to run \\"{prefix} {noun} {verb}\\" ({tool}, risk HIGH). Continue? [y/N]","main.cancelled":"Cancelled.","main.usage_completion":"Usage: expl completion bash|zsh|powershell","main.usage_tools_describe":"Usage: {prefix} tools describe <command|tool_name>","main.unknown_command_or_tool":"Unknown command or tool: {ref}","main.usage_tools":"Usage: {prefix} tools list|describe","main.usage_project_use":"Usage: expl project use <id|name>","main.default_project":"Default project: {name} ({projectId})","main.call_args_note":"Pass arguments as flags (--name x) or as JSON with --input <file|->. --json only changes the output to JSON; it is not an argument.","main.usage_call":"Usage: {prefix} call <tool_name>","main.unknown_tool":"Unknown tool: {name}","main.unknown_command_noun":"Unknown command: {prefix} {noun}","main.verbs_for":"Verbs for {noun}: {verbs}","main.usage_noun_verb":"Usage: {prefix} {noun} <verb>","main.unknown_command_noun_verb":"Unknown command: {prefix} {noun} {verb}","main.unknown_command_hint":"Unknown command. Run \\"{prefix} tools list\\".","main.did_you_mean":" Did you mean: {prefix} {candidate}?","main.input_parse":"Could not parse --input JSON: {error}","main.image_saved":"Image saved: {path}","main.missing_id":"Missing {flag} <id>. Pass it to \\"{prefix} {noun} {verb}\\", or give the id as the first argument. In an --input JSON the key is {prop}.","main.usage_lang":"Usage: expl lang [en|ja]","main.lang_current":"UI language: {lang}","main.lang_changed":"UI language changed to {lang}.","main.lang_not_changed":"The UI language was not changed: {reason}","main.candidates":"Available {noun} (pick an id):","server.saved":"Saved {bytes} bytes to {path}","server.query_cut_dataset":"Note: the result was cut at the row limit. Use expl server dataframe export for all rows.","server.query_cut_chart":"Note: the result was cut at the row limit. Narrow the query with filters, or aggregate it.","server.output_no_file":"This command returns no file. --output works with dataframe export, chart get-image, and dataset query / chart query (CSV).","server.output_batch":"--output does not work with several queries (queries). Run one query per call to save it as CSV.","main.verbs_detail":"Details of one command: {prefix} {noun} <verb> --help","main.help_more":"Flags and arguments of each verb: {prefix} <noun> --help. Details of one command: {prefix} <noun> <verb> --help.","main.describe_risk_high":"Risk: {risk} (even with --yes, the user must approve it in the Exploratory window, unless that tool is set to always allow)","main.hard_to_undo_desktop":"This command is hard to undo. Pass --yes to run it. Even with --yes, the user must approve it in the Exploratory window (not needed when that tool is set to always allow).","main.confirm_yes_not_enough":"--yes does not answer for the user: they must approve the request in the Exploratory window, then run the same command again.","main.confirm_run_r_alternative":"If you only need to check numbers, dataframe profile or a chart\'s result can replace run-r and need no approval.","args.unexpected_argument_flag":"Unexpected argument \\"{token}\\" for \\"{prefix} {noun} {verb}\\". Pass this value as --{flag} <{shape}>.","main.verbs_of_noun":"Verbs for {noun}:","main.help_commands_compact":"Commands (run as {prefix} <noun> <verb>), one line per command under its noun:","args.array_extra_value":"Unexpected argument \\"{token}\\" for \\"{prefix} {noun} {verb}\\". --{flag} takes one item per flag: repeat the flag, e.g. --{flag} <value> --{flag} <value>."}')},980(e){"use strict";e.exports=JSON.parse('{"args.missing_value":"{name} の値がありません。","args.invalid_timeout":"--timeout の値が正しくありません。","args.json_is_output":"--json は出力を JSON にするフラグです。引数は --json \'{...}\' ではなく、各フラグ(--name x)か --input <file|->(JSON)で渡してください。{ で始まる値そのものを引数として渡すときは、-- の後ろに書いてください。","args.json_parse":"JSON を解析できませんでした: {error}","args.invalid_value_types":"--{flag} の値が正しくありません。{types} を指定してください。","args.invalid_boolean":"--{flag} は true か false で指定してください。","args.array_as_list":"--{flag} は 1 つの値に 1 項目です。この値は一覧(JSON 配列またはカンマ区切り)に見えます。フラグを繰り返してください: --{flag} <value> --{flag} <value>。カンマを含む値をそのまま渡すときは、--input の JSON で {prop} を配列として指定してください。","args.bool_value":"--{flag} は有無を指定するフラグです。--{flag}、--{flag}=true、--{flag} true、--{flag} false のいずれかで書いてください({value} は使えません)。","args.instead_of_positional":"{positional} と --{flag} は同時に指定できません。--{flag} が {positional} の代わりになるので、位置引数は書きません。例: {example}","args.needs_flag_value":"--{flag} は --{other} {value} のときだけ使えます。--{other} {value} を足してください。","args.invalid_item":"--{flag} の {kind} の値が正しくありません。","args.unknown_flag":"\\"{prefix} {noun} {verb}\\" に --{flag} というフラグはありません。","args.did_you_mean_flag":" --{flag} のことですか?","args.unexpected_argument":"\\"{prefix} {noun} {verb}\\" に不要な引数 \\"{token}\\" があります。","args.too_many_positional":"位置引数が多すぎます。","args.invalid_enum":"--{flag} の値が正しくありません。次のいずれかを指定してください: {values}。","args.invalid_number":"--{flag} は数値で指定してください。","args.invalid_integer":"--{flag} は整数で指定してください。","client.no_response":"Exploratory からこのリクエストへの応答がありません。","client.pairing_wait":"Exploratory で expl の承認を待っています(確認が表示されています)...","output.each_cell":"各セル: {measure}","output.total":"合計","output.showing_rows":"{total} 行中 {shown} 行を表示しています。","output.warning":"警告: {text}","output.error":"エラー: {text}","output.start_desktop":"Exploratory デスクトップを起動してから、もう一度実行してください。","state.no_project_named":"\\"{ref}\\" という名前のプロジェクトはありません。\\"expl project list\\" で確認してください。","state.multiple_projects":"\\"{ref}\\" という名前のプロジェクトが複数あります。プロジェクト ID (ID と最終更新日時) で指定してください:\\n{ids}","wait.waiting":"{capability} ({operationId}) を待っています...","wait.timed_out":"タイムアウトしました。進捗は次のコマンドで確認できます: expl execution get {executionId} --operation-id {operationId}","main.version_not_running":"Exploratory: 起動していません","main.status_user":"ユーザー: {user}","main.describe_tool":"ツール: {tool}","main.describe_risk":"リスク: {risk}","main.describe_positional":"位置引数: {positional}","main.describe_project":"プロジェクト: --project で指定するか、expl project use で既定を設定してください","main.describe_json_only":"JSON のみで指定できる項目: {props}","main.describe_shape":"値の形:","main.describe_flag_example":"例: {example}","main.describe_array_repeat":"1 項目ごとにフラグを繰り返して指定します: {repeat}","main.help_array_note":"--x <value>... と書かれたフラグは 1 項目ごとに繰り返して指定します。例: {repeat}","main.guidance_missing":"サーバーの案内を取得できませんでした: {reason}","main.desktop_guidance_missing":"Desktop の案内を取得できませんでした: {reason}","main.describe_example_instead":"<{positional}> の代わりに --{flag} を使う例: {prefix} {noun} {verb} --{flag} \'{example}\'","main.help_commands":"コマンド:","main.describe_required":" [必須]","main.describe_example":"例: {prefix} {noun} {verb}{positional} --json","main.help_usage":"使い方: {prefix} <名詞> <動詞> [引数]","main.help_builtin":"組み込みコマンド:","main.help_nouns":"名詞: {nouns}","main.help_start_desktop":"コマンド一覧を表示するには Exploratory を起動してください。","main.no_project":"プロジェクトが指定されていません。--project <id|name> を付けるか、\\"expl project use <id|name>\\" を実行してください。","main.hard_to_undo":"このコマンドは元に戻しにくい操作です。実行するには --yes を付けてください。","main.confirm_prompt":"\\"{prefix} {noun} {verb}\\" ({tool}、リスク HIGH) を実行します。続けますか? [y/N]","main.cancelled":"キャンセルしました。","main.usage_completion":"使い方: expl completion bash|zsh|powershell","main.usage_tools_describe":"使い方: {prefix} tools describe <command|tool_name>","main.unknown_command_or_tool":"コマンドまたはツールが見つかりません: {ref}","main.usage_tools":"使い方: {prefix} tools list|describe","main.usage_project_use":"使い方: expl project use <id|name>","main.default_project":"デフォルトのプロジェクト: {name} ({projectId})","main.call_args_note":"引数は各フラグ(--name x)か --input <file|->(JSON)で渡します。--json は出力を JSON にするだけで、引数ではありません。","main.usage_call":"使い方: {prefix} call <tool_name>","main.unknown_tool":"ツールが見つかりません: {name}","main.unknown_command_noun":"コマンドが見つかりません: {prefix} {noun}","main.verbs_for":"{noun} の動詞: {verbs}","main.usage_noun_verb":"使い方: {prefix} {noun} <動詞>","main.unknown_command_noun_verb":"コマンドが見つかりません: {prefix} {noun} {verb}","main.unknown_command_hint":"コマンドが見つかりません。\\"{prefix} tools list\\" で一覧を確認してください。","main.did_you_mean":" {prefix} {candidate} のことですか?","main.image_saved":"画像を保存しました: {path}","main.input_parse":"--input の JSON を解析できませんでした: {error}","error.DESKTOP_NOT_RUNNING.message":"Exploratory が起動していません。","error.DESKTOP_NOT_RUNNING.action":"Exploratory を起動してから、もう一度実行してください","error.CHANNEL_DISABLED.message":"システム設定で、この接続方法(MCP または CLI)が無効になっています。","error.CHANNEL_DISABLED.action":"Exploratory の システム設定 > MCP / CLI で有効にしてから、もう一度実行してください","error.NOT_SIGNED_IN.message":"Exploratory にサインインしているユーザーがいません。","error.NOT_SIGNED_IN.action":"Exploratory にサインインしてから、もう一度実行してください","error.UNAUTHORIZED.message":"このアプリケーションは Exploratory で承認されていないか、アクセスが取り消されています。","error.UNAUTHORIZED.action":"もう一度実行してください。Exploratory が承認を求めます(トークンやパスワードを利用者に聞かないでください)","error.PAIRING_PENDING.message":"Exploratory が、このアプリケーションの承認を待っています。","error.PAIRING_PENDING.action":"Exploratory に表示された確認に答えてから、もう一度実行してください","error.PAIRING_REQUIRED.message":"この接続は受け付けられませんでした。","error.PAIRING_REQUIRED.action":"接続が受け付けられなかったことを利用者に伝えてください","error.PROJECT_NOT_OPEN.message":"プロジェクトはありますが、Exploratory で開かれていません。","error.PROJECT_NOT_OPEN.action":"Exploratory でプロジェクトを開いてから、もう一度実行してください","error.NOT_FOUND.message":"指定されたオブジェクトが見つかりません。","error.NOT_FOUND.action":"list_created_artifacts、list_charts、list_analytics で使えるものを確認してください","error.PERMISSION_DENIED.message":"このアプリケーションにはこの操作を行う権限がありません。","error.PERMISSION_DENIED.action":"この操作はこの接続では許可されていないことをユーザーに伝えてください","error.CONFIRMATION_REQUIRED.message":"この操作にはユーザーの確認が必要です。","error.CONFIRMATION_REQUIRED.action":"Exploratory で確認してください","error.CONFIRMATION_DECLINED.message":"ユーザーが Exploratory でこの操作を断りました。","error.CONFIRMATION_DECLINED.action":"同じ操作を繰り返さず、断られたことをユーザーに伝えてください","error.INVALID_PARAMETER.message":"パラメータが正しくありません。","error.INVALID_PARAMETER.action":"expl <名詞> <動詞> --help で指定できる値を確認し、メッセージに出ているパラメータを直して、もう一度実行してください","error.INVALID_COLUMN.message":"指定された列がデータフレームにありません。","error.INVALID_COLUMN.action":"get_data_frame で列を確認してください","error.INVALID_COLUMN_TYPE.message":"この操作には列の型が合いません。","error.INVALID_COLUMN_TYPE.action":"create_wrangling_step で変換した列を追加し (計算で as.character(<列>)、cut(<列>, ...)、<列> == \\"<値>\\" など)、その列を使ってください","error.REVISION_CONFLICT.message":"最後に読み込んだあとで、このオブジェクトが変更されました。","error.REVISION_CONFLICT.action":"もう一度読み込んで内容を確認してから、更新してください","error.EXECUTION_FAILED.message":"Exploratory で操作に失敗しました。","error.EXECUTION_FAILED.action":"メッセージに出ている原因を直して、もう一度実行してください。同じ失敗が続くときは、失敗した内容を確認してください","error.EXECUTION_TIMEOUT.message":"操作が許容時間を超えました。","error.EXECUTION_TIMEOUT.action":"もう一度実行するか、get_execution で結果を確認してください","error.RESOURCE_BUSY.message":"Exploratory が別の操作を実行中です。","error.RESOURCE_BUSY.action":"しばらくしてから、もう一度実行してください","error.PARTIALLY_CREATED.message":"作成に失敗し、作りかけのものが残っています。","error.PARTIALLY_CREATED.action":"同じものを作り直さず、返された id を update または delete に使ってください。","error.DATA_EGRESS_LIMIT.message":"結果が、返せる量を超えています。","error.DATA_EGRESS_LIMIT.action":"行数や列数を減らして、もう一度頼み直してください","error.UNSUPPORTED_OPERATION.message":"この操作には対応していません。","error.UNSUPPORTED_OPERATION.action":"ほかのコマンドで代用できる場合はそちらを使ってください。できない場合は未対応の操作です","main.missing_id":"{flag} <id> が指定されていません。\\"{prefix} {noun} {verb}\\" に渡すか、最初の引数に id を指定してください。--input の JSON で渡すときのキーは {prop} です。","main.usage_lang":"使い方: expl lang [en|ja]","main.lang_current":"UI の言語: {lang}","main.lang_changed":"UI の言語を {lang} に変えました。","main.lang_not_changed":"UI の言語を変えられませんでした: {reason}","main.candidates":"指定できる {noun} (id を選んでください):","error.PDF_EXPORT_FAILED.message":"PDF を作成できませんでした。","error.PDF_EXPORT_FAILED.action":"メッセージに示された原因を直して再実行し、同じ失敗が2回続く場合は失敗内容を利用者に伝えてください","error.PDF_EXPORT_TIMEOUT.message":"PDF の作成が制限時間を超えました。","error.PDF_EXPORT_TIMEOUT.action":"もう一度実行し、再び時間切れになる場合は利用者に伝えてください","error.R_REQUIRED.message":"書き出すための描画結果がまだありません。","error.R_REQUIRED.action":"Exploratory で一度開いて描画してから、もう一度実行してください","error.VERSION_MISMATCH.message":"起動している Exploratory とこの expl のバージョンに互換性がないため、接続できません。","error.VERSION_MISMATCH.action":"この expl と同じバージョンの Exploratory を起動してから、もう一度実行してください","error.PREVIEW_STALE.message":"試し実行の内容がもう成り立っていません。期限が切れたか、試したあとにステップやデータが変わりました。何も確定していません。","error.PREVIEW_STALE.action":"同じ変更でもう一度試し実行し、新しい結果を確かめてから確定してください","error.GUIDE_REQUIRED.message":"何も書き込んでいません。この接続では、この道具のガイドをまだ読んでいません。","error.GUIDE_REQUIRED.action":"このエラーにある topic と tool で get_guide を呼び、同じ引数でもう一度この道具を呼んでください","server.saved":"{path} に {bytes} バイト保存しました","server.query_cut_dataset":"注意: 結果は行数の上限で切れています。全行は expl server dataframe export で取得してください。","server.query_cut_chart":"注意: 結果は行数の上限で切れています。フィルターで絞り込むか、集計してください。","server.output_no_file":"このコマンドはファイルを返しません。--output が使えるのは dataframe export、chart get-image、dataset query / chart query (CSV) です。","server.output_batch":"複数のクエリ (queries) には --output を使えません。CSV に保存するときは 1 回に 1 つのクエリを実行してください。","main.verbs_detail":"1 コマンドの詳細: {prefix} {noun} <動詞> --help","main.help_more":"動詞ごとのフラグ・引数: {prefix} <名詞> --help。1 コマンドの詳細: {prefix} <名詞> <動詞> --help。","main.describe_risk_high":"リスク: {risk}(--yes を付けても、Exploratory の画面で利用者の承認が要ります。その道具を「常に許可」にしていれば不要)","main.hard_to_undo_desktop":"このコマンドは元に戻しにくい操作です。実行するには --yes を付けてください。--yes を付けても、Exploratory の画面で利用者の承認が要ります(その道具を「常に許可」にしていれば不要)。","main.confirm_yes_not_enough":"--yes は利用者の代わりに答えません。利用者が Exploratory の画面で承認してから、同じコマンドをもう一度実行してください。","main.confirm_run_r_alternative":"数字の確認だけなら、承認の要らない dataframe profile やチャートの結果で run-r の代わりにできます。","args.unexpected_argument_flag":"\\"{prefix} {noun} {verb}\\" に不要な引数 \\"{token}\\" があります。この値は --{flag} <{shape}> で渡してください。","error.CONFIRMATION_REQUIRED.pending_action":"Exploratory の画面に確認が出ています。利用者に画面で答えてもらってから、同じ引数でもう一度実行してください","main.verbs_of_noun":"{noun} の動詞:","main.help_commands_compact":"コマンド({prefix} <名詞> <動詞> で実行。名詞ごとに 1 行 1 コマンド):","args.array_extra_value":"\\"{prefix} {noun} {verb}\\" に不要な引数 \\"{token}\\" があります。--{flag} は 1 つの値に 1 項目です。複数渡すときはフラグを繰り返してください: --{flag} <value> --{flag} <value>。"}')}};const t={};function n(r){const o=t[r];if(void 0!==o)return o.exports;const i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}const r=n(982),o=n(896),i=n(857),s=n(928),a=n(18),l=n(49),c=n(823),u=n(965),p=n(736),d=n(107),f=n(42),m=n(351),h=n(587),g=n(654),_=n(134),E=n(677),w=m.createWriter({fd:1,isTTY:a.isatty(1)}),y=m.createWriter({fd:2,isTTY:a.isatty(2)});function x(e){const t=function(){process.exit(e)};Promise.all([w.flush(),y.flush()]).then(t).catch(t)}function O(e){try{y.write(f.t("output.error",{text:e&&e.message?e.message:String(e)})+"\n")}catch(e){}x(1)}process.on("beforeExit",function(){process.exit(process.exitCode||0)}),process.on("uncaughtException",O),process.on("unhandledRejection",O);let I=null;const v={promise:new Promise(function(e){I=e}),waiting:!1};let N=!1;process.on("SIGINT",function(){N=!0,I(),v.waiting||x(130)});const T=process.argv.slice(2);"1"===process.env.EXPL_ARGV_SEP&&("--"===T[0]&&T.shift(),delete process.env.EXPL_ARGV_SEP);const S=l.getUserAccountRootDir().userAccountRootDir,A=c.agentDir(S),R=function(){try{return JSON.parse(o.readFileSync(s.join(__dirname,"..","package.json"),"utf8")).version||"unknown"}catch(e){return"unknown"}}();f.setLang(p.readUILang(A));const b=r.randomBytes(16).toString("hex"),U=T.indexOf("--verbose")>=0?function(e){y.write(e+"\n")}:null,C=_.create({rootDir:S});d.run(T,{client:u.create({agentDir:A,env:process.env,sessionId:b,clientVersion:R,onTrace:U,onPairingWait:function(){y.write(f.t("client.pairing_wait")+"\n")}}),state:E.create({agentDir:A}),rootDir:S,sessionId:b,onTrace:U,server:{state:C,platform:process.platform,createClient:g.create,login:h.login,revoke:h.revoke,userinfo:h.userinfo,refresh:h.refresh,request:null,post:null,httpModule:null,spawn:null},writeFileBytes:function(e,t){o.writeFileSync(e,t)},writeStdoutBytes:function(e){let t=0;for(;t<e.length;)t+=o.writeSync(1,e,t,e.length-t)},stdout:w,stderr:y,stdinIsTTY:a.isatty(0),stdoutIsTTY:a.isatty(1),readStdin:function(){return o.readFileSync(0,"utf8")},readLine:function(){const e=Buffer.alloc(1),t=[];for(;;){let n;try{n=o.readSync(0,e,0,1,null)}catch(e){if("EAGAIN"===e.code)continue;if("EOF"===e.code)break;throw e}if(0===n||10===e[0])break;t.push(e[0])}return Buffer.from(t).toString("utf8").replace(/\r$/,"")},readSecret:function(e){y.write(e);const t=Buffer.alloc(1),n=[];process.stdin.setRawMode(!0);try{for(;;){let e;try{e=o.readSync(0,t,0,1,null)}catch(e){if("EAGAIN"===e.code)continue;if("EOF"===e.code)break;throw e}const r=t[0];if(0===e||10===r||13===r)break;3===r&&(process.stdin.setRawMode(!1),o.writeSync(2,"\n"),process.exit(130)),8!==r&&127!==r?n.push(r):n.pop()}}finally{process.stdin.setRawMode(!1),process.stdin.pause(),y.write("\n")}return Buffer.from(n).toString("utf8")},readFile:function(e){return o.readFileSync(e,"utf8")},writeFile:function(e,t){o.writeFileSync(e,t)},makeTmpDir:function(){return o.mkdtempSync(s.join(i.tmpdir(),"expl-"))},pathJoin:s.join,env:process.env,isInterrupted:function(){return N},interrupt:v,version:R}).then(x).catch(O)})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exploratory/cli",
3
- "version": "1.0.0-rc.1",
3
+ "version": "1.0.0",
4
4
  "description": "Command-line interface for Exploratory",
5
5
  "bin": {
6
6
  "expl": "bin/expl.js"