herdr-remote 0.2.39 → 0.3.32
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 +4 -2
- package/README.zh-CN.md +2 -2
- package/dist/chunks/3FQAXVGC.js +3 -0
- package/dist/chunks/42KARAL4.js +31 -0
- package/dist/chunks/44IGVPMA.js +5 -0
- package/dist/chunks/5LZFJ6UZ.js +3 -0
- package/dist/chunks/7SMZ43LI.js +9 -0
- package/dist/chunks/AX4EPJCP.js +4 -0
- package/dist/chunks/B76DFI4H.js +16 -0
- package/dist/chunks/BYGDPZZD.js +3 -0
- package/dist/chunks/C2UUZY6J.js +2 -0
- package/dist/chunks/CVJ4HBMP.js +3 -0
- package/dist/chunks/DGUZCGQN.js +3 -0
- package/dist/chunks/FONUO5O5.js +4 -0
- package/dist/chunks/H24ZP5D5.js +16 -0
- package/dist/chunks/I6NRCYLI.js +3 -0
- package/dist/chunks/JJGEV4EZ.js +3 -0
- package/dist/chunks/K5RFPHSF.js +5 -0
- package/dist/chunks/KGOQKOHH.js +5 -0
- package/dist/chunks/KRVF37OW.js +3 -0
- package/dist/chunks/KUDCC7ZO.js +6 -0
- package/dist/chunks/LPR662JH.js +77 -0
- package/dist/chunks/LY2ZGCXN.js +4 -0
- package/dist/chunks/M52LJEES.js +6 -0
- package/dist/chunks/MCUVFSSK.js +3 -0
- package/dist/chunks/MEFDV375.js +10 -0
- package/dist/chunks/MKAEXKXG.js +10 -0
- package/dist/chunks/O2LNVFUT.js +3 -0
- package/dist/chunks/PBMBFWLQ.js +3 -0
- package/dist/chunks/PBRQ3HEG.js +3 -0
- package/dist/chunks/QCSILMFB.js +3 -0
- package/dist/chunks/QRGNEKME.js +5 -0
- package/dist/chunks/RMHH3IAX.js +63 -0
- package/dist/chunks/TNLCNVA2.js +3 -0
- package/dist/chunks/U6QAYG3E.js +3 -0
- package/dist/chunks/VD54DF7R.js +45 -0
- package/dist/chunks/WY7WHEJ4.js +3 -0
- package/dist/cli.js +21 -294
- package/dist/connector/admin-broker.js +3 -303
- package/dist/connector/main.js +20 -18
- package/dist/harfbuzz-subset.wasm +0 -0
- package/dist/postinstall.js +17 -0
- package/herdr-plugin.toml +1 -1
- package/node_modules/herdr-remote-relay/bin/herdr-remote-relay.js +33 -92
- package/node_modules/herdr-remote-relay/package.json +3 -46
- package/package.json +8 -27
- package/dist/agent-status.js +0 -130
- package/dist/binary-plist.js +0 -157
- package/dist/config.js +0 -278
- package/dist/connector/admin-broker-setup.js +0 -40
- package/dist/connector/admin-shell.js +0 -67
- package/dist/connector/admin-tab.js +0 -90
- package/dist/connector/adminBrokerEndpoint.js +0 -68
- package/dist/connector/agent-watch.js +0 -123
- package/dist/connector/elevatedPty.js +0 -141
- package/dist/connector/font-server.js +0 -165
- package/dist/connector/herdr-prefix-keys.js +0 -28
- package/dist/connector/host-connector.js +0 -433
- package/dist/connector/host-hello.js +0 -32
- package/dist/connector/lock.js +0 -73
- package/dist/connector/sessions.js +0 -381
- package/dist/connector/update-report.js +0 -70
- package/dist/connector/wire.js +0 -42
- package/dist/exit-codes.js +0 -13
- package/dist/font-subset.js +0 -116
- package/dist/herdr-api.js +0 -254
- package/dist/herdr-command.js +0 -245
- package/dist/herdr-plugin.js +0 -120
- package/dist/herdr-server.js +0 -190
- package/dist/i18n/en.js +0 -257
- package/dist/i18n/index.js +0 -48
- package/dist/i18n/zh.js +0 -256
- package/dist/keepalive/detached.js +0 -97
- package/dist/keepalive/environment.js +0 -44
- package/dist/keepalive/index.js +0 -129
- package/dist/keepalive/launchd.js +0 -117
- package/dist/keepalive/systemd.js +0 -112
- package/dist/keepalive/types.js +0 -1
- package/dist/keepalive/windows-service-setup.js +0 -138
- package/dist/keepalive/windows-service.js +0 -272
- package/dist/keepalive/windows-task.js +0 -191
- package/dist/lib/process.js +0 -132
- package/dist/lifecycle.js +0 -79
- package/dist/net-interfaces.js +0 -82
- package/dist/node-pty-loader.js +0 -80
- package/dist/pasted-files.js +0 -115
- package/dist/paths.js +0 -74
- package/dist/pty-session.js +0 -133
- package/dist/relay-client.js +0 -106
- package/dist/relay-urls.js +0 -99
- package/dist/runtime.js +0 -107
- package/dist/service.js +0 -267
- package/dist/settings-model.js +0 -298
- package/dist/socket-discovery.js +0 -70
- package/dist/supervisor.js +0 -323
- package/dist/terminal-font/deps.js +0 -83
- package/dist/terminal-font/files.js +0 -357
- package/dist/terminal-font/formats.js +0 -355
- package/dist/terminal-font/index.js +0 -187
- package/dist/terminal-font/readers.js +0 -373
- package/dist/terminal-font/terminals.js +0 -147
- package/dist/terminal-palette.js +0 -399
- package/dist/tui/App.js +0 -199
- package/dist/tui/api.js +0 -91
- package/dist/tui/components/TextField.js +0 -50
- package/dist/tui/components/common.js +0 -80
- package/dist/tui/index.js +0 -36
- package/dist/tui/mouse/index.js +0 -164
- package/dist/tui/mouse/protocol.js +0 -96
- package/dist/tui/mouse/source.js +0 -79
- package/dist/tui/screens/About.js +0 -172
- package/dist/tui/screens/Herdr.js +0 -75
- package/dist/tui/screens/Keepalive.js +0 -141
- package/dist/tui/screens/Overview.js +0 -36
- package/dist/tui/screens/Pair.js +0 -74
- package/dist/tui/screens/Relay.js +0 -243
- package/dist/tui/screens/Services.js +0 -63
- package/dist/tui/screens/Wizard.js +0 -241
- package/dist/tui/terminal.js +0 -39
- package/dist/tui/theme.js +0 -33
- package/dist/update-command.js +0 -118
- package/dist/updater/in-place.js +0 -83
- package/dist/updater/npm.js +0 -62
- package/dist/updater.js +0 -401
- package/node_modules/herdr-remote-relay/README.md +0 -76
- package/node_modules/herdr-remote-relay/README.zh-CN.md +0 -76
- package/node_modules/herdr-remote-relay/config.example.json +0 -18
- package/node_modules/herdr-remote-relay/deploy/cloudflared/config.yml.example +0 -9
- package/node_modules/herdr-remote-relay/deploy/docker/compose.yaml +0 -23
- package/node_modules/herdr-remote-relay/deploy/nginx/herdr-remote-relay.conf.example +0 -49
- package/node_modules/herdr-remote-relay/deploy/systemd/herdr-remote-relay.service +0 -41
- package/node_modules/herdr-remote-relay/deploy/systemd/relay.env.example +0 -25
- package/node_modules/herdr-remote-relay/dist/auth-store.d.ts +0 -114
- package/node_modules/herdr-remote-relay/dist/auth-store.js +0 -289
- package/node_modules/herdr-remote-relay/dist/metrics.d.ts +0 -76
- package/node_modules/herdr-remote-relay/dist/metrics.js +0 -249
- package/node_modules/herdr-remote-relay/dist/protocol/frames.d.ts +0 -27
- package/node_modules/herdr-remote-relay/dist/protocol/frames.js +0 -110
- package/node_modules/herdr-remote-relay/dist/protocol/herdr-keys.d.ts +0 -8
- package/node_modules/herdr-remote-relay/dist/protocol/herdr-keys.js +0 -34
- package/node_modules/herdr-remote-relay/dist/protocol/http.d.ts +0 -165
- package/node_modules/herdr-remote-relay/dist/protocol/http.js +0 -3
- package/node_modules/herdr-remote-relay/dist/protocol/index.d.ts +0 -7
- package/node_modules/herdr-remote-relay/dist/protocol/index.js +0 -9
- package/node_modules/herdr-remote-relay/dist/protocol/messages.d.ts +0 -362
- package/node_modules/herdr-remote-relay/dist/protocol/messages.js +0 -20
- package/node_modules/herdr-remote-relay/dist/protocol/paste.d.ts +0 -14
- package/node_modules/herdr-remote-relay/dist/protocol/paste.js +0 -50
- package/node_modules/herdr-remote-relay/dist/protocol/release.d.ts +0 -8
- package/node_modules/herdr-remote-relay/dist/protocol/release.js +0 -17
- package/node_modules/herdr-remote-relay/dist/protocol/terminal.d.ts +0 -79
- package/node_modules/herdr-remote-relay/dist/protocol/terminal.js +0 -150
- package/node_modules/herdr-remote-relay/dist/relay-config.d.ts +0 -74
- package/node_modules/herdr-remote-relay/dist/relay-config.js +0 -316
- package/node_modules/herdr-remote-relay/dist/relay-server.d.ts +0 -67
- package/node_modules/herdr-remote-relay/dist/relay-server.js +0 -196
- package/node_modules/herdr-remote-relay/dist/scroll-input.d.ts +0 -17
- package/node_modules/herdr-remote-relay/dist/scroll-input.js +0 -124
- package/node_modules/herdr-remote-relay/dist/server/client-channel.d.ts +0 -3
- package/node_modules/herdr-remote-relay/dist/server/client-channel.js +0 -396
- package/node_modules/herdr-remote-relay/dist/server/font-proxy.d.ts +0 -19
- package/node_modules/herdr-remote-relay/dist/server/font-proxy.js +0 -155
- package/node_modules/herdr-remote-relay/dist/server/host-broadcasts.d.ts +0 -27
- package/node_modules/herdr-remote-relay/dist/server/host-broadcasts.js +0 -83
- package/node_modules/herdr-remote-relay/dist/server/host-channel.d.ts +0 -3
- package/node_modules/herdr-remote-relay/dist/server/host-channel.js +0 -271
- package/node_modules/herdr-remote-relay/dist/server/http-api.d.ts +0 -4
- package/node_modules/herdr-remote-relay/dist/server/http-api.js +0 -219
- package/node_modules/herdr-remote-relay/dist/server/maintenance.d.ts +0 -5
- package/node_modules/herdr-remote-relay/dist/server/maintenance.js +0 -64
- package/node_modules/herdr-remote-relay/dist/server/requests.d.ts +0 -34
- package/node_modules/herdr-remote-relay/dist/server/requests.js +0 -142
- package/node_modules/herdr-remote-relay/dist/server/sessions.d.ts +0 -36
- package/node_modules/herdr-remote-relay/dist/server/sessions.js +0 -230
- package/node_modules/herdr-remote-relay/dist/server/sockets.d.ts +0 -12
- package/node_modules/herdr-remote-relay/dist/server/sockets.js +0 -64
- package/node_modules/herdr-remote-relay/dist/server/status.d.ts +0 -11
- package/node_modules/herdr-remote-relay/dist/server/status.js +0 -99
- package/node_modules/herdr-remote-relay/dist/server/transport.d.ts +0 -16
- package/node_modules/herdr-remote-relay/dist/server/transport.js +0 -110
- package/node_modules/herdr-remote-relay/dist/server/types.d.ts +0 -133
- package/node_modules/herdr-remote-relay/dist/server/types.js +0 -3
- package/node_modules/herdr-remote-relay/dist/server/version.d.ts +0 -2
- package/node_modules/herdr-remote-relay/dist/server/version.js +0 -5
- package/node_modules/herdr-remote-relay/dist/state.d.ts +0 -6
- package/node_modules/herdr-remote-relay/dist/state.js +0 -47
- package/node_modules/ws/LICENSE +0 -20
- package/node_modules/ws/README.md +0 -548
- package/node_modules/ws/browser.js +0 -8
- package/node_modules/ws/index.js +0 -22
- package/node_modules/ws/lib/buffer-util.js +0 -131
- package/node_modules/ws/lib/constants.js +0 -19
- package/node_modules/ws/lib/event-target.js +0 -292
- package/node_modules/ws/lib/extension.js +0 -203
- package/node_modules/ws/lib/limiter.js +0 -55
- package/node_modules/ws/lib/permessage-deflate.js +0 -530
- package/node_modules/ws/lib/receiver.js +0 -743
- package/node_modules/ws/lib/sender.js +0 -607
- package/node_modules/ws/lib/stream.js +0 -161
- package/node_modules/ws/lib/subprotocol.js +0 -62
- package/node_modules/ws/lib/validation.js +0 -152
- package/node_modules/ws/lib/websocket-server.js +0 -562
- package/node_modules/ws/lib/websocket.js +0 -1407
- package/node_modules/ws/package.json +0 -74
- package/node_modules/ws/wrapper.mjs +0 -21
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{m as g,o as p}from"./KGOQKOHH.js";import"./PBMBFWLQ.js";import{a as s}from"./TNLCNVA2.js";import"./I6NRCYLI.js";import m from"node:fs";import c from"node:path";import{spawnSync as h}from"node:child_process";var d="herdr.remote.web",S="herdr-plugin.toml";function w(){return c.join(s,S)}function a(t,{timeout:r=15e3}={}){let e=h(g(),t,{encoding:"utf8",timeout:r,windowsHide:!0});if(e.error?.code==="ENOENT")throw Object.assign(new Error("herdr command not found"),{code:"HERDR_NOT_FOUND"});return e}function b(t){let r=[];for(let e of String(t||"").split(`
|
|
4
|
+
`)){let n=/^-\s+(\S+)\s+\((.*?)\)\s+(\S+)(?:\s+\[(.*)\])?/.exec(e.trim());if(!n)continue;let[,f,i,o,l]=n,u=l?l.split(";")[0].trim():null;r.push({id:f,name:i,enabled:o==="enabled",source:u,warnings:l?.includes(";")?l.slice(l.indexOf(";")+1).trim():null,localPath:u?.startsWith("local:")?u.slice(6):null})}return r}function k(){if(!m.existsSync(w()))return{available:!1,registered:!1,reason:"manifest missing"};let{version:t,supported:r}=p(),e={version:t,versionSupported:r},n;try{n=a(["plugin","list"])}catch(o){if(o.code==="HERDR_NOT_FOUND")return{available:!1,registered:!1,reason:"herdr not found"};throw o}if(n.status!==0)return{available:!0,registered:!1,reason:String(n.stderr||"").trim(),...e};let i=b(n.stdout).find(o=>o.id===d);return i?{available:!0,registered:!0,enabled:i.enabled,linkedPath:i.localPath,stale:i.localPath?c.resolve(i.localPath)!==c.resolve(s):!1,packageRoot:s,...e}:{available:!0,registered:!1,packageRoot:s,...e}}function _(){let t=k();t.registered&&t.stale&&a(["plugin","unlink",d]);let r=a(["plugin","link",s]);if(r.status!==0)throw new Error(String(r.stderr||r.stdout||"").trim()||"herdr plugin link failed");return{ok:!0,path:s,output:String(r.stdout||"").trim()}}function R(){let t=a(["plugin","unlink",d]);if(t.status!==0)throw new Error(String(t.stderr||t.stdout||"").trim()||"herdr plugin unlink failed");return{ok:!0,output:String(t.stdout||"").trim()}}export{b as parsePluginList,_ as register,k as registrationStatus,R as unregister};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{i as m}from"./PBMBFWLQ.js";import{d,g as _}from"./TNLCNVA2.js";function i(e){return e==="127.0.0.1"||e==="localhost"||e==="::1"||e==="[::1]"}function E(e){let r=typeof e=="string"?e.trim().toLowerCase():"";return r==="0.0.0.0"||r==="::"||r==="[::]"}function R(e){try{let r=new URL(e).hostname.toLowerCase();return r==="0.0.0.0"||r==="::"||r==="[::]"}catch{return!1}}function h(e){return typeof e=="string"?e.trim().replace(/\/+$/,""):""}function N(e){return e.relay.mode!=="remote"}function b(e){return e.relay.mode==="lan"?"0.0.0.0":"127.0.0.1"}function M(e,r=null){if(e.relay.mode==="lan"){let t=e.relay.lanHost;return t&&!i(t)&&!E(t)?t:r&&!i(r)&&!E(r)?r:"127.0.0.1"}return"127.0.0.1"}function B(e,r=null){return e.relay.publicUrl?e.relay.publicUrl:e.relay.mode==="remote"?A(e.relay.remoteUrl):`http://${M(e,r)}:${e.relay.port}`}function I(e){return e.relay.mode==="remote"?A(e.relay.remoteUrl):`http://127.0.0.1:${e.relay.port}`}function w(e){let r=e.relay.mode==="remote"?e.relay.remoteUrl:`ws://127.0.0.1:${e.relay.port}`;return T(r)}function A(e){try{let r=new URL(e);r.protocol==="ws:"&&(r.protocol="http:"),r.protocol==="wss:"&&(r.protocol="https:");let t=r.pathname.replace(/\/+$/,"");return`${r.origin}${t}`}catch{return h(e)}}function T(e){let r=new URL(e);r.protocol==="http:"&&(r.protocol="ws:"),r.protocol==="https:"&&(r.protocol="wss:");let t=r.pathname.replace(/\/+$/,"");return!t||t==="/"?r.pathname=m:t.endsWith(m)||(r.pathname=`${t}${m}`),r.toString()}import u from"node:fs";import c from"node:os";import x from"node:path";import S from"node:path";var F=S.resolve(import.meta.dirname,"..");var s={relay:{mode:"remote",host:"127.0.0.1",port:8787,publicUrl:"http://127.0.0.1:8787",maxPayloadBytes:5*1024*1024,maxClientsPerHost:16,maxHosts:1024,maxPendingHandshakes:1024,maxBufferedBytesPerClient:4*1024*1024,allowedOrigins:[],trustProxy:!1,hostReconnectGraceMs:30*1e3},auth:{pairingTtlMs:600*1e3,deviceTtlMs:720*60*60*1e3,maxDevices:32,password:null,adminToken:null,stateFile:null},cleanup:{intervalMs:60*1e3,heartbeatIntervalMs:30*1e3,staleAfterMs:90*1e3}};var p=["local","lan","remote"],z="wss://herdr-remote.564616.xyz",L=["auto","zh","en"],P=["auto","systemd","launchd","supervisor","windows-task","windows-service","none"];function y(e,r){return e.includes(r)}var a={ui:{language:"auto"},relay:{mode:"local",port:8787,lanHost:"",publicUrl:"",remoteUrl:"",maxPayloadBytes:s.relay.maxPayloadBytes,maxClientsPerHost:s.relay.maxClientsPerHost,maxHosts:s.relay.maxHosts,maxPendingHandshakes:s.relay.maxPendingHandshakes,maxBufferedBytesPerClient:s.relay.maxBufferedBytesPerClient,hostReconnectGraceMs:s.relay.hostReconnectGraceMs,allowedOrigins:[]},herdr:{socketPath:null,args:[],cwd:c.homedir(),autoStart:!1},auth:{pairingTtlMs:s.auth.pairingTtlMs,deviceTtlMs:s.auth.deviceTtlMs,maxDevices:s.auth.maxDevices},cleanup:{...s.cleanup},keepalive:{manager:"auto"}};function H(e){return JSON.parse(JSON.stringify(e))}function O(e){try{return JSON.parse(u.readFileSync(e,"utf8"))}catch(r){let{code:t,message:o}=r;return t!=="ENOENT"&&process.stderr.write(`herdr-remote: ignoring invalid JSON at ${e}: ${o}
|
|
4
|
+
`),{}}}function V(){let e=d();if(u.existsSync(e))return{migrated:!1,reason:"config already exists"};let r=_();if(!r||!u.existsSync(r))return{migrated:!1,reason:"no legacy config"};try{return u.mkdirSync(x.dirname(e),{recursive:!0,mode:448}),u.copyFileSync(r,e),{migrated:!0,from:r,to:e}}catch(t){return{migrated:!1,reason:t.message}}}function f(e){let r=H(a),t=e??{};for(let o of Object.keys(r)){let n=t[o];n&&typeof n=="object"&&Object.assign(r[o],n)}return r}function U(e,r){let t=r?.relay||{};y(p,t.mode)||(t.local===!1&&typeof t.url=="string"&&t.url?(e.relay.mode="remote",e.relay.remoteUrl||(e.relay.remoteUrl=t.url)):typeof t.host=="string"&&t.host&&!i(t.host)?e.relay.mode="lan":e.relay.mode="local"),e.relay.mode==="lan"&&!e.relay.lanHost&&typeof t.host=="string"&&!i(t.host)&&t.host!=="0.0.0.0"&&(e.relay.lanHost=t.host),delete e.relay.local,delete e.relay.host,delete e.relay.url,typeof e.relay.publicUrl=="string"&&/^https?:\/\/(127\.0\.0\.1|localhost)(:\d+)?\/?$/.test(e.relay.publicUrl)&&(e.relay.publicUrl="")}function l(e,r,t,o){let n=Number(e);return!Number.isInteger(n)||n<t||n>o?r:n}function D(e){y(p,e.relay.mode)||(e.relay.mode=a.relay.mode),y(L,e.ui.language)||(e.ui.language=a.ui.language),y(P,e.keepalive.manager)||(e.keepalive.manager=a.keepalive.manager),e.relay.port=l(e.relay.port,a.relay.port,1,65535),e.relay.maxPayloadBytes=l(e.relay.maxPayloadBytes,a.relay.maxPayloadBytes,4096,16*1024*1024),e.relay.maxClientsPerHost=l(e.relay.maxClientsPerHost,a.relay.maxClientsPerHost,1,256),e.relay.maxHosts=l(e.relay.maxHosts,a.relay.maxHosts,1,1e5),e.relay.maxPendingHandshakes=l(e.relay.maxPendingHandshakes,a.relay.maxPendingHandshakes,16,1e5),e.relay.maxBufferedBytesPerClient=l(e.relay.maxBufferedBytesPerClient,a.relay.maxBufferedBytesPerClient,64*1024,256*1024*1024),e.relay.hostReconnectGraceMs=l(e.relay.hostReconnectGraceMs,a.relay.hostReconnectGraceMs,1e3,1440*60*1e3),e.auth.pairingTtlMs=l(e.auth.pairingTtlMs,a.auth.pairingTtlMs,30*1e3,1440*60*1e3),e.auth.deviceTtlMs=l(e.auth.deviceTtlMs,a.auth.deviceTtlMs,60*1e3,365*24*60*60*1e3),e.auth.maxDevices=l(e.auth.maxDevices,a.auth.maxDevices,1,1e4),e.cleanup.intervalMs=l(e.cleanup.intervalMs,a.cleanup.intervalMs,1e3,1440*60*1e3),e.cleanup.heartbeatIntervalMs=l(e.cleanup.heartbeatIntervalMs,a.cleanup.heartbeatIntervalMs,1e3,600*1e3),e.cleanup.staleAfterMs=l(e.cleanup.staleAfterMs,a.cleanup.staleAfterMs,e.cleanup.heartbeatIntervalMs*2,1440*60*1e3),e.relay.publicUrl=h(e.relay.publicUrl),e.relay.remoteUrl=h(e.relay.remoteUrl),e.relay.lanHost=typeof e.relay.lanHost=="string"?e.relay.lanHost.trim():"",e.relay.mode==="lan"&&(i(e.relay.lanHost)||E(e.relay.lanHost))&&(e.relay.lanHost=""),R(e.relay.publicUrl)&&(e.relay.publicUrl=""),Array.isArray(e.relay.allowedOrigins)||(e.relay.allowedOrigins=[]),(!Array.isArray(e.herdr.args)||!e.herdr.args.every(t=>typeof t=="string"))&&(e.herdr.args=[]);let r=e.herdr.args;return r.includes("--no-session")&&(e.herdr.args=r.filter(t=>t!=="--no-session"),process.stderr.write(`herdr-remote: ignoring removed --no-session argument (removed in Herdr 0.9.0)
|
|
5
|
+
`)),(typeof e.herdr.socketPath!="string"||e.herdr.socketPath.length===0)&&(e.herdr.socketPath=null),(typeof e.herdr.cwd!="string"||e.herdr.cwd.length===0)&&(e.herdr.cwd=c.homedir()),e.herdr.autoStart=e.herdr.autoStart===!0,e.relay.mode==="remote"&&!e.relay.remoteUrl&&(e.relay.mode="local"),e}function Y(e){let r=process.env;if(r.HERDR_REMOTE_LANG&&y(L,r.HERDR_REMOTE_LANG)&&(e.ui.language=r.HERDR_REMOTE_LANG),r.HERDR_REMOTE_MODE&&y(p,r.HERDR_REMOTE_MODE)&&(e.relay.mode=r.HERDR_REMOTE_MODE),r.RELAY_PORT&&(e.relay.port=r.RELAY_PORT),r.RELAY_PUBLIC_URL&&(e.relay.publicUrl=r.RELAY_PUBLIC_URL),r.RELAY_REMOTE_URL&&(e.relay.remoteUrl=r.RELAY_REMOTE_URL),r.RELAY_MAX_HOSTS&&(e.relay.maxHosts=r.RELAY_MAX_HOSTS),r.RELAY_MAX_PENDING_HANDSHAKES&&(e.relay.maxPendingHandshakes=r.RELAY_MAX_PENDING_HANDSHAKES),r.RELAY_MAX_BUFFERED_BYTES_PER_CLIENT&&(e.relay.maxBufferedBytesPerClient=r.RELAY_MAX_BUFFERED_BYTES_PER_CLIENT),r.RELAY_HOST_RECONNECT_GRACE_MS&&(e.relay.hostReconnectGraceMs=r.RELAY_HOST_RECONNECT_GRACE_MS),r.HERDR_SOCKET_PATH&&(e.herdr.socketPath=r.HERDR_SOCKET_PATH),r.HERDR_CWD&&(e.herdr.cwd=r.HERDR_CWD),r.HERDR_ARGS_JSON)try{let t=JSON.parse(r.HERDR_ARGS_JSON);Array.isArray(t)&&(e.herdr.args=t)}catch(t){process.stderr.write(`herdr-remote: invalid HERDR_ARGS_JSON: ${t.message}
|
|
6
|
+
`)}}function q(){let e=O(d()),r=f(e);return U(r,e),Y(r),D(r)}function Q(){return u.existsSync(d())}export{i as a,E as b,R as c,N as d,b as e,B as f,I as g,w as h,T as i,p as j,z as k,L as l,P as m,V as n,q as o,Q as p};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{d as m,e as n,f as c,g as p}from"./44IGVPMA.js";import{a as l,h as o}from"./U6QAYG3E.js";import{d as s,g as i,h as v,j as f}from"./VD54DF7R.js";import{o as t}from"./M52LJEES.js";function u(a){let e=s(a);return e.installed||e.active?e:null}function S(a=t()){let e=u(a);return e?(e.active||i(a),{ok:!0,managed:!0,manager:e.manager,alreadyRunning:!!e.active}):{...m(),managed:!1}}function w(a=t()){let e=v(a);return e.managed?(n(),{ok:!0,managed:!0,manager:e.manager}):{...n(),managed:!1}}function P(a=t()){let e=u(a);return e?(i(a),{ok:!0,managed:!0,manager:e.manager}):{...c(),managed:!1}}function y(a=t()){if(u(a)?.active)return!0;let e=l();return o(e).some(({pid:r})=>r===e.hostPid)}async function x(a,e,{platform:r=process.platform,isRunning:d=()=>y(a),stop:g=w,start:k=S}={}){if(r!=="win32"||!d())return e();await g(a);try{return await e()}finally{await k(a)}}async function B(a=t()){let[e,r]=[await p(),s(a)];return{...e,keepalive:r,logsHint:f(a)}}export{u as a,S as b,w as c,P as d,y as e,x as f,B as g};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{a as M,b as O}from"./3FQAXVGC.js";import{h as I}from"./42KARAL4.js";import{b as g}from"./JJGEV4EZ.js";import{a as x}from"./CVJ4HBMP.js";import R from"node:net";var H=1e4,B=8*1024*1024,v=1e3,N=1e4,T=0;function L(r,t,n={},a={}){let{timeout:c=H,connect:o=R.connect}=a;T+=1;let m=`herdr-remote:${T}`;return new Promise((y,p)=>{let i,s="",h=!1,l=(e,u)=>{h||(h=!0,clearTimeout(w),i&&(i.removeAllListeners(),i.destroy()),e?p(e):y(u))},w=setTimeout(()=>l(new Error(`Herdr API did not answer ${t} in time`)),c);typeof w.unref=="function"&&w.unref();try{i=o(g(r))}catch(e){l(e);return}let f=i;f.setEncoding("utf8"),f.on("connect",()=>{f.write(`${JSON.stringify({id:m,method:t,params:n})}
|
|
4
|
+
`)}),f.on("data",e=>{if(s+=e,s.length>B){l(new Error("Herdr API sent an oversized response"));return}let u=s.indexOf(`
|
|
5
|
+
`);if(u===-1)return;let d;try{d=JSON.parse(s.slice(0,u))}catch{l(new Error("Herdr API sent a line that is not JSON"));return}if(d.error){let b=Object.assign(new Error(d.error.message||"Herdr API request failed"),{code:d.error.code||"herdr_api_error"});l(b);return}l(null,d.result)}),f.on("error",e=>l(e)),f.on("close",()=>l(new Error(`Herdr API closed before answering ${t}`)))})}function z(r,t,n,a={}){let{connect:c=R.connect,retryBaseMs:o=v,retryMaxMs:m=N,onStarted:y}=a,p=null,i=null,s=null,h=0,l=!1,w=()=>{if(l||i)return;let e=Math.min(o*2**h,m);h+=1,i=setTimeout(()=>{i=null,f()},e),typeof i.unref=="function"&&i.unref()},f=()=>{if(l)return;let e;try{e=c(g(r))}catch{w();return}p=e;let u="",d=null,b=!1,A=()=>{s&&clearTimeout(s),s=null};e.setEncoding("utf8"),e.on("connect",()=>{T+=1,d=`herdr-remote:subscription:${T}`,e.write(`${JSON.stringify({id:d,method:"events.subscribe",params:{subscriptions:t}})}
|
|
6
|
+
`),s=setTimeout(()=>e.destroy(),H),typeof s.unref=="function"&&s.unref()}),e.on("data",k=>{if(u+=k,Buffer.byteLength(u,"utf8")>B){e.destroy();return}let E=u.indexOf(`
|
|
7
|
+
`);for(;E!==-1;E=u.indexOf(`
|
|
8
|
+
`)){let $=u.slice(0,E);if(u=u.slice(E+1),!$)continue;let _;try{_=JSON.parse($)}catch{e.destroy();return}if(_?.id===d){if(A(),_.error){e.destroy();return}b=!0,h=0,y?.()}else if(b&&typeof _?.event=="string"&&_.data&&typeof _.data=="object")try{n(_)}catch(S){process.stderr.write(`herdr-remote: Herdr event handler failed: ${S instanceof Error?S.message:S}
|
|
9
|
+
`)}}}),e.on("error",()=>{}),e.on("close",()=>{A(),p===e&&(p=null),w()})};return f(),{close(){if(l)return;l=!0,i&&clearTimeout(i),s&&clearTimeout(s),i=null,s=null;let e=p;p=null,e&&e.destroy()}}}import C from"node:path";var D=5e3,J=100,U="HERDR_REMOTE_ADMIN_TAB";function P(r){return`'${r.replaceAll("'","''")}'`}function j(r){return`'${r.replaceAll("'","'\\''")}'`}function Q(r,t,n){let a=C.win32.basename(r).toLowerCase().replace(/\.exe$/,"");if(a==="powershell"||a==="pwsh")return`& ${P(t)} ${P(n)} admin-shell`;if(a==="cmd")return`"${t}" "${n}" admin-shell`;let c=o=>j(o.replaceAll("\\","/"));return`${c(t)} ${c(n)} admin-shell`}async function Y(r,t,n){let a=Date.now()+D;for(;;){let o=(await r(t,"pane.process_info",{pane_id:n})).process_info?.foreground_processes?.[0]?.name;if(o)return o;if(Date.now()>=a)throw new Error("The new tab did not start a shell in time.");await new Promise(m=>setTimeout(m,J))}}async function q({socketPath:r,label:t,request:n=L,brokerReady:a=I}){if(!await a())throw Object.assign(new Error("The administrator terminal broker is not running."),{code:"admin_broker_unavailable"});let c=await n(r,"tab.create",{label:t,focus:!1,env:{[U]:"1"}}),o=c.root_pane.pane_id;await n(r,"tab.focus",{tab_id:c.tab.tab_id});let m=await Y(n,r,o);await n(r,"pane.send_input",{pane_id:o,text:Q(m,process.execPath,x()),keys:["enter"]})}async function re(r,t){let n=O(M({preference:t.language}));try{await q({socketPath:t.socketPath,label:n("adminShell.tabLabel")})}catch(a){let{code:c,message:o}=a;process.stderr.write(`herdr-remote host connector: could not open an admin tab: ${o}
|
|
10
|
+
`),t.send({type:"error",clientId:r,code:c==="admin_broker_unavailable"?c:"admin_tab_failed",message:o})}}export{L as a,z as b,U as c,re as d};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{g as c,h as s}from"./RMHH3IAX.js";import{a as i}from"./CVJ4HBMP.js";import"./KGOQKOHH.js";import"./QRGNEKME.js";import"./PBMBFWLQ.js";import"./TNLCNVA2.js";import"./I6NRCYLI.js";import{spawn as a}from"node:child_process";function d(r){return new Promise((e,n)=>{r.once("error",n),r.once("close",o=>e(o??1))})}function l({action:r,nodePath:e,entryPoint:n}){let o=c,t=`"${n}" admin-broker ${r} --elevated`;return`$ErrorActionPreference = 'Stop'
|
|
4
|
+
try {
|
|
5
|
+
$process = Start-Process -FilePath '${o(e)}' -ArgumentList '${o(t)}' -Verb RunAs -Wait -PassThru -WindowStyle Hidden
|
|
6
|
+
} catch {
|
|
7
|
+
if (($_.Exception.HResult -band 65535) -eq 1223) { exit 1223 }
|
|
8
|
+
exit 1
|
|
9
|
+
}
|
|
10
|
+
exit $process.ExitCode`}function m(r,e){return Object.assign(new Error(r),{code:e})}async function f(r,e){if(process.platform!=="win32")throw new Error(e("adminBroker.windowsOnly"));let n=l({action:r,nodePath:process.execPath,entryPoint:i()}),o=a("powershell.exe",["-NoProfile","-NonInteractive","-EncodedCommand",s(n)],{windowsHide:!0,stdio:"ignore"}),t=await d(o);if(t===1223)throw m(e("adminBroker.elevationCancelled"),"ELEVATION_CANCELLED");if(t!==0)throw new Error(e("adminBroker.setupFailed"))}export{f as configureAdminBroker,l as renderAdminBrokerElevationScript};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./PBRQ3HEG.js";import"./U6QAYG3E.js";import"./KRVF37OW.js";import"./QRGNEKME.js";import"./PBMBFWLQ.js";import"./TNLCNVA2.js";import"./I6NRCYLI.js";export{b as ANSI_KEYS,a as ANSI_SLOTS,n as captureTerminalPalette,h as collectPalette,o as hostTerminalPalette,f as paletteFromEnvironment,d as parseOscColorReply,c as parseXColor,j as probeConsolePalette,i as probeTerminalPalette,k as rememberTerminalPalette,l as rememberedTerminalPalette,m as resolveHostPalette,e as sanitizePalette,g as takeOscColorReply};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
var T=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],R=["regular","bold","italic","boldItalic"],I=["truetype","opentype"],S=["cjk","all"];var y=/^#[0-9a-f]{6}$/i,w=/["'\\;,{}<>@\u0000-\u001f\u007f]/,h=/^[0-9a-f]{64}$/;function E(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function p(t,e){return t.includes(e)}function A(t){return typeof t=="string"&&y.test(t)?t.toLowerCase():void 0}function O(t){if(!E(t))return null;let e={};for(let r of["background","foreground","cursor"]){let o=A(t[r]);o&&(e[r]=o)}let n=t.ansi;if(E(n)){let r={};for(let o of T){let i=A(n[o]);i&&(r[o]=i)}Object.keys(r).length===T.length&&(e.ansi=r)}return Object.keys(e).length>0?e:null}function d(t){let e=typeof t=="string"?t.trim():"";return!e||e.length>128||w.test(e)?null:e}function U(t){if(!E(t))return null;let e=d(t.family);if(!e)return null;let n=Number(t.sizePx),r=Number.isFinite(n)&&n>=4&&n<=96?Math.round(n*10)/10:null,o=typeof t.source=="string"&&/^[a-z0-9-]{1,32}$/.test(t.source)?t.source:null,i=[],l=new Set;for(let f of Array.isArray(t.faces)?t.faces.slice(0,16):[]){if(!E(f))continue;let{style:a,format:c,bytes:s,sha256:u}=f;!p(R,a)||l.has(a)||p(I,c)&&(typeof s!="number"||!Number.isInteger(s)||s<=0||s>16777216||typeof u!="string"||!h.test(u)||(l.add(a),i.push({style:a,format:c,bytes:s,sha256:u})))}let m=[];for(let f of Array.isArray(t.subsets)?t.subsets.slice(0,16):[]){if(!E(f))continue;let a=d(f.family),{scope:c,sha256:s}=f;!a||f.style!=="regular"||p(S,c)&&(typeof s!="string"||!h.test(s)||m.some(u=>u.scope===c)||m.push({family:a,style:"regular",scope:c,sha256:s}))}return{family:e,...r!==null&&{sizePx:r},...o!==null&&{source:o},faces:i,subsets:m}}var M="dibin666/herdr-remote",g=`https://github.com/${M}/releases`,Y=`${g}/latest/download/latest.json`,L=`${g}/latest/download/herdr-remote.tgz`;function b(t){return`${g}/download/herdr-remote-v${t}/herdr-remote-${t}.tgz`}function _(t){return Buffer.isBuffer(t)?t:(typeof t=="string"||t instanceof ArrayBuffer,Buffer.from(t))}function k(t,e,n=Buffer.alloc(0)){if(typeof t!="string"||!t||typeof e!="string"||!e)throw new TypeError("type and streamId must be non-empty strings");let r=_(n),o=Buffer.from(JSON.stringify({type:t,streamId:e}),"utf8");if(o.length>8192)throw new RangeError("stream frame header is too large");let i=Buffer.allocUnsafe(4);return i.writeUInt32BE(o.length,0),Buffer.concat([i,o,r])}function P(t){let e=_(t);if(e.length<4)throw new Error("stream frame is truncated");let n=e.readUInt32BE(0);if(n===0||n>8192||e.length<4+n)throw new Error("stream frame header is invalid");let r;try{r=JSON.parse(e.subarray(4,4+n).toString("utf8"))}catch(o){throw new Error(`stream frame header is not JSON: ${o.message}`)}if(!r||typeof r.type!="string"||typeof r.streamId!="string")throw new Error("stream frame header is missing routing fields");return{version:1,type:r.type,streamId:r.streamId,payload:e.subarray(4+n)}}function X(t,e,n=Buffer.alloc(0)){let r=t;if(t==="output"?r=0:t==="input"&&(r=1),r!==0&&r!==1)throw new TypeError("type must be FRAME_TYPE_OUTPUT (0) or FRAME_TYPE_INPUT (1)");if(!Number.isInteger(e)||e<0||e>65535)throw new RangeError("streamIndex must be an unsigned 16-bit integer (0-65535)");let o=_(n),i=Buffer.allocUnsafe(4+o.length);return i.writeUInt8(255,0),i.writeUInt8(r,1),i.writeUInt16BE(e,2),o.copy(i,4),i}function F(t){let e=_(t);if(e.length<4)throw new Error("v2 stream frame is truncated");if(e.readUInt8(0)!==255)throw new Error("invalid v2 stream frame magic byte");let r=e.readUInt8(1);if(r!==0&&r!==1)throw new Error(`unknown v2 stream frame type: ${r}`);let o=e.readUInt16BE(2);return{version:2,type:r===0?"output":"input",typeCode:r,streamIndex:o,payload:e.subarray(4)}}function C(t){let e=_(t);if(e.length<4)throw new Error("stream frame is truncated");return e[0]===255?F(e):P(e)}var N=/^[\x21-\x7e]+$/;function z(t){if(!Array.isArray(t))return;let e=new Set;for(let n of t){if(e.size>=8)break;if(typeof n!="string")continue;let r=n.replace(/\s+/g,"").toLowerCase();r.length<=32&&N.test(r)&&e.add(r)}return e.size>0?[...e]:void 0}var G="/ws/host";var D={hostHandoff:"host_handoff",idleHeartbeat:"idle_heartbeat",binaryFrameV2:"binary_frame_v2",adminTabs:"admin_tabs"};var x={"image/png":".png","image/jpeg":".jpg","image/webp":".webp","image/gif":".gif"},K=Object.keys(x);function J(t){return typeof t=="string"&&Object.hasOwn(x,t)}function W(t,e){switch(t){case"image/png":return e.length>=8&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71;case"image/jpeg":return e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255;case"image/webp":return e.length>=12&&e[0]===82&&e[1]===73&&e[2]===70&&e[3]===70&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80;case"image/gif":return e.length>=6&&e[0]===71&&e[1]===73&&e[2]===70&&e[3]===56;default:return!1}}export{k as a,X as b,C as c,T as d,R as e,O as f,U as g,z as h,G as i,D as j,x as k,J as l,W as m,g as n,Y as o,L as p,b as q};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{a as g,c as S}from"./U6QAYG3E.js";import{d as p,f as b}from"./PBMBFWLQ.js";import f from"node:fs";import{spawnSync as O}from"node:child_process";var A=p.length,D="3",M=2,h=3e3,P=p;function v(e){if(typeof e!="string")return null;let n=/^rgba?:([0-9a-f]+)\/([0-9a-f]+)\/([0-9a-f]+)/i.exec(e.trim());if(!n)return null;let t=n.slice(1,4).map(r=>{let l=r.length;if(l===0||l>4)return null;let i=Math.round(parseInt(r,16)/(16**l-1)*255);return Math.max(0,Math.min(255,i))});return t.some(r=>r===null)?null:`#${t.map(r=>r.toString(16).padStart(2,"0")).join("")}`}function R(e,n){if(typeof e!="string")return null;let t=e.indexOf(`${n};`);if(t===-1)return null;let r=e.indexOf("\x1B\\",t),l=e.indexOf("\x07",t),i=-1,s=-1;if(r!==-1&&(l===-1||r<l))i=r,s=r+2;else if(l!==-1)i=l,s=l+1;else return null;let o=v(e.slice(t+n.length+1,i).trim());return o?{color:o,start:t,end:s}:null}function C(e,n){return R(e,n)?.color??null}var d=b;function T(e=process.env){let n=e.HERDR_TERM_PALETTE_JSON;if(!n)return null;try{return d(JSON.parse(n))}catch{return null}}function m(e,n){return O("stty",[...e,"-F",n],{encoding:"utf8",timeout:1e3,windowsHide:!0})}function y(e,n){let t=R(e.pending,n);return t?(e.pending=e.pending.slice(0,t.start)+e.pending.slice(t.end),t.color):null}var _=[{query:"\x1B]10;?\x1B\\",prefix:"\x1B]10",paletteKey:"foreground"},{query:"\x1B]11;?\x1B\\",prefix:"\x1B]11",paletteKey:"background"},{query:"\x1B]12;?\x1B\\",prefix:"\x1B]12",paletteKey:"cursor"},...P.map((e,n)=>({query:`\x1B]4;${n};?\x1B\\`,prefix:`\x1B]4;${n}`,paletteKey:"ansi",ansiKey:e}))];function x(e){let n={},t={};for(let r of _){let l=e(r.query,r.prefix);if(r.paletteKey==="ansi"){if(!l)break;t[r.ansiKey]=l}else l&&(n[r.paletteKey]=l)}return Object.keys(t).length===A&&(n.ansi=t),d(n)}function N(e,n,t,r){f.writeSync(e,n);let l=Buffer.alloc(256),i=0;for(;i<M&&Date.now()<r.overallDeadline;){let s=y(r,t);if(s)return s;let o=0;try{o=f.readSync(e,l,0,l.length,null)}catch(a){if(a.code==="EAGAIN"){i+=1;continue}return null}o>0?(r.pending+=l.toString("latin1",0,o),i=0):i+=1}return y(r,t)}function E({ttyPath:e="/dev/tty",timeoutMs:n=h}={}){if(process.platform==="win32")return null;let t=null,r=null;try{t=f.openSync(e,"r+")}catch{return null}try{let l=m(["-g"],e);if(l.status!==0||(r=l.stdout.trim(),m(["raw","-echo","min","0","time",D],e).status!==0))return null;let i={pending:"",overallDeadline:Date.now()+n},s=t;return x((o,a)=>N(s,o,a,i))}catch{return null}finally{if(r&&m([r],e),t!==null)try{f.closeSync(t)}catch{}}}async function I({input:e=process.stdin,output:n=process.stdout,timeoutMs:t=h}={}){if(!e.isTTY||!n.isTTY)return null;let r={pending:"",overallDeadline:Date.now()+t},l=null,i;try{return e.setRawMode(!0),await new Promise(s=>{let o=!1,a=()=>{o||(o=!0,s())};l=c=>{r.pending+=typeof c=="string"?c:c.toString("latin1"),/\x1b\[\?[\d;]*c/.test(r.pending)&&a()},e.on("data",l),e.resume(),i=setTimeout(a,Math.max(0,r.overallDeadline-Date.now())),n.write(`${_.map(({query:c})=>c).join("")}\x1B[c`)}),x((s,o)=>y(r,o))}catch{return null}finally{i&&clearTimeout(i),l&&e.removeListener("data",l);try{e.setRawMode(!1)}catch{}e.pause()}}function w(e){let n=d(e);if(!n)return null;try{S(t=>{t.terminalPalette=n})}catch{}return n}function K(){try{return d(g().terminalPalette)}catch{return null}}function J({env:e=process.env,probe:n=E}={}){return T(e)||n()||null}async function $({env:e=process.env,probe:n=E,platform:t=process.platform,consoleProbe:r=I}={}){if(e.HERDR_TERM_PALETTE_JSON)return T(e);if(!process.stdin.isTTY||!process.stdout.isTTY)return null;let l=t==="win32"?await r():n();return l?(e.HERDR_TERM_PALETTE_JSON=JSON.stringify(l),w(l),l):null}var u;function j({refresh:e=!1}={}){if(!e&&u!==void 0)return u;let n=T();if(n)return u=n,u;let t=E();return u=t?w(t):K(),u}export{A as a,P as b,v as c,C as d,d as e,T as f,y as g,x as h,E as i,I as j,w as k,K as l,J as m,$ as n,j as o};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{a as e,b as f,c as g,d as h,e as i,f as j,g as k,h as l,i as m,j as n}from"./VD54DF7R.js";import{a as c,b as d}from"./RMHH3IAX.js";import{b as a,c as b}from"./CVJ4HBMP.js";import"./KGOQKOHH.js";import"./M52LJEES.js";import"./KRVF37OW.js";import"./QRGNEKME.js";import"./PBMBFWLQ.js";import"./TNLCNVA2.js";import"./I6NRCYLI.js";export{g as detectManager,m as enableLinger,c as escapeXml,i as install,n as logsHint,d as renderLaunchdPlist,f as renderSystemdUnit,k as restart,b as serviceEnvironment,a as servicePath,h as status,l as stopManaged,e as systemdEnvironmentLine,j as uninstall};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import e from"node:crypto";import t from"node:fs";import i from"node:path";function s(r){t.mkdirSync(r,{recursive:!0,mode:448});try{t.chmodSync(r,448)}catch{}}function u(r,n){s(i.dirname(r));let o=`${r}.${process.pid}.${e.randomBytes(4).toString("hex")}.tmp`;t.writeFileSync(o,`${JSON.stringify(n,null,2)}
|
|
4
|
+
`,{mode:384});try{t.chmodSync(o,384)}catch{}t.renameSync(o,r);try{t.chmodSync(r,384)}catch{}}function p(r,n){try{return JSON.parse(t.readFileSync(r,"utf8"))}catch(o){let{code:c,message:m}=o;return c!=="ENOENT"&&process.stderr.write(`herdr-remote: invalid state at ${r}: ${m}
|
|
5
|
+
`),n}}function S(r=32){return e.randomBytes(r).toString("base64url")}export{s as a,u as b,p as c,S as d};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{a as m,c as S}from"./CVJ4HBMP.js";import{a as x}from"./QRGNEKME.js";import{a as R,b as D,c,f as g}from"./TNLCNVA2.js";import{spawnSync as T}from"node:child_process";import $ from"node:fs";import M from"node:os";import W from"node:path";var k="dev.herdr.remote";function C(){return W.join(M.homedir(),"Library","LaunchAgents",`${k}.plist`)}function n(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function V({nodePath:t=process.execPath,entryPoint:e=m(),label:r=k,outLog:o=g("supervisor"),errLog:i=g("supervisor"),environment:p={}}={}){let u=Object.entries(p).map(([y,v])=>` <key>${n(y)}</key>
|
|
4
|
+
<string>${n(v)}</string>`).join(`
|
|
5
|
+
`),s=u?` <key>EnvironmentVariables</key>
|
|
6
|
+
<dict>
|
|
7
|
+
${u}
|
|
8
|
+
</dict>
|
|
9
|
+
`:"";return`<?xml version="1.0" encoding="UTF-8"?>
|
|
10
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
11
|
+
<plist version="1.0">
|
|
12
|
+
<dict>
|
|
13
|
+
<key>Label</key>
|
|
14
|
+
<string>${n(r)}</string>
|
|
15
|
+
<key>ProgramArguments</key>
|
|
16
|
+
<array>
|
|
17
|
+
<string>${n(t)}</string>
|
|
18
|
+
<string>${n(e)}</string>
|
|
19
|
+
<string>run</string>
|
|
20
|
+
</array>
|
|
21
|
+
<key>RunAtLoad</key>
|
|
22
|
+
<true/>
|
|
23
|
+
<key>KeepAlive</key>
|
|
24
|
+
<true/>
|
|
25
|
+
<key>ProcessType</key>
|
|
26
|
+
<string>Background</string>
|
|
27
|
+
${s} <key>StandardOutPath</key>
|
|
28
|
+
<string>${n(o)}</string>
|
|
29
|
+
<key>StandardErrorPath</key>
|
|
30
|
+
<string>${n(i)}</string>
|
|
31
|
+
</dict>
|
|
32
|
+
</plist>
|
|
33
|
+
`}function O(){return`gui/${process.getuid?process.getuid():""}`}function d(){return`${O()}/${k}`}function L(t){return T("launchctl",t,{encoding:"utf8",windowsHide:!0})}function f(t){T("launchctl",t,{stdio:"ignore",windowsHide:!0})}var yt={name:"launchd",status(){let t=C();if(!$.existsSync(t))return{manager:"launchd",installed:!1,active:!1,enabled:!1};let e=L(["print",d()]),r=String(e.stdout||"");return{manager:"launchd",installed:!0,active:e.status===0&&/state = running/.test(r),enabled:e.status===0,unitPath:t,state:e.status===0?"loaded":"not loaded"}},async install(){let t=C();x(W.dirname(t)),x(c()),$.writeFileSync(t,V({environment:S()}),{mode:420}),f(["bootout",d()]);let e=L(["bootstrap",O(),t]);if(e.status!==0)throw new Error(`launchctl bootstrap failed: ${String(e.stderr||"").trim()}`);return f(["enable",d()]),{ok:!0,unitPath:t}},async uninstall(){let t=C();return f(["bootout",d()]),$.rmSync(t,{force:!0}),{ok:!0,unitPath:t}},restart(){return f(["kickstart","-k",d()]),{ok:!0}},stop(){f(["bootout",d()])},logsHint(){return`tail -f ${g("supervisor")}`}};import{spawn as G,spawnSync as E}from"node:child_process";import{createHash as Y}from"node:crypto";import a from"node:fs";import K from"node:os";import h from"node:path";var Q=2e4,X=250;function q(t){return`herdr-remote-${t.replace(/[^A-Za-z0-9._-]/g,"_")}`}function N(){return{domain:process.env.USERDOMAIN||"",user:process.env.USERNAME||K.userInfo().username}}function w(){let t=q(N().user),e=h.join(c(),"service");return{id:t,directory:e,exePath:h.join(e,`${t}.exe`),unitPath:h.join(e,`${t}.xml`)}}function H(t){return t.trim().split(/\r?\n/).pop()?.trim()}function z(t){let e=H(t)?.match(/"([^"]+)"\s*$/)?.[1];return e&&/^S-\d(?:-\d+)+$/.test(e)?e:null}function Z(t){let e=H(t);return e==="Started"||e==="Stopped"||e==="NonExistent"?e:"NonExistent"}function J(t){return"D:"+["(A;;CCLCSWRPWPDTLOCRRC;;;SY)","(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)","(A;;CCLCSWLOCRRC;;;IU)","(A;;CCLCSWLOCRRC;;;SU)",`(A;;CCLCSWRPWPDTLOCRRC;;;${t})`].join("")}function tt(t){let{id:e,user:r,domain:o,userSid:i,nodePath:p,entryPoint:u,workingDirectory:s,environment:y}=t,v=Object.entries(y).map(([U,B])=>` <env name="${n(U)}" value="${n(B)}"/>`);return`<service>
|
|
34
|
+
<id>${n(e)}</id>
|
|
35
|
+
<name>${n(`Herdr Remote (${r})`)}</name>
|
|
36
|
+
<description>${n(`Browser access to Herdr workspaces, running as ${o}\\${r}.`)}</description>
|
|
37
|
+
<executable>${n(p)}</executable>
|
|
38
|
+
<arguments>${n(`"${u}" run --daemon`)}</arguments>
|
|
39
|
+
<workingdirectory>${n(s)}</workingdirectory>
|
|
40
|
+
<startmode>Automatic</startmode>
|
|
41
|
+
<delayedAutoStart/>
|
|
42
|
+
<onfailure action="restart" delay="3 sec"/>
|
|
43
|
+
<resetfailure>1 hour</resetfailure>
|
|
44
|
+
<stoptimeout>15 sec</stoptimeout>
|
|
45
|
+
<logpath>${n(s)}</logpath>
|
|
46
|
+
<logname>supervisor</logname>
|
|
47
|
+
<log mode="append"/>
|
|
48
|
+
${v.join(`
|
|
49
|
+
`)}
|
|
50
|
+
<serviceaccount>
|
|
51
|
+
<domain>${n(o)}</domain>
|
|
52
|
+
<user>${n(r)}</user>
|
|
53
|
+
<allowservicelogon>true</allowservicelogon>
|
|
54
|
+
</serviceaccount>
|
|
55
|
+
<securityDescriptor>${n(J(i))}</securityDescriptor>
|
|
56
|
+
</service>
|
|
57
|
+
`}function _(t){return t.replace(/'/g,"''")}function et({nodePath:t,entryPoint:e}){let r=_(t),o=_(e);return`$ErrorActionPreference = 'Stop'
|
|
58
|
+
try {
|
|
59
|
+
$process = Start-Process -FilePath '${r}' -ArgumentList '"${o}" keepalive install --elevated' -Verb RunAs -Wait -PassThru
|
|
60
|
+
} catch {
|
|
61
|
+
exit 1223
|
|
62
|
+
}
|
|
63
|
+
exit $process.ExitCode`}function rt(t){return Buffer.from(t,"utf16le").toString("base64")}function l(t){return t?String(t).trim():""}function I(t){let e=E("sc.exe",[t,w().id],{encoding:"utf8",windowsHide:!0});return{code:e.status,stdout:l(e.stdout),stderr:l(e.stderr)}}function j(t,e){let r=e.stdout||e.stderr;return new Error(`sc.exe ${t} failed (${e.code}): ${r}`)}function nt(t){return t.code===0||t.code===1056?"ok":t.code===1069?"logon-failed":j("start",t)}function ot(){return I("start")}function it(){return I("stop")}function P(){let{exePath:t}=w();if(!a.existsSync(t))return"NonExistent";let e=E(t,["status"],{encoding:"utf8",windowsHide:!0});return e.error||e.status!==0?"NonExistent":Z(l(e.stdout))}function F(t,e=Q){let r=Date.now()+e;for(;P()!==t;){if(Date.now()>=r)throw new Error(`Windows service did not reach ${t} within ${e} ms`);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,X)}}function A(){let t=it();if(t.code!==0&&t.code!==1062&&t.code!==1060)throw j("stop",t)}function st(){let t=ot(),e=nt(t);if(e==="logon-failed"){let r=t.stdout||t.stderr;throw new Error(`Windows service logon failed (1069): ${r}`)}if(e instanceof Error)throw e;return{ok:!0}}function b(t){return Y("sha256").update(a.readFileSync(t)).digest("hex")}async function ct(){let t=w();await a.promises.mkdir(t.directory,{recursive:!0});let e=h.join(R,"vendor","winsw","WinSW.NET461.exe");if(!a.existsSync(t.exePath)||b(t.exePath)!==b(e))try{await a.promises.copyFile(e,t.exePath)}catch(s){throw["EBUSY","EPERM","EACCES"].includes(s.code||"")?new Error(`Could not replace ${t.exePath}; stop the Windows service first.`,{cause:s}):s}let r={...S(),HERDR_REMOTE_CONFIG_DIR:D(),HERDR_REMOTE_STATE_DIR:c(),HERDR_REMOTE_SERVICE:"1"},o=E("whoami",["/user","/fo","csv","/nh"],{encoding:"utf8",windowsHide:!0}),i=!o.error&&o.status===0?z(l(o.stdout)):null;if(!i)throw new Error(`Could not read the current Windows user SID: ${l(o.stderr)}`);let{user:p,domain:u}=N();return await a.promises.writeFile(t.unitPath,tt({id:t.id,user:p,domain:u,userSid:i,nodePath:process.execPath,entryPoint:m(),workingDirectory:c(),environment:r}),"utf8"),t}function at(t){return new Promise((e,r)=>{t.once("error",r),t.once("close",o=>e(o??1))})}async function ut(){let t=await ct(),e=et({nodePath:process.execPath,entryPoint:m()}),r=G("powershell.exe",["-NoProfile","-NonInteractive","-EncodedCommand",rt(e)],{windowsHide:!0,stdio:"ignore"}),o=await at(r);if(o===1223){let i=new Error("Administrator rights were not granted; nothing was installed.");throw i.code="ELEVATION_CANCELLED",i}if(o!==0)throw new Error(`Windows service installation did not complete (exit code ${o}).`);return{ok:!0,unitPath:t.unitPath,state:P()}}function dt(){let t=w(),e=P(),r=e!=="NonExistent";return{manager:"windows-service",installed:r,active:e==="Started",enabled:r,unitPath:t.unitPath,state:e}}async function lt(){let t=w();A(),F("Stopped");let e=E(t.exePath,["uninstall"],{windowsHide:!0});if(e.error||e.status!==0)throw new Error(`WinSW uninstall failed with exit code ${String(e.status)}: ${l(e.stdout)}`);if(P()!=="NonExistent")throw new Error(`Windows service still exists: ${t.id}`);return a.rmSync(t.directory,{recursive:!0,force:!0}),{ok:!0,unitPath:t.unitPath}}function pt(){return A(),F("Stopped"),st()}function mt(){return`Get-Content -Wait -Tail 40 "${h.join(c(),"supervisor.out.log")}"`}var Tt={name:"windows-service",status:dt,install:ut,uninstall:lt,restart:pt,stop:A,logsHint:mt};export{n as a,V as b,yt as c,q as d,N as e,w as f,_ as g,rt as h,nt as i,ot as j,P as k,F as l,Tt as m};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import f from"node:fs";import e from"node:os";import r from"node:path";function m(o){let n=o;for(let t=0;t<8;t+=1){let c=r.join(n,"package.json");try{if(JSON.parse(f.readFileSync(c,"utf8")).name==="herdr-remote")return n}catch{}let i=r.dirname(n);if(i===n)break;n=i}return r.resolve(o,"..")}var _=m(import.meta.dirname);function R(o=process.env,n=process.platform){return o.HERDR_REMOTE_CONFIG_DIR?o.HERDR_REMOTE_CONFIG_DIR:n==="win32"?r.join(o.APPDATA||r.join(e.homedir(),"AppData","Roaming"),"herdr-remote"):r.join(e.homedir(),".config","herdr-remote")}function a(o=process.env,n=process.platform){return o.HERDR_REMOTE_STATE_DIR?o.HERDR_REMOTE_STATE_DIR:n==="win32"?r.join(o.LOCALAPPDATA||r.join(e.homedir(),"AppData","Local"),"herdr-remote"):r.join(e.homedir(),".local","state","herdr-remote")}function D(){return r.join(R(),"config.json")}function d(){return r.join(a(),"runtime.json")}function E(o){return r.join(a(),`${o}.log`)}function h(){return process.env.HERDR_PLUGIN_CONFIG_DIR?r.join(process.env.HERDR_PLUGIN_CONFIG_DIR,"config.json"):null}export{_ as a,R as b,a as c,D as d,d as e,E as f,h as g};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{b as g,c as s}from"./KRVF37OW.js";import{a as i,b as m,c as p,d as r}from"./QRGNEKME.js";import{b as d,c as f,e as o}from"./TNLCNVA2.js";var y=2;function h(){let t=p(o(),{});return t&&typeof t=="object"?t:{}}function a(t){m(o(),t)}function I(t){let n=h();return t(n),a(n),n}function l(){return i(d()),i(f()),I(t=>{t.version||(t.version=y),t.hostId||(t.hostId=`host-${r(9)}`),t.hostToken||(t.hostToken=r(32))})}function w(t){let n=l();return n.relayPassword=typeof t=="string"?t.trim():"",a(n),n}function T(){let t=l();return t.hostId=`host-${r(9)}`,t.hostToken=r(32),a(t),t}function A(t,n,e){let x=Array.isArray(t.managedPids)?t.managedPids.filter(Boolean):[],u=s(x.filter(P=>P.pid!==e)),c=Number.isInteger(e)?g(e):null;return c&&u.push({name:n,pid:e,processStart:c,startedAt:new Date().toISOString()}),t.managedPids=u,t}function D(t=h()){let n=new Map;for(let e of t.managedPids||[])e&&!n.has(e.pid)&&n.set(e.pid,e);return s([...n.values()])}export{h as a,a as b,I as c,l as d,w as e,T as f,A as g,D as h};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{a as F,b as B,c as q,d as Q,e as P,g as r,h,m as i}from"./RMHH3IAX.js";import{a as m,b as G,c as a}from"./CVJ4HBMP.js";import{o as u}from"./M52LJEES.js";import{b as U,c as j}from"./KRVF37OW.js";import{a as w,b as M,c as W}from"./QRGNEKME.js";import{b as C,c as d,f as N}from"./TNLCNVA2.js";import{c as it}from"./I6NRCYLI.js";var It={};it(It,{detectManager:()=>rt,enableLinger:()=>At,escapeXml:()=>F,install:()=>Pt,logsHint:()=>xt,renderLaunchdPlist:()=>B,renderSystemdUnit:()=>O,restart:()=>Dt,serviceEnvironment:()=>a,servicePath:()=>G,status:()=>st,stopManaged:()=>bt,systemdEnvironmentLine:()=>L,uninstall:()=>Rt});import{spawnSync as Et}from"node:child_process";import tt from"node:fs";import Nt from"node:os";import et from"node:path";import{spawn as at}from"node:child_process";import D from"node:fs";import ct from"node:path";function k(){return ct.join(d(),"supervisor.pid")}function b(){let t=W(k(),{});return j([t]).length>0?t.pid:null}function X(){let t=b();if(t!==null)return{ok:!0,alreadyRunning:!0,pid:t};w(d());let e=D.openSync(N("supervisor"),"a");try{let n=at(process.execPath,[m(),"run","--daemon"],{cwd:d(),env:{...process.env,HERDR_REMOTE_SERVICE:"1",...a()},detached:!0,windowsHide:!0,stdio:["ignore",e,e]});return n.unref(),M(k(),{pid:n.pid,processStart:n.pid?U(n.pid):null,startedAt:new Date().toISOString()}),{ok:!0,pid:n.pid,note:"this fallback does not survive a reboot"}}finally{D.closeSync(e)}}function R(){let t=b();if(t!==null)try{process.kill(t,"SIGTERM")}catch{}return D.rmSync(k(),{force:!0}),{ok:!0,stoppedPid:t}}function A(t=process.platform,e=N("supervisor")){return t==="win32"?`Get-Content -Wait -Tail 40 "${e}"`:`tail -f ${e}`}var J={name:"supervisor",status(){let t=b(),e=t!==null;return{manager:"supervisor",installed:e,active:e,enabled:!1,pid:e?t:null,unitPath:k(),state:e?"running":"stopped"}},async install(){return X()},async uninstall(){return R()},restart(){return R(),X()},stop(){R()},logsHint(){return A()}};import{spawnSync as V}from"node:child_process";import x from"node:fs";import I from"node:os";import _ from"node:path";var c="herdr-remote.service";function $(){let t=process.env.XDG_CONFIG_HOME||_.join(I.homedir(),".config");return _.join(t,"systemd","user",c)}function L(t,e){let n=String(e).replace(/[\r\n]+/g," ").replace(/%/g,"%%");return/^[\w@+=:,./-]*$/.test(n)?`Environment=${t}=${n}`:`Environment="${t}=${n.replace(/([\\"])/g,"\\$1")}"`}function O({nodePath:t=process.execPath,entryPoint:e=m(),environment:n={}}={}){let s=Object.entries(n).map(([o,S])=>L(o,S)).join(`
|
|
4
|
+
`);return`[Unit]
|
|
5
|
+
Description=Herdr Remote (relay and host connector)
|
|
6
|
+
Documentation=https://github.com/dibin666/herdr-remote
|
|
7
|
+
After=default.target
|
|
8
|
+
|
|
9
|
+
[Service]
|
|
10
|
+
Type=simple
|
|
11
|
+
ExecStart=${t} ${e} run
|
|
12
|
+
Restart=always
|
|
13
|
+
RestartSec=3
|
|
14
|
+
# Give the relay and host connector time to close sessions cleanly.
|
|
15
|
+
TimeoutStopSec=15
|
|
16
|
+
${s}
|
|
17
|
+
|
|
18
|
+
[Install]
|
|
19
|
+
WantedBy=default.target
|
|
20
|
+
`}function l(t){return V("systemctl",["--user",...t],{encoding:"utf8",stdio:"pipe",windowsHide:!0})}function K(t,e){let n=l(t);if(n.status!==0)throw new Error(`${e}: ${String(n.stderr||"").trim()}`)}var Y={name:"systemd",status(){if(!x.existsSync($()))return{manager:"systemd",installed:!1,active:!1,enabled:!1};let e=l(["is-active",c]),n=l(["is-enabled",c]),s=V("loginctl",["show-user",I.userInfo().username,"--property=Linger"],{encoding:"utf8",windowsHide:!0});return{manager:"systemd",installed:!0,active:String(e.stdout||"").trim()==="active",enabled:String(n.stdout||"").trim().startsWith("enabled"),linger:String(s.stdout||"").includes("Linger=yes"),unitPath:$(),state:String(e.stdout||e.stderr||"").trim()}},async install(){let t=$();return w(_.dirname(t)),x.writeFileSync(t,O({environment:a()}),{mode:420}),K(["daemon-reload"],"systemctl --user daemon-reload failed"),K(["enable","--now",c],"systemctl --user enable --now failed"),{ok:!0,unitPath:t,hint:`loginctl enable-linger ${I.userInfo().username}`}},async uninstall(){let t=$();return l(["disable","--now",c]),x.rmSync(t,{force:!0}),l(["daemon-reload"]),{ok:!0,unitPath:t}},restart(){let t=l(["restart",c]);if(t.status!==0)throw new Error(String(t.stderr||"").trim()||"systemctl restart failed");return{ok:!0}},stop(){l(["stop",c])},logsHint(){return`journalctl --user -u ${c} -f`}};import{spawnSync as Z}from"node:child_process";import ut from"node:fs";import lt from"node:path";var dt=15e3,mt=15e3,z=250;function p(t=P().user){return Q(t)}function ft(t){let e={...t.environment,HERDR_REMOTE_CONFIG_DIR:t.configDirectory,HERDR_REMOTE_STATE_DIR:t.stateDirectory,HERDR_REMOTE_SERVICE:"1"};return`$ErrorActionPreference = 'Stop'
|
|
21
|
+
${Object.entries(e).map(([s,o])=>`$env:${s} = '${r(o)}'`).join(`
|
|
22
|
+
`)}
|
|
23
|
+
Set-Location -LiteralPath '${r(t.workingDirectory)}'
|
|
24
|
+
& '${r(t.nodePath)}' '${r(t.entryPoint)}' run --daemon
|
|
25
|
+
exit $LASTEXITCODE`}function pt(t){let e=r(t.taskName),n=r(t.account),s=r(t.powershellPath),o=r(t.workingDirectory),S=`-NoLogo -NoProfile -NonInteractive -WindowStyle Hidden -EncodedCommand ${h(t.launchScript)}`;return`$ErrorActionPreference = 'Stop'
|
|
26
|
+
$action = New-ScheduledTaskAction -Execute '${s}' -Argument '${S}' -WorkingDirectory '${o}'
|
|
27
|
+
$trigger = New-ScheduledTaskTrigger -AtLogOn -User '${n}'
|
|
28
|
+
# Interactive logon uses the signed-in token and avoids storing account credentials.
|
|
29
|
+
$principal = New-ScheduledTaskPrincipal -UserId '${n}' -LogonType Interactive -RunLevel Limited
|
|
30
|
+
$settings = New-ScheduledTaskSettingsSet -StartWhenAvailable -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 1) -ExecutionTimeLimit ([TimeSpan]::Zero) -MultipleInstances IgnoreNew
|
|
31
|
+
Register-ScheduledTask -TaskName '${e}' -Description 'Herdr Remote keep-alive' -Action $action -Trigger $trigger -Principal $principal -Settings $settings -Force | Out-Null
|
|
32
|
+
Enable-ScheduledTask -TaskName '${e}' | Out-Null
|
|
33
|
+
Start-ScheduledTask -TaskName '${e}'`}function St(t){try{let e=JSON.parse(t.replace(/^\uFEFF/,"").trim()).State;return e==="Ready"||e==="Queued"||e==="Running"||e==="Disabled"?e:"Absent"}catch{return"Absent"}}function H(){let t=process.env.SystemRoot||process.env.WINDIR||"C:\\Windows";return lt.join(t,"System32","WindowsPowerShell","v1.0","powershell.exe")}function gt(t){return`$ErrorActionPreference = 'Stop'
|
|
34
|
+
$task = Get-ScheduledTask -TaskName '${r(t)}' -ErrorAction SilentlyContinue
|
|
35
|
+
if ($null -eq $task) { '{"State":"Absent"}'; exit 0 }
|
|
36
|
+
[pscustomobject]@{ State = [string]$task.State } | ConvertTo-Json -Compress`}function y(t,e){let n=Z(H(),["-NoLogo","-NoProfile","-NonInteractive","-EncodedCommand",h(t)],{encoding:"utf8",windowsHide:!0});if(n.error||n.status!==0){let s=String(n.stderr||n.stdout||"").trim();throw new Error(`${e} failed (${String(n.status)}): ${s}`)}return String(n.stdout||"").trim()}function f(){let t=Z(H(),["-NoProfile","-NoLogo","-NonInteractive","-EncodedCommand",h(gt(p()))],{encoding:"utf8",windowsHide:!0});return t.error||t.status!==0?"Absent":St(String(t.stdout||""))}function wt(){let{domain:t,user:e}=P();return t?`${t}\\${e}`:e}function ht(t){let e=r(t);return`$ErrorActionPreference = 'Stop'
|
|
37
|
+
$task = Get-ScheduledTask -TaskName '${e}' -ErrorAction SilentlyContinue
|
|
38
|
+
if ($null -eq $task -or ($task.State -ne 'Running' -and $task.State -ne 'Queued')) { exit 0 }
|
|
39
|
+
Stop-ScheduledTask -TaskName '${e}'
|
|
40
|
+
$deadline = [DateTime]::UtcNow.AddMilliseconds(${mt})
|
|
41
|
+
do {
|
|
42
|
+
Start-Sleep -Milliseconds ${z}
|
|
43
|
+
$task = Get-ScheduledTask -TaskName '${e}' -ErrorAction SilentlyContinue
|
|
44
|
+
} while ($task -and ($task.State -eq 'Running' -or $task.State -eq 'Queued') -and [DateTime]::UtcNow -lt $deadline)
|
|
45
|
+
if ($task -and ($task.State -eq 'Running' -or $task.State -eq 'Queued')) { throw 'Scheduled task did not stop in time.' }`}function v(){let t=f();(t==="Running"||t==="Queued")&&y(ht(p()),"Stopping the Windows scheduled task")}function kt(){let t=d();return{nodePath:process.execPath,entryPoint:m(),workingDirectory:t,configDirectory:C(),stateDirectory:t,environment:a()}}function $t(){let t=f(),e=t!=="Absent";return{manager:"windows-task",installed:e,active:t==="Running",enabled:e&&t!=="Disabled",state:t.toLowerCase()}}async function yt(){f()!=="Absent"&&v(),i.status().installed&&await i.uninstall();let t=kt();await ut.promises.mkdir(t.workingDirectory,{recursive:!0});let e=ft(t),n=pt({taskName:p(),account:wt(),powershellPath:H(),workingDirectory:t.workingDirectory,launchScript:e});y(n,"Installing the Windows scheduled task");let s=Date.now()+dt,o=f();for(;o!=="Running"&&o!=="Absent"&&Date.now()<s;)await new Promise(S=>setTimeout(S,z)),o=f();if(o!=="Running")throw new Error(`Windows scheduled task did not start (state: ${o.toLowerCase()}).`);return{ok:!0,taskName:p(),state:o}}async function vt(){let t=p();if(f()!=="Absent"){v();let e=r(t);y(`Unregister-ScheduledTask -TaskName '${e}' -Confirm:$false -ErrorAction Stop`,"Removing the Windows scheduled task")}return i.status().installed&&await i.uninstall(),{ok:!0,taskName:t}}function Tt(){v();let t=r(p());return y(`Start-ScheduledTask -TaskName '${t}'`,"Starting the Windows scheduled task"),{ok:!0}}var T={name:"windows-task",status:$t,install:yt,uninstall:vt,restart:Tt,stop:v,logsHint:()=>A("win32")};function nt(t){return(process.env.PATH||"").split(et.delimiter).filter(Boolean).some(e=>{try{return tt.accessSync(et.join(e,t),tt.constants.X_OK),!0}catch{return!1}})}function rt(t="auto",e=process.platform){return t&&t!=="auto"?t:e==="win32"?"windows-task":e==="linux"?nt("systemctl")&&(process.env.DBUS_SESSION_BUS_ADDRESS||process.env.XDG_RUNTIME_DIR)?"systemd":"supervisor":e==="darwin"&&nt("launchctl")?"launchd":"supervisor"}function E(t){return rt(t.keepalive?.manager||"auto")}function ot(t){return t==="systemd"?Y:t==="launchd"?q:t==="windows-task"?T:t==="windows-service"?i:J}function g(t){let e=E(t);if(e==="windows-task"){if(T.status().installed)return T;if(i.status().installed)return i}return ot(e)}function st(t=u()){return E(t)==="none"?{manager:"none",installed:!1,active:!1,enabled:!1}:g(t).status()}async function Pt(t=u()){if(E(t)==="none")throw new Error("keep-alive is disabled in the configuration");let e=ot(E(t));return{manager:e.name,...await e.install()}}async function Rt(t=u()){let e=g(t);return{manager:e.name,...await e.uninstall()}}function Dt(t=u()){let e=g(t);return{manager:e.name,...e.restart()}}function bt(t=u()){let e=st(t);return e.manager==="none"||!e.installed&&!e.active?{managed:!1}:(g(t).stop(),{managed:!0,manager:e.manager})}function At(){let t=Nt.userInfo().username,e=Et("loginctl",["enable-linger",t],{encoding:"utf8",windowsHide:!0});if(e.status!==0)throw new Error(String(e.stderr||"").trim()||"loginctl enable-linger failed");return{ok:!0,username:t}}function xt(t=u()){return g(t).logsHint()}export{L as a,O as b,rt as c,st as d,Pt as e,Rt as f,Dt as g,bt as h,At as i,xt as j,It as k};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h}from"./H24ZP5D5.js";import"./U6QAYG3E.js";import"./KRVF37OW.js";import"./QRGNEKME.js";import"./PBMBFWLQ.js";import"./TNLCNVA2.js";import"./I6NRCYLI.js";export{f as captureTerminalFont,b as detectTerminalFont,e as fontFromEnvironment,h as loadHostTerminalFont,c as publicTerminalFont,d as readFontChunk,a as readTerminalFont,g as resolveHostFont};
|
package/dist/cli.js
CHANGED
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// the subcommands exist for scripting and for the actions declared in
|
|
5
|
-
// herdr-plugin.toml, which Herdr runs without a terminal attached.
|
|
6
|
-
import fs from 'node:fs';
|
|
7
|
-
import os from 'node:os';
|
|
8
|
-
import path from 'node:path';
|
|
9
|
-
import { LANGUAGES, loadConfig, migrateLegacyConfig } from './config.js';
|
|
10
|
-
import { PACKAGE_ROOT, configPath, stateDir } from './paths.js';
|
|
11
|
-
import { extractPairingCode } from './relay-client.js';
|
|
12
|
-
import { resolvePublicUrl } from './relay-urls.js';
|
|
13
|
-
import { createTranslator, detectLocale } from './i18n/index.js';
|
|
14
|
-
import { preferredLanAddress } from './net-interfaces.js';
|
|
15
|
-
const VERSION = JSON.parse(fs.readFileSync(path.join(PACKAGE_ROOT, 'package.json'), 'utf8')).version;
|
|
16
|
-
const USAGE = `herdr-remote ${VERSION} — browser access to Herdr workspaces
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{a as y,b as A}from"./chunks/3FQAXVGC.js";import{f as S,h as w}from"./chunks/DGUZCGQN.js";import"./chunks/U6QAYG3E.js";import{f as m,l as v,n as $,o as k}from"./chunks/M52LJEES.js";import"./chunks/KRVF37OW.js";import"./chunks/QRGNEKME.js";import"./chunks/PBMBFWLQ.js";import{a as d,c as h,d as g}from"./chunks/TNLCNVA2.js";import"./chunks/I6NRCYLI.js";import U from"node:fs";import P from"node:os";import u from"node:path";var j=JSON.parse(U.readFileSync(u.join(d,"package.json"),"utf8")).version,f=`herdr-remote ${j} \u2014 browser access to Herdr workspaces
|
|
17
4
|
|
|
18
5
|
Usage: herdr-remote [command] [options]
|
|
19
6
|
|
|
@@ -39,281 +26,21 @@ Options:
|
|
|
39
26
|
-v, --version Show version
|
|
40
27
|
|
|
41
28
|
Self-hosting: docs/self-hosted-relay.md
|
|
42
|
-
`;
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (arg === '--help' || arg === '-h') {
|
|
61
|
-
flags.help = true;
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
if (arg === '--version' || arg === '-v') {
|
|
65
|
-
flags.version = true;
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
if (arg === '--lang') {
|
|
69
|
-
flags.lang = argv[index + 1];
|
|
70
|
-
index += 1;
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
if (arg.startsWith('--lang=')) {
|
|
74
|
-
flags.lang = arg.slice('--lang='.length);
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
if (arg.startsWith('-')) {
|
|
78
|
-
flags.unknown = arg;
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
positional.push(arg);
|
|
82
|
-
}
|
|
83
|
-
return { positional, flags };
|
|
84
|
-
}
|
|
85
|
-
function printJson(value) {
|
|
86
|
-
process.stdout.write(`${JSON.stringify(value, null, 2)}\n`);
|
|
87
|
-
}
|
|
88
|
-
function describeStatus(status, t) {
|
|
89
|
-
const lines = [];
|
|
90
|
-
lines.push(`${t('overview.mode')}: ${t(`mode.${status.mode}`)}`);
|
|
91
|
-
if (status.relay.local) {
|
|
92
|
-
lines.push(`${t('overview.relay')}: ${status.relay.alive ? t('common.running') : t('common.stopped')} (${status.relay.bind}:${status.relay.port})`);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
lines.push(`${t('overview.relay')}: ${status.relay.remoteUrl}`);
|
|
96
|
-
}
|
|
97
|
-
lines.push(`${t('overview.host')}: ${status.host.alive ? t('common.running') : t('common.stopped')}`);
|
|
98
|
-
lines.push(`${t('overview.socket')}: ${status.host.socketPath}${status.host.socketExists ? '' : ` (${t('overview.socketMissing')})`}`);
|
|
99
|
-
lines.push(`${t('overview.webUrl')}: ${status.publicUrl}`);
|
|
100
|
-
if (status.keepalive) {
|
|
101
|
-
const state = status.keepalive.active
|
|
102
|
-
? t('common.running')
|
|
103
|
-
: status.keepalive.installed
|
|
104
|
-
? t('common.installed')
|
|
105
|
-
: t('common.notInstalled');
|
|
106
|
-
lines.push(`${t('overview.keepalive')}: ${status.keepalive.manager} — ${state}`);
|
|
107
|
-
}
|
|
108
|
-
if (status.relay.health && status.relay.health.ok === false) {
|
|
109
|
-
lines.push(`${t('overview.relay')}: ${t('overview.unreachable', { message: status.relay.health.message ?? '' })}`);
|
|
110
|
-
}
|
|
111
|
-
return lines.join('\n');
|
|
112
|
-
}
|
|
113
|
-
async function runTui(options) {
|
|
114
|
-
const { startTui } = await import('./tui/index.js');
|
|
115
|
-
await startTui(options);
|
|
116
|
-
}
|
|
117
|
-
async function main(argv = process.argv.slice(2)) {
|
|
118
|
-
const { positional, flags } = parseArgs(argv);
|
|
119
|
-
if (process.platform === 'win32') {
|
|
120
|
-
const relative = path.relative(PACKAGE_ROOT, process.cwd());
|
|
121
|
-
const insidePackage = relative === '' ||
|
|
122
|
-
(relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative));
|
|
123
|
-
if (insidePackage) {
|
|
124
|
-
// Herdr starts plugin panels in PACKAGE_ROOT; Windows locks the cwd,
|
|
125
|
-
// preventing npm from replacing that directory.
|
|
126
|
-
process.chdir(os.homedir());
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
const command = positional[0] || null;
|
|
130
|
-
// Answered before anything reads the config or queries the terminal.
|
|
131
|
-
if (flags.help) {
|
|
132
|
-
process.stdout.write(USAGE);
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
if (flags.version) {
|
|
136
|
-
process.stdout.write(`${VERSION}\n`);
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
if (flags.unknown) {
|
|
140
|
-
process.stderr.write(`herdr-remote: unknown option "${flags.unknown}"\n\n${USAGE}`);
|
|
141
|
-
process.exitCode = 2;
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
migrateLegacyConfig();
|
|
145
|
-
// Ask the terminal for its colors while it is still a plain terminal: the
|
|
146
|
-
// TUI takes the screen a few lines below, and the services this command
|
|
147
|
-
// starts usually run detached with nothing to ask. Everything downstream
|
|
148
|
-
// inherits the answer through the environment.
|
|
149
|
-
await (await import('./terminal-palette.js')).captureTerminalPalette();
|
|
150
|
-
// The font, likewise, is read while this process still knows which terminal
|
|
151
|
-
// it runs in: its variables and its parent process are gone once a service
|
|
152
|
-
// manager or Herdr's detached server starts the connector.
|
|
153
|
-
(await import('./terminal-font/index.js')).captureTerminalFont();
|
|
154
|
-
const config = loadConfig();
|
|
155
|
-
const preference = flags.lang && LANGUAGES.includes(flags.lang)
|
|
156
|
-
? flags.lang
|
|
157
|
-
: config.ui.language;
|
|
158
|
-
const t = createTranslator(detectLocale({ preference }));
|
|
159
|
-
// Loaded lazily so that the TUI does not pay for loading the
|
|
160
|
-
// service layer (which pulls in the relay package and node-pty).
|
|
161
|
-
const lifecycle = await import('./lifecycle.js');
|
|
162
|
-
const service = await import('./service.js');
|
|
163
|
-
switch (command) {
|
|
164
|
-
case null: {
|
|
165
|
-
if (process.stdin.isTTY && process.stdout.isTTY) {
|
|
166
|
-
await runTui({ language: flags.lang || null });
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
// Herdr runs plugin panes and actions without a TTY; emit status instead
|
|
170
|
-
// of trying to paint an interface into a pipe.
|
|
171
|
-
printJson(await lifecycle.fullStatus(config));
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
case 'start': {
|
|
175
|
-
const result = lifecycle.startAll(config);
|
|
176
|
-
if (flags.json)
|
|
177
|
-
printJson(result);
|
|
178
|
-
else
|
|
179
|
-
process.stdout.write(`${t('services.started')}\n${describeStatus(await lifecycle.fullStatus(config), t)}\n`);
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
case 'stop': {
|
|
183
|
-
const result = lifecycle.stopAll(config);
|
|
184
|
-
if (flags.json)
|
|
185
|
-
printJson(result);
|
|
186
|
-
else
|
|
187
|
-
process.stdout.write(`${t('services.stopped')}\n`);
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
case 'restart': {
|
|
191
|
-
const result = lifecycle.restartAll(config);
|
|
192
|
-
if (flags.json)
|
|
193
|
-
printJson(result);
|
|
194
|
-
else
|
|
195
|
-
process.stdout.write(`${t('services.restarted')}\n`);
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
case 'status': {
|
|
199
|
-
const status = await lifecycle.fullStatus(config);
|
|
200
|
-
if (flags.json)
|
|
201
|
-
printJson(status);
|
|
202
|
-
else
|
|
203
|
-
process.stdout.write(`${describeStatus(status, t)}\n`);
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
case 'pair': {
|
|
207
|
-
const pairing = await service.pair();
|
|
208
|
-
if (flags.json) {
|
|
209
|
-
printJson(pairing);
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
const code = extractPairingCode(pairing);
|
|
213
|
-
const url = pairing.pairUrl ||
|
|
214
|
-
`${resolvePublicUrl(config, preferredLanAddress())}/?pairCode=${encodeURIComponent(code)}`;
|
|
215
|
-
const minutes = `${Math.round((config.auth.pairingTtlMs || 600000) / 60000)}m`;
|
|
216
|
-
process.stdout.write(`${t('pair.code')}: ${code}\n${t('pair.url')}: ${url}\n${t('pair.expires', { minutes, time: new Date(pairing.expiresAt).toLocaleTimeString() })}\n`);
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
case 'url': {
|
|
220
|
-
process.stdout.write(`${resolvePublicUrl(config, preferredLanAddress())}\n`);
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
case 'update': {
|
|
224
|
-
const { runUpdate } = await import('./update-command.js');
|
|
225
|
-
const outcome = await runUpdate(t, {
|
|
226
|
-
config,
|
|
227
|
-
...(flags.json ? { report: () => { } } : {}),
|
|
228
|
-
});
|
|
229
|
-
if (flags.json)
|
|
230
|
-
printJson(outcome);
|
|
231
|
-
if (!outcome.ok)
|
|
232
|
-
process.exitCode = 1;
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
case 'run': {
|
|
236
|
-
const { runForeground } = await import('./supervisor.js');
|
|
237
|
-
await runForeground({ logToFiles: Boolean(flags.daemon) });
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
case 'admin-broker': {
|
|
241
|
-
const broker = await import('./connector/admin-broker.js');
|
|
242
|
-
const action = positional[1] || 'status';
|
|
243
|
-
if (action === 'install') {
|
|
244
|
-
broker.installAdminBroker(t);
|
|
245
|
-
printJson({ installed: true, available: await broker.waitForAdminBroker() });
|
|
246
|
-
}
|
|
247
|
-
else if (action === 'uninstall') {
|
|
248
|
-
broker.uninstallAdminBroker(t);
|
|
249
|
-
printJson({ installed: false });
|
|
250
|
-
}
|
|
251
|
-
else if (action === 'restart') {
|
|
252
|
-
if ((await broker.stopAdminBroker()) === 'busy')
|
|
253
|
-
throw new Error(t('adminBroker.busy'));
|
|
254
|
-
broker.startAdminBrokerTask(t);
|
|
255
|
-
printJson({ available: await broker.waitForAdminBroker() });
|
|
256
|
-
}
|
|
257
|
-
else if (action === 'status') {
|
|
258
|
-
printJson({ available: await broker.adminBrokerStatus() });
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
throw new Error(`unknown administrator broker action: ${action}`);
|
|
262
|
-
}
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
case 'admin-shell': {
|
|
266
|
-
const { runAdminShell } = await import('./connector/admin-shell.js');
|
|
267
|
-
process.exitCode = await runAdminShell(t);
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
case 'keepalive': {
|
|
271
|
-
const keepalive = await import('./keepalive/index.js');
|
|
272
|
-
const action = positional[1] || 'status';
|
|
273
|
-
if (action === 'install' && flags.elevated) {
|
|
274
|
-
const { completeServiceInstall } = await import('./keepalive/windows-service-setup.js');
|
|
275
|
-
process.exitCode = await completeServiceInstall(t);
|
|
276
|
-
}
|
|
277
|
-
else if (action === 'install')
|
|
278
|
-
printJson(await keepalive.install(config));
|
|
279
|
-
else if (action === 'uninstall')
|
|
280
|
-
printJson(await keepalive.uninstall(config));
|
|
281
|
-
else if (action === 'restart')
|
|
282
|
-
printJson(keepalive.restart(config));
|
|
283
|
-
else if (action === 'status')
|
|
284
|
-
printJson(keepalive.status(config));
|
|
285
|
-
else
|
|
286
|
-
throw new Error(`unknown keepalive action: ${action}`);
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
case 'plugin': {
|
|
290
|
-
const plugin = await import('./herdr-plugin.js');
|
|
291
|
-
const action = positional[1] || 'status';
|
|
292
|
-
if (action === 'link')
|
|
293
|
-
printJson(plugin.register());
|
|
294
|
-
else if (action === 'unlink')
|
|
295
|
-
printJson(plugin.unregister());
|
|
296
|
-
else if (action === 'status')
|
|
297
|
-
printJson(plugin.registrationStatus());
|
|
298
|
-
else
|
|
299
|
-
throw new Error(`unknown plugin action: ${action}`);
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
case 'config': {
|
|
303
|
-
// Handy when reporting a problem: where does this install read from?
|
|
304
|
-
printJson({ configPath: configPath(), stateDir: stateDir(), config });
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
default:
|
|
308
|
-
process.stderr.write(`herdr-remote: unknown command "${command}"\n\n${USAGE}`);
|
|
309
|
-
process.exitCode = 2;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
/** Runs the command line and reports a failure as the exit code. */
|
|
313
|
-
function run() {
|
|
314
|
-
main().catch((error) => {
|
|
315
|
-
process.stderr.write(`herdr-remote: ${error.message}\n`);
|
|
316
|
-
process.exitCode = 1;
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
export { run, parseArgs, describeStatus };
|
|
29
|
+
`;function E(n){let s=[],t={};for(let l=0;l<n.length;l+=1){let r=n[l];if(r==="--json"){t.json=!0;continue}if(r==="--daemon"){t.daemon=!0;continue}if(r==="--elevated"){t.elevated=!0;continue}if(r==="--help"||r==="-h"){t.help=!0;continue}if(r==="--version"||r==="-v"){t.version=!0;continue}if(r==="--lang"){t.lang=n[l+1],l+=1;continue}if(r.startsWith("--lang=")){t.lang=r.slice(7);continue}if(r.startsWith("-")){t.unknown=r;continue}s.push(r)}return{positional:s,flags:t}}function i(n){process.stdout.write(`${JSON.stringify(n,null,2)}
|
|
30
|
+
`)}function b(n,s){let t=[];if(t.push(`${s("overview.mode")}: ${s(`mode.${n.mode}`)}`),n.relay.local?t.push(`${s("overview.relay")}: ${n.relay.alive?s("common.running"):s("common.stopped")} (${n.relay.bind}:${n.relay.port})`):t.push(`${s("overview.relay")}: ${n.relay.remoteUrl}`),t.push(`${s("overview.host")}: ${n.host.alive?s("common.running"):s("common.stopped")}`),t.push(`${s("overview.socket")}: ${n.host.socketPath}${n.host.socketExists?"":` (${s("overview.socketMissing")})`}`),t.push(`${s("overview.webUrl")}: ${n.publicUrl}`),n.keepalive){let l=n.keepalive.active?s("common.running"):n.keepalive.installed?s("common.installed"):s("common.notInstalled");t.push(`${s("overview.keepalive")}: ${n.keepalive.manager} \u2014 ${l}`)}return n.relay.health&&n.relay.health.ok===!1&&t.push(`${s("overview.relay")}: ${s("overview.unreachable",{message:n.relay.health.message??""})}`),t.join(`
|
|
31
|
+
`)}async function B(n){let{startTui:s}=await import("./chunks/LPR662JH.js");await s(n)}async function O(n=process.argv.slice(2)){let{positional:s,flags:t}=E(n);if(process.platform==="win32"){let e=u.relative(d,process.cwd());(e===""||e!==".."&&!e.startsWith(`..${u.sep}`)&&!u.isAbsolute(e))&&process.chdir(P.homedir())}let l=s[0]||null;if(t.help){process.stdout.write(f);return}if(t.version){process.stdout.write(`${j}
|
|
32
|
+
`);return}if(t.unknown){process.stderr.write(`herdr-remote: unknown option "${t.unknown}"
|
|
33
|
+
|
|
34
|
+
${f}`),process.exitCode=2;return}$(),await(await import("./chunks/O2LNVFUT.js")).captureTerminalPalette(),(await import("./chunks/WY7WHEJ4.js")).captureTerminalFont();let r=k(),T=t.lang&&v.includes(t.lang)?t.lang:r.ui.language,a=A(y({preference:T})),c=await import("./chunks/5LZFJ6UZ.js"),C=await import("./chunks/BYGDPZZD.js");switch(l){case null:{if(process.stdin.isTTY&&process.stdout.isTTY){await B({language:t.lang||null});return}i(await c.fullStatus(r));return}case"start":{let e=c.startAll(r);t.json?i(e):process.stdout.write(`${a("services.started")}
|
|
35
|
+
${b(await c.fullStatus(r),a)}
|
|
36
|
+
`);return}case"stop":{let e=c.stopAll(r);t.json?i(e):process.stdout.write(`${a("services.stopped")}
|
|
37
|
+
`);return}case"restart":{let e=c.restartAll(r);t.json?i(e):process.stdout.write(`${a("services.restarted")}
|
|
38
|
+
`);return}case"status":{let e=await c.fullStatus(r);t.json?i(e):process.stdout.write(`${b(e,a)}
|
|
39
|
+
`);return}case"pair":{let e=await C.pair();if(t.json){i(e);return}let o=S(e),p=e.pairUrl||`${m(r,w())}/?pairCode=${encodeURIComponent(o)}`,x=`${Math.round((r.auth.pairingTtlMs||6e5)/6e4)}m`;process.stdout.write(`${a("pair.code")}: ${o}
|
|
40
|
+
${a("pair.url")}: ${p}
|
|
41
|
+
${a("pair.expires",{minutes:x,time:new Date(e.expiresAt).toLocaleTimeString()})}
|
|
42
|
+
`);return}case"url":{process.stdout.write(`${m(r,w())}
|
|
43
|
+
`);return}case"update":{let{runUpdate:e}=await import("./chunks/AX4EPJCP.js"),o=await e(a,{config:r,...t.json?{report:()=>{}}:{}});t.json&&i(o),o.ok||(process.exitCode=1);return}case"run":{let{runForeground:e}=await import("./chunks/K5RFPHSF.js");await e({logToFiles:!!t.daemon});return}case"admin-broker":{let e=await import("./connector/admin-broker.js"),o=s[1]||"status";if(o==="install")e.installAdminBroker(a),i({installed:!0,available:await e.waitForAdminBroker()});else if(o==="uninstall")e.uninstallAdminBroker(a),i({installed:!1});else if(o==="restart"){if(await e.stopAdminBroker()==="busy")throw new Error(a("adminBroker.busy"));e.startAdminBrokerTask(a),i({available:await e.waitForAdminBroker()})}else if(o==="status")i({available:await e.adminBrokerStatus()});else throw new Error(`unknown administrator broker action: ${o}`);return}case"admin-shell":{let{runAdminShell:e}=await import("./chunks/FONUO5O5.js");process.exitCode=await e(a);return}case"keepalive":{let e=await import("./chunks/QCSILMFB.js"),o=s[1]||"status";if(o==="install"&&t.elevated){let{completeServiceInstall:p}=await import("./chunks/B76DFI4H.js");process.exitCode=await p(a)}else if(o==="install")i(await e.install(r));else if(o==="uninstall")i(await e.uninstall(r));else if(o==="restart")i(e.restart(r));else if(o==="status")i(e.status(r));else throw new Error(`unknown keepalive action: ${o}`);return}case"plugin":{let e=await import("./chunks/LY2ZGCXN.js"),o=s[1]||"status";if(o==="link")i(e.register());else if(o==="unlink")i(e.unregister());else if(o==="status")i(e.registrationStatus());else throw new Error(`unknown plugin action: ${o}`);return}case"config":{i({configPath:g(),stateDir:h(),config:r});return}default:process.stderr.write(`herdr-remote: unknown command "${l}"
|
|
44
|
+
|
|
45
|
+
${f}`),process.exitCode=2}}function M(){O().catch(n=>{process.stderr.write(`herdr-remote: ${n.message}
|
|
46
|
+
`),process.exitCode=1})}export{b as describeStatus,E as parseArgs,M as run};
|