@codemation/host 0.6.0 → 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 +431 -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-C6q-CSKb.js → AppConfigFactory-Cx4qQvRk.js} +112 -52
- package/dist/AppConfigFactory-Cx4qQvRk.js.map +1 -0
- package/dist/{AppConfigFactory-YnveXE9k.d.ts → AppConfigFactory-DnLoQ9Li.d.ts} +8490 -5548
- package/dist/{AppContainerFactory-qaqc-R1D.js → AppContainerFactory-DqKYCRNP.js} +7641 -2083
- package/dist/AppContainerFactory-DqKYCRNP.js.map +1 -0
- package/dist/{CodemationAppContext-DRu1Dpri.d.ts → CodemationAppContext-CKVv9W9q.d.ts} +8 -4
- package/dist/{CodemationAuthoring.types-fBRppnmi.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-DVko3cVN.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-DJWr86f-.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-DGc-jfa2.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-DrMIDSw8.d.ts → CredentialContractsRegistry-Bq2bq28t.d.ts} +2 -2
- package/dist/{CredentialServices-UfvHB-rN.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-C-KHg9Mo.d.ts → ItemsInputNormalizer-_RwIfRIQ.d.ts} +89 -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-DbaNomrH.d.ts → TelemetryContracts-BtDx84Cp.d.ts} +13 -4
- package/dist/{WorkflowPolicyUiPresentationFactory-DQEY-h_S.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-CzK2KFuz.d.ts → WorkflowViewContracts-B7aFQcIw.d.ts} +10 -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-BbBk26m0.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-CmsIKnO9.js → persistenceServer-C-hH4z6l.js} +2 -2
- package/dist/{persistenceServer-CmsIKnO9.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-MUNGsBYK.d.ts → server-C4bS62rg.d.ts} +21 -6
- package/dist/{server-CJFfY67o.js → server-Y7kxwtCK.js} +7 -6
- package/dist/{server-CJFfY67o.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/20260519000000_workflow_audit_log/migration.sql +23 -0
- package/prisma/migrations/20260519100000_storage_growth_fixes/migration.sql +61 -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 +55 -17
- package/prisma/schema.sqlite.prisma +55 -17
- package/prisma-generated/prisma-postgresql-client/edge.js +33 -5
- package/prisma-generated/prisma-postgresql-client/index-browser.js +29 -1
- package/prisma-generated/prisma-postgresql-client/index.d.ts +8933 -5716
- package/prisma-generated/prisma-postgresql-client/index.js +33 -5
- package/prisma-generated/prisma-postgresql-client/package.json +1 -1
- package/prisma-generated/prisma-postgresql-client/schema.prisma +38 -0
- package/prisma-generated/prisma-sqlite-client/edge.js +33 -5
- package/prisma-generated/prisma-sqlite-client/index-browser.js +29 -1
- package/prisma-generated/prisma-sqlite-client/index.d.ts +8925 -5713
- package/prisma-generated/prisma-sqlite-client/index.js +33 -5
- package/prisma-generated/prisma-sqlite-client/package.json +1 -1
- package/prisma-generated/prisma-sqlite-client/schema.prisma +38 -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 +6 -0
- package/src/application/contracts/WorkflowWebsocketMessage.ts +3 -1
- package/src/application/mapping/WorkflowDefinitionMapper.ts +40 -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/PrismaMigrationDeployer.ts +21 -13
- package/src/infrastructure/persistence/PrismaTelemetryArtifactStore.ts +43 -8
- package/src/infrastructure/persistence/PrismaWorkflowRunRepository.ts +26 -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-C6q-CSKb.js.map +0 -1
- package/dist/AppContainerFactory-qaqc-R1D.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-Cb2pLmDd.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-vtJAGDat.d.ts +0 -9
- package/src/domain/credentials/OAuth2ConnectServiceFactory.ts +0 -411
|
@@ -262,6 +262,11 @@ interface PersistedWorkflowSnapshotNode {
|
|
|
262
262
|
tokenName?: string;
|
|
263
263
|
configTokenName?: string;
|
|
264
264
|
config: unknown;
|
|
265
|
+
/** Pre-computed static configuration summary; populated by WorkflowSnapshotCodec. */
|
|
266
|
+
inspectorSummary?: ReadonlyArray<Readonly<{
|
|
267
|
+
label: string;
|
|
268
|
+
value: string;
|
|
269
|
+
}>>;
|
|
265
270
|
}
|
|
266
271
|
interface PersistedWorkflowSnapshot {
|
|
267
272
|
id: WorkflowId;
|
|
@@ -340,6 +345,10 @@ interface ConnectionInvocationRecord {
|
|
|
340
345
|
readonly status: NodeExecutionStatus;
|
|
341
346
|
readonly managedInput?: JsonValue;
|
|
342
347
|
readonly managedOutput?: JsonValue;
|
|
348
|
+
/** Short human-readable description of what this invocation is doing right now (e.g. `"calling search_messages"`). Rendered as a sub-line on the canvas node card. */
|
|
349
|
+
readonly statusLabel?: string;
|
|
350
|
+
/** Stable identifier for the thing this invocation acts on (e.g. an MCP tool name like `"search_messages"`). Persists across status transitions so the inspector can show it on completed/failed entries too. Connection nodes that ARE the tool (e.g. node-backed agent tools) leave this unset — the parent node id already identifies the subject. */
|
|
351
|
+
readonly subjectName?: string;
|
|
343
352
|
readonly error?: NodeExecutionError;
|
|
344
353
|
readonly queuedAt?: string;
|
|
345
354
|
readonly startedAt?: string;
|
|
@@ -361,6 +370,8 @@ type ConnectionInvocationAppendArgs = Readonly<{
|
|
|
361
370
|
status: NodeExecutionStatus;
|
|
362
371
|
managedInput?: JsonValue;
|
|
363
372
|
managedOutput?: JsonValue;
|
|
373
|
+
statusLabel?: string;
|
|
374
|
+
subjectName?: string;
|
|
364
375
|
error?: NodeExecutionError;
|
|
365
376
|
queuedAt?: string;
|
|
366
377
|
startedAt?: string;
|
|
@@ -619,6 +630,26 @@ interface NodeConfigBase {
|
|
|
619
630
|
* configs (e.g. `AssertionNodeConfig`, `StringEqualsAssertionNodeConfig`).
|
|
620
631
|
*/
|
|
621
632
|
readonly emitsAssertions?: true;
|
|
633
|
+
/**
|
|
634
|
+
* Static configuration summary surfaced in the workflow inspector — the design-time
|
|
635
|
+
* "what does this node do" panel that renders before any run telemetry exists.
|
|
636
|
+
*
|
|
637
|
+
* Return 2–6 short label/value pairs derived from this config (method + url for an HTTP
|
|
638
|
+
* call, model + tool list for an agent, schedule + timezone for a cron trigger, etc.).
|
|
639
|
+
* Values are truncated by the UI; aim for one line each. Return `undefined` to opt out
|
|
640
|
+
* — the inspector hides the section when no rows are produced.
|
|
641
|
+
*
|
|
642
|
+
* Implement on the config class instance so the function can read sibling config fields.
|
|
643
|
+
* `defineNode({ inspectorSummary })` plumbs through to this.
|
|
644
|
+
*/
|
|
645
|
+
inspectorSummary?(): ReadonlyArray<NodeInspectorSummaryRow> | undefined;
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* One row of a node's static configuration summary. See {@link NodeConfigBase.inspectorSummary}.
|
|
649
|
+
*/
|
|
650
|
+
interface NodeInspectorSummaryRow {
|
|
651
|
+
readonly label: string;
|
|
652
|
+
readonly value: string;
|
|
622
653
|
}
|
|
623
654
|
declare const runnableNodeInputType: unique symbol;
|
|
624
655
|
declare const runnableNodeOutputType: unique symbol;
|
|
@@ -796,6 +827,29 @@ type NodeErrorHandlerSpec = TypeToken<NodeErrorHandler> | NodeErrorHandler;
|
|
|
796
827
|
*/
|
|
797
828
|
type TestSuiteRunId = string;
|
|
798
829
|
//#endregion
|
|
830
|
+
//#region ../core/src/contracts/CostTrackingTelemetryContract.d.ts
|
|
831
|
+
type CostTrackingComponent = "chat" | "ocr" | "rag";
|
|
832
|
+
interface CostTrackingUsageRecord {
|
|
833
|
+
readonly component: CostTrackingComponent;
|
|
834
|
+
readonly provider: string;
|
|
835
|
+
readonly operation: string;
|
|
836
|
+
readonly pricingKey: string;
|
|
837
|
+
readonly usageUnit: string;
|
|
838
|
+
readonly quantity: number;
|
|
839
|
+
readonly modelName?: string;
|
|
840
|
+
readonly attributes?: TelemetryAttributes;
|
|
841
|
+
}
|
|
842
|
+
interface CostTrackingPriceQuote {
|
|
843
|
+
readonly currency: string;
|
|
844
|
+
readonly currencyScale: number;
|
|
845
|
+
readonly estimatedAmountMinor: number;
|
|
846
|
+
readonly estimateKind: "catalog";
|
|
847
|
+
}
|
|
848
|
+
interface CostTrackingTelemetry {
|
|
849
|
+
captureUsage(args: CostTrackingUsageRecord): Promise<CostTrackingPriceQuote | undefined>;
|
|
850
|
+
forScope(scope: TelemetryScope): CostTrackingTelemetry;
|
|
851
|
+
}
|
|
852
|
+
//#endregion
|
|
799
853
|
//#region ../core/src/contracts/telemetryTypes.d.ts
|
|
800
854
|
type TelemetryAttributePrimitive = string | number | boolean | null;
|
|
801
855
|
interface TelemetryAttributes {
|
|
@@ -876,29 +930,6 @@ interface ExecutionTelemetry extends TelemetryScope {
|
|
|
876
930
|
}>): NodeExecutionTelemetry;
|
|
877
931
|
}
|
|
878
932
|
//#endregion
|
|
879
|
-
//#region ../core/src/contracts/CostTrackingTelemetryContract.d.ts
|
|
880
|
-
type CostTrackingComponent = "chat" | "ocr" | "rag";
|
|
881
|
-
interface CostTrackingUsageRecord {
|
|
882
|
-
readonly component: CostTrackingComponent;
|
|
883
|
-
readonly provider: string;
|
|
884
|
-
readonly operation: string;
|
|
885
|
-
readonly pricingKey: string;
|
|
886
|
-
readonly usageUnit: string;
|
|
887
|
-
readonly quantity: number;
|
|
888
|
-
readonly modelName?: string;
|
|
889
|
-
readonly attributes?: TelemetryAttributes;
|
|
890
|
-
}
|
|
891
|
-
interface CostTrackingPriceQuote {
|
|
892
|
-
readonly currency: string;
|
|
893
|
-
readonly currencyScale: number;
|
|
894
|
-
readonly estimatedAmountMinor: number;
|
|
895
|
-
readonly estimateKind: "catalog";
|
|
896
|
-
}
|
|
897
|
-
interface CostTrackingTelemetry {
|
|
898
|
-
captureUsage(args: CostTrackingUsageRecord): Promise<CostTrackingPriceQuote | undefined>;
|
|
899
|
-
forScope(scope: TelemetryScope): CostTrackingTelemetry;
|
|
900
|
-
}
|
|
901
|
-
//#endregion
|
|
902
933
|
//#region ../core/src/contracts/executionPersistenceContracts.d.ts
|
|
903
934
|
/** Canonical id for persisted execution rows (activation or connection invocation). */
|
|
904
935
|
type ExecutionInstanceId = string;
|
|
@@ -1016,6 +1047,35 @@ interface WebhookTriggerMatcher {
|
|
|
1016
1047
|
reloadWebhookRoutes?(): void;
|
|
1017
1048
|
}
|
|
1018
1049
|
//#endregion
|
|
1050
|
+
//#region ../core/src/contracts/mcpTypes.d.ts
|
|
1051
|
+
type McpServerTransport = "http";
|
|
1052
|
+
interface McpServerDeclaration {
|
|
1053
|
+
/** Globally unique slug, e.g. "gmail". Workflow authors reference this. */
|
|
1054
|
+
id: string;
|
|
1055
|
+
displayName: string;
|
|
1056
|
+
description: string;
|
|
1057
|
+
transport: McpServerTransport;
|
|
1058
|
+
url: string;
|
|
1059
|
+
/**
|
|
1060
|
+
* Credential types accepted by this MCP server, matching CredentialRequirement.acceptedTypes.
|
|
1061
|
+
* Absent or empty means no credential is required.
|
|
1062
|
+
*/
|
|
1063
|
+
acceptedCredentialTypes?: ReadonlyArray<string>;
|
|
1064
|
+
/**
|
|
1065
|
+
* Documentation only in MVP. The bind-time validator checks
|
|
1066
|
+
* requiredScopes ⊆ CredentialInstance.scopesGranted.
|
|
1067
|
+
*/
|
|
1068
|
+
requiredScopes?: string[];
|
|
1069
|
+
/** Non-secret static headers merged onto every MCP request. */
|
|
1070
|
+
staticHeaders?: Record<string, string>;
|
|
1071
|
+
/**
|
|
1072
|
+
* Overrides for tool descriptions advertised by the MCP server.
|
|
1073
|
+
* Applied by the connection pool after tools/list.
|
|
1074
|
+
* Key: exact tool name as returned by the server.
|
|
1075
|
+
*/
|
|
1076
|
+
toolDescriptionOverrides?: Record<string, string>;
|
|
1077
|
+
}
|
|
1078
|
+
//#endregion
|
|
1019
1079
|
//#region ../core/src/contracts/collectionTypes.d.ts
|
|
1020
1080
|
/**
|
|
1021
1081
|
* Represents a typed store for a single collection.
|
|
@@ -1347,6 +1407,10 @@ interface BinaryStorage {
|
|
|
1347
1407
|
openReadStream(storageKey: string): Promise<BinaryStorageReadResult | undefined>;
|
|
1348
1408
|
stat(storageKey: string): Promise<BinaryStorageStatResult>;
|
|
1349
1409
|
delete(storageKey: string): Promise<void>;
|
|
1410
|
+
/** Deletes multiple objects in bulk. Keys are batched internally. */
|
|
1411
|
+
deleteMany(storageKeys: ReadonlyArray<string>): Promise<void>;
|
|
1412
|
+
/** Lists all keys sharing a common prefix. Returns keys in arbitrary order. */
|
|
1413
|
+
listByPrefix(prefix: string): Promise<ReadonlyArray<string>>;
|
|
1350
1414
|
}
|
|
1351
1415
|
interface BinaryAttachmentCreateRequest {
|
|
1352
1416
|
name: string;
|
|
@@ -1569,5 +1633,5 @@ interface ChatModelFactory<TConfig extends ChatModelConfig = ChatModelConfig> {
|
|
|
1569
1633
|
}>): Promise<ChatLanguageModel> | ChatLanguageModel;
|
|
1570
1634
|
}
|
|
1571
1635
|
//#endregion
|
|
1572
|
-
export {
|
|
1573
|
-
//# sourceMappingURL=ItemsInputNormalizer-
|
|
1636
|
+
export { PersistedRunState as $, WorkflowRunDetailDto as A, NodeActivationId as B, AnyRunnableNodeConfig as C, CredentialSetupStatus as Ct, WebhookInvocationMatch as D, CredentialTypeRegistry as Dt, HttpMethod as E, CredentialTypeId as Et, ActivationIdFactory as F, PersistedRunPolicySnapshot as G, NodeInspectorSummaryRow as H, BinaryAttachment as I, RunnableNodeConfig as J, RunId as K, Item as L, TelemetryAttributes as M, TelemetryMetricRecord as N, WebhookTriggerMatcher as O, NodeId as Ot, TelemetrySpanEventRecord as P, NodeInputsByPort as Q, Items as R, ChainCursor as S, CredentialSessionService as St, McpServerDeclaration as T, CredentialTypeDefinition as Tt, NodeOutputs as U, NodeDefinition as V, ParentExecutionRef as W, WorkflowDefinition as X, RunnableNodeOutputJson as Y, CurrentStateExecutionRequest as Z, EngineExecutionLimitsPolicyConfig as _, CredentialJsonRecord as _t, ParamDeep as a, RunStatus as at, TestCaseRunStatus as b, CredentialRequirement as bt, NodeActivationContinuation as c, WebhookRunResult as ct, NodeExecutionRequestHandler as d, CredentialBinding as dt, PersistedWorkflowTokenRegistryLike as et, NodeExecutionScheduler as f, CredentialBindingKey as ft, TypeToken as g, CredentialInstanceRecord as gt, Container as h, CredentialInstanceId as ht, ToolConfig as i, RunResult as it, TelemetryArtifactAttachment as j, WebhookTriggerResolution as k, WorkflowId as kt, NodeExecutionContext as l, WorkflowExecutionRepository as lt, WorkflowSnapshotResolver as m, CredentialHealth as mt, AgentMessageConfig as n, RunExecutionOptions as nt, BinaryStorage as o, RunStopCondition as ot, WorkflowRepository as p, CredentialFieldSchema as pt, RunIdFactory as q, ChatModelConfig as r, RunPruneCandidate as rt, LiveWorkflowRepository as s, RunSummary as st, AgentGuardrailConfig as t, RunCurrentState as tt, NodeExecutionRequest as u, AnyCredentialType as ut, RunEvent as v, CredentialMaterialSourceKind as vt, WorkflowActivationPolicy as w, CredentialType as wt, TestSuiteRunStatus as x, CredentialSessionFactoryArgs as xt, RunEventBus as y, CredentialOAuth2AuthDefinition as yt, JsonValue as z };
|
|
1637
|
+
//# sourceMappingURL=ItemsInputNormalizer-_RwIfRIQ.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as CodemationLogConfig } from "./CodemationWhitelabelConfig-
|
|
1
|
+
import { n as CodemationLogConfig } from "./CodemationWhitelabelConfig-Ca2mCUeC.js";
|
|
2
2
|
|
|
3
3
|
//#region src/infrastructure/logging/LogLevelPolicy.d.ts
|
|
4
4
|
type LogLevel = "silent" | "debug" | "info" | "warn" | "error";
|
|
@@ -46,4 +46,4 @@ declare class LogLevelPolicyFactory {
|
|
|
46
46
|
declare const logLevelPolicyFactory: LogLevelPolicyFactory;
|
|
47
47
|
//#endregion
|
|
48
48
|
export { LogLevelPolicy as i, logLevelPolicyFactory as n, LogLevel as r, LogLevelPolicyFactory as t };
|
|
49
|
-
//# sourceMappingURL=LogLevelPolicyFactory-
|
|
49
|
+
//# sourceMappingURL=LogLevelPolicyFactory-ewCHLDLn.d.ts.map
|
package/dist/{PublicFrontendBootstrap-DzBgwOnG.d.ts → PublicFrontendBootstrap-Cev3qK46.d.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as CodemationAuthConfig } from "./CodemationWhitelabelConfig-
|
|
1
|
+
import { a as CodemationAuthConfig } from "./CodemationWhitelabelConfig-Ca2mCUeC.js";
|
|
2
2
|
|
|
3
3
|
//#region src/presentation/frontend/CodemationFrontendAuthSnapshot.d.ts
|
|
4
4
|
type CodemationFrontendAuthProviderSnapshot = Readonly<{
|
|
@@ -11,6 +11,11 @@ type CodemationFrontendAuthSnapshot = Readonly<{
|
|
|
11
11
|
oauthProviders: ReadonlyArray<CodemationFrontendAuthProviderSnapshot>;
|
|
12
12
|
secret: string | null;
|
|
13
13
|
uiAuthEnabled: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Present when auth.kind === "managed". Carries the CP-web origin for CORS
|
|
16
|
+
* awareness. No UI login flow is rendered in managed mode.
|
|
17
|
+
*/
|
|
18
|
+
cpWebOrigin?: string;
|
|
14
19
|
}>;
|
|
15
20
|
//#endregion
|
|
16
21
|
//#region src/presentation/frontend/FrontendAppConfig.d.ts
|
|
@@ -44,7 +49,9 @@ type PublicFrontendBootstrap = Readonly<{
|
|
|
44
49
|
oauthProviders: ReadonlyArray<CodemationFrontendAuthProviderSnapshot>;
|
|
45
50
|
productName: string;
|
|
46
51
|
uiAuthEnabled: boolean;
|
|
52
|
+
/** Present in managed mode — the CP web origin. No UI login is rendered when this is set. */
|
|
53
|
+
cpWebOrigin?: string;
|
|
47
54
|
}>;
|
|
48
55
|
//#endregion
|
|
49
56
|
export { CodemationFrontendAuthSnapshot as a, CodemationFrontendAuthProviderSnapshot as i, InternalAuthBootstrap as n, FrontendAppConfig as r, PublicFrontendBootstrap as t };
|
|
50
|
-
//# sourceMappingURL=PublicFrontendBootstrap-
|
|
57
|
+
//# sourceMappingURL=PublicFrontendBootstrap-Cev3qK46.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { r as AppConfig } from "./CodemationAppContext-CKVv9W9q.js";
|
|
2
|
+
import { a as CodemationAuthConfig } from "./CodemationWhitelabelConfig-Ca2mCUeC.js";
|
|
3
|
+
import { a as CodemationFrontendAuthSnapshot, n as InternalAuthBootstrap, r as FrontendAppConfig, t as PublicFrontendBootstrap } from "./PublicFrontendBootstrap-Cev3qK46.js";
|
|
4
|
+
import { ChildProcess } from "node:child_process";
|
|
5
|
+
|
|
6
|
+
//#region src/process/ProcessRunner.types.d.ts
|
|
7
|
+
type ProcessRunOptions = Readonly<{
|
|
8
|
+
cwd?: string;
|
|
9
|
+
env?: NodeJS.ProcessEnv;
|
|
10
|
+
/**
|
|
11
|
+
* Mirrors `child_process.SpawnOptions["stdio"]`. The runner forwards the value verbatim to the
|
|
12
|
+
* underlying subprocess, so callers that need fine-grained per-fd control (e.g.
|
|
13
|
+
* `["ignore", "pipe", "pipe"]`) can pass a tuple.
|
|
14
|
+
*/
|
|
15
|
+
stdio?: "inherit" | "pipe" | "ignore" | ReadonlyArray<"inherit" | "pipe" | "ignore">;
|
|
16
|
+
/**
|
|
17
|
+
* On Unix this detaches the child from the parent's process group so it becomes the group
|
|
18
|
+
* leader (used by {@link DevTrackedProcessTreeKiller} to broadcast SIGTERM to descendants).
|
|
19
|
+
* On Windows it is ignored — `windowsHide` should be used to suppress console windows instead.
|
|
20
|
+
*/
|
|
21
|
+
detached?: boolean;
|
|
22
|
+
windowsHide?: boolean;
|
|
23
|
+
}>;
|
|
24
|
+
type ProcessRunResult = Readonly<{
|
|
25
|
+
exitCode: number | null;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Cross-platform process spawning seam. Implementations resolve bare CLI names (`pnpm`, `prisma`,
|
|
29
|
+
* `next`, …) against the OS PATH using OS-appropriate executable lookup, so call sites stop having
|
|
30
|
+
* to remember `pnpm.cmd` or `shell: true` on Windows.
|
|
31
|
+
*
|
|
32
|
+
* `spawn` returns a Node `ChildProcess` so existing helpers like `DevNextChildProcessOutputFilter`
|
|
33
|
+
* and `DevTrackedProcessTreeKiller` keep working unchanged.
|
|
34
|
+
*/
|
|
35
|
+
interface ProcessRunner {
|
|
36
|
+
/** Long-lived child (dev watcher, Next dev server). Returns a `ChildProcess`. */
|
|
37
|
+
spawn(command: string, args: ReadonlyArray<string>, options?: ProcessRunOptions): ChildProcess;
|
|
38
|
+
/** Synchronous one-shot (used by Prisma migrate deploy). */
|
|
39
|
+
runSync(command: string, args: ReadonlyArray<string>, options?: ProcessRunOptions): ProcessRunResult;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/presentation/frontend/CodemationFrontendAuthSnapshotFactory.d.ts
|
|
43
|
+
declare class CodemationFrontendAuthSnapshotFactory {
|
|
44
|
+
createFromAppConfig(appConfig: AppConfig): CodemationFrontendAuthSnapshot;
|
|
45
|
+
createFromResolvedInputs(args: Readonly<{
|
|
46
|
+
authConfig: CodemationAuthConfig | undefined;
|
|
47
|
+
env: NodeJS.ProcessEnv;
|
|
48
|
+
uiAuthEnabled: boolean;
|
|
49
|
+
}>): CodemationFrontendAuthSnapshot;
|
|
50
|
+
private resolveUiAuthEnabled;
|
|
51
|
+
private resolveAuthSecret;
|
|
52
|
+
private createOauthProviders;
|
|
53
|
+
private createOAuthProvider;
|
|
54
|
+
private createOidcProvider;
|
|
55
|
+
private resolveOAuthProviderName;
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/presentation/frontend/FrontendAppConfigFactory.d.ts
|
|
59
|
+
declare class FrontendAppConfigFactory {
|
|
60
|
+
private readonly appConfig;
|
|
61
|
+
private readonly authSnapshotFactory;
|
|
62
|
+
constructor(appConfig: AppConfig, authSnapshotFactory: CodemationFrontendAuthSnapshotFactory);
|
|
63
|
+
create(): FrontendAppConfig;
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/presentation/frontend/InternalAuthBootstrapFactory.d.ts
|
|
67
|
+
declare class InternalAuthBootstrapFactory {
|
|
68
|
+
private readonly appConfig;
|
|
69
|
+
private readonly authSnapshotFactory;
|
|
70
|
+
constructor(appConfig: AppConfig, authSnapshotFactory: CodemationFrontendAuthSnapshotFactory);
|
|
71
|
+
create(): InternalAuthBootstrap;
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/presentation/frontend/PublicFrontendBootstrapFactory.d.ts
|
|
75
|
+
declare class PublicFrontendBootstrapFactory {
|
|
76
|
+
private readonly frontendAppConfigFactory;
|
|
77
|
+
constructor(frontendAppConfigFactory: FrontendAppConfigFactory);
|
|
78
|
+
create(): PublicFrontendBootstrap;
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
export { ProcessRunOptions as a, CodemationFrontendAuthSnapshotFactory as i, InternalAuthBootstrapFactory as n, ProcessRunResult as o, FrontendAppConfigFactory as r, ProcessRunner as s, PublicFrontendBootstrapFactory as t };
|
|
82
|
+
//# sourceMappingURL=PublicFrontendBootstrapFactory-CY2FS-5g.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as CodemationFrontendAuthSnapshot, n as InternalAuthBootstrap, r as FrontendAppConfig, t as PublicFrontendBootstrap } from "./PublicFrontendBootstrap-
|
|
1
|
+
import { a as CodemationFrontendAuthSnapshot, n as InternalAuthBootstrap, r as FrontendAppConfig, t as PublicFrontendBootstrap } from "./PublicFrontendBootstrap-Cev3qK46.js";
|
|
2
2
|
|
|
3
3
|
//#region src/presentation/http/ApiPaths.d.ts
|
|
4
4
|
declare class ApiPaths {
|
|
@@ -47,9 +47,9 @@ declare class ApiPaths {
|
|
|
47
47
|
static credentialInstance(instanceId: string, withSecrets?: boolean): string;
|
|
48
48
|
static credentialInstanceTest(instanceId: string): string;
|
|
49
49
|
static credentialBindings(): string;
|
|
50
|
-
static oauth2Auth(instanceId: string): string;
|
|
51
50
|
static oauth2RedirectUri(): string;
|
|
52
51
|
static oauth2Disconnect(instanceId: string): string;
|
|
52
|
+
static credentialOAuthStart(): string;
|
|
53
53
|
static workflowWebsocket(): string;
|
|
54
54
|
/** Dev gateway: stable browser WebSocket for build lifecycle (CLI → gateway → browser). */
|
|
55
55
|
static devGatewaySocket(): string;
|
|
@@ -116,4 +116,4 @@ declare class PublicFrontendBootstrapJsonCodec {
|
|
|
116
116
|
}
|
|
117
117
|
//#endregion
|
|
118
118
|
export { ApiPaths as a, CodemationFrontendAuthSnapshotJsonCodec as i, InternalAuthBootstrapJsonCodec as n, FrontendAppConfigJsonCodec as r, PublicFrontendBootstrapJsonCodec as t };
|
|
119
|
-
//# sourceMappingURL=PublicFrontendBootstrapJsonCodec-
|
|
119
|
+
//# sourceMappingURL=PublicFrontendBootstrapJsonCodec-CXG9Dxft.d.ts.map
|
|
@@ -128,13 +128,18 @@ var PublicFrontendBootstrapJsonCodec = class {
|
|
|
128
128
|
try {
|
|
129
129
|
const parsed = JSON.parse(serialized);
|
|
130
130
|
if (!parsed || typeof parsed !== "object") return null;
|
|
131
|
-
|
|
131
|
+
const base = {
|
|
132
132
|
credentialsEnabled: parsed.credentialsEnabled === true,
|
|
133
133
|
logoUrl: typeof parsed.logoUrl === "string" && parsed.logoUrl.trim().length > 0 ? parsed.logoUrl : null,
|
|
134
134
|
oauthProviders: this.resolveOauthProviders(parsed.oauthProviders),
|
|
135
135
|
productName: typeof parsed.productName === "string" && parsed.productName.trim().length > 0 ? parsed.productName : "Codemation",
|
|
136
136
|
uiAuthEnabled: parsed.uiAuthEnabled !== false
|
|
137
137
|
};
|
|
138
|
+
const cpWebOrigin = typeof parsed.cpWebOrigin === "string" && parsed.cpWebOrigin.trim().length > 0 ? parsed.cpWebOrigin : void 0;
|
|
139
|
+
return cpWebOrigin ? {
|
|
140
|
+
...base,
|
|
141
|
+
cpWebOrigin
|
|
142
|
+
} : base;
|
|
138
143
|
} catch {
|
|
139
144
|
return null;
|
|
140
145
|
}
|
|
@@ -155,4 +160,4 @@ var PublicFrontendBootstrapJsonCodec = class {
|
|
|
155
160
|
|
|
156
161
|
//#endregion
|
|
157
162
|
export { CodemationFrontendAuthSnapshotJsonCodec as i, InternalAuthBootstrapJsonCodec as n, FrontendAppConfigJsonCodec as r, PublicFrontendBootstrapJsonCodec as t };
|
|
158
|
-
//# sourceMappingURL=PublicFrontendBootstrapJsonCodec-
|
|
163
|
+
//# sourceMappingURL=PublicFrontendBootstrapJsonCodec-CegIF_ne.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PublicFrontendBootstrapJsonCodec-CegIF_ne.js","names":["base: PublicFrontendBootstrap"],"sources":["../src/presentation/frontend/CodemationFrontendAuthSnapshotJsonCodec.ts","../src/presentation/frontend/FrontendAppConfigJsonCodec.ts","../src/presentation/frontend/InternalAuthBootstrapJsonCodec.ts","../src/presentation/frontend/PublicFrontendBootstrapJsonCodec.ts"],"sourcesContent":["import type { CodemationAuthConfig } from \"../config/CodemationAuthConfig\";\n\nimport type {\n CodemationFrontendAuthProviderSnapshot,\n CodemationFrontendAuthSnapshot,\n} from \"./CodemationFrontendAuthSnapshot\";\n\nexport class CodemationFrontendAuthSnapshotJsonCodec {\n serialize(snapshot: CodemationFrontendAuthSnapshot): string {\n return JSON.stringify(snapshot);\n }\n\n deserialize(serialized: string | undefined): CodemationFrontendAuthSnapshot | null {\n if (!serialized || serialized.trim().length === 0) {\n return null;\n }\n try {\n const parsed = JSON.parse(serialized) as Partial<CodemationFrontendAuthSnapshot> | null;\n if (!parsed || typeof parsed !== \"object\") {\n return null;\n }\n return {\n config: this.resolveAuthConfig(parsed.config),\n credentialsEnabled: parsed.credentialsEnabled === true,\n oauthProviders: this.resolveOauthProviders(parsed.oauthProviders),\n secret: typeof parsed.secret === \"string\" && parsed.secret.trim().length > 0 ? parsed.secret : null,\n uiAuthEnabled: parsed.uiAuthEnabled !== false,\n };\n } catch {\n return null;\n }\n }\n\n private resolveAuthConfig(value: unknown): CodemationAuthConfig | undefined {\n return value && typeof value === \"object\" ? (value as CodemationAuthConfig) : undefined;\n }\n\n private resolveOauthProviders(value: unknown): ReadonlyArray<CodemationFrontendAuthProviderSnapshot> {\n if (!Array.isArray(value)) {\n return [];\n }\n return value.flatMap((entry) => {\n if (!entry || typeof entry !== \"object\") {\n return [];\n }\n const provider = entry as Partial<CodemationFrontendAuthProviderSnapshot>;\n if (typeof provider.id !== \"string\" || typeof provider.name !== \"string\") {\n return [];\n }\n return [\n {\n id: provider.id,\n name: provider.name,\n },\n ];\n });\n }\n}\n","import type { CodemationAuthConfig } from \"../config/CodemationAuthConfig\";\nimport type { FrontendAppConfig } from \"./FrontendAppConfig\";\nimport type { CodemationFrontendAuthProviderSnapshot } from \"./CodemationFrontendAuthSnapshot\";\n\nexport class FrontendAppConfigJsonCodec {\n serialize(config: FrontendAppConfig): string {\n return JSON.stringify(config);\n }\n\n deserialize(serialized: string | undefined): FrontendAppConfig | null {\n if (!serialized || serialized.trim().length === 0) {\n return null;\n }\n try {\n const parsed = JSON.parse(serialized) as Partial<FrontendAppConfig> | null;\n if (!parsed || typeof parsed !== \"object\" || !parsed.auth || typeof parsed.auth !== \"object\") {\n return null;\n }\n return {\n auth: {\n config: this.resolveAuthConfig(parsed.auth.config),\n credentialsEnabled: parsed.auth.credentialsEnabled === true,\n oauthProviders: this.resolveOauthProviders(parsed.auth.oauthProviders),\n secret:\n typeof parsed.auth.secret === \"string\" && parsed.auth.secret.trim().length > 0 ? parsed.auth.secret : null,\n uiAuthEnabled: parsed.auth.uiAuthEnabled !== false,\n },\n productName:\n typeof parsed.productName === \"string\" && parsed.productName.trim().length > 0\n ? parsed.productName\n : \"Codemation\",\n logoUrl: typeof parsed.logoUrl === \"string\" && parsed.logoUrl.trim().length > 0 ? parsed.logoUrl : null,\n };\n } catch {\n return null;\n }\n }\n\n private resolveAuthConfig(value: unknown): CodemationAuthConfig | undefined {\n return value && typeof value === \"object\" ? (value as CodemationAuthConfig) : undefined;\n }\n\n private resolveOauthProviders(value: unknown): ReadonlyArray<CodemationFrontendAuthProviderSnapshot> {\n if (!Array.isArray(value)) {\n return [];\n }\n return value.flatMap((entry) => {\n if (!entry || typeof entry !== \"object\") {\n return [];\n }\n const provider = entry as Partial<CodemationFrontendAuthProviderSnapshot>;\n if (typeof provider.id !== \"string\" || typeof provider.name !== \"string\") {\n return [];\n }\n return [{ id: provider.id, name: provider.name }];\n });\n }\n}\n","import type { CodemationAuthConfig } from \"../config/CodemationAuthConfig\";\nimport type { CodemationFrontendAuthProviderSnapshot } from \"./CodemationFrontendAuthSnapshot\";\nimport type { InternalAuthBootstrap } from \"./InternalAuthBootstrap\";\n\nexport class InternalAuthBootstrapJsonCodec {\n serialize(bootstrap: InternalAuthBootstrap): string {\n return JSON.stringify(bootstrap);\n }\n\n deserialize(serialized: string | undefined): InternalAuthBootstrap | null {\n if (!serialized || serialized.trim().length === 0) {\n return null;\n }\n try {\n const parsed = JSON.parse(serialized) as Partial<InternalAuthBootstrap> | null;\n if (!parsed || typeof parsed !== \"object\") {\n return null;\n }\n return {\n authConfig: this.resolveAuthConfig(parsed.authConfig),\n credentialsEnabled: parsed.credentialsEnabled === true,\n oauthProviders: this.resolveOauthProviders(parsed.oauthProviders),\n uiAuthEnabled: parsed.uiAuthEnabled !== false,\n };\n } catch {\n return null;\n }\n }\n\n private resolveAuthConfig(value: unknown): CodemationAuthConfig | undefined {\n return value && typeof value === \"object\" ? (value as CodemationAuthConfig) : undefined;\n }\n\n private resolveOauthProviders(value: unknown): ReadonlyArray<CodemationFrontendAuthProviderSnapshot> {\n if (!Array.isArray(value)) {\n return [];\n }\n return value.flatMap((entry) => {\n if (!entry || typeof entry !== \"object\") {\n return [];\n }\n const provider = entry as Partial<CodemationFrontendAuthProviderSnapshot>;\n if (typeof provider.id !== \"string\" || typeof provider.name !== \"string\") {\n return [];\n }\n return [{ id: provider.id, name: provider.name }];\n });\n }\n}\n","import type { PublicFrontendBootstrap } from \"./PublicFrontendBootstrap\";\nimport type { CodemationFrontendAuthProviderSnapshot } from \"./CodemationFrontendAuthSnapshot\";\n\nexport class PublicFrontendBootstrapJsonCodec {\n serialize(bootstrap: PublicFrontendBootstrap): string {\n return JSON.stringify(bootstrap);\n }\n\n deserialize(serialized: string | undefined): PublicFrontendBootstrap | null {\n if (!serialized || serialized.trim().length === 0) {\n return null;\n }\n try {\n const parsed = JSON.parse(serialized) as Partial<PublicFrontendBootstrap> | null;\n if (!parsed || typeof parsed !== \"object\") {\n return null;\n }\n const base: PublicFrontendBootstrap = {\n credentialsEnabled: parsed.credentialsEnabled === true,\n logoUrl: typeof parsed.logoUrl === \"string\" && parsed.logoUrl.trim().length > 0 ? parsed.logoUrl : null,\n oauthProviders: this.resolveOauthProviders(parsed.oauthProviders),\n productName:\n typeof parsed.productName === \"string\" && parsed.productName.trim().length > 0\n ? parsed.productName\n : \"Codemation\",\n uiAuthEnabled: parsed.uiAuthEnabled !== false,\n };\n const cpWebOrigin =\n typeof parsed.cpWebOrigin === \"string\" && parsed.cpWebOrigin.trim().length > 0 ? parsed.cpWebOrigin : undefined;\n return cpWebOrigin ? { ...base, cpWebOrigin } : base;\n } catch {\n return null;\n }\n }\n\n private resolveOauthProviders(value: unknown): ReadonlyArray<CodemationFrontendAuthProviderSnapshot> {\n if (!Array.isArray(value)) {\n return [];\n }\n return value.flatMap((entry) => {\n if (!entry || typeof entry !== \"object\") {\n return [];\n }\n const provider = entry as Partial<CodemationFrontendAuthProviderSnapshot>;\n if (typeof provider.id !== \"string\" || typeof provider.name !== \"string\") {\n return [];\n }\n return [{ id: provider.id, name: provider.name }];\n });\n }\n}\n"],"mappings":";AAOA,IAAa,0CAAb,MAAqD;CACnD,UAAU,UAAkD;AAC1D,SAAO,KAAK,UAAU,SAAS;;CAGjC,YAAY,YAAuE;AACjF,MAAI,CAAC,cAAc,WAAW,MAAM,CAAC,WAAW,EAC9C,QAAO;AAET,MAAI;GACF,MAAM,SAAS,KAAK,MAAM,WAAW;AACrC,OAAI,CAAC,UAAU,OAAO,WAAW,SAC/B,QAAO;AAET,UAAO;IACL,QAAQ,KAAK,kBAAkB,OAAO,OAAO;IAC7C,oBAAoB,OAAO,uBAAuB;IAClD,gBAAgB,KAAK,sBAAsB,OAAO,eAAe;IACjE,QAAQ,OAAO,OAAO,WAAW,YAAY,OAAO,OAAO,MAAM,CAAC,SAAS,IAAI,OAAO,SAAS;IAC/F,eAAe,OAAO,kBAAkB;IACzC;UACK;AACN,UAAO;;;CAIX,AAAQ,k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5C,UAAU,WAA4C;AACpD,SAAO,KAAK,UAAU,UAAU;;CAGlC,YAAY,YAAgE;AAC1E,MAAI,CAAC,cAAc,WAAW,MAAM,CAAC,WAAW,EAC9C,QAAO;AAET,MAAI;GACF,MAAM,SAAS,KAAK,MAAM,WAAW;AACrC,OAAI,CAAC,UAAU,OAAO,WAAW,SAC/B,QAAO;GAET,MAAMA,OAAgC;IACpC,oBAAoB,OAAO,uBAAuB;IAClD,SAAS,OAAO,OAAO,YAAY,YAAY,OAAO,QAAQ,MAAM,CAAC,SAAS,IAAI,OAAO,UAAU;IACnG,gBAAgB,KAAK,sBAAsB,OAAO,eAAe;IACjE,aACE,OAAO,OAAO,gBAAgB,YAAY,OAAO,YAAY,MAAM,CAAC,SAAS,IACzE,OAAO,cACP;IACN,eAAe,OAAO,kBAAkB;IACzC;GACD,MAAM,cACJ,OAAO,OAAO,gBAAgB,YAAY,OAAO,YAAY,MAAM,CAAC,SAAS,IAAI,OAAO,cAAc;AACxG,UAAO,cAAc;IAAE,GAAG;IAAM;IAAa,GAAG;UAC1C;AACN,UAAO;;;CAIX,AAAQ,sBAAsB,OAAuE;AACnG,MAAI,CAAC,MAAM,QAAQ,MAAM,CACvB,QAAO,EAAE;AAEX,SAAO,MAAM,SAAS,UAAU;AAC9B,OAAI,CAAC,SAAS,OAAO,UAAU,SAC7B,QAAO,EAAE;GAEX,MAAM,WAAW;AACjB,OAAI,OAAO,SAAS,OAAO,YAAY,OAAO,SAAS,SAAS,SAC9D,QAAO,EAAE;AAEX,UAAO,CAAC;IAAE,IAAI,SAAS;IAAI,MAAM,SAAS;IAAM,CAAC;IACjD"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { r as ConsoleLogger, t as LogLevelPolicyFactory } from "./LogLevelPolicyFactory-DCUzIN6G.js";
|
|
2
|
+
import { n as __decorateMetadata, t as __decorateParam } from "./decorateParam-BWxkAUSj.js";
|
|
3
|
+
import { t as __decorate } from "./decorate-CXWmflG_.js";
|
|
4
|
+
import { inject, injectable } from "@codemation/core";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { promises } from "node:fs";
|
|
7
|
+
|
|
8
|
+
//#region src/bootstrap/perf/BootTimer.ts
|
|
9
|
+
var BootTimer = class {
|
|
10
|
+
static enabled = false;
|
|
11
|
+
static root = null;
|
|
12
|
+
static current = null;
|
|
13
|
+
/** Enable boot tracing for the lifetime of the current process. Idempotent. */
|
|
14
|
+
static enable() {
|
|
15
|
+
if (this.enabled) return;
|
|
16
|
+
this.enabled = true;
|
|
17
|
+
this.root = {
|
|
18
|
+
name: "boot",
|
|
19
|
+
startNs: process.hrtime.bigint(),
|
|
20
|
+
endNs: null,
|
|
21
|
+
children: [],
|
|
22
|
+
parent: null
|
|
23
|
+
};
|
|
24
|
+
this.current = this.root;
|
|
25
|
+
}
|
|
26
|
+
static isEnabled() {
|
|
27
|
+
return this.enabled;
|
|
28
|
+
}
|
|
29
|
+
/** Wrap an async phase. Pass-through when disabled. */
|
|
30
|
+
static async measureAsync(name, fn) {
|
|
31
|
+
if (!this.enabled || !this.current) return await fn();
|
|
32
|
+
const node = this.pushPhase(name);
|
|
33
|
+
try {
|
|
34
|
+
return await fn();
|
|
35
|
+
} finally {
|
|
36
|
+
this.popPhase(node);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** Wrap a sync phase. Pass-through when disabled. */
|
|
40
|
+
static measure(name, fn) {
|
|
41
|
+
if (!this.enabled || !this.current) return fn();
|
|
42
|
+
const node = this.pushPhase(name);
|
|
43
|
+
try {
|
|
44
|
+
return fn();
|
|
45
|
+
} finally {
|
|
46
|
+
this.popPhase(node);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Manual start/stop for fire-and-forget phases (e.g. a spawned child process you only
|
|
51
|
+
* stop once a readiness probe succeeds). Returns the stop function.
|
|
52
|
+
*/
|
|
53
|
+
static start(name) {
|
|
54
|
+
if (!this.enabled || !this.current) return () => {};
|
|
55
|
+
const node = this.pushPhase(name);
|
|
56
|
+
return () => this.popPhase(node);
|
|
57
|
+
}
|
|
58
|
+
/** Print the tree to stderr and write JSON to the given path. Finalizes the root span. */
|
|
59
|
+
static async finish(outputJsonPath) {
|
|
60
|
+
if (!this.enabled || !this.root) return;
|
|
61
|
+
if (this.root.endNs === null) this.root.endNs = process.hrtime.bigint();
|
|
62
|
+
const totalMs = nodeMs(this.root);
|
|
63
|
+
process.stderr.write(`\n=== Boot trace (total ${totalMs.toFixed(0)}ms) ===\n`);
|
|
64
|
+
writeTree(this.root, 0, totalMs);
|
|
65
|
+
process.stderr.write("=========================================\n\n");
|
|
66
|
+
if (outputJsonPath) try {
|
|
67
|
+
await promises.mkdir(path.dirname(outputJsonPath), { recursive: true });
|
|
68
|
+
await promises.writeFile(outputJsonPath, JSON.stringify(this.snapshot(), null, 2), "utf8");
|
|
69
|
+
} catch (error) {
|
|
70
|
+
process.stderr.write(`[boot-timer] failed to write JSON trace: ${String(error)}\n`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/** Return a plain-object snapshot of the current tree (for tests / diffing). */
|
|
74
|
+
static snapshot() {
|
|
75
|
+
if (!this.root) return {
|
|
76
|
+
name: "boot",
|
|
77
|
+
ms: 0,
|
|
78
|
+
pct: 100,
|
|
79
|
+
children: []
|
|
80
|
+
};
|
|
81
|
+
const totalMs = nodeMs(this.root);
|
|
82
|
+
return toReport(this.root, totalMs);
|
|
83
|
+
}
|
|
84
|
+
/** Test helper: reset all state. Do not call in production code. */
|
|
85
|
+
static reset() {
|
|
86
|
+
this.enabled = false;
|
|
87
|
+
this.root = null;
|
|
88
|
+
this.current = null;
|
|
89
|
+
}
|
|
90
|
+
static pushPhase(name) {
|
|
91
|
+
const node = {
|
|
92
|
+
name,
|
|
93
|
+
startNs: process.hrtime.bigint(),
|
|
94
|
+
endNs: null,
|
|
95
|
+
children: [],
|
|
96
|
+
parent: this.current
|
|
97
|
+
};
|
|
98
|
+
this.current.children.push(node);
|
|
99
|
+
this.current = node;
|
|
100
|
+
return node;
|
|
101
|
+
}
|
|
102
|
+
static popPhase(node) {
|
|
103
|
+
node.endNs = process.hrtime.bigint();
|
|
104
|
+
this.current = node.parent ?? this.root;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
function nodeMs(node) {
|
|
108
|
+
const end = node.endNs ?? node.startNs;
|
|
109
|
+
return Number(end - node.startNs) / 1e6;
|
|
110
|
+
}
|
|
111
|
+
function toReport(node, totalMs) {
|
|
112
|
+
const ms = nodeMs(node);
|
|
113
|
+
return {
|
|
114
|
+
name: node.name,
|
|
115
|
+
ms,
|
|
116
|
+
pct: totalMs > 0 ? ms / totalMs * 100 : 0,
|
|
117
|
+
children: node.children.map((child) => toReport(child, totalMs))
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function writeTree(node, depth, totalMs) {
|
|
121
|
+
const ms = nodeMs(node);
|
|
122
|
+
const pct = totalMs > 0 ? (ms / totalMs * 100).toFixed(1) : "—";
|
|
123
|
+
const indent = " ".repeat(depth);
|
|
124
|
+
const msStr = ms.toFixed(0).padStart(6);
|
|
125
|
+
const pctStr = pct.padStart(5);
|
|
126
|
+
process.stderr.write(`${indent}${msStr}ms ${pctStr}% ${node.name}\n`);
|
|
127
|
+
for (const child of node.children) writeTree(child, depth + 1, totalMs);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region src/infrastructure/logging/FilteringLogger.ts
|
|
132
|
+
var FilteringLogger = class {
|
|
133
|
+
constructor(inner, scope, filter) {
|
|
134
|
+
this.inner = inner;
|
|
135
|
+
this.scope = scope;
|
|
136
|
+
this.filter = filter;
|
|
137
|
+
}
|
|
138
|
+
info(message, exception) {
|
|
139
|
+
if (!this.filter({
|
|
140
|
+
scope: this.scope,
|
|
141
|
+
level: "info",
|
|
142
|
+
message
|
|
143
|
+
})) return;
|
|
144
|
+
this.inner.info(message, exception);
|
|
145
|
+
}
|
|
146
|
+
warn(message, exception) {
|
|
147
|
+
if (!this.filter({
|
|
148
|
+
scope: this.scope,
|
|
149
|
+
level: "warn",
|
|
150
|
+
message
|
|
151
|
+
})) return;
|
|
152
|
+
this.inner.warn(message, exception);
|
|
153
|
+
}
|
|
154
|
+
error(message, exception) {
|
|
155
|
+
if (!this.filter({
|
|
156
|
+
scope: this.scope,
|
|
157
|
+
level: "error",
|
|
158
|
+
message
|
|
159
|
+
})) return;
|
|
160
|
+
this.inner.error(message, exception);
|
|
161
|
+
}
|
|
162
|
+
debug(message, exception) {
|
|
163
|
+
if (!this.filter({
|
|
164
|
+
scope: this.scope,
|
|
165
|
+
level: "debug",
|
|
166
|
+
message
|
|
167
|
+
})) return;
|
|
168
|
+
this.inner.debug(message, exception);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/infrastructure/logging/PerformanceLogPolicy.ts
|
|
174
|
+
/**
|
|
175
|
+
* Opt-in detailed timing / diagnostics lines (used with `ServerLoggerFactory#createPerformanceDiagnostics`).
|
|
176
|
+
*
|
|
177
|
+
* Set `CODEMATION_PERFORMANCE_LOGGING=true` to enable. Otherwise those loggers are silent regardless of level.
|
|
178
|
+
*/
|
|
179
|
+
var PerformanceLogPolicy = class {
|
|
180
|
+
shouldEmitDetailedTiming() {
|
|
181
|
+
return process.env.CODEMATION_PERFORMANCE_LOGGING === "true";
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region src/infrastructure/logging/PerformanceLogPolicyFactory.ts
|
|
187
|
+
/**
|
|
188
|
+
* Process-wide {@link PerformanceLogPolicy} singleton (same pattern as {@link LogLevelPolicyFactory}).
|
|
189
|
+
*/
|
|
190
|
+
var PerformanceLogPolicyFactory = class {
|
|
191
|
+
policy = new PerformanceLogPolicy();
|
|
192
|
+
create() {
|
|
193
|
+
return this.policy;
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
const performanceLogPolicyFactory = new PerformanceLogPolicyFactory();
|
|
197
|
+
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/infrastructure/logging/ServerLoggerFactory.ts
|
|
200
|
+
var _ref;
|
|
201
|
+
let ServerLoggerFactory = class ServerLoggerFactory$1 {
|
|
202
|
+
constructor(logLevelPolicyFactory) {
|
|
203
|
+
this.logLevelPolicyFactory = logLevelPolicyFactory;
|
|
204
|
+
}
|
|
205
|
+
create(scope) {
|
|
206
|
+
return new ConsoleLogger(scope, this.logLevelPolicyFactory.create());
|
|
207
|
+
}
|
|
208
|
+
createFiltered(scope, filter) {
|
|
209
|
+
return new FilteringLogger(this.create(scope), scope, filter);
|
|
210
|
+
}
|
|
211
|
+
createPerformanceDiagnostics(scope) {
|
|
212
|
+
return this.createFiltered(scope, (_entry) => performanceLogPolicyFactory.create().shouldEmitDetailedTiming());
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
ServerLoggerFactory = __decorate([
|
|
216
|
+
injectable(),
|
|
217
|
+
__decorateParam(0, inject(LogLevelPolicyFactory)),
|
|
218
|
+
__decorateMetadata("design:paramtypes", [typeof (_ref = typeof LogLevelPolicyFactory !== "undefined" && LogLevelPolicyFactory) === "function" ? _ref : Object])
|
|
219
|
+
], ServerLoggerFactory);
|
|
220
|
+
|
|
221
|
+
//#endregion
|
|
222
|
+
export { FilteringLogger as a, PerformanceLogPolicy as i, PerformanceLogPolicyFactory as n, BootTimer as o, performanceLogPolicyFactory as r, ServerLoggerFactory as t };
|
|
223
|
+
//# sourceMappingURL=ServerLoggerFactory-Ckk52S3w.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServerLoggerFactory-Ckk52S3w.js","names":["fs","node: PhaseNode","inner: Logger","scope: string","filter: LogFilter","ServerLoggerFactory","logLevelPolicyFactory: LogLevelPolicyFactory","ServerLogger"],"sources":["../src/bootstrap/perf/BootTimer.ts","../src/infrastructure/logging/FilteringLogger.ts","../src/infrastructure/logging/PerformanceLogPolicy.ts","../src/infrastructure/logging/PerformanceLogPolicyFactory.ts","../src/infrastructure/logging/ServerLoggerFactory.ts"],"sourcesContent":["/**\n * Lightweight boot-phase timer. Designed for diagnosing slow `pnpm dev` cold starts.\n *\n * Usage: every meaningful boot phase wraps its async work in\n * `await BootTimer.measureAsync(\"phase.name\", async () => { ... })`\n * (or the sync `measure` for non-async work). When `--trace-boot` is set on the CLI\n * the timer records each phase in a tree, prints a pretty tree to stderr at the end\n * of boot, and writes the same tree to `tmp/boot-trace.json` for diffing later.\n *\n * When disabled (default), every method is a near-zero-cost passthrough — no allocation,\n * no Date.now() calls, no tree construction. Safe to leave instrumentation in production\n * code paths.\n */\n\nimport { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\n\ntype PhaseNode = {\n name: string;\n startNs: bigint;\n endNs: bigint | null;\n children: PhaseNode[];\n parent: PhaseNode | null;\n};\n\nexport type BootTracePhase = Readonly<{\n name: string;\n ms: number;\n pct: number;\n children: ReadonlyArray<BootTracePhase>;\n}>;\n\nexport class BootTimer {\n private static enabled = false;\n private static root: PhaseNode | null = null;\n private static current: PhaseNode | null = null;\n\n /** Enable boot tracing for the lifetime of the current process. Idempotent. */\n static enable(): void {\n if (this.enabled) return;\n this.enabled = true;\n this.root = { name: \"boot\", startNs: process.hrtime.bigint(), endNs: null, children: [], parent: null };\n this.current = this.root;\n }\n\n static isEnabled(): boolean {\n return this.enabled;\n }\n\n /** Wrap an async phase. Pass-through when disabled. */\n static async measureAsync<T>(name: string, fn: () => Promise<T>): Promise<T> {\n if (!this.enabled || !this.current) {\n return await fn();\n }\n const node = this.pushPhase(name);\n try {\n return await fn();\n } finally {\n this.popPhase(node);\n }\n }\n\n /** Wrap a sync phase. Pass-through when disabled. */\n static measure<T>(name: string, fn: () => T): T {\n if (!this.enabled || !this.current) {\n return fn();\n }\n const node = this.pushPhase(name);\n try {\n return fn();\n } finally {\n this.popPhase(node);\n }\n }\n\n /**\n * Manual start/stop for fire-and-forget phases (e.g. a spawned child process you only\n * stop once a readiness probe succeeds). Returns the stop function.\n */\n static start(name: string): () => void {\n if (!this.enabled || !this.current) {\n return () => {};\n }\n const node = this.pushPhase(name);\n return () => this.popPhase(node);\n }\n\n /** Print the tree to stderr and write JSON to the given path. Finalizes the root span. */\n static async finish(outputJsonPath?: string): Promise<void> {\n if (!this.enabled || !this.root) return;\n if (this.root.endNs === null) {\n this.root.endNs = process.hrtime.bigint();\n }\n const totalMs = nodeMs(this.root);\n process.stderr.write(`\\n=== Boot trace (total ${totalMs.toFixed(0)}ms) ===\\n`);\n writeTree(this.root, 0, totalMs);\n process.stderr.write(\"=========================================\\n\\n\");\n if (outputJsonPath) {\n try {\n await fs.mkdir(path.dirname(outputJsonPath), { recursive: true });\n await fs.writeFile(outputJsonPath, JSON.stringify(this.snapshot(), null, 2), \"utf8\");\n } catch (error) {\n process.stderr.write(`[boot-timer] failed to write JSON trace: ${String(error)}\\n`);\n }\n }\n }\n\n /** Return a plain-object snapshot of the current tree (for tests / diffing). */\n static snapshot(): BootTracePhase {\n if (!this.root) {\n return { name: \"boot\", ms: 0, pct: 100, children: [] };\n }\n const totalMs = nodeMs(this.root);\n return toReport(this.root, totalMs);\n }\n\n /** Test helper: reset all state. Do not call in production code. */\n static reset(): void {\n this.enabled = false;\n this.root = null;\n this.current = null;\n }\n\n private static pushPhase(name: string): PhaseNode {\n const node: PhaseNode = {\n name,\n startNs: process.hrtime.bigint(),\n endNs: null,\n children: [],\n parent: this.current,\n };\n this.current!.children.push(node);\n this.current = node;\n return node;\n }\n\n private static popPhase(node: PhaseNode): void {\n node.endNs = process.hrtime.bigint();\n this.current = node.parent ?? this.root;\n }\n}\n\nfunction nodeMs(node: PhaseNode): number {\n const end = node.endNs ?? node.startNs;\n return Number(end - node.startNs) / 1e6;\n}\n\nfunction toReport(node: PhaseNode, totalMs: number): BootTracePhase {\n const ms = nodeMs(node);\n return {\n name: node.name,\n ms,\n pct: totalMs > 0 ? (ms / totalMs) * 100 : 0,\n children: node.children.map((child) => toReport(child, totalMs)),\n };\n}\n\nfunction writeTree(node: PhaseNode, depth: number, totalMs: number): void {\n const ms = nodeMs(node);\n const pct = totalMs > 0 ? ((ms / totalMs) * 100).toFixed(1) : \"—\";\n const indent = \" \".repeat(depth);\n const msStr = ms.toFixed(0).padStart(6);\n const pctStr = pct.padStart(5);\n process.stderr.write(`${indent}${msStr}ms ${pctStr}% ${node.name}\\n`);\n for (const child of node.children) {\n writeTree(child, depth + 1, totalMs);\n }\n}\n","import type { LogFilter } from \"../../application/logging/LogFilter\";\nimport type { Logger } from \"../../application/logging/Logger\";\n\nexport class FilteringLogger implements Logger {\n constructor(\n private readonly inner: Logger,\n private readonly scope: string,\n private readonly filter: LogFilter,\n ) {}\n\n info(message: string, exception?: Error): void {\n if (!this.filter({ scope: this.scope, level: \"info\", message })) {\n return;\n }\n this.inner.info(message, exception);\n }\n\n warn(message: string, exception?: Error): void {\n if (!this.filter({ scope: this.scope, level: \"warn\", message })) {\n return;\n }\n this.inner.warn(message, exception);\n }\n\n error(message: string, exception?: Error): void {\n if (!this.filter({ scope: this.scope, level: \"error\", message })) {\n return;\n }\n this.inner.error(message, exception);\n }\n\n debug(message: string, exception?: Error): void {\n if (!this.filter({ scope: this.scope, level: \"debug\", message })) {\n return;\n }\n this.inner.debug(message, exception);\n }\n}\n","/**\n * Opt-in detailed timing / diagnostics lines (used with `ServerLoggerFactory#createPerformanceDiagnostics`).\n *\n * Set `CODEMATION_PERFORMANCE_LOGGING=true` to enable. Otherwise those loggers are silent regardless of level.\n */\nexport class PerformanceLogPolicy {\n shouldEmitDetailedTiming(): boolean {\n return process.env.CODEMATION_PERFORMANCE_LOGGING === \"true\";\n }\n}\n","import { PerformanceLogPolicy } from \"./PerformanceLogPolicy\";\n\n/**\n * Process-wide {@link PerformanceLogPolicy} singleton (same pattern as {@link LogLevelPolicyFactory}).\n */\nexport class PerformanceLogPolicyFactory {\n private readonly policy = new PerformanceLogPolicy();\n\n create(): PerformanceLogPolicy {\n return this.policy;\n }\n}\n\nexport const performanceLogPolicyFactory = new PerformanceLogPolicyFactory();\n","import { inject, injectable } from \"@codemation/core\";\n\nimport type { LogFilter } from \"../../application/logging/LogFilter\";\nimport type { Logger, LoggerFactory } from \"../../application/logging/Logger\";\n\nimport { FilteringLogger } from \"./FilteringLogger\";\nimport { LogLevelPolicyFactory } from \"./LogLevelPolicyFactory\";\nimport { performanceLogPolicyFactory } from \"./PerformanceLogPolicyFactory\";\nimport { ServerLogger } from \"./ServerLogger\";\n\n@injectable()\nexport class ServerLoggerFactory implements LoggerFactory {\n constructor(@inject(LogLevelPolicyFactory) private readonly logLevelPolicyFactory: LogLevelPolicyFactory) {}\n\n create(scope: string): Logger {\n return new ServerLogger(scope, this.logLevelPolicyFactory.create());\n }\n\n createFiltered(scope: string, filter: LogFilter): Logger {\n return new FilteringLogger(this.create(scope), scope, filter);\n }\n\n createPerformanceDiagnostics(scope: string): Logger {\n return this.createFiltered(scope, (_entry) => performanceLogPolicyFactory.create().shouldEmitDetailedTiming());\n }\n}\n\nexport { ServerLogger } from \"./ServerLogger\";\n"],"mappings":";;;;;;;;AAgCA,IAAa,YAAb,MAAuB;CACrB,OAAe,UAAU;CACzB,OAAe,OAAyB;CACxC,OAAe,UAA4B;;CAG3C,OAAO,SAAe;AACpB,MAAI,KAAK,QAAS;AAClB,OAAK,UAAU;AACf,OAAK,OAAO;GAAE,MAAM;GAAQ,SAAS,QAAQ,OAAO,QAAQ;GAAE,OAAO;GAAM,UAAU,EAAE;GAAE,QAAQ;GAAM;AACvG,OAAK,UAAU,KAAK;;CAGtB,OAAO,YAAqB;AAC1B,SAAO,KAAK;;;CAId,aAAa,aAAgB,MAAc,IAAkC;AAC3E,MAAI,CAAC,KAAK,WAAW,CAAC,KAAK,QACzB,QAAO,MAAM,IAAI;EAEnB,MAAM,OAAO,KAAK,UAAU,KAAK;AACjC,MAAI;AACF,UAAO,MAAM,IAAI;YACT;AACR,QAAK,SAAS,KAAK;;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