@mesh-tech/mesh-cli 0.1.1 → 0.12.1
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/assets/intent/agents-fence.md +10 -0
- package/assets/intent/intent-claude-gate.mjs +255 -0
- package/assets/log-shipper.mjs +94 -0
- package/bin/mesh.mjs +80 -0
- package/dist/bin/mesh.d.ts +7 -9
- package/dist/bin/mesh.d.ts.map +1 -1
- package/dist/bin/mesh.js +20878 -37
- package/dist/bin/mesh.js.map +7 -1
- package/dist/build-info.json +4 -0
- package/dist/src/commands/agent-api-client.d.ts +79 -0
- package/dist/src/commands/agent-api-client.d.ts.map +1 -0
- package/dist/src/commands/agent-api-client.js +170 -0
- package/dist/src/commands/agent-api-client.js.map +1 -0
- package/dist/src/commands/artifacts.d.ts +13 -0
- package/dist/src/commands/artifacts.d.ts.map +1 -0
- package/dist/src/commands/artifacts.js +140 -0
- package/dist/src/commands/artifacts.js.map +1 -0
- package/dist/src/commands/cluster.d.ts +45 -0
- package/dist/src/commands/cluster.d.ts.map +1 -0
- package/dist/src/commands/cluster.js +259 -0
- package/dist/src/commands/cluster.js.map +1 -0
- package/dist/src/commands/conversations.d.ts +61 -0
- package/dist/src/commands/conversations.d.ts.map +1 -0
- package/dist/src/commands/conversations.js +239 -0
- package/dist/src/commands/conversations.js.map +1 -0
- package/dist/src/commands/create-app.d.ts +26 -3
- package/dist/src/commands/create-app.d.ts.map +1 -1
- package/dist/src/commands/create-app.js +465 -107
- package/dist/src/commands/create-app.js.map +1 -1
- package/dist/src/commands/deploy.d.ts +19 -0
- package/dist/src/commands/deploy.d.ts.map +1 -1
- package/dist/src/commands/deploy.js +83 -142
- package/dist/src/commands/deploy.js.map +1 -1
- package/dist/src/commands/dev-doctor.d.ts +137 -0
- package/dist/src/commands/dev-doctor.d.ts.map +1 -0
- package/dist/src/commands/dev-doctor.js +671 -0
- package/dist/src/commands/dev-doctor.js.map +1 -0
- package/dist/src/commands/dev-launch.d.ts +59 -0
- package/dist/src/commands/dev-launch.d.ts.map +1 -0
- package/dist/src/commands/dev-launch.js +118 -0
- package/dist/src/commands/dev-launch.js.map +1 -0
- package/dist/src/commands/dev-token-server.d.ts +32 -0
- package/dist/src/commands/dev-token-server.d.ts.map +1 -0
- package/dist/src/commands/dev-token-server.js +68 -0
- package/dist/src/commands/dev-token-server.js.map +1 -0
- package/dist/src/commands/dev.d.ts +289 -2
- package/dist/src/commands/dev.d.ts.map +1 -1
- package/dist/src/commands/dev.js +2501 -574
- package/dist/src/commands/dev.js.map +1 -1
- package/dist/src/commands/docs.d.ts +3 -0
- package/dist/src/commands/docs.d.ts.map +1 -0
- package/dist/src/commands/docs.js +262 -0
- package/dist/src/commands/docs.js.map +1 -0
- package/dist/src/commands/hub/index.d.ts +99 -0
- package/dist/src/commands/hub/index.d.ts.map +1 -0
- package/dist/src/commands/hub/index.js +452 -0
- package/dist/src/commands/hub/index.js.map +1 -0
- package/dist/src/commands/init.d.ts +65 -0
- package/dist/src/commands/init.d.ts.map +1 -0
- package/dist/src/commands/init.js +370 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/install-shim.d.ts +28 -0
- package/dist/src/commands/install-shim.d.ts.map +1 -0
- package/dist/src/commands/install-shim.js +191 -0
- package/dist/src/commands/install-shim.js.map +1 -0
- package/dist/src/commands/local/auth-provision.d.ts +71 -0
- package/dist/src/commands/local/auth-provision.d.ts.map +1 -0
- package/dist/src/commands/local/auth-provision.js +286 -0
- package/dist/src/commands/local/auth-provision.js.map +1 -0
- package/dist/src/commands/local/dev-local.d.ts +97 -0
- package/dist/src/commands/local/dev-local.d.ts.map +1 -0
- package/dist/src/commands/local/dev-local.js +306 -0
- package/dist/src/commands/local/dev-local.js.map +1 -0
- package/dist/src/commands/local/docker-runner.d.ts +37 -0
- package/dist/src/commands/local/docker-runner.d.ts.map +1 -0
- package/dist/src/commands/local/docker-runner.js +104 -0
- package/dist/src/commands/local/docker-runner.js.map +1 -0
- package/dist/src/commands/local/helpers.d.ts +22 -0
- package/dist/src/commands/local/helpers.d.ts.map +1 -0
- package/dist/src/commands/local/helpers.js +46 -0
- package/dist/src/commands/local/helpers.js.map +1 -0
- package/dist/src/commands/local/hub-local.d.ts +51 -0
- package/dist/src/commands/local/hub-local.d.ts.map +1 -0
- package/dist/src/commands/local/hub-local.js +197 -0
- package/dist/src/commands/local/hub-local.js.map +1 -0
- package/dist/src/commands/local/index.d.ts +23 -0
- package/dist/src/commands/local/index.d.ts.map +1 -0
- package/dist/src/commands/local/index.js +386 -0
- package/dist/src/commands/local/index.js.map +1 -0
- package/dist/src/commands/local/mocks.d.ts +361 -0
- package/dist/src/commands/local/mocks.d.ts.map +1 -0
- package/dist/src/commands/local/mocks.js +756 -0
- package/dist/src/commands/local/mocks.js.map +1 -0
- package/dist/src/commands/local/seed-zitadel.d.ts +151 -0
- package/dist/src/commands/local/seed-zitadel.d.ts.map +1 -0
- package/dist/src/commands/local/seed-zitadel.js +408 -0
- package/dist/src/commands/local/seed-zitadel.js.map +1 -0
- package/dist/src/commands/local/seed.d.ts +106 -0
- package/dist/src/commands/local/seed.d.ts.map +1 -0
- package/dist/src/commands/local/seed.js +252 -0
- package/dist/src/commands/local/seed.js.map +1 -0
- package/dist/src/commands/local/stack.d.ts +173 -0
- package/dist/src/commands/local/stack.d.ts.map +1 -0
- package/dist/src/commands/local/stack.js +499 -0
- package/dist/src/commands/local/stack.js.map +1 -0
- package/dist/src/commands/login.d.ts +256 -12
- package/dist/src/commands/login.d.ts.map +1 -1
- package/dist/src/commands/login.js +978 -50
- package/dist/src/commands/login.js.map +1 -1
- package/dist/src/commands/peer-addressing.d.ts +51 -0
- package/dist/src/commands/peer-addressing.d.ts.map +1 -0
- package/dist/src/commands/peer-addressing.js +64 -0
- package/dist/src/commands/peer-addressing.js.map +1 -0
- package/dist/src/commands/port-ownership.d.ts +69 -0
- package/dist/src/commands/port-ownership.d.ts.map +1 -0
- package/dist/src/commands/port-ownership.js +161 -0
- package/dist/src/commands/port-ownership.js.map +1 -0
- package/dist/src/commands/registry-publish.d.ts +3 -0
- package/dist/src/commands/registry-publish.d.ts.map +1 -0
- package/dist/src/commands/registry-publish.js +161 -0
- package/dist/src/commands/registry-publish.js.map +1 -0
- package/dist/src/commands/registry.d.ts +146 -2
- package/dist/src/commands/registry.d.ts.map +1 -1
- package/dist/src/commands/registry.js +541 -85
- package/dist/src/commands/registry.js.map +1 -1
- package/dist/src/commands/secrets/index.d.ts.map +1 -1
- package/dist/src/commands/secrets/index.js +15 -1
- package/dist/src/commands/secrets/index.js.map +1 -1
- package/dist/src/commands/secrets/migrate-config.d.ts +24 -0
- package/dist/src/commands/secrets/migrate-config.d.ts.map +1 -0
- package/dist/src/commands/secrets/migrate-config.js +277 -0
- package/dist/src/commands/secrets/migrate-config.js.map +1 -0
- package/dist/src/commands/secrets/set.d.ts +1 -0
- package/dist/src/commands/secrets/set.d.ts.map +1 -1
- package/dist/src/commands/secrets/set.js +96 -2
- package/dist/src/commands/secrets/set.js.map +1 -1
- package/dist/src/commands/skills.d.ts +34 -0
- package/dist/src/commands/skills.d.ts.map +1 -0
- package/dist/src/commands/skills.js +207 -0
- package/dist/src/commands/skills.js.map +1 -0
- package/dist/src/commands/stack.d.ts.map +1 -1
- package/dist/src/commands/stack.js +361 -23
- package/dist/src/commands/stack.js.map +1 -1
- package/dist/src/commands/temporal.d.ts +15 -0
- package/dist/src/commands/temporal.d.ts.map +1 -0
- package/dist/src/commands/temporal.js +781 -0
- package/dist/src/commands/temporal.js.map +1 -0
- package/dist/src/commands/tenant.d.ts +56 -0
- package/dist/src/commands/tenant.d.ts.map +1 -0
- package/dist/src/commands/tenant.js +233 -0
- package/dist/src/commands/tenant.js.map +1 -0
- package/dist/src/commands/tunnel/index.d.ts +49 -3
- package/dist/src/commands/tunnel/index.d.ts.map +1 -1
- package/dist/src/commands/tunnel/index.js +331 -8
- package/dist/src/commands/tunnel/index.js.map +1 -1
- package/dist/src/commands/vcs/clone.d.ts +3 -0
- package/dist/src/commands/vcs/clone.d.ts.map +1 -0
- package/dist/src/commands/vcs/clone.js +20 -0
- package/dist/src/commands/vcs/clone.js.map +1 -0
- package/dist/src/commands/vcs/common.d.ts +21 -0
- package/dist/src/commands/vcs/common.d.ts.map +1 -0
- package/dist/src/commands/vcs/common.js +62 -0
- package/dist/src/commands/vcs/common.js.map +1 -0
- package/dist/src/commands/vcs/drafts.d.ts +13 -0
- package/dist/src/commands/vcs/drafts.d.ts.map +1 -0
- package/dist/src/commands/vcs/drafts.js +45 -0
- package/dist/src/commands/vcs/drafts.js.map +1 -0
- package/dist/src/commands/vcs/get.d.ts +8 -0
- package/dist/src/commands/vcs/get.d.ts.map +1 -0
- package/dist/src/commands/vcs/get.js +61 -0
- package/dist/src/commands/vcs/get.js.map +1 -0
- package/dist/src/commands/vcs/index.d.ts +3 -0
- package/dist/src/commands/vcs/index.d.ts.map +1 -0
- package/dist/src/commands/vcs/index.js +58 -0
- package/dist/src/commands/vcs/index.js.map +1 -0
- package/dist/src/commands/vcs/propose.d.ts +23 -0
- package/dist/src/commands/vcs/propose.d.ts.map +1 -0
- package/dist/src/commands/vcs/propose.js +94 -0
- package/dist/src/commands/vcs/propose.js.map +1 -0
- package/dist/src/commands/vcs/review.d.ts +15 -0
- package/dist/src/commands/vcs/review.d.ts.map +1 -0
- package/dist/src/commands/vcs/review.js +35 -0
- package/dist/src/commands/vcs/review.js.map +1 -0
- package/dist/src/commands/vcs-enrich.d.ts +15 -0
- package/dist/src/commands/vcs-enrich.d.ts.map +1 -0
- package/dist/src/commands/vcs-enrich.js +28 -0
- package/dist/src/commands/vcs-enrich.js.map +1 -0
- package/dist/src/commands/vpn/index.d.ts +24 -0
- package/dist/src/commands/vpn/index.d.ts.map +1 -0
- package/dist/src/commands/vpn/index.js +543 -0
- package/dist/src/commands/vpn/index.js.map +1 -0
- package/dist/src/commands/vpn/tunnel.d.ts +11 -0
- package/dist/src/commands/vpn/tunnel.d.ts.map +1 -0
- package/dist/src/commands/vpn/tunnel.js +188 -0
- package/dist/src/commands/vpn/tunnel.js.map +1 -0
- package/dist/src/commands/workflow.d.ts +24 -0
- package/dist/src/commands/workflow.d.ts.map +1 -0
- package/dist/src/commands/workflow.js +577 -0
- package/dist/src/commands/workflow.js.map +1 -0
- package/dist/src/docs/assemble.d.ts +217 -0
- package/dist/src/docs/assemble.d.ts.map +1 -0
- package/dist/src/docs/assemble.js +739 -0
- package/dist/src/docs/assemble.js.map +1 -0
- package/dist/src/docs/cli-reference.d.ts +93 -0
- package/dist/src/docs/cli-reference.d.ts.map +1 -0
- package/dist/src/docs/cli-reference.js +256 -0
- package/dist/src/docs/cli-reference.js.map +1 -0
- package/dist/src/docs/discover.d.ts +60 -0
- package/dist/src/docs/discover.d.ts.map +1 -0
- package/dist/src/docs/discover.js +233 -0
- package/dist/src/docs/discover.js.map +1 -0
- package/dist/src/docs/portal.d.ts +79 -0
- package/dist/src/docs/portal.d.ts.map +1 -0
- package/dist/src/docs/portal.js +242 -0
- package/dist/src/docs/portal.js.map +1 -0
- package/dist/src/docs/registry-docs.d.ts +43 -0
- package/dist/src/docs/registry-docs.d.ts.map +1 -0
- package/dist/src/docs/registry-docs.js +138 -0
- package/dist/src/docs/registry-docs.js.map +1 -0
- package/dist/src/docs/schema.d.ts +48 -0
- package/dist/src/docs/schema.d.ts.map +1 -0
- package/dist/src/docs/schema.js +96 -0
- package/dist/src/docs/schema.js.map +1 -0
- package/dist/src/docs/serve.d.ts +27 -0
- package/dist/src/docs/serve.d.ts.map +1 -0
- package/dist/src/docs/serve.js +102 -0
- package/dist/src/docs/serve.js.map +1 -0
- package/dist/src/docs/start.d.ts +80 -0
- package/dist/src/docs/start.d.ts.map +1 -0
- package/dist/src/docs/start.js +313 -0
- package/dist/src/docs/start.js.map +1 -0
- package/dist/src/eval/agent-eval.d.mts +14 -0
- package/dist/src/eval/agent-eval.d.mts.map +1 -0
- package/dist/src/eval/agent-eval.mjs +273 -0
- package/dist/src/eval/agent-eval.mjs.map +1 -0
- package/dist/src/index.js +624 -7
- package/dist/src/index.js.map +7 -1
- package/dist/src/program.d.ts +26 -0
- package/dist/src/program.d.ts.map +1 -0
- package/dist/src/program.js +76 -0
- package/dist/src/program.js.map +1 -0
- package/dist/src/utils/auth-preflight.d.ts +159 -0
- package/dist/src/utils/auth-preflight.d.ts.map +1 -0
- package/dist/src/utils/auth-preflight.js +298 -0
- package/dist/src/utils/auth-preflight.js.map +1 -0
- package/dist/src/utils/aws-auth.d.ts +181 -0
- package/dist/src/utils/aws-auth.d.ts.map +1 -0
- package/dist/src/utils/aws-auth.js +527 -0
- package/dist/src/utils/aws-auth.js.map +1 -0
- package/dist/src/utils/bastion.d.ts +1 -1
- package/dist/src/utils/bastion.d.ts.map +1 -1
- package/dist/src/utils/bastion.js +29 -8
- package/dist/src/utils/bastion.js.map +1 -1
- package/dist/src/utils/build-info.d.ts +33 -0
- package/dist/src/utils/build-info.d.ts.map +1 -0
- package/dist/src/utils/build-info.js +102 -0
- package/dist/src/utils/build-info.js.map +1 -0
- package/dist/src/utils/capture-history.d.ts +62 -0
- package/dist/src/utils/capture-history.d.ts.map +1 -0
- package/dist/src/utils/capture-history.js +94 -0
- package/dist/src/utils/capture-history.js.map +1 -0
- package/dist/src/utils/deploy-preflight.d.ts +52 -0
- package/dist/src/utils/deploy-preflight.d.ts.map +1 -0
- package/dist/src/utils/deploy-preflight.js +183 -0
- package/dist/src/utils/deploy-preflight.js.map +1 -0
- package/dist/src/utils/errors.d.ts +75 -0
- package/dist/src/utils/errors.d.ts.map +1 -0
- package/dist/src/utils/errors.js +106 -0
- package/dist/src/utils/errors.js.map +1 -0
- package/dist/src/utils/first-party-contexts.d.ts +40 -0
- package/dist/src/utils/first-party-contexts.d.ts.map +1 -0
- package/dist/src/utils/first-party-contexts.js +53 -0
- package/dist/src/utils/first-party-contexts.js.map +1 -0
- package/dist/src/utils/index.d.ts +2 -0
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/index.js +2 -0
- package/dist/src/utils/index.js.map +1 -1
- package/dist/src/utils/kubeconfig.d.ts +62 -0
- package/dist/src/utils/kubeconfig.d.ts.map +1 -0
- package/dist/src/utils/kubeconfig.js +118 -0
- package/dist/src/utils/kubeconfig.js.map +1 -0
- package/dist/src/utils/log.d.ts +27 -1
- package/dist/src/utils/log.d.ts.map +1 -1
- package/dist/src/utils/log.js +59 -5
- package/dist/src/utils/log.js.map +1 -1
- package/dist/src/utils/pid.d.ts +47 -0
- package/dist/src/utils/pid.d.ts.map +1 -0
- package/dist/src/utils/pid.js +83 -0
- package/dist/src/utils/pid.js.map +1 -0
- package/dist/src/utils/pulumi-run.d.ts +23 -0
- package/dist/src/utils/pulumi-run.d.ts.map +1 -0
- package/dist/src/utils/pulumi-run.js +112 -0
- package/dist/src/utils/pulumi-run.js.map +1 -0
- package/dist/src/utils/pulumi.d.ts +15 -0
- package/dist/src/utils/pulumi.d.ts.map +1 -1
- package/dist/src/utils/pulumi.js +35 -0
- package/dist/src/utils/pulumi.js.map +1 -1
- package/dist/src/utils/reachability.d.ts +29 -0
- package/dist/src/utils/reachability.d.ts.map +1 -0
- package/dist/src/utils/reachability.js +81 -0
- package/dist/src/utils/reachability.js.map +1 -0
- package/dist/src/utils/recover-conversation.d.ts +154 -0
- package/dist/src/utils/recover-conversation.d.ts.map +1 -0
- package/dist/src/utils/recover-conversation.js +314 -0
- package/dist/src/utils/recover-conversation.js.map +1 -0
- package/dist/src/utils/registry-broker.d.ts +148 -0
- package/dist/src/utils/registry-broker.d.ts.map +1 -0
- package/dist/src/utils/registry-broker.js +180 -0
- package/dist/src/utils/registry-broker.js.map +1 -0
- package/dist/src/utils/socks-forward.d.ts +40 -0
- package/dist/src/utils/socks-forward.d.ts.map +1 -0
- package/dist/src/utils/socks-forward.js +97 -0
- package/dist/src/utils/socks-forward.js.map +1 -0
- package/dist/src/utils/stack-flag.d.ts +23 -0
- package/dist/src/utils/stack-flag.d.ts.map +1 -0
- package/dist/src/utils/stack-flag.js +41 -0
- package/dist/src/utils/stack-flag.js.map +1 -0
- package/dist/src/utils/tailscale-targets.d.ts +52 -0
- package/dist/src/utils/tailscale-targets.d.ts.map +1 -0
- package/dist/src/utils/tailscale-targets.js +93 -0
- package/dist/src/utils/tailscale-targets.js.map +1 -0
- package/dist/src/utils/tailscale.d.ts +277 -0
- package/dist/src/utils/tailscale.d.ts.map +1 -0
- package/dist/src/utils/tailscale.js +1007 -0
- package/dist/src/utils/tailscale.js.map +1 -0
- package/dist/src/utils/temporal-auth.d.ts +43 -0
- package/dist/src/utils/temporal-auth.d.ts.map +1 -0
- package/dist/src/utils/temporal-auth.js +176 -0
- package/dist/src/utils/temporal-auth.js.map +1 -0
- package/dist/src/utils/temporal-codec.d.ts +101 -0
- package/dist/src/utils/temporal-codec.d.ts.map +1 -0
- package/dist/src/utils/temporal-codec.js +319 -0
- package/dist/src/utils/temporal-codec.js.map +1 -0
- package/dist/src/utils/tunnel-ownership.d.ts +130 -0
- package/dist/src/utils/tunnel-ownership.d.ts.map +1 -0
- package/dist/src/utils/tunnel-ownership.js +274 -0
- package/dist/src/utils/tunnel-ownership.js.map +1 -0
- package/dist/src/utils/vpn-join.d.ts +32 -0
- package/dist/src/utils/vpn-join.d.ts.map +1 -0
- package/dist/src/utils/vpn-join.js +62 -0
- package/dist/src/utils/vpn-join.js.map +1 -0
- package/dist/src/utils/vpn.d.ts +62 -0
- package/dist/src/utils/vpn.d.ts.map +1 -0
- package/dist/src/utils/vpn.js +183 -0
- package/dist/src/utils/vpn.js.map +1 -0
- package/dist/src/utils/workflow-fingerprint.d.ts +49 -0
- package/dist/src/utils/workflow-fingerprint.d.ts.map +1 -0
- package/dist/src/utils/workflow-fingerprint.js +135 -0
- package/dist/src/utils/workflow-fingerprint.js.map +1 -0
- package/dist/src/utils/worktree-identity.d.ts +86 -0
- package/dist/src/utils/worktree-identity.d.ts.map +1 -0
- package/dist/src/utils/worktree-identity.js +164 -0
- package/dist/src/utils/worktree-identity.js.map +1 -0
- package/fragments/agents/AGENTS.md.hbs +92 -0
- package/fragments/agents/CLAUDE.md.hbs +8 -0
- package/fragments/base/Pulumi.dev.yaml.hbs +10 -0
- package/fragments/base/Pulumi.yaml.hbs +9 -0
- package/fragments/base/index.ts.hbs +107 -0
- package/fragments/base/package.json.hbs +22 -0
- package/{templates/api-web-db/api → fragments/base}/tsconfig.json +3 -4
- package/fragments/bucket/api/src/storage.ts.hbs +81 -0
- package/fragments/database/api/src/db.ts.hbs +23 -0
- package/fragments/database/prisma/schema.prisma.hbs +18 -0
- package/{templates/api-web-db → fragments/service}/api/.dockerignore +2 -0
- package/fragments/service/api/package.json.hbs +40 -0
- package/fragments/service/api/src/index.ts.hbs +58 -0
- package/{templates/api-web-db → fragments/service/api}/tsconfig.json +5 -3
- package/fragments/temporal/worker/.dockerignore +4 -0
- package/fragments/temporal/worker/Dockerfile +15 -0
- package/{templates/temporal-api-worker → fragments/temporal}/worker/package.json.hbs +3 -2
- package/fragments/temporal/worker/src/activities.ts.hbs +14 -0
- package/fragments/temporal/worker/src/worker.ts.hbs +27 -0
- package/fragments/temporal/worker/src/workflows.ts.hbs +24 -0
- package/fragments/temporal/worker/tsconfig.json +13 -0
- package/package.json +36 -22
- package/skills/core/SKILL.md +365 -0
- package/skills/pull-remote-agent-context/SKILL.md +194 -0
- package/stack/docker-compose.hub.yml +134 -0
- package/stack/docker-compose.yml +447 -0
- package/stack/hub/Dockerfile.api +18 -0
- package/stack/hub/Dockerfile.auth +10 -0
- package/stack/hub/Dockerfile.ui +10 -0
- package/stack/init/01-databases.sql +12 -0
- package/stack/observability/blackbox.yml +20 -0
- package/stack/observability/otel-collector.yaml +73 -0
- package/stack/observability/prometheus.yml +36 -0
- package/stack/observability/tempo.yaml +25 -0
- package/stack/temporal/local.yaml +44 -0
- package/templates/api-auth/AGENTS.md.hbs +16 -0
- package/templates/api-auth/Pulumi.dev.yaml.hbs +8 -0
- package/templates/api-auth/Pulumi.yaml.hbs +8 -0
- package/templates/api-auth/README.md.hbs +67 -0
- package/templates/api-auth/api/package.json.hbs +28 -0
- package/templates/api-auth/api/src/index.ts.hbs +96 -0
- package/templates/api-auth/api/src/schema.ts.hbs +35 -0
- package/templates/api-auth/api/src/seed-authz.ts.hbs +48 -0
- package/templates/api-auth/api/src/spicedb-http-provider.ts.hbs +89 -0
- package/templates/api-auth/index.ts.hbs +65 -0
- package/templates/api-auth/package.json.hbs +20 -0
- package/templates/api-auth/skills/develop/SKILL.md.hbs +32 -0
- package/templates/api-role-gating/AGENTS.md.hbs +20 -0
- package/templates/api-role-gating/Pulumi.dev.yaml.hbs +8 -0
- package/templates/api-role-gating/Pulumi.yaml.hbs +8 -0
- package/templates/api-role-gating/README.md.hbs +64 -0
- package/templates/api-role-gating/api/Dockerfile +17 -0
- package/templates/api-role-gating/api/package.json.hbs +28 -0
- package/templates/api-role-gating/api/src/authn.ts.hbs +29 -0
- package/templates/api-role-gating/api/src/authz.ts.hbs +12 -0
- package/templates/api-role-gating/api/src/main.ts.hbs +58 -0
- package/templates/api-role-gating/api/src/schema.ts.hbs +22 -0
- package/templates/api-role-gating/api/tsconfig.json +13 -0
- package/templates/api-role-gating/index.ts.hbs +107 -0
- package/templates/api-role-gating/package.json.hbs +21 -0
- package/templates/api-role-gating/skills/develop/SKILL.md.hbs +60 -0
- package/templates/api-role-gating/tsconfig.json +10 -0
- package/templates/apps-repo/README.md.hbs +24 -0
- package/templates/apps-repo/gitignore +41 -0
- package/templates/apps-repo/npmrc.hbs +7 -0
- package/templates/apps-repo/package.json.hbs +15 -0
- package/templates/apps-repo/pnpm-workspace.yaml +3 -0
- package/templates/apps-repo/tsconfig.json +18 -0
- package/templates/external-service/AGENTS.md.hbs +20 -0
- package/templates/external-service/Pulumi.dev.yaml.hbs +8 -0
- package/templates/external-service/Pulumi.yaml.hbs +8 -0
- package/templates/external-service/README.md.hbs +56 -0
- package/templates/external-service/api/Dockerfile +15 -0
- package/templates/external-service/api/package.json.hbs +25 -0
- package/templates/external-service/api/src/index.ts.hbs +81 -0
- package/templates/external-service/index.ts.hbs +82 -0
- package/templates/external-service/mocks/vendorpay/package.json.hbs +9 -0
- package/templates/external-service/mocks/vendorpay/server.mjs.hbs +61 -0
- package/templates/external-service/package.json.hbs +34 -0
- package/templates/external-service/skills/develop/SKILL.md.hbs +55 -0
- package/templates/external-service/tsconfig.json +10 -0
- package/templates/platform-repo/AGENTS.md.hbs +18 -0
- package/templates/platform-repo/README.md.hbs +38 -0
- package/templates/platform-repo/core/Pulumi.yaml.hbs +12 -0
- package/templates/platform-repo/core/Pulumi.{{tenant}}-{{env}}.yaml.hbs +57 -0
- package/templates/platform-repo/core/index.ts +62 -0
- package/templates/platform-repo/core/package.json.hbs +22 -0
- package/templates/platform-repo/core/tsconfig.json +8 -0
- package/templates/platform-repo/package.json.hbs +15 -0
- package/templates/platform-repo/platform/Pulumi.yaml.hbs +12 -0
- package/templates/platform-repo/platform/Pulumi.{{tenant}}-{{env}}.yaml.hbs +59 -0
- package/templates/platform-repo/platform/index.ts +95 -0
- package/templates/platform-repo/platform/package.json.hbs +26 -0
- package/templates/platform-repo/platform/tsconfig.json +8 -0
- package/templates/platform-repo/pnpm-workspace.yaml +3 -0
- package/templates/workflow/AGENTS.md.hbs +15 -0
- package/templates/workflow/Pulumi.dev.yaml.hbs +8 -0
- package/templates/workflow/Pulumi.yaml.hbs +8 -0
- package/templates/workflow/README.md.hbs +45 -0
- package/templates/workflow/api/.dockerignore +4 -0
- package/templates/workflow/api/Dockerfile +15 -0
- package/templates/{temporal-api-worker → workflow}/api/package.json.hbs +8 -6
- package/templates/workflow/api/src/index.ts.hbs +130 -0
- package/templates/workflow/api/tsconfig.json +14 -0
- package/templates/workflow/index.ts.hbs +67 -0
- package/templates/workflow/package.json.hbs +20 -0
- package/templates/workflow/skills/develop/SKILL.md.hbs +32 -0
- package/templates/workflow/tsconfig.json +10 -0
- package/templates/workflow/worker/.dockerignore +4 -0
- package/templates/workflow/worker/Dockerfile +13 -0
- package/templates/workflow/worker/package.json.hbs +25 -0
- package/templates/workflow/worker/src/worker.ts.hbs +24 -0
- package/templates/workflow/worker/tsconfig.json +14 -0
- package/dist/src/commands/devbox.d.ts +0 -22
- package/dist/src/commands/devbox.d.ts.map +0 -1
- package/dist/src/commands/devbox.js +0 -463
- package/dist/src/commands/devbox.js.map +0 -1
- package/templates/api-web-db/api/Dockerfile +0 -16
- package/templates/api-web-db/api/package.json.hbs +0 -21
- package/templates/api-web-db/api/src/index.ts.hbs +0 -123
- package/templates/api-web-db/package.json.hbs +0 -27
- package/templates/api-web-db/sst.config.ts.hbs +0 -151
- package/templates/api-web-db/web/.dockerignore +0 -3
- package/templates/api-web-db/web/Dockerfile +0 -17
- package/templates/api-web-db/web/app/lib/db.server.ts +0 -36
- package/templates/api-web-db/web/app/root.tsx +0 -29
- package/templates/api-web-db/web/app/routes/home.tsx.hbs +0 -114
- package/templates/api-web-db/web/app/routes.ts +0 -3
- package/templates/api-web-db/web/package.json.hbs +0 -30
- package/templates/api-web-db/web/prisma/schema.prisma +0 -25
- package/templates/api-web-db/web/prisma.config.ts +0 -18
- package/templates/api-web-db/web/react-router.config.ts +0 -5
- package/templates/api-web-db/web/tsconfig.json +0 -19
- package/templates/api-web-db/web/vite.config.ts +0 -9
- package/templates/temporal-api-worker/README.md.hbs +0 -133
- package/templates/temporal-api-worker/api/src/index.ts.hbs +0 -145
- package/templates/temporal-api-worker/package.json.hbs +0 -29
- package/templates/temporal-api-worker/sst.config.ts.hbs +0 -161
- package/templates/temporal-api-worker/worker/Dockerfile +0 -11
- package/templates/temporal-api-worker/worker/src/bundle-workflows.ts +0 -38
- package/templates/temporal-api-worker/worker/src/worker.ts.hbs +0 -93
- /package/templates/{temporal-api-worker → api-auth}/api/.dockerignore +0 -0
- /package/templates/{temporal-api-worker → api-auth}/api/Dockerfile +0 -0
- /package/templates/{temporal-api-worker → api-auth}/api/tsconfig.json +0 -0
- /package/templates/{temporal-api-worker → api-auth}/tsconfig.json +0 -0
- /package/templates/{temporal-api-worker/worker → api-role-gating/api}/.dockerignore +0 -0
- /package/templates/{temporal-api-worker/worker → external-service/api}/tsconfig.json +0 -0
- /package/templates/{temporal-api-worker → workflow}/api/src/encryption-codec.ts +0 -0
- /package/templates/{temporal-api-worker → workflow}/worker/src/activities.ts.hbs +0 -0
- /package/templates/{temporal-api-worker → workflow}/worker/src/encryption-codec.ts +0 -0
- /package/templates/{temporal-api-worker → workflow}/worker/src/workflows.ts.hbs +0 -0
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Temporal payload decryption helpers for mesh CLI.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the AES-256-GCM codec in `@mesh-tech/app-kit/temporal-codec`. The CLI
|
|
5
|
+
* can't depend on app-kit directly because app-kit depends on mesh-cli — so
|
|
6
|
+
* the codec logic is intentionally duplicated here, kept small, and bounded
|
|
7
|
+
* to read-only decryption (the CLI never encrypts).
|
|
8
|
+
*
|
|
9
|
+
* Wire format (matches app-kit EncryptionCodec):
|
|
10
|
+
* metadata["encoding"] = "binary/encrypted"
|
|
11
|
+
* metadata["encryption-key-id"] = first 16 hex chars of SHA-256(encodingKey)
|
|
12
|
+
* data = IV (12 bytes) || ciphertext || GCM auth tag (16 bytes)
|
|
13
|
+
*
|
|
14
|
+
* Decryption of `data` yields a serialized Temporal Payload protobuf, whose
|
|
15
|
+
* inner `encoding` metadata tells you how to interpret the inner bytes
|
|
16
|
+
* (`json/plain`, `binary/plain`, etc.). We hand-decode the Payload message
|
|
17
|
+
* (a trivial 2-field protobuf) instead of depending on `@temporalio/proto`,
|
|
18
|
+
* so the CLI stays dependency-clean and doesn't need a Temporal SDK peer.
|
|
19
|
+
*/
|
|
20
|
+
import { execFileSync } from "child_process";
|
|
21
|
+
import { webcrypto as crypto } from "node:crypto";
|
|
22
|
+
import { logSuccess, logWarn } from "./log.js";
|
|
23
|
+
// ── Encoding key resolution ────────────────────────────────────────────────
|
|
24
|
+
/**
|
|
25
|
+
* Read the Temporal encoding key from a Kubernetes secret in the given
|
|
26
|
+
* namespace. Returns `undefined` when kubectl is unavailable, the secret
|
|
27
|
+
* doesn't exist, or the caller isn't authenticated to the cluster.
|
|
28
|
+
*
|
|
29
|
+
* The K8s secret is preferred over Pulumi stack output because personal dev
|
|
30
|
+
* stacks ship a placeholder encoding key that cannot decrypt deployed
|
|
31
|
+
* payloads; the K8s secret is always authoritative for a given namespace.
|
|
32
|
+
*
|
|
33
|
+
* @param namespace - Kubernetes namespace matching the Temporal namespace
|
|
34
|
+
* (mesh apps use the same name for both).
|
|
35
|
+
*/
|
|
36
|
+
export function resolveTemporalEncodingKeyFromK8s(namespace) {
|
|
37
|
+
const secretName = `${namespace}-temporal-encoding-key`;
|
|
38
|
+
try {
|
|
39
|
+
const b64 = execFileSync("kubectl", [
|
|
40
|
+
"get",
|
|
41
|
+
"secret",
|
|
42
|
+
secretName,
|
|
43
|
+
"-n",
|
|
44
|
+
namespace,
|
|
45
|
+
"-o",
|
|
46
|
+
"jsonpath={.data.TEMPORAL_ENCODING_KEY}",
|
|
47
|
+
], { encoding: "utf-8", timeout: 10_000, stdio: ["pipe", "pipe", "pipe"] }).trim();
|
|
48
|
+
if (!b64)
|
|
49
|
+
return undefined;
|
|
50
|
+
return Buffer.from(b64, "base64").toString("utf-8");
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// kubectl missing, secret absent, or no cluster access — caller decides.
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// ── AES-256-GCM decryption ─────────────────────────────────────────────────
|
|
58
|
+
const ENCRYPTED_ENCODING = "binary/encrypted";
|
|
59
|
+
const IV_LENGTH = 12;
|
|
60
|
+
async function deriveKey(encodingKey) {
|
|
61
|
+
const keyData = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(encodingKey));
|
|
62
|
+
return crypto.subtle.importKey("raw", keyData, { name: "AES-GCM" }, false, ["decrypt"]);
|
|
63
|
+
}
|
|
64
|
+
async function aesGcmDecrypt(data, key) {
|
|
65
|
+
const iv = data.slice(0, IV_LENGTH);
|
|
66
|
+
const ciphertextWithTag = data.slice(IV_LENGTH);
|
|
67
|
+
const decrypted = await crypto.subtle.decrypt({ name: "AES-GCM", iv }, key, ciphertextWithTag);
|
|
68
|
+
return new Uint8Array(decrypted);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Build a decrypter closure for the given encoding key.
|
|
72
|
+
*/
|
|
73
|
+
export async function createPayloadDecrypter(encodingKey) {
|
|
74
|
+
const key = await deriveKey(encodingKey);
|
|
75
|
+
return async (payload) => {
|
|
76
|
+
if (!payload?.metadata)
|
|
77
|
+
return null;
|
|
78
|
+
const encodingBytes = payload.metadata["encoding"];
|
|
79
|
+
if (!encodingBytes)
|
|
80
|
+
return null;
|
|
81
|
+
const encoding = new TextDecoder().decode(encodingBytes);
|
|
82
|
+
if (encoding !== ENCRYPTED_ENCODING)
|
|
83
|
+
return null;
|
|
84
|
+
if (!payload.data)
|
|
85
|
+
return "[encrypted payload missing data]";
|
|
86
|
+
let inner;
|
|
87
|
+
try {
|
|
88
|
+
const decrypted = await aesGcmDecrypt(payload.data, key);
|
|
89
|
+
inner = decodePayloadProtobuf(decrypted);
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
93
|
+
return `[undecryptable: ${msg}]`;
|
|
94
|
+
}
|
|
95
|
+
return decodeInnerPayload(inner);
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Build a raw (Payload-in, Payload-out) decrypter for the given encoding key.
|
|
100
|
+
*
|
|
101
|
+
* This is the fixture-capture counterpart of {@link createPayloadDecrypter}:
|
|
102
|
+
* where that one renders a payload for human display (lossy — binary payloads
|
|
103
|
+
* become placeholders), this one returns the exact decrypted inner Payload so
|
|
104
|
+
* the bytes can be re-serialized into a replayable proto3-JSON history.
|
|
105
|
+
*/
|
|
106
|
+
export async function createRawPayloadDecrypter(encodingKey) {
|
|
107
|
+
const key = await deriveKey(encodingKey);
|
|
108
|
+
return async (payload) => {
|
|
109
|
+
if (!payload?.metadata)
|
|
110
|
+
return null;
|
|
111
|
+
const encodingBytes = payload.metadata["encoding"];
|
|
112
|
+
if (!encodingBytes)
|
|
113
|
+
return null;
|
|
114
|
+
const encoding = new TextDecoder().decode(encodingBytes);
|
|
115
|
+
if (encoding !== ENCRYPTED_ENCODING)
|
|
116
|
+
return null;
|
|
117
|
+
if (!payload.data) {
|
|
118
|
+
throw new Error("encrypted payload has no data to decrypt");
|
|
119
|
+
}
|
|
120
|
+
const decrypted = await aesGcmDecrypt(payload.data, key);
|
|
121
|
+
return decodePayloadProtobuf(decrypted);
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
// ── Hand-rolled Payload protobuf decoder ──────────────────────────────────
|
|
125
|
+
//
|
|
126
|
+
// temporal.api.common.v1.Payload has exactly two fields:
|
|
127
|
+
// message Payload {
|
|
128
|
+
// map<string, bytes> metadata = 1; // field 1, length-delimited
|
|
129
|
+
// bytes data = 2; // field 2, length-delimited
|
|
130
|
+
// }
|
|
131
|
+
// A protobuf `map<K, V>` is syntactic sugar for:
|
|
132
|
+
// repeated MapEntry { K key = 1; V value = 2; }
|
|
133
|
+
// so each metadata entry is itself a length-delimited submessage with two
|
|
134
|
+
// inner length-delimited fields.
|
|
135
|
+
//
|
|
136
|
+
// Decoding this by hand avoids pulling in `@temporalio/proto` as a peer dep.
|
|
137
|
+
function readVarint(buf, pos) {
|
|
138
|
+
let value = 0;
|
|
139
|
+
let shift = 0;
|
|
140
|
+
let next = pos;
|
|
141
|
+
while (next < buf.length) {
|
|
142
|
+
const byte = buf[next];
|
|
143
|
+
next += 1;
|
|
144
|
+
value |= (byte & 0x7f) << shift;
|
|
145
|
+
if ((byte & 0x80) === 0)
|
|
146
|
+
return { value, next };
|
|
147
|
+
shift += 7;
|
|
148
|
+
if (shift >= 32)
|
|
149
|
+
throw new Error("varint too large");
|
|
150
|
+
}
|
|
151
|
+
throw new Error("truncated varint");
|
|
152
|
+
}
|
|
153
|
+
function readLengthDelimited(buf, pos) {
|
|
154
|
+
const { value: length, next: afterLen } = readVarint(buf, pos);
|
|
155
|
+
const end = afterLen + length;
|
|
156
|
+
if (end > buf.length)
|
|
157
|
+
throw new Error("truncated length-delimited field");
|
|
158
|
+
return { bytes: buf.slice(afterLen, end), next: end };
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Decode a serialized `temporal.api.common.v1.Payload`.
|
|
162
|
+
*
|
|
163
|
+
* Unknown fields and wire types are skipped rather than throwing; we only
|
|
164
|
+
* need the two documented fields and Temporal's wire format is stable.
|
|
165
|
+
*/
|
|
166
|
+
function decodePayloadProtobuf(buf) {
|
|
167
|
+
const metadata = {};
|
|
168
|
+
let data;
|
|
169
|
+
let pos = 0;
|
|
170
|
+
while (pos < buf.length) {
|
|
171
|
+
const { value: tag, next: afterTag } = readVarint(buf, pos);
|
|
172
|
+
const fieldNumber = tag >>> 3;
|
|
173
|
+
const wireType = tag & 0x7;
|
|
174
|
+
pos = afterTag;
|
|
175
|
+
if (wireType === 2) {
|
|
176
|
+
const { bytes, next } = readLengthDelimited(buf, pos);
|
|
177
|
+
pos = next;
|
|
178
|
+
if (fieldNumber === 1) {
|
|
179
|
+
const entry = decodeMetadataEntry(bytes);
|
|
180
|
+
if (entry)
|
|
181
|
+
metadata[entry.key] = entry.value;
|
|
182
|
+
}
|
|
183
|
+
else if (fieldNumber === 2) {
|
|
184
|
+
data = bytes;
|
|
185
|
+
}
|
|
186
|
+
// Other fields: ignore.
|
|
187
|
+
}
|
|
188
|
+
else if (wireType === 0) {
|
|
189
|
+
// varint — skip
|
|
190
|
+
pos = readVarint(buf, pos).next;
|
|
191
|
+
}
|
|
192
|
+
else if (wireType === 1) {
|
|
193
|
+
pos += 8; // fixed64
|
|
194
|
+
}
|
|
195
|
+
else if (wireType === 5) {
|
|
196
|
+
pos += 4; // fixed32
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
throw new Error(`unsupported wire type ${wireType} at pos ${pos}`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return { metadata, data: data ?? new Uint8Array(0) };
|
|
203
|
+
}
|
|
204
|
+
function decodeMetadataEntry(buf) {
|
|
205
|
+
let key;
|
|
206
|
+
let value;
|
|
207
|
+
let pos = 0;
|
|
208
|
+
while (pos < buf.length) {
|
|
209
|
+
const { value: tag, next: afterTag } = readVarint(buf, pos);
|
|
210
|
+
const fieldNumber = tag >>> 3;
|
|
211
|
+
const wireType = tag & 0x7;
|
|
212
|
+
pos = afterTag;
|
|
213
|
+
if (wireType !== 2) {
|
|
214
|
+
// Skip unsupported fields defensively.
|
|
215
|
+
if (wireType === 0)
|
|
216
|
+
pos = readVarint(buf, pos).next;
|
|
217
|
+
else if (wireType === 1)
|
|
218
|
+
pos += 8;
|
|
219
|
+
else if (wireType === 5)
|
|
220
|
+
pos += 4;
|
|
221
|
+
else
|
|
222
|
+
throw new Error(`unsupported metadata wire type ${wireType}`);
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
const { bytes, next } = readLengthDelimited(buf, pos);
|
|
226
|
+
pos = next;
|
|
227
|
+
if (fieldNumber === 1)
|
|
228
|
+
key = new TextDecoder().decode(bytes);
|
|
229
|
+
else if (fieldNumber === 2)
|
|
230
|
+
value = bytes;
|
|
231
|
+
}
|
|
232
|
+
if (key === undefined || value === undefined)
|
|
233
|
+
return null;
|
|
234
|
+
return { key, value };
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Render a decrypted inner Payload as a human-readable string.
|
|
238
|
+
*
|
|
239
|
+
* Handles the common encodings Mesh workers emit:
|
|
240
|
+
* - `json/plain` → pretty-printed JSON
|
|
241
|
+
* - `binary/null` → literal `null`
|
|
242
|
+
* - `binary/plain` → `[binary N bytes]`
|
|
243
|
+
* - anything else → `[encoding=X, N bytes]`
|
|
244
|
+
*/
|
|
245
|
+
function decodeInnerPayload(payload) {
|
|
246
|
+
const meta = payload.metadata ?? {};
|
|
247
|
+
const encodingBytes = meta["encoding"];
|
|
248
|
+
const encoding = encodingBytes
|
|
249
|
+
? new TextDecoder().decode(encodingBytes)
|
|
250
|
+
: "unknown";
|
|
251
|
+
const data = payload.data ?? new Uint8Array(0);
|
|
252
|
+
if (encoding === "binary/null")
|
|
253
|
+
return "null";
|
|
254
|
+
if (encoding === "json/plain") {
|
|
255
|
+
const text = new TextDecoder().decode(data);
|
|
256
|
+
try {
|
|
257
|
+
return JSON.stringify(JSON.parse(text), null, 2);
|
|
258
|
+
}
|
|
259
|
+
catch {
|
|
260
|
+
// Not valid JSON despite the encoding claim — surface the raw text so
|
|
261
|
+
// the debugger sees whatever garbage the worker actually wrote.
|
|
262
|
+
return text;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (encoding === "binary/plain")
|
|
266
|
+
return `[binary, ${data.length} bytes]`;
|
|
267
|
+
return `[encoding=${encoding}, ${data.length} bytes]`;
|
|
268
|
+
}
|
|
269
|
+
// ── High-level helper ──────────────────────────────────────────────────────
|
|
270
|
+
/**
|
|
271
|
+
* Resolve the Temporal encoding key for a namespace, logging where it came
|
|
272
|
+
* from (or why it couldn't be found). Prefer the K8s secret (authoritative for
|
|
273
|
+
* the namespace); fall back to an explicit TEMPORAL_ENCODING_KEY env var. The
|
|
274
|
+
* env fallback lets you decrypt a workflow's history OFFLINE — e.g. to
|
|
275
|
+
* reconstruct a conversation, or capture a replay fixture, whose worker can no
|
|
276
|
+
* longer replay it — using the key from a running `mesh dev` worker env when
|
|
277
|
+
* kubectl/cluster access isn't set up.
|
|
278
|
+
*
|
|
279
|
+
* Returns `undefined` when neither source yields a key.
|
|
280
|
+
*/
|
|
281
|
+
export function resolveEncodingKey(namespace) {
|
|
282
|
+
const fromK8s = resolveTemporalEncodingKeyFromK8s(namespace);
|
|
283
|
+
const key = fromK8s ?? process.env.TEMPORAL_ENCODING_KEY;
|
|
284
|
+
if (!key) {
|
|
285
|
+
logWarn(`Could not read TEMPORAL_ENCODING_KEY from secret ` +
|
|
286
|
+
`${namespace}/${namespace}-temporal-encoding-key, and TEMPORAL_ENCODING_KEY ` +
|
|
287
|
+
"is not set. Configure kubectl (namespace read " +
|
|
288
|
+
"access), or export TEMPORAL_ENCODING_KEY (e.g. from a `mesh dev` worker env).");
|
|
289
|
+
return undefined;
|
|
290
|
+
}
|
|
291
|
+
logSuccess(fromK8s
|
|
292
|
+
? `Resolved encoding key from ${namespace}-temporal-encoding-key`
|
|
293
|
+
: "Resolved encoding key from TEMPORAL_ENCODING_KEY env");
|
|
294
|
+
return key;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Resolve the encoding key and build a decrypter for the given namespace.
|
|
298
|
+
* Logs a warning and returns `undefined` when the key can't be read; callers
|
|
299
|
+
* should fall back to printing events without payloads.
|
|
300
|
+
*/
|
|
301
|
+
export async function buildDecrypterForNamespace(namespace) {
|
|
302
|
+
const key = resolveEncodingKey(namespace);
|
|
303
|
+
if (!key)
|
|
304
|
+
return undefined;
|
|
305
|
+
return createPayloadDecrypter(key);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Resolve the encoding key and build a RAW (Payload-in/Payload-out) decrypter
|
|
309
|
+
* for the given namespace — used by `capture-history` to decrypt payloads back
|
|
310
|
+
* into replayable proto bytes. Returns `undefined` when the key can't be read;
|
|
311
|
+
* callers decide whether that's fatal.
|
|
312
|
+
*/
|
|
313
|
+
export async function buildRawDecrypterForNamespace(namespace) {
|
|
314
|
+
const key = resolveEncodingKey(namespace);
|
|
315
|
+
if (!key)
|
|
316
|
+
return undefined;
|
|
317
|
+
return createRawPayloadDecrypter(key);
|
|
318
|
+
}
|
|
319
|
+
//# sourceMappingURL=temporal-codec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temporal-codec.js","sourceRoot":"","sources":["../../../src/utils/temporal-codec.ts"],"names":[],"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C;IACzD,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,CACL,mDAAmD;YACjD,GAAG,SAAS,IAAI,SAAS,oDAAoD;YAC7E,gDAAgD;YAChD,+EAA+E,CAClF,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,UAAU,CACR,OAAO;QACL,CAAC,CAAC,8BAA8B,SAAS,wBAAwB;QACjE,CAAC,CAAC,sDAAsD,CAC3D,CAAC;IACF,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,SAAiB;IAEjB,MAAM,GAAG,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC1C,IAAI,CAAC,GAAG;QAAE,OAAO,SAAS,CAAC;IAC3B,OAAO,sBAAsB,CAAC,GAAG,CAAC,CAAC;AACrC,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,SAAiB;IAEjB,MAAM,GAAG,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC1C,IAAI,CAAC,GAAG;QAAE,OAAO,SAAS,CAAC;IAC3B,OAAO,yBAAyB,CAAC,GAAG,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ownership contract for the tunnel runner (MESH-2407).
|
|
3
|
+
*
|
|
4
|
+
* Three silent-dead-tunnel incidents in ten days (MESH-2169, MESH-2014, the
|
|
5
|
+
* #2991 re-review) shared one enabler: readiness was inferred from "something
|
|
6
|
+
* accepts TCP on the port". That conflates LIVENESS (a listener exists) with
|
|
7
|
+
* OWNERSHIP (the listener is OUR runner, wired to OUR SOCKS upstream). This
|
|
8
|
+
* module is the ownership half of the contract:
|
|
9
|
+
*
|
|
10
|
+
* - The runner that actually binds the forwarder ports writes a MANIFEST
|
|
11
|
+
* (pid, process-group id, a per-run random token, a loopback control port)
|
|
12
|
+
* and answers a one-shot control handshake with that token plus the ports
|
|
13
|
+
* it is listening on — read from its in-process `net.Server`s, so the
|
|
14
|
+
* answer can't be faked by a foreign listener and probing it opens no
|
|
15
|
+
* SOCKS→VPC data connection.
|
|
16
|
+
* - Callers verify ownership (manifest → live pid → control handshake →
|
|
17
|
+
* token/socks-port/port-coverage match) instead of dialing ports. A port
|
|
18
|
+
* that accepts TCP without passing the handshake is a SQUATTER and must be
|
|
19
|
+
* a loud failure, never adopt-and-continue.
|
|
20
|
+
* - Teardown signals process GROUPS recorded here (plus argv-discovered
|
|
21
|
+
* runners), so no kill path can orphan a grandchild with ports still bound.
|
|
22
|
+
*/
|
|
23
|
+
import * as net from 'node:net';
|
|
24
|
+
/** Written by the runner (the process that binds the ports) — never by callers. */
|
|
25
|
+
export interface RunnerManifest {
|
|
26
|
+
tenant: string;
|
|
27
|
+
/** Pid of the runner process itself (the port owner), NOT its launcher. */
|
|
28
|
+
pid: number;
|
|
29
|
+
/** Process-group id — all teardown paths signal `-pgid`, never a bare pid. */
|
|
30
|
+
pgid: number;
|
|
31
|
+
/** Per-run random token; the control handshake must echo it. */
|
|
32
|
+
token: string;
|
|
33
|
+
/** Loopback port answering the one-shot ownership handshake. */
|
|
34
|
+
controlPort: number;
|
|
35
|
+
/** SOCKS port the runner's forwarders dial (must match the live daemon's). */
|
|
36
|
+
socksPort: number;
|
|
37
|
+
/** Forwarder ports the runner is responsible for. */
|
|
38
|
+
ports: number[];
|
|
39
|
+
startedAt: string;
|
|
40
|
+
}
|
|
41
|
+
/** What the runner's control endpoint answers with. */
|
|
42
|
+
export interface ControlResponse {
|
|
43
|
+
token: string;
|
|
44
|
+
tenant: string;
|
|
45
|
+
pid: number;
|
|
46
|
+
socksPort: number;
|
|
47
|
+
/** Ports whose in-process `net.Server` is currently listening. */
|
|
48
|
+
listening: number[];
|
|
49
|
+
/** port → error code for forwarders that failed to bind (e.g. EADDRINUSE). */
|
|
50
|
+
bindErrors: Record<string, string>;
|
|
51
|
+
}
|
|
52
|
+
export declare function mintRunnerToken(): string;
|
|
53
|
+
export declare function readRunnerManifest(file: string): RunnerManifest | null;
|
|
54
|
+
export declare function writeRunnerManifest(file: string, manifest: RunnerManifest): void;
|
|
55
|
+
/**
|
|
56
|
+
* Remove the manifest — but only if it is still OURS (`token` matches). A dying
|
|
57
|
+
* runner must not clobber the manifest of a newer runner that already replaced it.
|
|
58
|
+
* Omit `token` for teardown paths that own the whole tenant state.
|
|
59
|
+
*/
|
|
60
|
+
export declare function clearRunnerManifest(file: string, token?: string): void;
|
|
61
|
+
/** Process-group id of a pid via `ps` (macOS/BSD); null when undiscoverable. */
|
|
62
|
+
export declare function getProcessGroupId(pid: number): number | null;
|
|
63
|
+
/**
|
|
64
|
+
* Pids of tunnel-runner processes for a tenant, parsed from `ps` output
|
|
65
|
+
* (`pid command` lines). Matches both `__run` and the legacy `__supervise`
|
|
66
|
+
* argv, and skips `exclude` (the calling process, when it IS the runner).
|
|
67
|
+
* Pure for unit tests; `discoverRunnerPids` feeds it live `ps` output.
|
|
68
|
+
*/
|
|
69
|
+
export declare function parseRunnerPidsFromPs(psOutput: string, tenant: string, exclude?: number): number[];
|
|
70
|
+
/** Live argv discovery of runner pids for a tenant (empty when `ps` fails). */
|
|
71
|
+
export declare function discoverRunnerPids(tenant: string, exclude?: number): number[];
|
|
72
|
+
/**
|
|
73
|
+
* Start the runner's one-shot control endpoint on a loopback ephemeral port.
|
|
74
|
+
* Each connection gets one JSON line (the live payload) and is closed — no
|
|
75
|
+
* protocol state, nothing routable, and probing it touches no data plane.
|
|
76
|
+
*/
|
|
77
|
+
export declare function startControlServer(payload: () => ControlResponse): Promise<{
|
|
78
|
+
server: net.Server;
|
|
79
|
+
port: number;
|
|
80
|
+
}>;
|
|
81
|
+
/** Dial the control endpoint and parse its one-line JSON answer; null on any failure. */
|
|
82
|
+
export declare function queryControl(port: number, timeoutMs?: number): Promise<ControlResponse | null>;
|
|
83
|
+
export interface OwnershipCheck {
|
|
84
|
+
ok: boolean;
|
|
85
|
+
/** Machine-readable failure reason ("" when ok). */
|
|
86
|
+
reason: string;
|
|
87
|
+
/** The control answer, when the handshake got that far. */
|
|
88
|
+
resp?: ControlResponse;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The ownership handshake: manifest → live pid → control endpoint → token,
|
|
92
|
+
* SOCKS port, and port coverage all match. Anything less is NOT ours — the
|
|
93
|
+
* caller must treat an accepting-but-unowned port as a squatter, never reuse it.
|
|
94
|
+
*/
|
|
95
|
+
export declare function verifyRunnerOwnership(args: {
|
|
96
|
+
manifest: RunnerManifest | null;
|
|
97
|
+
expectedSocksPort: number;
|
|
98
|
+
expectedPorts: number[];
|
|
99
|
+
isPidAlive?: (pid: number) => boolean;
|
|
100
|
+
query?: (port: number) => Promise<ControlResponse | null>;
|
|
101
|
+
}): Promise<OwnershipCheck>;
|
|
102
|
+
/**
|
|
103
|
+
* Poll an ownership check until it passes or `deadlineMs` of wall-clock elapses;
|
|
104
|
+
* returns the last (failing) check otherwise. The deadline bounds TIME, not
|
|
105
|
+
* rounds — each check can itself cost up to the control-query timeout, so a
|
|
106
|
+
* round-counting loop would multiply the promised deadline several-fold.
|
|
107
|
+
* Retrying also matters for correctness, not just latency: two failure reasons
|
|
108
|
+
* are transient by design (`ports-not-listening:` while the runner's self-heal
|
|
109
|
+
* loop rebinds a forwarder, `no-control-answer` under accept-backlog pressure),
|
|
110
|
+
* and a single-shot sample of a healthy shared runner in one of those windows
|
|
111
|
+
* would tear it down for every concurrent session on the tenant (MESH-2014).
|
|
112
|
+
*/
|
|
113
|
+
export declare function pollOwnership(check: () => Promise<OwnershipCheck>, deadlineMs: number): Promise<OwnershipCheck>;
|
|
114
|
+
/** Best-effort `lsof` description of what holds a port ("cmd (pid N)"); null if unknown. */
|
|
115
|
+
export declare function describePortOwner(port: number): string | null;
|
|
116
|
+
export interface SquattedPort {
|
|
117
|
+
port: number;
|
|
118
|
+
owner: string | null;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Of `ports`, the ones something is accepting TCP on. Called AFTER ownership
|
|
122
|
+
* failed / teardown ran, so every hit is a foreign or stale listener.
|
|
123
|
+
*/
|
|
124
|
+
export declare function findSquattedPorts(ports: number[], accepts: (port: number) => Promise<boolean>): Promise<SquattedPort[]>;
|
|
125
|
+
/**
|
|
126
|
+
* The loud-failure text for a squatted tunnel port (`mesh dev doctor` style:
|
|
127
|
+
* what is wrong, why we refuse, exactly what to run). Never adopt-and-continue.
|
|
128
|
+
*/
|
|
129
|
+
export declare function buildSquatterError(tenant: string, squatted: SquattedPort[], detail?: string): string;
|
|
130
|
+
//# sourceMappingURL=tunnel-ownership.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tunnel-ownership.d.ts","sourceRoot":"","sources":["../../../src/utils/tunnel-ownership.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAIhC,mFAAmF;AACnF,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,GAAG,EAAE,MAAM,CAAC;IACZ,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,WAAW,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,SAAS,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,uDAAuD;AACvD,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,8EAA8E;IAC9E,UAAU,EA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