@mesh-tech/mesh-cli 0.20.1 → 0.20.3
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/README.md +6 -5
- package/dist/bin/mesh.d.ts +0 -12
- package/dist/bin/mesh.js +99 -50
- package/dist/bin/mesh.js.map +2 -3
- package/dist/build-info.json +2 -2
- package/dist/src/commands/agent-api-client.d.ts +0 -70
- package/dist/src/commands/agent-api-client.js +0 -80
- package/dist/src/commands/app-check.d.ts +0 -56
- package/dist/src/commands/app-check.js +0 -72
- package/dist/src/commands/artifacts.d.ts +0 -11
- package/dist/src/commands/artifacts.js +0 -33
- package/dist/src/commands/cluster.d.ts +0 -39
- package/dist/src/commands/cluster.js +0 -73
- package/dist/src/commands/conversations.d.ts +0 -36
- package/dist/src/commands/conversations.js +0 -59
- package/dist/src/commands/create-app.d.ts +4 -88
- package/dist/src/commands/create-app.js +16 -155
- package/dist/src/commands/db/connect.d.ts +0 -7
- package/dist/src/commands/db/connect.js +0 -9
- package/dist/src/commands/db/credentials.d.ts +0 -7
- package/dist/src/commands/db/credentials.js +0 -10
- package/dist/src/commands/db/env.d.ts +0 -6
- package/dist/src/commands/db/env.js +0 -14
- package/dist/src/commands/db/exec.d.ts +0 -43
- package/dist/src/commands/db/exec.js +0 -69
- package/dist/src/commands/db/index.d.ts +0 -10
- package/dist/src/commands/db/index.js +0 -10
- package/dist/src/commands/db/psql.d.ts +0 -7
- package/dist/src/commands/db/psql.js +0 -18
- package/dist/src/commands/deploy.d.ts +0 -38
- package/dist/src/commands/deploy.js +1 -76
- package/dist/src/commands/dev-doctor.d.ts +0 -82
- package/dist/src/commands/dev-doctor.js +3 -132
- package/dist/src/commands/dev-launch.d.ts +0 -52
- package/dist/src/commands/dev-launch.js +0 -56
- package/dist/src/commands/dev-token-server.d.ts +0 -18
- package/dist/src/commands/dev-token-server.js +1 -24
- package/dist/src/commands/dev.d.ts +0 -246
- package/dist/src/commands/dev.js +5 -963
- package/dist/src/commands/docs.d.ts +0 -1
- package/dist/src/commands/docs.js +0 -12
- package/dist/src/commands/hub/index.d.ts +0 -60
- package/dist/src/commands/hub/index.js +2 -139
- package/dist/src/commands/init/wizard.d.ts +5 -116
- package/dist/src/commands/init/wizard.js +42 -110
- package/dist/src/commands/init.d.ts +0 -55
- package/dist/src/commands/init.js +0 -70
- package/dist/src/commands/install-shim.d.ts +0 -23
- package/dist/src/commands/install-shim.js +2 -29
- package/dist/src/commands/local/auth-provision.d.ts +0 -80
- package/dist/src/commands/local/auth-provision.js +0 -109
- package/dist/src/commands/local/dev-local.d.ts +0 -91
- package/dist/src/commands/local/dev-local.js +0 -147
- package/dist/src/commands/local/docker-runner.d.ts +0 -22
- package/dist/src/commands/local/docker-runner.js +2 -35
- package/dist/src/commands/local/helpers.d.ts +0 -14
- package/dist/src/commands/local/helpers.js +0 -13
- package/dist/src/commands/local/hub-local.d.ts +0 -96
- package/dist/src/commands/local/hub-local.js +0 -111
- package/dist/src/commands/local/index.d.ts +0 -14
- package/dist/src/commands/local/index.js +0 -86
- package/dist/src/commands/local/mocks.d.ts +0 -269
- package/dist/src/commands/local/mocks.js +1 -274
- package/dist/src/commands/local/seed-hub-catalog.d.ts +0 -25
- package/dist/src/commands/local/seed-hub-catalog.js +0 -41
- package/dist/src/commands/local/seed-zitadel.d.ts +0 -82
- package/dist/src/commands/local/seed-zitadel.js +0 -158
- package/dist/src/commands/local/seed.d.ts +0 -64
- package/dist/src/commands/local/seed.js +0 -78
- package/dist/src/commands/local/stack.d.ts +0 -141
- package/dist/src/commands/local/stack.js +0 -153
- package/dist/src/commands/login.d.ts +0 -265
- package/dist/src/commands/login.js +4 -418
- package/dist/src/commands/peer-addressing.d.ts +0 -39
- package/dist/src/commands/peer-addressing.js +0 -37
- package/dist/src/commands/port-ownership.d.ts +0 -44
- package/dist/src/commands/port-ownership.js +0 -47
- package/dist/src/commands/registry-publish.d.ts +0 -1
- package/dist/src/commands/registry-publish.js +0 -46
- package/dist/src/commands/registry.d.ts +4 -237
- package/dist/src/commands/registry.js +2 -316
- package/dist/src/commands/secrets/exec.d.ts +0 -16
- package/dist/src/commands/secrets/exec.js +0 -24
- package/dist/src/commands/secrets/index.d.ts +0 -9
- package/dist/src/commands/secrets/index.js +0 -10
- package/dist/src/commands/secrets/migrate-config.d.ts +0 -17
- package/dist/src/commands/secrets/migrate-config.js +0 -40
- package/dist/src/commands/secrets/reindex.d.ts +0 -38
- package/dist/src/commands/secrets/reindex.js +0 -39
- package/dist/src/commands/secrets/set.d.ts +0 -47
- package/dist/src/commands/secrets/set.js +0 -107
- package/dist/src/commands/site.d.ts +0 -1
- package/dist/src/commands/site.js +0 -61
- package/dist/src/commands/skills.d.ts +0 -61
- package/dist/src/commands/skills.js +0 -83
- package/dist/src/commands/stack.d.ts +0 -15
- package/dist/src/commands/stack.js +1 -128
- package/dist/src/commands/temporal.d.ts +0 -30
- package/dist/src/commands/temporal.js.map +0 -1
- package/dist/src/commands/tenant.d.ts +0 -31
- package/dist/src/commands/tenant.js +0 -55
- package/dist/src/commands/tunnel/index.d.ts +0 -40
- package/dist/src/commands/tunnel/index.js +0 -141
- package/dist/src/commands/vcs/clone.d.ts +0 -1
- package/dist/src/commands/vcs/clone.js +0 -4
- package/dist/src/commands/vcs/common.d.ts +0 -32
- package/dist/src/commands/vcs/common.js +0 -41
- package/dist/src/commands/vcs/drafts.d.ts +0 -1
- package/dist/src/commands/vcs/drafts.js +0 -1
- package/dist/src/commands/vcs/get.d.ts +0 -1
- package/dist/src/commands/vcs/get.js +0 -11
- package/dist/src/commands/vcs/index.d.ts +0 -1
- package/dist/src/commands/vcs/index.js +0 -1
- package/dist/src/commands/vcs/propose.d.ts +0 -26
- package/dist/src/commands/vcs/propose.js +3 -34
- package/dist/src/commands/vcs/review.d.ts +0 -1
- package/dist/src/commands/vcs/review.js +0 -1
- package/dist/src/commands/vcs/rm.d.ts +0 -11
- package/dist/src/commands/vcs/rm.js +0 -14
- package/dist/src/commands/vcs-enrich.d.ts +0 -12
- package/dist/src/commands/vcs-enrich.js +0 -12
- package/dist/src/commands/vpn/index.d.ts +0 -17
- package/dist/src/commands/vpn/index.js +0 -102
- package/dist/src/commands/vpn/tunnel.d.ts +0 -9
- package/dist/src/commands/vpn/tunnel.js +0 -37
- package/dist/src/commands/workflow.d.ts +0 -22
- package/dist/src/commands/workflow.js +0 -80
- package/dist/src/docs/assemble.d.ts +0 -117
- package/dist/src/docs/assemble.js +0 -142
- package/dist/src/docs/cli-reference.d.ts +0 -58
- package/dist/src/docs/cli-reference.js +0 -77
- package/dist/src/docs/discover.d.ts +0 -40
- package/dist/src/docs/discover.js +2 -60
- package/dist/src/docs/portal.d.ts +0 -44
- package/dist/src/docs/portal.js +0 -49
- package/dist/src/docs/registry-docs.d.ts +0 -29
- package/dist/src/docs/registry-docs.js +0 -40
- package/dist/src/docs/schema.d.ts +0 -36
- package/dist/src/docs/schema.js +0 -52
- package/dist/src/docs/serve.d.ts +0 -18
- package/dist/src/docs/serve.js +2 -30
- package/dist/src/docs/start.d.ts +0 -42
- package/dist/src/docs/start.js +0 -70
- package/dist/src/eval/agent-eval.d.mts +0 -12
- package/dist/src/eval/agent-eval.mjs +0 -22
- package/dist/src/index.d.ts +0 -6
- package/dist/src/index.js.map +0 -1
- package/dist/src/program.d.ts +0 -20
- package/dist/src/program.js +0 -24
- package/dist/src/utils/auth-preflight.d.ts +0 -137
- package/dist/src/utils/auth-preflight.js +0 -149
- package/dist/src/utils/aws-auth.d.ts +0 -163
- package/dist/src/utils/aws-auth.js +3 -232
- package/dist/src/utils/bastion.d.ts +0 -27
- package/dist/src/utils/bastion.js +0 -28
- package/dist/src/utils/build-info.d.ts +0 -22
- package/dist/src/utils/build-info.js +0 -27
- package/dist/src/utils/cache-home.d.ts +0 -23
- package/dist/src/utils/cache-home.js +0 -25
- package/dist/src/utils/capture-history.d.ts +0 -54
- package/dist/src/utils/capture-history.js +1 -55
- package/dist/src/utils/context.d.ts +0 -23
- package/dist/src/utils/context.js +0 -43
- package/dist/src/utils/credentials.d.ts +0 -38
- package/dist/src/utils/credentials.js +0 -39
- package/dist/src/utils/deploy-preflight.d.ts +0 -38
- package/dist/src/utils/deploy-preflight.js +1 -71
- package/dist/src/utils/errors.d.ts +0 -53
- package/dist/src/utils/errors.js +0 -49
- package/dist/src/utils/first-party-contexts.d.ts +0 -38
- package/dist/src/utils/first-party-contexts.js +0 -44
- package/dist/src/utils/index.d.ts +0 -4
- package/dist/src/utils/index.js +0 -4
- package/dist/src/utils/kubeconfig.d.ts +0 -40
- package/dist/src/utils/kubeconfig.js +0 -44
- package/dist/src/utils/log.d.ts +0 -20
- package/dist/src/utils/log.js +0 -20
- package/dist/src/utils/mesh-json.d.ts +0 -46
- package/dist/src/utils/mesh-json.js +0 -39
- package/dist/src/utils/pid.d.ts +0 -42
- package/dist/src/utils/pid.js +0 -48
- package/dist/src/utils/pulumi-run.d.ts +0 -14
- package/dist/src/utils/pulumi-run.js +0 -42
- package/dist/src/utils/pulumi.d.ts +0 -34
- package/dist/src/utils/pulumi.js +0 -38
- package/dist/src/utils/reachability.d.ts +0 -27
- package/dist/src/utils/reachability.js +0 -40
- package/dist/src/utils/recover-conversation.d.ts +0 -110
- package/dist/src/utils/recover-conversation.js +0 -108
- package/dist/src/utils/registry-broker.d.ts +5 -84
- package/dist/src/utils/registry-broker.js +0 -62
- package/dist/src/utils/registry-identity.d.ts +0 -149
- package/dist/src/utils/registry-identity.js +0 -143
- package/dist/src/utils/scaffold-versions.d.ts +0 -41
- package/dist/src/utils/scaffold-versions.js +0 -42
- package/dist/src/utils/socks-forward.d.ts +0 -24
- package/dist/src/utils/socks-forward.js +2 -25
- package/dist/src/utils/stack-flag.d.ts +0 -13
- package/dist/src/utils/stack-flag.js +0 -21
- package/dist/src/utils/tailscale-targets.d.ts +0 -37
- package/dist/src/utils/tailscale-targets.js +0 -33
- package/dist/src/utils/tailscale.d.ts +0 -177
- package/dist/src/utils/tailscale.js +6 -337
- package/dist/src/utils/temporal-auth.d.ts +0 -41
- package/dist/src/utils/temporal-auth.js +0 -52
- package/dist/src/utils/temporal-codec.d.ts +0 -89
- package/dist/src/utils/temporal-codec.js.map +0 -1
- package/dist/src/utils/tunnel-ownership.d.ts +0 -79
- package/dist/src/utils/tunnel-ownership.js +0 -74
- package/dist/src/utils/vpn-join.d.ts +0 -16
- package/dist/src/utils/vpn-join.js +0 -17
- package/dist/src/utils/vpn.d.ts +0 -42
- package/dist/src/utils/vpn.js +0 -52
- package/dist/src/utils/workflow-fingerprint.d.ts +0 -39
- package/dist/src/utils/workflow-fingerprint.js +1 -63
- package/dist/src/utils/worktree-identity.d.ts +0 -62
- package/dist/src/utils/worktree-identity.js +0 -88
- package/package.json +1 -1
- package/skills/core/SKILL.md +10 -11
- package/templates/api-auth/api/src/index.ts.hbs +1 -1
- package/templates/api-auth/api/src/spicedb-http-provider.ts.hbs +2 -2
- package/templates/api-role-gating/api/src/authn.ts.hbs +2 -2
- package/templates/api-role-gating/index.ts.hbs +1 -1
- package/templates/api-role-gating/skills/develop/SKILL.md.hbs +1 -1
- package/templates/platform-repo/core/Pulumi.{{tenant}}-{{env}}.yaml.hbs +2 -2
- package/templates/platform-repo/platform/index.ts +1 -1
- package/dist/bin/mesh.d.ts.map +0 -1
- package/dist/src/commands/agent-api-client.d.ts.map +0 -1
- package/dist/src/commands/agent-api-client.js.map +0 -1
- package/dist/src/commands/app-check.d.ts.map +0 -1
- package/dist/src/commands/app-check.js.map +0 -1
- package/dist/src/commands/artifacts.d.ts.map +0 -1
- package/dist/src/commands/artifacts.js.map +0 -1
- package/dist/src/commands/cluster.d.ts.map +0 -1
- package/dist/src/commands/cluster.js.map +0 -1
- package/dist/src/commands/conversations.d.ts.map +0 -1
- package/dist/src/commands/conversations.js.map +0 -1
- package/dist/src/commands/create-app.d.ts.map +0 -1
- package/dist/src/commands/create-app.js.map +0 -1
- package/dist/src/commands/db/connect.d.ts.map +0 -1
- package/dist/src/commands/db/connect.js.map +0 -1
- package/dist/src/commands/db/credentials.d.ts.map +0 -1
- package/dist/src/commands/db/credentials.js.map +0 -1
- package/dist/src/commands/db/env.d.ts.map +0 -1
- package/dist/src/commands/db/env.js.map +0 -1
- package/dist/src/commands/db/exec.d.ts.map +0 -1
- package/dist/src/commands/db/exec.js.map +0 -1
- package/dist/src/commands/db/index.d.ts.map +0 -1
- package/dist/src/commands/db/index.js.map +0 -1
- package/dist/src/commands/db/psql.d.ts.map +0 -1
- package/dist/src/commands/db/psql.js.map +0 -1
- package/dist/src/commands/deploy.d.ts.map +0 -1
- package/dist/src/commands/deploy.js.map +0 -1
- package/dist/src/commands/dev-doctor.d.ts.map +0 -1
- package/dist/src/commands/dev-doctor.js.map +0 -1
- package/dist/src/commands/dev-launch.d.ts.map +0 -1
- package/dist/src/commands/dev-launch.js.map +0 -1
- package/dist/src/commands/dev-token-server.d.ts.map +0 -1
- package/dist/src/commands/dev-token-server.js.map +0 -1
- package/dist/src/commands/dev.d.ts.map +0 -1
- package/dist/src/commands/dev.js.map +0 -1
- package/dist/src/commands/docs.d.ts.map +0 -1
- package/dist/src/commands/docs.js.map +0 -1
- package/dist/src/commands/hub/index.d.ts.map +0 -1
- package/dist/src/commands/hub/index.js.map +0 -1
- package/dist/src/commands/init/wizard.d.ts.map +0 -1
- package/dist/src/commands/init/wizard.js.map +0 -1
- package/dist/src/commands/init.d.ts.map +0 -1
- package/dist/src/commands/init.js.map +0 -1
- package/dist/src/commands/install-shim.d.ts.map +0 -1
- package/dist/src/commands/install-shim.js.map +0 -1
- package/dist/src/commands/local/auth-provision.d.ts.map +0 -1
- package/dist/src/commands/local/auth-provision.js.map +0 -1
- package/dist/src/commands/local/dev-local.d.ts.map +0 -1
- package/dist/src/commands/local/dev-local.js.map +0 -1
- package/dist/src/commands/local/docker-runner.d.ts.map +0 -1
- package/dist/src/commands/local/docker-runner.js.map +0 -1
- package/dist/src/commands/local/helpers.d.ts.map +0 -1
- package/dist/src/commands/local/helpers.js.map +0 -1
- package/dist/src/commands/local/hub-local.d.ts.map +0 -1
- package/dist/src/commands/local/hub-local.js.map +0 -1
- package/dist/src/commands/local/index.d.ts.map +0 -1
- package/dist/src/commands/local/index.js.map +0 -1
- package/dist/src/commands/local/mocks.d.ts.map +0 -1
- package/dist/src/commands/local/mocks.js.map +0 -1
- package/dist/src/commands/local/seed-hub-catalog.d.ts.map +0 -1
- package/dist/src/commands/local/seed-hub-catalog.js.map +0 -1
- package/dist/src/commands/local/seed-zitadel.d.ts.map +0 -1
- package/dist/src/commands/local/seed-zitadel.js.map +0 -1
- package/dist/src/commands/local/seed.d.ts.map +0 -1
- package/dist/src/commands/local/seed.js.map +0 -1
- package/dist/src/commands/local/stack.d.ts.map +0 -1
- package/dist/src/commands/local/stack.js.map +0 -1
- package/dist/src/commands/login.d.ts.map +0 -1
- package/dist/src/commands/login.js.map +0 -1
- package/dist/src/commands/peer-addressing.d.ts.map +0 -1
- package/dist/src/commands/peer-addressing.js.map +0 -1
- package/dist/src/commands/port-ownership.d.ts.map +0 -1
- package/dist/src/commands/port-ownership.js.map +0 -1
- package/dist/src/commands/registry-publish.d.ts.map +0 -1
- package/dist/src/commands/registry-publish.js.map +0 -1
- package/dist/src/commands/registry.d.ts.map +0 -1
- package/dist/src/commands/registry.js.map +0 -1
- package/dist/src/commands/secrets/exec.d.ts.map +0 -1
- package/dist/src/commands/secrets/exec.js.map +0 -1
- package/dist/src/commands/secrets/index.d.ts.map +0 -1
- package/dist/src/commands/secrets/index.js.map +0 -1
- package/dist/src/commands/secrets/migrate-config.d.ts.map +0 -1
- package/dist/src/commands/secrets/migrate-config.js.map +0 -1
- package/dist/src/commands/secrets/reindex.d.ts.map +0 -1
- package/dist/src/commands/secrets/reindex.js.map +0 -1
- package/dist/src/commands/secrets/set.d.ts.map +0 -1
- package/dist/src/commands/secrets/set.js.map +0 -1
- package/dist/src/commands/site.d.ts.map +0 -1
- package/dist/src/commands/site.js.map +0 -1
- package/dist/src/commands/skills.d.ts.map +0 -1
- package/dist/src/commands/skills.js.map +0 -1
- package/dist/src/commands/stack.d.ts.map +0 -1
- package/dist/src/commands/stack.js.map +0 -1
- package/dist/src/commands/temporal.d.ts.map +0 -1
- package/dist/src/commands/tenant.d.ts.map +0 -1
- package/dist/src/commands/tenant.js.map +0 -1
- package/dist/src/commands/tunnel/index.d.ts.map +0 -1
- package/dist/src/commands/tunnel/index.js.map +0 -1
- package/dist/src/commands/vcs/clone.d.ts.map +0 -1
- package/dist/src/commands/vcs/clone.js.map +0 -1
- package/dist/src/commands/vcs/common.d.ts.map +0 -1
- package/dist/src/commands/vcs/common.js.map +0 -1
- package/dist/src/commands/vcs/drafts.d.ts.map +0 -1
- package/dist/src/commands/vcs/drafts.js.map +0 -1
- package/dist/src/commands/vcs/get.d.ts.map +0 -1
- package/dist/src/commands/vcs/get.js.map +0 -1
- package/dist/src/commands/vcs/index.d.ts.map +0 -1
- package/dist/src/commands/vcs/index.js.map +0 -1
- package/dist/src/commands/vcs/propose.d.ts.map +0 -1
- package/dist/src/commands/vcs/propose.js.map +0 -1
- package/dist/src/commands/vcs/review.d.ts.map +0 -1
- package/dist/src/commands/vcs/review.js.map +0 -1
- package/dist/src/commands/vcs/rm.d.ts.map +0 -1
- package/dist/src/commands/vcs/rm.js.map +0 -1
- package/dist/src/commands/vcs-enrich.d.ts.map +0 -1
- package/dist/src/commands/vcs-enrich.js.map +0 -1
- package/dist/src/commands/vpn/index.d.ts.map +0 -1
- package/dist/src/commands/vpn/index.js.map +0 -1
- package/dist/src/commands/vpn/tunnel.d.ts.map +0 -1
- package/dist/src/commands/vpn/tunnel.js.map +0 -1
- package/dist/src/commands/workflow.d.ts.map +0 -1
- package/dist/src/commands/workflow.js.map +0 -1
- package/dist/src/docs/assemble.d.ts.map +0 -1
- package/dist/src/docs/assemble.js.map +0 -1
- package/dist/src/docs/cli-reference.d.ts.map +0 -1
- package/dist/src/docs/cli-reference.js.map +0 -1
- package/dist/src/docs/discover.d.ts.map +0 -1
- package/dist/src/docs/discover.js.map +0 -1
- package/dist/src/docs/portal.d.ts.map +0 -1
- package/dist/src/docs/portal.js.map +0 -1
- package/dist/src/docs/registry-docs.d.ts.map +0 -1
- package/dist/src/docs/registry-docs.js.map +0 -1
- package/dist/src/docs/schema.d.ts.map +0 -1
- package/dist/src/docs/schema.js.map +0 -1
- package/dist/src/docs/serve.d.ts.map +0 -1
- package/dist/src/docs/serve.js.map +0 -1
- package/dist/src/docs/start.d.ts.map +0 -1
- package/dist/src/docs/start.js.map +0 -1
- package/dist/src/eval/agent-eval.d.mts.map +0 -1
- package/dist/src/eval/agent-eval.mjs.map +0 -1
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/program.d.ts.map +0 -1
- package/dist/src/program.js.map +0 -1
- package/dist/src/utils/auth-preflight.d.ts.map +0 -1
- package/dist/src/utils/auth-preflight.js.map +0 -1
- package/dist/src/utils/aws-auth.d.ts.map +0 -1
- package/dist/src/utils/aws-auth.js.map +0 -1
- package/dist/src/utils/bastion.d.ts.map +0 -1
- package/dist/src/utils/bastion.js.map +0 -1
- package/dist/src/utils/build-info.d.ts.map +0 -1
- package/dist/src/utils/build-info.js.map +0 -1
- package/dist/src/utils/cache-home.d.ts.map +0 -1
- package/dist/src/utils/cache-home.js.map +0 -1
- package/dist/src/utils/capture-history.d.ts.map +0 -1
- package/dist/src/utils/capture-history.js.map +0 -1
- package/dist/src/utils/context.d.ts.map +0 -1
- package/dist/src/utils/context.js.map +0 -1
- package/dist/src/utils/credentials.d.ts.map +0 -1
- package/dist/src/utils/credentials.js.map +0 -1
- package/dist/src/utils/deploy-preflight.d.ts.map +0 -1
- package/dist/src/utils/deploy-preflight.js.map +0 -1
- package/dist/src/utils/errors.d.ts.map +0 -1
- package/dist/src/utils/errors.js.map +0 -1
- package/dist/src/utils/first-party-contexts.d.ts.map +0 -1
- package/dist/src/utils/first-party-contexts.js.map +0 -1
- package/dist/src/utils/index.d.ts.map +0 -1
- package/dist/src/utils/index.js.map +0 -1
- package/dist/src/utils/kubeconfig.d.ts.map +0 -1
- package/dist/src/utils/kubeconfig.js.map +0 -1
- package/dist/src/utils/log.d.ts.map +0 -1
- package/dist/src/utils/log.js.map +0 -1
- package/dist/src/utils/mesh-json.d.ts.map +0 -1
- package/dist/src/utils/mesh-json.js.map +0 -1
- package/dist/src/utils/pid.d.ts.map +0 -1
- package/dist/src/utils/pid.js.map +0 -1
- package/dist/src/utils/pulumi-run.d.ts.map +0 -1
- package/dist/src/utils/pulumi-run.js.map +0 -1
- package/dist/src/utils/pulumi.d.ts.map +0 -1
- package/dist/src/utils/pulumi.js.map +0 -1
- package/dist/src/utils/reachability.d.ts.map +0 -1
- package/dist/src/utils/reachability.js.map +0 -1
- package/dist/src/utils/recover-conversation.d.ts.map +0 -1
- package/dist/src/utils/recover-conversation.js.map +0 -1
- package/dist/src/utils/registry-broker.d.ts.map +0 -1
- package/dist/src/utils/registry-broker.js.map +0 -1
- package/dist/src/utils/registry-identity.d.ts.map +0 -1
- package/dist/src/utils/registry-identity.js.map +0 -1
- package/dist/src/utils/scaffold-versions.d.ts.map +0 -1
- package/dist/src/utils/scaffold-versions.js.map +0 -1
- package/dist/src/utils/socks-forward.d.ts.map +0 -1
- package/dist/src/utils/socks-forward.js.map +0 -1
- package/dist/src/utils/stack-flag.d.ts.map +0 -1
- package/dist/src/utils/stack-flag.js.map +0 -1
- package/dist/src/utils/tailscale-targets.d.ts.map +0 -1
- package/dist/src/utils/tailscale-targets.js.map +0 -1
- package/dist/src/utils/tailscale.d.ts.map +0 -1
- package/dist/src/utils/tailscale.js.map +0 -1
- package/dist/src/utils/temporal-auth.d.ts.map +0 -1
- package/dist/src/utils/temporal-auth.js.map +0 -1
- package/dist/src/utils/temporal-codec.d.ts.map +0 -1
- package/dist/src/utils/tunnel-ownership.d.ts.map +0 -1
- package/dist/src/utils/tunnel-ownership.js.map +0 -1
- package/dist/src/utils/vpn-join.d.ts.map +0 -1
- package/dist/src/utils/vpn-join.js.map +0 -1
- package/dist/src/utils/vpn.d.ts.map +0 -1
- package/dist/src/utils/vpn.js.map +0 -1
- package/dist/src/utils/workflow-fingerprint.d.ts.map +0 -1
- package/dist/src/utils/workflow-fingerprint.js.map +0 -1
- package/dist/src/utils/worktree-identity.d.ts.map +0 -1
- package/dist/src/utils/worktree-identity.js.map +0 -1
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env npx tsx
|
|
2
|
-
/**
|
|
3
|
-
* Agent eval runner — sends prompts to a mesh.ai.Agent API and captures
|
|
4
|
-
* structured traces of tool calls, results, errors, and artifacts.
|
|
5
|
-
*
|
|
6
|
-
* Usage:
|
|
7
|
-
* npx tsx agent-eval.mts --prompt "Build a contract onboarding workflow..."
|
|
8
|
-
* npx tsx agent-eval.mts --prompt-file prompts/contract-onboarding.md
|
|
9
|
-
* npx tsx agent-eval.mts --prompt "..." --api http://localhost:8787 --conversation conv-123
|
|
10
|
-
*
|
|
11
|
-
* Output: JSON trace to stdout (pipe to jq or a file), human summary to stderr.
|
|
12
|
-
*/
|
|
13
2
|
import { parseArgs } from "node:util";
|
|
14
|
-
// ── CLI args ─────────────────────────────────────────────────────────────────
|
|
15
3
|
const { values: args } = parseArgs({
|
|
16
4
|
options: {
|
|
17
5
|
prompt: { type: "string", short: "p" },
|
|
@@ -37,7 +25,6 @@ else {
|
|
|
37
25
|
console.error("Usage: agent-eval.mts --prompt '...' or --prompt-file <path>");
|
|
38
26
|
process.exit(1);
|
|
39
27
|
}
|
|
40
|
-
// ── SSE stream reader ────────────────────────────────────────────────────────
|
|
41
28
|
async function* readSSE(response) {
|
|
42
29
|
const reader = response.body.getReader();
|
|
43
30
|
const decoder = new TextDecoder();
|
|
@@ -60,12 +47,10 @@ async function* readSSE(response) {
|
|
|
60
47
|
yield JSON.parse(data);
|
|
61
48
|
}
|
|
62
49
|
catch {
|
|
63
|
-
// Skip malformed events
|
|
64
50
|
}
|
|
65
51
|
}
|
|
66
52
|
}
|
|
67
53
|
}
|
|
68
|
-
// ── Main ─────────────────────────────────────────────────────────────────────
|
|
69
54
|
const log = (msg) => process.stderr.write(msg + "\n");
|
|
70
55
|
const vlog = (msg) => { if (args.verbose)
|
|
71
56
|
log(` ${msg}`); };
|
|
@@ -155,7 +140,6 @@ try {
|
|
|
155
140
|
tc.result = event.result;
|
|
156
141
|
tc.durationMs = Date.now() - tc.startedAt;
|
|
157
142
|
pendingTools.delete(tc.toolId);
|
|
158
|
-
// Check for success: false in result
|
|
159
143
|
const r = event.result;
|
|
160
144
|
if (r && r.success === false) {
|
|
161
145
|
const errMsg = r.error ?? "success: false";
|
|
@@ -165,7 +149,6 @@ try {
|
|
|
165
149
|
else {
|
|
166
150
|
vlog(` <- ${tc.toolName} OK (${tc.durationMs}ms)`);
|
|
167
151
|
}
|
|
168
|
-
// Check for warnings
|
|
169
152
|
if (r && Array.isArray(r.warnings)) {
|
|
170
153
|
for (const w of r.warnings) {
|
|
171
154
|
trace.warnings.push(`${tc.toolName}: ${w}`);
|
|
@@ -196,7 +179,6 @@ try {
|
|
|
196
179
|
case "artifact-update": {
|
|
197
180
|
const a = event.artifact;
|
|
198
181
|
const entry = { id: a.id, type: a.type, title: a.title };
|
|
199
|
-
// Update or add
|
|
200
182
|
const idx = trace.artifacts.findIndex((x) => x.id === entry.id);
|
|
201
183
|
if (idx >= 0)
|
|
202
184
|
trace.artifacts[idx] = entry;
|
|
@@ -230,7 +212,6 @@ finally {
|
|
|
230
212
|
clearTimeout(timer);
|
|
231
213
|
}
|
|
232
214
|
trace.durationMs = Date.now() - startTime;
|
|
233
|
-
// ── Summary ──────────────────────────────────────────────────────────────────
|
|
234
215
|
log("\n--- Summary ---");
|
|
235
216
|
log(`Duration: ${(trace.durationMs / 1000).toFixed(1)}s`);
|
|
236
217
|
log(`Tool calls: ${trace.toolCalls.length}`);
|
|
@@ -252,7 +233,6 @@ if (trace.warnings.length > 0) {
|
|
|
252
233
|
for (const w of trace.warnings)
|
|
253
234
|
log(` - ${w}`);
|
|
254
235
|
}
|
|
255
|
-
// Tool call breakdown
|
|
256
236
|
const toolCounts = new Map();
|
|
257
237
|
for (const tc of trace.toolCalls) {
|
|
258
238
|
const entry = toolCounts.get(tc.toolName) ?? { count: 0, failed: 0 };
|
|
@@ -268,6 +248,4 @@ if (toolCounts.size > 0) {
|
|
|
268
248
|
}
|
|
269
249
|
}
|
|
270
250
|
log("");
|
|
271
|
-
// ── JSON trace to stdout ─────────────────────────────────────────────────────
|
|
272
251
|
console.log(JSON.stringify(trace, null, 2));
|
|
273
|
-
//# sourceMappingURL=agent-eval.mjs.map
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.js.map
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/errors.ts", "../../src/utils/log.ts", "../../src/utils/context.ts", "../../src/utils/bastion.ts", "../../src/utils/credentials.ts", "../../src/utils/pulumi.ts", "../../src/utils/vpn.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Shared CLI error type with structured remediation.\n *\n * Every failure along the golden path should tell the user the exact `mesh`\n * command (or doc) that fixes it. Remediation strings must be commands or\n * docs \u2014 never \"ask <person>\".\n */\n\nimport chalk from \"chalk\";\n\nexport interface Remediation {\n /** Exact command that fixes the failure, e.g. \"mesh login trabian-dev\" */\n command?: string;\n /** Documentation URL or repo-relative doc path with more context */\n docs?: string;\n /** Whether the owning command can apply this fix itself via --fix */\n autoFixable?: boolean;\n}\n\nexport interface MeshCliErrorOptions {\n remediation?: Remediation;\n /** Process exit code (default 1) */\n exitCode?: number;\n cause?: unknown;\n}\n\nexport class MeshCliError extends Error {\n readonly remediation?: Remediation;\n readonly exitCode: number;\n\n constructor(message: string, options: MeshCliErrorOptions = {}) {\n super(message, options.cause !== undefined ? { cause: options.cause } : undefined);\n this.name = \"MeshCliError\";\n this.remediation = options.remediation;\n this.exitCode = options.exitCode ?? 1;\n }\n}\n\n/**\n * Render an error's BODY \u2014 the message plus its \"\u2192 run: <command>\" /\n * \"\u2192 see: <docs>\" remediation lines, with no leading severity glyph.\n *\n * Use this when the caller supplies its own glyph: a recovery path that logs a\n * refusal through `logWarn` (which prefixes \u26A0) and carries on would otherwise\n * print \"\u26A0 \u2717 \u2026\". The remediation lines are the part that must survive \u2014 they\n * name the corrupt file to delete.\n */\nexport function renderErrorBody(err: unknown): string {\n const message = err instanceof Error ? err.message : String(err);\n if (!(err instanceof MeshCliError)) return message;\n const lines = [message];\n if (err.remediation?.command) {\n lines.push(chalk.cyan(\" \u2192 run: \") + err.remediation.command);\n }\n if (err.remediation?.docs) {\n lines.push(chalk.cyan(\" \u2192 see: \") + err.remediation.docs);\n }\n return lines.join(\"\\n\");\n}\n\n/**\n * Render an error for humans. MeshCliError gets its remediation appended as\n * \"\u2192 run: <command>\" / \"\u2192 see: <docs>\" lines; anything else renders its message.\n */\nexport function renderError(err: unknown): string {\n return chalk.red(\"\u2717\") + \" \" + renderErrorBody(err);\n}\n\n/**\n * Render an error as JSON for agents. Same structure as the human output:\n * { error, remediation?: { command?, docs?, autoFixable? } }.\n */\nexport function renderErrorJson(err: unknown): string {\n if (err instanceof MeshCliError) {\n return JSON.stringify({\n error: err.message,\n ...(err.remediation ? { remediation: err.remediation } : {}),\n });\n }\n return JSON.stringify({ error: err instanceof Error ? err.message : String(err) });\n}\n\nlet jsonPayloadEmitted = false;\n\n/**\n * Print a command's `--json` payload \u2014 the single machine-readable document on\n * stdout \u2014 and record that it happened.\n *\n * A command that emits a payload and *then* throws (the `mesh init` doctor\n * throws by design whenever a check fails) used to produce TWO concatenated\n * JSON documents on stdout, because `handleCliError` appended `{\"error\":\u2026}`.\n * Two documents is not JSON: `mesh init app-tenant --json | jq` failed to parse\n * on exactly the failure path a script cares about. Routing every payload\n * through here lets the handler know stdout is already spoken for.\n */\nexport function emitJsonPayload(payload: unknown): void {\n console.log(JSON.stringify(payload, null, 2));\n jsonPayloadEmitted = true;\n}\n\n/** True once a command has written its `--json` payload to stdout. */\nexport function hasEmittedJsonPayload(): boolean {\n return jsonPayloadEmitted;\n}\n\n/** Test seam \u2014 the flag is module state, so specs have to be able to clear it. */\nexport function resetJsonPayloadEmitted(): void {\n jsonPayloadEmitted = false;\n}\n\n/**\n * Top-level handler for bin/mesh.ts. Prints the error (JSON when the\n * invocation asked for --json anywhere, since per-command flags aren't\n * parsed once dispatch has failed) and exits with the error's code.\n *\n * When the command already emitted a `--json` payload, that payload IS the\n * machine surface \u2014 and it says strictly more than this error would (the\n * doctor's payload carries `ok:false` plus a per-check `fix` command). So the\n * error goes to stderr as human diagnostics and stdout keeps exactly one\n * parseable document.\n */\nexport function handleCliError(err: unknown): never {\n const wantsJson = process.argv.includes(\"--json\");\n if (wantsJson && !hasEmittedJsonPayload()) {\n console.log(renderErrorJson(err));\n } else {\n console.error(renderError(err));\n }\n process.exit(err instanceof MeshCliError ? err.exitCode : 1);\n}\n", "/**\n * Logging utilities with colored output.\n *\n * Non-TTY streams (CI, agent runs, piped output) get an [HH:MM:SS] prefix on\n * every line so long quiet stretches are attributable after the fact\n * (MESH-2479); interactive terminals stay clean. Override with\n * MESH_LOG_TIMESTAMPS=1 (force on) / =0 (force off).\n */\n\nimport chalk from \"chalk\";\n\n/**\n * Pure prefix decision, exported for tests: timestamps when the env flag says\n * so, else whenever stderr is not a TTY.\n */\nexport function logPrefix(opts: {\n isTTY: boolean;\n envFlag: string | undefined;\n now: Date;\n}): string {\n const enabled = opts.envFlag === \"1\" || (opts.envFlag !== \"0\" && !opts.isTTY);\n return enabled ? `[${opts.now.toISOString().slice(11, 19)}] ` : \"\";\n}\n\nfunction prefix(): string {\n return chalk.dim(\n logPrefix({\n isTTY: !!process.stderr.isTTY,\n envFlag: process.env.MESH_LOG_TIMESTAMPS,\n now: new Date(),\n }),\n );\n}\n\nexport function logInfo(message: string): void {\n console.error(prefix() + chalk.blue(\"\u2139\"), message);\n}\n\nexport function logSuccess(message: string): void {\n console.error(prefix() + chalk.green(\"\u2713\"), message);\n}\n\nexport function logWarn(message: string): void {\n console.error(prefix() + chalk.yellow(\"\u26A0\"), message);\n}\n\nexport function logError(message: string): void {\n console.error(prefix() + chalk.red(\"\u2717\"), message);\n}\n\n/** Render elapsed milliseconds compactly: \"45s\", \"2m 30s\", \"1h 5m\". */\nexport function formatElapsed(ms: number): string {\n const totalSec = Math.max(0, Math.round(ms / 1000));\n const h = Math.floor(totalSec / 3600);\n const m = Math.floor((totalSec % 3600) / 60);\n const s = totalSec % 60;\n if (h > 0) return `${h}h ${m}m`;\n if (m > 0) return `${m}m ${s}s`;\n return `${s}s`;\n}\n\n/**\n * Periodic \"still working\" line during a long silent operation (registry\n * fetches, image builds) so a non-TTY first run never sits at 0 bytes of\n * output for minutes (MESH-2479). `touch()` marks recent real output, which\n * suppresses the next beat \u2014 the heartbeat only fills silence.\n */\nexport function startHeartbeat(\n label: string,\n intervalMs = 15_000,\n): { stop: () => void; touch: () => void } {\n const startedAt = Date.now();\n let lastOutputAt = startedAt;\n const timer = setInterval(() => {\n if (Date.now() - lastOutputAt < intervalMs) return;\n logInfo(`\u2026 still working: ${label} (${formatElapsed(Date.now() - startedAt)} elapsed)`);\n }, intervalMs);\n timer.unref?.();\n return {\n stop: () => clearInterval(timer),\n touch: () => {\n lastOutputAt = Date.now();\n },\n };\n}\n", "/**\n * Context detection - determines tenant, stage, and platform environment\n * from the current directory and environment variables.\n */\n\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport { logInfo } from \"./log.js\";\n\nexport interface MeshContext {\n tenant: string;\n stage: string;\n platformEnv: string;\n}\n\n/**\n * Find a file by walking up directories from the starting directory.\n * Returns the full path to the file if found, undefined otherwise.\n */\nfunction findFileUpward(filename: string, startDir: string = process.cwd()): string | undefined {\n let currentDir = startDir;\n const root = path.parse(currentDir).root;\n\n while (currentDir !== root) {\n const filePath = path.join(currentDir, filename);\n if (fs.existsSync(filePath)) {\n return filePath;\n }\n currentDir = path.dirname(currentDir);\n }\n return undefined;\n}\n\n/**\n * Detect tenant and stage from current directory and environment.\n *\n * Priority for stage:\n * 1. --stage flag (passed as stageArg)\n * 2. MESH_STAGE env var\n * 3. SST_STAGE env var\n * 4. .sst/stage file\n * 5. Pulumi config file name\n * 6. Default: \"dev\"\n *\n * Priority for tenant:\n * 1. MESH_TENANT env var\n * 2. config.ts tenant field\n * 3. Pulumi config mesh:tenant\n * 4. Directory path (tenants/{tenant}/...)\n * 5. Default: \"mesh\"\n */\nexport function detectContext(stageArg?: string): MeshContext {\n let tenant: string | undefined;\n let stage: string | undefined;\n\n const cwd = process.cwd();\n\n // Try to detect from Pulumi.yaml\n if (fs.existsSync(\"Pulumi.yaml\")) {\n // Look for Pulumi.*.yaml config files\n const files = fs.readdirSync(\".\").filter(\n (f) => f.startsWith(\"Pulumi.\") && f.endsWith(\".yaml\") && f !== \"Pulumi.yaml\"\n );\n\n const configFile = files[0];\n if (configFile) {\n const content = fs.readFileSync(configFile, \"utf-8\");\n\n // Extract tenant from mesh:tenant config\n const tenantMatch = content.match(/^\\s*mesh:tenant:\\s*[\"']?([^\"'\\n]+)[\"']?/m);\n if (tenantMatch?.[1]) {\n tenant = tenantMatch[1].trim();\n }\n\n // Extract stage from filename: Pulumi.<stage>.yaml\n const stageMatch = configFile.match(/Pulumi\\.(.+)\\.yaml/);\n if (stageMatch?.[1]) {\n stage = stageMatch[1];\n }\n }\n }\n\n // Try to detect from SST config (walk up directories to find it)\n const sstConfigPath = findFileUpward(\"sst.config.ts\");\n let sstDir: string | undefined;\n\n if (sstConfigPath) {\n sstDir = path.dirname(sstConfigPath);\n\n // Check parent config.ts for tenant (relative to sst.config.ts location)\n const parentConfigPath = path.join(sstDir, \"..\", \"config.ts\");\n if (fs.existsSync(parentConfigPath)) {\n const configContent = fs.readFileSync(parentConfigPath, \"utf-8\");\n const tenantMatch = configContent.match(/tenant:\\s*[\"']([^\"']+)[\"']/);\n if (tenantMatch) {\n tenant = tenantMatch[1];\n }\n }\n\n // Check .sst/stage for current stage (relative to sst.config.ts location)\n const sstStagePath = path.join(sstDir, \".sst\", \"stage\");\n if (fs.existsSync(sstStagePath)) {\n stage = fs.readFileSync(sstStagePath, \"utf-8\").trim();\n }\n }\n\n // Fallback: infer tenant from directory path\n if (!tenant) {\n const pathMatch = cwd.match(/tenants\\/([^/]+)/);\n if (pathMatch) {\n tenant = pathMatch[1];\n }\n }\n\n // Apply priority: stageArg > MESH_STAGE > SST_STAGE > detected > default\n stage = stageArg || process.env.MESH_STAGE || process.env.SST_STAGE || stage || \"dev\";\n tenant = process.env.MESH_TENANT || tenant || \"mesh\";\n\n // Resolve platform environment from config.ts if available\n let platformEnv = stage;\n let platformEnvMap: Record<string, string> = {};\n let defaultPlatformEnv: string | undefined;\n\n // Try to read platformEnvMap and defaultPlatformEnv from config.ts (relative to sst.config.ts location)\n const configPath = sstDir ? path.join(sstDir, \"..\", \"config.ts\") : \"../config.ts\";\n if (fs.existsSync(configPath)) {\n const configContent = fs.readFileSync(configPath, \"utf-8\");\n\n // Parse platformEnvMap object\n const mapMatch = configContent.match(/platformEnvMap:\\s*\\{([^}]+)\\}/);\n if (mapMatch?.[1]) {\n const entries = mapMatch[1].matchAll(/(\\w+):\\s*[\"']([^\"']+)[\"']/g);\n for (const entry of entries) {\n const key = entry[1];\n const value = entry[2];\n if (key && value) {\n platformEnvMap[key] = value;\n }\n }\n }\n\n // Parse defaultPlatformEnv\n const defaultMatch = configContent.match(/defaultPlatformEnv:\\s*[\"']([^\"']+)[\"']/);\n if (defaultMatch?.[1]) {\n defaultPlatformEnv = defaultMatch[1];\n }\n }\n\n // Parse env from stage by stripping tenant prefix (matches Pulumi pattern)\n // e.g., \"mesh-dev-temporal\" \u2192 env \"dev-temporal\"\n const tenantPrefix = `${tenant}-`;\n const parsedEnv = stage.startsWith(tenantPrefix)\n ? stage.slice(tenantPrefix.length)\n : stage;\n\n // Use config mapping if available, then defaultPlatformEnv, otherwise use parsed env directly\n platformEnv = platformEnvMap[parsedEnv] ?? platformEnvMap[stage] ?? defaultPlatformEnv ?? parsedEnv;\n\n logInfo(`Stage: ${stage}, Platform: ${platformEnv}, Tenant: ${tenant}`);\n\n return { tenant, stage, platformEnv };\n}\n", "/**\n * Bastion utilities for SSM tunneling to platform services\n */\n\nimport { SSMClient, GetParameterCommand } from \"@aws-sdk/client-ssm\";\nimport { logInfo, logSuccess, logError } from \"./log.js\";\n\n/**\n * Service endpoint info\n */\nexport interface ServiceEndpoint {\n host: string;\n port: number;\n}\n\n/**\n * Platform bastion info from SSM\n */\nexport interface PlatformBastionInfo {\n instanceId: string;\n securityGroupId: string;\n services: Record<string, ServiceEndpoint>;\n}\n\n/**\n * Legacy bastion info (for backward compatibility with db commands)\n */\nexport interface BastionInfo {\n instanceId: string;\n rdsEndpoint: string;\n rdsPort: number;\n}\n\n/**\n * Get platform bastion info from SSM parameter store.\n *\n * Reads the platformBastion key from the platform export at\n * /mesh-platform/{tenant}/{platformEnv}/platform. Falls back to the legacy\n * separate parameter at /mesh-platform/{tenant}/{platformEnv}/platform-bastion\n * for backward compatibility.\n */\nexport async function getPlatformBastionInfo(\n tenant: string,\n platformEnv: string,\n region?: string\n): Promise<PlatformBastionInfo> {\n const ssm = new SSMClient(region ? { region } : {});\n\n // Captured so the final error can distinguish a CREDS failure (the common\n // case \u2014 stale/expired ambient AWS creds, or creds lacking cross-tenant read\n // on the hub param) from a genuinely missing bastion. Without this the read\n // error is swallowed and every failure looks like \"bastion not deployed\".\n let primaryError: unknown;\n\n // Primary: read from the platform export (platformBastion is a nested key)\n const platformPath = `/mesh-platform/${tenant}/${platformEnv}/platform`;\n logInfo(`Looking up platform bastion from ${platformPath}...`);\n\n try {\n const response = await ssm.send(\n new GetParameterCommand({ Name: platformPath })\n );\n\n if (response.Parameter?.Value) {\n const platform = JSON.parse(response.Parameter.Value);\n if (platform.platformBastion) {\n const info = platform.platformBastion as PlatformBastionInfo;\n logSuccess(`Found bastion: ${info.instanceId}`);\n\n const serviceNames = Object.keys(info.services);\n if (serviceNames.length > 0) {\n logInfo(`Available services: ${serviceNames.join(\", \")}`);\n }\n\n return info;\n }\n }\n } catch (err) {\n // Don't swallow: keep the real reason (AccessDenied / ExpiredToken / \u2026) so\n // the final error can be actionable. Then try the legacy path.\n primaryError = err;\n }\n\n // Fallback: legacy separate parameter\n const legacyPath = `/mesh-platform/${tenant}/${platformEnv}/platform-bastion`;\n logInfo(`Trying legacy path ${legacyPath}...`);\n\n try {\n const response = await ssm.send(\n new GetParameterCommand({ Name: legacyPath })\n );\n\n if (!response.Parameter?.Value) {\n throw new Error(`Platform bastion not found`);\n }\n\n const info = JSON.parse(response.Parameter.Value) as PlatformBastionInfo;\n logSuccess(`Found bastion: ${info.instanceId}`);\n\n const serviceNames = Object.keys(info.services);\n if (serviceNames.length > 0) {\n logInfo(`Available services: ${serviceNames.join(\", \")}`);\n }\n\n return info;\n } catch (legacyError) {\n // Classify on the PRIMARY read's error (the meaningful one) \u2014 the legacy\n // path is usually just ParameterNotFound and hides the real cause.\n const cause = primaryError ?? legacyError;\n const name = (cause as { name?: string })?.name ?? \"\";\n const credsProblem = /Expired|UnrecognizedClient|InvalidClientTokenId|InvalidSignature|CredentialsProviderError|AccessDenied/i.test(\n name\n );\n\n if (credsProblem) {\n logError(\n `Could not read the platform bastion from ${platformPath} \u2014 AWS error: ${name}.`\n );\n logInfo(\n \"This is almost always a CREDENTIALS problem, not a missing bastion.\"\n );\n logInfo(\n \" \u2022 The read uses the ambient AWS creds of this process; they must be valid AND able to read the HUB param above.\"\n );\n logInfo(\n \" \u2022 Check: `aws sts get-caller-identity` (ExpiredToken \u2192 refresh; AccessDenied \u2192 those creds lack hub read \u2014 use InfraAdmin-grade creds).\"\n );\n logInfo(\n \" \u2022 Stale creds often hide in the tmux GLOBAL env (`tmux show-environment -g | grep AWS_`); a per-shell `unset` won't clear them.\"\n );\n } else {\n logError(`Platform bastion not found in ${platformPath} or ${legacyPath}`);\n logInfo(\"Make sure platformBastion is enabled in your platform config and deployed.\");\n }\n throw cause;\n }\n}\n\n/**\n * Get bastion info from SSM parameter store (legacy format).\n * Reads from /mesh/{tenant}/{platformEnv}/platform-bastion and extracts RDS info.\n *\n * @deprecated Use getPlatformBastionInfo instead\n */\nexport async function getBastionInfo(\n tenant: string,\n platformEnv: string\n): Promise<BastionInfo> {\n const info = await getPlatformBastionInfo(tenant, platformEnv);\n\n const rdsService = info.services[\"rds\"];\n if (!rdsService) {\n throw new Error(\"RDS service not available in platform bastion. Is RDS enabled?\");\n }\n\n return {\n instanceId: info.instanceId,\n rdsEndpoint: rdsService.host,\n rdsPort: rdsService.port,\n };\n}\n", "/**\n * Database credential utilities\n */\n\nimport {\n SecretsManagerClient,\n GetSecretValueCommand,\n} from \"@aws-sdk/client-secrets-manager\";\nimport { logInfo, logSuccess } from \"./log.js\";\n\nexport interface DatabaseCredentials {\n username: string;\n password: string;\n host: string;\n port: number;\n database: string;\n}\n\n/**\n * Options for credential lookup\n */\nexport interface CredentialLookupOptions {\n /** App name (e.g., \"rdc\") - if provided, uses path mesh/{tenant}/{stage}/{app}/db-credentials */\n app?: string;\n}\n\n/**\n * Get DATABASE_URL from Secrets Manager.\n *\n * Credential path patterns:\n * - With app: mesh/{tenant}/{stage}/{app}/db-credentials\n * - Without app: mesh/{tenant}/{stage}/db-credentials\n *\n * Returns the DATABASE_URL string directly. Use rewriteDatabaseUrl() to\n * modify host/port for tunnel usage.\n */\nexport async function getDatabaseUrl(\n tenant: string,\n stage: string,\n options?: CredentialLookupOptions\n): Promise<string> {\n const secretsManager = new SecretsManagerClient({});\n\n // Build secret path - with or without app name\n const secretName = options?.app\n ? `mesh/${tenant}/${stage}/${options.app}/db-credentials`\n : `mesh/${tenant}/${stage}/db-credentials`;\n logInfo(`Looking up credentials at ${secretName}...`);\n\n try {\n const response = await secretsManager.send(\n new GetSecretValueCommand({ SecretId: secretName })\n );\n\n if (response.SecretString) {\n const secret = JSON.parse(response.SecretString);\n\n // Handle DATABASE_URL format (preferred)\n if (secret.DATABASE_URL) {\n const parsed = new URL(secret.DATABASE_URL);\n logSuccess(`Got credentials for user: ${parsed.username}`);\n return secret.DATABASE_URL;\n }\n\n // Handle individual fields format (legacy)\n if (secret.username && secret.password) {\n logSuccess(`Got credentials for user: ${secret.username}`);\n const database = secret.dbname ?? secret.database ?? \"postgres\";\n return `postgresql://${secret.username}:${encodeURIComponent(secret.password)}@${secret.host ?? \"localhost\"}:${secret.port ?? 5432}/${database}`;\n }\n\n throw new Error(`Secret ${secretName} has unexpected format (needs DATABASE_URL or username/password)`);\n }\n } catch (error) {\n if ((error as Error).message?.includes(\"unexpected format\")) {\n throw error;\n }\n // Secret not found - will be caught by caller\n }\n\n throw new Error(`Could not find credentials at ${secretName}`);\n}\n\n/**\n * @deprecated Use getDatabaseUrl instead - returns DATABASE_URL directly\n */\nexport async function getDbCredentials(\n tenant: string,\n stage: string,\n _platformEnv: string,\n rdsHost: string,\n rdsPort: number,\n options?: CredentialLookupOptions\n): Promise<DatabaseCredentials> {\n const databaseUrl = await getDatabaseUrl(tenant, stage, options);\n const parsed = new URL(databaseUrl);\n\n return {\n username: parsed.username,\n password: decodeURIComponent(parsed.password),\n host: rdsHost,\n port: rdsPort,\n database: parsed.pathname.slice(1),\n };\n}\n\n/**\n * Options for rewriting DATABASE_URL\n */\nexport interface DatabaseUrlRewriteOptions {\n /** New host:port endpoint (e.g., \"localhost:5432\") */\n endpoint?: string;\n /** SSL mode (require, no-verify, disable) */\n sslMode?: string;\n}\n\n/**\n * Rewrite DATABASE_URL with new endpoint and/or SSL mode.\n * Preserves username, password, database name, and other query params.\n *\n * Used by both mesh-env-exec (for sst dev) and mesh db exec (for ad-hoc commands).\n */\nexport function rewriteDatabaseUrl(\n url: string,\n options: DatabaseUrlRewriteOptions\n): string {\n try {\n const parsed = new URL(url);\n\n // Rewrite endpoint if provided\n if (options.endpoint) {\n if (options.endpoint.includes(\":\")) {\n const colonIndex = options.endpoint.lastIndexOf(\":\");\n parsed.hostname = options.endpoint.slice(0, colonIndex);\n parsed.port = options.endpoint.slice(colonIndex + 1);\n } else {\n parsed.hostname = options.endpoint;\n parsed.port = parsed.port || \"5432\";\n }\n }\n\n // Set SSL mode if provided\n if (options.sslMode) {\n parsed.searchParams.set(\"sslmode\", options.sslMode);\n // For Prisma: accept invalid/self-signed certificates through tunnels\n if (options.sslMode === \"require\" || options.sslMode === \"no-verify\") {\n parsed.searchParams.set(\"sslaccept\", \"accept_invalid_certs\");\n }\n }\n\n return parsed.toString();\n } catch {\n // If URL parsing fails, return original\n return url;\n }\n}\n\n/**\n * Build a DATABASE_URL from credentials.\n */\nexport function buildDatabaseUrl(\n creds: DatabaseCredentials,\n options?: DatabaseUrlRewriteOptions\n): string {\n const host = options?.endpoint?.split(\":\")[0] ?? creds.host;\n const port = options?.endpoint?.split(\":\")[1] ?? String(creds.port);\n\n let url = `postgresql://${creds.username}:${encodeURIComponent(creds.password)}@${host}:${port}/${creds.database}`;\n\n if (options?.sslMode) {\n url += `?sslmode=${options.sslMode}`;\n if (options.sslMode === \"require\" || options.sslMode === \"no-verify\") {\n url += \"&sslaccept=accept_invalid_certs\";\n }\n }\n\n return url;\n}\n\n/**\n * Try to read database info from SST outputs (when sst dev has run).\n */\nexport async function readSstOutputs(): Promise<{\n databaseUrl?: string;\n databaseName?: string;\n secretArn?: string;\n} | null> {\n const fs = await import(\"fs\");\n\n if (!fs.existsSync(\".sst/outputs.json\")) {\n return null;\n }\n\n try {\n const content = fs.readFileSync(\".sst/outputs.json\", \"utf-8\");\n const outputs = JSON.parse(content);\n\n if (outputs.databaseUrl) {\n logInfo(\"Found SST outputs with database config\");\n\n // Extract secret ARN from URL if present\n const secretArnMatch = outputs.databaseUrl.match(/secretArn=([^&]+)/);\n const secretArn = secretArnMatch\n ? decodeURIComponent(secretArnMatch[1])\n : undefined;\n\n return {\n databaseUrl: outputs.databaseUrl,\n databaseName: outputs.databaseName,\n secretArn,\n };\n }\n } catch {\n // Ignore parse errors\n }\n\n return null;\n}\n", "/**\n * Pulumi-related utilities shared across CLI commands.\n */\n\nimport { execFileSync } from \"child_process\";\nimport * as path from \"path\";\nimport * as fs from \"fs\";\n\n/**\n * Find the Pulumi app root by walking up from a starting directory.\n * Returns the first directory containing `Pulumi.yaml`, or null.\n */\nexport function findAppRoot(startDir: string): string | null {\n let dir = startDir;\n while (true) {\n if (fs.existsSync(path.join(dir, \"Pulumi.yaml\"))) return dir;\n const parent = path.dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n}\n\n/**\n * Find Pulumi.<stack>.yaml files in a directory.\n * Returns an array of stack names (without the Pulumi. prefix and .yaml suffix).\n */\nexport function findStackConfigs(appRoot: string): string[] {\n return fs.readdirSync(appRoot)\n .filter((f) => /^Pulumi\\..+\\.yaml$/.test(f) && f !== \"Pulumi.yaml\")\n .map((f) => f.replace(/^Pulumi\\./, \"\").replace(/\\.yaml$/, \"\"));\n}\n\n/**\n * Get the currently selected Pulumi stack name, or null.\n */\nexport function getCurrentStack(appRoot: string): string | null {\n try {\n const result = execFileSync(\"pulumi\", [\"stack\", \"--show-name\"], {\n encoding: \"utf-8\",\n cwd: appRoot,\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n });\n return result.trim() || null;\n } catch {\n return null;\n }\n}\n\n/**\n * Read a config value from Pulumi.<stack>.yaml.\n * Simple regex-based parser \u2014 handles single-line string values.\n * For complex values, use `pulumi config` CLI instead.\n */\nexport function readStackConfig(appRoot: string, stack: string, key: string): string | null {\n const configFile = path.join(appRoot, `Pulumi.${stack}.yaml`);\n if (!fs.existsSync(configFile)) return null;\n\n const content = fs.readFileSync(configFile, \"utf-8\");\n const pattern = new RegExp(`^\\\\s+${key.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}:\\\\s*(.+)$`, \"m\");\n const match = content.match(pattern);\n if (!match) return null;\n\n return match[1]!.trim().replace(/^[\"']|[\"']$/g, \"\");\n}\n\n/**\n * Run `pulumi stack output <key> --json` with the given extra args.\n *\n * Pulumi redacts secret-tainted outputs as the literal string `\"[secret]\"`.\n * Outputs like `env.register()`'s `dev` blob are tainted because they transitively\n * include secret values (e.g. `TEMPORAL_ENCODING_KEY`, DB passwords), even though\n * much of the blob (tunnels, namespace, service scaffolding) is non-secret.\n *\n * This helper tries without `--show-secrets` first \u2014 which avoids requiring\n * the local machine to have the stack's secrets provider configured (KMS access\n * etc.) \u2014 and retries with `--show-secrets` only if the first call returns a\n * `\"[secret]\"` placeholder. KMS/secrets-provider errors are not retried because\n * they will fail the same way with the flag set.\n */\nexport function pulumiStackOutput(\n appRoot: string,\n key: string,\n extraArgs: string[],\n env?: Record<string, string>,\n): string {\n const execEnv = env ? { ...process.env, ...env } : undefined;\n // First attempt: no --show-secrets (works without PULUMI_CONFIG_PASSPHRASE / KMS)\n try {\n const result = execFileSync(\n \"pulumi\",\n [\"stack\", \"output\", key, \"--json\", ...extraArgs],\n { cwd: appRoot, encoding: \"utf-8\", stdio: [\"ignore\", \"pipe\", \"pipe\"], env: execEnv }\n );\n // If the output contains \"[secret]\" placeholders, retry with --show-secrets\n if (result.includes('\"[secret]\"')) {\n return execFileSync(\n \"pulumi\",\n [\"stack\", \"output\", key, \"--json\", \"--show-secrets\", ...extraArgs],\n { cwd: appRoot, encoding: \"utf-8\", stdio: [\"ignore\", \"pipe\", \"pipe\"], env: execEnv }\n );\n }\n return result;\n } catch (err: unknown) {\n // If the error is a secrets/KMS issue, don't retry with --show-secrets\n // (it will fail the same way). Only retry for other Pulumi errors.\n const errMsg = (err as { stderr?: string })?.stderr ?? \"\";\n if (errMsg.includes(\"kms:\") || errMsg.includes(\"KMS\") || errMsg.includes(\"secrets manager\")) {\n throw err;\n }\n return execFileSync(\n \"pulumi\",\n [\"stack\", \"output\", key, \"--json\", \"--show-secrets\", ...extraArgs],\n { cwd: appRoot, encoding: \"utf-8\", stdio: [\"ignore\", \"pipe\", \"pipe\"], env: execEnv }\n );\n }\n}\n", "/**\n * VPN detection utilities\n */\n\nimport { execFile, execFileSync } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nconst TAILSCALE_PATHS = [\n \"tailscale\",\n \"/Applications/Tailscale.app/Contents/MacOS/Tailscale\",\n];\n\n/**\n * Detect whether a Tailscale VPN connection is active.\n *\n * Uses socket-aware `execTailscaleCmd` so it works in both kernel tun mode\n * (standard socket) and legacy userspace networking (/tmp/tailscale.sock).\n * Returns `true` only when BackendState is \"Running\" and Self.Online is true.\n * Returns `false` silently on any failure (binary missing, daemon stopped,\n * parse error, missing fields).\n */\nexport async function isVpnConnected(): Promise<boolean> {\n try {\n const stdout = await execTailscaleCmd([\"status\", \"--json\"]);\n const status: TailscaleDetailedStatus = JSON.parse(stdout);\n return status.BackendState === \"Running\" && status.Self?.Online === true;\n } catch {\n return false;\n }\n}\n\n// ---------------------------------------------------------------------------\n// DNS record management & Tailscale info\n// ---------------------------------------------------------------------------\n\n/** Standard socket (kernel tun mode), then legacy (userspace mode). */\nconst TAILSCALE_SOCKET_PATHS = [\"/var/run/tailscale/tailscaled.sock\", \"/tmp/tailscale.sock\"];\n\n/** Connection details for the Headscale DNS writer sidecar. */\nexport interface HeadscaleDnsConfig {\n namespace: string;\n pod: string;\n container: string;\n filePath: string;\n}\n\n/**\n * Build a HeadscaleDnsConfig from tenant/env, following the same naming\n * convention as `mesh vpn` (\u2060{tenant}-{env}-headscale).\n *\n * Pod name, container, and file path are infrastructure conventions that\n * rarely change \u2014 override via the optional parameter if they do.\n */\nexport function headscaleDnsConfig(\n tenant = \"mesh\",\n env = \"dev\",\n overrides?: Partial<HeadscaleDnsConfig>,\n): HeadscaleDnsConfig {\n return {\n namespace: `${tenant}-${env}-headscale`,\n pod: \"headscale-0\",\n container: \"dns-writer\",\n filePath: \"/var/lib/headscale/dns/extra-records.json\",\n ...overrides,\n };\n}\n\nexport interface DnsRecord {\n name: string;\n type: \"A\";\n value: string;\n}\n\ninterface TailscaleDetailedStatus {\n BackendState?: string;\n Self?: {\n Online?: boolean;\n HostName?: string;\n TailscaleIPs?: string[];\n };\n}\n\n/**\n * Execute a tailscale CLI command, trying each known binary path.\n * Automatically appends `--socket <path>` when a tailscale socket is found.\n */\nfunction execTailscaleCmd(args: string[]): Promise<string> {\n const socketPath = TAILSCALE_SOCKET_PATHS.find(existsSync);\n\n interface Attempt {\n binary: string;\n args: string[];\n }\n\n const attempts: Attempt[] = [];\n for (const binary of TAILSCALE_PATHS) {\n if (socketPath) {\n attempts.push({ binary, args: [\"--socket\", socketPath, ...args] });\n }\n attempts.push({ binary, args });\n }\n\n return new Promise((resolve, reject) => {\n let index = 0;\n\n function tryNext(): void {\n if (index >= attempts.length) {\n reject(new Error(\"All tailscale binary attempts failed\"));\n return;\n }\n\n const attempt = attempts[index++]!;\n execFile(attempt.binary, attempt.args, (error, stdout) => {\n if (error) {\n tryNext();\n } else {\n resolve(stdout);\n }\n });\n }\n\n tryNext();\n });\n}\n\n/**\n * Retrieve the current Tailscale hostname and IP address.\n *\n * Returns `null` when Tailscale is not installed, not running, or not online.\n */\nexport async function getTailscaleInfo(): Promise<{ hostname: string; ip: string } | null> {\n try {\n const stdout = await execTailscaleCmd([\"status\", \"--json\"]);\n const status: TailscaleDetailedStatus = JSON.parse(stdout);\n\n if (\n status.BackendState === \"Running\" &&\n status.Self?.Online === true &&\n status.Self.HostName &&\n status.Self.TailscaleIPs?.length\n ) {\n return {\n hostname: status.Self.HostName,\n ip: status.Self.TailscaleIPs[0]!,\n };\n }\n\n return null;\n } catch {\n return null;\n }\n}\n\n/** Helper: build kubectl exec args for the dns-writer sidecar. */\nfunction dnsWriterExec(cfg: HeadscaleDnsConfig, cmd: string[], interactive = false): string[] {\n return [\n \"exec\", ...(interactive ? [\"-i\"] : []),\n \"-n\", cfg.namespace, cfg.pod, \"-c\", cfg.container, \"--\", ...cmd,\n ];\n}\n\n/**\n * Read DNS records from the dns-writer sidecar in the Headscale pod.\n *\n * Throws with an actionable message if kubectl can't reach the pod.\n * Returns an empty array when the file is missing or contains invalid JSON.\n */\nexport function readDnsRecords(cfg: HeadscaleDnsConfig): DnsRecord[] {\n try {\n const raw = execFileSync(\"kubectl\", dnsWriterExec(cfg, [\"cat\", cfg.filePath]), {\n encoding: \"utf-8\",\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n const trimmed = raw.trim();\n if (!trimmed || trimmed === \"[]\") return [];\n try {\n return JSON.parse(trimmed);\n } catch {\n console.warn(`[vpn] DNS records file contains invalid JSON, treating as empty`);\n return [];\n }\n } catch (err) {\n const msg = (err as Error).message ?? String(err);\n if (msg.includes(\"not found\") || msg.includes(\"Unable to connect\")) {\n throw new Error(\n `Cannot reach Headscale DNS writer (namespace=${cfg.namespace}, pod=${cfg.pod}).\\n` +\n `Verify kubectl context and that the Headscale pod is running:\\n` +\n ` kubectl get pods -n ${cfg.namespace}`,\n );\n }\n if (msg.includes(\"No such file\")) {\n return [];\n }\n // Unexpected error \u2014 rethrow\n throw err;\n }\n}\n\n/**\n * Write DNS A records to the dns-writer sidecar in the Headscale pod.\n *\n * Pipes JSON via stdin to avoid shell-escaping issues.\n * Throws with an actionable message if kubectl can't reach the pod.\n */\nexport function registerDnsRecords(cfg: HeadscaleDnsConfig, records: DnsRecord[]): void {\n const json = JSON.stringify(records);\n try {\n execFileSync(\n \"kubectl\",\n dnsWriterExec(cfg, [\"sh\", \"-c\", `cat > '${cfg.filePath}'`], true),\n { input: json, stdio: [\"pipe\", \"pipe\", \"pipe\"] },\n );\n } catch (err) {\n const msg = (err as Error).message ?? String(err);\n throw new Error(\n `Failed to write DNS records to Headscale (namespace=${cfg.namespace}, pod=${cfg.pod}).\\n` +\n `${msg.includes(\"not found\") ? \"Pod not found. \" : \"\"}` +\n `Verify kubectl context: kubectl get pods -n ${cfg.namespace}`,\n );\n }\n}\n\n/**\n * Remove DNS records whose `name` ends with `suffix` from the Headscale pod.\n * Best-effort: logs a warning on failure instead of throwing.\n */\nexport function unregisterDnsRecords(cfg: HeadscaleDnsConfig, suffix: string): void {\n try {\n const records = readDnsRecords(cfg);\n const filtered = records.filter((r) => !r.name.endsWith(suffix));\n registerDnsRecords(cfg, filtered);\n } catch {\n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
1
|
-
/**
|
|
2
|
-
* The `mesh` command tree, as data.
|
|
3
|
-
*
|
|
4
|
-
* `bin/mesh.ts` used to build the commander program inline and immediately
|
|
5
|
-
* parse it, which meant the tree only existed inside a running CLI process.
|
|
6
|
-
* The docs generator needs to *walk* the tree without executing anything, so
|
|
7
|
-
* construction lives here and the bin is a thin runner.
|
|
8
|
-
*
|
|
9
|
-
* Nothing in this module may perform I/O or read credentials at import time —
|
|
10
|
-
* `mesh docs cli-reference` imports it in a plain node process with no AWS
|
|
11
|
-
* config, no Docker, and no TTY.
|
|
12
|
-
*/
|
|
13
1
|
import { Command } from "commander";
|
|
14
2
|
export declare const CLI_NAME = "mesh";
|
|
15
3
|
export declare const CLI_DESCRIPTION = "CLI for Mesh Lab development utilities";
|
|
16
|
-
/**
|
|
17
|
-
* Build a fresh `mesh` program.
|
|
18
|
-
*
|
|
19
|
-
* @param options.version version string for `--version`. Resolving the real
|
|
20
|
-
* one costs git spawns, so callers that don't need it (the docs generator)
|
|
21
|
-
* pass nothing and get a placeholder that never reaches generated output.
|
|
22
|
-
*/
|
|
23
4
|
export declare function createProgram(options?: {
|
|
24
5
|
version?: string;
|
|
25
6
|
}): Command;
|
|
26
|
-
//# sourceMappingURL=program.d.ts.map
|
package/dist/src/program.js
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The `mesh` command tree, as data.
|
|
3
|
-
*
|
|
4
|
-
* `bin/mesh.ts` used to build the commander program inline and immediately
|
|
5
|
-
* parse it, which meant the tree only existed inside a running CLI process.
|
|
6
|
-
* The docs generator needs to *walk* the tree without executing anything, so
|
|
7
|
-
* construction lives here and the bin is a thin runner.
|
|
8
|
-
*
|
|
9
|
-
* Nothing in this module may perform I/O or read credentials at import time —
|
|
10
|
-
* `mesh docs cli-reference` imports it in a plain node process with no AWS
|
|
11
|
-
* config, no Docker, and no TTY.
|
|
12
|
-
*/
|
|
13
1
|
import { Command } from "commander";
|
|
14
2
|
import { registerAppCommands } from "./commands/app-check.js";
|
|
15
3
|
import { registerArtifactsCommands } from "./commands/artifacts.js";
|
|
@@ -38,19 +26,8 @@ import { registerVpnCommands } from "./commands/vpn/index.js";
|
|
|
38
26
|
import { registerWorkflowCommands } from "./commands/workflow.js";
|
|
39
27
|
export const CLI_NAME = "mesh";
|
|
40
28
|
export const CLI_DESCRIPTION = "CLI for Mesh Lab development utilities";
|
|
41
|
-
/**
|
|
42
|
-
* Build a fresh `mesh` program.
|
|
43
|
-
*
|
|
44
|
-
* @param options.version version string for `--version`. Resolving the real
|
|
45
|
-
* one costs git spawns, so callers that don't need it (the docs generator)
|
|
46
|
-
* pass nothing and get a placeholder that never reaches generated output.
|
|
47
|
-
*/
|
|
48
29
|
export function createProgram(options = {}) {
|
|
49
30
|
const program = new Command();
|
|
50
|
-
// Positional options: an option is parsed by the command it follows, so a
|
|
51
|
-
// parent with flags of its own (`mesh init --json`) never swallows the
|
|
52
|
-
// same flag meant for its subcommand (`mesh init app-tenant --json`).
|
|
53
|
-
// Commander requires this on the root for any nested command to opt in.
|
|
54
31
|
program.name(CLI_NAME).description(CLI_DESCRIPTION).enablePositionalOptions();
|
|
55
32
|
if (options.version !== undefined)
|
|
56
33
|
program.version(options.version);
|
|
@@ -81,4 +58,3 @@ export function createProgram(options = {}) {
|
|
|
81
58
|
registerInstallShimCommand(program);
|
|
82
59
|
return program;
|
|
83
60
|
}
|
|
84
|
-
//# sourceMappingURL=program.js.map
|
|
@@ -1,190 +1,53 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* First-run auth preflight helpers (MESH-2479).
|
|
3
|
-
*
|
|
4
|
-
* `mesh start`/`mesh dev` do long work (registry tarball fetches, docker
|
|
5
|
-
* builds, pnpm installs) that fails minutes in — with npm's generic advice —
|
|
6
|
-
* when the CodeArtifact token or AWS SSO session is stale. These helpers
|
|
7
|
-
* verify auth BEFORE the long work and name the exact fixing command.
|
|
8
|
-
*
|
|
9
|
-
* Pure parsers/classifiers are exported separately from the impure probes so
|
|
10
|
-
* the branch logic is unit-testable without network or a home directory.
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* The command that fixes a stale/missing CodeArtifact token — **broker-first**,
|
|
14
|
-
* so it works for someone with no AWS account at all.
|
|
15
|
-
*
|
|
16
|
-
* Bare on purpose. The `@mesh-tech` registry is one global identity
|
|
17
|
-
* (`utils/registry-identity.ts`): `mesh registry login` resolves it, signs in
|
|
18
|
-
* if it must, and writes `~/.npmrc` in a single run, so no remediation ever
|
|
19
|
-
* needs to name a platform context.
|
|
20
|
-
*/
|
|
21
1
|
export declare const REGISTRY_LOGIN_FIX = "mesh registry login";
|
|
22
|
-
/**
|
|
23
|
-
* The AWS-profile form. Only correct for people who **deploy**, or when the
|
|
24
|
-
* registry broker is unavailable.
|
|
25
|
-
*
|
|
26
|
-
* Kept as a separate named constant rather than the default: `--profile`
|
|
27
|
-
* deliberately skips the broker, so printing it as the generic fix sends a
|
|
28
|
-
* developer with no AWS account to a command that cannot work for them.
|
|
29
|
-
*/
|
|
30
2
|
export declare const REGISTRY_LOGIN_FIX_AWS = "mesh registry login --profile mesh-dev";
|
|
31
|
-
/**
|
|
32
|
-
* Render the registry fix. Always the bare command — the registry is global,
|
|
33
|
-
* so a remediation that has to name a context is a remediation the reader has
|
|
34
|
-
* to edit first, and one that names the wrong context does not work at all.
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* registryLoginFix(); // → "mesh registry login"
|
|
38
|
-
*/
|
|
39
3
|
export declare function registryLoginFix(): string;
|
|
40
|
-
/** The documented AWS SSO login form (root package.json `sso` script). */
|
|
41
4
|
export declare const SSO_LOGIN_FIX = "aws sso login --sso-session=mesh # or: pnpm sso";
|
|
42
|
-
/**
|
|
43
|
-
* The `aws configure sso-session` snippet `pnpm sso` depends on. Printed
|
|
44
|
-
* verbatim when ~/.aws/config has no [sso-session mesh] section — kept here
|
|
45
|
-
* so the CLI and scripts/sso-login.sh describe the same setup.
|
|
46
|
-
*/
|
|
47
5
|
export declare const SSO_SESSION_SNIPPET = "[sso-session mesh]\nsso_start_url = https://trabian.awsapps.com/start\nsso_region = us-east-1\nsso_registration_scopes = sso:account:access";
|
|
48
|
-
/**
|
|
49
|
-
* The user-level npmrc `aws codeartifact login` writes into — the token line
|
|
50
|
-
* and, when the namespace flag is omitted, the unscoped `registry=` line.
|
|
51
|
-
*
|
|
52
|
-
* One definition for the whole CLI: the doctor, the probe, and the repair have
|
|
53
|
-
* to be looking at the same file or they disagree about the same machine.
|
|
54
|
-
* `os.homedir()` reads `$HOME` on POSIX, so a scratch-`HOME` test still works.
|
|
55
|
-
*/
|
|
56
6
|
export declare function homeNpmrcPath(): string;
|
|
57
7
|
export interface NpmrcRegistryAuth {
|
|
58
|
-
/** Registry base URL, e.g. https://mesh-platform-…codeartifact…/npm/mesh-packages/ */
|
|
59
8
|
endpoint: string;
|
|
60
9
|
token: string;
|
|
61
10
|
}
|
|
62
|
-
/**
|
|
63
|
-
* Extract the CodeArtifact registry endpoint + auth token from npmrc content.
|
|
64
|
-
* `aws codeartifact login` writes a line shaped like:
|
|
65
|
-
* //mesh-platform-…d.codeartifact.<region>.amazonaws.com/npm/<repo>/:_authToken=<tok>
|
|
66
|
-
* Returns null when no CodeArtifact token line is present.
|
|
67
|
-
*/
|
|
68
11
|
export declare function parseNpmrcRegistryAuth(content: string): NpmrcRegistryAuth | null;
|
|
69
|
-
/**
|
|
70
|
-
* Find an **unscoped** `registry=` line in npmrc content that points at
|
|
71
|
-
* CodeArtifact — the line `aws codeartifact login` writes when it is run
|
|
72
|
-
* WITHOUT `--namespace @mesh-tech`.
|
|
73
|
-
*
|
|
74
|
-
* That line makes CodeArtifact the *default* registry, so every public package
|
|
75
|
-
* (lodash, react, …) is fetched through it with the CodeArtifact token. When
|
|
76
|
-
* the token expires 12 hours later, `npm install` of anything at all fails
|
|
77
|
-
* with E401 — the private-scope breakage everyone expects, plus a total public
|
|
78
|
-
* npm outage nobody does.
|
|
79
|
-
*
|
|
80
|
-
* Deliberately narrow — it must only match a line that is BOTH unscoped AND a
|
|
81
|
-
* CodeArtifact host, so it never touches:
|
|
82
|
-
* - `@mesh-tech:registry=…` (scoped: the line we WANT)
|
|
83
|
-
* - `//…:_authToken=…` (auth, unaffected by the default registry)
|
|
84
|
-
* - `registry=https://npm.acme.internal/` (a team's legitimate private mirror)
|
|
85
|
-
*
|
|
86
|
-
* Returns the offending line verbatim (as it appears in the file), or null.
|
|
87
|
-
*/
|
|
88
12
|
export declare function findUnscopedCodeArtifactRegistry(content: string): string | null;
|
|
89
|
-
/**
|
|
90
|
-
* Remove every unscoped CodeArtifact `registry=` line from npmrc content.
|
|
91
|
-
* Pure: returns the rewritten content plus the first line removed (null when
|
|
92
|
-
* the content was already clean, in which case `content` is returned
|
|
93
|
-
* unchanged and callers should skip the write entirely).
|
|
94
|
-
*/
|
|
95
13
|
export declare function stripUnscopedCodeArtifactRegistry(content: string): {
|
|
96
14
|
content: string;
|
|
97
15
|
removed: string | null;
|
|
98
16
|
};
|
|
99
|
-
/**
|
|
100
|
-
* The `//host/path/:_authToken=` key `aws codeartifact login` writes for a
|
|
101
|
-
* registry endpoint — the endpoint with its scheme stripped and a leading `//`.
|
|
102
|
-
*
|
|
103
|
-
* Pure and shared so the broker path writes byte-identical lines to the AWS CLI
|
|
104
|
-
* path. Two spellings of the same key would leave a stale token line behind
|
|
105
|
-
* that npm might prefer, and the symptom (E401 hours later) points nowhere
|
|
106
|
-
* near the cause.
|
|
107
|
-
*/
|
|
108
17
|
export declare function npmrcAuthKeyForEndpoint(endpoint: string): string;
|
|
109
|
-
/**
|
|
110
|
-
* Upsert `key=value` lines into npmrc content: replace the existing line for a
|
|
111
|
-
* key when present, append it otherwise, and leave every other line untouched.
|
|
112
|
-
*
|
|
113
|
-
* Pure. Always emits a trailing newline, and never reorders lines a
|
|
114
|
-
* user put there themselves — an npmrc is a config file people hand-edit, and
|
|
115
|
-
* a token refresh that rewrites the whole thing is how unrelated settings
|
|
116
|
-
* silently disappear.
|
|
117
|
-
*/
|
|
118
18
|
export declare function upsertNpmrcLines(content: string, entries: ReadonlyArray<{
|
|
119
19
|
key: string;
|
|
120
20
|
value: string;
|
|
121
21
|
}>): string;
|
|
122
22
|
export type RegistryTokenState = "fresh" | "expired" | "missing" | "unreachable";
|
|
123
|
-
/** Map an HTTP status from an authenticated registry request to a token state. */
|
|
124
23
|
export declare function classifyRegistryStatus(status: number): "fresh" | "expired";
|
|
125
24
|
export interface RegistryProbe {
|
|
126
25
|
state: RegistryTokenState;
|
|
127
26
|
detail?: string;
|
|
128
27
|
}
|
|
129
|
-
/**
|
|
130
|
-
* Verify the CodeArtifact token in ~/.npmrc actually works, with one small
|
|
131
|
-
* authenticated metadata request (bounded by `timeoutMs`). Never throws.
|
|
132
|
-
*/
|
|
133
28
|
export declare function probeRegistryToken(opts?: {
|
|
134
29
|
npmrcPath?: string;
|
|
135
30
|
timeoutMs?: number;
|
|
136
31
|
fetchFn?: typeof fetch;
|
|
137
32
|
}): Promise<RegistryProbe>;
|
|
138
|
-
/**
|
|
139
|
-
* The one-glance answer to "can this machine install `@mesh-tech` packages?"
|
|
140
|
-
* — the `~/.npmrc` token probe plus the registry session, classified for a
|
|
141
|
-
* caller that must decide before doing anything else.
|
|
142
|
-
*/
|
|
143
33
|
export interface RegistryPreflight {
|
|
144
|
-
/** `valid` = the token works; the rest mirror `RegistryTokenState`. */
|
|
145
34
|
state: "valid" | "missing" | "expired" | "unreachable";
|
|
146
|
-
/** Who holds the registry session, when one is cached. */
|
|
147
35
|
email?: string;
|
|
148
|
-
/** The command that sets this machine up. */
|
|
149
36
|
fix: string;
|
|
150
|
-
/** The probe's detail, for the warn/fail line. */
|
|
151
37
|
detail?: string;
|
|
152
38
|
}
|
|
153
|
-
/**
|
|
154
|
-
* Classify a probe + session into the preflight verdict. Pure; the network
|
|
155
|
-
* part lives in `registryPreflight`.
|
|
156
|
-
*
|
|
157
|
-
* @example
|
|
158
|
-
* classifyRegistryPreflight({ state: "fresh" }, { email: "dev@trabian.com" }).state; // → "valid"
|
|
159
|
-
*/
|
|
160
39
|
export declare function classifyRegistryPreflight(probe: RegistryProbe, session: {
|
|
161
40
|
email: string;
|
|
162
41
|
} | null): RegistryPreflight;
|
|
163
|
-
/**
|
|
164
|
-
* Registry preflight for commands that cannot proceed without package access
|
|
165
|
-
* (`mesh create-app` outside the platform monorepo). Never throws.
|
|
166
|
-
*
|
|
167
|
-
* @example
|
|
168
|
-
* const pf = await registryPreflight();
|
|
169
|
-
* if (pf.state !== "valid" && pf.state !== "unreachable") process.exit(1);
|
|
170
|
-
*/
|
|
171
42
|
export declare function registryPreflight(opts?: {
|
|
172
43
|
npmrcPath?: string;
|
|
173
44
|
timeoutMs?: number;
|
|
174
45
|
fetchFn?: typeof fetch;
|
|
175
46
|
}): Promise<RegistryPreflight>;
|
|
176
|
-
/** True when npm output/an error message is an auth failure (E401/E403). */
|
|
177
47
|
export declare function isNpmAuthErrorText(text: string): boolean;
|
|
178
|
-
/** True when an npm exec error (with stderr/message) is an auth failure. */
|
|
179
48
|
export declare function isNpmAuthError(err: unknown): boolean;
|
|
180
|
-
/** True when an AWS SDK/CLI error message means the ambient session expired. */
|
|
181
49
|
export declare function isExpiredAwsTokenMessage(message: string): boolean;
|
|
182
|
-
/** Names of `[sso-session <name>]` sections in an AWS config file. */
|
|
183
50
|
export declare function parseSsoSessionNames(content: string): string[];
|
|
184
|
-
/** True when the AWS config file declares the named profile. */
|
|
185
51
|
export declare function awsConfigHasProfile(content: string, profile: string): boolean;
|
|
186
|
-
/** Read ~/.aws/config (honoring AWS_CONFIG_FILE); "" when unreadable. */
|
|
187
52
|
export declare function readAwsConfig(): string;
|
|
188
|
-
/** True when the app's package.json depends on any @mesh-tech/* package. */
|
|
189
53
|
export declare function appUsesMeshPackages(appRoot: string): boolean;
|
|
190
|
-
//# sourceMappingURL=auth-preflight.d.ts.map
|