@wildo-ai/wildo-cli 1.1.14 → 1.1.16
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/src/commands/context/journey.command.d.ts.map +1 -1
- package/dist/src/commands/context/journey.command.js +12 -0
- package/dist/src/commands/context/journey.command.js.map +1 -1
- package/dist/src/commands/creation/drive.command.d.ts.map +1 -1
- package/dist/src/commands/creation/drive.command.js +2 -1
- package/dist/src/commands/creation/drive.command.js.map +1 -1
- package/dist/src/commands/generate/email-command.utils.d.ts +2 -0
- package/dist/src/commands/generate/email-command.utils.d.ts.map +1 -1
- package/dist/src/commands/generate/email-command.utils.js +5 -0
- package/dist/src/commands/generate/email-command.utils.js.map +1 -1
- package/dist/src/commands/init.command.d.ts.map +1 -1
- package/dist/src/commands/init.command.js +7 -2
- package/dist/src/commands/init.command.js.map +1 -1
- package/dist/src/commands/local/deregister.command.d.ts.map +1 -1
- package/dist/src/commands/local/deregister.command.js +4 -0
- package/dist/src/commands/local/deregister.command.js.map +1 -1
- package/dist/src/commands/local/dev.command.d.ts +50 -0
- package/dist/src/commands/local/dev.command.d.ts.map +1 -1
- package/dist/src/commands/local/dev.command.js +144 -1
- package/dist/src/commands/local/dev.command.js.map +1 -1
- package/dist/src/commands/local/jobs-command.utils.d.ts +24 -0
- package/dist/src/commands/local/jobs-command.utils.d.ts.map +1 -0
- package/dist/src/commands/local/jobs-command.utils.js +44 -0
- package/dist/src/commands/local/jobs-command.utils.js.map +1 -0
- package/dist/src/commands/local/jobs-run.command.d.ts +7 -0
- package/dist/src/commands/local/jobs-run.command.d.ts.map +1 -0
- package/dist/src/commands/local/jobs-run.command.js +92 -0
- package/dist/src/commands/local/jobs-run.command.js.map +1 -0
- package/dist/src/commands/local/jobs.command.d.ts +7 -0
- package/dist/src/commands/local/jobs.command.d.ts.map +1 -0
- package/dist/src/commands/local/jobs.command.js +59 -0
- package/dist/src/commands/local/jobs.command.js.map +1 -0
- package/dist/src/commands/local/tunnel.command.d.ts +84 -0
- package/dist/src/commands/local/tunnel.command.d.ts.map +1 -0
- package/dist/src/commands/local/tunnel.command.js +274 -0
- package/dist/src/commands/local/tunnel.command.js.map +1 -0
- package/dist/src/commands/providers/grant-export.command.d.ts +16 -0
- package/dist/src/commands/providers/grant-export.command.d.ts.map +1 -0
- package/dist/src/commands/providers/grant-export.command.js +78 -0
- package/dist/src/commands/providers/grant-export.command.js.map +1 -0
- package/dist/src/commands/providers/grant-import.command.d.ts +15 -0
- package/dist/src/commands/providers/grant-import.command.d.ts.map +1 -0
- package/dist/src/commands/providers/grant-import.command.js +78 -0
- package/dist/src/commands/providers/grant-import.command.js.map +1 -0
- package/dist/src/kernel/command-runner.d.ts.map +1 -1
- package/dist/src/kernel/command-runner.js +4 -6
- package/dist/src/kernel/command-runner.js.map +1 -1
- package/dist/src/kernel/hooks.d.ts.map +1 -1
- package/dist/src/kernel/hooks.js +2 -1
- package/dist/src/kernel/hooks.js.map +1 -1
- package/dist/src/kernel/json-document-output.d.ts +7 -0
- package/dist/src/kernel/json-document-output.d.ts.map +1 -1
- package/dist/src/kernel/json-document-output.js +8 -0
- package/dist/src/kernel/json-document-output.js.map +1 -1
- package/dist/src/kernel/types.d.ts +8 -0
- package/dist/src/kernel/types.d.ts.map +1 -1
- package/dist/src/kernel/types.js.map +1 -1
- package/dist/src/services/application/app-bootstrap.service.d.ts +65 -7
- package/dist/src/services/application/app-bootstrap.service.d.ts.map +1 -1
- package/dist/src/services/application/app-bootstrap.service.js +94 -15
- package/dist/src/services/application/app-bootstrap.service.js.map +1 -1
- package/dist/src/services/application/app-local-runtime-addresses.service.d.ts +1 -1
- package/dist/src/services/application/app-local-runtime-addresses.service.d.ts.map +1 -1
- package/dist/src/services/application/app-local-runtime-addresses.service.js.map +1 -1
- package/dist/src/services/application/app-runtime-targets.service.d.ts.map +1 -1
- package/dist/src/services/application/app-runtime-targets.service.js +16 -2
- package/dist/src/services/application/app-runtime-targets.service.js.map +1 -1
- package/dist/src/services/application/application-dependency-alignment.service.d.ts +20 -0
- package/dist/src/services/application/application-dependency-alignment.service.d.ts.map +1 -1
- package/dist/src/services/application/application-dependency-alignment.service.js +32 -2
- package/dist/src/services/application/application-dependency-alignment.service.js.map +1 -1
- package/dist/src/services/application/application-runtime-bootstrap.service.d.ts +13 -0
- package/dist/src/services/application/application-runtime-bootstrap.service.d.ts.map +1 -1
- package/dist/src/services/application/application-runtime-bootstrap.service.js +32 -0
- package/dist/src/services/application/application-runtime-bootstrap.service.js.map +1 -1
- package/dist/src/services/application/environment-provider-configurations.service.d.ts +7 -0
- package/dist/src/services/application/environment-provider-configurations.service.d.ts.map +1 -1
- package/dist/src/services/application/environment-provider-configurations.service.js +1 -1
- package/dist/src/services/application/environment-provider-configurations.service.js.map +1 -1
- package/dist/src/services/application/local-tunnel.service.d.ts +153 -0
- package/dist/src/services/application/local-tunnel.service.d.ts.map +1 -0
- package/dist/src/services/application/local-tunnel.service.js +295 -0
- package/dist/src/services/application/local-tunnel.service.js.map +1 -0
- package/dist/src/services/application/provider-runtime-sync.service.d.ts.map +1 -1
- package/dist/src/services/application/provider-runtime-sync.service.js +3 -0
- package/dist/src/services/application/provider-runtime-sync.service.js.map +1 -1
- package/dist/src/services/application/saas-skeleton.service.d.ts +7 -0
- package/dist/src/services/application/saas-skeleton.service.d.ts.map +1 -1
- package/dist/src/services/application/saas-skeleton.service.js +2 -0
- package/dist/src/services/application/saas-skeleton.service.js.map +1 -1
- package/dist/src/services/catalog/service-address-resolver.service.d.ts +7 -1
- package/dist/src/services/catalog/service-address-resolver.service.d.ts.map +1 -1
- package/dist/src/services/catalog/service-address-resolver.service.js +6 -3
- package/dist/src/services/catalog/service-address-resolver.service.js.map +1 -1
- package/dist/src/services/companion/companion-client.service.d.ts +17 -0
- package/dist/src/services/companion/companion-client.service.d.ts.map +1 -1
- package/dist/src/services/companion/companion-client.service.js +21 -0
- package/dist/src/services/companion/companion-client.service.js.map +1 -1
- package/dist/src/services/companion/creation-drive.service.d.ts +18 -0
- package/dist/src/services/companion/creation-drive.service.d.ts.map +1 -1
- package/dist/src/services/companion/creation-drive.service.js +70 -1
- package/dist/src/services/companion/creation-drive.service.js.map +1 -1
- package/dist/src/services/credentials/application-secrets.service.d.ts +6 -0
- package/dist/src/services/credentials/application-secrets.service.d.ts.map +1 -1
- package/dist/src/services/credentials/application-secrets.service.js +1 -1
- package/dist/src/services/credentials/application-secrets.service.js.map +1 -1
- package/dist/src/services/credentials/provider-env-vars.utils.d.ts.map +1 -1
- package/dist/src/services/credentials/provider-env-vars.utils.js +3 -1
- package/dist/src/services/credentials/provider-env-vars.utils.js.map +1 -1
- package/dist/src/services/credentials/secrets-writer.service.d.ts +11 -2
- package/dist/src/services/credentials/secrets-writer.service.d.ts.map +1 -1
- package/dist/src/services/credentials/secrets-writer.service.js +12 -3
- package/dist/src/services/credentials/secrets-writer.service.js.map +1 -1
- package/dist/src/services/deployment/ci-deploy-generator.service.d.ts.map +1 -1
- package/dist/src/services/deployment/ci-deploy-generator.service.js +3 -3
- package/dist/src/services/deployment/ci-deploy-generator.service.js.map +1 -1
- package/dist/src/services/deployment/docker/docker-compose-generator.service.d.ts +12 -3
- package/dist/src/services/deployment/docker/docker-compose-generator.service.d.ts.map +1 -1
- package/dist/src/services/deployment/docker/docker-compose-generator.service.js +40 -22
- package/dist/src/services/deployment/docker/docker-compose-generator.service.js.map +1 -1
- package/dist/src/services/deployment/framework-pod-network-membership.d.ts +6 -0
- package/dist/src/services/deployment/framework-pod-network-membership.d.ts.map +1 -1
- package/dist/src/services/deployment/framework-pod-network-membership.js +17 -3
- package/dist/src/services/deployment/framework-pod-network-membership.js.map +1 -1
- package/dist/src/services/deployment/k8s/k8s-manifest-generator.service.d.ts +4 -1
- package/dist/src/services/deployment/k8s/k8s-manifest-generator.service.d.ts.map +1 -1
- package/dist/src/services/deployment/k8s/k8s-manifest-generator.service.js +17 -7
- package/dist/src/services/deployment/k8s/k8s-manifest-generator.service.js.map +1 -1
- package/dist/src/services/deployment/k8s/k8s-manifest.schemas.d.ts +7 -0
- package/dist/src/services/deployment/k8s/k8s-manifest.schemas.d.ts.map +1 -1
- package/dist/src/services/deployment/k8s/k8s-manifest.schemas.js.map +1 -1
- package/dist/src/services/deployment/k8s/k8s-secrets-generator.service.d.ts.map +1 -1
- package/dist/src/services/deployment/k8s/k8s-secrets-generator.service.js +15 -9
- package/dist/src/services/deployment/k8s/k8s-secrets-generator.service.js.map +1 -1
- package/dist/src/services/deployment/k8s/kind-pod-host-gateway.d.ts +43 -0
- package/dist/src/services/deployment/k8s/kind-pod-host-gateway.d.ts.map +1 -0
- package/dist/src/services/deployment/k8s/kind-pod-host-gateway.js +12 -0
- package/dist/src/services/deployment/k8s/kind-pod-host-gateway.js.map +1 -0
- package/dist/src/services/deployment/k8s/off-cluster-backing-services.d.ts +3 -1
- package/dist/src/services/deployment/k8s/off-cluster-backing-services.d.ts.map +1 -1
- package/dist/src/services/deployment/k8s/off-cluster-backing-services.js.map +1 -1
- package/dist/src/services/deployment/local-dev-late-workspace-members.service.d.ts +163 -0
- package/dist/src/services/deployment/local-dev-late-workspace-members.service.d.ts.map +1 -0
- package/dist/src/services/deployment/local-dev-late-workspace-members.service.js +356 -0
- package/dist/src/services/deployment/local-dev-late-workspace-members.service.js.map +1 -0
- package/dist/src/services/environment/authored-infra-config.utils.d.ts +13 -3
- package/dist/src/services/environment/authored-infra-config.utils.d.ts.map +1 -1
- package/dist/src/services/environment/authored-infra-config.utils.js +24 -4
- package/dist/src/services/environment/authored-infra-config.utils.js.map +1 -1
- package/dist/src/services/environment/container-host-gateway-listen-host.d.ts +6 -0
- package/dist/src/services/environment/container-host-gateway-listen-host.d.ts.map +1 -1
- package/dist/src/services/environment/container-host-gateway-listen-host.js +6 -0
- package/dist/src/services/environment/container-host-gateway-listen-host.js.map +1 -1
- package/dist/src/services/environment/env-configuration-generator.service.d.ts +12 -0
- package/dist/src/services/environment/env-configuration-generator.service.d.ts.map +1 -1
- package/dist/src/services/environment/env-configuration-generator.service.js +37 -5
- package/dist/src/services/environment/env-configuration-generator.service.js.map +1 -1
- package/dist/src/services/environment/env-vars-builder.service.d.ts +2 -1
- package/dist/src/services/environment/env-vars-builder.service.d.ts.map +1 -1
- package/dist/src/services/environment/env-vars-builder.service.js +47 -32
- package/dist/src/services/environment/env-vars-builder.service.js.map +1 -1
- package/dist/src/services/environment/environment-lifecycle.service.d.ts +7 -4
- package/dist/src/services/environment/environment-lifecycle.service.d.ts.map +1 -1
- package/dist/src/services/environment/environment-lifecycle.service.js +14 -18
- package/dist/src/services/environment/environment-lifecycle.service.js.map +1 -1
- package/dist/src/services/environment/environment-setup.service.d.ts.map +1 -1
- package/dist/src/services/environment/environment-setup.service.js +17 -6
- package/dist/src/services/environment/environment-setup.service.js.map +1 -1
- package/dist/src/services/environment/environment.service.d.ts +4 -3
- package/dist/src/services/environment/environment.service.d.ts.map +1 -1
- package/dist/src/services/environment/environment.service.js +0 -1
- package/dist/src/services/environment/environment.service.js.map +1 -1
- package/dist/src/services/framework/framework-docker-publish.service.d.ts +55 -15
- package/dist/src/services/framework/framework-docker-publish.service.d.ts.map +1 -1
- package/dist/src/services/framework/framework-docker-publish.service.js +115 -25
- package/dist/src/services/framework/framework-docker-publish.service.js.map +1 -1
- package/dist/src/services/framework/package-install.service.d.ts +7 -0
- package/dist/src/services/framework/package-install.service.d.ts.map +1 -1
- package/dist/src/services/framework/package-install.service.js +8 -1
- package/dist/src/services/framework/package-install.service.js.map +1 -1
- package/dist/src/services/registry/application-provider-connection.service.d.ts +16 -1
- package/dist/src/services/registry/application-provider-connection.service.d.ts.map +1 -1
- package/dist/src/services/registry/application-provider-connection.service.js +23 -0
- package/dist/src/services/registry/application-provider-connection.service.js.map +1 -1
- package/dist/src/services/registry/provider-grant-transfer.service.d.ts +48 -0
- package/dist/src/services/registry/provider-grant-transfer.service.d.ts.map +1 -0
- package/dist/src/services/registry/provider-grant-transfer.service.js +144 -0
- package/dist/src/services/registry/provider-grant-transfer.service.js.map +1 -0
- package/dist/src/services/registry/provider-module-scaffold.service.d.ts.map +1 -1
- package/dist/src/services/registry/provider-module-scaffold.service.js +10 -3
- package/dist/src/services/registry/provider-module-scaffold.service.js.map +1 -1
- package/dist/src/services/security/csp-sync.service.d.ts.map +1 -1
- package/dist/src/services/security/csp-sync.service.js +21 -2
- package/dist/src/services/security/csp-sync.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +19 -19
- package/templates/infra/docker-compose/docker-compose.wildo-platform.yml.hbs +16 -7
- package/templates/infra/k8s/platform/platform-crontabs-batches-manager/deployment.yaml.hbs +13 -0
- package/templates/saas/i18n/email/system/remote-agent-task-updated/labels.en.ts +11 -0
- package/templates/saas/i18n/email/system/remote-agent-task-updated/template.tsx +56 -0
- package/templates/saas/i18n/engine/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.en.ts +61 -0
- package/templates/saas/i18n/engine/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.fr.ts +61 -0
- package/templates/saas/scenarios/add-technical-doc/files/technical-doc/docusaurus.config.ts.hbs +5 -4
- package/templates/saas/scenarios/add-technical-doc/files/technical-doc/package.json.hbs +1 -1
- package/templates/saas/scenarios/add-technical-doc/files/technical-doc/scripts/substitute-api-origin.mjs +97 -32
- package/templates/saas/scenarios/add-technical-doc/files/technical-doc/src/plugins/api-reference-pages.ts +7 -6
- package/templates/saas/skeleton/.wildo-saas/wildo-dev-companion/scripts/dev-supervised.sh +18 -4
- package/templates/saas/skeleton/frontend/nginx-config/default.conf.hbs +1 -1
- package/templates/saas/skeleton/frontend/src/generated/csp.generated.json.hbs +4 -4
- package/templates/saas/skeleton/infrastructure/local/wildo.infra.local.config.ts.hbs +2 -0
- package/wildo-framework.info.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-address-resolver.service.js","sourceRoot":"","sources":["../../../../src/services/catalog/service-address-resolver.service.ts"],"names":[],"mappings":"AAAA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OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,WAAW,IAAI,EAAE,EAAE,CAAC;oBACrD,CAAC;oBACD,OAAO,YAAY,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;gBAC1C,CAAC;gBACD,OAAO,YAAY,CAAC,oBAAoB,CAAC,WAAW,EAAE,GAAG,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,CAAC;YAE9E,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,WAAW,GAAU,GAAG,CAAC,OAAO,CAAC;gBACvC,MAAM,IAAI,KAAK,CAAC,2BAA2B,WAAW,EAAE,CAAC,CAAC;YAC5D,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { PlatformDataServices } from '~wildo-cli/services/data-services/data-services.schemas';\nimport {\n type BackingServiceEnvConfig,\n type BackingServicesEnvConfig,\n BackingServiceKind,\n BackingServiceSource,\n K8S_LOCAL_DEFAULTS,\n PUBLIC_DOMAIN_DEFAULTS,\n PlatformWildoServices,\n WildoLocationType,\n WildoDeploymentRuntime,\n buildK8sInternalHost,\n} from '@wildo-ai/platform-config-lib';\nimport { DEFAULT_HOST } from '~wildo-cli/services/environment/platform-runtime.schemas';\nimport {\n INFRA_SERVICE_CATALOG,\n PLATFORM_SERVICE_CATALOG,\n resolveContainerInternalAlias,\n} from '~wildo-cli/services/catalog/service-catalog.schemas';\nimport type { PlatformEnvironmentConfiguration } from '~wildo-cli/services/environment/environment.schemas';\n\n// ============================================================================\n// Enums & Interfaces\n// ============================================================================\n\nexport enum AddressPerspective {\n HOST_FACING = 'host-facing',\n CONTAINER_INTERNAL = 'container-internal',\n}\n\nexport interface ServiceAddressContext {\n runtime: WildoDeploymentRuntime;\n locationType: WildoLocationType;\n perspective: AddressPerspective;\n namespace: string;\n /**\n * Public domain (`WildoInfraEnvConfig.publicDomain`) — the\n * runtime-agnostic external hostname browsers and reverse proxies\n * resolve. Used here only for K8s-remote host-facing addressing\n * (`https://<service>.<publicDomain>`); compose host-facing keeps\n * its `localhost` shape because operators typically don't put a\n * reverse proxy in front of local compose runs.\n */\n publicDomain: string;\n databaseSource: BackingServiceSource;\n /**\n * Authored backing-services snapshot (mirrored from\n * `wildo.infra.<env>.config.ts`). When present, per-service overrides\n * win over catalog defaults. Missing services keep catalog-driven topology.\n *\n * Override precedence per perspective:\n * - HOST_FACING: author `host` and `port` win.\n * - CONTAINER_INTERNAL (compose / K8s):\n * * container name stays canonical (catalog `containerName` /\n * `<service>.<namespace>.svc.cluster.local`) — that is the only\n * address the container network can resolve.\n * * port: author `port` wins for self-deployed services because the\n * generated docker-compose maps host port `port:port` (compose-side\n * binds match the container-listen port). For MANAGED/EXTERNAL\n * sources the author `host`/`port` are canonical for both\n * perspectives — catalog defaults never apply.\n */\n backingServices?: BackingServicesEnvConfig;\n}\n\nexport interface ResolvedServiceAddress {\n host: string;\n port: number;\n url: string;\n}\n\n/**\n * All fields are nullable: `mongodb` is null when Atlas (no local instance),\n * and ALL fields are null for K8s remote + HOST_FACING (no direct host access\n * to cluster-internal infra — use CONTAINER_INTERNAL perspective instead).\n */\nexport interface ResolvedInfraAddresses {\n mongodb: ResolvedServiceAddress | null;\n valkey: ResolvedServiceAddress | null;\n rabbitmq: ResolvedServiceAddress | null;\n rabbitmqManagement: ResolvedServiceAddress | null;\n minio: ResolvedServiceAddress | null;\n postgresql: ResolvedServiceAddress | null;\n /**\n * The ClamAV daemon an application backend submits uploads and received attachments to (#1910). Resolved like every\n * other backing service — `localhost` + the published port for a host-run process, the data-network alias for a\n * container — so a host-run dev backend reaches the same `clamav` container a containerised one does.\n */\n clamav: ResolvedServiceAddress | null;\n /**\n * The self-hosted immudb server apps-manager administers (#1696): it logs in there as the sysadmin to give each\n * application its own database and user. Resolved like every other backing service, so a host-run apps-manager and\n * a containerised one both reach the `immudb` container. Applications reach immudb through their own provider\n * address (`IMMUDB_HOST`), not through this.\n */\n immudb: ResolvedServiceAddress | null;\n /**\n * The self-hosted OpenBao holding the platform's custodied keys (#2933). apps-manager is its only client, host-run\n * in local development and containerised otherwise, so it resolves like `immudb`. Whether one runs at all is\n * `selfHostsPlatformKeyVault`; this address is meaningful only then.\n */\n openbao: ResolvedServiceAddress | null;\n}\n\nexport interface ResolvedPlatformAddresses {\n appsManager: ResolvedServiceAddress;\n crontabsBatchesManager: ResolvedServiceAddress;\n /**\n * Module-registry endpoint. Required by\n * `ApplicationEnvConfigurationSchema.PLATFORM_MODULE_REGISTRY_URL`\n * (engine `app-env-config.backend.schemas.ts`). Without this, every\n * application backend fails Zod env-validation at startup with\n * \"Invalid input: expected string, received undefined\" on\n * `PLATFORM_MODULE_REGISTRY_URL`.\n */\n moduleRegistry: ResolvedServiceAddress;\n}\n\nexport interface ResolvedAddresses {\n infra: ResolvedInfraAddresses;\n platform: ResolvedPlatformAddresses;\n}\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\nfunction buildAddress(host: string, port: number): ResolvedServiceAddress {\n return { host, port, url: `http://${host}:${port}` };\n}\n\n/**\n * Parse an authored S3-style endpoint (e.g. `http://localhost:9000`) into\n * its host/port parts. Returns `null` for malformed values so the\n * resolver can fall back to the per-field overrides (`s3.host` / `s3.port`)\n * or catalog defaults without throwing during topology resolution.\n *\n * The scheme (`http`/`https`) is intentionally NOT returned. The address\n * resolver constructs URLs with a hardcoded `http://` scheme today (see\n * `buildAddress`), so threading `useSsl` here would be a dead field that\n * lies about the resolver contract. If/when scheme propagation becomes\n * a real requirement, the `buildAddress` helper and downstream consumers\n * must be updated together — this signature change is the gate.\n */\nfunction parseEndpoint(endpoint: string | undefined): { host: string; port: number } | null {\n if (!endpoint) return null;\n try {\n const url = new URL(endpoint);\n const useSsl = url.protocol === 'https:';\n const port = url.port ? Number(url.port) : useSsl ? 443 : 80;\n if (!url.hostname || Number.isNaN(port)) return null;\n return { host: url.hostname, port };\n } catch {\n return null;\n }\n}\n\n/**\n * Resolve a host/port pair given an authored backing-service entry, the\n * catalog-driven defaults for that service, and the current perspective.\n *\n * The semantic model:\n * - For `BackingServiceSource.SELF` (we deploy the container): the catalog\n * container name is canonical for `CONTAINER_INTERNAL` because that is\n * the only DNS name the container network knows. Authored `host` only\n * applies to `HOST_FACING` (host-side dev tools). Authored `port` applies\n * to BOTH because the docker-compose generator maps `port:port`.\n * - For `BackingServiceSource.MANAGED`: the service is not in our\n * compose/K8s topology, so authored `host`/`port` are the only\n * canonical address for both perspectives. **Mongo-on-managed\n * special case**: when the brand is `'atlas'` (or any future\n * external-URL Mongo brand), callers detect this via\n * `addresses.infra.mongodb === null` (the resolver short-circuits\n * for managed Mongo at line 273) and read the connection URL from\n * secrets; this helper is not invoked for that branch. Slice\n * 4.B.0 (2026-05-07) replaced the prior `source: ATLAS` enum\n * value with `(source: MANAGED, provider: 'atlas')`.\n */\nfunction resolveOverriddenAddress(\n override: BackingServiceEnvConfig | undefined,\n fallback: { host: string; port: number },\n perspective: AddressPerspective,\n): { host: string; port: number } {\n if (!override) return fallback;\n const isManaged = override.source !== BackingServiceSource.SELF;\n\n if (isManaged) {\n return {\n host: override.host ?? fallback.host,\n port: override.port ?? fallback.port,\n };\n }\n\n if (perspective === AddressPerspective.HOST_FACING) {\n return {\n host: override.host ?? fallback.host,\n port: override.port ?? fallback.port,\n };\n }\n\n return {\n host: fallback.host,\n port: override.port ?? fallback.port,\n };\n}\n\n// ============================================================================\n// Resolver\n// ============================================================================\n\nexport class ServiceAddressResolver {\n static resolve(context: ServiceAddressContext): ResolvedAddresses {\n return {\n infra: ServiceAddressResolver.resolveInfra(context),\n platform: ServiceAddressResolver.resolvePlatform(context),\n };\n }\n\n static fromEnvironment(\n env: PlatformEnvironmentConfiguration,\n perspective: AddressPerspective,\n ): ServiceAddressContext {\n const isRemoteKubernetes =\n env.runtime === WildoDeploymentRuntime.KUBERNETES\n && env.locationType === WildoLocationType.REMOTE;\n const namespace = env.kubernetes?.namespace ?? (isRemoteKubernetes ? undefined : K8S_LOCAL_DEFAULTS.NAMESPACE);\n // `publicDomain` is a required top-level field on\n // `PlatformEnvironmentConfiguration` (mirrored from the schema's\n // required `WildoInfraEnvConfig.publicDomain`), but the default\n // `PUBLIC_DOMAIN_DEFAULTS.LOCAL_K8S` is kept as a defensive\n // belt-and-braces fallback for the local path so a hand-edited\n // hydrated config that drops the field still works for local\n // K8s development. Remote Kubernetes paths ALWAYS require an\n // explicitly authored value — there is no remote default.\n const publicDomain = env.publicDomain\n ?? (isRemoteKubernetes ? undefined : PUBLIC_DOMAIN_DEFAULTS.LOCAL_K8S);\n\n if (!namespace || !publicDomain) {\n throw new Error(\n `Environment '${env.name}' is missing explicit Kubernetes namespace or top-level publicDomain metadata.`,\n );\n }\n\n return {\n runtime: env.runtime,\n locationType: env.locationType,\n perspective,\n namespace,\n publicDomain,\n databaseSource: env.database.source ?? BackingServiceSource.SELF,\n backingServices: env.backingServices,\n };\n }\n\n // --------------------------------------------------------------------------\n // Infrastructure services\n // --------------------------------------------------------------------------\n\n private static resolveInfra(ctx: ServiceAddressContext): ResolvedInfraAddresses {\n const isK8sRemoteHostFacing =\n ctx.runtime === WildoDeploymentRuntime.KUBERNETES\n && ctx.locationType === WildoLocationType.REMOTE\n && ctx.perspective === AddressPerspective.HOST_FACING;\n\n if (isK8sRemoteHostFacing) {\n return {\n mongodb: null,\n valkey: null,\n rabbitmq: null,\n rabbitmqManagement: null,\n minio: null,\n postgresql: null,\n clamav: null,\n immudb: null,\n openbao: null,\n };\n }\n\n const mongoCatalog = INFRA_SERVICE_CATALOG[PlatformDataServices.MONGODB];\n const valkeyCatalog = INFRA_SERVICE_CATALOG[PlatformDataServices.VALKEY];\n const rabbitmqCatalog = INFRA_SERVICE_CATALOG[PlatformDataServices.RABBITMQ];\n const minioCatalog = INFRA_SERVICE_CATALOG[PlatformDataServices.MINIO];\n const pgCatalog = INFRA_SERVICE_CATALOG[PlatformDataServices.POSTGRESQL];\n const clamavCatalog = INFRA_SERVICE_CATALOG[PlatformDataServices.CLAMAV];\n const immudbCatalog = INFRA_SERVICE_CATALOG[PlatformDataServices.IMMUDB];\n const openbaoCatalog = INFRA_SERVICE_CATALOG[PlatformDataServices.OPENBAO];\n\n const mongoOverride = ctx.backingServices?.[BackingServiceKind.MONGODB];\n const redisOverride = ctx.backingServices?.[BackingServiceKind.REDIS];\n const rabbitOverride = ctx.backingServices?.[BackingServiceKind.RABBITMQ];\n const s3Override = ctx.backingServices?.[BackingServiceKind.S3];\n const pgOverride = ctx.backingServices?.[BackingServiceKind.POSTGRESQL];\n const clamavOverride = ctx.backingServices?.[BackingServiceKind.CLAMAV];\n const immudbOverride = ctx.backingServices?.[BackingServiceKind.IMMUDB];\n\n const s3EndpointParsed = parseEndpoint(s3Override?.endpoint);\n const s3OverrideMerged: BackingServiceEnvConfig | undefined = s3Override\n ? {\n ...s3Override,\n host: s3Override.host ?? s3EndpointParsed?.host,\n port: s3Override.port ?? s3EndpointParsed?.port,\n }\n : undefined;\n\n // Slice 4.B.0 (2026-05-07): the legacy `source: ATLAS` was the only\n // managed-Mongo enum value, so it stood in for \"any managed Mongo\n // — let the external service's connection URL handle it; we don't\n // need to resolve a local container address\". Post-reshape, the\n // same logic applies to every managed-Mongo brand (Atlas, future\n // DocumentDB, etc.) → loosen to the broader source check.\n const mongodb =\n ctx.databaseSource === BackingServiceSource.MANAGED\n ? null\n : ServiceAddressResolver.resolveInfraService(\n ctx,\n mongoCatalog.containerName,\n mongoCatalog.defaultPort,\n mongoCatalog.defaultPort,\n mongoOverride,\n );\n\n return {\n mongodb,\n valkey: ServiceAddressResolver.resolveInfraService(\n ctx, valkeyCatalog.containerName, valkeyCatalog.defaultPort, valkeyCatalog.defaultPort, redisOverride,\n ),\n rabbitmq: ServiceAddressResolver.resolveInfraService(\n ctx, rabbitmqCatalog.containerName, rabbitmqCatalog.defaultPort, rabbitmqCatalog.defaultPort, rabbitOverride,\n ),\n rabbitmqManagement: ServiceAddressResolver.resolveInfraService(\n ctx,\n rabbitmqCatalog.containerName,\n rabbitmqCatalog.additionalPorts!.management,\n rabbitmqCatalog.additionalPorts!.management,\n // The management UI rides on the same RabbitMQ container; we only\n // honor the authored host (HOST_FACING) — the management port itself\n // is image-defined and not part of the author surface today.\n rabbitOverride\n ? { ...rabbitOverride, port: undefined }\n : undefined,\n ),\n minio: ServiceAddressResolver.resolveInfraService(\n ctx, minioCatalog.containerName, minioCatalog.defaultPort, minioCatalog.defaultPort, s3OverrideMerged,\n ),\n postgresql: ServiceAddressResolver.resolveInfraService(\n ctx, pgCatalog.containerName, pgCatalog.defaultPort, pgCatalog.defaultPort, pgOverride,\n ),\n clamav: ServiceAddressResolver.resolveInfraService(\n ctx, clamavCatalog.containerName, clamavCatalog.defaultPort, clamavCatalog.defaultPort, clamavOverride,\n ),\n immudb: ServiceAddressResolver.resolveInfraService(\n ctx, immudbCatalog.containerName, immudbCatalog.defaultPort, immudbCatalog.defaultPort, immudbOverride,\n ),\n // No authored override: the platform's own Vault is not a backing service an environment addresses.\n openbao: ServiceAddressResolver.resolveInfraService(\n ctx, openbaoCatalog.containerName, openbaoCatalog.defaultPort, openbaoCatalog.defaultPort, undefined,\n ),\n };\n }\n\n /**\n * @param hostFacingPort Port exposed on the host (mapped port)\n * @param internalPort Port inside the container\n * @param override Optional authored backing-service entry; honored\n * per the precedence rules in `ServiceAddressContext.backingServices`.\n */\n private static resolveInfraService(\n ctx: ServiceAddressContext,\n serviceName: string,\n hostFacingPort: number,\n internalPort: number,\n override: BackingServiceEnvConfig | undefined,\n ): ResolvedServiceAddress {\n const isHostFacing = ctx.perspective === AddressPerspective.HOST_FACING;\n\n switch (ctx.runtime) {\n case WildoDeploymentRuntime.DOCKER_COMPOSE: {\n /*\n * A container dials the data-network ALIAS, never the bare service name.\n *\n * Both ends of this call are attached to `wildo-host-access`, the publish\n * bridge, which is created with ICC disabled — so the service name resolves\n * to an address that is deliberately unreachable, and the caller times out\n * against a service that is up. The alias is registered on the data segment\n * only, so it cannot resolve to the blocked bridge.\n *\n * @see CONTAINER_INTERNAL_ALIAS_SUFFIX for the measurement.\n *\n * HOST_FACING is untouched: a host process reaches the published port on\n * localhost and never consults Docker DNS.\n */\n const fallbackHost = isHostFacing ? DEFAULT_HOST : resolveContainerInternalAlias(serviceName);\n const fallbackPort = isHostFacing ? hostFacingPort : internalPort;\n const { host, port } = resolveOverriddenAddress(\n override,\n { host: fallbackHost, port: fallbackPort },\n ctx.perspective,\n );\n return buildAddress(host, port);\n }\n\n case WildoDeploymentRuntime.KUBERNETES: {\n if (ctx.locationType === WildoLocationType.LOCAL && isHostFacing) {\n const { host, port } = resolveOverriddenAddress(\n override,\n { host: DEFAULT_HOST, port: hostFacingPort },\n ctx.perspective,\n );\n return buildAddress(host, port);\n }\n const fallbackHost = buildK8sInternalHost(serviceName, ctx.namespace);\n const { host, port } = resolveOverriddenAddress(\n override,\n { host: fallbackHost, port: internalPort },\n ctx.perspective,\n );\n return buildAddress(host, port);\n }\n\n default: {\n const _exhaustive: never = ctx.runtime;\n throw new Error(`Unhandled runtime mode: ${_exhaustive}`);\n }\n }\n }\n\n // --------------------------------------------------------------------------\n // Platform (Wildo) services\n // --------------------------------------------------------------------------\n\n private static resolvePlatform(ctx: ServiceAddressContext): ResolvedPlatformAddresses {\n return {\n appsManager: ServiceAddressResolver.resolvePlatformService(ctx, PlatformWildoServices.APPS_MANAGER),\n crontabsBatchesManager: ServiceAddressResolver.resolvePlatformService(ctx, PlatformWildoServices.CRONTABS_BATCHES_MANAGER),\n moduleRegistry: ServiceAddressResolver.resolvePlatformService(ctx, PlatformWildoServices.MODULE_REGISTRY),\n };\n }\n\n private static resolvePlatformService(\n ctx: ServiceAddressContext,\n service: Exclude<PlatformWildoServices, PlatformWildoServices.PLATFORM_INIT>,\n ): ResolvedServiceAddress {\n const catalogEntry = PLATFORM_SERVICE_CATALOG[service];\n const port = catalogEntry.defaultPort;\n const serviceName = catalogEntry.containerName;\n const isHostFacing = ctx.perspective === AddressPerspective.HOST_FACING;\n\n switch (ctx.runtime) {\n case WildoDeploymentRuntime.DOCKER_COMPOSE:\n /*\n * Same alias rule as the infra branch, for the same reason: every platform\n * service declares `ports:` and is therefore on the ICC-disabled publish\n * bridge alongside the platform service it is calling.\n * @see CONTAINER_INTERNAL_ALIAS_SUFFIX\n */\n return isHostFacing\n ? buildAddress(DEFAULT_HOST, port)\n : buildAddress(resolveContainerInternalAlias(serviceName), port);\n\n case WildoDeploymentRuntime.KUBERNETES:\n if (isHostFacing) {\n if (ctx.locationType === WildoLocationType.REMOTE) {\n const host = `${serviceName}.${ctx.publicDomain}`;\n return { host, port: 443, url: `https://${host}` };\n }\n return buildAddress(DEFAULT_HOST, port);\n }\n return buildAddress(buildK8sInternalHost(serviceName, ctx.namespace), port);\n\n default: {\n const _exhaustive: never = ctx.runtime;\n throw new Error(`Unhandled runtime mode: ${_exhaustive}`);\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"service-address-resolver.service.js","sourceRoot":"","sources":["../../../../src/services/catalog/service-address-resolver.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yDAAyD,CAAC;AAC/F,OAAO,EAGL,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,0CAA0C,GAE3C,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,0DAA0D,CAAC;AACxF,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,6BAA6B,GAC9B,MAAM,qDAAqD,CAAC;AAG7D,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,iDAA2B,CAAA;IAC3B,+DAAyC,CAAA;AAC3C,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B;AAqGD,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E,SAAS,YAAY,CAAC,IAAY,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,CAAC,2BAA2B,WAAW,EAAE,CAAC,CAAC;YAC5D,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { PlatformDataServices } from '~wildo-cli/services/data-services/data-services.schemas';\nimport {\n type BackingServiceEnvConfig,\n type BackingServicesEnvConfig,\n BackingServiceKind,\n BackingServiceSource,\n K8S_LOCAL_DEFAULTS,\n PUBLIC_DOMAIN_DEFAULTS,\n PlatformWildoServices,\n WildoLocationType,\n WildoDeploymentRuntime,\n buildK8sInternalHost,\n environmentServiceProfileRunsMessageBroker,\n type EnvironmentServiceProfile,\n} from '@wildo-ai/platform-config-lib';\nimport { DEFAULT_HOST } from '~wildo-cli/services/environment/platform-runtime.schemas';\nimport {\n INFRA_SERVICE_CATALOG,\n PLATFORM_SERVICE_CATALOG,\n resolveContainerInternalAlias,\n} from '~wildo-cli/services/catalog/service-catalog.schemas';\nimport type { PlatformEnvironmentConfiguration } from '~wildo-cli/services/environment/environment.schemas';\n\n// ============================================================================\n// Enums & Interfaces\n// ============================================================================\n\nexport enum AddressPerspective {\n HOST_FACING = 'host-facing',\n CONTAINER_INTERNAL = 'container-internal',\n}\n\nexport interface ServiceAddressContext {\n runtime: WildoDeploymentRuntime;\n locationType: WildoLocationType;\n perspective: AddressPerspective;\n namespace: string;\n /**\n * Public domain (`WildoInfraEnvConfig.publicDomain`) — the\n * runtime-agnostic external hostname browsers and reverse proxies\n * resolve. Used here only for K8s-remote host-facing addressing\n * (`https://<service>.<publicDomain>`); compose host-facing keeps\n * its `localhost` shape because operators typically don't put a\n * reverse proxy in front of local compose runs.\n */\n publicDomain: string;\n databaseSource: BackingServiceSource;\n /**\n * Authored backing-services snapshot (mirrored from\n * `wildo.infra.<env>.config.ts`). When present, per-service overrides\n * win over catalog defaults. Missing services keep catalog-driven topology.\n *\n * Override precedence per perspective:\n * - HOST_FACING: author `host` and `port` win.\n * - CONTAINER_INTERNAL (compose / K8s):\n * * container name stays canonical (catalog `containerName` /\n * `<service>.<namespace>.svc.cluster.local`) — that is the only\n * address the container network can resolve.\n * * port: author `port` wins for self-deployed services because the\n * generated docker-compose maps host port `port:port` (compose-side\n * binds match the container-listen port). For MANAGED/EXTERNAL\n * sources the author `host`/`port` are canonical for both\n * perspectives — catalog defaults never apply.\n */\n backingServices?: BackingServicesEnvConfig;\n /**\n * The environment's service profile (#2303 slice D). A profile whose queue lives in the application's database runs no\n * message broker, so the RabbitMQ addresses resolve to `null` under it: every env builder emits broker keys only from a\n * resolved address, so none points at a host the environment does not run. Absent ⇒ FULL.\n */\n serviceProfile?: EnvironmentServiceProfile;\n}\n\nexport interface ResolvedServiceAddress {\n host: string;\n port: number;\n url: string;\n}\n\n/**\n * All fields are nullable: `mongodb` is null when Atlas (no local instance),\n * and ALL fields are null for K8s remote + HOST_FACING (no direct host access\n * to cluster-internal infra — use CONTAINER_INTERNAL perspective instead).\n */\nexport interface ResolvedInfraAddresses {\n mongodb: ResolvedServiceAddress | null;\n valkey: ResolvedServiceAddress | null;\n rabbitmq: ResolvedServiceAddress | null;\n rabbitmqManagement: ResolvedServiceAddress | null;\n minio: ResolvedServiceAddress | null;\n postgresql: ResolvedServiceAddress | null;\n /**\n * The ClamAV daemon an application backend submits uploads and received attachments to (#1910). Resolved like every\n * other backing service — `localhost` + the published port for a host-run process, the data-network alias for a\n * container — so a host-run dev backend reaches the same `clamav` container a containerised one does.\n */\n clamav: ResolvedServiceAddress | null;\n /**\n * The self-hosted immudb server apps-manager administers (#1696): it logs in there as the sysadmin to give each\n * application its own database and user. Resolved like every other backing service, so a host-run apps-manager and\n * a containerised one both reach the `immudb` container. Applications reach immudb through their own provider\n * address (`IMMUDB_HOST`), not through this.\n */\n immudb: ResolvedServiceAddress | null;\n /**\n * The self-hosted OpenBao holding the platform's custodied keys (#2933). apps-manager is its only client, host-run\n * in local development and containerised otherwise, so it resolves like `immudb`. Whether one runs at all is\n * `selfHostsPlatformKeyVault`; this address is meaningful only then.\n */\n openbao: ResolvedServiceAddress | null;\n}\n\nexport interface ResolvedPlatformAddresses {\n appsManager: ResolvedServiceAddress;\n crontabsBatchesManager: ResolvedServiceAddress;\n /**\n * Module-registry endpoint. Required by\n * `ApplicationEnvConfigurationSchema.PLATFORM_MODULE_REGISTRY_URL`\n * (engine `app-env-config.backend.schemas.ts`). Without this, every\n * application backend fails Zod env-validation at startup with\n * \"Invalid input: expected string, received undefined\" on\n * `PLATFORM_MODULE_REGISTRY_URL`.\n */\n moduleRegistry: ResolvedServiceAddress;\n}\n\nexport interface ResolvedAddresses {\n infra: ResolvedInfraAddresses;\n platform: ResolvedPlatformAddresses;\n}\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\nfunction buildAddress(host: string, port: number): ResolvedServiceAddress {\n return { host, port, url: `http://${host}:${port}` };\n}\n\n/**\n * Parse an authored S3-style endpoint (e.g. `http://localhost:9000`) into\n * its host/port parts. Returns `null` for malformed values so the\n * resolver can fall back to the per-field overrides (`s3.host` / `s3.port`)\n * or catalog defaults without throwing during topology resolution.\n *\n * The scheme (`http`/`https`) is intentionally NOT returned. The address\n * resolver constructs URLs with a hardcoded `http://` scheme today (see\n * `buildAddress`), so threading `useSsl` here would be a dead field that\n * lies about the resolver contract. If/when scheme propagation becomes\n * a real requirement, the `buildAddress` helper and downstream consumers\n * must be updated together — this signature change is the gate.\n */\nfunction parseEndpoint(endpoint: string | undefined): { host: string; port: number } | null {\n if (!endpoint) return null;\n try {\n const url = new URL(endpoint);\n const useSsl = url.protocol === 'https:';\n const port = url.port ? Number(url.port) : useSsl ? 443 : 80;\n if (!url.hostname || Number.isNaN(port)) return null;\n return { host: url.hostname, port };\n } catch {\n return null;\n }\n}\n\n/**\n * Resolve a host/port pair given an authored backing-service entry, the\n * catalog-driven defaults for that service, and the current perspective.\n *\n * The semantic model:\n * - For `BackingServiceSource.SELF` (we deploy the container): the catalog\n * container name is canonical for `CONTAINER_INTERNAL` because that is\n * the only DNS name the container network knows. Authored `host` only\n * applies to `HOST_FACING` (host-side dev tools). Authored `port` applies\n * to BOTH because the docker-compose generator maps `port:port`.\n * - For `BackingServiceSource.MANAGED`: the service is not in our\n * compose/K8s topology, so authored `host`/`port` are the only\n * canonical address for both perspectives. **Mongo-on-managed\n * special case**: when the brand is `'atlas'` (or any future\n * external-URL Mongo brand), callers detect this via\n * `addresses.infra.mongodb === null` (the resolver short-circuits\n * for managed Mongo at line 273) and read the connection URL from\n * secrets; this helper is not invoked for that branch. Slice\n * 4.B.0 (2026-05-07) replaced the prior `source: ATLAS` enum\n * value with `(source: MANAGED, provider: 'atlas')`.\n */\nfunction resolveOverriddenAddress(\n override: BackingServiceEnvConfig | undefined,\n fallback: { host: string; port: number },\n perspective: AddressPerspective,\n): { host: string; port: number } {\n if (!override) return fallback;\n const isManaged = override.source !== BackingServiceSource.SELF;\n\n if (isManaged) {\n return {\n host: override.host ?? fallback.host,\n port: override.port ?? fallback.port,\n };\n }\n\n if (perspective === AddressPerspective.HOST_FACING) {\n return {\n host: override.host ?? fallback.host,\n port: override.port ?? fallback.port,\n };\n }\n\n return {\n host: fallback.host,\n port: override.port ?? fallback.port,\n };\n}\n\n// ============================================================================\n// Resolver\n// ============================================================================\n\nexport class ServiceAddressResolver {\n static resolve(context: ServiceAddressContext): ResolvedAddresses {\n return {\n infra: ServiceAddressResolver.resolveInfra(context),\n platform: ServiceAddressResolver.resolvePlatform(context),\n };\n }\n\n static fromEnvironment(\n env: PlatformEnvironmentConfiguration,\n perspective: AddressPerspective,\n ): ServiceAddressContext {\n const isRemoteKubernetes =\n env.runtime === WildoDeploymentRuntime.KUBERNETES\n && env.locationType === WildoLocationType.REMOTE;\n const namespace = env.kubernetes?.namespace ?? (isRemoteKubernetes ? undefined : K8S_LOCAL_DEFAULTS.NAMESPACE);\n // `publicDomain` is a required top-level field on\n // `PlatformEnvironmentConfiguration` (mirrored from the schema's\n // required `WildoInfraEnvConfig.publicDomain`), but the default\n // `PUBLIC_DOMAIN_DEFAULTS.LOCAL_K8S` is kept as a defensive\n // belt-and-braces fallback for the local path so a hand-edited\n // hydrated config that drops the field still works for local\n // K8s development. Remote Kubernetes paths ALWAYS require an\n // explicitly authored value — there is no remote default.\n const publicDomain = env.publicDomain\n ?? (isRemoteKubernetes ? undefined : PUBLIC_DOMAIN_DEFAULTS.LOCAL_K8S);\n\n if (!namespace || !publicDomain) {\n throw new Error(\n `Environment '${env.name}' is missing explicit Kubernetes namespace or top-level publicDomain metadata.`,\n );\n }\n\n return {\n runtime: env.runtime,\n locationType: env.locationType,\n perspective,\n namespace,\n publicDomain,\n databaseSource: env.database.source ?? BackingServiceSource.SELF,\n backingServices: env.backingServices,\n serviceProfile: env.serviceProfile,\n };\n }\n\n // --------------------------------------------------------------------------\n // Infrastructure services\n // --------------------------------------------------------------------------\n\n private static resolveInfra(ctx: ServiceAddressContext): ResolvedInfraAddresses {\n const isK8sRemoteHostFacing =\n ctx.runtime === WildoDeploymentRuntime.KUBERNETES\n && ctx.locationType === WildoLocationType.REMOTE\n && ctx.perspective === AddressPerspective.HOST_FACING;\n\n if (isK8sRemoteHostFacing) {\n return {\n mongodb: null,\n valkey: null,\n rabbitmq: null,\n rabbitmqManagement: null,\n minio: null,\n postgresql: null,\n clamav: null,\n immudb: null,\n openbao: null,\n };\n }\n\n const mongoCatalog = INFRA_SERVICE_CATALOG[PlatformDataServices.MONGODB];\n const valkeyCatalog = INFRA_SERVICE_CATALOG[PlatformDataServices.VALKEY];\n const rabbitmqCatalog = INFRA_SERVICE_CATALOG[PlatformDataServices.RABBITMQ];\n const minioCatalog = INFRA_SERVICE_CATALOG[PlatformDataServices.MINIO];\n const pgCatalog = INFRA_SERVICE_CATALOG[PlatformDataServices.POSTGRESQL];\n const clamavCatalog = INFRA_SERVICE_CATALOG[PlatformDataServices.CLAMAV];\n const immudbCatalog = INFRA_SERVICE_CATALOG[PlatformDataServices.IMMUDB];\n const openbaoCatalog = INFRA_SERVICE_CATALOG[PlatformDataServices.OPENBAO];\n\n const mongoOverride = ctx.backingServices?.[BackingServiceKind.MONGODB];\n const redisOverride = ctx.backingServices?.[BackingServiceKind.REDIS];\n const rabbitOverride = ctx.backingServices?.[BackingServiceKind.RABBITMQ];\n const s3Override = ctx.backingServices?.[BackingServiceKind.S3];\n const pgOverride = ctx.backingServices?.[BackingServiceKind.POSTGRESQL];\n const clamavOverride = ctx.backingServices?.[BackingServiceKind.CLAMAV];\n const immudbOverride = ctx.backingServices?.[BackingServiceKind.IMMUDB];\n\n const s3EndpointParsed = parseEndpoint(s3Override?.endpoint);\n const s3OverrideMerged: BackingServiceEnvConfig | undefined = s3Override\n ? {\n ...s3Override,\n host: s3Override.host ?? s3EndpointParsed?.host,\n port: s3Override.port ?? s3EndpointParsed?.port,\n }\n : undefined;\n\n // Slice 4.B.0 (2026-05-07): the legacy `source: ATLAS` was the only\n // managed-Mongo enum value, so it stood in for \"any managed Mongo\n // — let the external service's connection URL handle it; we don't\n // need to resolve a local container address\". Post-reshape, the\n // same logic applies to every managed-Mongo brand (Atlas, future\n // DocumentDB, etc.) → loosen to the broader source check.\n const mongodb =\n ctx.databaseSource === BackingServiceSource.MANAGED\n ? null\n : ServiceAddressResolver.resolveInfraService(\n ctx,\n mongoCatalog.containerName,\n mongoCatalog.defaultPort,\n mongoCatalog.defaultPort,\n mongoOverride,\n );\n\n // #2303 slice D — no broker runs under a profile whose queue lives in the application's database: no address.\n const runsBroker = environmentServiceProfileRunsMessageBroker(ctx.serviceProfile);\n return {\n mongodb,\n valkey: ServiceAddressResolver.resolveInfraService(\n ctx, valkeyCatalog.containerName, valkeyCatalog.defaultPort, valkeyCatalog.defaultPort, redisOverride,\n ),\n rabbitmq: !runsBroker ? null : ServiceAddressResolver.resolveInfraService(\n ctx, rabbitmqCatalog.containerName, rabbitmqCatalog.defaultPort, rabbitmqCatalog.defaultPort, rabbitOverride,\n ),\n rabbitmqManagement: !runsBroker ? null : ServiceAddressResolver.resolveInfraService(\n ctx,\n rabbitmqCatalog.containerName,\n rabbitmqCatalog.additionalPorts!.management,\n rabbitmqCatalog.additionalPorts!.management,\n // The management UI rides on the same RabbitMQ container; we only\n // honor the authored host (HOST_FACING) — the management port itself\n // is image-defined and not part of the author surface today.\n rabbitOverride\n ? { ...rabbitOverride, port: undefined }\n : undefined,\n ),\n minio: ServiceAddressResolver.resolveInfraService(\n ctx, minioCatalog.containerName, minioCatalog.defaultPort, minioCatalog.defaultPort, s3OverrideMerged,\n ),\n postgresql: ServiceAddressResolver.resolveInfraService(\n ctx, pgCatalog.containerName, pgCatalog.defaultPort, pgCatalog.defaultPort, pgOverride,\n ),\n clamav: ServiceAddressResolver.resolveInfraService(\n ctx, clamavCatalog.containerName, clamavCatalog.defaultPort, clamavCatalog.defaultPort, clamavOverride,\n ),\n immudb: ServiceAddressResolver.resolveInfraService(\n ctx, immudbCatalog.containerName, immudbCatalog.defaultPort, immudbCatalog.defaultPort, immudbOverride,\n ),\n // No authored override: the platform's own Vault is not a backing service an environment addresses.\n openbao: ServiceAddressResolver.resolveInfraService(\n ctx, openbaoCatalog.containerName, openbaoCatalog.defaultPort, openbaoCatalog.defaultPort, undefined,\n ),\n };\n }\n\n /**\n * @param hostFacingPort Port exposed on the host (mapped port)\n * @param internalPort Port inside the container\n * @param override Optional authored backing-service entry; honored\n * per the precedence rules in `ServiceAddressContext.backingServices`.\n */\n private static resolveInfraService(\n ctx: ServiceAddressContext,\n serviceName: string,\n hostFacingPort: number,\n internalPort: number,\n override: BackingServiceEnvConfig | undefined,\n ): ResolvedServiceAddress {\n const isHostFacing = ctx.perspective === AddressPerspective.HOST_FACING;\n\n switch (ctx.runtime) {\n case WildoDeploymentRuntime.DOCKER_COMPOSE: {\n /*\n * A container dials the data-network ALIAS, never the bare service name.\n *\n * Both ends of this call are attached to `wildo-host-access`, the publish\n * bridge, which is created with ICC disabled — so the service name resolves\n * to an address that is deliberately unreachable, and the caller times out\n * against a service that is up. The alias is registered on the data segment\n * only, so it cannot resolve to the blocked bridge.\n *\n * @see CONTAINER_INTERNAL_ALIAS_SUFFIX for the measurement.\n *\n * HOST_FACING is untouched: a host process reaches the published port on\n * localhost and never consults Docker DNS.\n */\n const fallbackHost = isHostFacing ? DEFAULT_HOST : resolveContainerInternalAlias(serviceName);\n const fallbackPort = isHostFacing ? hostFacingPort : internalPort;\n const { host, port } = resolveOverriddenAddress(\n override,\n { host: fallbackHost, port: fallbackPort },\n ctx.perspective,\n );\n return buildAddress(host, port);\n }\n\n case WildoDeploymentRuntime.KUBERNETES: {\n if (ctx.locationType === WildoLocationType.LOCAL && isHostFacing) {\n const { host, port } = resolveOverriddenAddress(\n override,\n { host: DEFAULT_HOST, port: hostFacingPort },\n ctx.perspective,\n );\n return buildAddress(host, port);\n }\n const fallbackHost = buildK8sInternalHost(serviceName, ctx.namespace);\n const { host, port } = resolveOverriddenAddress(\n override,\n { host: fallbackHost, port: internalPort },\n ctx.perspective,\n );\n return buildAddress(host, port);\n }\n\n default: {\n const _exhaustive: never = ctx.runtime;\n throw new Error(`Unhandled runtime mode: ${_exhaustive}`);\n }\n }\n }\n\n // --------------------------------------------------------------------------\n // Platform (Wildo) services\n // --------------------------------------------------------------------------\n\n private static resolvePlatform(ctx: ServiceAddressContext): ResolvedPlatformAddresses {\n return {\n appsManager: ServiceAddressResolver.resolvePlatformService(ctx, PlatformWildoServices.APPS_MANAGER),\n crontabsBatchesManager: ServiceAddressResolver.resolvePlatformService(ctx, PlatformWildoServices.CRONTABS_BATCHES_MANAGER),\n moduleRegistry: ServiceAddressResolver.resolvePlatformService(ctx, PlatformWildoServices.MODULE_REGISTRY),\n };\n }\n\n private static resolvePlatformService(\n ctx: ServiceAddressContext,\n service: Exclude<PlatformWildoServices, PlatformWildoServices.PLATFORM_INIT>,\n ): ResolvedServiceAddress {\n const catalogEntry = PLATFORM_SERVICE_CATALOG[service];\n const port = catalogEntry.defaultPort;\n const serviceName = catalogEntry.containerName;\n const isHostFacing = ctx.perspective === AddressPerspective.HOST_FACING;\n\n switch (ctx.runtime) {\n case WildoDeploymentRuntime.DOCKER_COMPOSE:\n /*\n * Same alias rule as the infra branch, for the same reason: every platform\n * service declares `ports:` and is therefore on the ICC-disabled publish\n * bridge alongside the platform service it is calling.\n * @see CONTAINER_INTERNAL_ALIAS_SUFFIX\n */\n return isHostFacing\n ? buildAddress(DEFAULT_HOST, port)\n : buildAddress(resolveContainerInternalAlias(serviceName), port);\n\n case WildoDeploymentRuntime.KUBERNETES:\n if (isHostFacing) {\n if (ctx.locationType === WildoLocationType.REMOTE) {\n const host = `${serviceName}.${ctx.publicDomain}`;\n return { host, port: 443, url: `https://${host}` };\n }\n return buildAddress(DEFAULT_HOST, port);\n }\n return buildAddress(buildK8sInternalHost(serviceName, ctx.namespace), port);\n\n default: {\n const _exhaustive: never = ctx.runtime;\n throw new Error(`Unhandled runtime mode: ${_exhaustive}`);\n }\n }\n }\n}\n"]}
|
|
@@ -47,6 +47,23 @@ export declare function readCompanionProviderAccountRefusal(error: unknown): Mod
|
|
|
47
47
|
*/
|
|
48
48
|
export declare const COMPANION_UNREACHABLE_EXIT_CODE = 2;
|
|
49
49
|
export declare function companionFailureExitCode(error: unknown): number;
|
|
50
|
+
/**
|
|
51
|
+
* The connection to the companion CLOSED before the request got its whole answer (#4021): undici's `fetch failed` with a
|
|
52
|
+
* `SocketError` cause (`UND_ERR_SOCKET`: "other side closed" before the head, "terminated" mid-body). The companion was
|
|
53
|
+
* reached and did not finish answering, so this is neither a refusal (it said nothing) nor an unreachable companion (it
|
|
54
|
+
* was there when the request went out).
|
|
55
|
+
*
|
|
56
|
+
* Reference run 44052185141 (its log carries no error cause; the shape is reproduced against undici 7.30.2): a companion
|
|
57
|
+
* that stops while it holds a request (a restart after a dependency install, with the drive's loop request parked at the
|
|
58
|
+
* restart window) closes its HTTP server, which waits for that request until its bounded 5000 ms step gives up, and exits;
|
|
59
|
+
* the held socket is then closed from the companion's side and the client sees exactly this. `wildo creation drive` read
|
|
60
|
+
* it as the loop's refusal and stopped, twice.
|
|
61
|
+
*
|
|
62
|
+
* Kept OUT of {@link companionFailureExitCode}'s unreachable set on purpose: a closed connection does not say the
|
|
63
|
+
* companion is down, only that it stopped answering THIS request. A caller that can ask the companion whether it
|
|
64
|
+
* restarted (the drive reads its process start time) decides; the others report it as the failure it is.
|
|
65
|
+
*/
|
|
66
|
+
export declare function isCompanionConnectionClosedBeforeAnswer(error: unknown): boolean;
|
|
50
67
|
/**
|
|
51
68
|
* The CLIENT gave up waiting — the companion may still be doing the work. Distinct from
|
|
52
69
|
* {@link CompanionRefusalError} (the companion answered no) and from an unreachable companion, because a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"companion-client.service.d.ts","sourceRoot":"","sources":["../../../../src/services/companion/companion-client.service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH,OAAO,EAAmF,KAAK,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAC1J,OAAO,EAGL,2BAA2B,EAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAyOlE;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;aAG5B,MAAM,EAAE,MAAM;IAC9B;;;OAGG;aACa,OAAO,CAAC,EAAE,oBAAoB;gBAN9C,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,MAAM;IAC9B;;;OAGG;IACa,OAAO,CAAC,EAAE,oBAAoB;CAKjD;AAED,qDAAqD;AACrD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC5C;AAmBD;;;;;;GAMG;AACH,wBAAgB,mCAAmC,CAAC,KAAK,EAAE,OAAO,GAAG,2BAA2B,GAAG,SAAS,CAK3G;AAED;;;;;;GAMG;AACH,eAAO,MAAM,+BAA+B,IAAI,CAAC;AACjD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE/D;AAED;;;;;;GAMG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;aAClB,SAAS,EAAE,MAAM;gBAAjB,SAAS,EAAE,MAAM;CAIrD;AAED,eAAO,MAAM,eAAe;kBAElB,MAAM,SACN,WAAW,YACP,sBAAsB,gBACnB,2BAA2B,GACvC,OAAO,CAAC,QAAQ,CAAC;QAaV,CAAC,QAAQ,MAAM,YAAY,sBAAsB,GAAG,OAAO,CAAC,CAAC,CAAC;SAM7D,CAAC,QACJ,MAAM,SACL,OAAO,YACJ,sBAAsB,gBACnB,2BAA2B,GACvC,OAAO,CAAC,CAAC,CAAC;IAeb,uCAAuC;mBAClB,sBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC;CAS/D,CAAC"}
|
|
1
|
+
{"version":3,"file":"companion-client.service.d.ts","sourceRoot":"","sources":["../../../../src/services/companion/companion-client.service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH,OAAO,EAAmF,KAAK,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAC1J,OAAO,EAGL,2BAA2B,EAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAyOlE;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;aAG5B,MAAM,EAAE,MAAM;IAC9B;;;OAGG;aACa,OAAO,CAAC,EAAE,oBAAoB;gBAN9C,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,MAAM;IAC9B;;;OAGG;IACa,OAAO,CAAC,EAAE,oBAAoB;CAKjD;AAED,qDAAqD;AACrD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC5C;AAmBD;;;;;;GAMG;AACH,wBAAgB,mCAAmC,CAAC,KAAK,EAAE,OAAO,GAAG,2BAA2B,GAAG,SAAS,CAK3G;AAED;;;;;;GAMG;AACH,eAAO,MAAM,+BAA+B,IAAI,CAAC;AACjD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE/D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uCAAuC,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAG/E;AAED;;;;;;GAMG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;aAClB,SAAS,EAAE,MAAM;gBAAjB,SAAS,EAAE,MAAM;CAIrD;AAED,eAAO,MAAM,eAAe;kBAElB,MAAM,SACN,WAAW,YACP,sBAAsB,gBACnB,2BAA2B,GACvC,OAAO,CAAC,QAAQ,CAAC;QAaV,CAAC,QAAQ,MAAM,YAAY,sBAAsB,GAAG,OAAO,CAAC,CAAC,CAAC;SAM7D,CAAC,QACJ,MAAM,SACL,OAAO,YACJ,sBAAsB,gBACnB,2BAA2B,GACvC,OAAO,CAAC,CAAC,CAAC;IAeb,uCAAuC;mBAClB,sBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC;CAS/D,CAAC"}
|
|
@@ -286,6 +286,27 @@ export const COMPANION_UNREACHABLE_EXIT_CODE = 2;
|
|
|
286
286
|
export function companionFailureExitCode(error) {
|
|
287
287
|
return isTransientConnectionError(error) || error instanceof CompanionTokenAbsentError ? COMPANION_UNREACHABLE_EXIT_CODE : 1;
|
|
288
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* The connection to the companion CLOSED before the request got its whole answer (#4021): undici's `fetch failed` with a
|
|
291
|
+
* `SocketError` cause (`UND_ERR_SOCKET`: "other side closed" before the head, "terminated" mid-body). The companion was
|
|
292
|
+
* reached and did not finish answering, so this is neither a refusal (it said nothing) nor an unreachable companion (it
|
|
293
|
+
* was there when the request went out).
|
|
294
|
+
*
|
|
295
|
+
* Reference run 44052185141 (its log carries no error cause; the shape is reproduced against undici 7.30.2): a companion
|
|
296
|
+
* that stops while it holds a request (a restart after a dependency install, with the drive's loop request parked at the
|
|
297
|
+
* restart window) closes its HTTP server, which waits for that request until its bounded 5000 ms step gives up, and exits;
|
|
298
|
+
* the held socket is then closed from the companion's side and the client sees exactly this. `wildo creation drive` read
|
|
299
|
+
* it as the loop's refusal and stopped, twice.
|
|
300
|
+
*
|
|
301
|
+
* Kept OUT of {@link companionFailureExitCode}'s unreachable set on purpose: a closed connection does not say the
|
|
302
|
+
* companion is down, only that it stopped answering THIS request. A caller that can ask the companion whether it
|
|
303
|
+
* restarted (the drive reads its process start time) decides; the others report it as the failure it is.
|
|
304
|
+
*/
|
|
305
|
+
export function isCompanionConnectionClosedBeforeAnswer(error) {
|
|
306
|
+
if (!(error instanceof Error))
|
|
307
|
+
return false;
|
|
308
|
+
return error.cause?.code === 'UND_ERR_SOCKET';
|
|
309
|
+
}
|
|
289
310
|
/**
|
|
290
311
|
* The CLIENT gave up waiting — the companion may still be doing the work. Distinct from
|
|
291
312
|
* {@link CompanionRefusalError} (the companion answered no) and from an unreachable companion, because a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"companion-client.service.js","sourceRoot":"","sources":["../../../../src/services/companion/companion-client.service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,gFAAgF;AAChF,gFAAgF;AAChF,iFAAiF;AACjF,gDAAgD;AAChD,wEAAwE;AACxE,6EAA6E;AAC7E,gFAAgF;AAChF,6EAA6E;AAC7E,6BAA6B;AAC7B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,2BAA2B,EAAE,iCAAiC,EAAE,eAAe,EAAoC,MAAM,uBAAuB,CAAC;AAC1J,OAAO,EACL,sBAAsB,EACtB,4BAA4B,EAC5B,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE9H;;;;;;;;;;;;;;;;;;;;;;GAsBG;A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AAG,CAAC,EAAE;YAAE,MAAM,IAAI,qBAAqB,CAAC,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;QACzK,OAAO,GAAG,CAAC,IAAI,EAAgB,CAAC;IAClC,CAAC;IAED,uCAAuC;IACvC,KAAK,CAAC,IAAI,CAAC,OAAgC;QACzC,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;YACjC,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC,GAAG,IAAI,SAAS,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,2BAA2B,CAAC,SAAS,CAAC,CAAC;YACxH,OAAO,GAAG,CAAC,EAAE,CAAC;QAChB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF,CAAC;AAEF;;;GAGG;AACH,SAAS,kBAAkB,CAAC,IAAiB;IAC3C,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IACpD,OAAO,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,MAAM;QAC1C,CAAC,CAAC,2BAA2B,CAAC,SAAS;QACvC,CAAC,CAAC,2BAA2B,CAAC,QAAQ,CAAC;AAC3C,CAAC","sourcesContent":["/**\n * CompanionClientService — HTTP client for companion REST API.\n *\n * IMPLEMENTATION: DONE — get, post, ping, 10s timeout via AbortSignal.timeout.\n * Protocol (endpoints, payloads) TBD when companion service is defined.\n */\n\n// BOTH fetch and Agent must come from the SAME undici. Node's GLOBAL fetch is a\n// different undici (bundled 8.x on Node 26) whose dispatch-handler interface is\n// incompatible with this package's Agent (6.x) — passing our Agent as the global\n// fetch's `dispatcher` fails every request with\n// `InvalidArgumentError: invalid onError method (UND_ERR_INVALID_ARG)`.\n// That silently broke every long-running companion RPC (labels / translate /\n// email generation) when the toolchain moved to Node 26. Importing undici's own\n// fetch keeps the dispatcher/handler pair version-coherent regardless of the\n// Node-bundled undici major.\nimport { Agent, fetch } from 'undici';\nimport { ErrorCustomMessageReference, ModelProviderAccountRefusalSchema, WildoHeaderKeys, type ModelProviderAccountRefusal } from '@wildo-ai/saas-models';\nimport {\n COMPANION_DEFAULT_PORT,\n COMPANION_DEFAULT_TIMEOUT_MS,\n CompanionRequestRetryPolicy,\n} from './companion.schemas';\nimport type { CompanionClientOptions } from './companion.schemas';\nimport { COMPANION_TOKEN_HEADER, CompanionTokenAbsentError, readCompanionTokenNoFollow } from './companion-local-token.utils';\n\n/**\n * Lazily-built `undici.Agent` with long head/body timeouts for companion\n * RPCs. Required because Node's native `fetch` (undici under the hood)\n * defaults to `headersTimeout: 300_000` (5 min) — even if the caller\n * passes `AbortSignal.timeout(...)` with a longer ceiling, undici will\n * still give up at 5 min waiting for response headers.\n *\n * The companion's labelling, translation, and email generation endpoints\n * legitimately exceed 5 min (LLM batch jobs). The companion-side fix is\n * in `engine/saas-backend-lib` (`appConfiguration.runtime.httpServerConfiguration`);\n * this is the matching client-side fix. Both must move together — a\n * 30-min server-side `requestTimeout` is useless if the client gives up\n * at 5 min.\n *\n * Both dispatcher timeouts are OFF (0): each request's `AbortSignal.timeout(timeoutMs)`\n * is the one authority over how long the client waits. They were 31 minutes, \"slightly\n * above the 30-min companion server timeout\", and that cut every request whose own\n * deadline is longer: `wildo creation drive` holds a loop request for up to 6 hours, and\n * on reference run 42713670241 (#3204) every loop that took over 31 minutes ended in\n * `fetch failed` (`UND_ERR_HEADERS_TIMEOUT`), which the drive read as the loop's refusal\n * and stopped on five times. The companion's 30-minute `requestTimeout` bounds RECEIVING\n * a request, never the time to answer it, so it does not cut a long loop.\n */\nlet _longRunningAgent: Agent | undefined;\nfunction getLongRunningAgent(): Agent {\n if (!_longRunningAgent) {\n _longRunningAgent = new Agent({\n headersTimeout: 0,\n bodyTimeout: 0,\n keepAliveTimeout: 31 * 60_000,\n });\n }\n return _longRunningAgent;\n}\n\nfunction getBaseUrl(options?: CompanionClientOptions): string {\n const port = options?.port ?? COMPANION_DEFAULT_PORT;\n return options?.baseUrl ?? `http://localhost:${port}`;\n}\n\n/** Attempts (including the first) for transient connection failures. */\nconst CONNECTION_RETRY_ATTEMPTS = 4;\n/** Delay between connection-retry attempts (≈1.2s total across 4 attempts). */\nconst CONNECTION_RETRY_DELAY_MS = 400;\n\n/**\n * A transient connection failure — the companion is briefly unreachable, e.g.\n * mid-restart after a source edit (dev watcher → runtime-supervisor). undici's\n * `fetch` throws `TypeError: fetch failed` with the underlying error on `.cause`.\n * We retry ONLY these (never timeouts or HTTP status errors, which are real).\n */\nfunction isTransientConnectionError(err: unknown): boolean {\n if (!(err instanceof Error)) {\n return false;\n }\n const code = (err as { cause?: { code?: string } }).cause?.code;\n return code === 'ECONNREFUSED' || code === 'ECONNRESET' || code === 'ECONNABORTED' || code === 'EAI_AGAIN';\n}\n\n/**\n * undici gave up waiting for the head or the body (`fetch failed` with a timeout cause). The client stopped waiting, the\n * companion may still be working: a {@link CompanionRequestTimeoutError}, never a refusal of the request.\n */\nfunction isDispatcherTimeout(err: Error): boolean {\n const code = (err as { cause?: { code?: string } }).cause?.code;\n return code === 'UND_ERR_HEADERS_TIMEOUT' || code === 'UND_ERR_BODY_TIMEOUT';\n}\n\nasync function fetchWithTimeout(\n url: string,\n init: RequestInit & { timeoutMs?: number },\n options?: CompanionClientOptions,\n retryPolicy: CompanionRequestRetryPolicy = defaultRetryPolicy(init),\n): Promise<Response> {\n const timeoutMs = init.timeoutMs ?? options?.timeoutMs ?? COMPANION_DEFAULT_TIMEOUT_MS;\n const attempts = retryPolicy === CompanionRequestRetryPolicy.SAFE_READ ? CONNECTION_RETRY_ATTEMPTS : 1;\n\n let lastError: unknown;\n for (let attempt = 1; attempt <= attempts; attempt++) {\n // Fresh signal per attempt — an aborted/consumed AbortSignal can't be reused.\n const signal = AbortSignal.timeout(timeoutMs);\n try {\n // The cast bridges the AMBIENT `RequestInit` this function's signature uses\n // (undici-types via @types/node) and the imported undici's own structurally\n // identical `RequestInit` — the two type packages declare nominal twins\n // (FormData/Blob) that TypeScript refuses to unify across module identities.\n // Runtime-coherent by construction: fetch, Agent and the init all come from\n // the same imported undici (see the import note at the top of this file).\n return await fetch(url, {\n ...init,\n signal,\n dispatcher: getLongRunningAgent(),\n } as unknown as Parameters<typeof fetch>[1]);\n } catch (err) {\n if (err instanceof Error && (err.name === 'AbortError' || err.name === 'TimeoutError' || isDispatcherTimeout(err))) {\n throw new CompanionRequestTimeoutError(timeoutMs);\n }\n lastError = err;\n // Retry a briefly-unreachable companion (mid-restart); fail fast otherwise.\n if (attempt < attempts && isTransientConnectionError(err)) {\n await new Promise((resolve) => setTimeout(resolve, CONNECTION_RETRY_DELAY_MS));\n continue;\n }\n throw err;\n }\n }\n throw lastError;\n}\n\n/**\n * Methods that need no companion token — the same set the companion's own floor lets through.\n *\n * Kept as the METHOD rather than as a list of mutating routes for the reason the server side gives at\n * `COMPANION_TOKEN_FLOOR_UNGATED_METHODS`: the two ends must agree, and a verb is the only\n * discriminator both can compute without maintaining a copy of the other's route table.\n */\nconst COMPANION_TOKEN_UNGATED_METHODS: ReadonlySet<string> = new Set(['GET', 'HEAD', 'OPTIONS']);\n\n/**\n * Attach the machine-local companion token to a mutating request (P-29b).\n *\n * This is the CLIENT half of one invariant, and it lives HERE — at the single point every CLI\n * companion request funnels through — rather than at each of the eight call sites that build one.\n * Those call sites are four near-identical `resolveCompanionClientOptions` copies plus an inline\n * object literal in `charts-audit.command.ts`; a per-call-site attach would have been five hand-applied\n * copies of a rule, and the sixth would have been written without it.\n *\n * An explicitly-supplied token header WINS: `requestAuthorizedLocalCompanion` sets one, and a caller\n * that has gone to the trouble of naming a credential must not have it silently replaced.\n *\n * A failed read is raised, not swallowed. Sending the request without the token would trade a local\n * error that names the token file for a remote 401 that names the same file one hop further away —\n * and the local one can say WHY (the file is missing, or its mode is too broad), which the server\n * cannot know.\n *\n * **An ABSENT `appRoot` sends nothing and lets the companion refuse**, and that decision was\n * re-examined on 2026-09-10 rather than reversed. Raising locally instead was tried: it makes every\n * mutating call require an application root, which is true of the CLI's real callers and NOT of a\n * request whose only problem is a companion that has restarted — so the refusal has to be legible\n * wherever it comes from, not only in the one branch that can see it early. That is what\n * `describeCompanionFailure` below does, and it covers the stale-token case the local throw could\n * not. The branch is reachable: a `wildo` invocation with no targeted app resolves\n * `{ timeoutMs }` alone (`companion-client-options.utils.ts`).\n */\nasync function resolveCompanionTokenHeader(\n method: string,\n headers: Headers,\n options?: CompanionClientOptions,\n): Promise<void> {\n if (COMPANION_TOKEN_UNGATED_METHODS.has(method.toUpperCase())) return;\n if (options?.appRoot === undefined || headers.has(COMPANION_TOKEN_HEADER)) return;\n headers.set(COMPANION_TOKEN_HEADER, await readCompanionTokenNoFollow(options.appRoot));\n}\n\n/**\n * Turn a companion failure into a sentence that names the CAUSE, not only the status.\n *\n * A `401` from the companion carries `type: AUTHENTICATION`, a severity and a correlation id, and\n * NOTHING else — measured against the running companion on 2026-09-10. `sanitizeErrorForClient`\n * strips the explanatory context before it leaves the process, deliberately: a refusal must not teach\n * an unauthorized caller where the credential lives. The sentence that does explain is in the\n * COMPANION'S log, under the same correlation id.\n *\n * So `Companion API /api/companion/x: 401 Unauthorized` is all a CLI user would otherwise see, and it\n * reads as \"the thing I asked for failed\" rather than \"I sent no credential\" — the defect class this\n * whole change closed for three callers outside the CLI. The client is the one place that knows both\n * halves (which application it targeted, and whether it attached anything), so it is the one place\n * that can say which of the two happened.\n */\nfunction describeCompanionFailure(\n path: string,\n method: string,\n response: Response,\n options?: CompanionClientOptions,\n refusal?: string,\n): string {\n const base = refusal === undefined\n ? `Companion API ${path}: ${response.status} ${response.statusText}`\n : `Companion API ${path}: ${response.status} ${response.statusText} — ${refusal}`;\n if (response.status !== 401) return base;\n /*\n * The floor is VERB-discriminated, so this explanation has to be too — and the same set the attach\n * reads is the one that decides here, twenty lines apart in one file rather than two copies. A 401\n * on a READ is not a missing mutation credential: it comes from somewhere else entirely, and\n * telling the caller to check its companion token would send them to the wrong place.\n */\n if (COMPANION_TOKEN_UNGATED_METHODS.has(method.toUpperCase())) {\n return `${base} — this is a READ, which the companion's local-token floor does not gate, so the `\n + 'refusal is not about the machine-local token.';\n }\n return options?.appRoot === undefined\n ? `${base} — this route mutates and needs the machine-local companion token, and no targeted `\n + 'application was resolved, so none was sent. Run the command from inside a Wildo application.'\n : `${base} — the companion refused the token read from ${options.appRoot}/.wildo-saas/state/`\n + 'companion.token. It mints a fresh one on every boot, so this usually means it restarted; '\n + 'the companion\\'s own log carries the full refusal under the response\\'s correlation id.';\n}\n\n/**\n * The companion's own explanation of a refusal, when the body carries one.\n *\n * A refused REQUEST (a 4xx) answers with the reason the handler wrote — the engine's error envelope\n * allow-lists `message` in `details` for VALIDATION, CONFLICT and RATE_LIMIT. Without reading it, a\n * caller saw `400 Bad Request` and nothing else, and the refusal naming the fix (\"`get` takes `refs` OR\n * `aspectKeys`\") reached nobody (#1459, found on the first live `wildo context elements` run).\n *\n * Every OTHER type loses its `details` to the client sanitizer, so a refusal whose words matter (a 404\n * among them) carries them as `userGuidance` instead: when there is no `details.message`, read its\n * `explanation` and its `resolution`, joined when both are present (#1588). The raw text is right here — the CLI has no label tree to resolve\n * the guidance key against.\n *\n * Best-effort and non-throwing: an empty or non-JSON body simply yields no detail, and the status line\n * stands on its own as before.\n */\nasync function readRefusalDetail(response: Response): Promise<string | undefined> {\n try {\n const body = await response.clone().json() as {\n error?: { details?: { message?: unknown }; userGuidance?: { explanation?: unknown; resolution?: unknown } };\n };\n const text = (value: unknown): string | undefined => (typeof value === 'string' && value.trim().length > 0 ? value : undefined);\n const details = text(body?.error?.details?.message);\n if (details) return details;\n // Both halves when both are present: the resolution is the actionable one (#1588 review F4).\n const guidance = [text(body?.error?.userGuidance?.explanation), text(body?.error?.userGuidance?.resolution)].filter((part): part is string => part !== undefined);\n return guidance.length > 0 ? guidance.join(' ') : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * The companion ANSWERED, with a non-2xx status (#1588): carries that status, so a caller can tell a\n * refusal from a companion that is not there without parsing the message.\n */\nexport class CompanionRefusalError extends Error {\n public constructor(\n message: string,\n public readonly status: number,\n /**\n * What the answer's body said, when it was the engine's error shape: its stable message reference (`error.customMessageReference`)\n * and the facts its reference admits (`error.details`). How a caller branches on WHY without parsing the message (#3204).\n */\n public readonly refusal?: CompanionRefusalBody,\n ) {\n super(message);\n this.name = 'CompanionRefusalError';\n }\n}\n\n/** The machine-readable half of a refusal's body. */\nexport interface CompanionRefusalBody {\n readonly reference?: string;\n readonly details?: Record<string, unknown>;\n}\n\n/** The reference and admitted details of a refusal's body, or `undefined` when the body is not the engine's error shape. */\nasync function readRefusalBody(response: Response): Promise<CompanionRefusalBody | undefined> {\n try {\n const body = await response.clone().json() as { error?: { customMessageReference?: unknown; details?: unknown } };\n const reference = typeof body?.error?.customMessageReference === 'string' ? body.error.customMessageReference : undefined;\n const details = body?.error?.details !== null && typeof body?.error?.details === 'object' && !Array.isArray(body.error.details)\n ? body.error.details as Record<string, unknown>\n : undefined;\n return reference === undefined && details === undefined ? undefined : { ...(reference !== undefined ? { reference } : {}), ...(details !== undefined ? { details } : {}) };\n } catch {\n return undefined;\n }\n}\n\n/** Who refused, when the answer named only WHY: the engine's wire carries the reason alone (least disclosure). */\nconst UNNAMED_PROVIDER = 'the companion\\'s model provider';\n\n/**\n * The model provider ACCOUNT's refusal a companion answer carried (#3204): the engine answers it `502` with the reference\n * `model_provider_account_refused` and only the classified `details.reason`, since the provider and its words are the\n * operator's billing state and that answer can reach an end user. So the refusal read here names the reason, and points\n * at the companion's log for the rest. (The creation loop's own interruption carries the whole refusal.) `undefined` for\n * any other failure.\n */\nexport function readCompanionProviderAccountRefusal(error: unknown): ModelProviderAccountRefusal | undefined {\n if (!(error instanceof CompanionRefusalError) || error.refusal?.reference !== ErrorCustomMessageReference.MODEL_PROVIDER_ACCOUNT_REFUSED) return undefined;\n const reason = ModelProviderAccountRefusalSchema.shape.reason.safeParse(error.refusal.details?.reason);\n if (!reason.success) return undefined;\n return { reason: reason.data, provider: UNNAMED_PROVIDER, providerMessage: 'the companion\\'s log names the provider and quotes its answer' };\n}\n\n/**\n * The creation console's exit code for a failed companion call (#1652): 2 when the companion could not\n * be REACHED (nothing listening, connection reset, or a companion that never started here and so\n * left no token), 1 for everything else — a refusal it answered, a\n * timeout, a malformed request. The distinction is the one an agent branches on: \"fix what you sent\"\n * versus \"start the stack\", and it must not be recovered by parsing an error message.\n */\nexport const COMPANION_UNREACHABLE_EXIT_CODE = 2;\nexport function companionFailureExitCode(error: unknown): number {\n return isTransientConnectionError(error) || error instanceof CompanionTokenAbsentError ? COMPANION_UNREACHABLE_EXIT_CODE : 1;\n}\n\n/**\n * The CLIENT gave up waiting — the companion may still be doing the work. Distinct from\n * {@link CompanionRefusalError} (the companion answered no) and from an unreachable companion, because a\n * caller whose request STARTS work must not report a timeout as a failure: `wildo creation answer` on a\n * playbook round is refused fast when the answer is wrong and otherwise holds the request open for the\n * whole continuation, so a timeout there means the answer was admitted and the run is still going.\n */\nexport class CompanionRequestTimeoutError extends Error {\n public constructor(public readonly timeoutMs: number) {\n super(`Companion API request timed out after ${timeoutMs}ms`);\n this.name = 'CompanionRequestTimeoutError';\n }\n}\n\nexport const CompanionClient = {\n async request(\n path: string,\n init: RequestInit = {},\n options?: CompanionClientOptions,\n retryPolicy: CompanionRequestRetryPolicy = defaultRetryPolicy(init),\n ): Promise<Response> {\n const base = getBaseUrl(options);\n const headers = new Headers(options?.headers);\n new Headers(init.headers).forEach((value, key) => headers.set(key, value));\n await resolveCompanionTokenHeader(init.method ?? 'GET', headers, options);\n return fetchWithTimeout(\n `${base}${path.startsWith('/') ? path : `/${path}`}`,\n { ...init, headers },\n options,\n retryPolicy,\n );\n },\n\n async get<T>(path: string, options?: CompanionClientOptions): Promise<T> {\n const res = await CompanionClient.request(path, {}, options, CompanionRequestRetryPolicy.SAFE_READ);\n if (!res.ok) throw new CompanionRefusalError(describeCompanionFailure(path, 'GET', res, options, await readRefusalDetail(res)), res.status, await readRefusalBody(res));\n return res.json() as Promise<T>;\n },\n\n async post<T>(\n path: string,\n body?: unknown,\n options?: CompanionClientOptions,\n retryPolicy: CompanionRequestRetryPolicy = CompanionRequestRetryPolicy.NO_RETRY,\n ): Promise<T> {\n const res = await CompanionClient.request(\n path,\n {\n method: 'POST',\n headers: { [WildoHeaderKeys.CONTENT_TYPE]: 'application/json' },\n body: body ? JSON.stringify(body) : undefined,\n },\n options,\n retryPolicy,\n );\n if (!res.ok) throw new CompanionRefusalError(describeCompanionFailure(path, 'POST', res, options, await readRefusalDetail(res)), res.status, await readRefusalBody(res));\n return res.json() as Promise<T>;\n },\n\n /** Check if companion is reachable. */\n async ping(options?: CompanionClientOptions): Promise<boolean> {\n try {\n const base = getBaseUrl(options);\n const res = await fetchWithTimeout(`${base}/health`, { method: 'GET' }, options, CompanionRequestRetryPolicy.SAFE_READ);\n return res.ok;\n } catch {\n return false;\n }\n },\n};\n\n/**\n * Reads and heads are safe by their transport semantics. Every other method\n * starts no-retry unless a caller declares a stronger semantic contract.\n */\nfunction defaultRetryPolicy(init: RequestInit): CompanionRequestRetryPolicy {\n const method = (init.method ?? 'GET').toUpperCase();\n return method === 'GET' || method === 'HEAD'\n ? CompanionRequestRetryPolicy.SAFE_READ\n : CompanionRequestRetryPolicy.NO_RETRY;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"companion-client.service.js","sourceRoot":"","sources":["../../../../src/services/companion/companion-client.service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,gFAAgF;AAChF,gFAAgF;AAChF,iFAAiF;AACjF,gDAAgD;AAChD,wEAAwE;AACxE,6EAA6E;AAC7E,gFAAgF;AAChF,6EAA6E;AAC7E,6BAA6B;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AAC;AAEF;;;GAGG;AACH,SAAS,kBAAkB,CAAC,IAAiB;IAC3C,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IACpD,OAAO,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,MAAM;QAC1C,CAAC,CAAC,2BAA2B,CAAC,SAAS;QACvC,CAAC,CAAC,2BAA2B,CAAC,QAAQ,CAAC;AAC3C,CAAC","sourcesContent":["/**\n * CompanionClientService — HTTP client for companion REST API.\n *\n * IMPLEMENTATION: DONE — get, post, ping, 10s timeout via AbortSignal.timeout.\n * Protocol (endpoints, payloads) TBD when companion service is defined.\n */\n\n// BOTH fetch and Agent must come from the SAME undici. Node's GLOBAL fetch is a\n// different undici (bundled 8.x on Node 26) whose dispatch-handler interface is\n// incompatible with this package's Agent (6.x) — passing our Agent as the global\n// fetch's `dispatcher` fails every request with\n// `InvalidArgumentError: invalid onError method (UND_ERR_INVALID_ARG)`.\n// That silently broke every long-running companion RPC (labels / translate /\n// email generation) when the toolchain moved to Node 26. Importing undici's own\n// fetch keeps the dispatcher/handler pair version-coherent regardless of the\n// Node-bundled undici major.\nimport { Agent, fetch } from 'undici';\nimport { ErrorCustomMessageReference, ModelProviderAccountRefusalSchema, WildoHeaderKeys, type ModelProviderAccountRefusal } from '@wildo-ai/saas-models';\nimport {\n COMPANION_DEFAULT_PORT,\n COMPANION_DEFAULT_TIMEOUT_MS,\n CompanionRequestRetryPolicy,\n} from './companion.schemas';\nimport type { CompanionClientOptions } from './companion.schemas';\nimport { COMPANION_TOKEN_HEADER, CompanionTokenAbsentError, readCompanionTokenNoFollow } from './companion-local-token.utils';\n\n/**\n * Lazily-built `undici.Agent` with long head/body timeouts for companion\n * RPCs. Required because Node's native `fetch` (undici under the hood)\n * defaults to `headersTimeout: 300_000` (5 min) — even if the caller\n * passes `AbortSignal.timeout(...)` with a longer ceiling, undici will\n * still give up at 5 min waiting for response headers.\n *\n * The companion's labelling, translation, and email generation endpoints\n * legitimately exceed 5 min (LLM batch jobs). The companion-side fix is\n * in `engine/saas-backend-lib` (`appConfiguration.runtime.httpServerConfiguration`);\n * this is the matching client-side fix. Both must move together — a\n * 30-min server-side `requestTimeout` is useless if the client gives up\n * at 5 min.\n *\n * Both dispatcher timeouts are OFF (0): each request's `AbortSignal.timeout(timeoutMs)`\n * is the one authority over how long the client waits. They were 31 minutes, \"slightly\n * above the 30-min companion server timeout\", and that cut every request whose own\n * deadline is longer: `wildo creation drive` holds a loop request for up to 6 hours, and\n * on reference run 42713670241 (#3204) every loop that took over 31 minutes ended in\n * `fetch failed` (`UND_ERR_HEADERS_TIMEOUT`), which the drive read as the loop's refusal\n * and stopped on five times. The companion's 30-minute `requestTimeout` bounds RECEIVING\n * a request, never the time to answer it, so it does not cut a long loop.\n */\nlet _longRunningAgent: Agent | undefined;\nfunction getLongRunningAgent(): Agent {\n if (!_longRunningAgent) {\n _longRunningAgent = new Agent({\n headersTimeout: 0,\n bodyTimeout: 0,\n keepAliveTimeout: 31 * 60_000,\n });\n }\n return _longRunningAgent;\n}\n\nfunction getBaseUrl(options?: CompanionClientOptions): string {\n const port = options?.port ?? COMPANION_DEFAULT_PORT;\n return options?.baseUrl ?? `http://localhost:${port}`;\n}\n\n/** Attempts (including the first) for transient connection failures. */\nconst CONNECTION_RETRY_ATTEMPTS = 4;\n/** Delay between connection-retry attempts (≈1.2s total across 4 attempts). */\nconst CONNECTION_RETRY_DELAY_MS = 400;\n\n/**\n * A transient connection failure — the companion is briefly unreachable, e.g.\n * mid-restart after a source edit (dev watcher → runtime-supervisor). undici's\n * `fetch` throws `TypeError: fetch failed` with the underlying error on `.cause`.\n * We retry ONLY these (never timeouts or HTTP status errors, which are real).\n */\nfunction isTransientConnectionError(err: unknown): boolean {\n if (!(err instanceof Error)) {\n return false;\n }\n const code = (err as { cause?: { code?: string } }).cause?.code;\n return code === 'ECONNREFUSED' || code === 'ECONNRESET' || code === 'ECONNABORTED' || code === 'EAI_AGAIN';\n}\n\n/**\n * undici gave up waiting for the head or the body (`fetch failed` with a timeout cause). The client stopped waiting, the\n * companion may still be working: a {@link CompanionRequestTimeoutError}, never a refusal of the request.\n */\nfunction isDispatcherTimeout(err: Error): boolean {\n const code = (err as { cause?: { code?: string } }).cause?.code;\n return code === 'UND_ERR_HEADERS_TIMEOUT' || code === 'UND_ERR_BODY_TIMEOUT';\n}\n\nasync function fetchWithTimeout(\n url: string,\n init: RequestInit & { timeoutMs?: number },\n options?: CompanionClientOptions,\n retryPolicy: CompanionRequestRetryPolicy = defaultRetryPolicy(init),\n): Promise<Response> {\n const timeoutMs = init.timeoutMs ?? options?.timeoutMs ?? COMPANION_DEFAULT_TIMEOUT_MS;\n const attempts = retryPolicy === CompanionRequestRetryPolicy.SAFE_READ ? CONNECTION_RETRY_ATTEMPTS : 1;\n\n let lastError: unknown;\n for (let attempt = 1; attempt <= attempts; attempt++) {\n // Fresh signal per attempt — an aborted/consumed AbortSignal can't be reused.\n const signal = AbortSignal.timeout(timeoutMs);\n try {\n // The cast bridges the AMBIENT `RequestInit` this function's signature uses\n // (undici-types via @types/node) and the imported undici's own structurally\n // identical `RequestInit` — the two type packages declare nominal twins\n // (FormData/Blob) that TypeScript refuses to unify across module identities.\n // Runtime-coherent by construction: fetch, Agent and the init all come from\n // the same imported undici (see the import note at the top of this file).\n return await fetch(url, {\n ...init,\n signal,\n dispatcher: getLongRunningAgent(),\n } as unknown as Parameters<typeof fetch>[1]);\n } catch (err) {\n if (err instanceof Error && (err.name === 'AbortError' || err.name === 'TimeoutError' || isDispatcherTimeout(err))) {\n throw new CompanionRequestTimeoutError(timeoutMs);\n }\n lastError = err;\n // Retry a briefly-unreachable companion (mid-restart); fail fast otherwise.\n if (attempt < attempts && isTransientConnectionError(err)) {\n await new Promise((resolve) => setTimeout(resolve, CONNECTION_RETRY_DELAY_MS));\n continue;\n }\n throw err;\n }\n }\n throw lastError;\n}\n\n/**\n * Methods that need no companion token — the same set the companion's own floor lets through.\n *\n * Kept as the METHOD rather than as a list of mutating routes for the reason the server side gives at\n * `COMPANION_TOKEN_FLOOR_UNGATED_METHODS`: the two ends must agree, and a verb is the only\n * discriminator both can compute without maintaining a copy of the other's route table.\n */\nconst COMPANION_TOKEN_UNGATED_METHODS: ReadonlySet<string> = new Set(['GET', 'HEAD', 'OPTIONS']);\n\n/**\n * Attach the machine-local companion token to a mutating request (P-29b).\n *\n * This is the CLIENT half of one invariant, and it lives HERE — at the single point every CLI\n * companion request funnels through — rather than at each of the eight call sites that build one.\n * Those call sites are four near-identical `resolveCompanionClientOptions` copies plus an inline\n * object literal in `charts-audit.command.ts`; a per-call-site attach would have been five hand-applied\n * copies of a rule, and the sixth would have been written without it.\n *\n * An explicitly-supplied token header WINS: `requestAuthorizedLocalCompanion` sets one, and a caller\n * that has gone to the trouble of naming a credential must not have it silently replaced.\n *\n * A failed read is raised, not swallowed. Sending the request without the token would trade a local\n * error that names the token file for a remote 401 that names the same file one hop further away —\n * and the local one can say WHY (the file is missing, or its mode is too broad), which the server\n * cannot know.\n *\n * **An ABSENT `appRoot` sends nothing and lets the companion refuse**, and that decision was\n * re-examined on 2026-09-10 rather than reversed. Raising locally instead was tried: it makes every\n * mutating call require an application root, which is true of the CLI's real callers and NOT of a\n * request whose only problem is a companion that has restarted — so the refusal has to be legible\n * wherever it comes from, not only in the one branch that can see it early. That is what\n * `describeCompanionFailure` below does, and it covers the stale-token case the local throw could\n * not. The branch is reachable: a `wildo` invocation with no targeted app resolves\n * `{ timeoutMs }` alone (`companion-client-options.utils.ts`).\n */\nasync function resolveCompanionTokenHeader(\n method: string,\n headers: Headers,\n options?: CompanionClientOptions,\n): Promise<void> {\n if (COMPANION_TOKEN_UNGATED_METHODS.has(method.toUpperCase())) return;\n if (options?.appRoot === undefined || headers.has(COMPANION_TOKEN_HEADER)) return;\n headers.set(COMPANION_TOKEN_HEADER, await readCompanionTokenNoFollow(options.appRoot));\n}\n\n/**\n * Turn a companion failure into a sentence that names the CAUSE, not only the status.\n *\n * A `401` from the companion carries `type: AUTHENTICATION`, a severity and a correlation id, and\n * NOTHING else — measured against the running companion on 2026-09-10. `sanitizeErrorForClient`\n * strips the explanatory context before it leaves the process, deliberately: a refusal must not teach\n * an unauthorized caller where the credential lives. The sentence that does explain is in the\n * COMPANION'S log, under the same correlation id.\n *\n * So `Companion API /api/companion/x: 401 Unauthorized` is all a CLI user would otherwise see, and it\n * reads as \"the thing I asked for failed\" rather than \"I sent no credential\" — the defect class this\n * whole change closed for three callers outside the CLI. The client is the one place that knows both\n * halves (which application it targeted, and whether it attached anything), so it is the one place\n * that can say which of the two happened.\n */\nfunction describeCompanionFailure(\n path: string,\n method: string,\n response: Response,\n options?: CompanionClientOptions,\n refusal?: string,\n): string {\n const base = refusal === undefined\n ? `Companion API ${path}: ${response.status} ${response.statusText}`\n : `Companion API ${path}: ${response.status} ${response.statusText} — ${refusal}`;\n if (response.status !== 401) return base;\n /*\n * The floor is VERB-discriminated, so this explanation has to be too — and the same set the attach\n * reads is the one that decides here, twenty lines apart in one file rather than two copies. A 401\n * on a READ is not a missing mutation credential: it comes from somewhere else entirely, and\n * telling the caller to check its companion token would send them to the wrong place.\n */\n if (COMPANION_TOKEN_UNGATED_METHODS.has(method.toUpperCase())) {\n return `${base} — this is a READ, which the companion's local-token floor does not gate, so the `\n + 'refusal is not about the machine-local token.';\n }\n return options?.appRoot === undefined\n ? `${base} — this route mutates and needs the machine-local companion token, and no targeted `\n + 'application was resolved, so none was sent. Run the command from inside a Wildo application.'\n : `${base} — the companion refused the token read from ${options.appRoot}/.wildo-saas/state/`\n + 'companion.token. It mints a fresh one on every boot, so this usually means it restarted; '\n + 'the companion\\'s own log carries the full refusal under the response\\'s correlation id.';\n}\n\n/**\n * The companion's own explanation of a refusal, when the body carries one.\n *\n * A refused REQUEST (a 4xx) answers with the reason the handler wrote — the engine's error envelope\n * allow-lists `message` in `details` for VALIDATION, CONFLICT and RATE_LIMIT. Without reading it, a\n * caller saw `400 Bad Request` and nothing else, and the refusal naming the fix (\"`get` takes `refs` OR\n * `aspectKeys`\") reached nobody (#1459, found on the first live `wildo context elements` run).\n *\n * Every OTHER type loses its `details` to the client sanitizer, so a refusal whose words matter (a 404\n * among them) carries them as `userGuidance` instead: when there is no `details.message`, read its\n * `explanation` and its `resolution`, joined when both are present (#1588). The raw text is right here — the CLI has no label tree to resolve\n * the guidance key against.\n *\n * Best-effort and non-throwing: an empty or non-JSON body simply yields no detail, and the status line\n * stands on its own as before.\n */\nasync function readRefusalDetail(response: Response): Promise<string | undefined> {\n try {\n const body = await response.clone().json() as {\n error?: { details?: { message?: unknown }; userGuidance?: { explanation?: unknown; resolution?: unknown } };\n };\n const text = (value: unknown): string | undefined => (typeof value === 'string' && value.trim().length > 0 ? value : undefined);\n const details = text(body?.error?.details?.message);\n if (details) return details;\n // Both halves when both are present: the resolution is the actionable one (#1588 review F4).\n const guidance = [text(body?.error?.userGuidance?.explanation), text(body?.error?.userGuidance?.resolution)].filter((part): part is string => part !== undefined);\n return guidance.length > 0 ? guidance.join(' ') : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * The companion ANSWERED, with a non-2xx status (#1588): carries that status, so a caller can tell a\n * refusal from a companion that is not there without parsing the message.\n */\nexport class CompanionRefusalError extends Error {\n public constructor(\n message: string,\n public readonly status: number,\n /**\n * What the answer's body said, when it was the engine's error shape: its stable message reference (`error.customMessageReference`)\n * and the facts its reference admits (`error.details`). How a caller branches on WHY without parsing the message (#3204).\n */\n public readonly refusal?: CompanionRefusalBody,\n ) {\n super(message);\n this.name = 'CompanionRefusalError';\n }\n}\n\n/** The machine-readable half of a refusal's body. */\nexport interface CompanionRefusalBody {\n readonly reference?: string;\n readonly details?: Record<string, unknown>;\n}\n\n/** The reference and admitted details of a refusal's body, or `undefined` when the body is not the engine's error shape. */\nasync function readRefusalBody(response: Response): Promise<CompanionRefusalBody | undefined> {\n try {\n const body = await response.clone().json() as { error?: { customMessageReference?: unknown; details?: unknown } };\n const reference = typeof body?.error?.customMessageReference === 'string' ? body.error.customMessageReference : undefined;\n const details = body?.error?.details !== null && typeof body?.error?.details === 'object' && !Array.isArray(body.error.details)\n ? body.error.details as Record<string, unknown>\n : undefined;\n return reference === undefined && details === undefined ? undefined : { ...(reference !== undefined ? { reference } : {}), ...(details !== undefined ? { details } : {}) };\n } catch {\n return undefined;\n }\n}\n\n/** Who refused, when the answer named only WHY: the engine's wire carries the reason alone (least disclosure). */\nconst UNNAMED_PROVIDER = 'the companion\\'s model provider';\n\n/**\n * The model provider ACCOUNT's refusal a companion answer carried (#3204): the engine answers it `502` with the reference\n * `model_provider_account_refused` and only the classified `details.reason`, since the provider and its words are the\n * operator's billing state and that answer can reach an end user. So the refusal read here names the reason, and points\n * at the companion's log for the rest. (The creation loop's own interruption carries the whole refusal.) `undefined` for\n * any other failure.\n */\nexport function readCompanionProviderAccountRefusal(error: unknown): ModelProviderAccountRefusal | undefined {\n if (!(error instanceof CompanionRefusalError) || error.refusal?.reference !== ErrorCustomMessageReference.MODEL_PROVIDER_ACCOUNT_REFUSED) return undefined;\n const reason = ModelProviderAccountRefusalSchema.shape.reason.safeParse(error.refusal.details?.reason);\n if (!reason.success) return undefined;\n return { reason: reason.data, provider: UNNAMED_PROVIDER, providerMessage: 'the companion\\'s log names the provider and quotes its answer' };\n}\n\n/**\n * The creation console's exit code for a failed companion call (#1652): 2 when the companion could not\n * be REACHED (nothing listening, connection reset, or a companion that never started here and so\n * left no token), 1 for everything else — a refusal it answered, a\n * timeout, a malformed request. The distinction is the one an agent branches on: \"fix what you sent\"\n * versus \"start the stack\", and it must not be recovered by parsing an error message.\n */\nexport const COMPANION_UNREACHABLE_EXIT_CODE = 2;\nexport function companionFailureExitCode(error: unknown): number {\n return isTransientConnectionError(error) || error instanceof CompanionTokenAbsentError ? COMPANION_UNREACHABLE_EXIT_CODE : 1;\n}\n\n/**\n * The connection to the companion CLOSED before the request got its whole answer (#4021): undici's `fetch failed` with a\n * `SocketError` cause (`UND_ERR_SOCKET`: \"other side closed\" before the head, \"terminated\" mid-body). The companion was\n * reached and did not finish answering, so this is neither a refusal (it said nothing) nor an unreachable companion (it\n * was there when the request went out).\n *\n * Reference run 44052185141 (its log carries no error cause; the shape is reproduced against undici 7.30.2): a companion\n * that stops while it holds a request (a restart after a dependency install, with the drive's loop request parked at the\n * restart window) closes its HTTP server, which waits for that request until its bounded 5000 ms step gives up, and exits;\n * the held socket is then closed from the companion's side and the client sees exactly this. `wildo creation drive` read\n * it as the loop's refusal and stopped, twice.\n *\n * Kept OUT of {@link companionFailureExitCode}'s unreachable set on purpose: a closed connection does not say the\n * companion is down, only that it stopped answering THIS request. A caller that can ask the companion whether it\n * restarted (the drive reads its process start time) decides; the others report it as the failure it is.\n */\nexport function isCompanionConnectionClosedBeforeAnswer(error: unknown): boolean {\n if (!(error instanceof Error)) return false;\n return (error as { cause?: { code?: string } }).cause?.code === 'UND_ERR_SOCKET';\n}\n\n/**\n * The CLIENT gave up waiting — the companion may still be doing the work. Distinct from\n * {@link CompanionRefusalError} (the companion answered no) and from an unreachable companion, because a\n * caller whose request STARTS work must not report a timeout as a failure: `wildo creation answer` on a\n * playbook round is refused fast when the answer is wrong and otherwise holds the request open for the\n * whole continuation, so a timeout there means the answer was admitted and the run is still going.\n */\nexport class CompanionRequestTimeoutError extends Error {\n public constructor(public readonly timeoutMs: number) {\n super(`Companion API request timed out after ${timeoutMs}ms`);\n this.name = 'CompanionRequestTimeoutError';\n }\n}\n\nexport const CompanionClient = {\n async request(\n path: string,\n init: RequestInit = {},\n options?: CompanionClientOptions,\n retryPolicy: CompanionRequestRetryPolicy = defaultRetryPolicy(init),\n ): Promise<Response> {\n const base = getBaseUrl(options);\n const headers = new Headers(options?.headers);\n new Headers(init.headers).forEach((value, key) => headers.set(key, value));\n await resolveCompanionTokenHeader(init.method ?? 'GET', headers, options);\n return fetchWithTimeout(\n `${base}${path.startsWith('/') ? path : `/${path}`}`,\n { ...init, headers },\n options,\n retryPolicy,\n );\n },\n\n async get<T>(path: string, options?: CompanionClientOptions): Promise<T> {\n const res = await CompanionClient.request(path, {}, options, CompanionRequestRetryPolicy.SAFE_READ);\n if (!res.ok) throw new CompanionRefusalError(describeCompanionFailure(path, 'GET', res, options, await readRefusalDetail(res)), res.status, await readRefusalBody(res));\n return res.json() as Promise<T>;\n },\n\n async post<T>(\n path: string,\n body?: unknown,\n options?: CompanionClientOptions,\n retryPolicy: CompanionRequestRetryPolicy = CompanionRequestRetryPolicy.NO_RETRY,\n ): Promise<T> {\n const res = await CompanionClient.request(\n path,\n {\n method: 'POST',\n headers: { [WildoHeaderKeys.CONTENT_TYPE]: 'application/json' },\n body: body ? JSON.stringify(body) : undefined,\n },\n options,\n retryPolicy,\n );\n if (!res.ok) throw new CompanionRefusalError(describeCompanionFailure(path, 'POST', res, options, await readRefusalDetail(res)), res.status, await readRefusalBody(res));\n return res.json() as Promise<T>;\n },\n\n /** Check if companion is reachable. */\n async ping(options?: CompanionClientOptions): Promise<boolean> {\n try {\n const base = getBaseUrl(options);\n const res = await fetchWithTimeout(`${base}/health`, { method: 'GET' }, options, CompanionRequestRetryPolicy.SAFE_READ);\n return res.ok;\n } catch {\n return false;\n }\n },\n};\n\n/**\n * Reads and heads are safe by their transport semantics. Every other method\n * starts no-retry unless a caller declares a stronger semantic contract.\n */\nfunction defaultRetryPolicy(init: RequestInit): CompanionRequestRetryPolicy {\n const method = (init.method ?? 'GET').toUpperCase();\n return method === 'GET' || method === 'HEAD'\n ? CompanionRequestRetryPolicy.SAFE_READ\n : CompanionRequestRetryPolicy.NO_RETRY;\n}\n"]}
|
|
@@ -32,6 +32,12 @@
|
|
|
32
32
|
* the working tree; the run records survive). The restart itself is on the intervention ledger when the companion
|
|
33
33
|
* booted with runs in flight (#2231), and the driver also counts the restarts it saw, from the companion's start time.
|
|
34
34
|
*
|
|
35
|
+
* A restart reaches the driver in one of two shapes: nothing listens (connection refused), or the companion stopped while
|
|
36
|
+
* it HELD the loop request, which the client sees as the connection closing before any answer (`UND_ERR_SOCKET`; #4021,
|
|
37
|
+
* reference run 44052185141, where a dependency install's restart stopped the drive `loop-refused` twice). The second is
|
|
38
|
+
* never read as a restart on its own: the next status the companion answers settles it by its process start time, a new
|
|
39
|
+
* one resuming the drive and the same one stopping it {@link CreationDriveStopRule.LOOP_CONNECTION_LOST}.
|
|
40
|
+
*
|
|
35
41
|
* ## Holds it respects
|
|
36
42
|
*
|
|
37
43
|
* - a person's `wildo build stop` (#3206) is a STOP: a stopped build is never resumed unattended;
|
|
@@ -86,6 +92,13 @@ export declare enum CreationDriveStopRule {
|
|
|
86
92
|
LANES_FAILED = "lanes-failed",
|
|
87
93
|
/** The companion refused to run the loop (a preflight failure, a refusal whose remedy is a decision). */
|
|
88
94
|
LOOP_REFUSED = "loop-refused",
|
|
95
|
+
/**
|
|
96
|
+
* The connection closed before the companion answered the loop, and the companion did NOT restart (#4021): the same
|
|
97
|
+
* process, by its start time, answered the next read. Not a refusal (it said nothing) and not a restart (which the drive
|
|
98
|
+
* waits through), so something between the drive and the companion cut the request. The loop may still run there:
|
|
99
|
+
* `wildo creation pulse` shows it; run the drive again, which waits for it before choosing.
|
|
100
|
+
*/
|
|
101
|
+
LOOP_CONNECTION_LOST = "loop-connection-lost",
|
|
89
102
|
/** The autonomy posture leaves acceptance to a person: a marked critical gate is armed. */
|
|
90
103
|
ACCEPTANCE_HELD_FOR_PERSON = "acceptance-held-for-person",
|
|
91
104
|
/** The creation preflight found what would stop the run, before the first round. */
|
|
@@ -222,6 +235,11 @@ export interface CreationDrivePort {
|
|
|
222
235
|
readonly isClientTimeout: (error: unknown) => boolean;
|
|
223
236
|
/** The companion answered "not now" (503: a derivation still in progress, as after a restart). A wait, never an error. */
|
|
224
237
|
readonly isNotReadyYet: (error: unknown) => boolean;
|
|
238
|
+
/**
|
|
239
|
+
* The connection closed while the request waited for the companion's answer (#4021): it was reached and said nothing.
|
|
240
|
+
* What a companion that stops while it holds a request leaves behind; whether it RESTARTED is the status's start time.
|
|
241
|
+
*/
|
|
242
|
+
readonly isConnectionClosedBeforeAnswer: (error: unknown) => boolean;
|
|
225
243
|
/** The companion refused because a loop or composite already runs (409). */
|
|
226
244
|
readonly isAlreadyRunning: (error: unknown) => boolean;
|
|
227
245
|
/** The provider account's refusal (#3204) the companion ANSWERED with (a model call outside the loop's own steps), or `undefined`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"creation-drive.service.d.ts","sourceRoot":"","sources":["../../../../src/services/companion/creation-drive.service.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"creation-drive.service.d.ts","sourceRoot":"","sources":["../../../../src/services/companion/creation-drive.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,OAAO,EAIL,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EAChC,KAAK,kCAAkC,EACvC,KAAK,oBAAoB,EAC1B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAuC,KAAK,2BAA2B,EAAuB,MAAM,uBAAuB,CAAC;AAEnI,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,mGAAmG;AACnG,oBAAY,kBAAkB;IAC5B,KAAK,UAAU;CAChB;AAED,0GAA0G;AAC1G,oBAAY,qBAAqB;IAC/B;;;OAGG;IACH,YAAY,iBAAiB;IAC7B;;;;;OAKG;IACH,iBAAiB,sBAAsB;IACvC;;;OAGG;IACH,eAAe,oBAAoB;IACnC,kEAAkE;IAClE,YAAY,iBAAiB;IAC7B;;;OAGG;IACH,kBAAkB,uBAAuB;IACzC,0HAA0H;IAC1H,YAAY,iBAAiB;IAC7B,oFAAoF;IACpF,uBAAuB,4BAA4B;IACnD,6FAA6F;IAC7F,UAAU,eAAe;IACzB,6GAA6G;IAC7G,YAAY,iBAAiB;IAC7B,yGAAyG;IACzG,YAAY,iBAAiB;IAC7B;;;;;OAKG;IACH,oB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
33
|
* booted with runs in flight (#2231), and the driver also counts the restarts it saw, from the companion's start time.
|
|
34
34
|
*
|
|
35
|
+
* A restart reaches the driver in one of two shapes: nothing listens (connection refused), or the companion stopped while
|
|
36
|
+
* it HELD the loop request, which the client sees as the connection closing before any answer (`UND_ERR_SOCKET`; #4021,
|
|
37
|
+
* reference run 44052185141, where a dependency install's restart stopped the drive `loop-refused` twice). The second is
|
|
38
|
+
* never read as a restart on its own: the next status the companion answers settles it by its process start time, a new
|
|
39
|
+
* one resuming the drive and the same one stopping it {@link CreationDriveStopRule.LOOP_CONNECTION_LOST}.
|
|
40
|
+
*
|
|
35
41
|
* ## Holds it respects
|
|
36
42
|
*
|
|
37
43
|
* - a person's `wildo build stop` (#3206) is a STOP: a stopped build is never resumed unattended;
|
|
@@ -87,6 +93,13 @@ export var CreationDriveStopRule;
|
|
|
87
93
|
CreationDriveStopRule["LANES_FAILED"] = "lanes-failed";
|
|
88
94
|
/** The companion refused to run the loop (a preflight failure, a refusal whose remedy is a decision). */
|
|
89
95
|
CreationDriveStopRule["LOOP_REFUSED"] = "loop-refused";
|
|
96
|
+
/**
|
|
97
|
+
* The connection closed before the companion answered the loop, and the companion did NOT restart (#4021): the same
|
|
98
|
+
* process, by its start time, answered the next read. Not a refusal (it said nothing) and not a restart (which the drive
|
|
99
|
+
* waits through), so something between the drive and the companion cut the request. The loop may still run there:
|
|
100
|
+
* `wildo creation pulse` shows it; run the drive again, which waits for it before choosing.
|
|
101
|
+
*/
|
|
102
|
+
CreationDriveStopRule["LOOP_CONNECTION_LOST"] = "loop-connection-lost";
|
|
90
103
|
/** The autonomy posture leaves acceptance to a person: a marked critical gate is armed. */
|
|
91
104
|
CreationDriveStopRule["ACCEPTANCE_HELD_FOR_PERSON"] = "acceptance-held-for-person";
|
|
92
105
|
/** The creation preflight found what would stop the run, before the first round. */
|
|
@@ -283,6 +296,11 @@ function judgeChosenStop(rationale, requirements) {
|
|
|
283
296
|
return stop(CreationDriveStopRule.REQUIREMENTS_OPEN, `the loop chose to stop (${rationale}) while ${requirementsWithItems} of ${standing.requirementCount} requirement(s) carry ${standing.openItems.length} open item(s): `
|
|
284
297
|
+ `${named.join('; ')}${rest > 0 ? `; and ${rest} more` : ''}. Start refinement on them, or decide they are out of scope: wildo creation feed`);
|
|
285
298
|
}
|
|
299
|
+
/** `fetch failed (other side closed)`: the transport's line and its cause's, since `fetch failed` alone names nothing. */
|
|
300
|
+
function describeClosedConnection(error) {
|
|
301
|
+
const cause = error?.cause?.message;
|
|
302
|
+
return typeof cause === 'string' && cause.length > 0 ? `${describeCaughtError(error)} (${cause})` : describeCaughtError(error);
|
|
303
|
+
}
|
|
286
304
|
function stop(rule, waitingFor) {
|
|
287
305
|
return { action: CreationDriveAction.STOP, rule, waitingFor };
|
|
288
306
|
}
|
|
@@ -322,6 +340,12 @@ export async function runCreationDrive(port, options) {
|
|
|
322
340
|
let networkWaitSinceMs;
|
|
323
341
|
/** The standing read for the last loop's chosen stop (#3701); cleared when a loop runs, so a stale one never judges. */
|
|
324
342
|
let requirements;
|
|
343
|
+
/**
|
|
344
|
+
* The loop request whose connection closed before the companion answered (#4021), and the companion's start time when
|
|
345
|
+
* it was sent. Settled by the next status the companion answers: a new start time is a restart, waited through and
|
|
346
|
+
* resumed; the same one stops the drive {@link CreationDriveStopRule.LOOP_CONNECTION_LOST}.
|
|
347
|
+
*/
|
|
348
|
+
let loopConnectionLost;
|
|
325
349
|
const finish = (rule, waitingFor, providerAccountRefusal) => {
|
|
326
350
|
port.progress(`Stopped: ${rule} — ${waitingFor}`);
|
|
327
351
|
return {
|
|
@@ -372,7 +396,8 @@ export async function runCreationDrive(port, options) {
|
|
|
372
396
|
* A companion that does not answer, answers "not yet" (503: after a restart its first feed derivation is still
|
|
373
397
|
* running), or answers late is a WAIT, bounded; anything else is a defect worth surfacing (review of 6fe527ed3).
|
|
374
398
|
*/
|
|
375
|
-
|
|
399
|
+
// A read whose connection closed before the answer (#4021) is the same wait: a companion stopping under it.
|
|
400
|
+
if (!port.isCompanionUnreachable(error) && !port.isNotReadyYet(error) && !port.isClientTimeout(error) && !port.isConnectionClosedBeforeAnswer(error))
|
|
376
401
|
throw error;
|
|
377
402
|
unreachableSince ??= port.now();
|
|
378
403
|
if (port.now() - unreachableSince >= CREATION_DRIVE_COMPANION_DOWN_LIMIT_MS) {
|
|
@@ -394,6 +419,22 @@ export async function runCreationDrive(port, options) {
|
|
|
394
419
|
companionRestarts += 1;
|
|
395
420
|
port.progress(`The companion restarted (now since ${status.companionStartedAt}); re-reading its state`);
|
|
396
421
|
}
|
|
422
|
+
if (loopConnectionLost !== undefined) {
|
|
423
|
+
const lost = loopConnectionLost;
|
|
424
|
+
loopConnectionLost = undefined;
|
|
425
|
+
/*
|
|
426
|
+
* The companion's own process start time is the restart signal (the status route computes it once per process), so
|
|
427
|
+
* the closed connection is never read as a restart on its own. A restart was counted just above and the drive goes
|
|
428
|
+
* on from the durable rows; the same process means the request was cut by something else, which is no refusal the
|
|
429
|
+
* drive can name and no restart it can wait through.
|
|
430
|
+
*/
|
|
431
|
+
// An unknown start time cannot show a restart, so it stops rather than resume on a guess (fails closed).
|
|
432
|
+
if (lost.companionStartedAt === undefined || status.companionStartedAt === lost.companionStartedAt) {
|
|
433
|
+
return finish(CreationDriveStopRule.LOOP_CONNECTION_LOST, `the connection closed before the companion answered the loop (${lost.cause}), and the companion did not restart (running since ${status.companionStartedAt}); `
|
|
434
|
+
+ 'the loop may still run there (wildo creation pulse): run the drive again, which waits for it');
|
|
435
|
+
}
|
|
436
|
+
port.progress('The loop\'s connection closed because the companion restarted; resuming from its state');
|
|
437
|
+
}
|
|
397
438
|
companionStartedAt = status.companionStartedAt;
|
|
398
439
|
/*
|
|
399
440
|
* The goal is the requirements' to call (#3701): once the last loop chose to stop with nothing since, read where the
|
|
@@ -404,6 +445,22 @@ export async function runCreationDrive(port, options) {
|
|
|
404
445
|
requirements = { standing: await port.readRequirementsStanding() };
|
|
405
446
|
}
|
|
406
447
|
catch (error) {
|
|
448
|
+
/*
|
|
449
|
+
* A companion that stopped under this read (a held restart is released the moment the loop leaves nothing busy, and
|
|
450
|
+
* this read derives for a while), is down, or is not ready yet has not said the standing is unreadable (#4021): wait,
|
|
451
|
+
* bounded as any outage, WITHOUT marking that the drive waited, so the restarted companion is asked the same question
|
|
452
|
+
* for the same chosen stop. A client timeout is kept as an unread standing: the companion answered nothing late,
|
|
453
|
+
* which is a slow derivation rather than an absent companion.
|
|
454
|
+
*/
|
|
455
|
+
if (port.isCompanionUnreachable(error) || port.isConnectionClosedBeforeAnswer(error) || port.isNotReadyYet(error)) {
|
|
456
|
+
unreachableSince ??= port.now();
|
|
457
|
+
if (port.now() - unreachableSince >= CREATION_DRIVE_COMPANION_DOWN_LIMIT_MS) {
|
|
458
|
+
return finish(CreationDriveStopRule.COMPANION_UNREACHABLE, `the companion has not answered since ${new Date(unreachableSince).toISOString()}: wildo local dev`);
|
|
459
|
+
}
|
|
460
|
+
port.progress(`Waiting: ${CreationDriveWaitReason.COMPANION_DOWN} — the companion did not answer where the application stands; asking again`);
|
|
461
|
+
await port.sleep(CREATION_DRIVE_POLL_INTERVAL_MS);
|
|
462
|
+
continue;
|
|
463
|
+
}
|
|
407
464
|
requirements = { unreadBecause: describeCaughtError(error) };
|
|
408
465
|
}
|
|
409
466
|
}
|
|
@@ -455,6 +512,18 @@ export async function runCreationDrive(port, options) {
|
|
|
455
512
|
});
|
|
456
513
|
}
|
|
457
514
|
catch (error) {
|
|
515
|
+
/*
|
|
516
|
+
* The connection closed before the companion answered (#4021): a companion that stops while it holds the loop request
|
|
517
|
+
* (a restart after a dependency install) leaves exactly this. Reference run 44052185141 stopped `loop-refused: fetch
|
|
518
|
+
* failed` on it twice. Not decided here: the next status read settles it by the companion's start time, waiting
|
|
519
|
+
* (bounded, as any unreachable companion) while it is down or not ready.
|
|
520
|
+
*/
|
|
521
|
+
if (port.isConnectionClosedBeforeAnswer(error)) {
|
|
522
|
+
loopConnectionLost = { companionStartedAt, cause: describeClosedConnection(error) };
|
|
523
|
+
lastLoop = undefined;
|
|
524
|
+
port.progress(`Loop ${loops}: the connection closed before the companion answered; asking whether it restarted`);
|
|
525
|
+
continue;
|
|
526
|
+
}
|
|
458
527
|
// The companion went away under the loop, the client stopped waiting while it goes on, or another loop holds the
|
|
459
528
|
// subject: the next read decides (a restart is a wait, a running loop is a wait). Anything else is its refusal.
|
|
460
529
|
if (port.isCompanionUnreachable(error) || port.isClientTimeout(error) || port.isAlreadyRunning(error) || port.isNotReadyYet(error)) {
|