@alienplatform/core 3.3.11 → 3.3.13

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/index.js CHANGED
@@ -85,6 +85,112 @@ const AgentStatusSchema = z$2.object({
85
85
  }
86
86
  }).describe("Status of a single agent in the dev server");
87
87
  //#endregion
88
+ //#region src/generated/zod/ai-access-test-schema.ts
89
+ /**
90
+ * Generated by Kubb (https://kubb.dev/).
91
+ * Do not edit manually.
92
+ */
93
+ const AiAccessTestSchema = z$2.enum([
94
+ "verified",
95
+ "failed",
96
+ "not-checked"
97
+ ]);
98
+ //#endregion
99
+ //#region src/generated/zod/ai-availability-blocker-schema.ts
100
+ /**
101
+ * Generated by Kubb (https://kubb.dev/).
102
+ * Do not edit manually.
103
+ */
104
+ const AiAvailabilityBlockerSchema = z$2.enum([
105
+ "agreement-required",
106
+ "entitlement-required",
107
+ "model-activation-required",
108
+ "deployment-required",
109
+ "quota-configuration-required",
110
+ "region-unavailable",
111
+ "access-denied",
112
+ "observation-failed"
113
+ ]);
114
+ //#endregion
115
+ //#region src/generated/zod/ai-availability-source-schema.ts
116
+ /**
117
+ * Generated by Kubb (https://kubb.dev/).
118
+ * Do not edit manually.
119
+ */
120
+ /**
121
+ * @description Provider control plane used to observe model availability without invoking\na model, spending customer quota, or accepting provider terms.
122
+ */
123
+ const AiAvailabilitySourceSchema = z$2.enum([
124
+ "aws-bedrock",
125
+ "gcp-vertex",
126
+ "azure-foundry",
127
+ "anthropic"
128
+ ]).describe("Provider control plane used to observe model availability without invoking\na model, spending customer quota, or accepting provider terms.");
129
+ //#endregion
130
+ //#region src/generated/zod/ai-model-availability-schema.ts
131
+ /**
132
+ * Generated by Kubb (https://kubb.dev/).
133
+ * Do not edit manually.
134
+ */
135
+ const AiModelAvailabilitySchema = z$2.enum([
136
+ "available",
137
+ "blocked",
138
+ "unknown"
139
+ ]);
140
+ //#endregion
141
+ //#region src/generated/zod/client-api-schema.ts
142
+ /**
143
+ * Generated by Kubb (https://kubb.dev/).
144
+ * Do not edit manually.
145
+ */
146
+ /**
147
+ * @description A public API accepted from an application client.
148
+ */
149
+ const ClientApiSchema = z$2.enum([
150
+ "open-ai-chat-completions",
151
+ "open-ai-responses",
152
+ "anthropic-messages"
153
+ ]).describe("A public API accepted from an application client.");
154
+ //#endregion
155
+ //#region src/generated/zod/ai-model-availability-observation-schema.ts
156
+ /**
157
+ * Generated by Kubb (https://kubb.dev/).
158
+ * Do not edit manually.
159
+ */
160
+ const AiModelAvailabilityObservationSchema = z$2.object({
161
+ get "accessTest"() {
162
+ return AiAccessTestSchema;
163
+ },
164
+ get "availability"() {
165
+ return AiModelAvailabilitySchema;
166
+ },
167
+ get "blockers"() {
168
+ return z$2.array(AiAvailabilityBlockerSchema);
169
+ },
170
+ get "clientApis"() {
171
+ return z$2.array(ClientApiSchema.describe("A public API accepted from an application client."));
172
+ },
173
+ "errorCode": z$2.string().nullish(),
174
+ "publicModelId": z$2.string(),
175
+ "testedAt": z$2.iso.datetime().nullish()
176
+ });
177
+ //#endregion
178
+ //#region src/generated/zod/ai-availability-observation-schema.ts
179
+ /**
180
+ * Generated by Kubb (https://kubb.dev/).
181
+ * Do not edit manually.
182
+ */
183
+ const AiAvailabilityObservationSchema = z$2.object({
184
+ "catalogRevision": z$2.string(),
185
+ "location": z$2.string().nullish(),
186
+ get "models"() {
187
+ return z$2.array(AiModelAvailabilityObservationSchema);
188
+ },
189
+ get "source"() {
190
+ return AiAvailabilitySourceSchema.describe("Provider control plane used to observe model availability without invoking\na model, spending customer quota, or accepting provider terms.");
191
+ }
192
+ });
193
+ //#endregion
88
194
  //#region src/generated/zod/heartbeat-collection-issue-reason-schema.ts
89
195
  /**
90
196
  * Generated by Kubb (https://kubb.dev/).
@@ -181,6 +287,9 @@ const AiHeartbeatStatusSchema = z$2.object({
181
287
  * Do not edit manually.
182
288
  */
183
289
  const AwsBedrockAiHeartbeatDataSchema = z$2.object({
290
+ get "availability"() {
291
+ return AiAvailabilityObservationSchema;
292
+ },
184
293
  "region": z$2.string(),
185
294
  get "status"() {
186
295
  return AiHeartbeatStatusSchema;
@@ -194,6 +303,9 @@ const AwsBedrockAiHeartbeatDataSchema = z$2.object({
194
303
  */
195
304
  const AzureFoundryAiHeartbeatDataSchema = z$2.object({
196
305
  "accountName": z$2.string(),
306
+ get "availability"() {
307
+ return AiAvailabilityObservationSchema;
308
+ },
197
309
  "endpoint": z$2.string().nullish(),
198
310
  "location": z$2.string().nullish(),
199
311
  "resourceGroup": z$2.string().nullish(),
@@ -208,6 +320,9 @@ const AzureFoundryAiHeartbeatDataSchema = z$2.object({
208
320
  * Do not edit manually.
209
321
  */
210
322
  const ExternalAiHeartbeatDataSchema = z$2.object({
323
+ get "availability"() {
324
+ return z$2.union([AiAvailabilityObservationSchema, z$2.null()]).optional();
325
+ },
211
326
  "provider": z$2.string().describe("The BYO-key provider serving this binding (e.g. \"openai\"). Used on the Local\nplatform, where the app brings its own provider key instead of an ambient cloud."),
212
327
  get "status"() {
213
328
  return AiHeartbeatStatusSchema;
@@ -220,6 +335,9 @@ const ExternalAiHeartbeatDataSchema = z$2.object({
220
335
  * Do not edit manually.
221
336
  */
222
337
  const GcpVertexAiHeartbeatDataSchema = z$2.object({
338
+ get "availability"() {
339
+ return AiAvailabilityObservationSchema;
340
+ },
223
341
  "location": z$2.string(),
224
342
  "project": z$2.string(),
225
343
  get "status"() {
@@ -1410,6 +1528,38 @@ const AwsIamRoleServiceAccountHeartbeatDataSchema = z$2.object({
1410
1528
  },
1411
1529
  "tagCount": z$2.int().min(0)
1412
1530
  });
1531
+ z$2.object({ "keyArn": z$2.string().describe("Immutable KMS key ARN. Alias ARNs are not accepted.") }).describe("AWS KMS key created by the customer-installed setup stack.");
1532
+ //#endregion
1533
+ //#region src/generated/zod/key-heartbeat-status-schema.ts
1534
+ /**
1535
+ * Generated by Kubb (https://kubb.dev/).
1536
+ * Do not edit manually.
1537
+ */
1538
+ const KeyHeartbeatStatusSchema = z$2.object({
1539
+ get "health"() {
1540
+ return ObservedHealthSchema;
1541
+ },
1542
+ get "lifecycle"() {
1543
+ return ProviderLifecycleStateSchema;
1544
+ },
1545
+ "message": z$2.string().nullish()
1546
+ });
1547
+ //#endregion
1548
+ //#region src/generated/zod/aws-kms-key-heartbeat-data-schema.ts
1549
+ /**
1550
+ * Generated by Kubb (https://kubb.dev/).
1551
+ * Do not edit manually.
1552
+ */
1553
+ const AwsKmsKeyHeartbeatDataSchema = z$2.object({
1554
+ "enabled": z$2.boolean(),
1555
+ "keyArn": z$2.string(),
1556
+ "keySpec": z$2.string(),
1557
+ "keyState": z$2.string(),
1558
+ "keyUsage": z$2.string(),
1559
+ get "status"() {
1560
+ return KeyHeartbeatStatusSchema;
1561
+ }
1562
+ });
1413
1563
  //#endregion
1414
1564
  //#region src/generated/zod/aws-kv-import-data-schema.ts
1415
1565
  /**
@@ -2243,6 +2393,12 @@ z$2.object({
2243
2393
  "serverResourceId": z$2.string().describe("Full ARM resource id of the Flexible Server (the deletable handle)."),
2244
2394
  "version": z$2.string().describe("Engine version the server reports.")
2245
2395
  }).describe("Azure Postgres (Flexible Server + Private Endpoint) registration data: the handles by\nwhich a setup-created Flexible Server (with its Private Endpoint, private DNS zone, and\nthe Key Vault secret holding the master password) is registered as a Frozen Postgres\nresource. Setup owns the server, Alien refreshes and heartbeats it. The raw password is\nnever carried, only the Key Vault secret URI.");
2396
+ z$2.object({
2397
+ "keyId": z$2.string().describe("Full versioned Key Vault key ID used for new wrapping operations."),
2398
+ "keyName": z$2.string().describe("Key name within the vault."),
2399
+ "lineageVersionId": z$2.string().describe("Version ID that identifies the original key lineage."),
2400
+ "vaultResourceId": z$2.string().describe("ARM resource ID of the dedicated Key Vault.")
2401
+ }).describe("Azure Key Vault key created by the customer-installed setup stack.");
2246
2402
  //#endregion
2247
2403
  //#region src/generated/zod/azure-key-vault-heartbeat-data-schema.ts
2248
2404
  /**
@@ -2271,6 +2427,22 @@ const AzureKeyVaultHeartbeatDataSchema = z$2.object({
2271
2427
  "vaultUri": z$2.string().nullish()
2272
2428
  });
2273
2429
  //#endregion
2430
+ //#region src/generated/zod/azure-key-vault-key-heartbeat-data-schema.ts
2431
+ /**
2432
+ * Generated by Kubb (https://kubb.dev/).
2433
+ * Do not edit manually.
2434
+ */
2435
+ const AzureKeyVaultKeyHeartbeatDataSchema = z$2.object({
2436
+ "enabled": z$2.boolean().nullish(),
2437
+ "keyId": z$2.string(),
2438
+ "keyOperations": z$2.array(z$2.string()),
2439
+ "keyType": z$2.string(),
2440
+ "recoveryLevel": z$2.string().nullish(),
2441
+ get "status"() {
2442
+ return KeyHeartbeatStatusSchema;
2443
+ }
2444
+ });
2445
+ //#endregion
2274
2446
  //#region src/generated/zod/azure-kv-import-data-schema.ts
2275
2447
  /**
2276
2448
  * Generated by Kubb (https://kubb.dev/).
@@ -4563,7 +4735,7 @@ z$2.object({
4563
4735
  * Do not edit manually.
4564
4736
  */
4565
4737
  /**
4566
- * @description Email infrastructure for sending and receiving mail on customer-owned\ndomains. On AWS this is backed by SES: a shared configuration set, optional\ninbound/event wiring, and one email identity (Easy DKIM) per seed domain.\n\n# Infrastructure vs runtime data\n\nThis resource owns the email *infrastructure* and the capability to use it,\nnot the domain lifecycle. Deployment manages the configuration set, the\nevent topology, the inbound receipt topology, and any seed identities\nlisted in `domains`. Email identities created at runtime through the\n`email/manage-identities` grant are application data: they are not tracked\nby the deployment, are not removed when the stack is deleted, and their\nlifecycle — including deletion — belongs to the application.\n\nThe operator (or the application, for runtime-created identities) owns DNS:\nthe per-domain DKIM CNAME records surfaced in [`EmailOutputs`] must be\ncreated before SES verifies a domain and allows sending from it.\n\n# Inbound mail (AWS)\n\nWhen `inbound` is set, a SES receipt rule set is provisioned that writes\nraw incoming mail into the linked Storage bucket. The receipt rule is a\ncatch-all (no recipient filter), so mail for identities verified at runtime\nlands in the bucket without any infrastructure change.\n\nAlien activates the provisioned receipt rule set as part of setup. Because\nSES permits only one active receipt rule set per AWS account and region, an\nAWS stack may contain only one email resource with inbound delivery, and\ninstalling it makes its rule set the account\'s active rule set. SES email\nreceiving is available only in a subset of AWS regions; deploying `inbound`\nto an unsupported region fails during setup.\n\n# Update semantics\n\n`domains` is append-friendly: adding a domain provisions a new identity,\nremoving a domain deletes its identity (and its DKIM verification state).\nThe list may be empty. `inbound` and `events` may be added, removed, or\nrepointed; removing them tears down the corresponding receipt rule set /\nevent destination wiring.
4738
+ * @description Email infrastructure for sending and receiving mail on customer-owned\ndomains. On AWS this is backed by SES: a shared configuration set, optional\ninbound/event wiring, and one email identity (Easy DKIM) per seed domain.\n\n# Infrastructure vs runtime data\n\nThis resource owns the email *infrastructure* and the capability to use it,\nnot the domain lifecycle. Deployment manages the configuration set, the\nevent topology, the inbound receipt topology, and any seed identities\nlisted in `domains`. Email identities created at runtime through the\n`email/manage-identities` grant are application data: they are not tracked\nby the deployment, are not removed when the stack is deleted, and their\nlifecycle — including deletion — belongs to the application.\n\nThe operator (or the application, for runtime-created identities) owns DNS:\nthe per-domain DKIM CNAME records surfaced in [`EmailOutputs`] must be\ncreated before SES verifies a domain and allows sending from it.\n\n# Inbound mail (AWS)\n\nWhen `inbound` is set, a SES receipt rule set is provisioned that writes\nraw incoming mail into the linked Storage bucket. The receipt rule is a\ncatch-all (no recipient filter), so mail for identities verified at runtime\nlands in the bucket without any infrastructure change.\n\nAlien activates the provisioned receipt rule set as part of setup. Because\nSES permits only one active receipt rule set per AWS account and region, an\nAWS stack may contain only one email resource with inbound delivery. The\nresource requires exclusive ownership of SES receiving in its account and\nregion: setup refuses to replace an active rule set it does not own. Choose\nan unused region when the account already receives email through SES. SES email\nreceiving is available only in a subset of AWS regions; deploying `inbound`\nto an unsupported region fails during setup.\n\n# Update semantics\n\n`domains` is append-friendly: adding a domain provisions a new identity,\nremoving a domain deletes its identity (and its DKIM verification state).\nThe list may be empty. `inbound` and `events` may be added, removed, or\nrepointed; removing them tears down the corresponding receipt rule set /\nevent destination wiring.
4567
4739
  */
4568
4740
  const EmailSchema = z$2.object({
4569
4741
  "domains": z$2.optional(z$2.array(z$2.string()).describe("Seed mail domains provisioned at deploy time (one SES identity each).\nUseful for day-0 bootstrap and products with a static domain set.\nMay be empty (the default): products that create and verify domains\ndynamically should manage identities at runtime through the\n`email/manage-identities` grant instead of listing them here.")),
@@ -4574,7 +4746,7 @@ const EmailSchema = z$2.object({
4574
4746
  get "inbound"() {
4575
4747
  return z$2.union([EmailInboundSchema, z$2.null()]).optional();
4576
4748
  }
4577
- }).describe("Email infrastructure for sending and receiving mail on customer-owned\ndomains. On AWS this is backed by SES: a shared configuration set, optional\ninbound/event wiring, and one email identity (Easy DKIM) per seed domain.\n\n# Infrastructure vs runtime data\n\nThis resource owns the email *infrastructure* and the capability to use it,\nnot the domain lifecycle. Deployment manages the configuration set, the\nevent topology, the inbound receipt topology, and any seed identities\nlisted in `domains`. Email identities created at runtime through the\n`email/manage-identities` grant are application data: they are not tracked\nby the deployment, are not removed when the stack is deleted, and their\nlifecycle — including deletion — belongs to the application.\n\nThe operator (or the application, for runtime-created identities) owns DNS:\nthe per-domain DKIM CNAME records surfaced in [`EmailOutputs`] must be\ncreated before SES verifies a domain and allows sending from it.\n\n# Inbound mail (AWS)\n\nWhen `inbound` is set, a SES receipt rule set is provisioned that writes\nraw incoming mail into the linked Storage bucket. The receipt rule is a\ncatch-all (no recipient filter), so mail for identities verified at runtime\nlands in the bucket without any infrastructure change.\n\nAlien activates the provisioned receipt rule set as part of setup. Because\nSES permits only one active receipt rule set per AWS account and region, an\nAWS stack may contain only one email resource with inbound delivery, and\ninstalling it makes its rule set the account's active rule set. SES email\nreceiving is available only in a subset of AWS regions; deploying `inbound`\nto an unsupported region fails during setup.\n\n# Update semantics\n\n`domains` is append-friendly: adding a domain provisions a new identity,\nremoving a domain deletes its identity (and its DKIM verification state).\nThe list may be empty. `inbound` and `events` may be added, removed, or\nrepointed; removing them tears down the corresponding receipt rule set /\nevent destination wiring.");
4749
+ }).describe("Email infrastructure for sending and receiving mail on customer-owned\ndomains. On AWS this is backed by SES: a shared configuration set, optional\ninbound/event wiring, and one email identity (Easy DKIM) per seed domain.\n\n# Infrastructure vs runtime data\n\nThis resource owns the email *infrastructure* and the capability to use it,\nnot the domain lifecycle. Deployment manages the configuration set, the\nevent topology, the inbound receipt topology, and any seed identities\nlisted in `domains`. Email identities created at runtime through the\n`email/manage-identities` grant are application data: they are not tracked\nby the deployment, are not removed when the stack is deleted, and their\nlifecycle — including deletion — belongs to the application.\n\nThe operator (or the application, for runtime-created identities) owns DNS:\nthe per-domain DKIM CNAME records surfaced in [`EmailOutputs`] must be\ncreated before SES verifies a domain and allows sending from it.\n\n# Inbound mail (AWS)\n\nWhen `inbound` is set, a SES receipt rule set is provisioned that writes\nraw incoming mail into the linked Storage bucket. The receipt rule is a\ncatch-all (no recipient filter), so mail for identities verified at runtime\nlands in the bucket without any infrastructure change.\n\nAlien activates the provisioned receipt rule set as part of setup. Because\nSES permits only one active receipt rule set per AWS account and region, an\nAWS stack may contain only one email resource with inbound delivery. The\nresource requires exclusive ownership of SES receiving in its account and\nregion: setup refuses to replace an active rule set it does not own. Choose\nan unused region when the account already receives email through SES. SES email\nreceiving is available only in a subset of AWS regions; deploying `inbound`\nto an unsupported region fails during setup.\n\n# Update semantics\n\n`domains` is append-friendly: adding a domain provisions a new identity,\nremoving a domain deletes its identity (and its DKIM verification state).\nThe list may be empty. `inbound` and `events` may be added, removed, or\nrepointed; removing them tears down the corresponding receipt rule set /\nevent destination wiring.");
4578
4750
  //#endregion
4579
4751
  //#region src/generated/zod/response-handling-schema.ts
4580
4752
  /**
@@ -4725,6 +4897,22 @@ const GcpBuildImportDataSchema = z$2.object({
4725
4897
  "triggerName": z$2.string().describe("Cloud Build trigger name.")
4726
4898
  }).describe("GCP Build ImportData — Cloud Build trigger + worker pool reference.");
4727
4899
  //#endregion
4900
+ //#region src/generated/zod/gcp-cloud-kms-key-heartbeat-data-schema.ts
4901
+ /**
4902
+ * Generated by Kubb (https://kubb.dev/).
4903
+ * Do not edit manually.
4904
+ */
4905
+ const GcpCloudKmsKeyHeartbeatDataSchema = z$2.object({
4906
+ "algorithm": z$2.string().nullish(),
4907
+ "cryptoKeyName": z$2.string(),
4908
+ "primaryState": z$2.string().nullish(),
4909
+ "primaryVersion": z$2.string().nullish(),
4910
+ "purpose": z$2.string(),
4911
+ get "status"() {
4912
+ return KeyHeartbeatStatusSchema;
4913
+ }
4914
+ });
4915
+ //#endregion
4728
4916
  //#region src/generated/zod/gcp-cloud-run-worker-heartbeat-data-schema.ts
4729
4917
  /**
4730
4918
  * Generated by Kubb (https://kubb.dev/).
@@ -4834,6 +5022,10 @@ const GcpFirestoreKvHeartbeatDataSchema = z$2.object({
4834
5022
  "updateTime": z$2.string().nullish(),
4835
5023
  "versionRetentionPeriod": z$2.string().nullish()
4836
5024
  });
5025
+ z$2.object({
5026
+ "cryptoKeyName": z$2.string().describe("Full CryptoKey resource name, without a CryptoKeyVersion."),
5027
+ "primaryVersion": z$2.string().describe("Full primary CryptoKeyVersion resource name used for new wrapping operations.")
5028
+ }).describe("GCP Cloud KMS key created by the customer-installed setup stack.");
4837
5029
  //#endregion
4838
5030
  //#region src/generated/zod/gcp-kv-import-data-schema.ts
4839
5031
  /**
@@ -5233,6 +5425,73 @@ const ImportedResourceSchema = z$2.object({
5233
5425
  }
5234
5426
  }).describe("One resolved resource import payload.");
5235
5427
  //#endregion
5428
+ //#region src/generated/zod/key-fingerprint-schema.ts
5429
+ /**
5430
+ * Generated by Kubb (https://kubb.dev/).
5431
+ * Do not edit manually.
5432
+ */
5433
+ /**
5434
+ * @description Stable identity of a provider key family.\n\nProvider-native version rotation does not change this value. Replacing the\nprovider key does.
5435
+ */
5436
+ const KeyFingerprintSchema = z$2.union([
5437
+ z$2.object({
5438
+ "key_arn": z$2.string(),
5439
+ "provider": z$2.enum(["aws"])
5440
+ }),
5441
+ z$2.object({
5442
+ "crypto_key_name": z$2.string(),
5443
+ "provider": z$2.enum(["gcp"])
5444
+ }),
5445
+ z$2.object({
5446
+ "key_name": z$2.string(),
5447
+ "lineage_version_id": z$2.string(),
5448
+ "provider": z$2.enum(["azure"]),
5449
+ "vault_resource_id": z$2.string()
5450
+ })
5451
+ ]).describe("Stable identity of a provider key family.\n\nProvider-native version rotation does not change this value. Replacing the\nprovider key does.");
5452
+ //#endregion
5453
+ //#region src/generated/zod/key-heartbeat-data-schema.ts
5454
+ /**
5455
+ * Generated by Kubb (https://kubb.dev/).
5456
+ * Do not edit manually.
5457
+ */
5458
+ const KeyHeartbeatDataSchema = z$2.union([
5459
+ z$2.object({
5460
+ get "data"() {
5461
+ return AwsKmsKeyHeartbeatDataSchema;
5462
+ },
5463
+ "provider": z$2.enum(["aws-kms"])
5464
+ }),
5465
+ z$2.object({
5466
+ get "data"() {
5467
+ return GcpCloudKmsKeyHeartbeatDataSchema;
5468
+ },
5469
+ "provider": z$2.enum(["gcp-cloud-kms"])
5470
+ }),
5471
+ z$2.object({
5472
+ get "data"() {
5473
+ return AzureKeyVaultKeyHeartbeatDataSchema;
5474
+ },
5475
+ "provider": z$2.enum(["azure-key-vault"])
5476
+ })
5477
+ ]);
5478
+ z$2.object({
5479
+ get "fingerprint"() {
5480
+ return KeyFingerprintSchema.describe("Stable identity of a provider key family.\n\nProvider-native version rotation does not change this value. Replacing the\nprovider key does.");
5481
+ },
5482
+ "wrappingKeyId": z$2.string().describe("Exact provider key version used for new wrapping operations.")
5483
+ }).describe("Outputs generated by a successfully provisioned Key.");
5484
+ //#endregion
5485
+ //#region src/generated/zod/key-schema.ts
5486
+ /**
5487
+ * Generated by Kubb (https://kubb.dev/).
5488
+ * Do not edit manually.
5489
+ */
5490
+ /**
5491
+ * @description A customer-managed encryption key.
5492
+ */
5493
+ const KeySchema = z$2.object({ "id": z$2.string().describe("Identifier for the key resource.") }).describe("A customer-managed encryption key.");
5494
+ //#endregion
5236
5495
  //#region src/generated/zod/kubernetes-certificate-mode-schema.ts
5237
5496
  /**
5238
5497
  * Generated by Kubb (https://kubb.dev/).
@@ -5242,7 +5501,7 @@ const ImportedResourceSchema = z$2.object({
5242
5501
  * @description Certificate publication or reference mode for Kubernetes public endpoints.
5243
5502
  */
5244
5503
  const KubernetesCertificateModeSchema = z$2.union([
5245
- z$2.lazy(() => KubernetesTlsSecretRefSchema).and(z$2.object({ "mode": z$2.enum(["tlsSecretRef"]) })),
5504
+ z$2.lazy(() => KubernetesTlsSecretRefSchema).and(z$2.object({ "mode": z$2.enum(["tlsSecretRef"]) })).describe("Namespace-scoped Kubernetes TLS Secret reference."),
5246
5505
  z$2.object({
5247
5506
  "mode": z$2.enum(["managedAcmImport"]),
5248
5507
  "region": z$2.string().describe("ACM region. Defaults to the deployment region when omitted.").nullish(),
@@ -5483,7 +5742,7 @@ const KubernetesIngressRouteProfileSchema = z$2.object({
5483
5742
  /**
5484
5743
  * @description Kubernetes route API selected for public endpoints.
5485
5744
  */
5486
- const KubernetesRouteProfileSchema = z$2.union([z$2.lazy(() => KubernetesIngressRouteProfileSchema).and(z$2.object({ "routeApi": z$2.enum(["ingress"]) })), z$2.lazy(() => KubernetesGatewayRouteProfileSchema).and(z$2.object({ "routeApi": z$2.enum(["gateway"]) }))]).describe("Kubernetes route API selected for public endpoints.");
5745
+ const KubernetesRouteProfileSchema = z$2.union([z$2.lazy(() => KubernetesIngressRouteProfileSchema).and(z$2.object({ "routeApi": z$2.enum(["ingress"]) })).describe("Shared Ingress route profile values."), z$2.lazy(() => KubernetesGatewayRouteProfileSchema).and(z$2.object({ "routeApi": z$2.enum(["gateway"]) })).describe("Shared Gateway API route profile values.")]).describe("Kubernetes route API selected for public endpoints.");
5487
5746
  //#endregion
5488
5747
  //#region src/generated/zod/kubernetes-exposure-settings-schema.ts
5489
5748
  /**
@@ -5807,9 +6066,9 @@ const LocalWorkerHeartbeatDataSchema = z$2.object({
5807
6066
  * @description Management configuration for different cloud platforms.\n\nPlatform-derived configuration for cross-account/cross-tenant access.\nThis is NOT user-specified - it\'s derived from the Manager\'s ServiceAccount.
5808
6067
  */
5809
6068
  const ManagementConfigSchema = z$2.union([
5810
- z$2.lazy(() => AwsManagementConfigSchema).and(z$2.object({ "platform": z$2.enum(["aws"]) })),
5811
- z$2.lazy(() => GcpManagementConfigSchema).and(z$2.object({ "platform": z$2.enum(["gcp"]) })),
5812
- z$2.lazy(() => AzureManagementConfigSchema).and(z$2.object({ "platform": z$2.enum(["azure"]) })),
6069
+ z$2.lazy(() => AwsManagementConfigSchema).and(z$2.object({ "platform": z$2.enum(["aws"]) })).describe("AWS management configuration extracted from stack settings"),
6070
+ z$2.lazy(() => GcpManagementConfigSchema).and(z$2.object({ "platform": z$2.enum(["gcp"]) })).describe("GCP management configuration extracted from stack settings"),
6071
+ z$2.lazy(() => AzureManagementConfigSchema).and(z$2.object({ "platform": z$2.enum(["azure"]) })).describe("Azure management configuration extracted from stack settings"),
5813
6072
  z$2.object({ "platform": z$2.enum(["kubernetes"]) })
5814
6073
  ]).describe("Management configuration for different cloud platforms.\n\nPlatform-derived configuration for cross-account/cross-tenant access.\nThis is NOT user-specified - it's derived from the Manager's ServiceAccount.");
5815
6074
  //#endregion
@@ -6064,10 +6323,10 @@ const PostgresBackendSchema = z$2.object({ "type": z$2.enum(["auroraServerlessV2
6064
6323
  * Do not edit manually.
6065
6324
  */
6066
6325
  const PostgresHeartbeatDataSchema = z$2.union([
6067
- z$2.lazy(() => AuroraPostgresHeartbeatDataSchema).and(z$2.object({ "backend": z$2.enum(["aurora"]) })),
6068
- z$2.lazy(() => GcpCloudSqlPostgresHeartbeatDataSchema).and(z$2.object({ "backend": z$2.enum(["cloudSql"]) })),
6069
- z$2.lazy(() => AzureFlexibleServerPostgresHeartbeatDataSchema).and(z$2.object({ "backend": z$2.enum(["flexibleServer"]) })),
6070
- z$2.lazy(() => LocalPostgresHeartbeatDataSchema).and(z$2.object({ "backend": z$2.enum(["local"]) }))
6326
+ z$2.lazy(() => AuroraPostgresHeartbeatDataSchema).and(z$2.object({ "backend": z$2.enum(["aurora"]) })).describe("AWS Aurora Serverless v2 backend."),
6327
+ z$2.lazy(() => GcpCloudSqlPostgresHeartbeatDataSchema).and(z$2.object({ "backend": z$2.enum(["cloudSql"]) })).describe("GCP Cloud SQL backend."),
6328
+ z$2.lazy(() => AzureFlexibleServerPostgresHeartbeatDataSchema).and(z$2.object({ "backend": z$2.enum(["flexibleServer"]) })).describe("Azure Flexible Server backend."),
6329
+ z$2.lazy(() => LocalPostgresHeartbeatDataSchema).and(z$2.object({ "backend": z$2.enum(["local"]) })).describe("Local embedded Postgres backend.")
6071
6330
  ]);
6072
6331
  z$2.object({
6073
6332
  "database": z$2.string().describe("The default database created for this resource. On cloud backends this is the fixed\nlabel `POSTGRES_DATABASE_NAME` (`alien`); on Local it is the resource id."),
@@ -6437,6 +6696,12 @@ const ResourceHeartbeatDataSchema = z$2.union([
6437
6696
  return AiHeartbeatDataSchema;
6438
6697
  },
6439
6698
  "resourceType": z$2.enum(["ai"])
6699
+ }),
6700
+ z$2.object({
6701
+ get "data"() {
6702
+ return KeyHeartbeatDataSchema;
6703
+ },
6704
+ "resourceType": z$2.enum(["key"])
6440
6705
  })
6441
6706
  ]);
6442
6707
  //#endregion
@@ -6853,6 +7118,9 @@ const StorageOutputsSchema = z$2.object({ "bucketName": z$2.string().describe("T
6853
7118
  */
6854
7119
  const StorageSchema = z$2.object({
6855
7120
  "corsAllowedOrigins": z$2.optional(z$2.array(z$2.string()).describe("Browser origins allowed to read objects through signed URLs.\n\nWhen non-empty, providers configure CORS for `GET` and `HEAD` requests.\nAn origin of `*` is appropriate for private buckets whose signed URLs\nare bearer credentials and do not use browser cookies.\nDefault: `[]` (CORS disabled).")),
7121
+ get "encryptionKey"() {
7122
+ return z$2.union([ResourceRefSchema, z$2.null()]).optional();
7123
+ },
6856
7124
  "id": z$2.string().describe("Name of the the storage bucket.\nFor names with dots, each dot-separated label must be ≤ 63 characters."),
6857
7125
  get "lifecycleRules"() {
6858
7126
  return z$2.array(LifecycleRuleSchema.describe("Defines a rule for managing the lifecycle of objects within a storage bucket.")).describe("List of rules for automatic object management (e.g., expiration).\nDefault: `[]` (empty list)").optional();
@@ -6869,7 +7137,7 @@ const StorageSchema = z$2.object({
6869
7137
  /**
6870
7138
  * @description Request to submit a command response (from deployment)
6871
7139
  */
6872
- const SubmitResponseRequestSchema = z$2.lazy(() => CommandResponseSchema).describe("Request to submit a command response (from deployment)");
7140
+ const SubmitResponseRequestSchema = z$2.lazy(() => CommandResponseSchema).describe("Command response from deployment").describe("Request to submit a command response (from deployment)");
6873
7141
  //#endregion
6874
7142
  //#region src/generated/zod/upload-complete-request-schema.ts
6875
7143
  /**
@@ -7082,186 +7350,140 @@ var ResourceBuilder = class {
7082
7350
  }
7083
7351
  };
7084
7352
  //#endregion
7085
- //#region src/storage.ts
7353
+ //#region src/ai.ts
7086
7354
  /**
7087
- * Represents an object storage bucket.
7355
+ * Represents an AI Gateway resource that provides a unified interface to
7356
+ * managed AI inference services across cloud providers.
7088
7357
  */
7089
- var Storage = class extends ResourceBuilder {
7090
- _config = {
7091
- publicRead: false,
7092
- versioning: false,
7093
- lifecycleRules: [],
7094
- corsAllowedOrigins: []
7095
- };
7358
+ var AI = class extends ResourceBuilder {
7359
+ _config = {};
7096
7360
  /**
7097
- * Creates a new Storage builder.
7098
- * @param id ID of the storage bucket. For names with dots, each dot-separated label must be ≤ 63 characters.
7361
+ * Creates a new AI builder.
7362
+ * @param id Identifier for the AI resource. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
7099
7363
  */
7100
7364
  constructor(id) {
7101
7365
  super();
7102
7366
  this._config.id = id;
7103
7367
  }
7104
7368
  /**
7105
- * Returns a ResourceType representing any storage resource.
7106
- * Used for creating permission targets that apply to all storage resources.
7107
- * @returns The "storage" resource type.
7369
+ * Returns a ResourceType representing any AI resource.
7370
+ * Used for creating permission targets that apply to all AI resources.
7371
+ * @returns The "ai" resource type.
7108
7372
  */
7109
7373
  static any() {
7110
- return "storage";
7374
+ return "ai";
7111
7375
  }
7112
7376
  /**
7113
- * Allows public read access to objects without authentication.
7114
- * Default: `false`.
7115
- * @param value Whether to allow public read access.
7116
- * @returns The Storage builder instance.
7377
+ * Builds and validates the AI configuration.
7378
+ * @returns An immutable Resource representing the configured AI Gateway.
7379
+ * @throws Error if the AI configuration is invalid.
7117
7380
  */
7118
- publicRead(value) {
7119
- this._config.publicRead = value;
7120
- return this;
7381
+ build() {
7382
+ const config = AiSchema.parse(this._config);
7383
+ return this.resource({
7384
+ type: "ai",
7385
+ ...config
7386
+ });
7121
7387
  }
7388
+ };
7389
+ //#endregion
7390
+ //#region src/artifact-registry.ts
7391
+ /**
7392
+ * Represents an artifact registry for storing container images and other build artifacts.
7393
+ * This is a high-level wrapper resource that provides a cloud-agnostic interface over
7394
+ * AWS ECR, GCP Artifact Registry, and Azure Container Registry.
7395
+ */
7396
+ var ArtifactRegistry = class {
7397
+ _config = {};
7122
7398
  /**
7123
- * Enables object versioning.
7124
- * Default: `false`.
7125
- * @param value Whether to enable versioning.
7126
- * @returns The Storage builder instance.
7399
+ * Creates a new ArtifactRegistry builder.
7400
+ * @param id Identifier for the artifact registry. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
7127
7401
  */
7128
- versioning(value) {
7129
- this._config.versioning = value;
7130
- return this;
7402
+ constructor(id) {
7403
+ this._config.id = id;
7131
7404
  }
7132
7405
  /**
7133
- * Defines lifecycle rules for automatic object management (e.g., expiration).
7134
- * @param rules An array of lifecycle rules.
7135
- * @returns The Storage builder instance.
7406
+ * Returns a ResourceType representing any artifact registry resource.
7407
+ * Used for creating permission targets that apply to all artifact registry resources.
7408
+ * @returns The "artifact-registry" resource type.
7136
7409
  */
7137
- lifecycleRules(rules) {
7138
- this._config.lifecycleRules = rules;
7139
- return this;
7410
+ static any() {
7411
+ return "artifact-registry";
7140
7412
  }
7141
7413
  /**
7142
- * Allows browser reads from the listed origins through signed URLs.
7143
- * Providers enable `GET` and `HEAD`; use `*` only when the signed URL itself
7144
- * is the credential and browser cookies are not involved.
7145
- * @param origins Allowed browser origins.
7146
- * @returns The Storage builder instance.
7414
+ * AWS-only: Configure ECR private image replication to additional regions.
7415
+ * Ensures images pushed in the registry's home region are automatically
7416
+ * available in these destination regions (required when Lambda or other
7417
+ * compute runs in a different region).
7418
+ * @param regions - AWS region codes to replicate to (e.g., ["us-east-2", "eu-west-1"])
7147
7419
  */
7148
- corsAllowedOrigins(origins) {
7149
- this._config.corsAllowedOrigins = origins;
7420
+ replicationRegions(regions) {
7421
+ this._config.replicationRegions = regions;
7150
7422
  return this;
7151
7423
  }
7152
7424
  /**
7153
- * Builds and validates the storage configuration.
7154
- * @returns An immutable Resource representing the configured storage bucket.
7155
- * @throws Error if the storage configuration is invalid.
7425
+ * Builds and validates the artifact registry configuration.
7426
+ * @returns An immutable Resource representing the configured artifact registry.
7427
+ * @throws Error if the artifact registry configuration is invalid.
7156
7428
  */
7157
7429
  build() {
7158
- const config = StorageSchema.parse(this._config);
7159
- return this.resource({
7160
- type: "storage",
7161
- ...config
7430
+ return new Resource({
7431
+ type: "artifact-registry",
7432
+ ...ArtifactRegistrySchema.parse(this._config)
7162
7433
  });
7163
7434
  }
7164
7435
  };
7165
7436
  //#endregion
7166
- //#region src/worker.ts
7437
+ //#region src/build.ts
7167
7438
  /**
7168
- * Represents a serverless worker that executes code in response to triggers or direct invocations.
7169
- * Workers are the primary compute resource in serverless applications, designed to be stateless and ephemeral.
7439
+ * Represents a build resource that executes bash scripts to build code.
7440
+ * Builds are designed to be stateless and can be triggered on-demand to compile,
7441
+ * test, or package application code.
7170
7442
  */
7171
- var Worker = class extends ResourceBuilder {
7443
+ var Build = class {
7172
7444
  _config = {
7173
7445
  links: [],
7174
- triggers: [],
7175
- publicEndpoints: [],
7176
7446
  environment: {}
7177
7447
  };
7178
7448
  /**
7179
- * Creates a new Worker builder.
7180
- * @param id Identifier for the worker. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
7449
+ * Creates a new Build builder.
7450
+ * @param id Identifier for the build resource. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
7181
7451
  */
7182
7452
  constructor(id) {
7183
- super();
7184
7453
  this._config.id = id;
7185
7454
  }
7186
7455
  /**
7187
- * Returns a ResourceType representing any worker resource.
7188
- * Used for creating permission targets that apply to all worker resources.
7189
- * @returns The "worker" resource type.
7456
+ * Returns a ResourceType representing any build resource.
7457
+ * Used for creating permission targets that apply to all build resources.
7458
+ * @returns The "build" resource type.
7190
7459
  */
7191
7460
  static any() {
7192
- return "worker";
7193
- }
7194
- /**
7195
- * Sets the code for the worker, either a pre-built image or source code to be built.
7196
- * @param code The worker code configuration.
7197
- * @returns The Worker builder instance.
7198
- */
7199
- code(code) {
7200
- this._config.code = code;
7201
- return this;
7202
- }
7203
- /**
7204
- * Sets the memory allocated to the worker in megabytes (MB).
7205
- * Constraints: 128‑32768 MB (platform-specific limits may apply).
7206
- * Default: 512 MB.
7207
- * @param mb The memory in MB.
7208
- * @returns The Worker builder instance.
7209
- */
7210
- memoryMb(mb) {
7211
- this._config.memoryMb = mb;
7212
- return this;
7213
- }
7214
- /**
7215
- * Sets the maximum execution time for the worker in seconds.
7216
- * Constraints: 1‑3600 seconds (platform-specific limits may apply).
7217
- * Default: 30 seconds.
7218
- * @param sec The timeout in seconds.
7219
- * @returns The Worker builder instance.
7220
- */
7221
- timeoutSeconds(sec) {
7222
- this._config.timeoutSeconds = sec;
7223
- return this;
7224
- }
7225
- /**
7226
- * Sets the maximum number of concurrent executions allowed for the worker.
7227
- * `null` means platform default applies.
7228
- * @param limit The concurrency limit, or `null` for platform default.
7229
- * @returns The Worker builder instance.
7230
- */
7231
- concurrencyLimit(limit) {
7232
- this._config.concurrencyLimit = limit;
7233
- return this;
7461
+ return "build";
7234
7462
  }
7235
7463
  /**
7236
- * Exposes a named public HTTP endpoint for the worker.
7237
- *
7238
- * If no public endpoint is declared, the worker is private and only reachable
7239
- * through triggers, commands, or provider invocation APIs.
7464
+ * Sets the compute type for the build.
7465
+ * @param type The compute type (small, medium, large, x-large).
7466
+ * @returns The Build builder instance.
7240
7467
  */
7241
- publicEndpoint(name, options = {}) {
7242
- if (!this._config.publicEndpoints) this._config.publicEndpoints = [];
7243
- this._config.publicEndpoints.push({
7244
- name,
7245
- hostLabel: options.hostLabel,
7246
- wildcardSubdomains: options.wildcardSubdomains ?? false
7247
- });
7468
+ computeType(type) {
7469
+ this._config.computeType = type;
7248
7470
  return this;
7249
7471
  }
7250
7472
  /**
7251
- * Sets key-value pairs as environment variables for the worker.
7473
+ * Sets key-value pairs as environment variables for the build.
7252
7474
  * @param env A map of environment variable names to their values.
7253
- * @returns The Worker builder instance.
7475
+ * @returns The Build builder instance.
7254
7476
  */
7255
7477
  environment(env) {
7256
7478
  this._config.environment = env;
7257
7479
  return this;
7258
7480
  }
7259
7481
  /**
7260
- * Links another resource (e.g., Storage, KV, Queue) to this worker.
7261
- * This makes the linked resource accessible to the worker, often by injecting
7482
+ * Links another resource (e.g., Storage, ArtifactRegistry, Role) to this build.
7483
+ * This makes the linked resource accessible to the build, often by injecting
7262
7484
  * environment variables or granting permissions.
7263
7485
  * @param resource The resource to link.
7264
- * @returns The Worker builder instance.
7486
+ * @returns The Build builder instance.
7265
7487
  */
7266
7488
  link(resource) {
7267
7489
  if (!this._config.links) this._config.links = [];
@@ -7269,441 +7491,630 @@ var Worker = class extends ResourceBuilder {
7269
7491
  return this;
7270
7492
  }
7271
7493
  /**
7272
- * Assigns a permission profile to this worker.
7273
- * The profile defines the permissions granted to this worker when interacting
7494
+ * Assigns a permission profile to this build.
7495
+ * The profile defines the permissions granted to this build when interacting
7274
7496
  * with other cloud resources.
7275
7497
  * @param permissions The permission profile name.
7276
- * @returns The Worker builder instance.
7498
+ * @returns The Build builder instance.
7277
7499
  */
7278
7500
  permissions(permissions) {
7279
7501
  this._config.permissions = permissions;
7280
7502
  return this;
7281
7503
  }
7282
7504
  /**
7283
- * Configures a readiness probe for the worker.
7284
- * The probe will be executed after provisioning/update to verify the worker is ready.
7285
- * Only works with workers that declare a public endpoint.
7286
- *
7287
- * @example
7288
- * ```typescript
7289
- * const probe: ReadinessProbe = {
7290
- * method: "GET",
7291
- * path: "/health"
7292
- * };
7293
- *
7294
- * const func = new Worker("my-api")
7295
- * .code({ type: "image", image: "my-api:latest" })
7296
- * .publicEndpoint("api")
7297
- * .readinessProbe(probe)
7298
- * .build();
7299
- * ```
7300
- *
7301
- * @param probe The readiness probe configuration.
7302
- * @returns The Worker builder instance.
7303
- */
7304
- readinessProbe(probe) {
7305
- this._config.readinessProbe = probe;
7306
- return this;
7307
- }
7308
- /**
7309
- * Enables or disables the Commands protocol for the worker.
7310
- * When enabled, the platform pushes commands into the Worker runtime, which executes registered handlers.
7311
- * Default: false.
7312
- * @param enabled Whether to enable commands for this worker.
7313
- * @returns The Worker builder instance.
7314
- */
7315
- commandsEnabled(enabled) {
7316
- this._config.commandsEnabled = enabled;
7317
- return this;
7318
- }
7319
- /**
7320
- * Adds a trigger to the worker. Workers can have multiple triggers.
7321
- * Each trigger will independently invoke the worker when its conditions are met.
7322
- *
7323
- * @example
7324
- * ```typescript
7325
- * // Queue trigger
7326
- * const queueTrigger: WorkerTrigger = {
7327
- * type: "queue",
7328
- * queue: myQueue.ref()
7329
- * };
7330
- *
7331
- * // Schedule trigger
7332
- * const scheduleTrigg: WorkerTrigger = {
7333
- * type: "schedule",
7334
- * cron: "0 * * * *"
7335
- * };
7336
- *
7337
- * const func = new Worker("my-func")
7338
- * .code({ type: "image", image: "my-image:latest" })
7339
- * .trigger(queueTrigger)
7340
- * .trigger(scheduleTrigger)
7341
- * .build();
7342
- * ```
7343
- *
7344
- * @param trigger The trigger configuration.
7345
- * @returns The Worker builder instance.
7346
- */
7347
- trigger(trigger) {
7348
- if (!this._config.triggers) this._config.triggers = [];
7349
- this._config.triggers.push(trigger);
7350
- return this;
7351
- }
7352
- /**
7353
- * Builds and validates the worker configuration.
7354
- * @returns An immutable Resource representing the configured worker.
7355
- * @throws Error if the worker configuration is invalid (e.g., missing code).
7505
+ * Builds and validates the build configuration.
7506
+ * @returns An immutable Resource representing the configured build.
7507
+ * @throws Error if the build configuration is invalid.
7356
7508
  */
7357
7509
  build() {
7358
- const config = WorkerSchema.parse(this._config);
7359
- return this.resource({
7360
- type: "worker",
7361
- ...config
7510
+ return new Resource({
7511
+ type: "build",
7512
+ ...BuildSchema.parse(this._config)
7362
7513
  });
7363
7514
  }
7364
7515
  };
7365
7516
  //#endregion
7366
- //#region src/container.ts
7517
+ //#region src/error.ts
7367
7518
  /**
7368
- * Represents a long-running container workload.
7519
+ * This module provides a structured error handling system similar to Rust's error types,
7520
+ * with TypeScript type safety, error chaining, and context preservation.
7369
7521
  *
7370
- * Containers run on compute instances (EC2, GCE, Azure VMs) and are orchestrated
7371
- * by the managed container backend. They're designed for always-on workloads
7372
- * like web services, APIs, databases, and background workers.
7522
+ * @example Basic Usage
7523
+ * ```typescript
7524
+ * import { AlienError, defineError } from '@alienplatform/core'
7525
+ * import { z } from 'zod'
7526
+ *
7527
+ * // Define a type-safe error
7528
+ * const DatabaseError = defineError({
7529
+ * code: "DATABASE_CONNECTION_FAILED",
7530
+ * context: z.object({
7531
+ * host: z.string(),
7532
+ * port: z.number(),
7533
+ * reason: z.string(),
7534
+ * }),
7535
+ * message: ({ host, port, reason }) => `Failed to connect to database '${host}:${port}': ${reason}`,
7536
+ * retryable: true,
7537
+ * internal: false,
7538
+ * httpStatusCode: 502,
7539
+ * })
7540
+ *
7541
+ * // Use it
7542
+ * throw new AlienError(DatabaseError.create({
7543
+ * host: "localhost",
7544
+ * port: 5432,
7545
+ * reason: "Connection timeout"
7546
+ * }))
7547
+ * ```
7548
+ *
7549
+ * @example Error Chaining
7550
+ * ```typescript
7551
+ * try {
7552
+ * // Some operation that fails
7553
+ * throw new Error("Connection refused")
7554
+ * } catch (error) {
7555
+ * throw (await AlienError.from(error)).withContext(
7556
+ * DatabaseError.create({
7557
+ * host: "localhost",
7558
+ * port: 5432,
7559
+ * reason: "Connection refused by server"
7560
+ * })
7561
+ * )
7562
+ * }
7563
+ * ```
7564
+ *
7565
+ * @example External API Sanitization
7566
+ * ```typescript
7567
+ * const internalError = new AlienError(InternalApiError.create({
7568
+ * service: "payment-processor",
7569
+ * details: "Database password expired",
7570
+ * traceId: "trace-12345"
7571
+ * }))
7572
+ *
7573
+ * // Safe for external APIs (sanitizes internal errors)
7574
+ * const safeResponse = internalError.toExternal()
7575
+ * ```
7373
7576
  */
7374
- var Container = class extends ResourceBuilder {
7375
- _config = {
7376
- links: [],
7377
- ports: [],
7378
- publicEndpoints: [],
7379
- environment: {},
7380
- stateful: false
7381
- };
7382
- /**
7383
- * Creates a new Container builder.
7384
- * @param id Identifier for the container. Must be DNS-compatible: lowercase alphanumeric with hyphens.
7385
- */
7386
- constructor(id) {
7387
- super();
7388
- this._config.id = id;
7389
- }
7390
- /**
7391
- * Returns a ResourceType representing any container resource.
7392
- * Used for creating permission targets that apply to all container resources.
7393
- * @returns The "container" resource type.
7394
- */
7395
- static any() {
7396
- return "container";
7397
- }
7398
- /**
7399
- * Sets the container cluster this container runs on.
7400
- * @param clusterId The ComputeCluster resource ID.
7401
- * @returns The Container builder instance.
7402
- */
7403
- cluster(clusterId) {
7404
- this._config.cluster = clusterId;
7405
- return this;
7577
+ /**
7578
+ * Helper function to create type-safe error definitions.
7579
+ *
7580
+ * This function provides a clean API for defining reusable error types
7581
+ * with full TypeScript type safety and Zod validation.
7582
+ *
7583
+ * @template TContext - Zod schema type for the error context
7584
+ * @param metadata - Error metadata including code, schema, and message generator
7585
+ * @returns Object with metadata and a create function for error instances
7586
+ *
7587
+ * @example
7588
+ * ```typescript
7589
+ * const UserNotFound = defineError({
7590
+ * code: "USER_NOT_FOUND",
7591
+ * context: z.object({
7592
+ * userId: z.string(),
7593
+ * searchMethod: z.string(),
7594
+ * }),
7595
+ * message: ({ userId, searchMethod }) =>
7596
+ * `User '${userId}' not found using method '${searchMethod}'`,
7597
+ * retryable: false,
7598
+ * internal: false,
7599
+ * httpStatusCode: 404,
7600
+ * })
7601
+ *
7602
+ * // Usage
7603
+ * const error = UserNotFound.create({
7604
+ * userId: "123",
7605
+ * searchMethod: "database_lookup"
7606
+ * })
7607
+ * ```
7608
+ */
7609
+ function defineError(metadata) {
7610
+ return {
7611
+ metadata,
7612
+ contextSchema: metadata.context,
7613
+ create: (context) => ({
7614
+ metadata,
7615
+ contextSchema: metadata.context,
7616
+ context,
7617
+ toOptions: () => ({
7618
+ code: metadata.code,
7619
+ message: metadata.message(context),
7620
+ retryable: metadata.retryable,
7621
+ internal: metadata.internal,
7622
+ httpStatusCode: metadata.httpStatusCode,
7623
+ context
7624
+ })
7625
+ })
7626
+ };
7627
+ }
7628
+ /**
7629
+ * Main AlienError class that provides structured error handling.
7630
+ *
7631
+ * This class extends the standard JavaScript Error with additional features:
7632
+ * - Type-safe context data
7633
+ * - Error chaining and source tracking
7634
+ * - Retryability and internal/external visibility flags
7635
+ * - HTTP status code mapping
7636
+ * - Sanitization for external APIs
7637
+ *
7638
+ * @template TContext - Zod schema type for the error context
7639
+ *
7640
+ * @example Basic Construction
7641
+ * ```typescript
7642
+ * const error = new AlienError(DatabaseError.create({
7643
+ * host: "localhost",
7644
+ * port: 5432,
7645
+ * reason: "Timeout"
7646
+ * }))
7647
+ * ```
7648
+ *
7649
+ * @example Converting JavaScript Errors
7650
+ * ```typescript
7651
+ * try {
7652
+ * JSON.parse("invalid json")
7653
+ * } catch (jsError) {
7654
+ * const alienError = AlienError.from(jsError)
7655
+ * console.log(alienError.code) // "GENERIC_ERROR"
7656
+ * }
7657
+ * ```
7658
+ *
7659
+ * @example Error Chaining
7660
+ * ```typescript
7661
+ * const contextualError = AlienError.from(new Error("Network timeout"))
7662
+ * .withContext(DatabaseError.create({
7663
+ * host: "localhost",
7664
+ * port: 5432,
7665
+ * reason: "Connection timeout"
7666
+ * }))
7667
+ *
7668
+ * // Check error chain
7669
+ * console.log(contextualError.hasErrorCode("DATABASE_CONNECTION_FAILED")) // true
7670
+ * console.log(contextualError.toString()) // Shows full error chain
7671
+ * ```
7672
+ */
7673
+ var AlienError = class AlienError extends Error {
7674
+ /** Unique error code identifying the error type */
7675
+ code;
7676
+ /** Whether this error can be safely retried */
7677
+ retryable;
7678
+ /** Whether this error contains sensitive internal information */
7679
+ internal;
7680
+ /** HTTP status code for API responses */
7681
+ httpStatusCode;
7682
+ /** Type-safe context data specific to this error */
7683
+ context;
7684
+ /** Optional human-facing remediation hint */
7685
+ hint;
7686
+ /** Source error that caused this error (for chaining) */
7687
+ source;
7688
+ constructor(input) {
7689
+ let options;
7690
+ if ("metadata" in input && "context" in input) {
7691
+ const { metadata, context: contextData } = input;
7692
+ const message = metadata.message(contextData);
7693
+ options = {
7694
+ code: metadata.code,
7695
+ message,
7696
+ retryable: metadata.retryable,
7697
+ internal: metadata.internal,
7698
+ httpStatusCode: metadata.httpStatusCode,
7699
+ context: contextData
7700
+ };
7701
+ } else options = input;
7702
+ const message = options.message;
7703
+ super(message, { cause: options.source });
7704
+ this.name = "AlienError";
7705
+ this.code = options.code;
7706
+ this.retryable = options.retryable;
7707
+ this.internal = options.internal;
7708
+ this.httpStatusCode = options.httpStatusCode ?? 500;
7709
+ this.context = options.context;
7710
+ this.hint = options.hint;
7711
+ this.source = void 0;
7712
+ if (options.source && typeof options.source === "object") {
7713
+ if ("code" in options.source && "message" in options.source && "retryable" in options.source && "internal" in options.source) this.source = new AlienError(options.source);
7714
+ }
7406
7715
  }
7407
7716
  /**
7408
- * Sets the code for the container, either a pre-built image or source code to be built.
7409
- * @param code The container code configuration.
7410
- * @returns The Container builder instance.
7717
+ * Create an AlienError from a type-safe error definition.
7718
+ *
7719
+ * @template TContext - Zod schema type for the error context
7720
+ * @param definition - Error definition with type-safe context
7721
+ * @returns New AlienError instance
7411
7722
  */
7412
- code(code) {
7413
- this._config.code = code;
7414
- return this;
7723
+ static fromDefinition(definition) {
7724
+ return new AlienError(definition);
7415
7725
  }
7416
7726
  /**
7417
- * Sets the CPU resources for the container.
7418
- *
7419
- * For simplified configuration, use a single number:
7420
- * - `.cpu(1)` sets both min and desired to 1 vCPU
7421
- *
7422
- * For advanced configuration, use ResourceSpec:
7423
- * - `.cpu({ min: "0.5", desired: "1" })`
7727
+ * Create an AlienError from raw options (for compatibility).
7424
7728
  *
7425
- * @param value CPU in vCPUs (number) or ResourceSpec with min/desired.
7426
- * @returns The Container builder instance.
7729
+ * @param options - Raw error options conforming to AlienErrorOptions schema
7730
+ * @returns New AlienError instance
7427
7731
  */
7428
- cpu(value) {
7429
- if (typeof value === "number") this._config.cpu = {
7430
- min: value.toString(),
7431
- desired: value.toString()
7432
- };
7433
- else this._config.cpu = value;
7434
- return this;
7732
+ static fromOptions(options) {
7733
+ return new AlienError(AlienErrorSchema.parse(options));
7435
7734
  }
7436
7735
  /**
7437
- * Sets the memory resources for the container.
7438
- *
7439
- * Format: "<number>Mi" or "<number>Gi"
7440
- *
7441
- * Example: "512Mi", "2Gi", "16Gi"
7736
+ * Helper function to get a user-friendly type name for error context.
7442
7737
  *
7443
- * @param size Memory size string.
7444
- * @returns The Container builder instance.
7738
+ * @param error - Any value to get the type name for
7739
+ * @returns User-friendly type name
7445
7740
  */
7446
- memory(size) {
7447
- this._config.memory = {
7448
- min: size,
7449
- desired: size
7450
- };
7451
- return this;
7741
+ static getErrorTypeName(error) {
7742
+ if (error === null) return "null";
7743
+ if (error === void 0) return "undefined";
7744
+ if (error?.constructor?.name) return error.constructor.name;
7745
+ const typeofResult = typeof error;
7746
+ return typeofResult === "object" ? "Object" : typeofResult.charAt(0).toUpperCase() + typeofResult.slice(1);
7452
7747
  }
7453
7748
  /**
7454
- * Sets minimum and maximum replica counts with autoscaling configuration.
7749
+ * Convert a JavaScript Error or any object to a generic AlienError.
7455
7750
  *
7456
- * @param min Minimum replicas (always running).
7457
- * @param max Maximum replicas under load.
7458
- * @returns The Container builder instance.
7751
+ * This is equivalent to Rust's `.into_alien_error()` pattern and provides
7752
+ * a way to convert any JavaScript error into the structured AlienError format.
7753
+ *
7754
+ * @param error - Any JavaScript error or object to convert
7755
+ * @returns AlienError with GENERIC_ERROR code and preserved original error
7756
+ *
7757
+ * @example
7758
+ * ```typescript
7759
+ * try {
7760
+ * throw new TypeError("Invalid argument")
7761
+ * } catch (error) {
7762
+ * const alienError = AlienError.from(error)
7763
+ * console.log(alienError.code) // "GENERIC_ERROR"
7764
+ * console.log(alienError.context?.originalError) // Serialized TypeError
7765
+ * }
7766
+ * ```
7767
+ *
7768
+ * @example Chaining with context
7769
+ * ```typescript
7770
+ * try {
7771
+ * JSON.parse("invalid")
7772
+ * } catch (error) {
7773
+ * throw AlienError.from(error).withContext(
7774
+ * ValidationError.create({
7775
+ * input: "invalid",
7776
+ * expectedFormat: "JSON"
7777
+ * })
7778
+ * )
7779
+ * }
7780
+ * ```
7781
+ *
7782
+ * @example AxiosError conversion
7783
+ * ```typescript
7784
+ * try {
7785
+ * await axios.get('/api/resource')
7786
+ * } catch (error) {
7787
+ * // If error.response.data contains a valid AlienError structure, it will be parsed
7788
+ * const alienError = AlienError.from(error)
7789
+ * console.log(alienError.code) // Could be "REMOTE_RESOURCE_NOT_FOUND" if parsed from response
7790
+ * }
7791
+ * ```
7459
7792
  */
7460
- minReplicas(min) {
7461
- if (!this._config.autoscaling) this._config.autoscaling = {
7462
- min,
7463
- desired: min,
7464
- max: min * 10
7465
- };
7466
- else {
7467
- this._config.autoscaling.min = min;
7468
- this._config.autoscaling.desired = min;
7469
- }
7470
- return this;
7793
+ static async from(error) {
7794
+ if (error instanceof AlienError) return error;
7795
+ if (error instanceof Response) {
7796
+ let errorBody;
7797
+ try {
7798
+ errorBody = await error.json();
7799
+ } catch {
7800
+ return new AlienError({
7801
+ code: "GENERIC_ERROR",
7802
+ message: `HTTP request failed with status ${error.status}`,
7803
+ retryable: false,
7804
+ internal: true,
7805
+ httpStatusCode: error.status,
7806
+ context: {
7807
+ url: error.url,
7808
+ status: error.status,
7809
+ statusText: error.statusText
7810
+ }
7811
+ });
7812
+ }
7813
+ const parseResult = AlienErrorSchema.safeParse(errorBody);
7814
+ if (parseResult.success) return new AlienError(parseResult.data);
7815
+ return new AlienError({
7816
+ code: "GENERIC_ERROR",
7817
+ message: errorBody?.message || `HTTP request failed with status ${error.status}`,
7818
+ retryable: false,
7819
+ internal: true,
7820
+ httpStatusCode: error.status,
7821
+ context: {
7822
+ url: error.url,
7823
+ status: error.status,
7824
+ statusText: error.statusText,
7825
+ responseBody: errorBody
7826
+ }
7827
+ });
7828
+ }
7829
+ if (error?.response?.data && typeof error.response.data === "object") {
7830
+ const parseResult = AlienErrorSchema.safeParse(error.response.data);
7831
+ if (parseResult.success) return new AlienError(parseResult.data);
7832
+ }
7833
+ const serialized = serializeError(error);
7834
+ const message = serialized?.message || String(error);
7835
+ return new AlienError({
7836
+ code: "GENERIC_ERROR",
7837
+ message,
7838
+ retryable: false,
7839
+ internal: true,
7840
+ httpStatusCode: 500,
7841
+ context: {
7842
+ originalError: serialized,
7843
+ errorType: AlienError.getErrorTypeName(error)
7844
+ }
7845
+ });
7471
7846
  }
7472
7847
  /**
7473
- * Sets the maximum replica count for autoscaling.
7474
- * @param max Maximum replicas.
7475
- * @returns The Container builder instance.
7848
+ * Add context to this error, creating a new error that wraps this one.
7849
+ *
7850
+ * This is equivalent to Rust's `.with_context()` pattern and allows
7851
+ * building error chains with increasing levels of context.
7852
+ *
7853
+ * @template TNewContext - Zod schema type for the new context
7854
+ * @param definition - Error definition to wrap this error with
7855
+ * @returns New AlienError with this error as the source
7856
+ *
7857
+ * @example
7858
+ * ```typescript
7859
+ * // Clean fluent API
7860
+ * const authError = (await AlienError.from(new Error("ECONNREFUSED")))
7861
+ * .withContext(DatabaseError.create({
7862
+ * host: "localhost",
7863
+ * port: 5432,
7864
+ * reason: "Connection refused"
7865
+ * }))
7866
+ * .withContext(AuthError.create({
7867
+ * username: "john",
7868
+ * reason: "Database unavailable"
7869
+ * }))
7870
+ *
7871
+ * // Error chain: AuthError -> DatabaseError -> GENERIC_ERROR
7872
+ * console.log(authError.toString())
7873
+ * ```
7476
7874
  */
7477
- maxReplicas(max) {
7478
- if (!this._config.autoscaling) this._config.autoscaling = {
7479
- min: 1,
7480
- desired: 1,
7481
- max
7875
+ withContext(definition) {
7876
+ const { metadata, context: contextData } = definition;
7877
+ const message = metadata.message(contextData);
7878
+ const sourceOptions = {
7879
+ code: this.code,
7880
+ message: this.message,
7881
+ retryable: this.retryable,
7882
+ internal: this.internal,
7883
+ httpStatusCode: this.httpStatusCode,
7884
+ context: this.context,
7885
+ hint: this.hint,
7886
+ source: this.source?.toOptions()
7482
7887
  };
7483
- else this._config.autoscaling.max = max;
7484
- return this;
7485
- }
7486
- /**
7487
- * Sets a fixed replica count (for stateful containers or stateless without autoscaling).
7488
- * Cannot be used with minReplicas/maxReplicas.
7489
- * @param count Fixed number of replicas.
7490
- * @returns The Container builder instance.
7491
- */
7492
- replicas(count) {
7493
- this._config.replicas = count;
7494
- this._config.autoscaling = void 0;
7495
- return this;
7888
+ return new AlienError({
7889
+ code: metadata.code,
7890
+ message,
7891
+ retryable: metadata.retryable,
7892
+ internal: metadata.internal,
7893
+ httpStatusCode: metadata.httpStatusCode,
7894
+ context: contextData,
7895
+ source: sourceOptions
7896
+ });
7496
7897
  }
7497
7898
  /**
7498
- * Configures autoscaling behavior.
7499
- * @param config Autoscaling configuration.
7500
- * @returns The Container builder instance.
7899
+ * Convert this AlienError to the wire format (AlienErrorOptions).
7900
+ *
7901
+ * This method serializes the error into the standard format used
7902
+ * for transmitting errors over the network or storing them.
7903
+ *
7904
+ * @returns AlienErrorOptions object representing this error
7501
7905
  */
7502
- autoScale(config) {
7503
- this._config.autoscaling = config;
7504
- return this;
7906
+ toOptions() {
7907
+ return {
7908
+ code: this.code,
7909
+ message: this.message,
7910
+ retryable: this.retryable,
7911
+ internal: this.internal,
7912
+ httpStatusCode: this.httpStatusCode,
7913
+ context: this.context,
7914
+ hint: this.hint,
7915
+ source: this.source?.toOptions()
7916
+ };
7505
7917
  }
7506
7918
  /**
7507
- * Sets whether this container is stateful.
7508
- * Stateful containers get stable ordinals and support persistent storage.
7509
- * @param enabled Whether the container is stateful.
7510
- * @returns The Container builder instance.
7919
+ * Get a sanitized version for external APIs (hides internal errors).
7920
+ *
7921
+ * This method is crucial for security - it prevents sensitive internal
7922
+ * error details from being exposed to external users while preserving
7923
+ * the error chain structure for non-sensitive errors.
7924
+ *
7925
+ * @returns Sanitized AlienErrorOptions safe for external consumption
7926
+ *
7927
+ * @example
7928
+ * ```typescript
7929
+ * const internalError = new AlienError(InternalApiError.create({
7930
+ * service: "payment-processor",
7931
+ * details: "Database password expired for user admin",
7932
+ * traceId: "trace-12345"
7933
+ * }))
7934
+ *
7935
+ * console.log(internalError.toOptions())
7936
+ * // Shows full details including sensitive information
7937
+ *
7938
+ * console.log(internalError.toExternal())
7939
+ * // { code: "GENERIC_ERROR", message: "Internal server error", ... }
7940
+ * ```
7511
7941
  */
7512
- stateful(enabled) {
7513
- this._config.stateful = enabled;
7514
- return this;
7942
+ toExternal() {
7943
+ if (this.internal) return {
7944
+ code: "GENERIC_ERROR",
7945
+ message: "Internal server error",
7946
+ retryable: false,
7947
+ internal: false,
7948
+ httpStatusCode: 500
7949
+ };
7950
+ return {
7951
+ code: this.code,
7952
+ message: this.message,
7953
+ retryable: this.retryable,
7954
+ internal: this.internal,
7955
+ httpStatusCode: this.httpStatusCode,
7956
+ context: this.context,
7957
+ hint: this.hint,
7958
+ source: this.source?.toExternal()
7959
+ };
7515
7960
  }
7516
7961
  /**
7517
- * Adds an internal-only port to the container.
7518
- * Automatically creates DNS records for service discovery.
7519
- * @param port Port number (e.g., 3000, 8080, 5432).
7520
- * @returns The Container builder instance.
7962
+ * Check if this error chain contains an error with a specific code.
7963
+ *
7964
+ * This method traverses the entire error chain (this error and all
7965
+ * source errors) to find if any error has the specified code.
7966
+ *
7967
+ * @param code - Error code to search for
7968
+ * @returns True if the code is found anywhere in the error chain
7969
+ *
7970
+ * @example
7971
+ * ```typescript
7972
+ * const chainedError = authError.withContext(dbError.withContext(networkError))
7973
+ *
7974
+ * console.log(chainedError.hasErrorCode("AUTH_FAILED")) // true
7975
+ * console.log(chainedError.hasErrorCode("DATABASE_CONNECTION_FAILED")) // true
7976
+ * console.log(chainedError.hasErrorCode("NETWORK_TIMEOUT")) // true
7977
+ * console.log(chainedError.hasErrorCode("NONEXISTENT_ERROR")) // false
7978
+ * ```
7521
7979
  */
7522
- port(port) {
7523
- if (!this._config.ports) this._config.ports = [];
7524
- this._config.ports.push({ port });
7525
- return this;
7980
+ hasErrorCode(code) {
7981
+ if (this.code === code) return true;
7982
+ return this.source?.hasErrorCode(code) ?? false;
7526
7983
  }
7527
7984
  /**
7528
- * Adds multiple internal-only ports to the container.
7529
- * @param ports Array of port numbers.
7530
- * @returns The Container builder instance.
7985
+ * Find the first error in the chain with a specific code.
7986
+ *
7987
+ * This method traverses the error chain and returns the first error
7988
+ * instance that matches the specified code, allowing access to its
7989
+ * specific context and details.
7990
+ *
7991
+ * @param code - Error code to search for
7992
+ * @returns AlienError instance with the specified code, or undefined if not found
7993
+ *
7994
+ * @example
7995
+ * ```typescript
7996
+ * const chainedError = authError.withContext(dbError)
7997
+ *
7998
+ * const dbError = chainedError.findErrorByCode("DATABASE_CONNECTION_FAILED")
7999
+ * if (dbError) {
8000
+ * console.log("Database error context:", dbError.context)
8001
+ * console.log("Host:", dbError.context?.host)
8002
+ * }
8003
+ * ```
7531
8004
  */
7532
- ports(ports) {
7533
- if (!this._config.ports) this._config.ports = [];
7534
- this._config.ports.push(...ports.map((port) => ({ port })));
7535
- return this;
8005
+ findErrorByCode(code) {
8006
+ if (this.code === code) return this;
8007
+ return this.source?.findErrorByCode(code);
7536
8008
  }
7537
8009
  /**
7538
- * Exposes a named public endpoint for a container port.
8010
+ * Get a formatted string representation of the error chain.
7539
8011
  *
7540
- * Endpoint names are the stable contract for URLs, DNS, and runtime
7541
- * environment injection.
8012
+ * This method provides a human-readable representation of the entire
8013
+ * error chain, showing how errors are nested and providing context
8014
+ * for debugging and logging.
7542
8015
  *
7543
- * @param name Endpoint name, unique within this container.
7544
- * @param port Port number to expose.
7545
- * @param options "http"/"tcp" or endpoint options.
7546
- * @returns The Container builder instance.
7547
- */
7548
- publicEndpoint(name, port, options = "http") {
7549
- if (!this._config.ports) this._config.ports = [];
7550
- if (!this._config.publicEndpoints) this._config.publicEndpoints = [];
7551
- const endpoint = typeof options === "string" ? {
7552
- protocol: options,
7553
- hostLabel: void 0,
7554
- wildcardSubdomains: false
7555
- } : options;
7556
- if (!this._config.ports.some((p) => p.port === port)) this._config.ports.push({ port });
7557
- this._config.publicEndpoints.push({
7558
- name,
7559
- port,
7560
- protocol: endpoint.protocol,
7561
- hostLabel: endpoint.hostLabel,
7562
- wildcardSubdomains: endpoint.wildcardSubdomains ?? false
7563
- });
7564
- return this;
7565
- }
7566
- /**
7567
- * Sets environment variables for the container.
7568
- * @param vars Key-value pairs of environment variables.
7569
- * @returns The Container builder instance.
7570
- */
7571
- environment(vars) {
7572
- this._config.environment = {
7573
- ...this._config.environment,
7574
- ...vars
7575
- };
7576
- return this;
7577
- }
7578
- /**
7579
- * Sets ephemeral storage size.
7580
- * Data is lost on container restart.
7581
- * @param size Storage size (e.g., "10Gi", "100Gi", "500Gi").
7582
- * @returns The Container builder instance.
7583
- */
7584
- ephemeralStorage(size) {
7585
- this._config.ephemeralStorage = size;
7586
- return this;
7587
- }
7588
- /**
7589
- * Configures persistent storage and marks the container stateful.
7590
- * Data survives container restarts.
7591
- * @param size Storage size (e.g., "100Gi", "500Gi", "1Ti").
7592
- * @param options Optional mount path.
7593
- * @returns The Container builder instance.
7594
- */
7595
- persistentStorage(size, options = {}) {
7596
- const persistentStorage = {
7597
- size,
7598
- mountPath: options.mountPath ?? "/data"
7599
- };
7600
- this._config.persistentStorage = persistentStorage;
7601
- this._config.stateful = true;
7602
- return this;
7603
- }
7604
- /**
7605
- * Requests GPU resources.
7606
- * @param config GPU configuration with type and count.
7607
- * @returns The Container builder instance.
7608
- */
7609
- gpu(config) {
7610
- this._config.gpu = config;
7611
- return this;
7612
- }
7613
- /**
7614
- * Configures health check for the container.
7615
- * @param config Health check configuration.
7616
- * @returns The Container builder instance.
7617
- */
7618
- healthCheck(config) {
7619
- this._config.healthCheck = config;
7620
- return this;
7621
- }
7622
- /**
7623
- * Configures readiness probe (alias for healthCheck).
7624
- * @param config Readiness probe configuration with method and path.
7625
- * @returns The Container builder instance.
7626
- */
7627
- readinessProbe(config) {
7628
- this._config.healthCheck = {
7629
- path: config.path,
7630
- method: config.method,
7631
- timeoutSeconds: 1,
7632
- failureThreshold: 3
7633
- };
7634
- return this;
7635
- }
7636
- /**
7637
- * Sets the permission profile for this container.
7638
- * @param profile Permission profile name from stack permissions configuration.
7639
- * @returns The Container builder instance.
7640
- */
7641
- permissions(profile) {
7642
- this._config.permissions = profile;
7643
- return this;
7644
- }
7645
- /**
7646
- * Assigns the container to a specific compute pool.
7647
- * @param poolName Compute pool name.
7648
- * @returns The Container builder instance.
7649
- */
7650
- pool(poolName) {
7651
- this._config.pool = poolName;
7652
- return this;
7653
- }
7654
- /**
7655
- * Sets the command to override the image default.
7656
- * @param command Array of command arguments.
7657
- * @returns The Container builder instance.
7658
- */
7659
- command(command) {
7660
- this._config.command = command;
7661
- return this;
7662
- }
7663
- /**
7664
- * Sets the grace period used when stopping replicas during updates, drains, and deletes.
8016
+ * @returns Formatted string showing the complete error chain
7665
8017
  *
7666
- * The value is expressed in seconds. Valid values are 1 through 86400.
7667
- */
7668
- stopGracePeriod(seconds) {
7669
- this._config.stopGracePeriodSeconds = seconds;
7670
- return this;
7671
- }
7672
- /**
7673
- * Links this container to another resource (Storage, Queue, KV, etc.).
7674
- * @param resource The resource to link to.
7675
- * @returns The Container builder instance.
7676
- */
7677
- link(resource) {
7678
- if (!this._config.links) this._config.links = [];
7679
- this._config.links.push(resource.ref());
7680
- return this;
7681
- }
7682
- /**
7683
- * Enables or disables the Commands protocol for the container.
7684
- * When enabled, an app-owned receiver can lease this Container's pending commands and execute registered handlers.
7685
- * Default: false.
7686
- * @param enabled Whether to enable commands for this container.
7687
- * @returns The Container builder instance.
7688
- */
7689
- commandsEnabled(enabled) {
7690
- this._config.commandsEnabled = enabled;
7691
- return this;
7692
- }
7693
- /**
7694
- * Builds and validates the container configuration.
7695
- * @returns An immutable Resource representing the configured container.
7696
- * @throws Error if the container configuration is invalid.
8018
+ * @example
8019
+ * ```typescript
8020
+ * const chainedError = authError.withContext(dbError.withContext(networkError))
8021
+ * console.log(chainedError.toString())
8022
+ * // Output:
8023
+ * // AUTH_FAILED: User authentication failed for 'john'
8024
+ * // ├─▶ DATABASE_CONNECTION_FAILED: Failed to connect to database 'localhost:5432'
8025
+ * // ├─▶ GENERIC_ERROR: Connection timeout
8026
+ * ```
7697
8027
  */
7698
- build() {
7699
- const config = ContainerSchema.parse(this._config);
7700
- return this.resource({
7701
- type: "container",
7702
- ...config
7703
- });
8028
+ toString() {
8029
+ let result = `${this.code}: ${this.message}`;
8030
+ let current = this.source;
8031
+ let indent = "";
8032
+ while (current) {
8033
+ indent += " ";
8034
+ result += `\n${indent}├─▶ ${current.code}: ${current.message}`;
8035
+ current = current.source;
8036
+ }
8037
+ return result;
7704
8038
  }
7705
8039
  };
7706
8040
  //#endregion
8041
+ //#region src/common-errors.ts
8042
+ /**
8043
+ * Error thrown when a requested resource cannot be found in the stack state.
8044
+ * This matches the Rust alien-core error: RESOURCE_NOT_FOUND
8045
+ */
8046
+ const ResourceNotFoundError = defineError({
8047
+ code: "RESOURCE_NOT_FOUND",
8048
+ context: z$1.object({
8049
+ resourceId: z$1.string(),
8050
+ availableResources: z$1.array(z$1.string())
8051
+ }),
8052
+ message: ({ resourceId, availableResources }) => `Resource '${resourceId}' not found in stack state. Available resources: ${JSON.stringify(availableResources)}`,
8053
+ retryable: false,
8054
+ internal: false,
8055
+ httpStatusCode: 404
8056
+ });
8057
+ /**
8058
+ * Error thrown when resource outputs cannot be parsed according to their expected schema.
8059
+ * This indicates an internal system error or data corruption.
8060
+ */
8061
+ const ResourceOutputsParseError = defineError({
8062
+ code: "RESOURCE_OUTPUTS_PARSE_ERROR",
8063
+ context: z$1.object({
8064
+ resourceName: z$1.string(),
8065
+ resourceType: z$1.string(),
8066
+ validationErrors: z$1.string()
8067
+ }),
8068
+ message: ({ resourceName, resourceType, validationErrors }) => `Failed to parse outputs for resource '${resourceName}' of type '${resourceType}':\n${validationErrors}`,
8069
+ retryable: false,
8070
+ internal: true,
8071
+ httpStatusCode: 500
8072
+ });
8073
+ /**
8074
+ * Error thrown when there's a resource type mismatch during stack operations.
8075
+ * This matches the Rust alien-core error: UNEXPECTED_RESOURCE_TYPE
8076
+ */
8077
+ const UnexpectedResourceTypeError = defineError({
8078
+ code: "UNEXPECTED_RESOURCE_TYPE",
8079
+ context: z$1.object({
8080
+ resourceId: z$1.string(),
8081
+ expected: z$1.string(),
8082
+ actual: z$1.string()
8083
+ }),
8084
+ message: ({ resourceId, expected, actual }) => `Unexpected resource type for resource '${resourceId}': expected ${expected}, but got ${actual}`,
8085
+ retryable: false,
8086
+ internal: false,
8087
+ httpStatusCode: 400
8088
+ });
8089
+ /**
8090
+ * Error thrown when a binding's projected configuration is invalid.
8091
+ */
8092
+ const InvalidBindingConfigError = defineError({
8093
+ code: "INVALID_BINDING_CONFIG",
8094
+ context: z$1.object({
8095
+ message: z$1.string(),
8096
+ suggestion: z$1.string().optional()
8097
+ }),
8098
+ message: ({ message, suggestion }) => suggestion ? `${message}. ${suggestion}` : message,
8099
+ retryable: false,
8100
+ internal: false,
8101
+ httpStatusCode: 400
8102
+ });
8103
+ /**
8104
+ * Error thrown when a binding is not found.
8105
+ */
8106
+ const BindingNotFoundError = defineError({
8107
+ code: "BINDING_NOT_FOUND",
8108
+ context: z$1.object({
8109
+ bindingName: z$1.string(),
8110
+ bindingType: z$1.string()
8111
+ }),
8112
+ message: ({ bindingName, bindingType }) => `${bindingType} binding '${bindingName}' not found`,
8113
+ retryable: false,
8114
+ internal: false,
8115
+ httpStatusCode: 404
8116
+ });
8117
+ //#endregion
7707
8118
  //#region src/compute-cluster.ts
7708
8119
  /**
7709
8120
  * Declares a ComputeCluster — the setup-owned machine boundary for daemons and
@@ -7815,62 +8226,67 @@ function parseQuantityBytes(value) {
7815
8226
  return Math.round(amount * (suffix === "Ti" ? 1024 ** 4 : suffix === "Gi" ? 1024 ** 3 : suffix === "Mi" ? 1024 ** 2 : suffix === "Ki" ? 1024 : suffix === "T" ? 1e3 ** 4 : suffix === "G" ? 1e3 ** 3 : suffix === "M" ? 1e3 ** 2 : suffix === "k" ? 1e3 : 1));
7816
8227
  }
7817
8228
  //#endregion
7818
- //#region src/daemon.ts
8229
+ //#region src/container.ts
7819
8230
  /**
7820
- * Represents a resident process that runs once per eligible machine or node.
8231
+ * Represents a long-running container workload.
7821
8232
  *
7822
- * Daemons are intended for long-lived background processes such as endpoint
7823
- * agents and local side services.
8233
+ * Containers run on compute instances (EC2, GCE, Azure VMs) and are orchestrated
8234
+ * by the managed container backend. They're designed for always-on workloads
8235
+ * like web services, APIs, databases, and background workers.
7824
8236
  */
7825
- var Daemon = class extends ResourceBuilder {
8237
+ var Container = class extends ResourceBuilder {
7826
8238
  _config = {
7827
8239
  links: [],
8240
+ ports: [],
7828
8241
  publicEndpoints: [],
7829
8242
  environment: {},
7830
- cpu: {
7831
- min: "0.1",
7832
- desired: "0.1"
7833
- },
7834
- memory: {
7835
- min: "128Mi",
7836
- desired: "128Mi"
7837
- }
8243
+ stateful: false
7838
8244
  };
7839
8245
  /**
7840
- * Creates a new Daemon builder.
7841
- * @param id Identifier for the daemon. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
8246
+ * Creates a new Container builder.
8247
+ * @param id Identifier for the container. Must be DNS-compatible: lowercase alphanumeric with hyphens.
7842
8248
  */
7843
8249
  constructor(id) {
7844
8250
  super();
7845
8251
  this._config.id = id;
7846
8252
  }
7847
8253
  /**
7848
- * Returns a ResourceType representing any daemon resource.
7849
- * Used for creating permission targets that apply to all daemon resources.
7850
- * @returns The "daemon" resource type.
8254
+ * Returns a ResourceType representing any container resource.
8255
+ * Used for creating permission targets that apply to all container resources.
8256
+ * @returns The "container" resource type.
7851
8257
  */
7852
8258
  static any() {
7853
- return "daemon";
8259
+ return "container";
7854
8260
  }
7855
8261
  /**
7856
- * Sets the code for the daemon, either a pre-built image or source code to be built.
7857
- * @param code The daemon code configuration.
7858
- * @returns The Daemon builder instance.
8262
+ * Sets the container cluster this container runs on.
8263
+ * @param clusterId The ComputeCluster resource ID.
8264
+ * @returns The Container builder instance.
7859
8265
  */
7860
- code(code) {
7861
- this._config.code = code;
8266
+ cluster(clusterId) {
8267
+ this._config.cluster = clusterId;
7862
8268
  return this;
7863
8269
  }
7864
8270
  /**
7865
- * Sets the ComputeCluster this daemon runs on for AWS/GCP/Azure deployments.
7866
- * Kubernetes and Local deployments ignore this field.
8271
+ * Sets the code for the container, either a pre-built image or source code to be built.
8272
+ * @param code The container code configuration.
8273
+ * @returns The Container builder instance.
7867
8274
  */
7868
- cluster(clusterId) {
7869
- this._config.cluster = clusterId;
8275
+ code(code) {
8276
+ this._config.code = code;
7870
8277
  return this;
7871
8278
  }
7872
8279
  /**
7873
- * Sets CPU resources for each daemon instance.
8280
+ * Sets the CPU resources for the container.
8281
+ *
8282
+ * For simplified configuration, use a single number:
8283
+ * - `.cpu(1)` sets both min and desired to 1 vCPU
8284
+ *
8285
+ * For advanced configuration, use ResourceSpec:
8286
+ * - `.cpu({ min: "0.5", desired: "1" })`
8287
+ *
8288
+ * @param value CPU in vCPUs (number) or ResourceSpec with min/desired.
8289
+ * @returns The Container builder instance.
7874
8290
  */
7875
8291
  cpu(value) {
7876
8292
  if (typeof value === "number") this._config.cpu = {
@@ -7881,7 +8297,14 @@ var Daemon = class extends ResourceBuilder {
7881
8297
  return this;
7882
8298
  }
7883
8299
  /**
7884
- * Sets memory resources for each daemon instance.
8300
+ * Sets the memory resources for the container.
8301
+ *
8302
+ * Format: "<number>Mi" or "<number>Gi"
8303
+ *
8304
+ * Example: "512Mi", "2Gi", "16Gi"
8305
+ *
8306
+ * @param size Memory size string.
8307
+ * @returns The Container builder instance.
7885
8308
  */
7886
8309
  memory(size) {
7887
8310
  this._config.memory = {
@@ -7891,60 +8314,169 @@ var Daemon = class extends ResourceBuilder {
7891
8314
  return this;
7892
8315
  }
7893
8316
  /**
7894
- * Sets the backend pool/capacity group for daemon placement.
8317
+ * Sets minimum and maximum replica counts with autoscaling configuration.
8318
+ *
8319
+ * @param min Minimum replicas (always running).
8320
+ * @param max Maximum replicas under load.
8321
+ * @returns The Container builder instance.
7895
8322
  */
7896
- pool(pool) {
7897
- this._config.pool = pool;
8323
+ minReplicas(min) {
8324
+ if (!this._config.autoscaling) this._config.autoscaling = {
8325
+ min,
8326
+ desired: min,
8327
+ max: min * 10
8328
+ };
8329
+ else {
8330
+ this._config.autoscaling.min = min;
8331
+ this._config.autoscaling.desired = min;
8332
+ }
7898
8333
  return this;
7899
8334
  }
7900
8335
  /**
7901
- * Overrides the image default command.
8336
+ * Sets the maximum replica count for autoscaling.
8337
+ * @param max Maximum replicas.
8338
+ * @returns The Container builder instance.
7902
8339
  */
7903
- command(command) {
7904
- this._config.command = command;
8340
+ maxReplicas(max) {
8341
+ if (!this._config.autoscaling) this._config.autoscaling = {
8342
+ min: 1,
8343
+ desired: 1,
8344
+ max
8345
+ };
8346
+ else this._config.autoscaling.max = max;
7905
8347
  return this;
7906
8348
  }
7907
8349
  /**
7908
- * Sets the grace period used when stopping daemon instances during updates, drains, and deletes.
7909
- *
7910
- * The value is expressed in seconds. Valid values are 1 through 86400.
8350
+ * Sets a fixed replica count (for stateful containers or stateless without autoscaling).
8351
+ * Cannot be used with minReplicas/maxReplicas.
8352
+ * @param count Fixed number of replicas.
8353
+ * @returns The Container builder instance.
7911
8354
  */
7912
- stopGracePeriod(seconds) {
7913
- this._config.stopGracePeriodSeconds = seconds;
8355
+ replicas(count) {
8356
+ this._config.replicas = count;
8357
+ this._config.autoscaling = void 0;
7914
8358
  return this;
7915
8359
  }
7916
8360
  /**
7917
- * Sets backend runtime options for trusted daemon infrastructure.
7918
- *
7919
- * Use this only for daemons that intentionally need host-level access, such
7920
- * as a privileged loader that installs or supervises a native host process.
8361
+ * Configures autoscaling behavior.
8362
+ * @param config Autoscaling configuration.
8363
+ * @returns The Container builder instance.
7921
8364
  */
7922
- runtime(runtime) {
7923
- this._config.runtime = runtime;
8365
+ autoScale(config) {
8366
+ this._config.autoscaling = config;
7924
8367
  return this;
7925
8368
  }
7926
8369
  /**
7927
- * Exposes a named public endpoint for a daemon port.
8370
+ * Sets whether this container is stateful.
8371
+ * Stateful containers get stable ordinals and support persistent storage.
8372
+ * @param enabled Whether the container is stateful.
8373
+ * @returns The Container builder instance.
8374
+ */
8375
+ stateful(enabled) {
8376
+ this._config.stateful = enabled;
8377
+ return this;
8378
+ }
8379
+ /**
8380
+ * Adds an internal-only port to the container.
8381
+ * Automatically creates DNS records for service discovery.
8382
+ * @param port Port number (e.g., 3000, 8080, 5432).
8383
+ * @returns The Container builder instance.
8384
+ */
8385
+ port(port) {
8386
+ if (!this._config.ports) this._config.ports = [];
8387
+ this._config.ports.push({ port });
8388
+ return this;
8389
+ }
8390
+ /**
8391
+ * Adds multiple internal-only ports to the container.
8392
+ * @param ports Array of port numbers.
8393
+ * @returns The Container builder instance.
8394
+ */
8395
+ ports(ports) {
8396
+ if (!this._config.ports) this._config.ports = [];
8397
+ this._config.ports.push(...ports.map((port) => ({ port })));
8398
+ return this;
8399
+ }
8400
+ /**
8401
+ * Exposes a named public endpoint for a container port.
8402
+ *
8403
+ * Endpoint names are the stable contract for URLs, DNS, and runtime
8404
+ * environment injection.
8405
+ *
8406
+ * @param name Endpoint name, unique within this container.
8407
+ * @param port Port number to expose.
8408
+ * @param options "http"/"tcp" or endpoint options.
8409
+ * @returns The Container builder instance.
7928
8410
  */
7929
8411
  publicEndpoint(name, port, options = "http") {
8412
+ if (!this._config.ports) this._config.ports = [];
7930
8413
  if (!this._config.publicEndpoints) this._config.publicEndpoints = [];
7931
8414
  const endpoint = typeof options === "string" ? {
7932
8415
  protocol: options,
7933
8416
  hostLabel: void 0,
7934
8417
  wildcardSubdomains: false
7935
8418
  } : options;
7936
- const publicEndpoint = {
8419
+ if (!this._config.ports.some((p) => p.port === port)) this._config.ports.push({ port });
8420
+ this._config.publicEndpoints.push({
7937
8421
  name,
7938
8422
  port,
7939
8423
  protocol: endpoint.protocol,
7940
8424
  hostLabel: endpoint.hostLabel,
7941
8425
  wildcardSubdomains: endpoint.wildcardSubdomains ?? false
8426
+ });
8427
+ return this;
8428
+ }
8429
+ /**
8430
+ * Sets environment variables for the container.
8431
+ * @param vars Key-value pairs of environment variables.
8432
+ * @returns The Container builder instance.
8433
+ */
8434
+ environment(vars) {
8435
+ this._config.environment = {
8436
+ ...this._config.environment,
8437
+ ...vars
7942
8438
  };
7943
- this._config.publicEndpoints.push(publicEndpoint);
7944
8439
  return this;
7945
8440
  }
7946
8441
  /**
7947
- * Configures the HTTP health check used by public daemon endpoint load balancers.
8442
+ * Sets ephemeral storage size.
8443
+ * Data is lost on container restart.
8444
+ * @param size Storage size (e.g., "10Gi", "100Gi", "500Gi").
8445
+ * @returns The Container builder instance.
8446
+ */
8447
+ ephemeralStorage(size) {
8448
+ this._config.ephemeralStorage = size;
8449
+ return this;
8450
+ }
8451
+ /**
8452
+ * Configures persistent storage and marks the container stateful.
8453
+ * Data survives container restarts.
8454
+ * @param size Storage size (e.g., "100Gi", "500Gi", "1Ti").
8455
+ * @param options Optional mount path.
8456
+ * @returns The Container builder instance.
8457
+ */
8458
+ persistentStorage(size, options = {}) {
8459
+ const persistentStorage = {
8460
+ size,
8461
+ mountPath: options.mountPath ?? "/data"
8462
+ };
8463
+ this._config.persistentStorage = persistentStorage;
8464
+ this._config.stateful = true;
8465
+ return this;
8466
+ }
8467
+ /**
8468
+ * Requests GPU resources.
8469
+ * @param config GPU configuration with type and count.
8470
+ * @returns The Container builder instance.
8471
+ */
8472
+ gpu(config) {
8473
+ this._config.gpu = config;
8474
+ return this;
8475
+ }
8476
+ /**
8477
+ * Configures health check for the container.
8478
+ * @param config Health check configuration.
8479
+ * @returns The Container builder instance.
7948
8480
  */
7949
8481
  healthCheck(config) {
7950
8482
  this._config.healthCheck = config;
@@ -7952,6 +8484,8 @@ var Daemon = class extends ResourceBuilder {
7952
8484
  }
7953
8485
  /**
7954
8486
  * Configures readiness probe (alias for healthCheck).
8487
+ * @param config Readiness probe configuration with method and path.
8488
+ * @returns The Container builder instance.
7955
8489
  */
7956
8490
  readinessProbe(config) {
7957
8491
  this._config.healthCheck = {
@@ -7963,456 +8497,275 @@ var Daemon = class extends ResourceBuilder {
7963
8497
  return this;
7964
8498
  }
7965
8499
  /**
7966
- * Sets key-value pairs as environment variables for the daemon.
7967
- * @param env A map of environment variable names to their values.
7968
- * @returns The Daemon builder instance.
8500
+ * Sets the permission profile for this container.
8501
+ * @param profile Permission profile name from stack permissions configuration.
8502
+ * @returns The Container builder instance.
7969
8503
  */
7970
- environment(env) {
7971
- this._config.environment = env;
8504
+ permissions(profile) {
8505
+ this._config.permissions = profile;
7972
8506
  return this;
7973
8507
  }
7974
8508
  /**
7975
- * Links another resource to this daemon.
7976
- * This makes the linked resource accessible to the daemon, often by injecting
7977
- * environment variables or granting permissions.
7978
- * @param resource The resource to link.
7979
- * @returns The Daemon builder instance.
8509
+ * Assigns the container to a specific compute pool.
8510
+ * @param poolName Compute pool name.
8511
+ * @returns The Container builder instance.
7980
8512
  */
7981
- link(resource) {
7982
- if (!this._config.links) this._config.links = [];
7983
- this._config.links.push(resource.ref());
8513
+ pool(poolName) {
8514
+ this._config.pool = poolName;
7984
8515
  return this;
7985
8516
  }
7986
8517
  /**
7987
- * Assigns a permission profile to this daemon.
7988
- * The profile defines the permissions granted to this daemon when interacting
7989
- * with other cloud resources.
7990
- * @param permissions The permission profile name.
7991
- * @returns The Daemon builder instance.
8518
+ * Sets the command to override the image default.
8519
+ * @param command Array of command arguments.
8520
+ * @returns The Container builder instance.
7992
8521
  */
7993
- permissions(permissions) {
7994
- this._config.permissions = permissions;
8522
+ command(command) {
8523
+ this._config.command = command;
7995
8524
  return this;
7996
8525
  }
7997
8526
  /**
7998
- * Enables or disables the Commands protocol for the daemon.
7999
- * When enabled, an app-owned receiver can lease this Daemon's pending commands and execute registered handlers.
8527
+ * Sets the grace period used when stopping replicas during updates, drains, and deletes.
8528
+ *
8529
+ * The value is expressed in seconds. Valid values are 1 through 86400.
8530
+ */
8531
+ stopGracePeriod(seconds) {
8532
+ this._config.stopGracePeriodSeconds = seconds;
8533
+ return this;
8534
+ }
8535
+ /**
8536
+ * Links this container to another resource (Storage, Queue, KV, etc.).
8537
+ * @param resource The resource to link to.
8538
+ * @returns The Container builder instance.
8539
+ */
8540
+ link(resource) {
8541
+ if (!this._config.links) this._config.links = [];
8542
+ this._config.links.push(resource.ref());
8543
+ return this;
8544
+ }
8545
+ /**
8546
+ * Enables or disables the Commands protocol for the container.
8547
+ * When enabled, an app-owned receiver can lease this Container's pending commands and execute registered handlers.
8000
8548
  * Default: false.
8001
- * @param enabled Whether to enable commands for this daemon.
8002
- * @returns The Daemon builder instance.
8549
+ * @param enabled Whether to enable commands for this container.
8550
+ * @returns The Container builder instance.
8003
8551
  */
8004
8552
  commandsEnabled(enabled) {
8005
8553
  this._config.commandsEnabled = enabled;
8006
8554
  return this;
8007
8555
  }
8008
8556
  /**
8009
- * Builds and validates the daemon configuration.
8010
- * @returns An immutable Resource representing the configured daemon.
8011
- * @throws Error if the daemon configuration is invalid.
8557
+ * Builds and validates the container configuration.
8558
+ * @returns An immutable Resource representing the configured container.
8559
+ * @throws Error if the container configuration is invalid.
8012
8560
  */
8013
8561
  build() {
8014
- const config = DaemonSchema.parse(this._config);
8562
+ const config = ContainerSchema.parse(this._config);
8015
8563
  return this.resource({
8016
- type: "daemon",
8564
+ type: "container",
8017
8565
  ...config
8018
8566
  });
8019
8567
  }
8020
8568
  };
8021
8569
  //#endregion
8022
- //#region src/build.ts
8570
+ //#region src/daemon.ts
8023
8571
  /**
8024
- * Represents a build resource that executes bash scripts to build code.
8025
- * Builds are designed to be stateless and can be triggered on-demand to compile,
8026
- * test, or package application code.
8572
+ * Represents a resident process that runs once per eligible machine or node.
8573
+ *
8574
+ * Daemons are intended for long-lived background processes such as endpoint
8575
+ * agents and local side services.
8027
8576
  */
8028
- var Build = class {
8577
+ var Daemon = class extends ResourceBuilder {
8029
8578
  _config = {
8030
8579
  links: [],
8031
- environment: {}
8580
+ publicEndpoints: [],
8581
+ environment: {},
8582
+ cpu: {
8583
+ min: "0.1",
8584
+ desired: "0.1"
8585
+ },
8586
+ memory: {
8587
+ min: "128Mi",
8588
+ desired: "128Mi"
8589
+ }
8032
8590
  };
8033
8591
  /**
8034
- * Creates a new Build builder.
8035
- * @param id Identifier for the build resource. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
8592
+ * Creates a new Daemon builder.
8593
+ * @param id Identifier for the daemon. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
8036
8594
  */
8037
8595
  constructor(id) {
8596
+ super();
8038
8597
  this._config.id = id;
8039
8598
  }
8040
8599
  /**
8041
- * Returns a ResourceType representing any build resource.
8042
- * Used for creating permission targets that apply to all build resources.
8043
- * @returns The "build" resource type.
8600
+ * Returns a ResourceType representing any daemon resource.
8601
+ * Used for creating permission targets that apply to all daemon resources.
8602
+ * @returns The "daemon" resource type.
8044
8603
  */
8045
8604
  static any() {
8046
- return "build";
8605
+ return "daemon";
8047
8606
  }
8048
8607
  /**
8049
- * Sets the compute type for the build.
8050
- * @param type The compute type (small, medium, large, x-large).
8051
- * @returns The Build builder instance.
8608
+ * Sets the code for the daemon, either a pre-built image or source code to be built.
8609
+ * @param code The daemon code configuration.
8610
+ * @returns The Daemon builder instance.
8052
8611
  */
8053
- computeType(type) {
8054
- this._config.computeType = type;
8612
+ code(code) {
8613
+ this._config.code = code;
8055
8614
  return this;
8056
8615
  }
8057
8616
  /**
8058
- * Sets key-value pairs as environment variables for the build.
8059
- * @param env A map of environment variable names to their values.
8060
- * @returns The Build builder instance.
8617
+ * Sets the ComputeCluster this daemon runs on for AWS/GCP/Azure deployments.
8618
+ * Kubernetes and Local deployments ignore this field.
8061
8619
  */
8062
- environment(env) {
8063
- this._config.environment = env;
8620
+ cluster(clusterId) {
8621
+ this._config.cluster = clusterId;
8064
8622
  return this;
8065
8623
  }
8066
8624
  /**
8067
- * Links another resource (e.g., Storage, ArtifactRegistry, Role) to this build.
8068
- * This makes the linked resource accessible to the build, often by injecting
8069
- * environment variables or granting permissions.
8070
- * @param resource The resource to link.
8071
- * @returns The Build builder instance.
8625
+ * Sets CPU resources for each daemon instance.
8072
8626
  */
8073
- link(resource) {
8074
- if (!this._config.links) this._config.links = [];
8075
- this._config.links.push(resource.ref());
8627
+ cpu(value) {
8628
+ if (typeof value === "number") this._config.cpu = {
8629
+ min: value.toString(),
8630
+ desired: value.toString()
8631
+ };
8632
+ else this._config.cpu = value;
8076
8633
  return this;
8077
8634
  }
8078
8635
  /**
8079
- * Assigns a permission profile to this build.
8080
- * The profile defines the permissions granted to this build when interacting
8081
- * with other cloud resources.
8082
- * @param permissions The permission profile name.
8083
- * @returns The Build builder instance.
8636
+ * Sets memory resources for each daemon instance.
8084
8637
  */
8085
- permissions(permissions) {
8086
- this._config.permissions = permissions;
8638
+ memory(size) {
8639
+ this._config.memory = {
8640
+ min: size,
8641
+ desired: size
8642
+ };
8087
8643
  return this;
8088
8644
  }
8089
8645
  /**
8090
- * Builds and validates the build configuration.
8091
- * @returns An immutable Resource representing the configured build.
8092
- * @throws Error if the build configuration is invalid.
8646
+ * Sets the backend pool/capacity group for daemon placement.
8093
8647
  */
8094
- build() {
8095
- return new Resource({
8096
- type: "build",
8097
- ...BuildSchema.parse(this._config)
8098
- });
8648
+ pool(pool) {
8649
+ this._config.pool = pool;
8650
+ return this;
8099
8651
  }
8100
- };
8101
- //#endregion
8102
- //#region src/artifact-registry.ts
8103
- /**
8104
- * Represents an artifact registry for storing container images and other build artifacts.
8105
- * This is a high-level wrapper resource that provides a cloud-agnostic interface over
8106
- * AWS ECR, GCP Artifact Registry, and Azure Container Registry.
8107
- */
8108
- var ArtifactRegistry = class {
8109
- _config = {};
8110
8652
  /**
8111
- * Creates a new ArtifactRegistry builder.
8112
- * @param id Identifier for the artifact registry. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
8653
+ * Overrides the image default command.
8113
8654
  */
8114
- constructor(id) {
8115
- this._config.id = id;
8655
+ command(command) {
8656
+ this._config.command = command;
8657
+ return this;
8116
8658
  }
8117
8659
  /**
8118
- * Returns a ResourceType representing any artifact registry resource.
8119
- * Used for creating permission targets that apply to all artifact registry resources.
8120
- * @returns The "artifact-registry" resource type.
8660
+ * Sets the grace period used when stopping daemon instances during updates, drains, and deletes.
8661
+ *
8662
+ * The value is expressed in seconds. Valid values are 1 through 86400.
8121
8663
  */
8122
- static any() {
8123
- return "artifact-registry";
8664
+ stopGracePeriod(seconds) {
8665
+ this._config.stopGracePeriodSeconds = seconds;
8666
+ return this;
8124
8667
  }
8125
8668
  /**
8126
- * AWS-only: Configure ECR private image replication to additional regions.
8127
- * Ensures images pushed in the registry's home region are automatically
8128
- * available in these destination regions (required when Lambda or other
8129
- * compute runs in a different region).
8130
- * @param regions - AWS region codes to replicate to (e.g., ["us-east-2", "eu-west-1"])
8669
+ * Sets backend runtime options for trusted daemon infrastructure.
8670
+ *
8671
+ * Use this only for daemons that intentionally need host-level access, such
8672
+ * as a privileged loader that installs or supervises a native host process.
8131
8673
  */
8132
- replicationRegions(regions) {
8133
- this._config.replicationRegions = regions;
8674
+ runtime(runtime) {
8675
+ this._config.runtime = runtime;
8134
8676
  return this;
8135
8677
  }
8136
8678
  /**
8137
- * Builds and validates the artifact registry configuration.
8138
- * @returns An immutable Resource representing the configured artifact registry.
8139
- * @throws Error if the artifact registry configuration is invalid.
8679
+ * Exposes a named public endpoint for a daemon port.
8140
8680
  */
8141
- build() {
8142
- return new Resource({
8143
- type: "artifact-registry",
8144
- ...ArtifactRegistrySchema.parse(this._config)
8145
- });
8681
+ publicEndpoint(name, port, options = "http") {
8682
+ if (!this._config.publicEndpoints) this._config.publicEndpoints = [];
8683
+ const endpoint = typeof options === "string" ? {
8684
+ protocol: options,
8685
+ hostLabel: void 0,
8686
+ wildcardSubdomains: false
8687
+ } : options;
8688
+ const publicEndpoint = {
8689
+ name,
8690
+ port,
8691
+ protocol: endpoint.protocol,
8692
+ hostLabel: endpoint.hostLabel,
8693
+ wildcardSubdomains: endpoint.wildcardSubdomains ?? false
8694
+ };
8695
+ this._config.publicEndpoints.push(publicEndpoint);
8696
+ return this;
8146
8697
  }
8147
- };
8148
- //#endregion
8149
- //#region src/vault.ts
8150
- /**
8151
- * Represents a secure vault for storing secrets.
8152
- * This resource provides a platform-agnostic interface over cloud-native secret management services:
8153
- * - AWS: AWS Secrets Manager with prefixed secret names
8154
- * - GCP: Secret Manager with prefixed secret names
8155
- * - Azure: Key Vault resource
8156
- *
8157
- * The vault acts as a namespace for secrets and controls access permissions for workers and services.
8158
- */
8159
- var Vault = class extends ResourceBuilder {
8160
- _config = {};
8161
8698
  /**
8162
- * Creates a new Vault builder.
8163
- * @param id Identifier for the vault. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
8699
+ * Configures the HTTP health check used by public daemon endpoint load balancers.
8164
8700
  */
8165
- constructor(id) {
8166
- super();
8167
- this._config.id = id;
8701
+ healthCheck(config) {
8702
+ this._config.healthCheck = config;
8703
+ return this;
8168
8704
  }
8169
8705
  /**
8170
- * Returns a ResourceType representing any vault resource.
8171
- * Used for creating permission targets that apply to all vault resources.
8172
- * @returns The "vault" resource type.
8706
+ * Configures readiness probe (alias for healthCheck).
8173
8707
  */
8174
- static any() {
8175
- return "vault";
8708
+ readinessProbe(config) {
8709
+ this._config.healthCheck = {
8710
+ path: config.path,
8711
+ method: config.method,
8712
+ timeoutSeconds: 1,
8713
+ failureThreshold: 3
8714
+ };
8715
+ return this;
8176
8716
  }
8177
8717
  /**
8178
- * Builds and validates the vault configuration.
8179
- * @returns An immutable Resource representing the configured vault.
8180
- * @throws Error if the vault configuration is invalid.
8718
+ * Sets key-value pairs as environment variables for the daemon.
8719
+ * @param env A map of environment variable names to their values.
8720
+ * @returns The Daemon builder instance.
8181
8721
  */
8182
- build() {
8183
- const config = VaultSchema.parse(this._config);
8184
- return this.resource({
8185
- type: "vault",
8186
- ...config
8187
- });
8188
- }
8189
- };
8190
- //#endregion
8191
- //#region src/kv.ts
8192
- /**
8193
- * Represents a key-value store for data storage.
8194
- * This resource provides a platform-agnostic interface over cloud-native KV services:
8195
- * - AWS: DynamoDB with hash bucketing for load distribution
8196
- * - GCP: Firestore with document-based storage and collection management
8197
- * - Azure: Table Storage with client-side TTL filtering and partition fan-out
8198
- *
8199
- * The KV store supports basic operations: get, put, delete, exists, and scan_prefix.
8200
- * All operations support TTL for automatic expiration and conditional operations.
8201
- *
8202
- * Key Features:
8203
- * - Universal size limits: 512-byte keys, 24 KiB values
8204
- * - TTL support with logical expiry across all platforms
8205
- * - Atomic absent and version preconditions for puts and deletes
8206
- * - Prefix-based scanning with pagination
8207
- * - Platform-specific optimizations while maintaining consistent API
8208
- *
8209
- * Size Constraints:
8210
- * - Keys: ≤ 512 bytes with portable ASCII charset (a-z, A-Z, 0-9, -, _, :, .)
8211
- * - Values: ≤ 24,576 bytes (24 KiB)
8212
- *
8213
- * TTL Behavior:
8214
- * - Expired items appear absent on reads even if physically present
8215
- * - TTL precision varies by platform but logical behavior is consistent
8216
- *
8217
- * Scan Operations:
8218
- * - Returns arbitrary, unordered subsets in backend-natural order
8219
- * - No ordering guarantees across platforms
8220
- * - May return ≤ limit items (not guaranteed to fill)
8221
- * - Clients must de-duplicate keys across pages
8222
- * - No completeness guarantee under concurrent writes
8223
- */
8224
- var Kv = class extends ResourceBuilder {
8225
- _config = {};
8226
- /**
8227
- * Creates a new KV builder.
8228
- * @param id Identifier for the KV store. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
8229
- */
8230
- constructor(id) {
8231
- super();
8232
- this._config.id = id;
8233
- }
8234
- /**
8235
- * Returns a ResourceType representing any KV resource.
8236
- * Used for creating permission targets that apply to all KV resources.
8237
- * @returns The "kv" resource type.
8238
- */
8239
- static any() {
8240
- return "kv";
8241
- }
8242
- /**
8243
- * Builds and validates the KV configuration.
8244
- * @returns An immutable Resource representing the configured KV store.
8245
- * @throws Error if the KV configuration is invalid.
8246
- */
8247
- build() {
8248
- const config = KvSchema.parse(this._config);
8249
- return this.resource({
8250
- type: "kv",
8251
- ...config
8252
- });
8253
- }
8254
- };
8255
- //#endregion
8256
- //#region src/postgres.ts
8257
- /**
8258
- * Represents a managed PostgreSQL database. The target platform decides the backend;
8259
- * the database is private and reachable only by same-stack workloads.
8260
- */
8261
- var Postgres = class extends ResourceBuilder {
8262
- _config = {
8263
- version: "17",
8264
- storage: "20Gi",
8265
- highAvailability: false
8266
- };
8267
- /**
8268
- * Creates a new Postgres builder.
8269
- * @param id ID of the database. A database of this name is created on the server.
8270
- */
8271
- constructor(id) {
8272
- super();
8273
- this._config.id = id;
8274
- }
8275
- /**
8276
- * Returns a ResourceType representing any postgres resource.
8277
- * Used for creating permission targets that apply to all postgres resources.
8278
- * @returns The "postgres" resource type.
8279
- */
8280
- static any() {
8281
- return "postgres";
8282
- }
8283
- /**
8284
- * Sets the major engine version ("15" | "16" | "17"). Default `"17"`.
8285
- * The union narrows the generated schema's free-form string for authoring ergonomics;
8286
- * keep it in sync with the supported majors if the Rust `Postgres` resource adds one.
8287
- * @param value The major version.
8288
- * @returns The Postgres builder instance.
8289
- */
8290
- version(value) {
8291
- this._config.version = value;
8292
- return this;
8293
- }
8294
- /**
8295
- * Requests vCPUs (e.g. "0.5", "2"). On GCP and Azure, `cpu` and `memory` together pick the
8296
- * smallest tier that satisfies both. On AWS (Aurora Serverless v2) sizing comes from `memory`, so
8297
- * `cpu` is ignored.
8298
- * @param value The requested vCPUs.
8299
- * @returns The Postgres builder instance.
8300
- */
8301
- cpu(value) {
8302
- this._config.cpu = value;
8303
- return this;
8722
+ environment(env) {
8723
+ this._config.environment = env;
8724
+ return this;
8304
8725
  }
8305
8726
  /**
8306
- * Requests memory (e.g. "1Gi", "8Gi"). Drives the size on AWS (the ACU ceiling) and, together
8307
- * with `cpu`, the tier on GCP and Azure.
8308
- * @param value The requested memory.
8309
- * @returns The Postgres builder instance.
8727
+ * Links another resource to this daemon.
8728
+ * This makes the linked resource accessible to the daemon, often by injecting
8729
+ * environment variables or granting permissions.
8730
+ * @param resource The resource to link.
8731
+ * @returns The Daemon builder instance.
8310
8732
  */
8311
- memory(value) {
8312
- this._config.memory = value;
8733
+ link(resource) {
8734
+ if (!this._config.links) this._config.links = [];
8735
+ this._config.links.push(resource.ref());
8313
8736
  return this;
8314
8737
  }
8315
8738
  /**
8316
- * Sets allocated storage (e.g. "100Gi"). Default `"20Gi"`. Grow-only.
8317
- * @param value The storage size.
8318
- * @returns The Postgres builder instance.
8739
+ * Assigns a permission profile to this daemon.
8740
+ * The profile defines the permissions granted to this daemon when interacting
8741
+ * with other cloud resources.
8742
+ * @param permissions The permission profile name.
8743
+ * @returns The Daemon builder instance.
8319
8744
  */
8320
- storage(value) {
8321
- this._config.storage = value;
8745
+ permissions(permissions) {
8746
+ this._config.permissions = permissions;
8322
8747
  return this;
8323
8748
  }
8324
8749
  /**
8325
- * Enables multi-AZ / regional / zone-redundant high availability. Default `false`.
8326
- * @param value Whether to enable HA.
8327
- * @returns The Postgres builder instance.
8750
+ * Enables or disables the Commands protocol for the daemon.
8751
+ * When enabled, an app-owned receiver can lease this Daemon's pending commands and execute registered handlers.
8752
+ * Default: false.
8753
+ * @param enabled Whether to enable commands for this daemon.
8754
+ * @returns The Daemon builder instance.
8328
8755
  */
8329
- highAvailability(value = true) {
8330
- this._config.highAvailability = value;
8756
+ commandsEnabled(enabled) {
8757
+ this._config.commandsEnabled = enabled;
8331
8758
  return this;
8332
8759
  }
8333
8760
  /**
8334
- * Builds and validates the postgres configuration.
8335
- * @returns An immutable Resource representing the configured database.
8336
- * @throws Error if the configuration is invalid.
8337
- */
8338
- build() {
8339
- const config = PostgresSchema.parse(this._config);
8340
- return this.resource({
8341
- type: "postgres",
8342
- ...config
8343
- });
8344
- }
8345
- };
8346
- //#endregion
8347
- //#region src/ai.ts
8348
- /**
8349
- * Represents an AI Gateway resource that provides a unified interface to
8350
- * managed AI inference services across cloud providers.
8351
- */
8352
- var AI = class extends ResourceBuilder {
8353
- _config = {};
8354
- /**
8355
- * Creates a new AI builder.
8356
- * @param id Identifier for the AI resource. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
8357
- */
8358
- constructor(id) {
8359
- super();
8360
- this._config.id = id;
8361
- }
8362
- /**
8363
- * Returns a ResourceType representing any AI resource.
8364
- * Used for creating permission targets that apply to all AI resources.
8365
- * @returns The "ai" resource type.
8366
- */
8367
- static any() {
8368
- return "ai";
8369
- }
8370
- /**
8371
- * Builds and validates the AI configuration.
8372
- * @returns An immutable Resource representing the configured AI Gateway.
8373
- * @throws Error if the AI configuration is invalid.
8374
- */
8375
- build() {
8376
- const config = AiSchema.parse(this._config);
8377
- return this.resource({
8378
- type: "ai",
8379
- ...config
8380
- });
8381
- }
8382
- };
8383
- //#endregion
8384
- //#region src/queue.ts
8385
- /**
8386
- * Represents a message queue resource with minimal, portable semantics.
8387
- * Queue integrates with platform-native services (AWS SQS, GCP Pub/Sub, Azure Service Bus).
8388
- */
8389
- var Queue = class extends ResourceBuilder {
8390
- _config = {};
8391
- /**
8392
- * Creates a new Queue builder.
8393
- * @param id Identifier for the queue. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
8394
- */
8395
- constructor(id) {
8396
- super();
8397
- this._config.id = id;
8398
- }
8399
- /**
8400
- * Returns a ResourceType representing any queue resource.
8401
- * Used for creating permission targets that apply to all queue resources.
8402
- * @returns The "queue" resource type.
8403
- */
8404
- static any() {
8405
- return "queue";
8406
- }
8407
- /**
8408
- * Builds and validates the queue configuration.
8409
- * @returns An immutable Resource representing the configured queue.
8410
- * @throws Error if the queue configuration is invalid.
8761
+ * Builds and validates the daemon configuration.
8762
+ * @returns An immutable Resource representing the configured daemon.
8763
+ * @throws Error if the daemon configuration is invalid.
8411
8764
  */
8412
8765
  build() {
8413
- const config = QueueSchema.parse(this._config);
8766
+ const config = DaemonSchema.parse(this._config);
8414
8767
  return this.resource({
8415
- type: "queue",
8768
+ type: "daemon",
8416
8769
  ...config
8417
8770
  });
8418
8771
  }
@@ -8513,95 +8866,64 @@ var Email = class extends ResourceBuilder {
8513
8866
  }
8514
8867
  };
8515
8868
  //#endregion
8516
- //#region src/service-account.ts
8517
- /**
8518
- * Represents a non-human identity that can be assumed by compute services.
8519
- *
8520
- * Maps to:
8521
- * - AWS: IAM Role
8522
- * - GCP: Service Account
8523
- * - Azure: User-assigned Managed Identity
8524
- *
8525
- * ServiceAccounts can be used to grant specific permissions to compute resources
8526
- * and can be impersonated by other services for cross-account or cross-service access.
8527
- *
8528
- * @example
8529
- * ```typescript
8530
- * import { ServiceAccount, Worker } from "@alien/core"
8531
- *
8532
- * // Create a service account with stack-level permissions
8533
- * const dataProcessorAccount = new ServiceAccount("data-processor")
8534
- * .build()
8535
- *
8536
- * // Link it to a function to use its identity
8537
- * const processor = new Worker("processor")
8538
- * .code({ type: "image", image: "processor:latest" })
8539
- * .link(dataProcessorAccount)
8540
- * .build()
8541
- * ```
8542
- */
8543
- var ServiceAccount = class {
8544
- _config = { stackPermissionSets: [] };
8545
- /**
8546
- * Creates a new ServiceAccount builder.
8547
- * @param id Identifier for the service account. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
8548
- */
8549
- constructor(id) {
8550
- this._config.id = id;
8551
- }
8552
- /**
8553
- * Returns a ResourceType representing any service account resource.
8554
- * Used for creating permission targets that apply to all service account resources.
8555
- * @returns The "service-account" resource type.
8556
- */
8557
- static any() {
8558
- return "service-account";
8559
- }
8560
- /**
8561
- * Adds a stack-level permission set to the service account.
8562
- * Stack-level permissions apply to all resources in the stack.
8563
- *
8564
- * Note: Only inline permission set objects are supported. To use built-in permission sets,
8565
- * you need to resolve them first through the permission set registry or use permission profiles
8566
- * in your stack configuration.
8567
- *
8568
- * @example
8569
- * ```typescript
8570
- * import { ServiceAccount, type PermissionSet } from "@alien/core"
8571
- *
8572
- * const customPermissionSet: PermissionSet = {
8573
- * id: "custom/my-perms",
8574
- * description: "Custom permissions",
8575
- * platforms: {
8576
- * aws: [{ grant: { actions: ["s3:GetObject"] }, binding: { stack: { resources: ["*"] } } }]
8577
- * }
8578
- * }
8579
- *
8580
- * const account = new ServiceAccount("custom-processor")
8581
- * .stackPermissionSet(customPermissionSet)
8582
- * .build()
8583
- * ```
8584
- *
8585
- * @param permissionSet The permission set object with platform-specific permissions
8586
- * @returns The ServiceAccount builder instance.
8587
- */
8588
- stackPermissionSet(permissionSet) {
8589
- if (!this._config.stackPermissionSets) this._config.stackPermissionSets = [];
8590
- this._config.stackPermissionSets.push(permissionSet);
8591
- return this;
8592
- }
8593
- /**
8594
- * Builds and validates the service account configuration.
8595
- * @returns An immutable Resource representing the configured service account.
8596
- * @throws Error if the service account configuration is invalid.
8597
- */
8598
- build() {
8599
- return new Resource({
8600
- type: "service-account",
8601
- ...ServiceAccountSchema.parse(this._config)
8602
- });
8869
+ //#region src/get-resource-outputs.ts
8870
+ const ResourceSchemaMapping = {
8871
+ function: {
8872
+ input: WorkerSchema,
8873
+ output: WorkerOutputsSchema
8874
+ },
8875
+ container: {
8876
+ input: ContainerSchema,
8877
+ output: ContainerOutputsSchema
8878
+ },
8879
+ storage: {
8880
+ input: StorageSchema,
8881
+ output: StorageOutputsSchema
8882
+ },
8883
+ kv: {
8884
+ input: KvSchema,
8885
+ output: KvOutputsSchema
8886
+ },
8887
+ queue: {
8888
+ input: QueueSchema,
8889
+ output: QueueOutputsSchema
8890
+ },
8891
+ vault: {
8892
+ input: VaultSchema,
8893
+ output: VaultOutputsSchema
8894
+ },
8895
+ build: {
8896
+ input: BuildSchema,
8897
+ output: BuildOutputsSchema
8898
+ },
8899
+ "artifact-registry": {
8900
+ input: ArtifactRegistrySchema,
8901
+ output: ArtifactRegistryOutputsSchema
8902
+ },
8903
+ "service-account": {
8904
+ input: ServiceAccountSchema,
8905
+ output: ServiceAccountOutputsSchema
8906
+ },
8907
+ "remote-stack-management": {
8908
+ input: RemoteStackManagementSchema,
8909
+ output: RemoteStackManagementOutputsSchema
8603
8910
  }
8604
8911
  };
8912
+ function getResourceOutputs(params) {
8913
+ const { state, resource } = params;
8914
+ const resourceState = state.resources[resource.name];
8915
+ if (!resourceState) throw new AlienError(ResourceNotFoundError.create({
8916
+ resourceId: resource.name,
8917
+ availableResources: Object.keys(state.resources)
8918
+ }));
8919
+ const outputs = ResourceSchemaMapping[resource.type].output.safeParse(resourceState.outputs);
8920
+ if (!outputs.success) throw new AlienError(ResourceOutputsParseError.create({
8921
+ resourceName: resource.name,
8922
+ resourceType: resource.type,
8923
+ validationErrors: z$1.prettifyError(outputs.error)
8924
+ }));
8925
+ return outputs.data;
8926
+ }
8605
8927
  //#endregion
8606
8928
  //#region src/input.ts
8607
8929
  const stackInputDraftSymbol = Symbol("alien.stackInputDraft");
@@ -8730,7 +9052,7 @@ function toDefaultValue(kind, value) {
8730
9052
  }
8731
9053
  }
8732
9054
  function validateDraft(id, draft) {
8733
- if (!draft || draft[stackInputDraftSymbol] !== true) throw new Error(`Stack input '${id}' must be created with alien.string(), alien.secret(), or another input helper`);
9055
+ if (draft?.[stackInputDraftSymbol] !== true) throw new Error(`Stack input '${id}' must be created with alien.string(), alien.secret(), or another input helper`);
8734
9056
  if (normalizeArray(draft.options.providedBy).length === 0) throw new Error(`Stack input '${id}' must include at least one providedBy value`);
8735
9057
  if (!draft.options.label.trim()) throw new Error(`Stack input '${id}' must include a label`);
8736
9058
  if (draft.options.required && !draft.options.description.trim()) throw new Error(`Stack input '${id}' must include a description when required is true`);
@@ -8773,743 +9095,718 @@ function integerToString(value, field) {
8773
9095
  return String(value);
8774
9096
  }
8775
9097
  //#endregion
8776
- //#region src/stack.ts
9098
+ //#region src/key.ts
9099
+ /** A customer-managed encryption key. */
9100
+ var Key = class extends ResourceBuilder {
9101
+ _config = {};
9102
+ constructor(id) {
9103
+ super();
9104
+ this._config.id = id;
9105
+ }
9106
+ static any() {
9107
+ return "key";
9108
+ }
9109
+ build() {
9110
+ const config = KeySchema.parse(this._config);
9111
+ return this.resource({
9112
+ type: "key",
9113
+ ...config
9114
+ });
9115
+ }
9116
+ };
9117
+ //#endregion
9118
+ //#region src/kv.ts
8777
9119
  /**
8778
- * Represents a collection of cloud resources that are managed together.
8779
- * Stacks are the top-level organizational unit in an Alien application.
9120
+ * Represents a key-value store for data storage.
9121
+ * This resource provides a platform-agnostic interface over cloud-native KV services:
9122
+ * - AWS: DynamoDB with hash bucketing for load distribution
9123
+ * - GCP: Firestore with document-based storage and collection management
9124
+ * - Azure: Table Storage with client-side TTL filtering and partition fan-out
9125
+ *
9126
+ * The KV store supports basic operations: get, put, delete, exists, and scan_prefix.
9127
+ * All operations support TTL for automatic expiration and conditional operations.
9128
+ *
9129
+ * Key Features:
9130
+ * - Universal size limits: 512-byte keys, 24 KiB values
9131
+ * - TTL support with logical expiry across all platforms
9132
+ * - Atomic absent and version preconditions for puts and deletes
9133
+ * - Prefix-based scanning with pagination
9134
+ * - Platform-specific optimizations while maintaining consistent API
9135
+ *
9136
+ * Size Constraints:
9137
+ * - Keys: ≤ 512 bytes with portable ASCII charset (a-z, A-Z, 0-9, -, _, :, .)
9138
+ * - Values: ≤ 24,576 bytes (24 KiB)
9139
+ *
9140
+ * TTL Behavior:
9141
+ * - Expired items appear absent on reads even if physically present
9142
+ * - TTL precision varies by platform but logical behavior is consistent
9143
+ *
9144
+ * Scan Operations:
9145
+ * - Returns arbitrary, unordered subsets in backend-natural order
9146
+ * - No ordering guarantees across platforms
9147
+ * - May return ≤ limit items (not guaranteed to fill)
9148
+ * - Clients must de-duplicate keys across pages
9149
+ * - No completeness guarantee under concurrent writes
8780
9150
  */
8781
- var Stack = class {
8782
- _config = {
8783
- resources: {},
8784
- permissions: void 0
8785
- };
9151
+ var Kv = class extends ResourceBuilder {
9152
+ _config = {};
8786
9153
  /**
8787
- * Creates a new Stack builder.
8788
- * @param id Identifier for the stack. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 128 characters.
9154
+ * Creates a new KV builder.
9155
+ * @param id Identifier for the KV store. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
8789
9156
  */
8790
9157
  constructor(id) {
9158
+ super();
8791
9159
  this._config.id = id;
8792
9160
  }
8793
9161
  /**
8794
- * Adds a resource to the stack with a specified lifecycle.
8795
- * @param resource The resource to add (e.g., Worker, Storage).
8796
- * @param lifecycle The lifecycle state of the resource (e.g., Frozen, Live).
8797
- * @param options Optional configuration for the resource entry.
8798
- * @returns The Stack builder instance.
9162
+ * Returns a ResourceType representing any KV resource.
9163
+ * Used for creating permission targets that apply to all KV resources.
9164
+ * @returns The "kv" resource type.
8799
9165
  */
8800
- add(resource, lifecycle, options) {
8801
- const entry = {
8802
- config: resource.config,
8803
- lifecycle,
8804
- dependencies: []
8805
- };
8806
- if (options?.remoteAccess) entry.remoteAccess = true;
8807
- if (resource.enabledWhen !== void 0) entry.enabledWhen = resource.enabledWhen;
8808
- this._config.resources[resource.config.id] = entry;
8809
- return this;
9166
+ static any() {
9167
+ return "kv";
8810
9168
  }
8811
9169
  /**
8812
- * Declare which platforms this stack supports.
8813
- * When omitted, the stack supports all platforms.
9170
+ * Builds and validates the KV configuration.
9171
+ * @returns An immutable Resource representing the configured KV store.
9172
+ * @throws Error if the KV configuration is invalid.
8814
9173
  */
8815
- platforms(platforms) {
8816
- this._config.supportedPlatforms = platforms;
8817
- return this;
9174
+ build() {
9175
+ const config = KvSchema.parse(this._config);
9176
+ return this.resource({
9177
+ type: "kv",
9178
+ ...config
9179
+ });
8818
9180
  }
9181
+ };
9182
+ //#endregion
9183
+ //#region src/postgres.ts
9184
+ /**
9185
+ * Represents a managed PostgreSQL database. The target platform decides the backend;
9186
+ * the database is private and reachable only by same-stack workloads.
9187
+ */
9188
+ var Postgres = class extends ResourceBuilder {
9189
+ _config = {
9190
+ version: "17",
9191
+ storage: "20Gi",
9192
+ highAvailability: false
9193
+ };
8819
9194
  /**
8820
- * Configure permissions for this stack.
8821
- * @param config Permission configuration
8822
- * @returns The Stack builder instance.
9195
+ * Creates a new Postgres builder.
9196
+ * @param id ID of the database. A database of this name is created on the server.
8823
9197
  */
8824
- permissions(config) {
8825
- this._config.permissions = config;
8826
- return this;
9198
+ constructor(id) {
9199
+ super();
9200
+ this._config.id = id;
8827
9201
  }
8828
9202
  /**
8829
- * Configure values that must be provided before setup or deployment can proceed.
8830
- * @param inputs Stack input definitions created with alien.inputs({...}).
8831
- * @returns The Stack builder instance.
9203
+ * Returns a ResourceType representing any postgres resource.
9204
+ * Used for creating permission targets that apply to all postgres resources.
9205
+ * @returns The "postgres" resource type.
8832
9206
  */
8833
- inputs(inputs) {
8834
- this._config.inputs = getStackInputDefinitions(inputs);
8835
- return this;
9207
+ static any() {
9208
+ return "postgres";
8836
9209
  }
8837
9210
  /**
8838
- * Gets the stack ID without building/validating the stack.
8839
- * @returns The stack ID.
8840
- */
8841
- get id() {
8842
- return this._config.id;
9211
+ * Sets the major engine version ("15" | "16" | "17"). Default `"17"`.
9212
+ * The union narrows the generated schema's free-form string for authoring ergonomics;
9213
+ * keep it in sync with the supported majors if the Rust `Postgres` resource adds one.
9214
+ * @param value The major version.
9215
+ * @returns The Postgres builder instance.
9216
+ */
9217
+ version(value) {
9218
+ this._config.version = value;
9219
+ return this;
8843
9220
  }
8844
9221
  /**
8845
- * Builds and validates the stack configuration.
8846
- * @returns The complete and validated stack configuration.
8847
- * @throws Error if the stack configuration is invalid.
9222
+ * Requests vCPUs (e.g. "0.5", "2"). On GCP and Azure, `cpu` and `memory` together pick the
9223
+ * smallest tier that satisfies both. On AWS (Aurora Serverless v2) sizing comes from `memory`, so
9224
+ * `cpu` is ignored.
9225
+ * @param value The requested vCPUs.
9226
+ * @returns The Postgres builder instance.
9227
+ */
9228
+ cpu(value) {
9229
+ this._config.cpu = value;
9230
+ return this;
9231
+ }
9232
+ /**
9233
+ * Requests memory (e.g. "1Gi", "8Gi"). Drives the size on AWS (the ACU ceiling) and, together
9234
+ * with `cpu`, the tier on GCP and Azure.
9235
+ * @param value The requested memory.
9236
+ * @returns The Postgres builder instance.
9237
+ */
9238
+ memory(value) {
9239
+ this._config.memory = value;
9240
+ return this;
9241
+ }
9242
+ /**
9243
+ * Sets allocated storage (e.g. "100Gi"). Default `"20Gi"`. Grow-only.
9244
+ * @param value The storage size.
9245
+ * @returns The Postgres builder instance.
9246
+ */
9247
+ storage(value) {
9248
+ this._config.storage = value;
9249
+ return this;
9250
+ }
9251
+ /**
9252
+ * Enables multi-AZ / regional / zone-redundant high availability. Default `false`.
9253
+ * @param value Whether to enable HA.
9254
+ * @returns The Postgres builder instance.
9255
+ */
9256
+ highAvailability(value = true) {
9257
+ this._config.highAvailability = value;
9258
+ return this;
9259
+ }
9260
+ /**
9261
+ * Builds and validates the postgres configuration.
9262
+ * @returns An immutable Resource representing the configured database.
9263
+ * @throws Error if the configuration is invalid.
8848
9264
  */
8849
9265
  build() {
8850
- return StackSchema.parse(this._config);
9266
+ const config = PostgresSchema.parse(this._config);
9267
+ return this.resource({
9268
+ type: "postgres",
9269
+ ...config
9270
+ });
8851
9271
  }
8852
9272
  };
8853
9273
  //#endregion
8854
- //#region src/error.ts
9274
+ //#region src/queue.ts
8855
9275
  /**
8856
- * This module provides a structured error handling system similar to Rust's error types,
8857
- * with TypeScript type safety, error chaining, and context preservation.
8858
- *
8859
- * @example Basic Usage
8860
- * ```typescript
8861
- * import { AlienError, defineError } from '@alienplatform/core'
8862
- * import { z } from 'zod'
8863
- *
8864
- * // Define a type-safe error
8865
- * const DatabaseError = defineError({
8866
- * code: "DATABASE_CONNECTION_FAILED",
8867
- * context: z.object({
8868
- * host: z.string(),
8869
- * port: z.number(),
8870
- * reason: z.string(),
8871
- * }),
8872
- * message: ({ host, port, reason }) => `Failed to connect to database '${host}:${port}': ${reason}`,
8873
- * retryable: true,
8874
- * internal: false,
8875
- * httpStatusCode: 502,
8876
- * })
8877
- *
8878
- * // Use it
8879
- * throw new AlienError(DatabaseError.create({
8880
- * host: "localhost",
8881
- * port: 5432,
8882
- * reason: "Connection timeout"
8883
- * }))
8884
- * ```
8885
- *
8886
- * @example Error Chaining
8887
- * ```typescript
8888
- * try {
8889
- * // Some operation that fails
8890
- * throw new Error("Connection refused")
8891
- * } catch (error) {
8892
- * throw (await AlienError.from(error)).withContext(
8893
- * DatabaseError.create({
8894
- * host: "localhost",
8895
- * port: 5432,
8896
- * reason: "Connection refused by server"
8897
- * })
8898
- * )
8899
- * }
8900
- * ```
8901
- *
8902
- * @example External API Sanitization
8903
- * ```typescript
8904
- * const internalError = new AlienError(InternalApiError.create({
8905
- * service: "payment-processor",
8906
- * details: "Database password expired",
8907
- * traceId: "trace-12345"
8908
- * }))
8909
- *
8910
- * // Safe for external APIs (sanitizes internal errors)
8911
- * const safeResponse = internalError.toExternal()
8912
- * ```
9276
+ * Represents a message queue resource with minimal, portable semantics.
9277
+ * Queue integrates with platform-native services (AWS SQS, GCP Pub/Sub, Azure Service Bus).
8913
9278
  */
9279
+ var Queue = class extends ResourceBuilder {
9280
+ _config = {};
9281
+ /**
9282
+ * Creates a new Queue builder.
9283
+ * @param id Identifier for the queue. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
9284
+ */
9285
+ constructor(id) {
9286
+ super();
9287
+ this._config.id = id;
9288
+ }
9289
+ /**
9290
+ * Returns a ResourceType representing any queue resource.
9291
+ * Used for creating permission targets that apply to all queue resources.
9292
+ * @returns The "queue" resource type.
9293
+ */
9294
+ static any() {
9295
+ return "queue";
9296
+ }
9297
+ /**
9298
+ * Builds and validates the queue configuration.
9299
+ * @returns An immutable Resource representing the configured queue.
9300
+ * @throws Error if the queue configuration is invalid.
9301
+ */
9302
+ build() {
9303
+ const config = QueueSchema.parse(this._config);
9304
+ return this.resource({
9305
+ type: "queue",
9306
+ ...config
9307
+ });
9308
+ }
9309
+ };
9310
+ //#endregion
9311
+ //#region src/service-account.ts
8914
9312
  /**
8915
- * Helper function to create type-safe error definitions.
9313
+ * Represents a non-human identity that can be assumed by compute services.
8916
9314
  *
8917
- * This function provides a clean API for defining reusable error types
8918
- * with full TypeScript type safety and Zod validation.
9315
+ * Maps to:
9316
+ * - AWS: IAM Role
9317
+ * - GCP: Service Account
9318
+ * - Azure: User-assigned Managed Identity
8919
9319
  *
8920
- * @template TContext - Zod schema type for the error context
8921
- * @param metadata - Error metadata including code, schema, and message generator
8922
- * @returns Object with metadata and a create function for error instances
9320
+ * ServiceAccounts can be used to grant specific permissions to compute resources
9321
+ * and can be impersonated by other services for cross-account or cross-service access.
8923
9322
  *
8924
9323
  * @example
8925
9324
  * ```typescript
8926
- * const UserNotFound = defineError({
8927
- * code: "USER_NOT_FOUND",
8928
- * context: z.object({
8929
- * userId: z.string(),
8930
- * searchMethod: z.string(),
8931
- * }),
8932
- * message: ({ userId, searchMethod }) =>
8933
- * `User '${userId}' not found using method '${searchMethod}'`,
8934
- * retryable: false,
8935
- * internal: false,
8936
- * httpStatusCode: 404,
8937
- * })
8938
- *
8939
- * // Usage
8940
- * const error = UserNotFound.create({
8941
- * userId: "123",
8942
- * searchMethod: "database_lookup"
8943
- * })
8944
- * ```
8945
- */
8946
- function defineError(metadata) {
8947
- return {
8948
- metadata,
8949
- contextSchema: metadata.context,
8950
- create: (context) => ({
8951
- metadata,
8952
- contextSchema: metadata.context,
8953
- context,
8954
- toOptions: () => ({
8955
- code: metadata.code,
8956
- message: metadata.message(context),
8957
- retryable: metadata.retryable,
8958
- internal: metadata.internal,
8959
- httpStatusCode: metadata.httpStatusCode,
8960
- context
8961
- })
8962
- })
8963
- };
8964
- }
8965
- /**
8966
- * Main AlienError class that provides structured error handling.
8967
- *
8968
- * This class extends the standard JavaScript Error with additional features:
8969
- * - Type-safe context data
8970
- * - Error chaining and source tracking
8971
- * - Retryability and internal/external visibility flags
8972
- * - HTTP status code mapping
8973
- * - Sanitization for external APIs
8974
- *
8975
- * @template TContext - Zod schema type for the error context
8976
- *
8977
- * @example Basic Construction
8978
- * ```typescript
8979
- * const error = new AlienError(DatabaseError.create({
8980
- * host: "localhost",
8981
- * port: 5432,
8982
- * reason: "Timeout"
8983
- * }))
8984
- * ```
8985
- *
8986
- * @example Converting JavaScript Errors
8987
- * ```typescript
8988
- * try {
8989
- * JSON.parse("invalid json")
8990
- * } catch (jsError) {
8991
- * const alienError = AlienError.from(jsError)
8992
- * console.log(alienError.code) // "GENERIC_ERROR"
8993
- * }
8994
- * ```
9325
+ * import { ServiceAccount, Worker } from "@alien/core"
8995
9326
  *
8996
- * @example Error Chaining
8997
- * ```typescript
8998
- * const contextualError = AlienError.from(new Error("Network timeout"))
8999
- * .withContext(DatabaseError.create({
9000
- * host: "localhost",
9001
- * port: 5432,
9002
- * reason: "Connection timeout"
9003
- * }))
9327
+ * // Create a service account with stack-level permissions
9328
+ * const dataProcessorAccount = new ServiceAccount("data-processor")
9329
+ * .build()
9004
9330
  *
9005
- * // Check error chain
9006
- * console.log(contextualError.hasErrorCode("DATABASE_CONNECTION_FAILED")) // true
9007
- * console.log(contextualError.toString()) // Shows full error chain
9331
+ * // Link it to a function to use its identity
9332
+ * const processor = new Worker("processor")
9333
+ * .code({ type: "image", image: "processor:latest" })
9334
+ * .link(dataProcessorAccount)
9335
+ * .build()
9008
9336
  * ```
9009
9337
  */
9010
- var AlienError = class AlienError extends Error {
9011
- /** Unique error code identifying the error type */
9012
- code;
9013
- /** Whether this error can be safely retried */
9014
- retryable;
9015
- /** Whether this error contains sensitive internal information */
9016
- internal;
9017
- /** HTTP status code for API responses */
9018
- httpStatusCode;
9019
- /** Type-safe context data specific to this error */
9020
- context;
9021
- /** Optional human-facing remediation hint */
9022
- hint;
9023
- /** Source error that caused this error (for chaining) */
9024
- source;
9025
- constructor(input) {
9026
- let options;
9027
- if ("metadata" in input && "context" in input) {
9028
- const { metadata, context: contextData } = input;
9029
- const message = metadata.message(contextData);
9030
- options = {
9031
- code: metadata.code,
9032
- message,
9033
- retryable: metadata.retryable,
9034
- internal: metadata.internal,
9035
- httpStatusCode: metadata.httpStatusCode,
9036
- context: contextData
9037
- };
9038
- } else options = input;
9039
- const message = options.message;
9040
- super(message, { cause: options.source });
9041
- this.name = "AlienError";
9042
- this.code = options.code;
9043
- this.retryable = options.retryable;
9044
- this.internal = options.internal;
9045
- this.httpStatusCode = options.httpStatusCode ?? 500;
9046
- this.context = options.context;
9047
- this.hint = options.hint;
9048
- this.source = void 0;
9049
- if (options.source && typeof options.source === "object") {
9050
- if ("code" in options.source && "message" in options.source && "retryable" in options.source && "internal" in options.source) this.source = new AlienError(options.source);
9051
- }
9052
- }
9053
- /**
9054
- * Create an AlienError from a type-safe error definition.
9055
- *
9056
- * @template TContext - Zod schema type for the error context
9057
- * @param definition - Error definition with type-safe context
9058
- * @returns New AlienError instance
9059
- */
9060
- static fromDefinition(definition) {
9061
- return new AlienError(definition);
9062
- }
9338
+ var ServiceAccount = class {
9339
+ _config = { stackPermissionSets: [] };
9063
9340
  /**
9064
- * Create an AlienError from raw options (for compatibility).
9065
- *
9066
- * @param options - Raw error options conforming to AlienErrorOptions schema
9067
- * @returns New AlienError instance
9341
+ * Creates a new ServiceAccount builder.
9342
+ * @param id Identifier for the service account. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
9068
9343
  */
9069
- static fromOptions(options) {
9070
- return new AlienError(AlienErrorSchema.parse(options));
9344
+ constructor(id) {
9345
+ this._config.id = id;
9071
9346
  }
9072
9347
  /**
9073
- * Helper function to get a user-friendly type name for error context.
9074
- *
9075
- * @param error - Any value to get the type name for
9076
- * @returns User-friendly type name
9348
+ * Returns a ResourceType representing any service account resource.
9349
+ * Used for creating permission targets that apply to all service account resources.
9350
+ * @returns The "service-account" resource type.
9077
9351
  */
9078
- static getErrorTypeName(error) {
9079
- if (error === null) return "null";
9080
- if (error === void 0) return "undefined";
9081
- if (error?.constructor?.name) return error.constructor.name;
9082
- const typeofResult = typeof error;
9083
- return typeofResult === "object" ? "Object" : typeofResult.charAt(0).toUpperCase() + typeofResult.slice(1);
9352
+ static any() {
9353
+ return "service-account";
9084
9354
  }
9085
9355
  /**
9086
- * Convert a JavaScript Error or any object to a generic AlienError.
9087
- *
9088
- * This is equivalent to Rust's `.into_alien_error()` pattern and provides
9089
- * a way to convert any JavaScript error into the structured AlienError format.
9356
+ * Adds a stack-level permission set to the service account.
9357
+ * Stack-level permissions apply to all resources in the stack.
9090
9358
  *
9091
- * @param error - Any JavaScript error or object to convert
9092
- * @returns AlienError with GENERIC_ERROR code and preserved original error
9359
+ * Note: Only inline permission set objects are supported. To use built-in permission sets,
9360
+ * you need to resolve them first through the permission set registry or use permission profiles
9361
+ * in your stack configuration.
9093
9362
  *
9094
9363
  * @example
9095
9364
  * ```typescript
9096
- * try {
9097
- * throw new TypeError("Invalid argument")
9098
- * } catch (error) {
9099
- * const alienError = AlienError.from(error)
9100
- * console.log(alienError.code) // "GENERIC_ERROR"
9101
- * console.log(alienError.context?.originalError) // Serialized TypeError
9102
- * }
9103
- * ```
9365
+ * import { ServiceAccount, type PermissionSet } from "@alien/core"
9104
9366
  *
9105
- * @example Chaining with context
9106
- * ```typescript
9107
- * try {
9108
- * JSON.parse("invalid")
9109
- * } catch (error) {
9110
- * throw AlienError.from(error).withContext(
9111
- * ValidationError.create({
9112
- * input: "invalid",
9113
- * expectedFormat: "JSON"
9114
- * })
9115
- * )
9367
+ * const customPermissionSet: PermissionSet = {
9368
+ * id: "custom/my-perms",
9369
+ * description: "Custom permissions",
9370
+ * platforms: {
9371
+ * aws: [{ grant: { actions: ["s3:GetObject"] }, binding: { stack: { resources: ["*"] } } }]
9372
+ * }
9116
9373
  * }
9117
- * ```
9118
9374
  *
9119
- * @example AxiosError conversion
9120
- * ```typescript
9121
- * try {
9122
- * await axios.get('/api/resource')
9123
- * } catch (error) {
9124
- * // If error.response.data contains a valid AlienError structure, it will be parsed
9125
- * const alienError = AlienError.from(error)
9126
- * console.log(alienError.code) // Could be "REMOTE_RESOURCE_NOT_FOUND" if parsed from response
9127
- * }
9375
+ * const account = new ServiceAccount("custom-processor")
9376
+ * .stackPermissionSet(customPermissionSet)
9377
+ * .build()
9128
9378
  * ```
9379
+ *
9380
+ * @param permissionSet The permission set object with platform-specific permissions
9381
+ * @returns The ServiceAccount builder instance.
9129
9382
  */
9130
- static async from(error) {
9131
- if (error instanceof AlienError) return error;
9132
- if (error instanceof Response) {
9133
- let errorBody;
9134
- try {
9135
- errorBody = await error.json();
9136
- } catch {
9137
- return new AlienError({
9138
- code: "GENERIC_ERROR",
9139
- message: `HTTP request failed with status ${error.status}`,
9140
- retryable: false,
9141
- internal: true,
9142
- httpStatusCode: error.status,
9143
- context: {
9144
- url: error.url,
9145
- status: error.status,
9146
- statusText: error.statusText
9147
- }
9148
- });
9149
- }
9150
- const parseResult = AlienErrorSchema.safeParse(errorBody);
9151
- if (parseResult.success) return new AlienError(parseResult.data);
9152
- return new AlienError({
9153
- code: "GENERIC_ERROR",
9154
- message: errorBody?.message || `HTTP request failed with status ${error.status}`,
9155
- retryable: false,
9156
- internal: true,
9157
- httpStatusCode: error.status,
9158
- context: {
9159
- url: error.url,
9160
- status: error.status,
9161
- statusText: error.statusText,
9162
- responseBody: errorBody
9163
- }
9164
- });
9165
- }
9166
- if (error?.response?.data && typeof error.response.data === "object") {
9167
- const parseResult = AlienErrorSchema.safeParse(error.response.data);
9168
- if (parseResult.success) return new AlienError(parseResult.data);
9169
- }
9170
- const serialized = serializeError(error);
9171
- const message = serialized?.message || String(error);
9172
- return new AlienError({
9173
- code: "GENERIC_ERROR",
9174
- message,
9175
- retryable: false,
9176
- internal: true,
9177
- httpStatusCode: 500,
9178
- context: {
9179
- originalError: serialized,
9180
- errorType: AlienError.getErrorTypeName(error)
9181
- }
9182
- });
9383
+ stackPermissionSet(permissionSet) {
9384
+ if (!this._config.stackPermissionSets) this._config.stackPermissionSets = [];
9385
+ this._config.stackPermissionSets.push(permissionSet);
9386
+ return this;
9183
9387
  }
9184
9388
  /**
9185
- * Add context to this error, creating a new error that wraps this one.
9186
- *
9187
- * This is equivalent to Rust's `.with_context()` pattern and allows
9188
- * building error chains with increasing levels of context.
9189
- *
9190
- * @template TNewContext - Zod schema type for the new context
9191
- * @param definition - Error definition to wrap this error with
9192
- * @returns New AlienError with this error as the source
9193
- *
9194
- * @example
9195
- * ```typescript
9196
- * // Clean fluent API
9197
- * const authError = (await AlienError.from(new Error("ECONNREFUSED")))
9198
- * .withContext(DatabaseError.create({
9199
- * host: "localhost",
9200
- * port: 5432,
9201
- * reason: "Connection refused"
9202
- * }))
9203
- * .withContext(AuthError.create({
9204
- * username: "john",
9205
- * reason: "Database unavailable"
9206
- * }))
9207
- *
9208
- * // Error chain: AuthError -> DatabaseError -> GENERIC_ERROR
9209
- * console.log(authError.toString())
9210
- * ```
9389
+ * Builds and validates the service account configuration.
9390
+ * @returns An immutable Resource representing the configured service account.
9391
+ * @throws Error if the service account configuration is invalid.
9211
9392
  */
9212
- withContext(definition) {
9213
- const { metadata, context: contextData } = definition;
9214
- const message = metadata.message(contextData);
9215
- const sourceOptions = {
9216
- code: this.code,
9217
- message: this.message,
9218
- retryable: this.retryable,
9219
- internal: this.internal,
9220
- httpStatusCode: this.httpStatusCode,
9221
- context: this.context,
9222
- hint: this.hint,
9223
- source: this.source?.toOptions()
9224
- };
9225
- return new AlienError({
9226
- code: metadata.code,
9227
- message,
9228
- retryable: metadata.retryable,
9229
- internal: metadata.internal,
9230
- httpStatusCode: metadata.httpStatusCode,
9231
- context: contextData,
9232
- source: sourceOptions
9393
+ build() {
9394
+ return new Resource({
9395
+ type: "service-account",
9396
+ ...ServiceAccountSchema.parse(this._config)
9233
9397
  });
9234
9398
  }
9399
+ };
9400
+ //#endregion
9401
+ //#region src/stack.ts
9402
+ /**
9403
+ * Represents a collection of cloud resources that are managed together.
9404
+ * Stacks are the top-level organizational unit in an Alien application.
9405
+ */
9406
+ var Stack = class {
9407
+ _config = {
9408
+ resources: {},
9409
+ permissions: void 0
9410
+ };
9235
9411
  /**
9236
- * Convert this AlienError to the wire format (AlienErrorOptions).
9237
- *
9238
- * This method serializes the error into the standard format used
9239
- * for transmitting errors over the network or storing them.
9240
- *
9241
- * @returns AlienErrorOptions object representing this error
9412
+ * Creates a new Stack builder.
9413
+ * @param id Identifier for the stack. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 128 characters.
9242
9414
  */
9243
- toOptions() {
9244
- return {
9245
- code: this.code,
9246
- message: this.message,
9247
- retryable: this.retryable,
9248
- internal: this.internal,
9249
- httpStatusCode: this.httpStatusCode,
9250
- context: this.context,
9251
- hint: this.hint,
9252
- source: this.source?.toOptions()
9253
- };
9415
+ constructor(id) {
9416
+ this._config.id = id;
9254
9417
  }
9255
9418
  /**
9256
- * Get a sanitized version for external APIs (hides internal errors).
9257
- *
9258
- * This method is crucial for security - it prevents sensitive internal
9259
- * error details from being exposed to external users while preserving
9260
- * the error chain structure for non-sensitive errors.
9261
- *
9262
- * @returns Sanitized AlienErrorOptions safe for external consumption
9263
- *
9264
- * @example
9265
- * ```typescript
9266
- * const internalError = new AlienError(InternalApiError.create({
9267
- * service: "payment-processor",
9268
- * details: "Database password expired for user admin",
9269
- * traceId: "trace-12345"
9270
- * }))
9271
- *
9272
- * console.log(internalError.toOptions())
9273
- * // Shows full details including sensitive information
9274
- *
9275
- * console.log(internalError.toExternal())
9276
- * // { code: "GENERIC_ERROR", message: "Internal server error", ... }
9277
- * ```
9419
+ * Adds a resource to the stack with a specified lifecycle.
9420
+ * @param resource The resource to add (e.g., Worker, Storage).
9421
+ * @param lifecycle The lifecycle state of the resource (e.g., Frozen, Live).
9422
+ * @param options Optional configuration for the resource entry.
9423
+ * @returns The Stack builder instance.
9278
9424
  */
9279
- toExternal() {
9280
- if (this.internal) return {
9281
- code: "GENERIC_ERROR",
9282
- message: "Internal server error",
9283
- retryable: false,
9284
- internal: false,
9285
- httpStatusCode: 500
9286
- };
9287
- return {
9288
- code: this.code,
9289
- message: this.message,
9290
- retryable: this.retryable,
9291
- internal: this.internal,
9292
- httpStatusCode: this.httpStatusCode,
9293
- context: this.context,
9294
- hint: this.hint,
9295
- source: this.source?.toExternal()
9425
+ add(resource, lifecycle, options) {
9426
+ const entry = {
9427
+ config: resource.config,
9428
+ lifecycle,
9429
+ dependencies: []
9296
9430
  };
9431
+ if (options?.remoteAccess) entry.remoteAccess = true;
9432
+ if (resource.enabledWhen !== void 0) entry.enabledWhen = resource.enabledWhen;
9433
+ this._config.resources[resource.config.id] = entry;
9434
+ return this;
9297
9435
  }
9298
9436
  /**
9299
- * Check if this error chain contains an error with a specific code.
9300
- *
9301
- * This method traverses the entire error chain (this error and all
9302
- * source errors) to find if any error has the specified code.
9303
- *
9304
- * @param code - Error code to search for
9305
- * @returns True if the code is found anywhere in the error chain
9306
- *
9307
- * @example
9308
- * ```typescript
9309
- * const chainedError = authError.withContext(dbError.withContext(networkError))
9437
+ * Declare which platforms this stack supports.
9438
+ * When omitted, the stack supports all platforms.
9439
+ */
9440
+ platforms(platforms) {
9441
+ this._config.supportedPlatforms = platforms;
9442
+ return this;
9443
+ }
9444
+ /**
9445
+ * Configure permissions for this stack.
9446
+ * @param config Permission configuration
9447
+ * @returns The Stack builder instance.
9448
+ */
9449
+ permissions(config) {
9450
+ this._config.permissions = config;
9451
+ return this;
9452
+ }
9453
+ /**
9454
+ * Configure values that must be provided before setup or deployment can proceed.
9455
+ * @param inputs Stack input definitions created with alien.inputs({...}).
9456
+ * @returns The Stack builder instance.
9457
+ */
9458
+ inputs(inputs) {
9459
+ this._config.inputs = getStackInputDefinitions(inputs);
9460
+ return this;
9461
+ }
9462
+ /**
9463
+ * Gets the stack ID without building/validating the stack.
9464
+ * @returns The stack ID.
9465
+ */
9466
+ get id() {
9467
+ return this._config.id;
9468
+ }
9469
+ /**
9470
+ * Builds and validates the stack configuration.
9471
+ * @returns The complete and validated stack configuration.
9472
+ * @throws Error if the stack configuration is invalid.
9473
+ */
9474
+ build() {
9475
+ return StackSchema.parse(this._config);
9476
+ }
9477
+ };
9478
+ //#endregion
9479
+ //#region src/storage.ts
9480
+ /**
9481
+ * Represents an object storage bucket.
9482
+ */
9483
+ var Storage = class extends ResourceBuilder {
9484
+ _config = {
9485
+ publicRead: false,
9486
+ versioning: false,
9487
+ lifecycleRules: [],
9488
+ corsAllowedOrigins: []
9489
+ };
9490
+ /**
9491
+ * Creates a new Storage builder.
9492
+ * @param id ID of the storage bucket. For names with dots, each dot-separated label must be ≤ 63 characters.
9493
+ */
9494
+ constructor(id) {
9495
+ super();
9496
+ this._config.id = id;
9497
+ }
9498
+ /**
9499
+ * Returns a ResourceType representing any storage resource.
9500
+ * Used for creating permission targets that apply to all storage resources.
9501
+ * @returns The "storage" resource type.
9502
+ */
9503
+ static any() {
9504
+ return "storage";
9505
+ }
9506
+ /**
9507
+ * Allows public read access to objects without authentication.
9508
+ * Default: `false`.
9509
+ * @param value Whether to allow public read access.
9510
+ * @returns The Storage builder instance.
9511
+ */
9512
+ publicRead(value) {
9513
+ this._config.publicRead = value;
9514
+ return this;
9515
+ }
9516
+ /**
9517
+ * Enables object versioning.
9518
+ * Default: `false`.
9519
+ * @param value Whether to enable versioning.
9520
+ * @returns The Storage builder instance.
9521
+ */
9522
+ versioning(value) {
9523
+ this._config.versioning = value;
9524
+ return this;
9525
+ }
9526
+ /**
9527
+ * Defines lifecycle rules for automatic object management (e.g., expiration).
9528
+ * @param rules An array of lifecycle rules.
9529
+ * @returns The Storage builder instance.
9530
+ */
9531
+ lifecycleRules(rules) {
9532
+ this._config.lifecycleRules = rules;
9533
+ return this;
9534
+ }
9535
+ /**
9536
+ * Allows browser reads from the listed origins through signed URLs.
9537
+ * Providers enable `GET` and `HEAD`; use `*` only when the signed URL itself
9538
+ * is the credential and browser cookies are not involved.
9539
+ * @param origins Allowed browser origins.
9540
+ * @returns The Storage builder instance.
9541
+ */
9542
+ corsAllowedOrigins(origins) {
9543
+ this._config.corsAllowedOrigins = origins;
9544
+ return this;
9545
+ }
9546
+ /**
9547
+ * Uses an Alien Key for provider-native encryption of objects in this Storage resource.
9548
+ * The Key and Storage must both be added to the same stack.
9549
+ */
9550
+ encryptionKey(key) {
9551
+ if (key.config.type !== "key") throw new Error(`Storage.encryptionKey() requires an alien.Key, received '${key.config.type}'`);
9552
+ this._config.encryptionKey = key.ref();
9553
+ return this;
9554
+ }
9555
+ /**
9556
+ * Builds and validates the storage configuration.
9557
+ * @returns An immutable Resource representing the configured storage bucket.
9558
+ * @throws Error if the storage configuration is invalid.
9559
+ */
9560
+ build() {
9561
+ const config = StorageSchema.parse(this._config);
9562
+ return this.resource({
9563
+ type: "storage",
9564
+ ...config
9565
+ });
9566
+ }
9567
+ };
9568
+ //#endregion
9569
+ //#region src/vault.ts
9570
+ /**
9571
+ * Represents a secure vault for storing secrets.
9572
+ * This resource provides a platform-agnostic interface over cloud-native secret management services:
9573
+ * - AWS: AWS Secrets Manager with prefixed secret names
9574
+ * - GCP: Secret Manager with prefixed secret names
9575
+ * - Azure: Key Vault resource
9576
+ *
9577
+ * The vault acts as a namespace for secrets and controls access permissions for workers and services.
9578
+ */
9579
+ var Vault = class extends ResourceBuilder {
9580
+ _config = {};
9581
+ /**
9582
+ * Creates a new Vault builder.
9583
+ * @param id Identifier for the vault. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
9584
+ */
9585
+ constructor(id) {
9586
+ super();
9587
+ this._config.id = id;
9588
+ }
9589
+ /**
9590
+ * Returns a ResourceType representing any vault resource.
9591
+ * Used for creating permission targets that apply to all vault resources.
9592
+ * @returns The "vault" resource type.
9593
+ */
9594
+ static any() {
9595
+ return "vault";
9596
+ }
9597
+ /**
9598
+ * Builds and validates the vault configuration.
9599
+ * @returns An immutable Resource representing the configured vault.
9600
+ * @throws Error if the vault configuration is invalid.
9601
+ */
9602
+ build() {
9603
+ const config = VaultSchema.parse(this._config);
9604
+ return this.resource({
9605
+ type: "vault",
9606
+ ...config
9607
+ });
9608
+ }
9609
+ };
9610
+ //#endregion
9611
+ //#region src/worker.ts
9612
+ /**
9613
+ * Represents a serverless worker that executes code in response to triggers or direct invocations.
9614
+ * Workers are the primary compute resource in serverless applications, designed to be stateless and ephemeral.
9615
+ */
9616
+ var Worker = class extends ResourceBuilder {
9617
+ _config = {
9618
+ links: [],
9619
+ triggers: [],
9620
+ publicEndpoints: [],
9621
+ environment: {}
9622
+ };
9623
+ /**
9624
+ * Creates a new Worker builder.
9625
+ * @param id Identifier for the worker. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
9626
+ */
9627
+ constructor(id) {
9628
+ super();
9629
+ this._config.id = id;
9630
+ }
9631
+ /**
9632
+ * Returns a ResourceType representing any worker resource.
9633
+ * Used for creating permission targets that apply to all worker resources.
9634
+ * @returns The "worker" resource type.
9635
+ */
9636
+ static any() {
9637
+ return "worker";
9638
+ }
9639
+ /**
9640
+ * Sets the code for the worker, either a pre-built image or source code to be built.
9641
+ * @param code The worker code configuration.
9642
+ * @returns The Worker builder instance.
9643
+ */
9644
+ code(code) {
9645
+ this._config.code = code;
9646
+ return this;
9647
+ }
9648
+ /**
9649
+ * Sets the memory allocated to the worker in megabytes (MB).
9650
+ * Constraints: 128‑32768 MB (platform-specific limits may apply).
9651
+ * Default: 512 MB.
9652
+ * @param mb The memory in MB.
9653
+ * @returns The Worker builder instance.
9654
+ */
9655
+ memoryMb(mb) {
9656
+ this._config.memoryMb = mb;
9657
+ return this;
9658
+ }
9659
+ /**
9660
+ * Sets the maximum execution time for the worker in seconds.
9661
+ * Constraints: 1‑3600 seconds (platform-specific limits may apply).
9662
+ * Default: 30 seconds.
9663
+ * @param sec The timeout in seconds.
9664
+ * @returns The Worker builder instance.
9665
+ */
9666
+ timeoutSeconds(sec) {
9667
+ this._config.timeoutSeconds = sec;
9668
+ return this;
9669
+ }
9670
+ /**
9671
+ * Sets the maximum number of concurrent executions allowed for the worker.
9672
+ * `null` means platform default applies.
9673
+ * @param limit The concurrency limit, or `null` for platform default.
9674
+ * @returns The Worker builder instance.
9675
+ */
9676
+ concurrencyLimit(limit) {
9677
+ this._config.concurrencyLimit = limit;
9678
+ return this;
9679
+ }
9680
+ /**
9681
+ * Exposes a named public HTTP endpoint for the worker.
9310
9682
  *
9311
- * console.log(chainedError.hasErrorCode("AUTH_FAILED")) // true
9312
- * console.log(chainedError.hasErrorCode("DATABASE_CONNECTION_FAILED")) // true
9313
- * console.log(chainedError.hasErrorCode("NETWORK_TIMEOUT")) // true
9314
- * console.log(chainedError.hasErrorCode("NONEXISTENT_ERROR")) // false
9315
- * ```
9683
+ * If no public endpoint is declared, the worker is private and only reachable
9684
+ * through triggers, commands, or provider invocation APIs.
9685
+ */
9686
+ publicEndpoint(name, options = {}) {
9687
+ if (!this._config.publicEndpoints) this._config.publicEndpoints = [];
9688
+ this._config.publicEndpoints.push({
9689
+ name,
9690
+ hostLabel: options.hostLabel,
9691
+ wildcardSubdomains: options.wildcardSubdomains ?? false
9692
+ });
9693
+ return this;
9694
+ }
9695
+ /**
9696
+ * Sets key-value pairs as environment variables for the worker.
9697
+ * @param env A map of environment variable names to their values.
9698
+ * @returns The Worker builder instance.
9699
+ */
9700
+ environment(env) {
9701
+ this._config.environment = env;
9702
+ return this;
9703
+ }
9704
+ /**
9705
+ * Links another resource (e.g., Storage, KV, Queue) to this worker.
9706
+ * This makes the linked resource accessible to the worker, often by injecting
9707
+ * environment variables or granting permissions.
9708
+ * @param resource The resource to link.
9709
+ * @returns The Worker builder instance.
9710
+ */
9711
+ link(resource) {
9712
+ if (!this._config.links) this._config.links = [];
9713
+ this._config.links.push(resource.ref());
9714
+ return this;
9715
+ }
9716
+ /**
9717
+ * Assigns a permission profile to this worker.
9718
+ * The profile defines the permissions granted to this worker when interacting
9719
+ * with other cloud resources.
9720
+ * @param permissions The permission profile name.
9721
+ * @returns The Worker builder instance.
9316
9722
  */
9317
- hasErrorCode(code) {
9318
- if (this.code === code) return true;
9319
- return this.source?.hasErrorCode(code) ?? false;
9723
+ permissions(permissions) {
9724
+ this._config.permissions = permissions;
9725
+ return this;
9320
9726
  }
9321
9727
  /**
9322
- * Find the first error in the chain with a specific code.
9323
- *
9324
- * This method traverses the error chain and returns the first error
9325
- * instance that matches the specified code, allowing access to its
9326
- * specific context and details.
9327
- *
9328
- * @param code - Error code to search for
9329
- * @returns AlienError instance with the specified code, or undefined if not found
9728
+ * Configures a readiness probe for the worker.
9729
+ * The probe will be executed after provisioning/update to verify the worker is ready.
9730
+ * Only works with workers that declare a public endpoint.
9330
9731
  *
9331
9732
  * @example
9332
9733
  * ```typescript
9333
- * const chainedError = authError.withContext(dbError)
9734
+ * const probe: ReadinessProbe = {
9735
+ * method: "GET",
9736
+ * path: "/health"
9737
+ * };
9334
9738
  *
9335
- * const dbError = chainedError.findErrorByCode("DATABASE_CONNECTION_FAILED")
9336
- * if (dbError) {
9337
- * console.log("Database error context:", dbError.context)
9338
- * console.log("Host:", dbError.context?.host)
9339
- * }
9739
+ * const func = new Worker("my-api")
9740
+ * .code({ type: "image", image: "my-api:latest" })
9741
+ * .publicEndpoint("api")
9742
+ * .readinessProbe(probe)
9743
+ * .build();
9340
9744
  * ```
9745
+ *
9746
+ * @param probe The readiness probe configuration.
9747
+ * @returns The Worker builder instance.
9341
9748
  */
9342
- findErrorByCode(code) {
9343
- if (this.code === code) return this;
9344
- return this.source?.findErrorByCode(code);
9749
+ readinessProbe(probe) {
9750
+ this._config.readinessProbe = probe;
9751
+ return this;
9345
9752
  }
9346
9753
  /**
9347
- * Get a formatted string representation of the error chain.
9348
- *
9349
- * This method provides a human-readable representation of the entire
9350
- * error chain, showing how errors are nested and providing context
9351
- * for debugging and logging.
9352
- *
9353
- * @returns Formatted string showing the complete error chain
9754
+ * Enables or disables the Commands protocol for the worker.
9755
+ * When enabled, the platform pushes commands into the Worker runtime, which executes registered handlers.
9756
+ * Default: false.
9757
+ * @param enabled Whether to enable commands for this worker.
9758
+ * @returns The Worker builder instance.
9759
+ */
9760
+ commandsEnabled(enabled) {
9761
+ this._config.commandsEnabled = enabled;
9762
+ return this;
9763
+ }
9764
+ /**
9765
+ * Adds a trigger to the worker. Workers can have multiple triggers.
9766
+ * Each trigger will independently invoke the worker when its conditions are met.
9354
9767
  *
9355
9768
  * @example
9356
9769
  * ```typescript
9357
- * const chainedError = authError.withContext(dbError.withContext(networkError))
9358
- * console.log(chainedError.toString())
9359
- * // Output:
9360
- * // AUTH_FAILED: User authentication failed for 'john'
9361
- * // ├─▶ DATABASE_CONNECTION_FAILED: Failed to connect to database 'localhost:5432'
9362
- * // ├─▶ GENERIC_ERROR: Connection timeout
9770
+ * // Queue trigger
9771
+ * const queueTrigger: WorkerTrigger = {
9772
+ * type: "queue",
9773
+ * queue: myQueue.ref()
9774
+ * };
9775
+ *
9776
+ * // Schedule trigger
9777
+ * const scheduleTrigg: WorkerTrigger = {
9778
+ * type: "schedule",
9779
+ * cron: "0 * * * *"
9780
+ * };
9781
+ *
9782
+ * const func = new Worker("my-func")
9783
+ * .code({ type: "image", image: "my-image:latest" })
9784
+ * .trigger(queueTrigger)
9785
+ * .trigger(scheduleTrigger)
9786
+ * .build();
9363
9787
  * ```
9788
+ *
9789
+ * @param trigger The trigger configuration.
9790
+ * @returns The Worker builder instance.
9364
9791
  */
9365
- toString() {
9366
- let result = `${this.code}: ${this.message}`;
9367
- let current = this.source;
9368
- let indent = "";
9369
- while (current) {
9370
- indent += " ";
9371
- result += `\n${indent}├─▶ ${current.code}: ${current.message}`;
9372
- current = current.source;
9373
- }
9374
- return result;
9792
+ trigger(trigger) {
9793
+ if (!this._config.triggers) this._config.triggers = [];
9794
+ this._config.triggers.push(trigger);
9795
+ return this;
9375
9796
  }
9376
- };
9377
- //#endregion
9378
- //#region src/common-errors.ts
9379
- /**
9380
- * Error thrown when a requested resource cannot be found in the stack state.
9381
- * This matches the Rust alien-core error: RESOURCE_NOT_FOUND
9382
- */
9383
- const ResourceNotFoundError = defineError({
9384
- code: "RESOURCE_NOT_FOUND",
9385
- context: z$1.object({
9386
- resourceId: z$1.string(),
9387
- availableResources: z$1.array(z$1.string())
9388
- }),
9389
- message: ({ resourceId, availableResources }) => `Resource '${resourceId}' not found in stack state. Available resources: ${JSON.stringify(availableResources)}`,
9390
- retryable: false,
9391
- internal: false,
9392
- httpStatusCode: 404
9393
- });
9394
- /**
9395
- * Error thrown when resource outputs cannot be parsed according to their expected schema.
9396
- * This indicates an internal system error or data corruption.
9397
- */
9398
- const ResourceOutputsParseError = defineError({
9399
- code: "RESOURCE_OUTPUTS_PARSE_ERROR",
9400
- context: z$1.object({
9401
- resourceName: z$1.string(),
9402
- resourceType: z$1.string(),
9403
- validationErrors: z$1.string()
9404
- }),
9405
- message: ({ resourceName, resourceType, validationErrors }) => `Failed to parse outputs for resource '${resourceName}' of type '${resourceType}':\n${validationErrors}`,
9406
- retryable: false,
9407
- internal: true,
9408
- httpStatusCode: 500
9409
- });
9410
- /**
9411
- * Error thrown when there's a resource type mismatch during stack operations.
9412
- * This matches the Rust alien-core error: UNEXPECTED_RESOURCE_TYPE
9413
- */
9414
- const UnexpectedResourceTypeError = defineError({
9415
- code: "UNEXPECTED_RESOURCE_TYPE",
9416
- context: z$1.object({
9417
- resourceId: z$1.string(),
9418
- expected: z$1.string(),
9419
- actual: z$1.string()
9420
- }),
9421
- message: ({ resourceId, expected, actual }) => `Unexpected resource type for resource '${resourceId}': expected ${expected}, but got ${actual}`,
9422
- retryable: false,
9423
- internal: false,
9424
- httpStatusCode: 400
9425
- });
9426
- /**
9427
- * Error thrown when a binding's projected configuration is invalid.
9428
- */
9429
- const InvalidBindingConfigError = defineError({
9430
- code: "INVALID_BINDING_CONFIG",
9431
- context: z$1.object({
9432
- message: z$1.string(),
9433
- suggestion: z$1.string().optional()
9434
- }),
9435
- message: ({ message, suggestion }) => suggestion ? `${message}. ${suggestion}` : message,
9436
- retryable: false,
9437
- internal: false,
9438
- httpStatusCode: 400
9439
- });
9440
- /**
9441
- * Error thrown when a binding is not found.
9442
- */
9443
- const BindingNotFoundError = defineError({
9444
- code: "BINDING_NOT_FOUND",
9445
- context: z$1.object({
9446
- bindingName: z$1.string(),
9447
- bindingType: z$1.string()
9448
- }),
9449
- message: ({ bindingName, bindingType }) => `${bindingType} binding '${bindingName}' not found`,
9450
- retryable: false,
9451
- internal: false,
9452
- httpStatusCode: 404
9453
- });
9454
- //#endregion
9455
- //#region src/get-resource-outputs.ts
9456
- const ResourceSchemaMapping = {
9457
- function: {
9458
- input: WorkerSchema,
9459
- output: WorkerOutputsSchema
9460
- },
9461
- container: {
9462
- input: ContainerSchema,
9463
- output: ContainerOutputsSchema
9464
- },
9465
- storage: {
9466
- input: StorageSchema,
9467
- output: StorageOutputsSchema
9468
- },
9469
- kv: {
9470
- input: KvSchema,
9471
- output: KvOutputsSchema
9472
- },
9473
- queue: {
9474
- input: QueueSchema,
9475
- output: QueueOutputsSchema
9476
- },
9477
- vault: {
9478
- input: VaultSchema,
9479
- output: VaultOutputsSchema
9480
- },
9481
- build: {
9482
- input: BuildSchema,
9483
- output: BuildOutputsSchema
9484
- },
9485
- "artifact-registry": {
9486
- input: ArtifactRegistrySchema,
9487
- output: ArtifactRegistryOutputsSchema
9488
- },
9489
- "service-account": {
9490
- input: ServiceAccountSchema,
9491
- output: ServiceAccountOutputsSchema
9492
- },
9493
- "remote-stack-management": {
9494
- input: RemoteStackManagementSchema,
9495
- output: RemoteStackManagementOutputsSchema
9797
+ /**
9798
+ * Builds and validates the worker configuration.
9799
+ * @returns An immutable Resource representing the configured worker.
9800
+ * @throws Error if the worker configuration is invalid (e.g., missing code).
9801
+ */
9802
+ build() {
9803
+ const config = WorkerSchema.parse(this._config);
9804
+ return this.resource({
9805
+ type: "worker",
9806
+ ...config
9807
+ });
9496
9808
  }
9497
9809
  };
9498
- function getResourceOutputs(params) {
9499
- const { state, resource } = params;
9500
- const resourceState = state.resources[resource.name];
9501
- if (!resourceState) throw new AlienError(ResourceNotFoundError.create({
9502
- resourceId: resource.name,
9503
- availableResources: Object.keys(state.resources)
9504
- }));
9505
- const outputs = ResourceSchemaMapping[resource.type].output.safeParse(resourceState.outputs);
9506
- if (!outputs.success) throw new AlienError(ResourceOutputsParseError.create({
9507
- resourceName: resource.name,
9508
- resourceType: resource.type,
9509
- validationErrors: z$1.prettifyError(outputs.error)
9510
- }));
9511
- return outputs.data;
9512
- }
9513
9810
  //#endregion
9514
9811
  //#region src/experimental/aws-opensearch.ts
9515
9812
  /**
@@ -9605,6 +9902,6 @@ function validateOcu(field, value, allowZero) {
9605
9902
  //#region src/index.ts
9606
9903
  const experimental = { AwsOpenSearch };
9607
9904
  //#endregion
9608
- export { AI, AgentStatusSchema, AiSchema as AiConfigSchema, AlienError, AlienErrorSchema as AlienErrorOptionsSchema, AlienEventSchema, ArtifactRegistry, ArtifactRegistrySchema as ArtifactRegistryConfigSchema, ArtifactRegistryHeartbeatDataSchema, ArtifactRegistryHeartbeatStatusSchema, AwsArtifactRegistryImportDataSchema, AwsBuildImportDataSchema, AwsCodeBuildHeartbeatDataSchema, AwsComputeClusterHeartbeatDataSchema, AwsComputeClusterImportDataSchema, AwsDynamoDbKeySchemaElementSchema, AwsDynamoDbKvHeartbeatDataSchema, AwsEcrArtifactRegistryHeartbeatDataSchema, AwsEcrRepositoryHeartbeatDataSchema, AwsIamRoleServiceAccountHeartbeatDataSchema, AwsKvImportDataSchema, AwsLambdaWorkerHeartbeatDataSchema, AwsNetworkImportDataSchema, AwsParameterStoreVaultHeartbeatDataSchema, AwsQueueImportDataSchema, AwsRemoteStackManagementHeartbeatDataSchema, AwsRemoteStackManagementImportDataSchema, AwsS3StorageHeartbeatDataSchema, AwsServiceAccountImportDataSchema, AwsSqsQueueHeartbeatDataSchema, AwsStorageImportDataSchema, AwsVaultImportDataSchema, AwsVpcNetworkHeartbeatDataSchema, AwsWorkerImportDataSchema, AzureArtifactRegistryImportDataSchema, AzureBlobStorageHeartbeatDataSchema, AzureBuildImportDataSchema, AzureComputeClusterHeartbeatDataSchema, AzureComputeClusterImportDataSchema, AzureContainerAppsBuildHeartbeatDataSchema, AzureContainerAppsEnvironmentHeartbeatDataSchema, AzureContainerAppsEnvironmentHeartbeatStatusSchema, AzureContainerAppsEnvironmentImportDataSchema, AzureContainerAppsEnvironmentWorkloadProfileSchema, AzureContainerAppsWorkerHeartbeatDataSchema, AzureContainerRegistryHeartbeatDataSchema, AzureKeyVaultHeartbeatDataSchema, AzureKvImportDataSchema, AzureManagedIdentityServiceAccountHeartbeatDataSchema, AzureNetworkImportDataSchema, AzureQueueImportDataSchema, AzureRemoteStackManagementHeartbeatDataSchema, AzureRemoteStackManagementImportDataSchema, AzureResourceGroupHeartbeatDataSchema, AzureResourceGroupHeartbeatStatusSchema, AzureResourceGroupImportDataSchema, AzureResourceProviderActivationHeartbeatDataSchema, AzureServiceAccountImportDataSchema, AzureServiceActivationImportDataSchema, AzureServiceBusNamespaceHeartbeatDataSchema, AzureServiceBusNamespaceImportDataSchema, AzureServiceBusQueueHeartbeatDataSchema, AzureStorageAccountEndpointsSchema, AzureStorageAccountHeartbeatDataSchema, AzureStorageAccountImportDataSchema, AzureStorageImportDataSchema, AzureTableKvHeartbeatDataSchema, AzureVaultImportDataSchema, AzureVnetNetworkHeartbeatDataSchema, AzureWorkerImportDataSchema, BindingNotFoundError, BodySpecSchema, Build, BuildConfigSchema, BuildHeartbeatDataSchema, BuildHeartbeatStatusSchema, BuildOutputsSchema, BuildStatusSchema, CapacityGroupScalePolicySchema, CapacityGroupSchema, CommandDeliveryModeSchema, CommandResponseSchema, CommandStateSchema, CommandStatusResponseSchema, CommandTargetSchema, CommandTargetTypeSchema, ComputeCapacityGroupStatusSchema, ComputeCapacityRecommendationSchema, ComputeChoiceRangeSchema, ComputeCluster, ComputeClusterSchema as ComputeClusterConfigSchema, ComputeClusterHeartbeatDataSchema, ComputeClusterHeartbeatStatusSchema, ComputeTypeSchema, Container, ContainerAutoscalingSchema, ContainerCodeSchema, ContainerSchema as ContainerConfigSchema, ContainerHeartbeatDataSchema, ContainerPortSchema, CreateCommandRequestSchema, CreateCommandResponseSchema, Daemon, DaemonCodeSchema, DaemonSchema as DaemonConfigSchema, DaemonHeartbeatDataSchema, DaemonOutputsSchema, DeploymentModelSchema, DevResourceInfoSchema, DevStatusSchema, DevStatusStateSchema, Email, EmailSchema as EmailConfigSchema, EnvelopeSchema, EventChangeSchema, EventStateSchema, ExposeProtocolSchema, GcpArtifactRegistryHeartbeatDataSchema, GcpArtifactRegistryImportDataSchema, GcpBuildImportDataSchema, GcpCloudBuildHeartbeatDataSchema, GcpCloudRunWorkerHeartbeatDataSchema, GcpCloudStorageHeartbeatDataSchema, GcpComputeClusterHeartbeatDataSchema, GcpComputeClusterImportDataSchema, GcpFirestoreKvHeartbeatDataSchema, GcpKvImportDataSchema, GcpNetworkImportDataSchema, GcpPubSubQueueHeartbeatDataSchema, GcpQueueImportDataSchema, GcpRemoteStackManagementHeartbeatDataSchema, GcpRemoteStackManagementImportDataSchema, GcpSecretManagerVaultHeartbeatDataSchema, GcpServiceAccountHeartbeatDataSchema, GcpServiceAccountImportDataSchema, GcpServiceActivationImportDataSchema, GcpServiceUsageActivationHeartbeatDataSchema, GcpStorageImportDataSchema, GcpVaultImportDataSchema, GcpVpcNetworkHeartbeatDataSchema, GcpWorkerImportDataSchema, HeartbeatBackendSchema, HeartbeatIssueSeveritySchema, HeartbeatsModeSchema, HorizonContainerHeartbeatDataSchema, HttpMethodSchema, InvalidBindingConfigError, KubernetesBuildHeartbeatDataSchema, KubernetesClusterNodeStatusSchema, KubernetesContainerHeartbeatDataSchema, KubernetesDaemonHeartbeatDataSchema, KubernetesEventInvolvedObjectSchema, KubernetesEventSnapshotSchema, KubernetesEventSourceSchema, KubernetesNodeConditionStatusSchema, KubernetesNodeResourcesSchema, KubernetesNodeUsageSchema, KubernetesPodRuntimeUnitStatusSchema, KubernetesSecretVaultHeartbeatDataSchema, KubernetesWorkerHeartbeatDataSchema, Kv, KvSchema as KvConfigSchema, KvHeartbeatDataSchema, KvHeartbeatStatusSchema, LeaseInfoSchema, LeaseRequestSchema, LeaseResponseSchema, LocalArtifactRegistryHeartbeatDataSchema, LocalComputeClusterHeartbeatDataSchema, LocalContainerHeartbeatDataSchema, LocalDaemonHeartbeatDataSchema, LocalKvHeartbeatDataSchema, LocalQueueHeartbeatDataSchema, LocalRuntimeEventSnapshotSchema, LocalRuntimeEventSubjectSchema, LocalRuntimeUnitKindSchema, LocalRuntimeUnitStatusSchema, LocalServiceAccountHeartbeatDataSchema, LocalStorageHeartbeatDataSchema, LocalVaultHeartbeatDataSchema, LocalWorkerHeartbeatDataSchema, MachineProfileSchema, ManagedRuntimeEventInvolvedObjectSchema, ManagedRuntimeEventSnapshotSchema, ManagedRuntimeEventSourceSchema, ManagedRuntimeUnitStatusSchema, MessagePayloadSchema, MetricSampleSchema, NetworkHeartbeatDataSchema, NetworkHeartbeatStatusSchema, ObservedCountsSchema, ObservedHealthSchema, ObservedInventoryBatchSchema, ObservedResourceSampleSchema, PermissionSetSchema, PlatformSchema, Postgres, PostgresSchema as PostgresConfigSchema, PresignedRequestBackendSchema, PresignedRequestSchema, ProviderFleetStatusSchema, ProviderLifecycleStateSchema, PublicEndpointSchema, Queue, QueueSchema as QueueConfigSchema, QueueHeartbeatDataSchema, QueueHeartbeatStatusSchema, QueueMessageSchema, ReadinessProbeSchema, ReleaseRequestSchema, RemoteStackManagementHeartbeatDataSchema, RemoteStackManagementHeartbeatStatusSchema, Resource, ResourceHeartbeatDataSchema, ResourceHeartbeatSchema, ResourceLifecycleSchema, ResourceNotFoundError, ResourceOutputsParseError, ResourceRefSchema, ResourceSchemaMapping, ResourceStatusSchema, ResourceTypeSchema, ResponseHandlingSchema, ScheduledEventSchema, ServiceAccount, ServiceAccountSchema as ServiceAccountConfigSchema, ServiceAccountHeartbeatDataSchema, ServiceAccountHeartbeatStatusSchema, ServiceAccountOutputsSchema, ServiceActivationHeartbeatDataSchema, ServiceActivationHeartbeatStatusSchema, Stack, StackInputDefaultValueSchema, StackInputDefinitionSchema, StackInputEnvironmentMappingSchema, StackInputEnvironmentVariableTypeSchema, StackInputKindSchema, StackInputProviderSchema, StackInputValidationSchema, StackResourceStateSchema, StackSchema, StackSettingsSchema, StackStateSchema, StackStatusSchema, Storage, StorageSchema as StorageConfigSchema, StorageEventSchema, StorageEventTypeSchema, StorageEventsSchema, StorageHeartbeatDataSchema, StorageHeartbeatStatusSchema, StorageUploadSchema, SubmitResponseRequestSchema, TelemetryModeSchema, TraceContextSchema, UnexpectedResourceTypeError, UpdatesModeSchema, UploadCompleteRequestSchema, UploadCompleteResponseSchema, Vault, VaultSchema as VaultConfigSchema, VaultHeartbeatDataSchema, VaultHeartbeatStatusSchema, Worker, WorkerSchema as WorkerConfigSchema, WorkerHeartbeatDataSchema, WorkerOutputsSchema, WorkerPublicEndpointSchema, WorkerTriggerSchema, WorkloadHeartbeatStatusSchema, WorkloadReplicaStatusSchema, defineBooleanInput as boolean, defineError, defineEnumInput as enum, experimental, getResourceOutputs, getStackInputDefinitions, inputs, defineIntegerInput as integer, defineNumberInput as number, defineSecretInput as secret, defineStringInput as string, defineStringListInput as stringList };
9905
+ export { AI, AgentStatusSchema, AiSchema as AiConfigSchema, AlienError, AlienErrorSchema as AlienErrorOptionsSchema, AlienEventSchema, ArtifactRegistry, ArtifactRegistrySchema as ArtifactRegistryConfigSchema, ArtifactRegistryHeartbeatDataSchema, ArtifactRegistryHeartbeatStatusSchema, AwsArtifactRegistryImportDataSchema, AwsBuildImportDataSchema, AwsCodeBuildHeartbeatDataSchema, AwsComputeClusterHeartbeatDataSchema, AwsComputeClusterImportDataSchema, AwsDynamoDbKeySchemaElementSchema, AwsDynamoDbKvHeartbeatDataSchema, AwsEcrArtifactRegistryHeartbeatDataSchema, AwsEcrRepositoryHeartbeatDataSchema, AwsIamRoleServiceAccountHeartbeatDataSchema, AwsKvImportDataSchema, AwsLambdaWorkerHeartbeatDataSchema, AwsNetworkImportDataSchema, AwsParameterStoreVaultHeartbeatDataSchema, AwsQueueImportDataSchema, AwsRemoteStackManagementHeartbeatDataSchema, AwsRemoteStackManagementImportDataSchema, AwsS3StorageHeartbeatDataSchema, AwsServiceAccountImportDataSchema, AwsSqsQueueHeartbeatDataSchema, AwsStorageImportDataSchema, AwsVaultImportDataSchema, AwsVpcNetworkHeartbeatDataSchema, AwsWorkerImportDataSchema, AzureArtifactRegistryImportDataSchema, AzureBlobStorageHeartbeatDataSchema, AzureBuildImportDataSchema, AzureComputeClusterHeartbeatDataSchema, AzureComputeClusterImportDataSchema, AzureContainerAppsBuildHeartbeatDataSchema, AzureContainerAppsEnvironmentHeartbeatDataSchema, AzureContainerAppsEnvironmentHeartbeatStatusSchema, AzureContainerAppsEnvironmentImportDataSchema, AzureContainerAppsEnvironmentWorkloadProfileSchema, AzureContainerAppsWorkerHeartbeatDataSchema, AzureContainerRegistryHeartbeatDataSchema, AzureKeyVaultHeartbeatDataSchema, AzureKvImportDataSchema, AzureManagedIdentityServiceAccountHeartbeatDataSchema, AzureNetworkImportDataSchema, AzureQueueImportDataSchema, AzureRemoteStackManagementHeartbeatDataSchema, AzureRemoteStackManagementImportDataSchema, AzureResourceGroupHeartbeatDataSchema, AzureResourceGroupHeartbeatStatusSchema, AzureResourceGroupImportDataSchema, AzureResourceProviderActivationHeartbeatDataSchema, AzureServiceAccountImportDataSchema, AzureServiceActivationImportDataSchema, AzureServiceBusNamespaceHeartbeatDataSchema, AzureServiceBusNamespaceImportDataSchema, AzureServiceBusQueueHeartbeatDataSchema, AzureStorageAccountEndpointsSchema, AzureStorageAccountHeartbeatDataSchema, AzureStorageAccountImportDataSchema, AzureStorageImportDataSchema, AzureTableKvHeartbeatDataSchema, AzureVaultImportDataSchema, AzureVnetNetworkHeartbeatDataSchema, AzureWorkerImportDataSchema, BindingNotFoundError, BodySpecSchema, Build, BuildConfigSchema, BuildHeartbeatDataSchema, BuildHeartbeatStatusSchema, BuildOutputsSchema, BuildStatusSchema, CapacityGroupScalePolicySchema, CapacityGroupSchema, CommandDeliveryModeSchema, CommandResponseSchema, CommandStateSchema, CommandStatusResponseSchema, CommandTargetSchema, CommandTargetTypeSchema, ComputeCapacityGroupStatusSchema, ComputeCapacityRecommendationSchema, ComputeChoiceRangeSchema, ComputeCluster, ComputeClusterSchema as ComputeClusterConfigSchema, ComputeClusterHeartbeatDataSchema, ComputeClusterHeartbeatStatusSchema, ComputeTypeSchema, Container, ContainerAutoscalingSchema, ContainerCodeSchema, ContainerSchema as ContainerConfigSchema, ContainerHeartbeatDataSchema, ContainerPortSchema, CreateCommandRequestSchema, CreateCommandResponseSchema, Daemon, DaemonCodeSchema, DaemonSchema as DaemonConfigSchema, DaemonHeartbeatDataSchema, DaemonOutputsSchema, DeploymentModelSchema, DevResourceInfoSchema, DevStatusSchema, DevStatusStateSchema, Email, EmailSchema as EmailConfigSchema, EnvelopeSchema, EventChangeSchema, EventStateSchema, ExposeProtocolSchema, GcpArtifactRegistryHeartbeatDataSchema, GcpArtifactRegistryImportDataSchema, GcpBuildImportDataSchema, GcpCloudBuildHeartbeatDataSchema, GcpCloudRunWorkerHeartbeatDataSchema, GcpCloudStorageHeartbeatDataSchema, GcpComputeClusterHeartbeatDataSchema, GcpComputeClusterImportDataSchema, GcpFirestoreKvHeartbeatDataSchema, GcpKvImportDataSchema, GcpNetworkImportDataSchema, GcpPubSubQueueHeartbeatDataSchema, GcpQueueImportDataSchema, GcpRemoteStackManagementHeartbeatDataSchema, GcpRemoteStackManagementImportDataSchema, GcpSecretManagerVaultHeartbeatDataSchema, GcpServiceAccountHeartbeatDataSchema, GcpServiceAccountImportDataSchema, GcpServiceActivationImportDataSchema, GcpServiceUsageActivationHeartbeatDataSchema, GcpStorageImportDataSchema, GcpVaultImportDataSchema, GcpVpcNetworkHeartbeatDataSchema, GcpWorkerImportDataSchema, HeartbeatBackendSchema, HeartbeatIssueSeveritySchema, HeartbeatsModeSchema, HorizonContainerHeartbeatDataSchema, HttpMethodSchema, InvalidBindingConfigError, Key, KeySchema as KeyConfigSchema, KubernetesBuildHeartbeatDataSchema, KubernetesClusterNodeStatusSchema, KubernetesContainerHeartbeatDataSchema, KubernetesDaemonHeartbeatDataSchema, KubernetesEventInvolvedObjectSchema, KubernetesEventSnapshotSchema, KubernetesEventSourceSchema, KubernetesNodeConditionStatusSchema, KubernetesNodeResourcesSchema, KubernetesNodeUsageSchema, KubernetesPodRuntimeUnitStatusSchema, KubernetesSecretVaultHeartbeatDataSchema, KubernetesWorkerHeartbeatDataSchema, Kv, KvSchema as KvConfigSchema, KvHeartbeatDataSchema, KvHeartbeatStatusSchema, LeaseInfoSchema, LeaseRequestSchema, LeaseResponseSchema, LocalArtifactRegistryHeartbeatDataSchema, LocalComputeClusterHeartbeatDataSchema, LocalContainerHeartbeatDataSchema, LocalDaemonHeartbeatDataSchema, LocalKvHeartbeatDataSchema, LocalQueueHeartbeatDataSchema, LocalRuntimeEventSnapshotSchema, LocalRuntimeEventSubjectSchema, LocalRuntimeUnitKindSchema, LocalRuntimeUnitStatusSchema, LocalServiceAccountHeartbeatDataSchema, LocalStorageHeartbeatDataSchema, LocalVaultHeartbeatDataSchema, LocalWorkerHeartbeatDataSchema, MachineProfileSchema, ManagedRuntimeEventInvolvedObjectSchema, ManagedRuntimeEventSnapshotSchema, ManagedRuntimeEventSourceSchema, ManagedRuntimeUnitStatusSchema, MessagePayloadSchema, MetricSampleSchema, NetworkHeartbeatDataSchema, NetworkHeartbeatStatusSchema, ObservedCountsSchema, ObservedHealthSchema, ObservedInventoryBatchSchema, ObservedResourceSampleSchema, PermissionSetSchema, PlatformSchema, Postgres, PostgresSchema as PostgresConfigSchema, PresignedRequestBackendSchema, PresignedRequestSchema, ProviderFleetStatusSchema, ProviderLifecycleStateSchema, PublicEndpointSchema, Queue, QueueSchema as QueueConfigSchema, QueueHeartbeatDataSchema, QueueHeartbeatStatusSchema, QueueMessageSchema, ReadinessProbeSchema, ReleaseRequestSchema, RemoteStackManagementHeartbeatDataSchema, RemoteStackManagementHeartbeatStatusSchema, Resource, ResourceHeartbeatDataSchema, ResourceHeartbeatSchema, ResourceLifecycleSchema, ResourceNotFoundError, ResourceOutputsParseError, ResourceRefSchema, ResourceSchemaMapping, ResourceStatusSchema, ResourceTypeSchema, ResponseHandlingSchema, ScheduledEventSchema, ServiceAccount, ServiceAccountSchema as ServiceAccountConfigSchema, ServiceAccountHeartbeatDataSchema, ServiceAccountHeartbeatStatusSchema, ServiceAccountOutputsSchema, ServiceActivationHeartbeatDataSchema, ServiceActivationHeartbeatStatusSchema, Stack, StackInputDefaultValueSchema, StackInputDefinitionSchema, StackInputEnvironmentMappingSchema, StackInputEnvironmentVariableTypeSchema, StackInputKindSchema, StackInputProviderSchema, StackInputValidationSchema, StackResourceStateSchema, StackSchema, StackSettingsSchema, StackStateSchema, StackStatusSchema, Storage, StorageSchema as StorageConfigSchema, StorageEventSchema, StorageEventTypeSchema, StorageEventsSchema, StorageHeartbeatDataSchema, StorageHeartbeatStatusSchema, StorageUploadSchema, SubmitResponseRequestSchema, TelemetryModeSchema, TraceContextSchema, UnexpectedResourceTypeError, UpdatesModeSchema, UploadCompleteRequestSchema, UploadCompleteResponseSchema, Vault, VaultSchema as VaultConfigSchema, VaultHeartbeatDataSchema, VaultHeartbeatStatusSchema, Worker, WorkerSchema as WorkerConfigSchema, WorkerHeartbeatDataSchema, WorkerOutputsSchema, WorkerPublicEndpointSchema, WorkerTriggerSchema, WorkloadHeartbeatStatusSchema, WorkloadReplicaStatusSchema, defineBooleanInput as boolean, defineError, defineEnumInput as enum, experimental, getResourceOutputs, getStackInputDefinitions, inputs, defineIntegerInput as integer, defineNumberInput as number, defineSecretInput as secret, defineStringInput as string, defineStringListInput as stringList };
9609
9906
 
9610
9907
  //# sourceMappingURL=index.js.map