alchemy 2.0.0-beta.84 → 2.0.0-beta.85
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/THIRD_PARTY_LICENSES.md +2 -2
- package/bin/cli.js +14 -6
- package/bin/register-oxc.js +16 -12
- package/lib/AdoptPolicy.d.ts +73 -0
- package/lib/AdoptPolicy.d.ts.map +1 -1
- package/lib/AdoptPolicy.js +54 -0
- package/lib/AdoptPolicy.js.map +1 -1
- package/lib/Alchemist/AuthRegistry.d.ts +31 -0
- package/lib/Alchemist/AuthRegistry.d.ts.map +1 -0
- package/lib/Alchemist/AuthRegistry.js +95 -0
- package/lib/Alchemist/AuthRegistry.js.map +1 -0
- package/lib/Alchemist/Drift.d.ts +70 -0
- package/lib/Alchemist/Drift.d.ts.map +1 -0
- package/lib/Alchemist/Drift.js +54 -0
- package/lib/Alchemist/Drift.js.map +1 -0
- package/lib/Alchemist/Entrypoint.d.ts +27 -3
- package/lib/Alchemist/Entrypoint.d.ts.map +1 -1
- package/lib/Alchemist/Entrypoint.js +34 -3
- package/lib/Alchemist/Entrypoint.js.map +1 -1
- package/lib/Alchemist/Errors.d.ts +1 -1
- package/lib/Alchemist/Errors.d.ts.map +1 -1
- package/lib/Alchemist/Errors.js +1 -1
- package/lib/Alchemist/Errors.js.map +1 -1
- package/lib/Alchemist/Logs.d.ts +46 -0
- package/lib/Alchemist/Logs.d.ts.map +1 -0
- package/lib/Alchemist/{routes/logs.js → Logs.js} +21 -26
- package/lib/Alchemist/Logs.js.map +1 -0
- package/lib/Alchemist/Nuke.d.ts +69 -0
- package/lib/Alchemist/Nuke.d.ts.map +1 -0
- package/lib/Alchemist/Nuke.js +35 -0
- package/lib/Alchemist/Nuke.js.map +1 -0
- package/lib/Alchemist/Operations.d.ts +168 -0
- package/lib/Alchemist/Operations.d.ts.map +1 -0
- package/lib/Alchemist/Operations.js +165 -0
- package/lib/Alchemist/Operations.js.map +1 -0
- package/lib/Alchemist/Profile.d.ts +132 -0
- package/lib/Alchemist/Profile.d.ts.map +1 -0
- package/lib/Alchemist/{routes/profile.js → Profile.js} +20 -21
- package/lib/Alchemist/Profile.js.map +1 -0
- package/lib/Alchemist/{routes/provider.d.ts → Provider.d.ts} +4 -4
- package/lib/Alchemist/Provider.d.ts.map +1 -0
- package/lib/Alchemist/{routes/provider.js → Provider.js} +7 -6
- package/lib/Alchemist/Provider.js.map +1 -0
- package/lib/Alchemist/Runtime.d.ts +10 -6
- package/lib/Alchemist/Runtime.d.ts.map +1 -1
- package/lib/Alchemist/Runtime.js +38 -2
- package/lib/Alchemist/Runtime.js.map +1 -1
- package/lib/Alchemist/{routes/state.d.ts → State.d.ts} +36 -16
- package/lib/Alchemist/State.d.ts.map +1 -0
- package/lib/Alchemist/{routes/state.js → State.js} +50 -15
- package/lib/Alchemist/State.js.map +1 -0
- package/lib/Alchemist/index.d.ts +11 -10
- package/lib/Alchemist/index.d.ts.map +1 -1
- package/lib/Alchemist/index.js +10 -9
- package/lib/Alchemist/index.js.map +1 -1
- package/lib/Apply.d.ts +2 -8
- package/lib/Apply.d.ts.map +1 -1
- package/lib/Apply.js +364 -184
- package/lib/Apply.js.map +1 -1
- package/lib/Auth/AuthProvider.d.ts +24 -11
- package/lib/Auth/AuthProvider.d.ts.map +1 -1
- package/lib/Auth/AuthProvider.js +28 -12
- package/lib/Auth/AuthProvider.js.map +1 -1
- package/lib/Auth/BrowserOAuth.d.ts +6 -8
- package/lib/Auth/BrowserOAuth.d.ts.map +1 -1
- package/lib/Auth/BrowserOAuth.js +25 -41
- package/lib/Auth/BrowserOAuth.js.map +1 -1
- package/lib/Auth/Credentials.d.ts.map +1 -1
- package/lib/Auth/Credentials.js +2 -2
- package/lib/Auth/Credentials.js.map +1 -1
- package/lib/Auth/Demand.d.ts +4 -4
- package/lib/Auth/Demand.d.ts.map +1 -1
- package/lib/Auth/Demand.js +16 -10
- package/lib/Auth/Demand.js.map +1 -1
- package/lib/Auth/Env.d.ts +2 -1
- package/lib/Auth/Env.d.ts.map +1 -1
- package/lib/Auth/Env.js +4 -2
- package/lib/Auth/Env.js.map +1 -1
- package/lib/Auth/Inspect.d.ts +2 -2
- package/lib/Auth/Inspect.d.ts.map +1 -1
- package/lib/Auth/Inspect.js +3 -1
- package/lib/Auth/Inspect.js.map +1 -1
- package/lib/Auth/Lock.d.ts.map +1 -1
- package/lib/Auth/Lock.js +4 -8
- package/lib/Auth/Lock.js.map +1 -1
- package/lib/Auth/OAuthFlow.d.ts +3 -12
- package/lib/Auth/OAuthFlow.d.ts.map +1 -1
- package/lib/Auth/OAuthFlow.js +7 -17
- package/lib/Auth/OAuthFlow.js.map +1 -1
- package/lib/Auth/Paths.d.ts +2 -1
- package/lib/Auth/Paths.d.ts.map +1 -1
- package/lib/Auth/Paths.js +3 -2
- package/lib/Auth/Paths.js.map +1 -1
- package/lib/Auth/Profile.d.ts +10 -0
- package/lib/Auth/Profile.d.ts.map +1 -1
- package/lib/Auth/Profile.js +19 -2
- package/lib/Auth/Profile.js.map +1 -1
- package/lib/Auth/Registry.d.ts +20 -0
- package/lib/Auth/Registry.d.ts.map +1 -0
- package/lib/Auth/Registry.js +17 -0
- package/lib/Auth/Registry.js.map +1 -0
- package/lib/Auth/Resolve.d.ts +34 -2
- package/lib/Auth/Resolve.d.ts.map +1 -1
- package/lib/Auth/Resolve.js +51 -3
- package/lib/Auth/Resolve.js.map +1 -1
- package/lib/Auth/StoredAuthProvider.d.ts +1 -1
- package/lib/Auth/StoredAuthProvider.d.ts.map +1 -1
- package/lib/Auth/StoredAuthProvider.js +1 -2
- package/lib/Auth/StoredAuthProvider.js.map +1 -1
- package/lib/Binding.d.ts.map +1 -1
- package/lib/Binding.js +3 -1
- package/lib/Binding.js.map +1 -1
- package/lib/Bundle/Bundle.d.ts +5 -0
- package/lib/Bundle/Bundle.d.ts.map +1 -1
- package/lib/Bundle/Bundle.js +36 -6
- package/lib/Bundle/Bundle.js.map +1 -1
- package/lib/Bundle/NamespaceImportPlugin.d.ts +55 -0
- package/lib/Bundle/NamespaceImportPlugin.d.ts.map +1 -0
- package/lib/Bundle/NamespaceImportPlugin.js +226 -0
- package/lib/Bundle/NamespaceImportPlugin.js.map +1 -0
- package/lib/Bundle/index.d.ts +1 -0
- package/lib/Bundle/index.d.ts.map +1 -1
- package/lib/Bundle/index.js +1 -0
- package/lib/Bundle/index.js.map +1 -1
- package/lib/Cli/Format.d.ts.map +1 -1
- package/lib/Cli/Format.js +2 -1
- package/lib/Cli/Format.js.map +1 -1
- package/lib/Cli/GlobalLog.d.ts +72 -26
- package/lib/Cli/GlobalLog.d.ts.map +1 -1
- package/lib/Cli/GlobalLog.js +151 -59
- package/lib/Cli/GlobalLog.js.map +1 -1
- package/lib/Cli/LoggingCli.d.ts.map +1 -1
- package/lib/Cli/LoggingCli.js +24 -18
- package/lib/Cli/LoggingCli.js.map +1 -1
- package/lib/Cli/PlainCliFormatter.d.ts.map +1 -1
- package/lib/Cli/PlainCliFormatter.js +4 -1
- package/lib/Cli/PlainCliFormatter.js.map +1 -1
- package/lib/Cli/Present.d.ts +14 -0
- package/lib/Cli/Present.d.ts.map +1 -0
- package/lib/Cli/Present.js +22 -0
- package/lib/Cli/Present.js.map +1 -0
- package/lib/Cli/SigilRenderer.d.ts +58 -0
- package/lib/Cli/SigilRenderer.d.ts.map +1 -0
- package/lib/Cli/SigilRenderer.js +39 -0
- package/lib/Cli/SigilRenderer.js.map +1 -0
- package/lib/Cli/checkVersion.d.ts +11 -14
- package/lib/Cli/checkVersion.d.ts.map +1 -1
- package/lib/Cli/checkVersion.js +19 -77
- package/lib/Cli/checkVersion.js.map +1 -1
- package/lib/Cli/commands/confirm.d.ts +2 -2
- package/lib/Cli/commands/confirm.d.ts.map +1 -1
- package/lib/Cli/commands/confirm.js +3 -3
- package/lib/Cli/commands/confirm.js.map +1 -1
- package/lib/Cli/commands/deploy.d.ts +4 -4
- package/lib/Cli/commands/deploy.d.ts.map +1 -1
- package/lib/Cli/commands/deploy.js +40 -39
- package/lib/Cli/commands/deploy.js.map +1 -1
- package/lib/Cli/commands/dev.d.ts.map +1 -1
- package/lib/Cli/commands/dev.js +41 -3
- package/lib/Cli/commands/dev.js.map +1 -1
- package/lib/Cli/commands/drift.d.ts +2 -2
- package/lib/Cli/commands/drift.d.ts.map +1 -1
- package/lib/Cli/commands/drift.js +14 -13
- package/lib/Cli/commands/drift.js.map +1 -1
- package/lib/Cli/commands/errors.d.ts.map +1 -1
- package/lib/Cli/commands/errors.js +2 -1
- package/lib/Cli/commands/errors.js.map +1 -1
- package/lib/Cli/commands/instrument.d.ts +15 -5
- package/lib/Cli/commands/instrument.d.ts.map +1 -1
- package/lib/Cli/commands/instrument.js +33 -8
- package/lib/Cli/commands/instrument.js.map +1 -1
- package/lib/Cli/commands/logs.d.ts +1 -1
- package/lib/Cli/commands/logs.d.ts.map +1 -1
- package/lib/Cli/commands/logs.js +22 -22
- package/lib/Cli/commands/logs.js.map +1 -1
- package/lib/Cli/commands/nuke.d.ts +3 -2
- package/lib/Cli/commands/nuke.d.ts.map +1 -1
- package/lib/Cli/commands/nuke.js +19 -17
- package/lib/Cli/commands/nuke.js.map +1 -1
- package/lib/Cli/commands/profile/commands.d.ts +3 -2
- package/lib/Cli/commands/profile/commands.d.ts.map +1 -1
- package/lib/Cli/commands/profile/commands.js +26 -27
- package/lib/Cli/commands/profile/commands.js.map +1 -1
- package/lib/Cli/commands/profile/flows.d.ts +6 -5
- package/lib/Cli/commands/profile/flows.d.ts.map +1 -1
- package/lib/Cli/commands/profile/flows.js +19 -17
- package/lib/Cli/commands/profile/flows.js.map +1 -1
- package/lib/Cli/commands/profile/hub.d.ts +1 -2
- package/lib/Cli/commands/profile/hub.d.ts.map +1 -1
- package/lib/Cli/commands/profile/hub.js +15 -17
- package/lib/Cli/commands/profile/hub.js.map +1 -1
- package/lib/Cli/commands/provider.d.ts +3 -1
- package/lib/Cli/commands/provider.d.ts.map +1 -1
- package/lib/Cli/commands/provider.js +4 -4
- package/lib/Cli/commands/provider.js.map +1 -1
- package/lib/Cli/commands/render.d.ts +2 -4
- package/lib/Cli/commands/render.d.ts.map +1 -1
- package/lib/Cli/commands/render.js +33 -56
- package/lib/Cli/commands/render.js.map +1 -1
- package/lib/Cli/commands/state.d.ts +1 -2
- package/lib/Cli/commands/state.d.ts.map +1 -1
- package/lib/Cli/commands/state.js +74 -27
- package/lib/Cli/commands/state.js.map +1 -1
- package/lib/Cli/components/capabilities.d.ts +4 -0
- package/lib/Cli/components/capabilities.d.ts.map +1 -0
- package/lib/Cli/components/capabilities.js +18 -0
- package/lib/Cli/components/capabilities.js.map +1 -0
- package/lib/Cli/components/types.d.ts +2 -81
- package/lib/Cli/components/types.d.ts.map +1 -1
- package/lib/Cli/components/types.js +1 -3
- package/lib/Cli/components/types.js.map +1 -1
- package/lib/Cli/components/ui/Environment.d.ts +3 -3
- package/lib/Cli/components/ui/Environment.d.ts.map +1 -1
- package/lib/Cli/components/ui/Environment.js.map +1 -1
- package/lib/Cli/components/ui/Interactive.d.ts +17 -4
- package/lib/Cli/components/ui/Interactive.d.ts.map +1 -1
- package/lib/Cli/components/ui/Interactive.js +7 -11
- package/lib/Cli/components/ui/Interactive.js.map +1 -1
- package/lib/Cli/components/ui/Layout.d.ts +1 -1
- package/lib/Cli/components/ui/Layout.d.ts.map +1 -1
- package/lib/Cli/components/ui/Layout.js +1 -1
- package/lib/Cli/components/ui/Layout.js.map +1 -1
- package/lib/Cli/components/ui/Typography.d.ts +1 -1
- package/lib/Cli/components/ui/Typography.d.ts.map +1 -1
- package/lib/Cli/components/ui/Typography.js +1 -1
- package/lib/Cli/components/ui/Typography.js.map +1 -1
- package/lib/Cli/components/ui/index.d.ts +2 -2
- package/lib/Cli/components/ui/index.js +2 -2
- package/lib/Cli/components/view/ApprovePlan.d.ts +1 -1
- package/lib/Cli/components/view/ApprovePlan.d.ts.map +1 -1
- package/lib/Cli/components/view/ApprovePlan.js +2 -1
- package/lib/Cli/components/view/ApprovePlan.js.map +1 -1
- package/lib/Cli/components/view/Format.d.ts +5 -0
- package/lib/Cli/components/view/Format.d.ts.map +1 -0
- package/lib/Cli/components/view/Format.js +39 -0
- package/lib/Cli/components/view/Format.js.map +1 -0
- package/lib/Cli/components/view/Help.d.ts +2 -2
- package/lib/Cli/components/view/Help.d.ts.map +1 -1
- package/lib/Cli/components/view/Help.js +7 -5
- package/lib/Cli/components/view/Help.js.map +1 -1
- package/lib/Cli/components/view/Logo.js +1 -1
- package/lib/Cli/components/view/Logo.js.map +1 -1
- package/lib/Cli/components/view/Nuke.d.ts +8 -9
- package/lib/Cli/components/view/Nuke.d.ts.map +1 -1
- package/lib/Cli/components/view/Nuke.js +49 -52
- package/lib/Cli/components/view/Nuke.js.map +1 -1
- package/lib/Cli/components/view/PlanDecision.d.ts +1 -1
- package/lib/Cli/components/view/PlanDecision.d.ts.map +1 -1
- package/lib/Cli/components/view/PlanDecision.js +1 -1
- package/lib/Cli/components/view/PlanDecision.js.map +1 -1
- package/lib/Cli/components/view/PlanRow.js +1 -1
- package/lib/Cli/components/view/PlanRow.js.map +1 -1
- package/lib/Cli/components/view/PlanTree.d.ts +1 -1
- package/lib/Cli/components/view/PlanTree.d.ts.map +1 -1
- package/lib/Cli/components/view/PlanTree.js +1 -1
- package/lib/Cli/components/view/PlanView.js +1 -1
- package/lib/Cli/components/view/PlanView.js.map +1 -1
- package/lib/Cli/components/view/Profile.d.ts +1 -1
- package/lib/Cli/components/view/Profile.js +2 -2
- package/lib/Cli/components/view/Profile.js.map +1 -1
- package/lib/Cli/components/view/ProfileDashboard.d.ts +4 -4
- package/lib/Cli/components/view/ProfileDashboard.d.ts.map +1 -1
- package/lib/Cli/components/view/ProfileDashboard.js +9 -8
- package/lib/Cli/components/view/ProfileDashboard.js.map +1 -1
- package/lib/Cli/components/view/Prompts.d.ts +3 -3
- package/lib/Cli/components/view/Prompts.d.ts.map +1 -1
- package/lib/Cli/components/view/Prompts.js +11 -18
- package/lib/Cli/components/view/Prompts.js.map +1 -1
- package/lib/Cli/components/view/Runtime.d.ts +5 -5
- package/lib/Cli/components/view/Runtime.d.ts.map +1 -1
- package/lib/Cli/components/view/Runtime.js +136 -219
- package/lib/Cli/components/view/Runtime.js.map +1 -1
- package/lib/Cli/components/view/SigilCli.d.ts +2 -2
- package/lib/Cli/components/view/SigilCli.d.ts.map +1 -1
- package/lib/Cli/components/view/SigilCli.js +7 -7
- package/lib/Cli/components/view/SigilCli.js.map +1 -1
- package/lib/Cli/components/view/StateExplorer.d.ts +1 -1
- package/lib/Cli/components/view/StateExplorer.d.ts.map +1 -1
- package/lib/Cli/components/view/StateExplorer.js +2 -1
- package/lib/Cli/components/view/StateExplorer.js.map +1 -1
- package/lib/Cli/components/view/statusStyle.d.ts +2 -2
- package/lib/Cli/components/view/statusStyle.d.ts.map +1 -1
- package/lib/Cli/components/view/statusStyle.js +1 -1
- package/lib/Cli/components/view/statusStyle.js.map +1 -1
- package/lib/Cli/exec.d.ts +6 -1
- package/lib/Cli/exec.d.ts.map +1 -1
- package/lib/Cli/exec.js +29 -34
- package/lib/Cli/exec.js.map +1 -1
- package/lib/Cli/main.d.ts.map +1 -1
- package/lib/Cli/main.js +35 -26
- package/lib/Cli/main.js.map +1 -1
- package/lib/Cli/selectCli.d.ts +2 -2
- package/lib/Cli/selectCli.d.ts.map +1 -1
- package/lib/Cli/selectCli.js +2 -2
- package/lib/Cli/selectCli.js.map +1 -1
- package/lib/Command/Command.js +1 -1
- package/lib/Command/Command.js.map +1 -1
- package/lib/Command/Dev.d.ts +58 -4
- package/lib/Command/Dev.d.ts.map +1 -1
- package/lib/Command/Dev.js +87 -30
- package/lib/Command/Dev.js.map +1 -1
- package/lib/Command/Local.d.ts +1 -1
- package/lib/Command/Memo.js +1 -1
- package/lib/Command/Memo.js.map +1 -1
- package/lib/Command/Providers.d.ts +1 -1
- package/lib/Command/Providers.d.ts.map +1 -1
- package/lib/Contributions.d.ts +2 -3
- package/lib/Contributions.d.ts.map +1 -1
- package/lib/Contributions.js +38 -6
- package/lib/Contributions.js.map +1 -1
- package/lib/DNS/Adapter.d.ts +204 -0
- package/lib/DNS/Adapter.d.ts.map +1 -0
- package/lib/DNS/Adapter.js +112 -0
- package/lib/DNS/Adapter.js.map +1 -0
- package/lib/DNS/index.d.ts +2 -0
- package/lib/DNS/index.d.ts.map +1 -0
- package/lib/DNS/index.js +2 -0
- package/lib/DNS/index.js.map +1 -0
- package/lib/Deploy.d.ts +7 -2
- package/lib/Deploy.d.ts.map +1 -1
- package/lib/Deploy.js +8 -3
- package/lib/Deploy.js.map +1 -1
- package/lib/Destroy.d.ts +5 -8
- package/lib/Destroy.d.ts.map +1 -1
- package/lib/Destroy.js +10 -7
- package/lib/Destroy.js.map +1 -1
- package/lib/Diff.d.ts.map +1 -1
- package/lib/Diff.js +14 -4
- package/lib/Diff.js.map +1 -1
- package/lib/Drift.d.ts +7 -7
- package/lib/Drift.d.ts.map +1 -1
- package/lib/Drift.js +184 -101
- package/lib/Drift.js.map +1 -1
- package/lib/EvalStack.d.ts +23 -0
- package/lib/EvalStack.d.ts.map +1 -0
- package/lib/EvalStack.js +47 -0
- package/lib/EvalStack.js.map +1 -0
- package/lib/Events.d.ts +210 -0
- package/lib/Events.d.ts.map +1 -0
- package/lib/Events.js +244 -0
- package/lib/Events.js.map +1 -0
- package/lib/Interaction.d.ts +159 -48
- package/lib/Interaction.d.ts.map +1 -1
- package/lib/Interaction.js +139 -58
- package/lib/Interaction.js.map +1 -1
- package/lib/Local/LocalProvider.d.ts.map +1 -1
- package/lib/Local/LocalProvider.js +31 -9
- package/lib/Local/LocalProvider.js.map +1 -1
- package/lib/Local/RpcProvider.d.ts.map +1 -1
- package/lib/Local/RpcProvider.js +10 -1
- package/lib/Local/RpcProvider.js.map +1 -1
- package/lib/Local/RpcProviderProxy.d.ts +16 -0
- package/lib/Local/RpcProviderProxy.d.ts.map +1 -1
- package/lib/Local/RpcProviderProxy.js +19 -10
- package/lib/Local/RpcProviderProxy.js.map +1 -1
- package/lib/Local/RpcSerialization.d.ts +3 -2
- package/lib/Local/RpcSerialization.d.ts.map +1 -1
- package/lib/Local/RpcSerialization.js +13 -10
- package/lib/Local/RpcSerialization.js.map +1 -1
- package/lib/Local/RpcServer.d.ts +2 -1
- package/lib/Local/RpcServer.d.ts.map +1 -1
- package/lib/Local/RpcServer.js +19 -14
- package/lib/Local/RpcServer.js.map +1 -1
- package/lib/Local/RpcServerBun.d.ts.map +1 -1
- package/lib/Local/RpcServerBun.js +8 -4
- package/lib/Local/RpcServerBun.js.map +1 -1
- package/lib/Local/RpcServerEnvironment.d.ts +2 -3
- package/lib/Local/RpcServerEnvironment.d.ts.map +1 -1
- package/lib/Local/RpcServerEnvironment.js +2 -2
- package/lib/Local/RpcServerEnvironment.js.map +1 -1
- package/lib/Local/RpcServerNode.d.ts.map +1 -1
- package/lib/Local/RpcServerNode.js +5 -1
- package/lib/Local/RpcServerNode.js.map +1 -1
- package/lib/Local/RpcServerSession.d.ts +1 -1
- package/lib/Local/RpcServerSession.d.ts.map +1 -1
- package/lib/Local/RpcServerSession.js.map +1 -1
- package/lib/Local/RpcSpawner.d.ts +6 -8
- package/lib/Local/RpcSpawner.d.ts.map +1 -1
- package/lib/Local/RpcSpawner.js +45 -36
- package/lib/Local/RpcSpawner.js.map +1 -1
- package/lib/Local/Sidecar.d.ts +23 -0
- package/lib/Local/Sidecar.d.ts.map +1 -1
- package/lib/Local/Sidecar.js +14 -9
- package/lib/Local/Sidecar.js.map +1 -1
- package/lib/Nuke.d.ts +5 -23
- package/lib/Nuke.d.ts.map +1 -1
- package/lib/Nuke.js +48 -13
- package/lib/Nuke.js.map +1 -1
- package/lib/Output.d.ts +19 -1
- package/lib/Output.d.ts.map +1 -1
- package/lib/Output.js +96 -3
- package/lib/Output.js.map +1 -1
- package/lib/Plan.d.ts +5 -1
- package/lib/Plan.d.ts.map +1 -1
- package/lib/Plan.js +111 -33
- package/lib/Plan.js.map +1 -1
- package/lib/Platform.d.ts.map +1 -1
- package/lib/Platform.js +31 -7
- package/lib/Platform.js.map +1 -1
- package/lib/Provider.d.ts +45 -0
- package/lib/Provider.d.ts.map +1 -1
- package/lib/Provider.js +2 -2
- package/lib/Provider.js.map +1 -1
- package/lib/Report.d.ts +17 -195
- package/lib/Report.d.ts.map +1 -1
- package/lib/Report.js +39 -12
- package/lib/Report.js.map +1 -1
- package/lib/Runtime/ManagedHttpShutdown.d.ts +17 -0
- package/lib/Runtime/ManagedHttpShutdown.d.ts.map +1 -1
- package/lib/Runtime/ManagedHttpShutdown.js +11 -2
- package/lib/Runtime/ManagedHttpShutdown.js.map +1 -1
- package/lib/RuntimeContext.js +1 -1
- package/lib/RuntimeContext.js.map +1 -1
- package/lib/Stack.d.ts +49 -29
- package/lib/Stack.d.ts.map +1 -1
- package/lib/Stack.js +25 -31
- package/lib/Stack.js.map +1 -1
- package/lib/State/BucketState.d.ts.map +1 -1
- package/lib/State/BucketState.js +43 -14
- package/lib/State/BucketState.js.map +1 -1
- package/lib/State/LocalState.d.ts.map +1 -1
- package/lib/State/LocalState.js +3 -3
- package/lib/State/LocalState.js.map +1 -1
- package/lib/State/Provisioning.d.ts +5 -0
- package/lib/State/Provisioning.d.ts.map +1 -1
- package/lib/State/Provisioning.js +3 -1
- package/lib/State/Provisioning.js.map +1 -1
- package/lib/State/ResourceState.d.ts +2 -0
- package/lib/State/ResourceState.d.ts.map +1 -1
- package/lib/State/State.d.ts +26 -0
- package/lib/State/State.d.ts.map +1 -1
- package/lib/State/StateEncoding.d.ts +7 -0
- package/lib/State/StateEncoding.d.ts.map +1 -1
- package/lib/State/StateEncoding.js +19 -0
- package/lib/State/StateEncoding.js.map +1 -1
- package/lib/State/index.js +2 -2
- package/lib/State/index.js.map +1 -1
- package/lib/Telemetry/Layer.d.ts +2 -5
- package/lib/Telemetry/Layer.d.ts.map +1 -1
- package/lib/Telemetry/Layer.js +3 -23
- package/lib/Telemetry/Layer.js.map +1 -1
- package/lib/Telemetry/Metrics.d.ts +1 -1
- package/lib/Telemetry/Metrics.d.ts.map +1 -1
- package/lib/TelemetryRelay.js +1 -1
- package/lib/TelemetryRelay.js.map +1 -1
- package/lib/TelemetryRuntime.d.ts +1 -1
- package/lib/TelemetryRuntime.d.ts.map +1 -1
- package/lib/TelemetryRuntime.js +4 -3
- package/lib/TelemetryRuntime.js.map +1 -1
- package/lib/Util/ConsoleSink.d.ts +23 -2
- package/lib/Util/ConsoleSink.d.ts.map +1 -1
- package/lib/Util/ConsoleSink.js +54 -14
- package/lib/Util/ConsoleSink.js.map +1 -1
- package/lib/Util/LogAnnotation.d.ts +19 -0
- package/lib/Util/LogAnnotation.d.ts.map +1 -0
- package/lib/Util/LogAnnotation.js +19 -0
- package/lib/Util/LogAnnotation.js.map +1 -0
- package/lib/Util/LogRecord.d.ts +281 -0
- package/lib/Util/LogRecord.d.ts.map +1 -0
- package/lib/Util/LogRecord.js +267 -0
- package/lib/Util/LogRecord.js.map +1 -0
- package/lib/Util/Node.d.ts +9 -0
- package/lib/Util/Node.d.ts.map +1 -1
- package/lib/Util/Node.js +10 -6
- package/lib/Util/Node.js.map +1 -1
- package/lib/Util/PlatformServices.d.ts +3 -2
- package/lib/Util/PlatformServices.d.ts.map +1 -1
- package/lib/Util/PlatformServices.js +6 -2
- package/lib/Util/PlatformServices.js.map +1 -1
- package/lib/Util/ResourceOutput.d.ts +18 -10
- package/lib/Util/ResourceOutput.d.ts.map +1 -1
- package/lib/Util/ResourceOutput.js +22 -23
- package/lib/Util/ResourceOutput.js.map +1 -1
- package/lib/Util/Shutdown.d.ts +10 -0
- package/lib/Util/Shutdown.d.ts.map +1 -0
- package/lib/Util/Shutdown.js +32 -0
- package/lib/Util/Shutdown.js.map +1 -0
- package/lib/Util/Terminal.d.ts +2 -4
- package/lib/Util/Terminal.d.ts.map +1 -1
- package/lib/Util/Terminal.js +3 -11
- package/lib/Util/Terminal.js.map +1 -1
- package/lib/Util/TraceParent.d.ts +32 -0
- package/lib/Util/TraceParent.d.ts.map +1 -0
- package/lib/Util/TraceParent.js +42 -0
- package/lib/Util/TraceParent.js.map +1 -0
- package/lib/Util/base64.d.ts +7 -0
- package/lib/Util/base64.d.ts.map +1 -0
- package/lib/Util/base64.js +24 -0
- package/lib/Util/base64.js.map +1 -0
- package/lib/Util/cached-function.d.ts +5 -0
- package/lib/Util/cached-function.d.ts.map +1 -1
- package/lib/Util/cached-function.js +13 -8
- package/lib/Util/cached-function.js.map +1 -1
- package/lib/Util/data.d.ts +1 -1
- package/lib/Util/data.d.ts.map +1 -1
- package/lib/Util/data.js +1 -1
- package/lib/Util/data.js.map +1 -1
- package/lib/Util/equal.d.ts.map +1 -1
- package/lib/Util/equal.js +3 -2
- package/lib/Util/equal.js.map +1 -1
- package/lib/Util/extraFiles.d.ts.map +1 -1
- package/lib/Util/extraFiles.js +5 -5
- package/lib/Util/extraFiles.js.map +1 -1
- package/lib/Util/interactive.js +1 -1
- package/lib/Website/AstroOutput.d.ts +42 -0
- package/lib/Website/AstroOutput.d.ts.map +1 -0
- package/lib/Website/AstroOutput.js +34 -0
- package/lib/Website/AstroOutput.js.map +1 -0
- package/lib/Website/FrontendCore.d.ts +1 -1
- package/lib/Workflows.d.ts +9 -0
- package/lib/Workflows.d.ts.map +1 -1
- package/lib/Workflows.js +8 -0
- package/lib/Workflows.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/package.json +21 -28
- package/src/AdoptPolicy.ts +76 -0
- package/src/Alchemist/AuthRegistry.ts +164 -0
- package/src/Alchemist/Drift.ts +103 -0
- package/src/Alchemist/Entrypoint.ts +51 -3
- package/src/Alchemist/Errors.ts +1 -1
- package/src/Alchemist/{routes/logs.ts → Logs.ts} +28 -30
- package/src/Alchemist/Nuke.ts +90 -0
- package/src/Alchemist/Operations.ts +309 -0
- package/src/Alchemist/{routes/profile.ts → Profile.ts} +22 -22
- package/src/Alchemist/{routes/provider.ts → Provider.ts} +7 -6
- package/src/Alchemist/Runtime.ts +46 -12
- package/src/Alchemist/{routes/state.ts → State.ts} +78 -21
- package/src/Alchemist/index.ts +32 -15
- package/src/Apply.ts +513 -274
- package/src/Auth/AuthProvider.ts +76 -23
- package/src/Auth/BrowserOAuth.ts +37 -60
- package/src/Auth/Credentials.ts +2 -4
- package/src/Auth/Demand.ts +27 -18
- package/src/Auth/Env.ts +13 -8
- package/src/Auth/Inspect.ts +5 -2
- package/src/Auth/Lock.ts +4 -8
- package/src/Auth/OAuthFlow.ts +12 -26
- package/src/Auth/Paths.ts +3 -2
- package/src/Auth/Profile.ts +30 -2
- package/src/Auth/Registry.ts +27 -0
- package/src/Auth/Resolve.ts +75 -3
- package/src/Auth/StoredAuthProvider.ts +1 -2
- package/src/Binding.ts +3 -4
- package/src/Bundle/Bundle.ts +58 -7
- package/src/Bundle/NamespaceImportPlugin.ts +259 -0
- package/src/Bundle/index.ts +1 -0
- package/src/Cli/Format.ts +2 -1
- package/src/Cli/GlobalLog.ts +206 -68
- package/src/Cli/LoggingCli.ts +33 -20
- package/src/Cli/PlainCliFormatter.ts +4 -1
- package/src/Cli/Present.ts +34 -0
- package/src/Cli/SigilRenderer.ts +75 -0
- package/src/Cli/checkVersion.ts +25 -78
- package/src/Cli/commands/confirm.ts +3 -3
- package/src/Cli/commands/deploy.ts +53 -44
- package/src/Cli/commands/dev.ts +65 -7
- package/src/Cli/commands/drift.ts +20 -16
- package/src/Cli/commands/errors.ts +2 -3
- package/src/Cli/commands/instrument.ts +39 -8
- package/src/Cli/commands/logs.ts +22 -30
- package/src/Cli/commands/nuke.ts +25 -26
- package/src/Cli/commands/profile/commands.ts +34 -34
- package/src/Cli/commands/profile/flows.ts +26 -20
- package/src/Cli/commands/profile/hub.ts +16 -18
- package/src/Cli/commands/provider.ts +4 -4
- package/src/Cli/commands/render.ts +43 -71
- package/src/Cli/commands/state.ts +113 -33
- package/src/Cli/components/capabilities.ts +20 -0
- package/src/Cli/components/types.ts +13 -99
- package/src/Cli/components/ui/Environment.tsx +5 -5
- package/src/Cli/components/ui/Interactive.tsx +24 -15
- package/src/Cli/components/ui/Layout.tsx +1 -1
- package/src/Cli/components/ui/Typography.tsx +1 -1
- package/src/Cli/components/ui/index.ts +2 -2
- package/src/Cli/components/view/ApprovePlan.tsx +2 -1
- package/src/Cli/components/view/Format.tsx +58 -0
- package/src/Cli/components/view/Help.tsx +14 -17
- package/src/Cli/components/view/Logo.tsx +1 -1
- package/src/Cli/components/view/Nuke.tsx +74 -49
- package/src/Cli/components/view/PlanDecision.tsx +1 -1
- package/src/Cli/components/view/PlanRow.tsx +1 -1
- package/src/Cli/components/view/PlanTree.ts +2 -2
- package/src/Cli/components/view/PlanView.tsx +2 -2
- package/src/Cli/components/view/Profile.tsx +2 -2
- package/src/Cli/components/view/ProfileDashboard.tsx +12 -11
- package/src/Cli/components/view/Prompts.tsx +37 -75
- package/src/Cli/components/view/Runtime.tsx +132 -238
- package/src/Cli/components/view/SigilCli.tsx +12 -12
- package/src/Cli/components/view/StateExplorer.tsx +2 -1
- package/src/Cli/components/view/statusStyle.ts +2 -2
- package/src/Cli/exec.ts +48 -41
- package/src/Cli/main.ts +52 -33
- package/src/Cli/selectCli.ts +3 -3
- package/src/Command/Command.ts +1 -1
- package/src/Command/Dev.ts +129 -36
- package/src/Command/Memo.ts +1 -1
- package/src/Contributions.ts +42 -8
- package/src/DNS/Adapter.ts +289 -0
- package/src/DNS/index.ts +1 -0
- package/src/Deploy.ts +11 -3
- package/src/Destroy.ts +19 -13
- package/src/Diff.ts +17 -4
- package/src/Drift.ts +256 -127
- package/src/EvalStack.ts +97 -0
- package/src/Events.ts +296 -0
- package/src/Interaction.ts +332 -97
- package/src/Local/LocalProvider.ts +40 -9
- package/src/Local/RpcProvider.ts +11 -1
- package/src/Local/RpcProviderProxy.ts +29 -21
- package/src/Local/RpcSerialization.ts +32 -17
- package/src/Local/RpcServer.ts +25 -17
- package/src/Local/RpcServerBun.ts +10 -6
- package/src/Local/RpcServerEnvironment.ts +2 -2
- package/src/Local/RpcServerNode.ts +8 -1
- package/src/Local/RpcServerSession.ts +2 -2
- package/src/Local/RpcSpawner.ts +61 -37
- package/src/Local/Sidecar.ts +10 -1
- package/src/Nuke.ts +66 -43
- package/src/Output.ts +120 -7
- package/src/Plan.ts +140 -52
- package/src/Platform.ts +47 -18
- package/src/Provider.ts +48 -3
- package/src/Report.ts +77 -275
- package/src/Runtime/ManagedHttpShutdown.ts +21 -4
- package/src/RuntimeContext.ts +1 -1
- package/src/Stack.ts +113 -135
- package/src/State/BucketState.ts +53 -21
- package/src/State/LocalState.ts +7 -9
- package/src/State/Provisioning.ts +8 -1
- package/src/State/ResourceState.ts +2 -0
- package/src/State/State.ts +30 -0
- package/src/State/StateEncoding.ts +22 -0
- package/src/State/index.ts +2 -2
- package/src/Telemetry/Layer.ts +3 -24
- package/src/Telemetry/Metrics.ts +1 -1
- package/src/TelemetryRelay.ts +1 -1
- package/src/TelemetryRuntime.ts +8 -8
- package/src/Util/ConsoleSink.ts +76 -13
- package/src/Util/LogAnnotation.ts +18 -0
- package/src/Util/LogRecord.ts +386 -0
- package/src/Util/Node.ts +20 -6
- package/src/Util/PlatformServices.ts +17 -4
- package/src/Util/ResourceOutput.ts +26 -25
- package/src/Util/Shutdown.ts +52 -0
- package/src/Util/Terminal.ts +3 -20
- package/src/Util/TraceParent.ts +70 -0
- package/src/Util/base64.ts +22 -0
- package/src/Util/cached-function.ts +30 -19
- package/src/Util/data.ts +2 -2
- package/src/Util/equal.ts +3 -2
- package/src/Util/extraFiles.ts +9 -8
- package/src/Util/interactive.ts +1 -1
- package/src/Website/AstroOutput.ts +83 -0
- package/src/Workflows.ts +11 -0
- package/src/index.ts +1 -0
- package/lib/Alchemist/Progress.d.ts +0 -16
- package/lib/Alchemist/Progress.d.ts.map +0 -1
- package/lib/Alchemist/Progress.js +0 -123
- package/lib/Alchemist/Progress.js.map +0 -1
- package/lib/Alchemist/Session.d.ts +0 -116
- package/lib/Alchemist/Session.d.ts.map +0 -1
- package/lib/Alchemist/Session.js +0 -212
- package/lib/Alchemist/Session.js.map +0 -1
- package/lib/Alchemist/routes/drift.d.ts +0 -55
- package/lib/Alchemist/routes/drift.d.ts.map +0 -1
- package/lib/Alchemist/routes/drift.js +0 -52
- package/lib/Alchemist/routes/drift.js.map +0 -1
- package/lib/Alchemist/routes/logs.d.ts +0 -41
- package/lib/Alchemist/routes/logs.d.ts.map +0 -1
- package/lib/Alchemist/routes/logs.js.map +0 -1
- package/lib/Alchemist/routes/nuke.d.ts +0 -46
- package/lib/Alchemist/routes/nuke.d.ts.map +0 -1
- package/lib/Alchemist/routes/nuke.js +0 -80
- package/lib/Alchemist/routes/nuke.js.map +0 -1
- package/lib/Alchemist/routes/profile.d.ts +0 -133
- package/lib/Alchemist/routes/profile.d.ts.map +0 -1
- package/lib/Alchemist/routes/profile.js.map +0 -1
- package/lib/Alchemist/routes/provider.d.ts.map +0 -1
- package/lib/Alchemist/routes/provider.js.map +0 -1
- package/lib/Alchemist/routes/stack.d.ts +0 -95
- package/lib/Alchemist/routes/stack.d.ts.map +0 -1
- package/lib/Alchemist/routes/stack.js +0 -73
- package/lib/Alchemist/routes/stack.js.map +0 -1
- package/lib/Alchemist/routes/state.d.ts.map +0 -1
- package/lib/Alchemist/routes/state.js.map +0 -1
- package/lib/Cli/CliKit/CliKit.d.ts +0 -92
- package/lib/Cli/CliKit/CliKit.d.ts.map +0 -1
- package/lib/Cli/CliKit/CliKit.js +0 -27
- package/lib/Cli/CliKit/CliKit.js.map +0 -1
- package/lib/Cli/CliKit/index.d.ts +0 -9
- package/lib/Cli/CliKit/index.d.ts.map +0 -1
- package/lib/Cli/CliKit/index.js +0 -9
- package/lib/Cli/CliKit/index.js.map +0 -1
- package/lib/Cli/CliKit/interaction.d.ts +0 -13
- package/lib/Cli/CliKit/interaction.d.ts.map +0 -1
- package/lib/Cli/CliKit/interaction.js +0 -17
- package/lib/Cli/CliKit/interaction.js.map +0 -1
- package/lib/Cli/CliKit/layer.d.ts +0 -7
- package/lib/Cli/CliKit/layer.d.ts.map +0 -1
- package/lib/Cli/CliKit/layer.js +0 -33
- package/lib/Cli/CliKit/layer.js.map +0 -1
- package/lib/Local/DevLog.d.ts +0 -32
- package/lib/Local/DevLog.d.ts.map +0 -1
- package/lib/Local/DevLog.js +0 -112
- package/lib/Local/DevLog.js.map +0 -1
- package/lib/Test/Alchemy.d.ts +0 -79
- package/lib/Test/Alchemy.d.ts.map +0 -1
- package/lib/Test/Alchemy.js +0 -193
- package/lib/Test/Alchemy.js.map +0 -1
- package/lib/Test/Bun.d.ts +0 -69
- package/lib/Test/Bun.d.ts.map +0 -1
- package/lib/Test/Bun.js +0 -126
- package/lib/Test/Bun.js.map +0 -1
- package/lib/Test/Core.d.ts +0 -277
- package/lib/Test/Core.d.ts.map +0 -1
- package/lib/Test/Core.js +0 -362
- package/lib/Test/Core.js.map +0 -1
- package/lib/Test/Http.d.ts +0 -109
- package/lib/Test/Http.d.ts.map +0 -1
- package/lib/Test/Http.js +0 -123
- package/lib/Test/Http.js.map +0 -1
- package/lib/Test/TestState.d.ts +0 -12
- package/lib/Test/TestState.d.ts.map +0 -1
- package/lib/Test/TestState.js +0 -15
- package/lib/Test/TestState.js.map +0 -1
- package/lib/Test/Vitest.d.ts +0 -60
- package/lib/Test/Vitest.d.ts.map +0 -1
- package/lib/Test/Vitest.js +0 -132
- package/lib/Test/Vitest.js.map +0 -1
- package/lib/Test/index.d.ts +0 -3
- package/lib/Test/index.d.ts.map +0 -1
- package/lib/Test/index.js +0 -3
- package/lib/Test/index.js.map +0 -1
- package/lib/Util/FileLogger.d.ts +0 -7
- package/lib/Util/FileLogger.d.ts.map +0 -1
- package/lib/Util/FileLogger.js +0 -16
- package/lib/Util/FileLogger.js.map +0 -1
- package/src/Alchemist/Progress.ts +0 -167
- package/src/Alchemist/Session.ts +0 -415
- package/src/Alchemist/routes/drift.ts +0 -87
- package/src/Alchemist/routes/nuke.ts +0 -131
- package/src/Alchemist/routes/stack.ts +0 -173
- package/src/Cli/CliKit/CliKit.ts +0 -159
- package/src/Cli/CliKit/index.ts +0 -41
- package/src/Cli/CliKit/interaction.ts +0 -19
- package/src/Cli/CliKit/layer.ts +0 -44
- package/src/Local/DevLog.ts +0 -122
- package/src/Test/Alchemy.ts +0 -334
- package/src/Test/Bun.ts +0 -230
- package/src/Test/Core.ts +0 -785
- package/src/Test/Http.ts +0 -201
- package/src/Test/TestState.ts +0 -35
- package/src/Test/Vitest.ts +0 -239
- package/src/Test/index.ts +0 -2
- package/src/Util/FileLogger.ts +0 -20
package/src/Telemetry/Layer.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
3
3
|
import * as Layer from "effect/Layer";
|
|
4
|
-
import * as OtlpLogger from "effect/observability/OtlpLogger";
|
|
5
4
|
import * as OtlpMetrics from "effect/observability/OtlpMetrics";
|
|
6
5
|
import * as OtlpSerialization from "effect/observability/OtlpSerialization";
|
|
7
6
|
import * as OtlpTracer from "effect/observability/OtlpTracer";
|
|
@@ -10,7 +9,6 @@ import { collectAttributes, isTelemetryDisabled } from "./Attributes.ts";
|
|
|
10
9
|
|
|
11
10
|
const TRACES_URL = "https://otel.alchemy.run/v1/traces";
|
|
12
11
|
const METRICS_URL = "https://otel.alchemy.run/v1/metrics";
|
|
13
|
-
const LOGS_URL = "https://otel.alchemy.run/v1/logs";
|
|
14
12
|
|
|
15
13
|
const SERVICE_NAME = "alchemy-cli";
|
|
16
14
|
|
|
@@ -33,23 +31,7 @@ const buildOtlpLayer = (attrs: Record<string, unknown>): Layer.Layer<never, neve
|
|
|
33
31
|
resource,
|
|
34
32
|
exportInterval: "1 second",
|
|
35
33
|
});
|
|
36
|
-
|
|
37
|
-
// provide this layer *over* their terminal/file logger layer
|
|
38
|
-
// (`Layer.provideMerge(TelemetryLive, ConsoleLogLive)`), so the terminal
|
|
39
|
-
// logger has already replaced Effect's default stdout logger by the time
|
|
40
|
-
// this runs and the OTLP logger is simply added alongside it.
|
|
41
|
-
//
|
|
42
|
-
// `mergeWithExisting: false` here would make telemetry *replace* the
|
|
43
|
-
// terminal logger whenever this layer happened to be merged after it —
|
|
44
|
-
// exactly what silenced `alchemy dev`'s console output in the exec child.
|
|
45
|
-
const logger = OtlpLogger.layer({
|
|
46
|
-
url: LOGS_URL,
|
|
47
|
-
resource,
|
|
48
|
-
exportInterval: "1 second",
|
|
49
|
-
mergeWithExisting: true,
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
return Layer.mergeAll(tracer, metrics, logger).pipe(
|
|
34
|
+
return Layer.mergeAll(tracer, metrics).pipe(
|
|
53
35
|
Layer.provide(OtlpSerialization.layerJson),
|
|
54
36
|
Layer.provide(FetchHttpClient.layer),
|
|
55
37
|
);
|
|
@@ -61,11 +43,8 @@ const buildOtlpLayer = (attrs: Record<string, unknown>): Layer.Layer<never, neve
|
|
|
61
43
|
* {@link collectAttributes} as resource-level attributes so every signal
|
|
62
44
|
* carries user/project/runtime context.
|
|
63
45
|
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* `Layer.provideMerge(TelemetryLive, ConsoleLogLive)` — never as a sibling in
|
|
67
|
-
* a `Layer.mergeAll` (the last `CurrentLoggers` in a merge wins, silently
|
|
68
|
-
* dropping either the terminal output or the telemetry).
|
|
46
|
+
* Logs are never exported: they stay in the run log on disk, which users
|
|
47
|
+
* can attach to a support request.
|
|
69
48
|
*
|
|
70
49
|
* If the user has opted out (via `DO_NOT_TRACK`, `NO_TRACK`,
|
|
71
50
|
* `ALCHEMY_TELEMETRY_DISABLED`, or `~/.alchemy/telemetry-disabled`), this
|
package/src/Telemetry/Metrics.ts
CHANGED
|
@@ -151,7 +151,7 @@ export const recordStateStoreInit = <A extends { readonly id: string }, E, R>(
|
|
|
151
151
|
Effect.withSpan("state_store.init"),
|
|
152
152
|
);
|
|
153
153
|
|
|
154
|
-
export type ResourceOp = "precreate" | "create" | "update" | "delete" | "read";
|
|
154
|
+
export type ResourceOp = "observe" | "precreate" | "create" | "update" | "delete" | "read";
|
|
155
155
|
|
|
156
156
|
const elapsed = (startNs: bigint): Duration.Duration =>
|
|
157
157
|
Duration.nanos(process.hrtime.bigint() - startNs);
|
package/src/TelemetryRelay.ts
CHANGED
|
@@ -145,7 +145,7 @@ export const relay = <R = never>(
|
|
|
145
145
|
);
|
|
146
146
|
return response.status >= 200 && response.status < 300;
|
|
147
147
|
}).pipe(Effect.orElseSucceed(() => false));
|
|
148
|
-
const delivered = yield* Effect.
|
|
148
|
+
const delivered = yield* Effect.forEach(targets, forward, { concurrency: "unbounded" });
|
|
149
149
|
return delivered.some(Boolean)
|
|
150
150
|
? json(200, {})
|
|
151
151
|
: json(502, { error: "No destination accepted the batch" });
|
package/src/TelemetryRuntime.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as ConfigProvider from "effect/ConfigProvider";
|
|
|
2
2
|
import * as Context from "effect/Context";
|
|
3
3
|
import type * as Duration from "effect/Duration";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Formatter from "effect/Formatter";
|
|
5
6
|
import * as HttpClient from "effect/http/HttpClient";
|
|
6
7
|
import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
7
8
|
import * as Layer from "effect/Layer";
|
|
@@ -14,7 +15,6 @@ import * as Redacted from "effect/Redacted";
|
|
|
14
15
|
import * as Result from "effect/Result";
|
|
15
16
|
import type * as Scope from "effect/Scope";
|
|
16
17
|
import { unpackEnvValue } from "./RuntimeContext.ts";
|
|
17
|
-
import type { layer, layerOtlp } from "./Telemetry.ts";
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* The shape of the {@link Telemetry} reference: a Layer of telemetry
|
|
@@ -37,7 +37,7 @@ const readBoundValue = (key: string): Effect.Effect<unknown> =>
|
|
|
37
37
|
// directly instead of constructing a Config/Schema error for each absence.
|
|
38
38
|
Effect.orDie,
|
|
39
39
|
Effect.catchDefect((defect) =>
|
|
40
|
-
Predicate.isTagged(defect, "SourceError") ? Effect.
|
|
40
|
+
Predicate.isTagged(defect, "SourceError") ? Effect.undefined : Effect.die(defect),
|
|
41
41
|
),
|
|
42
42
|
Effect.map((node) => {
|
|
43
43
|
const raw = node?.value;
|
|
@@ -52,7 +52,7 @@ const readBoundValue = (key: string): Effect.Effect<unknown> =>
|
|
|
52
52
|
const readBound = (key: string): Effect.Effect<string | undefined> =>
|
|
53
53
|
readBoundValue(key).pipe(
|
|
54
54
|
Effect.map((inner) =>
|
|
55
|
-
inner === undefined ? undefined : typeof inner === "string" ? inner :
|
|
55
|
+
inner === undefined ? undefined : typeof inner === "string" ? inner : Formatter.format(inner),
|
|
56
56
|
),
|
|
57
57
|
);
|
|
58
58
|
|
|
@@ -198,8 +198,9 @@ const fanoutClient = (
|
|
|
198
198
|
return effect;
|
|
199
199
|
}
|
|
200
200
|
return Effect.gen(function* () {
|
|
201
|
-
const results = yield* Effect.
|
|
202
|
-
targets
|
|
201
|
+
const results = yield* Effect.forEach(
|
|
202
|
+
targets,
|
|
203
|
+
(target) =>
|
|
203
204
|
Effect.result(
|
|
204
205
|
base.execute(
|
|
205
206
|
request.pipe(
|
|
@@ -208,7 +209,6 @@ const fanoutClient = (
|
|
|
208
209
|
),
|
|
209
210
|
),
|
|
210
211
|
),
|
|
211
|
-
),
|
|
212
212
|
{ concurrency: "unbounded" },
|
|
213
213
|
);
|
|
214
214
|
const healthy = results.find(
|
|
@@ -411,8 +411,8 @@ const reference = Telemetry;
|
|
|
411
411
|
export const buildEventTelemetry = (
|
|
412
412
|
context: Context.Context<never>,
|
|
413
413
|
scope: Scope.Scope,
|
|
414
|
-
override?: TelemetryLayer
|
|
415
|
-
base?: TelemetryLayer
|
|
414
|
+
override?: TelemetryLayer,
|
|
415
|
+
base?: TelemetryLayer,
|
|
416
416
|
): Effect.Effect<Context.Context<never>> =>
|
|
417
417
|
Effect.suspend(() => {
|
|
418
418
|
const bound = base ?? Context.get(context, reference);
|
package/src/Util/ConsoleSink.ts
CHANGED
|
@@ -1,18 +1,81 @@
|
|
|
1
|
+
import { stripVTControlCharacters } from "node:util";
|
|
2
|
+
import * as Console from "effect/Console";
|
|
3
|
+
import * as DateTime from "effect/DateTime";
|
|
1
4
|
import * as Logger from "effect/Logger";
|
|
2
|
-
import
|
|
5
|
+
import type * as LogLevel from "effect/LogLevel";
|
|
6
|
+
import { LogAnnotation } from "./LogAnnotation.ts";
|
|
7
|
+
import { recordOf, safeStringify, severities } from "./LogRecord.ts";
|
|
8
|
+
import { formatResourceTag } from "./ResourceOutput.ts";
|
|
9
|
+
import { ansiFg, ANSI_RESET, colorsEnabled } from "./Terminal.ts";
|
|
10
|
+
import { theme } from "./Theme.ts";
|
|
3
11
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
12
|
+
export interface PrettyLoggerOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Color the prefix and resource tag, and keep the styling child processes
|
|
15
|
+
* wrote (vite, workerd); without colors their text is stripped.
|
|
16
|
+
* @default colorsEnabled()
|
|
17
|
+
*/
|
|
18
|
+
readonly colors?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const levelColor: Partial<Record<LogLevel.LogLevel, string>> = {
|
|
22
|
+
Fatal: theme.color.danger,
|
|
23
|
+
Error: theme.color.danger,
|
|
24
|
+
Warn: theme.color.warning,
|
|
25
|
+
Info: theme.color.success,
|
|
26
|
+
Debug: theme.color.info,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const clock = (date: Date) =>
|
|
30
|
+
DateTime.formatLocal(DateTime.fromDateUnsafe(date), {
|
|
31
|
+
locale: "en-GB",
|
|
32
|
+
hour: "2-digit",
|
|
33
|
+
minute: "2-digit",
|
|
34
|
+
second: "2-digit",
|
|
35
|
+
fractionalSecondDigits: 3,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/** One terminal line: `[12:00:00.000] INFO: [Site/Worker] text`. */
|
|
39
|
+
export const prettyLine = (options: {
|
|
40
|
+
readonly date: Date;
|
|
41
|
+
readonly level: LogLevel.Severity;
|
|
42
|
+
readonly text: string;
|
|
43
|
+
readonly resource?: string;
|
|
44
|
+
readonly colors?: boolean;
|
|
45
|
+
}): string => {
|
|
46
|
+
const colors = options.colors ?? colorsEnabled();
|
|
47
|
+
const paint = (color: string | undefined, text: string) =>
|
|
48
|
+
colors && color !== undefined ? `${ansiFg(color)}${text}${ANSI_RESET}` : text;
|
|
49
|
+
const tag =
|
|
50
|
+
options.resource === undefined ? "" : `${formatResourceTag(options.resource, colors)} `;
|
|
51
|
+
return `${paint(theme.color.muted, `[${clock(options.date)}]`)} ${paint(levelColor[options.level], options.level.toUpperCase())}: ${tag}${options.text}`;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The terminal rendering of a log record: `log` and `output` records (typed
|
|
56
|
+
* events are drawn by the renderers subscribed to them). The resource tag
|
|
57
|
+
* comes from the record, so producers log plain text and never format it.
|
|
58
|
+
*/
|
|
59
|
+
export const makePlainConsoleSink = (options: PrettyLoggerOptions = {}) => {
|
|
60
|
+
const colors = options.colors ?? colorsEnabled();
|
|
8
61
|
return Logger.make<unknown, void>((options) => {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
62
|
+
const record = recordOf(options);
|
|
63
|
+
if (record.kind !== "log" && record.kind !== "output") return;
|
|
64
|
+
const console = options.fiber.getRef(Console.Console);
|
|
65
|
+
const text = record.kind === "log" ? record.data.message : record.data.text;
|
|
66
|
+
const { [LogAnnotation.fqn]: fqn, ...attributes } = record.attributes;
|
|
67
|
+
console.log(
|
|
68
|
+
prettyLine({
|
|
69
|
+
date: new Date(record.time),
|
|
70
|
+
level: severities[record.level],
|
|
71
|
+
text: colors ? text : stripVTControlCharacters(text),
|
|
72
|
+
resource: typeof fqn === "string" ? fqn : undefined,
|
|
73
|
+
colors,
|
|
74
|
+
}),
|
|
75
|
+
);
|
|
76
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
77
|
+
console.log(` ${key}: ${typeof value === "string" ? value : safeStringify(value)}`);
|
|
78
|
+
}
|
|
79
|
+
if (record.kind === "log" && record.data.cause !== null) console.log(record.data.cause);
|
|
17
80
|
});
|
|
18
81
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Annotation keys alchemy reads. `fqn` is an ordinary attribute (the
|
|
3
|
+
* resource a record is about, when there is one); the rest map onto
|
|
4
|
+
* envelope fields instead of `attributes`.
|
|
5
|
+
*/
|
|
6
|
+
export const LogAnnotation = {
|
|
7
|
+
fqn: "fqn",
|
|
8
|
+
stream: "alchemy.stream",
|
|
9
|
+
process: "alchemy.process",
|
|
10
|
+
/** Set by `emit`: the record's message is a typed event. */
|
|
11
|
+
event: "alchemy.event",
|
|
12
|
+
/** `"global"`: account-level work, filed in the global run log. */
|
|
13
|
+
scope: "alchemy.scope",
|
|
14
|
+
/** Set on replay: what the original record carried. */
|
|
15
|
+
time: "alchemy.time",
|
|
16
|
+
cause: "alchemy.cause",
|
|
17
|
+
trace: "alchemy.trace",
|
|
18
|
+
} as const;
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import { writeSync } from "node:fs";
|
|
2
|
+
import * as Cause from "effect/Cause";
|
|
3
|
+
import * as Context from "effect/Context";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
import * as Logger from "effect/Logger";
|
|
7
|
+
import * as LogLevel from "effect/LogLevel";
|
|
8
|
+
import * as Option from "effect/Option";
|
|
9
|
+
import { CurrentLogAnnotations, MinimumLogLevel } from "effect/References";
|
|
10
|
+
import * as Schema from "effect/Schema";
|
|
11
|
+
import { Event, isKnownEventType } from "../Events.ts";
|
|
12
|
+
import { LogAnnotation } from "./LogAnnotation.ts";
|
|
13
|
+
import { processTrace, type TraceParent, withTraceParent } from "./TraceParent.ts";
|
|
14
|
+
|
|
15
|
+
/** Record levels, spelled like `--log-level`. */
|
|
16
|
+
export type Level = "trace" | "debug" | "info" | "warn" | "error" | "fatal";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* What a record is, and the first thing a sink filters on:
|
|
20
|
+
* - `log`: a line alchemy logged;
|
|
21
|
+
* - `event`: a typed event (see `emit`);
|
|
22
|
+
* - `output`: a line a child process wrote (dev servers, workerd, the user's code);
|
|
23
|
+
* - `run`: the first line of a run log, describing the run.
|
|
24
|
+
*/
|
|
25
|
+
export type Kind = "log" | "event" | "output" | "run";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The envelope every record shares. Every key is always present (`null`
|
|
29
|
+
* when it doesn't apply), so a reader filters on fields without guessing
|
|
30
|
+
* which ones a record carries; `data` has the shape its `kind` names.
|
|
31
|
+
*/
|
|
32
|
+
interface Envelope<K extends Kind, Data> {
|
|
33
|
+
/** Unix time in milliseconds. */
|
|
34
|
+
readonly time: number;
|
|
35
|
+
readonly level: Level;
|
|
36
|
+
readonly kind: K;
|
|
37
|
+
/** The alchemy process that produced it: `cli`, `exec` or `sidecar`. */
|
|
38
|
+
readonly process: string;
|
|
39
|
+
/** Which run log it belongs to: account-level work is `global`. */
|
|
40
|
+
readonly scope: "project" | "global";
|
|
41
|
+
/**
|
|
42
|
+
* The trace and span it was logged in, for joining with telemetry; outside
|
|
43
|
+
* any span, the process's trace (see `processTrace`).
|
|
44
|
+
*/
|
|
45
|
+
readonly trace: TraceParent;
|
|
46
|
+
/** Annotations on the record, beyond the envelope's own fields. */
|
|
47
|
+
readonly attributes: Readonly<Record<string, unknown>>;
|
|
48
|
+
readonly data: Data;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* One record as data. Every alchemy process logs these; only the process
|
|
53
|
+
* that owns the terminal renders them (pretty or JSON), so structure
|
|
54
|
+
* survives process boundaries instead of being baked into rendered text.
|
|
55
|
+
*/
|
|
56
|
+
export type LogRecord =
|
|
57
|
+
| Envelope<"log", { readonly message: string; readonly cause: string | null }>
|
|
58
|
+
| Envelope<"event", Event>
|
|
59
|
+
| Envelope<
|
|
60
|
+
"output",
|
|
61
|
+
{
|
|
62
|
+
readonly stream: "stdout" | "stderr";
|
|
63
|
+
/** The line as the child wrote it, ANSI styling included. */
|
|
64
|
+
readonly text: string;
|
|
65
|
+
}
|
|
66
|
+
>
|
|
67
|
+
| Envelope<
|
|
68
|
+
"run",
|
|
69
|
+
{
|
|
70
|
+
readonly version: string;
|
|
71
|
+
readonly pid: number;
|
|
72
|
+
readonly cwd: string;
|
|
73
|
+
readonly argv: ReadonlyArray<string>;
|
|
74
|
+
}
|
|
75
|
+
>;
|
|
76
|
+
|
|
77
|
+
const reserved: ReadonlySet<string> = new Set(
|
|
78
|
+
Object.values(LogAnnotation).filter((key) => key !== LogAnnotation.fqn),
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
/** The name this process stamps on its records: `cli`, `exec` or `sidecar`. */
|
|
82
|
+
export const LogProcess = Context.Reference<string>("alchemy/LogProcess", {
|
|
83
|
+
defaultValue: () => "cli",
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
/** The Effect log level of each record {@link Level}. */
|
|
87
|
+
export const severities: Record<Level, LogLevel.Severity> = {
|
|
88
|
+
trace: "Trace",
|
|
89
|
+
debug: "Debug",
|
|
90
|
+
info: "Info",
|
|
91
|
+
warn: "Warn",
|
|
92
|
+
error: "Error",
|
|
93
|
+
fatal: "Fatal",
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const levelOf = (logLevel: LogLevel.LogLevel): Level =>
|
|
97
|
+
logLevel === "All" || logLevel === "None" ? "info" : (logLevel.toLowerCase() as Level);
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* `JSON.stringify` that never throws: cycles become `"[Circular]"` and
|
|
101
|
+
* bigints their decimal string. Logging must not fail the work it reports.
|
|
102
|
+
*/
|
|
103
|
+
export const safeStringify = (value: unknown): string => {
|
|
104
|
+
const seen = new WeakSet<object>();
|
|
105
|
+
try {
|
|
106
|
+
return (
|
|
107
|
+
JSON.stringify(value, (_key, v: unknown) => {
|
|
108
|
+
if (typeof v === "bigint") return v.toString();
|
|
109
|
+
if (typeof v === "object" && v !== null) {
|
|
110
|
+
if (seen.has(v)) return "[Circular]";
|
|
111
|
+
seen.add(v);
|
|
112
|
+
}
|
|
113
|
+
return v;
|
|
114
|
+
}) ?? String(value)
|
|
115
|
+
);
|
|
116
|
+
} catch {
|
|
117
|
+
return String(value);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const messageText = (message: unknown): string => {
|
|
122
|
+
const parts = Array.isArray(message) ? message : [message];
|
|
123
|
+
return parts
|
|
124
|
+
.map((part) =>
|
|
125
|
+
typeof part === "string"
|
|
126
|
+
? part
|
|
127
|
+
: part instanceof Error
|
|
128
|
+
? (part.stack ?? part.message)
|
|
129
|
+
: safeStringify(part),
|
|
130
|
+
)
|
|
131
|
+
.join(" ");
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/** A record's {@link Kind}, read from its annotations alone. */
|
|
135
|
+
export const kindOf = (options: Logger.Options<unknown>): Exclude<Kind, "run"> => {
|
|
136
|
+
const annotations = options.fiber.getRef(CurrentLogAnnotations);
|
|
137
|
+
return annotations[LogAnnotation.event] === true
|
|
138
|
+
? "event"
|
|
139
|
+
: annotations[LogAnnotation.stream] !== undefined
|
|
140
|
+
? "output"
|
|
141
|
+
: "log";
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const isTrace = (value: unknown): value is TraceParent =>
|
|
145
|
+
typeof value === "object" &&
|
|
146
|
+
value !== null &&
|
|
147
|
+
typeof (value as { traceId?: unknown }).traceId === "string" &&
|
|
148
|
+
typeof (value as { spanId?: unknown }).spanId === "string";
|
|
149
|
+
|
|
150
|
+
/** The record a logger call describes. */
|
|
151
|
+
export const recordOf = (options: Logger.Options<unknown>): LogRecord => {
|
|
152
|
+
const all = options.fiber.getRef(CurrentLogAnnotations);
|
|
153
|
+
const string = (key: string) => (typeof all[key] === "string" ? all[key] : undefined);
|
|
154
|
+
const time = all[LogAnnotation.time];
|
|
155
|
+
const replayedTrace = all[LogAnnotation.trace];
|
|
156
|
+
const span = options.fiber.cache.span;
|
|
157
|
+
const head = {
|
|
158
|
+
time: typeof time === "number" ? time : options.date.getTime(),
|
|
159
|
+
level: levelOf(options.logLevel),
|
|
160
|
+
};
|
|
161
|
+
const envelope = {
|
|
162
|
+
process: string(LogAnnotation.process) ?? options.fiber.getRef(LogProcess),
|
|
163
|
+
scope: all[LogAnnotation.scope] === "global" ? ("global" as const) : ("project" as const),
|
|
164
|
+
trace: isTrace(replayedTrace)
|
|
165
|
+
? replayedTrace
|
|
166
|
+
: span === undefined
|
|
167
|
+
? processTrace
|
|
168
|
+
: { traceId: span.traceId, spanId: span.spanId },
|
|
169
|
+
attributes: Object.fromEntries(Object.entries(all).filter(([key]) => !reserved.has(key))),
|
|
170
|
+
};
|
|
171
|
+
const first = Array.isArray(options.message) ? options.message[0] : options.message;
|
|
172
|
+
switch (kindOf(options)) {
|
|
173
|
+
case "event":
|
|
174
|
+
// SAFETY: only `emit` (or a replayed event) sets the event annotation,
|
|
175
|
+
// and it logs one Event.
|
|
176
|
+
return { ...head, kind: "event", ...envelope, data: first as Event };
|
|
177
|
+
case "output":
|
|
178
|
+
return {
|
|
179
|
+
...head,
|
|
180
|
+
kind: "output",
|
|
181
|
+
...envelope,
|
|
182
|
+
data: {
|
|
183
|
+
stream: all[LogAnnotation.stream] === "stderr" ? "stderr" : "stdout",
|
|
184
|
+
text: messageText(options.message),
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
case "log":
|
|
188
|
+
return {
|
|
189
|
+
...head,
|
|
190
|
+
kind: "log",
|
|
191
|
+
...envelope,
|
|
192
|
+
data: {
|
|
193
|
+
message: messageText(options.message),
|
|
194
|
+
cause:
|
|
195
|
+
string(LogAnnotation.cause) ??
|
|
196
|
+
(options.cause.reasons.length > 0 ? Cause.pretty(options.cause) : null),
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Mark the logs of `effect` as account-level: the CLI files them in the
|
|
204
|
+
* global run log (`~/.alchemy/logs`) instead of the project's. For work that
|
|
205
|
+
* isn't about one project — the state store, auth and credentials, profiles.
|
|
206
|
+
*/
|
|
207
|
+
export const globalLogs = <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>
|
|
208
|
+
Effect.annotateLogs(effect, LogAnnotation.scope, "global");
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Set to `json` on alchemy child processes (sidecars) so they log
|
|
212
|
+
* {@link LogRecord} lines instead of rendering, and on the CLI to print
|
|
213
|
+
* records as JSON.
|
|
214
|
+
*/
|
|
215
|
+
export const LOG_FORMAT_ENV = "ALCHEMY_LOG_FORMAT";
|
|
216
|
+
|
|
217
|
+
/** The console's `--log-level`, for child processes that render the run's logs. */
|
|
218
|
+
export const LOG_LEVEL_ENV = "ALCHEMY_LOG_LEVEL";
|
|
219
|
+
|
|
220
|
+
/** Formats each record as one line of JSON (for `Logger.toFile`). */
|
|
221
|
+
export const formatJsonRecord = Logger.make<unknown, string>((options) =>
|
|
222
|
+
safeStringify(recordOf(options)),
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
/** A logger that writes each record as one line of JSON. */
|
|
226
|
+
export const jsonLogger = (write: (line: string) => void) => Logger.map(formatJsonRecord, write);
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* The only logger of an alchemy child process: every record as a JSON line
|
|
230
|
+
* on stdout, down to Debug, for the parent to filter and render.
|
|
231
|
+
*/
|
|
232
|
+
export const childJsonLogLayer = Layer.mergeAll(
|
|
233
|
+
Logger.layer([jsonLogger((line) => process.stdout.write(`${line}\n`))]),
|
|
234
|
+
Layer.succeed(MinimumLogLevel, "Debug"),
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Set on a child process that renders its own terminal output (the
|
|
239
|
+
* `alchemy dev` exec child) to the file descriptor its parent reads log
|
|
240
|
+
* records from. The parent writes the run log; the child keeps none.
|
|
241
|
+
*/
|
|
242
|
+
export const LOG_FD_ENV = "ALCHEMY_LOG_FD";
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Forward every record, down to Debug, to the parent as JSON lines on the
|
|
246
|
+
* descriptor in {@link LOG_FD_ENV}, alongside the installed loggers. Empty
|
|
247
|
+
* when the variable is unset.
|
|
248
|
+
*/
|
|
249
|
+
export const parentLogLayer = (): Layer.Layer<never> => {
|
|
250
|
+
const fd = Number(process.env[LOG_FD_ENV]);
|
|
251
|
+
if (!Number.isInteger(fd) || fd < 3) return Layer.empty;
|
|
252
|
+
const write = (line: string) => {
|
|
253
|
+
try {
|
|
254
|
+
writeSync(fd, `${line}\n`);
|
|
255
|
+
} catch {
|
|
256
|
+
// The parent is gone or stopped reading: logging must not fail the work.
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
return Logger.layer([jsonLogger(write)], {
|
|
260
|
+
mergeWithExisting: true,
|
|
261
|
+
});
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
/** An event of a `type` this version doesn't know: decoded, never validated. */
|
|
265
|
+
const UnknownEvent = Schema.StructWithRest(
|
|
266
|
+
Schema.Struct({
|
|
267
|
+
type: Schema.String.check(
|
|
268
|
+
Schema.makeFilter(
|
|
269
|
+
(type: string) => !isKnownEventType(type) || "A known event type must decode in full.",
|
|
270
|
+
),
|
|
271
|
+
),
|
|
272
|
+
}),
|
|
273
|
+
[Schema.Record(Schema.String, Schema.Unknown)],
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
const envelopeFields = {
|
|
277
|
+
time: Schema.Number,
|
|
278
|
+
level: Schema.Literals(["trace", "debug", "info", "warn", "error", "fatal"]),
|
|
279
|
+
process: Schema.String,
|
|
280
|
+
scope: Schema.Literals(["project", "global"]),
|
|
281
|
+
trace: Schema.Struct({ traceId: Schema.String, spanId: Schema.String }),
|
|
282
|
+
attributes: Schema.Record(Schema.String, Schema.Unknown),
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* The wire form of a {@link LogRecord}: what a child process sends and the
|
|
287
|
+
* run log stores. An event is decoded with the {@link Event} union; one whose
|
|
288
|
+
* `type` this version doesn't know is kept as-is rather than rejected, so a
|
|
289
|
+
* newer process's records still pass through.
|
|
290
|
+
*/
|
|
291
|
+
export const LogRecordSchema = Schema.Union([
|
|
292
|
+
Schema.Struct({
|
|
293
|
+
...envelopeFields,
|
|
294
|
+
kind: Schema.Literal("log"),
|
|
295
|
+
data: Schema.Struct({ message: Schema.String, cause: Schema.NullOr(Schema.String) }),
|
|
296
|
+
}),
|
|
297
|
+
Schema.Struct({
|
|
298
|
+
...envelopeFields,
|
|
299
|
+
kind: Schema.Literal("event"),
|
|
300
|
+
data: Schema.Union([Event, UnknownEvent]),
|
|
301
|
+
}),
|
|
302
|
+
Schema.Struct({
|
|
303
|
+
...envelopeFields,
|
|
304
|
+
kind: Schema.Literal("output"),
|
|
305
|
+
data: Schema.Struct({ stream: Schema.Literals(["stdout", "stderr"]), text: Schema.String }),
|
|
306
|
+
}),
|
|
307
|
+
Schema.Struct({
|
|
308
|
+
...envelopeFields,
|
|
309
|
+
kind: Schema.Literal("run"),
|
|
310
|
+
data: Schema.Struct({
|
|
311
|
+
version: Schema.String,
|
|
312
|
+
pid: Schema.Number,
|
|
313
|
+
cwd: Schema.String,
|
|
314
|
+
argv: Schema.Array(Schema.String),
|
|
315
|
+
}),
|
|
316
|
+
}),
|
|
317
|
+
]);
|
|
318
|
+
|
|
319
|
+
const decodeRecordLine = Schema.decodeUnknownOption(Schema.fromJsonString(LogRecordSchema));
|
|
320
|
+
|
|
321
|
+
/** Decode one JSON log line, or `undefined` when it isn't a log record. */
|
|
322
|
+
export const parseRecord = (line: string): typeof LogRecordSchema.Type | undefined =>
|
|
323
|
+
Option.getOrUndefined(decodeRecordLine(line));
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Log a record from another process through this process's loggers,
|
|
327
|
+
* keeping its envelope: the sinks here see the record the child produced.
|
|
328
|
+
*/
|
|
329
|
+
export const replayRecord = (record: typeof LogRecordSchema.Type): Effect.Effect<void> =>
|
|
330
|
+
record.kind === "run"
|
|
331
|
+
? Effect.void
|
|
332
|
+
: Effect.logWithLevel(severities[record.level])(
|
|
333
|
+
record.kind === "log"
|
|
334
|
+
? record.data.message
|
|
335
|
+
: record.kind === "output"
|
|
336
|
+
? record.data.text
|
|
337
|
+
: record.data,
|
|
338
|
+
).pipe(
|
|
339
|
+
Effect.annotateLogs({
|
|
340
|
+
...record.attributes,
|
|
341
|
+
[LogAnnotation.time]: record.time,
|
|
342
|
+
[LogAnnotation.process]: record.process,
|
|
343
|
+
[LogAnnotation.trace]: record.trace,
|
|
344
|
+
[LogAnnotation.scope]: record.scope,
|
|
345
|
+
...(record.kind === "event" ? { [LogAnnotation.event]: true } : {}),
|
|
346
|
+
...(record.kind === "output" ? { [LogAnnotation.stream]: record.data.stream } : {}),
|
|
347
|
+
...(record.kind === "log" && record.data.cause !== null
|
|
348
|
+
? { [LogAnnotation.cause]: record.data.cause }
|
|
349
|
+
: {}),
|
|
350
|
+
}),
|
|
351
|
+
// A record the child already let through keeps reaching the sinks,
|
|
352
|
+
// whatever this process's minimum level.
|
|
353
|
+
Effect.provideService(MinimumLogLevel, "Trace"),
|
|
354
|
+
// Loggers that read the fiber's span (OTLP) see the child's too.
|
|
355
|
+
withTraceParent(record.trace),
|
|
356
|
+
);
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Log one line a child process wrote. A JSON {@link LogRecord} (an alchemy
|
|
360
|
+
* child) is replayed as-is; anything else becomes an Info `output` record,
|
|
361
|
+
* from `source.process` or, when that's unset, this process.
|
|
362
|
+
*/
|
|
363
|
+
export const logChildLine = (
|
|
364
|
+
line: string,
|
|
365
|
+
source: {
|
|
366
|
+
readonly stream: "stdout" | "stderr";
|
|
367
|
+
readonly resource?: string;
|
|
368
|
+
readonly process?: string;
|
|
369
|
+
},
|
|
370
|
+
): Effect.Effect<void> => {
|
|
371
|
+
const record = parseRecord(line);
|
|
372
|
+
if (record !== undefined) {
|
|
373
|
+
return replayRecord(
|
|
374
|
+
source.resource !== undefined && record.attributes[LogAnnotation.fqn] === undefined
|
|
375
|
+
? { ...record, attributes: { ...record.attributes, [LogAnnotation.fqn]: source.resource } }
|
|
376
|
+
: record,
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
return Effect.logInfo(line).pipe(
|
|
380
|
+
Effect.annotateLogs({
|
|
381
|
+
[LogAnnotation.stream]: source.stream,
|
|
382
|
+
...(source.resource === undefined ? {} : { [LogAnnotation.fqn]: source.resource }),
|
|
383
|
+
...(source.process === undefined ? {} : { [LogAnnotation.process]: source.process }),
|
|
384
|
+
}),
|
|
385
|
+
);
|
|
386
|
+
};
|