gemi 0.222.0 → 0.222.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/index.js +1 -1
- package/dist/bin/gemi.js +71 -54
- package/dist/bin/gemi.js.map +6 -5
- package/dist/chunk-9kdqdjdf.js +521 -0
- package/dist/{chunk-wcj7rjfe.js.map → chunk-9kdqdjdf.js.map} +3 -3
- package/dist/{chunk-3b68kpz1.js → chunk-dy01vy29.js} +1 -1
- package/dist/{chunk-140r27bn.js → chunk-ejvjn9tq.js} +1 -1
- package/dist/{chunk-4xgjg08e.js → chunk-nqjchwdj.js} +1 -1
- package/dist/{chunk-073j13t7.js → chunk-qvspq5tm.js} +1 -1
- package/dist/{chunk-tn8gkch4.js → chunk-t7ppe7gt.js} +1 -1
- package/dist/{chunk-7czgj8ae.js → chunk-y8dpexn0.js} +2 -2
- package/dist/{chunk-7czgj8ae.js.map → chunk-y8dpexn0.js.map} +1 -1
- package/dist/console/run.js +1 -1
- package/dist/kernel/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/queue/QueueManager.d.ts +43 -0
- package/dist/services/queue/QueueManager.d.ts.map +1 -1
- package/dist/services/queue/work.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-wcj7rjfe.js +0 -517
- /package/dist/{chunk-3b68kpz1.js.map → chunk-dy01vy29.js.map} +0 -0
- /package/dist/{chunk-140r27bn.js.map → chunk-ejvjn9tq.js.map} +0 -0
- /package/dist/{chunk-4xgjg08e.js.map → chunk-nqjchwdj.js.map} +0 -0
- /package/dist/{chunk-073j13t7.js.map → chunk-qvspq5tm.js.map} +0 -0
- /package/dist/{chunk-tn8gkch4.js.map → chunk-t7ppe7gt.js.map} +0 -0
package/dist/services/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{rb as J$}from"../chunk-g6tqje74.js";import{$b as t9,Ab as g4,Bb as s1,Cb as F9,Db as L9,Eb as v9,Ib as I9,Jb as f9,Kb as y9,Lb as A9,Mb as g9,Nb as m9,Ob as c9,Pb as u9,Qb as p9,Rb as d9,Sb as l9,Tb as n4,Ub as v6,Vb as h,Wb as n9,Xb as i9,Yb as s9,Zb as o9,_b as a9,ac as r9,bc as e9,cc as W$,dc as Z$,ec as $$,fc as Q$,gc as Y$,hc as K$,sb as z9,tb as G9,ub as X9,vb as B9,wb as j9,xb as u4,yb as M9,zb as E4}from"../chunk-140r27bn.js";import{kc as d4}from"../chunk-tn8gkch4.js";import"../chunk-kp7wcpx7.js";import{be as D9,ce as H9,de as N9,ee as U9,fe as x9,ge as R9,he as O9,ie as _9,je as V9,ke as k9,le as C9,me as T9,ne as P9,oe as b9,pe as w9,qe as q9}from"../chunk-3b68kpz1.js";import{re as S9}from"../chunk-7xe5vd4w.js";import{Ae as oZ,Be as aZ,Ce as tZ,De as rZ,Ee as eZ,Fe as W9,Ge as Z9,He as $9,Ie as Q9,Je as Y9,Ke as K9,Pe as J9,se as cZ,te as uZ,ue as pZ,ve as dZ,we as lZ,xe as nZ,ye as iZ,ze as sZ}from"../chunk-wcj7rjfe.js";import{Qe as h9,Re as E9}from"../chunk-vcw98sp6.js";import"../chunk-qy0k2s5f.js";import{$e as W8,Af as Y6,Ag as DZ,Ah as yZ,Bf as M8,Bg as HZ,Bh as AZ,Cf as F8,Cg as NZ,Df as L8,Dg as UZ,Ef as D8,Ff as H8,Ig as R,Jg as i,Kg as xZ,Lg as SZ,Mg as RZ,Ng as OZ,Og as _Z,Qg as VZ,Rg as kZ,Sg as CZ,Tg as TZ,Uf as T8,Vf as P8,Vg as PZ,Wf as b8,Xf as w8,Yf as q8,Yg as bZ,Ze as V6,Zf as v8,Zg as wZ,_e as e5,_g as qZ,af as Z8,bh as vZ,cf as $8,eg as e8,fg as q6,gf as k6,gg as WZ,gh as IZ,hf as C4,if as B6,jf as T4,kf as P4,kg as ZZ,kh as fZ,lg as $Z,mg as YZ,of as f6,oh as i4,pf as y6,pg as KZ,ph as z1,qg as JZ,rf as Q8,rg as zZ,sf as Y8,sg as GZ,tf as K8,uf as J8,ug as XZ,vf as z8,vg as BZ,wf as G8,wg as jZ,xf as X8,xg as MZ,yf as B8,yg as FZ,zf as j8,zg as LZ}from"../chunk-bs4p7dys.js";import"../chunk-j9abwrkv.js";import"../chunk-4v5nwqw6.js";import{$i as U8,Ni as h4,Ri as j1,Ti as Y1,Xi as _4,Yi as C1,Zi as p1,_i as N8,aj as x8,bj as S8,cj as R8,oj as mW,pj as cW,sj as O8,ti as k4,tj as _8,ui as O4,vi as k1,vj as V8,wj as k8,xj as C8,zj as d1}from"../chunk-8gnbc9dg.js";import"../chunk-h1wmpa03.js";import{Fj as q}from"../chunk-t586p2g2.js";import"../chunk-qs2xvc8g.js";import{Rj as g8,Sj as m8,Tj as U,Uj as c8,Vj as b,Wj as u8,Xj as p8}from"../chunk-2y0nr525.js";import{bk as A8,ck as h8,dk as E8}from"../chunk-p4v71qfx.js";import"../chunk-anc5v266.js";import{Mk as QZ}from"../chunk-wy82t7mz.js";import{$k as a8,Ok as I8,Pk as f8,Qk as y8,Rk as d8,Sk as l8,Tk as n8,Uk as i8,Vk as s8,Wk as o8,al as t8,bl as r8}from"../chunk-tac25cnj.js";import"../chunk-0k2r6bep.js";import"../chunk-0av1gyns.js";import"../chunk-zmt5kdpb.js";import"../chunk-rat2827k.js";import{$l as gZ,Yl as w4,Zl as hZ,_l as EZ,bm as mZ}from"../chunk-t8ygf6zj.js";import"../chunk-yj7pbbnm.js";import{lm as C}from"../chunk-37209psn.js";import"../chunk-fqhkkpq3.js";import"../chunk-swmf6w3z.js";import"../chunk-6r7956dh.js";import"../chunk-5mrtgr7q.js";import"../chunk-55btq9c7.js";import{Qm as u1}from"../chunk-3dkv4989.js";import{Buffer as K6}from"buffer";class J6 extends C1{client;config;constructor(...W){super();this.config=W}async connect(){let W=await import("../chunk-nqgeny8m.js");return this.client??=new W.S3Client(...this.config),{sdk:W,client:this.client}}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,Q,Y,K=process.env.BUCKET_NAME;if(W instanceof Blob)$=W,Y=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Q=W.type;else $=W.body,Y=W.name,K=W.bucket??K,Q=W.contentType||($ instanceof Blob||$ instanceof File?$.type:void 0);Q=Q||void 0;let J=$ instanceof K6?$:$ instanceof Blob||$ instanceof File?K6.from(await $.arrayBuffer()):"",{sdk:z,client:G}=await this.connect();return Z?.throwIfAborted(),await G.send(new z.PutObjectCommand({Bucket:K,Key:Y,Body:J,ContentType:Q}),{abortSignal:Z}),Y}async delete(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME;if(!Z)throw Error("Object name has to be specified");let{sdk:Q,client:Y}=await this.connect();try{await Y.send(new Q.DeleteObjectCommand({Bucket:$,Key:Z}))}catch(K){if(K?.name==="NoSuchKey"||K?.$metadata?.httpStatusCode===404)return;throw K}}async*pages(W,{bucket:Z,signal:$}){let{sdk:Q,client:Y}=await this.connect(),K;do{$?.throwIfAborted();let J=await Y.send(new Q.ListObjectsV2Command({Bucket:Z??process.env.BUCKET_NAME,Prefix:W,ContinuationToken:K}),{abortSignal:$});yield(J.Contents??[]).map((z)=>({name:z.Key,size:z.Size??0,lastModified:z.LastModified??new Date(0)})),K=J.IsTruncated?J.NextContinuationToken:void 0}while(K)}async*objects(W,Z={}){for await(let $ of this.pages(W,Z))yield*$}async deletePrefix(W,Z={}){_4(W);let $=Z.bucket??process.env.BUCKET_NAME,{sdk:Q,client:Y}=await this.connect(),K=0;for await(let J of this.pages(W,{...Z,bucket:$})){if(J.length===0)continue;Z.signal?.throwIfAborted();let G=(await Y.send(new Q.DeleteObjectsCommand({Bucket:$,Delete:{Objects:J.map((X)=>({Key:X.name})),Quiet:!0}}),{abortSignal:Z.signal}))?.Errors??[];if(G.length>0){let X=G[0];throw Error(`S3 could not delete ${G.length} object(s) under "${W}", e.g. "${X.Key}": ${X.Code??"unknown"} ${X.Message??""}`.trim())}K+=J.length}return K}async list(W){let{sdk:Z,client:$}=await this.connect();return await $.send(new Z.ListObjectsV2Command({Bucket:process.env.BUCKET_NAME,Prefix:W}))}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=process.env.BUCKET_NAME,Q;if(typeof W==="string")Q=W;else $=W.bucket??$,Q=W.name;if(!Q)throw Error("Object name has to be specified");let{sdk:Y,client:K}=await this.connect();Z?.throwIfAborted();let J=await K.send(new Y.GetObjectCommand({Bucket:$,Key:Q}),{abortSignal:Z}),z=p1(J.Body.transformToWebStream(),Z);return Z?.throwIfAborted(),new Response(z,{headers:{"Content-Type":J.ContentType,"Content-Length":J.ContentLength.toString(),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":J.LastModified?.toUTCString()||"",ETag:J.ETag||""}})}async read(W){let Z=typeof W==="string"?{name:W}:W,$=Z.bucket??process.env.BUCKET_NAME,{name:Q,range:Y=null}=Z;if(!Q)throw Error("Object name has to be specified");let{sdk:K,client:J}=await this.connect(),z;try{z=await J.send(new K.GetObjectCommand({Bucket:$,Key:Q,Range:Y?O4(Y):void 0}))}catch(j){if(j?.name==="InvalidRange"||j?.$metadata?.httpStatusCode===416)throw new j1(await this.size({name:Q,bucket:$}));if(j?.name==="NoSuchKey"||j?.$metadata?.httpStatusCode===404)throw new Y1(Q);throw j}let G=k1(z.ContentRange),X=Boolean(G)&&z.$metadata?.httpStatusCode===206,B=G?.total??z.ContentLength??0;return{body:z.Body.transformToWebStream(),start:G?.start??0,end:G?.end??B-1,total:B,partial:X,type:z.ContentType??"application/octet-stream",etag:z.ETag||void 0,lastModified:z.LastModified,name:Q}}async size(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME,{sdk:Q,client:Y}=await this.connect();try{return(await Y.send(new Q.HeadObjectCommand({Bucket:$,Key:Z}))).ContentLength??0}catch(K){if(K?.name==="NotFound"||K?.$metadata?.httpStatusCode===404)throw new Y1(Z);throw K}}}import{Buffer as z6}from"buffer";import{Readable as dW}from"stream";function V4(W){return W?.statusCode===404||W?.details?.errorCode==="BlobNotFound"||W?.code==="BlobNotFound"}function lW(W){return W?.statusCode===416||W?.details?.errorCode==="InvalidRange"||W?.code==="InvalidRange"}class G6 extends C1{config;serviceClientPromise=null;constructor(W={}){super();this.config=W}async serviceClient(){if(this.config.serviceClient)return this.config.serviceClient;return this.serviceClientPromise??=(async()=>{let W;try{W=await import("@azure/storage-blob")}catch{throw Error("AzureBlobDriver requires the '@azure/storage-blob' package. Install it with `bun add @azure/storage-blob`, or pass a pre-built `serviceClient`.")}let Z=this.config.connectionString??process.env.AZURE_STORAGE_CONNECTION_STRING;if(this.config.url)return new W.BlobServiceClient(this.config.url,this.config.credential);if(Z)return W.BlobServiceClient.fromConnectionString(Z);throw Error("AzureBlobDriver needs a connection string (AZURE_STORAGE_CONNECTION_STRING), a `url`, or a `serviceClient`.")})(),this.serviceClientPromise}async blob(W,Z){if(!W)throw Error("Object name has to be specified");let $=Z??this.config.container??process.env.BUCKET_NAME;if(!$)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");return(await this.serviceClient()).getContainerClient($).getBlockBlobClient(W)}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,Q,Y,K;if(W instanceof Blob)$=W,Y=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Q=W.type;else $=W.body,Y=W.name,K=W.bucket,Q=W.contentType??($ instanceof Blob||$ instanceof File?$.type:void 0);let J=$ instanceof z6?$:z6.from(await $.arrayBuffer()),z=await this.blob(Y,K);return Z?.throwIfAborted(),await z.uploadData(J,{blobHTTPHeaders:Q?{blobContentType:Q}:void 0,abortSignal:Z}),Y}async*objects(W,{bucket:Z,signal:$}={}){$?.throwIfAborted();let Q=Z??this.config.container??process.env.BUCKET_NAME;if(!Q)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");let K=(await this.serviceClient()).getContainerClient(Q);for await(let J of K.listBlobsFlat({prefix:W}))$?.throwIfAborted(),yield{name:J.name,size:J.properties?.contentLength??0,lastModified:J.properties?.lastModified??new Date(0)}}async list(W){let Z=this.config.container??process.env.BUCKET_NAME,Q=(await this.serviceClient()).getContainerClient(Z),Y=[];for await(let K of Q.listBlobsFlat({prefix:W}))Y.push(K.name);return Y}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=await this.download(typeof W==="string"?{name:W}:{name:W.name,bucket:W.bucket},Z);return new Response($.body,{headers:{"Content-Type":$.type,"Content-Length":String($.total),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":$.lastModified?.toUTCString()??"",ETag:$.etag??""}})}async read(W){return this.download(typeof W==="string"?{name:W}:W)}async download(W,Z){let{name:$,bucket:Q,range:Y=null}=W,K=await this.blob($,Q);Z?.throwIfAborted();let J,z,G=Y?.kind==="suffix"||Y?.kind==="offset"&&Y.end===null&&Y.start===0;if(Y&&G){let V=await this.size({name:$,bucket:Q}),Q1=k4(Y,V);if(!Q1)throw new j1(V);J=Q1.start,z=Q1.length}else if(Y?.kind==="offset")J=Y.start,z=Y.end===null?void 0:Y.end-Y.start+1;let X;try{X=await K.download(J,z,Z?{abortSignal:Z}:void 0)}catch(V){if(lW(V))throw new j1(await this.size({name:$,bucket:Q}));if(V4(V))throw new Y1($);throw V}let B=k1(X.contentRange),j=Boolean(B),D=B?.total??X.contentLength??0,x=await nW(X);if(x instanceof ReadableStream)x=p1(x,Z);return Z?.throwIfAborted(),{body:x,start:B?.start??0,end:B?.end??D-1,total:D,partial:j,type:X.contentType??"application/octet-stream",etag:X.etag||void 0,lastModified:X.lastModified,name:$}}async size(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,Q=await this.blob(Z,$);try{return(await Q.getProperties()).contentLength??0}catch(Y){if(V4(Y))throw new Y1(Z);throw Y}}async delete(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,Q=await this.blob(Z,$);try{await Q.delete()}catch(Y){if(V4(Y))return;throw Y}}}async function nW(W){if(W.blobBody)return await W.blobBody;if(W.readableStreamBody)return dW.toWeb(W.readableStreamBody);return null}function iW(W){return W}class b4 extends Error{code="ERR_RATE_LIMITER_TIMEOUT";constructor(W){super(`RedisRateLimiter: Redis did not answer within ${W}ms.`);this.name="RedisRateLimiterTimeoutError"}}class l1 extends Error{code="ERR_RATE_LIMITER_DISCONNECTED";constructor(){super("RedisRateLimiter: the Redis client is not connected.");this.name="RedisRateLimiterDisconnectedError"}}var X6=1000,sW=60000,oW=`
|
|
2
|
+
import{rb as J$}from"../chunk-g6tqje74.js";import{$b as t9,Ab as g4,Bb as s1,Cb as F9,Db as L9,Eb as v9,Ib as I9,Jb as f9,Kb as y9,Lb as A9,Mb as g9,Nb as m9,Ob as c9,Pb as u9,Qb as p9,Rb as d9,Sb as l9,Tb as n4,Ub as v6,Vb as h,Wb as n9,Xb as i9,Yb as s9,Zb as o9,_b as a9,ac as r9,bc as e9,cc as W$,dc as Z$,ec as $$,fc as Q$,gc as Y$,hc as K$,sb as z9,tb as G9,ub as X9,vb as B9,wb as j9,xb as u4,yb as M9,zb as E4}from"../chunk-ejvjn9tq.js";import{kc as d4}from"../chunk-t7ppe7gt.js";import"../chunk-kp7wcpx7.js";import{be as D9,ce as H9,de as N9,ee as U9,fe as x9,ge as R9,he as O9,ie as _9,je as V9,ke as k9,le as C9,me as T9,ne as P9,oe as b9,pe as w9,qe as q9}from"../chunk-dy01vy29.js";import{re as S9}from"../chunk-7xe5vd4w.js";import{Ae as oZ,Be as aZ,Ce as tZ,De as rZ,Ee as eZ,Fe as W9,Ge as Z9,He as $9,Ie as Q9,Je as Y9,Ke as K9,Pe as J9,se as cZ,te as uZ,ue as pZ,ve as dZ,we as lZ,xe as nZ,ye as iZ,ze as sZ}from"../chunk-9kdqdjdf.js";import{Qe as h9,Re as E9}from"../chunk-vcw98sp6.js";import"../chunk-qy0k2s5f.js";import{$e as W8,Af as Y6,Ag as DZ,Ah as yZ,Bf as M8,Bg as HZ,Bh as AZ,Cf as F8,Cg as NZ,Df as L8,Dg as UZ,Ef as D8,Ff as H8,Ig as R,Jg as i,Kg as xZ,Lg as SZ,Mg as RZ,Ng as OZ,Og as _Z,Qg as VZ,Rg as kZ,Sg as CZ,Tg as TZ,Uf as T8,Vf as P8,Vg as PZ,Wf as b8,Xf as w8,Yf as q8,Yg as bZ,Ze as V6,Zf as v8,Zg as wZ,_e as e5,_g as qZ,af as Z8,bh as vZ,cf as $8,eg as e8,fg as q6,gf as k6,gg as WZ,gh as IZ,hf as C4,if as B6,jf as T4,kf as P4,kg as ZZ,kh as fZ,lg as $Z,mg as YZ,of as f6,oh as i4,pf as y6,pg as KZ,ph as z1,qg as JZ,rf as Q8,rg as zZ,sf as Y8,sg as GZ,tf as K8,uf as J8,ug as XZ,vf as z8,vg as BZ,wf as G8,wg as jZ,xf as X8,xg as MZ,yf as B8,yg as FZ,zf as j8,zg as LZ}from"../chunk-bs4p7dys.js";import"../chunk-j9abwrkv.js";import"../chunk-4v5nwqw6.js";import{$i as U8,Ni as h4,Ri as j1,Ti as Y1,Xi as _4,Yi as C1,Zi as p1,_i as N8,aj as x8,bj as S8,cj as R8,oj as mW,pj as cW,sj as O8,ti as k4,tj as _8,ui as O4,vi as k1,vj as V8,wj as k8,xj as C8,zj as d1}from"../chunk-8gnbc9dg.js";import"../chunk-h1wmpa03.js";import{Fj as q}from"../chunk-t586p2g2.js";import"../chunk-qs2xvc8g.js";import{Rj as g8,Sj as m8,Tj as U,Uj as c8,Vj as b,Wj as u8,Xj as p8}from"../chunk-2y0nr525.js";import{bk as A8,ck as h8,dk as E8}from"../chunk-p4v71qfx.js";import"../chunk-anc5v266.js";import{Mk as QZ}from"../chunk-wy82t7mz.js";import{$k as a8,Ok as I8,Pk as f8,Qk as y8,Rk as d8,Sk as l8,Tk as n8,Uk as i8,Vk as s8,Wk as o8,al as t8,bl as r8}from"../chunk-tac25cnj.js";import"../chunk-0k2r6bep.js";import"../chunk-0av1gyns.js";import"../chunk-zmt5kdpb.js";import"../chunk-rat2827k.js";import{$l as gZ,Yl as w4,Zl as hZ,_l as EZ,bm as mZ}from"../chunk-t8ygf6zj.js";import"../chunk-yj7pbbnm.js";import{lm as C}from"../chunk-37209psn.js";import"../chunk-fqhkkpq3.js";import"../chunk-swmf6w3z.js";import"../chunk-6r7956dh.js";import"../chunk-5mrtgr7q.js";import"../chunk-55btq9c7.js";import{Qm as u1}from"../chunk-3dkv4989.js";import{Buffer as K6}from"buffer";class J6 extends C1{client;config;constructor(...W){super();this.config=W}async connect(){let W=await import("../chunk-nqgeny8m.js");return this.client??=new W.S3Client(...this.config),{sdk:W,client:this.client}}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,Q,Y,K=process.env.BUCKET_NAME;if(W instanceof Blob)$=W,Y=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Q=W.type;else $=W.body,Y=W.name,K=W.bucket??K,Q=W.contentType||($ instanceof Blob||$ instanceof File?$.type:void 0);Q=Q||void 0;let J=$ instanceof K6?$:$ instanceof Blob||$ instanceof File?K6.from(await $.arrayBuffer()):"",{sdk:z,client:G}=await this.connect();return Z?.throwIfAborted(),await G.send(new z.PutObjectCommand({Bucket:K,Key:Y,Body:J,ContentType:Q}),{abortSignal:Z}),Y}async delete(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME;if(!Z)throw Error("Object name has to be specified");let{sdk:Q,client:Y}=await this.connect();try{await Y.send(new Q.DeleteObjectCommand({Bucket:$,Key:Z}))}catch(K){if(K?.name==="NoSuchKey"||K?.$metadata?.httpStatusCode===404)return;throw K}}async*pages(W,{bucket:Z,signal:$}){let{sdk:Q,client:Y}=await this.connect(),K;do{$?.throwIfAborted();let J=await Y.send(new Q.ListObjectsV2Command({Bucket:Z??process.env.BUCKET_NAME,Prefix:W,ContinuationToken:K}),{abortSignal:$});yield(J.Contents??[]).map((z)=>({name:z.Key,size:z.Size??0,lastModified:z.LastModified??new Date(0)})),K=J.IsTruncated?J.NextContinuationToken:void 0}while(K)}async*objects(W,Z={}){for await(let $ of this.pages(W,Z))yield*$}async deletePrefix(W,Z={}){_4(W);let $=Z.bucket??process.env.BUCKET_NAME,{sdk:Q,client:Y}=await this.connect(),K=0;for await(let J of this.pages(W,{...Z,bucket:$})){if(J.length===0)continue;Z.signal?.throwIfAborted();let G=(await Y.send(new Q.DeleteObjectsCommand({Bucket:$,Delete:{Objects:J.map((X)=>({Key:X.name})),Quiet:!0}}),{abortSignal:Z.signal}))?.Errors??[];if(G.length>0){let X=G[0];throw Error(`S3 could not delete ${G.length} object(s) under "${W}", e.g. "${X.Key}": ${X.Code??"unknown"} ${X.Message??""}`.trim())}K+=J.length}return K}async list(W){let{sdk:Z,client:$}=await this.connect();return await $.send(new Z.ListObjectsV2Command({Bucket:process.env.BUCKET_NAME,Prefix:W}))}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=process.env.BUCKET_NAME,Q;if(typeof W==="string")Q=W;else $=W.bucket??$,Q=W.name;if(!Q)throw Error("Object name has to be specified");let{sdk:Y,client:K}=await this.connect();Z?.throwIfAborted();let J=await K.send(new Y.GetObjectCommand({Bucket:$,Key:Q}),{abortSignal:Z}),z=p1(J.Body.transformToWebStream(),Z);return Z?.throwIfAborted(),new Response(z,{headers:{"Content-Type":J.ContentType,"Content-Length":J.ContentLength.toString(),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":J.LastModified?.toUTCString()||"",ETag:J.ETag||""}})}async read(W){let Z=typeof W==="string"?{name:W}:W,$=Z.bucket??process.env.BUCKET_NAME,{name:Q,range:Y=null}=Z;if(!Q)throw Error("Object name has to be specified");let{sdk:K,client:J}=await this.connect(),z;try{z=await J.send(new K.GetObjectCommand({Bucket:$,Key:Q,Range:Y?O4(Y):void 0}))}catch(j){if(j?.name==="InvalidRange"||j?.$metadata?.httpStatusCode===416)throw new j1(await this.size({name:Q,bucket:$}));if(j?.name==="NoSuchKey"||j?.$metadata?.httpStatusCode===404)throw new Y1(Q);throw j}let G=k1(z.ContentRange),X=Boolean(G)&&z.$metadata?.httpStatusCode===206,B=G?.total??z.ContentLength??0;return{body:z.Body.transformToWebStream(),start:G?.start??0,end:G?.end??B-1,total:B,partial:X,type:z.ContentType??"application/octet-stream",etag:z.ETag||void 0,lastModified:z.LastModified,name:Q}}async size(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME,{sdk:Q,client:Y}=await this.connect();try{return(await Y.send(new Q.HeadObjectCommand({Bucket:$,Key:Z}))).ContentLength??0}catch(K){if(K?.name==="NotFound"||K?.$metadata?.httpStatusCode===404)throw new Y1(Z);throw K}}}import{Buffer as z6}from"buffer";import{Readable as dW}from"stream";function V4(W){return W?.statusCode===404||W?.details?.errorCode==="BlobNotFound"||W?.code==="BlobNotFound"}function lW(W){return W?.statusCode===416||W?.details?.errorCode==="InvalidRange"||W?.code==="InvalidRange"}class G6 extends C1{config;serviceClientPromise=null;constructor(W={}){super();this.config=W}async serviceClient(){if(this.config.serviceClient)return this.config.serviceClient;return this.serviceClientPromise??=(async()=>{let W;try{W=await import("@azure/storage-blob")}catch{throw Error("AzureBlobDriver requires the '@azure/storage-blob' package. Install it with `bun add @azure/storage-blob`, or pass a pre-built `serviceClient`.")}let Z=this.config.connectionString??process.env.AZURE_STORAGE_CONNECTION_STRING;if(this.config.url)return new W.BlobServiceClient(this.config.url,this.config.credential);if(Z)return W.BlobServiceClient.fromConnectionString(Z);throw Error("AzureBlobDriver needs a connection string (AZURE_STORAGE_CONNECTION_STRING), a `url`, or a `serviceClient`.")})(),this.serviceClientPromise}async blob(W,Z){if(!W)throw Error("Object name has to be specified");let $=Z??this.config.container??process.env.BUCKET_NAME;if(!$)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");return(await this.serviceClient()).getContainerClient($).getBlockBlobClient(W)}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,Q,Y,K;if(W instanceof Blob)$=W,Y=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Q=W.type;else $=W.body,Y=W.name,K=W.bucket,Q=W.contentType??($ instanceof Blob||$ instanceof File?$.type:void 0);let J=$ instanceof z6?$:z6.from(await $.arrayBuffer()),z=await this.blob(Y,K);return Z?.throwIfAborted(),await z.uploadData(J,{blobHTTPHeaders:Q?{blobContentType:Q}:void 0,abortSignal:Z}),Y}async*objects(W,{bucket:Z,signal:$}={}){$?.throwIfAborted();let Q=Z??this.config.container??process.env.BUCKET_NAME;if(!Q)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");let K=(await this.serviceClient()).getContainerClient(Q);for await(let J of K.listBlobsFlat({prefix:W}))$?.throwIfAborted(),yield{name:J.name,size:J.properties?.contentLength??0,lastModified:J.properties?.lastModified??new Date(0)}}async list(W){let Z=this.config.container??process.env.BUCKET_NAME,Q=(await this.serviceClient()).getContainerClient(Z),Y=[];for await(let K of Q.listBlobsFlat({prefix:W}))Y.push(K.name);return Y}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=await this.download(typeof W==="string"?{name:W}:{name:W.name,bucket:W.bucket},Z);return new Response($.body,{headers:{"Content-Type":$.type,"Content-Length":String($.total),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":$.lastModified?.toUTCString()??"",ETag:$.etag??""}})}async read(W){return this.download(typeof W==="string"?{name:W}:W)}async download(W,Z){let{name:$,bucket:Q,range:Y=null}=W,K=await this.blob($,Q);Z?.throwIfAborted();let J,z,G=Y?.kind==="suffix"||Y?.kind==="offset"&&Y.end===null&&Y.start===0;if(Y&&G){let V=await this.size({name:$,bucket:Q}),Q1=k4(Y,V);if(!Q1)throw new j1(V);J=Q1.start,z=Q1.length}else if(Y?.kind==="offset")J=Y.start,z=Y.end===null?void 0:Y.end-Y.start+1;let X;try{X=await K.download(J,z,Z?{abortSignal:Z}:void 0)}catch(V){if(lW(V))throw new j1(await this.size({name:$,bucket:Q}));if(V4(V))throw new Y1($);throw V}let B=k1(X.contentRange),j=Boolean(B),D=B?.total??X.contentLength??0,x=await nW(X);if(x instanceof ReadableStream)x=p1(x,Z);return Z?.throwIfAborted(),{body:x,start:B?.start??0,end:B?.end??D-1,total:D,partial:j,type:X.contentType??"application/octet-stream",etag:X.etag||void 0,lastModified:X.lastModified,name:$}}async size(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,Q=await this.blob(Z,$);try{return(await Q.getProperties()).contentLength??0}catch(Y){if(V4(Y))throw new Y1(Z);throw Y}}async delete(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,Q=await this.blob(Z,$);try{await Q.delete()}catch(Y){if(V4(Y))return;throw Y}}}async function nW(W){if(W.blobBody)return await W.blobBody;if(W.readableStreamBody)return dW.toWeb(W.readableStreamBody);return null}function iW(W){return W}class b4 extends Error{code="ERR_RATE_LIMITER_TIMEOUT";constructor(W){super(`RedisRateLimiter: Redis did not answer within ${W}ms.`);this.name="RedisRateLimiterTimeoutError"}}class l1 extends Error{code="ERR_RATE_LIMITER_DISCONNECTED";constructor(){super("RedisRateLimiter: the Redis client is not connected.");this.name="RedisRateLimiterDisconnectedError"}}var X6=1000,sW=60000,oW=`
|
|
3
3
|
local currentKey = KEYS[1]
|
|
4
4
|
local previousKey = KEYS[2]
|
|
5
5
|
local limit = tonumber(ARGV[1])
|
|
@@ -8,6 +8,42 @@ import { backoffFor } from "./backoff";
|
|
|
8
8
|
import type { WorkflowClass } from "./workflow/Workflow";
|
|
9
9
|
import { WorkflowRuntime } from "./workflow/WorkflowRuntime";
|
|
10
10
|
export { backoffFor };
|
|
11
|
+
/**
|
|
12
|
+
* The thread a `worker = true` job runs in.
|
|
13
|
+
*
|
|
14
|
+
* The `await` on `dispatchJob` is load-bearing and its absence was a hang.
|
|
15
|
+
* `postMessage` structured-clones its argument and a Promise is not cloneable,
|
|
16
|
+
* so an un-awaited `dispatchJob` posted the pending promise, threw
|
|
17
|
+
* `DataCloneError` inside this handler, and posted nothing at all. `runInWorker`
|
|
18
|
+
* then never settled: `run` below never returned, its concurrency slot was
|
|
19
|
+
* never decremented, and neither the retry path nor `onDeadletter` ever fired —
|
|
20
|
+
* after `concurrency` such jobs the queue sits at its limit forever, with no
|
|
21
|
+
* error anywhere. Any job whose `run` is `async` hit it, which is every job
|
|
22
|
+
* that touches IO; a queued listener hits it unconditionally, because the
|
|
23
|
+
* synthetic job's `run` awaits `handle`.
|
|
24
|
+
*
|
|
25
|
+
* The await earns two more things. A rejecting job now reaches the `catch` and
|
|
26
|
+
* comes back as `{error}`, where the queue's ordinary retry-then-dead-letter
|
|
27
|
+
* path can have it, instead of being lost with the promise. And `destroy()` now
|
|
28
|
+
* runs after the job rather than under it, so the cloned kernel — its database
|
|
29
|
+
* connections included — outlives the work it was cloned for.
|
|
30
|
+
*
|
|
31
|
+
* ### Where the thread finds the application (#1318)
|
|
32
|
+
*
|
|
33
|
+
* The thread boots its own copy of the application. It used to import it from
|
|
34
|
+
* `app/bootstrap.ts` (`dist/server/bootstrap.mjs` in production), a file no
|
|
35
|
+
* template has and no build had emitted since the server moved to `Bun.build`,
|
|
36
|
+
* so the import failed inside the thread and the job hung. Now an app's own
|
|
37
|
+
* bootstrap is used when it exists, and otherwise the thread does what
|
|
38
|
+
* `gemi queue:work` does: `new App({ kernel })` from `app/kernel/Kernel.ts`,
|
|
39
|
+
* with `App` resolved from the application's own gemi, the copy its kernel
|
|
40
|
+
* extends.
|
|
41
|
+
*/
|
|
42
|
+
export declare function workerEntry(env?: Record<string, string | undefined>): {
|
|
43
|
+
bootstrap: string | undefined;
|
|
44
|
+
kernel: string;
|
|
45
|
+
app: string;
|
|
46
|
+
};
|
|
11
47
|
declare global {
|
|
12
48
|
/**
|
|
13
49
|
* The queue loop a `gemi dev` server is running over a driver that outlives
|
|
@@ -185,6 +221,13 @@ export declare class QueueManager {
|
|
|
185
221
|
* tidied away. A copy, so that walk cannot edit the registry underneath it.
|
|
186
222
|
*/
|
|
187
223
|
get registeredJobs(): ReadonlyArray<new () => Job>;
|
|
224
|
+
/**
|
|
225
|
+
* Runs a job's `run` here and now, with no queue around it: what a
|
|
226
|
+
* `worker = true` job's thread calls. Throws for a name nothing is
|
|
227
|
+
* registered under, which in a thread means it booted a different build of
|
|
228
|
+
* the application; returning `undefined` there reported success for work
|
|
229
|
+
* that never ran.
|
|
230
|
+
*/
|
|
188
231
|
dispatchJob(jobName: string, args: string): any;
|
|
189
232
|
/**
|
|
190
233
|
* Queues a job and resolves to its id once the driver has recorded it, then
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueueManager.d.ts","sourceRoot":"","sources":["../../../services/queue/QueueManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"QueueManager.d.ts","sourceRoot":"","sources":["../../../services/queue/QueueManager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAMhE,OAAO,EAAiB,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIjE,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAEjE,OAAO,KAAK,EAAgB,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACzF,OAAO,KAAK,EAAkB,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB;;;;;;;;;;;;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E;IAC7E,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC;IAI5B,uDAAuD;IACvD,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED;;;;;;;;;;OAUG;YACW,IAAI;YASJ,iBAAiB;IAmD/B;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,KAAK;IAoBb,0EAA0E;IAC1E,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,IAAI;IAOZ;;;OAGG;IACH,IAAI,OAAO,YAEV;IAED,qEAAqE;IACrE,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,OAAO;IAwBf;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAoBjB;;;;;;;OAOG;YACW,GAAG;IAoNjB,yEAAyE;IACzE,OAAO,CAAC,WAAW;IAanB;;;;;;;;;;OAUG;YACW,KAAK;CAiDpB;AAmBD;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,YAIlC;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,WAEtF;AAQD,mFAAmF;AACnF,wBAAgB,eAAe,CAAC,MAAM,UAAO,QAE5C;AAED,wBAAgB,aAAa,IAAI,OAAO,CAEvC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ke as J,Ne as A}from"../../chunk-
|
|
2
|
+
import{Ke as J,Ne as A}from"../../chunk-9kdqdjdf.js";import{Mk as V}from"../../chunk-wy82t7mz.js";import"../../chunk-tac25cnj.js";import"../../chunk-0k2r6bep.js";import"../../chunk-0av1gyns.js";import"../../chunk-zmt5kdpb.js";import"../../chunk-37209psn.js";import"../../chunk-fqhkkpq3.js";import{Am as _,Em as I,vm as Y,ym as N,zm as Z}from"../../chunk-6r7956dh.js";import{Im as x}from"../../chunk-5mrtgr7q.js";import"../../chunk-3dkv4989.js";import $ from"path";function X(z){if(!z.config.get("route.channels"))return null;let C=z.config.get("broadcast",{}).driver;if(!(C===void 0||C==="memory"||C instanceof V))return null;return'[gemi] Broadcasts from this worker reach no one: the broadcast driver is "memory", which delivers to the sockets of the process that emits, and a worker has none. Set `driver: "redis"` in app/config/broadcast.ts.'}class L extends Error{name="QueueWorkerRefused"}class O{kernel;stopping;keepAlive;settings;constructor(z,C={}){this.kernel=z;this.settings={..._(),...C}}async start(){if(await this.kernel.waitForBoot(),this.stopping)return;let z=this.kernel.app;if(!z.bound(J))throw new L("[gemi] `gemi queue:work` has no queue to claim from: this application does not register QueueServiceProvider.");let C=z.make(J);if(!C.durable)throw new L('[gemi] `gemi queue:work` refuses to start: the queue uses the memory driver, which keeps each job in the process that dispatched it, so a worker never sees one. Set `driver: "database"` (or another driver every process can reach) in app/config/queue.ts, or run jobs in the server and drop the worker.');C.start(),this.keepAlive=setInterval(()=>{},1073741824),console.log(`[gemi] Queue worker started: claiming up to ${C.config.concurrency} job(s) at a time.`);let E=X(z);if(E)console.warn(E)}stop(z={}){return this.stopping??=this.drain({...this.settings,...z}),this.stopping}async drain(z){let C=Date.now()+z.timeoutMs;Y();let E=this.kernel.app,F=E.resolved(J)?E.make(J):void 0;if(F)console.log(`[gemi] Shutting down: waiting for ${F.running} running job(s) (up to ${z.timeoutMs/1000}s).`),await F.drain(z.timeoutMs);let G=N()===0;if(!G){let U=C-Date.now();if(G=U>0&&await Promise.race([Z().then(()=>!0),new Promise((K)=>setTimeout(()=>K(!1),U))]),!G)console.error(`[gemi] Shutdown grace period elapsed with ${N()} held background task(s) still running; abandoning them.`)}let H=await this.kernel.shutdown({timeoutMs:z.providerTimeoutMs});clearInterval(this.keepAlive);let T=G&&(F?.running??0)===0&&H.failed.length===0&&H.timedOut.length===0;return console.log(`[gemi] Shutdown ${T?"complete":"finished with errors"}.`),T?0:1}}async function j(){let z=x();process.env.ROOT_DIR=z,process.env.APP_DIR=$.join(z,"app"),A();let C=$.join(z,"app/kernel/Kernel.ts"),{default:E}=await import(C);if(typeof E!=="function")return console.error(`[gemi] ${C} has no default export to boot the worker from.`),1;let F=new E;F.boot();let G=new O(F);I(()=>G.stop());try{await G.start()}catch(H){if(!(H instanceof L))throw H;return console.error(H.message),1}return}j().then((z)=>{if(z!==void 0)process.exit(z)},(z)=>{console.error("[gemi] The queue worker failed to start:",z),process.exit(1)});
|
|
3
3
|
|
|
4
4
|
//# debugId=07AAF52CEDF447F964756E2164756E21
|