@inixiative/infra 0.1.0 → 0.1.2
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/chunk-3V67V3N2.cjs +3 -0
- package/dist/chunk-3V67V3N2.cjs.map +1 -0
- package/dist/chunk-55HNIEAS.js +2 -0
- package/dist/chunk-55HNIEAS.js.map +1 -0
- package/dist/chunk-5UNXCQEH.js +3 -0
- package/dist/chunk-5UNXCQEH.js.map +1 -0
- package/dist/chunk-CNAFA6FE.cjs +2 -0
- package/dist/chunk-CNAFA6FE.cjs.map +1 -0
- package/dist/chunk-HONV2KPY.js +3 -0
- package/dist/chunk-HONV2KPY.js.map +1 -0
- package/dist/chunk-I3A224H4.js +3 -0
- package/dist/chunk-I3A224H4.js.map +1 -0
- package/dist/chunk-MO2YI2GE.cjs +2 -0
- package/dist/chunk-MO2YI2GE.cjs.map +1 -0
- package/dist/chunk-MP4O62RE.cjs +3 -0
- package/dist/chunk-MP4O62RE.cjs.map +1 -0
- package/dist/chunk-MXJ4EW3I.js +3 -0
- package/dist/chunk-MXJ4EW3I.js.map +1 -0
- package/dist/chunk-NGWNYW3U.js +3 -0
- package/dist/chunk-NGWNYW3U.js.map +1 -0
- package/dist/chunk-OHRGTWGZ.cjs +3 -0
- package/dist/chunk-OHRGTWGZ.cjs.map +1 -0
- package/dist/chunk-QREJ73ZG.cjs +2 -0
- package/dist/chunk-QREJ73ZG.cjs.map +1 -0
- package/dist/chunk-S47XOR4G.js +2 -0
- package/dist/chunk-S47XOR4G.js.map +1 -0
- package/dist/chunk-SLMYHBFB.cjs +3 -0
- package/dist/chunk-SLMYHBFB.cjs.map +1 -0
- package/dist/chunk-U5EA4FJI.cjs +2 -0
- package/dist/chunk-U5EA4FJI.cjs.map +1 -0
- package/dist/chunk-UZUGSMDK.js +2 -0
- package/dist/chunk-UZUGSMDK.js.map +1 -0
- package/dist/chunk-W5SAM2DK.js +2 -0
- package/dist/chunk-W5SAM2DK.js.map +1 -0
- package/dist/chunk-XGIX6QNV.cjs +3 -0
- package/dist/chunk-XGIX6QNV.cjs.map +1 -0
- package/dist/{contracts-BxHKiOwj.d.cts → contracts-isQ6Kn09.d.cts} +4 -0
- package/dist/{contracts-BxHKiOwj.d.ts → contracts-isQ6Kn09.d.ts} +4 -0
- package/dist/firecracker/index.cjs +1 -2
- package/dist/firecracker/index.cjs.map +1 -1
- package/dist/firecracker/index.d.cts +1 -1
- package/dist/firecracker/index.d.ts +1 -1
- package/dist/firecracker/index.js +1 -2
- package/dist/firecracker/index.js.map +1 -1
- package/dist/fly/index.cjs +1 -2
- package/dist/fly/index.cjs.map +1 -1
- package/dist/fly/index.d.cts +1 -1
- package/dist/fly/index.d.ts +1 -1
- package/dist/fly/index.js +1 -2
- package/dist/fly/index.js.map +1 -1
- package/dist/index.cjs +1 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/lifecycle/index.cjs +1 -1
- package/dist/lifecycle/index.cjs.map +1 -1
- package/dist/lifecycle/index.d.cts +1 -1
- package/dist/lifecycle/index.d.ts +1 -1
- package/dist/lifecycle/index.js +1 -1
- package/dist/lifecycle/index.js.map +1 -1
- package/dist/railway/index.cjs +1 -2
- package/dist/railway/index.cjs.map +1 -1
- package/dist/railway/index.d.cts +1 -1
- package/dist/railway/index.d.ts +1 -1
- package/dist/railway/index.js +1 -2
- package/dist/railway/index.js.map +1 -1
- package/dist/render/index.cjs +1 -2
- package/dist/render/index.cjs.map +1 -1
- package/dist/render/index.d.cts +1 -1
- package/dist/render/index.d.ts +1 -1
- package/dist/render/index.js +1 -2
- package/dist/render/index.js.map +1 -1
- package/package.json +8 -5
package/dist/lifecycle/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var G=new Set(["unreachable","rate_limited","provider_unavailable"]),a=class extends Error{code;status;provider;retryable;constructor(n,r,o){let t=o?.provider?`[${o.provider}] `:"";super(r?`${t}${r}`:`${t}Infrastructure request failed (${n})`,{cause:o?.cause}),this.name="InfraError",this.code=n,this.status=o?.status,this.provider=o?.provider,this.retryable=o?.retryable??G.has(n);}};var S=[{id:"starter",maxMemoryMb:512,monthlyUsd:7},{id:"standard",maxMemoryMb:2048,monthlyUsd:25},{id:"pro",maxMemoryMb:4096,monthlyUsd:85},{id:"pro_plus",maxMemoryMb:8192,monthlyUsd:175},{id:"pro_max",maxMemoryMb:16384,monthlyUsd:225},{id:"pro_ultra",maxMemoryMb:32768,monthlyUsd:450}],I=e=>{for(let n of S)if(e<=n.maxMemoryMb)return n;return S[S.length-1]},F=new Set(["build_failed","update_failed","pre_deploy_failed","canceled"]);new Set([...F,"deactivated"]);var b=730,N=.65,O=.1,d={railway:{memoryUsdPerGbHour:.0139,vcpuUsdPerHour:.0278,storageUsdPerGbMonth:.15},fly:{sharedVcpuUsdPerMonth:.7,performanceVcpuUsdPerMonth:21,memoryUsdPerGbMonth:6,suspendedRootfsUsdPerGbMonth:.15},render:{diskUsdPerGbMonth:.25},firecracker:{amortizedMemoryUsdPerGbMonth:3.5,amortizedVcpuUsdPerMonth:4,snapshotStorageUsdPerGbMonth:.05},aws:{fargateArmVcpuUsdPerHour:.0324,fargateArmMemoryUsdPerGbHour:.0036,storageUsdPerGbMonth:.08},gcp:{vcpuUsdPerHour:.0432,memoryUsdPerGbHour:.0048,storageUsdPerGbMonth:.1},azure:{vcpuUsdPerHour:.0432,memoryUsdPerGbHour:.0048,storageUsdPerGbMonth:.1}},h=e=>Math.round(e*1e4)/1e4,v=(e,n)=>{if(!Number.isFinite(e)||e<0)throw new a("invalid_request",`${n} must be a finite number >= 0 (got ${e})`)},U=(e,n)=>{if(!Number.isFinite(e)||e<0||e>1)throw new a("invalid_request",`${n} must be a finite number in [0, 1] (got ${e})`)},T=e=>{if(v(e.memoryMb,"memoryMb"),v(e.vcpus,"vcpus"),v(e.activeHoursPerMonth,"activeHoursPerMonth"),v(e.suspendedHoursPerMonth,"suspendedHoursPerMonth"),v(e.rootfsGb,"rootfsGb"),e.activeHoursPerMonth+e.suspendedHoursPerMonth>b)throw new a("invalid_request",`activeHoursPerMonth + suspendedHoursPerMonth must be <= ${b} (got ${e.activeHoursPerMonth+e.suspendedHoursPerMonth})`);let n=e.markupMultiplier??1;if(!Number.isFinite(n)||n<1)throw new a("invalid_request",`markupMultiplier must be a finite number >= 1 (got ${n})`);e.averageMemoryUtilization!==void 0&&U(e.averageMemoryUtilization,"averageMemoryUtilization"),e.averageCpuUtilization!==void 0&&U(e.averageCpuUtilization,"averageCpuUtilization");let r=e.memoryMb/1024,o=e.activeHoursPerMonth/b,t=(e.activeHoursPerMonth+e.suspendedHoursPerMonth)/b,m=e.suspendedHoursPerMonth/b,u=0,i=0,s="";switch(e.provider){case "railway":{let M=e.averageMemoryUtilization??N,W=e.averageCpuUtilization??O;u=r*M*e.activeHoursPerMonth*d.railway.memoryUsdPerGbHour+e.vcpus*W*e.activeHoursPerMonth*d.railway.vcpuUsdPerHour,i=e.rootfsGb*t*d.railway.storageUsdPerGbMonth,s="usage-metered active RAM/vCPU per second + persistent volume storage";break}case "fly":{let M=e.cpuKind==="performance"?d.fly.performanceVcpuUsdPerMonth:d.fly.sharedVcpuUsdPerMonth;u=(e.vcpus*M+r*d.fly.memoryUsdPerGbMonth)*o,i=e.rootfsGb*m*d.fly.suspendedRootfsUsdPerGbMonth,s="provisioned Firecracker microVM per second while active + rootfs-only storage while suspended";break}case "render":{let M=I(e.memoryMb);u=M.monthlyUsd*o,i=e.rootfsGb*t*d.render.diskUsdPerGbMonth,s=`prorated fixed Render ${M.id} tier while unsuspended + persistent disk`;break}case "firecracker":{u=(r*d.firecracker.amortizedMemoryUsdPerGbMonth+e.vcpus*d.firecracker.amortizedVcpuUsdPerMonth)*o,i=(e.rootfsGb+r)*m*d.firecracker.snapshotStorageUsdPerGbMonth,s="amortized dedicated bare-metal host capacity while active + NVMe snapshot storage while suspended";break}case "aws":{u=e.vcpus*e.activeHoursPerMonth*d.aws.fargateArmVcpuUsdPerHour+r*e.activeHoursPerMonth*d.aws.fargateArmMemoryUsdPerGbHour,i=e.rootfsGb*t*d.aws.storageUsdPerGbMonth,s="AWS Fargate ARM provisioned vCPU/GB-hour + EBS/snapshot storage";break}case "gcp":{u=e.vcpus*e.activeHoursPerMonth*d.gcp.vcpuUsdPerHour+r*e.activeHoursPerMonth*d.gcp.memoryUsdPerGbHour,i=e.rootfsGb*t*d.gcp.storageUsdPerGbMonth,s="GCP provisioned vCPU/GB-hour + persistent storage";break}case "azure":{u=e.vcpus*e.activeHoursPerMonth*d.azure.vcpuUsdPerHour+r*e.activeHoursPerMonth*d.azure.memoryUsdPerGbHour,i=e.rootfsGb*t*d.azure.storageUsdPerGbMonth,s="Azure Container Apps provisioned vCPU/GB-hour + storage";break}}let c=h(u),p=h(i),l=h(c+p),f=h(l*n),_=h(f-l);return {provider:e.provider,activeComputeUsd:c,suspendedStorageUsd:p,rawMonthlyCostUsd:l,markupMultiplier:n,markedUpMonthlyCostUsd:f,marginUsd:_,pricingBasis:s}};var q={railway:{id:"railway",name:"Railway",implemented:true,supportsArchiveHosting:true,supportsWorkloadDriver:true,isolation:"container",supportsSuspend:false,supportsByoAccount:true,supportsManagedAccount:true,billingUnit:"active_utilization_second",notes:"Usage-metered memory and CPU per second; stopped services bill nothing; no memory-snapshot suspend."},render:{id:"render",name:"Render",implemented:true,supportsArchiveHosting:true,supportsWorkloadDriver:true,isolation:"container",supportsSuspend:false,supportsByoAccount:true,supportsManagedAccount:true,billingUnit:"flat_plan_month",notes:"Managed web services and Postgres on fixed tiers; service suspend stops execution without a memory snapshot."},fly:{id:"fly",name:"Fly.io Machines",implemented:true,supportsArchiveHosting:false,supportsWorkloadDriver:true,isolation:"microvm",supportsSuspend:true,suspendMaxMemoryMb:2048,supportsByoAccount:true,supportsManagedAccount:true,billingUnit:"provisioned_second_with_suspend_storage",notes:"Firecracker microVMs with GA memory-snapshot suspend up to 2048 MB RAM and rootfs-only suspended storage billing."},firecracker:{id:"firecracker",name:"Firecracker",implemented:true,supportsArchiveHosting:false,supportsWorkloadDriver:true,isolation:"microvm",supportsSuspend:true,supportsByoAccount:true,supportsManagedAccount:true,billingUnit:"host_machine_month",notes:"Direct Firecracker VMM HTTP/Unix control plane for dedicated or bare-metal microVM hosts with full memory snapshots."},aws:{id:"aws",name:"AWS (Fargate / Lambda MicroVMs)",implemented:false,supportsArchiveHosting:false,supportsWorkloadDriver:false,isolation:"microvm",supportsSuspend:true,supportsByoAccount:true,supportsManagedAccount:true,billingUnit:"provisioned_vcpu_memory_second",notes:"Planned cloud adapter for AWS Fargate tasks and Firecracker-backed Lambda MicroVMs (8h session cap)."},gcp:{id:"gcp",name:"Google Cloud (Cloud Run / GKE Autopilot)",implemented:false,supportsArchiveHosting:false,supportsWorkloadDriver:false,isolation:"microvm",supportsSuspend:false,supportsByoAccount:true,supportsManagedAccount:true,billingUnit:"provisioned_vcpu_memory_second",notes:"Planned cloud adapter for Google Cloud Run and GKE Autopilot workloads."},azure:{id:"azure",name:"Azure (Container Apps / ACI)",implemented:false,supportsArchiveHosting:false,supportsWorkloadDriver:false,isolation:"container",supportsSuspend:false,supportsByoAccount:true,supportsManagedAccount:true,billingUnit:"provisioned_vcpu_memory_second",notes:"Planned cloud adapter for Azure Container Apps and Container Instances."}};var H=e=>q[e];var w=(e,n={})=>{switch(e){case "warm-interactive":return {workloadClass:e,idleSuspendMs:48e4,idleStopMs:108e5,drainGraceMs:6e4,pendingApprovalGraceMs:0,maxLifetimeMs:864e5,maxSuspendedMs:12096e5,softMemoryRecycleMb:1536,hardMemoryCapMb:2048,requireArchiveFlushBeforeWindDown:false,workingHoursPrewarm:n.workingHoursPrewarm,idleAction:"suspend"};case "warm-pool":return {workloadClass:e,idleSuspendMs:n.warmRetentionMode==="extended"?36e5:3e5,idleStopMs:108e5,drainGraceMs:6e4,pendingApprovalGraceMs:0,maxLifetimeMs:864e5,maxSuspendedMs:6048e5,softMemoryRecycleMb:1536,hardMemoryCapMb:2048,requireArchiveFlushBeforeWindDown:false,workingHoursPrewarm:n.workingHoursPrewarm,idleAction:"suspend"};case "batch-worker":return {workloadClass:e,idleSuspendMs:3e5,idleStopMs:3e5,drainGraceMs:12e4,pendingApprovalGraceMs:0,maxLifetimeMs:144e5,maxSuspendedMs:864e5,softMemoryRecycleMb:1536,hardMemoryCapMb:2048,requireArchiveFlushBeforeWindDown:false,idleAction:"terminate"};case "ephemeral-session":return {workloadClass:e,idleSuspendMs:9e5,idleStopMs:9e5,drainGraceMs:6e4,pendingApprovalGraceMs:18e5,maxLifetimeMs:864e5,maxSuspendedMs:6048e5,softMemoryRecycleMb:null,hardMemoryCapMb:null,requireArchiveFlushBeforeWindDown:true,idleAction:"suspend"};case "always-on":return {workloadClass:e,idleSuspendMs:null,idleStopMs:null,drainGraceMs:6e4,pendingApprovalGraceMs:0,maxLifetimeMs:null,maxSuspendedMs:null,softMemoryRecycleMb:null,hardMemoryCapMb:null,requireArchiveFlushBeforeWindDown:false,idleAction:"keep_warm"}}};var $=15e3,R=3e4,B=1e4,z=3e5,x=36e5,C=24*x,k=(e,n)=>{if(!Number.isFinite(e))throw new a("invalid_request",`${n} must be a finite number (got ${e})`)},A=(e,n)=>{if(!Number.isFinite(e)||e<0)throw new a("invalid_request",`${n} must be a finite number >= 0 (got ${e})`)},P=(e,n)=>{if(!Number.isInteger(e)||e<0)throw new a("invalid_request",`${n} must be an integer >= 0 (got ${e})`)},g=(e,n)=>{if(e!=null&&(!Number.isFinite(e)||e<=0))throw new a("invalid_request",`${n} must be a finite number > 0 (got ${e})`)},V=e=>{if(k(e.timezoneOffsetMinutes,"workingHoursPrewarm.timezoneOffsetMinutes"),!Number.isFinite(e.startHour)||e.startHour<0||e.startHour>=24)throw new a("invalid_request",`workingHoursPrewarm.startHour must be in [0, 24) (got ${e.startHour})`);if(!Number.isFinite(e.endHour)||e.endHour<0||e.endHour>24)throw new a("invalid_request",`workingHoursPrewarm.endHour must be in [0, 24] (got ${e.endHour})`);A(e.prewarmLeadMs,"workingHoursPrewarm.prewarmLeadMs");},Y=(e,n,r)=>{k(n,"nowMs"),k(e.createdAtMs,"snapshot.createdAtMs"),k(e.lastActivityAtMs,"snapshot.lastActivityAtMs"),k(e.stateEnteredAtMs,"snapshot.stateEnteredAtMs"),P(e.inFlightTurns,"snapshot.inFlightTurns"),P(e.activeBackgroundShells,"snapshot.activeBackgroundShells"),e.pendingApprovals!==void 0&&P(e.pendingApprovals,"snapshot.pendingApprovals"),g(e.provisionedMemoryMb,"snapshot.provisionedMemoryMb"),g(e.rssMemoryMb,"snapshot.rssMemoryMb"),r.idleSuspendMs!==null&&A(r.idleSuspendMs,"policy.idleSuspendMs"),r.idleStopMs!==null&&A(r.idleStopMs,"policy.idleStopMs"),A(r.drainGraceMs,"policy.drainGraceMs"),A(r.pendingApprovalGraceMs,"policy.pendingApprovalGraceMs"),r.maxLifetimeMs!==null&&g(r.maxLifetimeMs,"policy.maxLifetimeMs"),r.maxSuspendedMs!==null&&g(r.maxSuspendedMs,"policy.maxSuspendedMs"),g(r.softMemoryRecycleMb,"policy.softMemoryRecycleMb"),g(r.hardMemoryCapMb,"policy.hardMemoryCapMb"),r.workingHoursPrewarm&&V(r.workingHoursPrewarm);},L=(e,n,r)=>{let o=n.timezoneOffsetMinutes*6e4,t=new Date(e+o+r*C),m=t.getUTCDay();if(n.weekdaysOnly&&(m===0||m===6))return null;let u=Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-o,i=u+n.startHour*x,s=n.endHour<=n.startHour,c=u+n.endHour*x+(s?C:0);return {prewarmStartMs:i-n.prewarmLeadMs,windowStartMs:i,windowEndMs:c}},E=(e,n)=>{for(let r of [-1,0,1]){let o=L(e,n,r);if(o&&e>=o.prewarmStartMs&&e<o.windowEndMs)return o}return null},K=(e,n)=>{let r=null;for(let o=0;o<=8;o+=1){let t=L(e,n,o);t&&t.prewarmStartMs>e&&(r=r===null?t.prewarmStartMs:Math.min(r,t.prewarmStartMs));}return r},y=(...e)=>{let n=null;for(let r of e)r!=null&&(n=n===null?r:Math.min(n,r));return n},j=(e,n,r=w(e.workloadClass,{warmRetentionMode:e.warmRetentionMode}))=>{Y(e,n,r);let o=H(e.provider),t=e.inFlightTurns>0||e.activeBackgroundShells>0,m=(e.pendingApprovals??0)>0,u=Math.max(0,n-e.createdAtMs),i=r.maxLifetimeMs!==null&&u>=r.maxLifetimeMs,s=r.maxLifetimeMs!==null?e.createdAtMs+r.maxLifetimeMs:null;if(e.state==="destroyed")return {action:"none",reason:"workload_already_destroyed",nextCheckAtMs:null};if(e.state==="failed"||e.state==="orphaned")return {action:"terminate",reason:`reap_${e.state}_workload`,nextCheckAtMs:null};if(e.state==="provisioning"||e.state==="booting"||e.state==="suspending"||e.state==="terminating")return {action:"none",reason:`workload_${e.state}`,nextCheckAtMs:n+$};if(e.state==="suspended"){let l=Math.max(0,n-e.stateEnteredAtMs);if(r.maxSuspendedMs!==null&&l>=r.maxSuspendedMs)return {action:"terminate",reason:"suspended_retention_expired",nextCheckAtMs:null};if(r.workingHoursPrewarm&&E(n,r.workingHoursPrewarm))return {action:"prewarm",reason:"working_hours_prewarm_window",nextCheckAtMs:null};let f=r.maxSuspendedMs!==null?e.stateEnteredAtMs+r.maxSuspendedMs:null,_=r.workingHoursPrewarm?K(n,r.workingHoursPrewarm):null;return {action:"none",reason:"suspended_within_retention",nextCheckAtMs:y(f,_,n+z)}}if(e.state==="draining"){let l=Math.max(0,n-e.stateEnteredAtMs),f=e.stateEnteredAtMs+r.drainGraceMs,_=Math.max(0,n-e.lastActivityAtMs);if(t)return i?l<r.drainGraceMs?{action:"none",reason:"waiting_for_in_flight_work_to_drain",nextCheckAtMs:f}:{action:"terminate",reason:"max_lifetime_exceeded_with_active_work",nextCheckAtMs:null}:{action:"none",reason:"active_work_blocks_idle_drain",nextCheckAtMs:y(s,n+R)};if(m&&!i&&r.pendingApprovalGraceMs>0&&_<r.pendingApprovalGraceMs)return {action:"none",reason:"waiting_for_pending_approval",nextCheckAtMs:y(s,e.lastActivityAtMs+r.pendingApprovalGraceMs)};if(r.requireArchiveFlushBeforeWindDown&&!e.archiveFlushed)return !i||l<r.drainGraceMs?{action:"none",reason:"waiting_for_archive_flush",nextCheckAtMs:n+B}:{action:"terminate",reason:"max_lifetime_exceeded_without_archive_flush",nextCheckAtMs:null};if(i)return {action:"terminate",reason:"max_lifetime_reached_after_drain",nextCheckAtMs:null};if(r.idleAction==="terminate")return {action:"terminate",reason:"drain_complete_ready_to_terminate",nextCheckAtMs:null};let M=e.provisionedMemoryMb??e.rssMemoryMb;return o.supportsSuspend&&o.suspendMaxMemoryMb!==void 0&&M!==void 0&&M>o.suspendMaxMemoryMb?r.hardMemoryCapMb!==null?{action:"recycle",reason:"memory_exceeds_provider_suspend_cap",nextCheckAtMs:null}:{action:"terminate",reason:"cannot_suspend_above_provider_memory_cap",nextCheckAtMs:null}:{action:"suspend",reason:o.supportsSuspend?"drain_complete_ready_to_suspend":"drain_complete_ready_to_stop",nextCheckAtMs:null}}if(i)return t||r.requireArchiveFlushBeforeWindDown&&!e.archiveFlushed?{action:"drain",reason:"max_lifetime_reached_draining",nextCheckAtMs:n+r.drainGraceMs}:{action:"terminate",reason:"max_lifetime_reached",nextCheckAtMs:null};if(r.hardMemoryCapMb!==null&&e.rssMemoryMb!==void 0&&e.rssMemoryMb>(o.suspendMaxMemoryMb!==void 0?Math.min(r.hardMemoryCapMb,o.suspendMaxMemoryMb):r.hardMemoryCapMb))return {action:"recycle",reason:"rss_exceeds_hard_cap",nextCheckAtMs:null};if(r.softMemoryRecycleMb!==null&&e.rssMemoryMb!==void 0&&e.rssMemoryMb>=r.softMemoryRecycleMb&&!t)return {action:"recycle",reason:"rss_exceeds_soft_recycle_threshold",nextCheckAtMs:null};if(e.pinnedWarm||r.idleAction==="keep_warm")return {action:"none",reason:"workload_pinned_warm",nextCheckAtMs:s};if(r.workingHoursPrewarm){let l=E(n,r.workingHoursPrewarm);if(l)return {action:"none",reason:"within_working_hours_window",nextCheckAtMs:y(s,l.windowEndMs)}}if(t)return {action:"none",reason:"active_work_in_progress",nextCheckAtMs:y(s,n+R)};let c=o.supportsSuspend?r.idleSuspendMs:r.idleStopMs;if(c===null)return {action:"none",reason:"no_idle_timeout_configured",nextCheckAtMs:s};let p=Math.max(0,n-e.lastActivityAtMs);if(m&&r.pendingApprovalGraceMs>0){let l=Math.max(c,r.pendingApprovalGraceMs);if(p<l)return {action:"none",reason:"waiting_for_pending_approval",nextCheckAtMs:y(s,e.lastActivityAtMs+l)}}return p>=c?{action:"drain",reason:"idle_timeout_reached",nextCheckAtMs:n+r.drainGraceMs}:{action:"none",reason:"within_idle_window",nextCheckAtMs:y(s,e.lastActivityAtMs+c)}};var Z=["provisioning","booting","warm","active","draining","suspending","suspended","terminating","destroyed","failed","orphaned"],J=["warm-interactive","warm-pool","batch-worker","ephemeral-session","always-on"];var Q=1e3,D=(e,n)=>{let r=(n.priority??0)-(e.priority??0);if(r!==0)return r;let o=e.requestedAtMs-n.requestedAtMs;return o!==0?o:e.workloadId<n.workloadId?-1:e.workloadId>n.workloadId?1:0},X=e=>{let n=new Map;for(let r of e){if(!r.workloadId)throw new a("invalid_request","StaggeredWakeRequest.workloadId must be non-empty");if(!Number.isFinite(r.requestedAtMs))throw new a("invalid_request",`requestedAtMs must be finite (got ${r.requestedAtMs})`);if(r.priority!==void 0&&!Number.isFinite(r.priority))throw new a("invalid_request",`priority must be finite (got ${r.priority})`);let o=n.get(r.workloadId);(!o||D(r,o)<0)&&n.set(r.workloadId,r);}return [...n.values()]},ee=(e,n,r)=>{if(!Number.isFinite(n))throw new a("invalid_request",`nowMs must be finite (got ${n})`);if(!Number.isInteger(r.maxConcurrentWakes)||r.maxConcurrentWakes<1)throw new a("invalid_request",`maxConcurrentWakes must be an integer >= 1 (got ${r.maxConcurrentWakes})`);if(!Number.isFinite(r.minSpacingMs)||r.minSpacingMs<0)throw new a("invalid_request",`minSpacingMs must be a finite number >= 0 (got ${r.minSpacingMs})`);if(r.inFlightWakeCount!==void 0&&(!Number.isInteger(r.inFlightWakeCount)||r.inFlightWakeCount<0))throw new a("invalid_request",`inFlightWakeCount must be an integer >= 0 (got ${r.inFlightWakeCount})`);if(r.lastWakeLaunchedAtMs!==void 0&&r.lastWakeLaunchedAtMs!==null&&!Number.isFinite(r.lastWakeLaunchedAtMs))throw new a("invalid_request",`lastWakeLaunchedAtMs must be finite or null (got ${r.lastWakeLaunchedAtMs})`);let o=X(e).sort(D),t=r.inFlightWakeCount??0,m=Math.max(0,r.maxConcurrentWakes-t),u=[],i=[],s=r.minSpacingMs>0?r.minSpacingMs:Q,c=r.lastWakeLaunchedAtMs!==null&&r.lastWakeLaunchedAtMs!==void 0?Math.max(n,r.lastWakeLaunchedAtMs+r.minSpacingMs):n,p=0;for(let l of o){if(p>=m){let f=Math.max(c,n+s);i.push({request:l,earliestLaunchAtMs:f,reason:"concurrency_limit"}),c=f+s;continue}if(c>n){i.push({request:l,earliestLaunchAtMs:c,reason:"spacing_interval"}),p+=1,c+=r.minSpacingMs;continue}u.push(l),p+=1,r.minSpacingMs>0&&(c=n+r.minSpacingMs);}return {launchNow:u,defer:i}};exports.HOSTING_PRICING_RATES=d;exports.WORKLOAD_CLASSES=J;exports.WORKLOAD_LIFECYCLE_STATES=Z;exports.defaultWorkloadLifecyclePolicy=w;exports.evaluateWorkloadLifecycle=j;exports.planStaggeredWakes=ee;exports.projectHostingMonthlyCost=T;//# sourceMappingURL=index.cjs.map
|
|
1
|
+
'use strict';var chunkMO2YI2GE_cjs=require('../chunk-MO2YI2GE.cjs');require('../chunk-CNAFA6FE.cjs'),require('../chunk-QREJ73ZG.cjs');Object.defineProperty(exports,"HOSTING_PRICING_RATES",{enumerable:true,get:function(){return chunkMO2YI2GE_cjs.i}});Object.defineProperty(exports,"WORKLOAD_CLASSES",{enumerable:true,get:function(){return chunkMO2YI2GE_cjs.n}});Object.defineProperty(exports,"WORKLOAD_LIFECYCLE_STATES",{enumerable:true,get:function(){return chunkMO2YI2GE_cjs.m}});Object.defineProperty(exports,"defaultWorkloadLifecyclePolicy",{enumerable:true,get:function(){return chunkMO2YI2GE_cjs.k}});Object.defineProperty(exports,"evaluateWorkloadLifecycle",{enumerable:true,get:function(){return chunkMO2YI2GE_cjs.l}});Object.defineProperty(exports,"planStaggeredWakes",{enumerable:true,get:function(){return chunkMO2YI2GE_cjs.o}});Object.defineProperty(exports,"projectHostingMonthlyCost",{enumerable:true,get:function(){return chunkMO2YI2GE_cjs.j}});//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/infraError.ts","../../src/render/renderPlans.ts","../../src/lifecycle/costProjection.ts","../../src/core/providers.ts","../../src/lifecycle/lifecyclePolicy.ts","../../src/lifecycle/evaluateWorkloadLifecycle.ts","../../src/lifecycle/lifecycleTypes.ts","../../src/lifecycle/staggeredWakes.ts"],"names":["RETRYABLE_INFRA_ERROR_CODES","InfraError","code","message","details","prefix","RENDER_PLAN_TIERS","renderPlanForMemoryMb","memoryMb","tier","RENDER_FAILED_DEPLOY_STATUSES","HOURS_PER_MONTH","DEFAULT_RAILWAY_MEMORY_UTILIZATION","DEFAULT_RAILWAY_CPU_UTILIZATION","HOSTING_PRICING_RATES","roundUsd","amount","requireNonNegative","value","name","requireUnitInterval","projectHostingMonthlyCost","input","markupMultiplier","memoryGb","activeMonthFraction","totalStoredMonthFraction","suspendedMonthFraction","activeComputeUsd","suspendedStorageUsd","pricingBasis","memUtil","cpuUtil","vcpuMonthRate","plan","roundedActive","roundedStorage","roundedRaw","roundedMarkedUp","roundedMargin","INFRA_PROVIDERS","infraProviderDescriptor","provider","defaultWorkloadLifecyclePolicy","workloadClass","options","TRANSITIONAL_POLL_MS","ACTIVE_WORK_POLL_MS","ARCHIVE_FLUSH_POLL_MS","SUSPENDED_POLL_MS","HOUR_MS","DAY_MS","assertFiniteNumber","assertNonNegativeFinite","assertNonNegativeInteger","assertPositiveOptional","validateWorkingHoursSchedule","schedule","validateSnapshotAndPolicy","snapshot","nowMs","policy","workingWindowForDayDelta","dayDelta","offsetMs","shifted","dayOfWeek","localMidnightUtcMs","windowStartMs","isOvernight","windowEndMs","activeWorkingWindowAt","bounds","nextWorkingHoursPrewarmAtMs","next","earliestCheckTime","candidates","earliest","candidate","evaluateWorkloadLifecycle","descriptor","hasActiveWork","hasPendingApprovals","ageMs","maxLifetimeReached","lifetimeDeadlineMs","suspendedElapsedMs","expiryAtMs","nextPrewarmAtMs","drainElapsedMs","drainDeadlineMs","idleElapsedMs","suspendMemoryMb","activeWindow","idleLimitMs","approvalLimitMs","WORKLOAD_LIFECYCLE_STATES","WORKLOAD_CLASSES","DEFAULT_CONCURRENCY_RETRY_FLOOR_MS","compareWakeRequests","left","right","priorityDiff","requestedDiff","deduplicateRequests","requests","byWorkloadId","request","existing","planStaggeredWakes","sorted","inFlight","availableSlots","launchNow","defer","retryStepMs","nextEligibleAtMs","scheduledWithinConcurrency","earliestLaunchAtMs"],"mappings":"aAiBA,IAAMA,CAAAA,CAA2D,IAAI,GAAA,CAAI,CACvE,cACA,cAAA,CACA,sBACF,CAAC,CAAA,CAEYC,EAAN,cAAyB,KAAM,CAC3B,IAAA,CACA,OACA,QAAA,CACA,SAAA,CAET,WAAA,CAAYC,CAAAA,CAAsBC,CAAAA,CAAkBC,CAAAA,CAA6B,CAC/E,IAAMC,EAASD,CAAAA,EAAS,QAAA,CAAW,CAAA,CAAA,EAAIA,CAAAA,CAAQ,QAAQ,CAAA,EAAA,CAAA,CAAO,EAAA,CAC9D,KAAA,CAAMD,CAAAA,CAAU,GAAGE,CAAM,CAAA,EAAGF,CAAO,CAAA,CAAA,CAAK,CAAA,EAAGE,CAAM,CAAA,+BAAA,EAAkCH,CAAI,IAAK,CAC1F,KAAA,CAAOE,CAAAA,EAAS,KAClB,CAAC,CAAA,CACD,I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,CAAAP,CAAAA,CACA,kBAAA,CAAoBS,CAAAA,CACpB,OAAQ,kBACV,CAAC,CAAA,CACDC,CAAAA,EAA8B,EAC9BD,CAAAA,EAAoBvE,CAAAA,CAAQ,YAAA,CAC5B,QACF,CAEAoE,CAAAA,CAAU,IAAA,CAAKN,CAAO,CAAA,CACtBU,GAA8B,CAAA,CAC1BxE,CAAAA,CAAQ,YAAA,CAAe,CAAA,GACzBuE,EAAmBxD,CAAAA,CAAQf,CAAAA,CAAQ,YAAA,EAEvC,CAEA,OAAO,CAAE,SAAA,CAAAoE,CAAAA,CAAW,KAAA,CAAAC,CAAM,CAC5B","file":"index.cjs","sourcesContent":["export type InfraErrorCode =\n | 'authentication_failed'\n | 'rate_limited'\n | 'not_found'\n | 'conflict'\n | 'provider_unavailable'\n | 'unreachable'\n | 'invalid_request'\n | 'deploy_failed';\n\nexport type InfraErrorDetails = {\n readonly status?: number;\n readonly provider?: string;\n readonly cause?: unknown;\n readonly retryable?: boolean;\n};\n\nconst RETRYABLE_INFRA_ERROR_CODES: ReadonlySet<InfraErrorCode> = new Set([\n 'unreachable',\n 'rate_limited',\n 'provider_unavailable',\n]);\n\nexport class InfraError extends Error {\n readonly code: InfraErrorCode;\n readonly status?: number;\n readonly provider?: string;\n readonly retryable: boolean;\n\n constructor(code: InfraErrorCode, message?: string, details?: InfraErrorDetails) {\n const prefix = details?.provider ? `[${details.provider}] ` : '';\n super(message ? `${prefix}${message}` : `${prefix}Infrastructure request failed (${code})`, {\n cause: details?.cause,\n });\n this.name = 'InfraError';\n this.code = code;\n this.status = details?.status;\n this.provider = details?.provider;\n this.retryable = details?.retryable ?? RETRYABLE_INFRA_ERROR_CODES.has(code);\n }\n}\n\nexport const infraErrorForStatus = (\n status: number,\n details?: { readonly provider?: string; readonly message?: string },\n): InfraError => {\n const code: InfraErrorCode =\n status === 401 || status === 403\n ? 'authentication_failed'\n : status === 404\n ? 'not_found'\n : status === 409\n ? 'conflict'\n : status === 429\n ? 'rate_limited'\n : status === 400 || status === 422\n ? 'invalid_request'\n : 'provider_unavailable';\n const message = details?.message\n ? `HTTP ${status}: ${details.message}`\n : `HTTP ${status} (${code})`;\n return new InfraError(code, message, { status, provider: details?.provider });\n};\n\nexport const isInfraError = (error: unknown, code?: InfraErrorCode): error is InfraError =>\n error instanceof InfraError && (code === undefined || error.code === code);\n\nexport const requireNonEmpty = (\n value: string | undefined,\n label: string,\n provider?: string,\n): string => {\n if (!value?.trim()) {\n throw new InfraError('invalid_request', `Missing required ${label}`, { provider });\n }\n return value;\n};\n\nexport const ignoreNotFound = (error: unknown): void => {\n if (!isInfraError(error, 'not_found')) throw error;\n};\n\nexport const assertNoEgressAllowlist = (\n egressAllowlist: readonly string[] | undefined,\n provider: string,\n): void => {\n if (egressAllowlist && egressAllowlist.length > 0) {\n throw new InfraError('invalid_request', 'Egress allowlist is not enforced by this driver', {\n provider,\n });\n }\n};\n","export type RenderPlanId = 'starter' | 'standard' | 'pro' | 'pro_plus' | 'pro_max' | 'pro_ultra';\n\nexport type RenderPlanTier = {\n readonly id: RenderPlanId;\n readonly maxMemoryMb: number;\n readonly monthlyUsd: number;\n};\n\nexport const RENDER_PLAN_TIERS: readonly RenderPlanTier[] = [\n { id: 'starter', maxMemoryMb: 512, monthlyUsd: 7 },\n { id: 'standard', maxMemoryMb: 2048, monthlyUsd: 25 },\n { id: 'pro', maxMemoryMb: 4096, monthlyUsd: 85 },\n { id: 'pro_plus', maxMemoryMb: 8192, monthlyUsd: 175 },\n { id: 'pro_max', maxMemoryMb: 16_384, monthlyUsd: 225 },\n { id: 'pro_ultra', maxMemoryMb: 32_768, monthlyUsd: 450 },\n];\n\nexport const renderPlanForMemoryMb = (memoryMb: number): RenderPlanTier => {\n for (const tier of RENDER_PLAN_TIERS) {\n if (memoryMb <= tier.maxMemoryMb) return tier;\n }\n return RENDER_PLAN_TIERS[RENDER_PLAN_TIERS.length - 1];\n};\n\nexport const RENDER_FAILED_DEPLOY_STATUSES: ReadonlySet<string> = new Set([\n 'build_failed',\n 'update_failed',\n 'pre_deploy_failed',\n 'canceled',\n]);\n\nexport const RENDER_ENDED_DEPLOY_STATUSES: ReadonlySet<string> = new Set([\n ...RENDER_FAILED_DEPLOY_STATUSES,\n 'deactivated',\n]);\n","import type { WorkloadCpuKind } from '../core/contracts.ts';\nimport { InfraError } from '../core/infraError.ts';\nimport type { InfraProviderId } from '../core/providers.ts';\nimport { renderPlanForMemoryMb } from '../render/renderPlans.ts';\n\nconst HOURS_PER_MONTH = 730;\nconst DEFAULT_RAILWAY_MEMORY_UTILIZATION = 0.65;\nconst DEFAULT_RAILWAY_CPU_UTILIZATION = 0.1;\n\nexport type HostingCostProjectionInput = {\n readonly provider: InfraProviderId;\n readonly memoryMb: number;\n readonly vcpus: number;\n readonly activeHoursPerMonth: number;\n readonly suspendedHoursPerMonth: number;\n readonly rootfsGb: number;\n readonly markupMultiplier?: number;\n readonly averageMemoryUtilization?: number;\n readonly averageCpuUtilization?: number;\n readonly cpuKind?: WorkloadCpuKind;\n};\n\nexport type HostingCostProjection = {\n readonly provider: InfraProviderId;\n readonly activeComputeUsd: number;\n readonly suspendedStorageUsd: number;\n readonly rawMonthlyCostUsd: number;\n readonly markupMultiplier: number;\n readonly markedUpMonthlyCostUsd: number;\n readonly marginUsd: number;\n readonly pricingBasis: string;\n};\n\nexport const HOSTING_PRICING_RATES = {\n railway: {\n memoryUsdPerGbHour: 0.0139,\n vcpuUsdPerHour: 0.0278,\n storageUsdPerGbMonth: 0.15,\n },\n fly: {\n sharedVcpuUsdPerMonth: 0.7,\n performanceVcpuUsdPerMonth: 21.0,\n memoryUsdPerGbMonth: 6.0,\n suspendedRootfsUsdPerGbMonth: 0.15,\n },\n render: {\n diskUsdPerGbMonth: 0.25,\n },\n firecracker: {\n amortizedMemoryUsdPerGbMonth: 3.5,\n amortizedVcpuUsdPerMonth: 4.0,\n snapshotStorageUsdPerGbMonth: 0.05,\n },\n aws: {\n fargateArmVcpuUsdPerHour: 0.0324,\n fargateArmMemoryUsdPerGbHour: 0.0036,\n storageUsdPerGbMonth: 0.08,\n },\n gcp: {\n vcpuUsdPerHour: 0.0432,\n memoryUsdPerGbHour: 0.0048,\n storageUsdPerGbMonth: 0.1,\n },\n azure: {\n vcpuUsdPerHour: 0.0432,\n memoryUsdPerGbHour: 0.0048,\n storageUsdPerGbMonth: 0.1,\n },\n} as const;\n\nconst roundUsd = (amount: number): number => Math.round(amount * 10_000) / 10_000;\n\nconst requireNonNegative = (value: number, name: string): void => {\n if (!Number.isFinite(value) || value < 0) {\n throw new InfraError('invalid_request', `${name} must be a finite number >= 0 (got ${value})`);\n }\n};\n\nconst requireUnitInterval = (value: number, name: string): void => {\n if (!Number.isFinite(value) || value < 0 || value > 1) {\n throw new InfraError(\n 'invalid_request',\n `${name} must be a finite number in [0, 1] (got ${value})`,\n );\n }\n};\n\nexport const projectHostingMonthlyCost = (\n input: HostingCostProjectionInput,\n): HostingCostProjection => {\n requireNonNegative(input.memoryMb, 'memoryMb');\n requireNonNegative(input.vcpus, 'vcpus');\n requireNonNegative(input.activeHoursPerMonth, 'activeHoursPerMonth');\n requireNonNegative(input.suspendedHoursPerMonth, 'suspendedHoursPerMonth');\n requireNonNegative(input.rootfsGb, 'rootfsGb');\n\n if (input.activeHoursPerMonth + input.suspendedHoursPerMonth > HOURS_PER_MONTH) {\n throw new InfraError(\n 'invalid_request',\n `activeHoursPerMonth + suspendedHoursPerMonth must be <= ${HOURS_PER_MONTH} (got ${input.activeHoursPerMonth + input.suspendedHoursPerMonth})`,\n );\n }\n\n const markupMultiplier = input.markupMultiplier ?? 1;\n if (!Number.isFinite(markupMultiplier) || markupMultiplier < 1) {\n throw new InfraError(\n 'invalid_request',\n `markupMultiplier must be a finite number >= 1 (got ${markupMultiplier})`,\n );\n }\n\n if (input.averageMemoryUtilization !== undefined) {\n requireUnitInterval(input.averageMemoryUtilization, 'averageMemoryUtilization');\n }\n if (input.averageCpuUtilization !== undefined) {\n requireUnitInterval(input.averageCpuUtilization, 'averageCpuUtilization');\n }\n\n const memoryGb = input.memoryMb / 1024;\n const activeMonthFraction = input.activeHoursPerMonth / HOURS_PER_MONTH;\n const totalStoredMonthFraction =\n (input.activeHoursPerMonth + input.suspendedHoursPerMonth) / HOURS_PER_MONTH;\n const suspendedMonthFraction = input.suspendedHoursPerMonth / HOURS_PER_MONTH;\n\n let activeComputeUsd = 0;\n let suspendedStorageUsd = 0;\n let pricingBasis = '';\n\n switch (input.provider) {\n case 'railway': {\n const memUtil = input.averageMemoryUtilization ?? DEFAULT_RAILWAY_MEMORY_UTILIZATION;\n const cpuUtil = input.averageCpuUtilization ?? DEFAULT_RAILWAY_CPU_UTILIZATION;\n activeComputeUsd =\n memoryGb *\n memUtil *\n input.activeHoursPerMonth *\n HOSTING_PRICING_RATES.railway.memoryUsdPerGbHour +\n input.vcpus *\n cpuUtil *\n input.activeHoursPerMonth *\n HOSTING_PRICING_RATES.railway.vcpuUsdPerHour;\n suspendedStorageUsd =\n input.rootfsGb *\n totalStoredMonthFraction *\n HOSTING_PRICING_RATES.railway.storageUsdPerGbMonth;\n pricingBasis = 'usage-metered active RAM/vCPU per second + persistent volume storage';\n break;\n }\n case 'fly': {\n const vcpuMonthRate =\n input.cpuKind === 'performance'\n ? HOSTING_PRICING_RATES.fly.performanceVcpuUsdPerMonth\n : HOSTING_PRICING_RATES.fly.sharedVcpuUsdPerMonth;\n const monthlyActiveRate =\n input.vcpus * vcpuMonthRate + memoryGb * HOSTING_PRICING_RATES.fly.memoryUsdPerGbMonth;\n activeComputeUsd = monthlyActiveRate * activeMonthFraction;\n suspendedStorageUsd =\n input.rootfsGb *\n suspendedMonthFraction *\n HOSTING_PRICING_RATES.fly.suspendedRootfsUsdPerGbMonth;\n pricingBasis =\n 'provisioned Firecracker microVM per second while active + rootfs-only storage while suspended';\n break;\n }\n case 'render': {\n const plan = renderPlanForMemoryMb(input.memoryMb);\n activeComputeUsd = plan.monthlyUsd * activeMonthFraction;\n suspendedStorageUsd =\n input.rootfsGb * totalStoredMonthFraction * HOSTING_PRICING_RATES.render.diskUsdPerGbMonth;\n pricingBasis = `prorated fixed Render ${plan.id} tier while unsuspended + persistent disk`;\n break;\n }\n case 'firecracker': {\n const monthlyHostShare =\n memoryGb * HOSTING_PRICING_RATES.firecracker.amortizedMemoryUsdPerGbMonth +\n input.vcpus * HOSTING_PRICING_RATES.firecracker.amortizedVcpuUsdPerMonth;\n activeComputeUsd = monthlyHostShare * activeMonthFraction;\n suspendedStorageUsd =\n (input.rootfsGb + memoryGb) *\n suspendedMonthFraction *\n HOSTING_PRICING_RATES.firecracker.snapshotStorageUsdPerGbMonth;\n pricingBasis =\n 'amortized dedicated bare-metal host capacity while active + NVMe snapshot storage while suspended';\n break;\n }\n case 'aws': {\n activeComputeUsd =\n input.vcpus *\n input.activeHoursPerMonth *\n HOSTING_PRICING_RATES.aws.fargateArmVcpuUsdPerHour +\n memoryGb *\n input.activeHoursPerMonth *\n HOSTING_PRICING_RATES.aws.fargateArmMemoryUsdPerGbHour;\n suspendedStorageUsd =\n input.rootfsGb * totalStoredMonthFraction * HOSTING_PRICING_RATES.aws.storageUsdPerGbMonth;\n pricingBasis = 'AWS Fargate ARM provisioned vCPU/GB-hour + EBS/snapshot storage';\n break;\n }\n case 'gcp': {\n activeComputeUsd =\n input.vcpus * input.activeHoursPerMonth * HOSTING_PRICING_RATES.gcp.vcpuUsdPerHour +\n memoryGb * input.activeHoursPerMonth * HOSTING_PRICING_RATES.gcp.memoryUsdPerGbHour;\n suspendedStorageUsd =\n input.rootfsGb * totalStoredMonthFraction * HOSTING_PRICING_RATES.gcp.storageUsdPerGbMonth;\n pricingBasis = 'GCP provisioned vCPU/GB-hour + persistent storage';\n break;\n }\n case 'azure': {\n activeComputeUsd =\n input.vcpus * input.activeHoursPerMonth * HOSTING_PRICING_RATES.azure.vcpuUsdPerHour +\n memoryGb * input.activeHoursPerMonth * HOSTING_PRICING_RATES.azure.memoryUsdPerGbHour;\n suspendedStorageUsd =\n input.rootfsGb *\n totalStoredMonthFraction *\n HOSTING_PRICING_RATES.azure.storageUsdPerGbMonth;\n pricingBasis = 'Azure Container Apps provisioned vCPU/GB-hour + storage';\n break;\n }\n }\n\n const roundedActive = roundUsd(activeComputeUsd);\n const roundedStorage = roundUsd(suspendedStorageUsd);\n const roundedRaw = roundUsd(roundedActive + roundedStorage);\n const roundedMarkedUp = roundUsd(roundedRaw * markupMultiplier);\n const roundedMargin = roundUsd(roundedMarkedUp - roundedRaw);\n\n return {\n provider: input.provider,\n activeComputeUsd: roundedActive,\n suspendedStorageUsd: roundedStorage,\n rawMonthlyCostUsd: roundedRaw,\n markupMultiplier,\n markedUpMonthlyCostUsd: roundedMarkedUp,\n marginUsd: roundedMargin,\n pricingBasis,\n };\n};\n","export const IMPLEMENTED_INFRA_PROVIDERS = ['railway', 'render', 'fly', 'firecracker'] as const;\nexport const PLANNED_INFRA_PROVIDERS = ['aws', 'gcp', 'azure'] as const;\nexport const ARCHIVE_HOSTING_PROVIDERS = ['railway', 'render'] as const;\n\nexport type ImplementedInfraProvider = (typeof IMPLEMENTED_INFRA_PROVIDERS)[number];\nexport type PlannedInfraProvider = (typeof PLANNED_INFRA_PROVIDERS)[number];\nexport type ArchiveHostingProvider = (typeof ARCHIVE_HOSTING_PROVIDERS)[number];\nexport type InfraProviderId = ImplementedInfraProvider | PlannedInfraProvider;\n\nexport type InfraIsolationKind = 'microvm' | 'container';\n\nexport type InfraBillingUnit =\n | 'active_utilization_second'\n | 'provisioned_second_with_suspend_storage'\n | 'flat_plan_month'\n | 'host_machine_month'\n | 'provisioned_vcpu_memory_second';\n\nexport type InfraProviderDescriptor = {\n readonly id: InfraProviderId;\n readonly name: string;\n readonly implemented: boolean;\n readonly supportsArchiveHosting: boolean;\n readonly supportsWorkloadDriver: boolean;\n readonly isolation: InfraIsolationKind;\n readonly supportsSuspend: boolean;\n readonly suspendMaxMemoryMb?: number;\n readonly supportsByoAccount: boolean;\n readonly supportsManagedAccount: boolean;\n readonly billingUnit: InfraBillingUnit;\n readonly notes: string;\n};\n\nexport const INFRA_PROVIDERS: Readonly<Record<InfraProviderId, InfraProviderDescriptor>> = {\n railway: {\n id: 'railway',\n name: 'Railway',\n implemented: true,\n supportsArchiveHosting: true,\n supportsWorkloadDriver: true,\n isolation: 'container',\n supportsSuspend: false,\n supportsByoAccount: true,\n supportsManagedAccount: true,\n billingUnit: 'active_utilization_second',\n notes:\n 'Usage-metered memory and CPU per second; stopped services bill nothing; no memory-snapshot suspend.',\n },\n render: {\n id: 'render',\n name: 'Render',\n implemented: true,\n supportsArchiveHosting: true,\n supportsWorkloadDriver: true,\n isolation: 'container',\n supportsSuspend: false,\n supportsByoAccount: true,\n supportsManagedAccount: true,\n billingUnit: 'flat_plan_month',\n notes:\n 'Managed web services and Postgres on fixed tiers; service suspend stops execution without a memory snapshot.',\n },\n fly: {\n id: 'fly',\n name: 'Fly.io Machines',\n implemented: true,\n supportsArchiveHosting: false,\n supportsWorkloadDriver: true,\n isolation: 'microvm',\n supportsSuspend: true,\n suspendMaxMemoryMb: 2048,\n supportsByoAccount: true,\n supportsManagedAccount: true,\n billingUnit: 'provisioned_second_with_suspend_storage',\n notes:\n 'Firecracker microVMs with GA memory-snapshot suspend up to 2048 MB RAM and rootfs-only suspended storage billing.',\n },\n firecracker: {\n id: 'firecracker',\n name: 'Firecracker',\n implemented: true,\n supportsArchiveHosting: false,\n supportsWorkloadDriver: true,\n isolation: 'microvm',\n supportsSuspend: true,\n supportsByoAccount: true,\n supportsManagedAccount: true,\n billingUnit: 'host_machine_month',\n notes:\n 'Direct Firecracker VMM HTTP/Unix control plane for dedicated or bare-metal microVM hosts with full memory snapshots.',\n },\n aws: {\n id: 'aws',\n name: 'AWS (Fargate / Lambda MicroVMs)',\n implemented: false,\n supportsArchiveHosting: false,\n supportsWorkloadDriver: false,\n isolation: 'microvm',\n supportsSuspend: true,\n supportsByoAccount: true,\n supportsManagedAccount: true,\n billingUnit: 'provisioned_vcpu_memory_second',\n notes:\n 'Planned cloud adapter for AWS Fargate tasks and Firecracker-backed Lambda MicroVMs (8h session cap).',\n },\n gcp: {\n id: 'gcp',\n name: 'Google Cloud (Cloud Run / GKE Autopilot)',\n implemented: false,\n supportsArchiveHosting: false,\n supportsWorkloadDriver: false,\n isolation: 'microvm',\n supportsSuspend: false,\n supportsByoAccount: true,\n supportsManagedAccount: true,\n billingUnit: 'provisioned_vcpu_memory_second',\n notes: 'Planned cloud adapter for Google Cloud Run and GKE Autopilot workloads.',\n },\n azure: {\n id: 'azure',\n name: 'Azure (Container Apps / ACI)',\n implemented: false,\n supportsArchiveHosting: false,\n supportsWorkloadDriver: false,\n isolation: 'container',\n supportsSuspend: false,\n supportsByoAccount: true,\n supportsManagedAccount: true,\n billingUnit: 'provisioned_vcpu_memory_second',\n notes: 'Planned cloud adapter for Azure Container Apps and Container Instances.',\n },\n};\n\nexport const isInfraProvider = (value: string | null | undefined): value is InfraProviderId =>\n typeof value === 'string' && Object.hasOwn(INFRA_PROVIDERS, value);\n\nexport const isImplementedInfraProvider = (\n value: string | null | undefined,\n): value is ImplementedInfraProvider =>\n IMPLEMENTED_INFRA_PROVIDERS.some((provider) => provider === value);\n\nexport const isArchiveHostingProvider = (\n value: string | null | undefined,\n): value is ArchiveHostingProvider =>\n ARCHIVE_HOSTING_PROVIDERS.some((provider) => provider === value);\n\nexport const infraProviderDescriptor = (provider: InfraProviderId): InfraProviderDescriptor =>\n INFRA_PROVIDERS[provider];\n","import type {\n WarmRetentionMode,\n WorkingHoursSchedule,\n WorkloadClass,\n WorkloadLifecyclePolicy,\n} from './lifecycleTypes.ts';\n\nconst MINUTE_MS = 60_000;\nconst HOUR_MS = 60 * MINUTE_MS;\nconst DAY_MS = 24 * HOUR_MS;\n\nexport type WorkloadLifecyclePolicyOptions = {\n readonly warmRetentionMode?: WarmRetentionMode;\n readonly workingHoursPrewarm?: WorkingHoursSchedule;\n};\n\nexport const defaultWorkloadLifecyclePolicy = (\n workloadClass: WorkloadClass,\n options: WorkloadLifecyclePolicyOptions = {},\n): WorkloadLifecyclePolicy => {\n switch (workloadClass) {\n case 'warm-interactive':\n return {\n workloadClass,\n idleSuspendMs: 8 * MINUTE_MS,\n idleStopMs: 3 * HOUR_MS,\n drainGraceMs: 60_000,\n pendingApprovalGraceMs: 0,\n maxLifetimeMs: 24 * HOUR_MS,\n maxSuspendedMs: 14 * DAY_MS,\n softMemoryRecycleMb: 1536,\n hardMemoryCapMb: 2048,\n requireArchiveFlushBeforeWindDown: false,\n workingHoursPrewarm: options.workingHoursPrewarm,\n idleAction: 'suspend',\n };\n case 'warm-pool':\n return {\n workloadClass,\n idleSuspendMs: options.warmRetentionMode === 'extended' ? 60 * MINUTE_MS : 5 * MINUTE_MS,\n idleStopMs: 3 * HOUR_MS,\n drainGraceMs: 60_000,\n pendingApprovalGraceMs: 0,\n maxLifetimeMs: 24 * HOUR_MS,\n maxSuspendedMs: 7 * DAY_MS,\n softMemoryRecycleMb: 1536,\n hardMemoryCapMb: 2048,\n requireArchiveFlushBeforeWindDown: false,\n workingHoursPrewarm: options.workingHoursPrewarm,\n idleAction: 'suspend',\n };\n case 'batch-worker':\n return {\n workloadClass,\n idleSuspendMs: 5 * MINUTE_MS,\n idleStopMs: 5 * MINUTE_MS,\n drainGraceMs: 120_000,\n pendingApprovalGraceMs: 0,\n maxLifetimeMs: 4 * HOUR_MS,\n maxSuspendedMs: 24 * HOUR_MS,\n softMemoryRecycleMb: 1536,\n hardMemoryCapMb: 2048,\n requireArchiveFlushBeforeWindDown: false,\n idleAction: 'terminate',\n };\n case 'ephemeral-session':\n return {\n workloadClass,\n idleSuspendMs: 15 * MINUTE_MS,\n idleStopMs: 15 * MINUTE_MS,\n drainGraceMs: 60_000,\n pendingApprovalGraceMs: 30 * MINUTE_MS,\n maxLifetimeMs: 24 * HOUR_MS,\n maxSuspendedMs: 7 * DAY_MS,\n softMemoryRecycleMb: null,\n hardMemoryCapMb: null,\n requireArchiveFlushBeforeWindDown: true,\n idleAction: 'suspend',\n };\n case 'always-on':\n return {\n workloadClass,\n idleSuspendMs: null,\n idleStopMs: null,\n drainGraceMs: 60_000,\n pendingApprovalGraceMs: 0,\n maxLifetimeMs: null,\n maxSuspendedMs: null,\n softMemoryRecycleMb: null,\n hardMemoryCapMb: null,\n requireArchiveFlushBeforeWindDown: false,\n idleAction: 'keep_warm',\n };\n }\n};\n","import { InfraError } from '../core/infraError.ts';\nimport { infraProviderDescriptor } from '../core/providers.ts';\nimport { defaultWorkloadLifecyclePolicy } from './lifecyclePolicy.ts';\nimport type {\n WorkingHoursSchedule,\n WorkloadLifecycleDecision,\n WorkloadLifecyclePolicy,\n WorkloadLifecycleSnapshot,\n} from './lifecycleTypes.ts';\n\nconst TRANSITIONAL_POLL_MS = 15_000;\nconst ACTIVE_WORK_POLL_MS = 30_000;\nconst ARCHIVE_FLUSH_POLL_MS = 10_000;\nconst SUSPENDED_POLL_MS = 300_000;\nconst HOUR_MS = 3_600_000;\nconst DAY_MS = 24 * HOUR_MS;\n\nconst assertFiniteNumber = (value: number, name: string): void => {\n if (!Number.isFinite(value)) {\n throw new InfraError('invalid_request', `${name} must be a finite number (got ${value})`);\n }\n};\n\nconst assertNonNegativeFinite = (value: number, name: string): void => {\n if (!Number.isFinite(value) || value < 0) {\n throw new InfraError('invalid_request', `${name} must be a finite number >= 0 (got ${value})`);\n }\n};\n\nconst assertNonNegativeInteger = (value: number, name: string): void => {\n if (!Number.isInteger(value) || value < 0) {\n throw new InfraError('invalid_request', `${name} must be an integer >= 0 (got ${value})`);\n }\n};\n\nconst assertPositiveOptional = (value: number | null | undefined, name: string): void => {\n if (value === null || value === undefined) return;\n if (!Number.isFinite(value) || value <= 0) {\n throw new InfraError('invalid_request', `${name} must be a finite number > 0 (got ${value})`);\n }\n};\n\nconst validateWorkingHoursSchedule = (schedule: WorkingHoursSchedule): void => {\n assertFiniteNumber(schedule.timezoneOffsetMinutes, 'workingHoursPrewarm.timezoneOffsetMinutes');\n if (!Number.isFinite(schedule.startHour) || schedule.startHour < 0 || schedule.startHour >= 24) {\n throw new InfraError(\n 'invalid_request',\n `workingHoursPrewarm.startHour must be in [0, 24) (got ${schedule.startHour})`,\n );\n }\n if (!Number.isFinite(schedule.endHour) || schedule.endHour < 0 || schedule.endHour > 24) {\n throw new InfraError(\n 'invalid_request',\n `workingHoursPrewarm.endHour must be in [0, 24] (got ${schedule.endHour})`,\n );\n }\n assertNonNegativeFinite(schedule.prewarmLeadMs, 'workingHoursPrewarm.prewarmLeadMs');\n};\n\nconst validateSnapshotAndPolicy = (\n snapshot: WorkloadLifecycleSnapshot,\n nowMs: number,\n policy: WorkloadLifecyclePolicy,\n): void => {\n assertFiniteNumber(nowMs, 'nowMs');\n assertFiniteNumber(snapshot.createdAtMs, 'snapshot.createdAtMs');\n assertFiniteNumber(snapshot.lastActivityAtMs, 'snapshot.lastActivityAtMs');\n assertFiniteNumber(snapshot.stateEnteredAtMs, 'snapshot.stateEnteredAtMs');\n assertNonNegativeInteger(snapshot.inFlightTurns, 'snapshot.inFlightTurns');\n assertNonNegativeInteger(snapshot.activeBackgroundShells, 'snapshot.activeBackgroundShells');\n if (snapshot.pendingApprovals !== undefined) {\n assertNonNegativeInteger(snapshot.pendingApprovals, 'snapshot.pendingApprovals');\n }\n assertPositiveOptional(snapshot.provisionedMemoryMb, 'snapshot.provisionedMemoryMb');\n assertPositiveOptional(snapshot.rssMemoryMb, 'snapshot.rssMemoryMb');\n\n if (policy.idleSuspendMs !== null) {\n assertNonNegativeFinite(policy.idleSuspendMs, 'policy.idleSuspendMs');\n }\n if (policy.idleStopMs !== null) {\n assertNonNegativeFinite(policy.idleStopMs, 'policy.idleStopMs');\n }\n assertNonNegativeFinite(policy.drainGraceMs, 'policy.drainGraceMs');\n assertNonNegativeFinite(policy.pendingApprovalGraceMs, 'policy.pendingApprovalGraceMs');\n if (policy.maxLifetimeMs !== null) {\n assertPositiveOptional(policy.maxLifetimeMs, 'policy.maxLifetimeMs');\n }\n if (policy.maxSuspendedMs !== null) {\n assertPositiveOptional(policy.maxSuspendedMs, 'policy.maxSuspendedMs');\n }\n assertPositiveOptional(policy.softMemoryRecycleMb, 'policy.softMemoryRecycleMb');\n assertPositiveOptional(policy.hardMemoryCapMb, 'policy.hardMemoryCapMb');\n if (policy.workingHoursPrewarm) {\n validateWorkingHoursSchedule(policy.workingHoursPrewarm);\n }\n};\n\ntype WorkingWindowBounds = {\n readonly prewarmStartMs: number;\n readonly windowStartMs: number;\n readonly windowEndMs: number;\n};\n\nconst workingWindowForDayDelta = (\n nowMs: number,\n schedule: WorkingHoursSchedule,\n dayDelta: number,\n): WorkingWindowBounds | null => {\n const offsetMs = schedule.timezoneOffsetMinutes * 60_000;\n const shifted = new Date(nowMs + offsetMs + dayDelta * DAY_MS);\n const dayOfWeek = shifted.getUTCDay();\n if (schedule.weekdaysOnly && (dayOfWeek === 0 || dayOfWeek === 6)) {\n return null;\n }\n const localMidnightUtcMs =\n Date.UTC(shifted.getUTCFullYear(), shifted.getUTCMonth(), shifted.getUTCDate()) - offsetMs;\n const windowStartMs = localMidnightUtcMs + schedule.startHour * HOUR_MS;\n const isOvernight = schedule.endHour <= schedule.startHour;\n const windowEndMs = localMidnightUtcMs + schedule.endHour * HOUR_MS + (isOvernight ? DAY_MS : 0);\n const prewarmStartMs = windowStartMs - schedule.prewarmLeadMs;\n return { prewarmStartMs, windowStartMs, windowEndMs };\n};\n\nconst activeWorkingWindowAt = (\n nowMs: number,\n schedule: WorkingHoursSchedule,\n): WorkingWindowBounds | null => {\n for (const dayDelta of [-1, 0, 1]) {\n const bounds = workingWindowForDayDelta(nowMs, schedule, dayDelta);\n if (!bounds) continue;\n if (nowMs >= bounds.prewarmStartMs && nowMs < bounds.windowEndMs) {\n return bounds;\n }\n }\n return null;\n};\n\nconst nextWorkingHoursPrewarmAtMs = (\n nowMs: number,\n schedule: WorkingHoursSchedule,\n): number | null => {\n let next: number | null = null;\n for (let dayDelta = 0; dayDelta <= 8; dayDelta += 1) {\n const bounds = workingWindowForDayDelta(nowMs, schedule, dayDelta);\n if (!bounds) continue;\n if (bounds.prewarmStartMs > nowMs) {\n next = next === null ? bounds.prewarmStartMs : Math.min(next, bounds.prewarmStartMs);\n }\n }\n return next;\n};\n\nconst earliestCheckTime = (...candidates: Array<number | null | undefined>): number | null => {\n let earliest: number | null = null;\n for (const candidate of candidates) {\n if (candidate === null || candidate === undefined) continue;\n earliest = earliest === null ? candidate : Math.min(earliest, candidate);\n }\n return earliest;\n};\n\nexport const evaluateWorkloadLifecycle = (\n snapshot: WorkloadLifecycleSnapshot,\n nowMs: number,\n policy: WorkloadLifecyclePolicy = defaultWorkloadLifecyclePolicy(snapshot.workloadClass, {\n warmRetentionMode: snapshot.warmRetentionMode,\n }),\n): WorkloadLifecycleDecision => {\n validateSnapshotAndPolicy(snapshot, nowMs, policy);\n\n const descriptor = infraProviderDescriptor(snapshot.provider);\n const hasActiveWork = snapshot.inFlightTurns > 0 || snapshot.activeBackgroundShells > 0;\n const hasPendingApprovals = (snapshot.pendingApprovals ?? 0) > 0;\n const ageMs = Math.max(0, nowMs - snapshot.createdAtMs);\n const maxLifetimeReached = policy.maxLifetimeMs !== null && ageMs >= policy.maxLifetimeMs;\n const lifetimeDeadlineMs =\n policy.maxLifetimeMs !== null ? snapshot.createdAtMs + policy.maxLifetimeMs : null;\n\n if (snapshot.state === 'destroyed') {\n return { action: 'none', reason: 'workload_already_destroyed', nextCheckAtMs: null };\n }\n\n if (snapshot.state === 'failed' || snapshot.state === 'orphaned') {\n return {\n action: 'terminate',\n reason: `reap_${snapshot.state}_workload`,\n nextCheckAtMs: null,\n };\n }\n\n if (\n snapshot.state === 'provisioning' ||\n snapshot.state === 'booting' ||\n snapshot.state === 'suspending' ||\n snapshot.state === 'terminating'\n ) {\n return {\n action: 'none',\n reason: `workload_${snapshot.state}`,\n nextCheckAtMs: nowMs + TRANSITIONAL_POLL_MS,\n };\n }\n\n if (snapshot.state === 'suspended') {\n const suspendedElapsedMs = Math.max(0, nowMs - snapshot.stateEnteredAtMs);\n if (policy.maxSuspendedMs !== null && suspendedElapsedMs >= policy.maxSuspendedMs) {\n return {\n action: 'terminate',\n reason: 'suspended_retention_expired',\n nextCheckAtMs: null,\n };\n }\n\n if (policy.workingHoursPrewarm) {\n if (activeWorkingWindowAt(nowMs, policy.workingHoursPrewarm)) {\n return {\n action: 'prewarm',\n reason: 'working_hours_prewarm_window',\n nextCheckAtMs: null,\n };\n }\n }\n\n const expiryAtMs =\n policy.maxSuspendedMs !== null ? snapshot.stateEnteredAtMs + policy.maxSuspendedMs : null;\n const nextPrewarmAtMs = policy.workingHoursPrewarm\n ? nextWorkingHoursPrewarmAtMs(nowMs, policy.workingHoursPrewarm)\n : null;\n return {\n action: 'none',\n reason: 'suspended_within_retention',\n nextCheckAtMs: earliestCheckTime(expiryAtMs, nextPrewarmAtMs, nowMs + SUSPENDED_POLL_MS),\n };\n }\n\n if (snapshot.state === 'draining') {\n const drainElapsedMs = Math.max(0, nowMs - snapshot.stateEnteredAtMs);\n const drainDeadlineMs = snapshot.stateEnteredAtMs + policy.drainGraceMs;\n const idleElapsedMs = Math.max(0, nowMs - snapshot.lastActivityAtMs);\n\n if (hasActiveWork) {\n if (!maxLifetimeReached) {\n return {\n action: 'none',\n reason: 'active_work_blocks_idle_drain',\n nextCheckAtMs: earliestCheckTime(lifetimeDeadlineMs, nowMs + ACTIVE_WORK_POLL_MS),\n };\n }\n if (drainElapsedMs < policy.drainGraceMs) {\n return {\n action: 'none',\n reason: 'waiting_for_in_flight_work_to_drain',\n nextCheckAtMs: drainDeadlineMs,\n };\n }\n return {\n action: 'terminate',\n reason: 'max_lifetime_exceeded_with_active_work',\n nextCheckAtMs: null,\n };\n }\n\n if (\n hasPendingApprovals &&\n !maxLifetimeReached &&\n policy.pendingApprovalGraceMs > 0 &&\n idleElapsedMs < policy.pendingApprovalGraceMs\n ) {\n return {\n action: 'none',\n reason: 'waiting_for_pending_approval',\n nextCheckAtMs: earliestCheckTime(\n lifetimeDeadlineMs,\n snapshot.lastActivityAtMs + policy.pendingApprovalGraceMs,\n ),\n };\n }\n\n if (policy.requireArchiveFlushBeforeWindDown && !snapshot.archiveFlushed) {\n if (!maxLifetimeReached || drainElapsedMs < policy.drainGraceMs) {\n return {\n action: 'none',\n reason: 'waiting_for_archive_flush',\n nextCheckAtMs: nowMs + ARCHIVE_FLUSH_POLL_MS,\n };\n }\n return {\n action: 'terminate',\n reason: 'max_lifetime_exceeded_without_archive_flush',\n nextCheckAtMs: null,\n };\n }\n\n if (maxLifetimeReached) {\n return {\n action: 'terminate',\n reason: 'max_lifetime_reached_after_drain',\n nextCheckAtMs: null,\n };\n }\n\n if (policy.idleAction === 'terminate') {\n return {\n action: 'terminate',\n reason: 'drain_complete_ready_to_terminate',\n nextCheckAtMs: null,\n };\n }\n\n const suspendMemoryMb = snapshot.provisionedMemoryMb ?? snapshot.rssMemoryMb;\n if (\n descriptor.supportsSuspend &&\n descriptor.suspendMaxMemoryMb !== undefined &&\n suspendMemoryMb !== undefined &&\n suspendMemoryMb > descriptor.suspendMaxMemoryMb\n ) {\n return policy.hardMemoryCapMb !== null\n ? {\n action: 'recycle',\n reason: 'memory_exceeds_provider_suspend_cap',\n nextCheckAtMs: null,\n }\n : {\n action: 'terminate',\n reason: 'cannot_suspend_above_provider_memory_cap',\n nextCheckAtMs: null,\n };\n }\n\n return {\n action: 'suspend',\n reason: descriptor.supportsSuspend\n ? 'drain_complete_ready_to_suspend'\n : 'drain_complete_ready_to_stop',\n nextCheckAtMs: null,\n };\n }\n\n // States: 'warm' | 'active'\n if (maxLifetimeReached) {\n if (hasActiveWork || (policy.requireArchiveFlushBeforeWindDown && !snapshot.archiveFlushed)) {\n return {\n action: 'drain',\n reason: 'max_lifetime_reached_draining',\n nextCheckAtMs: nowMs + policy.drainGraceMs,\n };\n }\n return {\n action: 'terminate',\n reason: 'max_lifetime_reached',\n nextCheckAtMs: null,\n };\n }\n\n if (\n policy.hardMemoryCapMb !== null &&\n snapshot.rssMemoryMb !== undefined &&\n snapshot.rssMemoryMb >\n (descriptor.suspendMaxMemoryMb !== undefined\n ? Math.min(policy.hardMemoryCapMb, descriptor.suspendMaxMemoryMb)\n : policy.hardMemoryCapMb)\n ) {\n return {\n action: 'recycle',\n reason: 'rss_exceeds_hard_cap',\n nextCheckAtMs: null,\n };\n }\n\n if (\n policy.softMemoryRecycleMb !== null &&\n snapshot.rssMemoryMb !== undefined &&\n snapshot.rssMemoryMb >= policy.softMemoryRecycleMb &&\n !hasActiveWork\n ) {\n return {\n action: 'recycle',\n reason: 'rss_exceeds_soft_recycle_threshold',\n nextCheckAtMs: null,\n };\n }\n\n if (snapshot.pinnedWarm || policy.idleAction === 'keep_warm') {\n return {\n action: 'none',\n reason: 'workload_pinned_warm',\n nextCheckAtMs: lifetimeDeadlineMs,\n };\n }\n\n if (policy.workingHoursPrewarm) {\n const activeWindow = activeWorkingWindowAt(nowMs, policy.workingHoursPrewarm);\n if (activeWindow) {\n return {\n action: 'none',\n reason: 'within_working_hours_window',\n nextCheckAtMs: earliestCheckTime(lifetimeDeadlineMs, activeWindow.windowEndMs),\n };\n }\n }\n\n if (hasActiveWork) {\n return {\n action: 'none',\n reason: 'active_work_in_progress',\n nextCheckAtMs: earliestCheckTime(lifetimeDeadlineMs, nowMs + ACTIVE_WORK_POLL_MS),\n };\n }\n\n const idleLimitMs = descriptor.supportsSuspend ? policy.idleSuspendMs : policy.idleStopMs;\n if (idleLimitMs === null) {\n return {\n action: 'none',\n reason: 'no_idle_timeout_configured',\n nextCheckAtMs: lifetimeDeadlineMs,\n };\n }\n\n const idleElapsedMs = Math.max(0, nowMs - snapshot.lastActivityAtMs);\n if (hasPendingApprovals && policy.pendingApprovalGraceMs > 0) {\n const approvalLimitMs = Math.max(idleLimitMs, policy.pendingApprovalGraceMs);\n if (idleElapsedMs < approvalLimitMs) {\n return {\n action: 'none',\n reason: 'waiting_for_pending_approval',\n nextCheckAtMs: earliestCheckTime(\n lifetimeDeadlineMs,\n snapshot.lastActivityAtMs + approvalLimitMs,\n ),\n };\n }\n }\n\n if (idleElapsedMs >= idleLimitMs) {\n return {\n action: 'drain',\n reason: 'idle_timeout_reached',\n nextCheckAtMs: nowMs + policy.drainGraceMs,\n };\n }\n\n return {\n action: 'none',\n reason: 'within_idle_window',\n nextCheckAtMs: earliestCheckTime(lifetimeDeadlineMs, snapshot.lastActivityAtMs + idleLimitMs),\n };\n};\n","import type { InfraProviderId } from '../core/providers.ts';\n\nexport const WORKLOAD_LIFECYCLE_STATES = [\n 'provisioning',\n 'booting',\n 'warm',\n 'active',\n 'draining',\n 'suspending',\n 'suspended',\n 'terminating',\n 'destroyed',\n 'failed',\n 'orphaned',\n] as const;\n\nexport type WorkloadLifecycleState = (typeof WORKLOAD_LIFECYCLE_STATES)[number];\n\nexport const WORKLOAD_CLASSES = [\n 'warm-interactive',\n 'warm-pool',\n 'batch-worker',\n 'ephemeral-session',\n 'always-on',\n] as const;\n\nexport type WorkloadClass = (typeof WORKLOAD_CLASSES)[number];\n\nexport type WarmRetentionMode = 'short' | 'extended';\n\nexport type WorkingHoursSchedule = {\n readonly timezoneOffsetMinutes: number;\n readonly startHour: number;\n readonly endHour: number;\n readonly weekdaysOnly: boolean;\n readonly prewarmLeadMs: number;\n};\n\nexport type WorkloadIdleAction = 'suspend' | 'terminate' | 'keep_warm';\n\nexport type WorkloadLifecyclePolicy = {\n readonly workloadClass: WorkloadClass;\n readonly idleSuspendMs: number | null;\n readonly idleStopMs: number | null;\n readonly drainGraceMs: number;\n readonly pendingApprovalGraceMs: number;\n readonly maxLifetimeMs: number | null;\n readonly maxSuspendedMs: number | null;\n readonly softMemoryRecycleMb: number | null;\n readonly hardMemoryCapMb: number | null;\n readonly requireArchiveFlushBeforeWindDown: boolean;\n readonly workingHoursPrewarm?: WorkingHoursSchedule;\n readonly idleAction: WorkloadIdleAction;\n};\n\nexport type WorkloadLifecycleSnapshot = {\n readonly workloadId: string;\n readonly workloadClass: WorkloadClass;\n readonly provider: InfraProviderId;\n readonly state: WorkloadLifecycleState;\n readonly createdAtMs: number;\n readonly lastActivityAtMs: number;\n readonly stateEnteredAtMs: number;\n readonly inFlightTurns: number;\n readonly activeBackgroundShells: number;\n readonly pendingApprovals?: number;\n readonly archiveFlushed: boolean;\n readonly provisionedMemoryMb?: number;\n readonly rssMemoryMb?: number;\n readonly pinnedWarm?: boolean;\n readonly warmRetentionMode?: WarmRetentionMode;\n};\n\nexport type WorkloadLifecycleAction =\n | 'none'\n | 'prewarm'\n | 'drain'\n | 'suspend'\n | 'terminate'\n | 'recycle';\n\nexport type WorkloadLifecycleDecision = {\n readonly action: WorkloadLifecycleAction;\n readonly reason: string;\n readonly nextCheckAtMs: number | null;\n};\n","import { InfraError } from '../core/infraError.ts';\n\nconst DEFAULT_CONCURRENCY_RETRY_FLOOR_MS = 1_000;\n\nexport type StaggeredWakeRequest = {\n readonly workloadId: string;\n readonly priority?: number;\n readonly requestedAtMs: number;\n};\n\nexport type StaggeredWakeOptions = {\n readonly maxConcurrentWakes: number;\n readonly minSpacingMs: number;\n readonly inFlightWakeCount?: number;\n readonly lastWakeLaunchedAtMs?: number | null;\n};\n\nexport type DeferredWakeReason = 'concurrency_limit' | 'spacing_interval';\n\nexport type DeferredWake = {\n readonly request: StaggeredWakeRequest;\n readonly earliestLaunchAtMs: number;\n readonly reason: DeferredWakeReason;\n};\n\nexport type StaggeredWakePlan = {\n readonly launchNow: readonly StaggeredWakeRequest[];\n readonly defer: readonly DeferredWake[];\n};\n\nconst compareWakeRequests = (left: StaggeredWakeRequest, right: StaggeredWakeRequest): number => {\n const priorityDiff = (right.priority ?? 0) - (left.priority ?? 0);\n if (priorityDiff !== 0) return priorityDiff;\n const requestedDiff = left.requestedAtMs - right.requestedAtMs;\n if (requestedDiff !== 0) return requestedDiff;\n return left.workloadId < right.workloadId ? -1 : left.workloadId > right.workloadId ? 1 : 0;\n};\n\nconst deduplicateRequests = (requests: readonly StaggeredWakeRequest[]): StaggeredWakeRequest[] => {\n const byWorkloadId = new Map<string, StaggeredWakeRequest>();\n for (const request of requests) {\n if (!request.workloadId) {\n throw new InfraError('invalid_request', 'StaggeredWakeRequest.workloadId must be non-empty');\n }\n if (!Number.isFinite(request.requestedAtMs)) {\n throw new InfraError(\n 'invalid_request',\n `requestedAtMs must be finite (got ${request.requestedAtMs})`,\n );\n }\n if (request.priority !== undefined && !Number.isFinite(request.priority)) {\n throw new InfraError('invalid_request', `priority must be finite (got ${request.priority})`);\n }\n\n const existing = byWorkloadId.get(request.workloadId);\n if (!existing || compareWakeRequests(request, existing) < 0) {\n byWorkloadId.set(request.workloadId, request);\n }\n }\n return [...byWorkloadId.values()];\n};\n\nexport const planStaggeredWakes = (\n requests: readonly StaggeredWakeRequest[],\n nowMs: number,\n options: StaggeredWakeOptions,\n): StaggeredWakePlan => {\n if (!Number.isFinite(nowMs)) {\n throw new InfraError('invalid_request', `nowMs must be finite (got ${nowMs})`);\n }\n if (!Number.isInteger(options.maxConcurrentWakes) || options.maxConcurrentWakes < 1) {\n throw new InfraError(\n 'invalid_request',\n `maxConcurrentWakes must be an integer >= 1 (got ${options.maxConcurrentWakes})`,\n );\n }\n if (!Number.isFinite(options.minSpacingMs) || options.minSpacingMs < 0) {\n throw new InfraError(\n 'invalid_request',\n `minSpacingMs must be a finite number >= 0 (got ${options.minSpacingMs})`,\n );\n }\n if (\n options.inFlightWakeCount !== undefined &&\n (!Number.isInteger(options.inFlightWakeCount) || options.inFlightWakeCount < 0)\n ) {\n throw new InfraError(\n 'invalid_request',\n `inFlightWakeCount must be an integer >= 0 (got ${options.inFlightWakeCount})`,\n );\n }\n if (\n options.lastWakeLaunchedAtMs !== undefined &&\n options.lastWakeLaunchedAtMs !== null &&\n !Number.isFinite(options.lastWakeLaunchedAtMs)\n ) {\n throw new InfraError(\n 'invalid_request',\n `lastWakeLaunchedAtMs must be finite or null (got ${options.lastWakeLaunchedAtMs})`,\n );\n }\n\n const sorted = deduplicateRequests(requests).sort(compareWakeRequests);\n const inFlight = options.inFlightWakeCount ?? 0;\n const availableSlots = Math.max(0, options.maxConcurrentWakes - inFlight);\n const launchNow: StaggeredWakeRequest[] = [];\n const defer: DeferredWake[] = [];\n\n const retryStepMs =\n options.minSpacingMs > 0 ? options.minSpacingMs : DEFAULT_CONCURRENCY_RETRY_FLOOR_MS;\n\n let nextEligibleAtMs =\n options.lastWakeLaunchedAtMs !== null && options.lastWakeLaunchedAtMs !== undefined\n ? Math.max(nowMs, options.lastWakeLaunchedAtMs + options.minSpacingMs)\n : nowMs;\n let scheduledWithinConcurrency = 0;\n\n for (const request of sorted) {\n if (scheduledWithinConcurrency >= availableSlots) {\n const earliestLaunchAtMs = Math.max(nextEligibleAtMs, nowMs + retryStepMs);\n defer.push({\n request,\n earliestLaunchAtMs,\n reason: 'concurrency_limit',\n });\n nextEligibleAtMs = earliestLaunchAtMs + retryStepMs;\n continue;\n }\n\n if (nextEligibleAtMs > nowMs) {\n defer.push({\n request,\n earliestLaunchAtMs: nextEligibleAtMs,\n reason: 'spacing_interval',\n });\n scheduledWithinConcurrency += 1;\n nextEligibleAtMs += options.minSpacingMs;\n continue;\n }\n\n launchNow.push(request);\n scheduledWithinConcurrency += 1;\n if (options.minSpacingMs > 0) {\n nextEligibleAtMs = nowMs + options.minSpacingMs;\n }\n }\n\n return { launchNow, defer };\n};\n"]}
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
package/dist/lifecycle/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var G=new Set(["unreachable","rate_limited","provider_unavailable"]),a=class extends Error{code;status;provider;retryable;constructor(n,r,o){let t=o?.provider?`[${o.provider}] `:"";super(r?`${t}${r}`:`${t}Infrastructure request failed (${n})`,{cause:o?.cause}),this.name="InfraError",this.code=n,this.status=o?.status,this.provider=o?.provider,this.retryable=o?.retryable??G.has(n);}};var S=[{id:"starter",maxMemoryMb:512,monthlyUsd:7},{id:"standard",maxMemoryMb:2048,monthlyUsd:25},{id:"pro",maxMemoryMb:4096,monthlyUsd:85},{id:"pro_plus",maxMemoryMb:8192,monthlyUsd:175},{id:"pro_max",maxMemoryMb:16384,monthlyUsd:225},{id:"pro_ultra",maxMemoryMb:32768,monthlyUsd:450}],I=e=>{for(let n of S)if(e<=n.maxMemoryMb)return n;return S[S.length-1]},F=new Set(["build_failed","update_failed","pre_deploy_failed","canceled"]);new Set([...F,"deactivated"]);var b=730,N=.65,O=.1,d={railway:{memoryUsdPerGbHour:.0139,vcpuUsdPerHour:.0278,storageUsdPerGbMonth:.15},fly:{sharedVcpuUsdPerMonth:.7,performanceVcpuUsdPerMonth:21,memoryUsdPerGbMonth:6,suspendedRootfsUsdPerGbMonth:.15},render:{diskUsdPerGbMonth:.25},firecracker:{amortizedMemoryUsdPerGbMonth:3.5,amortizedVcpuUsdPerMonth:4,snapshotStorageUsdPerGbMonth:.05},aws:{fargateArmVcpuUsdPerHour:.0324,fargateArmMemoryUsdPerGbHour:.0036,storageUsdPerGbMonth:.08},gcp:{vcpuUsdPerHour:.0432,memoryUsdPerGbHour:.0048,storageUsdPerGbMonth:.1},azure:{vcpuUsdPerHour:.0432,memoryUsdPerGbHour:.0048,storageUsdPerGbMonth:.1}},h=e=>Math.round(e*1e4)/1e4,v=(e,n)=>{if(!Number.isFinite(e)||e<0)throw new a("invalid_request",`${n} must be a finite number >= 0 (got ${e})`)},U=(e,n)=>{if(!Number.isFinite(e)||e<0||e>1)throw new a("invalid_request",`${n} must be a finite number in [0, 1] (got ${e})`)},T=e=>{if(v(e.memoryMb,"memoryMb"),v(e.vcpus,"vcpus"),v(e.activeHoursPerMonth,"activeHoursPerMonth"),v(e.suspendedHoursPerMonth,"suspendedHoursPerMonth"),v(e.rootfsGb,"rootfsGb"),e.activeHoursPerMonth+e.suspendedHoursPerMonth>b)throw new a("invalid_request",`activeHoursPerMonth + suspendedHoursPerMonth must be <= ${b} (got ${e.activeHoursPerMonth+e.suspendedHoursPerMonth})`);let n=e.markupMultiplier??1;if(!Number.isFinite(n)||n<1)throw new a("invalid_request",`markupMultiplier must be a finite number >= 1 (got ${n})`);e.averageMemoryUtilization!==void 0&&U(e.averageMemoryUtilization,"averageMemoryUtilization"),e.averageCpuUtilization!==void 0&&U(e.averageCpuUtilization,"averageCpuUtilization");let r=e.memoryMb/1024,o=e.activeHoursPerMonth/b,t=(e.activeHoursPerMonth+e.suspendedHoursPerMonth)/b,m=e.suspendedHoursPerMonth/b,u=0,i=0,s="";switch(e.provider){case "railway":{let M=e.averageMemoryUtilization??N,W=e.averageCpuUtilization??O;u=r*M*e.activeHoursPerMonth*d.railway.memoryUsdPerGbHour+e.vcpus*W*e.activeHoursPerMonth*d.railway.vcpuUsdPerHour,i=e.rootfsGb*t*d.railway.storageUsdPerGbMonth,s="usage-metered active RAM/vCPU per second + persistent volume storage";break}case "fly":{let M=e.cpuKind==="performance"?d.fly.performanceVcpuUsdPerMonth:d.fly.sharedVcpuUsdPerMonth;u=(e.vcpus*M+r*d.fly.memoryUsdPerGbMonth)*o,i=e.rootfsGb*m*d.fly.suspendedRootfsUsdPerGbMonth,s="provisioned Firecracker microVM per second while active + rootfs-only storage while suspended";break}case "render":{let M=I(e.memoryMb);u=M.monthlyUsd*o,i=e.rootfsGb*t*d.render.diskUsdPerGbMonth,s=`prorated fixed Render ${M.id} tier while unsuspended + persistent disk`;break}case "firecracker":{u=(r*d.firecracker.amortizedMemoryUsdPerGbMonth+e.vcpus*d.firecracker.amortizedVcpuUsdPerMonth)*o,i=(e.rootfsGb+r)*m*d.firecracker.snapshotStorageUsdPerGbMonth,s="amortized dedicated bare-metal host capacity while active + NVMe snapshot storage while suspended";break}case "aws":{u=e.vcpus*e.activeHoursPerMonth*d.aws.fargateArmVcpuUsdPerHour+r*e.activeHoursPerMonth*d.aws.fargateArmMemoryUsdPerGbHour,i=e.rootfsGb*t*d.aws.storageUsdPerGbMonth,s="AWS Fargate ARM provisioned vCPU/GB-hour + EBS/snapshot storage";break}case "gcp":{u=e.vcpus*e.activeHoursPerMonth*d.gcp.vcpuUsdPerHour+r*e.activeHoursPerMonth*d.gcp.memoryUsdPerGbHour,i=e.rootfsGb*t*d.gcp.storageUsdPerGbMonth,s="GCP provisioned vCPU/GB-hour + persistent storage";break}case "azure":{u=e.vcpus*e.activeHoursPerMonth*d.azure.vcpuUsdPerHour+r*e.activeHoursPerMonth*d.azure.memoryUsdPerGbHour,i=e.rootfsGb*t*d.azure.storageUsdPerGbMonth,s="Azure Container Apps provisioned vCPU/GB-hour + storage";break}}let c=h(u),p=h(i),l=h(c+p),f=h(l*n),_=h(f-l);return {provider:e.provider,activeComputeUsd:c,suspendedStorageUsd:p,rawMonthlyCostUsd:l,markupMultiplier:n,markedUpMonthlyCostUsd:f,marginUsd:_,pricingBasis:s}};var q={railway:{id:"railway",name:"Railway",implemented:true,supportsArchiveHosting:true,supportsWorkloadDriver:true,isolation:"container",supportsSuspend:false,supportsByoAccount:true,supportsManagedAccount:true,billingUnit:"active_utilization_second",notes:"Usage-metered memory and CPU per second; stopped services bill nothing; no memory-snapshot suspend."},render:{id:"render",name:"Render",implemented:true,supportsArchiveHosting:true,supportsWorkloadDriver:true,isolation:"container",supportsSuspend:false,supportsByoAccount:true,supportsManagedAccount:true,billingUnit:"flat_plan_month",notes:"Managed web services and Postgres on fixed tiers; service suspend stops execution without a memory snapshot."},fly:{id:"fly",name:"Fly.io Machines",implemented:true,supportsArchiveHosting:false,supportsWorkloadDriver:true,isolation:"microvm",supportsSuspend:true,suspendMaxMemoryMb:2048,supportsByoAccount:true,supportsManagedAccount:true,billingUnit:"provisioned_second_with_suspend_storage",notes:"Firecracker microVMs with GA memory-snapshot suspend up to 2048 MB RAM and rootfs-only suspended storage billing."},firecracker:{id:"firecracker",name:"Firecracker",implemented:true,supportsArchiveHosting:false,supportsWorkloadDriver:true,isolation:"microvm",supportsSuspend:true,supportsByoAccount:true,supportsManagedAccount:true,billingUnit:"host_machine_month",notes:"Direct Firecracker VMM HTTP/Unix control plane for dedicated or bare-metal microVM hosts with full memory snapshots."},aws:{id:"aws",name:"AWS (Fargate / Lambda MicroVMs)",implemented:false,supportsArchiveHosting:false,supportsWorkloadDriver:false,isolation:"microvm",supportsSuspend:true,supportsByoAccount:true,supportsManagedAccount:true,billingUnit:"provisioned_vcpu_memory_second",notes:"Planned cloud adapter for AWS Fargate tasks and Firecracker-backed Lambda MicroVMs (8h session cap)."},gcp:{id:"gcp",name:"Google Cloud (Cloud Run / GKE Autopilot)",implemented:false,supportsArchiveHosting:false,supportsWorkloadDriver:false,isolation:"microvm",supportsSuspend:false,supportsByoAccount:true,supportsManagedAccount:true,billingUnit:"provisioned_vcpu_memory_second",notes:"Planned cloud adapter for Google Cloud Run and GKE Autopilot workloads."},azure:{id:"azure",name:"Azure (Container Apps / ACI)",implemented:false,supportsArchiveHosting:false,supportsWorkloadDriver:false,isolation:"container",supportsSuspend:false,supportsByoAccount:true,supportsManagedAccount:true,billingUnit:"provisioned_vcpu_memory_second",notes:"Planned cloud adapter for Azure Container Apps and Container Instances."}};var H=e=>q[e];var w=(e,n={})=>{switch(e){case "warm-interactive":return {workloadClass:e,idleSuspendMs:48e4,idleStopMs:108e5,drainGraceMs:6e4,pendingApprovalGraceMs:0,maxLifetimeMs:864e5,maxSuspendedMs:12096e5,softMemoryRecycleMb:1536,hardMemoryCapMb:2048,requireArchiveFlushBeforeWindDown:false,workingHoursPrewarm:n.workingHoursPrewarm,idleAction:"suspend"};case "warm-pool":return {workloadClass:e,idleSuspendMs:n.warmRetentionMode==="extended"?36e5:3e5,idleStopMs:108e5,drainGraceMs:6e4,pendingApprovalGraceMs:0,maxLifetimeMs:864e5,maxSuspendedMs:6048e5,softMemoryRecycleMb:1536,hardMemoryCapMb:2048,requireArchiveFlushBeforeWindDown:false,workingHoursPrewarm:n.workingHoursPrewarm,idleAction:"suspend"};case "batch-worker":return {workloadClass:e,idleSuspendMs:3e5,idleStopMs:3e5,drainGraceMs:12e4,pendingApprovalGraceMs:0,maxLifetimeMs:144e5,maxSuspendedMs:864e5,softMemoryRecycleMb:1536,hardMemoryCapMb:2048,requireArchiveFlushBeforeWindDown:false,idleAction:"terminate"};case "ephemeral-session":return {workloadClass:e,idleSuspendMs:9e5,idleStopMs:9e5,drainGraceMs:6e4,pendingApprovalGraceMs:18e5,maxLifetimeMs:864e5,maxSuspendedMs:6048e5,softMemoryRecycleMb:null,hardMemoryCapMb:null,requireArchiveFlushBeforeWindDown:true,idleAction:"suspend"};case "always-on":return {workloadClass:e,idleSuspendMs:null,idleStopMs:null,drainGraceMs:6e4,pendingApprovalGraceMs:0,maxLifetimeMs:null,maxSuspendedMs:null,softMemoryRecycleMb:null,hardMemoryCapMb:null,requireArchiveFlushBeforeWindDown:false,idleAction:"keep_warm"}}};var $=15e3,R=3e4,B=1e4,z=3e5,x=36e5,C=24*x,k=(e,n)=>{if(!Number.isFinite(e))throw new a("invalid_request",`${n} must be a finite number (got ${e})`)},A=(e,n)=>{if(!Number.isFinite(e)||e<0)throw new a("invalid_request",`${n} must be a finite number >= 0 (got ${e})`)},P=(e,n)=>{if(!Number.isInteger(e)||e<0)throw new a("invalid_request",`${n} must be an integer >= 0 (got ${e})`)},g=(e,n)=>{if(e!=null&&(!Number.isFinite(e)||e<=0))throw new a("invalid_request",`${n} must be a finite number > 0 (got ${e})`)},V=e=>{if(k(e.timezoneOffsetMinutes,"workingHoursPrewarm.timezoneOffsetMinutes"),!Number.isFinite(e.startHour)||e.startHour<0||e.startHour>=24)throw new a("invalid_request",`workingHoursPrewarm.startHour must be in [0, 24) (got ${e.startHour})`);if(!Number.isFinite(e.endHour)||e.endHour<0||e.endHour>24)throw new a("invalid_request",`workingHoursPrewarm.endHour must be in [0, 24] (got ${e.endHour})`);A(e.prewarmLeadMs,"workingHoursPrewarm.prewarmLeadMs");},Y=(e,n,r)=>{k(n,"nowMs"),k(e.createdAtMs,"snapshot.createdAtMs"),k(e.lastActivityAtMs,"snapshot.lastActivityAtMs"),k(e.stateEnteredAtMs,"snapshot.stateEnteredAtMs"),P(e.inFlightTurns,"snapshot.inFlightTurns"),P(e.activeBackgroundShells,"snapshot.activeBackgroundShells"),e.pendingApprovals!==void 0&&P(e.pendingApprovals,"snapshot.pendingApprovals"),g(e.provisionedMemoryMb,"snapshot.provisionedMemoryMb"),g(e.rssMemoryMb,"snapshot.rssMemoryMb"),r.idleSuspendMs!==null&&A(r.idleSuspendMs,"policy.idleSuspendMs"),r.idleStopMs!==null&&A(r.idleStopMs,"policy.idleStopMs"),A(r.drainGraceMs,"policy.drainGraceMs"),A(r.pendingApprovalGraceMs,"policy.pendingApprovalGraceMs"),r.maxLifetimeMs!==null&&g(r.maxLifetimeMs,"policy.maxLifetimeMs"),r.maxSuspendedMs!==null&&g(r.maxSuspendedMs,"policy.maxSuspendedMs"),g(r.softMemoryRecycleMb,"policy.softMemoryRecycleMb"),g(r.hardMemoryCapMb,"policy.hardMemoryCapMb"),r.workingHoursPrewarm&&V(r.workingHoursPrewarm);},L=(e,n,r)=>{let o=n.timezoneOffsetMinutes*6e4,t=new Date(e+o+r*C),m=t.getUTCDay();if(n.weekdaysOnly&&(m===0||m===6))return null;let u=Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-o,i=u+n.startHour*x,s=n.endHour<=n.startHour,c=u+n.endHour*x+(s?C:0);return {prewarmStartMs:i-n.prewarmLeadMs,windowStartMs:i,windowEndMs:c}},E=(e,n)=>{for(let r of [-1,0,1]){let o=L(e,n,r);if(o&&e>=o.prewarmStartMs&&e<o.windowEndMs)return o}return null},K=(e,n)=>{let r=null;for(let o=0;o<=8;o+=1){let t=L(e,n,o);t&&t.prewarmStartMs>e&&(r=r===null?t.prewarmStartMs:Math.min(r,t.prewarmStartMs));}return r},y=(...e)=>{let n=null;for(let r of e)r!=null&&(n=n===null?r:Math.min(n,r));return n},j=(e,n,r=w(e.workloadClass,{warmRetentionMode:e.warmRetentionMode}))=>{Y(e,n,r);let o=H(e.provider),t=e.inFlightTurns>0||e.activeBackgroundShells>0,m=(e.pendingApprovals??0)>0,u=Math.max(0,n-e.createdAtMs),i=r.maxLifetimeMs!==null&&u>=r.maxLifetimeMs,s=r.maxLifetimeMs!==null?e.createdAtMs+r.maxLifetimeMs:null;if(e.state==="destroyed")return {action:"none",reason:"workload_already_destroyed",nextCheckAtMs:null};if(e.state==="failed"||e.state==="orphaned")return {action:"terminate",reason:`reap_${e.state}_workload`,nextCheckAtMs:null};if(e.state==="provisioning"||e.state==="booting"||e.state==="suspending"||e.state==="terminating")return {action:"none",reason:`workload_${e.state}`,nextCheckAtMs:n+$};if(e.state==="suspended"){let l=Math.max(0,n-e.stateEnteredAtMs);if(r.maxSuspendedMs!==null&&l>=r.maxSuspendedMs)return {action:"terminate",reason:"suspended_retention_expired",nextCheckAtMs:null};if(r.workingHoursPrewarm&&E(n,r.workingHoursPrewarm))return {action:"prewarm",reason:"working_hours_prewarm_window",nextCheckAtMs:null};let f=r.maxSuspendedMs!==null?e.stateEnteredAtMs+r.maxSuspendedMs:null,_=r.workingHoursPrewarm?K(n,r.workingHoursPrewarm):null;return {action:"none",reason:"suspended_within_retention",nextCheckAtMs:y(f,_,n+z)}}if(e.state==="draining"){let l=Math.max(0,n-e.stateEnteredAtMs),f=e.stateEnteredAtMs+r.drainGraceMs,_=Math.max(0,n-e.lastActivityAtMs);if(t)return i?l<r.drainGraceMs?{action:"none",reason:"waiting_for_in_flight_work_to_drain",nextCheckAtMs:f}:{action:"terminate",reason:"max_lifetime_exceeded_with_active_work",nextCheckAtMs:null}:{action:"none",reason:"active_work_blocks_idle_drain",nextCheckAtMs:y(s,n+R)};if(m&&!i&&r.pendingApprovalGraceMs>0&&_<r.pendingApprovalGraceMs)return {action:"none",reason:"waiting_for_pending_approval",nextCheckAtMs:y(s,e.lastActivityAtMs+r.pendingApprovalGraceMs)};if(r.requireArchiveFlushBeforeWindDown&&!e.archiveFlushed)return !i||l<r.drainGraceMs?{action:"none",reason:"waiting_for_archive_flush",nextCheckAtMs:n+B}:{action:"terminate",reason:"max_lifetime_exceeded_without_archive_flush",nextCheckAtMs:null};if(i)return {action:"terminate",reason:"max_lifetime_reached_after_drain",nextCheckAtMs:null};if(r.idleAction==="terminate")return {action:"terminate",reason:"drain_complete_ready_to_terminate",nextCheckAtMs:null};let M=e.provisionedMemoryMb??e.rssMemoryMb;return o.supportsSuspend&&o.suspendMaxMemoryMb!==void 0&&M!==void 0&&M>o.suspendMaxMemoryMb?r.hardMemoryCapMb!==null?{action:"recycle",reason:"memory_exceeds_provider_suspend_cap",nextCheckAtMs:null}:{action:"terminate",reason:"cannot_suspend_above_provider_memory_cap",nextCheckAtMs:null}:{action:"suspend",reason:o.supportsSuspend?"drain_complete_ready_to_suspend":"drain_complete_ready_to_stop",nextCheckAtMs:null}}if(i)return t||r.requireArchiveFlushBeforeWindDown&&!e.archiveFlushed?{action:"drain",reason:"max_lifetime_reached_draining",nextCheckAtMs:n+r.drainGraceMs}:{action:"terminate",reason:"max_lifetime_reached",nextCheckAtMs:null};if(r.hardMemoryCapMb!==null&&e.rssMemoryMb!==void 0&&e.rssMemoryMb>(o.suspendMaxMemoryMb!==void 0?Math.min(r.hardMemoryCapMb,o.suspendMaxMemoryMb):r.hardMemoryCapMb))return {action:"recycle",reason:"rss_exceeds_hard_cap",nextCheckAtMs:null};if(r.softMemoryRecycleMb!==null&&e.rssMemoryMb!==void 0&&e.rssMemoryMb>=r.softMemoryRecycleMb&&!t)return {action:"recycle",reason:"rss_exceeds_soft_recycle_threshold",nextCheckAtMs:null};if(e.pinnedWarm||r.idleAction==="keep_warm")return {action:"none",reason:"workload_pinned_warm",nextCheckAtMs:s};if(r.workingHoursPrewarm){let l=E(n,r.workingHoursPrewarm);if(l)return {action:"none",reason:"within_working_hours_window",nextCheckAtMs:y(s,l.windowEndMs)}}if(t)return {action:"none",reason:"active_work_in_progress",nextCheckAtMs:y(s,n+R)};let c=o.supportsSuspend?r.idleSuspendMs:r.idleStopMs;if(c===null)return {action:"none",reason:"no_idle_timeout_configured",nextCheckAtMs:s};let p=Math.max(0,n-e.lastActivityAtMs);if(m&&r.pendingApprovalGraceMs>0){let l=Math.max(c,r.pendingApprovalGraceMs);if(p<l)return {action:"none",reason:"waiting_for_pending_approval",nextCheckAtMs:y(s,e.lastActivityAtMs+l)}}return p>=c?{action:"drain",reason:"idle_timeout_reached",nextCheckAtMs:n+r.drainGraceMs}:{action:"none",reason:"within_idle_window",nextCheckAtMs:y(s,e.lastActivityAtMs+c)}};var Z=["provisioning","booting","warm","active","draining","suspending","suspended","terminating","destroyed","failed","orphaned"],J=["warm-interactive","warm-pool","batch-worker","ephemeral-session","always-on"];var Q=1e3,D=(e,n)=>{let r=(n.priority??0)-(e.priority??0);if(r!==0)return r;let o=e.requestedAtMs-n.requestedAtMs;return o!==0?o:e.workloadId<n.workloadId?-1:e.workloadId>n.workloadId?1:0},X=e=>{let n=new Map;for(let r of e){if(!r.workloadId)throw new a("invalid_request","StaggeredWakeRequest.workloadId must be non-empty");if(!Number.isFinite(r.requestedAtMs))throw new a("invalid_request",`requestedAtMs must be finite (got ${r.requestedAtMs})`);if(r.priority!==void 0&&!Number.isFinite(r.priority))throw new a("invalid_request",`priority must be finite (got ${r.priority})`);let o=n.get(r.workloadId);(!o||D(r,o)<0)&&n.set(r.workloadId,r);}return [...n.values()]},ee=(e,n,r)=>{if(!Number.isFinite(n))throw new a("invalid_request",`nowMs must be finite (got ${n})`);if(!Number.isInteger(r.maxConcurrentWakes)||r.maxConcurrentWakes<1)throw new a("invalid_request",`maxConcurrentWakes must be an integer >= 1 (got ${r.maxConcurrentWakes})`);if(!Number.isFinite(r.minSpacingMs)||r.minSpacingMs<0)throw new a("invalid_request",`minSpacingMs must be a finite number >= 0 (got ${r.minSpacingMs})`);if(r.inFlightWakeCount!==void 0&&(!Number.isInteger(r.inFlightWakeCount)||r.inFlightWakeCount<0))throw new a("invalid_request",`inFlightWakeCount must be an integer >= 0 (got ${r.inFlightWakeCount})`);if(r.lastWakeLaunchedAtMs!==void 0&&r.lastWakeLaunchedAtMs!==null&&!Number.isFinite(r.lastWakeLaunchedAtMs))throw new a("invalid_request",`lastWakeLaunchedAtMs must be finite or null (got ${r.lastWakeLaunchedAtMs})`);let o=X(e).sort(D),t=r.inFlightWakeCount??0,m=Math.max(0,r.maxConcurrentWakes-t),u=[],i=[],s=r.minSpacingMs>0?r.minSpacingMs:Q,c=r.lastWakeLaunchedAtMs!==null&&r.lastWakeLaunchedAtMs!==void 0?Math.max(n,r.lastWakeLaunchedAtMs+r.minSpacingMs):n,p=0;for(let l of o){if(p>=m){let f=Math.max(c,n+s);i.push({request:l,earliestLaunchAtMs:f,reason:"concurrency_limit"}),c=f+s;continue}if(c>n){i.push({request:l,earliestLaunchAtMs:c,reason:"spacing_interval"}),p+=1,c+=r.minSpacingMs;continue}u.push(l),p+=1,r.minSpacingMs>0&&(c=n+r.minSpacingMs);}return {launchNow:u,defer:i}};export{d as HOSTING_PRICING_RATES,J as WORKLOAD_CLASSES,Z as WORKLOAD_LIFECYCLE_STATES,w as defaultWorkloadLifecyclePolicy,j as evaluateWorkloadLifecycle,ee as planStaggeredWakes,T as projectHostingMonthlyCost};//# sourceMappingURL=index.js.map
|
|
1
|
+
export{i as HOSTING_PRICING_RATES,n as WORKLOAD_CLASSES,m as WORKLOAD_LIFECYCLE_STATES,k as defaultWorkloadLifecyclePolicy,l as evaluateWorkloadLifecycle,o as planStaggeredWakes,j as projectHostingMonthlyCost}from'../chunk-W5SAM2DK.js';import'../chunk-55HNIEAS.js';import'../chunk-S47XOR4G.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/infraError.ts","../../src/render/renderPlans.ts","../../src/lifecycle/costProjection.ts","../../src/core/providers.ts","../../src/lifecycle/lifecyclePolicy.ts","../../src/lifecycle/evaluateWorkloadLifecycle.ts","../../src/lifecycle/lifecycleTypes.ts","../../src/lifecycle/staggeredWakes.ts"],"names":["RETRYABLE_INFRA_ERROR_CODES","InfraError","code","message","details","prefix","RENDER_PLAN_TIERS","renderPlanForMemoryMb","memoryMb","tier","RENDER_FAILED_DEPLOY_STATUSES","HOURS_PER_MONTH","DEFAULT_RAILWAY_MEMORY_UTILIZATION","DEFAULT_RAILWAY_CPU_UTILIZATION","HOSTING_PRICING_RATES","roundUsd","amount","requireNonNegative","value","name","requireUnitInterval","projectHostingMonthlyCost","input","markupMultiplier","memoryGb","activeMonthFraction","totalStoredMonthFraction","suspendedMonthFraction","activeComputeUsd","suspendedStorageUsd","pricingBasis","memUtil","cpuUtil","vcpuMonthRate","plan","roundedActive","roundedStorage","roundedRaw","roundedMarkedUp","roundedMargin","INFRA_PROVIDERS","infraProviderDescriptor","provider","defaultWorkloadLifecyclePolicy","workloadClass","options","TRANSITIONAL_POLL_MS","ACTIVE_WORK_POLL_MS","ARCHIVE_FLUSH_POLL_MS","SUSPENDED_POLL_MS","HOUR_MS","DAY_MS","assertFiniteNumber","assertNonNegativeFinite","assertNonNegativeInteger","assertPositiveOptional","validateWorkingHoursSchedule","schedule","validateSnapshotAndPolicy","snapshot","nowMs","policy","workingWindowForDayDelta","dayDelta","offsetMs","shifted","dayOfWeek","localMidnightUtcMs","windowStartMs","isOvernight","windowEndMs","activeWorkingWindowAt","bounds","nextWorkingHoursPrewarmAtMs","next","earliestCheckTime","candidates","earliest","candidate","evaluateWorkloadLifecycle","descriptor","hasActiveWork","hasPendingApprovals","ageMs","maxLifetimeReached","lifetimeDeadlineMs","suspendedElapsedMs","expiryAtMs","nextPrewarmAtMs","drainElapsedMs","drainDeadlineMs","idleElapsedMs","suspendMemoryMb","activeWindow","idleLimitMs","approvalLimitMs","WORKLOAD_LIFECYCLE_STATES","WORKLOAD_CLASSES","DEFAULT_CONCURRENCY_RETRY_FLOOR_MS","compareWakeRequests","left","right","priorityDiff","requestedDiff","deduplicateRequests","requests","byWorkloadId","request","existing","planStaggeredWakes","sorted","inFlight","availableSlots","launchNow","defer","retryStepMs","nextEligibleAtMs","scheduledW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yB,MAAA,CACtE,IAAA,CAAK,GAAA,CAAIe,EAAOf,CAAAA,CAAQ,oBAAA,CAAuBA,CAAAA,CAAQ,YAAY,EACnEe,CAAAA,CACFyD,CAAAA,CAA6B,CAAA,CAEjC,IAAA,IAAWV,CAAAA,IAAWG,CAAAA,CAAQ,CAC5B,GAAIO,GAA8BL,CAAAA,CAAgB,CAChD,IAAMM,CAAAA,CAAqB,KAAK,GAAA,CAAIF,CAAAA,CAAkBxD,CAAAA,CAAQuD,CAAW,EACzED,CAAAA,CAAM,IAAA,CAAK,CACT,OAAA,CAAAP,CAAAA,CACA,kBAAA,CAAAW,CAAAA,CACA,MAAA,CAAQ,mBACV,CAAC,CAAA,CACDF,CAAAA,CAAmBE,CAAAA,CAAqBH,EACxC,QACF,CAEA,GAAIC,CAAAA,CAAmBxD,EAAO,CAC5BsD,CAAAA,CAAM,IAAA,CAAK,CACT,OAAA,CAAAP,CAAAA,CACA,kBAAA,CAAoBS,CAAAA,CACpB,OAAQ,kBACV,CAAC,CAAA,CACDC,CAAAA,EAA8B,EAC9BD,CAAAA,EAAoBvE,CAAAA,CAAQ,YAAA,CAC5B,QACF,CAEAoE,CAAAA,CAAU,IAAA,CAAKN,CAAO,CAAA,CACtBU,GAA8B,CAAA,CAC1BxE,CAAAA,CAAQ,YAAA,CAAe,CAAA,GACzBuE,EAAmBxD,CAAAA,CAAQf,CAAAA,CAAQ,YAAA,EAEvC,CAEA,OAAO,CAAE,SAAA,CAAAoE,CAAAA,CAAW,KAAA,CAAAC,CAAM,CAC5B","file":"index.js","sourcesContent":["export type InfraErrorCode =\n | 'authentication_failed'\n | 'rate_limited'\n | 'not_found'\n | 'conflict'\n | 'provider_unavailable'\n | 'unreachable'\n | 'invalid_request'\n | 'deploy_failed';\n\nexport type InfraErrorDetails = {\n readonly status?: number;\n readonly provider?: string;\n readonly cause?: unknown;\n readonly retryable?: boolean;\n};\n\nconst RETRYABLE_INFRA_ERROR_CODES: ReadonlySet<InfraErrorCode> = new Set([\n 'unreachable',\n 'rate_limited',\n 'provider_unavailable',\n]);\n\nexport class InfraError extends Error {\n readonly code: InfraErrorCode;\n readonly status?: number;\n readonly provider?: string;\n readonly retryable: boolean;\n\n constructor(code: InfraErrorCode, message?: string, details?: InfraErrorDetails) {\n const prefix = details?.provider ? `[${details.provider}] ` : '';\n super(message ? `${prefix}${message}` : `${prefix}Infrastructure request failed (${code})`, {\n cause: details?.cause,\n });\n this.name = 'InfraError';\n this.code = code;\n this.status = details?.status;\n this.provider = details?.provider;\n this.retryable = details?.retryable ?? RETRYABLE_INFRA_ERROR_CODES.has(code);\n }\n}\n\nexport const infraErrorForStatus = (\n status: number,\n details?: { readonly provider?: string; readonly message?: string },\n): InfraError => {\n const code: InfraErrorCode =\n status === 401 || status === 403\n ? 'authentication_failed'\n : status === 404\n ? 'not_found'\n : status === 409\n ? 'conflict'\n : status === 429\n ? 'rate_limited'\n : status === 400 || status === 422\n ? 'invalid_request'\n : 'provider_unavailable';\n const message = details?.message\n ? `HTTP ${status}: ${details.message}`\n : `HTTP ${status} (${code})`;\n return new InfraError(code, message, { status, provider: details?.provider });\n};\n\nexport const isInfraError = (error: unknown, code?: InfraErrorCode): error is InfraError =>\n error instanceof InfraError && (code === undefined || error.code === code);\n\nexport const requireNonEmpty = (\n value: string | undefined,\n label: string,\n provider?: string,\n): string => {\n if (!value?.trim()) {\n throw new InfraError('invalid_request', `Missing required ${label}`, { provider });\n }\n return value;\n};\n\nexport const ignoreNotFound = (error: unknown): void => {\n if (!isInfraError(error, 'not_found')) throw error;\n};\n\nexport const assertNoEgressAllowlist = (\n egressAllowlist: readonly string[] | undefined,\n provider: string,\n): void => {\n if (egressAllowlist && egressAllowlist.length > 0) {\n throw new InfraError('invalid_request', 'Egress allowlist is not enforced by this driver', {\n provider,\n });\n }\n};\n","export type RenderPlanId = 'starter' | 'standard' | 'pro' | 'pro_plus' | 'pro_max' | 'pro_ultra';\n\nexport type RenderPlanTier = {\n readonly id: RenderPlanId;\n readonly maxMemoryMb: number;\n readonly monthlyUsd: number;\n};\n\nexport const RENDER_PLAN_TIERS: readonly RenderPlanTier[] = [\n { id: 'starter', maxMemoryMb: 512, monthlyUsd: 7 },\n { id: 'standard', maxMemoryMb: 2048, monthlyUsd: 25 },\n { id: 'pro', maxMemoryMb: 4096, monthlyUsd: 85 },\n { id: 'pro_plus', maxMemoryMb: 8192, monthlyUsd: 175 },\n { id: 'pro_max', maxMemoryMb: 16_384, monthlyUsd: 225 },\n { id: 'pro_ultra', maxMemoryMb: 32_768, monthlyUsd: 450 },\n];\n\nexport const renderPlanForMemoryMb = (memoryMb: number): RenderPlanTier => {\n for (const tier of RENDER_PLAN_TIERS) {\n if (memoryMb <= tier.maxMemoryMb) return tier;\n }\n return RENDER_PLAN_TIERS[RENDER_PLAN_TIERS.length - 1];\n};\n\nexport const RENDER_FAILED_DEPLOY_STATUSES: ReadonlySet<string> = new Set([\n 'build_failed',\n 'update_failed',\n 'pre_deploy_failed',\n 'canceled',\n]);\n\nexport const RENDER_ENDED_DEPLOY_STATUSES: ReadonlySet<string> = new Set([\n ...RENDER_FAILED_DEPLOY_STATUSES,\n 'deactivated',\n]);\n","import type { WorkloadCpuKind } from '../core/contracts.ts';\nimport { InfraError } from '../core/infraError.ts';\nimport type { InfraProviderId } from '../core/providers.ts';\nimport { renderPlanForMemoryMb } from '../render/renderPlans.ts';\n\nconst HOURS_PER_MONTH = 730;\nconst DEFAULT_RAILWAY_MEMORY_UTILIZATION = 0.65;\nconst DEFAULT_RAILWAY_CPU_UTILIZATION = 0.1;\n\nexport type HostingCostProjectionInput = {\n readonly provider: InfraProviderId;\n readonly memoryMb: number;\n readonly vcpus: number;\n readonly activeHoursPerMonth: number;\n readonly suspendedHoursPerMonth: number;\n readonly rootfsGb: number;\n readonly markupMultiplier?: number;\n readonly averageMemoryUtilization?: number;\n readonly averageCpuUtilization?: number;\n readonly cpuKind?: WorkloadCpuKind;\n};\n\nexport type HostingCostProjection = {\n readonly provider: InfraProviderId;\n readonly activeComputeUsd: number;\n readonly suspendedStorageUsd: number;\n readonly rawMonthlyCostUsd: number;\n readonly markupMultiplier: number;\n readonly markedUpMonthlyCostUsd: number;\n readonly marginUsd: number;\n readonly pricingBasis: string;\n};\n\nexport const HOSTING_PRICING_RATES = {\n railway: {\n memoryUsdPerGbHour: 0.0139,\n vcpuUsdPerHour: 0.0278,\n storageUsdPerGbMonth: 0.15,\n },\n fly: {\n sharedVcpuUsdPerMonth: 0.7,\n performanceVcpuUsdPerMonth: 21.0,\n memoryUsdPerGbMonth: 6.0,\n suspendedRootfsUsdPerGbMonth: 0.15,\n },\n render: {\n diskUsdPerGbMonth: 0.25,\n },\n firecracker: {\n amortizedMemoryUsdPerGbMonth: 3.5,\n amortizedVcpuUsdPerMonth: 4.0,\n snapshotStorageUsdPerGbMonth: 0.05,\n },\n aws: {\n fargateArmVcpuUsdPerHour: 0.0324,\n fargateArmMemoryUsdPerGbHour: 0.0036,\n storageUsdPerGbMonth: 0.08,\n },\n gcp: {\n vcpuUsdPerHour: 0.0432,\n memoryUsdPerGbHour: 0.0048,\n storageUsdPerGbMonth: 0.1,\n },\n azure: {\n vcpuUsdPerHour: 0.0432,\n memoryUsdPerGbHour: 0.0048,\n storageUsdPerGbMonth: 0.1,\n },\n} as const;\n\nconst roundUsd = (amount: number): number => Math.round(amount * 10_000) / 10_000;\n\nconst requireNonNegative = (value: number, name: string): void => {\n if (!Number.isFinite(value) || value < 0) {\n throw new InfraError('invalid_request', `${name} must be a finite number >= 0 (got ${value})`);\n }\n};\n\nconst requireUnitInterval = (value: number, name: string): void => {\n if (!Number.isFinite(value) || value < 0 || value > 1) {\n throw new InfraError(\n 'invalid_request',\n `${name} must be a finite number in [0, 1] (got ${value})`,\n );\n }\n};\n\nexport const projectHostingMonthlyCost = (\n input: HostingCostProjectionInput,\n): HostingCostProjection => {\n requireNonNegative(input.memoryMb, 'memoryMb');\n requireNonNegative(input.vcpus, 'vcpus');\n requireNonNegative(input.activeHoursPerMonth, 'activeHoursPerMonth');\n requireNonNegative(input.suspendedHoursPerMonth, 'suspendedHoursPerMonth');\n requireNonNegative(input.rootfsGb, 'rootfsGb');\n\n if (input.activeHoursPerMonth + input.suspendedHoursPerMonth > HOURS_PER_MONTH) {\n throw new InfraError(\n 'invalid_request',\n `activeHoursPerMonth + suspendedHoursPerMonth must be <= ${HOURS_PER_MONTH} (got ${input.activeHoursPerMonth + input.suspendedHoursPerMonth})`,\n );\n }\n\n const markupMultiplier = input.markupMultiplier ?? 1;\n if (!Number.isFinite(markupMultiplier) || markupMultiplier < 1) {\n throw new InfraError(\n 'invalid_request',\n `markupMultiplier must be a finite number >= 1 (got ${markupMultiplier})`,\n );\n }\n\n if (input.averageMemoryUtilization !== undefined) {\n requireUnitInterval(input.averageMemoryUtilization, 'averageMemoryUtilization');\n }\n if (input.averageCpuUtilization !== undefined) {\n requireUnitInterval(input.averageCpuUtilization, 'averageCpuUtilization');\n }\n\n const memoryGb = input.memoryMb / 1024;\n const activeMonthFraction = input.activeHoursPerMonth / HOURS_PER_MONTH;\n const totalStoredMonthFraction =\n (input.activeHoursPerMonth + input.suspendedHoursPerMonth) / HOURS_PER_MONTH;\n const suspendedMonthFraction = input.suspendedHoursPerMonth / HOURS_PER_MONTH;\n\n let activeComputeUsd = 0;\n let suspendedStorageUsd = 0;\n let pricingBasis = '';\n\n switch (input.provider) {\n case 'railway': {\n const memUtil = input.averageMemoryUtilization ?? DEFAULT_RAILWAY_MEMORY_UTILIZATION;\n const cpuUtil = input.averageCpuUtilization ?? DEFAULT_RAILWAY_CPU_UTILIZATION;\n activeComputeUsd =\n memoryGb *\n memUtil *\n input.activeHoursPerMonth *\n HOSTING_PRICING_RATES.railway.memoryUsdPerGbHour +\n input.vcpus *\n cpuUtil *\n input.activeHoursPerMonth *\n HOSTING_PRICING_RATES.railway.vcpuUsdPerHour;\n suspendedStorageUsd =\n input.rootfsGb *\n totalStoredMonthFraction *\n HOSTING_PRICING_RATES.railway.storageUsdPerGbMonth;\n pricingBasis = 'usage-metered active RAM/vCPU per second + persistent volume storage';\n break;\n }\n case 'fly': {\n const vcpuMonthRate =\n input.cpuKind === 'performance'\n ? HOSTING_PRICING_RATES.fly.performanceVcpuUsdPerMonth\n : HOSTING_PRICING_RATES.fly.sharedVcpuUsdPerMonth;\n const monthlyActiveRate =\n input.vcpus * vcpuMonthRate + memoryGb * HOSTING_PRICING_RATES.fly.memoryUsdPerGbMonth;\n activeComputeUsd = monthlyActiveRate * activeMonthFraction;\n suspendedStorageUsd =\n input.rootfsGb *\n suspendedMonthFraction *\n HOSTING_PRICING_RATES.fly.suspendedRootfsUsdPerGbMonth;\n pricingBasis =\n 'provisioned Firecracker microVM per second while active + rootfs-only storage while suspended';\n break;\n }\n case 'render': {\n const plan = renderPlanForMemoryMb(input.memoryMb);\n activeComputeUsd = plan.monthlyUsd * activeMonthFraction;\n suspendedStorageUsd =\n input.rootfsGb * totalStoredMonthFraction * HOSTING_PRICING_RATES.render.diskUsdPerGbMonth;\n pricingBasis = `prorated fixed Render ${plan.id} tier while unsuspended + persistent disk`;\n break;\n }\n case 'firecracker': {\n const monthlyHostShare =\n memoryGb * HOSTING_PRICING_RATES.firecracker.amortizedMemoryUsdPerGbMonth +\n input.vcpus * HOSTING_PRICING_RATES.firecracker.amortizedVcpuUsdPerMonth;\n activeComputeUsd = monthlyHostShare * activeMonthFraction;\n suspendedStorageUsd =\n (input.rootfsGb + memoryGb) *\n suspendedMonthFraction *\n HOSTING_PRICING_RATES.firecracker.snapshotStorageUsdPerGbMonth;\n pricingBasis =\n 'amortized dedicated bare-metal host capacity while active + NVMe snapshot storage while suspended';\n break;\n }\n case 'aws': {\n activeComputeUsd =\n input.vcpus *\n input.activeHoursPerMonth *\n HOSTING_PRICING_RATES.aws.fargateArmVcpuUsdPerHour +\n memoryGb *\n input.activeHoursPerMonth *\n HOSTING_PRICING_RATES.aws.fargateArmMemoryUsdPerGbHour;\n suspendedStorageUsd =\n input.rootfsGb * totalStoredMonthFraction * HOSTING_PRICING_RATES.aws.storageUsdPerGbMonth;\n pricingBasis = 'AWS Fargate ARM provisioned vCPU/GB-hour + EBS/snapshot storage';\n break;\n }\n case 'gcp': {\n activeComputeUsd =\n input.vcpus * input.activeHoursPerMonth * HOSTING_PRICING_RATES.gcp.vcpuUsdPerHour +\n memoryGb * input.activeHoursPerMonth * HOSTING_PRICING_RATES.gcp.memoryUsdPerGbHour;\n suspendedStorageUsd =\n input.rootfsGb * totalStoredMonthFraction * HOSTING_PRICING_RATES.gcp.storageUsdPerGbMonth;\n pricingBasis = 'GCP provisioned vCPU/GB-hour + persistent storage';\n break;\n }\n case 'azure': {\n activeComputeUsd =\n input.vcpus * input.activeHoursPerMonth * HOSTING_PRICING_RATES.azure.vcpuUsdPerHour +\n memoryGb * input.activeHoursPerMonth * HOSTING_PRICING_RATES.azure.memoryUsdPerGbHour;\n suspendedStorageUsd =\n input.rootfsGb *\n totalStoredMonthFraction *\n HOSTING_PRICING_RATES.azure.storageUsdPerGbMonth;\n pricingBasis = 'Azure Container Apps provisioned vCPU/GB-hour + storage';\n break;\n }\n }\n\n const roundedActive = roundUsd(activeComputeUsd);\n const roundedStorage = roundUsd(suspendedStorageUsd);\n const roundedRaw = roundUsd(roundedActive + roundedStorage);\n const roundedMarkedUp = roundUsd(roundedRaw * markupMultiplier);\n const roundedMargin = roundUsd(roundedMarkedUp - roundedRaw);\n\n return {\n provider: input.provider,\n activeComputeUsd: roundedActive,\n suspendedStorageUsd: roundedStorage,\n rawMonthlyCostUsd: roundedRaw,\n markupMultiplier,\n markedUpMonthlyCostUsd: roundedMarkedUp,\n marginUsd: roundedMargin,\n pricingBasis,\n };\n};\n","export const IMPLEMENTED_INFRA_PROVIDERS = ['railway', 'render', 'fly', 'firecracker'] as const;\nexport const PLANNED_INFRA_PROVIDERS = ['aws', 'gcp', 'azure'] as const;\nexport const ARCHIVE_HOSTING_PROVIDERS = ['railway', 'render'] as const;\n\nexport type ImplementedInfraProvider = (typeof IMPLEMENTED_INFRA_PROVIDERS)[number];\nexport type PlannedInfraProvider = (typeof PLANNED_INFRA_PROVIDERS)[number];\nexport type ArchiveHostingProvider = (typeof ARCHIVE_HOSTING_PROVIDERS)[number];\nexport type InfraProviderId = ImplementedInfraProvider | PlannedInfraProvider;\n\nexport type InfraIsolationKind = 'microvm' | 'container';\n\nexport type InfraBillingUnit =\n | 'active_utilization_second'\n | 'provisioned_second_with_suspend_storage'\n | 'flat_plan_month'\n | 'host_machine_month'\n | 'provisioned_vcpu_memory_second';\n\nexport type InfraProviderDescriptor = {\n readonly id: InfraProviderId;\n readonly name: string;\n readonly implemented: boolean;\n readonly supportsArchiveHosting: boolean;\n readonly supportsWorkloadDriver: boolean;\n readonly isolation: InfraIsolationKind;\n readonly supportsSuspend: boolean;\n readonly suspendMaxMemoryMb?: number;\n readonly supportsByoAccount: boolean;\n readonly supportsManagedAccount: boolean;\n readonly billingUnit: InfraBillingUnit;\n readonly notes: string;\n};\n\nexport const INFRA_PROVIDERS: Readonly<Record<InfraProviderId, InfraProviderDescriptor>> = {\n railway: {\n id: 'railway',\n name: 'Railway',\n implemented: true,\n supportsArchiveHosting: true,\n supportsWorkloadDriver: true,\n isolation: 'container',\n supportsSuspend: false,\n supportsByoAccount: true,\n supportsManagedAccount: true,\n billingUnit: 'active_utilization_second',\n notes:\n 'Usage-metered memory and CPU per second; stopped services bill nothing; no memory-snapshot suspend.',\n },\n render: {\n id: 'render',\n name: 'Render',\n implemented: true,\n supportsArchiveHosting: true,\n supportsWorkloadDriver: true,\n isolation: 'container',\n supportsSuspend: false,\n supportsByoAccount: true,\n supportsManagedAccount: true,\n billingUnit: 'flat_plan_month',\n notes:\n 'Managed web services and Postgres on fixed tiers; service suspend stops execution without a memory snapshot.',\n },\n fly: {\n id: 'fly',\n name: 'Fly.io Machines',\n implemented: true,\n supportsArchiveHosting: false,\n supportsWorkloadDriver: true,\n isolation: 'microvm',\n supportsSuspend: true,\n suspendMaxMemoryMb: 2048,\n supportsByoAccount: true,\n supportsManagedAccount: true,\n billingUnit: 'provisioned_second_with_suspend_storage',\n notes:\n 'Firecracker microVMs with GA memory-snapshot suspend up to 2048 MB RAM and rootfs-only suspended storage billing.',\n },\n firecracker: {\n id: 'firecracker',\n name: 'Firecracker',\n implemented: true,\n supportsArchiveHosting: false,\n supportsWorkloadDriver: true,\n isolation: 'microvm',\n supportsSuspend: true,\n supportsByoAccount: true,\n supportsManagedAccount: true,\n billingUnit: 'host_machine_month',\n notes:\n 'Direct Firecracker VMM HTTP/Unix control plane for dedicated or bare-metal microVM hosts with full memory snapshots.',\n },\n aws: {\n id: 'aws',\n name: 'AWS (Fargate / Lambda MicroVMs)',\n implemented: false,\n supportsArchiveHosting: false,\n supportsWorkloadDriver: false,\n isolation: 'microvm',\n supportsSuspend: true,\n supportsByoAccount: true,\n supportsManagedAccount: true,\n billingUnit: 'provisioned_vcpu_memory_second',\n notes:\n 'Planned cloud adapter for AWS Fargate tasks and Firecracker-backed Lambda MicroVMs (8h session cap).',\n },\n gcp: {\n id: 'gcp',\n name: 'Google Cloud (Cloud Run / GKE Autopilot)',\n implemented: false,\n supportsArchiveHosting: false,\n supportsWorkloadDriver: false,\n isolation: 'microvm',\n supportsSuspend: false,\n supportsByoAccount: true,\n supportsManagedAccount: true,\n billingUnit: 'provisioned_vcpu_memory_second',\n notes: 'Planned cloud adapter for Google Cloud Run and GKE Autopilot workloads.',\n },\n azure: {\n id: 'azure',\n name: 'Azure (Container Apps / ACI)',\n implemented: false,\n supportsArchiveHosting: false,\n supportsWorkloadDriver: false,\n isolation: 'container',\n supportsSuspend: false,\n supportsByoAccount: true,\n supportsManagedAccount: true,\n billingUnit: 'provisioned_vcpu_memory_second',\n notes: 'Planned cloud adapter for Azure Container Apps and Container Instances.',\n },\n};\n\nexport const isInfraProvider = (value: string | null | undefined): value is InfraProviderId =>\n typeof value === 'string' && Object.hasOwn(INFRA_PROVIDERS, value);\n\nexport const isImplementedInfraProvider = (\n value: string | null | undefined,\n): value is ImplementedInfraProvider =>\n IMPLEMENTED_INFRA_PROVIDERS.some((provider) => provider === value);\n\nexport const isArchiveHostingProvider = (\n value: string | null | undefined,\n): value is ArchiveHostingProvider =>\n ARCHIVE_HOSTING_PROVIDERS.some((provider) => provider === value);\n\nexport const infraProviderDescriptor = (provider: InfraProviderId): InfraProviderDescriptor =>\n INFRA_PROVIDERS[provider];\n","import type {\n WarmRetentionMode,\n WorkingHoursSchedule,\n WorkloadClass,\n WorkloadLifecyclePolicy,\n} from './lifecycleTypes.ts';\n\nconst MINUTE_MS = 60_000;\nconst HOUR_MS = 60 * MINUTE_MS;\nconst DAY_MS = 24 * HOUR_MS;\n\nexport type WorkloadLifecyclePolicyOptions = {\n readonly warmRetentionMode?: WarmRetentionMode;\n readonly workingHoursPrewarm?: WorkingHoursSchedule;\n};\n\nexport const defaultWorkloadLifecyclePolicy = (\n workloadClass: WorkloadClass,\n options: WorkloadLifecyclePolicyOptions = {},\n): WorkloadLifecyclePolicy => {\n switch (workloadClass) {\n case 'warm-interactive':\n return {\n workloadClass,\n idleSuspendMs: 8 * MINUTE_MS,\n idleStopMs: 3 * HOUR_MS,\n drainGraceMs: 60_000,\n pendingApprovalGraceMs: 0,\n maxLifetimeMs: 24 * HOUR_MS,\n maxSuspendedMs: 14 * DAY_MS,\n softMemoryRecycleMb: 1536,\n hardMemoryCapMb: 2048,\n requireArchiveFlushBeforeWindDown: false,\n workingHoursPrewarm: options.workingHoursPrewarm,\n idleAction: 'suspend',\n };\n case 'warm-pool':\n return {\n workloadClass,\n idleSuspendMs: options.warmRetentionMode === 'extended' ? 60 * MINUTE_MS : 5 * MINUTE_MS,\n idleStopMs: 3 * HOUR_MS,\n drainGraceMs: 60_000,\n pendingApprovalGraceMs: 0,\n maxLifetimeMs: 24 * HOUR_MS,\n maxSuspendedMs: 7 * DAY_MS,\n softMemoryRecycleMb: 1536,\n hardMemoryCapMb: 2048,\n requireArchiveFlushBeforeWindDown: false,\n workingHoursPrewarm: options.workingHoursPrewarm,\n idleAction: 'suspend',\n };\n case 'batch-worker':\n return {\n workloadClass,\n idleSuspendMs: 5 * MINUTE_MS,\n idleStopMs: 5 * MINUTE_MS,\n drainGraceMs: 120_000,\n pendingApprovalGraceMs: 0,\n maxLifetimeMs: 4 * HOUR_MS,\n maxSuspendedMs: 24 * HOUR_MS,\n softMemoryRecycleMb: 1536,\n hardMemoryCapMb: 2048,\n requireArchiveFlushBeforeWindDown: false,\n idleAction: 'terminate',\n };\n case 'ephemeral-session':\n return {\n workloadClass,\n idleSuspendMs: 15 * MINUTE_MS,\n idleStopMs: 15 * MINUTE_MS,\n drainGraceMs: 60_000,\n pendingApprovalGraceMs: 30 * MINUTE_MS,\n maxLifetimeMs: 24 * HOUR_MS,\n maxSuspendedMs: 7 * DAY_MS,\n softMemoryRecycleMb: null,\n hardMemoryCapMb: null,\n requireArchiveFlushBeforeWindDown: true,\n idleAction: 'suspend',\n };\n case 'always-on':\n return {\n workloadClass,\n idleSuspendMs: null,\n idleStopMs: null,\n drainGraceMs: 60_000,\n pendingApprovalGraceMs: 0,\n maxLifetimeMs: null,\n maxSuspendedMs: null,\n softMemoryRecycleMb: null,\n hardMemoryCapMb: null,\n requireArchiveFlushBeforeWindDown: false,\n idleAction: 'keep_warm',\n };\n }\n};\n","import { InfraError } from '../core/infraError.ts';\nimport { infraProviderDescriptor } from '../core/providers.ts';\nimport { defaultWorkloadLifecyclePolicy } from './lifecyclePolicy.ts';\nimport type {\n WorkingHoursSchedule,\n WorkloadLifecycleDecision,\n WorkloadLifecyclePolicy,\n WorkloadLifecycleSnapshot,\n} from './lifecycleTypes.ts';\n\nconst TRANSITIONAL_POLL_MS = 15_000;\nconst ACTIVE_WORK_POLL_MS = 30_000;\nconst ARCHIVE_FLUSH_POLL_MS = 10_000;\nconst SUSPENDED_POLL_MS = 300_000;\nconst HOUR_MS = 3_600_000;\nconst DAY_MS = 24 * HOUR_MS;\n\nconst assertFiniteNumber = (value: number, name: string): void => {\n if (!Number.isFinite(value)) {\n throw new InfraError('invalid_request', `${name} must be a finite number (got ${value})`);\n }\n};\n\nconst assertNonNegativeFinite = (value: number, name: string): void => {\n if (!Number.isFinite(value) || value < 0) {\n throw new InfraError('invalid_request', `${name} must be a finite number >= 0 (got ${value})`);\n }\n};\n\nconst assertNonNegativeInteger = (value: number, name: string): void => {\n if (!Number.isInteger(value) || value < 0) {\n throw new InfraError('invalid_request', `${name} must be an integer >= 0 (got ${value})`);\n }\n};\n\nconst assertPositiveOptional = (value: number | null | undefined, name: string): void => {\n if (value === null || value === undefined) return;\n if (!Number.isFinite(value) || value <= 0) {\n throw new InfraError('invalid_request', `${name} must be a finite number > 0 (got ${value})`);\n }\n};\n\nconst validateWorkingHoursSchedule = (schedule: WorkingHoursSchedule): void => {\n assertFiniteNumber(schedule.timezoneOffsetMinutes, 'workingHoursPrewarm.timezoneOffsetMinutes');\n if (!Number.isFinite(schedule.startHour) || schedule.startHour < 0 || schedule.startHour >= 24) {\n throw new InfraError(\n 'invalid_request',\n `workingHoursPrewarm.startHour must be in [0, 24) (got ${schedule.startHour})`,\n );\n }\n if (!Number.isFinite(schedule.endHour) || schedule.endHour < 0 || schedule.endHour > 24) {\n throw new InfraError(\n 'invalid_request',\n `workingHoursPrewarm.endHour must be in [0, 24] (got ${schedule.endHour})`,\n );\n }\n assertNonNegativeFinite(schedule.prewarmLeadMs, 'workingHoursPrewarm.prewarmLeadMs');\n};\n\nconst validateSnapshotAndPolicy = (\n snapshot: WorkloadLifecycleSnapshot,\n nowMs: number,\n policy: WorkloadLifecyclePolicy,\n): void => {\n assertFiniteNumber(nowMs, 'nowMs');\n assertFiniteNumber(snapshot.createdAtMs, 'snapshot.createdAtMs');\n assertFiniteNumber(snapshot.lastActivityAtMs, 'snapshot.lastActivityAtMs');\n assertFiniteNumber(snapshot.stateEnteredAtMs, 'snapshot.stateEnteredAtMs');\n assertNonNegativeInteger(snapshot.inFlightTurns, 'snapshot.inFlightTurns');\n assertNonNegativeInteger(snapshot.activeBackgroundShells, 'snapshot.activeBackgroundShells');\n if (snapshot.pendingApprovals !== undefined) {\n assertNonNegativeInteger(snapshot.pendingApprovals, 'snapshot.pendingApprovals');\n }\n assertPositiveOptional(snapshot.provisionedMemoryMb, 'snapshot.provisionedMemoryMb');\n assertPositiveOptional(snapshot.rssMemoryMb, 'snapshot.rssMemoryMb');\n\n if (policy.idleSuspendMs !== null) {\n assertNonNegativeFinite(policy.idleSuspendMs, 'policy.idleSuspendMs');\n }\n if (policy.idleStopMs !== null) {\n assertNonNegativeFinite(policy.idleStopMs, 'policy.idleStopMs');\n }\n assertNonNegativeFinite(policy.drainGraceMs, 'policy.drainGraceMs');\n assertNonNegativeFinite(policy.pendingApprovalGraceMs, 'policy.pendingApprovalGraceMs');\n if (policy.maxLifetimeMs !== null) {\n assertPositiveOptional(policy.maxLifetimeMs, 'policy.maxLifetimeMs');\n }\n if (policy.maxSuspendedMs !== null) {\n assertPositiveOptional(policy.maxSuspendedMs, 'policy.maxSuspendedMs');\n }\n assertPositiveOptional(policy.softMemoryRecycleMb, 'policy.softMemoryRecycleMb');\n assertPositiveOptional(policy.hardMemoryCapMb, 'policy.hardMemoryCapMb');\n if (policy.workingHoursPrewarm) {\n validateWorkingHoursSchedule(policy.workingHoursPrewarm);\n }\n};\n\ntype WorkingWindowBounds = {\n readonly prewarmStartMs: number;\n readonly windowStartMs: number;\n readonly windowEndMs: number;\n};\n\nconst workingWindowForDayDelta = (\n nowMs: number,\n schedule: WorkingHoursSchedule,\n dayDelta: number,\n): WorkingWindowBounds | null => {\n const offsetMs = schedule.timezoneOffsetMinutes * 60_000;\n const shifted = new Date(nowMs + offsetMs + dayDelta * DAY_MS);\n const dayOfWeek = shifted.getUTCDay();\n if (schedule.weekdaysOnly && (dayOfWeek === 0 || dayOfWeek === 6)) {\n return null;\n }\n const localMidnightUtcMs =\n Date.UTC(shifted.getUTCFullYear(), shifted.getUTCMonth(), shifted.getUTCDate()) - offsetMs;\n const windowStartMs = localMidnightUtcMs + schedule.startHour * HOUR_MS;\n const isOvernight = schedule.endHour <= schedule.startHour;\n const windowEndMs = localMidnightUtcMs + schedule.endHour * HOUR_MS + (isOvernight ? DAY_MS : 0);\n const prewarmStartMs = windowStartMs - schedule.prewarmLeadMs;\n return { prewarmStartMs, windowStartMs, windowEndMs };\n};\n\nconst activeWorkingWindowAt = (\n nowMs: number,\n schedule: WorkingHoursSchedule,\n): WorkingWindowBounds | null => {\n for (const dayDelta of [-1, 0, 1]) {\n const bounds = workingWindowForDayDelta(nowMs, schedule, dayDelta);\n if (!bounds) continue;\n if (nowMs >= bounds.prewarmStartMs && nowMs < bounds.windowEndMs) {\n return bounds;\n }\n }\n return null;\n};\n\nconst nextWorkingHoursPrewarmAtMs = (\n nowMs: number,\n schedule: WorkingHoursSchedule,\n): number | null => {\n let next: number | null = null;\n for (let dayDelta = 0; dayDelta <= 8; dayDelta += 1) {\n const bounds = workingWindowForDayDelta(nowMs, schedule, dayDelta);\n if (!bounds) continue;\n if (bounds.prewarmStartMs > nowMs) {\n next = next === null ? bounds.prewarmStartMs : Math.min(next, bounds.prewarmStartMs);\n }\n }\n return next;\n};\n\nconst earliestCheckTime = (...candidates: Array<number | null | undefined>): number | null => {\n let earliest: number | null = null;\n for (const candidate of candidates) {\n if (candidate === null || candidate === undefined) continue;\n earliest = earliest === null ? candidate : Math.min(earliest, candidate);\n }\n return earliest;\n};\n\nexport const evaluateWorkloadLifecycle = (\n snapshot: WorkloadLifecycleSnapshot,\n nowMs: number,\n policy: WorkloadLifecyclePolicy = defaultWorkloadLifecyclePolicy(snapshot.workloadClass, {\n warmRetentionMode: snapshot.warmRetentionMode,\n }),\n): WorkloadLifecycleDecision => {\n validateSnapshotAndPolicy(snapshot, nowMs, policy);\n\n const descriptor = infraProviderDescriptor(snapshot.provider);\n const hasActiveWork = snapshot.inFlightTurns > 0 || snapshot.activeBackgroundShells > 0;\n const hasPendingApprovals = (snapshot.pendingApprovals ?? 0) > 0;\n const ageMs = Math.max(0, nowMs - snapshot.createdAtMs);\n const maxLifetimeReached = policy.maxLifetimeMs !== null && ageMs >= policy.maxLifetimeMs;\n const lifetimeDeadlineMs =\n policy.maxLifetimeMs !== null ? snapshot.createdAtMs + policy.maxLifetimeMs : null;\n\n if (snapshot.state === 'destroyed') {\n return { action: 'none', reason: 'workload_already_destroyed', nextCheckAtMs: null };\n }\n\n if (snapshot.state === 'failed' || snapshot.state === 'orphaned') {\n return {\n action: 'terminate',\n reason: `reap_${snapshot.state}_workload`,\n nextCheckAtMs: null,\n };\n }\n\n if (\n snapshot.state === 'provisioning' ||\n snapshot.state === 'booting' ||\n snapshot.state === 'suspending' ||\n snapshot.state === 'terminating'\n ) {\n return {\n action: 'none',\n reason: `workload_${snapshot.state}`,\n nextCheckAtMs: nowMs + TRANSITIONAL_POLL_MS,\n };\n }\n\n if (snapshot.state === 'suspended') {\n const suspendedElapsedMs = Math.max(0, nowMs - snapshot.stateEnteredAtMs);\n if (policy.maxSuspendedMs !== null && suspendedElapsedMs >= policy.maxSuspendedMs) {\n return {\n action: 'terminate',\n reason: 'suspended_retention_expired',\n nextCheckAtMs: null,\n };\n }\n\n if (policy.workingHoursPrewarm) {\n if (activeWorkingWindowAt(nowMs, policy.workingHoursPrewarm)) {\n return {\n action: 'prewarm',\n reason: 'working_hours_prewarm_window',\n nextCheckAtMs: null,\n };\n }\n }\n\n const expiryAtMs =\n policy.maxSuspendedMs !== null ? snapshot.stateEnteredAtMs + policy.maxSuspendedMs : null;\n const nextPrewarmAtMs = policy.workingHoursPrewarm\n ? nextWorkingHoursPrewarmAtMs(nowMs, policy.workingHoursPrewarm)\n : null;\n return {\n action: 'none',\n reason: 'suspended_within_retention',\n nextCheckAtMs: earliestCheckTime(expiryAtMs, nextPrewarmAtMs, nowMs + SUSPENDED_POLL_MS),\n };\n }\n\n if (snapshot.state === 'draining') {\n const drainElapsedMs = Math.max(0, nowMs - snapshot.stateEnteredAtMs);\n const drainDeadlineMs = snapshot.stateEnteredAtMs + policy.drainGraceMs;\n const idleElapsedMs = Math.max(0, nowMs - snapshot.lastActivityAtMs);\n\n if (hasActiveWork) {\n if (!maxLifetimeReached) {\n return {\n action: 'none',\n reason: 'active_work_blocks_idle_drain',\n nextCheckAtMs: earliestCheckTime(lifetimeDeadlineMs, nowMs + ACTIVE_WORK_POLL_MS),\n };\n }\n if (drainElapsedMs < policy.drainGraceMs) {\n return {\n action: 'none',\n reason: 'waiting_for_in_flight_work_to_drain',\n nextCheckAtMs: drainDeadlineMs,\n };\n }\n return {\n action: 'terminate',\n reason: 'max_lifetime_exceeded_with_active_work',\n nextCheckAtMs: null,\n };\n }\n\n if (\n hasPendingApprovals &&\n !maxLifetimeReached &&\n policy.pendingApprovalGraceMs > 0 &&\n idleElapsedMs < policy.pendingApprovalGraceMs\n ) {\n return {\n action: 'none',\n reason: 'waiting_for_pending_approval',\n nextCheckAtMs: earliestCheckTime(\n lifetimeDeadlineMs,\n snapshot.lastActivityAtMs + policy.pendingApprovalGraceMs,\n ),\n };\n }\n\n if (policy.requireArchiveFlushBeforeWindDown && !snapshot.archiveFlushed) {\n if (!maxLifetimeReached || drainElapsedMs < policy.drainGraceMs) {\n return {\n action: 'none',\n reason: 'waiting_for_archive_flush',\n nextCheckAtMs: nowMs + ARCHIVE_FLUSH_POLL_MS,\n };\n }\n return {\n action: 'terminate',\n reason: 'max_lifetime_exceeded_without_archive_flush',\n nextCheckAtMs: null,\n };\n }\n\n if (maxLifetimeReached) {\n return {\n action: 'terminate',\n reason: 'max_lifetime_reached_after_drain',\n nextCheckAtMs: null,\n };\n }\n\n if (policy.idleAction === 'terminate') {\n return {\n action: 'terminate',\n reason: 'drain_complete_ready_to_terminate',\n nextCheckAtMs: null,\n };\n }\n\n const suspendMemoryMb = snapshot.provisionedMemoryMb ?? snapshot.rssMemoryMb;\n if (\n descriptor.supportsSuspend &&\n descriptor.suspendMaxMemoryMb !== undefined &&\n suspendMemoryMb !== undefined &&\n suspendMemoryMb > descriptor.suspendMaxMemoryMb\n ) {\n return policy.hardMemoryCapMb !== null\n ? {\n action: 'recycle',\n reason: 'memory_exceeds_provider_suspend_cap',\n nextCheckAtMs: null,\n }\n : {\n action: 'terminate',\n reason: 'cannot_suspend_above_provider_memory_cap',\n nextCheckAtMs: null,\n };\n }\n\n return {\n action: 'suspend',\n reason: descriptor.supportsSuspend\n ? 'drain_complete_ready_to_suspend'\n : 'drain_complete_ready_to_stop',\n nextCheckAtMs: null,\n };\n }\n\n // States: 'warm' | 'active'\n if (maxLifetimeReached) {\n if (hasActiveWork || (policy.requireArchiveFlushBeforeWindDown && !snapshot.archiveFlushed)) {\n return {\n action: 'drain',\n reason: 'max_lifetime_reached_draining',\n nextCheckAtMs: nowMs + policy.drainGraceMs,\n };\n }\n return {\n action: 'terminate',\n reason: 'max_lifetime_reached',\n nextCheckAtMs: null,\n };\n }\n\n if (\n policy.hardMemoryCapMb !== null &&\n snapshot.rssMemoryMb !== undefined &&\n snapshot.rssMemoryMb >\n (descriptor.suspendMaxMemoryMb !== undefined\n ? Math.min(policy.hardMemoryCapMb, descriptor.suspendMaxMemoryMb)\n : policy.hardMemoryCapMb)\n ) {\n return {\n action: 'recycle',\n reason: 'rss_exceeds_hard_cap',\n nextCheckAtMs: null,\n };\n }\n\n if (\n policy.softMemoryRecycleMb !== null &&\n snapshot.rssMemoryMb !== undefined &&\n snapshot.rssMemoryMb >= policy.softMemoryRecycleMb &&\n !hasActiveWork\n ) {\n return {\n action: 'recycle',\n reason: 'rss_exceeds_soft_recycle_threshold',\n nextCheckAtMs: null,\n };\n }\n\n if (snapshot.pinnedWarm || policy.idleAction === 'keep_warm') {\n return {\n action: 'none',\n reason: 'workload_pinned_warm',\n nextCheckAtMs: lifetimeDeadlineMs,\n };\n }\n\n if (policy.workingHoursPrewarm) {\n const activeWindow = activeWorkingWindowAt(nowMs, policy.workingHoursPrewarm);\n if (activeWindow) {\n return {\n action: 'none',\n reason: 'within_working_hours_window',\n nextCheckAtMs: earliestCheckTime(lifetimeDeadlineMs, activeWindow.windowEndMs),\n };\n }\n }\n\n if (hasActiveWork) {\n return {\n action: 'none',\n reason: 'active_work_in_progress',\n nextCheckAtMs: earliestCheckTime(lifetimeDeadlineMs, nowMs + ACTIVE_WORK_POLL_MS),\n };\n }\n\n const idleLimitMs = descriptor.supportsSuspend ? policy.idleSuspendMs : policy.idleStopMs;\n if (idleLimitMs === null) {\n return {\n action: 'none',\n reason: 'no_idle_timeout_configured',\n nextCheckAtMs: lifetimeDeadlineMs,\n };\n }\n\n const idleElapsedMs = Math.max(0, nowMs - snapshot.lastActivityAtMs);\n if (hasPendingApprovals && policy.pendingApprovalGraceMs > 0) {\n const approvalLimitMs = Math.max(idleLimitMs, policy.pendingApprovalGraceMs);\n if (idleElapsedMs < approvalLimitMs) {\n return {\n action: 'none',\n reason: 'waiting_for_pending_approval',\n nextCheckAtMs: earliestCheckTime(\n lifetimeDeadlineMs,\n snapshot.lastActivityAtMs + approvalLimitMs,\n ),\n };\n }\n }\n\n if (idleElapsedMs >= idleLimitMs) {\n return {\n action: 'drain',\n reason: 'idle_timeout_reached',\n nextCheckAtMs: nowMs + policy.drainGraceMs,\n };\n }\n\n return {\n action: 'none',\n reason: 'within_idle_window',\n nextCheckAtMs: earliestCheckTime(lifetimeDeadlineMs, snapshot.lastActivityAtMs + idleLimitMs),\n };\n};\n","import type { InfraProviderId } from '../core/providers.ts';\n\nexport const WORKLOAD_LIFECYCLE_STATES = [\n 'provisioning',\n 'booting',\n 'warm',\n 'active',\n 'draining',\n 'suspending',\n 'suspended',\n 'terminating',\n 'destroyed',\n 'failed',\n 'orphaned',\n] as const;\n\nexport type WorkloadLifecycleState = (typeof WORKLOAD_LIFECYCLE_STATES)[number];\n\nexport const WORKLOAD_CLASSES = [\n 'warm-interactive',\n 'warm-pool',\n 'batch-worker',\n 'ephemeral-session',\n 'always-on',\n] as const;\n\nexport type WorkloadClass = (typeof WORKLOAD_CLASSES)[number];\n\nexport type WarmRetentionMode = 'short' | 'extended';\n\nexport type WorkingHoursSchedule = {\n readonly timezoneOffsetMinutes: number;\n readonly startHour: number;\n readonly endHour: number;\n readonly weekdaysOnly: boolean;\n readonly prewarmLeadMs: number;\n};\n\nexport type WorkloadIdleAction = 'suspend' | 'terminate' | 'keep_warm';\n\nexport type WorkloadLifecyclePolicy = {\n readonly workloadClass: WorkloadClass;\n readonly idleSuspendMs: number | null;\n readonly idleStopMs: number | null;\n readonly drainGraceMs: number;\n readonly pendingApprovalGraceMs: number;\n readonly maxLifetimeMs: number | null;\n readonly maxSuspendedMs: number | null;\n readonly softMemoryRecycleMb: number | null;\n readonly hardMemoryCapMb: number | null;\n readonly requireArchiveFlushBeforeWindDown: boolean;\n readonly workingHoursPrewarm?: WorkingHoursSchedule;\n readonly idleAction: WorkloadIdleAction;\n};\n\nexport type WorkloadLifecycleSnapshot = {\n readonly workloadId: string;\n readonly workloadClass: WorkloadClass;\n readonly provider: InfraProviderId;\n readonly state: WorkloadLifecycleState;\n readonly createdAtMs: number;\n readonly lastActivityAtMs: number;\n readonly stateEnteredAtMs: number;\n readonly inFlightTurns: number;\n readonly activeBackgroundShells: number;\n readonly pendingApprovals?: number;\n readonly archiveFlushed: boolean;\n readonly provisionedMemoryMb?: number;\n readonly rssMemoryMb?: number;\n readonly pinnedWarm?: boolean;\n readonly warmRetentionMode?: WarmRetentionMode;\n};\n\nexport type WorkloadLifecycleAction =\n | 'none'\n | 'prewarm'\n | 'drain'\n | 'suspend'\n | 'terminate'\n | 'recycle';\n\nexport type WorkloadLifecycleDecision = {\n readonly action: WorkloadLifecycleAction;\n readonly reason: string;\n readonly nextCheckAtMs: number | null;\n};\n","import { InfraError } from '../core/infraError.ts';\n\nconst DEFAULT_CONCURRENCY_RETRY_FLOOR_MS = 1_000;\n\nexport type StaggeredWakeRequest = {\n readonly workloadId: string;\n readonly priority?: number;\n readonly requestedAtMs: number;\n};\n\nexport type StaggeredWakeOptions = {\n readonly maxConcurrentWakes: number;\n readonly minSpacingMs: number;\n readonly inFlightWakeCount?: number;\n readonly lastWakeLaunchedAtMs?: number | null;\n};\n\nexport type DeferredWakeReason = 'concurrency_limit' | 'spacing_interval';\n\nexport type DeferredWake = {\n readonly request: StaggeredWakeRequest;\n readonly earliestLaunchAtMs: number;\n readonly reason: DeferredWakeReason;\n};\n\nexport type StaggeredWakePlan = {\n readonly launchNow: readonly StaggeredWakeRequest[];\n readonly defer: readonly DeferredWake[];\n};\n\nconst compareWakeRequests = (left: StaggeredWakeRequest, right: StaggeredWakeRequest): number => {\n const priorityDiff = (right.priority ?? 0) - (left.priority ?? 0);\n if (priorityDiff !== 0) return priorityDiff;\n const requestedDiff = left.requestedAtMs - right.requestedAtMs;\n if (requestedDiff !== 0) return requestedDiff;\n return left.workloadId < right.workloadId ? -1 : left.workloadId > right.workloadId ? 1 : 0;\n};\n\nconst deduplicateRequests = (requests: readonly StaggeredWakeRequest[]): StaggeredWakeRequest[] => {\n const byWorkloadId = new Map<string, StaggeredWakeRequest>();\n for (const request of requests) {\n if (!request.workloadId) {\n throw new InfraError('invalid_request', 'StaggeredWakeRequest.workloadId must be non-empty');\n }\n if (!Number.isFinite(request.requestedAtMs)) {\n throw new InfraError(\n 'invalid_request',\n `requestedAtMs must be finite (got ${request.requestedAtMs})`,\n );\n }\n if (request.priority !== undefined && !Number.isFinite(request.priority)) {\n throw new InfraError('invalid_request', `priority must be finite (got ${request.priority})`);\n }\n\n const existing = byWorkloadId.get(request.workloadId);\n if (!existing || compareWakeRequests(request, existing) < 0) {\n byWorkloadId.set(request.workloadId, request);\n }\n }\n return [...byWorkloadId.values()];\n};\n\nexport const planStaggeredWakes = (\n requests: readonly StaggeredWakeRequest[],\n nowMs: number,\n options: StaggeredWakeOptions,\n): StaggeredWakePlan => {\n if (!Number.isFinite(nowMs)) {\n throw new InfraError('invalid_request', `nowMs must be finite (got ${nowMs})`);\n }\n if (!Number.isInteger(options.maxConcurrentWakes) || options.maxConcurrentWakes < 1) {\n throw new InfraError(\n 'invalid_request',\n `maxConcurrentWakes must be an integer >= 1 (got ${options.maxConcurrentWakes})`,\n );\n }\n if (!Number.isFinite(options.minSpacingMs) || options.minSpacingMs < 0) {\n throw new InfraError(\n 'invalid_request',\n `minSpacingMs must be a finite number >= 0 (got ${options.minSpacingMs})`,\n );\n }\n if (\n options.inFlightWakeCount !== undefined &&\n (!Number.isInteger(options.inFlightWakeCount) || options.inFlightWakeCount < 0)\n ) {\n throw new InfraError(\n 'invalid_request',\n `inFlightWakeCount must be an integer >= 0 (got ${options.inFlightWakeCount})`,\n );\n }\n if (\n options.lastWakeLaunchedAtMs !== undefined &&\n options.lastWakeLaunchedAtMs !== null &&\n !Number.isFinite(options.lastWakeLaunchedAtMs)\n ) {\n throw new InfraError(\n 'invalid_request',\n `lastWakeLaunchedAtMs must be finite or null (got ${options.lastWakeLaunchedAtMs})`,\n );\n }\n\n const sorted = deduplicateRequests(requests).sort(compareWakeRequests);\n const inFlight = options.inFlightWakeCount ?? 0;\n const availableSlots = Math.max(0, options.maxConcurrentWakes - inFlight);\n const launchNow: StaggeredWakeRequest[] = [];\n const defer: DeferredWake[] = [];\n\n const retryStepMs =\n options.minSpacingMs > 0 ? options.minSpacingMs : DEFAULT_CONCURRENCY_RETRY_FLOOR_MS;\n\n let nextEligibleAtMs =\n options.lastWakeLaunchedAtMs !== null && options.lastWakeLaunchedAtMs !== undefined\n ? Math.max(nowMs, options.lastWakeLaunchedAtMs + options.minSpacingMs)\n : nowMs;\n let scheduledWithinConcurrency = 0;\n\n for (const request of sorted) {\n if (scheduledWithinConcurrency >= availableSlots) {\n const earliestLaunchAtMs = Math.max(nextEligibleAtMs, nowMs + retryStepMs);\n defer.push({\n request,\n earliestLaunchAtMs,\n reason: 'concurrency_limit',\n });\n nextEligibleAtMs = earliestLaunchAtMs + retryStepMs;\n continue;\n }\n\n if (nextEligibleAtMs > nowMs) {\n defer.push({\n request,\n earliestLaunchAtMs: nextEligibleAtMs,\n reason: 'spacing_interval',\n });\n scheduledWithinConcurrency += 1;\n nextEligibleAtMs += options.minSpacingMs;\n continue;\n }\n\n launchNow.push(request);\n scheduledWithinConcurrency += 1;\n if (options.minSpacingMs > 0) {\n nextEligibleAtMs = nowMs + options.minSpacingMs;\n }\n }\n\n return { launchNow, defer };\n};\n"]}
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
package/dist/railway/index.cjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
'use strict';var http=require('http');var ue=new Set(["unreachable","rate_limited","provider_unavailable"]),d=class extends Error{code;status;provider;retryable;constructor(r,n,t){let a=t?.provider?`[${t.provider}] `:"";super(n?`${a}${n}`:`${a}Infrastructure request failed (${r})`,{cause:t?.cause}),this.name="InfraError",this.code=r,this.status=t?.status,this.provider=t?.provider,this.retryable=t?.retryable??ue.has(r);}},U=(e,r)=>{let n=e===401||e===403?"authentication_failed":e===404?"not_found":e===409?"conflict":e===429?"rate_limited":e===400||e===422?"invalid_request":"provider_unavailable",t=r?.message?`HTTP ${e}: ${r.message}`:`HTTP ${e} (${n})`;return new d(n,t,{status:e,provider:r?.provider})},ye=(e,r)=>e instanceof d&&(e.code===r),p=(e,r,n)=>{if(!e?.trim())throw new d("invalid_request",`Missing required ${r}`,{provider:n});return e},N=e=>{if(!ye(e,"not_found"))throw e},K=(e,r)=>{if(e&&e.length>0)throw new d("invalid_request","Egress allowlist is not enforced by this driver",{provider:r})};var x="ghcr.io/inixiative/archive",q=4700,$="archive",z=e=>{if(!e.archiveToken)throw new d("authentication_failed","Archive server token is required");return e.archiveToken};var me=3e4,Y=500,Q=e=>e.replace(/\/+$/,""),I=e=>{try{let r=new URL(e);return `${r.protocol}//${r.host}${r.pathname}`}catch{return e.split("?")[0]?.split("#")[0]??e}},ge=(e,r)=>{let n=e.replace(/Bearer\s+[A-Za-z0-9._~+/-]+=*/gi,"Bearer [REDACTED]");return r&&r.length>0&&(n=n.split(r).join("[REDACTED]")),n},J=(e,r)=>{let n=ge(e.trim(),r);if(n)return n.length>Y?`${n.slice(0,Y)}...`:n},Z=(e,r)=>{if(e===void 0)return me;if(!Number.isFinite(e)||e<=0)throw new d("invalid_request",`timeoutMs must be a finite positive number (got ${e})`,{provider:r});return e},X=(e,r,n)=>{if(!(r===204||!e.trim()))try{return JSON.parse(e)}catch(t){throw new d("provider_unavailable","Provider returned malformed JSON",{status:r,provider:n,cause:t})}},ve=async(e,r,n)=>{let t=Z(n.timeoutMs,n.provider),a;try{a=new URL(e);}catch(s){throw new d("invalid_request",`Invalid request URL: ${I(e)}`,{provider:n.provider,cause:s})}let i=`${a.pathname}${a.search}`,o=await new Promise((s,u)=>{let c=false,y,_=m=>{c||(c=true,y!==void 0&&clearTimeout(y),s(m));},C=m=>{c||(c=true,y!==void 0&&clearTimeout(y),u(m));},R=http.request({socketPath:r,method:n.method,path:i,headers:{...n.headers,...n.serializedBody!==void 0?{"Content-Length":String(Buffer.byteLength(n.serializedBody))}:{}},timeout:t},m=>{let F=[];m.on("data",k=>{F.push(typeof k=="string"?Buffer.from(k):k);}),m.on("end",()=>{_({status:m.statusCode??0,body:Buffer.concat(F).toString("utf8")});}),m.on("close",()=>{m.complete||C(new d("unreachable",`Unix socket response closed prematurely for ${I(e)}`,{provider:n.provider}));}),m.on("error",k=>{C(new d("unreachable",`Unix socket response failed for ${I(e)}`,{provider:n.provider,cause:k}));});});y=setTimeout(()=>{let m=new Error(`Unix socket request exceeded deadline of ${t}ms`);R.destroy(m),C(new d("unreachable",`Unix socket request timed out for ${I(e)}`,{provider:n.provider,cause:m}));},t),R.on("timeout",()=>{R.destroy(new Error(`Unix socket request timed out after ${t}ms`));}),R.on("error",m=>{C(new d("unreachable",`Unix socket request failed for ${I(e)}`,{provider:n.provider,cause:m}));}),n.serializedBody!==void 0&&R.write(n.serializedBody),R.end();});if(o.status>=300&&o.status<400)throw new d("unreachable",`Unexpected redirect (${o.status}) from ${I(e)}`,{status:o.status,provider:n.provider});if(o.status<200||o.status>=300)throw U(o.status,{provider:n.provider,message:J(o.body,n.token)});return X(o.body,o.status,n.provider)},ee=async(e,r={})=>{let n=Z(r.timeoutMs,r.provider),t=r.method??"GET",a=r.body!==void 0?JSON.stringify(r.body):void 0,i={Accept:"application/json",...r.token?{Authorization:`Bearer ${r.token}`}:{},...a!==void 0?{"Content-Type":"application/json"}:{},...r.headers};if(r.unixSocketPath&&typeof Bun>"u")return ve(e,r.unixSocketPath,{method:t,headers:i,serializedBody:a,timeoutMs:n,token:r.token,provider:r.provider});let o={method:t,redirect:"error",signal:AbortSignal.timeout(n),headers:i,...a!==void 0?{body:a}:{},...r.unixSocketPath?{unix:r.unixSocketPath}:{}},s;try{s=await fetch(e,o);}catch(c){throw new d("unreachable",`Request to ${I(e)} failed`,{provider:r.provider,cause:c})}if(!s.ok){let c=await s.text().catch(()=>"");throw U(s.status,{provider:r.provider,message:J(c,r.token)})}if(s.status===204)return;let u=await s.text().catch(c=>{throw new d("unreachable","Failed to read response body",{status:s.status,provider:r.provider,cause:c})});return X(u,s.status,r.provider)};var re="https://backboard.railway.com/graphql/v2",we=e=>{if(typeof e=="string")switch(e.toUpperCase()){case "UNAUTHENTICATED":case "FORBIDDEN":case "UNAUTHORIZED":return "authentication_failed";case "NOT_FOUND":return "not_found";case "CONFLICT":return "conflict";case "TOO_MANY_REQUESTS":case "RATE_LIMITED":return "rate_limited";case "BAD_USER_INPUT":case "GRAPHQL_VALIDATION_FAILED":return "invalid_request";default:return}},Ie=e=>{let r=e.toLowerCase();return r.includes("not authorized")||r.includes("unauthorized")?"authentication_failed":r.includes("rate limit")||r.includes("too quickly")?"rate_limited":r.includes("not found")?"not_found":r.includes("already exists")||r.includes("conflict")?"conflict":r.includes("bad user input")||r.includes("invalid")?"invalid_request":"provider_unavailable"},l=async(e,r,n={},t=re)=>{let a=await ee(Q(t),{method:"POST",token:e,body:{query:r,variables:n},provider:"railway"});if(Array.isArray(a?.errors)&&a.errors.length>0){let i=a.errors.map(y=>typeof y?.message=="string"?y.message.trim():"").filter(y=>y.length>0),o=i.length>0?i.join("; "):"Railway GraphQL error",s=a.errors.map(y=>we(y?.extensions?.code)).find(y=>y!==void 0),u=Ie(o),c=u==="rate_limited"||u==="authentication_failed"?u:s??u;throw new d(c,o,{provider:"railway"})}if(!a?.data||typeof a.data!="object")throw new d("provider_unavailable","Railway GraphQL response omitted data",{provider:"railway"});return a.data};var T=e=>e?.edges.map(r=>r.node)??[],v=(e,r)=>{if(e==null)throw new d("not_found",`Railway ${r} not found`,{provider:"railway"});return e},P=async e=>{let r=[],n=new Set,t=null;do{let a=await e(t);r.push(...T(a));let i=a.pageInfo?.hasNextPage?a.pageInfo.endCursor??null:null;if(i!==null){if(n.has(i))throw new d("provider_unavailable","Railway pagination cursor repeated",{provider:"railway"});n.add(i);}t=i;}while(t!==null);return r},H=async(e,r)=>{let{apiToken:n}=await l(e,"query { apiToken { workspaces { id name } } }",{},r);if(!Array.isArray(n?.workspaces))throw new d("provider_unavailable","Railway apiToken response omitted workspaces",{provider:"railway"});return n.workspaces.map(({id:t,name:a})=>({id:t,name:a}))},W=async(e,r,n,t)=>{let a=new Set,i=null;do{let o=await l(e,"query($workspaceId: String, $after: String) { projects(workspaceId: $workspaceId, first: 100, after: $after) { edges { node { id name environments { edges { node { id name } } } } } pageInfo { hasNextPage endCursor } } }",{workspaceId:r,after:i},t),{projects:s}=o,u=T(s).find(y=>y.name===n);if(u)return {id:u.id,name:u.name,environments:T(u.environments)};let c=s.pageInfo?.hasNextPage?s.pageInfo.endCursor??null:null;if(c!==null){if(a.has(c))throw new d("provider_unavailable","Railway projects pagination cursor repeated",{provider:"railway"});a.add(c);}i=c;}while(i!==null)},ne=async(e,r,n,t="production",a)=>{let{projectCreate:i}=await l(e,"mutation($input: ProjectCreateInput!) { projectCreate(input: $input) { id name environments { edges { node { id name } } } } }",{input:{name:n,workspaceId:r,defaultEnvironmentName:t}},a);return {id:i.id,name:i.name,environments:T(i.environments)}},te=async(e,r,n)=>P(async t=>{let{project:a}=await l(e,"query($id: String!, $after: String) { project(id: $id) { environments(first: 100, after: $after) { edges { node { id name } } pageInfo { hasNextPage endCursor } } } }",{id:r,after:t},n);return v(a,`project ${r}`).environments}),b=async(e,r,n,t,a)=>{if(t?.projectId&&t?.environmentId)return {projectId:t.projectId,environmentId:t.environmentId};if(t?.projectId){let s=await te(e,t.projectId,a),u=s.find(c=>c.name==="production")??s[0];return {projectId:t.projectId,environmentId:p(u?.id,"Railway environmentId","railway")}}let i=await W(e,r,n,a)??await ne(e,r,n,"production",a),o=i.environments.find(s=>s.name==="production")??i.environments[0];return {projectId:i.id,environmentId:p(o?.id,"Railway environmentId","railway")}},fe=async(e,r,n,t)=>{let{environmentRename:a}=await l(e,"mutation($id: String!, $name: String!) { environmentRename(id: $id, input: { name: $name }) }",{id:r,name:n},t);return a},h=async(e,r,n,t,a)=>{let o=(await P(async u=>{let{project:c}=await l(e,"query($id: String!, $after: String) { project(id: $id) { services(first: 100, after: $after) { edges { node { id name } } pageInfo { hasNextPage endCursor } } } }",{id:r,after:u},a);return v(c,`project ${r}`).services})).find(u=>u.name===t);if(o)return o.id;let{serviceCreate:s}=await l(e,"mutation($input: ServiceCreateInput!) { serviceCreate(input: $input) { id } }",{input:{projectId:r,environmentId:n,name:t}},a);return s.id},Re=async(e,r,n,t)=>{let{serviceUpdate:a}=await l(e,"mutation($id: String!, $input: ServiceUpdateInput!) { serviceUpdate(id: $id, input: $input) { id name } }",{id:r,input:{name:n}},t);return a},w=async(e,r,n,t,a)=>{let{serviceInstanceUpdate:i}=await l(e,"mutation($serviceId: String!, $environmentId: String, $input: ServiceInstanceUpdateInput!) { serviceInstanceUpdate(serviceId: $serviceId, environmentId: $environmentId, input: $input) }",{serviceId:r,environmentId:n,input:t},a);if(i===false)throw new d("provider_unavailable",`Failed to update Railway service instance ${r}`,{provider:"railway"})},he=async(e,r,n,t)=>{let{serviceInstance:a}=await l(e,"query($serviceId: String!, $environmentId: String!) { serviceInstance(serviceId: $serviceId, environmentId: $environmentId) { id source { repo } } }",{serviceId:r,environmentId:n},t);return !!v(a,`serviceInstance ${r}`).source?.repo},Se=async(e,r,n,t,a="main",i)=>{await w(e,r,n,{source:{repo:t}},i);let{service:o}=await l(e,"query($id: String!) { service(id: $id) { projectId } }",{id:r},i),s=v(o,`service ${r}`).projectId;(await P(async y=>{let{deploymentTriggers:_}=await l(e,"query($projectId: String!, $serviceId: String!, $environmentId: String!, $after: String) { deploymentTriggers(projectId: $projectId, serviceId: $serviceId, environmentId: $environmentId, first: 100, after: $after) { edges { node { id branch repository } } pageInfo { hasNextPage endCursor } } }",{projectId:s,serviceId:r,environmentId:n,after:y},i);return _})).some(y=>y.repository===t&&y.branch===a)||await l(e,"mutation($input: DeploymentTriggerCreateInput!) { deploymentTriggerCreate(input: $input) { id } }",{input:{projectId:s,environmentId:n,serviceId:r,provider:"github",repository:t,branch:a,checkSuites:false}},i);},ke=async(e,r,n)=>P(async t=>{let{project:a}=await l(e,"query($id: String!, $after: String) { project(id: $id) { volumes(first: 100, after: $after) { edges { node { id name } } pageInfo { hasNextPage endCursor } } } }",{id:r,after:t},n);return v(a,`project ${r}`).volumes}),E=async(e,r,n,t,a,i)=>{(await P(async s=>{let{environment:u}=await l(e,"query($id: String!, $projectId: String, $after: String) { environment(id: $id, projectId: $projectId) { volumeInstances(first: 100, after: $after) { edges { node { serviceId mountPath } } pageInfo { hasNextPage endCursor } } } }",{id:n,projectId:r,after:s},i);return v(u,`environment ${n}`).volumeInstances})).some(s=>s.serviceId===t&&s.mountPath===a)||await l(e,"mutation($input: VolumeCreateInput!) { volumeCreate(input: $input) { id } }",{input:{projectId:r,environmentId:n,serviceId:t,mountPath:a}},i);},$e=async(e,r,n,t)=>{let{volumeUpdate:a}=await l(e,"mutation($volumeId: String!, $input: VolumeUpdateInput!) { volumeUpdate(volumeId: $volumeId, input: $input) { id name } }",{volumeId:r,input:{name:n}},t);return a},O=async(e,r,n,t,a)=>{let{variables:i}=await l(e,"query($projectId: String!, $environmentId: String!, $serviceId: String) { variables(projectId: $projectId, environmentId: $environmentId, serviceId: $serviceId, unrendered: true) }",{projectId:r,environmentId:n,serviceId:t},a);return i},S=async(e,r,n,t,a,i={},o)=>{await l(e,"mutation($input: VariableCollectionUpsertInput!) { variableCollectionUpsert(input: $input) }",{input:{projectId:r,environmentId:n,serviceId:t,variables:a,skipDeploys:i.skipDeploys??true}},o);},g=async(e,r,n,t)=>{let{serviceInstance:a}=await l(e,"query($serviceId: String!, $environmentId: String!) { serviceInstance(serviceId: $serviceId, environmentId: $environmentId) { latestDeployment { id status } domains { serviceDomains { domain } } source { repo } } }",{serviceId:r,environmentId:n},t),i=v(a,`serviceInstance ${r}`);return {latestDeployment:i.latestDeployment,domains:i.domains.serviceDomains.map(o=>o.domain),sourceRepo:i.source?.repo}},f=async(e,r,n,t={},a)=>{let i=t.commitSha?"mutation($serviceId: String!, $environmentId: String!, $commitSha: String) { serviceInstanceDeployV2(serviceId: $serviceId, environmentId: $environmentId, commitSha: $commitSha) }":"mutation($serviceId: String!, $environmentId: String!) { serviceInstanceDeployV2(serviceId: $serviceId, environmentId: $environmentId) }",o=t.commitSha?{serviceId:r,environmentId:n,commitSha:t.commitSha}:{serviceId:r,environmentId:n},{serviceInstanceDeployV2:s}=await l(e,i,o,a);return p(s,"Railway deploymentId","railway")},Pe=async(e,r,n,t={},a)=>{let{serviceInstanceDeploy:i}=await l(e,"mutation($serviceId: String!, $environmentId: String!, $latestCommit: Boolean!) { serviceInstanceDeploy(serviceId: $serviceId, environmentId: $environmentId, latestCommit: $latestCommit) }",{serviceId:r,environmentId:n,latestCommit:t.latestCommit??true},a);if(!i)throw new d("provider_unavailable",`Failed to deploy latest commit for Railway service ${r}`,{provider:"railway"})},V=async(e,r,n)=>{let{deployment:t}=await l(e,"query($id: String!) { deployment(id: $id) { status } }",{id:r},n);return v(t,`deployment ${r}`).status},B=async(e,r,n)=>{let{deploymentStop:t}=await l(e,"mutation($id: String!) { deploymentStop(id: $id) }",{id:r},n);return t},D=async(e,r,n,t,a)=>{let o=(await g(e,r,n,a)).domains[0];if(o)return o;let{serviceDomainCreate:s}=await l(e,"mutation($input: ServiceDomainCreateInput!) { serviceDomainCreate(input: $input) { domain } }",{input:{serviceId:r,environmentId:n,...t!==void 0?{targetPort:t}:{}}},a);return s.domain},ae=async(e,r,n)=>{let{project:t}=await l(e,"query($id: String!) { project(id: $id) { buckets { id name } } }",{id:r},n);return v(t,`project ${r}`).buckets??[]},ie=async(e,r,n,t)=>{let{bucketCreate:a}=await l(e,"mutation($input: BucketCreateInput!) { bucketCreate(input: $input) { id name } }",{input:{projectId:r,name:n}},t);return {id:a.id,name:a.name}},be=async(e,r,n,t)=>{let a=(await ae(e,r,t)).find(i=>i.name===n);return a||ie(e,r,n,t)},Ee=async(e,r,n,t,a)=>{let{bucketS3Credentials:i}=await l(e,"query($bucketId: String!, $environmentId: String!, $projectId: String!) { bucketS3Credentials(bucketId: $bucketId, environmentId: $environmentId, projectId: $projectId) { accessKeyId bucketName endpoint region secretAccessKey urlStyle } }",{bucketId:r,environmentId:n,projectId:t},a);if(!i?.bucketName||!i?.accessKeyId)throw new d("provider_unavailable","Railway bucket credentials are not ready yet",{provider:"railway"});return {bucket:i.bucketName,accessKeyId:i.accessKeyId,secretAccessKey:i.secretAccessKey,region:i.region,endpoint:i.endpoint,urlStyle:i.urlStyle}},L=async(e,r,n)=>{await l(e,"mutation($id: String!) { serviceDelete(id: $id) }",{id:r},n).catch(N);},G=async(e,r,n)=>{await l(e,"mutation($id: String!) { projectScheduleDelete(id: $id) }",{id:r},n).catch(N);};var j="archive-postgres",le="archive",De="pgvector/pgvector:pg17",oe="/var/lib/postgresql/data",se=new Set(["SUCCESS","SLEEPING"]),Ae=new Set(["FAILED","CRASHED","REMOVED","SKIPPED"]),Ce=()=>{let e=crypto.getRandomValues(new Uint8Array(32));return Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")},de=async(e,r,n)=>{let t=await g(e.token,n,r,e.apiUrl);return t.latestDeployment||await f(e.token,n,r,{},e.apiUrl),t},xe={provider:"railway",fetchWorkspaces:H,provisionDatabase:async e=>{let{projectId:r,environmentId:n}=await b(e.token,e.workspaceId,e.name,e.ids,e.apiUrl),t=e.ids.databaseServiceId??await h(e.token,r,n,j,e.apiUrl);return await E(e.token,r,n,t,oe,e.apiUrl),(await O(e.token,r,n,t,e.apiUrl)).POSTGRES_PASSWORD||await S(e.token,r,n,t,{POSTGRES_USER:$,POSTGRES_DB:$,POSTGRES_PASSWORD:Ce(),PGDATA:`${oe}/pgdata`},{skipDeploys:true},e.apiUrl),await w(e.token,t,n,{source:{image:De}},e.apiUrl),await de(e,n,t),{projectId:r,environmentId:n,databaseServiceId:t}},fetchDatabaseReadiness:async e=>{let n=(await g(e.token,p(e.ids.databaseServiceId,"archive databaseServiceId","railway"),p(e.ids.environmentId,"archive environmentId","railway"),e.apiUrl)).latestDeployment?.status;if(n==="FAILED"||n==="CRASHED")throw new d("deploy_failed",`Railway database deployment ${n}`,{provider:"railway"});return n==="SUCCESS"},provisionService:async e=>{let r=p(e.ids.projectId,"archive projectId","railway"),n=p(e.ids.environmentId,"archive environmentId","railway"),t=e.ids.serviceId??await h(e.token,r,n,le,e.apiUrl);await S(e.token,r,n,t,{ARCHIVE_SERVER_TOKEN:z(e),PORT:String(q),DATABASE_URL:`postgresql://${$}:\${{${j}.POSTGRES_PASSWORD}}@\${{${j}.RAILWAY_PRIVATE_DOMAIN}}:5432/${$}`},{skipDeploys:true},e.apiUrl),await w(e.token,t,n,{source:{image:`${x}:${e.imageVersion}`},healthcheckPath:"/health"},e.apiUrl);let a=await de(e,n,t),i=a.domains[0]??await D(e.token,t,n,q,e.apiUrl);if(a.latestDeployment?.status==="FAILED"||a.latestDeployment?.status==="CRASHED")throw new d("deploy_failed","Railway archive service deployment failed",{provider:"railway"});return {ids:{...e.ids,serviceId:t},url:`https://${i}`}},fetchServiceReadiness:async e=>{let n=(await g(e.token,p(e.ids.serviceId,"archive serviceId","railway"),p(e.ids.environmentId,"archive environmentId","railway"),e.apiUrl)).latestDeployment?.status;if(n==="FAILED"||n==="CRASHED")throw new d("deploy_failed",`Railway archive service deployment ${n}`,{provider:"railway"});return !!(n&&se.has(n))},fetchServiceFailureStatus:async e=>{let n=(await g(e.token,p(e.ids.serviceId,"archive serviceId","railway"),p(e.ids.environmentId,"archive environmentId","railway"),e.apiUrl)).latestDeployment?.status;return n==="FAILED"||n==="CRASHED"},deployImage:async e=>{let r=p(e.ids.environmentId,"archive environmentId","railway"),n=p(e.ids.serviceId,"archive serviceId","railway");await w(e.token,n,r,{source:{image:`${x}:${e.imageVersion}`}},e.apiUrl);let t=await f(e.token,n,r,{},e.apiUrl);return {...e.ids,deploymentId:t}},restoreImage:async e=>{await w(e.token,p(e.ids.serviceId,"archive serviceId","railway"),p(e.ids.environmentId,"archive environmentId","railway"),{source:{image:`${x}:${e.imageVersion}`}},e.apiUrl);},fetchImageDeployStatus:async e=>{let r=await V(e.token,p(e.ids.deploymentId,"archive deploymentId","railway"),e.apiUrl);return se.has(r)?"live":Ae.has(r)?"failed":"deploying"},destroyService:async e=>{let r=e.ids.projectId??(await W(e.token,e.workspaceId,e.name,e.apiUrl))?.id;r&&await G(e.token,r,e.apiUrl);}};var A=e=>{if(!e.token)throw new d("authentication_failed","Railway API token is required",{provider:"railway"});return e.token},M=(e,r)=>p(r.environmentId??e.environmentId,"Railway environmentId","railway"),Te=e=>{switch(e){case "SUCCESS":return "running";case "SLEEPING":return "suspended";case "BUILDING":case "DEPLOYING":case "INITIALIZING":case "WAITING":return "starting";case "REMOVING":return "stopping";case "REMOVED":case "STOPPED":case void 0:return "stopped";case "FAILED":case "CRASHED":return "failed";default:return "unknown"}},ce={provider:"railway",provisionWorkload:async(e,r)=>{let n=A(e);K(r.egressAllowlist,"railway");let t=e.projectId,a=e.environmentId;if(!t||!a){if(!t&&!e.workspaceId)throw new d("invalid_request","Railway workload provisioning requires either (projectId + environmentId), projectId, or workspaceId",{provider:"railway"});let c=await b(n,e.workspaceId??"",r.name,{projectId:t,environmentId:a},e.apiUrl);t=c.projectId,a=c.environmentId;}let i=await h(n,t,a,r.name,e.apiUrl);r.volume&&await E(n,t,a,i,r.volume.mountPath,e.apiUrl);let o={...r.env??{},...r.port?{PORT:String(r.port.internalPort)}:{}};Object.keys(o).length>0&&await S(n,t,a,i,o,{skipDeploys:true},e.apiUrl),await w(n,i,a,{source:{image:r.image},...r.healthcheckPath?{healthcheckPath:r.healthcheckPath}:{}},e.apiUrl);let s=await f(n,i,a,{},e.apiUrl),u;return r.port?.publicHttps&&(u=`https://${await D(n,i,a,r.port.internalPort,e.apiUrl)}`),{provider:"railway",workloadId:i,name:r.name,url:u,memoryMb:r.memoryMb,vcpus:r.vcpus,projectId:t,environmentId:a,metadata:{deploymentId:s}}},suspendWorkload:async(e,r)=>{let n=A(e),t=M(e,r),i=(await g(n,r.workloadId,t,e.apiUrl)).latestDeployment?.id??r.metadata?.deploymentId;return i&&await B(n,i,e.apiUrl),{...r,environmentId:t,metadata:i?{...r.metadata,deploymentId:i}:r.metadata}},wakeWorkload:async(e,r)=>{let n=A(e),t=M(e,r),a=await f(n,r.workloadId,t,{},e.apiUrl);return {...r,environmentId:t,metadata:{...r.metadata,deploymentId:a}}},fetchWorkloadStatus:async(e,r)=>{let n=A(e),t=M(e,r),a=await g(n,r.workloadId,t,e.apiUrl),i=a.latestDeployment?.status??"STOPPED",o=a.domains[0];return {provider:"railway",workloadId:r.workloadId,state:Te(a.latestDeployment?.status),providerState:i,region:r.region,url:o?`https://${o}`:r.url,memoryMb:r.memoryMb,vcpus:r.vcpus,updatedAt:new Date().toISOString()}},fetchWorkloadUsage:async(e,r)=>{await ce.fetchWorkloadStatus(e,r);let n=new Date().toISOString();return {provider:"railway",workloadId:r.workloadId,memoryMb:r.memoryMb??0,vcpus:r.vcpus??0,activeSeconds:0,suspendedSeconds:0,rootfsGb:0,metered:false,windowStartIso:n,windowEndIso:n}},destroyWorkload:async(e,r)=>{let n=A(e);await L(n,r.workloadId,e.apiUrl);}};
|
|
2
|
-
exports.RAILWAY_API_URL=re;exports.RAILWAY_ARCHIVE_SERVICE=le;exports.RAILWAY_DATABASE_SERVICE=j;exports.connectRailwayServiceToGitHub=Se;exports.createRailwayBucket=ie;exports.createRailwayProject=ne;exports.deleteRailwayService=L;exports.deployRailwayServiceInstance=f;exports.deployRailwayServiceLatestCommit=Pe;exports.ensureRailwayBucket=be;exports.ensureRailwayProject=b;exports.ensureRailwayService=h;exports.ensureRailwayServiceDomain=D;exports.ensureRailwayVolume=E;exports.fetchRailwayBucketCredentials=Ee;exports.fetchRailwayDeploymentStatus=V;exports.fetchRailwayProjectBuckets=ae;exports.fetchRailwayProjectByName=W;exports.fetchRailwayProjectEnvironments=te;exports.fetchRailwayProjectVolumes=ke;exports.fetchRailwayServiceGitHubConnectionStatus=he;exports.fetchRailwayServiceInstance=g;exports.fetchRailwayServiceVariables=O;exports.fetchRailwayWorkspaces=H;exports.railwayArchiveDriver=xe;exports.railwayWorkloadDriver=ce;exports.renameRailwayEnvironment=fe;exports.renameRailwayService=Re;exports.renameRailwayVolume=$e;exports.scheduleRailwayProjectDelete=G;exports.sendRailwayGraphql=l;exports.stopRailwayDeployment=B;exports.updateRailwayServiceInstance=w;exports.upsertRailwayServiceVariables=S;//# sourceMappingURL=index.cjs.map
|
|
1
|
+
'use strict';var chunkXGIX6QNV_cjs=require('../chunk-XGIX6QNV.cjs');require('../chunk-U5EA4FJI.cjs'),require('../chunk-OHRGTWGZ.cjs'),require('../chunk-QREJ73ZG.cjs');Object.defineProperty(exports,"RAILWAY_API_URL",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.a}});Object.defineProperty(exports,"RAILWAY_ARCHIVE_SERVICE",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.F}});Object.defineProperty(exports,"RAILWAY_DATABASE_SERVICE",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.E}});Object.defineProperty(exports,"connectRailwayServiceToGitHub",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.m}});Object.defineProperty(exports,"createRailwayBucket",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.z}});Object.defineProperty(exports,"createRailwayProject",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.e}});Object.defineProperty(exports,"deleteRailwayService",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.C}});Object.defineProperty(exports,"deployRailwayServiceInstance",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.t}});Object.defineProperty(exports,"deployRailwayServiceLatestCommit",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.u}});Object.defineProperty(exports,"ensureRailwayBucket",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.A}});Object.defineProperty(exports,"ensureRailwayProject",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.g}});Object.defineProperty(exports,"ensureRailwayService",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.i}});Object.defineProperty(exports,"ensureRailwayServiceDomain",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.x}});Object.defineProperty(exports,"ensureRailwayVolume",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.o}});Object.defineProperty(exports,"fetchRailwayBucketCredentials",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.B}});Object.defineProperty(exports,"fetchRailwayDeploymentStatus",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.v}});Object.defineProperty(exports,"fetchRailwayProjectBuckets",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.y}});Object.defineProperty(exports,"fetchRailwayProjectByName",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.d}});Object.defineProperty(exports,"fetchRailwayProjectEnvironments",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.f}});Object.defineProperty(exports,"fetchRailwayProjectVolumes",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.n}});Object.defineProperty(exports,"fetchRailwayServiceGitHubConnectionStatus",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.l}});Object.defineProperty(exports,"fetchRailwayServiceInstance",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.s}});Object.defineProperty(exports,"fetchRailwayServiceVariables",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.q}});Object.defineProperty(exports,"fetchRailwayWorkspaces",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.c}});Object.defineProperty(exports,"railwayArchiveDriver",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.G}});Object.defineProperty(exports,"railwayWorkloadDriver",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.H}});Object.defineProperty(exports,"renameRailwayEnvironment",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.h}});Object.defineProperty(exports,"renameRailwayService",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.j}});Object.defineProperty(exports,"renameRailwayVolume",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.p}});Object.defineProperty(exports,"scheduleRailwayProjectDelete",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.D}});Object.defineProperty(exports,"sendRailwayGraphql",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.b}});Object.defineProperty(exports,"stopRailwayDeployment",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.w}});Object.defineProperty(exports,"updateRailwayServiceInstance",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.k}});Object.defineProperty(exports,"upsertRailwayServiceVariables",{enumerable:true,get:function(){return chunkXGIX6QNV_cjs.r}});//# sourceMappingURL=index.cjs.map
|
|
3
2
|
//# sourceMappingURL=index.cjs.map
|