@linzumi/cli 1.0.323 → 1.0.326
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 +1 -1
- package/dist/cloud-supervisor.mjs +99 -253
- package/dist/hosted-coding-account-worker.js +8 -30
- package/dist/index.js +444 -420
- package/dist/native/darwin/manifest.json +1 -1
- package/dist/remote-codex-harness-worker.js +127 -118
- package/dist/tcp-tunnel-cli.mjs +25 -25
- package/package.json +6 -7
- package/scripts/build.mjs +2 -1
- package/scripts/bump-cli-version.mjs +64 -39
- package/scripts/vendor-codex-app-server-protocol.ts +0 -383
- package/scripts/vm-provision-proof.mjs +0 -150
package/dist/tcp-tunnel-cli.mjs
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { createRequire as __linzumiBundleCreateRequire } from 'node:module';
|
|
2
2
|
const require = __linzumiBundleCreateRequire(import.meta.url);
|
|
3
|
-
import*as
|
|
4
|
-
`),await
|
|
5
|
-
`)}switch(
|
|
6
|
-
`)}break}if(
|
|
7
|
-
`):
|
|
8
|
-
`)}}return e.websocket=void 0,e.tunnel=void 0,
|
|
9
|
-
`),e.socket.destroy(),e.websocket=void 0,e.tunnel=void 0,
|
|
10
|
-
`),Promise.resolve()}),
|
|
11
|
-
`),e.socket.destroy(),
|
|
12
|
-
`),
|
|
13
|
-
`)}catch(
|
|
14
|
-
`),e.socket.destroy(),await
|
|
15
|
-
`)})});try{await
|
|
16
|
-
`),
|
|
17
|
-
`,"utf8"),
|
|
18
|
-
Code: `+
|
|
19
|
-
Open: `+
|
|
20
|
-
`);let
|
|
21
|
-
`),
|
|
3
|
+
import*as oe from"ws";import*as g from"node:fs";import*as D from"node:os";import*as le from"node:net";import*as F from"node:path";function O(e){return e===void 0?{BS_PRIVATE_NESTED_SOME_NONE:0}:e!==null&&e.BS_PRIVATE_NESTED_SOME_NONE!==void 0?{BS_PRIVATE_NESTED_SOME_NONE:e.BS_PRIVATE_NESTED_SOME_NONE+1|0}:e}function B(e){if(e!=null)return O(e)}function k(e){if(e===null||e.BS_PRIVATE_NESTED_SOME_NONE===void 0)return e;let t=e.BS_PRIVATE_NESTED_SOME_NONE;if(t!==0)return{BS_PRIVATE_NESTED_SOME_NONE:t-1|0}}function J(e,t){let n=e.findIndex(t);if(n!==-1)return n}function q(e,t){let n=t!==void 0?parseInt(e,t):parseInt(e);if(!(Number.isNaN(n)||n>2147483647||n<-2147483648))return n|0}import*as W from"node:crypto";function C(e){if(e.RE_EXN_ID==="JsExn")return O(e._1)}var A=(e=>t=>t&&typeof t[e]=="string"?t[e]:void 0),De=A("stack"),G=A("message"),Me=A("name"),We=A("fileName");function H(e){throw new Error(e)}function Q(e,t){if(e!==void 0)return t(k(e))}function P(e,t){return e!==void 0?k(e):t}function me(e){return e==null?!1:typeof e.RE_EXN_ID=="string"}function L(e){return me(e)?e:{RE_EXN_ID:"JsExn",_1:e}}function M(e,t){return e.catch(n=>t(L(n)))}import*as Z from"undici";import*as U from"node:fs";var Y="KANDAN_TLS_CA_FILE";function ee(){let e=process.env[Y];if(e===void 0)return"Unconfigured";let t=e.trim();return t===""?"Unconfigured":U.existsSync(t)?{TAG:"Configured",ca:U.readFileSync(t,"utf8")}:H(Y+" does not exist: "+t)}function te(){let e=ee();if(typeof e=="object")return e.ca}function ne(){let e=ee();if(typeof e=="object")return O(new Z.Agent({connect:{ca:e.ca}}))}function ae(){let e=ne();if(e===void 0)return fetch;let t=k(e);return(n,r)=>fetch(n,Object.assign({},r,{dispatcher:t}))}var we="wss://linzumi.link",ve="https://serve.linzumi.com";function Be(e){return new Error(e)}function x(e){let t=C(e);return t!==void 0?P(G(k(t)),"unknown error"):"unknown error"}function R(e,t){let n=e.trim();if(n==="")throw new Error(t+" must not be empty");return n}function Je(e){return e%256}function ge(e,t){let n=new Error("tunnel refused "+e.toString()+": "+t);return n.name="TunnelRefusalError",n.code=e,n.reason=t,n.exitCode=e%256,n}function Ee(e,t,n){let r=new Error(t);return r.name="TunnelListenerError",r.code=e,r.exitCode=n,r}function _e(e,t){let n=new URL(e),r=n.protocol,o;switch(r){case"https:":case"wss:":o="wss:";break;default:o="ws:"}return n.protocol=o,n.pathname="/tunnel/connect",n.search="",n.searchParams.set("forward_id",t),n.hash="",n.toString()}function ye(e){switch(e){case 4001:return"authentication invalid, expired, or timed out";case 4002:return"share revoked or unpublished";case 4003:return"preview origin unavailable";case 4004:return"target is not a registered approved forward";case 4005:return"runner offline or runner-side connection failed";case 4006:return"protocol error";case 4007:return"idle timeout";case 4008:return"concurrency cap reached";default:return"connection closed"}}function Se(e){let t;try{t=JSON.parse(e)}catch{t=void 0}if(t===void 0||typeof t!="object"||t===null||Array.isArray(t))return"Invalid";let n=t.ok,r=t.tunnel_id;if(n===!0&&typeof r=="string"?r.trim()!=="":!1)return"Ready";let i=t.error,l=t.reason;return i!==void 0&&typeof i=="number"&&l!==void 0&&typeof l=="string"&&i>=4001&&i<=4008&&l.trim()!==""?{NAME:"Refusal",VAL:[i|0,l]}:"Invalid"}async function ue(e,t,n,r,o){let i=o!==void 0?o:E=>{},l=t.kind,c;switch(l){case"share-token":c="Bearer share_token:"+t.token;break;case"user-session":c="Bearer user_session:"+t.token;break;default:throw new Error("unknown tunnel credential kind: "+l)}let d=Object.fromEntries([["authorization",c]]),s=r!==void 0?n(e,{headers:d,ca:r}):n(e,{headers:d});i(s);let u={contents:!1},a={contents:void 0},f={contents:[]},m={contents:void 0},h={contents:void 0},y=new Promise((E,S)=>{h.contents=E});return await new Promise((E,S)=>{s.on("message",(p,w)=>{if(w){let I=u.contents,z=p.byteLength<=65536;if(I&&z){let N=a.contents;if(N!==void 0)return N(p,s);f.contents.push(p);return}return s.close(4006,"protocol error"),u.contents?void 0:S(new Error("tunnel sent binary data before authentication"))}let v=Se(p.toString("utf8"));if(typeof v!="object")return v==="Invalid"?(s.close(4006,"unexpected text frame"),u.contents?void 0:S(new Error("tunnel returned an invalid authentication frame"))):(u.contents=!0,E());let _=v.VAL;m.contents=[_[0],_[1]]}),s.once("error",p=>{if(!u.contents)return S(L(p))}),s.once("close",(p,w)=>{let v=m.contents,_;if(v!==void 0)_=v[1];else{let N=w.toString("utf8").trim();_=N===""?ye(p):N}let I=h.contents;if(I!==void 0&&I({code:p,reason:_}),u.contents)return;let z=m.contents;return S(z!==void 0?ge(z[0],z[1]):new Error("tunnel closed before authentication ("+p.toString()+": "+_+")"))})}),{websocket:s,closed:y,attachBinary:E=>{if(a.contents!==void 0)throw new Error("tunnel binary pipe is already attached");a.contents=E,f.contents.forEach(p=>E(p,s)),f.contents=[]},close:async()=>{let E=s.readyState;return E!==3&&E!==2&&s.close(1e3,"local stream closed"),await y.then(S=>Promise.resolve())},terminate:async()=>(s.readyState!==3&&s.terminate(),await y.then(S=>Promise.resolve()))}}function Pe(e,t){return new Promise((n,r)=>{if(e.readyState!==1)return r(new Error("tunnel WebSocket is not open"));e.send(t,{binary:!0},i=>i==null?n():r(L(i)))})}function be(e){return e.destroyed?Promise.resolve():new Promise((t,n)=>{let r={contents:!1},o={contents:void 0},i=()=>{if(r.contents)return;r.contents=!0;let l=o.contents;l!==void 0&&clearTimeout(l),t()};e.once("close",i),e.end(()=>{if(e.destroyed)return i();o.contents=setTimeout(()=>{e.destroyed||e.destroy(),i()},2e3)})})}function ke(e){e.socket.destroyed||e.socket.destroy();let t=e.tunnel,n=t!==void 0?O(t.websocket):e.websocket;if(n===void 0)return;let r=k(n);if(r.readyState!==3){r.terminate();return}}function Le(e,t,n){let r={contents:void 0},o={contents:!1};return i=>{let l=r.contents;if(l!==void 0){let u=o.contents;return i==="ListenerShutdown"&&(u||(o.contents=!0,ke(e))),l}let c={contents:void 0},d=new Promise((u,a)=>{c.contents=u});return r.contents=d,M((async()=>{if(i==="RelayFailure"){let a=e.tunnel;if(a!==void 0){let f=a.websocket.readyState,m=0;f>=2?f>=4&&(m=1):f>=0?a.websocket.terminate():m=1,m===1&&t("linzumi connect: stream "+e.id+" relay-failure teardown saw unknown WebSocket state "+f.toString()+`
|
|
4
|
+
`),await a.closed.then(h=>Promise.resolve())}else t("linzumi connect: stream "+e.id+` relay-failure teardown had no active tunnel to abort
|
|
5
|
+
`)}switch(i){case"LocalFirst":break;case"RemoteFirst":case"RelayFailure":await be(e.socket);break;case"ListenerShutdown":e.socket.destroy();break}let u=0;switch(i){case"LocalFirst":case"RemoteFirst":u=1;break;case"RelayFailure":break;case"ListenerShutdown":let a=e.tunnel;if(a!==void 0)await a.terminate();else{let f=e.websocket;if(f!==void 0){let m=k(f);m.readyState!==3&&m.terminate()}else t("linzumi connect: stream "+e.id+` teardown had no WebSocket to close
|
|
6
|
+
`)}break}if(u===1){let a=e.tunnel;if(a!==void 0)await a.close();else{let f=e.websocket;if(f!==void 0){let m=k(f),h=m.readyState;h>3||h<1?h!==0?t("linzumi connect: stream "+e.id+" teardown saw unknown WebSocket state "+h.toString()+`
|
|
7
|
+
`):m.terminate():h>=2||m.close(1e3,"local stream closed")}else t("linzumi connect: stream "+e.id+` teardown had no WebSocket to close
|
|
8
|
+
`)}}return e.websocket=void 0,e.tunnel=void 0,n(e.id)})(),u=>(t("linzumi connect: stream "+e.id+" teardown failed: "+x(u)+`
|
|
9
|
+
`),e.socket.destroy(),e.websocket=void 0,e.tunnel=void 0,n(e.id),Promise.resolve())).then(()=>{let u=c.contents;return u!==void 0?u():t("linzumi connect: stream "+e.id+` teardown completion was unavailable
|
|
10
|
+
`),Promise.resolve()}),d}}function Oe(e){return e.listening?new Promise((t,n)=>{e.close(r=>r==null?t():n(L(r)))}):Promise.resolve()}function Ie(e,t){return new Promise((n,r)=>{let o=l=>{e.off("listening",i),r(L(l))},i=()=>{e.off("error",o),n()};e.once("error",o),e.once("listening",i),e.listen(t,"127.0.0.1")})}async function ze(e,t,n,r,o,i,l,c){let d=Le(e,i,c);e.teardown=d,e.socket.once("error",s=>{i("linzumi connect: local stream failed: "+s.message+`
|
|
11
|
+
`),e.socket.destroy(),d("LocalFirst")}),e.socket.once("close",()=>{d("LocalFirst")});try{let s=await ue(t,n,r,o,h=>{e.websocket=O(h)});e.tunnel=s;let u=l(),a=e.socket.destroyed;if(u)return await d("ListenerShutdown");if(a)return await d("LocalFirst");s.attachBinary((h,y)=>{if(!e.socket.write(h)){y.pause(),e.socket.once("drain",()=>{y.resume()});return}});let f={contents:Promise.resolve()};e.socket.on("data",h=>{e.socket.pause(),f.contents=M(f.contents.then(async()=>{let y=async b=>{if(b>=h.byteLength)return;let E=(b+65536|0)>h.byteLength?h.byteLength:b+65536|0;return await Pe(s.websocket,h.subarray(b,E)),await y(b+65536|0)};if(await y(0),!e.socket.destroyed){e.socket.resume();return}}),y=>(i("linzumi connect: stream relay failed: "+x(y)+`
|
|
12
|
+
`),d("RelayFailure"),Promise.resolve()))}),e.socket.resume();let m=await s.closed;return await d("RemoteFirst"),l()?void 0:i("linzumi connect: stream closed "+m.code.toString()+": "+m.reason+`
|
|
13
|
+
`)}catch(s){let u=L(s);return i("linzumi connect: stream failed: "+x(u)+`
|
|
14
|
+
`),e.socket.destroy(),await d(l()?"ListenerShutdown":"LocalFirst")}}async function Ne(e){let t=R(e.forwardId,"forward id"),r=e.credential.kind,o=R(e.credential.token,"tunnel credential"),i={kind:r,token:o},l=P(e.writeStderr,p=>{process.stderr.write(p)}),c=P(e.webSocketFactory,(p,w)=>new oe.WebSocket(p,w)),d=te(),s=_e(e.tunnelBaseUrl,t);await(await ue(s,i,c,d,void 0)).terminate();let a=le.createServer({allowHalfOpen:!0}),f=[],m={contents:!1},h={contents:void 0},y=new Promise((p,w)=>{h.contents=p});a.on("connection",p=>{p.pause();let w={id:W.randomUUID(),socket:p,websocket:void 0,tunnel:void 0,teardown:void 0};f.push(w),ze(w,s,i,c,d,l,()=>m.contents,v=>{let _=J(f,I=>I.id===v);if(_!==void 0){f.splice(_,1);return}else return l("linzumi connect: completed stream "+v+` was absent from the registry
|
|
15
|
+
`)})});try{await Ie(a,e.localPort)}catch(p){let w=L(p),v=C(w);if(v!==void 0){let _=k(v).code;throw _==null?w:_==="EADDRINUSE"?Ee("EADDRINUSE","127.0.0.1:"+e.localPort.toString()+" is already in use",2):w}throw w}let b=a.address(),E;if(b==null)throw new Error("TCP tunnel listener did not expose a loopback TCP port");return E=b.port,{port:E,closed:y,close:async()=>{if(m.contents)return await y;m.contents=!0;let p=f.map(v=>{let _=v.teardown;return _!==void 0?_("ListenerShutdown"):(l("linzumi connect: stream "+v.id+` had no teardown during listener shutdown
|
|
16
|
+
`),v.socket.destroy(),Promise.resolve())});await Oe(a),await Promise.all(p).then(v=>Promise.resolve());let w=h.contents;if(w!==void 0)return w()},activeStreamCount:()=>f.length}}function Ve(e){return F.join(e,".linzumi","user-auth.json")}function qe(){return F.join(D.homedir(),".linzumi","user-auth.json")}function j(e){let t=new URL(e),n=t.protocol,r;switch(n){case"https:":case"wss:":r="https:";break;default:r="http:"}t.protocol=r,t.pathname="",t.search="",t.hash="";let o=t.toString();return o.endsWith("/")?o.slice(0,o.length-1|0):o}function $(e,t){let n=e[t];if(typeof n=="string"){if(n.trim()==="")throw new Error("Linzumi CLI login response was missing "+t);return n}throw new Error("Linzumi CLI login response was missing "+t)}function re(e,t){let n=e[t];if(typeof n=="number"){if(n>0)return n;throw new Error("Linzumi CLI login response had invalid "+t)}throw new Error("Linzumi CLI login response had invalid "+t)}function $e(e){let t;try{t=JSON.parse(g.readFileSync(e,"utf8"))}catch(n){let r=L(n);throw new Error("cannot read Linzumi user auth at "+e+"; run `linzumi login` ("+x(r)+")")}if(typeof t=="object"&&t!==null&&!Array.isArray(t)){if(t.version===1)return{version:1,apiUrl:$(t,"apiUrl"),token:$(t,"token")};throw new Error("invalid Linzumi user auth at "+e+"; run `linzumi login`")}throw new Error("invalid Linzumi user auth at "+e+"; run `linzumi login`")}function Fe(e,t){let n=F.dirname(t);g.mkdirSync(n,{recursive:!0,mode:448}),g.chmodSync(n,448);let r=t+"."+process.pid.toString()+"."+W.randomUUID()+".tmp",o;try{let i=g.openSync(r,"wx",384);o=i;let l=JSON.stringify({version:e.version,apiUrl:e.apiUrl,token:e.token}),c;if(l!==void 0)c=l;else throw new Error("Linzumi user auth serialization failed");g.writeFileSync(i,c+`
|
|
17
|
+
`,"utf8"),g.closeSync(i),o=void 0,g.chmodSync(r,384),g.renameSync(r,t),g.chmodSync(t,384);return}catch(i){let l=o;throw l!==void 0&&g.closeSync(l),g.rmSync(r,{force:!0}),i}}async function ie(e,t,n,r,o){let i=JSON.stringify({operationName:n,documentId:r,variables:o}),l;if(i!==void 0)l=i;else throw new Error("Linzumi CLI login request serialization failed");let c=await e(t,{method:"POST",headers:Object.fromEntries([["content-type","application/json"]]),body:l}),d=await c.json();if(c.ok){if(typeof d=="object"&&d!==null&&!Array.isArray(d)){let s=d.errors;if(s!==void 0)if(Array.isArray(s)){if(s.length!==0)throw new Error("Linzumi CLI login returned GraphQL errors")}else throw new Error("Linzumi CLI login returned GraphQL errors");let u=d.data;if(u!==void 0){if(typeof u=="object"&&u!==null&&!Array.isArray(u))return u;throw new Error("Linzumi CLI login returned no GraphQL data")}throw new Error("Linzumi CLI login returned no GraphQL data")}throw new Error("Linzumi CLI login returned invalid GraphQL JSON")}throw new Error("Linzumi CLI login request failed: HTTP "+c.status.toString()+" "+c.statusText)}async function Ge(e,t){let n=t.fetchImpl,r=n!==void 0?n:ae(),o=P(t.wait,p=>new Promise((w,v)=>{setTimeout(()=>w(),p)})),i=P(t.now,()=>Date.now()),l=P(e.writeStdout,p=>{process.stdout.write(p)}),c=j(e.apiUrl),d=new URL("/api/v2/graphql",c).toString(),u=(await ie(r,d,"StartCliDeviceLogin","CE6X73GvfyE",{})).startCliDeviceLogin,a;if(u!==void 0)if(typeof u=="object"&&u!==null&&!Array.isArray(u))a=u;else throw new Error("Linzumi CLI login response was missing startCliDeviceLogin");else throw new Error("Linzumi CLI login response was missing startCliDeviceLogin");switch($(a,"__typename")){case"StartCliDeviceLoginPendingSessionLimit":throw new Error("Linzumi CLI login reached the pending session limit; finish an existing login");case"StartCliDeviceLoginRateLimited":throw new Error("Linzumi CLI login was rate limited; try again later");case"StartCliDeviceLoginSuccess":break;default:throw new Error("Linzumi CLI login returned an unknown startCliDeviceLogin result")}let m=$(a,"deviceCode"),h=$(a,"userCode"),y=$(a,"verifyUrl"),b=re(a,"interval")*1e3,E=i()+re(a,"expiresIn")*1e3;l(`Log in to Linzumi:
|
|
18
|
+
Code: `+h+`
|
|
19
|
+
Open: `+y+`
|
|
20
|
+
`);let S=async()=>{if(i()<E){await o(b);let w=(await ie(r,d,"PollCliDeviceLogin","u2t1DgIfG-8",{deviceCode:m})).pollCliDeviceLogin,v;if(w!==void 0)if(typeof w=="object"&&w!==null&&!Array.isArray(w))v=w;else throw new Error("Linzumi CLI login response was missing pollCliDeviceLogin");else throw new Error("Linzumi CLI login response was missing pollCliDeviceLogin");switch($(v,"__typename")){case"CliDeviceLoginApproved":let I=$(v,"token"),z={version:1,apiUrl:c,token:I},N=P(e.authFilePath,F.join(D.homedir(),".linzumi","user-auth.json"));return Fe(z,N),l("Login saved to "+N+`
|
|
21
|
+
`),z;case"CliDeviceLoginDenied":throw new Error("Linzumi CLI login was denied");case"CliDeviceLoginExpired":throw new Error("Linzumi CLI login expired; run `linzumi login` again");case"CliDeviceLoginPending":return await S();default:throw new Error("Linzumi CLI login returned an unknown pollCliDeviceLogin result")}}else throw new Error("Linzumi CLI login expired; run `linzumi login` again")};return await S()}function Te(e){let t=!1,n=[],r={},o=["local-port","share-token","api-url","linzumi-url","tunnel-url"],i=0;for(;i<e.length;){let a=e[i];if(a!==void 0)switch(a){case"--help":case"-h":t=!0,i=i+1|0;break;default:if(a.startsWith("--")){let f=a.indexOf("="),m=f!==-1?a.slice(2,f):a.slice(2,a.length);if(o.includes(m)){let h=f!==-1?a.slice(f+1|0,a.length):e[i+1|0];if(h!==void 0){if(h.startsWith("--"))throw new Error("--"+m+" requires a value");r[m]=h,i=i+(f!==-1?1:2)|0}else throw new Error("--"+m+" requires a value")}else throw new Error("unknown tunnel flag --"+m)}else n.push(a),i=i+1|0}else i=e.length}if(n.length>1)throw new Error("linzumi connect accepts exactly one forward id");let l=r["local-port"],c;if(l!==void 0){let a=q(l,void 0);if(a!==void 0)if(a>=1&&a<=65535)c=a;else throw new Error("--local-port must be a TCP port from 1 to 65535");else throw new Error("--local-port must be a TCP port from 1 to 65535")}else c=0;let d=r["api-url"],s=r["linzumi-url"],u;if(d!==void 0)if(s!==void 0){if(d!==s)throw new Error("use only one of --api-url or --linzumi-url");u=d}else u=d;else u=s!==void 0?s:ve;return{help:t,forwardReference:n[0],localPort:c,shareToken:r["share-token"],apiUrl:u,tunnelUrl:P(r["tunnel-url"],we)}}function xe(e){let t=e.kind;switch(t){case"share-token":return"Bearer share_token:"+e.token;case"user-session":return"Bearer user_session:"+e.token;default:throw new Error("unknown tunnel credential kind: "+t)}}function Ce(e,t,n){if(e!==void 0)return{kind:"share-token",token:R(e,"share token")};let r=$e(P(n,F.join(D.homedir(),".linzumi","user-auth.json"))),o=j(t);if(r.apiUrl===o)return{kind:"user-session",token:r.token};throw new Error("stored user login is for "+r.apiUrl+", not "+o+"; run `linzumi login --api-url "+o+"`")}async function Ae(e,t,n,r){let o=R(e,"forward id");if(!o.includes(":"))return o;let i=new URL("/api/v2/tcp-tunnel/forwards/resolve",t);i.searchParams.set("alias",o);let l=await r(i.toString(),{method:"GET",headers:Object.fromEntries([["authorization",xe(n)]])}),c=await l.json();if(l.ok&&typeof c=="object"&&c!==null&&!Array.isArray(c)){let s=c.forward_id,u=0;if(s!==void 0){if(typeof s=="string"){if(s.trim()==="")throw new Error("tunnel target "+o+" did not resolve to a forward id");return s}u=2}else u=2;if(u===2)throw new Error("tunnel target "+o+" did not resolve to a forward id")}throw new Error("cannot resolve tunnel target "+o+" (HTTP "+l.status.toString()+")")}function He(){return`Usage: linzumi connect <forward-id> [options]
|
|
22
22
|
|
|
23
23
|
Expose one registered Linzumi TCP forward on IPv4 loopback. Any
|
|
24
24
|
client-initiated, single-stream TCP protocol is supported. UDP, FTP-style
|
|
@@ -30,7 +30,7 @@ Options:
|
|
|
30
30
|
--api-url <url> Linzumi product API origin
|
|
31
31
|
--tunnel-url <url> Linzumi preview tunnel origin
|
|
32
32
|
-h, --help Show this help
|
|
33
|
-
`}async function
|
|
33
|
+
`}async function Xe(e,t){let n=P(t.writeStdout,o=>{process.stdout.write(o)}),r=P(t.writeStderr,o=>{process.stderr.write(o)});try{let o=Te(e),i=o.help,l=o.forwardReference;if(i)return n(`Usage: linzumi connect <forward-id> [options]
|
|
34
34
|
|
|
35
35
|
Expose one registered Linzumi TCP forward on IPv4 loopback. Any
|
|
36
36
|
client-initiated, single-stream TCP protocol is supported. UDP, FTP-style
|
|
@@ -42,8 +42,8 @@ Options:
|
|
|
42
42
|
--api-url <url> Linzumi product API origin
|
|
43
43
|
--tunnel-url <url> Linzumi preview tunnel origin
|
|
44
44
|
-h, --help Show this help
|
|
45
|
-
`),0;if(
|
|
46
|
-
`);let
|
|
47
|
-
`),1}catch(
|
|
48
|
-
`),
|
|
49
|
-
`),1)}}var
|
|
45
|
+
`),0;if(l!==void 0){let c=j(o.apiUrl),d=Ce(o.shareToken,c,t.authFilePath),s=t.fetchImpl,u=s!==void 0?s:ae(),a=await Ae(l,c,d,u),f=await Ne({forwardId:a,tunnelBaseUrl:o.tunnelUrl,credential:d,localPort:o.localPort,writeStderr:r});n("Listening on 127.0.0.1:"+f.port.toString()+`
|
|
46
|
+
`);let m=()=>{f.close()};return process.once("SIGINT",m),process.once("SIGTERM",m),await f.closed,process.off("SIGINT",m),process.off("SIGTERM",m),0}return r(`linzumi connect: a forward id is required
|
|
47
|
+
`),1}catch(o){let i=L(o),l=x(i),c=Q(C(i),d=>B(d.exitCode));return c!==void 0?(r("linzumi connect: "+l+`
|
|
48
|
+
`),c):(r("linzumi connect: "+l+`
|
|
49
|
+
`),1)}}var Qe=65536,Ke=2e3;export{ke as abortStream,ye as closeReasonDefault,Oe as closeServer,xe as credentialAuthorization,ve as defaultHttpUrl,we as defaultTcpTunnelWebSocketUrl,Ve as defaultUserAuthFilePath,qe as defaultUserAuthFilePathDefault,be as drainAndEndSocket,Be as errorExn,ie as graphqlMutation,ae as linzumiTrustedFetchFromEnv,Ie as listenLoopback,Ee as listenerError,Ke as localHalfOpenGraceMs,Le as makeStreamTeardown,Qe as maxTcpTunnelFrameBytes,x as messageOfUnknown,j as normalizedUserAuthApiUrl,ue as openAuthenticatedTunnel,ze as openTcpStream,Se as parseAuthFrame,Te as parseConnectArgs,$e as readStoredUserAuth,ge as refusalError,re as requiredPositiveNumberField,$ as requiredStringField,R as requiredValue,Ce as resolveCredential,Ae as resolveForwardReference,Xe as runTcpConnectCommand,Ge as runUserLogin,Pe as sendBinaryFrame,Ne as startTcpTunnelListener,He as tcpConnectHelpText,_e as tcpTunnelWebSocketUrl,Je as tunnelRefusalExitCode,Fe as writeStoredUserAuth};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linzumi/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.326",
|
|
4
4
|
"description": "Linzumi CLI \u2014 point a Codex agent at the real code on your laptop, with your team watching and steering from shared threads.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -19,17 +19,16 @@
|
|
|
19
19
|
"build": "rescript build ../linzumi-cli-rescript && node scripts/build.mjs",
|
|
20
20
|
"bump-version": "node scripts/bump-cli-version.mjs",
|
|
21
21
|
"test": "pnpm --dir ../linzumi-cli-rescript test && npm run test:operational",
|
|
22
|
-
"typecheck": "rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.source.json",
|
|
22
|
+
"typecheck": "rescript build ../linzumi-cli-rescript && npm run codex-protocol:declarations && tsgo --noEmit -p tsconfig.source.json",
|
|
23
23
|
"prepack": "rescript build -q ../linzumi-cli-rescript && node scripts/build.mjs",
|
|
24
24
|
"pack:dry-run": "npm pack --dry-run",
|
|
25
25
|
"test:operational": "vitest run --config vitest.config.mjs",
|
|
26
|
-
"
|
|
26
|
+
"codex-protocol:declarations": "node ../linzumi-cli-rescript/scripts/CodexProtocolGenerate.res.mjs --repo-root ../.. --declarations-out packages/linzumi-cli/.generated/codex-app-server-protocol.d.ts",
|
|
27
27
|
"test:startup": "npm run build && node --test --test-concurrency=1 ../linzumi-cli-rescript/src/parity/CommanderStartupRefusalConformance.res.mjs",
|
|
28
|
-
"typecheck:all": "rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.json",
|
|
29
|
-
"typecheck:watch": "rescript build ../linzumi-cli-rescript && tsgo --noEmit -w -p tsconfig.source.json",
|
|
28
|
+
"typecheck:all": "rescript build ../linzumi-cli-rescript && npm run codex-protocol:declarations && tsgo --noEmit -p tsconfig.json",
|
|
29
|
+
"typecheck:watch": "rescript build ../linzumi-cli-rescript && npm run codex-protocol:declarations && tsgo --noEmit -w -p tsconfig.source.json",
|
|
30
30
|
"test:agent-source": "LINZUMI_CI_QUARANTINE=0 pnpm exec vitest run --config vitest.config.mjs test/channelSession.test.ts test/kandanQueue.test.ts -t '(retains three busy accepted source snapshots without fusing or interrupting|keeps different accepted agent sources distinct through interrupt pickup)' && pnpm --dir ../linzumi-cli-rescript build && pnpm --dir ../linzumi-cli-rescript exec node --import tsx src/parity/AgentOpenaiModelProviderConformance.res.mjs && pnpm --dir ../linzumi-cli-rescript exec node --import tsx src/parity/WorkerMintCredentialConformance.res.mjs",
|
|
31
|
-
"codex:history-table": "node scripts/codex_history_table.mjs"
|
|
32
|
-
"vendor:codex-app-server-protocol:check": "tsx scripts/vendor-codex-app-server-protocol.ts --check"
|
|
31
|
+
"codex:history-table": "node scripts/codex_history_table.mjs"
|
|
33
32
|
},
|
|
34
33
|
"keywords": [
|
|
35
34
|
"linzumi",
|
package/scripts/build.mjs
CHANGED
|
@@ -164,6 +164,8 @@ for (const [source, output, external] of [
|
|
|
164
164
|
['ws', 'undici', 'blessed', '@anthropic-ai/claude-agent-sdk'],
|
|
165
165
|
],
|
|
166
166
|
['mcp/CommanderMcpEntry.res.mjs', 'mcp-server.mjs', []],
|
|
167
|
+
// Dependency-free cloud guest: NO externals, it runs on the guest's bare node.
|
|
168
|
+
['vmsandbox/CommanderGuestCloudEntry.res.mjs', 'cloud-supervisor.mjs', []],
|
|
167
169
|
[
|
|
168
170
|
'worker/CommanderHostedAccountWorker.res.mjs',
|
|
169
171
|
'hosted-coding-account-worker.js',
|
|
@@ -194,7 +196,6 @@ for (const [source, output, external] of [
|
|
|
194
196
|
});
|
|
195
197
|
}
|
|
196
198
|
for (const [source, output] of [
|
|
197
|
-
['cloudSupervisorEntry.ts', 'cloud-supervisor.mjs'],
|
|
198
199
|
['crossHarnessFailover.mjs', 'crossHarnessFailover.mjs'],
|
|
199
200
|
]) {
|
|
200
201
|
await build({
|
|
@@ -8,19 +8,24 @@
|
|
|
8
8
|
//
|
|
9
9
|
// 1. pnpm bump-version <new-version> --spec plans/<release-spec>.md
|
|
10
10
|
// (for example: 1.2.3-beta with its approved release spec)
|
|
11
|
-
// 2. Run the test suite: pnpm
|
|
11
|
+
// 2. Run the test suite: pnpm test
|
|
12
12
|
// 3. Commit with a "[deploy-commander]" title and merge to main (the
|
|
13
13
|
// deprecated "[deploy-cli]" marker was retired in the N3.9 window on
|
|
14
14
|
// 2026-07-20 and is now loudly inert - naming program).
|
|
15
15
|
// 4. The main publish workflow (.github/workflows/linzumi-cli-publish.yml)
|
|
16
16
|
// publishes @linzumi/cli@<new-version> to npm.
|
|
17
17
|
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
18
|
+
// package.json is the SINGLE version source (scripts/build.mjs defines
|
|
19
|
+
// process.env.LINZUMI_CLI_VERSION from it). The version is still pinned in a
|
|
20
|
+
// few derived places (README.md, the public alias manifest and lockfile
|
|
21
|
+
// importer). No test pins the version: the package-manifest conformance
|
|
22
|
+
// derives it from package.json (spec/single-commander.md, zero-TS). This
|
|
23
|
+
// script rewrites every known site, FAILS LOUDLY if any expected pattern is
|
|
24
|
+
// missing, appends one entry to release-log.md (the release history; it never
|
|
25
|
+
// carries the exact version token), and then scans
|
|
26
|
+
// package.json/release-log.md/src/README/test/scripts/bin for any leftover
|
|
27
|
+
// exact old-version token - so a future, not-yet-listed pin site cannot
|
|
28
|
+
// silently drift past a release.
|
|
24
29
|
//
|
|
25
30
|
// Flags:
|
|
26
31
|
// --spec <path> Required standalone release spec under plans/.
|
|
@@ -155,37 +160,32 @@ const knownSites = [
|
|
|
155
160
|
pattern: `"version": "${oldVersion}"`,
|
|
156
161
|
replacement: `"version": "${newVersion}"`,
|
|
157
162
|
},
|
|
158
|
-
{
|
|
159
|
-
file: 'src/version.ts',
|
|
160
|
-
description: 'linzumiCliVersion constant',
|
|
161
|
-
pattern: `export const linzumiCliVersion = '${oldVersion}';`,
|
|
162
|
-
replacement: `export const linzumiCliVersion = '${newVersion}';`,
|
|
163
|
-
},
|
|
164
163
|
{
|
|
165
164
|
file: 'README.md',
|
|
166
165
|
description: 'pinned npx --version example',
|
|
167
166
|
pattern: `npx -y @linzumi/cli@${oldVersion} --version`,
|
|
168
167
|
replacement: `npx -y @linzumi/cli@${newVersion} --version`,
|
|
169
168
|
},
|
|
170
|
-
{
|
|
171
|
-
file: 'test/packageManifest.test.ts',
|
|
172
|
-
description: 'package manifest version expectation',
|
|
173
|
-
pattern: `expect(manifest.version).toBe('${oldVersion}');`,
|
|
174
|
-
replacement: `expect(manifest.version).toBe('${newVersion}');`,
|
|
175
|
-
},
|
|
176
169
|
];
|
|
177
170
|
|
|
178
171
|
function countOccurrences(haystack, needle) {
|
|
179
172
|
return haystack.split(needle).length - 1;
|
|
180
173
|
}
|
|
181
174
|
|
|
182
|
-
//
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
175
|
+
// Spec: spec/deploy-pipeline-rules.md (rule22 step 3, the autobump
|
|
176
|
+
// inheritance). release-log.md is the release history (formerly the
|
|
177
|
+
// src/version.ts spec comment): each bump appends exactly this fixed entry at
|
|
178
|
+
// the end of the file. The entry never carries the exact version token (the
|
|
179
|
+
// same token rule as the leftover scan; `1.2.3-foo` is a distinct version) - the leftover scan
|
|
180
|
+
// below refuses the old version anywhere in the log, and the entry itself is
|
|
181
|
+
// refused when it would carry the new one (a release spec path naming it), so
|
|
182
|
+
// the NEXT bump's scan can never trip on this one.
|
|
183
|
+
const releaseLogFile = 'release-log.md';
|
|
184
|
+
|
|
185
|
+
function appendReleaseLogEntry(content) {
|
|
186
|
+
if (!content.endsWith('\n')) {
|
|
187
187
|
fail(
|
|
188
|
-
|
|
188
|
+
`${releaseLogFile} must end with a newline so the release entry appends as whole lines`
|
|
189
189
|
);
|
|
190
190
|
}
|
|
191
191
|
|
|
@@ -199,7 +199,13 @@ function appendVersionSpecComment(content) {
|
|
|
199
199
|
'',
|
|
200
200
|
].join('\n');
|
|
201
201
|
|
|
202
|
-
|
|
202
|
+
if (versionToken(newVersion).test(entry)) {
|
|
203
|
+
fail(
|
|
204
|
+
`the ${releaseLogFile} entry would name '${newVersion}' (release spec ${releaseSpec}); the release log never carries a version literal`
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return `${content}${entry}`;
|
|
203
209
|
}
|
|
204
210
|
|
|
205
211
|
const plannedWrites = new Map();
|
|
@@ -224,13 +230,10 @@ for (const site of knownSites) {
|
|
|
224
230
|
);
|
|
225
231
|
}
|
|
226
232
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
plannedWrites.set(site.file, rewritten);
|
|
233
|
+
plannedWrites.set(
|
|
234
|
+
site.file,
|
|
235
|
+
content.split(site.pattern).join(site.replacement)
|
|
236
|
+
);
|
|
234
237
|
summary.push({
|
|
235
238
|
file: site.file,
|
|
236
239
|
description: site.description,
|
|
@@ -238,11 +241,30 @@ for (const site of knownSites) {
|
|
|
238
241
|
});
|
|
239
242
|
}
|
|
240
243
|
|
|
244
|
+
{
|
|
245
|
+
let releaseLog;
|
|
246
|
+
|
|
247
|
+
try {
|
|
248
|
+
releaseLog = readFileSync(join(packageRoot, releaseLogFile), 'utf8');
|
|
249
|
+
} catch (error) {
|
|
250
|
+
fail(
|
|
251
|
+
`expected release log ${releaseLogFile} could not be read: ${error.message}`
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
plannedWrites.set(releaseLogFile, appendReleaseLogEntry(releaseLog));
|
|
256
|
+
summary.push({
|
|
257
|
+
file: releaseLogFile,
|
|
258
|
+
description: 'release log entry appended',
|
|
259
|
+
occurrences: 1,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
241
263
|
// Leftover scan: after the planned rewrites, no exact old-version token may remain
|
|
242
264
|
// anywhere in the package surface. This is what catches an unlisted 8th site.
|
|
243
265
|
function scanTargets() {
|
|
244
266
|
const roots = ['src', 'test', 'scripts', 'bin'];
|
|
245
|
-
const files = ['package.json', 'README.md'];
|
|
267
|
+
const files = ['package.json', 'README.md', releaseLogFile];
|
|
246
268
|
|
|
247
269
|
// Spec: plans/2026-07-12-linzumi-unscoped-npm-package-spec.md
|
|
248
270
|
// The alias version and canonical dependency are one release invariant.
|
|
@@ -309,10 +331,13 @@ function walk(directory) {
|
|
|
309
331
|
// A dependency with a longer patch/prerelease/build is a distinct version,
|
|
310
332
|
// not another CLI pin. Conventional artifact prefixes (v, cli-) introduce pins;
|
|
311
333
|
// only numeric/dotted prefixes can extend the version itself.
|
|
312
|
-
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
);
|
|
334
|
+
function versionToken(version) {
|
|
335
|
+
const escaped = version.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
336
|
+
|
|
337
|
+
return new RegExp(`(^|[^0-9.])${escaped}(?=$|[^0-9A-Za-z.+-])`);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const oldVersionToken = versionToken(oldVersion);
|
|
316
341
|
const leftovers = [];
|
|
317
342
|
|
|
318
343
|
for (const file of scanTargets()) {
|
|
@@ -367,6 +392,6 @@ if (dryRun) {
|
|
|
367
392
|
process.stdout.write('Dry run - no files were written.\n');
|
|
368
393
|
} else {
|
|
369
394
|
process.stdout.write(
|
|
370
|
-
'Done. Now run the test suite before committing:\n pnpm
|
|
395
|
+
'Done. Now run the test suite before committing:\n pnpm test\nThen commit with a "[deploy-commander]" title and merge to main to publish.\n'
|
|
371
396
|
);
|
|
372
397
|
}
|