@linzumi/cli 1.0.295 → 1.0.297
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/assets/ghostty-vt.wasm +0 -0
- package/dist/cloud-supervisor.mjs +99 -99
- package/dist/hosted-coding-account-worker.js +16 -16
- package/dist/index.js +454 -424
- package/dist/mcp-server.mjs +27 -27
- package/dist/native/darwin/manifest.json +4 -4
- package/dist/native/darwin/preview-process-identity +0 -0
- package/dist/remote-codex-harness-worker.js +115 -109
- package/dist/tcp-tunnel-cli.mjs +16 -16
- package/native/darwin/linzumi-terminal-pty-helper +0 -0
- package/native/darwin/terminal-pty-helper.manifest.json +3 -3
- package/package.json +2 -1
- package/scripts/build.mjs +9 -0
- package/scripts/check-package-size-budget.mjs +1 -0
- package/scripts/qa/codex-keychain-partition-repro.md +0 -128
- package/scripts/qa/codex-keychain-partition-repro.sh +0 -151
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 ne from"ws";import*as w from"node:fs";import*as j from"node:os";import*as re from"node:net";import*as L 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 M(e){if(e!=null)return O(e)}function T(e){if(e===null||e.BS_PRIVATE_NESTED_SOME_NONE===void 0)return e;let n=e.BS_PRIVATE_NESTED_SOME_NONE;if(n!==0)return{BS_PRIVATE_NESTED_SOME_NONE:n-1|0}}function W(e,n){let r=e.findIndex(n);if(r!==-1)return r}function H(e,n){let r=n!==void 0?parseInt(e,n):parseInt(e);if(!(Number.isNaN(r)||r>2147483647||r<-2147483648))return r|0}import*as U from"node:crypto";function
|
|
4
|
-
`),await s.closed.then(
|
|
5
|
-
`)}switch(o){case"LocalFirst":break;case"RemoteFirst":case"RelayFailure":await Se(e.socket);break;case"ListenerShutdown":e.socket.destroy();break}let d=0;switch(o){case"LocalFirst":case"RemoteFirst":d=1;break;case"RelayFailure":break;case"ListenerShutdown":let s=e.tunnel;if(s!==void 0)await s.terminate();else{let
|
|
6
|
-
`)}break}if(d===1){let s=e.tunnel;if(s!==void 0)await s.close();else{let
|
|
7
|
-
`):y.terminate():
|
|
3
|
+
import*as ne from"ws";import*as w from"node:fs";import*as j from"node:os";import*as re from"node:net";import*as L 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 M(e){if(e!=null)return O(e)}function T(e){if(e===null||e.BS_PRIVATE_NESTED_SOME_NONE===void 0)return e;let n=e.BS_PRIVATE_NESTED_SOME_NONE;if(n!==0)return{BS_PRIVATE_NESTED_SOME_NONE:n-1|0}}function W(e,n){let r=e.findIndex(n);if(r!==-1)return r}function H(e,n){let r=n!==void 0?parseInt(e,n):parseInt(e);if(!(Number.isNaN(r)||r>2147483647||r<-2147483648))return r|0}import*as U from"node:crypto";function R(e){if(e.RE_EXN_ID==="JsExn")return O(e._1)}var N=(e=>n=>n&&typeof n[e]=="string"?n[e]:void 0),Je=N("stack"),K=N("message"),je=N("name"),De=N("fileName");function G(e,n){if(e!==void 0)return n(T(e))}function S(e,n){return e!==void 0?T(e):n}function se(e){return e==null?!1:typeof e.RE_EXN_ID=="string"}function P(e){return se(e)?e:{RE_EXN_ID:"JsExn",_1:e}}function D(e,n){return e.catch(r=>n(P(r)))}import{existsSync as Q,readFileSync as Z}from"node:fs";import{Agent as ce}from"undici";import He from"ws";function $(){let e=process.env.KANDAN_TLS_CA_FILE;if(e===void 0||e.trim()==="")return;let n=e.trim();if(!Q(n))throw new Error(`KANDAN_TLS_CA_FILE does not exist: ${n}`);return Z(n,"utf8")}function ye(){return pe(process.env.KANDAN_TLS_CA_FILE)}function pe(e){if(e===void 0||e.trim()==="")return;let n=e.trim();if(!Q(n))throw new Error(`KANDAN_TLS_CA_FILE does not exist: ${n}`);let r=Z(n,"utf8");return{caFile:n,ca:r,dispatcher:new ce({connect:{ca:r}})}}function fe(e){return e===void 0?fetch:((n,r)=>{let t={...r??{},dispatcher:e.dispatcher};return fetch(n,t)})}function A(){return fe(ye())}var Qe=64*1024*1024,Ze=32*1024;function en(e){return $()}function nn(e){return A()}var ge="wss://linzumi.link",he="https://serve.linzumi.com";function rn(e){return new Error(e)}function z(e){let n=R(e);return n!==void 0?S(K(T(n)),"unknown error"):"unknown error"}function J(e,n){let r=e.trim();if(r==="")throw new Error(n+" must not be empty");return r}function tn(e){return e%256}function we(e,n){let r=new Error("tunnel refused "+e.toString()+": "+n);return r.name="TunnelRefusalError",r.code=e,r.reason=n,r.exitCode=e%256,r}function be(e,n,r){let t=new Error(n);return t.name="TunnelListenerError",t.code=e,t.exitCode=r,t}function _e(e,n){let r=new URL(e),t=r.protocol,i;switch(t){case"https:":case"wss:":i="wss:";break;default:i="ws:"}return r.protocol=i,r.pathname="/tunnel/connect",r.search="",r.searchParams.set("forward_id",n),r.hash="",r.toString()}function ve(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 Ie(e){let n;try{n=JSON.parse(e)}catch{n=void 0}if(n===void 0||typeof n!="object"||n===null||Array.isArray(n))return"Invalid";let r=n.ok,t=n.tunnel_id;if(r===!0&&typeof t=="string"?t.trim()!=="":!1)return"Ready";let o=n.error,a=n.reason;return o!==void 0&&typeof o=="number"&&a!==void 0&&typeof a=="string"&&o>=4001&&o<=4008&&a.trim()!==""?{NAME:"Refusal",VAL:[o|0,a]}:"Invalid"}async function te(e,n,r,t,i){let o=i!==void 0?i:b=>{},a=n.kind,u;switch(a){case"share-token":u="Bearer share_token:"+n.token;break;case"user-session":u="Bearer user_session:"+n.token;break;default:throw new Error("unknown tunnel credential kind: "+a)}let c=Object.fromEntries([["authorization",u]]),l=t!==void 0?r(e,{headers:c,ca:t}):r(e,{headers:c});o(l);let d={contents:!1},s={contents:void 0},p={contents:[]},y={contents:void 0},f={contents:void 0},v=new Promise((b,I)=>{f.contents=b});return await new Promise((b,I)=>{l.on("message",(_,g)=>{if(g){let k=d.contents,x=_.byteLength<=65536;if(k&&x){let F=s.contents;if(F!==void 0)return F(_,l);p.contents.push(_);return}return l.close(4006,"protocol error"),d.contents?void 0:I(new Error("tunnel sent binary data before authentication"))}let m=Ie(_.toString("utf8"));if(typeof m!="object")return m==="Invalid"?(l.close(4006,"unexpected text frame"),d.contents?void 0:I(new Error("tunnel returned an invalid authentication frame"))):(d.contents=!0,b());let h=m.VAL;y.contents=[h[0],h[1]]}),l.once("error",_=>{if(!d.contents)return I(P(_))}),l.once("close",(_,g)=>{let m=y.contents,h;if(m!==void 0)h=m[1];else{let F=g.toString("utf8").trim();h=F===""?ve(_):F}let k=f.contents;if(k!==void 0&&k({code:_,reason:h}),d.contents)return;let x=y.contents;return I(x!==void 0?we(x[0],x[1]):new Error("tunnel closed before authentication ("+_.toString()+": "+h+")"))})}),{websocket:l,closed:v,attachBinary:b=>{if(s.contents!==void 0)throw new Error("tunnel binary pipe is already attached");s.contents=b,p.contents.forEach(_=>b(_,l)),p.contents=[]},close:async()=>{let b=l.readyState;return b!==3&&b!==2&&l.close(1e3,"local stream closed"),await v.then(I=>Promise.resolve())},terminate:async()=>(l.readyState!==3&&l.terminate(),await v.then(I=>Promise.resolve()))}}function ke(e,n){return new Promise((r,t)=>{if(e.readyState!==1)return t(new Error("tunnel WebSocket is not open"));e.send(n,{binary:!0},o=>o==null?r():t(P(o)))})}function Se(e){return e.destroyed?Promise.resolve():new Promise((n,r)=>{let t={contents:!1},i={contents:void 0},o=()=>{if(t.contents)return;t.contents=!0;let a=i.contents;a!==void 0&&clearTimeout(a),n()};e.once("close",o),e.end(()=>{if(e.destroyed)return o();i.contents=setTimeout(()=>{e.destroyed||e.destroy(),o()},2e3)})})}function Ee(e){e.socket.destroyed||e.socket.destroy();let n=e.tunnel,r=n!==void 0?O(n.websocket):e.websocket;if(r===void 0)return;let t=T(r);if(t.readyState!==3){t.terminate();return}}function Pe(e,n,r){let t={contents:void 0},i={contents:!1};return o=>{let a=t.contents;if(a!==void 0){let d=i.contents;return o==="ListenerShutdown"&&(d||(i.contents=!0,Ee(e))),a}let u={contents:void 0},c=new Promise((d,s)=>{u.contents=d});return t.contents=c,D((async()=>{if(o==="RelayFailure"){let s=e.tunnel;if(s!==void 0){let p=s.websocket.readyState,y=0;p>=2?p>=4&&(y=1):p>=0?s.websocket.terminate():y=1,y===1&&n("linzumi connect: stream "+e.id+" relay-failure teardown saw unknown WebSocket state "+p.toString()+`
|
|
4
|
+
`),await s.closed.then(f=>Promise.resolve())}else n("linzumi connect: stream "+e.id+` relay-failure teardown had no active tunnel to abort
|
|
5
|
+
`)}switch(o){case"LocalFirst":break;case"RemoteFirst":case"RelayFailure":await Se(e.socket);break;case"ListenerShutdown":e.socket.destroy();break}let d=0;switch(o){case"LocalFirst":case"RemoteFirst":d=1;break;case"RelayFailure":break;case"ListenerShutdown":let s=e.tunnel;if(s!==void 0)await s.terminate();else{let p=e.websocket;if(p!==void 0){let y=T(p);y.readyState!==3&&y.terminate()}else n("linzumi connect: stream "+e.id+` teardown had no WebSocket to close
|
|
6
|
+
`)}break}if(d===1){let s=e.tunnel;if(s!==void 0)await s.close();else{let p=e.websocket;if(p!==void 0){let y=T(p),f=y.readyState;f>3||f<1?f!==0?n("linzumi connect: stream "+e.id+" teardown saw unknown WebSocket state "+f.toString()+`
|
|
7
|
+
`):y.terminate():f>=2||y.close(1e3,"local stream closed")}else n("linzumi connect: stream "+e.id+` teardown had no WebSocket to close
|
|
8
8
|
`)}}return e.websocket=void 0,e.tunnel=void 0,r(e.id)})(),d=>(n("linzumi connect: stream "+e.id+" teardown failed: "+z(d)+`
|
|
9
9
|
`),e.socket.destroy(),e.websocket=void 0,e.tunnel=void 0,r(e.id),Promise.resolve())).then(()=>{let d=u.contents;return d!==void 0?d():n("linzumi connect: stream "+e.id+` teardown completion was unavailable
|
|
10
10
|
`),Promise.resolve()}),c}}function xe(e){return e.listening?new Promise((n,r)=>{e.close(t=>t==null?n():r(P(t)))}):Promise.resolve()}function Te(e,n){return new Promise((r,t)=>{let i=a=>{e.off("listening",o),t(P(a))},o=()=>{e.off("error",i),r()};e.once("error",i),e.once("listening",o),e.listen(n,"127.0.0.1")})}async function Fe(e,n,r,t,i,o,a,u){let c=Pe(e,o,u);e.teardown=c,e.socket.once("error",l=>{o("linzumi connect: local stream failed: "+l.message+`
|
|
11
|
-
`),e.socket.destroy(),c("LocalFirst")}),e.socket.once("close",()=>{c("LocalFirst")});try{let l=await te(n,r,t,i,
|
|
11
|
+
`),e.socket.destroy(),c("LocalFirst")}),e.socket.once("close",()=>{c("LocalFirst")});try{let l=await te(n,r,t,i,f=>{e.websocket=O(f)});e.tunnel=l;let d=a(),s=e.socket.destroyed;if(d)return await c("ListenerShutdown");if(s)return await c("LocalFirst");l.attachBinary((f,v)=>{if(!e.socket.write(f)){v.pause(),e.socket.once("drain",()=>{v.resume()});return}});let p={contents:Promise.resolve()};e.socket.on("data",f=>{e.socket.pause(),p.contents=D(p.contents.then(async()=>{let v=async E=>{if(E>=f.byteLength)return;let b=(E+65536|0)>f.byteLength?f.byteLength:E+65536|0;return await ke(l.websocket,f.subarray(E,b)),await v(E+65536|0)};if(await v(0),!e.socket.destroyed){e.socket.resume();return}}),v=>(o("linzumi connect: stream relay failed: "+z(v)+`
|
|
12
12
|
`),c("RelayFailure"),Promise.resolve()))}),e.socket.resume();let y=await l.closed;return await c("RemoteFirst"),a()?void 0:o("linzumi connect: stream closed "+y.code.toString()+": "+y.reason+`
|
|
13
13
|
`)}catch(l){let d=P(l);return o("linzumi connect: stream failed: "+z(d)+`
|
|
14
|
-
`),e.socket.destroy(),await c(a()?"ListenerShutdown":"LocalFirst")}}async function Oe(e){let n=J(e.forwardId,"forward id"),t=e.credential.kind,i=J(e.credential.token,"tunnel credential"),o={kind:t,token:i},a=S(e.writeStderr,g=>{process.stderr.write(g)}),u=S(e.webSocketFactory,(g,m)=>new ne.WebSocket(g,m)),c=$(),l=c==null?void 0:O(c),d=_e(e.tunnelBaseUrl,n);await(await te(d,o,u,l,void 0)).terminate();let
|
|
15
|
-
`)})});try{await Te(
|
|
16
|
-
`),h.socket.destroy(),Promise.resolve())});await xe(
|
|
17
|
-
`,"utf8"),w.closeSync(o),i=void 0,w.chmodSync(t,384),w.renameSync(t,n),w.chmodSync(n,384);return}catch(o){let a=i;throw a!==void 0&&w.closeSync(a),w.rmSync(t,{force:!0}),o}}async function ee(e,n,r,t,i){let o=JSON.stringify({operationName:r,documentId:t,variables:i}),a;if(o!==void 0)a=o;else throw new Error("Linzumi CLI login request serialization failed");let u=await e(n,{method:"POST",headers:Object.fromEntries([["content-type","application/json"]]),body:a}),c=await u.json();if(u.ok){if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let l=c.errors;if(l!==void 0)if(Array.isArray(l)){if(l.length!==0)throw new Error("Linzumi CLI login returned GraphQL errors")}else throw new Error("Linzumi CLI login returned GraphQL errors");let d=c.data;if(d!==void 0){if(typeof d=="object"&&d!==null&&!Array.isArray(d))return d;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 "+u.status.toString()+" "+u.statusText)}async function dn(e,n){let r=n.fetchImpl,t=r!==void 0?r:A(),i=S(n.wait,_=>new Promise((g,m)=>{setTimeout(()=>g(),_)})),o=S(n.now,()=>Date.now()),a=S(e.writeStdout,_=>{process.stdout.write(_)}),u=B(e.apiUrl),c=new URL("/api/v2/graphql",u).toString(),d=(await ee(t,c,"StartCliDeviceLogin","CE6X73GvfyE",{})).startCliDeviceLogin,s;if(d!==void 0)if(typeof d=="object"&&d!==null&&!Array.isArray(d))s=d;else throw new Error("Linzumi CLI login response was missing startCliDeviceLogin");else throw new Error("Linzumi CLI login response was missing startCliDeviceLogin");switch(C(s,"__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 y=C(s,"deviceCode"),
|
|
18
|
-
Code: `+
|
|
14
|
+
`),e.socket.destroy(),await c(a()?"ListenerShutdown":"LocalFirst")}}async function Oe(e){let n=J(e.forwardId,"forward id"),t=e.credential.kind,i=J(e.credential.token,"tunnel credential"),o={kind:t,token:i},a=S(e.writeStderr,g=>{process.stderr.write(g)}),u=S(e.webSocketFactory,(g,m)=>new ne.WebSocket(g,m)),c=$(),l=c==null?void 0:O(c),d=_e(e.tunnelBaseUrl,n);await(await te(d,o,u,l,void 0)).terminate();let p=re.createServer({allowHalfOpen:!0}),y=[],f={contents:!1},v={contents:void 0},E=new Promise((g,m)=>{v.contents=g});p.on("connection",g=>{g.pause();let m={id:U.randomUUID(),socket:g,websocket:void 0,tunnel:void 0,teardown:void 0};y.push(m),Fe(m,d,o,u,l,a,()=>f.contents,h=>{let k=W(y,x=>x.id===h);if(k!==void 0){y.splice(k,1);return}else return a("linzumi connect: completed stream "+h+` was absent from the registry
|
|
15
|
+
`)})});try{await Te(p,e.localPort)}catch(g){let m=P(g),h=R(m);if(h!==void 0){let k=T(h).code;throw k==null?m:k==="EADDRINUSE"?be("EADDRINUSE","127.0.0.1:"+e.localPort.toString()+" is already in use",2):m}throw m}let b=p.address(),I;if(b==null)throw new Error("TCP tunnel listener did not expose a loopback TCP port");return I=b.port,{port:I,closed:E,close:async()=>{if(f.contents)return await E;f.contents=!0;let g=y.map(h=>{let k=h.teardown;return k!==void 0?k("ListenerShutdown"):(a("linzumi connect: stream "+h.id+` had no teardown during listener shutdown
|
|
16
|
+
`),h.socket.destroy(),Promise.resolve())});await xe(p),await Promise.all(g).then(h=>Promise.resolve());let m=v.contents;if(m!==void 0)return m()},activeStreamCount:()=>y.length}}function on(e){return L.join(e,".linzumi","user-auth.json")}function an(){return L.join(j.homedir(),".linzumi","user-auth.json")}function B(e){let n=new URL(e),r=n.protocol,t;switch(r){case"https:":case"wss:":t="https:";break;default:t="http:"}n.protocol=t,n.pathname="",n.search="",n.hash="";let i=n.toString();return i.endsWith("/")?i.slice(0,i.length-1|0):i}function C(e,n){let r=e[n];if(typeof r=="string"){if(r.trim()==="")throw new Error("Linzumi CLI login response was missing "+n);return r}throw new Error("Linzumi CLI login response was missing "+n)}function Y(e,n){let r=e[n];if(typeof r=="number"){if(r>0)return r;throw new Error("Linzumi CLI login response had invalid "+n)}throw new Error("Linzumi CLI login response had invalid "+n)}function Ce(e){let n;try{n=JSON.parse(w.readFileSync(e,"utf8"))}catch(r){let t=P(r);throw new Error("cannot read Linzumi user auth at "+e+"; run `linzumi login` ("+z(t)+")")}if(typeof n=="object"&&n!==null&&!Array.isArray(n)){if(n.version===1)return{version:1,apiUrl:C(n,"apiUrl"),token:C(n,"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 Le(e,n){let r=L.dirname(n);w.mkdirSync(r,{recursive:!0,mode:448}),w.chmodSync(r,448);let t=n+"."+process.pid.toString()+"."+U.randomUUID()+".tmp",i;try{let o=w.openSync(t,"wx",384);i=o;let a=JSON.stringify({version:e.version,apiUrl:e.apiUrl,token:e.token}),u;if(a!==void 0)u=a;else throw new Error("Linzumi user auth serialization failed");w.writeFileSync(o,u+`
|
|
17
|
+
`,"utf8"),w.closeSync(o),i=void 0,w.chmodSync(t,384),w.renameSync(t,n),w.chmodSync(n,384);return}catch(o){let a=i;throw a!==void 0&&w.closeSync(a),w.rmSync(t,{force:!0}),o}}async function ee(e,n,r,t,i){let o=JSON.stringify({operationName:r,documentId:t,variables:i}),a;if(o!==void 0)a=o;else throw new Error("Linzumi CLI login request serialization failed");let u=await e(n,{method:"POST",headers:Object.fromEntries([["content-type","application/json"]]),body:a}),c=await u.json();if(u.ok){if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let l=c.errors;if(l!==void 0)if(Array.isArray(l)){if(l.length!==0)throw new Error("Linzumi CLI login returned GraphQL errors")}else throw new Error("Linzumi CLI login returned GraphQL errors");let d=c.data;if(d!==void 0){if(typeof d=="object"&&d!==null&&!Array.isArray(d))return d;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 "+u.status.toString()+" "+u.statusText)}async function dn(e,n){let r=n.fetchImpl,t=r!==void 0?r:A(),i=S(n.wait,_=>new Promise((g,m)=>{setTimeout(()=>g(),_)})),o=S(n.now,()=>Date.now()),a=S(e.writeStdout,_=>{process.stdout.write(_)}),u=B(e.apiUrl),c=new URL("/api/v2/graphql",u).toString(),d=(await ee(t,c,"StartCliDeviceLogin","CE6X73GvfyE",{})).startCliDeviceLogin,s;if(d!==void 0)if(typeof d=="object"&&d!==null&&!Array.isArray(d))s=d;else throw new Error("Linzumi CLI login response was missing startCliDeviceLogin");else throw new Error("Linzumi CLI login response was missing startCliDeviceLogin");switch(C(s,"__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 y=C(s,"deviceCode"),f=C(s,"userCode"),v=C(s,"verifyUrl"),E=Y(s,"interval")*1e3,b=o()+Y(s,"expiresIn")*1e3;a(`Log in to Linzumi:
|
|
18
|
+
Code: `+f+`
|
|
19
19
|
Open: `+v+`
|
|
20
20
|
`);let I=async()=>{if(o()<b){await i(E);let g=(await ee(t,c,"PollCliDeviceLogin","u2t1DgIfG-8",{deviceCode:y})).pollCliDeviceLogin,m;if(g!==void 0)if(typeof g=="object"&&g!==null&&!Array.isArray(g))m=g;else throw new Error("Linzumi CLI login response was missing pollCliDeviceLogin");else throw new Error("Linzumi CLI login response was missing pollCliDeviceLogin");switch(C(m,"__typename")){case"CliDeviceLoginApproved":let k=C(m,"token"),x={version:1,apiUrl:u,token:k},F=S(e.authFilePath,L.join(j.homedir(),".linzumi","user-auth.json"));return Le(x,F),a("Login saved to "+F+`
|
|
21
|
-
`),x;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 I();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 I()}function Ae(e){let n=!1,r=[],t={},i=["local-port","share-token","api-url","linzumi-url","tunnel-url"],o=0;for(;o<e.length;){let s=e[o];if(s!==void 0)switch(s){case"--help":case"-h":n=!0,o=o+1|0;break;default:if(s.startsWith("--")){let
|
|
21
|
+
`),x;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 I();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 I()}function Ae(e){let n=!1,r=[],t={},i=["local-port","share-token","api-url","linzumi-url","tunnel-url"],o=0;for(;o<e.length;){let s=e[o];if(s!==void 0)switch(s){case"--help":case"-h":n=!0,o=o+1|0;break;default:if(s.startsWith("--")){let p=s.indexOf("="),y=p!==-1?s.slice(2,p):s.slice(2,s.length);if(i.includes(y)){let f=p!==-1?s.slice(p+1|0,s.length):e[o+1|0];if(f!==void 0){if(f.startsWith("--"))throw new Error("--"+y+" requires a value");t[y]=f,o=o+(p!==-1?1:2)|0}else throw new Error("--"+y+" requires a value")}else throw new Error("unknown tunnel flag --"+y)}else r.push(s),o=o+1|0}else o=e.length}if(r.length>1)throw new Error("linzumi connect accepts exactly one forward id");let a=t["local-port"],u;if(a!==void 0){let s=H(a,void 0);if(s!==void 0)if(s>=1&&s<=65535)u=s;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 u=0;let c=t["api-url"],l=t["linzumi-url"],d;if(c!==void 0)if(l!==void 0){if(c!==l)throw new Error("use only one of --api-url or --linzumi-url");d=c}else d=c;else d=l!==void 0?l:he;return{help:n,forwardReference:r[0],localPort:u,shareToken:t["share-token"],apiUrl:d,tunnelUrl:S(t["tunnel-url"],ge)}}function ze(e){let n=e.kind;switch(n){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: "+n)}}function qe(e,n,r){if(e!==void 0)return{kind:"share-token",token:J(e,"share token")};let t=Ce(S(r,L.join(j.homedir(),".linzumi","user-auth.json"))),i=B(n);if(t.apiUrl===i)return{kind:"user-session",token:t.token};throw new Error("stored user login is for "+t.apiUrl+", not "+i+"; run `linzumi login --api-url "+i+"`")}async function Re(e,n,r,t){let i=J(e,"forward id");if(!i.includes(":"))return i;let o=new URL("/api/v2/tcp-tunnel/forwards/resolve",n);o.searchParams.set("alias",i);let a=await t(o.toString(),{method:"GET",headers:Object.fromEntries([["authorization",ze(r)]])}),u=await a.json();if(a.ok&&typeof u=="object"&&u!==null&&!Array.isArray(u)){let l=u.forward_id,d=0;if(l!==void 0){if(typeof l=="string"){if(l.trim()==="")throw new Error("tunnel target "+i+" did not resolve to a forward id");return l}d=2}else d=2;if(d===2)throw new Error("tunnel target "+i+" did not resolve to a forward id")}throw new Error("cannot resolve tunnel target "+i+" (HTTP "+a.status.toString()+")")}function ln(){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
|
|
@@ -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(a!==void 0){let u=B(i.apiUrl),c=
|
|
46
|
-
`);let y=()=>{
|
|
47
|
-
`),1}catch(i){let o=P(i),a=z(o),u=G(
|
|
45
|
+
`),0;if(a!==void 0){let u=B(i.apiUrl),c=qe(i.shareToken,u,n.authFilePath),l=n.fetchImpl,d=l!==void 0?l:A(),s=await Re(a,u,c,d),p=await Oe({forwardId:s,tunnelBaseUrl:i.tunnelUrl,credential:c,localPort:i.localPort,writeStderr:t});r("Listening on 127.0.0.1:"+p.port.toString()+`
|
|
46
|
+
`);let y=()=>{p.close()};return process.once("SIGINT",y),process.once("SIGTERM",y),await p.closed,process.off("SIGINT",y),process.off("SIGTERM",y),0}return t(`linzumi connect: a forward id is required
|
|
47
|
+
`),1}catch(i){let o=P(i),a=z(o),u=G(R(o),c=>M(c.exitCode));return u!==void 0?(t("linzumi connect: "+a+`
|
|
48
48
|
`),u):(t("linzumi connect: "+a+`
|
|
49
|
-
`),1)}}var un=65536,cn=2e3;export{Ee as abortStream,ve as closeReasonDefault,xe as closeServer,ze as credentialAuthorization,he as defaultHttpUrl,ge as defaultTcpTunnelWebSocketUrl,on as defaultUserAuthFilePath,an as defaultUserAuthFilePathDefault,Se as drainAndEndSocket,rn as errorExn,ee as graphqlMutation,en as linzumiTlsCaFromEnv,nn as linzumiTrustedFetchFromEnv,Te as listenLoopback,be as listenerError,cn as localHalfOpenGraceMs,Pe as makeStreamTeardown,un as maxTcpTunnelFrameBytes,z as messageOfUnknown,B as normalizedUserAuthApiUrl,te as openAuthenticatedTunnel,Fe as openTcpStream,Ie as parseAuthFrame,Ae as parseConnectArgs,Ce as readStoredUserAuth,we as refusalError,Y as requiredPositiveNumberField,C as requiredStringField,J as requiredValue,
|
|
49
|
+
`),1)}}var un=65536,cn=2e3;export{Ee as abortStream,ve as closeReasonDefault,xe as closeServer,ze as credentialAuthorization,he as defaultHttpUrl,ge as defaultTcpTunnelWebSocketUrl,on as defaultUserAuthFilePath,an as defaultUserAuthFilePathDefault,Se as drainAndEndSocket,rn as errorExn,ee as graphqlMutation,en as linzumiTlsCaFromEnv,nn as linzumiTrustedFetchFromEnv,Te as listenLoopback,be as listenerError,cn as localHalfOpenGraceMs,Pe as makeStreamTeardown,un as maxTcpTunnelFrameBytes,z as messageOfUnknown,B as normalizedUserAuthApiUrl,te as openAuthenticatedTunnel,Fe as openTcpStream,Ie as parseAuthFrame,Ae as parseConnectArgs,Ce as readStoredUserAuth,we as refusalError,Y as requiredPositiveNumberField,C as requiredStringField,J as requiredValue,qe as resolveCredential,Re as resolveForwardReference,sn as runTcpConnectCommand,dn as runUserLogin,ke as sendBinaryFrame,Oe as startTcpTunnelListener,ln as tcpConnectHelpText,_e as tcpTunnelWebSocketUrl,tn as tunnelRefusalExitCode,Le as writeStoredUserAuth};
|
|
Binary file
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": 1,
|
|
3
3
|
"sourceSha256": "0fe0761fe94c9791cdffb1ed2e271b4aee1ec777cdb984219da0ea1d3c2cc399",
|
|
4
4
|
"buildScriptSha256": "42e501268392badf5caa9ca0b64e28f0c3d7e437542c95512e362969cd1471cf",
|
|
5
|
-
"binarySha256": "
|
|
5
|
+
"binarySha256": "90f178d65067a4313c00fa82697825d38886e6a89dee2063c13146b4891a20eb",
|
|
6
6
|
"architectures": [
|
|
7
7
|
"arm64",
|
|
8
8
|
"x86_64"
|
|
@@ -19,6 +19,6 @@
|
|
|
19
19
|
"x86_64",
|
|
20
20
|
"-mmacosx-version-min=11.0"
|
|
21
21
|
],
|
|
22
|
-
"compiler": "Apple clang version 21.0.0 (clang-2100.
|
|
23
|
-
"sdkVersion": "
|
|
22
|
+
"compiler": "Apple clang version 21.0.0 (clang-2100.3.34.2)",
|
|
23
|
+
"sdkVersion": "27.0"
|
|
24
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linzumi/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.297",
|
|
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": {
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
48
48
|
"@openai/codex": "0.159.2",
|
|
49
49
|
"blessed": "^0.1.81",
|
|
50
|
+
"ghostty-web": "0.4.0",
|
|
50
51
|
"proper-lockfile": "3.2.0",
|
|
51
52
|
"undici": "^6.25.0",
|
|
52
53
|
"ws": "^8.18.0",
|
package/scripts/build.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
chmod,
|
|
14
14
|
} from 'node:fs/promises';
|
|
15
15
|
import { execFileSync } from 'node:child_process';
|
|
16
|
+
import { createRequire } from 'node:module';
|
|
16
17
|
import { createHash } from 'node:crypto';
|
|
17
18
|
import { tmpdir } from 'node:os';
|
|
18
19
|
import { dirname, join } from 'node:path';
|
|
@@ -142,6 +143,14 @@ await copyFile(
|
|
|
142
143
|
join(packageRoot, 'src/assets/linzumi-logo.svg'),
|
|
143
144
|
join(packageRoot, 'dist/assets/linzumi-logo.svg')
|
|
144
145
|
);
|
|
146
|
+
// Spec: spec/native-remote-terminal-rules.md (:native-remote-terminal/assistant.reads).
|
|
147
|
+
// The Ghostty VT core the Assistant's read-time screen rebuild loads from
|
|
148
|
+
// <bundle dir>/assets (CommanderTerminalSnapshot pins its SHA-256). The nix
|
|
149
|
+
// image copies the same file to bin/assets (nix/linzumi-cli.nix).
|
|
150
|
+
await copyFile(
|
|
151
|
+
createRequire(import.meta.url).resolve('ghostty-web/ghostty-vt.wasm'),
|
|
152
|
+
join(packageRoot, 'dist/assets/ghostty-vt.wasm')
|
|
153
|
+
);
|
|
145
154
|
|
|
146
155
|
for (const [source, output, external] of [
|
|
147
156
|
[
|
|
@@ -23,6 +23,7 @@ const requiredFiles = [
|
|
|
23
23
|
'native/darwin/linzumi-terminal-pty-helper',
|
|
24
24
|
'native/darwin/terminal-pty-helper.manifest.json',
|
|
25
25
|
'dist/assets/linzumi-logo.svg',
|
|
26
|
+
'dist/assets/ghostty-vt.wasm',
|
|
26
27
|
];
|
|
27
28
|
export const GUEST_BUNDLE_FLOOR_BYTES = {
|
|
28
29
|
'dist/mcp-server.mjs': 100 * 1024,
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
# Codex MCP keychain re-prompt - fix + QA
|
|
2
|
-
|
|
3
|
-
Spec: `kandan/server_v2/plans/2026-06-24-codex-mcp-keychain-reprompt-report.md`
|
|
4
|
-
|
|
5
|
-
## The problem (one paragraph)
|
|
6
|
-
|
|
7
|
-
Codex stores its MCP OAuth secret in a macOS login-keychain generic-password
|
|
8
|
-
item labeled `Codex MCP Credentials`. The item's access-control list is bound to
|
|
9
|
-
one exact codex binary (its CDHash). When Codex.app auto-updates (new CDHash),
|
|
10
|
-
or you move between codex identities (official OpenAI team `2DC432GLL2`, the
|
|
11
|
-
unsigned npm `codex` under `node`, or a Linzumi-re-signed codex), the CDHash no
|
|
12
|
-
longer matches the ACL and macOS re-prompts: "codex wants to use the Codex MCP
|
|
13
|
-
Credentials in your keychain". The proper upstream fixes (a Designated-
|
|
14
|
-
Requirement-bound ACL, or moving to the data-protection keychain) are OpenAI's.
|
|
15
|
-
|
|
16
|
-
## The no-upstream fix (lever 2)
|
|
17
|
-
|
|
18
|
-
Set the keychain item's PARTITION LIST to the code-signing team id(s) so any
|
|
19
|
-
same-team-signed codex build is granted silent access across updates, instead of
|
|
20
|
-
binding access to a single CDHash. This is what the
|
|
21
|
-
`linzumi fix-codex-keychain` subcommand does. The exact command it runs per
|
|
22
|
-
matching item is:
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
security set-generic-password-partition-list \
|
|
26
|
-
-S "teamid:2DC432GLL2,teamid:2CWCP5BR45,apple:" \
|
|
27
|
-
-s "Codex MCP Credentials" \
|
|
28
|
-
-a <account> \
|
|
29
|
-
-k <login-keychain-password>
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
- `2DC432GLL2` - OpenAI Codex code-signing team (the official Codex.app).
|
|
33
|
-
- `2CWCP5BR45` - Linzumi's macOS team
|
|
34
|
-
(`kandan/kandan-electron-shell/scripts/common_macos_beta.sh` `DEFAULT_TEAM_ID`,
|
|
35
|
-
overridable via `KANDAN_DEVELOPMENT_TEAM`; add more with `--team-id`).
|
|
36
|
-
- `apple:` - keeps Apple-provided tooling working.
|
|
37
|
-
|
|
38
|
-
The helper is macOS-only, scoped exclusively to the `Codex MCP Credentials`
|
|
39
|
-
service, idempotent, and consent-gated: it defaults to a dry run and only
|
|
40
|
-
mutates with `--apply`. The login-keychain password is never logged or
|
|
41
|
-
persisted (pass it via `LINZUMI_KEYCHAIN_PASSWORD` for automation, or let macOS
|
|
42
|
-
prompt).
|
|
43
|
-
|
|
44
|
-
### Using the helper
|
|
45
|
-
|
|
46
|
-
```
|
|
47
|
-
# Dry run - shows the item(s) and the partition list it would apply.
|
|
48
|
-
linzumi fix-codex-keychain
|
|
49
|
-
|
|
50
|
-
# Apply. macOS authorizes the ACL change with your login-keychain password.
|
|
51
|
-
linzumi fix-codex-keychain --apply
|
|
52
|
-
|
|
53
|
-
# Add an extra signing team (e.g. a custom re-signed codex).
|
|
54
|
-
linzumi fix-codex-keychain --apply --team-id ABCDE12345
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Automated synthetic repro (no GUI, no real item)
|
|
58
|
-
|
|
59
|
-
`scripts/qa/codex-keychain-partition-repro.sh` proves the mechanism the helper
|
|
60
|
-
relies on, without touching your real login keychain or the real
|
|
61
|
-
`Codex MCP Credentials` item, and without needing a real Codex.app update.
|
|
62
|
-
|
|
63
|
-
It creates a dedicated, unlocked test keychain with a known password, adds a
|
|
64
|
-
test item whose partition list does NOT include the target team (the would-
|
|
65
|
-
re-prompt precondition), runs the exact `set-generic-password-partition-list`
|
|
66
|
-
command the helper runs, then reads the partition list back with
|
|
67
|
-
`security dump-keychain -a` to prove the target team flipped from absent to
|
|
68
|
-
present. The test keychain is deleted on exit via a `trap` (even on failure).
|
|
69
|
-
|
|
70
|
-
Run it:
|
|
71
|
-
|
|
72
|
-
```
|
|
73
|
-
bash packages/linzumi-cli/scripts/qa/codex-keychain-partition-repro.sh
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
Expected output ends with:
|
|
77
|
-
|
|
78
|
-
```
|
|
79
|
-
== BEFORE: target team must be ABSENT from the partition list ==
|
|
80
|
-
partition list (before): apple:
|
|
81
|
-
ok: target team is absent before the fix (a same-team codex would re-prompt).
|
|
82
|
-
...
|
|
83
|
-
== AFTER: target team must now be PRESENT in the partition list ==
|
|
84
|
-
partition list (after): teamid:2DC432GLL2, apple:
|
|
85
|
-
ok: target team is present after the fix (same-team codex builds read silently).
|
|
86
|
-
...
|
|
87
|
-
RESULT: PASS (partition list flipped from team-absent to team-present)
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### What the synthetic repro does and does NOT prove
|
|
91
|
-
|
|
92
|
-
- PROVES (headless, deterministic): the fix command writes the intended
|
|
93
|
-
partition list onto the item; the team id transitions from absent to present,
|
|
94
|
-
observed verbatim via `security dump-keychain -a`. This is the load-bearing
|
|
95
|
-
state change.
|
|
96
|
-
- Does NOT prove headlessly: that a same-team-signed codex binary then reads the
|
|
97
|
-
secret with zero GUI prompt. Demonstrating the silent read requires a binary
|
|
98
|
-
actually signed by the team in the partition; `/usr/bin/security` is not, and
|
|
99
|
-
the authorization for a non-member reader is a GUI event that cannot be
|
|
100
|
-
satisfied non-interactively (it returns errSec interaction-not-allowed in an
|
|
101
|
-
automated shell). That payoff is confirmed by the on-device manual procedure
|
|
102
|
-
below, which is itself inherently a GUI observation (the re-prompt is a dialog).
|
|
103
|
-
|
|
104
|
-
## On-device manual verification (real Codex.app item)
|
|
105
|
-
|
|
106
|
-
This is the human, on-device confirmation of the end-user payoff. Do it on a Mac
|
|
107
|
-
that actually uses Codex.app MCP credentials.
|
|
108
|
-
|
|
109
|
-
1. Observe the BEFORE re-prompt. Trigger codex MCP usage (or force a re-prompt by
|
|
110
|
-
updating Codex.app, or temporarily switching codex identities). macOS shows:
|
|
111
|
-
"codex wants to use the Codex MCP Credentials in your keychain". This dialog
|
|
112
|
-
is the bug; note that it appears.
|
|
113
|
-
2. Apply the fix:
|
|
114
|
-
```
|
|
115
|
-
linzumi fix-codex-keychain # dry run: confirm the item + plan
|
|
116
|
-
linzumi fix-codex-keychain --apply # enter your login-keychain password once
|
|
117
|
-
```
|
|
118
|
-
3. Confirm AFTER. Relaunch codex / Codex.app (or re-trigger the same MCP usage,
|
|
119
|
-
ideally after an app update so the CDHash differs). The credential is read
|
|
120
|
-
with NO re-prompt. To double-check the state without a relaunch:
|
|
121
|
-
```
|
|
122
|
-
security dump-keychain -a login.keychain-db \
|
|
123
|
-
| grep -A2 'authorizations (1): partition_id'
|
|
124
|
-
```
|
|
125
|
-
The `description:` line for the `Codex MCP Credentials` item now lists
|
|
126
|
-
`teamid:2DC432GLL2` (and `teamid:2CWCP5BR45`, `apple:`).
|
|
127
|
-
|
|
128
|
-
Re-running `linzumi fix-codex-keychain --apply` is harmless (idempotent).
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
# Spec: plans/2026-06-24-codex-mcp-keychain-reprompt-report.md
|
|
4
|
-
#
|
|
5
|
-
# Self-contained, NON-INTERACTIVE proof of the Codex MCP keychain partition-list
|
|
6
|
-
# fix (lever 2). It NEVER touches your real login keychain or the real
|
|
7
|
-
# "Codex MCP Credentials" item, and it does NOT require a real Codex.app update.
|
|
8
|
-
#
|
|
9
|
-
# WHAT IT PROVES (headless, deterministic):
|
|
10
|
-
# The fix runs `security set-generic-password-partition-list` to add the
|
|
11
|
-
# code-signing team(s) to a keychain item's PARTITION LIST. A keychain item's
|
|
12
|
-
# silent-read access is gated by that partition list. We create a dedicated
|
|
13
|
-
# test item whose partition list does NOT include the target team
|
|
14
|
-
# ("teamid:2DC432GLL2"), confirm the team is ABSENT (the "broken" / would-
|
|
15
|
-
# re-prompt precondition), run the SAME command the helper runs, and confirm
|
|
16
|
-
# the team is now PRESENT (the "fixed" state). The partition list is read back
|
|
17
|
-
# verbatim via `security dump-keychain -a`, so the before/after transition is
|
|
18
|
-
# fully observable without any GUI.
|
|
19
|
-
#
|
|
20
|
-
# WHY NOT "silent read" headlessly:
|
|
21
|
-
# The post-fix payoff is that a same-team-signed codex binary reads the secret
|
|
22
|
-
# with NO GUI prompt. Demonstrating that requires a binary that is actually in
|
|
23
|
-
# the team partition; /usr/bin/security is not, and the authorization is a GUI
|
|
24
|
-
# event. That on-device confirmation is the manual procedure in the QA doc.
|
|
25
|
-
# This script proves the load-bearing state change the helper performs.
|
|
26
|
-
#
|
|
27
|
-
# Everything happens inside a DEDICATED test keychain with a KNOWN password,
|
|
28
|
-
# created unlocked and deleted on exit (even on failure, via trap), so macOS
|
|
29
|
-
# never pops a GUI dialog and your real keychains are untouched.
|
|
30
|
-
#
|
|
31
|
-
# Usage: bash codex-keychain-partition-repro.sh
|
|
32
|
-
# Exit: 0 = PASS, 1 = FAIL, 2 = not macOS.
|
|
33
|
-
|
|
34
|
-
set -u
|
|
35
|
-
|
|
36
|
-
if [[ "$(uname -s)" != "Darwin" ]]; then
|
|
37
|
-
echo "SKIP: this repro only runs on macOS (darwin). Detected: $(uname -s)" >&2
|
|
38
|
-
exit 2
|
|
39
|
-
fi
|
|
40
|
-
|
|
41
|
-
KEYCHAIN_NAME="linzumi-qa.keychain"
|
|
42
|
-
KEYCHAIN_PW="linzumi-qa-$$"
|
|
43
|
-
SERVICE="Codex MCP Credentials TEST"
|
|
44
|
-
ACCOUNT="testacct"
|
|
45
|
-
SECRET="testsecret-$$"
|
|
46
|
-
# The official OpenAI Codex team id is the partition we add (the same default
|
|
47
|
-
# the helper applies). The synthetic item proves the partition-list mechanism;
|
|
48
|
-
# the team id value is not verified against a real signature in this test.
|
|
49
|
-
TARGET_TEAM="2DC432GLL2"
|
|
50
|
-
# BEFORE: a partition list WITHOUT the target team. AFTER: target team + apple.
|
|
51
|
-
BEFORE_PARTITION="apple:"
|
|
52
|
-
AFTER_PARTITION="teamid:${TARGET_TEAM},apple:"
|
|
53
|
-
|
|
54
|
-
cleanup() {
|
|
55
|
-
security delete-keychain "$KEYCHAIN_NAME" >/dev/null 2>&1 || true
|
|
56
|
-
}
|
|
57
|
-
trap cleanup EXIT
|
|
58
|
-
|
|
59
|
-
# Read the partition-list "description:" line (under the partition_id
|
|
60
|
-
# authorization) for the test item from a keychain dump.
|
|
61
|
-
read_partition_description() {
|
|
62
|
-
security dump-keychain -a "$KEYCHAIN_NAME" 2>/dev/null \
|
|
63
|
-
| grep -A2 'authorizations (1): partition_id' \
|
|
64
|
-
| grep 'description:' \
|
|
65
|
-
| head -n1 \
|
|
66
|
-
| sed 's/^[[:space:]]*description:[[:space:]]*//'
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
echo "== Codex MCP keychain partition-list repro (synthetic, non-interactive) =="
|
|
70
|
-
echo "test keychain: $KEYCHAIN_NAME"
|
|
71
|
-
echo "service: $SERVICE"
|
|
72
|
-
echo "target team: teamid:$TARGET_TEAM"
|
|
73
|
-
echo
|
|
74
|
-
|
|
75
|
-
# Clean slate in case a prior aborted run left the keychain behind.
|
|
76
|
-
cleanup
|
|
77
|
-
|
|
78
|
-
echo "[setup] create + unlock dedicated test keychain"
|
|
79
|
-
if ! security create-keychain -p "$KEYCHAIN_PW" "$KEYCHAIN_NAME"; then
|
|
80
|
-
echo "FAIL: could not create test keychain" >&2
|
|
81
|
-
exit 1
|
|
82
|
-
fi
|
|
83
|
-
# Disable auto-relock so no GUI unlock prompt can appear during the run.
|
|
84
|
-
security set-keychain-settings "$KEYCHAIN_NAME" || true
|
|
85
|
-
security unlock-keychain -p "$KEYCHAIN_PW" "$KEYCHAIN_NAME" || true
|
|
86
|
-
|
|
87
|
-
echo "[setup] add a test item (permissive ACL) then set a partition list that"
|
|
88
|
-
echo " EXCLUDES the target team (the would-re-prompt precondition)"
|
|
89
|
-
if ! security add-generic-password \
|
|
90
|
-
-a "$ACCOUNT" -s "$SERVICE" -w "$SECRET" -A "$KEYCHAIN_NAME"; then
|
|
91
|
-
echo "FAIL: could not add test item" >&2
|
|
92
|
-
exit 1
|
|
93
|
-
fi
|
|
94
|
-
security unlock-keychain -p "$KEYCHAIN_PW" "$KEYCHAIN_NAME" || true
|
|
95
|
-
if ! security set-generic-password-partition-list \
|
|
96
|
-
-S "$BEFORE_PARTITION" \
|
|
97
|
-
-s "$SERVICE" -a "$ACCOUNT" -k "$KEYCHAIN_PW" "$KEYCHAIN_NAME" \
|
|
98
|
-
>/dev/null 2>&1; then
|
|
99
|
-
echo "FAIL: could not set the BEFORE partition list" >&2
|
|
100
|
-
exit 1
|
|
101
|
-
fi
|
|
102
|
-
|
|
103
|
-
echo
|
|
104
|
-
echo "== BEFORE: target team must be ABSENT from the partition list =="
|
|
105
|
-
BEFORE_DESC="$(read_partition_description)"
|
|
106
|
-
echo "partition list (before): ${BEFORE_DESC:-<none>}"
|
|
107
|
-
if echo "$BEFORE_DESC" | grep -q "teamid:${TARGET_TEAM}"; then
|
|
108
|
-
echo "BEFORE precondition NOT met: target team already present." >&2
|
|
109
|
-
BEFORE_OK=0
|
|
110
|
-
else
|
|
111
|
-
echo "ok: target team is absent before the fix (a same-team codex would re-prompt)."
|
|
112
|
-
BEFORE_OK=1
|
|
113
|
-
fi
|
|
114
|
-
|
|
115
|
-
echo
|
|
116
|
-
echo "== APPLY FIX: the exact command the helper runs =="
|
|
117
|
-
echo "running: security set-generic-password-partition-list -S \"$AFTER_PARTITION\" -s \"$SERVICE\" -a \"$ACCOUNT\" -k <pw> $KEYCHAIN_NAME"
|
|
118
|
-
security unlock-keychain -p "$KEYCHAIN_PW" "$KEYCHAIN_NAME" || true
|
|
119
|
-
if ! security set-generic-password-partition-list \
|
|
120
|
-
-S "$AFTER_PARTITION" \
|
|
121
|
-
-s "$SERVICE" -a "$ACCOUNT" -k "$KEYCHAIN_PW" "$KEYCHAIN_NAME" \
|
|
122
|
-
>/dev/null 2>&1; then
|
|
123
|
-
echo "FAIL: set-generic-password-partition-list failed" >&2
|
|
124
|
-
exit 1
|
|
125
|
-
fi
|
|
126
|
-
echo "partition list applied."
|
|
127
|
-
|
|
128
|
-
echo
|
|
129
|
-
echo "== AFTER: target team must now be PRESENT in the partition list =="
|
|
130
|
-
AFTER_DESC="$(read_partition_description)"
|
|
131
|
-
echo "partition list (after): ${AFTER_DESC:-<none>}"
|
|
132
|
-
if echo "$AFTER_DESC" | grep -q "teamid:${TARGET_TEAM}"; then
|
|
133
|
-
echo "ok: target team is present after the fix (same-team codex builds read silently)."
|
|
134
|
-
AFTER_OK=1
|
|
135
|
-
else
|
|
136
|
-
echo "AFTER FAILED: target team is still absent." >&2
|
|
137
|
-
AFTER_OK=0
|
|
138
|
-
fi
|
|
139
|
-
|
|
140
|
-
echo
|
|
141
|
-
echo "============================== VERDICT =============================="
|
|
142
|
-
echo "BEFORE (team absent): $BEFORE_OK"
|
|
143
|
-
echo "AFTER (team present): $AFTER_OK"
|
|
144
|
-
|
|
145
|
-
if [[ $BEFORE_OK -eq 1 && $AFTER_OK -eq 1 ]]; then
|
|
146
|
-
echo "RESULT: PASS (partition list flipped from team-absent to team-present)"
|
|
147
|
-
exit 0
|
|
148
|
-
fi
|
|
149
|
-
|
|
150
|
-
echo "RESULT: FAIL"
|
|
151
|
-
exit 1
|