@codemation/host 0.2.5 → 0.3.0

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 (109) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/{AppConfigFactory-CqKWXqOm.js → AppConfigFactory-BPp02HMv.js} +82 -5
  3. package/dist/{AppConfigFactory-CqKWXqOm.js.map → AppConfigFactory-BPp02HMv.js.map} +1 -1
  4. package/dist/{AppConfigFactory-CK28UPK0.d.ts → AppConfigFactory-Dq7ttwQ_.d.ts} +6001 -144
  5. package/dist/{AppContainerFactory-CcSGFNLW.js → AppContainerFactory-D9je1sSV.js} +2604 -155
  6. package/dist/AppContainerFactory-D9je1sSV.js.map +1 -0
  7. package/dist/{CodemationAppContext-KqDoeHqN.d.ts → CodemationAppContext-P7P-xZhQ.d.ts} +2 -2
  8. package/dist/{CodemationAuthoring.types-BP6Inucu.d.ts → CodemationAuthoring.types-OMYu7vKP.d.ts} +3 -3
  9. package/dist/{CodemationConfigNormalizer-DIAE0VHw.d.ts → CodemationConfigNormalizer-BCtBrJDe.d.ts} +2 -2
  10. package/dist/{CodemationConsumerConfigLoader-nj9kTmfJ.d.ts → CodemationConsumerConfigLoader-evvw4b_a.d.ts} +2 -2
  11. package/dist/CodemationPluginListMerger-PSTtEQjC.d.ts +674 -0
  12. package/dist/{CredentialServices-BFQD_VN1.d.ts → CredentialServices-0Hk8RFY1.d.ts} +3 -3
  13. package/dist/{CredentialServices-BPKUF8Xs.js → CredentialServices-BNBMFOPt.js} +6 -1
  14. package/dist/CredentialServices-BNBMFOPt.js.map +1 -0
  15. package/dist/{PublicFrontendBootstrapFactory-DTA1iDo0.d.ts → PublicFrontendBootstrapFactory-D0_ds7nS.d.ts} +2 -2
  16. package/dist/authoring.d.ts +3 -3
  17. package/dist/consumer.d.ts +4 -4
  18. package/dist/credentials.d.ts +3 -3
  19. package/dist/credentials.js +1 -1
  20. package/dist/devServerSidecar.d.ts +1 -1
  21. package/dist/{index-Dd6BrWyH.d.ts → index-CeS2saCe.d.ts} +105 -2
  22. package/dist/index.d.ts +12 -11
  23. package/dist/index.js +5 -5
  24. package/dist/nextServer.d.ts +8 -58
  25. package/dist/nextServer.js +6 -100
  26. package/dist/{persistenceServer-DKbFDxoS.js → persistenceServer-CA0_q0D7.js} +2 -2
  27. package/dist/{persistenceServer-DKbFDxoS.js.map → persistenceServer-CA0_q0D7.js.map} +1 -1
  28. package/dist/{persistenceServer-Y-u7lV7f.d.ts → persistenceServer-CJeu1STC.d.ts} +2 -2
  29. package/dist/persistenceServer.d.ts +5 -5
  30. package/dist/persistenceServer.js +2 -2
  31. package/dist/{server-CFpgKuVE.js → server-C_ZIEOTY.js} +4 -4
  32. package/dist/{server-CFpgKuVE.js.map → server-C_ZIEOTY.js.map} +1 -1
  33. package/dist/{server-axppTMgo.d.ts → server-Clvg5x1w.d.ts} +11 -5
  34. package/dist/server.d.ts +8 -8
  35. package/dist/server.js +5 -5
  36. package/package.json +6 -5
  37. package/prisma/migrations/20260414120000_telemetry_foundation/migration.sql +112 -0
  38. package/prisma/migrations/20260414153000_telemetry_retention_metrics_refactor/migration.sql +239 -0
  39. package/prisma/migrations.sqlite/20260414120000_telemetry_foundation/migration.sql +103 -0
  40. package/prisma/migrations.sqlite/20260414153000_telemetry_retention_metrics_refactor/migration.sql +540 -0
  41. package/prisma/schema.postgresql.prisma +100 -1
  42. package/prisma/schema.sqlite.prisma +100 -1
  43. package/scripts/generate-prisma-clients.mjs +89 -1
  44. package/src/application/contracts/TelemetryDashboardContracts.ts +113 -0
  45. package/src/application/contracts/TelemetryRunTraceContracts.ts +13 -0
  46. package/src/application/cost/FrameworkCostCatalogEntries.ts +126 -0
  47. package/src/application/queries/GetTelemetryDashboardDimensionsQuery.ts +11 -0
  48. package/src/application/queries/GetTelemetryDashboardDimensionsQueryHandler.ts +20 -0
  49. package/src/application/queries/GetTelemetryDashboardRunsQuery.ts +11 -0
  50. package/src/application/queries/GetTelemetryDashboardRunsQueryHandler.ts +20 -0
  51. package/src/application/queries/GetTelemetryDashboardSummaryQuery.ts +11 -0
  52. package/src/application/queries/GetTelemetryDashboardSummaryQueryHandler.ts +29 -0
  53. package/src/application/queries/GetTelemetryDashboardTimeseriesQuery.ts +11 -0
  54. package/src/application/queries/GetTelemetryDashboardTimeseriesQueryHandler.ts +36 -0
  55. package/src/application/queries/GetTelemetryRunTraceQuery.ts +8 -0
  56. package/src/application/queries/GetTelemetryRunTraceQueryHandler.ts +20 -0
  57. package/src/application/queries/WorkflowQueryHandlers.ts +5 -0
  58. package/src/application/runs/WorkflowRunRetentionPruneScheduler.ts +71 -26
  59. package/src/application/telemetry/CompositeTelemetryExporter.ts +13 -0
  60. package/src/application/telemetry/LazyExecutionTelemetryFactory.ts +21 -0
  61. package/src/application/telemetry/NoOpTelemetryExporter.ts +7 -0
  62. package/src/application/telemetry/OtelExecutionTelemetry.types.ts +41 -0
  63. package/src/application/telemetry/OtelExecutionTelemetryFactory.ts +56 -0
  64. package/src/application/telemetry/OtelIdentityFactory.ts +41 -0
  65. package/src/application/telemetry/RunEventBusTelemetryReporter.ts +188 -0
  66. package/src/application/telemetry/StoredExecutionTelemetry.ts +56 -0
  67. package/src/application/telemetry/StoredNodeExecutionTelemetry.ts +35 -0
  68. package/src/application/telemetry/StoredTelemetrySpanScope.ts +188 -0
  69. package/src/application/telemetry/TelemetryEnricherChain.ts +85 -0
  70. package/src/application/telemetry/TelemetryPrivacyPolicy.ts +19 -0
  71. package/src/application/telemetry/TelemetryQueryService.ts +815 -0
  72. package/src/application/telemetry/TelemetryRetentionTimestampFactory.ts +40 -0
  73. package/src/applicationTokens.ts +18 -0
  74. package/src/bootstrap/AppContainerFactory.ts +124 -1
  75. package/src/bootstrap/AppContainerLifecycle.ts +8 -0
  76. package/src/bootstrap/runtime/FrontendRuntime.ts +8 -0
  77. package/src/bootstrap/runtime/WorkerRuntime.ts +8 -0
  78. package/src/domain/runs/WorkflowRunRepository.ts +3 -1
  79. package/src/domain/telemetry/TelemetryContracts.ts +197 -0
  80. package/src/infrastructure/persistence/InMemoryRunTraceContextRepository.ts +56 -0
  81. package/src/infrastructure/persistence/InMemoryTelemetryArtifactStore.ts +56 -0
  82. package/src/infrastructure/persistence/InMemoryTelemetryMetricPointStore.ts +97 -0
  83. package/src/infrastructure/persistence/InMemoryTelemetrySpanStore.ts +113 -0
  84. package/src/infrastructure/persistence/InMemoryWorkflowRunRepository.ts +4 -2
  85. package/src/infrastructure/persistence/PrismaRunTraceContextRepository.ts +92 -0
  86. package/src/infrastructure/persistence/PrismaTelemetryArtifactStore.ts +125 -0
  87. package/src/infrastructure/persistence/PrismaTelemetryMetricPointStore.ts +134 -0
  88. package/src/infrastructure/persistence/PrismaTelemetrySpanStore.ts +166 -0
  89. package/src/infrastructure/persistence/PrismaWorkflowRunRepository.ts +20 -7
  90. package/src/infrastructure/persistence/generated/prisma-postgresql-client/edge.js +85 -4
  91. package/src/infrastructure/persistence/generated/prisma-postgresql-client/index-browser.js +81 -0
  92. package/src/infrastructure/persistence/generated/prisma-postgresql-client/index.d.ts +6488 -102
  93. package/src/infrastructure/persistence/generated/prisma-postgresql-client/index.js +85 -4
  94. package/src/infrastructure/persistence/generated/prisma-postgresql-client/package.json +1 -1
  95. package/src/infrastructure/persistence/generated/prisma-postgresql-client/schema.prisma +100 -0
  96. package/src/infrastructure/persistence/generated/prisma-sqlite-client/edge.js +85 -4
  97. package/src/infrastructure/persistence/generated/prisma-sqlite-client/index-browser.js +81 -0
  98. package/src/infrastructure/persistence/generated/prisma-sqlite-client/index.d.ts +6476 -98
  99. package/src/infrastructure/persistence/generated/prisma-sqlite-client/index.js +85 -4
  100. package/src/infrastructure/persistence/generated/prisma-sqlite-client/package.json +1 -1
  101. package/src/infrastructure/persistence/generated/prisma-sqlite-client/schema.prisma +100 -0
  102. package/src/presentation/http/ApiPaths.ts +22 -0
  103. package/src/presentation/http/hono/registrars/TelemetryHonoApiRouteRegistrar.ts +19 -0
  104. package/src/presentation/http/routeHandlers/TelemetryDashboardRequestError.ts +1 -0
  105. package/src/presentation/http/routeHandlers/TelemetryHttpRouteHandler.ts +181 -0
  106. package/dist/AppContainerFactory-CcSGFNLW.js.map +0 -1
  107. package/dist/CodemationPluginListMerger-QvUa2SIt.d.ts +0 -357
  108. package/dist/CredentialServices-BPKUF8Xs.js.map +0 -1
  109. package/dist/nextServer.js.map +0 -1
@@ -176,6 +176,11 @@ const ApplicationTokens = {
176
176
  LoggerFactory: Symbol.for("codemation.application.LoggerFactory"),
177
177
  PerformanceDiagnosticsLogger: Symbol.for("codemation.application.PerformanceDiagnosticsLogger"),
178
178
  CredentialStore: Symbol.for("codemation.application.CredentialStore"),
179
+ RunTraceContextRepository: Symbol.for("codemation.application.RunTraceContextRepository"),
180
+ TelemetrySpanStore: Symbol.for("codemation.application.TelemetrySpanStore"),
181
+ TelemetryArtifactStore: Symbol.for("codemation.application.TelemetryArtifactStore"),
182
+ TelemetryMetricPointStore: Symbol.for("codemation.application.TelemetryMetricPointStore"),
183
+ TelemetryExporter: Symbol.for("codemation.application.TelemetryExporter"),
179
184
  PrismaClient: Symbol.for("codemation.application.PrismaClient"),
180
185
  SessionVerifier: Symbol.for("codemation.application.SessionVerifier"),
181
186
  Clock: Symbol.for("codemation.application.Clock")
@@ -1007,4 +1012,4 @@ CredentialTestService = __decorate([
1007
1012
 
1008
1013
  //#endregion
1009
1014
  export { CredentialInstanceService as a, CredentialSecretCipher as c, ApplicationTokens as d, ApplicationRequestError as f, OpenAiApiKeyCredentialHealthTester as h, CredentialBindingService as i, CredentialFieldEnvOverlayService as l, OpenAiApiKeyCredentialTypeFactory as m, CredentialSessionServiceImpl as n, CredentialOAuth2ScopeResolver as o, CredentialTypeRegistryImpl as p, CredentialRuntimeMaterialService as r, CredentialMaterialResolver as s, CredentialTestService as t, WorkflowCredentialNodeResolver as u };
1010
- //# sourceMappingURL=CredentialServices-BPKUF8Xs.js.map
1015
+ //# sourceMappingURL=CredentialServices-BNBMFOPt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CredentialServices-BNBMFOPt.js","names":["fetchImpl: typeof globalThis.fetch","healthTester: OpenAiApiKeyCredentialHealthTester","CredentialTypeRegistryImpl","WorkflowCredentialNodeResolver","entry","labels: string[]","CredentialFieldEnvOverlayService","appConfig: AppConfig","pub: Record<string, unknown>","mat: Record<string, unknown>","CredentialSecretCipher","appConfig: AppConfig","CredentialMaterialResolver","credentialStore: CredentialStore","credentialSecretCipher: CredentialSecretCipher","appConfig: AppConfig","resolved: Record<string, unknown>","missingEnvironmentVariables: string[]","CredentialOAuth2ScopeResolver","CredentialInstanceService","credentialStore: CredentialStore","credentialTypeRegistry: CredentialTypeRegistryImpl","credentialSecretCipher: CredentialSecretCipher","credentialFieldEnvOverlayService: CredentialFieldEnvOverlayService","credentialMaterialResolver: CredentialMaterialResolver","credentialOAuth2ScopeResolver: CredentialOAuth2ScopeResolver","credentialSessionService: MutableCredentialSessionService","instance: CredentialInstanceRecord","updatedInstance: CredentialInstanceRecord","out: Record<string, unknown>","CredentialBindingService","credentialStore: CredentialStore","credentialInstanceService: CredentialInstanceService","workflowRepository: WorkflowRepository","credentialSessionService: MutableCredentialSessionService","workflowCredentialNodeResolver: WorkflowCredentialNodeResolver","binding: CredentialBinding","slots: WorkflowCredentialHealthSlotDto[]","CredentialRuntimeMaterialService","credentialStore: CredentialStore","credentialMaterialResolver: CredentialMaterialResolver","credentialSecretCipher: CredentialSecretCipher","credentialTypeRegistry: CredentialTypeRegistryImpl","CredentialSessionServiceImpl","credentialStore: CredentialStore","credentialRuntimeMaterialService: CredentialRuntimeMaterialService","credentialFieldEnvOverlayService: CredentialFieldEnvOverlayService","credentialTypeRegistry: CredentialTypeRegistryImpl","workflowRepository: WorkflowRepository","workflowCredentialNodeResolver: WorkflowCredentialNodeResolver","bindingKey: CredentialBindingKey","CredentialTestService","credentialInstanceService: CredentialInstanceService","credentialRuntimeMaterialService: CredentialRuntimeMaterialService","credentialFieldEnvOverlayService: CredentialFieldEnvOverlayService","credentialTypeRegistry: CredentialTypeRegistryImpl","credentialStore: CredentialStore","credentialSessionService: MutableCredentialSessionService"],"sources":["../src/infrastructure/credentials/OpenAiApiKeyCredentialHealthTester.ts","../src/infrastructure/credentials/OpenAiApiKeyCredentialTypeFactory.ts","../src/domain/credentials/CredentialTypeRegistryImpl.ts","../src/application/ApplicationRequestError.ts","../src/applicationTokens.ts","../src/domain/credentials/WorkflowCredentialNodeResolver.ts","../src/domain/credentials/CredentialFieldEnvOverlayService.ts","../src/domain/credentials/CredentialSecretCipher.ts","../src/domain/credentials/CredentialMaterialResolver.ts","../src/domain/credentials/CredentialOAuth2ScopeResolver.ts","../src/domain/credentials/CredentialInstanceService.ts","../src/domain/credentials/CredentialBindingService.ts","../src/domain/credentials/CredentialRuntimeMaterialService.ts","../src/domain/credentials/CredentialSessionServiceImpl.ts","../src/domain/credentials/CredentialTestService.ts"],"sourcesContent":["import type { CredentialHealth, CredentialSessionFactoryArgs } from \"@codemation/core\";\n\nimport type { OpenAiApiKeyMaterial, OpenAiApiKeyPublicConfig } from \"./OpenAiApiKeyCredentialShapes.types\";\n\n/**\n * Verifies an OpenAI-compatible API key by calling the provider's models list endpoint\n * (GET `/v1/models` relative to the configured base URL).\n */\nexport class OpenAiApiKeyCredentialHealthTester {\n constructor(private readonly fetchImpl: typeof globalThis.fetch) {}\n\n async test(\n args: CredentialSessionFactoryArgs<OpenAiApiKeyPublicConfig, OpenAiApiKeyMaterial>,\n ): Promise<CredentialHealth> {\n const testedAt = new Date().toISOString();\n const apiKey = String(args.material.apiKey ?? \"\").trim();\n if (apiKey.length === 0) {\n return {\n status: \"failing\",\n message: \"OpenAI API key is empty.\",\n testedAt,\n };\n }\n\n const modelsUrl = this.resolveModelsListUrl(args.publicConfig.baseUrl);\n\n try {\n const response = await this.fetchImpl(modelsUrl, {\n method: \"GET\",\n headers: {\n Authorization: `Bearer ${apiKey}`,\n },\n signal: AbortSignal.timeout(25_000),\n });\n\n if (response.ok) {\n return {\n status: \"healthy\",\n message: \"API key verified against the models endpoint.\",\n testedAt,\n };\n }\n\n const message = await this.parseErrorMessage(response);\n return {\n status: \"failing\",\n message,\n testedAt,\n };\n } catch (error) {\n return {\n status: \"failing\",\n message: error instanceof Error ? error.message : String(error),\n testedAt,\n };\n }\n }\n\n private resolveModelsListUrl(baseUrlRaw: unknown): string {\n const defaultBase = \"https://api.openai.com/v1\";\n const raw = typeof baseUrlRaw === \"string\" ? baseUrlRaw.trim() : \"\";\n const base = raw === \"\" ? defaultBase : raw.replace(/\\/+$/, \"\");\n if (base.endsWith(\"/models\")) {\n return base;\n }\n if (base.endsWith(\"/v1\")) {\n return `${base}/models`;\n }\n return `${base}/v1/models`;\n }\n\n private async parseErrorMessage(response: Response): Promise<string> {\n const prefix = `HTTP ${response.status}`;\n try {\n const text = await response.text();\n if (text.trim() === \"\") {\n return prefix;\n }\n const parsed = JSON.parse(text) as { error?: { message?: string } };\n const fromApi = parsed.error?.message;\n if (typeof fromApi === \"string\" && fromApi.trim() !== \"\") {\n return `${prefix}: ${fromApi.trim()}`;\n }\n return `${prefix}: ${text.length > 280 ? `${text.slice(0, 280)}…` : text}`;\n } catch {\n return prefix;\n }\n }\n}\n","import type { CredentialType } from \"../../domain/credentials/CredentialServices\";\n\nimport type { OpenAiApiKeyCredentialHealthTester } from \"./OpenAiApiKeyCredentialHealthTester\";\nimport type {\n OpenAiApiKeyMaterial,\n OpenAiApiKeyPublicConfig,\n OpenAiApiKeySession,\n} from \"./OpenAiApiKeyCredentialShapes.types\";\n\n/**\n * Builds the OpenAI-compatible API key credential (`openai.apiKey`) registration.\n * Used by {@link FrameworkBuiltinCredentialTypesRegistrar} and may be listed in {@link CodemationConfig.credentialTypes}\n * so consumer apps always register the type even when bootstrap order differs.\n */\nexport class OpenAiApiKeyCredentialTypeFactory {\n constructor(private readonly healthTester: OpenAiApiKeyCredentialHealthTester) {}\n\n createCredentialType(): CredentialType<OpenAiApiKeyPublicConfig, OpenAiApiKeyMaterial, OpenAiApiKeySession> {\n return {\n definition: {\n typeId: \"openai.apiKey\",\n displayName: \"OpenAI API key\",\n description: \"API key and optional base URL for OpenAI or OpenAI-compatible chat endpoints.\",\n publicFields: [\n {\n key: \"baseUrl\",\n label: \"Base URL\",\n type: \"string\",\n placeholder: \"https://api.openai.com/v1\",\n helpText: \"Leave empty to use the default OpenAI API endpoint.\",\n },\n ],\n secretFields: [{ key: \"apiKey\", label: \"API key\", type: \"password\", required: true }],\n supportedSourceKinds: [\"db\", \"env\", \"code\"],\n },\n createSession: async (args) => {\n const baseUrlRaw = args.publicConfig.baseUrl;\n const baseUrl = typeof baseUrlRaw === \"string\" && baseUrlRaw.trim() !== \"\" ? baseUrlRaw.trim() : undefined;\n return {\n apiKey: String(args.material.apiKey ?? \"\"),\n baseUrl,\n };\n },\n test: async (args) => this.healthTester.test(args),\n };\n }\n}\n","import type { CredentialTypeDefinition, CredentialTypeId, CredentialTypeRegistry } from \"@codemation/core\";\n\nimport { injectable } from \"@codemation/core\";\n\nimport type { AnyCredentialType, CredentialType } from \"./CredentialServices\";\n\n@injectable()\nexport class CredentialTypeRegistryImpl implements CredentialTypeRegistry {\n private readonly credentialTypesById = new Map<CredentialTypeId, AnyCredentialType>();\n\n register(type: CredentialType<any, any, unknown>): void {\n if (this.credentialTypesById.has(type.definition.typeId)) {\n throw new Error(`Credential type already registered: ${type.definition.typeId}`);\n }\n this.credentialTypesById.set(type.definition.typeId, type);\n }\n\n listTypes(): ReadonlyArray<CredentialTypeDefinition> {\n return [...this.credentialTypesById.values()].map((entry) => entry.definition);\n }\n\n getType(typeId: CredentialTypeId): CredentialTypeDefinition | undefined {\n return this.credentialTypesById.get(typeId)?.definition;\n }\n\n getCredentialType(typeId: CredentialTypeId): AnyCredentialType | undefined {\n return this.credentialTypesById.get(typeId);\n }\n}\n","export class ApplicationRequestError extends Error {\n readonly status: number;\n\n readonly payload: Readonly<{ error: string; errors?: ReadonlyArray<string> }>;\n\n constructor(status: number, message: string, errors?: ReadonlyArray<string>) {\n super(message);\n this.name = \"ApplicationRequestError\";\n this.status = status;\n this.payload = errors && errors.length > 0 ? { error: message, errors } : { error: message };\n }\n}\n","import type { Clock, TypeToken } from \"@codemation/core\";\nimport type { SessionVerifier } from \"./application/auth/SessionVerifier\";\nimport type { Command } from \"./application/bus/Command\";\nimport type { CommandBus } from \"./application/bus/CommandBus\";\nimport type { CommandHandler } from \"./application/bus/CommandHandler\";\nimport type { DomainEvent } from \"./application/bus/DomainEvent\";\nimport type { DomainEventBus } from \"./application/bus/DomainEventBus\";\nimport type { DomainEventHandler } from \"./application/bus/DomainEventHandler\";\nimport type { Query } from \"./application/bus/Query\";\nimport type { QueryBus } from \"./application/bus/QueryBus\";\nimport type { QueryHandler } from \"./application/bus/QueryHandler\";\nimport type { Logger, LoggerFactory } from \"./application/logging/Logger\";\nimport type { WorkflowWebsocketPublisher } from \"./application/websocket/WorkflowWebsocketPublisher\";\nimport type { CredentialStore } from \"./domain/credentials/CredentialServices\";\nimport type {\n RunTraceContextRepository,\n TelemetryArtifactStore,\n TelemetryExporter,\n TelemetryMetricPointStore,\n TelemetrySpanStore,\n} from \"./domain/telemetry/TelemetryContracts\";\nimport type { WorkflowRunRepository } from \"./domain/runs/WorkflowRunRepository\";\nimport type { WorkflowDebuggerOverlayRepository } from \"./domain/workflows/WorkflowDebuggerOverlayRepository\";\nimport type { WorkflowDefinitionRepository } from \"./domain/workflows/WorkflowDefinitionRepository\";\nimport type { WorkflowActivationRepository } from \"./domain/workflows/WorkflowActivationRepository\";\nimport type { PrismaDatabaseClient } from \"./infrastructure/persistence/PrismaDatabaseClient\";\nimport type { WorkerRuntimeScheduler } from \"./infrastructure/scheduler/WorkerRuntimeScheduler\";\nimport type { AppConfig } from \"./presentation/config/AppConfig\";\nimport type { CodemationAuthConfig } from \"./presentation/config/CodemationAuthConfig\";\nimport type { CodemationWhitelabelConfig } from \"./presentation/config/CodemationWhitelabelConfig\";\nimport type { HonoApiRouteRegistrar } from \"./presentation/http/hono/HonoApiRouteRegistrar\";\n\nexport const ApplicationTokens = {\n CodemationAuthConfig: Symbol.for(\"codemation.application.CodemationAuthConfig\") as TypeToken<\n CodemationAuthConfig | undefined\n >,\n CodemationWhitelabelConfig: Symbol.for(\n \"codemation.application.CodemationWhitelabelConfig\",\n ) as TypeToken<CodemationWhitelabelConfig>,\n AppConfig: Symbol.for(\"codemation.application.AppConfig\") as TypeToken<AppConfig>,\n WebSocketPort: Symbol.for(\"codemation.application.WebSocketPort\") as TypeToken<number>,\n WebSocketBindHost: Symbol.for(\"codemation.application.WebSocketBindHost\") as TypeToken<string>,\n QueryBus: Symbol.for(\"codemation.application.QueryBus\") as TypeToken<QueryBus>,\n CommandBus: Symbol.for(\"codemation.application.CommandBus\") as TypeToken<CommandBus>,\n DomainEventBus: Symbol.for(\"codemation.application.DomainEventBus\") as TypeToken<DomainEventBus>,\n QueryHandler: Symbol.for(\"codemation.application.QueryHandler\") as TypeToken<QueryHandler<Query<unknown>, unknown>>,\n CommandHandler: Symbol.for(\"codemation.application.CommandHandler\") as TypeToken<\n CommandHandler<Command<unknown>, unknown>\n >,\n DomainEventHandler: Symbol.for(\"codemation.application.DomainEventHandler\") as TypeToken<\n DomainEventHandler<DomainEvent>\n >,\n HonoApiRouteRegistrar: Symbol.for(\"codemation.application.HonoApiRouteRegistrar\") as TypeToken<HonoApiRouteRegistrar>,\n WorkflowWebsocketPublisher: Symbol.for(\n \"codemation.application.WorkflowWebsocketPublisher\",\n ) as TypeToken<WorkflowWebsocketPublisher>,\n WorkerRuntimeScheduler: Symbol.for(\n \"codemation.application.WorkerRuntimeScheduler\",\n ) as TypeToken<WorkerRuntimeScheduler>,\n WorkflowDefinitionRepository: Symbol.for(\n \"codemation.application.WorkflowDefinitionRepository\",\n ) as TypeToken<WorkflowDefinitionRepository>,\n WorkflowActivationRepository: Symbol.for(\n \"codemation.application.WorkflowActivationRepository\",\n ) as TypeToken<WorkflowActivationRepository>,\n WorkflowDebuggerOverlayRepository: Symbol.for(\n \"codemation.application.WorkflowDebuggerOverlayRepository\",\n ) as TypeToken<WorkflowDebuggerOverlayRepository>,\n WorkflowRunRepository: Symbol.for(\"codemation.application.WorkflowRunRepository\") as TypeToken<WorkflowRunRepository>,\n LoggerFactory: Symbol.for(\"codemation.application.LoggerFactory\") as TypeToken<LoggerFactory>,\n /**\n * Opt-in timing/diagnostics logger (`CODEMATION_PERFORMANCE_LOGGING` + normal minimum log level).\n */\n PerformanceDiagnosticsLogger: Symbol.for(\"codemation.application.PerformanceDiagnosticsLogger\") as TypeToken<Logger>,\n CredentialStore: Symbol.for(\"codemation.application.CredentialStore\") as TypeToken<CredentialStore>,\n RunTraceContextRepository: Symbol.for(\n \"codemation.application.RunTraceContextRepository\",\n ) as TypeToken<RunTraceContextRepository>,\n TelemetrySpanStore: Symbol.for(\"codemation.application.TelemetrySpanStore\") as TypeToken<TelemetrySpanStore>,\n TelemetryArtifactStore: Symbol.for(\n \"codemation.application.TelemetryArtifactStore\",\n ) as TypeToken<TelemetryArtifactStore>,\n TelemetryMetricPointStore: Symbol.for(\n \"codemation.application.TelemetryMetricPointStore\",\n ) as TypeToken<TelemetryMetricPointStore>,\n TelemetryExporter: Symbol.for(\"codemation.application.TelemetryExporter\") as TypeToken<TelemetryExporter>,\n PrismaClient: Symbol.for(\"codemation.application.PrismaClient\") as TypeToken<PrismaDatabaseClient>,\n SessionVerifier: Symbol.for(\"codemation.application.SessionVerifier\") as TypeToken<SessionVerifier>,\n Clock: Symbol.for(\"codemation.application.Clock\") as TypeToken<Clock>,\n} as const;\n","import type { CredentialRequirement, WorkflowDefinition } from \"@codemation/core\";\nimport {\n AgentConfigInspector,\n AgentConnectionNodeCollector,\n type AgentConnectionNodeDescriptor,\n ConnectionNodeIdFactory,\n} from \"@codemation/core\";\n\nimport { injectable } from \"@codemation/core\";\n\nexport type WorkflowCredentialSlotRef = Readonly<{\n workflowId: string;\n nodeId: string;\n nodeName: string;\n requirement: CredentialRequirement;\n}>;\n\n/**\n * Resolves credential requirements for workflow node ids, including connection-owned LLM/tool children.\n */\n@injectable()\nexport class WorkflowCredentialNodeResolver {\n /**\n * Human-readable label for credential errors (workflow node name or agent › attachment).\n */\n describeCredentialNodeDisplay(workflow: WorkflowDefinition, nodeId: string): string {\n const direct = workflow.nodes.find((n) => n.id === nodeId);\n if (direct) {\n return direct.name ?? direct.config.name ?? direct.id;\n }\n const recursive = this.findRecursiveConnectionNode(workflow, nodeId);\n if (!recursive) {\n return nodeId;\n }\n return this.buildRecursiveDisplayLabel(recursive.rootAgentLabel, recursive.entry, recursive.entriesById);\n }\n\n isCredentialNodeIdInWorkflow(workflow: WorkflowDefinition, nodeId: string): boolean {\n if (workflow.nodes.some((n) => n.id === nodeId)) {\n return true;\n }\n return this.findRecursiveConnectionNode(workflow, nodeId) !== undefined;\n }\n\n findRequirement(\n workflow: WorkflowDefinition,\n nodeId: string,\n slotKey: string,\n ): Readonly<{ nodeName: string; requirement: CredentialRequirement }> | undefined {\n const direct = this.findDirectRequirement(workflow, nodeId, slotKey);\n if (direct) {\n return direct;\n }\n const recursive = this.findRecursiveConnectionNode(workflow, nodeId);\n if (!recursive) {\n return undefined;\n }\n const requirement = recursive.entry.credentialSource\n .getCredentialRequirements?.()\n ?.find((entry) => entry.slotKey === slotKey);\n return requirement ? { nodeName: recursive.entry.name, requirement } : undefined;\n }\n\n listSlots(workflow: WorkflowDefinition): ReadonlyArray<WorkflowCredentialSlotRef> {\n const slotsByKey = new Map<string, WorkflowCredentialSlotRef>();\n\n for (const node of workflow.nodes) {\n if (AgentConfigInspector.isAgentNodeConfig(node.config)) {\n this.addRecursiveAgentSlots(workflow.id, node.id, node.config, slotsByKey);\n continue;\n }\n this.addSlotsForRequirements(\n workflow.id,\n node.id,\n node.name ?? node.config.name ?? node.id,\n node.config.getCredentialRequirements?.() ?? [],\n slotsByKey,\n );\n }\n return [...slotsByKey.values()];\n }\n\n private findDirectRequirement(\n workflow: WorkflowDefinition,\n nodeId: string,\n slotKey: string,\n ): Readonly<{ nodeName: string; requirement: CredentialRequirement }> | undefined {\n const node = workflow.nodes.find((entry) => entry.id === nodeId);\n if (!node || AgentConfigInspector.isAgentNodeConfig(node.config)) {\n return undefined;\n }\n const requirement = node.config.getCredentialRequirements?.()?.find((entry) => entry.slotKey === slotKey);\n if (!requirement) {\n return undefined;\n }\n return { nodeName: node.name ?? node.config.name ?? node.id, requirement };\n }\n\n private addRecursiveAgentSlots(\n workflowId: string,\n rootAgentNodeId: string,\n agentConfig: Parameters<typeof AgentConnectionNodeCollector.collect>[1],\n slotsByKey: Map<string, WorkflowCredentialSlotRef>,\n ): void {\n for (const entry of AgentConnectionNodeCollector.collect(rootAgentNodeId, agentConfig)) {\n this.addSlotsForRequirements(\n workflowId,\n entry.nodeId,\n entry.name,\n entry.credentialSource.getCredentialRequirements?.() ?? [],\n slotsByKey,\n );\n }\n }\n\n private addSlotsForRequirements(\n workflowId: string,\n nodeId: string,\n nodeName: string,\n requirements: ReadonlyArray<CredentialRequirement>,\n slotsByKey: Map<string, WorkflowCredentialSlotRef>,\n ): void {\n for (const requirement of requirements) {\n const key = `${nodeId}\\0${requirement.slotKey}`;\n if (slotsByKey.has(key)) {\n continue;\n }\n slotsByKey.set(key, {\n workflowId,\n nodeId,\n nodeName,\n requirement,\n });\n }\n }\n\n private findRecursiveConnectionNode(\n workflow: WorkflowDefinition,\n nodeId: string,\n ):\n | Readonly<{\n rootAgentNodeId: string;\n rootAgentLabel: string;\n entry: AgentConnectionNodeDescriptor;\n entriesById: ReadonlyMap<string, AgentConnectionNodeDescriptor>;\n }>\n | undefined {\n if (\n !ConnectionNodeIdFactory.isLanguageModelConnectionNodeId(nodeId) &&\n !ConnectionNodeIdFactory.isToolConnectionNodeId(nodeId)\n ) {\n return undefined;\n }\n for (const node of workflow.nodes) {\n if (!AgentConfigInspector.isAgentNodeConfig(node.config)) {\n continue;\n }\n const entries = AgentConnectionNodeCollector.collect(node.id, node.config);\n const entriesById = new Map(entries.map((entry) => [entry.nodeId, entry]));\n const entry = entriesById.get(nodeId);\n if (!entry) {\n continue;\n }\n return {\n rootAgentNodeId: node.id,\n rootAgentLabel: node.name ?? node.config.name ?? node.id,\n entry,\n entriesById,\n };\n }\n return undefined;\n }\n\n private buildRecursiveDisplayLabel(\n rootAgentLabel: string,\n entry: AgentConnectionNodeDescriptor,\n entriesById: ReadonlyMap<string, AgentConnectionNodeDescriptor>,\n ): string {\n const labels = [rootAgentLabel, ...this.collectAncestorToolLabels(entry.parentNodeId, entriesById)];\n labels.push(entry.role === \"languageModel\" ? \"Language model\" : entry.name);\n return labels.join(\" › \");\n }\n\n private collectAncestorToolLabels(\n parentNodeId: string,\n entriesById: ReadonlyMap<string, AgentConnectionNodeDescriptor>,\n ): ReadonlyArray<string> {\n const labels: string[] = [];\n let currentNodeId = parentNodeId;\n while (true) {\n const parentEntry = entriesById.get(currentNodeId);\n if (!parentEntry) {\n return labels.reverse();\n }\n if (parentEntry.role === \"tool\" || parentEntry.role === \"nestedAgent\") {\n labels.push(parentEntry.name);\n }\n currentNodeId = parentEntry.parentNodeId;\n }\n }\n}\n","import type { CredentialFieldSchema, CredentialTypeDefinition } from \"@codemation/core\";\nimport { inject, injectable } from \"@codemation/core\";\n\nimport { ApplicationTokens } from \"../../applicationTokens\";\nimport type { AppConfig } from \"../../presentation/config/AppConfig\";\n\nimport type { JsonRecord } from \"./CredentialServices\";\n\n@injectable()\nexport class CredentialFieldEnvOverlayService {\n constructor(\n @inject(ApplicationTokens.AppConfig)\n private readonly appConfig: AppConfig,\n ) {}\n\n /** True when the field declares an env var and process.env has a non-empty string for it. */\n isFieldResolvedFromEnv(field: CredentialFieldSchema): boolean {\n const name = field.envVarName?.trim();\n if (!name) {\n return false;\n }\n const v = this.appConfig.env[name];\n return typeof v === \"string\" && v.length > 0;\n }\n\n apply(\n args: Readonly<{\n definition: CredentialTypeDefinition;\n publicConfig: JsonRecord;\n material: JsonRecord;\n }>,\n ): Readonly<{ resolvedPublicConfig: JsonRecord; resolvedMaterial: JsonRecord }> {\n const pub: Record<string, unknown> = { ...args.publicConfig };\n const mat: Record<string, unknown> = { ...args.material };\n for (const field of args.definition.publicFields ?? []) {\n const name = field.envVarName?.trim();\n if (!name) {\n continue;\n }\n const v = this.appConfig.env[name];\n if (typeof v === \"string\" && v.length > 0) {\n pub[field.key] = v;\n }\n }\n for (const field of args.definition.secretFields ?? []) {\n const name = field.envVarName?.trim();\n if (!name) {\n continue;\n }\n const v = this.appConfig.env[name];\n if (typeof v === \"string\" && v.length > 0) {\n mat[field.key] = v;\n }\n }\n return Object.freeze({\n resolvedPublicConfig: Object.freeze(pub),\n resolvedMaterial: Object.freeze(mat),\n });\n }\n}\n","import { createCipheriv, createDecipheriv, createHash, randomBytes } from \"node:crypto\";\n\nimport { inject, injectable } from \"@codemation/core\";\n\nimport { ApplicationTokens } from \"../../applicationTokens\";\nimport type { AppConfig } from \"../../presentation/config/AppConfig\";\n\nimport type { JsonRecord } from \"./CredentialServices\";\n\n@injectable()\nexport class CredentialSecretCipher {\n private static readonly algorithm = \"aes-256-gcm\";\n private static readonly schemaVersion = 1;\n private static readonly ivLength = 12;\n\n constructor(\n @inject(ApplicationTokens.AppConfig)\n private readonly appConfig: AppConfig,\n ) {}\n\n encrypt(value: JsonRecord): Readonly<{\n encryptedJson: string;\n encryptionKeyId: string;\n schemaVersion: number;\n }> {\n const iv = randomBytes(CredentialSecretCipher.ivLength);\n const cipher = createCipheriv(CredentialSecretCipher.algorithm, this.resolveKeyMaterial(), iv);\n const plaintext = Buffer.from(JSON.stringify(value), \"utf8\");\n const encrypted = Buffer.concat([cipher.update(plaintext), cipher.final()]);\n const authTag = cipher.getAuthTag();\n return {\n encryptedJson: Buffer.concat([iv, authTag, encrypted]).toString(\"base64\"),\n encryptionKeyId: this.resolveKeyId(),\n schemaVersion: CredentialSecretCipher.schemaVersion,\n };\n }\n\n decrypt(\n record: Readonly<{\n encryptedJson: string;\n encryptionKeyId: string;\n schemaVersion: number;\n }>,\n ): JsonRecord {\n const packed = Buffer.from(record.encryptedJson, \"base64\");\n const iv = packed.subarray(0, CredentialSecretCipher.ivLength);\n const authTag = packed.subarray(CredentialSecretCipher.ivLength, CredentialSecretCipher.ivLength + 16);\n const encrypted = packed.subarray(CredentialSecretCipher.ivLength + 16);\n const decipher = createDecipheriv(CredentialSecretCipher.algorithm, this.resolveKeyMaterial(), iv);\n decipher.setAuthTag(authTag);\n const plaintext = Buffer.concat([decipher.update(encrypted), decipher.final()]).toString(\"utf8\");\n return JSON.parse(plaintext) as JsonRecord;\n }\n\n private resolveKeyMaterial(): Buffer {\n const rawValue = this.appConfig.env.CODEMATION_CREDENTIALS_MASTER_KEY;\n if (!rawValue || rawValue.trim().length === 0) {\n throw new Error(\"CODEMATION_CREDENTIALS_MASTER_KEY is required to encrypt database-managed credentials.\");\n }\n return createHash(\"sha256\").update(rawValue).digest();\n }\n\n private resolveKeyId(): string {\n const rawValue = this.appConfig.env.CODEMATION_CREDENTIALS_MASTER_KEY;\n return createHash(\"sha256\")\n .update(rawValue ?? \"\")\n .digest(\"hex\")\n .slice(0, 12);\n }\n}\n","import { inject, injectable } from \"@codemation/core\";\n\nimport { ApplicationTokens } from \"../../applicationTokens\";\nimport type { AppConfig } from \"../../presentation/config/AppConfig\";\n\nimport { CredentialSecretCipher } from \"./CredentialSecretCipher\";\nimport type { CredentialInstanceRecord, CredentialStore, JsonRecord } from \"./CredentialServices\";\n\n@injectable()\nexport class CredentialMaterialResolver {\n constructor(\n @inject(ApplicationTokens.CredentialStore)\n private readonly credentialStore: CredentialStore,\n @inject(CredentialSecretCipher)\n private readonly credentialSecretCipher: CredentialSecretCipher,\n @inject(ApplicationTokens.AppConfig)\n private readonly appConfig: AppConfig,\n ) {}\n\n async resolveMaterial(instance: CredentialInstanceRecord): Promise<JsonRecord> {\n if (instance.secretRef.kind === \"db\") {\n const secretMaterial = await this.credentialStore.getSecretMaterial(instance.instanceId);\n if (!secretMaterial) {\n throw new Error(`Credential ${instance.instanceId} is missing encrypted secret material.`);\n }\n return this.credentialSecretCipher.decrypt(secretMaterial);\n }\n if (instance.secretRef.kind === \"env\") {\n return this.resolveEnvMaterial(instance);\n }\n return instance.secretRef.value;\n }\n\n private resolveEnvMaterial(instance: CredentialInstanceRecord): JsonRecord {\n if (instance.secretRef.kind !== \"env\") {\n throw new Error(`Credential ${instance.instanceId} is not environment-backed.`);\n }\n const resolved: Record<string, unknown> = {};\n const missingEnvironmentVariables: string[] = [];\n for (const [fieldKey, envVarName] of Object.entries(instance.secretRef.envByField)) {\n const value = this.appConfig.env[envVarName];\n if (value === undefined || value.length === 0) {\n missingEnvironmentVariables.push(envVarName);\n continue;\n }\n resolved[fieldKey] = value;\n }\n if (missingEnvironmentVariables.length > 0) {\n throw new Error(\n `Credential ${instance.instanceId} requires environment variables that are not set: ${missingEnvironmentVariables.join(\", \")}.`,\n );\n }\n return resolved;\n }\n}\n","import type { CredentialOAuth2AuthDefinition } from \"@codemation/core\";\nimport { injectable } from \"@codemation/core\";\nimport type { JsonRecord } from \"./CredentialServices\";\n\n@injectable()\nexport class CredentialOAuth2ScopeResolver {\n resolveRequestedScopes(auth: CredentialOAuth2AuthDefinition, publicConfig: JsonRecord): ReadonlyArray<string> {\n const scopesFromPublicConfig = auth.scopesFromPublicConfig;\n if (!scopesFromPublicConfig) {\n return [...auth.scopes];\n }\n const preset = this.resolveString(publicConfig[scopesFromPublicConfig.presetFieldKey]);\n if (!preset) {\n return [...auth.scopes];\n }\n const presetScopes = scopesFromPublicConfig.presetScopes[preset];\n if (presetScopes) {\n return [...presetScopes];\n }\n const customPresetKey = scopesFromPublicConfig.customPresetKey ?? \"custom\";\n if (preset !== customPresetKey) {\n return [...auth.scopes];\n }\n const customScopes = this.resolveScopeList(\n publicConfig[scopesFromPublicConfig.customScopesFieldKey ?? \"customScopes\"],\n );\n if (customScopes.length > 0) {\n return customScopes;\n }\n return [...auth.scopes];\n }\n\n private resolveString(value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return undefined;\n }\n const normalized = value.trim();\n return normalized.length > 0 ? normalized : undefined;\n }\n\n private resolveScopeList(value: unknown): ReadonlyArray<string> {\n if (Array.isArray(value)) {\n return this.dedupe(\n value.map((entry) => (typeof entry === \"string\" ? entry.trim() : \"\")).filter((entry) => entry.length > 0),\n );\n }\n if (typeof value !== \"string\") {\n return [];\n }\n return this.dedupe(\n value\n .split(/[\\s,]+/)\n .map((entry) => entry.trim())\n .filter((entry) => entry.length > 0),\n );\n }\n\n private dedupe(entries: ReadonlyArray<string>): ReadonlyArray<string> {\n return [...new Set(entries)];\n }\n}\n","import { randomUUID } from \"node:crypto\";\n\nimport type {\n CredentialFieldSchema,\n CredentialInstanceId,\n CredentialMaterialSourceKind,\n CredentialTypeId,\n} from \"@codemation/core\";\n\nimport { CoreTokens, inject, injectable } from \"@codemation/core\";\n\nimport { ApplicationRequestError } from \"../../application/ApplicationRequestError\";\n\nimport type {\n CreateCredentialInstanceRequest,\n CredentialInstanceDto,\n CredentialInstanceWithSecretsDto,\n CredentialOAuth2ConnectionDto,\n UpdateCredentialInstanceRequest,\n} from \"../../application/contracts/CredentialContractsRegistry\";\n\nimport { ApplicationTokens } from \"../../applicationTokens\";\n\nimport { CredentialFieldEnvOverlayService } from \"./CredentialFieldEnvOverlayService\";\nimport { CredentialMaterialResolver } from \"./CredentialMaterialResolver\";\nimport { CredentialOAuth2ScopeResolver } from \"./CredentialOAuth2ScopeResolver\";\nimport { CredentialSecretCipher } from \"./CredentialSecretCipher\";\nimport type {\n CredentialInstanceRecord,\n CredentialSecretMaterialRecord,\n CredentialSecretRef,\n CredentialStore,\n CredentialTestRecord,\n AnyCredentialType,\n JsonRecord,\n MutableCredentialSessionService,\n} from \"./CredentialServices\";\nimport { CredentialTypeRegistryImpl } from \"./CredentialServices\";\n\n@injectable()\nexport class CredentialInstanceService {\n constructor(\n @inject(ApplicationTokens.CredentialStore)\n private readonly credentialStore: CredentialStore,\n @inject(CredentialTypeRegistryImpl)\n private readonly credentialTypeRegistry: CredentialTypeRegistryImpl,\n @inject(CredentialSecretCipher)\n private readonly credentialSecretCipher: CredentialSecretCipher,\n @inject(CredentialFieldEnvOverlayService)\n private readonly credentialFieldEnvOverlayService: CredentialFieldEnvOverlayService,\n @inject(CredentialMaterialResolver)\n private readonly credentialMaterialResolver: CredentialMaterialResolver,\n @inject(CredentialOAuth2ScopeResolver)\n private readonly credentialOAuth2ScopeResolver: CredentialOAuth2ScopeResolver,\n @inject(CoreTokens.CredentialSessionService)\n private readonly credentialSessionService: MutableCredentialSessionService,\n ) {}\n\n async listInstances(): Promise<ReadonlyArray<CredentialInstanceDto>> {\n const instances = await this.credentialStore.listInstances();\n const latestTestResults = await this.credentialStore.getLatestTestResults(\n instances.map((instance) => instance.instanceId),\n );\n return await Promise.all(\n instances.map(async (instance) => await this.toDto(instance, latestTestResults.get(instance.instanceId))),\n );\n }\n\n async getInstance(instanceId: CredentialInstanceId): Promise<CredentialInstanceDto | undefined> {\n const instance = await this.credentialStore.getInstance(instanceId);\n if (!instance) {\n return undefined;\n }\n const latestTestResult = await this.credentialStore.getLatestTestResult(instanceId);\n return await this.toDto(instance, latestTestResult);\n }\n\n async getInstanceWithSecrets(\n instanceId: CredentialInstanceId,\n ): Promise<CredentialInstanceWithSecretsDto | undefined> {\n const instance = await this.credentialStore.getInstance(instanceId);\n if (!instance) {\n return undefined;\n }\n const latestTestResult = await this.credentialStore.getLatestTestResult(instanceId);\n const base = await this.toDto(instance, latestTestResult);\n try {\n const material = await this.credentialMaterialResolver.resolveMaterial(instance);\n const secretConfig = Object.fromEntries(Object.entries(material).map(([k, v]) => [k, String(v ?? \"\")])) as Record<\n string,\n string\n >;\n const envSecretRefs =\n instance.secretRef.kind === \"env\" ? (instance.secretRef.envByField as Record<string, string>) : undefined;\n return { ...base, secretConfig, envSecretRefs };\n } catch {\n return base;\n }\n }\n\n async create(request: CreateCredentialInstanceRequest): Promise<CredentialInstanceDto> {\n const credentialType = this.requireCredentialType(request.typeId);\n const publicFields = credentialType.definition.publicFields ?? [];\n const secretFields = credentialType.definition.secretFields ?? [];\n this.validateRequestFields({\n displayName: request.displayName,\n publicFields,\n publicConfig: request.publicConfig ?? {},\n secretFields,\n sourceKind: request.sourceKind,\n secretConfig: request.secretConfig ?? {},\n envSecretRefs: request.envSecretRefs ?? {},\n });\n const timestamp = new Date().toISOString();\n const strippedPublic = this.stripEnvManagedFieldValues(publicFields, request.publicConfig ?? {});\n const strippedSecretForRef = this.stripEnvManagedFieldValues(secretFields, request.secretConfig ?? {});\n const instance: CredentialInstanceRecord = {\n instanceId: randomUUID(),\n typeId: request.typeId,\n displayName: request.displayName.trim(),\n sourceKind: request.sourceKind,\n publicConfig: Object.freeze({ ...strippedPublic }),\n secretRef: this.createSecretRef(request.sourceKind, strippedSecretForRef, request.envSecretRefs ?? {}),\n tags: Object.freeze([...(request.tags ?? [])]),\n setupStatus: credentialType.definition.auth?.kind === \"oauth2\" ? \"draft\" : \"ready\",\n createdAt: timestamp,\n updatedAt: timestamp,\n };\n await this.credentialStore.saveInstance({\n instance,\n secretMaterial: this.createSecretMaterial(instance, strippedSecretForRef, timestamp),\n });\n this.credentialSessionService.evictInstance(instance.instanceId);\n return this.toDto(instance, undefined);\n }\n\n async update(\n instanceId: CredentialInstanceId,\n request: UpdateCredentialInstanceRequest,\n ): Promise<CredentialInstanceDto> {\n const existing = await this.requireInstance(instanceId);\n const credentialType = this.requireCredentialType(existing.typeId);\n const mergedPublicRaw = { ...(request.publicConfig ?? existing.publicConfig) };\n const updatedAt = new Date().toISOString();\n const nextSecretConfig = request.secretConfig;\n const nextEnvSecretRefs = request.envSecretRefs;\n const secretFields = credentialType.definition.secretFields ?? [];\n this.validateRequestFields({\n displayName: request.displayName ?? existing.displayName,\n publicFields: credentialType.definition.publicFields ?? [],\n publicConfig: mergedPublicRaw,\n secretFields,\n sourceKind: existing.sourceKind,\n secretConfig: nextSecretConfig ?? {},\n envSecretRefs: nextEnvSecretRefs ?? {},\n allowSecretOmission: true,\n });\n const publicConfig = Object.freeze({\n ...this.stripEnvManagedFieldValues(credentialType.definition.publicFields ?? [], mergedPublicRaw),\n });\n const mergedSecretForRef =\n nextSecretConfig !== undefined ? this.stripEnvManagedFieldValues(secretFields, nextSecretConfig) : undefined;\n const instance: CredentialInstanceRecord = {\n ...existing,\n displayName: request.displayName?.trim() || existing.displayName,\n publicConfig,\n tags: Object.freeze([...(request.tags ?? existing.tags)]),\n setupStatus: request.setupStatus ?? existing.setupStatus,\n secretRef:\n nextSecretConfig || nextEnvSecretRefs\n ? this.createSecretRef(existing.sourceKind, mergedSecretForRef ?? {}, nextEnvSecretRefs ?? {})\n : existing.secretRef,\n updatedAt,\n };\n await this.credentialStore.saveInstance({\n instance,\n secretMaterial:\n nextSecretConfig !== undefined && mergedSecretForRef !== undefined\n ? this.createSecretMaterial(instance, mergedSecretForRef, updatedAt)\n : undefined,\n });\n this.credentialSessionService.evictInstance(instance.instanceId);\n return this.toDto(instance, await this.credentialStore.getLatestTestResult(instance.instanceId));\n }\n\n async delete(instanceId: CredentialInstanceId): Promise<void> {\n await this.credentialStore.deleteInstance(instanceId);\n this.credentialSessionService.evictInstance(instanceId);\n }\n\n async disconnectOAuth2(instanceId: CredentialInstanceId): Promise<CredentialInstanceDto> {\n const instance = await this.requireInstance(instanceId);\n const credentialType = this.requireCredentialType(instance.typeId);\n if (credentialType.definition.auth?.kind !== \"oauth2\") {\n throw new ApplicationRequestError(400, `Credential instance ${instanceId} does not use OAuth2.`);\n }\n const updatedInstance: CredentialInstanceRecord = {\n ...instance,\n setupStatus: \"draft\",\n updatedAt: new Date().toISOString(),\n };\n await this.credentialStore.saveInstance({\n instance: updatedInstance,\n });\n await this.credentialStore.deleteOAuth2Material(instanceId);\n this.credentialSessionService.evictInstance(instanceId);\n return await this.toDto(updatedInstance, await this.credentialStore.getLatestTestResult(instanceId));\n }\n\n async requireInstance(instanceId: CredentialInstanceId): Promise<CredentialInstanceRecord> {\n const instance = await this.credentialStore.getInstance(instanceId);\n if (!instance) {\n throw new ApplicationRequestError(404, `Unknown credential instance: ${instanceId}`);\n }\n return instance;\n }\n\n private createSecretRef(\n sourceKind: CredentialMaterialSourceKind,\n secretConfig: JsonRecord,\n envSecretRefs: Readonly<Record<string, string>>,\n ): CredentialSecretRef {\n if (sourceKind === \"db\") {\n return { kind: \"db\" };\n }\n if (sourceKind === \"env\") {\n return {\n kind: \"env\",\n envByField: Object.freeze({ ...envSecretRefs }),\n };\n }\n return {\n kind: \"code\",\n value: Object.freeze({ ...secretConfig }),\n };\n }\n\n private createSecretMaterial(\n instance: CredentialInstanceRecord,\n secretConfig: JsonRecord,\n updatedAt: string,\n ): CredentialSecretMaterialRecord | undefined {\n if (instance.sourceKind !== \"db\") {\n return undefined;\n }\n const encrypted = this.credentialSecretCipher.encrypt(secretConfig);\n return {\n instanceId: instance.instanceId,\n encryptedJson: encrypted.encryptedJson,\n encryptionKeyId: encrypted.encryptionKeyId,\n schemaVersion: encrypted.schemaVersion,\n updatedAt,\n };\n }\n\n private validateRequestFields(\n args: Readonly<{\n displayName: string;\n publicFields: ReadonlyArray<CredentialFieldSchema>;\n publicConfig: JsonRecord;\n secretFields: ReadonlyArray<CredentialFieldSchema>;\n sourceKind: CredentialMaterialSourceKind;\n secretConfig: JsonRecord;\n envSecretRefs: Readonly<Record<string, string>>;\n allowSecretOmission?: boolean;\n }>,\n ): void {\n if (!args.displayName || args.displayName.trim().length === 0) {\n throw new ApplicationRequestError(400, \"Credential displayName is required.\");\n }\n this.assertRequiredFields(\"publicConfig\", args.publicFields, args.publicConfig);\n if (args.sourceKind === \"db\") {\n if (!args.allowSecretOmission || Object.keys(args.secretConfig).length > 0) {\n this.assertRequiredFields(\"secretConfig\", args.secretFields, args.secretConfig);\n }\n return;\n }\n if (args.sourceKind === \"env\") {\n if (!args.allowSecretOmission || Object.keys(args.envSecretRefs).length > 0) {\n this.assertRequiredEnvFields(args.secretFields, args.envSecretRefs);\n }\n return;\n }\n if (!args.allowSecretOmission || Object.keys(args.secretConfig).length > 0) {\n this.assertRequiredFields(\"secretConfig\", args.secretFields, args.secretConfig);\n }\n }\n\n private stripEnvManagedFieldValues(fields: ReadonlyArray<CredentialFieldSchema>, value: JsonRecord): JsonRecord {\n const out: Record<string, unknown> = { ...value };\n for (const field of fields) {\n if (this.credentialFieldEnvOverlayService.isFieldResolvedFromEnv(field)) {\n delete out[field.key];\n }\n }\n return Object.freeze(out);\n }\n\n private assertRequiredFields(\n fieldName: string,\n schema: ReadonlyArray<CredentialFieldSchema>,\n value: JsonRecord,\n ): void {\n const missing = schema\n .filter((field) => field.required === true)\n .filter((field) => !this.credentialFieldEnvOverlayService.isFieldResolvedFromEnv(field))\n .filter((field) => value[field.key] === undefined || value[field.key] === null || value[field.key] === \"\")\n .map((field) => field.key);\n if (missing.length > 0) {\n throw new ApplicationRequestError(400, `Missing required ${fieldName} field(s): ${missing.join(\", \")}`);\n }\n }\n\n private assertRequiredEnvFields(\n schema: ReadonlyArray<CredentialFieldSchema>,\n envSecretRefs: Readonly<Record<string, string>>,\n ): void {\n const missing = schema\n .filter((field) => field.required === true)\n .filter((field) => !this.credentialFieldEnvOverlayService.isFieldResolvedFromEnv(field))\n .filter((field) => !envSecretRefs[field.key] || envSecretRefs[field.key]!.trim().length === 0)\n .map((field) => field.key);\n if (missing.length > 0) {\n throw new ApplicationRequestError(400, `Missing required envSecretRefs field(s): ${missing.join(\", \")}`);\n }\n }\n\n private requireCredentialType(typeId: CredentialTypeId): AnyCredentialType {\n const credentialType = this.credentialTypeRegistry.getCredentialType(typeId);\n if (!credentialType) {\n throw new ApplicationRequestError(400, `Unknown credential type: ${typeId}`);\n }\n return credentialType;\n }\n\n async markOAuth2Connected(instanceId: CredentialInstanceId, connectedAt: string): Promise<void> {\n const instance = await this.requireInstance(instanceId);\n await this.credentialStore.saveInstance({\n instance: {\n ...instance,\n setupStatus: \"ready\",\n updatedAt: connectedAt,\n },\n });\n this.credentialSessionService.evictInstance(instanceId);\n }\n\n private async toDto(\n instance: CredentialInstanceRecord,\n latestTestResult: CredentialTestRecord | undefined,\n ): Promise<CredentialInstanceDto> {\n const oauth2Connection = await this.toOAuth2ConnectionDto(instance);\n return {\n instanceId: instance.instanceId,\n typeId: instance.typeId,\n displayName: instance.displayName,\n sourceKind: instance.sourceKind,\n publicConfig: instance.publicConfig,\n tags: instance.tags,\n setupStatus: instance.setupStatus,\n createdAt: instance.createdAt,\n updatedAt: instance.updatedAt,\n latestHealth: latestTestResult?.health,\n oauth2Connection,\n };\n }\n\n private async toOAuth2ConnectionDto(\n instance: CredentialInstanceRecord,\n ): Promise<CredentialOAuth2ConnectionDto | undefined> {\n const credentialType = this.credentialTypeRegistry.getCredentialType(instance.typeId);\n if (credentialType?.definition.auth?.kind !== \"oauth2\") {\n return undefined;\n }\n const providerId =\n \"providerId\" in credentialType.definition.auth ? credentialType.definition.auth.providerId : \"custom\";\n const material = await this.credentialStore.getOAuth2Material(instance.instanceId);\n if (!material) {\n const requestedScopes = this.credentialOAuth2ScopeResolver.resolveRequestedScopes(\n credentialType.definition.auth,\n instance.publicConfig,\n );\n return {\n status: \"disconnected\",\n providerId,\n scopes: [...requestedScopes],\n };\n }\n return {\n status: \"connected\",\n providerId: material.providerId,\n connectedEmail: material.connectedEmail,\n connectedAt: material.connectedAt,\n scopes: material.scopes,\n updatedAt: material.updatedAt,\n };\n }\n}\n","import type {\n CredentialBinding,\n CredentialBindingKey,\n CredentialInstanceId,\n CredentialRequirement,\n WorkflowDefinition,\n WorkflowRepository,\n} from \"@codemation/core\";\n\nimport { CoreTokens, inject, injectable } from \"@codemation/core\";\n\nimport { ApplicationRequestError } from \"../../application/ApplicationRequestError\";\n\nimport type {\n WorkflowCredentialHealthDto,\n WorkflowCredentialHealthSlotDto,\n} from \"../../application/contracts/CredentialContractsRegistry\";\n\nimport { ApplicationTokens } from \"../../applicationTokens\";\n\nimport { WorkflowCredentialNodeResolver } from \"./WorkflowCredentialNodeResolver\";\nimport { CredentialInstanceService } from \"./CredentialInstanceService\";\nimport type { CredentialStore, MutableCredentialSessionService } from \"./CredentialServices\";\n\n@injectable()\nexport class CredentialBindingService {\n constructor(\n @inject(ApplicationTokens.CredentialStore)\n private readonly credentialStore: CredentialStore,\n @inject(CredentialInstanceService)\n private readonly credentialInstanceService: CredentialInstanceService,\n @inject(CoreTokens.WorkflowRepository)\n private readonly workflowRepository: WorkflowRepository,\n @inject(CoreTokens.CredentialSessionService)\n private readonly credentialSessionService: MutableCredentialSessionService,\n @inject(WorkflowCredentialNodeResolver)\n private readonly workflowCredentialNodeResolver: WorkflowCredentialNodeResolver,\n ) {}\n\n async upsertBinding(\n args: Readonly<{ workflowId: string; nodeId: string; slotKey: string; instanceId: CredentialInstanceId }>,\n ): Promise<CredentialBinding> {\n const workflow = this.requireWorkflow(args.workflowId);\n const requirement = this.requireRequirement(workflow, args.nodeId, args.slotKey);\n const instance = await this.credentialInstanceService.requireInstance(args.instanceId);\n if (!requirement.acceptedTypes.includes(instance.typeId)) {\n throw new ApplicationRequestError(\n 400,\n `Credential instance ${instance.instanceId} (${instance.typeId}) is not compatible with slot ${args.slotKey}. Accepted types: ${requirement.acceptedTypes.join(\", \")}`,\n );\n }\n const binding: CredentialBinding = {\n key: {\n workflowId: args.workflowId,\n nodeId: args.nodeId,\n slotKey: args.slotKey,\n },\n instanceId: args.instanceId,\n updatedAt: new Date().toISOString(),\n };\n await this.credentialStore.upsertBinding(binding);\n this.credentialSessionService.evictBinding(binding.key);\n return binding;\n }\n\n async listWorkflowHealth(workflowId: string): Promise<WorkflowCredentialHealthDto> {\n const workflow = this.requireWorkflow(workflowId);\n const bindings = await this.credentialStore.listBindingsByWorkflowId(workflowId);\n const bindingsByKey = new Map(bindings.map((binding) => [this.toBindingKeyString(binding.key), binding] as const));\n const slots: WorkflowCredentialHealthSlotDto[] = [];\n for (const slotRef of this.workflowCredentialNodeResolver.listSlots(workflow)) {\n const requirement = slotRef.requirement;\n const bindingKey = {\n workflowId,\n nodeId: slotRef.nodeId,\n slotKey: requirement.slotKey,\n } satisfies CredentialBindingKey;\n const binding = bindingsByKey.get(this.toBindingKeyString(bindingKey));\n if (!binding) {\n slots.push({\n workflowId,\n nodeId: slotRef.nodeId,\n nodeName: slotRef.nodeName,\n requirement,\n health: {\n status: requirement.optional ? \"optional-unbound\" : \"unbound\",\n },\n });\n continue;\n }\n const instance = await this.credentialInstanceService.requireInstance(binding.instanceId);\n const latestTestResult = await this.credentialStore.getLatestTestResult(instance.instanceId);\n slots.push({\n workflowId,\n nodeId: slotRef.nodeId,\n nodeName: slotRef.nodeName,\n requirement,\n instance: {\n instanceId: instance.instanceId,\n typeId: instance.typeId,\n displayName: instance.displayName,\n setupStatus: instance.setupStatus,\n },\n health: {\n status: latestTestResult?.health.status ?? \"unknown\",\n message: latestTestResult?.health.message,\n testedAt: latestTestResult?.health.testedAt,\n },\n });\n }\n return {\n workflowId,\n slots,\n };\n }\n\n private requireWorkflow(workflowId: string): WorkflowDefinition {\n const workflow = this.workflowRepository.get(decodeURIComponent(workflowId));\n if (!workflow) {\n throw new ApplicationRequestError(404, `Unknown workflowId: ${workflowId}`);\n }\n return workflow;\n }\n\n private requireRequirement(workflow: WorkflowDefinition, nodeId: string, slotKey: string): CredentialRequirement {\n const resolved = this.workflowCredentialNodeResolver.findRequirement(workflow, nodeId, slotKey);\n if (!resolved) {\n if (!this.workflowCredentialNodeResolver.isCredentialNodeIdInWorkflow(workflow, nodeId)) {\n throw new ApplicationRequestError(404, `Unknown workflow node: ${nodeId}`);\n }\n throw new ApplicationRequestError(400, `Node ${nodeId} does not declare credential slot ${slotKey}.`);\n }\n return resolved.requirement;\n }\n\n private toBindingKeyString(bindingKey: CredentialBindingKey): string {\n return `${bindingKey.workflowId}:${bindingKey.nodeId}:${bindingKey.slotKey}`;\n }\n}\n","import { inject, injectable } from \"@codemation/core\";\n\nimport { ApplicationTokens } from \"../../applicationTokens\";\n\nimport { CredentialMaterialResolver } from \"./CredentialMaterialResolver\";\nimport { CredentialSecretCipher } from \"./CredentialSecretCipher\";\nimport type { CredentialInstanceRecord, CredentialStore, JsonRecord } from \"./CredentialServices\";\nimport { CredentialTypeRegistryImpl } from \"./CredentialServices\";\n\n@injectable()\nexport class CredentialRuntimeMaterialService {\n constructor(\n @inject(ApplicationTokens.CredentialStore)\n private readonly credentialStore: CredentialStore,\n @inject(CredentialMaterialResolver)\n private readonly credentialMaterialResolver: CredentialMaterialResolver,\n @inject(CredentialSecretCipher)\n private readonly credentialSecretCipher: CredentialSecretCipher,\n @inject(CredentialTypeRegistryImpl)\n private readonly credentialTypeRegistry: CredentialTypeRegistryImpl,\n ) {}\n\n async compose(instance: CredentialInstanceRecord): Promise<JsonRecord> {\n const baseMaterial = await this.credentialMaterialResolver.resolveMaterial(instance);\n const auth = this.credentialTypeRegistry.getCredentialType(instance.typeId)?.definition.auth;\n if (auth?.kind !== \"oauth2\") {\n return baseMaterial;\n }\n const oauth2Material = await this.credentialStore.getOAuth2Material(instance.instanceId);\n if (!oauth2Material) {\n return baseMaterial;\n }\n const decryptedOauth2Material = this.credentialSecretCipher.decrypt(oauth2Material);\n return Object.freeze({\n ...baseMaterial,\n ...decryptedOauth2Material,\n });\n }\n}\n","import type {\n CredentialBindingKey,\n CredentialInstanceId,\n CredentialSessionService,\n WorkflowRepository,\n} from \"@codemation/core\";\n\nimport { CoreTokens, CredentialUnboundError, inject, injectable } from \"@codemation/core\";\n\nimport { ApplicationRequestError } from \"../../application/ApplicationRequestError\";\n\nimport { ApplicationTokens } from \"../../applicationTokens\";\n\nimport { WorkflowCredentialNodeResolver } from \"./WorkflowCredentialNodeResolver\";\nimport { CredentialFieldEnvOverlayService } from \"./CredentialFieldEnvOverlayService\";\nimport { CredentialRuntimeMaterialService } from \"./CredentialRuntimeMaterialService\";\nimport type { CredentialStore } from \"./CredentialServices\";\nimport { CredentialTypeRegistryImpl } from \"./CredentialServices\";\n\n@injectable()\nexport class CredentialSessionServiceImpl implements CredentialSessionService {\n private readonly cachedSessionsByInstanceId = new Map<CredentialInstanceId, Promise<unknown>>();\n private readonly cachedInstanceIdsByBindingKey = new Map<string, CredentialInstanceId>();\n\n constructor(\n @inject(ApplicationTokens.CredentialStore)\n private readonly credentialStore: CredentialStore,\n @inject(CredentialRuntimeMaterialService)\n private readonly credentialRuntimeMaterialService: CredentialRuntimeMaterialService,\n @inject(CredentialFieldEnvOverlayService)\n private readonly credentialFieldEnvOverlayService: CredentialFieldEnvOverlayService,\n @inject(CredentialTypeRegistryImpl)\n private readonly credentialTypeRegistry: CredentialTypeRegistryImpl,\n @inject(CoreTokens.WorkflowRepository)\n private readonly workflowRepository: WorkflowRepository,\n @inject(WorkflowCredentialNodeResolver)\n private readonly workflowCredentialNodeResolver: WorkflowCredentialNodeResolver,\n ) {}\n\n async getSession<TSession = unknown>(\n args: Readonly<{ workflowId: string; nodeId: string; slotKey: string }>,\n ): Promise<TSession> {\n const workflow = this.workflowRepository.get(decodeURIComponent(args.workflowId));\n const displayLabel = workflow\n ? this.workflowCredentialNodeResolver.describeCredentialNodeDisplay(workflow, args.nodeId)\n : undefined;\n const requirement = workflow\n ? this.workflowCredentialNodeResolver.findRequirement(workflow, args.nodeId, args.slotKey)?.requirement\n : undefined;\n const bindingKey: CredentialBindingKey = {\n workflowId: args.workflowId,\n nodeId: args.nodeId,\n slotKey: args.slotKey,\n };\n const binding = await this.credentialStore.getBinding(bindingKey);\n if (!binding) {\n const unbound = new CredentialUnboundError(bindingKey, requirement?.acceptedTypes ?? []);\n if (displayLabel) {\n throw new Error(`${displayLabel}: ${unbound.message}`, { cause: unbound });\n }\n throw unbound;\n }\n const bindingCacheKey = this.toBindingKeyString(bindingKey);\n this.cachedInstanceIdsByBindingKey.set(bindingCacheKey, binding.instanceId);\n const cachedSession = this.cachedSessionsByInstanceId.get(binding.instanceId);\n if (cachedSession) {\n return (await cachedSession) as TSession;\n }\n const nextSessionPromise = this.createSession(binding.instanceId, displayLabel).catch((error) => {\n this.cachedSessionsByInstanceId.delete(binding.instanceId);\n throw error;\n });\n this.cachedSessionsByInstanceId.set(binding.instanceId, nextSessionPromise);\n return (await nextSessionPromise) as TSession;\n }\n\n evictInstance(instanceId: CredentialInstanceId): void {\n this.cachedSessionsByInstanceId.delete(instanceId);\n }\n\n evictBinding(bindingKey: CredentialBindingKey): void {\n const cacheKey = this.toBindingKeyString(bindingKey);\n const instanceId = this.cachedInstanceIdsByBindingKey.get(cacheKey);\n if (instanceId) {\n this.cachedSessionsByInstanceId.delete(instanceId);\n }\n this.cachedInstanceIdsByBindingKey.delete(cacheKey);\n }\n\n private async createSession(instanceId: CredentialInstanceId, displayLabel?: string): Promise<unknown> {\n const instance = await this.credentialStore.getInstance(instanceId);\n if (!instance) {\n throw new ApplicationRequestError(404, `Unknown credential instance: ${instanceId}`);\n }\n const credentialType = this.credentialTypeRegistry.getCredentialType(instance.typeId);\n if (!credentialType) {\n const prefix = displayLabel ? `${displayLabel}: ` : \"\";\n throw new ApplicationRequestError(\n 400,\n `${prefix}Credential type \"${instance.typeId}\" is not registered in this runtime (binding points at an unknown type).`,\n );\n }\n const material = await this.credentialRuntimeMaterialService.compose(instance);\n const { resolvedPublicConfig, resolvedMaterial } = this.credentialFieldEnvOverlayService.apply({\n definition: credentialType.definition,\n publicConfig: instance.publicConfig,\n material,\n });\n return await credentialType.createSession({\n instance,\n material: resolvedMaterial,\n publicConfig: resolvedPublicConfig,\n });\n }\n\n private toBindingKeyString(bindingKey: CredentialBindingKey): string {\n return `${bindingKey.workflowId}:${bindingKey.nodeId}:${bindingKey.slotKey}`;\n }\n}\n","import { randomUUID } from \"node:crypto\";\n\nimport type { CredentialHealth, CredentialInstanceId, CredentialTypeId } from \"@codemation/core\";\n\nimport { CoreTokens, inject, injectable } from \"@codemation/core\";\n\nimport { ApplicationRequestError } from \"../../application/ApplicationRequestError\";\n\nimport { ApplicationTokens } from \"../../applicationTokens\";\n\nimport { CredentialFieldEnvOverlayService } from \"./CredentialFieldEnvOverlayService\";\nimport { CredentialInstanceService } from \"./CredentialInstanceService\";\nimport { CredentialRuntimeMaterialService } from \"./CredentialRuntimeMaterialService\";\nimport type { CredentialStore, AnyCredentialType, MutableCredentialSessionService } from \"./CredentialServices\";\nimport { CredentialTypeRegistryImpl } from \"./CredentialServices\";\n\n@injectable()\nexport class CredentialTestService {\n constructor(\n @inject(CredentialInstanceService)\n private readonly credentialInstanceService: CredentialInstanceService,\n @inject(CredentialRuntimeMaterialService)\n private readonly credentialRuntimeMaterialService: CredentialRuntimeMaterialService,\n @inject(CredentialFieldEnvOverlayService)\n private readonly credentialFieldEnvOverlayService: CredentialFieldEnvOverlayService,\n @inject(CredentialTypeRegistryImpl)\n private readonly credentialTypeRegistry: CredentialTypeRegistryImpl,\n @inject(ApplicationTokens.CredentialStore)\n private readonly credentialStore: CredentialStore,\n @inject(CoreTokens.CredentialSessionService)\n private readonly credentialSessionService: MutableCredentialSessionService,\n ) {}\n\n async test(instanceId: CredentialInstanceId): Promise<CredentialHealth> {\n const instance = await this.credentialInstanceService.requireInstance(instanceId);\n const credentialType = this.requireCredentialType(instance.typeId);\n const material = await this.credentialRuntimeMaterialService.compose(instance);\n const { resolvedPublicConfig, resolvedMaterial } = this.credentialFieldEnvOverlayService.apply({\n definition: credentialType.definition,\n publicConfig: instance.publicConfig,\n material,\n });\n const health = await credentialType.test({\n instance,\n material: resolvedMaterial,\n publicConfig: resolvedPublicConfig,\n });\n const testedAt = health.testedAt ?? new Date().toISOString();\n await this.credentialStore.saveTestResult({\n testId: randomUUID(),\n instanceId,\n health: {\n ...health,\n testedAt,\n },\n testedAt,\n expiresAt: health.expiresAt,\n });\n this.credentialSessionService.evictInstance(instanceId);\n return {\n ...health,\n testedAt,\n };\n }\n\n private requireCredentialType(typeId: CredentialTypeId): AnyCredentialType {\n const credentialType = this.credentialTypeRegistry.getCredentialType(typeId);\n if (!credentialType) {\n throw new ApplicationRequestError(400, `Unknown credential type: ${typeId}`);\n }\n return credentialType;\n }\n}\n"],"mappings":";;;;;;;;;;AAQA,I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,EAAC,aAAa;AAC5D,QAAM,KAAK,gBAAgB,eAAe;GACxC,QAAQ,YAAY;GACpB;GACA,QAAQ;IACN,GAAG;IACH;IACD;GACD;GACA,WAAW,OAAO;GACnB,CAAC;AACF,OAAK,yBAAyB,cAAc,WAAW;AACvD,SAAO;GACL,GAAG;GACH;GACD;;CAGH,AAAQ,sBAAsB,QAA6C;EACzE,MAAM,iBAAiB,KAAK,uBAAuB,kBAAkB,OAAO;AAC5E,MAAI,CAAC,eACH,OAAM,IAAI,wBAAwB,KAAK,4BAA4B,SAAS;AAE9E,SAAO;;;;CAtDV,YAAY;oBAGR,OAAO,0BAA0B;oBAEjC,OAAO,iCAAiC;oBAExC,OAAO,iCAAiC;oBAExC,OAAO,2BAA2B;oBAElC,OAAO,kBAAkB,gBAAgB;oBAEzC,OAAO,WAAW,yBAAyB"}
@@ -1,4 +1,4 @@
1
- import { r as AppConfig } from "./CodemationAppContext-KqDoeHqN.js";
1
+ import { r as AppConfig } from "./CodemationAppContext-P7P-xZhQ.js";
2
2
  import { a as CodemationAuthConfig } from "./CodemationWhitelabelConfig-D5rYcLlj.js";
3
3
  import { a as CodemationFrontendAuthSnapshot, n as InternalAuthBootstrap, r as FrontendAppConfig, t as PublicFrontendBootstrap } from "./PublicFrontendBootstrap-ci0Vwxrb.js";
4
4
 
@@ -90,4 +90,4 @@ declare class PublicFrontendBootstrapFactory {
90
90
  }
91
91
  //#endregion
92
92
  export { WorkflowDto as a, CodemationFrontendAuthSnapshotFactory as i, InternalAuthBootstrapFactory as n, WorkflowSummary as o, FrontendAppConfigFactory as r, PublicFrontendBootstrapFactory as t };
93
- //# sourceMappingURL=PublicFrontendBootstrapFactory-DTA1iDo0.d.ts.map
93
+ //# sourceMappingURL=PublicFrontendBootstrapFactory-D0_ds7nS.d.ts.map
@@ -1,5 +1,5 @@
1
- import "./index-Dd6BrWyH.js";
2
- import { a as defineCodemationApp, i as FriendlyCodemationExecutionConfig, n as DefinePluginOptions, o as definePlugin, r as FriendlyCodemationDatabaseConfig, s as workflow, t as DefineCodemationAppOptions } from "./CodemationAuthoring.types-BP6Inucu.js";
3
- import { _ as CodemationEngineExecutionLimitsConfig, b as CodemationSchedulerConfig, c as CodemationPluginContext, d as CodemationAppSchedulerConfig, f as CodemationAppSchedulerKind, g as CodemationDatabaseKind, h as CodemationDatabaseConfig, m as CodemationConfig, n as CodemationRegistrationContextBase, o as CodemationPlugin, p as CodemationApplicationRuntimeConfig, s as CodemationPluginConfig, t as CodemationAppContext, u as CodemationAppDefinition, v as CodemationEventBusConfig, x as CodemationSchedulerKind, y as CodemationEventBusKind } from "./CodemationAppContext-KqDoeHqN.js";
1
+ import "./index-CeS2saCe.js";
2
+ import { a as defineCodemationApp, i as FriendlyCodemationExecutionConfig, n as DefinePluginOptions, o as definePlugin, r as FriendlyCodemationDatabaseConfig, s as workflow, t as DefineCodemationAppOptions } from "./CodemationAuthoring.types-OMYu7vKP.js";
3
+ import { _ as CodemationEngineExecutionLimitsConfig, b as CodemationSchedulerConfig, c as CodemationPluginContext, d as CodemationAppSchedulerConfig, f as CodemationAppSchedulerKind, g as CodemationDatabaseKind, h as CodemationDatabaseConfig, m as CodemationConfig, n as CodemationRegistrationContextBase, o as CodemationPlugin, p as CodemationApplicationRuntimeConfig, s as CodemationPluginConfig, t as CodemationAppContext, u as CodemationAppDefinition, v as CodemationEventBusConfig, x as CodemationSchedulerKind, y as CodemationEventBusKind } from "./CodemationAppContext-P7P-xZhQ.js";
4
4
  import "./CodemationWhitelabelConfig-D5rYcLlj.js";
5
5
  export { type CodemationAppContext, type CodemationAppDefinition, type CodemationAppSchedulerConfig, type CodemationAppSchedulerKind, type CodemationApplicationRuntimeConfig, type CodemationConfig, type CodemationDatabaseConfig, type CodemationDatabaseKind, type CodemationEngineExecutionLimitsConfig, type CodemationEventBusConfig, type CodemationEventBusKind, type CodemationPlugin, type CodemationPluginConfig, type CodemationPluginContext, type CodemationRegistrationContextBase, type CodemationSchedulerConfig, type CodemationSchedulerKind, type DefineCodemationAppOptions, type DefinePluginOptions, type FriendlyCodemationDatabaseConfig, type FriendlyCodemationExecutionConfig, defineCodemationApp, definePlugin, workflow };
@@ -1,6 +1,6 @@
1
- import "./index-Dd6BrWyH.js";
2
- import "./CodemationAppContext-KqDoeHqN.js";
1
+ import "./index-CeS2saCe.js";
2
+ import "./CodemationAppContext-P7P-xZhQ.js";
3
3
  import "./CodemationWhitelabelConfig-D5rYcLlj.js";
4
- import "./CodemationConfigNormalizer-DIAE0VHw.js";
5
- import { i as CodemationConsumerAppResolver, n as CodemationConsumerConfigResolution, r as CodemationConsumerApp, t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-nj9kTmfJ.js";
4
+ import "./CodemationConfigNormalizer-BCtBrJDe.js";
5
+ import { i as CodemationConsumerAppResolver, n as CodemationConsumerConfigResolution, r as CodemationConsumerApp, t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-evvw4b_a.js";
6
6
  export { type CodemationConsumerApp, CodemationConsumerAppResolver, CodemationConsumerConfigLoader, type CodemationConsumerConfigResolution };
@@ -1,7 +1,7 @@
1
- import { b as CredentialSessionFactoryArgs, l as AnyCredentialType, p as CredentialHealth } from "./index-Dd6BrWyH.js";
2
- import "./CodemationAppContext-KqDoeHqN.js";
1
+ import { b as CredentialSessionFactoryArgs, l as AnyCredentialType, p as CredentialHealth } from "./index-CeS2saCe.js";
2
+ import "./CodemationAppContext-P7P-xZhQ.js";
3
3
  import "./CodemationWhitelabelConfig-D5rYcLlj.js";
4
- import { a as CredentialInstanceService, i as CredentialBindingService, n as CredentialType } from "./CredentialServices-BFQD_VN1.js";
4
+ import { a as CredentialInstanceService, i as CredentialBindingService, n as CredentialType } from "./CredentialServices-0Hk8RFY1.js";
5
5
 
6
6
  //#region src/infrastructure/credentials/OpenAiApiKeyCredentialShapes.types.d.ts
7
7
  /**
@@ -1,6 +1,6 @@
1
1
  import "./decorateParam-D7WPDFAf.js";
2
2
  import "./decorate-Dq0XLibd.js";
3
- import { a as CredentialInstanceService, h as OpenAiApiKeyCredentialHealthTester, i as CredentialBindingService, m as OpenAiApiKeyCredentialTypeFactory } from "./CredentialServices-BPKUF8Xs.js";
3
+ import { a as CredentialInstanceService, h as OpenAiApiKeyCredentialHealthTester, i as CredentialBindingService, m as OpenAiApiKeyCredentialTypeFactory } from "./CredentialServices-BNBMFOPt.js";
4
4
 
5
5
  //#region src/credentials.ts
6
6
  const defaultOpenAiApiKeyCredentialTypeFactory = new OpenAiApiKeyCredentialTypeFactory(new OpenAiApiKeyCredentialHealthTester(globalThis.fetch));
@@ -1,4 +1,4 @@
1
- import { F as WorkflowDefinition, H as Container } from "./index-Dd6BrWyH.js";
1
+ import { I as WorkflowDefinition, U as Container } from "./index-CeS2saCe.js";
2
2
 
3
3
  //#region src/presentation/server/CodemationTsyringeParamInfoReader.d.ts
4
4
  declare class CodemationTsyringeParamInfoReader {
@@ -66,6 +66,98 @@ interface ExponentialRetryPolicySpec {
66
66
  readonly jitter?: boolean;
67
67
  }
68
68
  //#endregion
69
+ //#region ../core/src/contracts/telemetryTypes.d.ts
70
+ type TelemetryAttributePrimitive = string | number | boolean | null;
71
+ interface TelemetryAttributes {
72
+ readonly [key: string]: TelemetryAttributePrimitive | undefined;
73
+ }
74
+ interface TelemetryMetricRecord {
75
+ readonly name: string;
76
+ readonly value: number;
77
+ readonly unit?: string;
78
+ readonly attributes?: TelemetryAttributes;
79
+ }
80
+ interface TelemetrySpanEventRecord {
81
+ readonly name: string;
82
+ readonly occurredAt?: Date;
83
+ readonly attributes?: TelemetryAttributes;
84
+ }
85
+ interface TelemetryArtifactAttachment {
86
+ readonly kind: string;
87
+ readonly contentType: string;
88
+ readonly previewText?: string;
89
+ readonly previewJson?: JsonValue;
90
+ readonly payloadText?: string;
91
+ readonly payloadJson?: JsonValue;
92
+ readonly bytes?: number;
93
+ readonly truncated?: boolean;
94
+ readonly expiresAt?: Date;
95
+ }
96
+ interface TelemetryArtifactReference {
97
+ readonly artifactId: string;
98
+ readonly traceId?: string;
99
+ readonly spanId?: string;
100
+ }
101
+ interface TelemetrySpanEnd {
102
+ readonly status?: "ok" | "error";
103
+ readonly statusMessage?: string;
104
+ readonly endedAt?: Date;
105
+ readonly attributes?: TelemetryAttributes;
106
+ }
107
+ interface TelemetryChildSpanStart {
108
+ readonly name: string;
109
+ readonly kind?: "internal" | "client";
110
+ readonly startedAt?: Date;
111
+ readonly attributes?: TelemetryAttributes;
112
+ }
113
+ interface TelemetryScope {
114
+ readonly traceId?: string;
115
+ readonly spanId?: string;
116
+ readonly costTracking?: CostTrackingTelemetry;
117
+ addSpanEvent(args: TelemetrySpanEventRecord): Promise<void> | void;
118
+ recordMetric(args: TelemetryMetricRecord): Promise<void> | void;
119
+ attachArtifact(args: TelemetryArtifactAttachment): Promise<TelemetryArtifactReference> | TelemetryArtifactReference;
120
+ }
121
+ interface TelemetrySpanScope extends TelemetryScope {
122
+ readonly traceId: string;
123
+ readonly spanId: string;
124
+ end(args?: TelemetrySpanEnd): Promise<void> | void;
125
+ }
126
+ interface NodeExecutionTelemetry extends ExecutionTelemetry, TelemetrySpanScope {
127
+ startChildSpan(args: TelemetryChildSpanStart): TelemetrySpanScope;
128
+ }
129
+ interface ExecutionTelemetry extends TelemetryScope {
130
+ readonly traceId: string;
131
+ readonly spanId: string;
132
+ forNode(args: Readonly<{
133
+ nodeId: NodeId;
134
+ activationId: NodeActivationId;
135
+ }>): NodeExecutionTelemetry;
136
+ }
137
+ //#endregion
138
+ //#region ../core/src/contracts/CostTrackingTelemetryContract.d.ts
139
+ type CostTrackingComponent = "chat" | "ocr" | "rag";
140
+ interface CostTrackingUsageRecord {
141
+ readonly component: CostTrackingComponent;
142
+ readonly provider: string;
143
+ readonly operation: string;
144
+ readonly pricingKey: string;
145
+ readonly usageUnit: string;
146
+ readonly quantity: number;
147
+ readonly modelName?: string;
148
+ readonly attributes?: TelemetryAttributes;
149
+ }
150
+ interface CostTrackingPriceQuote {
151
+ readonly currency: string;
152
+ readonly currencyScale: number;
153
+ readonly estimatedAmountMinor: number;
154
+ readonly estimateKind: "catalog";
155
+ }
156
+ interface CostTrackingTelemetry {
157
+ captureUsage(args: CostTrackingUsageRecord): Promise<CostTrackingPriceQuote | undefined>;
158
+ forScope(scope: TelemetryScope): CostTrackingTelemetry;
159
+ }
160
+ //#endregion
69
161
  //#region ../core/src/contracts/runTypes.d.ts
70
162
  interface RunExecutionOptions {
71
163
  /** Run-intent override: force the inline scheduler and bypass node-level offload decisions. */
@@ -148,6 +240,7 @@ interface NodeExecutionError {
148
240
  message: string;
149
241
  name?: string;
150
242
  stack?: string;
243
+ details?: JsonValue;
151
244
  }
152
245
  interface NodeExecutionSnapshot {
153
246
  runId: RunId;
@@ -639,6 +732,7 @@ interface ExecutionContext {
639
732
  now: () => Date;
640
733
  data: RunDataSnapshot;
641
734
  nodeState?: NodeExecutionStatePublisher;
735
+ telemetry: ExecutionTelemetry;
642
736
  binary: ExecutionBinaryService;
643
737
  getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
644
738
  }
@@ -646,6 +740,7 @@ interface NodeExecutionContext<TConfig$1 extends NodeConfigBase = NodeConfigBase
646
740
  nodeId: NodeId;
647
741
  activationId: NodeActivationId;
648
742
  config: TConfig$1;
743
+ telemetry: NodeExecutionTelemetry;
649
744
  binary: NodeBinaryAttachmentService;
650
745
  }
651
746
  interface NodeExecutionRequest {
@@ -892,10 +987,16 @@ interface WorkflowStoragePolicyDecisionArgs {
892
987
  interface WorkflowPrunePolicySpec {
893
988
  readonly runDataRetentionSeconds?: number;
894
989
  readonly binaryRetentionSeconds?: number;
990
+ readonly telemetrySpanRetentionSeconds?: number;
991
+ readonly telemetryArtifactRetentionSeconds?: number;
992
+ readonly telemetryMetricRetentionSeconds?: number;
895
993
  }
896
994
  interface PersistedRunPolicySnapshot {
897
995
  readonly retentionSeconds?: number;
898
996
  readonly binaryRetentionSeconds?: number;
997
+ readonly telemetrySpanRetentionSeconds?: number;
998
+ readonly telemetryArtifactRetentionSeconds?: number;
999
+ readonly telemetryMetricRetentionSeconds?: number;
899
1000
  readonly storagePolicy: WorkflowStoragePolicyMode;
900
1001
  }
901
1002
  interface WorkflowErrorHandler {
@@ -1161,6 +1262,8 @@ interface AgentGuardrailConfig {
1161
1262
  interface ChatModelConfig {
1162
1263
  readonly type: TypeToken<ChatModelFactory<ChatModelConfig>>;
1163
1264
  readonly name: string;
1265
+ readonly provider?: string;
1266
+ readonly modelName?: string;
1164
1267
  readonly presentation?: AgentCanvasPresentation;
1165
1268
  getCredentialRequirements?(): ReadonlyArray<CredentialRequirement>;
1166
1269
  }
@@ -1379,5 +1482,5 @@ declare class RunIntentService {
1379
1482
  private createWebhookExecutionOptions;
1380
1483
  }
1381
1484
  //#endregion
1382
- export { RunCurrentState as $, Items as A, NodeExecutionScheduler as B, CredentialType as C, ActivationIdFactory as D, CredentialTypeRegistry as E, WorkflowDefinition as F, RunEvent as G, Container as H, WorkflowId as I, AnyRunnableNodeConfig as J, RunEventBus as K, BinaryStorage as L, RunIdFactory as M, RunnableNodeConfig as N, BinaryAttachment as O, RunnableNodeOutputJson as P, PersistedRunState as Q, NodeExecutionContext as R, CredentialSetupStatus as S, CredentialTypeId as T, TypeToken as U, WorkflowRepository as V, EngineExecutionLimitsPolicyConfig as W, WebhookInvocationMatch as X, WorkflowActivationPolicy as Y, WorkflowRunDetailDto as Z, CredentialMaterialSourceKind as _, ChatModelConfig as a, CredentialSessionFactoryArgs as b, DefinedNodeConfigInput as c, CredentialBindingKey as d, RunPruneCandidate as et, CredentialFieldSchema as f, CredentialJsonRecord as g, CredentialInstanceRecord as h, AgentMessageConfig as i, RunId as j, Item as k, AnyCredentialType as l, CredentialInstanceId as m, Engine as n, Clock as nt, ToolConfig as o, CredentialHealth as p, ChainCursor as q, AgentGuardrailConfig as r, DefinedNode as s, RunIntentService as t, RunSummary as tt, CredentialBinding as u, CredentialOAuth2AuthDefinition as v, CredentialTypeDefinition as w, CredentialSessionService as x, CredentialRequirement as y, NodeExecutionRequestHandler as z };
1383
- //# sourceMappingURL=index-Dd6BrWyH.d.ts.map
1485
+ export { PersistedRunState as $, Items as A, NodeExecutionRequestHandler as B, CredentialType as C, ActivationIdFactory as D, CredentialTypeRegistry as E, RunnableNodeOutputJson as F, EngineExecutionLimitsPolicyConfig as G, WorkflowRepository as H, WorkflowDefinition as I, ChainCursor as J, RunEvent as K, WorkflowId as L, RunId as M, RunIdFactory as N, BinaryAttachment as O, RunnableNodeConfig as P, WorkflowRunDetailDto as Q, BinaryStorage as R, CredentialSetupStatus as S, CredentialTypeId as T, Container as U, NodeExecutionScheduler as V, TypeToken as W, WorkflowActivationPolicy as X, AnyRunnableNodeConfig as Y, WebhookInvocationMatch as Z, CredentialMaterialSourceKind as _, ChatModelConfig as a, TelemetryMetricRecord as at, CredentialSessionFactoryArgs as b, DefinedNodeConfigInput as c, CredentialBindingKey as d, RunCurrentState as et, CredentialFieldSchema as f, CredentialJsonRecord as g, CredentialInstanceRecord as h, AgentMessageConfig as i, TelemetryAttributes as it, PersistedRunPolicySnapshot as j, Item as k, AnyCredentialType as l, CredentialInstanceId as m, Engine as n, RunSummary as nt, ToolConfig as o, TelemetrySpanEventRecord as ot, CredentialHealth as p, RunEventBus as q, AgentGuardrailConfig as r, TelemetryArtifactAttachment as rt, DefinedNode as s, Clock as st, RunIntentService as t, RunPruneCandidate as tt, CredentialBinding as u, CredentialOAuth2AuthDefinition as v, CredentialTypeDefinition as w, CredentialSessionService as x, CredentialRequirement as y, NodeExecutionContext as z };
1486
+ //# sourceMappingURL=index-CeS2saCe.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,17 +1,18 @@
1
- import "./index-Dd6BrWyH.js";
2
- import { a as defineCodemationApp, i as FriendlyCodemationExecutionConfig, n as DefinePluginOptions, o as definePlugin, r as FriendlyCodemationDatabaseConfig, s as workflow, t as DefineCodemationAppOptions } from "./CodemationAuthoring.types-BP6Inucu.js";
3
- import { S as CodemationWorkflowDiscovery, _ as CodemationEngineExecutionLimitsConfig, a as AppPluginLoadSummary, b as CodemationSchedulerConfig, c as CodemationPluginContext, d as CodemationAppSchedulerConfig, f as CodemationAppSchedulerKind, g as CodemationDatabaseKind, h as CodemationDatabaseConfig, l as CodemationPluginPackageMetadata, m as CodemationConfig, n as CodemationRegistrationContextBase, o as CodemationPlugin, p as CodemationApplicationRuntimeConfig, r as AppConfig, s as CodemationPluginConfig, t as CodemationAppContext, u as CodemationAppDefinition, v as CodemationEventBusConfig, w as CodemationClassToken, x as CodemationSchedulerKind, y as CodemationEventBusKind } from "./CodemationAppContext-KqDoeHqN.js";
1
+ import "./index-CeS2saCe.js";
2
+ import { a as defineCodemationApp, i as FriendlyCodemationExecutionConfig, n as DefinePluginOptions, o as definePlugin, r as FriendlyCodemationDatabaseConfig, s as workflow, t as DefineCodemationAppOptions } from "./CodemationAuthoring.types-OMYu7vKP.js";
3
+ import { S as CodemationWorkflowDiscovery, _ as CodemationEngineExecutionLimitsConfig, a as AppPluginLoadSummary, b as CodemationSchedulerConfig, c as CodemationPluginContext, d as CodemationAppSchedulerConfig, f as CodemationAppSchedulerKind, g as CodemationDatabaseKind, h as CodemationDatabaseConfig, l as CodemationPluginPackageMetadata, m as CodemationConfig, n as CodemationRegistrationContextBase, o as CodemationPlugin, p as CodemationApplicationRuntimeConfig, r as AppConfig, s as CodemationPluginConfig, t as CodemationAppContext, u as CodemationAppDefinition, v as CodemationEventBusConfig, w as CodemationClassToken, x as CodemationSchedulerKind, y as CodemationEventBusKind } from "./CodemationAppContext-P7P-xZhQ.js";
4
4
  import { a as CodemationAuthConfig, c as CodemationAuthOidcProviderConfig, i as CodemationLogRule, n as CodemationLogConfig, o as CodemationAuthKind, r as CodemationLogLevelName, s as CodemationAuthOAuthProviderConfig, t as CodemationWhitelabelConfig } from "./CodemationWhitelabelConfig-D5rYcLlj.js";
5
+ import "./LogLevelPolicy-CkiJAH75.js";
5
6
  import { a as CodemationFrontendAuthSnapshot, i as CodemationFrontendAuthProviderSnapshot, n as InternalAuthBootstrap, r as FrontendAppConfig, t as PublicFrontendBootstrap } from "./PublicFrontendBootstrap-ci0Vwxrb.js";
6
7
  import { i as CodemationFrontendAuthSnapshotJsonCodec, n as InternalAuthBootstrapJsonCodec, r as FrontendAppConfigJsonCodec, t as PublicFrontendBootstrapJsonCodec } from "./PublicFrontendBootstrapJsonCodec-Ja0GQgpp.js";
7
- import "./CodemationConfigNormalizer-DIAE0VHw.js";
8
- import { t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-nj9kTmfJ.js";
9
- import "./CredentialServices-BFQD_VN1.js";
10
- import { _ as Command, c as WorkerRuntime, d as AppContainerLifecycle, f as AppContainerFactory, g as CommandBus, h as Query, l as FrontendRuntime, m as QueryBus, n as CodemationBootstrapRequest, r as ApplicationTokens, t as CodemationPluginListMerger, u as DatabaseMigrations } from "./CodemationPluginListMerger-QvUa2SIt.js";
11
- import { r as PrismaDatabaseClient, t as AppConfigFactory } from "./AppConfigFactory-CK28UPK0.js";
12
- import { t as CodemationPostgresPrismaClientFactory } from "./persistenceServer-Y-u7lV7f.js";
13
- import { c as CodemationServerGateway, l as ApiPaths } from "./server-axppTMgo.js";
14
- import { i as CodemationFrontendAuthSnapshotFactory, n as InternalAuthBootstrapFactory, r as FrontendAppConfigFactory, t as PublicFrontendBootstrapFactory } from "./PublicFrontendBootstrapFactory-DTA1iDo0.js";
8
+ import "./CodemationConfigNormalizer-BCtBrJDe.js";
9
+ import { t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-evvw4b_a.js";
10
+ import "./CredentialServices-0Hk8RFY1.js";
11
+ import { S as Command, _ as AppContainerFactory, b as Query, c as FrontendRuntime, g as AppContainerLifecycle, h as DatabaseMigrations, n as CodemationBootstrapRequest, r as ApplicationTokens, s as WorkerRuntime, t as CodemationPluginListMerger, x as CommandBus, y as QueryBus } from "./CodemationPluginListMerger-PSTtEQjC.js";
12
+ import { r as PrismaDatabaseClient, t as AppConfigFactory } from "./AppConfigFactory-Dq7ttwQ_.js";
13
+ import { t as CodemationPostgresPrismaClientFactory } from "./persistenceServer-CJeu1STC.js";
14
+ import { c as CodemationServerGateway, l as ApiPaths } from "./server-Clvg5x1w.js";
15
+ import { i as CodemationFrontendAuthSnapshotFactory, n as InternalAuthBootstrapFactory, r as FrontendAppConfigFactory, t as PublicFrontendBootstrapFactory } from "./PublicFrontendBootstrapFactory-D0_ds7nS.js";
15
16
 
16
17
  //#region src/application/contracts/userDirectoryContracts.types.d.ts
17
18
  type UserAccountStatus = "invited" | "active" | "inactive";
package/dist/index.js CHANGED
@@ -5,12 +5,12 @@ import { t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigL
5
5
  import "./ServerLoggerFactory-CsNW5qhz.js";
6
6
  import "./decorateParam-D7WPDFAf.js";
7
7
  import "./decorate-Dq0XLibd.js";
8
- import { d as ApplicationTokens } from "./CredentialServices-BPKUF8Xs.js";
9
- import { E as ListUserAccountsQuery, T as UpsertLocalBootstrapUserCommand, _ as CodemationFrontendAuthSnapshotFactory, a as AppContainerLifecycle, g as FrontendAppConfigFactory, h as InternalAuthBootstrapFactory, i as DatabaseMigrations, m as PublicFrontendBootstrapFactory, n as WorkerRuntime, r as FrontendRuntime, t as AppContainerFactory, y as ApiPaths } from "./AppContainerFactory-CcSGFNLW.js";
10
- import { n as CodemationPluginPackageMetadata, t as AppConfigFactory } from "./AppConfigFactory-CqKWXqOm.js";
8
+ import { d as ApplicationTokens } from "./CredentialServices-BNBMFOPt.js";
9
+ import { D as ListUserAccountsQuery, E as UpsertLocalBootstrapUserCommand, _ as FrontendAppConfigFactory, a as AppContainerLifecycle, b as ApiPaths, g as InternalAuthBootstrapFactory, h as PublicFrontendBootstrapFactory, i as DatabaseMigrations, n as WorkerRuntime, r as FrontendRuntime, t as AppContainerFactory, v as CodemationFrontendAuthSnapshotFactory } from "./AppContainerFactory-D9je1sSV.js";
10
+ import { n as CodemationPluginPackageMetadata, t as AppConfigFactory } from "./AppConfigFactory-BPp02HMv.js";
11
11
  import { n as CodemationBootstrapRequest, t as CodemationPluginListMerger } from "./CodemationPluginListMerger-_lZaa6gO.js";
12
- import { t as CodemationPostgresPrismaClientFactory } from "./persistenceServer-DKbFDxoS.js";
13
- import { r as CodemationServerGateway } from "./server-CFpgKuVE.js";
12
+ import { t as CodemationPostgresPrismaClientFactory } from "./persistenceServer-CA0_q0D7.js";
13
+ import { r as CodemationServerGateway } from "./server-C_ZIEOTY.js";
14
14
  import { workflow } from "@codemation/core-nodes";
15
15
 
16
16
  export { ApiPaths, AppConfigFactory, AppContainerFactory, AppContainerLifecycle, ApplicationTokens, CodemationBootstrapRequest, CodemationConsumerConfigLoader, CodemationFrontendAuthSnapshotFactory, CodemationFrontendAuthSnapshotJsonCodec, CodemationPluginListMerger, CodemationPluginPackageMetadata, CodemationPostgresPrismaClientFactory, CodemationServerGateway, DatabaseMigrations, FrontendAppConfigFactory, FrontendAppConfigJsonCodec, FrontendRuntime, InternalAuthBootstrapFactory, InternalAuthBootstrapJsonCodec, ListUserAccountsQuery, PublicFrontendBootstrapFactory, PublicFrontendBootstrapJsonCodec, UpsertLocalBootstrapUserCommand, WorkerRuntime, defineCodemationApp, definePlugin, workflow };
@@ -1,13 +1,13 @@
1
- import { D as ActivationIdFactory, F as WorkflowDefinition$1, L as BinaryStorage, M as RunIdFactory, O as BinaryAttachment, X as WebhookInvocationMatch, Y as WorkflowActivationPolicy, k as Item, nt as Clock, t as RunIntentService, v as CredentialOAuth2AuthDefinition, w as CredentialTypeDefinition } from "./index-Dd6BrWyH.js";
2
- import { r as AppConfig } from "./CodemationAppContext-KqDoeHqN.js";
1
+ import { D as ActivationIdFactory, I as WorkflowDefinition$1, N as RunIdFactory, O as BinaryAttachment, R as BinaryStorage, X as WorkflowActivationPolicy, Z as WebhookInvocationMatch, k as Item, t as RunIntentService, v as CredentialOAuth2AuthDefinition, w as CredentialTypeDefinition } from "./index-CeS2saCe.js";
2
+ import { r as AppConfig } from "./CodemationAppContext-P7P-xZhQ.js";
3
3
  import { l as Logger, u as LoggerFactory } from "./CodemationWhitelabelConfig-D5rYcLlj.js";
4
- import { t as LogLevelPolicy } from "./LogLevelPolicy-CkiJAH75.js";
4
+ import "./LogLevelPolicy-CkiJAH75.js";
5
5
  import { a as CodemationFrontendAuthSnapshot, i as CodemationFrontendAuthProviderSnapshot, n as InternalAuthBootstrap, r as FrontendAppConfig, t as PublicFrontendBootstrap } from "./PublicFrontendBootstrap-ci0Vwxrb.js";
6
- import "./CodemationConfigNormalizer-DIAE0VHw.js";
7
- import { a as CredentialInstanceService, c as CredentialSecretCipher, i as CredentialBindingService, l as CredentialFieldEnvOverlayService, o as CredentialOAuth2ScopeResolver, r as CredentialRuntimeMaterialService, s as CredentialMaterialResolver, t as CredentialStore, u as CredentialTypeRegistryImpl } from "./CredentialServices-BFQD_VN1.js";
8
- import { a as WorkflowDebuggerOverlayRepository, c as WorkerRuntime, d as AppContainerLifecycle, f as AppContainerFactory, g as CommandBus, i as HonoApiRouteRegistrar, l as FrontendRuntime, m as QueryBus, n as CodemationBootstrapRequest, o as WorkflowRunRepository, p as WorkflowWebsocketServer, r as ApplicationTokens, s as SessionVerifier, t as CodemationPluginListMerger, u as DatabaseMigrations } from "./CodemationPluginListMerger-QvUa2SIt.js";
9
- import { t as AppConfigFactory } from "./AppConfigFactory-CK28UPK0.js";
10
- import { a as WorkflowDto, n as InternalAuthBootstrapFactory, o as WorkflowSummary, r as FrontendAppConfigFactory, t as PublicFrontendBootstrapFactory } from "./PublicFrontendBootstrapFactory-DTA1iDo0.js";
6
+ import "./CodemationConfigNormalizer-BCtBrJDe.js";
7
+ import { a as CredentialInstanceService, c as CredentialSecretCipher, i as CredentialBindingService, l as CredentialFieldEnvOverlayService, o as CredentialOAuth2ScopeResolver, r as CredentialRuntimeMaterialService, s as CredentialMaterialResolver, t as CredentialStore, u as CredentialTypeRegistryImpl } from "./CredentialServices-0Hk8RFY1.js";
8
+ import { _ as AppContainerFactory, a as WorkflowDebuggerOverlayRepository, c as FrontendRuntime, d as LogLevelPolicyFactory, f as logLevelPolicyFactory, g as AppContainerLifecycle, h as DatabaseMigrations, i as HonoApiRouteRegistrar, l as WorkflowRunRetentionPruneScheduler, m as WorkflowRunRepository, n as CodemationBootstrapRequest, o as SessionVerifier, p as LogFilter, r as ApplicationTokens, s as WorkerRuntime, t as CodemationPluginListMerger, u as ServerLoggerFactory, v as WorkflowWebsocketServer, x as CommandBus, y as QueryBus } from "./CodemationPluginListMerger-PSTtEQjC.js";
9
+ import { t as AppConfigFactory } from "./AppConfigFactory-Dq7ttwQ_.js";
10
+ import { a as WorkflowDto, n as InternalAuthBootstrapFactory, o as WorkflowSummary, r as FrontendAppConfigFactory, t as PublicFrontendBootstrapFactory } from "./PublicFrontendBootstrapFactory-D0_ds7nS.js";
11
11
  import { Hono } from "hono";
12
12
  import { NodeDefinition, WorkflowDefinition } from "@codemation/core/browser";
13
13
 
@@ -29,13 +29,6 @@ type DevBootstrapSummaryJson = Readonly<{
29
29
  }>>;
30
30
  }>;
31
31
  //#endregion
32
- //#region src/application/logging/LogFilter.d.ts
33
- type LogFilter = (entry: Readonly<{
34
- scope: string;
35
- level: "info" | "warn" | "error" | "debug";
36
- message: string;
37
- }>) => boolean;
38
- //#endregion
39
32
  //#region src/infrastructure/logging/FilteringLogger.d.ts
40
33
  declare class FilteringLogger implements Logger {
41
34
  private readonly inner;
@@ -48,18 +41,6 @@ declare class FilteringLogger implements Logger {
48
41
  debug(message: string, exception?: Error): void;
49
42
  }
50
43
  //#endregion
51
- //#region src/infrastructure/logging/LogLevelPolicyFactory.d.ts
52
- /**
53
- * Process-wide {@link LogLevelPolicy} singleton for server and browser loggers.
54
- * Plain class (no `@injectable` from `@codemation/core`): client components import this file; decorating would pull core into the browser bundle.
55
- */
56
- declare class LogLevelPolicyFactory {
57
- private readonly policy;
58
- create(): LogLevelPolicy;
59
- }
60
- /** Shared factory for call sites outside the DI container (e.g. next-host bootstrap). */
61
- declare const logLevelPolicyFactory: LogLevelPolicyFactory;
62
- //#endregion
63
44
  //#region src/infrastructure/logging/PerformanceLogPolicy.d.ts
64
45
  /**
65
46
  * Opt-in detailed timing / diagnostics lines (used with `ServerLoggerFactory#createPerformanceDiagnostics`).
@@ -80,15 +61,6 @@ declare class PerformanceLogPolicyFactory {
80
61
  }
81
62
  declare const performanceLogPolicyFactory: PerformanceLogPolicyFactory;
82
63
  //#endregion
83
- //#region src/infrastructure/logging/ServerLoggerFactory.d.ts
84
- declare class ServerLoggerFactory implements LoggerFactory {
85
- private readonly logLevelPolicyFactory;
86
- constructor(logLevelPolicyFactory: LogLevelPolicyFactory);
87
- create(scope: string): Logger;
88
- createFiltered(scope: string, filter: LogFilter): Logger;
89
- createPerformanceDiagnostics(scope: string): Logger;
90
- }
91
- //#endregion
92
64
  //#region src/application/binary/RunBinaryAttachmentLookupService.d.ts
93
65
  declare class RunBinaryAttachmentLookupService {
94
66
  private readonly workflowRunRepository;
@@ -148,28 +120,6 @@ declare class WorkflowDefinitionMapper implements DataMapper<WorkflowDefinition$
148
120
  private nodeTypeName;
149
121
  }
150
122
  //#endregion
151
- //#region src/application/runs/WorkflowRunRetentionPruneScheduler.d.ts
152
- /**
153
- * Periodically deletes terminal workflow runs whose age exceeds the effective retention
154
- * (`policySnapshot.retentionSeconds` or `CODEMATION_RUN_RETENTION_DEFAULT_SECONDS`),
155
- * and removes binary blobs referenced from run state via {@link BinaryStorage}.
156
- */
157
- declare class WorkflowRunRetentionPruneScheduler {
158
- private readonly clock;
159
- private readonly runs;
160
- private readonly binaryStorage;
161
- private readonly appConfig;
162
- private timer;
163
- private readonly logger;
164
- constructor(clock: Clock, runs: WorkflowRunRepository, binaryStorage: BinaryStorage, appConfig: AppConfig, loggerFactory: ServerLoggerFactory);
165
- start(): void;
166
- stop(): void;
167
- /** Exposed for tests; production path is the interval started by {@link start}. */
168
- runOnce(): Promise<void>;
169
- private loadStorageKeysFromRunStateFallback;
170
- private collectStorageKeysFromValue;
171
- }
172
- //#endregion
173
123
  //#region src/infrastructure/webhooks/RequestToWebhookItemMapper.d.ts
174
124
  declare class RequestToWebhookItemMapper {
175
125
  private readonly binaryStorage;