@wildo-ai/wildo-cli 1.1.15 → 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.
Files changed (102) hide show
  1. package/dist/src/commands/context/journey.command.d.ts.map +1 -1
  2. package/dist/src/commands/context/journey.command.js +12 -0
  3. package/dist/src/commands/context/journey.command.js.map +1 -1
  4. package/dist/src/commands/creation/drive.command.d.ts.map +1 -1
  5. package/dist/src/commands/creation/drive.command.js +2 -1
  6. package/dist/src/commands/creation/drive.command.js.map +1 -1
  7. package/dist/src/commands/local/dev.command.d.ts +44 -0
  8. package/dist/src/commands/local/dev.command.d.ts.map +1 -1
  9. package/dist/src/commands/local/dev.command.js +74 -3
  10. package/dist/src/commands/local/dev.command.js.map +1 -1
  11. package/dist/src/commands/providers/grant-export.command.d.ts +16 -0
  12. package/dist/src/commands/providers/grant-export.command.d.ts.map +1 -0
  13. package/dist/src/commands/providers/grant-export.command.js +78 -0
  14. package/dist/src/commands/providers/grant-export.command.js.map +1 -0
  15. package/dist/src/commands/providers/grant-import.command.d.ts +15 -0
  16. package/dist/src/commands/providers/grant-import.command.d.ts.map +1 -0
  17. package/dist/src/commands/providers/grant-import.command.js +78 -0
  18. package/dist/src/commands/providers/grant-import.command.js.map +1 -0
  19. package/dist/src/kernel/command-runner.d.ts.map +1 -1
  20. package/dist/src/kernel/command-runner.js +4 -6
  21. package/dist/src/kernel/command-runner.js.map +1 -1
  22. package/dist/src/kernel/hooks.d.ts.map +1 -1
  23. package/dist/src/kernel/hooks.js +2 -1
  24. package/dist/src/kernel/hooks.js.map +1 -1
  25. package/dist/src/kernel/json-document-output.d.ts +7 -0
  26. package/dist/src/kernel/json-document-output.d.ts.map +1 -1
  27. package/dist/src/kernel/json-document-output.js +8 -0
  28. package/dist/src/kernel/json-document-output.js.map +1 -1
  29. package/dist/src/kernel/types.d.ts +8 -0
  30. package/dist/src/kernel/types.d.ts.map +1 -1
  31. package/dist/src/kernel/types.js.map +1 -1
  32. package/dist/src/services/application/app-bootstrap.service.d.ts +24 -6
  33. package/dist/src/services/application/app-bootstrap.service.d.ts.map +1 -1
  34. package/dist/src/services/application/app-bootstrap.service.js +46 -13
  35. package/dist/src/services/application/app-bootstrap.service.js.map +1 -1
  36. package/dist/src/services/application/app-local-runtime-addresses.service.d.ts +1 -1
  37. package/dist/src/services/application/app-local-runtime-addresses.service.d.ts.map +1 -1
  38. package/dist/src/services/application/app-local-runtime-addresses.service.js.map +1 -1
  39. package/dist/src/services/application/app-runtime-targets.service.d.ts.map +1 -1
  40. package/dist/src/services/application/app-runtime-targets.service.js +7 -1
  41. package/dist/src/services/application/app-runtime-targets.service.js.map +1 -1
  42. package/dist/src/services/application/application-runtime-bootstrap.service.d.ts +13 -0
  43. package/dist/src/services/application/application-runtime-bootstrap.service.d.ts.map +1 -1
  44. package/dist/src/services/application/application-runtime-bootstrap.service.js +32 -0
  45. package/dist/src/services/application/application-runtime-bootstrap.service.js.map +1 -1
  46. package/dist/src/services/application/environment-provider-configurations.service.d.ts +7 -0
  47. package/dist/src/services/application/environment-provider-configurations.service.d.ts.map +1 -1
  48. package/dist/src/services/application/environment-provider-configurations.service.js +1 -1
  49. package/dist/src/services/application/environment-provider-configurations.service.js.map +1 -1
  50. package/dist/src/services/application/local-tunnel.service.d.ts.map +1 -1
  51. package/dist/src/services/application/local-tunnel.service.js +2 -1
  52. package/dist/src/services/application/local-tunnel.service.js.map +1 -1
  53. package/dist/src/services/companion/companion-client.service.d.ts +17 -0
  54. package/dist/src/services/companion/companion-client.service.d.ts.map +1 -1
  55. package/dist/src/services/companion/companion-client.service.js +21 -0
  56. package/dist/src/services/companion/companion-client.service.js.map +1 -1
  57. package/dist/src/services/companion/creation-drive.service.d.ts +18 -0
  58. package/dist/src/services/companion/creation-drive.service.d.ts.map +1 -1
  59. package/dist/src/services/companion/creation-drive.service.js +70 -1
  60. package/dist/src/services/companion/creation-drive.service.js.map +1 -1
  61. package/dist/src/services/deployment/docker/docker-compose-generator.service.d.ts +10 -1
  62. package/dist/src/services/deployment/docker/docker-compose-generator.service.d.ts.map +1 -1
  63. package/dist/src/services/deployment/docker/docker-compose-generator.service.js +24 -10
  64. package/dist/src/services/deployment/docker/docker-compose-generator.service.js.map +1 -1
  65. package/dist/src/services/deployment/framework-pod-network-membership.d.ts.map +1 -1
  66. package/dist/src/services/deployment/framework-pod-network-membership.js +5 -0
  67. package/dist/src/services/deployment/framework-pod-network-membership.js.map +1 -1
  68. package/dist/src/services/deployment/local-dev-late-workspace-members.service.d.ts +43 -4
  69. package/dist/src/services/deployment/local-dev-late-workspace-members.service.d.ts.map +1 -1
  70. package/dist/src/services/deployment/local-dev-late-workspace-members.service.js +116 -9
  71. package/dist/src/services/deployment/local-dev-late-workspace-members.service.js.map +1 -1
  72. package/dist/src/services/environment/authored-infra-config.utils.d.ts +4 -3
  73. package/dist/src/services/environment/authored-infra-config.utils.d.ts.map +1 -1
  74. package/dist/src/services/environment/authored-infra-config.utils.js +4 -3
  75. package/dist/src/services/environment/authored-infra-config.utils.js.map +1 -1
  76. package/dist/src/services/framework/package-install.service.d.ts +7 -0
  77. package/dist/src/services/framework/package-install.service.d.ts.map +1 -1
  78. package/dist/src/services/framework/package-install.service.js +8 -1
  79. package/dist/src/services/framework/package-install.service.js.map +1 -1
  80. package/dist/src/services/registry/application-provider-connection.service.d.ts +16 -1
  81. package/dist/src/services/registry/application-provider-connection.service.d.ts.map +1 -1
  82. package/dist/src/services/registry/application-provider-connection.service.js +23 -0
  83. package/dist/src/services/registry/application-provider-connection.service.js.map +1 -1
  84. package/dist/src/services/registry/provider-grant-transfer.service.d.ts +48 -0
  85. package/dist/src/services/registry/provider-grant-transfer.service.d.ts.map +1 -0
  86. package/dist/src/services/registry/provider-grant-transfer.service.js +144 -0
  87. package/dist/src/services/registry/provider-grant-transfer.service.js.map +1 -0
  88. package/dist/src/services/registry/provider-module-scaffold.service.d.ts.map +1 -1
  89. package/dist/src/services/registry/provider-module-scaffold.service.js +10 -3
  90. package/dist/src/services/registry/provider-module-scaffold.service.js.map +1 -1
  91. package/dist/tsconfig.build.tsbuildinfo +1 -1
  92. package/package.json +19 -19
  93. package/templates/infra/docker-compose/docker-compose.wildo-platform.yml.hbs +2 -0
  94. package/templates/saas/i18n/email/system/remote-agent-task-updated/labels.en.ts +11 -0
  95. package/templates/saas/i18n/email/system/remote-agent-task-updated/template.tsx +56 -0
  96. package/templates/saas/i18n/engine/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.en.ts +61 -0
  97. package/templates/saas/i18n/engine/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.fr.ts +61 -0
  98. package/templates/saas/scenarios/add-technical-doc/files/technical-doc/docusaurus.config.ts.hbs +5 -4
  99. package/templates/saas/scenarios/add-technical-doc/files/technical-doc/package.json.hbs +1 -1
  100. package/templates/saas/scenarios/add-technical-doc/files/technical-doc/scripts/substitute-api-origin.mjs +97 -32
  101. package/templates/saas/scenarios/add-technical-doc/files/technical-doc/src/plugins/api-reference-pages.ts +7 -6
  102. package/wildo-framework.info.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"authored-infra-config.utils.js","sourceRoot":"","sources":["../../../../src/services/environment/authored-infra-config.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAE7C,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,0CAA0C,EAC1C,gCAAgC,EAChC,kBAAkB,EAClB,gBAAgB,EAChB,yBAAyB,GAE1B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,2CAA2C,EAC3C,yCAAyC,GAC1C,MAAM,yDAAyD,CAAC;AAOjE,uHAAuH;AACvH,MAAM,UAAU,8BAA8B,CAAC,QAAgB,EAAE,OAAe;IAC9E,OAAO,yBAAyB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACtD,CAAC;AAED;;;;GAIG;AACH,MAA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env>.config.ts` descriptor and projecting it into the\n * platform-level `PlatformEnvConfigJson` shape.\n *\n * Originally lived as private helpers inside `commands/config/sync.command.ts`.\n * Extracted so the new runtime-bootstrap surface (used by `wildo local up`\n * pre-flight) can reuse the exact same projection — single source of truth\n * keeps the runtime artifacts written by `local up` byte-identical to the\n * ones `wildo config sync --domain manifest` would produce later.\n */\n\nimport { existsSync, readdirSync } from 'fs';\n\nimport {\n BackingServiceSource,\n DatabaseEngine,\n environmentServiceProfileRunsMessageBroker,\n resolveApplicationDatabaseEngine,\n loadInfraEnvConfig,\n resolveAppLayout,\n resolveInfraEnvConfigPath,\n type WildoInfraEnvConfig,\n} from '@wildo-ai/platform-config-lib';\nimport type { PlatformEnvConfigJson } from '~wildo-cli/services/credentials/credentials.schemas';\nimport {\n DEFAULT_PLATFORM_FILE_STORAGE_CONFIGURATION,\n DEFAULT_PLATFORM_POSTGRESQL_CONFIGURATION,\n} from '~wildo-cli/services/data-services/data-services.schemas';\n\nexport interface LoadedAuthoredInfraEnvConfig {\n path: string;\n config: WildoInfraEnvConfig;\n}\n\n/** The shared path rule (`resolveInfraEnvConfigPath` in platform-config-lib), kept under the CLI's historical name. */\nexport function resolveAuthoredInfraConfigPath(saasRoot: string, envName: string): string {\n return resolveInfraEnvConfigPath(saasRoot, envName);\n}\n\n/**\n * The shared loader (`loadInfraEnvConfig` in platform-config-lib), kept under the CLI's historical name and argument\n * order so its importers and the test that mocks this module are unchanged. The dev companion reads the same file\n * through the shared loader.\n */\nexport async function loadAuthoredInfraEnvConfig(\n envName: string,\n saasRoot: string,\n): Promise<LoadedAuthoredInfraEnvConfig | null> {\n return loadInfraEnvConfig(saasRoot, envName);\n}\n\n/**\n * Whether the platform a HOST application owns runs a message broker, from its authored `local` descriptor (#2303\n * slice D): `environmentServiceProfileRunsMessageBroker` of its `serviceProfile`. Read by `wildo init` before scaffolding\n * a hosted application, whose descriptor must declare no RabbitMQ vhost on a host that runs no broker.\n *\n * A host with no readable `local` descriptor answers `true`, the broker every host ran before profiles existed: the\n * scaffold keeps its previous shape, and the hosted resolution then names what is wrong with the host.\n */\nexport async function readHostRunsMessageBroker(hostRoot: string): Promise<boolean> {\n try {\n const loaded = await loadAuthoredInfraEnvConfig(HOST_LOCAL_ENVIRONMENT_NAME, hostRoot);\n return environmentServiceProfileRunsMessageBroker(loaded?.config.serviceProfile);\n } catch {\n return true;\n }\n}\n\n/** The environment a hosted scaffold is written for: the local one (`infrastructure/local/`). */\nconst HOST_LOCAL_ENVIRONMENT_NAME = 'local';\n\n/** One authored environment: the directory name it lives under, and its loaded config. */\nexport interface LoadedNamedAuthoredInfraEnvConfig extends LoadedAuthoredInfraEnvConfig {\n envName: string;\n}\n\n/** An environment directory whose authored config failed to load, and why. */\nexport interface UnreadableAuthoredInfraEnvConfig {\n readonly envName: string;\n readonly error: unknown;\n}\n\n/**\n * One environment directory as {@link settleAllAuthoredInfraEnvConfigs} found it: loaded, or failing to load. Told apart\n * with `'error' in`, which narrows whether or not the compiling package checks nulls strictly.\n */\nexport type SettledAuthoredInfraEnvConfig = LoadedNamedAuthoredInfraEnvConfig | UnreadableAuthoredInfraEnvConfig;\n\n/**\n * Every environment the application authors: each directory of its infrastructure home that carries an authored\n * `wildo.infra.<local|remote>.config.ts`, loaded through {@link loadAuthoredInfraEnvConfig}. A directory without one is\n * not an environment and is skipped. Empty when the application has no infrastructure home.\n *\n * The ONE enumeration of an application's environments: the lockfile projections and the `config sync` servability\n * preflight (`loadAuthoredInfraEnvSelections`, #1693) and the schema planner's default adapter (#2708) all judge this\n * same population, so no reader can count one environment another misses. The dev companion cannot import this module\n * and restates the same walk for the same question (`assessApplicationSchemaPlanObligation`, #2724: is a baseline owed?);\n * change one, change both.\n *\n * SETTLED rather than thrown, so a reader that can still answer with the environments that did load decides that for\n * itself: the schema planner refuses only when an unreadable environment could change its answer.\n * {@link loadAllAuthoredInfraEnvConfigs} is the throwing form.\n */\nexport async function settleAllAuthoredInfraEnvConfigs(saasRoot: string): Promise<SettledAuthoredInfraEnvConfig[]> {\n const infraDir = resolveAppLayout(saasRoot).authoredInfrastructureHome;\n if (!existsSync(infraDir)) return [];\n const settled: SettledAuthoredInfraEnvConfig[] = [];\n for (const entry of readdirSync(infraDir, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n try {\n const authored = await loadAuthoredInfraEnvConfig(entry.name, saasRoot);\n if (authored) settled.push({ envName: entry.name, ...authored });\n } catch (error) {\n settled.push({ envName: entry.name, error });\n }\n }\n return settled;\n}\n\n/** {@link settleAllAuthoredInfraEnvConfigs}, throwing the first environment that failed to load. */\nexport async function loadAllAuthoredInfraEnvConfigs(saasRoot: string): Promise<LoadedNamedAuthoredInfraEnvConfig[]> {\n const loaded: LoadedNamedAuthoredInfraEnvConfig[] = [];\n for (const environment of await settleAllAuthoredInfraEnvConfigs(saasRoot)) {\n if ('error' in environment) throw environment.error;\n loaded.push(environment);\n }\n return loaded;\n}\n\n/**\n * Reason string when the authored infra config cannot serve as a config.json\n * fallback (currently: Atlas-backed environments require generated config.json\n * because authored infra config does not include Atlas API metadata or\n * external Mongo connection endpoints).\n */\nexport function getUnsupportedAuthoredConfigFallbackReason(\n envName: string,\n authoredConfigPath: string,\n authoredConfig: WildoInfraEnvConfig,\n): string | null {\n // Slice 4.B.0 (2026-05-07): Atlas detection now uses (source=MANAGED,\n // provider='atlas') instead of the legacy `source: ATLAS` enum value.\n // Same operational meaning — operator authored a managed Mongo whose\n // brand is Atlas; the generated config.json carries the Atlas API\n // metadata + external endpoints that the authored infra descriptor\n // doesn't include.\n const mongo = authoredConfig.backingServices.mongodb;\n if (mongo?.source === BackingServiceSource.MANAGED && mongo.provider === 'atlas') {\n return (\n `Cannot regenerate config for '${envName}' from authored infra descriptor at ${authoredConfigPath}: `\n + 'Atlas-backed environments require generated config.json because authored infra config '\n + 'does not include Atlas API metadata or external Mongo connection endpoints.'\n );\n }\n\n return null;\n}\n\n/**\n * Resolve the platform's database engine for an authored environment.\n *\n * **Precedence: an authored `database` block WINS; the inference below is the fallback.**\n *\n * The inference exists because the engine was historically not authorable at all — it lived only\n * as an answer to an interactive prompt in the machine-local `environments.json`. Every environment\n * predating the authored field relies on it, so it keeps its exact behaviour.\n *\n * What it cannot express, and why the authored field had to exist: the rule is\n * `postgresql && !mongodb`, while a PostgreSQL platform is REQUIRED to also declare\n * `backingServices.mongodb` (the bootstrap plane is Mongo-wired, and both this schema and\n * `env-vars-builder` refuse a PostgreSQL platform that renders no mongod). The intended state is\n * therefore `postgresql && mongodb`, which this function always resolves to MONGODB. It is not a\n * bug in the rule — it is a question the rule cannot be asked.\n *\n * This is the same inexpressibility Phase 5.1 fixed one layer down, where `needsLocalMongoDB` was\n * `engine === MONGODB && source === SELF` and became a union so that \"which containers render\"\n * stopped being collapsed into \"what engine is the platform\". The identical collapse survived here,\n * in \"what engine is the platform\" vs \"which services are declared\".\n *\n * **Deliberately NOT made smarter.** Widening it to \"postgresql present ⇒ PostgreSQL\" would flip\n * every environment that declares PostgreSQL as an APPLICATION-tier substrate — Wonder Todos'\n * `local` does exactly that today — into a PostgreSQL PLATFORM on its next `wildo config sync`.\n * A silent engine change on an existing environment is the worst outcome available here.\n */\nexport function resolveDatabaseChoiceFromInfraConfig(\n config: WildoInfraEnvConfig,\n): PlatformEnvConfigJson['database'] {\n if (config.database) {\n return config.database;\n }\n\n return inferDatabaseChoiceFromInfraConfig(config);\n}\n\n/**\n * The pre-authoring inference. Retained as the fallback for environments that author no `database`\n * block — see {@link resolveDatabaseChoiceFromInfraConfig} for the precedence and for why this\n * cannot express a PostgreSQL platform.\n */\nexport function inferDatabaseChoiceFromInfraConfig(\n config: WildoInfraEnvConfig,\n): PlatformEnvConfigJson['database'] {\n const postgresql = config.backingServices.postgresql;\n const mongodb = config.backingServices.mongodb;\n\n if (postgresql && !mongodb) {\n return {\n engine: DatabaseEngine.POSTGRESQL,\n source: postgresql.source,\n };\n }\n\n return {\n engine: DatabaseEngine.MONGODB,\n source: mongodb?.source ?? BackingServiceSource.SELF,\n };\n}\n\n/**\n * The bytes `config.json` holds: the one serialization every writer of the generated file uses (the local self-heal,\n * `config sync`, and the remote overlay of `loadConfigForSync`), so equal content is equal bytes and a file is\n * rewritten only when its content moves (#2311).\n */\nexport function serializeConfigJson(config: PlatformEnvConfigJson): string {\n return `${JSON.stringify(config, null, 2)}\\n`;\n}\n\n/**\n * Project a parsed `wildo.infra.<env>.config.ts` into the persisted\n * platform-level `environments/<env>/config.json` shape.\n *\n * `devCompanion` is intentionally NOT persisted here — see Slice 3 deep-review\n * M-5 note in `commands/config/sync.command.ts` for the dual-config-json\n * design rationale.\n */\nexport function buildConfigJsonFromInfraEnvConfig(config: WildoInfraEnvConfig): PlatformEnvConfigJson {\n const storage = config.backingServices.s3;\n const postgresql = config.backingServices.postgresql;\n\n return {\n type: config.locationType,\n runtime: config.runtime,\n runtimeEnvironment: config.runtimeEnvironment,\n /**\n * Always present here, never `undefined`: the authored schema resolves its own default from\n * `locationType` in the transform, so what reaches this projection is the environment's settled\n * answer rather than what the author happened to type.\n */\n localDataStorage: config.localDataStorage,\n /** Always present: the descriptor transform resolves `FULL` when nothing is authored (#2303). */\n serviceProfile: config.serviceProfile,\n database: resolveDatabaseChoiceFromInfraConfig(config),\n /**\n * The APPLICATION's engine — RESOLVED, never inferred and never left absent.\n *\n * Absence means PostgreSQL (`DEFAULT_APPLICATION_DATABASE_ENGINE`, #1571), and it is resolved HERE\n * so `config.json` always carries an explicit engine: every later reader of the file — the\n * bootstrap request, the e2e store probe — then sees the same answer without holding its own copy\n * of the default. Inferring it from which backing services are declared would resurrect exactly\n * the defect the authored field exists to remove, since `postgresql && mongodb` is both the normal\n * state and unresolvable by inference.\n *\n * ⚠️ THIS is the projection that writes `config.json`, not the `transform` in\n * `defineInfraEnvConfig`. Both exist and both must carry a new field: the transform feeds\n * in-process consumers, this one feeds the file every generator later reads. Adding the field to\n * only the transform (2026-08-19) produced a silently ABSENT key here — the reconcile reported\n * success and `applicationDatabase` simply was not in the written file.\n */\n applicationDatabase: { engine: resolveApplicationDatabaseEngine(config.applicationDatabase) },\n infrastructure: {\n storage: {\n provider: (storage?.provider ?? DEFAULT_PLATFORM_FILE_STORAGE_CONFIGURATION.PROVIDER) as 'minio',\n useSsl: storage?.endpoint?.startsWith('https://') ?? false,\n bucket: storage?.bucket ?? DEFAULT_PLATFORM_FILE_STORAGE_CONFIGURATION.BUCKET,\n },\n postgresql: {\n database: postgresql?.database ?? DEFAULT_PLATFORM_POSTGRESQL_CONFIGURATION.DATABASE,\n sslMode: DEFAULT_PLATFORM_POSTGRESQL_CONFIGURATION.SSL_MODE,\n },\n },\n publicDomain: config.publicDomain,\n serviceHosts: config.serviceHosts,\n cdn: config.cdn,\n platformStorage: config.platformStorage,\n platformKeyManagement: config.platformKeyManagement,\n systemsOfRecord: config.systemsOfRecord,\n kubernetes: config.kubernetes\n ? {\n namespace: config.kubernetes.namespace,\n ingressClass: config.kubernetes.ingressClass,\n services: config.kubernetes.services,\n }\n : undefined,\n remoteProvider: config.remoteProvider,\n infrastructureHost: config.infrastructureHost,\n backingServices: config.backingServices,\n serviceAuth: config.serviceAuth,\n logging: config.logging,\n observability: config.observability,\n providerSelection: config.providerSelection,\n email: config.email,\n agentContentGuardrails: config.agentContentGuardrails,\n ownershipDnsStandIn: config.ownershipDnsStandIn,\n applicationCreationVerification: config.applicationCreationVerification,\n };\n}\n"]}
1
+ {"version":3,"file":"authored-infra-config.utils.js","sourceRoot":"","sources":["../../../../src/services/environment/authored-infra-config.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAE7C,OAAO,EACL,oBAAoB,EACpB,cAAc,EAEd,0CAA0C,EAC1C,gCAAgC,EAChC,kBAAkB,EAClB,gBAAgB,EAChB,yBAAyB,GAE1B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,2CAA2C,EAC3C,yCAAyC,GAC1C,MAAM,yDAAyD,CA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EAAE,MAAM,CAAC,sBAAsB;QACrD,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;QAC/C,+BAA+B,EAAE,MAAM,CAAC,+BAA+B;KACxE,CAAC;AACJ,CAAC","sourcesContent":["/**\n * authored-infra-config.utils — shared helpers for reading the authored\n * `wildo.infra.<env>.config.ts` descriptor and projecting it into the\n * platform-level `PlatformEnvConfigJson` shape.\n *\n * Originally lived as private helpers inside `commands/config/sync.command.ts`.\n * Extracted so the new runtime-bootstrap surface (used by `wildo local up`\n * pre-flight) can reuse the exact same projection — single source of truth\n * keeps the runtime artifacts written by `local up` byte-identical to the\n * ones `wildo config sync --domain manifest` would produce later.\n */\n\nimport { existsSync, readdirSync } from 'fs';\n\nimport {\n BackingServiceSource,\n DatabaseEngine,\n type LoadConfigOptions,\n environmentServiceProfileRunsMessageBroker,\n resolveApplicationDatabaseEngine,\n loadInfraEnvConfig,\n resolveAppLayout,\n resolveInfraEnvConfigPath,\n type WildoInfraEnvConfig,\n} from '@wildo-ai/platform-config-lib';\nimport type { PlatformEnvConfigJson } from '~wildo-cli/services/credentials/credentials.schemas';\nimport {\n DEFAULT_PLATFORM_FILE_STORAGE_CONFIGURATION,\n DEFAULT_PLATFORM_POSTGRESQL_CONFIGURATION,\n} from '~wildo-cli/services/data-services/data-services.schemas';\n\nexport interface LoadedAuthoredInfraEnvConfig {\n path: string;\n config: WildoInfraEnvConfig;\n}\n\n/** The shared path rule (`resolveInfraEnvConfigPath` in platform-config-lib), kept under the CLI's historical name. */\nexport function resolveAuthoredInfraConfigPath(saasRoot: string, envName: string): string {\n return resolveInfraEnvConfigPath(saasRoot, envName);\n}\n\n/**\n * The shared loader (`loadInfraEnvConfig` in platform-config-lib), kept under the CLI's historical name and argument\n * order so its importers and the test that mocks this module are unchanged. The dev companion reads the same file\n * through the shared loader. `options` is the shared loader's (fresh evaluation, module resolution); omitted, the\n * file is evaluated once per process and the loader infers its resolution.\n */\nexport async function loadAuthoredInfraEnvConfig(\n envName: string,\n saasRoot: string,\n options?: Pick<LoadConfigOptions, 'freshModuleCache' | 'moduleResolution'>,\n): Promise<LoadedAuthoredInfraEnvConfig | null> {\n return loadInfraEnvConfig(saasRoot, envName, options);\n}\n\n/**\n * Whether the platform a HOST application owns runs a message broker, from its authored `local` descriptor (#2303\n * slice D): `environmentServiceProfileRunsMessageBroker` of its `serviceProfile`. Read by `wildo init` before scaffolding\n * a hosted application, whose descriptor must declare no RabbitMQ vhost on a host that runs no broker.\n *\n * A host with no readable `local` descriptor answers `true`, the broker every host ran before profiles existed: the\n * scaffold keeps its previous shape, and the hosted resolution then names what is wrong with the host.\n */\nexport async function readHostRunsMessageBroker(hostRoot: string): Promise<boolean> {\n try {\n const loaded = await loadAuthoredInfraEnvConfig(HOST_LOCAL_ENVIRONMENT_NAME, hostRoot);\n return environmentServiceProfileRunsMessageBroker(loaded?.config.serviceProfile);\n } catch {\n return true;\n }\n}\n\n/** The environment a hosted scaffold is written for: the local one (`infrastructure/local/`). */\nconst HOST_LOCAL_ENVIRONMENT_NAME = 'local';\n\n/** One authored environment: the directory name it lives under, and its loaded config. */\nexport interface LoadedNamedAuthoredInfraEnvConfig extends LoadedAuthoredInfraEnvConfig {\n envName: string;\n}\n\n/** An environment directory whose authored config failed to load, and why. */\nexport interface UnreadableAuthoredInfraEnvConfig {\n readonly envName: string;\n readonly error: unknown;\n}\n\n/**\n * One environment directory as {@link settleAllAuthoredInfraEnvConfigs} found it: loaded, or failing to load. Told apart\n * with `'error' in`, which narrows whether or not the compiling package checks nulls strictly.\n */\nexport type SettledAuthoredInfraEnvConfig = LoadedNamedAuthoredInfraEnvConfig | UnreadableAuthoredInfraEnvConfig;\n\n/**\n * Every environment the application authors: each directory of its infrastructure home that carries an authored\n * `wildo.infra.<local|remote>.config.ts`, loaded through {@link loadAuthoredInfraEnvConfig}. A directory without one is\n * not an environment and is skipped. Empty when the application has no infrastructure home.\n *\n * The ONE enumeration of an application's environments: the lockfile projections and the `config sync` servability\n * preflight (`loadAuthoredInfraEnvSelections`, #1693) and the schema planner's default adapter (#2708) all judge this\n * same population, so no reader can count one environment another misses. The dev companion cannot import this module\n * and restates the same walk for the same question (`assessApplicationSchemaPlanObligation`, #2724: is a baseline owed?);\n * change one, change both.\n *\n * SETTLED rather than thrown, so a reader that can still answer with the environments that did load decides that for\n * itself: the schema planner refuses only when an unreadable environment could change its answer.\n * {@link loadAllAuthoredInfraEnvConfigs} is the throwing form.\n */\nexport async function settleAllAuthoredInfraEnvConfigs(saasRoot: string): Promise<SettledAuthoredInfraEnvConfig[]> {\n const infraDir = resolveAppLayout(saasRoot).authoredInfrastructureHome;\n if (!existsSync(infraDir)) return [];\n const settled: SettledAuthoredInfraEnvConfig[] = [];\n for (const entry of readdirSync(infraDir, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n try {\n const authored = await loadAuthoredInfraEnvConfig(entry.name, saasRoot);\n if (authored) settled.push({ envName: entry.name, ...authored });\n } catch (error) {\n settled.push({ envName: entry.name, error });\n }\n }\n return settled;\n}\n\n/** {@link settleAllAuthoredInfraEnvConfigs}, throwing the first environment that failed to load. */\nexport async function loadAllAuthoredInfraEnvConfigs(saasRoot: string): Promise<LoadedNamedAuthoredInfraEnvConfig[]> {\n const loaded: LoadedNamedAuthoredInfraEnvConfig[] = [];\n for (const environment of await settleAllAuthoredInfraEnvConfigs(saasRoot)) {\n if ('error' in environment) throw environment.error;\n loaded.push(environment);\n }\n return loaded;\n}\n\n/**\n * Reason string when the authored infra config cannot serve as a config.json\n * fallback (currently: Atlas-backed environments require generated config.json\n * because authored infra config does not include Atlas API metadata or\n * external Mongo connection endpoints).\n */\nexport function getUnsupportedAuthoredConfigFallbackReason(\n envName: string,\n authoredConfigPath: string,\n authoredConfig: WildoInfraEnvConfig,\n): string | null {\n // Slice 4.B.0 (2026-05-07): Atlas detection now uses (source=MANAGED,\n // provider='atlas') instead of the legacy `source: ATLAS` enum value.\n // Same operational meaning — operator authored a managed Mongo whose\n // brand is Atlas; the generated config.json carries the Atlas API\n // metadata + external endpoints that the authored infra descriptor\n // doesn't include.\n const mongo = authoredConfig.backingServices.mongodb;\n if (mongo?.source === BackingServiceSource.MANAGED && mongo.provider === 'atlas') {\n return (\n `Cannot regenerate config for '${envName}' from authored infra descriptor at ${authoredConfigPath}: `\n + 'Atlas-backed environments require generated config.json because authored infra config '\n + 'does not include Atlas API metadata or external Mongo connection endpoints.'\n );\n }\n\n return null;\n}\n\n/**\n * Resolve the platform's database engine for an authored environment.\n *\n * **Precedence: an authored `database` block WINS; the inference below is the fallback.**\n *\n * The inference exists because the engine was historically not authorable at all — it lived only\n * as an answer to an interactive prompt in the machine-local `environments.json`. Every environment\n * predating the authored field relies on it, so it keeps its exact behaviour.\n *\n * What it cannot express, and why the authored field had to exist: the rule is\n * `postgresql && !mongodb`, while a PostgreSQL platform is REQUIRED to also declare\n * `backingServices.mongodb` (the bootstrap plane is Mongo-wired, and both this schema and\n * `env-vars-builder` refuse a PostgreSQL platform that renders no mongod). The intended state is\n * therefore `postgresql && mongodb`, which this function always resolves to MONGODB. It is not a\n * bug in the rule — it is a question the rule cannot be asked.\n *\n * This is the same inexpressibility Phase 5.1 fixed one layer down, where `needsLocalMongoDB` was\n * `engine === MONGODB && source === SELF` and became a union so that \"which containers render\"\n * stopped being collapsed into \"what engine is the platform\". The identical collapse survived here,\n * in \"what engine is the platform\" vs \"which services are declared\".\n *\n * **Deliberately NOT made smarter.** Widening it to \"postgresql present ⇒ PostgreSQL\" would flip\n * every environment that declares PostgreSQL as an APPLICATION-tier substrate — Wonder Todos'\n * `local` does exactly that today — into a PostgreSQL PLATFORM on its next `wildo config sync`.\n * A silent engine change on an existing environment is the worst outcome available here.\n */\nexport function resolveDatabaseChoiceFromInfraConfig(\n config: WildoInfraEnvConfig,\n): PlatformEnvConfigJson['database'] {\n if (config.database) {\n return config.database;\n }\n\n return inferDatabaseChoiceFromInfraConfig(config);\n}\n\n/**\n * The pre-authoring inference. Retained as the fallback for environments that author no `database`\n * block — see {@link resolveDatabaseChoiceFromInfraConfig} for the precedence and for why this\n * cannot express a PostgreSQL platform.\n */\nexport function inferDatabaseChoiceFromInfraConfig(\n config: WildoInfraEnvConfig,\n): PlatformEnvConfigJson['database'] {\n const postgresql = config.backingServices.postgresql;\n const mongodb = config.backingServices.mongodb;\n\n if (postgresql && !mongodb) {\n return {\n engine: DatabaseEngine.POSTGRESQL,\n source: postgresql.source,\n };\n }\n\n return {\n engine: DatabaseEngine.MONGODB,\n source: mongodb?.source ?? BackingServiceSource.SELF,\n };\n}\n\n/**\n * The bytes `config.json` holds: the one serialization every writer of the generated file uses (the local self-heal,\n * `config sync`, and the remote overlay of `loadConfigForSync`), so equal content is equal bytes and a file is\n * rewritten only when its content moves (#2311).\n */\nexport function serializeConfigJson(config: PlatformEnvConfigJson): string {\n return `${JSON.stringify(config, null, 2)}\\n`;\n}\n\n/**\n * Project a parsed `wildo.infra.<env>.config.ts` into the persisted\n * platform-level `environments/<env>/config.json` shape.\n *\n * `devCompanion` is intentionally NOT persisted here — see Slice 3 deep-review\n * M-5 note in `commands/config/sync.command.ts` for the dual-config-json\n * design rationale.\n */\nexport function buildConfigJsonFromInfraEnvConfig(config: WildoInfraEnvConfig): PlatformEnvConfigJson {\n const storage = config.backingServices.s3;\n const postgresql = config.backingServices.postgresql;\n\n return {\n type: config.locationType,\n runtime: config.runtime,\n runtimeEnvironment: config.runtimeEnvironment,\n /**\n * Always present here, never `undefined`: the authored schema resolves its own default from\n * `locationType` in the transform, so what reaches this projection is the environment's settled\n * answer rather than what the author happened to type.\n */\n localDataStorage: config.localDataStorage,\n /** Always present: the descriptor transform resolves `FULL` when nothing is authored (#2303). */\n serviceProfile: config.serviceProfile,\n database: resolveDatabaseChoiceFromInfraConfig(config),\n /**\n * The APPLICATION's engine — RESOLVED, never inferred and never left absent.\n *\n * Absence means PostgreSQL (`DEFAULT_APPLICATION_DATABASE_ENGINE`, #1571), and it is resolved HERE\n * so `config.json` always carries an explicit engine: every later reader of the file — the\n * bootstrap request, the e2e store probe — then sees the same answer without holding its own copy\n * of the default. Inferring it from which backing services are declared would resurrect exactly\n * the defect the authored field exists to remove, since `postgresql && mongodb` is both the normal\n * state and unresolvable by inference.\n *\n * ⚠️ THIS is the projection that writes `config.json`, not the `transform` in\n * `defineInfraEnvConfig`. Both exist and both must carry a new field: the transform feeds\n * in-process consumers, this one feeds the file every generator later reads. Adding the field to\n * only the transform (2026-08-19) produced a silently ABSENT key here — the reconcile reported\n * success and `applicationDatabase` simply was not in the written file.\n */\n applicationDatabase: { engine: resolveApplicationDatabaseEngine(config.applicationDatabase) },\n infrastructure: {\n storage: {\n provider: (storage?.provider ?? DEFAULT_PLATFORM_FILE_STORAGE_CONFIGURATION.PROVIDER) as 'minio',\n useSsl: storage?.endpoint?.startsWith('https://') ?? false,\n bucket: storage?.bucket ?? DEFAULT_PLATFORM_FILE_STORAGE_CONFIGURATION.BUCKET,\n },\n postgresql: {\n database: postgresql?.database ?? DEFAULT_PLATFORM_POSTGRESQL_CONFIGURATION.DATABASE,\n sslMode: DEFAULT_PLATFORM_POSTGRESQL_CONFIGURATION.SSL_MODE,\n },\n },\n publicDomain: config.publicDomain,\n serviceHosts: config.serviceHosts,\n cdn: config.cdn,\n platformStorage: config.platformStorage,\n platformKeyManagement: config.platformKeyManagement,\n systemsOfRecord: config.systemsOfRecord,\n kubernetes: config.kubernetes\n ? {\n namespace: config.kubernetes.namespace,\n ingressClass: config.kubernetes.ingressClass,\n services: config.kubernetes.services,\n }\n : undefined,\n remoteProvider: config.remoteProvider,\n infrastructureHost: config.infrastructureHost,\n backingServices: config.backingServices,\n serviceAuth: config.serviceAuth,\n logging: config.logging,\n observability: config.observability,\n providerSelection: config.providerSelection,\n email: config.email,\n agentContentGuardrails: config.agentContentGuardrails,\n ownershipDnsStandIn: config.ownershipDnsStandIn,\n applicationCreationVerification: config.applicationCreationVerification,\n };\n}\n"]}
@@ -6,6 +6,13 @@
6
6
  * under any `wildo local dev` running against it, so its supervisors hold their runtimes (and spend no crash budget)
7
7
  * until it ends, then relaunch them, and its compile watchers compile again. A synchronous install beats no heartbeat,
8
8
  * which is why the record carries the CLI's pid and a deadline instead.
9
+ *
10
+ * `--no-frozen-lockfile`, because both callers change the dependency configuration on purpose (`wildo update` rewrites
11
+ * the `@wildo-ai/*` pins, a provider install or removal its packages and overrides) and the install exists to bring the
12
+ * lockfile in line with it. pnpm freezes the lockfile whenever `CI` is set, so a plain `pnpm install` refused every
13
+ * `wildo update` run in CI with `ERR_PNPM_LOCKFILE_CONFIG_MISMATCH` (client creation run 44256325098, on GitHub Actions).
14
+ * spec-cite: https://pnpm.io/cli/install (fetched 2026-11-18) — "In a CI environment, installation fails if a lockfile is
15
+ * present but needs an update. To allow lockfile updates in CI, run pnpm install --no-frozen-lockfile."
9
16
  */
10
17
  export declare function runPnpmInstall(log: {
11
18
  info(message: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"package-install.service.d.ts","sourceRoot":"","sources":["../../../../src/services/framework/package-install.service.ts"],"names":[],"mappings":"AAUA;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE;IAAE,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAUtI;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE;IAAE,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAQjJ"}
1
+ {"version":3,"file":"package-install.service.d.ts","sourceRoot":"","sources":["../../../../src/services/framework/package-install.service.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE;IAAE,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAUtI;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE;IAAE,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAQjJ"}
@@ -14,11 +14,18 @@ import { PackageManagerCommand, spawnPackageManager } from './framework-update.s
14
14
  * under any `wildo local dev` running against it, so its supervisors hold their runtimes (and spend no crash budget)
15
15
  * until it ends, then relaunch them, and its compile watchers compile again. A synchronous install beats no heartbeat,
16
16
  * which is why the record carries the CLI's pid and a deadline instead.
17
+ *
18
+ * `--no-frozen-lockfile`, because both callers change the dependency configuration on purpose (`wildo update` rewrites
19
+ * the `@wildo-ai/*` pins, a provider install or removal its packages and overrides) and the install exists to bring the
20
+ * lockfile in line with it. pnpm freezes the lockfile whenever `CI` is set, so a plain `pnpm install` refused every
21
+ * `wildo update` run in CI with `ERR_PNPM_LOCKFILE_CONFIG_MISMATCH` (client creation run 44256325098, on GitHub Actions).
22
+ * spec-cite: https://pnpm.io/cli/install (fetched 2026-11-18) — "In a CI environment, installation fails if a lockfile is
23
+ * present but needs an update. To allow lockfile updates in CI, run pnpm install --no-frozen-lockfile."
17
24
  */
18
25
  export function runPnpmInstall(log, label, cwd) {
19
26
  log.info(` ${label}…`);
20
27
  return withDependencyInstallRecordSync(cwd, { initiator: `wildo ${label}` }, () => {
21
- const result = spawnPackageManager(PackageManagerCommand.PNPM, ['install'], { cwd, stdio: 'inherit' });
28
+ const result = spawnPackageManager(PackageManagerCommand.PNPM, ['install', '--no-frozen-lockfile'], { cwd, stdio: 'inherit' });
22
29
  if (result.status !== 0) {
23
30
  log.error(` ${label} failed (exit ${result.status ?? 'signal'}).`);
24
31
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"package-install.service.js","sourceRoot":"","sources":["../../../../src/services/framework/package-install.service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,+BAA+B,EAAE,MAAM,4CAA4C,CAAC;AAE7F,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAExF;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,GAAkE,EAAE,KAAa,EAAE,GAAW;IAC3H,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,GAAG,CAAC,CAAC;IACxB,OAAO,+BAA+B,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,SAAS,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE;QAChF,MAAM,MAAM,GAAG,mBAAmB,CAAC,qBAAqB,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QACvG,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,GAAG,CAAC,KAAK,CAAC,KAAK,KAAK,iBAAiB,MAAM,CAAC,MAAM,IAAI,QAAQ,IAAI,CAAC,CAAC;YACpE,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,GAAkE,EAAE,KAAwB,EAAE,GAAW;IACtI,GAAG,CAAC,IAAI,CAAC,qBAAqB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,mBAAmB,CAAC,qBAAqB,CAAC,IAAI,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IACvH,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,GAAG,CAAC,KAAK,CAAC,qBAAqB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,iBAAiB,MAAM,CAAC,MAAM,IAAI,QAAQ,IAAI,CAAC,CAAC;QAC9F,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["/**\n * `pnpm install` in an application, shared by `wildo update` and the registry's provider install (#2014).\n *\n * Its own module, calling `spawnPackageManager` through an import, so a test that replaces the package-manager spawn\n * on `framework-update.service` replaces it here too.\n */\nimport { withDependencyInstallRecordSync } from '@wildo-ai/platform-core-shared/dev-runtime';\n\nimport { PackageManagerCommand, spawnPackageManager } from './framework-update.service';\n\n/**\n * Run `pnpm install` in `cwd`, output streamed to the terminal. Returns whether it succeeded; the caller decides what a\n * failure means.\n *\n * Bracketed by the dependency-install record (#3552) when `cwd` is an application: the install re-creates `node_modules`\n * under any `wildo local dev` running against it, so its supervisors hold their runtimes (and spend no crash budget)\n * until it ends, then relaunch them, and its compile watchers compile again. A synchronous install beats no heartbeat,\n * which is why the record carries the CLI's pid and a deadline instead.\n */\nexport function runPnpmInstall(log: { info(message: string): void; error(message: string): void }, label: string, cwd: string): boolean {\n log.info(` ${label}…`);\n return withDependencyInstallRecordSync(cwd, { initiator: `wildo ${label}` }, () => {\n const result = spawnPackageManager(PackageManagerCommand.PNPM, ['install'], { cwd, stdio: 'inherit' });\n if (result.status !== 0) {\n log.error(` ${label} failed (exit ${result.status ?? 'signal'}).`);\n return false;\n }\n return true;\n });\n}\n\n/**\n * Run `pnpm rebuild -r <names>` in `cwd` (#2801): the install scripts of `names`, in every workspace package that has\n * them. Needed after their names enter `onlyBuiltDependencies` (pnpm-workspace.yaml): up to pnpm 10.24 an install that finds the package already\n * installed answers \"already up to date\" and runs nothing, even when the allow-list changed (measured on 10.6.4 to\n * 10.24.0, #3014). From 10.25.0 the install builds it itself, which `namesToRebuildAfterInstall` accounts for; a rebuild\n * with no install before it (the lockfile repair) is still what runs the script, on both.\n */\nexport function runPnpmRebuild(log: { info(message: string): void; error(message: string): void }, names: readonly string[], cwd: string): boolean {\n log.info(` pnpm rebuild -r ${names.join(' ')}…`);\n const result = spawnPackageManager(PackageManagerCommand.PNPM, ['rebuild', '-r', ...names], { cwd, stdio: 'inherit' });\n if (result.status !== 0) {\n log.error(` pnpm rebuild -r ${names.join(' ')} failed (exit ${result.status ?? 'signal'}).`);\n return false;\n }\n return true;\n}\n"]}
1
+ {"version":3,"file":"package-install.service.js","sourceRoot":"","sources":["../../../../src/services/framework/package-install.service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,+BAA+B,EAAE,MAAM,4CAA4C,CAAC;AAE7F,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAExF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,cAAc,CAAC,GAAkE,EAAE,KAAa,EAAE,GAAW;IAC3H,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,GAAG,CAAC,CAAC;IACxB,OAAO,+BAA+B,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,SAAS,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE;QAChF,MAAM,MAAM,GAAG,mBAAmB,CAAC,qBAAqB,CAAC,IAAI,EAAE,CAAC,SAAS,EAAE,sBAAsB,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAC/H,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,GAAG,CAAC,KAAK,CAAC,KAAK,KAAK,iBAAiB,MAAM,CAAC,MAAM,IAAI,QAAQ,IAAI,CAAC,CAAC;YACpE,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,GAAkE,EAAE,KAAwB,EAAE,GAAW;IACtI,GAAG,CAAC,IAAI,CAAC,qBAAqB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,mBAAmB,CAAC,qBAAqB,CAAC,IAAI,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IACvH,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,GAAG,CAAC,KAAK,CAAC,qBAAqB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,iBAAiB,MAAM,CAAC,MAAM,IAAI,QAAQ,IAAI,CAAC,CAAC;QAC9F,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["/**\n * `pnpm install` in an application, shared by `wildo update` and the registry's provider install (#2014).\n *\n * Its own module, calling `spawnPackageManager` through an import, so a test that replaces the package-manager spawn\n * on `framework-update.service` replaces it here too.\n */\nimport { withDependencyInstallRecordSync } from '@wildo-ai/platform-core-shared/dev-runtime';\n\nimport { PackageManagerCommand, spawnPackageManager } from './framework-update.service';\n\n/**\n * Run `pnpm install` in `cwd`, output streamed to the terminal. Returns whether it succeeded; the caller decides what a\n * failure means.\n *\n * Bracketed by the dependency-install record (#3552) when `cwd` is an application: the install re-creates `node_modules`\n * under any `wildo local dev` running against it, so its supervisors hold their runtimes (and spend no crash budget)\n * until it ends, then relaunch them, and its compile watchers compile again. A synchronous install beats no heartbeat,\n * which is why the record carries the CLI's pid and a deadline instead.\n *\n * `--no-frozen-lockfile`, because both callers change the dependency configuration on purpose (`wildo update` rewrites\n * the `@wildo-ai/*` pins, a provider install or removal its packages and overrides) and the install exists to bring the\n * lockfile in line with it. pnpm freezes the lockfile whenever `CI` is set, so a plain `pnpm install` refused every\n * `wildo update` run in CI with `ERR_PNPM_LOCKFILE_CONFIG_MISMATCH` (client creation run 44256325098, on GitHub Actions).\n * spec-cite: https://pnpm.io/cli/install (fetched 2026-11-18) — \"In a CI environment, installation fails if a lockfile is\n * present but needs an update. To allow lockfile updates in CI, run pnpm install --no-frozen-lockfile.\"\n */\nexport function runPnpmInstall(log: { info(message: string): void; error(message: string): void }, label: string, cwd: string): boolean {\n log.info(` ${label}…`);\n return withDependencyInstallRecordSync(cwd, { initiator: `wildo ${label}` }, () => {\n const result = spawnPackageManager(PackageManagerCommand.PNPM, ['install', '--no-frozen-lockfile'], { cwd, stdio: 'inherit' });\n if (result.status !== 0) {\n log.error(` ${label} failed (exit ${result.status ?? 'signal'}).`);\n return false;\n }\n return true;\n });\n}\n\n/**\n * Run `pnpm rebuild -r <names>` in `cwd` (#2801): the install scripts of `names`, in every workspace package that has\n * them. Needed after their names enter `onlyBuiltDependencies` (pnpm-workspace.yaml): up to pnpm 10.24 an install that finds the package already\n * installed answers \"already up to date\" and runs nothing, even when the allow-list changed (measured on 10.6.4 to\n * 10.24.0, #3014). From 10.25.0 the install builds it itself, which `namesToRebuildAfterInstall` accounts for; a rebuild\n * with no install before it (the lockfile repair) is still what runs the script, on both.\n */\nexport function runPnpmRebuild(log: { info(message: string): void; error(message: string): void }, names: readonly string[], cwd: string): boolean {\n log.info(` pnpm rebuild -r ${names.join(' ')}…`);\n const result = spawnPackageManager(PackageManagerCommand.PNPM, ['rebuild', '-r', ...names], { cwd, stdio: 'inherit' });\n if (result.status !== 0) {\n log.error(` pnpm rebuild -r ${names.join(' ')} failed (exit ${result.status ?? 'signal'}).`);\n return false;\n }\n return true;\n}\n"]}
@@ -24,7 +24,7 @@
24
24
  * No password and no token: the answers carry none, and a refusal is reduced to its status, type, message reference and
25
25
  * code, which the application's error envelope already sanitizes.
26
26
  */
27
- import { ProviderOAuth2RevocationOutcome, type LinkedProviderConnectionView } from '@wildo-ai/saas-models';
27
+ import { ProviderOAuth2RevocationOutcome, type LinkedProviderConnectionView, type ProviderGrantImportAnswer, type ProviderGrantTransferDocument, type ProviderGrantTransferOwner } from '@wildo-ai/saas-models';
28
28
  /** Where the running application's API and interactive frontend answer. */
29
29
  export interface ApplicationApiTarget {
30
30
  /** The backend's origin (`VITE_API_BASE_URL`), without the `/api/v1` prefix. */
@@ -120,6 +120,21 @@ export declare class ApplicationProviderConnectionClient {
120
120
  listConnections(): Promise<readonly LinkedProviderConnectionView[]>;
121
121
  /** Disconnect the application's own account at one connection: the rows deleted and what each vendor answered. */
122
122
  disconnect(connectionRef: string): Promise<ApplicationConnectionDisconnectAnswer>;
123
+ /**
124
+ * EXPORT one stored grant in its portable form (grant seeding, development and test only): the document holds tokens,
125
+ * so the caller writes it only where the operator asked. The application records the export.
126
+ */
127
+ exportGrant(input: {
128
+ owner: ProviderGrantTransferOwner;
129
+ connectionRef: string;
130
+ secretSlug?: string;
131
+ }): Promise<ProviderGrantTransferDocument>;
132
+ /** IMPORT an exported grant for `owner` (grant seeding): where it was stored. Never a token. */
133
+ importGrant(input: {
134
+ owner: ProviderGrantTransferOwner;
135
+ document: ProviderGrantTransferDocument;
136
+ replaceExisting?: boolean;
137
+ }): Promise<ProviderGrantImportAnswer>;
123
138
  /** End the session the CLI opened. Best-effort: a sign-out that fails leaves a session that expires on its own. */
124
139
  signOut(): Promise<void>;
125
140
  private authorized;
@@ -1 +1 @@
1
- {"version":3,"file":"application-provider-connection.service.d.ts","sourceRoot":"","sources":["../../../../src/services/registry/application-provider-connection.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAQL,+BAA+B,EAE/B,KAAK,4BAA4B,EAClC,MAAM,uBAAuB,CAAC;AAK/B,2EAA2E;AAC3E,MAAM,WAAW,oB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O,CAAC,SAAS,4BAA4B,EAAE,CAAC;IAMzE,kHAAkH;IAC5G,UAAU,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,qCAAqC,CAAC;IAKvF,mHAAmH;IAC7G,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAqBhB,UAAU;YAgBV,IAAI;IAKlB,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,GAAG;CAGZ;AAmBD;;;;GAIG;AACH,wBAAsB,2BAA2B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAShG;AAKD;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAU9D;AAED;;;;;GAKG;AACH,wBAAsB,gCAAgC,CACpD,OAAO,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,uBAAuB,CAAA;CAAE,EAC9H,SAAS,CAAC,EAAE,SAAS,GACpB,OAAO,CAAC,mCAAmC,CAAC,CAkB9C;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,SAAS,4BAA4B,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,4BAA4B,GAAG,SAAS,CAErJ;AAED,iHAAiH;AACjH,wBAAgB,qCAAqC,CAAC,UAAU,EAAE,4BAA4B,GAAG,MAAM,CAUtG;AAED,uEAAuE;AACvE,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAazF"}
1
+ {"version":3,"file":"application-provider-connection.service.d.ts","sourceRoot":"","sources":["../../../../src/services/registry/application-provider-connection.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAQL,+BAA+B,EAE/B,KAAK,4BAA4B,EACjC,KAAK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;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,SAAS,4BAA4B,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,4BAA4B,GAAG,SAAS,CAErJ;AAED,iHAAiH;AACjH,wBAAgB,qCAAqC,CAAC,UAAU,EAAE,4BAA4B,GAAG,MAAM,CAUtG;AAED,uEAAuE;AACvE,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAazF"}
@@ -170,6 +170,29 @@ export class ApplicationProviderConnectionClient {
170
170
  const path = MANUAL_CONTROLLER_ROUTES_URLS[ManualControllerRouteKey.PROVIDER_CONNECTION_APPLICATION_DISCONNECT].replace(':connectionRef', encodeURIComponent(connectionRef));
171
171
  return await this.authorized('DELETE', path, `disconnect '${connectionRef}'`);
172
172
  }
173
+ /**
174
+ * EXPORT one stored grant in its portable form (grant seeding, development and test only): the document holds tokens,
175
+ * so the caller writes it only where the operator asked. The application records the export.
176
+ */
177
+ async exportGrant(input) {
178
+ const answer = await this.authorized('POST', MANUAL_CONTROLLER_ROUTES_URLS[ManualControllerRouteKey.PROVIDER_CONNECTION_GRANT_EXPORT], 'export the grant', {
179
+ owner: input.owner,
180
+ connectionRef: input.connectionRef,
181
+ ...(input.secretSlug === undefined ? {} : { secretSlug: input.secretSlug }),
182
+ });
183
+ const document = answer.document;
184
+ if (document === undefined)
185
+ throw new ApplicationConnectionRequestRefusedError('The application answered no grant document.', 200);
186
+ return document;
187
+ }
188
+ /** IMPORT an exported grant for `owner` (grant seeding): where it was stored. Never a token. */
189
+ async importGrant(input) {
190
+ return await this.authorized('POST', MANUAL_CONTROLLER_ROUTES_URLS[ManualControllerRouteKey.PROVIDER_CONNECTION_GRANT_IMPORT], 'import the grant', {
191
+ owner: input.owner,
192
+ document: input.document,
193
+ ...(input.replaceExisting === true ? { replaceExisting: true } : {}),
194
+ });
195
+ }
173
196
  /** End the session the CLI opened. Best-effort: a sign-out that fails leaves a session that expires on its own. */
174
197
  async signOut() {
175
198
  if (this.accessToken === undefined)
@@ -1 +1 @@
1
- {"version":3,"file":"application-provider-connection.service.js","sourceRoot":"","sources":["../../../../src/services/registry/application-provider-connection.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EACL,eAAe,EACf,UAAU,EACV,kBAAkB,EAClB,6BAA6B,EAC7B,wBAAwB,EACxB,6BAA6B,EAC7B,iCAAiC,EACjC,+BAA+B,EAC/B,eAAe,GAEhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,0CAA0C,EAAE,sCAAsC,EAAE,MAAM,sCAAsC,CAAC;AAE1I,OAAO,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,oDAAoD,CAAC;AAgDlH;;;GAGG;AACH,MAAM,OAAO,wCAAyC,SAAQ,KAAK;IAGtD;IACA;IACA;IACA;IALX,YACE,OAAe,EACN,MAAc,EACd,SAAkB,EAClB,sBAA+B,EAC/B,IAAa;QAEtB,KAAK,CAAC,OAAO,CAAC,CAAC;QALN,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAS;QAClB,2BAAsB,GAAtB,sBAAsB,CAAS;QAC/B,SAAI,GAAJ,IAAI,CAAS;QAGtB,IAAI,CAAC,IAAI,GAAG,0CAA0C,CAAC;IACzD,CAAC;CACF;AAED,gFAAgF;AAChF,MAAM,OAAO,6BAA8B,SAAQ,KAAK;IACtD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAC;IAC9C,CAAC;CACF;AAID;;;;;GAKG;AACH,MAAM,yCAAyC,GAAG,MAAM,CAAC;AAEzD,MAAM,eAAe,GAAG,GAAgB,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,yCAAyC,CAAC,CAAC;AAE1G,oHAAoH;AACpH,SAAS,eAAe,CAAC,GAAW,EAAE,MAAc,EAAE,KAAwE;IAC5H,M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4E,CAAC;QACtF,KAAK,+BAA+B,CAAC,WAAW;YAC9C,OAAO,0EAA0E,CAAC;IACtF,CAAC;AACH,CAAC","sourcesContent":["/**\n * The APPLICATION's own provider connection, driven from the terminal against the RUNNING application (#3579).\n *\n * Not the same thing as `provider-connect.service.ts`. That one runs a vendor consent outside any application and keeps\n * the token in a local probe store, for a module's live proof. This one asks a running application to connect ITS OWN\n * vendor account (#3398): the grant lands in the application's `applicationProviderCredentials` store, sealed and renewed\n * there, and the CLI never sees a token.\n *\n * ## What the terminal does, and what the browser must\n *\n * The CLI signs in as the application's local administrator (the candidates the local-credentials rule names, the same\n * ones `wildo frontend look` uses), or, for a deployed application named with `--api-url`, as the administrator the\n * operator names and whose password they type. It calls `POST /connections/:providerRef/start` with an application target, and opens the\n * authorize URL it answers. The vendor then sends the browser back to the application's callback, which hands `state` and\n * `code` to the frontend, and the FRONTEND completes the attempt (`POST /connections/complete`) with its own bearer token.\n * The completion checks that the finisher is the initiator, so the browser must be signed in to the application as the\n * same administrator. That is deliberate in the engine (`handleComplete`) and is not worked around here.\n *\n * `listApplicationConnections` reads `GET /connections/linked?ownerScope=application` and `disconnect…` calls\n * `DELETE /connections/application/:connectionRef`. Both are refused by the application to anyone but a super-administrator.\n *\n * ## What is never printed\n *\n * No password and no token: the answers carry none, and a refusal is reduced to its status, type, message reference and\n * code, which the application's error envelope already sanitizes.\n */\n\nimport {\n AuthFactorLevel,\n AuthMethod,\n MAIN_API_BASE_PATH,\n MANUAL_CONTROLLER_ROUTES_URLS,\n ManualControllerRouteKey,\n ProviderConnectionRefusalCode,\n ProviderCredentialValidationState,\n ProviderOAuth2RevocationOutcome,\n WildoHeaderKeys,\n type LinkedProviderConnectionView,\n} from '@wildo-ai/saas-models';\nimport { ExternalProvider_Connection_DelegationMode, ExternalProvider_Connection_OwnerScope } from '@wildo-ai/external-connectors-models';\n\nimport { resolveInteractiveFrontend, signInCandidates } from '~wildo-cli/services/frontend/frontend-look.service';\n\n/** Where the running application's API and interactive frontend answer. */\nexport interface ApplicationApiTarget {\n /** The backend's origin (`VITE_API_BASE_URL`), without the `/api/v1` prefix. */\n readonly apiBaseUrl: string;\n /**\n * The frontend service name the callback sends the browser back to (`VITE_FRONTEND_SERVICE_NAME`). Absent only for a\n * remote target given without one, which can list and disconnect but not start a connection.\n */\n readonly frontendServiceName?: string;\n /** Where the person signs in, for the message telling them which browser session finishes the connection. */\n readonly frontendUrl: string;\n}\n\n/** One administrator identity to sign in with. `label` names where it came from; the password is never printed. */\nexport interface ApplicationSignInCandidate {\n readonly label: string;\n readonly email: string;\n readonly password: string;\n}\n\n/**\n * A DEPLOYED application, named by the operator (#3579): its API origin, its interactive frontend's service name, and the\n * administrator the operator signs in as, whose password they typed. The local stack's are read from the application\n * instead.\n */\nexport interface RemoteApplicationTarget {\n readonly apiUrl: string;\n readonly frontendServiceName?: string;\n readonly email: string;\n readonly password: string;\n}\n\n/** One row a disconnect deleted, as the application answers it. Never a token. */\nexport interface ApplicationConnectionDisconnectedRow {\n readonly credentialId: string;\n readonly providerRef: string;\n readonly secretSlug: string;\n readonly vendorRevocation: ProviderOAuth2RevocationOutcome;\n}\n\n/** The answer of `DELETE /connections/application/:connectionRef`. */\nexport interface ApplicationConnectionDisconnectAnswer {\n readonly connectionRef: string;\n readonly disconnected: readonly ApplicationConnectionDisconnectedRow[];\n}\n\n/**\n * The application refused a request: its status and the framework error envelope's stable fields. `message` is written\n * for the operator, from those fields only.\n */\nexport class ApplicationConnectionRequestRefusedError extends Error {\n constructor(\n message: string,\n readonly status: number,\n readonly errorType?: string,\n readonly customMessageReference?: string,\n readonly code?: string,\n ) {\n super(message);\n this.name = 'ApplicationConnectionRequestRefusedError';\n }\n}\n\n/** Why the CLI could not sign in. The password is never part of the message. */\nexport class ApplicationSignInRefusedError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ApplicationSignInRefusedError';\n }\n}\n\nexport type FetchLike = (url: string, init: { method: string; headers: Record<string, string>; body?: string; signal?: AbortSignal }) => Promise<Response>;\n\n/**\n * How long one request to the running application may take, its answer's body included (the signal stays armed while\n * the body is read). A person is waiting at the terminal. Sign-in and listing answer in well under a second; a disconnect\n * revokes the grant at each vendor before it answers, which is the slow case, and a minute leaves room for a vendor that\n * is slow without leaving the command hanging on one that never answers.\n */\nconst APPLICATION_CONNECTION_REQUEST_TIMEOUT_MS = 60_000;\n\nconst requestDeadline = (): AbortSignal => AbortSignal.timeout(APPLICATION_CONNECTION_REQUEST_TIMEOUT_MS);\n\n/** What the operator reads for a refusal the application answered: the cause, by the status and the stable code. */\nfunction describeRefusal(act: string, status: number, error: { type?: string; customMessageReference?: string; code?: string }): string {\n const fields = [error.type, error.customMessageReference, error.code].filter((field): field is string => typeof field === 'string' && field.length > 0);\n const detail = fields.length === 0 ? '' : ` (${fields.join(' · ')})`;\n const hint = status === 403\n ? ' The signed-in account is not a super-administrator of the application.'\n : status === 401\n ? ' The sign-in was not accepted.'\n : error.code === ProviderConnectionRefusalCode.CONNECTION_NOT_ADMISSIBLE\n ? ' The provider does not admit the application\\'s own connection (APPLICATION × SERVICE).'\n : error.code === ProviderConnectionRefusalCode.PROVIDER_NOT_CONNECTABLE\n ? ' The provider declares no OAuth2 consent; its application credential is set in the deployment environment.'\n : '';\n return `The application refused to ${act}: HTTP ${status}${detail}.${hint}`;\n}\n\n/**\n * A signed-in session with the running application, for the three application-connection acts. Holds the access token\n * and the refresh cookie in memory only, and signs out at {@link signOut}.\n */\nexport class ApplicationProviderConnectionClient {\n private accessToken: string | undefined;\n private refreshCookie: string | undefined;\n private signedInEmail: string | undefined;\n\n constructor(\n private readonly target: ApplicationApiTarget,\n // outbound-deadline: every call through fetchImpl passes `signal: requestDeadline()` in `init`.\n private readonly fetchImpl: FetchLike = (url, init) => fetch(url, init),\n ) {}\n\n /** Where the person signs in to finish a connection in the browser. */\n get frontendUrl(): string {\n return this.target.frontendUrl;\n }\n\n /** The administrator the session was opened as, after {@link signIn}. */\n get email(): string | undefined {\n return this.signedInEmail;\n }\n\n /**\n * Sign in with the first candidate the application accepts: identify, then the password factor through\n * `POST /auth/authenticate` (the step that mints the token; `/auth/authenticate/password` never does). An account that\n * asks a second factor is refused: the CLI does not answer one.\n */\n async signIn(candidates: readonly ApplicationSignInCandidate[]): Promise<ApplicationSignInCandidate> {\n if (candidates.length === 0) {\n throw new ApplicationSignInRefusedError('No local administrator credential found (the application\\'s infrastructure/local/secrets/secrets.json has no admin).');\n }\n const refusals: string[] = [];\n for (const candidate of candidates) {\n const identified = await this.post(MANUAL_CONTROLLER_ROUTES_URLS[ManualControllerRouteKey.AUTH_IDENTIFY], { email: candidate.email });\n const sessionId = (identified.body as { sessionId?: unknown } | undefined)?.sessionId;\n if (!identified.ok || typeof sessionId !== 'string') {\n refusals.push(`${candidate.label}: identify answered HTTP ${identified.status}`);\n continue;\n }\n const authenticated = await this.post(MANUAL_CONTROLLER_ROUTES_URLS[ManualControllerRouteKey.AUTH_AUTHENTICATE], {\n sessionId,\n email: candidate.email,\n password: candidate.password,\n method: AuthMethod.PASSWORD,\n factorLevel: AuthFactorLevel.FIRST,\n });\n const answer = authenticated.body as { accessToken?: unknown; requiresMFA?: unknown } | undefined;\n if (authenticated.ok && answer?.requiresMFA === true) {\n refusals.push(`${candidate.label}: the account asks a second factor, which the CLI does not answer`);\n continue;\n }\n if (!authenticated.ok || typeof answer?.accessToken !== 'string' || answer.accessToken.length === 0) {\n refusals.push(`${candidate.label}: the password was not accepted (HTTP ${authenticated.status})`);\n continue;\n }\n this.accessToken = answer.accessToken;\n this.refreshCookie = readCookieHeader(authenticated.response);\n this.signedInEmail = candidate.email;\n return candidate;\n }\n throw new ApplicationSignInRefusedError(`Could not sign in to ${this.target.apiBaseUrl} as an administrator: ${refusals.join('; ')}.`);\n }\n\n /**\n * Begin connecting the application's own account at `providerRef`: answers the vendor's authorize URL. The header naming\n * the frontend is what lets the callback send the browser back to the screen that completes the attempt.\n */\n async startConnection(providerRef: string, options: { scopes?: readonly string[]; connectionParameters?: Readonly<Record<string, string>> } = {}): Promise<string> {\n if (this.target.frontendServiceName === undefined) {\n throw new ApplicationSignInRefusedError('Name the application\\'s interactive frontend service (`--frontend-service`): the vendor sends the browser back to it, and it completes the connection.');\n }\n const path = MANUAL_CONTROLLER_ROUTES_URLS[ManualControllerRouteKey.PROVIDER_CONNECTION_START].replace(':providerRef', encodeURIComponent(providerRef));\n const answer = await this.authorized('POST', path, 'start the application\\'s connection', {\n target: { ownerScope: ExternalProvider_Connection_OwnerScope.APPLICATION, delegation: ExternalProvider_Connection_DelegationMode.SERVICE },\n ...(options.scopes === undefined ? {} : { scopes: [...options.scopes] }),\n ...(options.connectionParameters === undefined || Object.keys(options.connectionParameters).length === 0 ? {} : { connectionParameters: { ...options.connectionParameters } }),\n });\n const authorizeUrl = (answer as { authorizeUrl?: unknown }).authorizeUrl;\n if (typeof authorizeUrl !== 'string' || authorizeUrl.length === 0) {\n throw new ApplicationConnectionRequestRefusedError('The application answered no authorize URL.', 200);\n }\n return authorizeUrl;\n }\n\n /** The application's own connections: standing, scopes and the vendor's last refusal, never a token. */\n async listConnections(): Promise<readonly LinkedProviderConnectionView[]> {\n const path = `${MANUAL_CONTROLLER_ROUTES_URLS[ManualControllerRouteKey.PROVIDER_CONNECTION_LIST]}?ownerScope=${ExternalProvider_Connection_OwnerScope.APPLICATION}`;\n const answer = await this.authorized('GET', path, 'list the application\\'s connections');\n return ((answer as { connections?: LinkedProviderConnectionView[] }).connections ?? []);\n }\n\n /** Disconnect the application's own account at one connection: the rows deleted and what each vendor answered. */\n async disconnect(connectionRef: string): Promise<ApplicationConnectionDisconnectAnswer> {\n const path = MANUAL_CONTROLLER_ROUTES_URLS[ManualControllerRouteKey.PROVIDER_CONNECTION_APPLICATION_DISCONNECT].replace(':connectionRef', encodeURIComponent(connectionRef));\n return await this.authorized('DELETE', path, `disconnect '${connectionRef}'`) as ApplicationConnectionDisconnectAnswer;\n }\n\n /** End the session the CLI opened. Best-effort: a sign-out that fails leaves a session that expires on its own. */\n async signOut(): Promise<void> {\n if (this.accessToken === undefined) return;\n try {\n await this.fetchImpl(this.url(MANUAL_CONTROLLER_ROUTES_URLS[ManualControllerRouteKey.AUTH_LOGOUT]), {\n method: 'POST',\n headers: {\n ...this.baseHeaders(),\n [WildoHeaderKeys.AUTHORIZATION]: `Bearer ${this.accessToken}`,\n ...(this.refreshCookie === undefined ? {} : { cookie: this.refreshCookie }),\n },\n body: '{}',\n signal: requestDeadline(),\n });\n } catch {\n // The session expires on its own.\n } finally {\n this.accessToken = undefined;\n this.refreshCookie = undefined;\n }\n }\n\n private async authorized(method: string, path: string, act: string, body?: unknown): Promise<unknown> {\n if (this.accessToken === undefined) throw new ApplicationSignInRefusedError('Sign in before calling the application.');\n const response = await this.fetchImpl(this.url(path), {\n method,\n headers: { ...this.baseHeaders(), [WildoHeaderKeys.AUTHORIZATION]: `Bearer ${this.accessToken}` },\n ...(body === undefined ? {} : { body: JSON.stringify(body) }),\n signal: requestDeadline(),\n });\n const parsed = await readJson(response);\n if (!response.ok) {\n const error = ((parsed as { error?: { type?: string; customMessageReference?: string; code?: string } } | undefined)?.error) ?? {};\n throw new ApplicationConnectionRequestRefusedError(describeRefusal(act, response.status, error), response.status, error.type, error.customMessageReference, error.code);\n }\n return parsed ?? {};\n }\n\n private async post(path: string, body: unknown): Promise<{ ok: boolean; status: number; body: unknown; response: Response }> {\n const response = await this.fetchImpl(this.url(path), { method: 'POST', headers: this.baseHeaders(), body: JSON.stringify(body), signal: requestDeadline() });\n return { ok: response.ok, status: response.status, body: await readJson(response), response };\n }\n\n private baseHeaders(): Record<string, string> {\n return {\n 'content-type': 'application/json',\n // What the application's own frontend sends; the start leg records it so the callback returns the browser there.\n ...(this.target.frontendServiceName === undefined ? {} : { [WildoHeaderKeys.FRONTEND_SERVICE_NAME]: this.target.frontendServiceName }),\n };\n }\n\n private url(path: string): string {\n return `${this.target.apiBaseUrl.replace(/\\/+$/, '')}${MAIN_API_BASE_PATH}${path}`;\n }\n}\n\nasync function readJson(response: Response): Promise<unknown> {\n try {\n const text = await response.text();\n return text.length === 0 ? undefined : JSON.parse(text);\n } catch {\n return undefined;\n }\n}\n\n/** The cookies a sign-in set, as one `Cookie` header, so the sign-out can name the session it ends. */\nfunction readCookieHeader(response: Response): string | undefined {\n const headers = response.headers as Headers & { getSetCookie?: () => string[] };\n const setCookies = typeof headers.getSetCookie === 'function' ? headers.getSetCookie() : [];\n const pairs = setCookies.map((cookie) => cookie.split(';')[0]?.trim()).filter((pair): pair is string => typeof pair === 'string' && pair.includes('='));\n return pairs.length === 0 ? undefined : pairs.join('; ');\n}\n\n/**\n * Where the running application answers, from its interactive frontend's generated `.env` (`VITE_API_BASE_URL`,\n * `VITE_FRONTEND_SERVICE_NAME`) and its runtime address: the same resolution `wildo frontend look` makes. Refused when\n * either value is missing, because the callback could then not send the browser back to the screen that completes.\n */\nexport async function resolveApplicationApiTarget(appRoot: string): Promise<ApplicationApiTarget> {\n const frontend = await resolveInteractiveFrontend(appRoot);\n if (frontend.apiBaseUrl === null || frontend.serviceName === null) {\n throw new ApplicationSignInRefusedError(\n 'The interactive frontend\\'s .env declares no VITE_API_BASE_URL or VITE_FRONTEND_SERVICE_NAME, so the CLI cannot reach the application, '\n + 'and the vendor could not send the browser back to the screen that completes the connection. Run `wildo local init` (or regenerate the frontend env) and try again.',\n );\n }\n return { apiBaseUrl: frontend.apiBaseUrl, frontendServiceName: frontend.serviceName, frontendUrl: frontend.url };\n}\n\n/** The hosts a typed password may reach over plain http: this machine only. */\nconst LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]', '::1']);\n\n/**\n * Refuse to send a typed administrator password where it would travel in clear text: an `--api-url` must be https, or\n * http on this machine's loopback. A URL that does not parse is refused too.\n */\nexport function assertPasswordMayTravelTo(apiUrl: string): void {\n let parsed: URL;\n try {\n parsed = new URL(apiUrl);\n } catch {\n throw new ApplicationSignInRefusedError(`--api-url is not a URL: '${apiUrl}'.`);\n }\n if (parsed.protocol === 'https:') return;\n if (parsed.protocol === 'http:' && LOOPBACK_HOSTS.has(parsed.hostname)) return;\n throw new ApplicationSignInRefusedError(`--api-url must be https (or http on localhost): the administrator's password would travel to '${parsed.host}' in clear text.`);\n}\n\n/**\n * Open a signed-in session with the running application. Sign it out when done.\n *\n * - `remote`: a deployed application the operator names, signed in as the administrator they typed.\n * - otherwise the local stack, from the application root, signed in as its local administrator.\n */\nexport async function openApplicationConnectionSession(\n options: { readonly appRoot: string | null; readonly frameworkRoot: string | null; readonly remote?: RemoteApplicationTarget },\n fetchImpl?: FetchLike,\n): Promise<ApplicationProviderConnectionClient> {\n if (options.remote !== undefined) {\n assertPasswordMayTravelTo(options.remote.apiUrl);\n const apiBaseUrl = options.remote.apiUrl.replace(/\\/+$/, '').replace(new RegExp(`${MAIN_API_BASE_PATH}$`), '');\n const client = new ApplicationProviderConnectionClient({\n apiBaseUrl,\n ...(options.remote.frontendServiceName === undefined ? {} : { frontendServiceName: options.remote.frontendServiceName }),\n frontendUrl: 'the application\\'s own frontend',\n }, fetchImpl);\n await client.signIn([{ label: 'the administrator given', email: options.remote.email, password: options.remote.password }]);\n return client;\n }\n if (options.appRoot === null) {\n throw new ApplicationSignInRefusedError('No targeted app root detected. Run it from the application root (where wildo.saas.config.ts is), or name a deployed application with --api-url.');\n }\n const client = new ApplicationProviderConnectionClient(await resolveApplicationApiTarget(options.appRoot), fetchImpl);\n await client.signIn(signInCandidates(options.appRoot, options.frameworkRoot).map((candidate) => ({ label: candidate.source, email: candidate.email, password: candidate.password })));\n return client;\n}\n\n/**\n * The connection a ref names: the one keyed on it, else the one that serves it (a member of a declared shared connection\n * is disconnected through its base). `undefined` when the application holds none.\n */\nexport function findApplicationConnection(connections: readonly LinkedProviderConnectionView[], ref: string): LinkedProviderConnectionView | undefined {\n return connections.find((connection) => connection.connectionRef === ref) ?? connections.find((connection) => connection.servesRefs.includes(ref));\n}\n\n/** What a connection's standing means to the operator, from its validation state and whether it is turned on. */\nexport function describeApplicationConnectionStanding(connection: LinkedProviderConnectionView): string {\n if (!connection.enabled) return 'turned off';\n switch (connection.validationState) {\n case ProviderCredentialValidationState.VALID:\n return 'healthy (the vendor accepted it on its last use)';\n case ProviderCredentialValidationState.INVALID:\n return `refused by the vendor: reconnect it${connection.validationError === undefined ? '' : ` (${connection.validationError})`}`;\n case ProviderCredentialValidationState.UNVALIDATED:\n return 'connected, not yet used';\n }\n}\n\n/** What telling the vendor achieved, in words the operator acts on. */\nexport function describeVendorRevocation(outcome: ProviderOAuth2RevocationOutcome): string {\n switch (outcome) {\n case ProviderOAuth2RevocationOutcome.REVOKED:\n return 'the vendor withdrew the grant';\n case ProviderOAuth2RevocationOutcome.NOT_DECLARED:\n return 'the vendor was not told (the provider declares no revocation endpoint): remove the app at the vendor\\'s own console';\n case ProviderOAuth2RevocationOutcome.NOT_CONFIGURED:\n return 'the vendor was not told (the application\\'s client registration for it is unset): remove the app at the vendor\\'s console';\n case ProviderOAuth2RevocationOutcome.REFUSED:\n return 'the vendor refused the revocation: remove the app at the vendor\\'s console';\n case ProviderOAuth2RevocationOutcome.UNREACHABLE:\n return 'the vendor could not be reached: remove the app at the vendor\\'s console';\n }\n}\n"]}
1
+ {"version":3,"file":"application-provider-connection.service.js","sourceRoot":"","sources":["../../../../src/services/registry/application-provider-connection.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EACL,eAAe,EACf,UAAU,EACV,kBAAkB,EAClB,6BAA6B,EAC7B,wBAAwB,EACxB,6BAA6B,EAC7B,iCAAiC,EACjC,+BAA+B,EAC/B,eAAe,GAKhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,0CAA0C,EAAE,sCAAsC,EAAE,MAAM,sCAAsC,CAAC;AAE1I,OAAO,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,oDAAoD,CAAC;AAgDlH;;;GAGG;AACH,MAAM,OAAO,wCAAyC,SAAQ,KAAK;IAGtD;IACA;IACA;I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AAC,CAAC,KAAK,UAAU,CAAC,eAAe,GAAG,EAAE,CAAC;QACpI,KAAK,iCAAiC,CAAC,WAAW;YAChD,OAAO,yBAAyB,CAAC;IACrC,CAAC;AACH,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,wBAAwB,CAAC,OAAwC;IAC/E,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,+BAA+B,CAAC,OAAO;YAC1C,OAAO,+BAA+B,CAAC;QACzC,KAAK,+BAA+B,CAAC,YAAY;YAC/C,OAAO,qHAAqH,CAAC;QAC/H,KAAK,+BAA+B,CAAC,cAAc;YACjD,OAAO,2HAA2H,CAAC;QACrI,KAAK,+BAA+B,CAAC,OAAO;YAC1C,OAAO,4EAA4E,CAAC;QACtF,KAAK,+BAA+B,CAAC,WAAW;YAC9C,OAAO,0EAA0E,CAAC;IACtF,CAAC;AACH,CAAC","sourcesContent":["/**\n * The APPLICATION's own provider connection, driven from the terminal against the RUNNING application (#3579).\n *\n * Not the same thing as `provider-connect.service.ts`. That one runs a vendor consent outside any application and keeps\n * the token in a local probe store, for a module's live proof. This one asks a running application to connect ITS OWN\n * vendor account (#3398): the grant lands in the application's `applicationProviderCredentials` store, sealed and renewed\n * there, and the CLI never sees a token.\n *\n * ## What the terminal does, and what the browser must\n *\n * The CLI signs in as the application's local administrator (the candidates the local-credentials rule names, the same\n * ones `wildo frontend look` uses), or, for a deployed application named with `--api-url`, as the administrator the\n * operator names and whose password they type. It calls `POST /connections/:providerRef/start` with an application target, and opens the\n * authorize URL it answers. The vendor then sends the browser back to the application's callback, which hands `state` and\n * `code` to the frontend, and the FRONTEND completes the attempt (`POST /connections/complete`) with its own bearer token.\n * The completion checks that the finisher is the initiator, so the browser must be signed in to the application as the\n * same administrator. That is deliberate in the engine (`handleComplete`) and is not worked around here.\n *\n * `listApplicationConnections` reads `GET /connections/linked?ownerScope=application` and `disconnect…` calls\n * `DELETE /connections/application/:connectionRef`. Both are refused by the application to anyone but a super-administrator.\n *\n * ## What is never printed\n *\n * No password and no token: the answers carry none, and a refusal is reduced to its status, type, message reference and\n * code, which the application's error envelope already sanitizes.\n */\n\nimport {\n AuthFactorLevel,\n AuthMethod,\n MAIN_API_BASE_PATH,\n MANUAL_CONTROLLER_ROUTES_URLS,\n ManualControllerRouteKey,\n ProviderConnectionRefusalCode,\n ProviderCredentialValidationState,\n ProviderOAuth2RevocationOutcome,\n WildoHeaderKeys,\n type LinkedProviderConnectionView,\n type ProviderGrantImportAnswer,\n type ProviderGrantTransferDocument,\n type ProviderGrantTransferOwner,\n} from '@wildo-ai/saas-models';\nimport { ExternalProvider_Connection_DelegationMode, ExternalProvider_Connection_OwnerScope } from '@wildo-ai/external-connectors-models';\n\nimport { resolveInteractiveFrontend, signInCandidates } from '~wildo-cli/services/frontend/frontend-look.service';\n\n/** Where the running application's API and interactive frontend answer. */\nexport interface ApplicationApiTarget {\n /** The backend's origin (`VITE_API_BASE_URL`), without the `/api/v1` prefix. */\n readonly apiBaseUrl: string;\n /**\n * The frontend service name the callback sends the browser back to (`VITE_FRONTEND_SERVICE_NAME`). Absent only for a\n * remote target given without one, which can list and disconnect but not start a connection.\n */\n readonly frontendServiceName?: string;\n /** Where the person signs in, for the message telling them which browser session finishes the connection. */\n readonly frontendUrl: string;\n}\n\n/** One administrator identity to sign in with. `label` names where it came from; the password is never printed. */\nexport interface ApplicationSignInCandidate {\n readonly label: string;\n readonly email: string;\n readonly password: string;\n}\n\n/**\n * A DEPLOYED application, named by the operator (#3579): its API origin, its interactive frontend's service name, and the\n * administrator the operator signs in as, whose password they typed. The local stack's are read from the application\n * instead.\n */\nexport interface RemoteApplicationTarget {\n readonly apiUrl: string;\n readonly frontendServiceName?: string;\n readonly email: string;\n readonly password: string;\n}\n\n/** One row a disconnect deleted, as the application answers it. Never a token. */\nexport interface ApplicationConnectionDisconnectedRow {\n readonly credentialId: string;\n readonly providerRef: string;\n readonly secretSlug: string;\n readonly vendorRevocation: ProviderOAuth2RevocationOutcome;\n}\n\n/** The answer of `DELETE /connections/application/:connectionRef`. */\nexport interface ApplicationConnectionDisconnectAnswer {\n readonly connectionRef: string;\n readonly disconnected: readonly ApplicationConnectionDisconnectedRow[];\n}\n\n/**\n * The application refused a request: its status and the framework error envelope's stable fields. `message` is written\n * for the operator, from those fields only.\n */\nexport class ApplicationConnectionRequestRefusedError extends Error {\n constructor(\n message: string,\n readonly status: number,\n readonly errorType?: string,\n readonly customMessageReference?: string,\n readonly code?: string,\n ) {\n super(message);\n this.name = 'ApplicationConnectionRequestRefusedError';\n }\n}\n\n/** Why the CLI could not sign in. The password is never part of the message. */\nexport class ApplicationSignInRefusedError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ApplicationSignInRefusedError';\n }\n}\n\nexport type FetchLike = (url: string, init: { method: string; headers: Record<string, string>; body?: string; signal?: AbortSignal }) => Promise<Response>;\n\n/**\n * How long one request to the running application may take, its answer's body included (the signal stays armed while\n * the body is read). A person is waiting at the terminal. Sign-in and listing answer in well under a second; a disconnect\n * revokes the grant at each vendor before it answers, which is the slow case, and a minute leaves room for a vendor that\n * is slow without leaving the command hanging on one that never answers.\n */\nconst APPLICATION_CONNECTION_REQUEST_TIMEOUT_MS = 60_000;\n\nconst requestDeadline = (): AbortSignal => AbortSignal.timeout(APPLICATION_CONNECTION_REQUEST_TIMEOUT_MS);\n\n/** What the operator reads for a refusal the application answered: the cause, by the status and the stable code. */\nfunction describeRefusal(act: string, status: number, error: { type?: string; customMessageReference?: string; code?: string }): string {\n const fields = [error.type, error.customMessageReference, error.code].filter((field): field is string => typeof field === 'string' && field.length > 0);\n const detail = fields.length === 0 ? '' : ` (${fields.join(' · ')})`;\n const hint = status === 403\n ? ' The signed-in account is not a super-administrator of the application.'\n : status === 401\n ? ' The sign-in was not accepted.'\n : error.code === ProviderConnectionRefusalCode.CONNECTION_NOT_ADMISSIBLE\n ? ' The provider does not admit the application\\'s own connection (APPLICATION × SERVICE).'\n : error.code === ProviderConnectionRefusalCode.PROVIDER_NOT_CONNECTABLE\n ? ' The provider declares no OAuth2 consent; its application credential is set in the deployment environment.'\n : '';\n return `The application refused to ${act}: HTTP ${status}${detail}.${hint}`;\n}\n\n/**\n * A signed-in session with the running application, for the three application-connection acts. Holds the access token\n * and the refresh cookie in memory only, and signs out at {@link signOut}.\n */\nexport class ApplicationProviderConnectionClient {\n private accessToken: string | undefined;\n private refreshCookie: string | undefined;\n private signedInEmail: string | undefined;\n\n constructor(\n private readonly target: ApplicationApiTarget,\n // outbound-deadline: every call through fetchImpl passes `signal: requestDeadline()` in `init`.\n private readonly fetchImpl: FetchLike = (url, init) => fetch(url, init),\n ) {}\n\n /** Where the person signs in to finish a connection in the browser. */\n get frontendUrl(): string {\n return this.target.frontendUrl;\n }\n\n /** The administrator the session was opened as, after {@link signIn}. */\n get email(): string | undefined {\n return this.signedInEmail;\n }\n\n /**\n * Sign in with the first candidate the application accepts: identify, then the password factor through\n * `POST /auth/authenticate` (the step that mints the token; `/auth/authenticate/password` never does). An account that\n * asks a second factor is refused: the CLI does not answer one.\n */\n async signIn(candidates: readonly ApplicationSignInCandidate[]): Promise<ApplicationSignInCandidate> {\n if (candidates.length === 0) {\n throw new ApplicationSignInRefusedError('No local administrator credential found (the application\\'s infrastructure/local/secrets/secrets.json has no admin).');\n }\n const refusals: string[] = [];\n for (const candidate of candidates) {\n const identified = await this.post(MANUAL_CONTROLLER_ROUTES_URLS[ManualControllerRouteKey.AUTH_IDENTIFY], { email: candidate.email });\n const sessionId = (identified.body as { sessionId?: unknown } | undefined)?.sessionId;\n if (!identified.ok || typeof sessionId !== 'string') {\n refusals.push(`${candidate.label}: identify answered HTTP ${identified.status}`);\n continue;\n }\n const authenticated = await this.post(MANUAL_CONTROLLER_ROUTES_URLS[ManualControllerRouteKey.AUTH_AUTHENTICATE], {\n sessionId,\n email: candidate.email,\n password: candidate.password,\n method: AuthMethod.PASSWORD,\n factorLevel: AuthFactorLevel.FIRST,\n });\n const answer = authenticated.body as { accessToken?: unknown; requiresMFA?: unknown } | undefined;\n if (authenticated.ok && answer?.requiresMFA === true) {\n refusals.push(`${candidate.label}: the account asks a second factor, which the CLI does not answer`);\n continue;\n }\n if (!authenticated.ok || typeof answer?.accessToken !== 'string' || answer.accessToken.length === 0) {\n refusals.push(`${candidate.label}: the password was not accepted (HTTP ${authenticated.status})`);\n continue;\n }\n this.accessToken = answer.accessToken;\n this.refreshCookie = readCookieHeader(authenticated.response);\n this.signedInEmail = candidate.email;\n return candidate;\n }\n throw new ApplicationSignInRefusedError(`Could not sign in to ${this.target.apiBaseUrl} as an administrator: ${refusals.join('; ')}.`);\n }\n\n /**\n * Begin connecting the application's own account at `providerRef`: answers the vendor's authorize URL. The header naming\n * the frontend is what lets the callback send the browser back to the screen that completes the attempt.\n */\n async startConnection(providerRef: string, options: { scopes?: readonly string[]; connectionParameters?: Readonly<Record<string, string>> } = {}): Promise<string> {\n if (this.target.frontendServiceName === undefined) {\n throw new ApplicationSignInRefusedError('Name the application\\'s interactive frontend service (`--frontend-service`): the vendor sends the browser back to it, and it completes the connection.');\n }\n const path = MANUAL_CONTROLLER_ROUTES_URLS[ManualControllerRouteKey.PROVIDER_CONNECTION_START].replace(':providerRef', encodeURIComponent(providerRef));\n const answer = await this.authorized('POST', path, 'start the application\\'s connection', {\n target: { ownerScope: ExternalProvider_Connection_OwnerScope.APPLICATION, delegation: ExternalProvider_Connection_DelegationMode.SERVICE },\n ...(options.scopes === undefined ? {} : { scopes: [...options.scopes] }),\n ...(options.connectionParameters === undefined || Object.keys(options.connectionParameters).length === 0 ? {} : { connectionParameters: { ...options.connectionParameters } }),\n });\n const authorizeUrl = (answer as { authorizeUrl?: unknown }).authorizeUrl;\n if (typeof authorizeUrl !== 'string' || authorizeUrl.length === 0) {\n throw new ApplicationConnectionRequestRefusedError('The application answered no authorize URL.', 200);\n }\n return authorizeUrl;\n }\n\n /** The application's own connections: standing, scopes and the vendor's last refusal, never a token. */\n async listConnections(): Promise<readonly LinkedProviderConnectionView[]> {\n const path = `${MANUAL_CONTROLLER_ROUTES_URLS[ManualControllerRouteKey.PROVIDER_CONNECTION_LIST]}?ownerScope=${ExternalProvider_Connection_OwnerScope.APPLICATION}`;\n const answer = await this.authorized('GET', path, 'list the application\\'s connections');\n return ((answer as { connections?: LinkedProviderConnectionView[] }).connections ?? []);\n }\n\n /** Disconnect the application's own account at one connection: the rows deleted and what each vendor answered. */\n async disconnect(connectionRef: string): Promise<ApplicationConnectionDisconnectAnswer> {\n const path = MANUAL_CONTROLLER_ROUTES_URLS[ManualControllerRouteKey.PROVIDER_CONNECTION_APPLICATION_DISCONNECT].replace(':connectionRef', encodeURIComponent(connectionRef));\n return await this.authorized('DELETE', path, `disconnect '${connectionRef}'`) as ApplicationConnectionDisconnectAnswer;\n }\n\n /**\n * EXPORT one stored grant in its portable form (grant seeding, development and test only): the document holds tokens,\n * so the caller writes it only where the operator asked. The application records the export.\n */\n async exportGrant(input: { owner: ProviderGrantTransferOwner; connectionRef: string; secretSlug?: string }): Promise<ProviderGrantTransferDocument> {\n const answer = await this.authorized('POST', MANUAL_CONTROLLER_ROUTES_URLS[ManualControllerRouteKey.PROVIDER_CONNECTION_GRANT_EXPORT], 'export the grant', {\n owner: input.owner,\n connectionRef: input.connectionRef,\n ...(input.secretSlug === undefined ? {} : { secretSlug: input.secretSlug }),\n });\n const document = (answer as { document?: ProviderGrantTransferDocument }).document;\n if (document === undefined) throw new ApplicationConnectionRequestRefusedError('The application answered no grant document.', 200);\n return document;\n }\n\n /** IMPORT an exported grant for `owner` (grant seeding): where it was stored. Never a token. */\n async importGrant(input: { owner: ProviderGrantTransferOwner; document: ProviderGrantTransferDocument; replaceExisting?: boolean }): Promise<ProviderGrantImportAnswer> {\n return await this.authorized('POST', MANUAL_CONTROLLER_ROUTES_URLS[ManualControllerRouteKey.PROVIDER_CONNECTION_GRANT_IMPORT], 'import the grant', {\n owner: input.owner,\n document: input.document,\n ...(input.replaceExisting === true ? { replaceExisting: true } : {}),\n }) as ProviderGrantImportAnswer;\n }\n\n /** End the session the CLI opened. Best-effort: a sign-out that fails leaves a session that expires on its own. */\n async signOut(): Promise<void> {\n if (this.accessToken === undefined) return;\n try {\n await this.fetchImpl(this.url(MANUAL_CONTROLLER_ROUTES_URLS[ManualControllerRouteKey.AUTH_LOGOUT]), {\n method: 'POST',\n headers: {\n ...this.baseHeaders(),\n [WildoHeaderKeys.AUTHORIZATION]: `Bearer ${this.accessToken}`,\n ...(this.refreshCookie === undefined ? {} : { cookie: this.refreshCookie }),\n },\n body: '{}',\n signal: requestDeadline(),\n });\n } catch {\n // The session expires on its own.\n } finally {\n this.accessToken = undefined;\n this.refreshCookie = undefined;\n }\n }\n\n private async authorized(method: string, path: string, act: string, body?: unknown): Promise<unknown> {\n if (this.accessToken === undefined) throw new ApplicationSignInRefusedError('Sign in before calling the application.');\n const response = await this.fetchImpl(this.url(path), {\n method,\n headers: { ...this.baseHeaders(), [WildoHeaderKeys.AUTHORIZATION]: `Bearer ${this.accessToken}` },\n ...(body === undefined ? {} : { body: JSON.stringify(body) }),\n signal: requestDeadline(),\n });\n const parsed = await readJson(response);\n if (!response.ok) {\n const error = ((parsed as { error?: { type?: string; customMessageReference?: string; code?: string } } | undefined)?.error) ?? {};\n throw new ApplicationConnectionRequestRefusedError(describeRefusal(act, response.status, error), response.status, error.type, error.customMessageReference, error.code);\n }\n return parsed ?? {};\n }\n\n private async post(path: string, body: unknown): Promise<{ ok: boolean; status: number; body: unknown; response: Response }> {\n const response = await this.fetchImpl(this.url(path), { method: 'POST', headers: this.baseHeaders(), body: JSON.stringify(body), signal: requestDeadline() });\n return { ok: response.ok, status: response.status, body: await readJson(response), response };\n }\n\n private baseHeaders(): Record<string, string> {\n return {\n 'content-type': 'application/json',\n // What the application's own frontend sends; the start leg records it so the callback returns the browser there.\n ...(this.target.frontendServiceName === undefined ? {} : { [WildoHeaderKeys.FRONTEND_SERVICE_NAME]: this.target.frontendServiceName }),\n };\n }\n\n private url(path: string): string {\n return `${this.target.apiBaseUrl.replace(/\\/+$/, '')}${MAIN_API_BASE_PATH}${path}`;\n }\n}\n\nasync function readJson(response: Response): Promise<unknown> {\n try {\n const text = await response.text();\n return text.length === 0 ? undefined : JSON.parse(text);\n } catch {\n return undefined;\n }\n}\n\n/** The cookies a sign-in set, as one `Cookie` header, so the sign-out can name the session it ends. */\nfunction readCookieHeader(response: Response): string | undefined {\n const headers = response.headers as Headers & { getSetCookie?: () => string[] };\n const setCookies = typeof headers.getSetCookie === 'function' ? headers.getSetCookie() : [];\n const pairs = setCookies.map((cookie) => cookie.split(';')[0]?.trim()).filter((pair): pair is string => typeof pair === 'string' && pair.includes('='));\n return pairs.length === 0 ? undefined : pairs.join('; ');\n}\n\n/**\n * Where the running application answers, from its interactive frontend's generated `.env` (`VITE_API_BASE_URL`,\n * `VITE_FRONTEND_SERVICE_NAME`) and its runtime address: the same resolution `wildo frontend look` makes. Refused when\n * either value is missing, because the callback could then not send the browser back to the screen that completes.\n */\nexport async function resolveApplicationApiTarget(appRoot: string): Promise<ApplicationApiTarget> {\n const frontend = await resolveInteractiveFrontend(appRoot);\n if (frontend.apiBaseUrl === null || frontend.serviceName === null) {\n throw new ApplicationSignInRefusedError(\n 'The interactive frontend\\'s .env declares no VITE_API_BASE_URL or VITE_FRONTEND_SERVICE_NAME, so the CLI cannot reach the application, '\n + 'and the vendor could not send the browser back to the screen that completes the connection. Run `wildo local init` (or regenerate the frontend env) and try again.',\n );\n }\n return { apiBaseUrl: frontend.apiBaseUrl, frontendServiceName: frontend.serviceName, frontendUrl: frontend.url };\n}\n\n/** The hosts a typed password may reach over plain http: this machine only. */\nconst LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]', '::1']);\n\n/**\n * Refuse to send a typed administrator password where it would travel in clear text: an `--api-url` must be https, or\n * http on this machine's loopback. A URL that does not parse is refused too.\n */\nexport function assertPasswordMayTravelTo(apiUrl: string): void {\n let parsed: URL;\n try {\n parsed = new URL(apiUrl);\n } catch {\n throw new ApplicationSignInRefusedError(`--api-url is not a URL: '${apiUrl}'.`);\n }\n if (parsed.protocol === 'https:') return;\n if (parsed.protocol === 'http:' && LOOPBACK_HOSTS.has(parsed.hostname)) return;\n throw new ApplicationSignInRefusedError(`--api-url must be https (or http on localhost): the administrator's password would travel to '${parsed.host}' in clear text.`);\n}\n\n/**\n * Open a signed-in session with the running application. Sign it out when done.\n *\n * - `remote`: a deployed application the operator names, signed in as the administrator they typed.\n * - otherwise the local stack, from the application root, signed in as its local administrator.\n */\nexport async function openApplicationConnectionSession(\n options: { readonly appRoot: string | null; readonly frameworkRoot: string | null; readonly remote?: RemoteApplicationTarget },\n fetchImpl?: FetchLike,\n): Promise<ApplicationProviderConnectionClient> {\n if (options.remote !== undefined) {\n assertPasswordMayTravelTo(options.remote.apiUrl);\n const apiBaseUrl = options.remote.apiUrl.replace(/\\/+$/, '').replace(new RegExp(`${MAIN_API_BASE_PATH}$`), '');\n const client = new ApplicationProviderConnectionClient({\n apiBaseUrl,\n ...(options.remote.frontendServiceName === undefined ? {} : { frontendServiceName: options.remote.frontendServiceName }),\n frontendUrl: 'the application\\'s own frontend',\n }, fetchImpl);\n await client.signIn([{ label: 'the administrator given', email: options.remote.email, password: options.remote.password }]);\n return client;\n }\n if (options.appRoot === null) {\n throw new ApplicationSignInRefusedError('No targeted app root detected. Run it from the application root (where wildo.saas.config.ts is), or name a deployed application with --api-url.');\n }\n const client = new ApplicationProviderConnectionClient(await resolveApplicationApiTarget(options.appRoot), fetchImpl);\n await client.signIn(signInCandidates(options.appRoot, options.frameworkRoot).map((candidate) => ({ label: candidate.source, email: candidate.email, password: candidate.password })));\n return client;\n}\n\n/**\n * The connection a ref names: the one keyed on it, else the one that serves it (a member of a declared shared connection\n * is disconnected through its base). `undefined` when the application holds none.\n */\nexport function findApplicationConnection(connections: readonly LinkedProviderConnectionView[], ref: string): LinkedProviderConnectionView | undefined {\n return connections.find((connection) => connection.connectionRef === ref) ?? connections.find((connection) => connection.servesRefs.includes(ref));\n}\n\n/** What a connection's standing means to the operator, from its validation state and whether it is turned on. */\nexport function describeApplicationConnectionStanding(connection: LinkedProviderConnectionView): string {\n if (!connection.enabled) return 'turned off';\n switch (connection.validationState) {\n case ProviderCredentialValidationState.VALID:\n return 'healthy (the vendor accepted it on its last use)';\n case ProviderCredentialValidationState.INVALID:\n return `refused by the vendor: reconnect it${connection.validationError === undefined ? '' : ` (${connection.validationError})`}`;\n case ProviderCredentialValidationState.UNVALIDATED:\n return 'connected, not yet used';\n }\n}\n\n/** What telling the vendor achieved, in words the operator acts on. */\nexport function describeVendorRevocation(outcome: ProviderOAuth2RevocationOutcome): string {\n switch (outcome) {\n case ProviderOAuth2RevocationOutcome.REVOKED:\n return 'the vendor withdrew the grant';\n case ProviderOAuth2RevocationOutcome.NOT_DECLARED:\n return 'the vendor was not told (the provider declares no revocation endpoint): remove the app at the vendor\\'s own console';\n case ProviderOAuth2RevocationOutcome.NOT_CONFIGURED:\n return 'the vendor was not told (the application\\'s client registration for it is unset): remove the app at the vendor\\'s console';\n case ProviderOAuth2RevocationOutcome.REFUSED:\n return 'the vendor refused the revocation: remove the app at the vendor\\'s console';\n case ProviderOAuth2RevocationOutcome.UNREACHABLE:\n return 'the vendor could not be reached: remove the app at the vendor\\'s console';\n }\n}\n"]}
@@ -0,0 +1,48 @@
1
+ import { ProviderGrantTransferRefusalCode, type ProviderGrantTransferDocument, type ProviderGrantTransferOwner } from '@wildo-ai/saas-models';
2
+ /** What the operator types for `--owner`, by scope: the prefix before the colon. */
3
+ export declare enum GrantTransferOwnerPrefix {
4
+ USER = "user",
5
+ ORGANIZATION = "organization",
6
+ APPLICATION = "application"
7
+ }
8
+ /**
9
+ * Read `--owner`: `user:<email>`, `organization:<id or slug>`, or `application`. Throws, naming the forms, on anything
10
+ * else.
11
+ */
12
+ export declare function parseGrantTransferOwner(text: string): ProviderGrantTransferOwner;
13
+ /** The owner, as a person reads it. */
14
+ export declare function describeGrantTransferOwner(owner: ProviderGrantTransferOwner): string;
15
+ /**
16
+ * Refuse unless the application answers on this machine. A grant transfer is for a framework or application
17
+ * developer's LOCAL stack (and the QA VM's, which is one); a deployed application is never its target.
18
+ */
19
+ export declare function assertLocalGrantTransferTarget(apiBaseUrl: string): void;
20
+ /** Where `export` writes the document: a file (created 0600), or stdout. */
21
+ export interface GrantDocumentDestination {
22
+ /** A path, or `-` / undefined for stdout. */
23
+ readonly out?: string;
24
+ /** stdout is a terminal. */
25
+ readonly stdoutIsTerminal: boolean;
26
+ /** The operator asked for the document on the terminal (`--to-terminal`). */
27
+ readonly toTerminal: boolean;
28
+ }
29
+ /**
30
+ * Write the document where the operator asked. A file is created with mode 0600 BEFORE anything is written (and an
31
+ * existing file is re-moded 0600 before it is truncated), so the tokens are never readable by another user even for an
32
+ * instant. stdout is refused when it is a terminal, unless `toTerminal`: a token on the screen is a token in the
33
+ * scrollback, a screen share and a terminal recording.
34
+ *
35
+ * @returns where it went, for the message.
36
+ */
37
+ export declare function writeGrantTransferDocument(document: ProviderGrantTransferDocument, destination: GrantDocumentDestination, writeStdout?: (text: string) => void): string;
38
+ /** Read a document from a file, or from stdin when `from` is `-`; refuses anything that is not an export of this format. */
39
+ export declare function readGrantTransferDocument(from: string, readStdin?: () => string): ProviderGrantTransferDocument;
40
+ /**
41
+ * What to do next, for each refusal the transfer routes answer WITH a code on the wire: a 400 or a 409. The two 404s
42
+ * (`OWNER_NOT_FOUND`, `GRANT_NOT_FOUND`) carry no code to a client, so they have no entry here; the CLI names them by
43
+ * their status and message reference instead.
44
+ */
45
+ export declare const GRANT_TRANSFER_REFUSAL_HINTS: Readonly<Partial<Record<ProviderGrantTransferRefusalCode, string>>>;
46
+ /** The hint for a refusal's code, when the code is one of the transfer routes'. */
47
+ export declare function grantTransferRefusalHint(code: string | undefined): string | undefined;
48
+ //# sourceMappingURL=provider-grant-transfer.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-grant-transfer.service.d.ts","sourceRoot":"","sources":["../../../../src/services/registry/provider-grant-transfer.service.ts"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