@codemation/host 0.5.1 → 0.7.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.
- package/CHANGELOG.md +465 -0
- package/LICENSE +1 -37
- package/dist/{ApiPaths-CLTHphYZ.js → ApiPaths-Dv1dcHu_.js} +4 -4
- package/dist/ApiPaths-Dv1dcHu_.js.map +1 -0
- package/dist/{AppConfigFactory-CvpFScwB.js → AppConfigFactory-Cx4qQvRk.js} +114 -53
- package/dist/AppConfigFactory-Cx4qQvRk.js.map +1 -0
- package/dist/{AppConfigFactory-LK76niPc.d.ts → AppConfigFactory-DnLoQ9Li.d.ts} +8527 -5549
- package/dist/{AppContainerFactory-BlLrm6_h.js → AppContainerFactory-DqKYCRNP.js} +7656 -2090
- package/dist/AppContainerFactory-DqKYCRNP.js.map +1 -0
- package/dist/{CodemationAppContext-CvWi5gey.d.ts → CodemationAppContext-CKVv9W9q.d.ts} +8 -4
- package/dist/{CodemationAuthoring.types-BuKNTDC1.d.ts → CodemationAuthoring.types-DA3G3s6d.d.ts} +25 -5
- package/dist/{CodemationAuthoring.types-DZl-sJaM.js → CodemationAuthoring.types-NGkBcmmT.js} +18 -6
- package/dist/CodemationAuthoring.types-NGkBcmmT.js.map +1 -0
- package/dist/{CodemationConfigNormalizer-CYdR0PR5.d.ts → CodemationConfigNormalizer-BAKjetJ6.d.ts} +3 -3
- package/dist/{CodemationConsumerConfigLoader-BeAUS144.js → CodemationConsumerConfigLoader-GYpBBvqE.js} +79 -10
- package/dist/CodemationConsumerConfigLoader-GYpBBvqE.js.map +1 -0
- package/dist/{CodemationConsumerConfigLoader-C3nAj9Bj.d.ts → CodemationConsumerConfigLoader-nxOqvv46.d.ts} +17 -2
- package/dist/{CodemationPluginListMerger-B-W5Fa_X.js → CodemationPluginListMerger-D1B1IEbt.js} +1 -1
- package/dist/{CodemationPluginListMerger-B-W5Fa_X.js.map → CodemationPluginListMerger-D1B1IEbt.js.map} +1 -1
- package/dist/{CodemationPluginListMerger-D-gwVwtw.d.ts → CodemationPluginListMerger-DKLAHT2b.d.ts} +123 -16
- package/dist/CodemationTsyringeTypeInfoRegistrar-Bj6FJYFz.js +97 -0
- package/dist/CodemationTsyringeTypeInfoRegistrar-Bj6FJYFz.js.map +1 -0
- package/dist/{CodemationWhitelabelConfig-CWbcyQqn.d.ts → CodemationWhitelabelConfig-Ca2mCUeC.d.ts} +2 -2
- package/dist/{CollectionContracts.types-DdpHft0i.d.ts → CollectionContracts.types-DDyFYT_D.d.ts} +1 -1
- package/dist/{CredentialContractsRegistry-D7mcPed2.d.ts → CredentialContractsRegistry-Bq2bq28t.d.ts} +2 -2
- package/dist/{CredentialServices-DdCEP2xt.d.ts → CredentialServices-Be2I60Th.d.ts} +65 -20
- package/dist/{CredentialServices-CgxwguAv.js → CredentialServices-Dk8yypeL.js} +310 -51
- package/dist/CredentialServices-Dk8yypeL.js.map +1 -0
- package/dist/InternalHonoApiRouteRegistrar-Ce1yxpnO.d.ts +17 -0
- package/dist/InternalPingRegistrar-DY3kSfxP.js +221 -0
- package/dist/InternalPingRegistrar-DY3kSfxP.js.map +1 -0
- package/dist/{ItemsInputNormalizer-D1WppVMU.d.ts → ItemsInputNormalizer-_RwIfRIQ.d.ts} +108 -25
- package/dist/{LogLevelPolicyFactory-CampWO0l.d.ts → LogLevelPolicyFactory-ewCHLDLn.d.ts} +2 -2
- package/dist/{PublicFrontendBootstrap-DzBgwOnG.d.ts → PublicFrontendBootstrap-Cev3qK46.d.ts} +9 -2
- package/dist/PublicFrontendBootstrapFactory-CY2FS-5g.d.ts +82 -0
- package/dist/{PublicFrontendBootstrapJsonCodec-Cl_DLRh0.d.ts → PublicFrontendBootstrapJsonCodec-CXG9Dxft.d.ts} +3 -3
- package/dist/{PublicFrontendBootstrapJsonCodec-DzqvA0uo.js → PublicFrontendBootstrapJsonCodec-CegIF_ne.js} +7 -2
- package/dist/PublicFrontendBootstrapJsonCodec-CegIF_ne.js.map +1 -0
- package/dist/ServerLoggerFactory-Ckk52S3w.js +223 -0
- package/dist/ServerLoggerFactory-Ckk52S3w.js.map +1 -0
- package/dist/{TelemetryContracts-BsOD_Y17.d.ts → TelemetryContracts-BtDx84Cp.d.ts} +13 -4
- package/dist/{WorkflowPolicyUiPresentationFactory-DNE5oAI6.d.ts → WorkflowPolicyUiPresentationFactory-6MyjCvBO.d.ts} +2 -2
- package/dist/{WorkflowPolicyUiPresentationFactory-DhPqQ9aB.js → WorkflowPolicyUiPresentationFactory-Bb-ae_Zh.js} +1 -1
- package/dist/{WorkflowPolicyUiPresentationFactory-DhPqQ9aB.js.map → WorkflowPolicyUiPresentationFactory-Bb-ae_Zh.js.map} +1 -1
- package/dist/{WorkflowViewContracts-0ZgsHQdp.d.ts → WorkflowViewContracts-B7aFQcIw.d.ts} +15 -1
- package/dist/authoring.d.ts +5 -5
- package/dist/authoring.js +1 -1
- package/dist/client.d.ts +4 -4
- package/dist/client.js +2 -2
- package/dist/consumer.d.ts +6 -6
- package/dist/consumer.js +2 -2
- package/dist/credentials.d.ts +6 -6
- package/dist/credentials.js +1 -1
- package/dist/devServerSidecar.d.ts +2 -2
- package/dist/devServerSidecar.js +1 -94
- package/dist/devServerSidecar.js.map +1 -1
- package/dist/dto.d.ts +6 -6
- package/dist/{index-BlGs9e9Q.d.ts → index-DilAYwnH.d.ts} +49 -3
- package/dist/index.d.ts +110 -21
- package/dist/index.js +15 -13
- package/dist/mapping.d.ts +2 -2
- package/dist/mapping.js +1 -1
- package/dist/nextServer.d.ts +43 -88
- package/dist/nextServer.js +9 -7
- package/dist/pairing.d.ts +93 -0
- package/dist/pairing.js +5 -0
- package/dist/pairing.types-snfZ_OzB.d.ts +19 -0
- package/dist/{persistenceServer-CpNFYa_q.js → persistenceServer-C-hH4z6l.js} +2 -2
- package/dist/{persistenceServer-CpNFYa_q.js.map → persistenceServer-C-hH4z6l.js.map} +1 -1
- package/dist/persistenceServer-CeTHtC6E.d.ts +30 -0
- package/dist/persistenceServer.d.ts +8 -8
- package/dist/persistenceServer.js +3 -3
- package/dist/{server-CQWdkT7t.d.ts → server-C4bS62rg.d.ts} +21 -6
- package/dist/{server-BK43OKxW.js → server-Y7kxwtCK.js} +7 -6
- package/dist/{server-BK43OKxW.js.map → server-Y7kxwtCK.js.map} +1 -1
- package/dist/server.d.ts +14 -14
- package/dist/server.js +13 -11
- package/package.json +29 -42
- package/prisma/migrations/20260507120000_execution_instance_child_run_id/migration.sql +5 -0
- package/prisma/migrations/20260519000000_workflow_audit_log/migration.sql +23 -0
- package/prisma/migrations/20260519100000_storage_growth_fixes/migration.sql +61 -0
- package/prisma/migrations.sqlite/20260507120000_execution_instance_child_run_id/migration.sql +5 -0
- package/prisma/migrations.sqlite/20260519000000_workflow_audit_log/migration.sql +21 -0
- package/prisma/migrations.sqlite/20260519100000_storage_growth_fixes/migration.sql +29 -0
- package/prisma/schema.postgresql.prisma +56 -17
- package/prisma/schema.sqlite.prisma +56 -17
- package/prisma-generated/prisma-postgresql-client/edge.js +35 -6
- package/prisma-generated/prisma-postgresql-client/index-browser.js +31 -2
- package/prisma-generated/prisma-postgresql-client/index.d.ts +8971 -5718
- package/prisma-generated/prisma-postgresql-client/index.js +35 -6
- package/prisma-generated/prisma-postgresql-client/package.json +1 -1
- package/prisma-generated/prisma-postgresql-client/schema.prisma +39 -0
- package/prisma-generated/prisma-sqlite-client/edge.js +35 -6
- package/prisma-generated/prisma-sqlite-client/index-browser.js +31 -2
- package/prisma-generated/prisma-sqlite-client/index.d.ts +8963 -5715
- package/prisma-generated/prisma-sqlite-client/index.js +35 -6
- package/prisma-generated/prisma-sqlite-client/package.json +1 -1
- package/prisma-generated/prisma-sqlite-client/schema.prisma +39 -0
- package/scripts/check-collections.mjs +18 -0
- package/scripts/generate-prisma-clients.mjs +20 -11
- package/src/application/WorkflowAuditLogPruneScheduler.ts +96 -0
- package/src/application/auth/AuthenticatedPrincipal.ts +4 -0
- package/src/application/commands/StartWorkflowRunCommandHandler.ts +4 -0
- package/src/application/contracts/WorkflowViewContracts.ts +11 -0
- package/src/application/contracts/WorkflowWebsocketMessage.ts +3 -1
- package/src/application/mapping/WorkflowDefinitionMapper.ts +44 -1
- package/src/application/runs/WorkflowRunRetentionPruneScheduler.ts +7 -1
- package/src/application/telemetry/OtelExecutionTelemetry.types.ts +5 -0
- package/src/application/telemetry/OtelExecutionTelemetryFactory.ts +4 -0
- package/src/application/telemetry/StoredTelemetrySpanScope.ts +6 -2
- package/src/application/telemetry/TelemetryRetentionTimestampFactory.ts +27 -17
- package/src/application/telemetry/TelemetrySpanPublisher.ts +11 -0
- package/src/application/websocket/TelemetrySpanWebsocketRelay.ts +31 -0
- package/src/applicationTokens.ts +20 -1
- package/src/audit/IAuditEmitter.ts +32 -0
- package/src/audit/PrismaWorkflowAuditLogRepository.ts +34 -0
- package/src/audit/WorkflowAuditLogWriter.ts +125 -0
- package/src/auth/managed/ManagedAuthConfig.ts +29 -0
- package/src/auth/managed/ManagedAuthMiddleware.ts +52 -0
- package/src/auth/managed/ManagedCorsMiddleware.ts +43 -0
- package/src/auth/managed/ManagedModeBootGuard.ts +27 -0
- package/src/auth/managed/index.ts +5 -0
- package/src/bootstrap/AppContainerFactory.ts +277 -29
- package/src/bootstrap/AppContainerLifecycle.ts +31 -0
- package/src/bootstrap/perf/BootTimer.ts +168 -0
- package/src/bootstrap/runtime/AppConfigFactory.ts +21 -65
- package/src/bootstrap/runtime/FrontendRuntime.ts +4 -1
- package/src/bootstrap/runtime/WorkerRuntime.ts +2 -1
- package/src/credentials/BrokerClient.ts +49 -0
- package/src/credentials/BrokerRefreshError.ts +12 -0
- package/src/credentials/BrokerRefreshInvalidGrantError.ts +13 -0
- package/src/credentials/ControlPlaneCatalogFetcher.ts +261 -0
- package/src/credentials/CredentialOAuth2MaterialReader.ts +136 -0
- package/src/credentials/InternalCredentialsListRegistrar.ts +48 -0
- package/src/credentials/InternalCredentialsPushRegistrar.ts +125 -0
- package/src/credentials/LocalOAuthFlowExecutor.ts +316 -0
- package/src/credentials/ManagedOAuthFlowExecutor.ts +94 -0
- package/src/credentials/ManagedOAuthRefreshInvalidGrantError.ts +13 -0
- package/src/credentials/catalogTypes.ts +4 -0
- package/src/credentials/refresh/CredentialDisconnectedError.ts +11 -0
- package/src/domain/credentials/CredentialBindingService.ts +54 -2
- package/src/domain/credentials/CredentialKeyRotatedError.ts +22 -0
- package/src/domain/credentials/CredentialSecretCipher.ts +68 -6
- package/src/domain/credentials/CredentialTypeRegistryImpl.ts +117 -10
- package/src/domain/credentials/OAuth2RedirectUriResolver.ts +79 -0
- package/src/domain/credentials/WorkflowCredentialNodeResolver.ts +14 -5
- package/src/domain/telemetry/TelemetryContracts.ts +7 -1
- package/src/domain/workflows/WorkflowActivationPreflight.ts +24 -1
- package/src/domain/workflows/WorkflowActivationPreflightRules.ts +40 -1
- package/src/index.ts +6 -0
- package/src/infrastructure/binary/LocalFilesystemBinaryStorageRegistry.ts +29 -1
- package/src/infrastructure/binary/S3BinaryStorage.ts +169 -0
- package/src/infrastructure/binary/S3BinaryStorageConfig.ts +17 -0
- package/src/infrastructure/config/CodemationPluginRegistrar.ts +3 -1
- package/src/infrastructure/persistence/CodemationDatabaseUrlParser.ts +41 -0
- package/src/infrastructure/persistence/InMemoryTelemetryArtifactStore.ts +8 -3
- package/src/infrastructure/persistence/InMemoryWorkflowRunRepository.ts +1 -0
- package/src/infrastructure/persistence/PrismaMigrationDeployer.ts +21 -13
- package/src/infrastructure/persistence/PrismaTelemetryArtifactStore.ts +43 -8
- package/src/infrastructure/persistence/PrismaWorkflowRunRepository.ts +33 -3
- package/src/infrastructure/persistence/PrismaWorkflowSnapshotRepository.ts +48 -0
- package/src/mcp/AgentMcpIntegrationImpl.ts +344 -0
- package/src/mcp/McpClientFactory.ts +29 -0
- package/src/mcp/McpConnectionPool.ts +184 -0
- package/src/mcp/McpConnectionPool.types.ts +12 -0
- package/src/mcp/McpServerCatalog.ts +104 -0
- package/src/mcp/index.ts +5 -0
- package/src/pairing/HmacRequestSigner.ts +32 -0
- package/src/pairing/IncomingHmacVerifier.ts +82 -0
- package/src/pairing/InternalHmacAuthMiddleware.ts +33 -0
- package/src/pairing/InternalPingRegistrar.ts +25 -0
- package/src/pairing/PairedFetch.ts +33 -0
- package/src/pairing/PairingConfigFactory.ts +35 -0
- package/src/pairing/PairingConfigToken.ts +6 -0
- package/src/pairing/index.ts +14 -0
- package/src/pairing/pairing.types.ts +18 -0
- package/src/pairing.ts +17 -0
- package/src/persistenceServer.ts +1 -0
- package/src/presentation/config/AppConfig.ts +7 -1
- package/src/presentation/config/CodemationAuthConfig.ts +1 -1
- package/src/presentation/config/CodemationAuthoring.types.ts +54 -5
- package/src/presentation/config/CodemationConfig.ts +3 -0
- package/src/presentation/config/CodemationConfigNormalizer.ts +39 -1
- package/src/presentation/config/CodemationPlugin.ts +2 -1
- package/src/presentation/frontend/CodemationFrontendAuthSnapshot.ts +5 -0
- package/src/presentation/frontend/CodemationFrontendAuthSnapshotFactory.ts +7 -1
- package/src/presentation/frontend/PublicFrontendBootstrap.ts +2 -0
- package/src/presentation/frontend/PublicFrontendBootstrapFactory.ts +5 -1
- package/src/presentation/frontend/PublicFrontendBootstrapJsonCodec.ts +4 -1
- package/src/presentation/http/ApiPaths.ts +4 -4
- package/src/presentation/http/ServerHttpErrorResponseFactory.ts +39 -2
- package/src/presentation/http/hono/CodemationHonoApiAppFactory.ts +33 -8
- package/src/presentation/http/hono/InternalHonoApiRouteRegistrar.ts +12 -0
- package/src/presentation/http/hono/registrars/ManagedMeHonoApiRouteRegistrar.ts +35 -0
- package/src/presentation/http/hono/registrars/OAuth2HonoApiRouteRegistrar.ts +2 -2
- package/src/presentation/http/routeHandlers/CredentialHttpRouteHandler.ts +28 -0
- package/src/presentation/http/routeHandlers/OAuth2HttpRouteHandlerFactory.ts +98 -41
- package/src/presentation/server/CodemationConsumerConfigLoader.ts +54 -7
- package/src/presentation/server/CodemationPluginDiscovery.ts +5 -0
- package/src/presentation/server/WorkflowDefinitionExportsResolver.ts +18 -0
- package/src/presentation/server/WorkflowModulePathFinder.ts +12 -1
- package/src/presentation/websocket/ManagedWebsocketAuthenticator.ts +50 -0
- package/src/presentation/websocket/WebsocketAuthenticator.types.ts +12 -0
- package/src/presentation/websocket/WorkflowWebsocketServer.ts +24 -3
- package/src/process/ExecaProcessRunner.ts +41 -0
- package/src/process/ProcessRunner.types.ts +39 -0
- package/src/server.ts +2 -0
- package/src/workflows/InternalWorkflowActivationRegistrar.ts +42 -0
- package/src/workflows/InternalWorkflowDetailRegistrar.ts +33 -0
- package/src/workflows/InternalWorkflowTestRunRegistrar.ts +91 -0
- package/src/workflows/InternalWorkflowsListRegistrar.ts +28 -0
- package/src/workflows/discovery/WorkflowDirectoryDiscoverer.ts +79 -0
- package/tsconfig.json +2 -0
- package/vitest.shared.ts +5 -0
- package/dist/ApiPaths-CLTHphYZ.js.map +0 -1
- package/dist/AppConfigFactory-CvpFScwB.js.map +0 -1
- package/dist/AppContainerFactory-BlLrm6_h.js.map +0 -1
- package/dist/CodemationAuthoring.types-DZl-sJaM.js.map +0 -1
- package/dist/CodemationConsumerConfigLoader-BeAUS144.js.map +0 -1
- package/dist/CredentialServices-CgxwguAv.js.map +0 -1
- package/dist/PublicFrontendBootstrapFactory-BMWqNM9a.d.ts +0 -45
- package/dist/PublicFrontendBootstrapJsonCodec-DzqvA0uo.js.map +0 -1
- package/dist/ServerLoggerFactory-BKSIh9Xv.js +0 -98
- package/dist/ServerLoggerFactory-BKSIh9Xv.js.map +0 -1
- package/dist/persistenceServer-CIVt3UOX.d.ts +0 -9
- package/src/domain/credentials/OAuth2ConnectServiceFactory.ts +0 -411
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as __decorateMetadata, t as __decorateParam } from "./decorateParam-BWxkAUSj.js";
|
|
2
2
|
import { t as __decorate } from "./decorate-CXWmflG_.js";
|
|
3
3
|
import { AgentConfigInspector, AgentConnectionNodeCollector, ConnectionNodeIdFactory, CoreTokens, CredentialUnboundError, inject, injectable } from "@codemation/core";
|
|
4
|
-
import { createCipheriv, createDecipheriv, createHash, randomBytes, randomUUID } from "node:crypto";
|
|
4
|
+
import { createCipheriv, createDecipheriv, createHash, hkdfSync, randomBytes, randomUUID } from "node:crypto";
|
|
5
5
|
|
|
6
6
|
//#region src/infrastructure/credentials/OpenAiApiKeyCredentialHealthTester.ts
|
|
7
7
|
/**
|
|
@@ -116,42 +116,6 @@ var OpenAiApiKeyCredentialTypeFactory = class {
|
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
118
|
|
|
119
|
-
//#endregion
|
|
120
|
-
//#region src/domain/credentials/CredentialTypeRegistryImpl.ts
|
|
121
|
-
let CredentialTypeRegistryImpl = class CredentialTypeRegistryImpl$1 {
|
|
122
|
-
credentialTypesById = /* @__PURE__ */ new Map();
|
|
123
|
-
register(type) {
|
|
124
|
-
if (this.credentialTypesById.has(type.definition.typeId)) throw new Error(`Credential type already registered: ${type.definition.typeId}`);
|
|
125
|
-
this.credentialTypesById.set(type.definition.typeId, type);
|
|
126
|
-
}
|
|
127
|
-
listTypes() {
|
|
128
|
-
return [...this.credentialTypesById.values()].map((entry) => entry.definition);
|
|
129
|
-
}
|
|
130
|
-
getType(typeId) {
|
|
131
|
-
return this.credentialTypesById.get(typeId)?.definition;
|
|
132
|
-
}
|
|
133
|
-
getCredentialType(typeId) {
|
|
134
|
-
return this.credentialTypesById.get(typeId);
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
CredentialTypeRegistryImpl = __decorate([injectable()], CredentialTypeRegistryImpl);
|
|
138
|
-
|
|
139
|
-
//#endregion
|
|
140
|
-
//#region src/application/ApplicationRequestError.ts
|
|
141
|
-
var ApplicationRequestError = class extends Error {
|
|
142
|
-
status;
|
|
143
|
-
payload;
|
|
144
|
-
constructor(status, message, errors) {
|
|
145
|
-
super(message);
|
|
146
|
-
this.name = "ApplicationRequestError";
|
|
147
|
-
this.status = status;
|
|
148
|
-
this.payload = errors && errors.length > 0 ? {
|
|
149
|
-
error: message,
|
|
150
|
-
errors
|
|
151
|
-
} : { error: message };
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
|
|
155
119
|
//#endregion
|
|
156
120
|
//#region src/applicationTokens.ts
|
|
157
121
|
const ApplicationTokens = {
|
|
@@ -167,7 +131,11 @@ const ApplicationTokens = {
|
|
|
167
131
|
CommandHandler: Symbol.for("codemation.application.CommandHandler"),
|
|
168
132
|
DomainEventHandler: Symbol.for("codemation.application.DomainEventHandler"),
|
|
169
133
|
HonoApiRouteRegistrar: Symbol.for("codemation.application.HonoApiRouteRegistrar"),
|
|
134
|
+
InternalHonoApiRouteRegistrar: Symbol.for("codemation.application.InternalHonoApiRouteRegistrar"),
|
|
135
|
+
ManagedCorsMiddleware: Symbol.for("codemation.application.ManagedCorsMiddleware"),
|
|
136
|
+
WebsocketAuthenticator: Symbol.for("codemation.application.WebsocketAuthenticator"),
|
|
170
137
|
WorkflowWebsocketPublisher: Symbol.for("codemation.application.WorkflowWebsocketPublisher"),
|
|
138
|
+
TelemetrySpanPublisher: Symbol.for("codemation.application.TelemetrySpanPublisher"),
|
|
171
139
|
WorkerRuntimeScheduler: Symbol.for("codemation.application.WorkerRuntimeScheduler"),
|
|
172
140
|
WorkflowDefinitionRepository: Symbol.for("codemation.application.WorkflowDefinitionRepository"),
|
|
173
141
|
WorkflowActivationRepository: Symbol.for("codemation.application.WorkflowActivationRepository"),
|
|
@@ -183,12 +151,218 @@ const ApplicationTokens = {
|
|
|
183
151
|
TelemetryExporter: Symbol.for("codemation.application.TelemetryExporter"),
|
|
184
152
|
PrismaClient: Symbol.for("codemation.application.PrismaClient"),
|
|
185
153
|
SessionVerifier: Symbol.for("codemation.application.SessionVerifier"),
|
|
186
|
-
Clock: Symbol.for("codemation.application.Clock")
|
|
154
|
+
Clock: Symbol.for("codemation.application.Clock"),
|
|
155
|
+
WorkflowAuditEmitter: Symbol.for("codemation.application.WorkflowAuditEmitter"),
|
|
156
|
+
ProcessRunner: Symbol.for("codemation.application.ProcessRunner"),
|
|
157
|
+
OAuthFlowExecutor: Symbol.for("codemation.application.OAuthFlowExecutor")
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/domain/credentials/CredentialTypeRegistryImpl.ts
|
|
162
|
+
const SOURCE_PRIORITY$1 = {
|
|
163
|
+
plugin: 0,
|
|
164
|
+
config: 1,
|
|
165
|
+
controlPlane: 2
|
|
166
|
+
};
|
|
167
|
+
let CredentialTypeRegistryImpl = class CredentialTypeRegistryImpl$1 {
|
|
168
|
+
entries = /* @__PURE__ */ new Map();
|
|
169
|
+
bySource = /* @__PURE__ */ new Map();
|
|
170
|
+
constructor(loggers) {
|
|
171
|
+
this.loggers = loggers;
|
|
172
|
+
}
|
|
173
|
+
merge(source, types) {
|
|
174
|
+
const logger = this.loggers.create("CredentialTypeRegistryImpl");
|
|
175
|
+
for (const type of types) this.insert(source, type, logger);
|
|
176
|
+
}
|
|
177
|
+
mergeDefinitions(source, definitions) {
|
|
178
|
+
const logger = this.loggers.create("CredentialTypeRegistryImpl");
|
|
179
|
+
for (const definition of definitions) {
|
|
180
|
+
const existing = this.entries.get(definition.typeId);
|
|
181
|
+
const sourcePriority = SOURCE_PRIORITY$1[source];
|
|
182
|
+
if (existing) {
|
|
183
|
+
if (sourcePriority < SOURCE_PRIORITY$1[existing.source]) {
|
|
184
|
+
logger.warn(`CredentialTypeRegistryImpl: id collision — lower-priority source "${source}" ignored for typeId "${definition.typeId}" (current source: "${existing.source}")`);
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
if (sourcePriority > SOURCE_PRIORITY$1[existing.source]) {
|
|
188
|
+
logger.warn(`CredentialTypeRegistryImpl: typeId "${definition.typeId}" shadowed — "${existing.source}" overridden by higher-priority source "${source}"`);
|
|
189
|
+
this.bySource.get(existing.source)?.delete(definition.typeId);
|
|
190
|
+
}
|
|
191
|
+
const nextType = sourcePriority === SOURCE_PRIORITY$1[existing.source] ? {
|
|
192
|
+
...existing.type,
|
|
193
|
+
definition
|
|
194
|
+
} : {
|
|
195
|
+
definition,
|
|
196
|
+
createSession: this.createUnsupportedSessionFactory(definition.typeId, source),
|
|
197
|
+
test: this.createUnsupportedHealthTester(definition.typeId, source)
|
|
198
|
+
};
|
|
199
|
+
this.recordEntry(definition.typeId, {
|
|
200
|
+
type: nextType,
|
|
201
|
+
source
|
|
202
|
+
});
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
const stubType = {
|
|
206
|
+
definition,
|
|
207
|
+
createSession: this.createUnsupportedSessionFactory(definition.typeId, source),
|
|
208
|
+
test: this.createUnsupportedHealthTester(definition.typeId, source)
|
|
209
|
+
};
|
|
210
|
+
this.recordEntry(definition.typeId, {
|
|
211
|
+
type: stubType,
|
|
212
|
+
source
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
clear(source) {
|
|
217
|
+
const ids = this.bySource.get(source);
|
|
218
|
+
if (!ids) return;
|
|
219
|
+
for (const id of ids) this.entries.delete(id);
|
|
220
|
+
this.bySource.delete(source);
|
|
221
|
+
}
|
|
222
|
+
listTypes() {
|
|
223
|
+
return [...this.entries.values()].map((entry) => entry.type.definition);
|
|
224
|
+
}
|
|
225
|
+
getType(typeId) {
|
|
226
|
+
return this.entries.get(typeId)?.type.definition;
|
|
227
|
+
}
|
|
228
|
+
getCredentialType(typeId) {
|
|
229
|
+
return this.entries.get(typeId)?.type;
|
|
230
|
+
}
|
|
231
|
+
insert(source, type, logger) {
|
|
232
|
+
const typeId = type.definition.typeId;
|
|
233
|
+
const existing = this.entries.get(typeId);
|
|
234
|
+
const sourcePriority = SOURCE_PRIORITY$1[source];
|
|
235
|
+
if (existing) {
|
|
236
|
+
if (sourcePriority < SOURCE_PRIORITY$1[existing.source]) {
|
|
237
|
+
logger.warn(`CredentialTypeRegistryImpl: id collision — lower-priority source "${source}" ignored for typeId "${typeId}" (current source: "${existing.source}")`);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
if (sourcePriority > SOURCE_PRIORITY$1[existing.source]) {
|
|
241
|
+
logger.warn(`CredentialTypeRegistryImpl: typeId "${typeId}" shadowed — "${existing.source}" overridden by higher-priority source "${source}"`);
|
|
242
|
+
this.bySource.get(existing.source)?.delete(typeId);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
this.recordEntry(typeId, {
|
|
246
|
+
type,
|
|
247
|
+
source
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
recordEntry(typeId, entry) {
|
|
251
|
+
this.entries.set(typeId, entry);
|
|
252
|
+
if (!this.bySource.has(entry.source)) this.bySource.set(entry.source, /* @__PURE__ */ new Set());
|
|
253
|
+
this.bySource.get(entry.source).add(typeId);
|
|
254
|
+
}
|
|
255
|
+
createUnsupportedSessionFactory(typeId, source) {
|
|
256
|
+
return async () => {
|
|
257
|
+
throw new Error(`Credential type "${typeId}" (source "${source}") was registered with definition only — no createSession implementation is available in this runtime.`);
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
createUnsupportedHealthTester(typeId, source) {
|
|
261
|
+
return async () => ({
|
|
262
|
+
status: "unknown",
|
|
263
|
+
message: `Credential type "${typeId}" (source "${source}") has no local test implementation.`
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
CredentialTypeRegistryImpl = __decorate([
|
|
268
|
+
injectable(),
|
|
269
|
+
__decorateParam(0, inject(ApplicationTokens.LoggerFactory)),
|
|
270
|
+
__decorateMetadata("design:paramtypes", [Object])
|
|
271
|
+
], CredentialTypeRegistryImpl);
|
|
272
|
+
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region src/application/ApplicationRequestError.ts
|
|
275
|
+
var ApplicationRequestError = class extends Error {
|
|
276
|
+
status;
|
|
277
|
+
payload;
|
|
278
|
+
constructor(status, message, errors) {
|
|
279
|
+
super(message);
|
|
280
|
+
this.name = "ApplicationRequestError";
|
|
281
|
+
this.status = status;
|
|
282
|
+
this.payload = errors && errors.length > 0 ? {
|
|
283
|
+
error: message,
|
|
284
|
+
errors
|
|
285
|
+
} : { error: message };
|
|
286
|
+
}
|
|
187
287
|
};
|
|
188
288
|
|
|
289
|
+
//#endregion
|
|
290
|
+
//#region src/mcp/McpServerCatalog.ts
|
|
291
|
+
const SOURCE_PRIORITY = {
|
|
292
|
+
plugin: 0,
|
|
293
|
+
config: 1,
|
|
294
|
+
controlPlane: 2
|
|
295
|
+
};
|
|
296
|
+
const ID_PATTERN = /^[a-z0-9-]+$/;
|
|
297
|
+
let McpServerCatalog = class McpServerCatalog$1 {
|
|
298
|
+
entries = /* @__PURE__ */ new Map();
|
|
299
|
+
bySource = /* @__PURE__ */ new Map();
|
|
300
|
+
env;
|
|
301
|
+
constructor(loggers, appConfig) {
|
|
302
|
+
this.loggers = loggers;
|
|
303
|
+
this.env = appConfig.env;
|
|
304
|
+
}
|
|
305
|
+
merge(source, declarations) {
|
|
306
|
+
const logger = this.loggers.create("McpServerCatalog");
|
|
307
|
+
for (const decl of declarations) {
|
|
308
|
+
if (!this.validate(decl, source, logger)) continue;
|
|
309
|
+
const existing = this.entries.get(decl.id);
|
|
310
|
+
if (existing) {
|
|
311
|
+
if (SOURCE_PRIORITY[source] <= SOURCE_PRIORITY[existing.source]) {
|
|
312
|
+
logger.warn(`McpServerCatalog: id collision — lower-priority source "${source}" ignored for id "${decl.id}" (current source: "${existing.source}")`);
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
logger.warn(`McpServerCatalog: id "${decl.id}" shadowed — "${existing.source}" overridden by higher-priority source "${source}"`);
|
|
316
|
+
this.bySource.get(existing.source)?.delete(decl.id);
|
|
317
|
+
}
|
|
318
|
+
this.entries.set(decl.id, {
|
|
319
|
+
decl,
|
|
320
|
+
source
|
|
321
|
+
});
|
|
322
|
+
if (!this.bySource.has(source)) this.bySource.set(source, /* @__PURE__ */ new Set());
|
|
323
|
+
this.bySource.get(source).add(decl.id);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
get(id) {
|
|
327
|
+
return this.entries.get(id)?.decl;
|
|
328
|
+
}
|
|
329
|
+
getAll() {
|
|
330
|
+
return [...this.entries.values()].map((entry) => entry.decl);
|
|
331
|
+
}
|
|
332
|
+
clear(source) {
|
|
333
|
+
const ids = this.bySource.get(source);
|
|
334
|
+
if (!ids) return;
|
|
335
|
+
for (const id of ids) this.entries.delete(id);
|
|
336
|
+
this.bySource.delete(source);
|
|
337
|
+
}
|
|
338
|
+
validate(decl, source, logger) {
|
|
339
|
+
if (!ID_PATTERN.test(decl.id)) {
|
|
340
|
+
logger.warn(`McpServerCatalog: declaration from "${source}" has invalid id "${decl.id}" (must match /^[a-z0-9-]+$/) — skipped`);
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
if (decl.transport === "stdio") {
|
|
344
|
+
if (this.env.CODEMATION_ALLOW_STDIO_MCP !== "true") {
|
|
345
|
+
logger.warn(`McpServerCatalog: declaration "${decl.id}" from "${source}" uses stdio transport which is disabled (set CODEMATION_ALLOW_STDIO_MCP=true to allow) — skipped`);
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return true;
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
McpServerCatalog = __decorate([
|
|
353
|
+
injectable(),
|
|
354
|
+
__decorateParam(0, inject(ApplicationTokens.LoggerFactory)),
|
|
355
|
+
__decorateParam(1, inject(ApplicationTokens.AppConfig)),
|
|
356
|
+
__decorateMetadata("design:paramtypes", [Object, Object])
|
|
357
|
+
], McpServerCatalog);
|
|
358
|
+
|
|
189
359
|
//#endregion
|
|
190
360
|
//#region src/domain/credentials/WorkflowCredentialNodeResolver.ts
|
|
361
|
+
var _ref$6;
|
|
191
362
|
let WorkflowCredentialNodeResolver = class WorkflowCredentialNodeResolver$1 {
|
|
363
|
+
constructor(mcpCatalog) {
|
|
364
|
+
this.mcpCatalog = mcpCatalog;
|
|
365
|
+
}
|
|
192
366
|
/**
|
|
193
367
|
* Human-readable label for credential errors (workflow node name or agent › attachment).
|
|
194
368
|
*/
|
|
@@ -236,7 +410,9 @@ let WorkflowCredentialNodeResolver = class WorkflowCredentialNodeResolver$1 {
|
|
|
236
410
|
};
|
|
237
411
|
}
|
|
238
412
|
addRecursiveAgentSlots(workflowId, rootAgentNodeId, agentConfig, slotsByKey) {
|
|
239
|
-
|
|
413
|
+
const mcpResolver = this.mcpCatalog ? (id) => this.mcpCatalog.get(id) : void 0;
|
|
414
|
+
const descriptors = AgentConnectionNodeCollector.collect(rootAgentNodeId, agentConfig, mcpResolver);
|
|
415
|
+
for (const entry of descriptors) this.addSlotsForRequirements(workflowId, entry.nodeId, entry.name, entry.credentialSource.getCredentialRequirements?.() ?? [], slotsByKey);
|
|
240
416
|
}
|
|
241
417
|
addSlotsForRequirements(workflowId, nodeId, nodeName, requirements, slotsByKey) {
|
|
242
418
|
for (const requirement of requirements) {
|
|
@@ -251,10 +427,11 @@ let WorkflowCredentialNodeResolver = class WorkflowCredentialNodeResolver$1 {
|
|
|
251
427
|
}
|
|
252
428
|
}
|
|
253
429
|
findRecursiveConnectionNode(workflow, nodeId) {
|
|
254
|
-
if (!ConnectionNodeIdFactory.isLanguageModelConnectionNodeId(nodeId) && !ConnectionNodeIdFactory.isToolConnectionNodeId(nodeId)) return;
|
|
430
|
+
if (!ConnectionNodeIdFactory.isLanguageModelConnectionNodeId(nodeId) && !ConnectionNodeIdFactory.isToolConnectionNodeId(nodeId) && !ConnectionNodeIdFactory.isMcpConnectionNodeId(nodeId)) return;
|
|
431
|
+
const mcpResolver = this.mcpCatalog ? (id) => this.mcpCatalog.get(id) : void 0;
|
|
255
432
|
for (const node of workflow.nodes) {
|
|
256
433
|
if (!AgentConfigInspector.isAgentNodeConfig(node.config)) continue;
|
|
257
|
-
const entries = AgentConnectionNodeCollector.collect(node.id, node.config);
|
|
434
|
+
const entries = AgentConnectionNodeCollector.collect(node.id, node.config, mcpResolver);
|
|
258
435
|
const entriesById = new Map(entries.map((entry$1) => [entry$1.nodeId, entry$1]));
|
|
259
436
|
const entry = entriesById.get(nodeId);
|
|
260
437
|
if (!entry) continue;
|
|
@@ -282,7 +459,11 @@ let WorkflowCredentialNodeResolver = class WorkflowCredentialNodeResolver$1 {
|
|
|
282
459
|
}
|
|
283
460
|
}
|
|
284
461
|
};
|
|
285
|
-
WorkflowCredentialNodeResolver = __decorate([
|
|
462
|
+
WorkflowCredentialNodeResolver = __decorate([
|
|
463
|
+
injectable(),
|
|
464
|
+
__decorateParam(0, inject(McpServerCatalog)),
|
|
465
|
+
__decorateMetadata("design:paramtypes", [typeof (_ref$6 = typeof McpServerCatalog !== "undefined" && McpServerCatalog) === "function" ? _ref$6 : Object])
|
|
466
|
+
], WorkflowCredentialNodeResolver);
|
|
286
467
|
|
|
287
468
|
//#endregion
|
|
288
469
|
//#region src/domain/credentials/CredentialFieldEnvOverlayService.ts
|
|
@@ -324,6 +505,27 @@ CredentialFieldEnvOverlayService = __decorate([
|
|
|
324
505
|
__decorateMetadata("design:paramtypes", [Object])
|
|
325
506
|
], CredentialFieldEnvOverlayService);
|
|
326
507
|
|
|
508
|
+
//#endregion
|
|
509
|
+
//#region src/domain/credentials/CredentialKeyRotatedError.ts
|
|
510
|
+
/**
|
|
511
|
+
* Thrown by {@link CredentialSecretCipher.decrypt} when the credential's stored
|
|
512
|
+
* `encryptionKeyId` does not match the current master key's id.
|
|
513
|
+
*
|
|
514
|
+
* This indicates the `CODEMATION_CREDENTIALS_MASTER_KEY` environment variable has
|
|
515
|
+
* been rotated since the credential was encrypted. The operator must re-bind the
|
|
516
|
+
* affected credential (which re-encrypts it with the new key).
|
|
517
|
+
*
|
|
518
|
+
* See {@link docs/security-boundary.md} for the key rotation contract.
|
|
519
|
+
*/
|
|
520
|
+
var CredentialKeyRotatedError = class extends Error {
|
|
521
|
+
storedKeyId;
|
|
522
|
+
constructor(storedKeyId) {
|
|
523
|
+
super(`Credential was encrypted with key "${storedKeyId}" but the current master key produces a different id. Re-bind the credential to re-encrypt it with the active key.`);
|
|
524
|
+
this.name = "CredentialKeyRotatedError";
|
|
525
|
+
this.storedKeyId = storedKeyId;
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
|
|
327
529
|
//#endregion
|
|
328
530
|
//#region src/domain/credentials/CredentialSecretCipher.ts
|
|
329
531
|
var _CredentialSecretCipher;
|
|
@@ -332,14 +534,16 @@ let CredentialSecretCipher = class CredentialSecretCipher$1 {
|
|
|
332
534
|
_CredentialSecretCipher = this;
|
|
333
535
|
}
|
|
334
536
|
static algorithm = "aes-256-gcm";
|
|
335
|
-
static
|
|
537
|
+
static currentSchemaVersion = 2;
|
|
336
538
|
static ivLength = 12;
|
|
539
|
+
static HKDF_SALT = "codemation/credential-cipher/v1";
|
|
540
|
+
static HKDF_INFO = "aes-256-gcm-key";
|
|
337
541
|
constructor(appConfig) {
|
|
338
542
|
this.appConfig = appConfig;
|
|
339
543
|
}
|
|
340
544
|
encrypt(value) {
|
|
341
545
|
const iv = randomBytes(_CredentialSecretCipher.ivLength);
|
|
342
|
-
const cipher = createCipheriv(_CredentialSecretCipher.algorithm, this.
|
|
546
|
+
const cipher = createCipheriv(_CredentialSecretCipher.algorithm, this.resolveKeyMaterialV2(), iv);
|
|
343
547
|
const plaintext = Buffer.from(JSON.stringify(value), "utf8");
|
|
344
548
|
const encrypted = Buffer.concat([cipher.update(plaintext), cipher.final()]);
|
|
345
549
|
const authTag = cipher.getAuthTag();
|
|
@@ -350,24 +554,50 @@ let CredentialSecretCipher = class CredentialSecretCipher$1 {
|
|
|
350
554
|
encrypted
|
|
351
555
|
]).toString("base64"),
|
|
352
556
|
encryptionKeyId: this.resolveKeyId(),
|
|
353
|
-
schemaVersion: _CredentialSecretCipher.
|
|
557
|
+
schemaVersion: _CredentialSecretCipher.currentSchemaVersion
|
|
354
558
|
};
|
|
355
559
|
}
|
|
356
560
|
decrypt(record) {
|
|
561
|
+
const keyMaterial = (record.schemaVersion ?? 1) >= 2 ? this.resolveKeyMaterialV2() : this.resolveKeyMaterialV1();
|
|
562
|
+
const currentKeyId = this.resolveKeyId();
|
|
563
|
+
if (record.encryptionKeyId !== currentKeyId) throw new CredentialKeyRotatedError(record.encryptionKeyId);
|
|
357
564
|
const packed = Buffer.from(record.encryptedJson, "base64");
|
|
358
565
|
const iv = packed.subarray(0, _CredentialSecretCipher.ivLength);
|
|
359
566
|
const authTag = packed.subarray(_CredentialSecretCipher.ivLength, _CredentialSecretCipher.ivLength + 16);
|
|
360
567
|
const encrypted = packed.subarray(_CredentialSecretCipher.ivLength + 16);
|
|
361
|
-
const decipher = createDecipheriv(_CredentialSecretCipher.algorithm,
|
|
568
|
+
const decipher = createDecipheriv(_CredentialSecretCipher.algorithm, keyMaterial, iv);
|
|
362
569
|
decipher.setAuthTag(authTag);
|
|
363
570
|
const plaintext = Buffer.concat([decipher.update(encrypted), decipher.final()]).toString("utf8");
|
|
364
571
|
return JSON.parse(plaintext);
|
|
365
572
|
}
|
|
366
|
-
|
|
573
|
+
/**
|
|
574
|
+
* Current (v2) key derivation: HKDF-SHA-256 with a fixed application salt and info label.
|
|
575
|
+
* Input must be a base64-encoded 32-byte value (`CODEMATION_CREDENTIALS_MASTER_KEY`).
|
|
576
|
+
*/
|
|
577
|
+
resolveKeyMaterialV2() {
|
|
578
|
+
const ikm = this.resolveBase64Key32Bytes();
|
|
579
|
+
return Buffer.from(hkdfSync("sha256", ikm, Buffer.from(_CredentialSecretCipher.HKDF_SALT, "utf8"), Buffer.from(_CredentialSecretCipher.HKDF_INFO, "utf8"), 32));
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Legacy (v1) key derivation: SHA-256 of the raw env string.
|
|
583
|
+
* Retained for decrypt-side backward compatibility only.
|
|
584
|
+
*/
|
|
585
|
+
resolveKeyMaterialV1() {
|
|
367
586
|
const rawValue = this.appConfig.env.CODEMATION_CREDENTIALS_MASTER_KEY;
|
|
368
587
|
if (!rawValue || rawValue.trim().length === 0) throw new Error("CODEMATION_CREDENTIALS_MASTER_KEY is required to encrypt database-managed credentials.");
|
|
369
588
|
return createHash("sha256").update(rawValue).digest();
|
|
370
589
|
}
|
|
590
|
+
/**
|
|
591
|
+
* Validates and returns the raw 32-byte key material from the env var.
|
|
592
|
+
* Throws if the env var is absent or does not decode to exactly 32 bytes.
|
|
593
|
+
*/
|
|
594
|
+
resolveBase64Key32Bytes() {
|
|
595
|
+
const rawValue = this.appConfig.env.CODEMATION_CREDENTIALS_MASTER_KEY;
|
|
596
|
+
if (!rawValue || rawValue.trim().length === 0) throw new Error("CODEMATION_CREDENTIALS_MASTER_KEY is required to encrypt database-managed credentials.");
|
|
597
|
+
const decoded = Buffer.from(rawValue.trim(), "base64");
|
|
598
|
+
if (decoded.length !== 32) throw new Error(`CODEMATION_CREDENTIALS_MASTER_KEY must be a base64-encoded 32-byte value (got ${decoded.length} bytes). Generate a valid key with: openssl rand -base64 32`);
|
|
599
|
+
return decoded;
|
|
600
|
+
}
|
|
371
601
|
resolveKeyId() {
|
|
372
602
|
const rawValue = this.appConfig.env.CODEMATION_CREDENTIALS_MASTER_KEY;
|
|
373
603
|
return createHash("sha256").update(rawValue ?? "").digest("hex").slice(0, 12);
|
|
@@ -713,12 +943,14 @@ CredentialInstanceService = __decorate([
|
|
|
713
943
|
//#region src/domain/credentials/CredentialBindingService.ts
|
|
714
944
|
var _ref$3, _ref2$3;
|
|
715
945
|
let CredentialBindingService = class CredentialBindingService$1 {
|
|
716
|
-
|
|
946
|
+
logger;
|
|
947
|
+
constructor(credentialStore, credentialInstanceService, workflowRepository, credentialSessionService, workflowCredentialNodeResolver, loggerFactory) {
|
|
717
948
|
this.credentialStore = credentialStore;
|
|
718
949
|
this.credentialInstanceService = credentialInstanceService;
|
|
719
950
|
this.workflowRepository = workflowRepository;
|
|
720
951
|
this.credentialSessionService = credentialSessionService;
|
|
721
952
|
this.workflowCredentialNodeResolver = workflowCredentialNodeResolver;
|
|
953
|
+
this.logger = loggerFactory.create("CredentialBindingService");
|
|
722
954
|
}
|
|
723
955
|
async upsertBinding(args) {
|
|
724
956
|
const workflow = this.requireWorkflow(args.workflowId);
|
|
@@ -738,6 +970,31 @@ let CredentialBindingService = class CredentialBindingService$1 {
|
|
|
738
970
|
this.credentialSessionService.evictBinding(binding.key);
|
|
739
971
|
return binding;
|
|
740
972
|
}
|
|
973
|
+
async assertRequiredCredentialsBound(workflowId) {
|
|
974
|
+
const workflow = this.requireWorkflow(workflowId);
|
|
975
|
+
const bindings = await this.credentialStore.listBindingsByWorkflowId(workflowId);
|
|
976
|
+
const boundKeys = new Set(bindings.map((b) => this.toBindingKeyString(b.key)));
|
|
977
|
+
const unboundByDb = this.workflowCredentialNodeResolver.listSlots(workflow).filter((slot) => !slot.requirement.optional).filter((slot) => !boundKeys.has(this.toBindingKeyString({
|
|
978
|
+
workflowId,
|
|
979
|
+
nodeId: slot.nodeId,
|
|
980
|
+
slotKey: slot.requirement.slotKey
|
|
981
|
+
})));
|
|
982
|
+
if (unboundByDb.length === 0) return;
|
|
983
|
+
const confirmed = [];
|
|
984
|
+
for (const slot of unboundByDb) try {
|
|
985
|
+
await this.credentialSessionService.getSession({
|
|
986
|
+
workflowId,
|
|
987
|
+
nodeId: slot.nodeId,
|
|
988
|
+
slotKey: slot.requirement.slotKey
|
|
989
|
+
});
|
|
990
|
+
} catch (error) {
|
|
991
|
+
if (!(error instanceof CredentialUnboundError)) this.logger.debug(`CredentialBindingService: unexpected error resolving session for slot ${slot.requirement.slotKey} on ${slot.nodeId}`, error instanceof Error ? error : void 0);
|
|
992
|
+
confirmed.push(slot);
|
|
993
|
+
}
|
|
994
|
+
if (confirmed.length === 0) return;
|
|
995
|
+
const descriptions = confirmed.map((slot) => `"${slot.requirement.label}" on ${slot.nodeName ?? slot.nodeId}`).join(", ");
|
|
996
|
+
throw new ApplicationRequestError(400, `Cannot run workflow: required credential slot${confirmed.length > 1 ? "s" : ""} not bound: ${descriptions}`);
|
|
997
|
+
}
|
|
741
998
|
async listWorkflowHealth(workflowId) {
|
|
742
999
|
const workflow = this.requireWorkflow(workflowId);
|
|
743
1000
|
const bindings = await this.credentialStore.listBindingsByWorkflowId(workflowId);
|
|
@@ -810,12 +1067,14 @@ CredentialBindingService = __decorate([
|
|
|
810
1067
|
__decorateParam(2, inject(CoreTokens.WorkflowRepository)),
|
|
811
1068
|
__decorateParam(3, inject(CoreTokens.CredentialSessionService)),
|
|
812
1069
|
__decorateParam(4, inject(WorkflowCredentialNodeResolver)),
|
|
1070
|
+
__decorateParam(5, inject(ApplicationTokens.LoggerFactory)),
|
|
813
1071
|
__decorateMetadata("design:paramtypes", [
|
|
814
1072
|
Object,
|
|
815
1073
|
typeof (_ref$3 = typeof CredentialInstanceService !== "undefined" && CredentialInstanceService) === "function" ? _ref$3 : Object,
|
|
816
1074
|
Object,
|
|
817
1075
|
Object,
|
|
818
|
-
typeof (_ref2$3 = typeof WorkflowCredentialNodeResolver !== "undefined" && WorkflowCredentialNodeResolver) === "function" ? _ref2$3 : Object
|
|
1076
|
+
typeof (_ref2$3 = typeof WorkflowCredentialNodeResolver !== "undefined" && WorkflowCredentialNodeResolver) === "function" ? _ref2$3 : Object,
|
|
1077
|
+
Object
|
|
819
1078
|
])
|
|
820
1079
|
], CredentialBindingService);
|
|
821
1080
|
|
|
@@ -1011,5 +1270,5 @@ CredentialTestService = __decorate([
|
|
|
1011
1270
|
], CredentialTestService);
|
|
1012
1271
|
|
|
1013
1272
|
//#endregion
|
|
1014
|
-
export { CredentialInstanceService as a, CredentialSecretCipher as c,
|
|
1015
|
-
//# sourceMappingURL=CredentialServices-
|
|
1273
|
+
export { CredentialInstanceService as a, CredentialSecretCipher as c, McpServerCatalog as d, ApplicationRequestError as f, OpenAiApiKeyCredentialHealthTester as g, OpenAiApiKeyCredentialTypeFactory as h, CredentialBindingService as i, CredentialFieldEnvOverlayService as l, ApplicationTokens as m, CredentialSessionServiceImpl as n, CredentialOAuth2ScopeResolver as o, CredentialTypeRegistryImpl as p, CredentialRuntimeMaterialService as r, CredentialMaterialResolver as s, CredentialTestService as t, WorkflowCredentialNodeResolver as u };
|
|
1274
|
+
//# sourceMappingURL=CredentialServices-Dk8yypeL.js.map
|