@codemation/host 0.7.0 → 0.9.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 +89 -0
- package/LICENSE +37 -1
- package/dist/{ApiPaths-Dv1dcHu_.js → ApiPaths-DCvrlIjg.js} +12 -1
- package/dist/{ApiPaths-Dv1dcHu_.js.map → ApiPaths-DCvrlIjg.js.map} +1 -1
- package/dist/{AppConfigFactory-Cx4qQvRk.js → AppConfigFactory-D4LL1aOR.js} +77 -297
- package/dist/AppConfigFactory-D4LL1aOR.js.map +1 -0
- package/dist/{AppConfigFactory-DnLoQ9Li.d.ts → AppConfigFactory-DncmwCD1.d.ts} +2918 -199
- package/dist/{AppContainerFactory-DqKYCRNP.js → AppContainerFactory-jpYXGZGe.js} +1733 -475
- package/dist/AppContainerFactory-jpYXGZGe.js.map +1 -0
- package/dist/{CodemationAppContext-CKVv9W9q.d.ts → CodemationAppContext-K51b7oXe.d.ts} +9 -3
- package/dist/{CodemationAuthoring.types-DA3G3s6d.d.ts → CodemationAuthoring.types-BXlXIl4K.d.ts} +9 -4
- package/dist/{CodemationAuthoring.types-NGkBcmmT.js → CodemationAuthoring.types-BteaR3Dc.js} +3 -2
- package/dist/CodemationAuthoring.types-BteaR3Dc.js.map +1 -0
- package/dist/{CodemationConfigNormalizer-BAKjetJ6.d.ts → CodemationConfigNormalizer-B4rDYC9h.d.ts} +3 -3
- package/dist/{CodemationConsumerConfigLoader-GYpBBvqE.js → CodemationConsumerConfigLoader-By-6tuGc.js} +3 -1
- package/dist/CodemationConsumerConfigLoader-By-6tuGc.js.map +1 -0
- package/dist/{CodemationConsumerConfigLoader-nxOqvv46.d.ts → CodemationConsumerConfigLoader-Dt4jyLx6.d.ts} +3 -2
- package/dist/{CodemationPluginListMerger-DKLAHT2b.d.ts → CodemationPluginListMerger-DS6I3Xe0.d.ts} +64 -27
- package/dist/{persistenceServer-C-hH4z6l.js → CodemationPostgresPrismaClientFactory-C7156Fe-.js} +2 -2
- package/dist/CodemationPostgresPrismaClientFactory-C7156Fe-.js.map +1 -0
- package/dist/CodemationPostgresPrismaClientFactory-CTNTPnDr.d.ts +9 -0
- package/dist/{CredentialContractsRegistry-Bq2bq28t.d.ts → CredentialContractsRegistry-Dgu-rEXi.d.ts} +16 -3
- package/dist/{CredentialServices-Be2I60Th.d.ts → CredentialServices-B3wPyp2y.d.ts} +4 -4
- package/dist/{CredentialServices-Dk8yypeL.js → CredentialServices-Bios0dM8.js} +10 -4
- package/dist/CredentialServices-Bios0dM8.js.map +1 -0
- package/dist/{InternalPingRegistrar-DY3kSfxP.js → InternalPingRegistrar-BavAAnvk.js} +19 -16
- package/dist/InternalPingRegistrar-BavAAnvk.js.map +1 -0
- package/dist/{ItemsInputNormalizer-_RwIfRIQ.d.ts → ItemsInputNormalizer-CFkfNMLt.d.ts} +1434 -1225
- package/dist/PrismaMigrationDeployer-DdEcXXVi.d.ts +14 -0
- package/dist/{PublicFrontendBootstrapFactory-CY2FS-5g.d.ts → PublicFrontendBootstrapFactory-ClEjZP74.d.ts} +2 -2
- package/dist/{PublicFrontendBootstrapJsonCodec-CXG9Dxft.d.ts → PublicFrontendBootstrapJsonCodec-HNItQ7ol.d.ts} +6 -1
- package/dist/{TelemetryContracts-BtDx84Cp.d.ts → TelemetryContracts-DpZEODQM.d.ts} +2 -2
- package/dist/{WorkflowPolicyUiPresentationFactory-6MyjCvBO.d.ts → WorkflowPolicyUiPresentationFactory-BNn2fvR_.d.ts} +2 -2
- package/dist/{WorkflowPolicyUiPresentationFactory-Bb-ae_Zh.js → WorkflowPolicyUiPresentationFactory-DfvD2VHk.js} +1 -1
- package/dist/{WorkflowPolicyUiPresentationFactory-Bb-ae_Zh.js.map → WorkflowPolicyUiPresentationFactory-DfvD2VHk.js.map} +1 -1
- package/dist/authoring.d.ts +4 -4
- package/dist/authoring.js +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/consumer.d.ts +5 -5
- package/dist/consumer.js +1 -1
- package/dist/credentials.d.ts +5 -5
- package/dist/credentials.js +1 -1
- package/dist/devServerSidecar.d.ts +2 -2
- package/dist/dto.d.ts +5 -5
- package/dist/{index-DilAYwnH.d.ts → index-ChIfeWzk.d.ts} +71 -28
- package/dist/index.d.ts +49 -17
- package/dist/index.js +106 -13
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/persistence/PrismaMigrationOperations.d.ts +44 -0
- package/dist/infrastructure/persistence/PrismaMigrationOperations.js +302 -0
- package/dist/infrastructure/persistence/PrismaMigrationOperations.js.map +1 -0
- package/dist/mapping.d.ts +2 -2
- package/dist/mapping.js +1 -1
- package/dist/nextServer.d.ts +15 -39
- package/dist/nextServer.js +6 -6
- package/dist/pairing.d.ts +27 -8
- package/dist/pairing.js +19 -3
- package/dist/pairing.js.map +1 -0
- package/dist/{pairing.types-snfZ_OzB.d.ts → pairing.types-D9Bjn98U.d.ts} +1 -1
- package/dist/persistenceServer.d.ts +31 -7
- package/dist/persistenceServer.js +2 -2
- package/dist/{server-C4bS62rg.d.ts → server-B5trn7y4.d.ts} +5 -5
- package/dist/{server-Y7kxwtCK.js → server-BlG9qV5S.js} +5 -5
- package/dist/{server-Y7kxwtCK.js.map → server-BlG9qV5S.js.map} +1 -1
- package/dist/server.d.ts +10 -10
- package/dist/server.js +9 -9
- package/package.json +28 -25
- package/playwright.config.ts +8 -2
- package/playwright.scaffolded-dev.config.ts +8 -2
- package/prisma/migrations/20260526120000_credential_material_pointer/migration.sql +18 -0
- package/prisma/migrations/20260527120000_add_human_task/migration.sql +32 -0
- package/prisma/migrations/20260527130000_add_hitl_state_json/migration.sql +6 -0
- package/prisma/migrations/20260527130000_add_hmac_nonce/migration.sql +12 -0
- package/prisma/migrations.sqlite/20260526120000_credential_material_pointer/migration.sql +13 -0
- package/prisma/migrations.sqlite/20260527120000_add_human_task/migration.sql +30 -0
- package/prisma/migrations.sqlite/20260527130000_add_hitl_state_json/migration.sql +6 -0
- package/prisma/migrations.sqlite/20260527130000_add_hmac_nonce/migration.sql +9 -0
- package/prisma/schema.postgresql.prisma +48 -0
- package/prisma/schema.sqlite.prisma +48 -0
- package/prisma-generated/prisma-postgresql-client/edge.js +40 -6
- package/prisma-generated/prisma-postgresql-client/index-browser.js +36 -2
- package/prisma-generated/prisma-postgresql-client/index.d.ts +3179 -163
- package/prisma-generated/prisma-postgresql-client/index.js +40 -6
- package/prisma-generated/prisma-postgresql-client/package.json +1 -1
- package/prisma-generated/prisma-postgresql-client/schema.prisma +48 -0
- package/prisma-generated/prisma-sqlite-client/edge.js +40 -6
- package/prisma-generated/prisma-sqlite-client/index-browser.js +36 -2
- package/prisma-generated/prisma-sqlite-client/index.d.ts +3175 -163
- package/prisma-generated/prisma-sqlite-client/index.js +40 -6
- package/prisma-generated/prisma-sqlite-client/package.json +1 -1
- package/prisma-generated/prisma-sqlite-client/schema.prisma +48 -0
- package/src/application/contracts/CredentialContractsRegistry.ts +15 -0
- package/src/application/credentials/AppGalleryProjector.ts +69 -0
- package/src/application/hitl/DecideHumanTaskCommandHandler.ts +149 -0
- package/src/application/hitl/DecisionSchemaValidator.ts +22 -0
- package/src/application/hitl/HitlCallbackHandler.ts +96 -0
- package/src/application/mapping/WorkflowDefinitionMapper.ts +1 -3
- package/src/application/queries/CredentialQueryHandlers.ts +2 -0
- package/src/application/queries/GetCredentialAppsQuery.ts +4 -0
- package/src/application/queries/GetCredentialAppsQueryHandler.ts +27 -0
- package/src/application/telemetry/ResumeTelemetryContextForRun.ts +53 -0
- package/src/application/telemetry/TelemetryRetentionTimestampFactory.ts +9 -8
- package/src/applicationTokens.ts +11 -1
- package/src/auth/managed/ManagedCorsMiddleware.ts +20 -5
- package/src/bootstrap/AppContainerFactory.ts +121 -3
- package/src/bootstrap/runtime/HeadlessApiRuntime.ts +47 -0
- package/src/credentials/CachingCredentialMaterialProvider.ts +96 -0
- package/src/credentials/CompositeCredentialMaterialProvider.ts +47 -0
- package/src/credentials/ControlPlaneCatalogFetcher.ts +8 -28
- package/src/credentials/ControlPlaneCredentialMaterialProvider.ts +79 -0
- package/src/credentials/CredentialOAuth2MaterialReader.ts +2 -7
- package/src/credentials/InternalCredentialsBindingRegistrar.ts +83 -0
- package/src/credentials/LocalCredentialMaterialProvider.ts +92 -0
- package/src/domain/credentials/CredentialInstanceService.ts +5 -1
- package/src/domain/credentials/CredentialTypeRegistryImpl.ts +18 -4
- package/src/domain/workflows/WorkflowActivationPreflightRules.ts +7 -4
- package/src/dto.ts +2 -0
- package/src/hitl/ControlPlaneInboxChannel.ts +102 -0
- package/src/hitl/HitlResumeTokenSigner.ts +80 -0
- package/src/hitl/HitlTimeoutJobScheduler.ts +77 -0
- package/src/hitl/HitlTimeoutWorker.ts +138 -0
- package/src/hitl/InboxChannelResolver.ts +49 -0
- package/src/hitl/LocalInboxChannel.ts +37 -0
- package/src/index.ts +3 -0
- package/src/infrastructure/persistence/PrismaCredentialStore.ts +10 -0
- package/src/infrastructure/persistence/PrismaHmacNonceStore.ts +29 -0
- package/src/infrastructure/persistence/PrismaHumanTaskStore.ts +156 -0
- package/src/infrastructure/persistence/PrismaMigrationDeployer.ts +53 -383
- package/src/infrastructure/persistence/PrismaMigrationOperations.ts +401 -0
- package/src/infrastructure/persistence/PrismaWorkflowRunRepository.ts +39 -0
- package/src/mcp/AgentMcpIntegrationImpl.ts +5 -1
- package/src/pairing/HmacNonceStore.ts +14 -0
- package/src/pairing/HmacNonceStoreToken.ts +4 -0
- package/src/pairing/HmacRequestSigner.ts +10 -1
- package/src/pairing/InMemoryHmacNonceStore.ts +24 -0
- package/src/pairing/IncomingHmacVerifier.ts +28 -12
- package/src/pairing/InternalHmacAuthMiddleware.ts +1 -1
- package/src/pairing/index.ts +3 -0
- package/src/presentation/config/CodemationAuthoring.types.ts +7 -1
- package/src/presentation/config/CodemationConfig.ts +6 -0
- package/src/presentation/http/ApiPaths.ts +14 -0
- package/src/presentation/http/HeadlessHttpServerFactory.ts +56 -0
- package/src/presentation/http/hono/HonoHttpAnonymousRoutePolicyRegistry.ts +4 -0
- package/src/presentation/http/hono/registrars/CredentialHonoApiRouteRegistrar.ts +1 -0
- package/src/presentation/http/hono/registrars/HitlDecideHonoApiRouteRegistrar.ts +54 -0
- package/src/presentation/http/hono/registrars/HitlInternalCallbackHonoApiRouteRegistrar.ts +33 -0
- package/src/presentation/http/hono/registrars/HitlResumeHonoApiRouteRegistrar.ts +43 -0
- package/src/presentation/http/routeHandlers/CredentialHttpRouteHandler.ts +9 -0
- package/src/presentation/http/routeHandlers/OAuth2HttpRouteHandlerFactory.ts +1 -1
- package/src/presentation/server/CodemationConsumerConfigLoader.ts +7 -2
- package/src/presentation/websocket/WorkflowWebsocketServerFactory.ts +16 -0
- package/src/server.ts +7 -2
- package/src/workflows/InternalWorkflowTestRunRegistrar.ts +9 -0
- package/tsconfig.json +1 -0
- package/dist/AppConfigFactory-Cx4qQvRk.js.map +0 -1
- package/dist/AppContainerFactory-DqKYCRNP.js.map +0 -1
- package/dist/CodemationAuthoring.types-NGkBcmmT.js.map +0 -1
- package/dist/CodemationConsumerConfigLoader-GYpBBvqE.js.map +0 -1
- package/dist/CredentialServices-Dk8yypeL.js.map +0 -1
- package/dist/InternalPingRegistrar-DY3kSfxP.js.map +0 -1
- package/dist/persistenceServer-C-hH4z6l.js.map +0 -1
- package/dist/persistenceServer-CeTHtC6E.d.ts +0 -30
- package/src/credentials/catalogTypes.ts +0 -4
|
@@ -1,8 +1,32 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import "./ItemsInputNormalizer-
|
|
3
|
-
import { i as AppPersistenceConfig } from "./CodemationAppContext-
|
|
1
|
+
import "./index-ChIfeWzk.js";
|
|
2
|
+
import "./ItemsInputNormalizer-CFkfNMLt.js";
|
|
3
|
+
import { i as AppPersistenceConfig } from "./CodemationAppContext-K51b7oXe.js";
|
|
4
4
|
import "./CodemationWhitelabelConfig-Ca2mCUeC.js";
|
|
5
|
-
import "./CodemationConfigNormalizer-
|
|
6
|
-
import { n as
|
|
7
|
-
import {
|
|
8
|
-
|
|
5
|
+
import "./CodemationConfigNormalizer-B4rDYC9h.js";
|
|
6
|
+
import { n as PrismaDatabaseClient, t as AppConfigFactory } from "./AppConfigFactory-DncmwCD1.js";
|
|
7
|
+
import { t as PrismaMigrationDeployer } from "./PrismaMigrationDeployer-DdEcXXVi.js";
|
|
8
|
+
import { t as CodemationPostgresPrismaClientFactory } from "./CodemationPostgresPrismaClientFactory-CTNTPnDr.js";
|
|
9
|
+
|
|
10
|
+
//#region src/infrastructure/persistence/CodemationDatabaseUrlParser.d.ts
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Parses `CODEMATION_DATABASE_URL` into an {@link AppPersistenceConfig}.
|
|
14
|
+
*
|
|
15
|
+
* Supported schemes (case-insensitive):
|
|
16
|
+
* - `sqlite://relative/path/to/file.db` → resolved relative to consumerRoot
|
|
17
|
+
* - `sqlite:///absolute/path/to/file.db` → leading slash = POSIX absolute
|
|
18
|
+
* - `sqlite://C:/path/file.db` → Windows-style absolute (path.isAbsolute()
|
|
19
|
+
* returns true for these)
|
|
20
|
+
* - `pgsql://user:pass@host:5432/dbname` → normalised to postgresql://
|
|
21
|
+
* - `postgresql://user:pass@host:5432/db` → pass-through (Prisma's expected scheme)
|
|
22
|
+
* - `postgres://user:pass@host:5432/db` → pass-through (common alias)
|
|
23
|
+
*
|
|
24
|
+
* Throws on any other scheme. Empty / whitespace input is also an error — callers
|
|
25
|
+
* should default before calling parse().
|
|
26
|
+
*/
|
|
27
|
+
declare class CodemationDatabaseUrlParser {
|
|
28
|
+
parse(url: string, consumerRoot: string): AppPersistenceConfig;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { AppConfigFactory, type AppPersistenceConfig, CodemationDatabaseUrlParser, CodemationPostgresPrismaClientFactory, type PrismaDatabaseClient as PrismaClient, PrismaMigrationDeployer };
|
|
32
|
+
//# sourceMappingURL=persistenceServer.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./decorate-CXWmflG_.js";
|
|
2
|
-
import { i as PrismaMigrationDeployer, n as CodemationDatabaseUrlParser, t as AppConfigFactory } from "./AppConfigFactory-
|
|
3
|
-
import { t as CodemationPostgresPrismaClientFactory } from "./
|
|
2
|
+
import { i as PrismaMigrationDeployer, n as CodemationDatabaseUrlParser, t as AppConfigFactory } from "./AppConfigFactory-D4LL1aOR.js";
|
|
3
|
+
import { t as CodemationPostgresPrismaClientFactory } from "./CodemationPostgresPrismaClientFactory-C7156Fe-.js";
|
|
4
4
|
|
|
5
5
|
export { AppConfigFactory, CodemationDatabaseUrlParser, CodemationPostgresPrismaClientFactory, PrismaMigrationDeployer };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { m as CodemationConfig, o as CodemationPlugin, r as AppConfig } from "./CodemationAppContext-
|
|
2
|
-
import { t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-
|
|
1
|
+
import { m as CodemationConfig, o as CodemationPlugin, r as AppConfig } from "./CodemationAppContext-K51b7oXe.js";
|
|
2
|
+
import { t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-Dt4jyLx6.js";
|
|
3
3
|
import { i as WorkflowSummary, t as WorkflowDto } from "./WorkflowViewContracts-B7aFQcIw.js";
|
|
4
|
-
import { t as AppConfigFactory } from "./AppConfigFactory-
|
|
5
|
-
import { a as ProcessRunOptions, o as ProcessRunResult, s as ProcessRunner } from "./PublicFrontendBootstrapFactory-
|
|
4
|
+
import { t as AppConfigFactory } from "./AppConfigFactory-DncmwCD1.js";
|
|
5
|
+
import { a as ProcessRunOptions, o as ProcessRunResult, s as ProcessRunner } from "./PublicFrontendBootstrapFactory-ClEjZP74.js";
|
|
6
6
|
import { ChildProcess } from "node:child_process";
|
|
7
7
|
|
|
8
8
|
//#region src/process/ExecaProcessRunner.d.ts
|
|
@@ -104,4 +104,4 @@ declare class WorkflowDiscoveryPathSegmentsComputer {
|
|
|
104
104
|
}
|
|
105
105
|
//#endregion
|
|
106
106
|
export { CodemationResolvedPluginPackage as a, CodemationServerGateway as c, CodemationPluginDiscovery as i, ExecaProcessRunner as l, WorkflowModulePathFinder as n, AppConfigLoadResult as o, CodemationDiscoveredPluginPackage as r, AppConfigLoader as s, WorkflowDiscoveryPathSegmentsComputer as t };
|
|
107
|
-
//# sourceMappingURL=server-
|
|
107
|
+
//# sourceMappingURL=server-B5trn7y4.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as CodemationConfigNormalizer, t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-
|
|
2
|
-
import { m as ApplicationTokens } from "./CredentialServices-
|
|
3
|
-
import { A as WorkflowDefinitionMapper, C as CodemationHonoApiApp, M as GetWorkflowDetailQuery, d as FrontendRuntime, j as GetWorkflowSummariesQuery, m as AppContainerLifecycle, t as AppContainerFactory } from "./AppContainerFactory-
|
|
4
|
-
import { r as CodemationPluginPackageMetadata, t as AppConfigFactory } from "./AppConfigFactory-
|
|
1
|
+
import { a as CodemationConfigNormalizer, t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-By-6tuGc.js";
|
|
2
|
+
import { m as ApplicationTokens } from "./CredentialServices-Bios0dM8.js";
|
|
3
|
+
import { A as WorkflowDefinitionMapper, C as CodemationHonoApiApp, M as GetWorkflowDetailQuery, d as FrontendRuntime, j as GetWorkflowSummariesQuery, m as AppContainerLifecycle, t as AppContainerFactory } from "./AppContainerFactory-jpYXGZGe.js";
|
|
4
|
+
import { r as CodemationPluginPackageMetadata, t as AppConfigFactory } from "./AppConfigFactory-D4LL1aOR.js";
|
|
5
5
|
import { readFile, readdir } from "node:fs/promises";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { pathToFileURL } from "node:url";
|
|
@@ -219,4 +219,4 @@ var CodemationPluginDiscovery = class {
|
|
|
219
219
|
|
|
220
220
|
//#endregion
|
|
221
221
|
export { AppConfigLoader as n, CodemationServerGateway as r, CodemationPluginDiscovery as t };
|
|
222
|
-
//# sourceMappingURL=server-
|
|
222
|
+
//# sourceMappingURL=server-BlG9qV5S.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-Y7kxwtCK.js","names":["config: CodemationConfig","consumerRoot: string","configSource?: string","workflowSources: ReadonlyArray<string>","env?: Readonly<NodeJS.ProcessEnv>","consumerConfigLoader: CodemationConsumerConfigLoader","appConfigFactory: AppConfigFactory","discoveredPackages: CodemationDiscoveredPluginPackage[]","resolvedPackages: CodemationResolvedPluginPackage[]","packageRoots: string[]"],"sources":["../src/presentation/http/CodemationServerGatewayFactory.ts","../src/presentation/server/AppConfigLoader.ts","../src/presentation/server/CodemationPluginDiscovery.ts"],"sourcesContent":["import { accessSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { QueryBus } from \"../../application/bus/QueryBus\";\nimport type { WorkflowDto, WorkflowSummary } from \"../../application/contracts/WorkflowViewContracts\";\nimport { WorkflowDefinitionMapper } from \"../../application/mapping/WorkflowDefinitionMapper\";\nimport { GetWorkflowDetailQuery } from \"../../application/queries/GetWorkflowDetailQuery\";\nimport { GetWorkflowSummariesQuery } from \"../../application/queries/GetWorkflowSummariesQuery\";\nimport { ApplicationTokens } from \"../../applicationTokens\";\nimport { AppContainerFactory } from \"../../bootstrap/AppContainerFactory\";\nimport { AppContainerLifecycle } from \"../../bootstrap/AppContainerLifecycle\";\nimport { FrontendRuntime } from \"../../bootstrap/runtime/FrontendRuntime\";\nimport { AppConfigFactory } from \"../../bootstrap/runtime/AppConfigFactory\";\nimport type { CodemationConfig } from \"../config/CodemationConfig\";\nimport { CodemationConfigNormalizer } from \"../config/CodemationConfigNormalizer\";\nimport { CodemationHonoApiApp } from \"./hono/CodemationHonoApiAppFactory\";\n\ntype ServerGatewayContext = Readonly<{\n container: import(\"@codemation/core\").Container;\n httpApi: CodemationHonoApiApp;\n queryBus: QueryBus;\n workflowDefinitionMapper: WorkflowDefinitionMapper;\n}>;\n\nexport class CodemationServerGateway {\n private static readonly contextsByConfig = new WeakMap<object, Promise<ServerGatewayContext>>();\n\n constructor(\n private readonly config: CodemationConfig,\n private readonly consumerRoot: string,\n private readonly configSource?: string,\n private readonly workflowSources: ReadonlyArray<string> = [],\n private readonly env?: Readonly<NodeJS.ProcessEnv>,\n ) {}\n\n async dispatch(request: Request): Promise<Response> {\n return await (await this.getContext()).httpApi.fetch(request);\n }\n\n async prepare(): Promise<void> {\n await this.getContext();\n }\n\n async close(): Promise<void> {\n const cachedContext = CodemationServerGateway.contextsByConfig.get(this.config as object);\n if (!cachedContext) {\n return;\n }\n CodemationServerGateway.contextsByConfig.delete(this.config as object);\n await (await cachedContext).container.resolve(AppContainerLifecycle).stop();\n }\n\n async loadWorkflowSummaries(): Promise<ReadonlyArray<WorkflowSummary>> {\n const context = await this.getContext();\n const workflows = await context.queryBus.execute(new GetWorkflowSummariesQuery());\n return workflows.map((workflow) => context.workflowDefinitionMapper.toSummary(workflow));\n }\n\n async loadWorkflowDetail(workflowId: string): Promise<WorkflowDto> {\n const context = await this.getContext();\n const workflow = await context.queryBus.execute(new GetWorkflowDetailQuery(workflowId));\n if (!workflow) {\n throw new Error(`Unknown workflowId: ${workflowId}`);\n }\n return await context.workflowDefinitionMapper.map(workflow);\n }\n\n private getContext(): Promise<ServerGatewayContext> {\n const cachedContext = CodemationServerGateway.contextsByConfig.get(this.config as object);\n if (cachedContext) {\n return cachedContext;\n }\n const nextContext = this.createContext();\n CodemationServerGateway.contextsByConfig.set(this.config as object, nextContext);\n return nextContext;\n }\n\n private async createContext(): Promise<ServerGatewayContext> {\n const repoRoot = this.detectWorkspaceRoot(this.consumerRoot);\n // This gateway is the config/env boundary that materializes AppConfig from raw inputs.\n // eslint-disable-next-line no-restricted-properties\n const env = this.env ?? process.env;\n const appConfig = new AppConfigFactory().create({\n repoRoot,\n consumerRoot: this.consumerRoot,\n env,\n config: new CodemationConfigNormalizer().normalize(this.config),\n workflowSources: this.resolveWorkflowSources(),\n });\n const container = await new AppContainerFactory().create({\n appConfig,\n sharedWorkflowWebsocketServer: null,\n });\n await container.resolve(FrontendRuntime).start();\n return {\n container,\n httpApi: container.resolve(CodemationHonoApiApp),\n queryBus: container.resolve(ApplicationTokens.QueryBus),\n workflowDefinitionMapper: container.resolve(WorkflowDefinitionMapper),\n };\n }\n\n private resolveWorkflowSources(): ReadonlyArray<string> {\n if (this.workflowSources.length > 0) {\n return [...this.workflowSources];\n }\n if (!this.configSource || !this.config.workflows || this.config.workflows.length === 0) {\n return [];\n }\n return [this.configSource];\n }\n private detectWorkspaceRoot(startDirectory: string): string {\n let currentDirectory = path.resolve(startDirectory);\n while (true) {\n try {\n accessSync(path.resolve(currentDirectory, \"pnpm-workspace.yaml\"));\n return currentDirectory;\n } catch {\n const parentDirectory = path.dirname(currentDirectory);\n if (parentDirectory === currentDirectory) {\n return startDirectory;\n }\n currentDirectory = parentDirectory;\n }\n }\n }\n}\n","import type { AppConfig } from \"../config/AppConfig\";\nimport { CodemationConsumerConfigLoader } from \"./CodemationConsumerConfigLoader\";\nimport { AppConfigFactory } from \"../../bootstrap/runtime/AppConfigFactory\";\n\nexport type AppConfigLoadResult = Readonly<{\n appConfig: AppConfig;\n bootstrapSource: string | null;\n}>;\n\nexport class AppConfigLoader {\n constructor(\n private readonly consumerConfigLoader: CodemationConsumerConfigLoader = new CodemationConsumerConfigLoader(),\n private readonly appConfigFactory: AppConfigFactory = new AppConfigFactory(),\n ) {}\n\n async load(\n args: Readonly<{\n consumerRoot: string;\n repoRoot: string;\n env: NodeJS.ProcessEnv;\n configPathOverride?: string;\n }>,\n ): Promise<AppConfigLoadResult> {\n const resolution = await this.consumerConfigLoader.load({\n consumerRoot: args.consumerRoot,\n configPathOverride: args.configPathOverride,\n });\n return {\n appConfig: this.appConfigFactory.create({\n repoRoot: args.repoRoot,\n consumerRoot: args.consumerRoot,\n env: args.env,\n config: resolution.config,\n workflowSources: resolution.workflowSources,\n }),\n bootstrapSource: resolution.bootstrapSource,\n };\n }\n}\n","import type { CodemationPackageManifest } from \"../config/CodemationPackageManifest\";\nimport { CodemationPluginPackageMetadata, type CodemationPlugin } from \"../config/CodemationPlugin\";\nimport { readFile, readdir } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nexport type CodemationDiscoveredPluginPackage = Readonly<{\n packageName: string;\n packageRoot: string;\n pluginEntry: string;\n developmentEntry?: string;\n}>;\n\nexport type CodemationResolvedPluginPackage = Readonly<\n CodemationDiscoveredPluginPackage & {\n plugin: CodemationPlugin;\n }\n>;\n\ntype PackageJsonShape = Readonly<{\n codemation?: CodemationPackageManifest;\n name?: string;\n exports?: Readonly<Record<string, unknown>>;\n}>;\n\nexport class CodemationPluginDiscovery {\n private readonly pluginPackageMetadata = new CodemationPluginPackageMetadata();\n\n async discover(consumerRoot: string): Promise<ReadonlyArray<CodemationDiscoveredPluginPackage>> {\n const nodeModulesRoot = path.resolve(consumerRoot, \"node_modules\");\n const packageRoots = await this.collectPackageRoots(nodeModulesRoot);\n const discoveredPackages: CodemationDiscoveredPluginPackage[] = [];\n for (const packageRoot of packageRoots) {\n const packageJson = await this.readPackageJson(path.resolve(packageRoot, \"package.json\"));\n const pluginManifest = packageJson.codemation?.plugin;\n if (!packageJson.name || typeof pluginManifest !== \"string\" || pluginManifest.trim().length === 0) {\n continue;\n }\n discoveredPackages.push({\n packageName: packageJson.name,\n packageRoot,\n pluginEntry: pluginManifest,\n developmentEntry: await this.resolveDevelopmentPluginEntry(packageRoot),\n });\n }\n return discoveredPackages.sort((left, right) => left.packageName.localeCompare(right.packageName));\n }\n\n async resolvePlugins(consumerRoot: string): Promise<ReadonlyArray<CodemationResolvedPluginPackage>> {\n const discoveredPackages = await this.discover(consumerRoot);\n return await this.resolveDiscoveredPackages(discoveredPackages);\n }\n\n async resolveDiscoveredPackages(\n discoveredPackages: ReadonlyArray<CodemationDiscoveredPluginPackage>,\n ): Promise<ReadonlyArray<CodemationResolvedPluginPackage>> {\n const resolvedPackages: CodemationResolvedPluginPackage[] = [];\n for (const discoveredPackage of discoveredPackages) {\n resolvedPackages.push({\n ...discoveredPackage,\n plugin: await this.loadPlugin(discoveredPackage),\n });\n }\n return resolvedPackages;\n }\n\n private async collectPackageRoots(nodeModulesRoot: string): Promise<ReadonlyArray<string>> {\n try {\n const entries = await readdir(nodeModulesRoot, { withFileTypes: true });\n const packageRoots: string[] = [];\n for (const entry of entries) {\n if (!entry.isDirectory() && !entry.isSymbolicLink()) {\n continue;\n }\n if (entry.name.startsWith(\"@\")) {\n const scopedEntries = await readdir(path.resolve(nodeModulesRoot, entry.name), { withFileTypes: true });\n for (const scopedEntry of scopedEntries) {\n if (scopedEntry.isDirectory() || scopedEntry.isSymbolicLink()) {\n packageRoots.push(path.resolve(nodeModulesRoot, entry.name, scopedEntry.name));\n }\n }\n continue;\n }\n packageRoots.push(path.resolve(nodeModulesRoot, entry.name));\n }\n return packageRoots;\n } catch {\n return [];\n }\n }\n\n private async readPackageJson(packageJsonPath: string): Promise<PackageJsonShape> {\n try {\n const rawPackageJson = await readFile(packageJsonPath, \"utf8\");\n return JSON.parse(rawPackageJson) as PackageJsonShape;\n } catch {\n return {};\n }\n }\n\n private async loadPlugin(discoveredPackage: CodemationDiscoveredPluginPackage): Promise<CodemationPlugin> {\n const pluginModulePath = path.resolve(discoveredPackage.packageRoot, this.resolvePluginEntry(discoveredPackage));\n const importedModule = (await import(\n /* webpackIgnore: true */ this.resolvePluginModuleSpecifier(pluginModulePath)\n )) as Record<string, unknown>;\n const exportedValue = importedModule.default;\n const plugin = this.resolvePluginValue(exportedValue);\n if (!plugin) {\n throw new Error(`Plugin package \"${discoveredPackage.packageName}\" did not default-export a Codemation plugin.`);\n }\n return this.pluginPackageMetadata.attachPackageName(plugin, discoveredPackage.packageName);\n }\n\n private resolvePluginValue(value: unknown): CodemationPlugin | null {\n if (this.isPluginConfig(value)) {\n return value;\n }\n return null;\n }\n\n private isPluginConfig(value: unknown): value is CodemationPlugin {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return false;\n }\n const pluginValue = value as {\n credentialTypes?: unknown;\n mcpServers?: unknown;\n register?: unknown;\n sandbox?: unknown;\n };\n if (pluginValue.register !== undefined && typeof pluginValue.register !== \"function\") {\n return false;\n }\n if (pluginValue.credentialTypes !== undefined && !Array.isArray(pluginValue.credentialTypes)) {\n return false;\n }\n if (pluginValue.mcpServers !== undefined && !Array.isArray(pluginValue.mcpServers)) {\n return false;\n }\n return (\n pluginValue.register !== undefined ||\n pluginValue.credentialTypes !== undefined ||\n pluginValue.mcpServers !== undefined ||\n pluginValue.sandbox !== undefined ||\n Object.keys(pluginValue).length === 0\n );\n }\n\n private resolvePluginEntry(discoveredPackage: CodemationDiscoveredPluginPackage): string {\n const preferSource =\n process.env.CODEMATION_PREFER_PLUGIN_SOURCE_ENTRY === \"true\" &&\n typeof discoveredPackage.developmentEntry === \"string\" &&\n discoveredPackage.developmentEntry.trim().length > 0;\n const selectedEntry = preferSource ? discoveredPackage.developmentEntry : discoveredPackage.pluginEntry;\n return selectedEntry;\n }\n\n private async resolveDevelopmentPluginEntry(packageRoot: string): Promise<string | undefined> {\n const candidates = [\n path.resolve(packageRoot, \"codemation.plugin.ts\"),\n path.resolve(packageRoot, \"codemation.plugin.js\"),\n path.resolve(packageRoot, \"src\", \"codemation.plugin.ts\"),\n path.resolve(packageRoot, \"src\", \"codemation.plugin.js\"),\n ];\n for (const candidate of candidates) {\n if (await this.exists(candidate)) {\n return path.relative(packageRoot, candidate);\n }\n }\n return undefined;\n }\n\n private async exists(filePath: string): Promise<boolean> {\n try {\n await readFile(filePath, \"utf8\");\n return true;\n } catch {\n return false;\n }\n }\n\n private resolvePluginModuleSpecifier(pluginModulePath: string): string {\n return pathToFileURL(pluginModulePath).href;\n }\n}\n"],"mappings":";;;;;;;;;;AAuBA,IAAa,0BAAb,MAAa,wBAAwB;CACnC,OAAwB,mCAAmB,IAAI,SAAgD;CAE/F,YACE,AAAiBA,QACjB,AAAiBC,cAC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AChC,YAAY,eAAe,UAC3B,YAAY,YAAY,UACxB,OAAO,KAAK,YAAY,CAAC,WAAW;;CAIxC,AAAQ,mBAAmB,mBAA8D;AAMvF,SAJE,QAAQ,IAAI,0CAA0C,UACtD,OAAO,kBAAkB,qBAAqB,YAC9C,kBAAkB,iBAAiB,MAAM,CAAC,SAAS,IAChB,kBAAkB,mBAAmB,kBAAkB;;CAI9F,MAAc,8BAA8B,aAAkD;EAC5F,MAAM,aAAa;GACjB,KAAK,QAAQ,aAAa,uBAAuB;GACjD,KAAK,QAAQ,aAAa,uBAAuB;GACjD,KAAK,QAAQ,aAAa,OAAO,uBAAuB;GACxD,KAAK,QAAQ,aAAa,OAAO,uBAAuB;GACzD;AACD,OAAK,MAAM,aAAa,WACtB,KAAI,MAAM,KAAK,OAAO,UAAU,CAC9B,QAAO,KAAK,SAAS,aAAa,UAAU;;CAMlD,MAAc,OAAO,UAAoC;AACvD,MAAI;AACF,SAAM,SAAS,UAAU,OAAO;AAChC,UAAO;UACD;AACN,UAAO;;;CAIX,AAAQ,6BAA6B,kBAAkC;AACrE,SAAO,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"server-BlG9qV5S.js","names":["config: CodemationConfig","consumerRoot: string","configSource?: string","workflowSources: ReadonlyArray<string>","env?: Readonly<NodeJS.ProcessEnv>","consumerConfigLoader: CodemationConsumerConfigLoader","appConfigFactory: AppConfigFactory","discoveredPackages: CodemationDiscoveredPluginPackage[]","resolvedPackages: CodemationResolvedPluginPackage[]","packageRoots: string[]"],"sources":["../src/presentation/http/CodemationServerGatewayFactory.ts","../src/presentation/server/AppConfigLoader.ts","../src/presentation/server/CodemationPluginDiscovery.ts"],"sourcesContent":["import { accessSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { QueryBus } from \"../../application/bus/QueryBus\";\nimport type { WorkflowDto, WorkflowSummary } from \"../../application/contracts/WorkflowViewContracts\";\nimport { WorkflowDefinitionMapper } from \"../../application/mapping/WorkflowDefinitionMapper\";\nimport { GetWorkflowDetailQuery } from \"../../application/queries/GetWorkflowDetailQuery\";\nimport { GetWorkflowSummariesQuery } from \"../../application/queries/GetWorkflowSummariesQuery\";\nimport { ApplicationTokens } from \"../../applicationTokens\";\nimport { AppContainerFactory } from \"../../bootstrap/AppContainerFactory\";\nimport { AppContainerLifecycle } from \"../../bootstrap/AppContainerLifecycle\";\nimport { FrontendRuntime } from \"../../bootstrap/runtime/FrontendRuntime\";\nimport { AppConfigFactory } from \"../../bootstrap/runtime/AppConfigFactory\";\nimport type { CodemationConfig } from \"../config/CodemationConfig\";\nimport { CodemationConfigNormalizer } from \"../config/CodemationConfigNormalizer\";\nimport { CodemationHonoApiApp } from \"./hono/CodemationHonoApiAppFactory\";\n\ntype ServerGatewayContext = Readonly<{\n container: import(\"@codemation/core\").Container;\n httpApi: CodemationHonoApiApp;\n queryBus: QueryBus;\n workflowDefinitionMapper: WorkflowDefinitionMapper;\n}>;\n\nexport class CodemationServerGateway {\n private static readonly contextsByConfig = new WeakMap<object, Promise<ServerGatewayContext>>();\n\n constructor(\n private readonly config: CodemationConfig,\n private readonly consumerRoot: string,\n private readonly configSource?: string,\n private readonly workflowSources: ReadonlyArray<string> = [],\n private readonly env?: Readonly<NodeJS.ProcessEnv>,\n ) {}\n\n async dispatch(request: Request): Promise<Response> {\n return await (await this.getContext()).httpApi.fetch(request);\n }\n\n async prepare(): Promise<void> {\n await this.getContext();\n }\n\n async close(): Promise<void> {\n const cachedContext = CodemationServerGateway.contextsByConfig.get(this.config as object);\n if (!cachedContext) {\n return;\n }\n CodemationServerGateway.contextsByConfig.delete(this.config as object);\n await (await cachedContext).container.resolve(AppContainerLifecycle).stop();\n }\n\n async loadWorkflowSummaries(): Promise<ReadonlyArray<WorkflowSummary>> {\n const context = await this.getContext();\n const workflows = await context.queryBus.execute(new GetWorkflowSummariesQuery());\n return workflows.map((workflow) => context.workflowDefinitionMapper.toSummary(workflow));\n }\n\n async loadWorkflowDetail(workflowId: string): Promise<WorkflowDto> {\n const context = await this.getContext();\n const workflow = await context.queryBus.execute(new GetWorkflowDetailQuery(workflowId));\n if (!workflow) {\n throw new Error(`Unknown workflowId: ${workflowId}`);\n }\n return await context.workflowDefinitionMapper.map(workflow);\n }\n\n private getContext(): Promise<ServerGatewayContext> {\n const cachedContext = CodemationServerGateway.contextsByConfig.get(this.config as object);\n if (cachedContext) {\n return cachedContext;\n }\n const nextContext = this.createContext();\n CodemationServerGateway.contextsByConfig.set(this.config as object, nextContext);\n return nextContext;\n }\n\n private async createContext(): Promise<ServerGatewayContext> {\n const repoRoot = this.detectWorkspaceRoot(this.consumerRoot);\n // This gateway is the config/env boundary that materializes AppConfig from raw inputs.\n // eslint-disable-next-line no-restricted-properties\n const env = this.env ?? process.env;\n const appConfig = new AppConfigFactory().create({\n repoRoot,\n consumerRoot: this.consumerRoot,\n env,\n config: new CodemationConfigNormalizer().normalize(this.config),\n workflowSources: this.resolveWorkflowSources(),\n });\n const container = await new AppContainerFactory().create({\n appConfig,\n sharedWorkflowWebsocketServer: null,\n });\n await container.resolve(FrontendRuntime).start();\n return {\n container,\n httpApi: container.resolve(CodemationHonoApiApp),\n queryBus: container.resolve(ApplicationTokens.QueryBus),\n workflowDefinitionMapper: container.resolve(WorkflowDefinitionMapper),\n };\n }\n\n private resolveWorkflowSources(): ReadonlyArray<string> {\n if (this.workflowSources.length > 0) {\n return [...this.workflowSources];\n }\n if (!this.configSource || !this.config.workflows || this.config.workflows.length === 0) {\n return [];\n }\n return [this.configSource];\n }\n private detectWorkspaceRoot(startDirectory: string): string {\n let currentDirectory = path.resolve(startDirectory);\n while (true) {\n try {\n accessSync(path.resolve(currentDirectory, \"pnpm-workspace.yaml\"));\n return currentDirectory;\n } catch {\n const parentDirectory = path.dirname(currentDirectory);\n if (parentDirectory === currentDirectory) {\n return startDirectory;\n }\n currentDirectory = parentDirectory;\n }\n }\n }\n}\n","import type { AppConfig } from \"../config/AppConfig\";\nimport { CodemationConsumerConfigLoader } from \"./CodemationConsumerConfigLoader\";\nimport { AppConfigFactory } from \"../../bootstrap/runtime/AppConfigFactory\";\n\nexport type AppConfigLoadResult = Readonly<{\n appConfig: AppConfig;\n bootstrapSource: string | null;\n}>;\n\nexport class AppConfigLoader {\n constructor(\n private readonly consumerConfigLoader: CodemationConsumerConfigLoader = new CodemationConsumerConfigLoader(),\n private readonly appConfigFactory: AppConfigFactory = new AppConfigFactory(),\n ) {}\n\n async load(\n args: Readonly<{\n consumerRoot: string;\n repoRoot: string;\n env: NodeJS.ProcessEnv;\n configPathOverride?: string;\n }>,\n ): Promise<AppConfigLoadResult> {\n const resolution = await this.consumerConfigLoader.load({\n consumerRoot: args.consumerRoot,\n configPathOverride: args.configPathOverride,\n });\n return {\n appConfig: this.appConfigFactory.create({\n repoRoot: args.repoRoot,\n consumerRoot: args.consumerRoot,\n env: args.env,\n config: resolution.config,\n workflowSources: resolution.workflowSources,\n }),\n bootstrapSource: resolution.bootstrapSource,\n };\n }\n}\n","import type { CodemationPackageManifest } from \"../config/CodemationPackageManifest\";\nimport { CodemationPluginPackageMetadata, type CodemationPlugin } from \"../config/CodemationPlugin\";\nimport { readFile, readdir } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nexport type CodemationDiscoveredPluginPackage = Readonly<{\n packageName: string;\n packageRoot: string;\n pluginEntry: string;\n developmentEntry?: string;\n}>;\n\nexport type CodemationResolvedPluginPackage = Readonly<\n CodemationDiscoveredPluginPackage & {\n plugin: CodemationPlugin;\n }\n>;\n\ntype PackageJsonShape = Readonly<{\n codemation?: CodemationPackageManifest;\n name?: string;\n exports?: Readonly<Record<string, unknown>>;\n}>;\n\nexport class CodemationPluginDiscovery {\n private readonly pluginPackageMetadata = new CodemationPluginPackageMetadata();\n\n async discover(consumerRoot: string): Promise<ReadonlyArray<CodemationDiscoveredPluginPackage>> {\n const nodeModulesRoot = path.resolve(consumerRoot, \"node_modules\");\n const packageRoots = await this.collectPackageRoots(nodeModulesRoot);\n const discoveredPackages: CodemationDiscoveredPluginPackage[] = [];\n for (const packageRoot of packageRoots) {\n const packageJson = await this.readPackageJson(path.resolve(packageRoot, \"package.json\"));\n const pluginManifest = packageJson.codemation?.plugin;\n if (!packageJson.name || typeof pluginManifest !== \"string\" || pluginManifest.trim().length === 0) {\n continue;\n }\n discoveredPackages.push({\n packageName: packageJson.name,\n packageRoot,\n pluginEntry: pluginManifest,\n developmentEntry: await this.resolveDevelopmentPluginEntry(packageRoot),\n });\n }\n return discoveredPackages.sort((left, right) => left.packageName.localeCompare(right.packageName));\n }\n\n async resolvePlugins(consumerRoot: string): Promise<ReadonlyArray<CodemationResolvedPluginPackage>> {\n const discoveredPackages = await this.discover(consumerRoot);\n return await this.resolveDiscoveredPackages(discoveredPackages);\n }\n\n async resolveDiscoveredPackages(\n discoveredPackages: ReadonlyArray<CodemationDiscoveredPluginPackage>,\n ): Promise<ReadonlyArray<CodemationResolvedPluginPackage>> {\n const resolvedPackages: CodemationResolvedPluginPackage[] = [];\n for (const discoveredPackage of discoveredPackages) {\n resolvedPackages.push({\n ...discoveredPackage,\n plugin: await this.loadPlugin(discoveredPackage),\n });\n }\n return resolvedPackages;\n }\n\n private async collectPackageRoots(nodeModulesRoot: string): Promise<ReadonlyArray<string>> {\n try {\n const entries = await readdir(nodeModulesRoot, { withFileTypes: true });\n const packageRoots: string[] = [];\n for (const entry of entries) {\n if (!entry.isDirectory() && !entry.isSymbolicLink()) {\n continue;\n }\n if (entry.name.startsWith(\"@\")) {\n const scopedEntries = await readdir(path.resolve(nodeModulesRoot, entry.name), { withFileTypes: true });\n for (const scopedEntry of scopedEntries) {\n if (scopedEntry.isDirectory() || scopedEntry.isSymbolicLink()) {\n packageRoots.push(path.resolve(nodeModulesRoot, entry.name, scopedEntry.name));\n }\n }\n continue;\n }\n packageRoots.push(path.resolve(nodeModulesRoot, entry.name));\n }\n return packageRoots;\n } catch {\n return [];\n }\n }\n\n private async readPackageJson(packageJsonPath: string): Promise<PackageJsonShape> {\n try {\n const rawPackageJson = await readFile(packageJsonPath, \"utf8\");\n return JSON.parse(rawPackageJson) as PackageJsonShape;\n } catch {\n return {};\n }\n }\n\n private async loadPlugin(discoveredPackage: CodemationDiscoveredPluginPackage): Promise<CodemationPlugin> {\n const pluginModulePath = path.resolve(discoveredPackage.packageRoot, this.resolvePluginEntry(discoveredPackage));\n const importedModule = (await import(\n /* webpackIgnore: true */ this.resolvePluginModuleSpecifier(pluginModulePath)\n )) as Record<string, unknown>;\n const exportedValue = importedModule.default;\n const plugin = this.resolvePluginValue(exportedValue);\n if (!plugin) {\n throw new Error(`Plugin package \"${discoveredPackage.packageName}\" did not default-export a Codemation plugin.`);\n }\n return this.pluginPackageMetadata.attachPackageName(plugin, discoveredPackage.packageName);\n }\n\n private resolvePluginValue(value: unknown): CodemationPlugin | null {\n if (this.isPluginConfig(value)) {\n return value;\n }\n return null;\n }\n\n private isPluginConfig(value: unknown): value is CodemationPlugin {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return false;\n }\n const pluginValue = value as {\n credentialTypes?: unknown;\n mcpServers?: unknown;\n register?: unknown;\n sandbox?: unknown;\n };\n if (pluginValue.register !== undefined && typeof pluginValue.register !== \"function\") {\n return false;\n }\n if (pluginValue.credentialTypes !== undefined && !Array.isArray(pluginValue.credentialTypes)) {\n return false;\n }\n if (pluginValue.mcpServers !== undefined && !Array.isArray(pluginValue.mcpServers)) {\n return false;\n }\n return (\n pluginValue.register !== undefined ||\n pluginValue.credentialTypes !== undefined ||\n pluginValue.mcpServers !== undefined ||\n pluginValue.sandbox !== undefined ||\n Object.keys(pluginValue).length === 0\n );\n }\n\n private resolvePluginEntry(discoveredPackage: CodemationDiscoveredPluginPackage): string {\n const preferSource =\n process.env.CODEMATION_PREFER_PLUGIN_SOURCE_ENTRY === \"true\" &&\n typeof discoveredPackage.developmentEntry === \"string\" &&\n discoveredPackage.developmentEntry.trim().length > 0;\n const selectedEntry = preferSource ? discoveredPackage.developmentEntry : discoveredPackage.pluginEntry;\n return selectedEntry;\n }\n\n private async resolveDevelopmentPluginEntry(packageRoot: string): Promise<string | undefined> {\n const candidates = [\n path.resolve(packageRoot, \"codemation.plugin.ts\"),\n path.resolve(packageRoot, \"codemation.plugin.js\"),\n path.resolve(packageRoot, \"src\", \"codemation.plugin.ts\"),\n path.resolve(packageRoot, \"src\", \"codemation.plugin.js\"),\n ];\n for (const candidate of candidates) {\n if (await this.exists(candidate)) {\n return path.relative(packageRoot, candidate);\n }\n }\n return undefined;\n }\n\n private async exists(filePath: string): Promise<boolean> {\n try {\n await readFile(filePath, \"utf8\");\n return true;\n } catch {\n return false;\n }\n }\n\n private resolvePluginModuleSpecifier(pluginModulePath: string): string {\n return pathToFileURL(pluginModulePath).href;\n }\n}\n"],"mappings":";;;;;;;;;;AAuBA,IAAa,0BAAb,MAAa,wBAAwB;CACnC,OAAwB,mCAAmB,IAAI,SAAgD;CAE/F,YACE,AAAiBA,QACjB,AAAiBC,cACjB,AAAiBC,cACjB,AAAiBC,kBAAyC,EAAE,EAC5D,AAAiBC,KACjB;EALiB;EACA;EACA;EACA;EACA;;CAGnB,MAAM,SAAS,SAAqC;AAClD,SAAO,OAAO,MAAM,KAAK,YAAY,EAAE,QAAQ,MAAM,QAAQ;;CAG/D,MAAM,UAAyB;AAC7B,QAAM,KAAK,YAAY;;CAGzB,MAAM,QAAuB;EAC3B,MAAM,gBAAgB,wBAAwB,iBAAiB,IAAI,KAAK,OAAiB;AACzF,MAAI,CAAC,cACH;AAEF,0BAAwB,iBAAiB,OAAO,KAAK,OAAiB;AACtE,SAAO,MAAM,eAAe,UAAU,QAAQ,sBAAsB,CAAC,MAAM;;CAG7E,MAAM,wBAAiE;EACrE,MAAM,UAAU,MAAM,KAAK,YAAY;AAEvC,UADkB,MAAM,QAAQ,SAAS,QAAQ,IAAI,2BAA2B,CAAC,EAChE,KAAK,aAAa,QAAQ,yBAAyB,UAAU,SAAS,CAAC;;CAG1F,MAAM,mBAAmB,YAA0C;EAC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UAAO;;;CAIX,AAAQ,6BAA6B,kBAAkC;AACrE,SAAO,cAAc,iBAAiB,CAAC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import "./ItemsInputNormalizer-
|
|
3
|
-
import "./CodemationAppContext-
|
|
1
|
+
import "./index-ChIfeWzk.js";
|
|
2
|
+
import "./ItemsInputNormalizer-CFkfNMLt.js";
|
|
3
|
+
import "./CodemationAppContext-K51b7oXe.js";
|
|
4
4
|
import "./CodemationWhitelabelConfig-Ca2mCUeC.js";
|
|
5
|
-
import { a as ApiPaths, i as CodemationFrontendAuthSnapshotJsonCodec, n as InternalAuthBootstrapJsonCodec, r as FrontendAppConfigJsonCodec, t as PublicFrontendBootstrapJsonCodec } from "./PublicFrontendBootstrapJsonCodec-
|
|
5
|
+
import { a as ApiPaths, i as CodemationFrontendAuthSnapshotJsonCodec, n as InternalAuthBootstrapJsonCodec, r as FrontendAppConfigJsonCodec, t as PublicFrontendBootstrapJsonCodec } from "./PublicFrontendBootstrapJsonCodec-HNItQ7ol.js";
|
|
6
6
|
import { n as InternalAuthBootstrap, r as FrontendAppConfig, t as PublicFrontendBootstrap } from "./PublicFrontendBootstrap-Cev3qK46.js";
|
|
7
|
-
import "./CodemationConfigNormalizer-
|
|
8
|
-
import { i as CodemationConsumerAppResolver, n as CodemationConsumerConfigResolution, r as CodemationConsumerApp, t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-
|
|
7
|
+
import "./CodemationConfigNormalizer-B4rDYC9h.js";
|
|
8
|
+
import { i as CodemationConsumerAppResolver, n as CodemationConsumerConfigResolution, r as CodemationConsumerApp, t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-Dt4jyLx6.js";
|
|
9
9
|
import "./WorkflowViewContracts-B7aFQcIw.js";
|
|
10
|
-
import {
|
|
11
|
-
import { a as ProcessRunOptions, i as CodemationFrontendAuthSnapshotFactory, n as InternalAuthBootstrapFactory, o as ProcessRunResult, r as FrontendAppConfigFactory, s as ProcessRunner, t as PublicFrontendBootstrapFactory } from "./PublicFrontendBootstrapFactory-
|
|
12
|
-
import {
|
|
13
|
-
import { a as CodemationResolvedPluginPackage, c as CodemationServerGateway, i as CodemationPluginDiscovery, l as ExecaProcessRunner, n as WorkflowModulePathFinder, o as AppConfigLoadResult, r as CodemationDiscoveredPluginPackage, s as AppConfigLoader, t as WorkflowDiscoveryPathSegmentsComputer } from "./server-
|
|
10
|
+
import { n as PrismaDatabaseClient } from "./AppConfigFactory-DncmwCD1.js";
|
|
11
|
+
import { a as ProcessRunOptions, i as CodemationFrontendAuthSnapshotFactory, n as InternalAuthBootstrapFactory, o as ProcessRunResult, r as FrontendAppConfigFactory, s as ProcessRunner, t as PublicFrontendBootstrapFactory } from "./PublicFrontendBootstrapFactory-ClEjZP74.js";
|
|
12
|
+
import { t as CodemationPostgresPrismaClientFactory } from "./CodemationPostgresPrismaClientFactory-CTNTPnDr.js";
|
|
13
|
+
import { a as CodemationResolvedPluginPackage, c as CodemationServerGateway, i as CodemationPluginDiscovery, l as ExecaProcessRunner, n as WorkflowModulePathFinder, o as AppConfigLoadResult, r as CodemationDiscoveredPluginPackage, s as AppConfigLoader, t as WorkflowDiscoveryPathSegmentsComputer } from "./server-B5trn7y4.js";
|
|
14
14
|
export { ApiPaths, AppConfigLoadResult, AppConfigLoader, CodemationConsumerApp, CodemationConsumerAppResolver, CodemationConsumerConfigLoader, CodemationConsumerConfigResolution, CodemationDiscoveredPluginPackage, CodemationFrontendAuthSnapshotFactory, CodemationFrontendAuthSnapshotJsonCodec, CodemationPluginDiscovery, CodemationPostgresPrismaClientFactory, CodemationResolvedPluginPackage, CodemationServerGateway, ExecaProcessRunner, FrontendAppConfig, FrontendAppConfigFactory, FrontendAppConfigJsonCodec, InternalAuthBootstrap, InternalAuthBootstrapFactory, InternalAuthBootstrapJsonCodec, PrismaDatabaseClient as PrismaClient, ProcessRunOptions, ProcessRunResult, ProcessRunner, PublicFrontendBootstrap, PublicFrontendBootstrapFactory, PublicFrontendBootstrapJsonCodec, WorkflowDiscoveryPathSegmentsComputer, WorkflowModulePathFinder };
|
package/dist/server.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import "./LogLevelPolicyFactory-DCUzIN6G.js";
|
|
2
|
-
import { t as ApiPaths } from "./ApiPaths-
|
|
2
|
+
import { t as ApiPaths } from "./ApiPaths-DCvrlIjg.js";
|
|
3
3
|
import { i as CodemationFrontendAuthSnapshotJsonCodec, n as InternalAuthBootstrapJsonCodec, r as FrontendAppConfigJsonCodec, t as PublicFrontendBootstrapJsonCodec } from "./PublicFrontendBootstrapJsonCodec-CegIF_ne.js";
|
|
4
|
-
import { i as CodemationConsumerAppResolver, n as WorkflowDiscoveryPathSegmentsComputer, r as WorkflowModulePathFinder, t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-
|
|
4
|
+
import { i as CodemationConsumerAppResolver, n as WorkflowDiscoveryPathSegmentsComputer, r as WorkflowModulePathFinder, t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-By-6tuGc.js";
|
|
5
5
|
import "./ServerLoggerFactory-Ckk52S3w.js";
|
|
6
6
|
import "./decorateParam-BWxkAUSj.js";
|
|
7
7
|
import "./decorate-CXWmflG_.js";
|
|
8
|
-
import "./CredentialServices-
|
|
8
|
+
import "./CredentialServices-Bios0dM8.js";
|
|
9
9
|
import "./CodemationTsyringeTypeInfoRegistrar-Bj6FJYFz.js";
|
|
10
|
-
import { D as FrontendAppConfigFactory, E as InternalAuthBootstrapFactory, O as CodemationFrontendAuthSnapshotFactory, T as PublicFrontendBootstrapFactory, g as ExecaProcessRunner } from "./AppContainerFactory-
|
|
11
|
-
import "./
|
|
12
|
-
import "./
|
|
13
|
-
import "./AppConfigFactory-
|
|
14
|
-
import { t as CodemationPostgresPrismaClientFactory } from "./
|
|
15
|
-
import { n as AppConfigLoader, r as CodemationServerGateway, t as CodemationPluginDiscovery } from "./server-
|
|
10
|
+
import { D as FrontendAppConfigFactory, E as InternalAuthBootstrapFactory, O as CodemationFrontendAuthSnapshotFactory, T as PublicFrontendBootstrapFactory, g as ExecaProcessRunner } from "./AppContainerFactory-jpYXGZGe.js";
|
|
11
|
+
import "./InternalPingRegistrar-BavAAnvk.js";
|
|
12
|
+
import "./WorkflowPolicyUiPresentationFactory-DfvD2VHk.js";
|
|
13
|
+
import "./AppConfigFactory-D4LL1aOR.js";
|
|
14
|
+
import { t as CodemationPostgresPrismaClientFactory } from "./CodemationPostgresPrismaClientFactory-C7156Fe-.js";
|
|
15
|
+
import { n as AppConfigLoader, r as CodemationServerGateway, t as CodemationPluginDiscovery } from "./server-BlG9qV5S.js";
|
|
16
16
|
|
|
17
17
|
export { ApiPaths, AppConfigLoader, CodemationConsumerAppResolver, CodemationConsumerConfigLoader, CodemationFrontendAuthSnapshotFactory, CodemationFrontendAuthSnapshotJsonCodec, CodemationPluginDiscovery, CodemationPostgresPrismaClientFactory, CodemationServerGateway, ExecaProcessRunner, FrontendAppConfigFactory, FrontendAppConfigJsonCodec, InternalAuthBootstrapFactory, InternalAuthBootstrapJsonCodec, PublicFrontendBootstrapFactory, PublicFrontendBootstrapJsonCodec, WorkflowDiscoveryPathSegmentsComputer, WorkflowModulePathFinder };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codemation/host",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -88,50 +88,39 @@
|
|
|
88
88
|
"@aws-sdk/lib-storage": "^3.1049.0",
|
|
89
89
|
"@better-auth/prisma-adapter": "^1.5.6",
|
|
90
90
|
"@libsql/client": "^0.17.2",
|
|
91
|
-
"@monaco-editor/react": "^4.7.0",
|
|
92
91
|
"@prisma/adapter-libsql": "^7.6.0",
|
|
93
92
|
"@prisma/adapter-pg": "^7.0.0",
|
|
94
93
|
"@prisma/client": "^7.0.0",
|
|
95
94
|
"@prisma/client-runtime-utils": "^7.5.0",
|
|
96
|
-
"@tanstack/react-query": "^5.90.21",
|
|
97
|
-
"@types/bcryptjs": "^3.0.0",
|
|
98
|
-
"@uiw/react-json-view": "2.0.0-alpha.41",
|
|
99
|
-
"@xyflow/react": "^12.10.1",
|
|
100
95
|
"ai": "^6.0.168",
|
|
96
|
+
"ajv": "^8.20.0",
|
|
101
97
|
"bcryptjs": "^3.0.3",
|
|
102
98
|
"better-auth": "^1.5.6",
|
|
103
99
|
"bullmq": "^5.58.3",
|
|
104
|
-
"
|
|
105
|
-
"date-fns": "^4.1.0",
|
|
100
|
+
"dotenv": "^17.3.1",
|
|
106
101
|
"execa": "^9.6.1",
|
|
107
102
|
"hono": "^4.12.8",
|
|
108
103
|
"jose": "^6.2.2",
|
|
109
|
-
"lucide-react": "^0.577.0",
|
|
110
|
-
"monaco-editor": "^0.55.1",
|
|
111
104
|
"pg": "^8.16.3",
|
|
112
|
-
"pretty-ms": "^9.3.0",
|
|
113
105
|
"prisma": "^7.0.0",
|
|
114
|
-
"rc-tree": "^5.13.1",
|
|
115
|
-
"react": "^19.2.4",
|
|
116
|
-
"react-dom": "^19.2.4",
|
|
117
|
-
"react-router-dom": "^7.13.1",
|
|
118
|
-
"react-use-websocket": "^4.13.0",
|
|
119
106
|
"reflect-metadata": "^0.2.2",
|
|
120
107
|
"sanitize-filename": "^1.6.4",
|
|
121
108
|
"serialize-javascript": "^7.0.4",
|
|
122
109
|
"tsx": "^4.21.0",
|
|
123
110
|
"ws": "^8.19.0",
|
|
124
|
-
"
|
|
125
|
-
"@codemation/core": "0.
|
|
126
|
-
"@codemation/
|
|
127
|
-
"@codemation/
|
|
128
|
-
"@codemation/core-nodes": "0.8.0"
|
|
111
|
+
"@codemation/core": "0.12.0",
|
|
112
|
+
"@codemation/core-nodes": "0.9.0",
|
|
113
|
+
"@codemation/eventbus-redis": "0.0.40",
|
|
114
|
+
"@codemation/managed-auth": "0.1.0"
|
|
129
115
|
},
|
|
130
116
|
"devDependencies": {
|
|
117
|
+
"@monaco-editor/react": "^4.7.0",
|
|
131
118
|
"@playwright/test": "^1.58.2",
|
|
119
|
+
"@tanstack/react-query": "^5.90.21",
|
|
132
120
|
"@tanstack/react-router": "^1.167.3",
|
|
133
121
|
"@testing-library/jest-dom": "^6.9.1",
|
|
134
122
|
"@testing-library/react": "^16.3.2",
|
|
123
|
+
"@types/bcryptjs": "^3.0.0",
|
|
135
124
|
"@types/dagre": "^0.7.54",
|
|
136
125
|
"@types/node": "^25.3.5",
|
|
137
126
|
"@types/pg": "^8.15.5",
|
|
@@ -140,23 +129,37 @@
|
|
|
140
129
|
"@types/serialize-javascript": "^5.0.4",
|
|
141
130
|
"@types/ws": "^8.18.1",
|
|
142
131
|
"@types/zxcvbn": "^4.4.5",
|
|
132
|
+
"@uiw/react-json-view": "2.0.0-alpha.41",
|
|
143
133
|
"@vitest/coverage-v8": "^4.0.18",
|
|
144
|
-
"
|
|
134
|
+
"@xyflow/react": "^12.10.1",
|
|
135
|
+
"dagre": "^0.8.5",
|
|
136
|
+
"date-fns": "^4.1.0",
|
|
145
137
|
"eslint": "^10.0.3",
|
|
138
|
+
"execa": "^9.6.1",
|
|
146
139
|
"jsdom": "^28.1.0",
|
|
140
|
+
"lucide-react": "^0.577.0",
|
|
141
|
+
"monaco-editor": "^0.55.1",
|
|
147
142
|
"monocart-coverage-reports": "^2.12.9",
|
|
148
143
|
"monocart-reporter": "^2.10.0",
|
|
144
|
+
"pretty-ms": "^9.3.0",
|
|
145
|
+
"rc-tree": "^5.13.1",
|
|
146
|
+
"react": "^19.2.4",
|
|
147
|
+
"react-dom": "^19.2.4",
|
|
148
|
+
"react-router-dom": "^7.13.1",
|
|
149
|
+
"react-use-websocket": "^4.13.0",
|
|
149
150
|
"testcontainers": "^10.28.0",
|
|
150
151
|
"tsdown": "^0.15.5",
|
|
151
152
|
"typescript": "^5.9.3",
|
|
152
153
|
"vitest": "^4.0.18",
|
|
153
|
-
"zod": "^4.3.6"
|
|
154
|
+
"zod": "^4.3.6",
|
|
155
|
+
"zxcvbn": "^4.4.2",
|
|
156
|
+
"@codemation/core-nodes-gmail": "0.3.2"
|
|
154
157
|
},
|
|
155
158
|
"scripts": {
|
|
156
159
|
"changeset:verify": "pnpm --workspace-root run changeset:verify",
|
|
157
160
|
"prisma:generate": "node ./scripts/generate-prisma-clients.mjs && node ./scripts/ensure-prisma-runtime-sourcemaps.mjs",
|
|
158
|
-
"build": "tsdown src/index.ts src/authoring.ts src/client.ts src/credentials.ts src/consumer.ts src/dto.ts src/mapping.ts src/nextServer.ts src/server.ts src/devServerSidecar.ts src/persistenceServer.ts src/pairing.ts --out-dir dist --sourcemap",
|
|
159
|
-
"dev": "tsdown src/index.ts src/authoring.ts src/client.ts src/credentials.ts src/consumer.ts src/dto.ts src/mapping.ts src/nextServer.ts src/server.ts src/devServerSidecar.ts src/persistenceServer.ts src/pairing.ts --out-dir dist --sourcemap --watch",
|
|
161
|
+
"build": "tsdown src/index.ts src/authoring.ts src/client.ts src/credentials.ts src/consumer.ts src/dto.ts src/mapping.ts src/nextServer.ts src/server.ts src/devServerSidecar.ts src/persistenceServer.ts src/pairing.ts src/infrastructure/persistence/PrismaMigrationOperations.ts --out-dir dist --sourcemap",
|
|
162
|
+
"dev": "tsdown src/index.ts src/authoring.ts src/client.ts src/credentials.ts src/consumer.ts src/dto.ts src/mapping.ts src/nextServer.ts src/server.ts src/devServerSidecar.ts src/persistenceServer.ts src/pairing.ts src/infrastructure/persistence/PrismaMigrationOperations.ts --out-dir dist --sourcemap --watch",
|
|
160
163
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
161
164
|
"lint": "eslint .",
|
|
162
165
|
"test": "pnpm -w exec concurrently -m 5 -c auto -n unit,integration,ui,browser,e2e \"pnpm run test:unit\" \"pnpm run test:integration\" \"pnpm run test:ui\" \"pnpm run test:browser\" \"pnpm run test:e2e\"",
|
package/playwright.config.ts
CHANGED
|
@@ -55,12 +55,18 @@ export default defineConfig({
|
|
|
55
55
|
/** Align with app URL and AUTH_URL so Auth.js cookies are not split across localhost vs 127.0.0.1. */
|
|
56
56
|
baseURL: baseUrl,
|
|
57
57
|
trace: "retain-on-failure",
|
|
58
|
-
|
|
58
|
+
// Video is disabled: it requires Playwright's ffmpeg binary, and every
|
|
59
|
+
// cdn.playwright.dev download hangs on CI (delivers bytes then never closes the
|
|
60
|
+
// stream). trace + screenshot already cover on-failure debugging without ffmpeg.
|
|
61
|
+
video: "off",
|
|
59
62
|
},
|
|
60
63
|
projects: [
|
|
61
64
|
{
|
|
62
65
|
name: "chromium",
|
|
63
|
-
|
|
66
|
+
// Use the runner's preinstalled Google Chrome (channel) instead of Playwright's
|
|
67
|
+
// bundled chromium: cdn.playwright.dev deterministically hangs after the binary
|
|
68
|
+
// download on CI, and the system Chrome is the same engine/version.
|
|
69
|
+
use: { ...devices["Desktop Chrome"], channel: "chrome" },
|
|
64
70
|
},
|
|
65
71
|
],
|
|
66
72
|
webServer: {
|
|
@@ -34,13 +34,19 @@ export default defineConfig({
|
|
|
34
34
|
],
|
|
35
35
|
use: {
|
|
36
36
|
trace: "retain-on-failure",
|
|
37
|
-
|
|
37
|
+
// Video is disabled: it requires Playwright's ffmpeg binary, and every
|
|
38
|
+
// cdn.playwright.dev download hangs on CI (delivers bytes then never closes the
|
|
39
|
+
// stream). trace + screenshot already cover on-failure debugging without ffmpeg.
|
|
40
|
+
video: "off",
|
|
38
41
|
screenshot: "only-on-failure",
|
|
39
42
|
},
|
|
40
43
|
projects: [
|
|
41
44
|
{
|
|
42
45
|
name: "chromium",
|
|
43
|
-
|
|
46
|
+
// Use the runner's preinstalled Google Chrome (channel) instead of Playwright's
|
|
47
|
+
// bundled chromium: cdn.playwright.dev deterministically hangs after the binary
|
|
48
|
+
// download on CI, and the system Chrome is the same engine/version.
|
|
49
|
+
use: { ...devices["Desktop Chrome"], channel: "chrome" },
|
|
44
50
|
},
|
|
45
51
|
],
|
|
46
52
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
-- Migration: Credential material provider seam (credentials-vault sprint, story 01).
|
|
2
|
+
-- Adds the {material_source, material_ref} pointer on CredentialInstance.
|
|
3
|
+
-- See docs/design/credentials-oauth-unification.md "Material provider seam".
|
|
4
|
+
--
|
|
5
|
+
-- All existing rows are local-mode workspace rows; backfill the pointer to
|
|
6
|
+
-- {source: "local", ref: instance_id} so the bytes still resolve via the
|
|
7
|
+
-- existing PrismaCredentialStore tables (CredentialOAuth2Material /
|
|
8
|
+
-- CredentialSecretMaterial).
|
|
9
|
+
|
|
10
|
+
ALTER TABLE "CredentialInstance"
|
|
11
|
+
ADD COLUMN "material_source" TEXT NOT NULL DEFAULT 'local';
|
|
12
|
+
|
|
13
|
+
ALTER TABLE "CredentialInstance"
|
|
14
|
+
ADD COLUMN "material_ref" TEXT NOT NULL DEFAULT '';
|
|
15
|
+
|
|
16
|
+
UPDATE "CredentialInstance"
|
|
17
|
+
SET "material_ref" = "instance_id"
|
|
18
|
+
WHERE "material_ref" = '';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
-- Create HumanTask table for HITL story 02: durable task record + signed resume token.
|
|
2
|
+
-- Indexed for efficient "pending tasks for workspace/workflow" queries (story 06, 09).
|
|
3
|
+
|
|
4
|
+
CREATE TABLE "human_task" (
|
|
5
|
+
"id" TEXT NOT NULL,
|
|
6
|
+
"run_id" TEXT NOT NULL,
|
|
7
|
+
"workflow_id" TEXT NOT NULL,
|
|
8
|
+
"workspace_id" TEXT,
|
|
9
|
+
"node_id" TEXT NOT NULL,
|
|
10
|
+
"activation_id" TEXT NOT NULL,
|
|
11
|
+
"item_index" INTEGER NOT NULL,
|
|
12
|
+
"status" TEXT NOT NULL,
|
|
13
|
+
"channel" TEXT NOT NULL,
|
|
14
|
+
"subject_json" TEXT NOT NULL,
|
|
15
|
+
"metadata_json" TEXT NOT NULL,
|
|
16
|
+
"decision_schema_json" TEXT NOT NULL,
|
|
17
|
+
"decision_schema_hash" TEXT NOT NULL,
|
|
18
|
+
"on_timeout" TEXT NOT NULL,
|
|
19
|
+
"delivery_ref_json" TEXT,
|
|
20
|
+
"decision_json" TEXT,
|
|
21
|
+
"decided_at" TIMESTAMP(3),
|
|
22
|
+
"decided_by_json" TEXT,
|
|
23
|
+
"resume_token_hash" TEXT NOT NULL,
|
|
24
|
+
"expires_at" TIMESTAMP(3) NOT NULL,
|
|
25
|
+
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
26
|
+
|
|
27
|
+
CONSTRAINT "human_task_pkey" PRIMARY KEY ("id")
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
CREATE INDEX "human_task_run_id_idx" ON "human_task"("run_id");
|
|
31
|
+
CREATE INDEX "human_task_workflow_id_status_idx" ON "human_task"("workflow_id", "status");
|
|
32
|
+
CREATE INDEX "human_task_workspace_id_status_expires_at_idx" ON "human_task"("workspace_id", "status", "expires_at");
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
-- Add dedicated hitl_state_json column to Run table.
|
|
2
|
+
-- Replaces the interim _hitl* key stash inside mutable_state_json (commit 63a6cfb3).
|
|
3
|
+
-- Old rows with _hitl* keys inside mutable_state_json are still handled by the
|
|
4
|
+
-- repository's legacy-fallback load path until re-saved with the new column.
|
|
5
|
+
|
|
6
|
+
ALTER TABLE "Run" ADD COLUMN "hitl_state_json" TEXT;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-- Migration: Durable HMAC nonce store for replay protection (T6 security fix).
|
|
2
|
+
-- Replaces the in-memory Map in IncomingHmacVerifier with a Prisma-backed store
|
|
3
|
+
-- so replay protection survives process restarts within the 300-second window.
|
|
4
|
+
|
|
5
|
+
CREATE TABLE "hmac_nonce" (
|
|
6
|
+
"nonce" TEXT NOT NULL,
|
|
7
|
+
"expires_at" TIMESTAMP(3) NOT NULL,
|
|
8
|
+
|
|
9
|
+
CONSTRAINT "hmac_nonce_pkey" PRIMARY KEY ("nonce")
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
CREATE INDEX "hmac_nonce_expires_at_idx" ON "hmac_nonce"("expires_at");
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
-- Migration: Credential material provider seam (credentials-vault sprint, story 01) - SQLite variant.
|
|
2
|
+
-- Adds the {material_source, material_ref} pointer on CredentialInstance.
|
|
3
|
+
-- See docs/design/credentials-oauth-unification.md "Material provider seam".
|
|
4
|
+
|
|
5
|
+
ALTER TABLE "CredentialInstance"
|
|
6
|
+
ADD COLUMN "material_source" TEXT NOT NULL DEFAULT 'local';
|
|
7
|
+
|
|
8
|
+
ALTER TABLE "CredentialInstance"
|
|
9
|
+
ADD COLUMN "material_ref" TEXT NOT NULL DEFAULT '';
|
|
10
|
+
|
|
11
|
+
UPDATE "CredentialInstance"
|
|
12
|
+
SET "material_ref" = "instance_id"
|
|
13
|
+
WHERE "material_ref" = '';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
-- Create HumanTask table for HITL story 02 (SQLite variant).
|
|
2
|
+
-- Mirrors the PostgreSQL migration but uses TEXT for timestamp columns (SQLite has no native TIMESTAMP type).
|
|
3
|
+
|
|
4
|
+
CREATE TABLE "human_task" (
|
|
5
|
+
"id" TEXT NOT NULL PRIMARY KEY,
|
|
6
|
+
"run_id" TEXT NOT NULL,
|
|
7
|
+
"workflow_id" TEXT NOT NULL,
|
|
8
|
+
"workspace_id" TEXT,
|
|
9
|
+
"node_id" TEXT NOT NULL,
|
|
10
|
+
"activation_id" TEXT NOT NULL,
|
|
11
|
+
"item_index" INTEGER NOT NULL,
|
|
12
|
+
"status" TEXT NOT NULL,
|
|
13
|
+
"channel" TEXT NOT NULL,
|
|
14
|
+
"subject_json" TEXT NOT NULL,
|
|
15
|
+
"metadata_json" TEXT NOT NULL,
|
|
16
|
+
"decision_schema_json" TEXT NOT NULL,
|
|
17
|
+
"decision_schema_hash" TEXT NOT NULL,
|
|
18
|
+
"on_timeout" TEXT NOT NULL,
|
|
19
|
+
"delivery_ref_json" TEXT,
|
|
20
|
+
"decision_json" TEXT,
|
|
21
|
+
"decided_at" DATETIME,
|
|
22
|
+
"decided_by_json" TEXT,
|
|
23
|
+
"resume_token_hash" TEXT NOT NULL,
|
|
24
|
+
"expires_at" DATETIME NOT NULL,
|
|
25
|
+
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
CREATE INDEX "human_task_run_id_idx" ON "human_task"("run_id");
|
|
29
|
+
CREATE INDEX "human_task_workflow_id_status_idx" ON "human_task"("workflow_id", "status");
|
|
30
|
+
CREATE INDEX "human_task_workspace_id_status_expires_at_idx" ON "human_task"("workspace_id", "status", "expires_at");
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
-- Add dedicated hitl_state_json column to Run table (SQLite variant).
|
|
2
|
+
-- Replaces the interim _hitl* key stash inside mutable_state_json (commit 63a6cfb3).
|
|
3
|
+
-- Old rows with _hitl* keys inside mutable_state_json are still handled by the
|
|
4
|
+
-- repository's legacy-fallback load path until re-saved with the new column.
|
|
5
|
+
|
|
6
|
+
ALTER TABLE "Run" ADD COLUMN "hitl_state_json" TEXT;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- Migration: Durable HMAC nonce store for replay protection (T6 security fix, SQLite variant).
|
|
2
|
+
-- Mirrors the PostgreSQL migration but uses TEXT for the timestamp column (SQLite has no native TIMESTAMP type).
|
|
3
|
+
|
|
4
|
+
CREATE TABLE "hmac_nonce" (
|
|
5
|
+
"nonce" TEXT NOT NULL PRIMARY KEY,
|
|
6
|
+
"expires_at" DATETIME NOT NULL
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
CREATE INDEX "hmac_nonce_expires_at_idx" ON "hmac_nonce"("expires_at");
|
|
@@ -22,6 +22,7 @@ model Run {
|
|
|
22
22
|
policySnapshotJson String? @map("policy_snapshot_json")
|
|
23
23
|
engineCountersJson String? @map("engine_counters_json")
|
|
24
24
|
mutableStateJson String? @map("mutable_state_json")
|
|
25
|
+
hitlStateJson String? @map("hitl_state_json")
|
|
25
26
|
outputsByNodeJson String @map("outputs_by_node_json")
|
|
26
27
|
updatedAt String @map("updated_at")
|
|
27
28
|
testSuiteRunId String? @map("test_suite_run_id")
|
|
@@ -344,6 +345,10 @@ model CredentialInstance {
|
|
|
344
345
|
setupStatus String @map("setup_status")
|
|
345
346
|
createdAt String @map("created_at")
|
|
346
347
|
updatedAt String @map("updated_at")
|
|
348
|
+
// Material provider seam — see docs/design/credentials-oauth-unification.md.
|
|
349
|
+
// Pointer to where the bytes live (workspace DB vs control plane).
|
|
350
|
+
materialSource String @default("local") @map("material_source")
|
|
351
|
+
materialRef String @default("") @map("material_ref")
|
|
347
352
|
}
|
|
348
353
|
|
|
349
354
|
model CredentialSecretMaterial {
|
|
@@ -507,3 +512,46 @@ model WorkflowAuditLog {
|
|
|
507
512
|
@@index([workflowId, occurredAt])
|
|
508
513
|
@@map("workflow_audit_log")
|
|
509
514
|
}
|
|
515
|
+
|
|
516
|
+
/// HMAC nonce store for replay protection (T6 security fix).
|
|
517
|
+
/// Nonces are persisted across process restarts so a replayed request within
|
|
518
|
+
/// the 300-second timestamp window is rejected even after a restart.
|
|
519
|
+
model HmacNonce {
|
|
520
|
+
nonce String @id @map("nonce")
|
|
521
|
+
expiresAt DateTime @map("expires_at")
|
|
522
|
+
|
|
523
|
+
@@index([expiresAt])
|
|
524
|
+
@@map("hmac_nonce")
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
model HumanTask {
|
|
528
|
+
id String @id @map("id")
|
|
529
|
+
runId String @map("run_id")
|
|
530
|
+
workflowId String @map("workflow_id")
|
|
531
|
+
workspaceId String? @map("workspace_id")
|
|
532
|
+
nodeId String @map("node_id")
|
|
533
|
+
activationId String @map("activation_id")
|
|
534
|
+
itemIndex Int @map("item_index")
|
|
535
|
+
/// pending | decided | timed_out | auto_accepted | cancelled
|
|
536
|
+
status String @map("status")
|
|
537
|
+
/// local | control-plane-inbox
|
|
538
|
+
channel String @map("channel")
|
|
539
|
+
subjectJson String @map("subject_json")
|
|
540
|
+
metadataJson String @map("metadata_json")
|
|
541
|
+
decisionSchemaJson String @map("decision_schema_json")
|
|
542
|
+
decisionSchemaHash String @map("decision_schema_hash")
|
|
543
|
+
/// halt | auto-accept
|
|
544
|
+
onTimeout String @map("on_timeout")
|
|
545
|
+
deliveryRefJson String? @map("delivery_ref_json")
|
|
546
|
+
decisionJson String? @map("decision_json")
|
|
547
|
+
decidedAt DateTime? @map("decided_at")
|
|
548
|
+
decidedByJson String? @map("decided_by_json")
|
|
549
|
+
resumeTokenHash String @map("resume_token_hash")
|
|
550
|
+
expiresAt DateTime @map("expires_at")
|
|
551
|
+
createdAt DateTime @default(now()) @map("created_at")
|
|
552
|
+
|
|
553
|
+
@@index([runId])
|
|
554
|
+
@@index([workflowId, status])
|
|
555
|
+
@@index([workspaceId, status, expiresAt])
|
|
556
|
+
@@map("human_task")
|
|
557
|
+
}
|