@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 623 lines 21.7 KB
Raw
1 import * as bne from "@distilled.cloud/gcp/blockchainnodeengine_v1";
2 import { Unowned } from "alchemy/AdoptPolicy";
3 import { isResolved } from "alchemy/Diff";
4 import * as Provider from "alchemy/Provider";
5 import { Resource } from "alchemy/Resource";
6 import { tagRecord } from "alchemy/Tags";
7 import * as Effect from "effect/Effect";
8 import * as Schedule from "effect/Schedule";
9 import { GcpEnvironment } from "../Environment.ts";
10 import { createInternalLabels, diffLabels, hasAlchemyLabels, toLabels } from "../Labels.ts";
11 import type { Providers } from "../Providers.ts";
12 import {
13 COLLECTION,
14 DEFAULT_BLOCKCHAIN_TYPE,
15 DEFAULT_CONSENSUS_CLIENT,
16 DEFAULT_EXECUTION_CLIENT,
17 DEFAULT_NETWORK,
18 DEFAULT_NODE_TYPE,
19 ResourceNotResolved,
20 fieldMask,
21 isReadyState,
22 listAtLocation,
23 listLabeledPages,
24 normalizeEnum,
25 normalizeLocation,
26 parentOf,
27 parseName,
28 replaceOnIdentity,
29 resourceName,
30 sameEnum,
31 sameStringList,
32 sameText,
33 toPhysicalId,
34 userLabels,
35 waitForOperation,
36 waitUntilExists,
37 waitUntilGone,
38 waitUntilReady,
39 } from "./internal.ts";
40
41 export type ValidatorConfig = {
42 /**
43 * Ethereum address the beacon client sends fee rewards to when the
44 * validator client has no recipient configured.
45 */
46 beaconFeeRecipient?: string;
47 /**
48 * MEV-relay URLs. When set, a GCP-managed MEV-boost service is
49 * configured on the beacon client.
50 */
51 mevRelayUrls?: string[];
52 /**
53 * Deploy a GCP-managed validator client next to the beacon client.
54 * Immutable — changing it replaces the node.
55 */
56 managedValidatorClient?: boolean;
57 };
58
59 export type GethDetails = {
60 /**
61 * Geth garbage collection mode (`FULL` or `ARCHIVE`). Immutable —
62 * changing it replaces the node.
63 */
64 garbageCollectionMode?: bne.GethDetailsGarbageCollectionModeEnum | (string & {});
65 };
66
67 export type EthereumDetails = {
68 /**
69 * Ethereum node type (`LIGHT`, `FULL`, `ARCHIVE`). Immutable —
70 * changing it replaces the node.
71 * @default "FULL"
72 */
73 nodeType?: bne.EthereumDetailsNodeTypeEnum | (string & {});
74 /**
75 * Enable JSON-RPC `debug` namespace methods. Immutable — changing it
76 * replaces the node.
77 * @default false
78 */
79 apiEnableDebug?: boolean;
80 /**
81 * Ethereum network (`MAINNET`, `TESTNET_SEPOLIA`, `TESTNET_HOLESKY`,
82 * `TESTNET_GOERLI_PRATER`). Immutable — changing it replaces the node.
83 * @default "TESTNET_SEPOLIA"
84 */
85 network?: bne.EthereumDetailsNetworkEnum | (string & {});
86 /**
87 * Validator / MEV configuration. `beaconFeeRecipient` and
88 * `mevRelayUrls` update in place; `managedValidatorClient` is
89 * immutable.
90 */
91 validatorConfig?: ValidatorConfig;
92 /**
93 * Geth-specific options. Immutable.
94 */
95 gethDetails?: GethDetails;
96 /**
97 * Execution client (`GETH` or `ERIGON`). Immutable — changing it
98 * replaces the node.
99 * @default "GETH"
100 */
101 executionClient?: bne.EthereumDetailsExecutionClientEnum | (string & {});
102 /**
103 * Consensus client (`LIGHTHOUSE` or `ERIGON_EMBEDDED_CONSENSUS_LAYER`).
104 * Immutable — changing it replaces the node.
105 * @default "LIGHTHOUSE"
106 */
107 consensusClient?: bne.EthereumDetailsConsensusClientEnum | (string & {});
108 /**
109 * Enable JSON-RPC `admin` namespace methods. Immutable — changing it
110 * replaces the node.
111 * @default false
112 */
113 apiEnableAdmin?: boolean;
114 };
115
116 export type EndpointInfo = {
117 /** JSON-RPC HTTPS endpoint. */
118 jsonRpcApiEndpoint: string | undefined;
119 /** WebSocket endpoint. */
120 websocketsApiEndpoint: string | undefined;
121 };
122
123 export type ConnectionInfo = {
124 /**
125 * Private Service Connect attachment
126 * (`projects/{project}/regions/{region}/serviceAttachments/{name}`).
127 */
128 serviceAttachment: string | undefined;
129 /** Public JSON-RPC / WebSocket endpoints, when exposed. */
130 endpointInfo: EndpointInfo | undefined;
131 };
132
133 export type EthereumEndpoints = {
134 /** Beacon API endpoint. */
135 beaconApiEndpoint: string | undefined;
136 /** Beacon Prometheus metrics endpoint. */
137 beaconPrometheusMetricsApiEndpoint: string | undefined;
138 /** Execution-client Prometheus metrics endpoint. */
139 executionClientPrometheusMetricsApiEndpoint: string | undefined;
140 };
141
142 export type BlockchainNodeProps = {
143 /**
144 * Node id (the `{blockchainNode}` segment of
145 * `projects/{project}/locations/{location}/blockchainNodes/{blockchainNode}`).
146 * If omitted, a unique RFC1035 name is generated from the stack, stage,
147 * and logical id. Must be 1-63 characters, start with a letter, and end
148 * with a letter or digit. Immutable — changing it replaces the node.
149 */
150 blockchainNodeId?: string;
151 /**
152 * Region (`us-central1`, `us-east1`, …). Immutable — changing it
153 * replaces the node. `US-CENTRAL1` is accepted and normalized to
154 * `us-central1`.
155 * @default the stack's GCP region (`GCP.Region`, else the profile
156 * region, else `us-central1`)
157 */
158 location?: string;
159 /**
160 * Blockchain type. Ethereum is the only supported value. Immutable —
161 * changing it replaces the node.
162 * @default "ETHEREUM"
163 */
164 blockchainType?: bne.BlockchainNodeBlockchainTypeEnum | (string & {});
165 /**
166 * Restrict access to Private Service Connect (no public endpoints).
167 * Deprecated by the API in favor of public endpoints. Immutable —
168 * changing it replaces the node.
169 * @default false
170 */
171 privateServiceConnectEnabled?: boolean;
172 /**
173 * Ethereum-specific configuration. Immutable fields (`network`,
174 * `nodeType`, clients, API namespaces, Geth GC mode, managed
175 * validator) replace the node. Validator fee recipient and MEV
176 * relays update in place.
177 */
178 ethereumDetails?: EthereumDetails;
179 /**
180 * User labels. Alchemy ownership labels are merged in automatically.
181 */
182 labels?: Record<string, string>;
183 };
184
185 export type BlockchainNode = Resource<
186 "GCP.BlockchainNodeEngine.BlockchainNode",
187 BlockchainNodeProps,
188 {
189 /** Full resource name `projects/{project}/locations/{location}/blockchainNodes/{blockchainNode}`. */
190 name: string;
191 /** Node id (last path segment). */
192 blockchainNodeId: string;
193 /** Project id. */
194 project: string;
195 /** Region id (`us-central1`, …). */
196 location: string;
197 /** Blockchain type (`ETHEREUM`). */
198 blockchainType: string | undefined;
199 /** Whether Private Service Connect is enabled. */
200 privateServiceConnectEnabled: boolean;
201 /** User labels (Alchemy ownership labels stripped). */
202 labels: Record<string, string>;
203 /** Ethereum configuration currently applied. */
204 ethereumDetails: EthereumDetails | undefined;
205 /** Ethereum-specific additional endpoints. */
206 additionalEndpoints: EthereumEndpoints | undefined;
207 /** Connection information (JSON-RPC / WebSocket / PSC). */
208 connectionInfo: ConnectionInfo | undefined;
209 /** Server-reported state (`CREATING`, `RUNNING`, `SYNCING`, …). */
210 state: string | undefined;
211 /** RFC3339 creation timestamp. */
212 createTime: string | undefined;
213 /** RFC3339 last-update timestamp. */
214 updateTime: string | undefined;
215 },
216 never,
217 Providers
218 >;
219
220 /**
221 * A Blockchain Node Engine node — a fully managed Ethereum execution
222 * and consensus client.
223 *
224 * Changing `blockchainNodeId`, `location`, `blockchainType`,
225 * `privateServiceConnectEnabled`, or immutable Ethereum fields
226 * (`network`, `nodeType`, execution/consensus clients, API namespaces,
227 * Geth garbage collection, managed validator) replaces the node.
228 * Labels, `beaconFeeRecipient`, and `mevRelayUrls` update in place.
229 *
230 * Provisioning typically takes 15-45 minutes and the API is
231 * entitlement-gated. Prefer `TESTNET_SEPOLIA` over `MAINNET`.
232 *
233 * ### Creating a Node
234 * **Example:** Generated name, Sepolia full node
235 * ```typescript
236 * const node = yield* GCP.BlockchainNodeEngine.BlockchainNode("Sepolia", {});
237 * ```
238 *
239 * **Example:** Explicit id, labels, and Geth archive
240 * ```typescript
241 * const node = yield* GCP.BlockchainNodeEngine.BlockchainNode("Sepolia", {
242 * blockchainNodeId: "app-sepolia",
243 * location: "us-central1",
244 * labels: { env: "prod" },
245 * ethereumDetails: {
246 * network: "TESTNET_SEPOLIA",
247 * nodeType: "ARCHIVE",
248 * executionClient: "GETH",
249 * consensusClient: "LIGHTHOUSE",
250 * gethDetails: { garbageCollectionMode: "ARCHIVE" },
251 * },
252 * });
253 * ```
254 *
255 * ### Validator configuration
256 * **Example:** Suggested fee recipient and MEV relays
257 * ```typescript
258 * const node = yield* GCP.BlockchainNodeEngine.BlockchainNode("Sepolia", {
259 * ethereumDetails: {
260 * network: "TESTNET_SEPOLIA",
261 * nodeType: "FULL",
262 * validatorConfig: {
263 * beaconFeeRecipient: "0x0000000000000000000000000000000000000000",
264 * mevRelayUrls: ["https://relay.example"],
265 * },
266 * },
267 * });
268 * ```
269 *
270 * @resource
271 * @category BlockchainNodeEngine
272 */
273 export const BlockchainNode = Resource<BlockchainNode>("GCP.BlockchainNodeEngine.BlockchainNode");
274
275 const toValidator = (
276 config: bne.ValidatorConfig | ValidatorConfig | undefined,
277 ): ValidatorConfig | undefined => {
278 if (config === undefined) return undefined;
279 if (
280 config.beaconFeeRecipient === undefined &&
281 (config.mevRelayUrls === undefined || config.mevRelayUrls.length === 0) &&
282 config.managedValidatorClient === undefined
283 ) {
284 return undefined;
285 }
286 return {
287 beaconFeeRecipient: config.beaconFeeRecipient,
288 mevRelayUrls: config.mevRelayUrls ? [...config.mevRelayUrls] : undefined,
289 managedValidatorClient: config.managedValidatorClient,
290 };
291 };
292
293 const toGeth = (details: bne.GethDetails | GethDetails | undefined): GethDetails | undefined => {
294 if (details?.garbageCollectionMode === undefined) return undefined;
295 return { garbageCollectionMode: details.garbageCollectionMode };
296 };
297
298 const toEthereum = (
299 details: bne.EthereumDetails | EthereumDetails | undefined,
300 ): EthereumDetails | undefined => {
301 if (details === undefined) return undefined;
302 return {
303 nodeType: details.nodeType,
304 apiEnableDebug: details.apiEnableDebug,
305 network: details.network,
306 validatorConfig: toValidator(details.validatorConfig),
307 gethDetails: toGeth(details.gethDetails),
308 executionClient: details.executionClient,
309 consensusClient: details.consensusClient,
310 apiEnableAdmin: details.apiEnableAdmin,
311 };
312 };
313
314 const mergeEthereum = (
315 previous: EthereumDetails | undefined,
316 next: EthereumDetails | undefined,
317 ): EthereumDetails => ({
318 nodeType: next?.nodeType ?? previous?.nodeType,
319 apiEnableDebug: next?.apiEnableDebug ?? previous?.apiEnableDebug,
320 network: next?.network ?? previous?.network,
321 validatorConfig: {
322 beaconFeeRecipient:
323 next?.validatorConfig?.beaconFeeRecipient ?? previous?.validatorConfig?.beaconFeeRecipient,
324 mevRelayUrls: next?.validatorConfig?.mevRelayUrls ?? previous?.validatorConfig?.mevRelayUrls,
325 managedValidatorClient:
326 next?.validatorConfig?.managedValidatorClient ??
327 previous?.validatorConfig?.managedValidatorClient,
328 },
329 gethDetails: {
330 garbageCollectionMode:
331 next?.gethDetails?.garbageCollectionMode ?? previous?.gethDetails?.garbageCollectionMode,
332 },
333 executionClient: next?.executionClient ?? previous?.executionClient,
334 consensusClient: next?.consensusClient ?? previous?.consensusClient,
335 apiEnableAdmin: next?.apiEnableAdmin ?? previous?.apiEnableAdmin,
336 });
337
338 const ethereumIdentityKey = (details: EthereumDetails | undefined) =>
339 JSON.stringify({
340 nodeType: normalizeEnum(details?.nodeType, ""),
341 network: normalizeEnum(details?.network, ""),
342 executionClient: normalizeEnum(details?.executionClient, ""),
343 consensusClient: normalizeEnum(details?.consensusClient, ""),
344 apiEnableAdmin: details?.apiEnableAdmin === true,
345 apiEnableDebug: details?.apiEnableDebug === true,
346 gc: normalizeEnum(details?.gethDetails?.garbageCollectionMode, ""),
347 managedValidator: details?.validatorConfig?.managedValidatorClient === true,
348 });
349
350 const desiredEthereum = (news: BlockchainNodeProps): EthereumDetails => {
351 const details = news.ethereumDetails;
352 return {
353 nodeType: normalizeEnum(details?.nodeType, DEFAULT_NODE_TYPE),
354 apiEnableDebug: details?.apiEnableDebug === true,
355 network: normalizeEnum(details?.network, DEFAULT_NETWORK),
356 validatorConfig: details?.validatorConfig,
357 gethDetails: details?.gethDetails,
358 executionClient: normalizeEnum(details?.executionClient, DEFAULT_EXECUTION_CLIENT),
359 consensusClient: normalizeEnum(details?.consensusClient, DEFAULT_CONSENSUS_CLIENT),
360 apiEnableAdmin: details?.apiEnableAdmin === true,
361 };
362 };
363
364 const toCreateBody = (
365 news: BlockchainNodeProps,
366 desiredLabels: Record<string, string>,
367 ): bne.BlockchainNode => {
368 const ethereum = desiredEthereum(news);
369 return {
370 blockchainType: normalizeEnum(news.blockchainType, DEFAULT_BLOCKCHAIN_TYPE),
371 privateServiceConnectEnabled: news.privateServiceConnectEnabled === true,
372 labels: desiredLabels,
373 ethereumDetails: {
374 nodeType: ethereum.nodeType,
375 apiEnableDebug: ethereum.apiEnableDebug,
376 network: ethereum.network,
377 validatorConfig: ethereum.validatorConfig,
378 gethDetails: ethereum.gethDetails,
379 executionClient: ethereum.executionClient,
380 consensusClient: ethereum.consensusClient,
381 apiEnableAdmin: ethereum.apiEnableAdmin,
382 },
383 };
384 };
385
386 const toEndpoints = (
387 endpoints: bne.EthereumEndpoints | undefined,
388 ): EthereumEndpoints | undefined => {
389 if (endpoints === undefined) return undefined;
390 return {
391 beaconApiEndpoint: endpoints.beaconApiEndpoint,
392 beaconPrometheusMetricsApiEndpoint: endpoints.beaconPrometheusMetricsApiEndpoint,
393 executionClientPrometheusMetricsApiEndpoint:
394 endpoints.executionClientPrometheusMetricsApiEndpoint,
395 };
396 };
397
398 const toConnection = (info: bne.ConnectionInfo | undefined): ConnectionInfo | undefined => {
399 if (info === undefined) return undefined;
400 return {
401 serviceAttachment: info.serviceAttachment,
402 endpointInfo: info.endpointInfo
403 ? {
404 jsonRpcApiEndpoint: info.endpointInfo.jsonRpcApiEndpoint,
405 websocketsApiEndpoint: info.endpointInfo.websocketsApiEndpoint,
406 }
407 : undefined,
408 };
409 };
410
411 const toAttrs = (node: bne.BlockchainNode, project: string, region: string) => {
412 const name = node.name ?? "";
413 const parsed = parseName(name, region);
414 return {
415 name,
416 blockchainNodeId: parsed.id,
417 project: parsed.project || project,
418 location: parsed.location,
419 blockchainType: node.blockchainType,
420 privateServiceConnectEnabled: node.privateServiceConnectEnabled === true,
421 labels: userLabels(node.labels),
422 ethereumDetails: toEthereum(node.ethereumDetails),
423 additionalEndpoints: toEndpoints(node.ethereumDetails?.additionalEndpoints),
424 connectionInfo: toConnection(node.connectionInfo),
425 state: node.state,
426 createTime: node.createTime,
427 updateTime: node.updateTime,
428 };
429 };
430
431 const isPlaceholder = (node: bne.BlockchainNode) => {
432 const name = node.name ?? "";
433 return name.length === 0 || name.endsWith(`/${COLLECTION}/-`) || name.endsWith(`/${COLLECTION}/`);
434 };
435
436 const getByName = (name: string) =>
437 name.length === 0
438 ? Effect.undefined
439 : bne
440 .getProjectsLocationsBlockchainNodes({ name })
441 .pipe(Effect.catchTag("NotFound", () => Effect.undefined));
442
443 const listOwned = (project: string, region: string) =>
444 listAtLocation(project, region, (parent) =>
445 listLabeledPages(
446 bne.listProjectsLocationsBlockchainNodes.pages({
447 parent,
448 pageSize: 1000,
449 }),
450 (page) => page.blockchainNodes,
451 (item) => item.labels,
452 ),
453 );
454
455 export const BlockchainNodeProvider = () =>
456 Provider.succeed(BlockchainNode, {
457 stables: ["name", "blockchainNodeId", "project", "location", "blockchainType", "createTime"],
458
459 diff: Effect.fn(function* ({ news, olds, output }) {
460 if (!isResolved(news)) return undefined;
461 const env = yield* GcpEnvironment.current;
462 const previousType = olds?.blockchainType ?? output?.blockchainType;
463 const nextType = news.blockchainType ?? previousType;
464 const previousPsc =
465 olds?.privateServiceConnectEnabled ?? output?.privateServiceConnectEnabled;
466 const nextPsc = news.privateServiceConnectEnabled ?? previousPsc ?? false;
467 const previousEthereum = toEthereum(olds?.ethereumDetails ?? output?.ethereumDetails);
468 const nextEthereum = mergeEthereum(previousEthereum, news.ethereumDetails);
469 return replaceOnIdentity({
470 previousId: olds?.blockchainNodeId ?? output?.blockchainNodeId,
471 nextId: news.blockchainNodeId ?? olds?.blockchainNodeId ?? output?.blockchainNodeId,
472 previousLocation: normalizeLocation(olds?.location ?? output?.location, env.region),
473 nextLocation: normalizeLocation(
474 news.location ?? olds?.location ?? output?.location,
475 env.region,
476 ),
477 extra:
478 (previousType !== undefined &&
479 nextType !== undefined &&
480 !sameEnum(previousType, nextType)) ||
481 (previousPsc === true) !== (nextPsc === true) ||
482 (previousEthereum !== undefined &&
483 ethereumIdentityKey(previousEthereum) !== ethereumIdentityKey(nextEthereum)),
484 });
485 }),
486
487 read: Effect.fn(function* ({ id, olds, output }) {
488 const env = yield* GcpEnvironment.current;
489 const blockchainNodeId = yield* toPhysicalId(
490 id,
491 olds?.blockchainNodeId,
492 output?.blockchainNodeId,
493 "node",
494 );
495 const location = normalizeLocation(olds?.location ?? output?.location, env.region);
496 const name = output?.name ?? resourceName(env.project, location, blockchainNodeId);
497 const existing = yield* getByName(name);
498 if (existing === undefined) return undefined;
499 const attrs = toAttrs(existing, env.project, env.region);
500 return (yield* hasAlchemyLabels(id, tagRecord(existing.labels))) ? attrs : Unowned(attrs);
501 }),
502
503 list: () =>
504 Effect.gen(function* () {
505 const env = yield* GcpEnvironment.current;
506 const items = yield* listOwned(env.project, env.region);
507 return items
508 .filter((item) => !isPlaceholder(item))
509 .map((item) => toAttrs(item, env.project, env.region));
510 }),
511
512 reconcile: Effect.fn(function* ({ id, news, output }) {
513 const env = yield* GcpEnvironment.current;
514 const blockchainNodeId = yield* toPhysicalId(
515 id,
516 news.blockchainNodeId,
517 output?.blockchainNodeId,
518 "node",
519 );
520 const location = normalizeLocation(news.location ?? output?.location, env.region);
521 const name = resourceName(env.project, location, blockchainNodeId);
522 const desiredLabels = {
523 ...toLabels(news.labels),
524 ...(yield* createInternalLabels(id)),
525 };
526
527 let current = yield* getByName(output?.name ?? name);
528
529 if (current === undefined) {
530 const created = yield* bne
531 .createProjectsLocationsBlockchainNodes({
532 parent: parentOf(env.project, location),
533 blockchainNodeId,
534 body: toCreateBody(news, desiredLabels),
535 })
536 .pipe(Effect.catchTag("Conflict", () => Effect.undefined));
537 if (created !== undefined) {
538 yield* waitForOperation(created);
539 }
540 current = yield* waitUntilExists(getByName(name), name);
541 }
542
543 if (current === undefined) {
544 return yield* new ResourceNotResolved({ resourceName: name });
545 }
546
547 let latest = current;
548 if (!isReadyState(latest.state)) {
549 latest = yield* waitUntilReady(
550 getByName(latest.name ?? name),
551 latest.name ?? name,
552 (node) => node.state,
553 );
554 }
555
556 const observedLabels = tagRecord(latest.labels);
557 const { upsert, removed } = diffLabels(observedLabels, desiredLabels);
558 const labelsChanged = upsert.length > 0 || removed.length > 0;
559 const desiredValidator = news.ethereumDetails?.validatorConfig;
560 const observedValidator = latest.ethereumDetails?.validatorConfig;
561 const feeChanged =
562 desiredValidator?.beaconFeeRecipient !== undefined &&
563 !sameText(
564 (observedValidator?.beaconFeeRecipient ?? "").toLowerCase(),
565 desiredValidator.beaconFeeRecipient.toLowerCase(),
566 );
567 const relaysChanged =
568 desiredValidator?.mevRelayUrls !== undefined &&
569 !sameStringList(observedValidator?.mevRelayUrls, desiredValidator.mevRelayUrls);
570
571 const mask = fieldMask([
572 labelsChanged && "labels",
573 feeChanged && "ethereum_details.validator_config.beacon_fee_recipient",
574 relaysChanged && "ethereum_details.validator_config.mev_relay_urls",
575 ]);
576
577 if (mask.length > 0) {
578 const operation = yield* bne.patchProjectsLocationsBlockchainNodes({
579 name: latest.name ?? name,
580 updateMask: mask,
581 body: {
582 name: latest.name ?? name,
583 labels: desiredLabels,
584 ethereumDetails:
585 feeChanged || relaysChanged
586 ? {
587 validatorConfig: {
588 beaconFeeRecipient:
589 desiredValidator?.beaconFeeRecipient ??
590 observedValidator?.beaconFeeRecipient,
591 mevRelayUrls:
592 desiredValidator?.mevRelayUrls ?? observedValidator?.mevRelayUrls,
593 },
594 }
595 : undefined,
596 },
597 });
598 yield* waitForOperation(operation);
599 latest = yield* waitUntilExists(getByName(latest.name ?? name), latest.name ?? name);
600 }
601
602 return toAttrs(latest, env.project, env.region);
603 }),
604
605 delete: Effect.fn(function* ({ output }) {
606 const operation = yield* bne
607 .deleteProjectsLocationsBlockchainNodes({
608 name: output.name,
609 })
610 .pipe(
611 Effect.retry({
612 while: (error) => error._tag === "Conflict",
613 times: 8,
614 schedule: Schedule.spaced("5 seconds"),
615 }),
616 Effect.catchTag("NotFound", () => Effect.undefined),
617 );
618 if (operation !== undefined) {
619 yield* waitForOperation(operation, { notFoundOk: true });
620 }
621 yield* waitUntilGone(getByName(output.name), output.name);
622 }),
623 });