gemi 0.115.0 → 0.116.0
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/{chunk-t24p7gc6.js → chunk-1q9kd20m.js} +1 -1
- package/dist/{chunk-0z8ejxre.js → chunk-4088szy9.js} +1 -1
- package/dist/chunk-49nyyjfe.js +5 -0
- package/dist/{chunk-9b4erdy2.js.map → chunk-49nyyjfe.js.map} +3 -3
- package/dist/{chunk-0av6xvm6.js → chunk-6cx8ncd4.js} +1 -1
- package/dist/{chunk-jafm3613.js → chunk-6d8rvr1v.js} +2 -2
- package/dist/{chunk-jafm3613.js.map → chunk-6d8rvr1v.js.map} +1 -1
- package/dist/{chunk-wzrt5mac.js → chunk-79xg42e7.js} +1 -1
- package/dist/chunk-jmg2zsaf.js +5 -0
- package/dist/{chunk-7g9yh5ae.js.map → chunk-jmg2zsaf.js.map} +4 -4
- package/dist/chunk-ms9k0rx6.js +46 -0
- package/dist/{chunk-d6591xck.js.map → chunk-ms9k0rx6.js.map} +5 -5
- package/dist/{chunk-mps6ynbh.js → chunk-p91b8zcn.js} +1 -1
- package/dist/{chunk-dexdkh3z.js → chunk-pn8v6fj2.js} +1 -1
- package/dist/{chunk-mtbygktb.js → chunk-v1tfdgy1.js} +1 -1
- package/dist/{chunk-t4t3hqe0.js → chunk-yf1njzd5.js} +1 -1
- package/dist/chunks/{ThemeProvider-BgLyzzOL.js → ThemeProvider-BLI4zpLu.js} +8 -3
- package/dist/chunks/ThemeProvider-BLI4zpLu.js.map +1 -0
- package/dist/client/ClientRouter.d.ts +3 -5
- package/dist/client/ClientRouter.d.ts.map +1 -1
- package/dist/client/ClientRouterContext.d.ts.map +1 -1
- package/dist/client/Head.d.ts +1 -1
- package/dist/client/Head.d.ts.map +1 -1
- package/dist/client/ServerDataProvider.d.ts +2 -0
- package/dist/client/ServerDataProvider.d.ts.map +1 -1
- package/dist/client/createRoot.d.ts +2 -4
- package/dist/client/createRoot.d.ts.map +1 -1
- package/dist/client/htmlAttributes.d.ts +18 -0
- package/dist/client/htmlAttributes.d.ts.map +1 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +79 -6
- package/dist/client/index.js.map +1 -1
- package/dist/email/index.js +1 -1
- package/dist/facades/Meta.d.ts +11 -1
- package/dist/facades/Meta.d.ts.map +1 -1
- package/dist/facades/index.js +1 -1
- package/dist/http/HttpRequest.d.ts +3 -0
- package/dist/http/HttpRequest.d.ts.map +1 -1
- package/dist/http/Metadata.d.ts +23 -0
- package/dist/http/Metadata.d.ts.map +1 -1
- package/dist/http/index.js +1 -1
- package/dist/http/requestContext.d.ts +3 -0
- package/dist/http/requestContext.d.ts.map +1 -1
- package/dist/i18n/index.d.ts +1 -0
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/index.js.map +2 -2
- package/dist/kernel/index.js +1 -1
- package/dist/orm/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/router/ViewRouteDispatcher.d.ts +3 -1
- package/dist/services/router/ViewRouteDispatcher.d.ts.map +1 -1
- package/dist/services/router/config.d.ts +19 -0
- package/dist/services/router/config.d.ts.map +1 -1
- package/dist/testing/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-7g9yh5ae.js +0 -5
- package/dist/chunk-9b4erdy2.js +0 -5
- package/dist/chunk-d6591xck.js +0 -46
- package/dist/chunks/ThemeProvider-BgLyzzOL.js.map +0 -1
- /package/dist/{chunk-t24p7gc6.js.map → chunk-1q9kd20m.js.map} +0 -0
- /package/dist/{chunk-0z8ejxre.js.map → chunk-4088szy9.js.map} +0 -0
- /package/dist/{chunk-0av6xvm6.js.map → chunk-6cx8ncd4.js.map} +0 -0
- /package/dist/{chunk-wzrt5mac.js.map → chunk-79xg42e7.js.map} +0 -0
- /package/dist/{chunk-mps6ynbh.js.map → chunk-p91b8zcn.js.map} +0 -0
- /package/dist/{chunk-dexdkh3z.js.map → chunk-pn8v6fj2.js.map} +0 -0
- /package/dist/{chunk-mtbygktb.js.map → chunk-v1tfdgy1.js.map} +0 -0
- /package/dist/{chunk-t4t3hqe0.js.map → chunk-yf1njzd5.js.map} +0 -0
package/dist/ai/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$b as JZ,Sb as LQ,Tb as P6,Ub as C9,Xb as QZ,Yb as ZZ,Zb as VZ,_b as GZ,ac as WZ,bc as YZ,cc as XZ,dc as j,ec as F9,fc as KZ,gc as HZ,hc as N6}from"../chunk-0z8ejxre.js";import{wc as DZ}from"../chunk-2z1981d0.js";import{Ac as _Q,Ec as qQ}from"../chunk-7vb4eey2.js";import{Hg as w9,Jg as X9,Kg as JQ,Mg as $Z,Og as U6,Xf as D6,_f as L6,og as l0,pg as v9,qg as W9,rg as M9}from"../chunk-dexdkh3z.js";import{Pg as F6,Rg as J$,Sg as W$}from"../chunk-15c2vgaf.js";import{Wg as p9}from"../chunk-9b4erdy2.js";import"../chunk-tn2bryy2.js";import"../chunk-cbqazg9k.js";import{ah as NZ,bh as CZ,ph as OZ}from"../chunk-1myhm0g3.js";import"../chunk-kejwjerj.js";import{bi as I9}from"../chunk-t4yh4nf9.js";import"../chunk-1vzks22y.js";import"../chunk-zyt2w03d.js";import"../chunk-1hr4xht1.js";import"../chunk-vw8849ys.js";class h extends Error{status;body;requestId;constructor($,Q,Z){super(`Provider request failed with status ${$}: ${j6(Q)}`);this.name="ProviderHttpError",this.status=$,this.body=Q,this.requestId=Z}}class R9 extends Error{timeoutMs;constructor($){super(`Provider request timed out after ${$}ms`);this.name="ProviderTimeoutError",this.timeoutMs=$}}function j6($){let Q=PQ($);if(Q?.message)return Q.message;if(typeof $==="string")return $.slice(0,500);return"no error body"}function PQ($){if(!$||typeof $!=="object")return null;let Q=$,V=Q.error&&typeof Q.error==="object"?Q.error:$;if(typeof V.message!=="string"&&typeof V.code!=="string"&&typeof V.type!=="string")return null;let G=V.innererror?.code??V.code;return{message:V.message,type:V.type,code:G,param:V.param}}function b($){if(!$||typeof $!=="object")return{};let{status:Q,requestId:Z}=$;return{...typeof Q==="number"&&Q>=100&&Q<=599?{status:Q}:{},...typeof Z==="string"&&Z?{requestId:Z}:{}}}function I($){if($ instanceof R9)return{code:"provider_error",message:$.message,retryable:!0};if(k6($))return{code:"aborted",message:"The request was aborted.",retryable:!1};if($ instanceof h)return A6($.status,PQ($.body),$.message);if($ instanceof TypeError)return{code:"provider_error",message:`Could not reach the provider: ${$.message}`,retryable:!0};if($ instanceof Error)return{code:"provider_error",message:$.message,retryable:!1};return{code:"unknown",message:String($),retryable:!1}}function A6($,Q,Z){let V=Q?.message??Z,G=(Q?.code??"").toLowerCase(),J=(Q?.type??"").toLowerCase(),W=`${G} ${J} ${V}`.toLowerCase();if($===429){let X=G==="insufficient_quota"||W.includes("quota");return{code:"rate_limited",message:V,retryable:!X}}if($>=500||$===408||$===409)return{code:"provider_error",message:V,retryable:!0};if(T6(W))return{code:"context_length_exceeded",message:V,retryable:!1};if(E6(W))return{code:"content_filtered",message:V,retryable:!1};if(Q?.param?.startsWith("tools")||W.includes("invalid schema for function"))return{code:"invalid_tool_input",message:V,retryable:!1};return{code:"provider_error",message:V,retryable:!1}}function T6($){return $.includes("context_length_exceeded")||$.includes("maximum context length")||$.includes("context window")||$.includes("reduce the length")}function E6($){return $.includes("content_filter")||$.includes("content_policy_violation")||$.includes("responsibleaipolicyviolation")||$.includes("content management policy")}function k6($){if(!$||typeof $!=="object")return!1;let Q=$;return Q.name==="AbortError"||Q.code==="ABORT_ERR"}class w extends Error{constructor(){super("The run was stopped");this.name="RunAborted"}}function c($,Q){if(Q.aborted)return Promise.reject(new w);return new Promise((Z,V)=>{let G=()=>V(new w);Q.addEventListener("abort",G,{once:!0}),$.then(Z,V).finally(()=>Q.removeEventListener("abort",G))})}function R(){return{inputTokens:0,outputTokens:0,totalTokens:0}}function M($,Q){if(!Q)return $;let Z={inputTokens:$.inputTokens+(Q.inputTokens??0),outputTokens:$.outputTokens+(Q.outputTokens??0),totalTokens:$.totalTokens+(Q.totalTokens??0)};if(Q.reasoningTokens!==void 0||$.reasoningTokens!==void 0)Z.reasoningTokens=($.reasoningTokens??0)+(Q.reasoningTokens??0);if(Q.cachedInputTokens!==void 0||$.cachedInputTokens!==void 0)Z.cachedInputTokens=($.cachedInputTokens??0)+(Q.cachedInputTokens??0);if(Q.imageInputTokens!==void 0||$.imageInputTokens!==void 0)Z.imageInputTokens=($.imageInputTokens??0)+(Q.imageInputTokens??0);if(Q.imageOutputTokens!==void 0||$.imageOutputTokens!==void 0)Z.imageOutputTokens=($.imageOutputTokens??0)+(Q.imageOutputTokens??0);return Z}function S9($){if(!$.trim())return{};try{return JSON.parse($)}catch{}let Q=[],Z=!1,V=!1;for(let W of $){if(Z){if(V)V=!1;else if(W==="\\")V=!0;else if(W==='"')Z=!1;continue}if(W==='"')Z=!0;else if(W==="{")Q.push("}");else if(W==="[")Q.push("]");else if(W==="}"||W==="]")Q.pop()}let G=$;if(Z)G+='"';G=G.replace(/[,:]\s*$/,"");let J=Q.reverse().join("");try{return JSON.parse(G+J)}catch{try{return JSON.parse(G.replace(/,?\s*"[^"]*"\s*$/,"")+J)}catch{return{}}}}function j9($){return{name:"output",schema:$.toJSONSchema(),strict:W9($)}}function A9($,Q){let Z=$.safeParse(S9(Q));if(Z.ok===!0)return{ok:!0,value:Z.value};return{ok:!1,error:{code:"invalid_output",message:`The model's structured answer did not match the output schema: ${Z.errors.join(", ")}`,retryable:!0}}}function T9($){if($.length>0)$[0];return $}function Y9($,Q,Z){let V=$.content[$.content.length-1];if(V&&V.type===Q){V.text=(V.text??"")+Z;return}$.content.push(Q==="text"?{type:"text",text:Z}:{type:"reasoning",text:Z})}function E9($,Q,Z){let V=$.content[$.content.length-1];if(V&&V.type==="reasoning"&&V.id===Q){V.text=(V.text??"")+Z;return}$.content.push(Q?{type:"reasoning",id:Q,text:Z}:{type:"reasoning",text:Z})}function Y$($){return K9($)}async function K9($,Q={}){let Z=`gen_${crypto.randomUUID()}`,V=await I6($);if(Q.settled?.(V),!V.ok){if($.logErrors!==!1&&V.error.code!=="aborted")x6(Z,V.error,Q.origin);if($.throwOnError)throw new H9({runId:Z,messages:V.messages,finishReason:V.finishReason,usage:V.usage,error:V.error})}return V}function x6($,Q,Z){let V=`[gemi/ai] generate() failed (${Q.code}${Q.status!==void 0?` ${Q.status}`:""}): ${Q.message}`,G={...Z,generateId:$,error:Q},J=!1;try{X9.error(V,G),J=!0}catch{}if(!J||Bun.env.NODE_ENV==="development")console.error(V,G)}async function I6($){let Q=$.messages??[];if(Q.length===0&&!$.prompt)throw Error("generate() was given neither a `prompt` nor `messages`, so there is nothing to send the model.");let Z=[...Q];if($.prompt)Z.push({id:`msg_${crypto.randomUUID()}`,role:"user",content:[{type:"text",text:$.prompt}],createdAt:new Date().toISOString()});let V={id:`msg_${crypto.randomUUID()}`,role:"assistant",content:[],createdAt:new Date().toISOString()},G=$.signal??new AbortController().signal,J=R(),W="stop",X,K={},Y="";try{let D=$.provider.stream({messages:[...Z],systemPrompt:$.instructions?.trim()?$.instructions:void 0,output:j9($.output),reasoning:$.reasoning,maxOutputTokens:$.maxOutputTokens,temperature:$.temperature,signal:$.signal})[Symbol.asyncIterator]();try{for(;;){let L=await c(Promise.resolve(D.next()),G);if(L.done)break;let F=L.value;switch(F.type){case"output-delta":Y+=F.delta;break;case"text-delta":Y9(V,"text",F.delta);break;case"reasoning-delta":E9(V,F.id,F.delta);break;case"finish":if(J=M(J,F.usage),!X)W=F.reason;break;case"error":W="error",X=F.error,K=b(F);break}}}finally{if(G.aborted)Promise.resolve(D.return?.()).catch(()=>{})}}catch(z){if(z instanceof w||G.aborted)W="aborted",X=w6(G);else W="error",X=$.provider.normalizeError(z),K=b(z)}let H=!1,B;if(!X)if(W==="length")X={code:"invalid_output",message:"The model ran out of output tokens before finishing its structured answer, so it was cut off. Raise maxOutputTokens, or ask for a shorter answer.",retryable:!0};else if(!Y.trim())X={code:"invalid_output",message:"The model finished without giving a structured answer.",retryable:!0};else{let z=A9($.output,Y);if(z.ok===!0)H=!0,B=z.value;else X=z.error}if(H)V.content.push({type:"output",value:B});else if(Y)Y9(V,"text",Y);for(let z of V.content)if((z.type==="text"||z.type==="reasoning")&&typeof z.text==="string")z.text=T9(z.text);if(V.finishReason=W,V.usage=J,Z.push(V),H)return{ok:!0,output:B,messages:Z,usage:J,finishReason:W};return{ok:!1,error:{...X,...K},messages:Z,usage:J,finishReason:W}}function w6($){return $.reason?.name==="TimeoutError"?{code:"timeout",message:"The generation timed out.",retryable:!0}:{code:"aborted",message:"The generation was stopped.",retryable:!1}}class z9 extends j{id;code="attachment_not_found";constructor($){super(`No attachment ${$}.`);this.id=$;this.name="AttachmentNotFoundError"}}class g extends j{code="invalid_attachment_scope";constructor($){super($);this.name="InvalidAttachmentScopeError"}}function X$($){if(!$||typeof $.key!=="string"||$.key.length===0)throw new g("An attachment scope needs a non-empty key. Return `null` from `attachmentScope()` for a request that has no subject \u2014 an empty key is a bucket every caller shares.");return $}var v="gemi_att_";function K$(){return`${v}${crypto.randomUUID()}`}class p{store;storage;scope;constructor($,Q,Z){this.store=$;this.storage=Q;this.scope=Z;X$(Z)}get scopeKey(){return this.scope.key}async get($){let Q=await this.store.find(this.scope,$);if(!Q||Q.scopeKey!==this.scope.key)throw new z9($);return Q}async read($){return await this.readRecord($,await this.get($))}async readRecord($,Q){if(!Q.objectName)throw new z9($);return await this.storage.read({name:Q.objectName})}async file($){let Q=await this.get($),V=(await this.readRecord($,Q)).body,G=V instanceof Blob?V:V?await new Response(V).blob():new Blob([]);return new File([G],Q.name,{type:Q.mimeType})}async put($,Q={}){let Z=K$(),V=Q.mimeType??$.type??"",G=Q.name??($ instanceof File?$.name:Z),J=await this.storage.put({name:H$(Z,G),body:$,contentType:V||void 0}),W={id:Z,scopeKey:this.scope.key,objectName:J,name:G,mimeType:V||"application/octet-stream",size:$.size,createdAt:new Date().toISOString(),destination:Q.fileId?"both":"storage",...Q.fileId?{fileId:Q.fileId}:{}};return await this.store.put(this.scope,W),W}}function H$($,Q){let Z=/\.([A-Za-z0-9]{1,8})$/.exec(Q);return`attachments/${$}${Z?`.${Z[1].toLowerCase()}`:""}`}class k9{rows=new Map;async put($,Q){X$($),this.rows.set(Q.id,{...Q,scopeKey:$.key})}async find($,Q){X$($);let Z=this.rows.get(Q);if(!Z||Z.scopeKey!==$.key)return null;return Z}get size(){return this.rows.size}}var t=new k9;class B9{jobs=new Map;async create($){if(this.jobs.has($.id))throw Error(`A background job with the id ${$.id} already exists.`);let Q=Date.now(),{deadlineMs:Z,...V}=$,G={...structuredClone(V),state:"running",createdAt:Q,updatedAt:Q,deadlineAt:Q+Z};return this.jobs.set(G.id,G),this.trim(G.threadId),structuredClone(G)}async get($){let Q=this.jobs.get($);return Q?structuredClone(Q):null}async listForThread($,Q={}){let Z=[];for(let V of this.jobs.values()){if(V.threadId!==$)continue;if(Q.states&&!Q.states.includes(V.state))continue;Z.push(V)}return Z.sort(NQ),(Q.limit===void 0?Z:Z.slice(0,Q.limit)).map((V)=>structuredClone(V))}async transition($,Q,Z){let V=this.jobs.get($);if(!V||!Q.includes(V.state))return!1;let G=structuredClone(Z),J=Date.now();if(Object.assign(V,G,{updatedAt:J}),G.state&&G.state!=="running"&&V.settledAt===void 0)V.settledAt=G.settledAt??J;return!0}async overdue($,Q){let Z=[];for(let V of this.jobs.values())if(V.state==="running"&&V.deadlineAt<=$)Z.push(V);return Z.sort((V,G)=>V.deadlineAt-G.deadlineAt),Z.slice(0,Math.max(0,Q)).map((V)=>structuredClone(V))}async now(){return Date.now()}trim($){let Q=[...this.jobs.values()].filter((Z)=>Z.threadId===$&&Z.state!=="running").sort(NQ);for(let Z of Q.slice(200))this.jobs.delete(Z.id)}}function NQ($,Q){return Q.createdAt-$.createdAt||($.id<Q.id?1:$.id>Q.id?-1:0)}var MQ=Symbol.for("gemi.ai.JobHandle");class b9{id;toolCallId;summary;deadlineAt;[MQ]=!0;constructor($,Q,Z,V){this.id=$;this.toolCallId=Q;this.summary=Z;this.deadlineAt=V}}function RQ($){return typeof $==="object"&&$!==null&&$[MQ]===!0}class D9 extends j{code="jobs_require_thread";constructor($){super($,{retryable:!1});this.name="JobsRequireThreadError"}}var a=new B9,b6=["running","ok","error"],y={get store(){return a},use($){a=$},get($){return a.get($)},async settle($,Q){return x9(a,$,Q)},async fail($,Q){return x9(a,$,{error:Q})},async sweep($={}){let Q=a,Z=$.limit??100,V=await z$(Q),G=0;for(let J of await Q.overdue(V,Z))if(await B$(Q,J))G++;return G}};async function z$($){return $.now?await $.now():Date.now()}function B$($,Q){return $.transition(Q.id,["running"],{state:"error",error:{code:"timeout",message:`The background job for "${Q.toolName}" did not finish before its deadline, so it was given up on. Its result, if it ever arrives, is ignored.`,toolCallId:Q.toolCallId,retryable:!0}})}async function x9($,Q,Z){let V=await $.get(Q);if(!V||V.state!=="running")return!1;let G=Z.usage?M(V.usage??R(),Z.usage):void 0;if("error"in Z)return $.transition(Q,["running"],{state:"error",error:f6(V,Z.error),...G?{usage:G}:{}});return $.transition(Q,["running"],{state:"ok",output:SQ(Z.output,V),...G?{usage:G}:{}})}function f6($,Q){if(typeof Q==="string")return{code:"tool_error",message:Q,toolCallId:$.toolCallId,retryable:!0};if(Q instanceof Error){let Z={code:"tool_error",message:Q.message,toolCallId:$.toolCallId,retryable:Q instanceof j?Q.retryable:!0};if(!(Q instanceof j))console.error(`The background job ${$.job??"(tracked)"} for "${$.toolName}" failed.`,Q);return F9(Z,{source:"tool",toolName:$.toolName,cause:Q})}return{code:Q.code??"tool_error",message:String(Q.message),toolCallId:$.toolCallId,retryable:Q.retryable??!0}}function SQ($,Q){if($===void 0)return null;try{return JSON.parse(JSON.stringify($))}catch(Z){throw Error(`The output of the background job for "${Q.toolName}" is not JSON: ${String(Z)}`)}}var D$=3600000;function jQ($){let Q=null,Z=(V,G,J={})=>{if($.async===void 0)throw new j(`"${$.toolName}" called ctx.jobs, but the tool does not declare \`async\`. Add \`async: { deadlineMs }\` to its definition.`,{retryable:!1});if(!$.jobs||!$.threadId)throw new D9(`"${$.toolName}" can only run in the background on a conversation the server keeps (a turn with a threadId), and this one has none.`);if($.depth>0)throw new D9(`"${$.toolName}" can only run in the background from the top-level agent, not from a sub-agent.`);if(Q)throw new j(`"${$.toolName}" started a background job already: a tool call has at most one.`,{retryable:!1});let W=J.deadlineMs??$.async.deadlineMs??D$;if(!Number.isFinite(W)||W<=0)throw new j(`A job's deadlineMs must be a positive number; got ${W}.`);let{jobs:X,threadId:K}=$;return Q=(async()=>{let Y=y.store,H=(await Y.listForThread(K,{limit:50})).find((D)=>D.toolCallId===$.toolCallId);if(H)return CQ(H);let B=async()=>{let D=await Y.create({id:`ajob_${crypto.randomUUID()}`,threadId:K,runId:$.runId,toolCallId:$.toolCallId,toolName:$.toolName,owner:X.owner,job:V?V.name:null,...J.summary!==void 0?{summary:SQ(J.summary,$)}:{},attachmentScope:$.attachments?.scopeKey??null,deadlineMs:W});if(V)try{await v6(V,{jobId:D.id,args:G})}catch(L){if(Y.transaction)throw L;throw await Y.transition(D.id,["running"],{state:"error",error:{code:"tool_error",message:`The background job for "${$.toolName}" could not be queued.`,toolCallId:$.toolCallId,retryable:!0}}).catch(()=>{}),L}return D},z=Y.transaction?await Y.transaction(B):await B();return CQ(z)})(),Q};return{start:(V,G,J)=>Z(V,G,J),track:(V)=>Z(null,void 0,V)}}function CQ($){return new b9($.id,$.toolCallId,$.summary,$.deadlineAt)}function v6($,Q){if($.name==="unset"||!$.name)throw Error("Cannot start an AgentJob with no `static name`.");return I9(qQ).push($,JSON.stringify([Q]))}class F$ extends _Q{attachments=t;attachmentStorage=w9;constructor(){super();let $=this.run;this.run=(Q)=>this.$runEnvelope(Q,$)}onDeadletter($,...Q){let Z=Q[0];if(!Z?.jobId)return;x9(y.store,Z.jobId,{error:$}).catch((V)=>{console.error(`Could not record the failure of background job ${Z.jobId}.`,V)})}async $runEnvelope($,Q){let Z=y.store,V=await Z.get($.jobId);if(!V||V.state!=="running")return;let G=new AQ(V,this),J;try{J=await Q.call(this,$.args,G)}catch(W){throw await OQ(Z,V.id,G.usage),W}if(this.$outcome)return await OQ(Z,V.id,G.usage),J;return await x9(Z,V.id,{output:J,usage:G.usage}),J}}async function OQ($,Q,Z){if(Z.totalTokens===0&&Z.inputTokens===0&&Z.outputTokens===0)return;let V=await $.get(Q);if(!V)return;await $.transition(Q,b6,{usage:M(V.usage??R(),Z)}).catch(()=>{})}class AQ{id;threadId;toolCallId;toolName;owner;summary;signal=new AbortController().signal;usage=R();attachments;constructor($,Q){this.id=$.id,this.threadId=$.threadId,this.toolCallId=$.toolCallId,this.toolName=$.toolName,this.owner=$.owner,this.summary=$.summary;let Z=$.attachmentScope?new p(Q.attachments,Q.attachmentStorage,{key:$.attachmentScope}):null,V=()=>{if(!Z)throw new g("The run that started this job had no attachment scope, so the job cannot store or read files. See `attachmentScope()` on the controller.");return Z};this.attachments={put:(G,J={})=>V().put(G,J),get:(G)=>V().get(G),read:(G)=>V().read(G),file:(G)=>V().file(G)}}generate($){return K9($,{origin:{threadId:this.threadId,toolCallId:this.toolCallId,jobId:this.id},settled:(Q)=>{this.usage=M(this.usage,Q.usage)}})}async generateImage($,Q){let{name:Z,...V}=Q,G=await $.generate({...V,signal:this.signal});return this.park($,G,Z)}async editImage($,Q){let{name:Z,images:V,mask:G,...J}=Q,W=async(K)=>typeof K==="string"?await this.attachments.file(K):K,X=await $.edit({...J,images:await Promise.all(V.map(W)),...G?{mask:await W(G)}:{},signal:this.signal});return this.park($,X,Z)}async park($,Q,Z){this.usage=M(this.usage,Q.usage);let V=Q.mimeType==="image/jpeg"?"jpg":"png";return{attachment:await this.attachments.put(Q.image,{name:Z??`${$.name}.${V}`,mimeType:Q.mimeType}),size:Q.size,mimeType:Q.mimeType,usage:Q.usage}}}function m($){let Q=new Set;for(let Z of $)for(let V of Z.content??[]){if(V.type!=="tool-call")continue;for(let G of V.attachments??[])if(G&&"shown"in G&&G.shown)Q.add(G.shown.messageId)}return Q}function L9($){if($.length===0)return[];let Q=m($),Z=[0];for(let V=1;V<$.length;V++){let G=$[V];if(G.role==="user"&&!Q.has(G.id))Z.push(V)}return Z}function y6($){let Q=L9($);return Q.map((Z,V)=>$.slice(Z,Q[V+1]??$.length))}function EQ($){try{return JSON.stringify($).length}catch{return 0}}var h6=4,kQ=10,xQ="[Earlier turns of this conversation are not shown.]";function r($,Q={}){let Z=[...$],V=L9(Z),G=g6(Q),J=f9(Q.maxTurns)??1/0,W=Math.max(1,Math.floor(f9(Q.step)??kQ));if(V.length<=1||J>=V.length&&G===1/0)return{messages:Z,start:0,omittedTurns:0,omittedMessages:0};let X=Array.from({length:Z.length+1},()=>0);if(G!==1/0)for(let U=Z.length-1;U>=0;U--)X[U]=X[U+1]+EQ(Z[U]);let K=(U)=>V.length-U<=J&&X[V[U]]<=G,Y=-1;for(let U=0;U<V.length;U+=W)if(K(U)){Y=U;break}if(Y<0){for(let U=0;U<V.length;U++)if(K(U)){Y=U;break}}if(Y<0)Y=V.length-1;if(Y===0)return{messages:Z,start:0,omittedTurns:0,omittedMessages:0};let H=V[Y],B=Z.slice(0,H),z=B.filter((U)=>U.role==="system"),D=u6(B,Z.slice(H)),L={turns:Y,messages:B.length-z.length},F=typeof Q.note==="function"?Q.note(L):Q.note===void 0?xQ:Q.note;if(F){let U=D[0];D[0]={...U,content:[{type:"text",text:F},...U.content]}}return{messages:[...z,...D],start:H,omittedTurns:L.turns,omittedMessages:L.messages}}function f9($){return typeof $==="number"&&$>0?$:void 0}function g6($){let Q=f9($.maxBytes)??1/0,Z=f9($.maxTokens);return Math.min(Q,Z===void 0?1/0:Z*h6)}function TQ($,Q){let Z=Array.isArray($?.namespaces)?$.namespaces:[],V=Array.isArray($?.loaded)?$.loaded:[];return Q.namespace?Z.includes(Q.namespace):V.includes(String(Q.name))}function L$($){return Array.isArray($.toolSearches)?$.toolSearches:[]}function u6($,Q){let Z=[];for(let Y of $)for(let H of Y.content??[])if(H.type==="tool-call")Z.push(...L$(H));if(Z.length===0)return Q;let V=[],G=new Set,J;if(Q.forEach((Y,H)=>{(Y.content??[]).forEach((B,z)=>{if(B.type!=="tool-call"||B.partial)return;if(V.push(...L$(B)),V.some((L)=>TQ(L,B)))return;let D=Z.filter((L)=>TQ(L,B));if(D.length===0)return;for(let L of D)G.add(L);J??={message:H,part:z}})}),!J)return Q;let W=Z.filter((Y)=>G.has(Y)),X=[...Q],K=X[J.message];return X[J.message]={...K,content:K.content.map((Y,H)=>H===J.part&&Y.type==="tool-call"?{...Y,toolSearches:[...W,...L$(Y)]}:Y)},X}var fQ=1000,c6=24000,p6=20000,vQ=1e5,m6=120000,yQ=["You keep a running summary of a conversation between a user and an AI assistant.","The assistant will continue the conversation with only your summary and the latest turns, so the summary has to carry everything from the earlier turns it may still need.","You are given the summary so far (possibly empty) and the turns that came after it. Answer the updated summary, which replaces the old one.","Keep: the user's goals, preferences and constraints; decisions made and why; facts, names, ids, numbers, dates, file names and URLs that may matter later; what tools were used and their important results; open questions and unfinished work.","Drop greetings, repetition and anything later turns superseded. Do not invent anything, and do not answer the user.","Write terse prose or bullet points, in the language of the conversation."].join(" "),hQ="[Summary of the earlier turns of this conversation, which are not shown:]",l6=8;class N${ttlMs;threads=new Map;lastSweep=0;constructor($=86400000){this.ttlMs=$}async loadSummaries($){this.sweep();let Q=this.threads.get($);if(!Q)return[];return Q.touchedAt=Date.now(),Q.summaries.slice()}async saveSummary($,Q){this.sweep();let Z=this.threads.get($)??{summaries:[],touchedAt:Date.now()};Z.summaries=h9(Z.summaries,Q),Z.touchedAt=Date.now(),this.threads.set($,Z)}delete($){this.threads.delete($)}sweep($=Date.now()){if($-this.lastSweep<60000)return;this.lastSweep=$;for(let[Q,Z]of this.threads)if($-Z.touchedAt>this.ttlMs)this.threads.delete(Q)}}function h9($,Q){return[Q,...$.filter((Z)=>Z.cutMessageId!==Q.cutMessageId)].slice(0,l6)}var C$=new N$;function gQ($){let Q=$;return typeof Q?.loadSummaries==="function"&&typeof Q?.saveSummary==="function"}function uQ($,Q,Z){let V=u(Z.maxSummaryTokens)??fQ,G=(K)=>Math.max(1,K-V),J={...Q,...u(Q.maxTokens)?{maxTokens:G(Q.maxTokens)}:{},...u(Q.maxBytes)?{maxBytes:Math.max(1,Q.maxBytes-V*P$)}:{}},W=d6(Q,Z),X={...J,note:!1,...W?{maxTokens:Math.min(J.maxTokens??1/0,G(W))}:{}};return{plain:J,cut:r($,X),maxSummaryTokens:V}}function d6($,Q){if(Q.triggerTokens===!1)return;let Z=u(Q.triggerTokens||void 0);if(Z)return Z;if(u($.maxTokens)||u($.maxBytes))return;return vQ}async function cQ($){let{history:Q,window:Z,compact:V}=$,{plain:G,cut:J,maxSummaryTokens:W}=uQ(Q,Z,V);if(J.omittedTurns===0)return J.messages;let X=`${Q[J.start].id}:${J.start}`,K=$.memo?.get(X);if(K===void 0){try{K=await t6($,J.start,W)}catch(D){if($.signal.aborted)throw D;K=null}if(!$.signal.aborted)$.memo?.set(X,K)}if(!K)return r(Q,G).messages;let Y=Q.length-J.start,H=J.messages.slice(0,J.messages.length-Y),B=J.messages.slice(J.messages.length-Y),z=Q[J.start];return[...H,{id:`summary_${z.id}`,role:"user",content:[{type:"text",text:`${hQ}
|
|
2
|
+
import{$b as JZ,Sb as LQ,Tb as P6,Ub as C9,Xb as QZ,Yb as ZZ,Zb as VZ,_b as GZ,ac as WZ,bc as YZ,cc as XZ,dc as j,ec as F9,fc as KZ,gc as HZ,hc as N6}from"../chunk-4088szy9.js";import{wc as DZ}from"../chunk-2z1981d0.js";import{Ac as _Q,Ec as qQ}from"../chunk-7vb4eey2.js";import{Hg as w9,Jg as X9,Kg as JQ,Mg as $Z,Og as U6,Xf as D6,_f as L6,og as l0,pg as v9,qg as W9,rg as M9}from"../chunk-pn8v6fj2.js";import{Pg as F6,Rg as J$,Sg as W$}from"../chunk-15c2vgaf.js";import{Wg as p9}from"../chunk-49nyyjfe.js";import"../chunk-tn2bryy2.js";import"../chunk-cbqazg9k.js";import{ah as NZ,bh as CZ,ph as OZ}from"../chunk-1myhm0g3.js";import"../chunk-kejwjerj.js";import{bi as I9}from"../chunk-t4yh4nf9.js";import"../chunk-1vzks22y.js";import"../chunk-zyt2w03d.js";import"../chunk-1hr4xht1.js";import"../chunk-vw8849ys.js";class h extends Error{status;body;requestId;constructor($,Q,Z){super(`Provider request failed with status ${$}: ${j6(Q)}`);this.name="ProviderHttpError",this.status=$,this.body=Q,this.requestId=Z}}class R9 extends Error{timeoutMs;constructor($){super(`Provider request timed out after ${$}ms`);this.name="ProviderTimeoutError",this.timeoutMs=$}}function j6($){let Q=PQ($);if(Q?.message)return Q.message;if(typeof $==="string")return $.slice(0,500);return"no error body"}function PQ($){if(!$||typeof $!=="object")return null;let Q=$,V=Q.error&&typeof Q.error==="object"?Q.error:$;if(typeof V.message!=="string"&&typeof V.code!=="string"&&typeof V.type!=="string")return null;let G=V.innererror?.code??V.code;return{message:V.message,type:V.type,code:G,param:V.param}}function b($){if(!$||typeof $!=="object")return{};let{status:Q,requestId:Z}=$;return{...typeof Q==="number"&&Q>=100&&Q<=599?{status:Q}:{},...typeof Z==="string"&&Z?{requestId:Z}:{}}}function I($){if($ instanceof R9)return{code:"provider_error",message:$.message,retryable:!0};if(k6($))return{code:"aborted",message:"The request was aborted.",retryable:!1};if($ instanceof h)return A6($.status,PQ($.body),$.message);if($ instanceof TypeError)return{code:"provider_error",message:`Could not reach the provider: ${$.message}`,retryable:!0};if($ instanceof Error)return{code:"provider_error",message:$.message,retryable:!1};return{code:"unknown",message:String($),retryable:!1}}function A6($,Q,Z){let V=Q?.message??Z,G=(Q?.code??"").toLowerCase(),J=(Q?.type??"").toLowerCase(),W=`${G} ${J} ${V}`.toLowerCase();if($===429){let X=G==="insufficient_quota"||W.includes("quota");return{code:"rate_limited",message:V,retryable:!X}}if($>=500||$===408||$===409)return{code:"provider_error",message:V,retryable:!0};if(T6(W))return{code:"context_length_exceeded",message:V,retryable:!1};if(E6(W))return{code:"content_filtered",message:V,retryable:!1};if(Q?.param?.startsWith("tools")||W.includes("invalid schema for function"))return{code:"invalid_tool_input",message:V,retryable:!1};return{code:"provider_error",message:V,retryable:!1}}function T6($){return $.includes("context_length_exceeded")||$.includes("maximum context length")||$.includes("context window")||$.includes("reduce the length")}function E6($){return $.includes("content_filter")||$.includes("content_policy_violation")||$.includes("responsibleaipolicyviolation")||$.includes("content management policy")}function k6($){if(!$||typeof $!=="object")return!1;let Q=$;return Q.name==="AbortError"||Q.code==="ABORT_ERR"}class w extends Error{constructor(){super("The run was stopped");this.name="RunAborted"}}function c($,Q){if(Q.aborted)return Promise.reject(new w);return new Promise((Z,V)=>{let G=()=>V(new w);Q.addEventListener("abort",G,{once:!0}),$.then(Z,V).finally(()=>Q.removeEventListener("abort",G))})}function R(){return{inputTokens:0,outputTokens:0,totalTokens:0}}function M($,Q){if(!Q)return $;let Z={inputTokens:$.inputTokens+(Q.inputTokens??0),outputTokens:$.outputTokens+(Q.outputTokens??0),totalTokens:$.totalTokens+(Q.totalTokens??0)};if(Q.reasoningTokens!==void 0||$.reasoningTokens!==void 0)Z.reasoningTokens=($.reasoningTokens??0)+(Q.reasoningTokens??0);if(Q.cachedInputTokens!==void 0||$.cachedInputTokens!==void 0)Z.cachedInputTokens=($.cachedInputTokens??0)+(Q.cachedInputTokens??0);if(Q.imageInputTokens!==void 0||$.imageInputTokens!==void 0)Z.imageInputTokens=($.imageInputTokens??0)+(Q.imageInputTokens??0);if(Q.imageOutputTokens!==void 0||$.imageOutputTokens!==void 0)Z.imageOutputTokens=($.imageOutputTokens??0)+(Q.imageOutputTokens??0);return Z}function S9($){if(!$.trim())return{};try{return JSON.parse($)}catch{}let Q=[],Z=!1,V=!1;for(let W of $){if(Z){if(V)V=!1;else if(W==="\\")V=!0;else if(W==='"')Z=!1;continue}if(W==='"')Z=!0;else if(W==="{")Q.push("}");else if(W==="[")Q.push("]");else if(W==="}"||W==="]")Q.pop()}let G=$;if(Z)G+='"';G=G.replace(/[,:]\s*$/,"");let J=Q.reverse().join("");try{return JSON.parse(G+J)}catch{try{return JSON.parse(G.replace(/,?\s*"[^"]*"\s*$/,"")+J)}catch{return{}}}}function j9($){return{name:"output",schema:$.toJSONSchema(),strict:W9($)}}function A9($,Q){let Z=$.safeParse(S9(Q));if(Z.ok===!0)return{ok:!0,value:Z.value};return{ok:!1,error:{code:"invalid_output",message:`The model's structured answer did not match the output schema: ${Z.errors.join(", ")}`,retryable:!0}}}function T9($){if($.length>0)$[0];return $}function Y9($,Q,Z){let V=$.content[$.content.length-1];if(V&&V.type===Q){V.text=(V.text??"")+Z;return}$.content.push(Q==="text"?{type:"text",text:Z}:{type:"reasoning",text:Z})}function E9($,Q,Z){let V=$.content[$.content.length-1];if(V&&V.type==="reasoning"&&V.id===Q){V.text=(V.text??"")+Z;return}$.content.push(Q?{type:"reasoning",id:Q,text:Z}:{type:"reasoning",text:Z})}function Y$($){return K9($)}async function K9($,Q={}){let Z=`gen_${crypto.randomUUID()}`,V=await I6($);if(Q.settled?.(V),!V.ok){if($.logErrors!==!1&&V.error.code!=="aborted")x6(Z,V.error,Q.origin);if($.throwOnError)throw new H9({runId:Z,messages:V.messages,finishReason:V.finishReason,usage:V.usage,error:V.error})}return V}function x6($,Q,Z){let V=`[gemi/ai] generate() failed (${Q.code}${Q.status!==void 0?` ${Q.status}`:""}): ${Q.message}`,G={...Z,generateId:$,error:Q},J=!1;try{X9.error(V,G),J=!0}catch{}if(!J||Bun.env.NODE_ENV==="development")console.error(V,G)}async function I6($){let Q=$.messages??[];if(Q.length===0&&!$.prompt)throw Error("generate() was given neither a `prompt` nor `messages`, so there is nothing to send the model.");let Z=[...Q];if($.prompt)Z.push({id:`msg_${crypto.randomUUID()}`,role:"user",content:[{type:"text",text:$.prompt}],createdAt:new Date().toISOString()});let V={id:`msg_${crypto.randomUUID()}`,role:"assistant",content:[],createdAt:new Date().toISOString()},G=$.signal??new AbortController().signal,J=R(),W="stop",X,K={},Y="";try{let D=$.provider.stream({messages:[...Z],systemPrompt:$.instructions?.trim()?$.instructions:void 0,output:j9($.output),reasoning:$.reasoning,maxOutputTokens:$.maxOutputTokens,temperature:$.temperature,signal:$.signal})[Symbol.asyncIterator]();try{for(;;){let L=await c(Promise.resolve(D.next()),G);if(L.done)break;let F=L.value;switch(F.type){case"output-delta":Y+=F.delta;break;case"text-delta":Y9(V,"text",F.delta);break;case"reasoning-delta":E9(V,F.id,F.delta);break;case"finish":if(J=M(J,F.usage),!X)W=F.reason;break;case"error":W="error",X=F.error,K=b(F);break}}}finally{if(G.aborted)Promise.resolve(D.return?.()).catch(()=>{})}}catch(z){if(z instanceof w||G.aborted)W="aborted",X=w6(G);else W="error",X=$.provider.normalizeError(z),K=b(z)}let H=!1,B;if(!X)if(W==="length")X={code:"invalid_output",message:"The model ran out of output tokens before finishing its structured answer, so it was cut off. Raise maxOutputTokens, or ask for a shorter answer.",retryable:!0};else if(!Y.trim())X={code:"invalid_output",message:"The model finished without giving a structured answer.",retryable:!0};else{let z=A9($.output,Y);if(z.ok===!0)H=!0,B=z.value;else X=z.error}if(H)V.content.push({type:"output",value:B});else if(Y)Y9(V,"text",Y);for(let z of V.content)if((z.type==="text"||z.type==="reasoning")&&typeof z.text==="string")z.text=T9(z.text);if(V.finishReason=W,V.usage=J,Z.push(V),H)return{ok:!0,output:B,messages:Z,usage:J,finishReason:W};return{ok:!1,error:{...X,...K},messages:Z,usage:J,finishReason:W}}function w6($){return $.reason?.name==="TimeoutError"?{code:"timeout",message:"The generation timed out.",retryable:!0}:{code:"aborted",message:"The generation was stopped.",retryable:!1}}class z9 extends j{id;code="attachment_not_found";constructor($){super(`No attachment ${$}.`);this.id=$;this.name="AttachmentNotFoundError"}}class g extends j{code="invalid_attachment_scope";constructor($){super($);this.name="InvalidAttachmentScopeError"}}function X$($){if(!$||typeof $.key!=="string"||$.key.length===0)throw new g("An attachment scope needs a non-empty key. Return `null` from `attachmentScope()` for a request that has no subject \u2014 an empty key is a bucket every caller shares.");return $}var v="gemi_att_";function K$(){return`${v}${crypto.randomUUID()}`}class p{store;storage;scope;constructor($,Q,Z){this.store=$;this.storage=Q;this.scope=Z;X$(Z)}get scopeKey(){return this.scope.key}async get($){let Q=await this.store.find(this.scope,$);if(!Q||Q.scopeKey!==this.scope.key)throw new z9($);return Q}async read($){return await this.readRecord($,await this.get($))}async readRecord($,Q){if(!Q.objectName)throw new z9($);return await this.storage.read({name:Q.objectName})}async file($){let Q=await this.get($),V=(await this.readRecord($,Q)).body,G=V instanceof Blob?V:V?await new Response(V).blob():new Blob([]);return new File([G],Q.name,{type:Q.mimeType})}async put($,Q={}){let Z=K$(),V=Q.mimeType??$.type??"",G=Q.name??($ instanceof File?$.name:Z),J=await this.storage.put({name:H$(Z,G),body:$,contentType:V||void 0}),W={id:Z,scopeKey:this.scope.key,objectName:J,name:G,mimeType:V||"application/octet-stream",size:$.size,createdAt:new Date().toISOString(),destination:Q.fileId?"both":"storage",...Q.fileId?{fileId:Q.fileId}:{}};return await this.store.put(this.scope,W),W}}function H$($,Q){let Z=/\.([A-Za-z0-9]{1,8})$/.exec(Q);return`attachments/${$}${Z?`.${Z[1].toLowerCase()}`:""}`}class k9{rows=new Map;async put($,Q){X$($),this.rows.set(Q.id,{...Q,scopeKey:$.key})}async find($,Q){X$($);let Z=this.rows.get(Q);if(!Z||Z.scopeKey!==$.key)return null;return Z}get size(){return this.rows.size}}var t=new k9;class B9{jobs=new Map;async create($){if(this.jobs.has($.id))throw Error(`A background job with the id ${$.id} already exists.`);let Q=Date.now(),{deadlineMs:Z,...V}=$,G={...structuredClone(V),state:"running",createdAt:Q,updatedAt:Q,deadlineAt:Q+Z};return this.jobs.set(G.id,G),this.trim(G.threadId),structuredClone(G)}async get($){let Q=this.jobs.get($);return Q?structuredClone(Q):null}async listForThread($,Q={}){let Z=[];for(let V of this.jobs.values()){if(V.threadId!==$)continue;if(Q.states&&!Q.states.includes(V.state))continue;Z.push(V)}return Z.sort(NQ),(Q.limit===void 0?Z:Z.slice(0,Q.limit)).map((V)=>structuredClone(V))}async transition($,Q,Z){let V=this.jobs.get($);if(!V||!Q.includes(V.state))return!1;let G=structuredClone(Z),J=Date.now();if(Object.assign(V,G,{updatedAt:J}),G.state&&G.state!=="running"&&V.settledAt===void 0)V.settledAt=G.settledAt??J;return!0}async overdue($,Q){let Z=[];for(let V of this.jobs.values())if(V.state==="running"&&V.deadlineAt<=$)Z.push(V);return Z.sort((V,G)=>V.deadlineAt-G.deadlineAt),Z.slice(0,Math.max(0,Q)).map((V)=>structuredClone(V))}async now(){return Date.now()}trim($){let Q=[...this.jobs.values()].filter((Z)=>Z.threadId===$&&Z.state!=="running").sort(NQ);for(let Z of Q.slice(200))this.jobs.delete(Z.id)}}function NQ($,Q){return Q.createdAt-$.createdAt||($.id<Q.id?1:$.id>Q.id?-1:0)}var MQ=Symbol.for("gemi.ai.JobHandle");class b9{id;toolCallId;summary;deadlineAt;[MQ]=!0;constructor($,Q,Z,V){this.id=$;this.toolCallId=Q;this.summary=Z;this.deadlineAt=V}}function RQ($){return typeof $==="object"&&$!==null&&$[MQ]===!0}class D9 extends j{code="jobs_require_thread";constructor($){super($,{retryable:!1});this.name="JobsRequireThreadError"}}var a=new B9,b6=["running","ok","error"],y={get store(){return a},use($){a=$},get($){return a.get($)},async settle($,Q){return x9(a,$,Q)},async fail($,Q){return x9(a,$,{error:Q})},async sweep($={}){let Q=a,Z=$.limit??100,V=await z$(Q),G=0;for(let J of await Q.overdue(V,Z))if(await B$(Q,J))G++;return G}};async function z$($){return $.now?await $.now():Date.now()}function B$($,Q){return $.transition(Q.id,["running"],{state:"error",error:{code:"timeout",message:`The background job for "${Q.toolName}" did not finish before its deadline, so it was given up on. Its result, if it ever arrives, is ignored.`,toolCallId:Q.toolCallId,retryable:!0}})}async function x9($,Q,Z){let V=await $.get(Q);if(!V||V.state!=="running")return!1;let G=Z.usage?M(V.usage??R(),Z.usage):void 0;if("error"in Z)return $.transition(Q,["running"],{state:"error",error:f6(V,Z.error),...G?{usage:G}:{}});return $.transition(Q,["running"],{state:"ok",output:SQ(Z.output,V),...G?{usage:G}:{}})}function f6($,Q){if(typeof Q==="string")return{code:"tool_error",message:Q,toolCallId:$.toolCallId,retryable:!0};if(Q instanceof Error){let Z={code:"tool_error",message:Q.message,toolCallId:$.toolCallId,retryable:Q instanceof j?Q.retryable:!0};if(!(Q instanceof j))console.error(`The background job ${$.job??"(tracked)"} for "${$.toolName}" failed.`,Q);return F9(Z,{source:"tool",toolName:$.toolName,cause:Q})}return{code:Q.code??"tool_error",message:String(Q.message),toolCallId:$.toolCallId,retryable:Q.retryable??!0}}function SQ($,Q){if($===void 0)return null;try{return JSON.parse(JSON.stringify($))}catch(Z){throw Error(`The output of the background job for "${Q.toolName}" is not JSON: ${String(Z)}`)}}var D$=3600000;function jQ($){let Q=null,Z=(V,G,J={})=>{if($.async===void 0)throw new j(`"${$.toolName}" called ctx.jobs, but the tool does not declare \`async\`. Add \`async: { deadlineMs }\` to its definition.`,{retryable:!1});if(!$.jobs||!$.threadId)throw new D9(`"${$.toolName}" can only run in the background on a conversation the server keeps (a turn with a threadId), and this one has none.`);if($.depth>0)throw new D9(`"${$.toolName}" can only run in the background from the top-level agent, not from a sub-agent.`);if(Q)throw new j(`"${$.toolName}" started a background job already: a tool call has at most one.`,{retryable:!1});let W=J.deadlineMs??$.async.deadlineMs??D$;if(!Number.isFinite(W)||W<=0)throw new j(`A job's deadlineMs must be a positive number; got ${W}.`);let{jobs:X,threadId:K}=$;return Q=(async()=>{let Y=y.store,H=(await Y.listForThread(K,{limit:50})).find((D)=>D.toolCallId===$.toolCallId);if(H)return CQ(H);let B=async()=>{let D=await Y.create({id:`ajob_${crypto.randomUUID()}`,threadId:K,runId:$.runId,toolCallId:$.toolCallId,toolName:$.toolName,owner:X.owner,job:V?V.name:null,...J.summary!==void 0?{summary:SQ(J.summary,$)}:{},attachmentScope:$.attachments?.scopeKey??null,deadlineMs:W});if(V)try{await v6(V,{jobId:D.id,args:G})}catch(L){if(Y.transaction)throw L;throw await Y.transition(D.id,["running"],{state:"error",error:{code:"tool_error",message:`The background job for "${$.toolName}" could not be queued.`,toolCallId:$.toolCallId,retryable:!0}}).catch(()=>{}),L}return D},z=Y.transaction?await Y.transaction(B):await B();return CQ(z)})(),Q};return{start:(V,G,J)=>Z(V,G,J),track:(V)=>Z(null,void 0,V)}}function CQ($){return new b9($.id,$.toolCallId,$.summary,$.deadlineAt)}function v6($,Q){if($.name==="unset"||!$.name)throw Error("Cannot start an AgentJob with no `static name`.");return I9(qQ).push($,JSON.stringify([Q]))}class F$ extends _Q{attachments=t;attachmentStorage=w9;constructor(){super();let $=this.run;this.run=(Q)=>this.$runEnvelope(Q,$)}onDeadletter($,...Q){let Z=Q[0];if(!Z?.jobId)return;x9(y.store,Z.jobId,{error:$}).catch((V)=>{console.error(`Could not record the failure of background job ${Z.jobId}.`,V)})}async $runEnvelope($,Q){let Z=y.store,V=await Z.get($.jobId);if(!V||V.state!=="running")return;let G=new AQ(V,this),J;try{J=await Q.call(this,$.args,G)}catch(W){throw await OQ(Z,V.id,G.usage),W}if(this.$outcome)return await OQ(Z,V.id,G.usage),J;return await x9(Z,V.id,{output:J,usage:G.usage}),J}}async function OQ($,Q,Z){if(Z.totalTokens===0&&Z.inputTokens===0&&Z.outputTokens===0)return;let V=await $.get(Q);if(!V)return;await $.transition(Q,b6,{usage:M(V.usage??R(),Z)}).catch(()=>{})}class AQ{id;threadId;toolCallId;toolName;owner;summary;signal=new AbortController().signal;usage=R();attachments;constructor($,Q){this.id=$.id,this.threadId=$.threadId,this.toolCallId=$.toolCallId,this.toolName=$.toolName,this.owner=$.owner,this.summary=$.summary;let Z=$.attachmentScope?new p(Q.attachments,Q.attachmentStorage,{key:$.attachmentScope}):null,V=()=>{if(!Z)throw new g("The run that started this job had no attachment scope, so the job cannot store or read files. See `attachmentScope()` on the controller.");return Z};this.attachments={put:(G,J={})=>V().put(G,J),get:(G)=>V().get(G),read:(G)=>V().read(G),file:(G)=>V().file(G)}}generate($){return K9($,{origin:{threadId:this.threadId,toolCallId:this.toolCallId,jobId:this.id},settled:(Q)=>{this.usage=M(this.usage,Q.usage)}})}async generateImage($,Q){let{name:Z,...V}=Q,G=await $.generate({...V,signal:this.signal});return this.park($,G,Z)}async editImage($,Q){let{name:Z,images:V,mask:G,...J}=Q,W=async(K)=>typeof K==="string"?await this.attachments.file(K):K,X=await $.edit({...J,images:await Promise.all(V.map(W)),...G?{mask:await W(G)}:{},signal:this.signal});return this.park($,X,Z)}async park($,Q,Z){this.usage=M(this.usage,Q.usage);let V=Q.mimeType==="image/jpeg"?"jpg":"png";return{attachment:await this.attachments.put(Q.image,{name:Z??`${$.name}.${V}`,mimeType:Q.mimeType}),size:Q.size,mimeType:Q.mimeType,usage:Q.usage}}}function m($){let Q=new Set;for(let Z of $)for(let V of Z.content??[]){if(V.type!=="tool-call")continue;for(let G of V.attachments??[])if(G&&"shown"in G&&G.shown)Q.add(G.shown.messageId)}return Q}function L9($){if($.length===0)return[];let Q=m($),Z=[0];for(let V=1;V<$.length;V++){let G=$[V];if(G.role==="user"&&!Q.has(G.id))Z.push(V)}return Z}function y6($){let Q=L9($);return Q.map((Z,V)=>$.slice(Z,Q[V+1]??$.length))}function EQ($){try{return JSON.stringify($).length}catch{return 0}}var h6=4,kQ=10,xQ="[Earlier turns of this conversation are not shown.]";function r($,Q={}){let Z=[...$],V=L9(Z),G=g6(Q),J=f9(Q.maxTurns)??1/0,W=Math.max(1,Math.floor(f9(Q.step)??kQ));if(V.length<=1||J>=V.length&&G===1/0)return{messages:Z,start:0,omittedTurns:0,omittedMessages:0};let X=Array.from({length:Z.length+1},()=>0);if(G!==1/0)for(let U=Z.length-1;U>=0;U--)X[U]=X[U+1]+EQ(Z[U]);let K=(U)=>V.length-U<=J&&X[V[U]]<=G,Y=-1;for(let U=0;U<V.length;U+=W)if(K(U)){Y=U;break}if(Y<0){for(let U=0;U<V.length;U++)if(K(U)){Y=U;break}}if(Y<0)Y=V.length-1;if(Y===0)return{messages:Z,start:0,omittedTurns:0,omittedMessages:0};let H=V[Y],B=Z.slice(0,H),z=B.filter((U)=>U.role==="system"),D=u6(B,Z.slice(H)),L={turns:Y,messages:B.length-z.length},F=typeof Q.note==="function"?Q.note(L):Q.note===void 0?xQ:Q.note;if(F){let U=D[0];D[0]={...U,content:[{type:"text",text:F},...U.content]}}return{messages:[...z,...D],start:H,omittedTurns:L.turns,omittedMessages:L.messages}}function f9($){return typeof $==="number"&&$>0?$:void 0}function g6($){let Q=f9($.maxBytes)??1/0,Z=f9($.maxTokens);return Math.min(Q,Z===void 0?1/0:Z*h6)}function TQ($,Q){let Z=Array.isArray($?.namespaces)?$.namespaces:[],V=Array.isArray($?.loaded)?$.loaded:[];return Q.namespace?Z.includes(Q.namespace):V.includes(String(Q.name))}function L$($){return Array.isArray($.toolSearches)?$.toolSearches:[]}function u6($,Q){let Z=[];for(let Y of $)for(let H of Y.content??[])if(H.type==="tool-call")Z.push(...L$(H));if(Z.length===0)return Q;let V=[],G=new Set,J;if(Q.forEach((Y,H)=>{(Y.content??[]).forEach((B,z)=>{if(B.type!=="tool-call"||B.partial)return;if(V.push(...L$(B)),V.some((L)=>TQ(L,B)))return;let D=Z.filter((L)=>TQ(L,B));if(D.length===0)return;for(let L of D)G.add(L);J??={message:H,part:z}})}),!J)return Q;let W=Z.filter((Y)=>G.has(Y)),X=[...Q],K=X[J.message];return X[J.message]={...K,content:K.content.map((Y,H)=>H===J.part&&Y.type==="tool-call"?{...Y,toolSearches:[...W,...L$(Y)]}:Y)},X}var fQ=1000,c6=24000,p6=20000,vQ=1e5,m6=120000,yQ=["You keep a running summary of a conversation between a user and an AI assistant.","The assistant will continue the conversation with only your summary and the latest turns, so the summary has to carry everything from the earlier turns it may still need.","You are given the summary so far (possibly empty) and the turns that came after it. Answer the updated summary, which replaces the old one.","Keep: the user's goals, preferences and constraints; decisions made and why; facts, names, ids, numbers, dates, file names and URLs that may matter later; what tools were used and their important results; open questions and unfinished work.","Drop greetings, repetition and anything later turns superseded. Do not invent anything, and do not answer the user.","Write terse prose or bullet points, in the language of the conversation."].join(" "),hQ="[Summary of the earlier turns of this conversation, which are not shown:]",l6=8;class N${ttlMs;threads=new Map;lastSweep=0;constructor($=86400000){this.ttlMs=$}async loadSummaries($){this.sweep();let Q=this.threads.get($);if(!Q)return[];return Q.touchedAt=Date.now(),Q.summaries.slice()}async saveSummary($,Q){this.sweep();let Z=this.threads.get($)??{summaries:[],touchedAt:Date.now()};Z.summaries=h9(Z.summaries,Q),Z.touchedAt=Date.now(),this.threads.set($,Z)}delete($){this.threads.delete($)}sweep($=Date.now()){if($-this.lastSweep<60000)return;this.lastSweep=$;for(let[Q,Z]of this.threads)if($-Z.touchedAt>this.ttlMs)this.threads.delete(Q)}}function h9($,Q){return[Q,...$.filter((Z)=>Z.cutMessageId!==Q.cutMessageId)].slice(0,l6)}var C$=new N$;function gQ($){let Q=$;return typeof Q?.loadSummaries==="function"&&typeof Q?.saveSummary==="function"}function uQ($,Q,Z){let V=u(Z.maxSummaryTokens)??fQ,G=(K)=>Math.max(1,K-V),J={...Q,...u(Q.maxTokens)?{maxTokens:G(Q.maxTokens)}:{},...u(Q.maxBytes)?{maxBytes:Math.max(1,Q.maxBytes-V*P$)}:{}},W=d6(Q,Z),X={...J,note:!1,...W?{maxTokens:Math.min(J.maxTokens??1/0,G(W))}:{}};return{plain:J,cut:r($,X),maxSummaryTokens:V}}function d6($,Q){if(Q.triggerTokens===!1)return;let Z=u(Q.triggerTokens||void 0);if(Z)return Z;if(u($.maxTokens)||u($.maxBytes))return;return vQ}async function cQ($){let{history:Q,window:Z,compact:V}=$,{plain:G,cut:J,maxSummaryTokens:W}=uQ(Q,Z,V);if(J.omittedTurns===0)return J.messages;let X=`${Q[J.start].id}:${J.start}`,K=$.memo?.get(X);if(K===void 0){try{K=await t6($,J.start,W)}catch(D){if($.signal.aborted)throw D;K=null}if(!$.signal.aborted)$.memo?.set(X,K)}if(!K)return r(Q,G).messages;let Y=Q.length-J.start,H=J.messages.slice(0,J.messages.length-Y),B=J.messages.slice(J.messages.length-Y),z=Q[J.start];return[...H,{id:`summary_${z.id}`,role:"user",content:[{type:"text",text:`${hQ}
|
|
3
3
|
${K.text}`}],createdAt:z.createdAt},...B]}var IQ="\x00next-turn";function pQ($){let Q=i6($).finally(()=>y9.delete(Q));return y9.add(Q),Q}var y9=new Set;async function i6($){try{let Q={id:IQ,role:"user",content:[{type:"text",text:""}],createdAt:new Date().toISOString()},Z=[...$.history,Q],V=[...$.stored,Q],{cut:G,maxSummaryTokens:J}=uQ(Z,$.window,$.compact);if(G.omittedTurns===0||Z[G.start].id===IQ)return;let W=mQ({...$,history:Z,stored:V},G.start);if((await g9($.store,$.threadId)).some(W.matches))return;await lQ(W,{...$,history:Z,stored:V},G.start,J).promise}catch{}}async function n6(){while(P9.size>0||y9.size>0)await Promise.allSettled([...y9,...[...P9.values()].map(($)=>$.promise)])}var P9=new Map,l=new Map,o6=1000;function s6($,Q){l.set($,M(l.get($)??R(),Q));while(l.size>o6)l.delete(l.keys().next().value)}function wQ($,Q){let Z=l.get($);if(!Z)return;l.delete($),Q(Z)}function mQ($,Q){let Z=$.history[Q].id,V=G8($.stored,Q),G=V[Q];return{key:`${$.threadId}\x00${Z}\x00${G}`,fingerprints:V,matches:(J)=>J?.cutMessageId===Z&&J.fingerprint===G}}async function t6($,Q,Z){let V=mQ($,Q),G=(await g9($.store,$.threadId)).find(V.matches);if(G)return wQ(V.key,$.onUsage),G;let J=lQ(V,$,Q,Z);if(J.owed)$.onUsage(J.owed),J.owed=void 0;J.payers.push($.onUsage);try{return await a6(J.promise,$.signal)}finally{J.payers.splice(J.payers.indexOf($.onUsage),1),wQ(V.key,$.onUsage)}}function lQ($,Q,Z,V){let G=P9.get($.key);if(G)return G;let J={promise:void 0,payers:[],owed:void 0},W=(X)=>{let K=J.payers[0];if(K)K(X);else J.owed=M(J.owed??R(),X)};return J.promise=(async()=>{let{store:X,threadId:K}=Q,Y=u(Q.compact.lockWaitMs)??p6,H=null;if(X.lockSummary){try{H=await X.lockSummary(K,Q.history[Z].id,Y+60000)}catch{H=null}if(!H)return e6(Q,$.matches,Y)}try{let B=await g9(X,K),z=B.find($.matches);if(z)return z;return await $8(Q,B,$.fingerprints,Z,V,W)}finally{if(H)await H().catch(()=>{})}})().catch(()=>null).finally(()=>{if(P9.delete($.key),J.owed)s6($.key,J.owed);J.owed=void 0}),P9.set($.key,J),J}function a6($,Q){if(Q.aborted)return Promise.reject(Q.reason);return new Promise((Z,V)=>{let G=()=>V(Q.reason);Q.addEventListener("abort",G,{once:!0}),$.then((J)=>{Q.removeEventListener("abort",G),Z(J)},(J)=>{Q.removeEventListener("abort",G),V(J)})})}async function g9($,Q){try{let Z=await $.loadSummaries(Q);return Array.isArray(Z)?Z.filter(r6):[]}catch{return[]}}function r6($){let Q=$;return!!Q&&typeof Q.cutMessageId==="string"&&typeof Q.text==="string"&&typeof Q.fingerprint==="string"}async function e6($,Q,Z){let V=Date.now()+Z;while(Date.now()<V){await new Promise((J)=>setTimeout(J,250));let G=(await g9($.store,$.threadId)).find(Q);if(G)return G}return null}async function $8($,Q,Z,V,G,J){let{history:W,compact:X}=$,K=L9(W),Y=K.indexOf(V),H=new Map(K.map((O)=>[W[O].id,O])),B,z=0;for(let O of Q){let A=H.get(O.cutMessageId);if(A===void 0||A>=V||A<=z)continue;if(O.fingerprint!==Z[A])continue;B=O,z=A}let D=(u(X.chunkTokens)??c6)*P$,L=Q8(W,K,z,V,D),F=G*P$,U=`${X.instructions??yQ} Keep the summary under about ${Math.round(G*0.75)} words.`,P=B?.text??"",q=R();for(let O of L){let A=await Y$({provider:X.provider??$.provider,instructions:U,prompt:`Summary so far:
|
|
4
4
|
${P||"(none yet: these are the first turns of the conversation)"}
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Kc as o}from"./chunk-
|
|
2
|
+
import{Kc as o}from"./chunk-v1tfdgy1.js";import{Lc as i}from"./chunk-n672d4g8.js";import{_g as t}from"./chunk-cbqazg9k.js";import{Zh as r}from"./chunk-jmg2zsaf.js";class n extends i{register(){this.app.singleton(r,()=>new r(t(o(),this.app.config.get("translation",{}))))}}
|
|
3
3
|
export{n as eb};
|
|
4
4
|
|
|
5
5
|
//# debugId=C32FA7347CB1EE1064756E2164756E21
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Kg as M}from"./chunk-
|
|
2
|
+
import{Kg as M}from"./chunk-pn8v6fj2.js";import{bi as P}from"./chunk-t4yh4nf9.js";class C{spent=new Map;sweepAt=1024;async consume(J,Q){return this.consumeSync(J,Q)}consumeSync(J,Q,Z=Date.now()){if(this.spent.size>=this.sweepAt)this.sweep(Z);let W=this.spent.get(J);if(W!==void 0&&W>Z)return!1;return this.spent.set(J,Q),!0}get size(){return this.spent.size}sweep(J){for(let[Q,Z]of this.spent)if(Z<=J)this.spent.delete(Q);this.sweepAt=Math.max(1024,this.spent.size*2)}}class N{injectedClient;prefix;constructor(J={}){this.injectedClient=J.client,this.prefix=J.prefix??"gemi:ai:nonce"}async consume(J,Q){let Z=Math.max(1,Math.ceil(Q-Date.now()));return await this.client.send("SET",[`${this.prefix}:${J}`,"1","PX",String(Z),"NX"])==="OK"}get client(){if(this.injectedClient)return this.injectedClient;let J=P(),Q=J.bound(M)?J.make(M).client:void 0;if(!Q)throw Error("RedisNonceStore could not reach the Redis client. Register RedisServiceProvider on your application, or pass a client: new RedisNonceStore({ client }).");return Q}}var S=new C;class D extends Error{retryable;constructor(J,Q={}){super(J,Q.cause!==void 0?{cause:Q.cause}:void 0);this.name="ToolError",this.retryable=Q.retryable??!0}}var u={provider_error:"The model provider returned an error.",rate_limited:"The model provider is rate limiting requests. Try again shortly.",context_length_exceeded:"The conversation is too long for the model.",content_filtered:"The model provider's content filter blocked this request.",invalid_tool_input:"The model provider rejected the request.",tool_error:"A tool failed.",unknown:"The run failed unexpectedly."};function V(J,Q){if(Q.source==="tool"){if(Q.cause instanceof D)return J;return{...J,message:`The tool "${Q.toolName}" failed with an unexpected error.`}}let Z=u[J.code];return Z===void 0?J:{...J,message:Z}}function e(J,Q,Z,W){let $;try{$=(J??V)(Q,Z)}catch(X){W(X),$=V(Q,Z)}return{code:$.code,message:$.message,...$.toolCallId!==void 0?{toolCallId:$.toolCallId}:{},retryable:$.retryable}}var L=new WeakMap;function JJ(J,Q){if(J!==Q)L.set(J,Q)}function QJ(J){return L.get(J)??J}import{createHmac as E,hkdfSync as m,randomBytes as k,timingSafeEqual as d}from"crypto";var z="agt2",j="agt1",O=[z,j],G=86400000,p=Date.now()+G;function f(J){return J<=p}var v="gemi.ai.pending-call.v1",I="gemi.ai.nested-run.v1",l="gemi.ai.execution-receipt.v1",t="gemi.ai.signing",b=new Map;function H(J,Q){let Z=K(Q),W=`${J}\x00${Z}`,$=b.get(W);if(!$){if($=Buffer.from(m("sha256",Z,t,J,32)),b.size>64)b.clear();b.set(W,$)}return $}function K(J){let Q=J??process.env.SECRET;if(!Q)throw Error("Signing a pending tool call needs an app secret. Set SECRET in the environment.");return Q}function q(J){if(J===null||typeof J!=="object")return JSON.stringify(J)??"null";if(Array.isArray(J))return`[${J.map(q).join(",")}]`;let Q=J;return`{${Object.keys(Q).filter((W)=>Q[W]!==void 0).sort().map((W)=>`${JSON.stringify(W)}:${q(Q[W])}`).join(",")}}`}function c(J){return J.map((Q)=>`${Q.length}:${Q}`).join("")}function B(J,Q){return E("sha256",J).update(c(Q)).digest()}function x(J,Q){let Z=Buffer.from(J.split(".")[4],"base64url");return Z.length===Q.length&&d(Z,Q)}function U(J){return q(J??null)}function R(J,Q,Z){return[z,J.runId,J.toolCallId,J.name,J.kind,Q,String(Z),q(J.input),q(J.path??[]),U(J.subject)]}function n(J,Q,Z){let W=[j,J.runId,J.toolCallId,J.name,J.kind,Q,String(Z),q(J.input)];if(J.path&&J.path.length>0)W.push(q(J.path));return W}var T=(J)=>Buffer.from(J,"utf8").toString("base64url"),o=(J)=>Buffer.from(J,"base64url").toString("utf8");function qJ(J,Q={}){let Z=H(v,Q.secret),$=(Q.now??Date.now())+(Q.ttlMs??G),X=k(12).toString("base64url"),h=B(Z,R(J,X,$)).toString("base64url");return[z,T(J.runId),X,$.toString(36),h].join(".")}function a(J){return Y(J,O)}function Y(J,Q){let Z=J.split(".");if(Z.length!==5||!Q.includes(Z[0]))return null;let W=Number.parseInt(Z[3],36);if(!Number.isFinite(W))return null;try{return{runId:o(Z[1]),nonce:Z[2],expiresAt:W,version:Z[0]}}catch{return null}}function XJ(J,Q,Z={}){let W=Y(J,O);if(!W)return{ok:!1,reason:"malformed"};if(W.version===j&&!f(W.expiresAt))return{ok:!1,reason:"forged"};let $=W.version===j?B(K(Z.secret),n(Q,W.nonce,W.expiresAt)):B(H(v,Z.secret),R(Q,W.nonce,W.expiresAt));if(!x(J,$))return{ok:!1,reason:"forged"};if((Z.now??Date.now())>W.expiresAt)return{ok:!1,reason:"expired"};return{ok:!0,runId:W.runId,nonce:W.nonce,expiresAt:W.expiresAt}}var F="agn2",w="agn1",A=[F,w];function _(J,Q,Z){return[...y(J,Q,Z,F),U(J.subject)]}function y(J,Q,Z,W=w){return[W,J.runId,q(J.path),J.nestedRunId,Q,String(Z),q([...J.open].sort()),q(J.input)]}function BJ(J,Q={}){let Z=H(I,Q.secret),$=(Q.now??Date.now())+(Q.ttlMs??G),X=k(12).toString("base64url"),h=B(Z,_(J,X,$)).toString("base64url");return[F,T(J.runId),X,$.toString(36),h].join(".")}function HJ(J,Q,Z={}){let W=Y(J,A);if(!W)return{ok:!1,reason:"malformed"};if(W.version===w&&!f(W.expiresAt))return{ok:!1,reason:"forged"};let $={...Q,runId:W.runId},X=W.version===w?B(K(Z.secret),y($,W.nonce,W.expiresAt)):B(H(I,Z.secret),_($,W.nonce,W.expiresAt));if(!x(J,X))return{ok:!1,reason:"forged"};if((Z.now??Date.now())>W.expiresAt)return{ok:!1,reason:"expired"};return{ok:!0,runId:W.runId,nonce:W.nonce,expiresAt:W.expiresAt}}function bJ(J,Q,Z={}){let W=H(l,Z.secret);return B(W,[J,Q.runId,Q.toolCallId,Q.name,Q.kind,q(Q.input),q(Q.path??[]),U(Q.subject)]).toString("base64url")}function jJ(J,Q){return g(Q,a(J))}function wJ(J,Q){return g(Q,Y(J,A))}async function g(J,Q){if(!Q)return!1;return J.consume(Q.nonce,Q.expiresAt)}
|
|
3
3
|
export{C as Sb,N as Tb,S as Ub,H as Vb,q as Wb,qJ as Xb,a as Yb,XJ as Zb,BJ as _b,HJ as $b,bJ as ac,jJ as bc,wJ as cc,D as dc,V as ec,e as fc,JJ as gc,QJ as hc};
|
|
4
4
|
|
|
5
5
|
//# debugId=9F5261FBB47F185564756E2164756E21
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{AsyncLocalStorage as E}from"async_hooks";class Q{content={title:"Gemi App",description:null,openGraph:null,htmlAttributes:null,canonical:null,alternates:null};touched=!1;render(){return{title:this.content.title,description:this.content.description,openGraph:this.content.openGraph,htmlAttributes:this.content.htmlAttributes,canonical:this.content.canonical,alternates:this.content.alternates}}htmlAttributes(j){this.touched=!0;let B=Object.fromEntries(Object.entries(j).filter(([,z])=>z!==void 0));this.content.htmlAttributes={...this.content.htmlAttributes,...B}}canonical(j){this.touched=!0,this.content.canonical=j}alternates(j){this.touched=!0,this.content.alternates=j}title(j){this.touched=!0,this.content.title=j}description(j){this.touched=!0,this.content.description=j}openGraph({title:j,description:B,type:z,url:G,image:J,imageAlt:U,imageWidth:V,imageHeight:X,twitterImage:Y=J,twitterImageAlt:K=U,twitterImageWidth:N=V,twitterImageHeight:b=X}){this.touched=!0;let Z=J,$=Y;if(J&&!J.startsWith("http"))Z=`${process.env.HOST_NAME}${J}`,$=`${process.env.HOST_NAME}${Y}`;this.content.openGraph=Object.fromEntries(Object.entries({title:j,description:B,type:z,url:G,image:Z,imageAlt:U,imageWidth:V,imageHeight:X,twitterImage:$,twitterImageAlt:K,twitterImageWidth:N,twitterImageHeight:b}).filter(([H,M])=>M!==void 0))}}function F(j,B,z={}){return[`${j}=${B}`,z.maxAge?`Max-Age=${z.maxAge}`:"",z.httpOnly?"HttpOnly":"",z.secure?"Secure":"",z.sameSite?`SameSite=${z.sameSite}`:"SameSite=Strict",z.path?`Path=${z.path}`:"Path=/",z.domain?`Domain=${z.domain}`:"",z.expires?`Expires=${z.expires.toUTCString()}`:"",z.partitioned?"Partitioned":""].filter((G)=>G!=="").join("; ")}var P=new E;class L{req;cookies=new Set;headers=new Headers;serverQueries=null;user=null;csrfHmac=null;locale=null;metadata=new Q;rangeRequest=null;sessionId=null;featureEvaluations=null;featureContext=null;featureBuckets=null;pendingWork=new Set;ended=!1;constructor(j){this.req=j}waitUntil(j){if(this.ended)return;let B=Promise.resolve(j).then(()=>{},()=>{});this.pendingWork.add(B),B.then(()=>this.pendingWork.delete(B))}hasPendingWork(){return this.pendingWork.size>0}async whenIdle(){while(this.pendingWork.size>0)await Promise.all(Array.from(this.pendingWork))}setLocale(j){this.locale=j}renderMeta(){return this.metadata.render()}setCSRFHmac(j){this.csrfHmac=j}setCookie(j,B,z={}){this.cookies.add(F(j,B,z))}deleteCookie(j,B={}){this.cookies.add(F(j,"",{...B,maxAge:-1}))}setHeaders(j,B){this.headers.set(j,B)}setUser(j){this.user=j}setRequest(j){this.req=j}destroy(){this.ended=!0,delete this.cookies,delete this.headers,this.serverQueries=null,this.sessionId=null,this.featureEvaluations=null,this.featureContext=null,this.featureBuckets=null,delete this.user}}var D="session_id";function y(){let j=T.getStore();if(!j)return null;if(j.sessionId)return j.sessionId;let B=j.req?.cookies?.get(D);if(B)j.sessionId=B;return j.sessionId}function A(){let j=T.getStore();if(!j)return null;let B=y();if(B)return B;let z=Bun.randomUUIDv7();return j.sessionId=z,j.setCookie(D,z,{httpOnly:!0,secure:Bun.env.NODE_ENV==="production",sameSite:"Lax",expires:new Date(Date.now()+31536000000)}),z}class T{static getStore(){return P.getStore()}static setRequest(j){P.getStore().req=j}static run(j,B,z){let G=new L(j);if(z)G.user=z.user;return P.run(G,B)}static runWith(j,B){return P.run(j,B)}static exit(j){return P.exit(j)}}
|
|
3
|
+
export{y as Ug,A as Vg,T as Wg};
|
|
4
|
+
|
|
5
|
+
//# debugId=6CD53DADDD8CD4E664756E2164756E21
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
"sources": ["../http/requestContext.ts", "../http/Metadata.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import { AsyncLocalStorage } from \"node:async_hooks\";\nimport type { HttpRequest } from \"./HttpRequest\";\nimport { Metadata } from \"./Metadata\";\nimport type { ByteRange } from \"./range\";\n// Type-only: `services/router` imports from `http`, so a runtime import here\n// would be circular.\nimport type { ServerQueryStore } from \"../services/router/ServerQueryStore\";\n\nexport interface CreateCookieOptions {\n maxAge?: number;\n expires?: Date;\n httpOnly?: boolean;\n secure?: boolean;\n sameSite?: \"Strict\" | \"Lax\";\n path?: string;\n domain?: string;\n partitioned?: boolean;\n}\n\nexport function createCookie(\n name: string,\n value: string,\n options: CreateCookieOptions = {},\n) {\n return [\n `${name}=${value}`,\n options.maxAge ? `Max-Age=${options.maxAge}` : \"\",\n options.httpOnly ? \"HttpOnly\" : \"\",\n options.secure ? \"Secure\" : \"\",\n options.sameSite ? `SameSite=${options.sameSite}` : \"SameSite=Strict\",\n options.path ? `Path=${options.path}` : \"Path=/\",\n options.domain ? `Domain=${options.domain}` : \"\",\n options.expires ? `Expires=${options.expires.toUTCString()}` : \"\",\n options.partitioned ? \"Partitioned\" : \"\",\n ]\n .filter((i) => i !== \"\")\n .join(\"; \");\n}\n\nconst requestContext = new AsyncLocalStorage<Store>();\n\n/**\n * What a route's request context takes over from the global middleware list's\n * (see `runGlobalMiddleware`): the user, so one the list resolved is not\n * looked up a second time.\n */\nexport interface CarriedContext {\n user: any;\n}\n\nclass Store {\n cookies: Set<string> = new Set();\n headers: Headers = new Headers();\n /**\n * Every server-side query of this request — prefetched or discovered during\n * the streaming render. Assigned by the view router (or lazily by the\n * `Query` facade); `null` for api requests, which must not query themselves.\n */\n serverQueries: ServerQueryStore | null = null;\n user: any = null;\n csrfHmac: string | null = null;\n locale: string | null = null;\n metadata = new Metadata();\n /**\n * The parsed `Range` of the in-flight request, picked up by\n * `FileStorage.read()` so a range reaches the storage backend without every\n * handler having to thread it through by hand.\n *\n * Only populated inside a `this.stream()` route, and cleared once that route\n * returns: a `FileStorage.read()` in an ordinary handler must never start\n * silently returning partial bytes.\n */\n rangeRequest: ByteRange | null = null;\n\n /**\n * This request's `session_id`, once read or minted.\n *\n * The cookie itself cannot answer for it. `setCookie` appends a *serialized*\n * `Set-Cookie` string to `cookies`, so a value written during this request is\n * not readable back out of it, and `req.cookies` still holds only what the\n * browser sent. Anything needing the id in the same request that mints it —\n * feature-flag bucketing, most obviously — has to read it from here.\n */\n sessionId: string | null = null;\n\n /**\n * This request's feature-flag evaluations, computed once.\n *\n * One map per request is what keeps a handler and the SSR payload from\n * disagreeing: a percentage rollout evaluated twice would be consistent\n * anyway — the bucketing is deterministic — but an attribute hook reading a\n * clock, or a `now`-based rule, would not be. Anything the page renders and\n * anything the server branched on have to be the same answer.\n */\n featureEvaluations: Map<string, unknown> | null = null;\n /** The context those evaluations were made against, built at most once. */\n featureContext: unknown = null;\n /** Bucket memo, shared across every flag evaluated for this request. */\n featureBuckets: Map<string, number> | null = null;\n\n /**\n * What `waitUntil` was handed and has not settled yet. Public only because\n * `req.ctx()`'s declared type spells this class out, which a private field\n * cannot be part of; nothing outside the store should touch either.\n */\n pendingWork = new Set<Promise<void>>();\n ended = false;\n\n constructor(public req: HttpRequest) {}\n\n /**\n * Keeps this request open until `work` settles: the api router holds\n * `onRequestEnd` and `destroy()` back until then, so code in `work` still\n * finds `user`, headers and cookies here.\n *\n * For work that outlives the response on purpose. An agent run is the\n * reason it exists: a client that disconnects has not stopped the run, and\n * its next tool call still reads the user who started it. Ignored once the\n * request has ended — there is nothing left to hold open.\n *\n * Only api routes honour this. A view request ends regardless, so work\n * handed to its store — a run started in a view loader — finds no user.\n */\n waitUntil(work: PromiseLike<unknown>) {\n if (this.ended) {\n return;\n }\n const settled = Promise.resolve(work).then(\n () => {},\n () => {},\n );\n this.pendingWork.add(settled);\n void settled.then(() => this.pendingWork.delete(settled));\n }\n\n /** Whether anything handed to `waitUntil` is still running. */\n hasPendingWork() {\n return this.pendingWork.size > 0;\n }\n\n /**\n * Settles once everything handed to `waitUntil` has, including work added\n * while waiting — a run can start another before it ends.\n */\n async whenIdle() {\n while (this.pendingWork.size > 0) {\n await Promise.all(Array.from(this.pendingWork));\n }\n }\n\n setLocale(locale: string) {\n this.locale = locale;\n }\n\n renderMeta() {\n return this.metadata.render();\n }\n\n setCSRFHmac(hmac: string) {\n this.csrfHmac = hmac;\n }\n\n setCookie(name: string, value: string, options: CreateCookieOptions = {}) {\n this.cookies.add(createCookie(name, value, options));\n }\n\n /**\n * A cookie set with a `domain` or `path` is only cleared by a deletion that\n * names the same ones.\n */\n deleteCookie(name: string, options: Pick<CreateCookieOptions, \"domain\" | \"path\"> = {}) {\n this.cookies.add(createCookie(name, \"\", { ...options, maxAge: -1 }));\n }\n\n setHeaders(name: string, value: string) {\n this.headers.set(name, value);\n }\n\n setUser(user: any) {\n this.user = user;\n }\n\n setRequest(req: HttpRequest<any, any>) {\n this.req = req;\n }\n\n destroy() {\n this.ended = true;\n delete this.cookies;\n delete this.headers;\n this.serverQueries = null;\n this.sessionId = null;\n this.featureEvaluations = null;\n this.featureContext = null;\n this.featureBuckets = null;\n delete this.user;\n }\n}\n\nexport const SESSION_ID_COOKIE = \"session_id\";\n\n/**\n * The `session_id` the browser sent, or the one minted earlier in this request.\n * Never mints one, so it is safe on an api request, where a `Set-Cookie` nobody\n * asked for would be a surprise.\n *\n * `null` outside a request, and for an anonymous visitor whose first request is\n * not a view — both meaning \"no stable subject\", which callers must handle\n * rather than paper over with a random value. A per-call random id would give\n * every request its own bucket, which is worse than no bucketing at all: a\n * percentage rollout would reshuffle on every page load.\n *\n * ## It is client-supplied, and unauthenticated\n *\n * Whatever the browser sent, unvalidated. It is a bucketing subject, not a\n * credential — never authenticate or authorize on it. A visitor can pick a value\n * that lands them in any percentage rollout, and signing it would not change\n * that: they can discard the cookie and collect fresh ones until one does. Load\n * bearing enough to state, because `.feature()` route gating is built on top of\n * evaluation — see its documentation for what may safely gate a route.\n */\nexport function sessionId(): string | null {\n const store = RequestContext.getStore();\n if (!store) {\n return null;\n }\n if (store.sessionId) {\n return store.sessionId;\n }\n const sent = store.req?.cookies?.get(SESSION_ID_COOKIE);\n if (sent) {\n store.sessionId = sent;\n }\n return store.sessionId;\n}\n\n/**\n * The same, but mints and sets the cookie when the browser sent none.\n *\n * Call this once per **view** request, early enough that everything downstream —\n * flag evaluation included — sees the same id the browser is about to be given.\n * It used to live inline in `ViewRouteDispatcher.onRequestEnd`, which ran only\n * on the document path and only after the response was decided, so a client-side\n * navigation minted nothing and a first-ever visitor had no id at the point\n * flags were evaluated.\n */\nexport function ensureSessionId(): string | null {\n const store = RequestContext.getStore();\n if (!store) {\n return null;\n }\n const existing = sessionId();\n if (existing) {\n return existing;\n }\n\n const minted = Bun.randomUUIDv7();\n store.sessionId = minted;\n store.setCookie(SESSION_ID_COOKIE, minted, {\n httpOnly: true,\n secure: process.env.NODE_ENV === \"production\",\n // `Lax`, not `Strict`, and the difference is load-bearing. `Strict`\n // withholds the cookie on cross-site *top-level navigation*, so a visitor\n // arriving from a search result or a shared link would arrive without it,\n // be minted a new id, and overwrite the old one — re-bucketing on every\n // external entry, which is how most anonymous traffic arrives. This is not\n // a credential (`access_token` stays `Strict`); it is an opaque bucketing\n // id, and `Lax` still blocks cross-site POST.\n sameSite: \"Lax\",\n expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365),\n });\n return minted;\n}\n\nexport class RequestContext {\n static getStore() {\n return requestContext.getStore()!;\n }\n\n static setRequest(req: HttpRequest<any, any>) {\n requestContext.getStore().req = req;\n }\n\n /**\n * Opens a fresh request scope. `carried` seeds it with what the global\n * middleware list resolved for the same request; nothing else crosses over.\n */\n static run<T>(\n httpRequest: HttpRequest,\n fn: () => T,\n carried?: CarriedContext | null,\n ): T {\n const store = new Store(httpRequest);\n if (carried) {\n store.user = carried.user;\n }\n return requestContext.run(store, fn);\n }\n\n /**\n * Re-enters an *existing* request scope. Stream lifecycle callbacks fire\n * after the HTTP server has taken over the response body — outside the\n * AsyncLocalStorage scope the request ran in — so the view router captures\n * the live store and re-enters it around user-facing hooks, keeping\n * `req.ctx()` (and everything context-backed) working inside them.\n */\n static runWith<T>(store: Store, fn: () => T): T {\n return requestContext.run(store, fn);\n }\n\n /**\n * Runs `fn` outside any request scope, as the server's own `fetch` handler\n * is. For a request dispatched from inside another one, which must start from\n * where a client's request would, not from its initiator's store.\n */\n static exit<T>(fn: () => T): T {\n return requestContext.exit(fn);\n }\n}\n",
|
|
6
|
-
"export type OpenGraphParams = {\n title: string;\n description?: string;\n type: string;\n url: string;\n image: string;\n imageAlt?: string;\n imageWidth?: number;\n imageHeight?: number;\n twitterImage?: string;\n twitterImageAlt?: string;\n twitterImageWidth?: number;\n twitterImageHeight?: number;\n};\nexport class Metadata {\n content: any = {\n title: \"Gemi App\",\n description: null,\n openGraph: null,\n };\n\n /**\n * Whether a handler set anything, as opposed to `content` still being the\n * defaults. A partially rendered response that touched no metadata sends\n * none, so the client keeps what the skipped segments put there.\n */\n touched = false;\n\n render() {\n return {\n title: this.content.title,\n description: this.content.description,\n openGraph: this.content.openGraph,\n };\n }\n\n title(title: string) {\n this.touched = true;\n this.content.title = title;\n }\n\n description(description: string) {\n this.touched = true;\n this.content.description = description;\n }\n\n openGraph({\n title,\n description,\n type,\n url,\n image,\n imageAlt,\n imageWidth,\n imageHeight,\n twitterImage = image,\n twitterImageAlt = imageAlt,\n twitterImageWidth = imageWidth,\n twitterImageHeight = imageHeight,\n }: OpenGraphParams) {\n this.touched = true;\n let _image = image;\n let _twitterImage = twitterImage;\n if (image && !image.startsWith(\"http\")) {\n _image = `${process.env.HOST_NAME}${image}`;\n _twitterImage = `${process.env.HOST_NAME}${twitterImage}`;\n }\n this.content.openGraph = Object.fromEntries(\n Object.entries({\n title,\n description,\n type,\n url,\n image: _image,\n imageAlt,\n imageWidth,\n imageHeight,\n twitterImage: _twitterImage,\n twitterImageAlt,\n twitterImageWidth,\n twitterImageHeight,\n }).filter(([_, value]) => value !== undefined),\n );\n }\n}\n"
|
|
6
|
+
"export type OpenGraphParams = {\n title: string;\n description?: string;\n type: string;\n url: string;\n image: string;\n imageAlt?: string;\n imageWidth?: number;\n imageHeight?: number;\n twitterImage?: string;\n twitterImageAlt?: string;\n twitterImageWidth?: number;\n twitterImageHeight?: number;\n};\n/**\n * Attributes for the document's `<html>` element, handed to the root (or a\n * static view's) layout as its `htmlAttributes` prop.\n */\nexport type HtmlAttributes = {\n /** The document's language, e.g. `\"tr\"`. Defaults to the request's locale. */\n lang?: string;\n /** Text direction. Defaults to the one `lang` is written in. */\n dir?: \"ltr\" | \"rtl\" | \"auto\";\n};\n\n/** One `<link rel=\"alternate\" hreflang>`: the same page in another language. */\nexport type AlternateLink = {\n /** A BCP 47 tag, or `\"x-default\"` for the page to use when none matches. */\n hrefLang: string;\n href: string;\n};\n\nexport class Metadata {\n content: any = {\n title: \"Gemi App\",\n description: null,\n openGraph: null,\n htmlAttributes: null,\n canonical: null,\n alternates: null,\n };\n\n /**\n * Whether a handler set anything, as opposed to `content` still being the\n * defaults. A partially rendered response that touched no metadata sends\n * none, so the client keeps what the skipped segments put there.\n */\n touched = false;\n\n render() {\n return {\n title: this.content.title,\n description: this.content.description,\n openGraph: this.content.openGraph,\n htmlAttributes: this.content.htmlAttributes,\n canonical: this.content.canonical,\n alternates: this.content.alternates,\n };\n }\n\n /** Merged into what earlier calls set; `undefined` leaves an attribute alone. */\n htmlAttributes(attributes: HtmlAttributes) {\n this.touched = true;\n const defined = Object.fromEntries(\n Object.entries(attributes).filter(([, value]) => value !== undefined),\n );\n this.content.htmlAttributes = { ...this.content.htmlAttributes, ...defined };\n }\n\n canonical(url: string) {\n this.touched = true;\n this.content.canonical = url;\n }\n\n alternates(links: AlternateLink[]) {\n this.touched = true;\n this.content.alternates = links;\n }\n\n title(title: string) {\n this.touched = true;\n this.content.title = title;\n }\n\n description(description: string) {\n this.touched = true;\n this.content.description = description;\n }\n\n openGraph({\n title,\n description,\n type,\n url,\n image,\n imageAlt,\n imageWidth,\n imageHeight,\n twitterImage = image,\n twitterImageAlt = imageAlt,\n twitterImageWidth = imageWidth,\n twitterImageHeight = imageHeight,\n }: OpenGraphParams) {\n this.touched = true;\n let _image = image;\n let _twitterImage = twitterImage;\n if (image && !image.startsWith(\"http\")) {\n _image = `${process.env.HOST_NAME}${image}`;\n _twitterImage = `${process.env.HOST_NAME}${twitterImage}`;\n }\n this.content.openGraph = Object.fromEntries(\n Object.entries({\n title,\n description,\n type,\n url,\n image: _image,\n imageAlt,\n imageWidth,\n imageHeight,\n twitterImage: _twitterImage,\n twitterImageAlt,\n twitterImageWidth,\n twitterImageHeight,\n }).filter(([_, value]) => value !== undefined),\n );\n }\n}\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": ";AAAA,4BAAS,
|
|
9
|
-
"debugId": "
|
|
8
|
+
"mappings": ";AAAA,4BAAS,oBCgCF,MAAM,CAAS,CACpB,QAAe,CACb,MAAO,WACP,YAAa,KACb,UAAW,KACX,eAAgB,KAChB,UAAW,KACX,WAAY,IACd,EAOA,QAAU,GAEV,MAAM,EAAG,CACP,MAAO,CACL,MAAO,KAAK,QAAQ,MACpB,YAAa,KAAK,QAAQ,YAC1B,UAAW,KAAK,QAAQ,UACxB,eAAgB,KAAK,QAAQ,eAC7B,UAAW,KAAK,QAAQ,UACxB,WAAY,KAAK,QAAQ,UAC3B,EAIF,cAAc,CAAC,EAA4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
|
+
"debugId": "6CD53DADDD8CD4E664756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{We as O,Xe as E,Ye as k}from"./chunk-whtzggn6.js";import{ef as T,of as R,qf as i,rf as C,sf as M,tf as Xz}from"./chunk-hytt9qyj.js";import{Wg as l}from"./chunk-
|
|
2
|
+
import{We as O,Xe as E,Ye as k}from"./chunk-whtzggn6.js";import{ef as T,of as R,qf as i,rf as C,sf as M,tf as Xz}from"./chunk-hytt9qyj.js";import{Wg as l}from"./chunk-49nyyjfe.js";import{nh as a}from"./chunk-1myhm0g3.js";var $z=["every","none","some"],Vz=["is","isNot"];function g(z){return z==="many"?$z:Vz}function h(z,J){let W=Object.keys(z);return W.length>0&&W.every((Z)=>J.includes(Z))}var m="_count";function y(z){return Object.keys(z.relations).filter((J)=>z.relations[J]?.kind==="many").sort()}function N(z,J,W,Z){let X={model:z,operation:J,hasUser:W!=null};return Object.defineProperty(X,"user",{enumerable:!0,get(){if(W==null&&!Z)throw new R(z,J,"no-user");return W}}),X}class n{}class Qz extends n{}var qz=new Set(["findMany","findFirst","findFirstOrThrow","findUnique","findUniqueOrThrow","count","aggregate","groupBy","update","updateMany","delete","deleteMany"]),Yz=new Set(["create","createMany","upsert"]),jz=new Set(["update","updateMany","upsert"]),Lz=new Set(["update","updateMany"]),Kz=new Set(["create","createMany"]),p=new WeakMap;function Gz(z,J,W){if(typeof z!=="function")return z;let Z=p.get(z);if(Z!==void 0)return Z;let X;try{X=new z}catch($){throw new M(b(J),W,"constructor-threw",`${f(z)}, and constructing it threw:
|
|
3
3
|
|
|
4
4
|
${$?.message??String($)}`,H,void 0,{cause:$})}return t(X,J,W),p.set(z,X),X}function S(z,J){return z.map((W,Z)=>Gz(W,J,Z))}var H=["before","scope","onCreate","onUpdate","redact"];var u=new WeakSet;function s(z,J){if(u.has(J))return;for(let W=0;W<J.length;W++)Uz(J[W],z,W);u.add(J)}function Uz(z,J,W){let Z=b(J),X=typeof z;if(z===null||Array.isArray(z)||X!=="object"&&X!=="function")throw new M(Z,W,"not-a-policy",o(z),H);if(X==="function"){if(!Mz(z))throw new M(Z,W,"not-constructable",f(z),H);return}t(z,J,W)}function t(z,J,W){let Z=b(J),X=0,$=[];for(let Y of H){let q=z[Y];if(q===void 0||q===null){if(Y in z)$.push(Y);continue}if(typeof q!=="function")throw new M(Z,W,"hook-not-callable",`'${Y}' that is ${o(q)} rather than a function`,H);X++}if(X>0)return;if($.length>0)throw new M(Z,W,"no-hooks",`It writes ${$.map((Y)=>`'${Y}'`).join(", ")} down and leaves ${$.length===1?"it":"them"} unset, which reads as `+"absent \u2014 so nothing is left to run.",H);let V=Fz(z),Q=Iz(V);throw new M(Z,W,"no-hooks",V.length===0?"It is empty.":`It spells ${Hz(V)}.`+(V.length===1&&V[0]==="default"?" A lone 'default' is a module namespace rather than the policy "+"inside it \u2014 put `entry.default` in the array, or import the "+"policy by name.":""),H,Q)}function Hz(z){let J=z.slice(0,8).map((W)=>`'${W}'`);return z.length>J.length?`${J.join(", ")} and ${z.length-J.length} more`:J.join(", ")}function Mz(z){try{return Reflect.construct(Bz,[],z),!0}catch{return!1}}var Bz=function(){};function Fz(z){let J=new Set,W=z;while(W!==null&&W!==Object.prototype){for(let Z of Object.getOwnPropertyNames(W))if(Z!=="constructor")J.add(Z);W=Object.getPrototypeOf(W)}return[...J]}function Iz(z){let J,W=2;for(let Z of z)for(let X of H){let $=Tz(Z.toLowerCase(),X.toLowerCase());if($<W)W=$,J={key:Z,hook:X}}return J}function Tz(z,J){if(z===J)return 0;let W=Array.from({length:J.length+1},(Z,X)=>X);for(let Z=1;Z<=z.length;Z++){let X=W[0];W[0]=Z;for(let $=1;$<=J.length;$++){let V=W[$];W[$]=Math.min(W[$]+1,W[$-1]+1,X+(z[Z-1]===J[$-1]?0:1)),X=V}}return W[J.length]}function o(z){if(z===null)return"null";if(z===void 0)return"undefined";if(typeof z==="string")return`the string ${JSON.stringify(z)}`;if(typeof z==="function")return f(z);if(Array.isArray(z))return"an array";if(typeof z==="object")return"an object";return`the ${typeof z} ${String(z)}`}function f(z){return z.name?`the function \`${z.name}\``:"an anonymous function"}function _(z){let J,W,Z,X=z;while(X&&X!==Function.prototype){if(Object.hasOwn(X,"$policy"))throw Error(`${X.name??"This model"} declares \`$policy\`, which is now \`$policies\` and takes a list. The old `+"name is not read, so this model is currently unpolicied \u2014 every "+"scope, onCreate and redact on it is being skipped.");if(Object.hasOwn(X,"$policies")&&X.$policies){let $=X.$policies;if($.length>0){let V=X;if(s(V,$),W===void 0&&J===void 0)W=$,Z=V;else J??=S(W,Z),W=void 0,J.unshift(...S($,V))}}X=Object.getPrototypeOf(X)}if(J!==void 0)return J;if(W===void 0)return Nz;return W.some(($)=>typeof $==="function")?S(W,Z):W}function r(z){let J=z;while(J&&J!==Function.prototype){if(Object.hasOwn(J,"$policies")&&J.$policies){let W=J.$policies;if(W.length>0)s(J,W)}J=Object.getPrototypeOf(J)}}function b(z){return z?.name??"This model"}var Nz=Object.freeze([]);function D(z,J,W,Z=[]){if(z.length===0)return W;let X=W,$;for(let V of z)if(V.before){if(V.before(J)===!1)throw new R(J.model,J.operation)}for(let V of z){if(!V.scope)continue;if(Kz.has(J.operation)){Sz(V,J);continue}let Q=V.scope(J);if(Q===void 0||Q===null)continue;if(Rz(J),Lz.has(J.operation)&&!V.onUpdate){let Y=Pz(Q);if(Y.length>0)($??=[]).push(...Y)}X=_z(X,Q)}if(Yz.has(J.operation)){for(let V of z)if(V.onCreate)X=Dz(X,J,V)}if(jz.has(J.operation)){for(let V of z)if(V.onUpdate)X=Az(X,J,V)}if($!==void 0)Cz($,J,X,Z);return X}function _z(z,J){let W=z?.where;if(W===void 0||W===null)return{...z,where:J};if(typeof W!=="object"||Array.isArray(W))return{...z,where:{AND:[W,J]}};let Z=W.AND,X=Z===void 0||Z===null?[]:Array.isArray(Z)?Z:[Z];return{...z,where:{...W,AND:[...X,J]}}}function Dz(z,J,W){let Z=(X)=>W.onCreate(J,{...X});if(J.operation==="createMany"){let X=z?.data;return{...z,data:Array.isArray(X)?X.map(Z):Z(X)}}if(J.operation==="upsert")return{...z,create:Z(z?.create)};return{...z,data:Z(z?.data)}}function Az(z,J,W){let Z=J.operation==="upsert"?"update":"data",X=z?.[Z];if(X===void 0||X===null)return z;return{...z,[Z]:W.onUpdate(J,{...X})}}function Cz(z,J,W,Z=[]){let X=W?.data;if(typeof X!=="object"||X===null)return;let $=z.filter((V)=>(V in X)&&!Z.includes(V));if($.length===0)return;throw new i(J.model,J.operation,[...new Set($)])}function Pz(z){if(typeof z!=="object"||z===null||Array.isArray(z))return[];let J=[];for(let W of Object.keys(z)){if(W==="AND"||W==="OR"||W==="NOT")continue;J.push(W)}return J}function Sz(z,J){if(z.onCreate)return;throw new T(J.operation,J.model,J.operation,`${J.model} has a policy that scopes reads but no 'onCreate', and ${J.operation} has no where clause for a scope to narrow. As written the policy would confine reads to the caller and let an insert name any value it likes. Add an onCreate that sets the scoped `+"column \u2014 or, if unscoped creates are intended, say so with an onCreate "+"that returns its data unchanged.")}function Rz(z){if(qz.has(z.operation))return;throw new T(z.operation,z.model,z.operation,`${z.model} has a policy with a scope, and ${z.operation} cannot carry one: its where clause compiles to an 'on conflict' target, which is a key rather than a filter. Running it would write outside the scope.
|
|
5
5
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Fa as y}from"./chunk-5stgtwqw.js";import{createElement as q}from"react";function z(i,n){let p=Object.keys(n).sort((s,g)=>g.length-s.length).map((s)=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),b=new RegExp(p.join("|"),"g");return i.replace(b,(s)=>n[s])}async function L(i,n,p=[],b){let s=[...p.map((t)=>`${i}/views/${t}.tsx`),b?`${i}/views/${b}.tsx`:`${i}/views/RootLayout.tsx`],g=new Set;for(let t of s){let u=n.moduleGraph.getModulesByFile(t);if(u)for(let x of u)g.add(x)}let e=[],l=[],r={};for(let t of g)if(t)for(let u of t.importedModules){if(u.file.includes("module.css"))r[u.file]=u.ssrTransformResult.map.sourcesContent.join("");if(u.file.includes(".css"))l.push(u.file)}for(let t of l){let u=await n.transformRequest(t+"?direct"),x=t.includes("module.css"),k="";if(x)k=z(r[t],u.default);e.push({isDev:!0,id:t,content:x?k:u.code})}return e.map((t,u)=>{return q("style",{key:u,type:"text/css","data-vite-dev-id":t.id,dangerouslySetInnerHTML:{__html:t.content}})})}async function _(i=[]){return i.map((n,p)=>{return q("style",{key:p,id:n?.id,type:"text/css",dangerouslySetInnerHTML:{__html:n.content}})})}import{existsSync as J}from"fs";import{basename as N}from"path";import{networkInterfaces as O}from"os";var v={name:"gemi",version:"0.
|
|
2
|
+
import{Fa as y}from"./chunk-5stgtwqw.js";import{createElement as q}from"react";function z(i,n){let p=Object.keys(n).sort((s,g)=>g.length-s.length).map((s)=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),b=new RegExp(p.join("|"),"g");return i.replace(b,(s)=>n[s])}async function L(i,n,p=[],b){let s=[...p.map((t)=>`${i}/views/${t}.tsx`),b?`${i}/views/${b}.tsx`:`${i}/views/RootLayout.tsx`],g=new Set;for(let t of s){let u=n.moduleGraph.getModulesByFile(t);if(u)for(let x of u)g.add(x)}let e=[],l=[],r={};for(let t of g)if(t)for(let u of t.importedModules){if(u.file.includes("module.css"))r[u.file]=u.ssrTransformResult.map.sourcesContent.join("");if(u.file.includes(".css"))l.push(u.file)}for(let t of l){let u=await n.transformRequest(t+"?direct"),x=t.includes("module.css"),k="";if(x)k=z(r[t],u.default);e.push({isDev:!0,id:t,content:x?k:u.code})}return e.map((t,u)=>{return q("style",{key:u,type:"text/css","data-vite-dev-id":t.id,dangerouslySetInnerHTML:{__html:t.content}})})}async function _(i=[]){return i.map((n,p)=>{return q("style",{key:p,id:n?.id,type:"text/css",dangerouslySetInnerHTML:{__html:n.content}})})}import{existsSync as J}from"fs";import{basename as N}from"path";import{networkInterfaces as O}from"os";var v={name:"gemi",version:"0.116.0",private:!1,license:"MIT",author:"Enes Tufekci <enes@gemijs.dev>",repository:{type:"git",url:"git+https://github.com/nstfkc/gemi.git",directory:"packages/gemi"},bin:{gemi:"./dist/bin/gemi.js","gemi-orm-generator":"./dist/bin/orm-generator.js"},files:["dist/**/*","ide/typescript-plugin/package.json","skills/**/*"],module:!0,exports:{"./http":"./http/index.ts","./client":"./client/index.ts","./ai":"./ai/index.ts","./ai/client":"./ai/client/index.ts","./testing":"./testing/index.ts","./app":"./app/index.ts","./facades":"./facades/index.ts","./email":"./email/index.ts","./vite":"./dist/vite/index.mjs","./kernel":"./kernel/index.ts","./services":"./services/index.ts","./i18n":"./i18n/index.ts","./dictionary":"./i18n/dictionaryRuntime.ts","./server":"./server/index.ts","./config":"./config/index.ts","./container":"./container/index.ts","./foundation":"./foundation/index.ts","./database":"./database/index.ts","./orm":"./orm/index.ts","./support":"./support/index.ts","./console/run":"./console/run.ts","./queue/work":"./services/queue/work.ts","./stats/route-table":"./stats/route-table.ts","./ide/typescript-plugin":"./ide/typescript-plugin/index.ts","./bun/preload":"./bun/preload.ts","./bun/plugin":"./bun/plugin.ts","./vitest":"./vitest/index.ts"},scripts:{lint:"oxlint",typecheck:"tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.browser.json && tsc --noEmit -p ide/typescript-plugin/tsconfig.json",build:"NODE_ENV=production bun run build:core && bun run build:bin && bun run build:types && bun run build:client && bun run build:plugin && bun run build:ts-plugin && bun run build:client-types && bun run build:augmentation","build:core":"bun ./scripts/build.ts","build:bin":"bun build --outdir=./dist/bin --target=bun --external=vite --external=react-dom --external=react/jsx-runtime --external=bun --external=sharp --external=@azure/storage-blob --external=typescript --sourcemap ./bin/gemi.ts ./bin/orm-generator.ts && bun ./scripts/prepare-bin.ts","build:client":"rm -rf dist/client dist/testing dist/ai/client dist/chunks && vite build -c vite.client.config.mts","build:plugin":"vite build -c vite.plugin.config.mts","build:ts-plugin":"bun ./scripts/build-ts-plugin.ts","build:types":"tsc -p tsconfig.build.json","build:client-types":"tsc -p tsconfig.browser.json",test:"bun --bun x vitest","test:types":"vitest run --typecheck.only","test:live":"bun --bun x vitest run ai/live","test:packaging":"bun --bun x vitest run --config vitest.packaging.config.ts","build:publish":"bun scripts/build-publish.ts",prepublishOnly:"echo 'Do not publish from this directory \u2014 its exports point at TS source. Run: bun run build:publish, then publish from .publish/' && exit 1","build:augmentation":"bun ./scripts/wire-augmentation.ts"},dependencies:{"@aws-sdk/client-s3":"^3.629.0","@aws-sdk/s3-request-presigner":"^3.629.0","ast-types":"^0.14.2",commander:"^12.1.0",history:"^5.3.0","jsx-email":"2.0.0-rc2.1","magic-string":"^0.30.17",open:"^10.1.0","react-error-boundary":"^6.0.0",recast:"^0.23.9",resend:"^6.12.3",satori:"^0.12.2","temporal-polyfill":"^0.2.5","twitter-api-v2":"^1.20.2","urlpattern-polyfill":"^10.0.0",uuid:"^9.0.1"},devDependencies:{"@babel/parser":"^7.25.4","@prisma/generator-helper":"^6.5.0","@repo/typescript-config":"*","@testing-library/react":"^16.3.2","@types/bun":"^1.3.14","@types/eslint":"^8.56.5","@types/node":"^20.11.24","@types/react":"^19.0.2","@types/react-dom":"^19.0.2",eslint:"^8.57.0",jsdom:"^30.0.1",oxlint:"^1.39.0",postgres:"^3.4.5",react:"19.2.3","react-dom":"19.2.3",typescript:"^5.7.3",vitest:"^4.0.0"},peerDependencies:{"@azure/storage-blob":"^12.28.0",react:">=19","react-dom":">=19",sharp:"^0.34.2",typescript:">=5",vite:"^8.0.0",postgres:"^3.4.0"},peerDependenciesMeta:{"@azure/storage-blob":{optional:!0},typescript:{optional:!0},postgres:{optional:!0}}};var Q=[" \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557\u2588\u2588\u2557","\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551","\u2588\u2588\u2551 \u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551\u2588\u2588\u2551","\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2551","\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2551"," \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D"],W=Boolean(process.stdout.isTTY)&&!process.env.NO_COLOR,c=(i,n)=>W?`\x1B[${i}m${n}\x1B[0m`:n,X=(i)=>c("1",i),d=(i)=>c("2",i),j=(i)=>c("36",i),Y=(i)=>c("32",i),Z=(i)=>c("35",i);function $(){return v.version??"?"}function f(i){for(let n of Object.values(O()))for(let p of n??[])if((p.family==="IPv4"||p.family===4)&&!p.internal)return`http://${p.address}:${i}`;return null}function H(i){return y(i).filter((n)=>J(n)).map((n)=>N(n))}function T(i){let{port:n,rootDir:p}=i,b=`http://localhost:${n}`,s=f(n),g=H(p),e=(r,t)=>` ${Y("\u279C")} ${X(r.padEnd(9))}${t}`,l=["",...Q.map((r)=>Z(r)),"",` ${d("gemi")} ${j(`v${$()}`)}`,"",e("Local:",j(b)),e("Network:",s?j(s):d("unavailable")),e("Env:",g.length?g.join(", "):d("none")),""];console.log(l.join(`
|
|
3
3
|
`))}function I(i=process.env.SERVER_IDLE_TIMEOUT){if(i===void 0||i.trim()==="")return 10;let n=Number(i.trim());if(!Number.isInteger(n)||n<0||n>255)throw Error(`SERVER_IDLE_TIMEOUT must be a whole number of seconds from 0 to 255 (0 disables the timeout), got ${JSON.stringify(i)}.`);return n}
|
|
4
4
|
export{L as R,_ as S,T,I as U};
|
|
5
5
|
|
|
6
|
-
//# debugId=
|
|
6
|
+
//# debugId=CA6084C1FF63828F64756E2164756E21
|
|
@@ -7,6 +7,6 @@
|
|
|
7
7
|
"/**\n * Bun's default, and what both servers use when `SERVER_IDLE_TIMEOUT` is unset.\n */\nexport const DEFAULT_SERVER_IDLE_TIMEOUT = 10;\n\n/**\n * The `idleTimeout` (seconds) both `gemi dev` and `gemi start` pass to\n * `Bun.serve`, from `SERVER_IDLE_TIMEOUT` (#787).\n *\n * One reader for both servers, so a long-poll that works under `gemi start`\n * also works under `gemi dev`. Before this, only `httpProd` read the variable\n * and the dev server always ran at Bun's 10 seconds.\n *\n * It is the time a connection may stay silent, a response that has not started\n * included, before Bun closes it; `0` disables it. It does not apply to an\n * upgraded websocket (the HMR relay included), which has its own\n * `websocket.idleTimeout`.\n *\n * Unset or blank means the default. Anything that is not a whole number from 0\n * to 255 (Bun's own limits) fails the boot with the variable's name, instead\n * of Bun's \"expects idleTimeout to be an integer\", which does not say where the\n * value came from.\n */\nexport function serverIdleTimeout(raw: string | undefined = process.env.SERVER_IDLE_TIMEOUT): number {\n if (raw === undefined || raw.trim() === \"\") return DEFAULT_SERVER_IDLE_TIMEOUT;\n\n const seconds = Number(raw.trim());\n if (!Number.isInteger(seconds) || seconds < 0 || seconds > 255) {\n throw new Error(\n `SERVER_IDLE_TIMEOUT must be a whole number of seconds from 0 to 255 ` +\n `(0 disables the timeout), got ${JSON.stringify(raw)}.`,\n );\n }\n return seconds;\n}\n"
|
|
8
8
|
],
|
|
9
9
|
"mappings": ";yCAAA,wBAAS,cAGT,SAAS,CAAc,CAAC,EAAc,EAAwC,CAC5E,IAAM,EAAc,OAAO,KAAK,CAAM,EACnC,KAAK,CAAC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AC1B,KAAK,EAAM,QAAE,MAAM,EAAK,EAAM,OAAO,CAAC,CAAC,IAAI,IAEvC,EAAM,CACV,GACA,GAAG,EAAI,IAAI,CAAC,IAAS,EAAQ,CAAI,CAAC,EAClC,GACA,KAAK,EAAI,MAAM,KAAK,EAAK,IAAI,EAAY,GAAG,IAC5C,GACA,EAAI,SAAU,EAAK,CAAK,CAAC,EACzB,EAAI,WAAY,EAAU,EAAK,CAAO,EAAI,EAAI,aAAa,CAAC,EAC5D,EAAI,OAAQ,EAAI,OAAS,EAAI,KAAK,IAAI,EAAI,EAAI,MAAM,CAAC,EACrD,EACF,EAEA,QAAQ,IAAI,EAAI,KAAK;AAAA,CAAI,CAAC,EC/CrB,SAAS,CAAiB,CAAC,EAA0B,QAAQ,IAAI,oBAA6B,CACnG,GAAI,IAAQ,QAAa,EAAI,KAAK,IAAM,GAAI,MArBH,IAuBzC,IAAM,EAAU,OAAO,EAAI,KAAK,CAAC,EACjC,GAAI,CAAC,OAAO,UAAU,CAAO,GAAK,EAAU,GAAK,EAAU,IACzD,MAAU,MACR,qGACmC,KAAK,UAAU,CAAG,IACvD,EAEF,OAAO",
|
|
10
|
-
"debugId": "
|
|
10
|
+
"debugId": "CA6084C1FF63828F64756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{S as D,T as KJ,U as OJ}from"./chunk-
|
|
2
|
+
import{S as D,T as KJ,U as OJ}from"./chunk-6d8rvr1v.js";import{na as B,ra as L,sa as UJ}from"./chunk-frerzsxq.js";import{Ca as e}from"./chunk-4mfrgd5m.js";import"./chunk-5stgtwqw.js";import{Nc as a,qe as QJ,re as A}from"./chunk-ms9k0rx6.js";import"./chunk-whtzggn6.js";import"./chunk-hytt9qyj.js";import{cg as o,dg as n,gg as i}from"./chunk-pn8v6fj2.js";import{Tg as WJ}from"./chunk-15c2vgaf.js";import"./chunk-49nyyjfe.js";import"./chunk-tn2bryy2.js";import"./chunk-cbqazg9k.js";import"./chunk-1myhm0g3.js";import"./chunk-kejwjerj.js";import"./chunk-aazmrxj9.js";import"./chunk-jmg2zsaf.js";import"./chunk-t4yh4nf9.js";import"./chunk-1vzks22y.js";import"./chunk-zyt2w03d.js";import{ni as YJ}from"./chunk-1hr4xht1.js";import{oi as N}from"./chunk-d9mar37g.js";import"./chunk-vw8849ys.js";import{join as w,resolve as VJ,sep as zJ}from"path";import{Duplex as qJ}from"stream";import{constants as P,createBrotliCompress as TJ,createGzip as RJ}from"zlib";var bJ=["br","gzip"],kJ=1024,SJ=5,wJ=19,vJ=6;function EJ(J){if(J===void 0)return 1;if(!/^\d+(\.\d{0,3})?$/.test(J.trim()))return 1;let $=Number(J.trim());return Number.isFinite($)?Math.min($,1):1}function yJ(J){if(J===null||J===void 0)return null;let $=new Map;for(let Z of J.split(",")){let[X,...Q]=Z.split(";"),W=X.trim().toLowerCase();if(W==="")continue;let j=1;for(let Y of Q){let K=Y.indexOf("=");if(K===-1)continue;if(Y.slice(0,K).trim().toLowerCase()==="q"){j=EJ(Y.slice(K+1));break}}$.set(W,j)}return $}function b(J,$=bJ){let Z=yJ(J);if(!Z)return null;let X=Z.get("*"),Q=null,W=0;for(let j of $){let Y=Z.get(j)??X??0;if(Y>W)Q=j,W=Y}return Q}function gJ(J,$){if(!J)return!1;return J.split(",").some((Z)=>Z.trim().toLowerCase().split("=")[0].trim()===$)}function fJ(J,$){if(J==="HEAD")return!1;if($.status<200||$.status===204||$.status===206||$.status===304)return!1;if($.headers.has("Content-Range"))return!1;let Z=$.headers.get("Content-Type");if(!Z||!/^\s*text\/html\s*(;|$)/i.test(Z))return!1;if(!$.body)return!1;let X=$.headers.get("Content-Encoding");if(X&&X.trim().toLowerCase()!=="identity")return!1;if(gJ($.headers.get("Cache-Control"),"no-transform"))return!1;let Q=$.headers.get("Content-Length");if(Q!==null&&Number(Q)<kJ)return!1;return!0}function mJ(J){let $=J==="br"?TJ({params:{[P.BROTLI_PARAM_QUALITY]:SJ,[P.BROTLI_PARAM_LGWIN]:wJ},flush:P.BROTLI_OPERATION_FLUSH}):RJ({level:vJ,flush:P.Z_SYNC_FLUSH});return qJ.toWeb($)}function uJ(J){let $=J.get("Vary");if(!$){J.set("Vary","Accept-Encoding");return}let Z=$.split(",").map((X)=>X.trim().toLowerCase());if(Z.includes("*")||Z.includes("accept-encoding"))return;J.append("Vary","Accept-Encoding")}function c(J,$){if(!fJ(J.method,$))return $;let Z=new Headers($.headers);uJ(Z);let X=b(J.headers.get("Accept-Encoding"));if(!X)return new Response($.body,{status:$.status,statusText:$.statusText,headers:Z});let Q;try{Q=mJ(X)}catch{return new Response($.body,{status:$.status,statusText:$.statusText,headers:Z})}return Z.set("Content-Encoding",X),Z.delete("Content-Length"),new Response($.body.pipeThrough(Q),{status:$.status,statusText:$.statusText,headers:Z})}import{readdir as nJ,stat as t}from"fs/promises";import{join as iJ}from"path";import{mkdir as U2,readFile as hJ,stat as K2,writeFile as O2}from"fs/promises";import{dirname as z2,join as cJ}from"path";import{promisify as p}from"util";import{brotliCompress as pJ,constants as C2,gzip as dJ}from"zlib";var lJ=".vite/static-assets.json";var d={br:".br",gzip:".gz"},oJ=["br","gzip"],I2=p(pJ),F2=p(dJ);async function l(J){let $;try{$=await hJ(cJ(J,lJ),"utf8")}catch{return null}let Z;try{Z=JSON.parse($)?.files}catch{return null}if(!Z||typeof Z!=="object")return null;let X={files:{}};for(let[Q,W]of Object.entries(Z)){if(!Array.isArray(W))continue;X.files[Q]=oJ.filter((j)=>W.includes(j))}return X}function k(J){let $=J.toString(),Z=new Bun.CryptoHasher("sha1");return Z.update($),Z.digest("hex")}async function r(J){let $=new Set;async function Z(X,Q){let W;try{W=await nJ(X,{withFileTypes:!0})}catch{return}for(let j of W){if(j.name.startsWith("."))continue;if(Q&&j.name==="assets")continue;let Y=iJ(X,j.name),K=j.isDirectory(),V=j.isFile();if(j.isSymbolicLink())try{let I=await t(Y);K=I.isDirectory(),V=I.isFile()}catch{continue}if(V)$.add(Y);else if(K&&!j.isSymbolicLink())await Z(Y,!1)}}return await Z(J,!0),$}var aJ="public, max-age=31536000, must-revalidate",tJ="public, max-age=31536000, immutable";async function rJ(J,$,Z){if(Z.length===0||J.headers.has("Range"))return null;let X=b(J.headers.get("Accept-Encoding"),Z);if(!X)return null;let Q=$+d[X];try{let W=await t(Q);return W.isFile()?{encoding:X,path:Q,size:W.size}:null}catch{return null}}async function s(J,$,Z={}){let X=Bun.file($),Q=Z.encodings??[],W={"Content-Type":X.type||"application/octet-stream","Cache-Control":Z.immutable?tJ:aJ,"Accept-Ranges":"bytes"};if(Q.length>0)W.Vary="Accept-Encoding";let j=await rJ(J,$,Q);if(j){let V=Bun.file(j.path);return new Response(V.stream(),{headers:{...W,"Content-Encoding":j.encoding,"Content-Length":String(j.size),ETag:`${k(V.lastModified)}-${j.encoding}`}})}let Y=X.size;W.ETag=k(X.lastModified);let K=o(J.headers.get("Range"));if(K){let V=n(K,Y);if(!V)return a(Y);return new Response(X.slice(V.start,V.end+1).stream(),{status:206,headers:{...W,"Content-Range":i(V.start,V.end,Y),"Content-Length":String(V.length)}})}return new Response(X.stream(),{headers:{...W,"Content-Length":String(Y)}})}import{stat as Z2}from"fs/promises";var _="app/client.tsx";function JJ(J,$=B){let Z=J[_]?.file;if(!Z)return;return{module:L(Z,$),preload:M(J,_,$)}}function M(J,$,Z=B){let X=[],Q=new Set,W=(j)=>{if(Q.has(j))return;Q.add(j);let Y=J[j];if(!Y?.file)return;X.push(L(Y.file,Z));for(let K of Y.imports??[])W(K)};return W($),X}function $J(J,$){let Z=[],X=new Set,Q=new Set,W=(j)=>{if(Q.has(j))return;Q.add(j);let Y=J[j];if(!Y)return;for(let K of Y.imports??[])W(K);for(let K of Y.css??[])if(!X.has(K))X.add(K),Z.push(K)};return W($),Z}function ZJ(J,$=B){let Z=new Map;return(X)=>{if(!Z.has(X)){let Q=`${X}${e}`,W=J[Q]?.file;Z.set(X,W?{src:L(W,$),preload:M(J,Q,$)}:void 0)}return Z.get(X)}}function XJ(J,$=30000){let Z=JSON.stringify("gemi:chunk-reload"),X=JSON.stringify(`Failed to fetch dynamically imported module: ${J}`);return`var r=!1;try{var s=window.sessionStorage,m=JSON.parse(s.getItem(${Z})||"null");var d=m?Date.now()-m.at:NaN;if(navigator.onLine!==!1&&!(d>=0&&d<${$})){s.setItem(${Z},JSON.stringify({url:window.location.href,at:Date.now()}));r=!0}}catch(e){}if(r)window.location.reload();else throw new Error(${X});export {}`}var sJ=new RegExp(`^${QJ}/.+\\.m?js$`);function eJ(J){return sJ.test(J)}function HJ(J){if(eJ(J))return new Response(XJ(J),{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store"}});if(A(J))return new Response("Not found",{status:404});return}var J2=`<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8" />
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var H=/^[a-z]{2,3}(?:[-_][a-z0-9]{2,8})*$/i;function M(j){return H.test(j)}function $(j){return j.split(/[-_]/)[0].toLowerCase()}function z(j,B,N){let Q=j?.split(";")[0].trim();if(!Q||!M(Q))return null;let P=Q.replaceAll("_","-").toLowerCase(),J=B.find((X)=>X.toLowerCase()===P);if(J)return J;let K=$(Q),R=B.filter((X)=>$(X)===K);if(R.length===0)return null;if(N&&R.includes(N))return N;return R[0]}var C="UTC";function W(j){if(typeof j!=="string"||j.length===0)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:j}),!0}catch{return!1}}var S=new Map,x=500;function U(j,B){let N=S.get(j);if(N===void 0){if(S.size>=x)S.delete(S.keys().next().value);N=B(),S.set(j,N)}return N}function Y(j){return j instanceof Date?j:new Date(j)}function I(j){return j.dateStyle!==void 0||j.timeStyle!==void 0||j.weekday!==void 0||j.era!==void 0||j.year!==void 0||j.month!==void 0||j.day!==void 0||j.dayPeriod!==void 0||j.hour!==void 0||j.minute!==void 0||j.second!==void 0||j.fractionalSecondDigits!==void 0||j.timeZoneName!==void 0}function G(j){let{locale:B,timeZone:N}=j,Q=(J={})=>{let K={...J,timeZone:J.timeZone??N};return U(`dt|${B}|${JSON.stringify(K)}`,()=>{return new Intl.DateTimeFormat(B,K)})},P=(J,K)=>{if(J&&I(J))return J;return{...K,...J}};return{locale:B,timeZone:N,date(J,K){return Q(P(K,{dateStyle:"medium"})).format(Y(J))},time(J,K){return Q(P(K,{timeStyle:"short"})).format(Y(J))},dateTime(J,K){return Q(P(K,{dateStyle:"medium",timeStyle:"short"})).format(Y(J))},number(J,K={}){return U(`n|${B}|${JSON.stringify(K)}`,()=>new Intl.NumberFormat(B,K)).format(J)},relative(J,K,R={}){return U(`r|${B}|${JSON.stringify(R)}`,()=>new Intl.RelativeTimeFormat(B,R)).format(J,K)},list(J,K={}){return U(`l|${B}|${JSON.stringify(K)}`,()=>new Intl.ListFormat(B,K)).format(J)},plural(J,K={}){return U(`p|${B}|${JSON.stringify(K)}`,()=>new Intl.PluralRules(B,K)).select(J)},dateTimeFormat:Q}}class _{config;static token="translator";translations={};isEnabled=!1;constructor(j){this.config=j;if(!W(this.config.timeZone))throw Error(`translation.timeZone: "${String(this.config.timeZone)}" is not a time zone this runtime knows. Use an IANA name such as "UTC" or "Europe/Istanbul".`);let B={};for(let[N,Q]of Object.entries(this.config.prefetch))for(let P of this.config.supportedLocales){if(!B[P])B[P]={};B[P][N]={};for(let J of Q){B[P][N][J.name]={};for(let[K,R]of Object.entries(J.dictionary))this.isEnabled=!0,B[P][N][J.name][K]=R[P]}}this.translations=B}get isLocaleAware(){return this.isEnabled||this.config.supportedLocales.length>0}get supportedLocales(){return this.config.supportedLocales}get defaultLocale(){return this.config.defaultLocale}get components(){return this.config.components}get timeZone(){return this.config.timeZone}detectTimeZone(j){if(j){let B=this.config.detectTimeZone(j);if(W(B))return B}return this.config.timeZone}formatter(j,B){return G({locale:j||this.defaultLocale,timeZone:W(B)?B:this.timeZone})}onLocaleChange(j){return this.config.onLocaleChange(j)}detectLocale(j){let B=this.config.defaultLocale??this.config.supportedLocales[0]??"en-US",N=(K)=>z(K,this.config.supportedLocales,this.config.defaultLocale),Q=N(this.config.detectLocale(j));if(Q)return Q;let P=N(j.cookies.get("i18n-locale"));if(P)return P;let J=j.headers.get("accept-language")??"";for(let K of J.split(",")){let R=N(K);if(R)return R}return B}getPageTranslations(j,B){if(this.translations[j][B])return this.translations[j][B];return{}}}
|
|
3
|
+
export{z as Vh,C as Wh,W as Xh,G as Yh,_ as Zh};
|
|
4
|
+
|
|
5
|
+
//# debugId=75B19AA2B7B2AB2664756E2164756E21
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../i18n/
|
|
3
|
+
"sources": ["../i18n/resolveLocale.ts", "../i18n/formatter.ts", "../i18n/Translator.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * Locale- and time-zone-aware formatting, shared by `useFormatter`, the\n * `format` property of a `useDictionary` result and `Lang.formatter()`.\n *\n * Dependency-free on purpose: components import it, so it must not pull in the\n * server facades.\n *\n * Why the time zone is pinned: a `Date` formatted with no `timeZone` uses the\n * runtime's zone, which is the server's during SSR and the viewer's in the\n * browser. The two disagree for anyone not sitting in the server's zone, so the\n * same instant can print a different hour, or a different day, on each side —\n * a hydration mismatch at best, a wrong date at worst. Every formatter here\n * carries one zone, resolved on the server and shipped with the page, so both\n * sides print the same text.\n */\n\nexport type DateInput = Date | number | string;\n\nexport interface FormatterInit {\n /** BCP 47 locale tag. */\n locale: string;\n /** IANA time zone, such as `UTC` or `Europe/Istanbul`. */\n timeZone: string;\n}\n\nexport interface Formatter {\n readonly locale: string;\n readonly timeZone: string;\n /** A date, `{ dateStyle: \"medium\" }` unless options are given. */\n date(value: DateInput, options?: Intl.DateTimeFormatOptions): string;\n /** A time of day, `{ timeStyle: \"short\" }` unless options are given. */\n time(value: DateInput, options?: Intl.DateTimeFormatOptions): string;\n /** Date and time, `{ dateStyle: \"medium\", timeStyle: \"short\" }` unless options are given. */\n dateTime(value: DateInput, options?: Intl.DateTimeFormatOptions): string;\n number(value: number | bigint, options?: Intl.NumberFormatOptions): string;\n relative(\n value: number,\n unit: Intl.RelativeTimeFormatUnit,\n options?: Intl.RelativeTimeFormatOptions,\n ): string;\n list(values: Iterable<string>, options?: Intl.ListFormatOptions): string;\n /** The CLDR plural category for `count`: `one`, `few`, `other`, … */\n plural(count: number, options?: Intl.PluralRulesOptions): Intl.LDMLPluralRule;\n /**\n * The cached `Intl.DateTimeFormat` behind `date`/`time`/`dateTime`, with the\n * formatter's zone applied. For `formatToParts` or `formatRange`.\n */\n dateTimeFormat(options?: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;\n}\n\n/** The zone used when the app configures none. */\nexport const DEFAULT_TIME_ZONE = \"UTC\";\n\n/**\n * Whether `timeZone` is an IANA zone (or offset) this runtime's `Intl` accepts.\n * An unknown zone makes `Intl.DateTimeFormat` throw a `RangeError`, so a zone\n * that comes from a cookie or a user record is checked before it is trusted.\n */\nexport function isValidTimeZone(timeZone: unknown): timeZone is string {\n if (typeof timeZone !== \"string\" || timeZone.length === 0) {\n return false;\n }\n try {\n new Intl.DateTimeFormat(\"en-US\", { timeZone });\n return true;\n } catch {\n return false;\n }\n}\n\n// Constructing an `Intl` formatter is the expensive part — it resolves locale\n// data — so each one is built once per (kind, locale, options). Options are\n// keyed by their JSON; callers pass small literal objects, and a key order\n// difference only costs a duplicate entry, never a wrong result.\nconst cache = new Map<string, unknown>();\nconst CACHE_LIMIT = 500;\n\nfunction cached<T>(key: string, create: () => T): T {\n let value = cache.get(key) as T | undefined;\n if (value === undefined) {\n if (cache.size >= CACHE_LIMIT) {\n // Insertion order: drop the oldest. Unbounded user-driven option objects\n // (a currency per row) must not grow a long-lived server process forever.\n cache.delete(cache.keys().next().value!);\n }\n value = create();\n cache.set(key, value);\n }\n return value;\n}\n\nfunction toDate(value: DateInput): Date {\n return value instanceof Date ? value : new Date(value);\n}\n\nfunction hasDateTimeFields(options: Intl.DateTimeFormatOptions): boolean {\n return (\n options.dateStyle !== undefined ||\n options.timeStyle !== undefined ||\n options.weekday !== undefined ||\n options.era !== undefined ||\n options.year !== undefined ||\n options.month !== undefined ||\n options.day !== undefined ||\n options.dayPeriod !== undefined ||\n options.hour !== undefined ||\n options.minute !== undefined ||\n options.second !== undefined ||\n options.fractionalSecondDigits !== undefined ||\n options.timeZoneName !== undefined\n );\n}\n\nexport function createFormatter(init: FormatterInit): Formatter {\n const { locale, timeZone } = init;\n\n const dateTimeFormat = (options: Intl.DateTimeFormatOptions = {}) => {\n // `??`, not a spread: `{ timeZone: undefined }` would otherwise drop the\n // pinned zone and fall back to the runtime's, which is the bug this exists\n // to prevent.\n const resolved = { ...options, timeZone: options.timeZone ?? timeZone };\n return cached(`dt|${locale}|${JSON.stringify(resolved)}`, () => {\n return new Intl.DateTimeFormat(locale, resolved);\n });\n };\n\n const withDefaults = (\n options: Intl.DateTimeFormatOptions | undefined,\n defaults: Intl.DateTimeFormatOptions,\n ) => {\n if (options && hasDateTimeFields(options)) {\n return options;\n }\n // Options that only tweak (a `timeZone`, `hour12`) still get the default\n // fields; otherwise `{ timeZone }` alone would print a bare numeric date.\n return { ...defaults, ...options };\n };\n\n return {\n locale,\n timeZone,\n date(value, options) {\n return dateTimeFormat(withDefaults(options, { dateStyle: \"medium\" })).format(\n toDate(value),\n );\n },\n time(value, options) {\n return dateTimeFormat(withDefaults(options, { timeStyle: \"short\" })).format(\n toDate(value),\n );\n },\n dateTime(value, options) {\n return dateTimeFormat(\n withDefaults(options, { dateStyle: \"medium\", timeStyle: \"short\" }),\n ).format(toDate(value));\n },\n number(value, options = {}) {\n return cached(\n `n|${locale}|${JSON.stringify(options)}`,\n () => new Intl.NumberFormat(locale, options),\n ).format(value);\n },\n relative(value, unit, options = {}) {\n return cached(\n `r|${locale}|${JSON.stringify(options)}`,\n () => new Intl.RelativeTimeFormat(locale, options),\n ).format(value, unit);\n },\n list(values, options = {}) {\n return cached(\n `l|${locale}|${JSON.stringify(options)}`,\n () => new Intl.ListFormat(locale, options),\n ).format(values);\n },\n plural(count, options = {}) {\n return cached(\n `p|${locale}|${JSON.stringify(options)}`,\n () => new Intl.PluralRules(locale, options),\n ).select(count);\n },\n dateTimeFormat,\n };\n}\n",
|
|
6
5
|
"// A BCP 47-ish tag: a 2–3 letter language, then any number of subtags. Loose on\n// purpose — it only has to tell `en`, `de-AT` and `zh-Hant-TW` apart from path\n// segments like `blog` or `settings`.\nconst LOCALE_TAG = /^[a-z]{2,3}(?:[-_][a-z0-9]{2,8})*$/i;\n\nexport function looksLikeLocale(segment: string): boolean {\n return LOCALE_TAG.test(segment);\n}\n\nfunction languageOf(tag: string): string {\n return tag.split(/[-_]/)[0].toLowerCase();\n}\n\n/**\n * Maps a requested locale onto one the app supports, or `null` when none fits.\n *\n * An exact match wins, ignoring case (`en-us` → `en-US`). Otherwise the tag\n * falls back to a supported locale of the same language, so a short tag\n * resolves to its long form (`en` → `en-US`) and an unsupported region to a\n * supported one (`de-AT` → `de-DE`). When several share the language, the\n * default locale is preferred, then the first in `supportedLocales`.\n */\nexport function resolveLocale(\n requested: string | null | undefined,\n supportedLocales: string[],\n defaultLocale?: string,\n): string | null {\n // An `Accept-Language` entry may carry a weight: `de-AT;q=0.9`.\n const tag = requested?.split(\";\")[0].trim();\n if (!tag || !looksLikeLocale(tag)) {\n return null;\n }\n\n const normalized = tag.replaceAll(\"_\", \"-\").toLowerCase();\n const exact = supportedLocales.find((l) => l.toLowerCase() === normalized);\n if (exact) {\n return exact;\n }\n\n const language = languageOf(tag);\n const sameLanguage = supportedLocales.filter((l) => languageOf(l) === language);\n if (sameLanguage.length === 0) {\n return null;\n }\n if (defaultLocale && sameLanguage.includes(defaultLocale)) {\n return defaultLocale;\n }\n return sameLanguage[0];\n}\n",
|
|
6
|
+
"/**\n * Locale- and time-zone-aware formatting, shared by `useFormatter`, the\n * `format` property of a `useDictionary` result and `Lang.formatter()`.\n *\n * Dependency-free on purpose: components import it, so it must not pull in the\n * server facades.\n *\n * Why the time zone is pinned: a `Date` formatted with no `timeZone` uses the\n * runtime's zone, which is the server's during SSR and the viewer's in the\n * browser. The two disagree for anyone not sitting in the server's zone, so the\n * same instant can print a different hour, or a different day, on each side —\n * a hydration mismatch at best, a wrong date at worst. Every formatter here\n * carries one zone, resolved on the server and shipped with the page, so both\n * sides print the same text.\n */\n\nexport type DateInput = Date | number | string;\n\nexport interface FormatterInit {\n /** BCP 47 locale tag. */\n locale: string;\n /** IANA time zone, such as `UTC` or `Europe/Istanbul`. */\n timeZone: string;\n}\n\nexport interface Formatter {\n readonly locale: string;\n readonly timeZone: string;\n /** A date, `{ dateStyle: \"medium\" }` unless options are given. */\n date(value: DateInput, options?: Intl.DateTimeFormatOptions): string;\n /** A time of day, `{ timeStyle: \"short\" }` unless options are given. */\n time(value: DateInput, options?: Intl.DateTimeFormatOptions): string;\n /** Date and time, `{ dateStyle: \"medium\", timeStyle: \"short\" }` unless options are given. */\n dateTime(value: DateInput, options?: Intl.DateTimeFormatOptions): string;\n number(value: number | bigint, options?: Intl.NumberFormatOptions): string;\n relative(\n value: number,\n unit: Intl.RelativeTimeFormatUnit,\n options?: Intl.RelativeTimeFormatOptions,\n ): string;\n list(values: Iterable<string>, options?: Intl.ListFormatOptions): string;\n /** The CLDR plural category for `count`: `one`, `few`, `other`, … */\n plural(count: number, options?: Intl.PluralRulesOptions): Intl.LDMLPluralRule;\n /**\n * The cached `Intl.DateTimeFormat` behind `date`/`time`/`dateTime`, with the\n * formatter's zone applied. For `formatToParts` or `formatRange`.\n */\n dateTimeFormat(options?: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;\n}\n\n/** The zone used when the app configures none. */\nexport const DEFAULT_TIME_ZONE = \"UTC\";\n\n/**\n * Whether `timeZone` is an IANA zone (or offset) this runtime's `Intl` accepts.\n * An unknown zone makes `Intl.DateTimeFormat` throw a `RangeError`, so a zone\n * that comes from a cookie or a user record is checked before it is trusted.\n */\nexport function isValidTimeZone(timeZone: unknown): timeZone is string {\n if (typeof timeZone !== \"string\" || timeZone.length === 0) {\n return false;\n }\n try {\n new Intl.DateTimeFormat(\"en-US\", { timeZone });\n return true;\n } catch {\n return false;\n }\n}\n\n// Constructing an `Intl` formatter is the expensive part — it resolves locale\n// data — so each one is built once per (kind, locale, options). Options are\n// keyed by their JSON; callers pass small literal objects, and a key order\n// difference only costs a duplicate entry, never a wrong result.\nconst cache = new Map<string, unknown>();\nconst CACHE_LIMIT = 500;\n\nfunction cached<T>(key: string, create: () => T): T {\n let value = cache.get(key) as T | undefined;\n if (value === undefined) {\n if (cache.size >= CACHE_LIMIT) {\n // Insertion order: drop the oldest. Unbounded user-driven option objects\n // (a currency per row) must not grow a long-lived server process forever.\n cache.delete(cache.keys().next().value!);\n }\n value = create();\n cache.set(key, value);\n }\n return value;\n}\n\nfunction toDate(value: DateInput): Date {\n return value instanceof Date ? value : new Date(value);\n}\n\nfunction hasDateTimeFields(options: Intl.DateTimeFormatOptions): boolean {\n return (\n options.dateStyle !== undefined ||\n options.timeStyle !== undefined ||\n options.weekday !== undefined ||\n options.era !== undefined ||\n options.year !== undefined ||\n options.month !== undefined ||\n options.day !== undefined ||\n options.dayPeriod !== undefined ||\n options.hour !== undefined ||\n options.minute !== undefined ||\n options.second !== undefined ||\n options.fractionalSecondDigits !== undefined ||\n options.timeZoneName !== undefined\n );\n}\n\nexport function createFormatter(init: FormatterInit): Formatter {\n const { locale, timeZone } = init;\n\n const dateTimeFormat = (options: Intl.DateTimeFormatOptions = {}) => {\n // `??`, not a spread: `{ timeZone: undefined }` would otherwise drop the\n // pinned zone and fall back to the runtime's, which is the bug this exists\n // to prevent.\n const resolved = { ...options, timeZone: options.timeZone ?? timeZone };\n return cached(`dt|${locale}|${JSON.stringify(resolved)}`, () => {\n return new Intl.DateTimeFormat(locale, resolved);\n });\n };\n\n const withDefaults = (\n options: Intl.DateTimeFormatOptions | undefined,\n defaults: Intl.DateTimeFormatOptions,\n ) => {\n if (options && hasDateTimeFields(options)) {\n return options;\n }\n // Options that only tweak (a `timeZone`, `hour12`) still get the default\n // fields; otherwise `{ timeZone }` alone would print a bare numeric date.\n return { ...defaults, ...options };\n };\n\n return {\n locale,\n timeZone,\n date(value, options) {\n return dateTimeFormat(withDefaults(options, { dateStyle: \"medium\" })).format(\n toDate(value),\n );\n },\n time(value, options) {\n return dateTimeFormat(withDefaults(options, { timeStyle: \"short\" })).format(\n toDate(value),\n );\n },\n dateTime(value, options) {\n return dateTimeFormat(\n withDefaults(options, { dateStyle: \"medium\", timeStyle: \"short\" }),\n ).format(toDate(value));\n },\n number(value, options = {}) {\n return cached(\n `n|${locale}|${JSON.stringify(options)}`,\n () => new Intl.NumberFormat(locale, options),\n ).format(value);\n },\n relative(value, unit, options = {}) {\n return cached(\n `r|${locale}|${JSON.stringify(options)}`,\n () => new Intl.RelativeTimeFormat(locale, options),\n ).format(value, unit);\n },\n list(values, options = {}) {\n return cached(\n `l|${locale}|${JSON.stringify(options)}`,\n () => new Intl.ListFormat(locale, options),\n ).format(values);\n },\n plural(count, options = {}) {\n return cached(\n `p|${locale}|${JSON.stringify(options)}`,\n () => new Intl.PluralRules(locale, options),\n ).select(count);\n },\n dateTimeFormat,\n };\n}\n",
|
|
7
7
|
"import type { HttpRequest } from \"../http/HttpRequest\";\nimport type { Dictionary } from \"./Dictionary\";\nimport type { TranslationConfig } from \"./config\";\nimport { resolveLocale } from \"./resolveLocale\";\nimport {\n createFormatter,\n isValidTimeZone,\n type Formatter,\n} from \"./formatter\";\n\nexport class Translator {\n static token = \"translator\";\n\n translations = {};\n isEnabled = false;\n\n constructor(public config: Required<TranslationConfig>) {\n // Fail at boot rather than on the first page that prints a date: `Intl`\n // throws a `RangeError` for a zone it does not know.\n if (!isValidTimeZone(this.config.timeZone)) {\n throw new Error(\n `translation.timeZone: \"${String(this.config.timeZone)}\" is not a time zone this runtime knows. Use an IANA name such as \"UTC\" or \"Europe/Istanbul\".`,\n );\n }\n\n const translations = {};\n\n for (const [route, dicArray] of Object.entries(this.config.prefetch)) {\n for (const locale of this.config.supportedLocales) {\n if (!translations[locale]) {\n translations[locale] = {};\n }\n translations[locale][route] = {};\n for (const dic of dicArray) {\n translations[locale][route][dic.name] = {};\n for (const [key, value] of Object.entries(dic.dictionary)) {\n this.isEnabled = true;\n translations[locale][route][dic.name][key] = value[locale];\n }\n }\n }\n }\n this.translations = translations;\n }\n\n /**\n * Whether the app does locale-aware routing and rendering at all.\n *\n * `isEnabled` only means the legacy `prefetch` config has dictionaries to\n * serve. An app on `defineDictionary` has an empty `prefetch` and declares\n * its locales through `supportedLocales` alone, so gating on `isEnabled`\n * leaves it without locale detection or a locale URL prefix. Both the render\n * path and the redirect read this, because when they disagreed a migrated app\n * rendered a non-default locale at `/` with no redirect and no `Vary` — one\n * cache fill away from serving that document to everyone.\n */\n get isLocaleAware(): boolean {\n return this.isEnabled || this.config.supportedLocales.length > 0;\n }\n\n get supportedLocales(): string[] {\n return this.config.supportedLocales;\n }\n\n get defaultLocale(): string {\n return this.config.defaultLocale;\n }\n\n get components(): Record<string, Dictionary<any>> {\n return this.config.components;\n }\n\n /** The configured zone; `UTC` unless `translation.timeZone` says otherwise. */\n get timeZone(): string {\n return this.config.timeZone;\n }\n\n /**\n * The zone dates are formatted in for this request: `detectTimeZone`'s\n * answer when it gives a zone `Intl` knows, the configured zone otherwise.\n * A bad value from a cookie must not take the page down, so it is ignored\n * rather than thrown.\n */\n detectTimeZone(req: HttpRequest<any, any> | null | undefined): string {\n if (req) {\n const detected = this.config.detectTimeZone(req);\n if (isValidTimeZone(detected)) {\n return detected;\n }\n }\n return this.config.timeZone;\n }\n\n /**\n * A formatter for `locale` (the default locale when omitted) in `timeZone`\n * (the configured zone when omitted). For server code outside a request —\n * jobs, emails. Inside a request, `Lang.formatter()` picks up the request's\n * locale and zone.\n */\n formatter(locale?: string, timeZone?: string): Formatter {\n return createFormatter({\n locale: locale || this.defaultLocale,\n timeZone: isValidTimeZone(timeZone) ? timeZone : this.timeZone,\n });\n }\n\n onLocaleChange(locale: string): Promise<void> | void {\n return this.config.onLocaleChange(locale);\n }\n\n detectLocale(req: HttpRequest<any, any>) {\n const fallbackLocale =\n this.config.defaultLocale ?? this.config.supportedLocales[0] ?? \"en-US\";\n const resolve = (tag: string | null | undefined) =>\n resolveLocale(tag, this.config.supportedLocales, this.config.defaultLocale);\n\n const detectedLocale = resolve(this.config.detectLocale(req));\n if (detectedLocale) {\n return detectedLocale;\n }\n\n const previousLocale = resolve(req.cookies.get(\"i18n-locale\"));\n if (previousLocale) {\n return previousLocale;\n }\n\n // Entries are in the browser's preference order; the first one the app can\n // serve, even by language alone (`de-AT` → `de-DE`), wins.\n const acceptLanguage = req.headers.get(\"accept-language\") ?? \"\";\n for (const entry of acceptLanguage.split(\",\")) {\n const locale = resolve(entry);\n if (locale) {\n return locale;\n }\n }\n\n return fallbackLocale;\n }\n\n getPageTranslations(locale: string, scope: string) {\n if (this.translations[locale][scope]) {\n return this.translations[locale][scope];\n }\n return {};\n }\n}\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": ";
|
|
10
|
-
"debugId": "
|
|
9
|
+
"mappings": ";AAGA,IAAM,EAAa,sCAEZ,SAAS,CAAe,CAAC,EAA0B,CACxD,OAAO,EAAW,KAAK,CAAO,EAGhC,SAAS,CAAU,CAAC,EAAqB,CACvC,OAAO,EAAI,MAAM,MAAM,EAAE,GAAG,YAAY,EAYnC,SAAS,CAAa,CAC3B,EACA,EACA,EACe,CAEf,IAAM,EAAM,GAAW,MAAM,GAAG,EAAE,GAAG,KAAK,EAC1C,GAAI,CAAC,GAAO,CAAC,EAAgB,CAAG,EAC9B,OAAO,KAGT,IAAM,EAAa,EAAI,WAAW,IAAK,GAAG,EAAE,YAAY,EAClD,EAAQ,EAAiB,KAAK,CAAC,IAAM,EAAE,YAAY,IAAM,CAAU,EACzE,GAAI,EACF,OAAO,EAGT,IAAM,E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