{"version":3,"file":"adapter.cjs","names":["Schema","Context"],"sources":["../../../src/services/hosting/adapter.ts"],"sourcesContent":["import { Context, type Effect, Schema } from \"effect\";\n\n/**\n * The deploy console's single substrate coupling (ADR 0035): operating a\n * runtime instance — boot an image with identity env, observe it, restart it,\n * stop it — expressed in platform vocabulary only. No substrate resource\n * types, ports, networks, or machine ids cross this seam; implementations\n * return a URL and keep the derivation private.\n */\n\nexport interface RuntimeDescriptor {\n  /** Stable logical instance name, unique per hosting namespace. */\n  readonly instance: string;\n  /** OCI image reference, digest-pinned in production. */\n  readonly image: string;\n  /**\n   * Identity env forwarded verbatim (BOS_ACCOUNT / BOS_GATEWAY today). The\n   * adapter never interprets these values.\n   */\n  readonly identityEnv: Readonly<Record<string, string>>;\n}\n\nexport interface DeployedInstance {\n  readonly instance: string;\n  /** Where the instance serves traffic after a health-gated boot. */\n  readonly url: string;\n}\n\nexport interface InstanceSnapshot {\n  readonly instance: string;\n  readonly running: boolean;\n  /** Present only while the instance is running and health-known. */\n  readonly url: string | undefined;\n  readonly image: string | undefined;\n}\n\nexport class DeployFailed extends Schema.TaggedError<DeployFailed>()(\"DeployFailed\", {\n  instance: Schema.String,\n  reason: Schema.String,\n}) {}\n\nexport class HealthTimeout extends Schema.TaggedError<HealthTimeout>()(\"HealthTimeout\", {\n  instance: Schema.String,\n  url: Schema.String,\n  attempts: Schema.Finite,\n}) {}\n\nexport class InstanceNotFound extends Schema.TaggedError<InstanceNotFound>()(\"InstanceNotFound\", {\n  instance: Schema.String,\n}) {}\n\nexport class HostingOperationFailed extends Schema.TaggedError<HostingOperationFailed>()(\n  \"HostingOperationFailed\",\n  {\n    instance: Schema.String,\n    operation: Schema.String,\n    reason: Schema.String,\n  },\n) {}\n\nexport class HostingAdapter extends Context.Service<\n  HostingAdapter,\n  {\n    /**\n     * Converge the instance to the descriptor (idempotent for an unchanged\n     * descriptor), then health-gate before returning its URL.\n     */\n    deploy(\n      descriptor: RuntimeDescriptor,\n    ): Effect.Effect<DeployedInstance, DeployFailed | HealthTimeout>;\n    /** Observe the instance without mutating it. Unknown instances report `running: false`. */\n    current(instance: string): Effect.Effect<InstanceSnapshot, HostingOperationFailed>;\n    /**\n     * Restart the instance (starting it when stopped) and health-gate again.\n     * Fails for an instance that has never been deployed.\n     */\n    restart(\n      instance: string,\n    ): Effect.Effect<DeployedInstance, InstanceNotFound | HealthTimeout | HostingOperationFailed>;\n    /** Stop the instance. Fails for an instance that has never been deployed. */\n    stop(instance: string): Effect.Effect<void, InstanceNotFound | HostingOperationFailed>;\n  }\n>()(\"hosting/HostingAdapter\") {}\n\nexport type HostingAdapterService = HostingAdapter[\"Service\"];\n"],"mappings":";;;;AAoCA,IAAa,eAAb,cAAkCA,cAAO,YAA0B,CAAC,CAAC,gBAAgB;CACnF,UAAUA,cAAO;CACjB,QAAQA,cAAO;AACjB,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,gBAAb,cAAmCA,cAAO,YAA2B,CAAC,CAAC,iBAAiB;CACtF,UAAUA,cAAO;CACjB,KAAKA,cAAO;CACZ,UAAUA,cAAO;AACnB,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,mBAAb,cAAsCA,cAAO,YAA8B,CAAC,CAAC,oBAAoB,EAC/F,UAAUA,cAAO,OACnB,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,yBAAb,cAA4CA,cAAO,YAAoC,CAAC,CACtF,0BACA;CACE,UAAUA,cAAO;CACjB,WAAWA,cAAO;CAClB,QAAQA,cAAO;AACjB,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,iBAAb,cAAoCC,eAAQ,QAsB1C,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC"}