planx 20.5.3 → 20.5.4

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/domain.main.mjs CHANGED
@@ -1,4 +1,4 @@
1
- globalThis.__PLANX_SERVICE_VERSION__="20.5.3";
1
+ globalThis.__PLANX_SERVICE_VERSION__="20.5.4";
2
2
  import { createRequire } from 'module';
3
3
  const require = createRequire(import.meta.url);
4
4
 
@@ -460,7 +460,7 @@ Content-Length: 0\r
460
460
 
461
461
  `)})},cancel(){C?.(),C=null}});return new Response(i.pipeThrough(new TextEncoderStream),{headers:{"content-type":"text/event-stream","cache-control":"no-cache"}})})}var J0=LI(WQ());var L0=LI(WQ());import{createHash as Zf}from"node:crypto";var t0=LI(WQ());var mf="http://do.internal";async function D0(A,g,I,Q){let C=await zi(A,g,{method:Q.method,url:`${mf}${Q.path}`,headers:{[GB]:I,...Q.headers},body:Q.body});if(typeof C=="string")throw new Error(`[domain-gateway] ${g} ${Q.path}: ${C}`);return{status:C.response.status,body:await Xc(C)}}function r0(A,g,I){return async({document:Q,variables:C})=>{let{status:B,body:i}=await D0(A,g,I,{method:"POST",path:"/graphql",headers:{"content-type":"application/json",[Pc]:jc},body:JSON.stringify({query:(0,t0.print)(Q),variables:C})});if(B>=400)throw new Error(`[domain-gateway] ${g} /graphql failed: ${B}`);return JSON.parse(i)}}function n0(A,g,I){return async()=>{let{status:Q,body:C}=await D0(A,g,I,{method:"GET",path:"/federation"});if(Q>=300)return[];try{let B=JSON.parse(C);return Array.isArray(B?.joins)?B.joins:[]}catch{return[]}}}var Lg=LI(WQ());var PI=LI(WQ()),AB="Domain";function ZQ(A){return new Set(Object.values(A.getTypeMap()).filter(g=>!g.name.startsWith("__")&&!(0,PI.isSpecifiedScalarType)(g)).map(g=>g.name))}function a0(A,g){return{...A,value:`${g}${A.value}`}}function w0(A,g){let I=A.getSubscriptionType()?.name;return[...ZQ(A)].filter(Q=>Q!==I).map(Q=>`${g}${Q}`)}function c0(A,g=AB){let I=ZQ(A),Q=A.getSubscriptionType()?.name,C=i=>i.name.value===Q?null:I.has(i.name.value)?{...i,name:a0(i.name,g)}:i,B=(0,PI.visit)((0,PI.parse)((0,PI.printSchema)(A)),{SchemaDefinition:()=>null,SchemaExtension:()=>null,NamedType:i=>I.has(i.name.value)?{...i,name:a0(i.name,g)}:void 0,ObjectTypeDefinition:C,InterfaceTypeDefinition:C,UnionTypeDefinition:C,EnumTypeDefinition:C,InputObjectTypeDefinition:C,ScalarTypeDefinition:C});return(0,PI.print)({...B,kind:PI.Kind.DOCUMENT})}function F0(A,g,I=AB){let Q=A.startsWith(I)?A.slice(I.length):A;return g.has(Q)?Q:A}var CI=LI(WQ());function h0(A,g,I){(0,CI.visit)(A,{FragmentSpread(Q){let C=g[Q.name.value];C&&!I.has(C.name.value)&&(I.set(C.name.value,C),h0(C.selectionSet,g,I))}})}function bf(A){let g=new Set;for(let I of A)(0,CI.visit)(I,{Variable(Q){g.add(Q.name.value)}});return g}function qf(A,g,I){return(0,CI.visit)(A,{NamedType:Q=>({...Q,name:{...Q.name,value:F0(Q.name.value,g,I)}})})}function fn(A,g,I=AB){let Q=A.fieldNodes[0],C=new Map;Q.selectionSet&&h0(Q.selectionSet,A.fragments,C);let B=bf([Q,...C.values()]),i=(A.operation.variableDefinitions??[]).filter(r=>B.has(r.variable.name.value)),e={kind:CI.Kind.DOCUMENT,definitions:[{kind:CI.Kind.OPERATION_DEFINITION,operation:CI.OperationTypeNode.QUERY,variableDefinitions:i,selectionSet:{kind:CI.Kind.SELECTION_SET,selections:[Q]}},...C.values()]},t=Object.fromEntries(Object.entries(A.variableValues??{}).filter(([r])=>B.has(r)));return{document:qf(e,g,I),variables:t}}function Tf(A,g){let[I,...Q]=A.definitions,C={kind:CI.Kind.SELECTION_SET,selections:I.selectionSet.selections},B={kind:CI.Kind.FIELD,name:{kind:CI.Kind.NAME,value:g},selectionSet:C};return{...A,definitions:[{...I,selectionSet:{kind:CI.Kind.SELECTION_SET,selections:[B]}},...Q]}}function Hn(A,g,I=AB,Q,C=B=>B){let B=ZQ(g);return async(i,e,t,r)=>{let h=fn(r,B,I),y=C(Q?Tf(h.document,Q):h.document),S=await A({document:y,variables:h.variables}),u=r.fieldNodes[0].alias?.value??r.fieldNodes[0].name.value,H=S.data,EA=Q?H?.[Q]:H,nA=EA?EA[u]:void 0,uA=S.errors??[];if(uA.length>0&&nA==null)throw new CI.GraphQLError(uA.map(PA=>PA.message).join("; "),{nodes:r.fieldNodes[0],path:(0,CI.responsePathAsArray)(r.path)});return xf(nA,uA,Q?[Q,u]:[u]),nA??null}}function xf(A,g,I){for(let Q of g){let C=Q.path??[];if(C.length<=I.length||I.some((e,t)=>C[t]!==e))continue;let B=C.slice(I.length),i=A;for(let e=0;e<B.length&&!(typeof i!="object"||i===null);e+=1){let t=i,r=t[B[e]];if(e===B.length-1||r===null||r===void 0){t[B[e]]=new CI.GraphQLError(Q.message);break}i=r}}}var Fo=LI(WQ());var pn="session";function mn(A,g,I){return A.replace(/[A-Za-z_][A-Za-z0-9_]*/g,Q=>g.has(Q)?`${I}${Q}`:Q)}function R0(A,g,I,Q,C){let B=A.getQueryType()?.getFields()[pn],i=B?(0,Fo.getNamedType)(B.type):null;if(!i||!(0,Fo.isObjectType)(i))return[];let e=ZQ(A),t=[];for(let r of Object.values(i.getFields())){if(I.has(r.name)){Q(`[domain-gateway] ${C} \u306E Session \u62E1\u5F35 ${r.name} \u3092\u7E2B\u308F\u306A\u3044 (\u65E2\u5B58\u306E field \u3068\u885D\u7A81)`);continue}I.add(r.name),t.push({name:r.name,type:mn(String(r.type),e,g)})}return t}var ho="domain",y0=A=>`__planx_key_${A}`;async function N0(A,g){let I=[];for(let Q of A.filter(C=>C.mount.field!==ho)){let C=await Q.mount.federation?.().catch(()=>[])??[];for(let B of C){let i=A.find(y=>y.mount.field===B.plugin&&y.mount.field!==ho),e=Q.remote.getQueryType()?.getFields()[B.query],t=e?.args.find(y=>y.name===B.arg),r=i?.remote.getType(B.type),h=i?(0,Lg.isObjectType)(r)?!e||!t?`${Q.mount.field} \u306B root field ${B.query}(${B.arg}) \u304C\u7121\u3044`:r.getFields()[B.field]?`${B.field} \u306F\u65E2\u306B\u3042\u308B`:null:`\u578B ${B.type} \u304C\u7121\u3044`:`plugin ${B.plugin} \u304C\u7121\u3044`;if(h||!i||!e||!t){g(`[domain-gateway] ${Q.mount.field} \u306E join ${B.plugin}.${B.type}.${B.field} \u3092\u7E2B\u308F\u306A\u3044 (${h})`);continue}I.push({decl:B,source:Q,target:i,returnType:mn(String(e.type),ZQ(Q.remote),Q.mount.prefix),argType:String(t.type)})}}return I}function G0(A){return A.map(g=>`extend type ${g.target.mount.prefix}${g.decl.type} { ${g.decl.field}: ${g.returnType} }`)}function U0(A,g){let I=new Map;for(let Q of A)I.set(Q.decl.type,[...I.get(Q.decl.type)??[],Q]);return I.size===0?Q=>Q:Q=>{let C=new Lg.TypeInfo(g);return(0,Lg.visit)(Q,(0,Lg.visitWithTypeInfo)(C,{Field:B=>I.get(C.getParentType()?.name??"")?.some(i=>i.decl.field===B.name.value)?null:void 0,SelectionSet:B=>{let i=I.get(C.getParentType()?.name??"");if(!i)return;let t=[...new Set(i.map(r=>r.decl.key))].map(r=>({kind:Lg.Kind.FIELD,alias:{kind:Lg.Kind.NAME,value:y0(r)},name:{kind:Lg.Kind.NAME,value:r}}));return{...B,selections:[...B.selections,...t]}}}))}}function M0(A){let g=new WeakMap,I=async(Q,C)=>{g.delete(Q);let B=[...C.keys.keys()],i=fn(C.info,ZQ(A.source.remote),A.source.mount.prefix),[e,...t]=i.document.definitions,r=B.map((u,H)=>({kind:Lg.Kind.FIELD,alias:{kind:Lg.Kind.NAME,value:`k${H}`},name:{kind:Lg.Kind.NAME,value:A.decl.query},arguments:[{kind:Lg.Kind.ARGUMENT,name:{kind:Lg.Kind.NAME,value:A.decl.arg},value:{kind:Lg.Kind.VARIABLE,name:{kind:Lg.Kind.NAME,value:`__k${H}`}}}],selectionSet:Q.selectionSet})),h=[...e.variableDefinitions??[],...B.map((u,H)=>({kind:Lg.Kind.VARIABLE_DEFINITION,variable:{kind:Lg.Kind.VARIABLE,name:{kind:Lg.Kind.NAME,value:`__k${H}`}},type:(0,Lg.parseType)(A.argType)}))],y={kind:Lg.Kind.DOCUMENT,definitions:[{...e,variableDefinitions:h,selectionSet:{kind:Lg.Kind.SELECTION_SET,selections:r}},...t]},S={...i.variables,...Object.fromEntries(B.map((u,H)=>[`__k${H}`,u]))};try{let u=await A.source.mount.executor({document:y,variables:S}),H=u.data??{};B.forEach((EA,nA)=>{let uA=C.keys.get(EA)??[];if(H[`k${nA}`]===void 0&&u.errors?.length){let PA=new Lg.GraphQLError(u.errors.map(jA=>jA.message).join("; "));uA.forEach(jA=>jA.reject(PA))}else uA.forEach(PA=>PA.resolve(H[`k${nA}`]??null))})}catch(u){C.keys.forEach(H=>H.forEach(EA=>EA.reject(u)))}};return(Q,C,B,i)=>{let e=String(Q[y0(A.decl.key)]??Q[A.decl.key]??""),t=i.fieldNodes[0],r=g.get(t);if(!r){let y={keys:new Map,info:i};r=y,g.set(t,y),queueMicrotask(()=>{I(t,y)})}let h=r.keys.get(e)??[];return r.keys.set(e,h),new Promise((y,S)=>h.push({resolve:y,reject:S}))}}function Vf(A){return`${A.charAt(0).toUpperCase()}${A.slice(1)}`}function Of(A,g){let I=[...A].sort((B,i)=>i.boundAt-B.boundAt)[0],Q=I?[{field:ho,prefix:AB,objectId:I.objectId}]:[],C=[...g].sort((B,i)=>B.name.localeCompare(i.name)).map(B=>({field:B.name,prefix:Vf(B.name),objectId:B.objectId}));return[...Q,...C]}function S0(A,g){return Of(A.bindingsOf(g),A.plugins()).map(I=>({field:I.field,prefix:I.prefix,executor:r0(A,I.objectId,g),federation:n0(A,I.objectId,g)}))}var wC=LI(WQ());var k0="Query";async function vf(A){let g=await A({document:(0,wC.parse)((0,wC.getIntrospectionQuery)())});if(!g.data||g.errors&&g.errors.length>0)throw new Error(`[domain-gateway] introspection failed: ${JSON.stringify(g.errors??null)}`);return(0,wC.buildClientSchema)(g.data)}var bn=A=>A.getFields();async function Wf(A,g){let I=new Set([k0]),Q=new Set,C=[];for(let B of A){let i=await vf(B.executor).catch(h=>(g(`[domain-gateway] ${B.field}: ${h instanceof Error?h.message:String(h)}`),null)),e=i?.getQueryType();if(!i||!e)continue;let t=w0(i,B.prefix),r=[...t.filter(h=>I.has(h)),...Q.has(B.field)?[B.field]:[]];if(r.length>0){g(`[domain-gateway] ${B.field} \u3092\u7E2B\u308F\u306A\u3044 (\u885D\u7A81: ${r.join(", ")})`);continue}t.forEach(h=>I.add(h)),Q.add(B.field),C.push({mount:B,remote:i,queryName:`${B.prefix}${e.name}`})}return C}async function l0(A,g=()=>{}){let I=await Wf(A,g);if(I.length===0)return null;let Q=new Set(I.map(h=>h.mount.field)),C=I.map(h=>({...h,hoist:R0(h.remote,h.mount.prefix,Q,g,h.mount.field)})),B=[...I.map(h=>`${h.mount.field}: ${h.queryName}`),...C.flatMap(h=>h.hoist.map(y=>`${y.name}: ${y.type}`))],i=await N0(I,g),e=[...I.map(({mount:h,remote:y})=>c0(y,h.prefix)),`type ${k0} { ${B.join(" ")} }`,...G0(i)].join(`
462
462
  `),t=(0,wC.buildSchema)(e),r=bn(t.getQueryType());for(let{mount:h,remote:y,queryName:S,hoist:u}of C){let H=U0(i.filter(nA=>nA.target.mount===h),y);r[h.field].resolve=()=>({});let EA=bn(t.getType(S));for(let nA of Object.keys(y.getQueryType()?.getFields()??{}))EA[nA]&&(EA[nA].resolve=Hn(h.executor,y,h.prefix,void 0,H));for(let nA of u)r[nA.name].resolve=Hn(h.executor,y,h.prefix,pn,H)}for(let h of i)bn(t.getType(`${h.target.mount.prefix}${h.decl.type}`))[h.decl.field].resolve=M0(h);return t}function K0(A,g=()=>{}){let I=new Map;A.onChange(()=>I.clear());async function Q(C){try{let B=await l0(S0(A,C),i=>g(C,i));return B?{schema:B,hash:Zf("sha256").update((0,L0.printSchema)(B)).digest("hex")}:null}catch(B){return g(C,B instanceof Error?B.message:String(B)),null}}return{schemaFor(C){let B=I.get(C);if(B)return B;let i=Q(C);return I.set(C,i),i}}}function Pf(A){if(typeof A!="object"||A===null)return null;let{query:g,variables:I,operationName:Q}=A;return typeof g!="string"||I!=null&&(typeof I!="object"||Array.isArray(I))||Q!=null&&typeof Q!="string"?null:{query:g,variables:I,operationName:Q}}function u0(A,g){let I=null,Q=()=>I??=g().then(C=>K0(C,(B,i)=>process.stderr.write(`[domain-gateway] ${B}: ${i}
463
- `)));A.get("/domain/sessions/:sessionId/graphql/hash",async C=>{let B=await(await Q()).schemaFor(C.req.param("sessionId"));return B?C.json({hash:B.hash}):C.json({error:{code:"NO_GATEWAY",message:"no domain object is mounted for this session"}},404)}),A.post("/domain/sessions/:sessionId/graphql",async C=>{let B=await(await Q()).schemaFor(C.req.param("sessionId"));if(!B)return C.json({error:{code:"NO_GATEWAY",message:"no domain object is mounted for this session"}},404);let i=Pf(await C.req.json().catch(()=>null));if(!i)return C.json({error:{code:"INVALID_BODY",message:"expected { query, variables?, operationName? }"}},400);let e=await(0,J0.graphql)({schema:B.schema,source:i.query,variableValues:i.variables??void 0,operationName:i.operationName??void 0});return C.json(e)})}var zf="20.5.3";function d0(A){let g=new vo;g.onError((e,t)=>{let r=e.message||String(e)||e.name||"unknown";return process.stderr.write(`[domain-http] ${t.req.method} ${t.req.path} failed: ${r}
463
+ `)));A.get("/domain/sessions/:sessionId/graphql/hash",async C=>{let B=await(await Q()).schemaFor(C.req.param("sessionId"));return B?C.json({hash:B.hash}):C.json({error:{code:"NO_GATEWAY",message:"no domain object is mounted for this session"}},404)}),A.post("/domain/sessions/:sessionId/graphql",async C=>{let B=await(await Q()).schemaFor(C.req.param("sessionId"));if(!B)return C.json({error:{code:"NO_GATEWAY",message:"no domain object is mounted for this session"}},404);let i=Pf(await C.req.json().catch(()=>null));if(!i)return C.json({error:{code:"INVALID_BODY",message:"expected { query, variables?, operationName? }"}},400);let e=await(0,J0.graphql)({schema:B.schema,source:i.query,variableValues:i.variables??void 0,operationName:i.operationName??void 0});return C.json(e)})}var zf="20.5.4";function d0(A){let g=new vo;g.onError((e,t)=>{let r=e.message||String(e)||e.name||"unknown";return process.stderr.write(`[domain-http] ${t.req.method} ${t.req.path} failed: ${r}
464
464
  ${e.stack??""}
465
465
  `),t.json({error:{message:r}},500)});let{injectWebSocket:I,upgradeWebSocket:Q}=Xw({app:g}),C=A,B=null,i=()=>(C??=jf(_f(Xf(),"domain-objects-")),B??=_i.restore({dbDir:C}),B);return AF(g,i,Q),gF(g,i),IF(g,i),u0(g,i),g.get("/health",e=>e.json({status:"ok",service:"domain",version:zf})),{app:g,injectWebSocket:I}}function Y0(){return{port:Number(process.env.PORT??0),portFile:process.env.PLANX_DOMAIN_PORT_FILE,pidFile:process.env.PLANX_DOMAIN_PID_FILE,dbDir:process.env.PLANX_DOMAIN_DB_DIR}}async function AH(){let{port:A,portFile:g,pidFile:I,dbDir:Q}=Y0();Q&&cC.mkdirSync(Q,{recursive:!0});let C=Q?$f(Q,"objects"):void 0,{app:B,injectWebSocket:i}=d0(C),e=await new Promise(t=>{let r=Qa({fetch:B.fetch,port:A,hostname:"127.0.0.1"},y=>t(y.port));i(r);let h=()=>{try{r.close?.()}catch{}if(I)try{cC.unlinkSync(I)}catch{}if(g)try{cC.unlinkSync(g)}catch{}process.exit(0)};process.on("SIGTERM",h),process.on("SIGINT",h)});g&&cC.writeFileSync(g,String(e)),I&&cC.writeFileSync(I,String(process.pid)),process.stdout.write(JSON.stringify({service:"domain",port:e,pid:process.pid})+`
466
466
  `),process.stdin.resume(),process.stdin.on("end",()=>process.exit(1)),process.on("uncaughtException",(t,r)=>{try{process.stderr.write(`[domain] Uncaught exception (${r}): ${t instanceof Error?t.message:String(t)}
package/exit.main.mjs CHANGED
@@ -1,4 +1,4 @@
1
- globalThis.__PLANX_SERVICE_VERSION__="20.5.3";
1
+ globalThis.__PLANX_SERVICE_VERSION__="20.5.4";
2
2
  var G=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function Ue(e){let t=e.toLowerCase();return t.startsWith("::ffff:")&&G.test(t.slice(7))?t.slice(7):t}function W(e){let t=Ue(e),r=G.exec(t);return r?r[1]==="127"||t==="0.0.0.0":t==="::1"||t==="::"||t==="0:0:0:0:0:0:0:1"||t==="0:0:0:0:0:0:0:0"}import*as j from"node:dns";import*as U from"node:net";var V={ECONNREFUSED:5,ENETUNREACH:3,EHOSTUNREACH:4,ENOTFOUND:4,EAI_AGAIN:4,ETIMEDOUT:4};function X(e){let t=e?.code;return typeof t=="string"&&t in V?V[t]:1}var we=async e=>(await j.promises.lookup(e)).address;function Te(e,t,r){return new Promise(n=>{let o=U.connect({host:e,port:t}),s=i=>{o.destroy(),n({ok:!1,rep:i})};o.setTimeout(r,()=>s(4)),o.once("error",i=>s(X(i))),o.once("connect",()=>{o.setTimeout(0),o.removeAllListeners("error"),n({ok:!0,socket:o})})})}function I(e={}){let t=e.isForbidden??W,r=e.lookup??we;return async n=>{let o;try{o=U.isIP(n)?n:await r(n)}catch(s){return{ok:!1,rep:X(s)}}return t(o)?{ok:!1,rep:2}:{ok:!0,ip:o}}}function Q(e={}){let t=I(e),r=e.connectTimeoutMs??15e3;return Object.assign(async({host:o,port:s})=>{let i=await t(o);return i.ok?Te(i.ip,s,r):i},{resolve:t})}import*as me from"node:net";var ee=!!globalThis.__webrtcProxyDebug||typeof process<"u"&&!!process.env?.PLANX_PROXY_DEBUG;var He=1,Ne=3,Me=4,A=class{constructor(){this.buf=Buffer.alloc(0);this.greetingDone=!1;this.requestDone=!1}push(t){this.buf=Buffer.concat([this.buf,t])}takeGreeting(){if(this.greetingDone||this.buf.length<2)return null;if(this.buf[0]!==5)throw new Error(`[socks] unsupported version: ${this.buf[0]}`);let t=this.buf[1];if(this.buf.length<2+t)return null;let r=[...this.buf.subarray(2,2+t)];return this.buf=this.buf.subarray(2+t),this.greetingDone=!0,{methods:r}}takeRequest(){if(!this.greetingDone||this.requestDone||this.buf.length<4)return null;if(this.buf[0]!==5)throw new Error(`[socks] unsupported version in request: ${this.buf[0]}`);let t=this.buf[1],r=this.buf[3],n,o,s;if(r===He){if(o=10,this.buf.length<o)return null;n=[...this.buf.subarray(4,8)].join("."),s=Buffer.from(this.buf.subarray(4,8))}else if(r===Ne){if(this.buf.length<5)return null;let u=this.buf[4];if(o=5+u+2,this.buf.length<o)return null;n=this.buf.subarray(5,5+u).toString("latin1")}else if(r===Me){if(o=22,this.buf.length<o)return null;s=Buffer.from(this.buf.subarray(4,20));let u=this.buf.subarray(4,20).toString("hex");n=[0,4,8,12,16,20,24,28].map(c=>u.slice(c,c+4)).join(":")}else throw new Error(`[socks] unsupported ATYP: ${r}`);let i=this.buf.readUInt16BE(o-2);return this.buf=this.buf.subarray(o),this.requestDone=!0,{cmd:t,atyp:r,host:n,port:i,addrBytes:s}}drainRest(){let t=this.buf;return this.buf=Buffer.alloc(0),t}};var Ar={1:4,4:16};var g=e=>new Error(`socks address: ${e}`);function H(e,t){if(!Number.isInteger(t)||t<0||t>65535)throw g(`port out of range: ${t}`);let r=[t>>8,t&255];if(e.kind==="ipv4"){if(e.addr.length!==4)throw g("ipv4 must be 4 bytes");return Uint8Array.from([1,...e.addr,...r])}if(e.kind==="ipv6"){if(e.addr.length!==16)throw g("ipv6 must be 16 bytes");return Uint8Array.from([4,...e.addr,...r])}let n=new TextEncoder().encode(e.name);if(n.length===0||n.length>255)throw g(`domain length ${n.length} is not in 1..255`);return Uint8Array.from([3,n.length,...n,...r])}function $e(e){if(e.length===0)throw g("empty");let t=e[0];if(t===1)return{address:{kind:"ipv4",addr:e.slice(1,5)},end:5};if(t===4)return{address:{kind:"ipv6",addr:e.slice(1,17)},end:17};if(t===3){if(e.length<2)throw g("domain length missing");let r=2+e[1];return{address:{kind:"domain",name:new TextDecoder().decode(e.slice(2,r))},end:r}}throw g(`unknown atyp 0x${t.toString(16)}`)}function N(e){let{address:t,end:r}=$e(e);if(e.length<r+2)throw g(`truncated (${e.length} < ${r+2})`);return{address:t,port:e[r]<<8|e[r+1],length:r+2}}var ze=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,Fe=/^[0-9a-f]{1,4}$/i;function re(e){let t=ze.exec(e),r=t?t.slice(1).map(Number):null;return r&&r.every(n=>n<=255)?r:null}function te(e){if(e==="")return[];let t=[];for(let r of e.split(":")){let n=re(r);if(n)t.push(n[0]<<8|n[1],n[2]<<8|n[3]);else if(Fe.test(r))t.push(parseInt(r,16));else return null}return t}function Ke(e){let t=e.split("%")[0].split("::");if(t.length>2)return null;let r=te(t[0]),n=t.length===2?te(t[1]):[];if(!r||!n)return null;let o=8-r.length-n.length;if(t.length===2?o<1:o!==0)return null;let s=[...r,...new Array(o).fill(0),...n];return Uint8Array.from(s.flatMap(i=>[i>>8,i&255]))}function M(e){let t=re(e);if(t)return{kind:"ipv4",addr:Uint8Array.from(t)};let r=e.includes(":")?Ke(e):null;return r?{kind:"ipv6",addr:r}:{kind:"domain",name:e}}var $=e=>new Error(`socks udp: ${e}`),Tr=Uint8Array.of(1,0,0,0,0,0,0);function F(e,t){let r=new Uint8Array(3+e.length+t.length);return r.set(e,3),r.set(t,3+e.length),r}function K(e){if(e.length<3)throw $(`too short (${e.length})`);if(e[0]!==0||e[1]!==0)throw $("reserved bytes must be 0");let t;try{t=N(e.subarray(3))}catch(r){throw $(r instanceof Error?r.message:String(r))}return{frag:e[2],target:t,data:e.subarray(3+t.length)}}function T(e,t){return Buffer.from([5,e,0,1,127,0,0,1,t>>8,t&255])}function k(e){return Buffer.from([5,e])}function E(e){return Buffer.from([5,e,0,1,0,0,0,0,0,0])}var O=new TextEncoder,q=new TextDecoder;var dn=O.encode(`0\r
3
3
  \r
4
4
  `);var yn=Buffer.from(`\r
package/explorer.main.mjs CHANGED
@@ -1,4 +1,4 @@
1
- globalThis.__PLANX_SERVICE_VERSION__="20.5.3";
1
+ globalThis.__PLANX_SERVICE_VERSION__="20.5.4";
2
2
  import*as j from"fs";import{dirname as Mt,join as Ft}from"path";function ae(e,t){let s=e[t];if(!s)throw new Error(`explorer child \u306E\u8D77\u52D5\u306B ${t} \u304C\u5FC5\u8981\u3067\u3059`);return s}function De(e=process.env){let t=Number(e.PLANX_EXPLORER_LEASE_MS??"");return{port:Number(e.PORT??0),portFile:e.PLANX_EXPLORER_PORT_FILE,pidFile:e.PLANX_EXPLORER_PID_FILE,sessionPortFile:ae(e,"PLANX_SESSION_PORT_FILE"),domainPortFile:e.PLANX_DOMAIN_PORT_FILE??Ft(Mt(ae(e,"PLANX_SESSION_PORT_FILE")),"domain.port"),filesystemPortFile:ae(e,"PLANX_FILESYSTEM_PORT_FILE"),...Number.isInteger(t)&&t>0?{leaseMs:t}:{}}}import{existsSync as Nt,readFileSync as Ut}from"fs";function C(e,t){if(!Nt(e))throw new Error(`${t} \u304C\u8D77\u52D5\u3057\u3066\u3044\u307E\u305B\u3093: ${e} \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093`);let s=Number(Ut(e,"utf-8").trim());if(!Number.isInteger(s)||s<=0)throw new Error(`${t} \u306E port file \u304C\u4E0D\u6B63\u3067\u3059: ${e}`);return s}import{readFileSync as je}from"fs";import{createHash as ke}from"crypto";var He=4,Me=250,Fe=e=>new Promise(t=>setTimeout(t,e)),k=class extends Error{constructor(s,r){super(s);this.status=r;this.name="DoRequestError"}};async function W(e,t){if(!e.ok)throw new k(`${t} \u306B\u5931\u6557\u3057\u307E\u3057\u305F (${e.status}): ${await e.text()}`,e.status)}async function ce(e,t,s,r){for(let n=1;;n+=1){let o=await fetch(e,t).catch(a=>a instanceof Error?a:new Error(String(a)));if(!(o instanceof Error||o.status>=500)||n===He){if(o instanceof Error)throw new Error(`${s} \u306B\u5931\u6557\u3057\u307E\u3057\u305F (${He} \u56DE\u8A66\u884C): ${o.message}`);return o}o instanceof Error||await o.text().catch(()=>{}),await r(Me*2**(n-1))}}var le=new Set;async function Ne(e){let t=e.sleep??Fe,s=je(e.bundlePath,"utf-8"),r=null;for(let n=1;n<=(e.attempts??30);n+=1)try{let o=e.deployUrl(),i=await fetch(o,{method:"POST",headers:e.headers,body:s});await W(i,"explorer plugin \u306E install"),le.add(`${o}
3
3
  ${ke("sha256").update(s).digest("hex")}`);return}catch(o){r=o,await t(Me*4)}throw r}function Ue(e,t={}){let s=t.sleep??Fe;return{async deploy(r){let n="explorer DO \u306E deploy";if(!e.deployUrl)throw new Error(`${n} \u306B\u5931\u6557\u3057\u307E\u3057\u305F: domain child \u306E port \u304C\u672A\u6307\u5B9A\u3067\u3059`);let o=je(r,"utf-8"),i=`${e.deployUrl}
4
4
  ${ke("sha256").update(o).digest("hex")}`;if(le.has(i)&&e.activateUrl){let c=await ce(e.activateUrl,{method:"POST"},n,s);if(c.status!==404)return W(c,n);await c.text().catch(()=>{})}let a=await ce(e.deployUrl,{method:"POST",headers:e.deployHeaders,body:o},n,s);await W(a,n),le.add(i)},async command(r,n){let o=`command ${r}`,i=await ce(`${e.baseUrl}/${r}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n)},o,s);return await W(i,o),await i.json()}}}function he(e){try{return new URL(e).pathname}catch{return""}}function G(e){let t=he(e);return t?t.endsWith("/")?t:t.slice(0,t.lastIndexOf("/")+1):""}var qt=new Set(["localhost","127.0.0.1"]);function Bt(e){return`${e.protocol}//${e.hostname}`}function Wt(e){let t=e.host,s=e.hostname;return t.length>s.length?t.slice(s.length):""}function qe(e,t){if(!t)return e;try{let s=new URL(e);return qt.has(s.hostname)?`${Bt(new URL(t))}${Wt(s)}${s.pathname}${s.search}`:e}catch{return e}}var Be=10,ue=`http://127.0.0.1:${Be}`,We="x-planx-session-id";function K(e){try{return new URL(e).port===String(Be)}catch{return!1}}function de(e,t){return!t||!e.startsWith(t)?e:ue+e.slice(t.length)}var Ge="explorer",Gt="x-planx-domain-name";function Ke(e,t){return{baseUrl:`http://127.0.0.1:${e.sessionPort}/sessions/${t}/api`,deployUrl:e.domainPort?`http://127.0.0.1:${e.domainPort}/domain/objects/deploy`:"",deployHeaders:{[We]:t,[Gt]:Ge},...e.domainPort?{activateUrl:`http://127.0.0.1:${e.domainPort}/domain/sessions/${t}/plugins/${Ge}`}:{}}}var v=e=>String(e??""),ze=e=>Array.isArray(e)?e.filter(t=>typeof t=="object"&&t!==null):[],Xe=(e,t)=>Number(e.ord??0)-Number(t.ord??0)||v(e.id).localeCompare(v(t.id));function Kt(e){return{url:v(e.url),name:v(e.name),type:v(e.type),size:e.size==null?null:Number(e.size),mtime:e.mtime==null?null:v(e.mtime)}}function zt(e,t){let s=v(e.id);return{id:s,location:v(e.location),locationEtag:v(e.location_etag),filter:v(e.filter),listingCollection:v(e.listing_collection),refreshRequestedAt:v(e.refresh_requested_at),refreshedAt:v(e.refreshed_at),entries:t.filter(r=>v(r.explorer_id)===s).sort(Xe).map(Kt)}}function Ve(e){let t=typeof e=="object"&&e!==null?e:{},s=ze(t.entries);return{agent:"connected",explorers:ze(t.explorers).sort(Xe).map(n=>zt(n,s))}}function Je(e){let t=e.replace(/\r\n/g,`
@@ -1,4 +1,4 @@
1
- globalThis.__PLANX_SERVICE_VERSION__="20.5.3";
1
+ globalThis.__PLANX_SERVICE_VERSION__="20.5.4";
2
2
  import*as h from"fs";import{statSync as Q}from"fs";import{createServer as _e}from"http";import{basename as Ae,join as Le}from"path";import{createHash as oe}from"crypto";import{readdirSync as te,statSync as D}from"fs";import{join as ne}from"path";function re(t){let e=D(t,{throwIfNoEntry:!1});return e?e.isDirectory()?"dir":"file":"symlink"}function E(t){return te(t).map(n=>{let i=ne(t,n),o=re(i),s=D(i,{throwIfNoEntry:!1});return{name:n,type:o,size:o==="dir"||!s?null:s.size,mtime:s?new Date(s.mtimeMs).toISOString():null}}).sort((n,i)=>n.type!==i.type?n.type==="dir"?-1:1:n.name.localeCompare(i.name))}var b=["index.html","index.htm"],N=["GET"];function R(t,e){let n=E(e).map(o=>({url:`${t}${encodeURIComponent(o.name)}${o.type==="dir"?"/":""}`,name:o.name,type:o.type,size:o.size,mtime:o.mtime,allow:N})),i=n.find(o=>o.type==="file"&&b.includes(o.name));return{collection:t,etag:ie(n),allow:N,index:i?.url??null,next:null,entries:n}}function _(t){let r=E(t).find(n=>n.type==="file"&&b.includes(n.name));return r?r.name:null}function ie(t){let e=t.map(r=>`${r.name}:${r.type}:${r.size??""}:${r.mtime??""}`).join(`
3
3
  `);return`"${oe("sha256").update(e).digest("hex").slice(0,16)}"`}function A(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function se(t,e){let r=encodeURIComponent(t);return e==="dir"?`${r}/`:r}function L(t){let e=A(new URL(t.collection).pathname),r=t.entries.map(n=>{let i=se(n.name,n.type),o=A(n.name)+(n.type==="dir"?"/":""),s=n.size===null?"":String(n.size);return`<li><a href="${i}">${o}</a> <span>${s}</span></li>`}).join(`
4
4
  `);return["<!doctype html>",'<meta charset="utf-8">',`<title>Index of ${e}</title>`,"<style>body{font:14px/1.6 monospace;padding:16px}ul{list-style:none;padding:0}","a{text-decoration:none}span{color:#888;margin-left:1em}</style>",`<h1>Index of ${e}</h1>`,"<ul>",'<li><a href="../">../</a></li>',r,"</ul>",""].join(`
package/llm.main.mjs CHANGED
@@ -1,4 +1,4 @@
1
- globalThis.__PLANX_SERVICE_VERSION__="20.5.3";
1
+ globalThis.__PLANX_SERVICE_VERSION__="20.5.4";
2
2
  import*as kr from"node:fs";import{join as ua}from"node:path";var er=["You condense the output of a coding-agent tool call so a stronger model can continue the task with fewer tokens.","Keep everything the next step may depend on: file paths, identifiers, error messages, numbers, exit status, final state.","Error messages, exit status and final state are always kept, whatever the instruction says.",'The "Recent instruction" is what the agent is trying to establish with this call: whatever directly answers it must be kept verbatim (code lines included); if the answer is that something is absent, state that absence explicitly; everything else may be folded aggressively.',"Extract only. Do not add interpretations, conclusions or advice that are not in the output.","The instruction is only a guide to what matters; never restate it, and never write about task progress, remaining steps or what the agent should do next, since none of that is in the output.","Write in the language of the tool output (usually English), not the language of the instruction.","Remove repetition, decoration, progress output and anything derivable from the retained lines.","Do not alter, reformat or paraphrase paths, identifiers, code lines or error text; copy them verbatim.",'Reply with the condensed text only, starting with "[llm]" on the first line. Be strictly shorter than the input.'].join(" ");function ro(e){let t=typeof e.toolInput=="string"?e.toolInput:JSON.stringify(e.toolInput??{}),r=e.instruction?`
3
3
  Recent instruction: ${e.instruction}`:"";return`Tool: ${e.toolName}
4
4
  Input: ${t}${r}
package/log.main.mjs CHANGED
@@ -1,4 +1,4 @@
1
- globalThis.__PLANX_SERVICE_VERSION__="20.5.3";
1
+ globalThis.__PLANX_SERVICE_VERSION__="20.5.4";
2
2
  import { createRequire } from 'module';
3
3
  const require = createRequire(import.meta.url);
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "planx",
3
- "version": "20.5.3",
3
+ "version": "20.5.4",
4
4
  "author": "Nozomu Miyamoto",
5
5
  "description": "planx \u2014 Angular DI \u30d9\u30fc\u30b9\u306e machina \u30bf\u30fc\u30df\u30ca\u30eb\u30de\u30eb\u30c1\u30d7\u30ec\u30af\u30b5 / \u30d4\u30a2\u30bb\u30c3\u30b7\u30e7\u30f3\u7ba1\u7406 CLI",
6
6
  "type": "module",
@@ -44,11 +44,11 @@
44
44
  "ws": "8.18.3"
45
45
  },
46
46
  "optionalDependencies": {
47
- "@planx.machina.at/tunnel-darwin-arm64": "20.5.3",
48
- "@planx.machina.at/tunnel-darwin-x64": "20.5.3",
49
- "@planx.machina.at/tunnel-linux-x64-gnu": "20.5.3",
50
- "@planx.machina.at/tunnel-linux-arm64-gnu": "20.5.3",
51
- "@planx.machina.at/tunnel-linux-x64-musl": "20.5.3"
47
+ "@planx.machina.at/tunnel-darwin-arm64": "20.5.4",
48
+ "@planx.machina.at/tunnel-darwin-x64": "20.5.4",
49
+ "@planx.machina.at/tunnel-linux-x64-gnu": "20.5.4",
50
+ "@planx.machina.at/tunnel-linux-arm64-gnu": "20.5.4",
51
+ "@planx.machina.at/tunnel-linux-x64-musl": "20.5.4"
52
52
  },
53
53
  "publishConfig": {
54
54
  "access": "public"