@messenger-agent/client 0.29.0 → 0.30.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/dist/args.d.ts CHANGED
@@ -4,6 +4,7 @@ export type InstallArgs = {
4
4
  tunnelId?: string;
5
5
  token?: string;
6
6
  workspace?: string;
7
+ server?: string;
7
8
  serverUrl?: string;
8
9
  configPath: string;
9
10
  dataDir: string;
package/dist/args.js CHANGED
@@ -1,5 +1,5 @@
1
- import S from"cac";import{defaultConfigPath as u,defaultDataDir as U,resolvePath as d}from"./paths.js";import{normalizeReleaseChannel as $}from"./runtime.js";const C="CODING_AGENT_TUNNEL_SERVER_URL",v=["install","upgrade","sessions","maintenance","status","start","restart","stop","uninstall"],W=[...v,"run-service"];class r extends Error{}function D(n,t=process.env){if(n[0]==="--version"||n[0]==="-v"){if(n.length>1)throw new r(`Unknown option for version: ${n[1]}`);return{command:"version"}}const o=n[0];if(!o||o==="--help"||o==="-h")throw new r(b());if(n.includes("--"))throw new r(`Unknown option for ${o}: --`);P(n);let i;const e=h({env:t,includeInternalCommands:!0,onParsed(a){i=a}});try{e.parse(["node","coding-agent",...n])}catch(a){const s=a instanceof Error?a.message:String(a);throw new r(I(s,n))}if(!i)throw new r(`Unknown command: ${o}`);return i}function b(){const n=h({includeInternalCommands:!1});return n.help(),`${A(()=>n.outputHelp())}
1
+ import v from"cac";import{defaultConfigPath as u,defaultDataDir as U,resolvePath as d}from"./paths.js";import{normalizeReleaseChannel as S}from"./runtime.js";const $="CODING_AGENT_TUNNEL_SERVER_URL",C=["install","upgrade","sessions","maintenance","status","start","restart","stop","uninstall"],W=[...C,"run-service"];class r extends Error{}function R(n,t=process.env){if(n[0]==="--version"||n[0]==="-v"){if(n.length>1)throw new r(`Unknown option for version: ${n[1]}`);return{command:"version"}}const o=n[0];if(!o||o==="--help"||o==="-h")throw new r(b());if(n.includes("--"))throw new r(`Unknown option for ${o}: --`);P(n);let i;const e=h({env:t,includeInternalCommands:!0,onParsed(a){i=a}});try{e.parse(["node","coding-agent",...n])}catch(a){const s=a instanceof Error?a.message:String(a);throw new r(I(s,n))}if(!i)throw new r(`Unknown command: ${o}`);return i}function b(){const n=h({includeInternalCommands:!1});return n.help(),`${x(()=>n.outputHelp())}
2
2
 
3
3
  Global Options:
4
- -v, --version Show the installed client version`}function h(n){const t=S("coding-agent"),o=n.env??process.env,i=n.onParsed??(()=>{});t.command("install","Install and configure the local coding-agent service").option("--tunnel-id <id>","Tunnel id").option("--token <token>","Tunnel token").option("--workspace <path>","Workspace path (default: ~/messenger-workspace)").option("--server-url <wss-url>","Tunnel server URL").option("--config <path>","Config file path",{default:u}).option("--data-dir <path>","Data directory",{default:U}).option("--workspace-id <id>","Workspace id").option("--workspace-name <name>","Workspace display name").option("--channel <channel>","Auto-upgrade release channel: latest, beta, or alpha").action(e=>{const a=c(e.tunnelId),s=c(e.token),l=c(e.workspace);i({command:"install",tunnelId:a,token:s,workspace:l?d(l):void 0,serverUrl:c(e.serverUrl)??o[C],configPath:d(f(e.config,"--config")),dataDir:d(f(e.dataDir,"--data-dir")),workspaceId:c(e.workspaceId),workspaceName:c(e.workspaceName),channel:g(e.channel)})}),t.command("upgrade","Upgrade the local coding-agent runtime").option("--version <version>","Runtime version or release channel",{default:"latest"}).option("--channel <channel>","Auto-upgrade release channel: latest, beta, or alpha").option("--config <path>","Config file path",{default:u}).option("--delay <seconds>","Schedule the upgrade after a delay").option("--allow-waiting","Allow upgrade while sessions wait for user input").action(e=>{const a=p(e.delay),s=e.allowWaiting===!0;w(s,a),i({command:"upgrade",version:f(e.version,"--version"),configPath:d(f(e.config,"--config")),delaySeconds:a,allowWaiting:s,channel:g(e.channel)})}),t.command("sessions","Show active and waiting client sessions").option("--json","Print machine-readable JSON").option("--config <path>","Config file path",{default:u}).action(e=>{i({command:"sessions",json:e.json===!0,configPath:d(f(e.config,"--config"))})}),t.command("maintenance <action>","Inspect or cancel scheduled maintenance").option("--json","Print machine-readable JSON").option("--config <path>","Config file path",{default:u}).action((e,a)=>{if(e!=="status"&&e!=="cancel")throw new r(`Unknown maintenance action: ${e}`);i({command:"maintenance",action:e,json:a.json===!0,configPath:d(f(a.config,"--config"))})});for(const e of["status","start"])t.command(e,`${y(e)} the local coding-agent service`).action(()=>{i({command:e})});t.command("restart [agent]","Restart the local service or a specific agent").option("--delay <seconds>","Schedule the restart after a delay").option("--allow-waiting","Allow restart while sessions wait for user input").action((e,a)=>{if(e!==void 0&&e!=="codex"&&e!=="claude")throw new r(`Unknown agent for restart: ${e}`);const s=p(a.delay),l=a.allowWaiting===!0;w(l,s),i({command:"restart",agent:e,delaySeconds:s,allowWaiting:l})});for(const e of["stop","uninstall"])t.command(e,`${y(e)} the local coding-agent service`).option("--delay <seconds>",`Schedule the ${e} after a delay`).option("--allow-waiting",`Allow ${e} while sessions wait for user input`).action(a=>{const s=p(a.delay),l=a.allowWaiting===!0;w(l,s),i({command:e,delaySeconds:s,allowWaiting:l})});return n.includeInternalCommands&&t.command("run-service","Run the managed service supervisor").option("--config <path>","Config file path").action(e=>{const a=c(e.config);i({command:"run-service",configPath:a?d(a):void 0})}),t}function f(n,t){const o=c(n);if(!o)throw new r(`Missing value for ${t}`);return o}function c(n){return typeof n=="string"?n:void 0}function g(n){const t=c(n);if(t!==void 0)try{return $(t)}catch{throw new r(`Unknown release channel for --channel: ${t} (expected latest, beta, or alpha)`)}}function p(n){if(n===void 0)return;const t=typeof n=="number"?String(n):f(n,"--delay");if(!/^\d+$/.test(t))throw new r("--delay must be an integer between 1 and 86400 seconds");const o=Number.parseInt(t,10);if(o<1||o>86400)throw new r("--delay must be an integer between 1 and 86400 seconds");return o}function w(n,t){if(n&&t===void 0)throw new r("--allow-waiting requires --delay")}function I(n,t){if(n.startsWith("Unknown option `")){const o=m(t);if(o)return`Unknown option for ${t[0]}: ${o}`}if(n.startsWith("option `")){const o=/^option `([^` ]+)/.exec(n);if(o)return`Missing value for ${o[1]}`}if(n.startsWith("Unused args:")){const o=t.slice(1).find(i=>!i.startsWith("-"));if(o)return`Unknown option for ${t[0]}: ${o}`}return n}function m(n){const t=n[0];if(!t||!k(t))return n.find(i=>i.startsWith("-"));const o=x(t);for(const i of n.slice(1)){if(!i.startsWith("-"))continue;const e=i.includes("=")?i.slice(0,i.indexOf("=")):i;if(!o.has(e))return e}}function P(n){const t=n[0];if(!t||!k(t))return;const o=m(n);if(o)throw new r(`Unknown option for ${t}: ${o}`)}function x(n){switch(n){case"install":return new Set(["--tunnel-id","--token","--workspace","--server-url","--config","--data-dir","--workspace-id","--workspace-name","--channel"]);case"upgrade":return new Set(["--version","--channel","--config","--delay","--allow-waiting"]);case"sessions":case"maintenance":return new Set(["--json","--config"]);case"restart":case"stop":case"uninstall":return new Set(["--delay","--allow-waiting"]);case"run-service":return new Set(["--config"]);default:return new Set}}function k(n){return W.includes(n)}function A(n){const t=console.info,o=[];console.info=(...i)=>{o.push(i.map(String).join(" "))};try{n()}finally{console.info=t}return o.join(`
5
- `)}function y(n){return`${n.charAt(0).toUpperCase()}${n.slice(1)}`}export{r as UsageError,D as parseCliArgs,b as usage};
4
+ -v, --version Show the installed client version`}function h(n){const t=v("coding-agent"),o=n.env??process.env,i=n.onParsed??(()=>{});t.command("install","Install and configure the local coding-agent service").option("--tunnel-id <id>","Tunnel id").option("--token <token>","Tunnel token").option("--workspace <path>","Workspace path (default: ~/messenger-workspace)").option("--server <url>","Agent bridge server URL").option("--server-url <wss-url>","Tunnel server URL").option("--config <path>","Config file path",{default:u}).option("--data-dir <path>","Data directory",{default:U}).option("--workspace-id <id>","Workspace id").option("--workspace-name <name>","Workspace display name").option("--channel <channel>","Auto-upgrade release channel: latest, beta, or alpha").action(e=>{const a=c(e.tunnelId),s=c(e.token),l=c(e.workspace);i({command:"install",tunnelId:a,token:s,workspace:l?d(l):void 0,server:c(e.server),serverUrl:c(e.serverUrl)??o[$],configPath:d(f(e.config,"--config")),dataDir:d(f(e.dataDir,"--data-dir")),workspaceId:c(e.workspaceId),workspaceName:c(e.workspaceName),channel:g(e.channel)})}),t.command("upgrade","Upgrade the local coding-agent runtime").option("--version <version>","Runtime version or release channel",{default:"latest"}).option("--channel <channel>","Auto-upgrade release channel: latest, beta, or alpha").option("--config <path>","Config file path",{default:u}).option("--delay <seconds>","Schedule the upgrade after a delay").option("--allow-waiting","Allow upgrade while sessions wait for user input").action(e=>{const a=p(e.delay),s=e.allowWaiting===!0;w(s,a),i({command:"upgrade",version:f(e.version,"--version"),configPath:d(f(e.config,"--config")),delaySeconds:a,allowWaiting:s,channel:g(e.channel)})}),t.command("sessions","Show active and waiting client sessions").option("--json","Print machine-readable JSON").option("--config <path>","Config file path",{default:u}).action(e=>{i({command:"sessions",json:e.json===!0,configPath:d(f(e.config,"--config"))})}),t.command("maintenance <action>","Inspect or cancel scheduled maintenance").option("--json","Print machine-readable JSON").option("--config <path>","Config file path",{default:u}).action((e,a)=>{if(e!=="status"&&e!=="cancel")throw new r(`Unknown maintenance action: ${e}`);i({command:"maintenance",action:e,json:a.json===!0,configPath:d(f(a.config,"--config"))})});for(const e of["status","start"])t.command(e,`${y(e)} the local coding-agent service`).action(()=>{i({command:e})});t.command("restart [agent]","Restart the local service or a specific agent").option("--delay <seconds>","Schedule the restart after a delay").option("--allow-waiting","Allow restart while sessions wait for user input").action((e,a)=>{if(e!==void 0&&e!=="codex"&&e!=="claude")throw new r(`Unknown agent for restart: ${e}`);const s=p(a.delay),l=a.allowWaiting===!0;w(l,s),i({command:"restart",agent:e,delaySeconds:s,allowWaiting:l})});for(const e of["stop","uninstall"])t.command(e,`${y(e)} the local coding-agent service`).option("--delay <seconds>",`Schedule the ${e} after a delay`).option("--allow-waiting",`Allow ${e} while sessions wait for user input`).action(a=>{const s=p(a.delay),l=a.allowWaiting===!0;w(l,s),i({command:e,delaySeconds:s,allowWaiting:l})});return n.includeInternalCommands&&t.command("run-service","Run the managed service supervisor").option("--config <path>","Config file path").action(e=>{const a=c(e.config);i({command:"run-service",configPath:a?d(a):void 0})}),t}function f(n,t){const o=c(n);if(!o)throw new r(`Missing value for ${t}`);return o}function c(n){return typeof n=="string"?n:void 0}function g(n){const t=c(n);if(t!==void 0)try{return S(t)}catch{throw new r(`Unknown release channel for --channel: ${t} (expected latest, beta, or alpha)`)}}function p(n){if(n===void 0)return;const t=typeof n=="number"?String(n):f(n,"--delay");if(!/^\d+$/.test(t))throw new r("--delay must be an integer between 1 and 86400 seconds");const o=Number.parseInt(t,10);if(o<1||o>86400)throw new r("--delay must be an integer between 1 and 86400 seconds");return o}function w(n,t){if(n&&t===void 0)throw new r("--allow-waiting requires --delay")}function I(n,t){if(n.startsWith("Unknown option `")){const o=m(t);if(o)return`Unknown option for ${t[0]}: ${o}`}if(n.startsWith("option `")){const o=/^option `([^` ]+)/.exec(n);if(o)return`Missing value for ${o[1]}`}if(n.startsWith("Unused args:")){const o=t.slice(1).find(i=>!i.startsWith("-"));if(o)return`Unknown option for ${t[0]}: ${o}`}return n}function m(n){const t=n[0];if(!t||!k(t))return n.find(i=>i.startsWith("-"));const o=A(t);for(const i of n.slice(1)){if(!i.startsWith("-"))continue;const e=i.includes("=")?i.slice(0,i.indexOf("=")):i;if(!o.has(e))return e}}function P(n){const t=n[0];if(!t||!k(t))return;const o=m(n);if(o)throw new r(`Unknown option for ${t}: ${o}`)}function A(n){switch(n){case"install":return new Set(["--tunnel-id","--token","--workspace","--server","--server-url","--config","--data-dir","--workspace-id","--workspace-name","--channel"]);case"upgrade":return new Set(["--version","--channel","--config","--delay","--allow-waiting"]);case"sessions":case"maintenance":return new Set(["--json","--config"]);case"restart":case"stop":case"uninstall":return new Set(["--delay","--allow-waiting"]);case"run-service":return new Set(["--config"]);default:return new Set}}function k(n){return W.includes(n)}function x(n){const t=console.info,o=[];console.info=(...i)=>{o.push(i.map(String).join(" "))};try{n()}finally{console.info=t}return o.join(`
5
+ `)}function y(n){return`${n.charAt(0).toUpperCase()}${n.slice(1)}`}export{r as UsageError,R as parseCliArgs,b as usage};
@@ -7,6 +7,7 @@ export type ClientConfigOptions = {
7
7
  workspaceName?: string;
8
8
  tunnelId: string;
9
9
  token: string;
10
+ server?: string;
10
11
  serverUrl?: string;
11
12
  preserveWorkspaces?: boolean;
12
13
  };
@@ -1 +1 @@
1
- import{constants as m}from"node:fs";import{access as w,chmod as u,mkdir as n,readFile as p,rename as g,stat as x,writeFile as C}from"node:fs/promises";import{dirname as c,join as o}from"node:path";import{parse as y,stringify as v}from"yaml";import{normalizeReleaseChannel as _}from"./runtime.js";function s(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function d(e,r){const t=e[r];if(s(t))return t;const a={};return e[r]=a,a}async function h(e,r){await n(c(r),{recursive:!0,mode:448}),await u(c(r),448),await n(e,{recursive:!0,mode:448}),await n(o(e,"logs"),{recursive:!0,mode:448}),await n(o(e,"uploads"),{recursive:!0,mode:448}),await n(o(e,"runtime"),{recursive:!0,mode:448})}async function k(e){try{return await w(e,m.F_OK),!0}catch{return!1}}async function l(e){if(!await k(e))return{};const r=y(await p(e,"utf8"));if(r==null)return{};if(!s(r))throw new Error(`Config file must contain a YAML object: ${e}`);return r}function U(e,r){const t={...e};t.log_level??="info",r.preserveWorkspaces||(t.workspaces=[{id:r.workspaceId,name:r.workspaceName??`${r.tunnelId} Default`,path:r.workspacePath}]),t.data_dir=r.dataDir;const a=d(t,"file_uploads");a.temp_dir=o(r.dataDir,"uploads");const i=d(t,"tunnel");return i.enabled=!0,r.serverUrl&&(i.server_url=r.serverUrl),i.tunnel_id=r.tunnelId,i.token=r.token,t}async function E(e){const t=(await l(e)).auto_upgrade,a=s(t)?t.channel:void 0;return _(a)??"latest"}async function F(e,r){const t=await l(e),a=d(t,"auto_upgrade");a.channel=r,await f(e,t)}async function f(e,r){await n(c(e),{recursive:!0,mode:448});const t=`${e}.${process.pid}.${Date.now()}.tmp`;await C(t,v(r),{mode:384}),await u(t,384),await g(t,e),await u(e,384)}async function I(e){await h(e.dataDir,e.configPath);const r=await l(e.configPath),t=U(r,e);return await f(e.configPath,t),t}async function Y(e){if(((await x(e)).mode&511&63)!==0)throw new Error(`Config file permissions are too broad: ${e}`)}export{Y as assertPrivateConfig,h as ensureClientDirectories,U as mergeClientConfig,l as readConfigYaml,E as readUpgradeChannel,I as updateClientConfig,f as writeConfigYaml,F as writeUpgradeChannel};
1
+ import{constants as m}from"node:fs";import{access as w,chmod as u,mkdir as n,readFile as p,rename as g,stat as v,writeFile as x}from"node:fs/promises";import{dirname as s,join as o}from"node:path";import{normalizeAgentServer as C}from"@messenger-agent/shared/agent-config";import{parse as y,stringify as _}from"yaml";import{normalizeReleaseChannel as h}from"./runtime.js";function c(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function d(e,r){const t=e[r];if(c(t))return t;const a={};return e[r]=a,a}async function k(e,r){await n(s(r),{recursive:!0,mode:448}),await u(s(r),448),await n(e,{recursive:!0,mode:448}),await n(o(e,"logs"),{recursive:!0,mode:448}),await n(o(e,"uploads"),{recursive:!0,mode:448}),await n(o(e,"runtime"),{recursive:!0,mode:448})}async function U(e){try{return await w(e,m.F_OK),!0}catch{return!1}}async function f(e){if(!await U(e))return{};const r=y(await p(e,"utf8"));if(r==null)return{};if(!c(r))throw new Error(`Config file must contain a YAML object: ${e}`);return r}function $(e,r){const t={...e};t.log_level??="info",r.preserveWorkspaces||(t.workspaces=[{id:r.workspaceId,name:r.workspaceName??`${r.tunnelId} Default`,path:r.workspacePath}]),t.data_dir=r.dataDir,r.server&&(t.server=C(r.server));const a=d(t,"file_uploads");a.temp_dir=o(r.dataDir,"uploads");const i=d(t,"tunnel");return i.enabled=!0,r.serverUrl&&(i.server_url=r.serverUrl),i.tunnel_id=r.tunnelId,i.token=r.token,t}async function I(e){const t=(await f(e)).auto_upgrade,a=c(t)?t.channel:void 0;return h(a)??"latest"}async function Y(e,r){const t=await f(e),a=d(t,"auto_upgrade");a.channel=r,await l(e,t)}async function l(e,r){await n(s(e),{recursive:!0,mode:448});const t=`${e}.${process.pid}.${Date.now()}.tmp`;await x(t,_(r),{mode:384}),await u(t,384),await g(t,e),await u(e,384)}async function z(e){await k(e.dataDir,e.configPath);const r=await f(e.configPath),t=$(r,e);return await l(e.configPath,t),t}async function R(e){if(((await v(e)).mode&511&63)!==0)throw new Error(`Config file permissions are too broad: ${e}`)}export{R as assertPrivateConfig,k as ensureClientDirectories,$ as mergeClientConfig,f as readConfigYaml,I as readUpgradeChannel,z as updateClientConfig,l as writeConfigYaml,Y as writeUpgradeChannel};
package/dist/install.js CHANGED
@@ -1 +1 @@
1
- import{mkdir as w,realpath as l,stat as m}from"node:fs/promises";import{readConfigYaml as h,updateClientConfig as k,writeUpgradeChannel as y}from"./config-file.js";import{installRuntime as g}from"./runtime.js";import{installService as v}from"./service.js";import{UsageError as f}from"./args.js";import{defaultWorkspacePath as d}from"./paths.js";function P(e=process.platform){if(e!=="linux"&&e!=="darwin")throw new Error("Only Linux and macOS are supported")}function A(e=process.versions.node){const t=Number.parseInt(e.split(".")[0]??"",10);if(!Number.isInteger(t)||t<24)throw new Error("Node.js 24 or newer is required")}function x(e){if(e.tunnelId&&!/^[A-Za-z0-9._:-]+$/.test(e.tunnelId))throw new Error("--tunnel-id may only contain letters, numbers, '.', '_', ':', and '-'");if(e.workspaceId&&!/^[A-Za-z0-9._:-]+$/.test(e.workspaceId))throw new Error("--workspace-id may only contain letters, numbers, '.', '_', ':', and '-'");if(e.workspaceName&&(e.workspaceName.trim().length===0||e.workspaceName.trim().length>128))throw new Error("--workspace-name must be between 1 and 128 characters")}async function D(e,t=!1){t&&await w(e,{recursive:!0});const n=await l(e);if(!(await m(n)).isDirectory())throw new Error("--workspace must point to an existing directory");return n}async function M(e){P(),A();const t=await I(e);x(t);const n=await D(t.workspace,t.createWorkspace);await k({configPath:t.configPath,dataDir:t.dataDir,workspacePath:n,workspaceId:t.workspaceId,workspaceName:t.workspaceName,tunnelId:t.tunnelId,token:t.token,serverUrl:t.serverUrl,preserveWorkspaces:t.preserveWorkspaces}),e.channel&&await y(t.configPath,e.channel);const o=await g({version:"current",configPath:t.configPath}),a=await v({configPath:t.configPath,dataDir:t.dataDir,workspacePath:n,serviceCommandPath:o.wrapperPath});return{configPath:t.configPath,dataDir:t.dataDir,workspacePath:n,runtime:o,service:a}}async function I(e){const t=await h(e.configPath),n=b(t,"tunnel"),o=e.tunnelId??p(n,"tunnel_id"),a=e.token??p(n,"token"),s=N(t,e.workspaceId,o),i=e.workspace??s?.path??d,r=e.workspaceId??s?.id??(o?`${o}--default`:void 0),c=e.workspaceName??s?.name??(o?`${o} Default`:void 0),u=i===d;if(!o)throw new f("Missing required option: --tunnel-id");if(!a)throw new f("Missing required option: --token");if(!r)throw new f("Missing required option: --workspace-id");if(!c)throw new f("Missing required option: --workspace-name");return{...e,tunnelId:o,token:a,workspace:i,workspaceId:r,workspaceName:c,preserveWorkspaces:!e.workspace&&!!s,createWorkspace:u}}function N(e,t,n){const o=e.workspaces;if(!Array.isArray(o))return;const a=o.filter(r=>!!r&&typeof r=="object"&&!Array.isArray(r)&&typeof r.path=="string");if(t){const r=a.find(c=>c.id===t);return!r||typeof r.path!="string"?void 0:{id:t,name:typeof r.name=="string"&&r.name?r.name:`${n??t} Default`,path:r.path}}const s=t??(n?`${n}--default`:void 0),i=(s?a.find(r=>r.id===s):void 0)??a.find(r=>r.id==="default")??a[0];if(!(!i||typeof i.path!="string"))return{id:typeof i.id=="string"&&i.id?i.id:s??"default",name:typeof i.name=="string"&&i.name?i.name:`${n??s??"default"} Default`,path:i.path}}function b(e,t){const n=e[t];if(!(!n||typeof n!="object"||Array.isArray(n)))return n}function p(e,t){const n=e?.[t];return typeof n=="string"&&n?n:void 0}export{A as assertNodeVersion,P as assertSupportedPlatform,M as installClient,I as resolveInstallArgs,D as resolveWorkspacePath,x as validateInstallArgs};
1
+ import{mkdir as w,realpath as l,stat as m}from"node:fs/promises";import{normalizeAgentServer as h}from"@messenger-agent/shared/agent-config";import{readConfigYaml as k,updateClientConfig as v,writeUpgradeChannel as y}from"./config-file.js";import{installRuntime as g}from"./runtime.js";import{installService as P}from"./service.js";import{UsageError as d}from"./args.js";import{defaultWorkspacePath as f}from"./paths.js";function A(e=process.platform){if(e!=="linux"&&e!=="darwin")throw new Error("Only Linux and macOS are supported")}function x(e=process.versions.node){const r=Number.parseInt(e.split(".")[0]??"",10);if(!Number.isInteger(r)||r<24)throw new Error("Node.js 24 or newer is required")}function D(e){if(e.server)try{h(e.server)}catch{throw new Error("--server must be a valid HTTP or HTTPS server address")}if(e.tunnelId&&!/^[A-Za-z0-9._:-]+$/.test(e.tunnelId))throw new Error("--tunnel-id may only contain letters, numbers, '.', '_', ':', and '-'");if(e.workspaceId&&!/^[A-Za-z0-9._:-]+$/.test(e.workspaceId))throw new Error("--workspace-id may only contain letters, numbers, '.', '_', ':', and '-'");if(e.workspaceName&&(e.workspaceName.trim().length===0||e.workspaceName.trim().length>128))throw new Error("--workspace-name must be between 1 and 128 characters")}async function I(e,r=!1){r&&await w(e,{recursive:!0});const t=await l(e);if(!(await m(t)).isDirectory())throw new Error("--workspace must point to an existing directory");return t}async function M(e){A(),x();const r=await N(e);D(r);const t=await I(r.workspace,r.createWorkspace);await v({configPath:r.configPath,dataDir:r.dataDir,workspacePath:t,workspaceId:r.workspaceId,workspaceName:r.workspaceName,tunnelId:r.tunnelId,token:r.token,server:r.server,serverUrl:r.serverUrl,preserveWorkspaces:r.preserveWorkspaces}),e.channel&&await y(r.configPath,e.channel);const o=await g({version:"current",configPath:r.configPath}),a=await P({configPath:r.configPath,dataDir:r.dataDir,workspacePath:t,serviceCommandPath:o.wrapperPath});return{configPath:r.configPath,dataDir:r.dataDir,workspacePath:t,runtime:o,service:a}}async function N(e){const r=await k(e.configPath),t=E(r,"tunnel"),o=e.tunnelId??p(t,"tunnel_id"),a=e.token??p(t,"token"),s=b(r,e.workspaceId,o),i=e.workspace??s?.path??f,n=e.workspaceId??s?.id??(o?`${o}--default`:void 0),c=e.workspaceName??s?.name??(o?`${o} Default`:void 0),u=i===f;if(!o)throw new d("Missing required option: --tunnel-id");if(!a)throw new d("Missing required option: --token");if(!n)throw new d("Missing required option: --workspace-id");if(!c)throw new d("Missing required option: --workspace-name");return{...e,tunnelId:o,token:a,workspace:i,workspaceId:n,workspaceName:c,preserveWorkspaces:!e.workspace&&!!s,createWorkspace:u}}function b(e,r,t){const o=e.workspaces;if(!Array.isArray(o))return;const a=o.filter(n=>!!n&&typeof n=="object"&&!Array.isArray(n)&&typeof n.path=="string");if(r){const n=a.find(c=>c.id===r);return!n||typeof n.path!="string"?void 0:{id:r,name:typeof n.name=="string"&&n.name?n.name:`${t??r} Default`,path:n.path}}const s=r??(t?`${t}--default`:void 0),i=(s?a.find(n=>n.id===s):void 0)??a.find(n=>n.id==="default")??a[0];if(!(!i||typeof i.path!="string"))return{id:typeof i.id=="string"&&i.id?i.id:s??"default",name:typeof i.name=="string"&&i.name?i.name:`${t??s??"default"} Default`,path:i.path}}function E(e,r){const t=e[r];if(!(!t||typeof t!="object"||Array.isArray(t)))return t}function p(e,r){const t=e?.[r];return typeof t=="string"&&t?t:void 0}export{x as assertNodeVersion,A as assertSupportedPlatform,M as installClient,N as resolveInstallArgs,I as resolveWorkspacePath,D as validateInstallArgs};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@messenger-agent/client",
3
- "version": "0.29.0",
3
+ "version": "0.30.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -20,10 +20,10 @@
20
20
  "dependencies": {
21
21
  "cac": "^7.0.0",
22
22
  "yaml": "^2.9.0",
23
- "@messenger-agent/claude-agent": "0.29.0",
24
- "@messenger-agent/messenger-agent": "0.29.0",
25
- "@messenger-agent/codex-agent": "0.29.0",
26
- "@messenger-agent/shared": "0.29.0"
23
+ "@messenger-agent/claude-agent": "0.30.0",
24
+ "@messenger-agent/codex-agent": "0.30.0",
25
+ "@messenger-agent/messenger-agent": "0.30.0",
26
+ "@messenger-agent/shared": "0.30.0"
27
27
  },
28
28
  "scripts": {
29
29
  "build": "rm -rf dist && tsc -p tsconfig.json && node ../../scripts/copy-client-assets.mjs && chmod +x dist/index.js",