neon 9.9.0 → 9.9.2

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.
Files changed (42) hide show
  1. package/dist/_chunks/{auth-CEb642X3.js → auth-SCu1foxg.js} +14 -6
  2. package/dist/_chunks/{checkout-9zUY4N8W.js → checkout-CC3Y_LUJ.js} +4 -4
  3. package/dist/_chunks/{claim-D7fATGLw.js → claim-C4DWuUCK.js} +1 -1
  4. package/dist/_chunks/{computes-OKFUNFee.js → computes-Cgc9-J33.js} +4 -15
  5. package/dist/_chunks/{config-CUWOp44_.js → config-Cc0NZ9Rn.js} +2 -2
  6. package/dist/_chunks/{deploy-BUkXtacE.js → deploy-CKKy88xM.js} +1 -1
  7. package/dist/_chunks/{dev-Dp6LuAe2.js → dev-BeaZHcw_.js} +4 -4
  8. package/dist/_chunks/{git-BISnX9MB.js → git-D1hFEGIH.js} +2 -2
  9. package/dist/_chunks/{link-CfbTC-or.js → link-Dz9ROPcr.js} +3 -3
  10. package/dist/_chunks/{postgres-BhR1vUFM.js → postgres-BbEt_7c9.js} +1 -1
  11. package/dist/_chunks/{profile-BVkmMwHO.js → profile-Bcs3EiSZ.js} +1 -1
  12. package/dist/_chunks/{status-BM42rYe1.js → status-ts-VXi7s.js} +1 -1
  13. package/dist/auth.js +3 -0
  14. package/dist/auth_context.js +16 -2
  15. package/dist/auth_recovery.js +1 -1
  16. package/dist/commands/auth.js +1 -1
  17. package/dist/commands/checkout.js +1 -1
  18. package/dist/commands/claim.js +1 -1
  19. package/dist/commands/computes.js +1 -1
  20. package/dist/commands/config.js +1 -1
  21. package/dist/commands/deploy.js +1 -1
  22. package/dist/commands/dev.js +1 -1
  23. package/dist/commands/env.js +1 -1
  24. package/dist/commands/functions_new.js +1 -1
  25. package/dist/commands/git.js +1 -1
  26. package/dist/commands/index.js +12 -12
  27. package/dist/commands/link.js +1 -1
  28. package/dist/commands/postgres.js +1 -1
  29. package/dist/commands/profile.js +1 -1
  30. package/dist/commands/status.js +1 -1
  31. package/dist/commands/subscribe.js +1 -1
  32. package/dist/env.js +7 -1
  33. package/dist/index.js +2 -2
  34. package/dist/init/auth.js +2 -2
  35. package/dist/init/copy.js +27 -13
  36. package/dist/init/deploy.js +2 -2
  37. package/dist/init/link.js +2 -2
  38. package/dist/init/run.js +15 -13
  39. package/dist/utils/inspect_db.js +1 -1
  40. package/dist/utils/inspect_queries.js +43 -17
  41. package/package.json +6 -6
  42. package/dist/_chunks/{env-DxcO3oJk.js → env-6tb3p9iY.js} +2 -2
@@ -4,18 +4,18 @@ import { hasTerminal, isCi } from "../env.js";
4
4
  import { log } from "../log.js";
5
5
  import { withExclusiveLock } from "../refresh_lock.js";
6
6
  import { getApiClient, isNeonApiError } from "../api.js";
7
- import { setAuthContext } from "../auth_context.js";
7
+ import { saveKeyCommand, setAuthContext, signInGuidance } from "../auth_context.js";
8
8
  import { a as isOwnedCredentialPath } from "./paths-B55ZfOg1.js";
9
9
  import { currentContextFile, isAskCommand, isClaimCommand, isConfigAdd, isConfigInit, isCurrentBranchProbe, isDocsCommand, isFeedbackCommand, isFunctionsTemplateCommand, isGitLocalCommand, isIncidentsCommand, isInspectDbUrl, isMcpCommand, isMcpOauth, isPluginsCommand, isProfileCommand, isSkillsCommand, isUnfollowedGitHookSync, readContextFile } from "../context.js";
10
10
  import { _ as readProfiles, b as upsertProfile, f as locationForName, g as profilesUsingPath, i as assertValidProfileName, m as newProfileLocation, n as KEYRING_CREDENTIALS, p as locationOf, r as assertProfilesUsable, t as DEFAULT_PROFILE, u as isKeyringPointer, v as resolveProfile, y as selectProfileName } from "./profiles-kpRUx7gU.js";
11
11
  import { extendTokenSet } from "../utils/auth.js";
12
+ import { getCliName } from "../utils/cli_name.js";
12
13
  import { AuthRefreshError, auth, classifyRefreshFailure, refreshToken } from "../auth.js";
13
14
  import { i as selectCredential, n as displacedProfileWarning, t as credentialInputs } from "./auth_selection-D81EvEz9.js";
14
15
  import { ClaimableClient, ClaimableServiceError } from "../claimable/api.js";
15
16
  import { assertionHasExpired, claimableCredentialsExist, claimableCredentialsPath, readLinkedClaimableCredentials, shouldUseClaimableCredentials } from "../claimable/state.js";
16
17
  import { hostUpdateFor, hostsForProfile, issuingHosts } from "../hosts.js";
17
18
  import { readOutgoingCredential, retirePreviousCredential } from "../retire_credential.js";
18
- import { getCliName } from "../utils/cli_name.js";
19
19
  import { helpEpilogue, helpWidth, wrapHelpText } from "../utils/help_text.js";
20
20
  import { existsSync } from "node:fs";
21
21
  import { join } from "node:path";
@@ -77,7 +77,7 @@ const authFlow = async ({ configDir, oauthHost, clientId, apiHost, forceAuth, "f
77
77
  const declared = readProfiles(configDir)?.profiles[profileName];
78
78
  storeFor(configDir).assertKeyringWritable(declared !== void 0 && isKeyringPointer(declared.credentials) ? profileName : void 0);
79
79
  }
80
- if (!(forceAuth ?? forceAuthKebab) && isCi()) throw new Error("Cannot run interactive auth in CI");
80
+ if (!(forceAuth ?? forceAuthKebab) && isCi()) throw new Error(profile?.trim() || process.env.NEON_PROFILE?.trim() ? `Cannot run interactive auth in CI. Save an API key to this profile: \`${saveKeyCommand(getCliName(), profileName)}\`` : "Cannot run interactive auth in CI. Set NEON_API_KEY to an API key.");
81
81
  let previousFile;
82
82
  let previousWasKeyring = false;
83
83
  let previousOutgoing = null;
@@ -494,13 +494,21 @@ const ensureAuth = async (props) => {
494
494
  return;
495
495
  }
496
496
  const state = loaded === null ? "has no stored credential" : "holds a session that has expired";
497
- const signInHint = `Run \`${getCliName()} login --profile ${selection.profile}\` to sign in, or use an API key with --api-key or NEON_API_KEY.`;
497
+ const forceAuth = props.forceAuth ?? props["force-auth"];
498
+ const signInHint = signInGuidance({
499
+ cli: getCliName(),
500
+ profile: selection.profile,
501
+ explicitProfile: selection.explicit,
502
+ offerClaimable: loaded === null && localContext.projectId === void 0 && localContext.orgId === void 0,
503
+ ci: isCi() && !forceAuth
504
+ });
498
505
  if (props._[0] === "me") {
499
- log.info(`Not signed in: profile "${selection.profile}" ${state}. ${signInHint}`);
506
+ log.info(`Not signed in: profile "${selection.profile}" ${state}.\n${signInHint}`);
500
507
  process.exitCode = 1;
501
508
  return;
502
509
  }
503
- if (!(props.forceAuth ?? props["force-auth"]) && !isCi() && !hasTerminal()) throw new Error(`Not signed in: profile "${selection.profile}" ${state}, and this shell has no terminal to start a browser sign-in from. ${signInHint}`);
510
+ if (!forceAuth && !isCi() && !hasTerminal()) throw new Error(`Not signed in: profile "${selection.profile}" ${state}, and this shell has no terminal to start a browser sign-in from.\n${signInHint}`);
511
+ if (isCi() && !forceAuth) throw new Error(`Cannot run interactive auth in CI. Profile "${selection.profile}" ${state}.\n${signInHint}`);
504
512
  const apiKey = await authFlow({
505
513
  ...props,
506
514
  profile: selection.profile,
@@ -3,17 +3,17 @@ import { isCi } from "../env.js";
3
3
  import { log } from "../log.js";
4
4
  import { isNeonApiError } from "../api.js";
5
5
  import { applyContext, contextBranch, readContextFile } from "../context.js";
6
- import { isClaimableEnvTarget } from "../claimable/state.js";
7
6
  import { getCliName } from "../utils/cli_name.js";
7
+ import { isClaimableEnvTarget } from "../claimable/state.js";
8
8
  import { loadEnvFileIntoProcess } from "../env_file.js";
9
9
  import { createBranch, pickBranchInteractively } from "../utils/branch_picker.js";
10
10
  import { looksLikeBranchId } from "../utils/formats.js";
11
11
  import { fillSingleProject, listAllProjectBranches } from "../utils/enrichers.js";
12
12
  import { buildCheckoutEvent, readGitContext } from "../utils/git.js";
13
13
  import { buildHookBranch, loadHookConfig, resolveHookEnv, runCheckoutAfterHook, runCheckoutBeforeHook, runCreateAfterHook, runCreateBeforeHook } from "../utils/hooks.js";
14
- import { n as autoPullEnvAfterPin } from "./env-DxcO3oJk.js";
15
- import { a as applyPolicyOnCreate, f as envFlag, l as createBranchFromPolicyOnCheckout } from "./config-CUWOp44_.js";
16
- import { i as handler$1 } from "./link-CfbTC-or.js";
14
+ import { n as autoPullEnvAfterPin } from "./env-6tb3p9iY.js";
15
+ import { a as applyPolicyOnCreate, f as envFlag, l as createBranchFromPolicyOnCheckout } from "./config-Cc0NZ9Rn.js";
16
+ import { i as handler$1 } from "./link-Dz9ROPcr.js";
17
17
  import chalk from "chalk";
18
18
  import prompts from "prompts";
19
19
  // src/commands/checkout.ts
@@ -12,7 +12,7 @@ import { projectConfigPath } from "../project.js";
12
12
  import { resolveEnvFilePath } from "../env_file.js";
13
13
  import { writer } from "../writer.js";
14
14
  import { noPassthrough } from "../utils/flags.js";
15
- import { c as pull } from "./env-DxcO3oJk.js";
15
+ import { c as pull } from "./env-6tb3p9iY.js";
16
16
  import { existsSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
17
17
  import open from "open";
18
18
  import prompts from "prompts";
@@ -152,26 +152,15 @@ const updateRequest = (props) => {
152
152
  if (Object.keys(endpoint).length === 0) throw new Error("Nothing to update. Pass --cu, --suspend-timeout, --name, or --disabled.");
153
153
  return endpoint;
154
154
  };
155
- /**
156
- * Mutations return the compute as it was when the request was accepted, so after waiting
157
- * the compute is read again to show the state the change produced.
158
- */
159
155
  const mutate = async (props, action, run) => {
160
156
  const { neon, fail } = await sdk(props);
161
- const params = {
157
+ const compute = await run(neon, {
162
158
  projectId: props.projectId,
163
159
  endpointId: props.id
164
- };
165
- try {
166
- const accepted = await run(neon, params, { waitForReadiness: props.wait });
167
- if (!props.wait) {
168
- writeCompute(props, accepted, `Compute ${props.id}: ${action.verb} accepted, not yet applied`);
169
- return;
170
- }
171
- writeCompute(props, await neon.postgres.endpoints.get(params), `Compute ${props.id} ${action.done}`);
172
- } catch (error) {
160
+ }, { waitForReadiness: props.wait }).catch((error) => {
173
161
  throw fail(error);
174
- }
162
+ });
163
+ writeCompute(props, compute, props.wait ? `Compute ${props.id} ${action.done}` : `Compute ${props.id}: ${action.verb} accepted, not yet applied`);
175
164
  };
176
165
  const update = (props) => {
177
166
  const endpoint = updateRequest(props);
@@ -7,7 +7,7 @@ import "../config.js";
7
7
  import { contextBranch, ensureDirectoryGitignored, readContextFile } from "../context.js";
8
8
  import { DetailedError } from "../errors.js";
9
9
  import { getCliName } from "../utils/cli_name.js";
10
- import { l as existingApiClient } from "./auth-CEb642X3.js";
10
+ import { l as existingApiClient } from "./auth-SCu1foxg.js";
11
11
  import { NEON_SERVICES, NEON_SERVICE_LABELS, deprecatedServiceMessage, servicesFlagValue, servicesOption } from "../neon_services.js";
12
12
  import { FUNCTION_FILENAME, FUNCTION_SLUG, FUNCTION_TEMPLATE, REQUIRED_PACKAGES, dataApiChoiceFromView, parseConfigInitServices, renderFunctionSource, renderNeonConfig, renderNeonConfigFromView } from "../config_template.js";
13
13
  import { TYPESCRIPT_EXTENSION, asRelativeModulePath, editNeonConfig } from "../config_edit.js";
@@ -26,7 +26,7 @@ import { readGitContext } from "../utils/git.js";
26
26
  import { resolveHookEnv, runDeployAfterHook, runDeployBeforeHook } from "../utils/hooks.js";
27
27
  import { pickServicesInteractively } from "../utils/service_picker.js";
28
28
  import { zipBundle } from "../utils/zip.js";
29
- import { n as autoPullEnvAfterPin } from "./env-DxcO3oJk.js";
29
+ import { n as autoPullEnvAfterPin } from "./env-6tb3p9iY.js";
30
30
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
31
31
  import { dirname, join, relative, resolve } from "node:path";
32
32
  import chalk from "chalk";
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
2
  import { fillSingleProject } from "../utils/enrichers.js";
3
- import { f as envFlag, i as applyFlags, p as envPullFlag, r as applyCmd } from "./config-CUWOp44_.js";
3
+ import { f as envFlag, i as applyFlags, p as envPullFlag, r as applyCmd } from "./config-Cc0NZ9Rn.js";
4
4
  import { DEPLOY_COMMANDS_EPILOGUE } from "../commands/deploy_help.js";
5
5
  // src/commands/deploy.ts
6
6
  var deploy_exports = /* @__PURE__ */ __exportAll({
@@ -1,15 +1,15 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
2
  import { log } from "../log.js";
3
- import { isClaimableEnvTarget } from "../claimable/state.js";
4
3
  import { getCliName } from "../utils/cli_name.js";
4
+ import { isClaimableEnvTarget } from "../claimable/state.js";
5
5
  import { defaultDevEnvFiles, readEnvFile, resolveEnvFilePath } from "../env_file.js";
6
6
  import { t as NEON_DEV_FUNCTION_PORTS } from "./env-EJU-0InB.js";
7
- import { branchIdResolve } from "../utils/enrichers.js";
8
- import { bundleEntry } from "../utils/esbuild.js";
9
7
  import { a as resolveDevEnv } from "./env-CFBmcKyo.js";
10
- import { f as envFlag } from "./config-CUWOp44_.js";
11
8
  import { findConfigFunctionBySource, resolveFunctionsFromConfig } from "../dev/functions.js";
12
9
  import { resolveWatchInputs } from "../dev/inputs.js";
10
+ import { branchIdResolve } from "../utils/enrichers.js";
11
+ import { bundleEntry } from "../utils/esbuild.js";
12
+ import { f as envFlag } from "./config-Cc0NZ9Rn.js";
13
13
  import { existsSync, mkdirSync, rmSync, statSync, writeFileSync } from "node:fs";
14
14
  import { basename, dirname, join, relative, resolve } from "node:path";
15
15
  import { fileURLToPath } from "node:url";
@@ -5,8 +5,8 @@ import { CONTEXT_FILE, contextBranch, gitBranchMap, gitBranchMapping, isUnfollow
5
5
  import { writer } from "../writer.js";
6
6
  import { neonSafeBranchName } from "../utils/branch_name.js";
7
7
  import { currentGitBranch, gitPull, gitRepoRoot, hasUpstream, installPostCheckoutHook, isGitRepo, isManagedHook, localGitBranches, postCheckoutHookPath, readGitContext, removePostCheckoutHook } from "../utils/git.js";
8
- import { o as quoteFlagValue } from "./link-CfbTC-or.js";
9
- import { o as handler$1 } from "./checkout-9zUY4N8W.js";
8
+ import { o as quoteFlagValue } from "./link-Dz9ROPcr.js";
9
+ import { o as handler$1 } from "./checkout-CC3Y_LUJ.js";
10
10
  import { existsSync } from "node:fs";
11
11
  import { join } from "node:path";
12
12
  import chalk from "chalk";
@@ -5,16 +5,16 @@ import { isNeonApiError, messageFromBody } from "../api.js";
5
5
  import { r as defaultDir } from "./paths-B55ZfOg1.js";
6
6
  import "../config.js";
7
7
  import { applyContext, contextBranch, readContextFile, setContext, updateContextFile } from "../context.js";
8
- import { isClaimableEnvTarget } from "../claimable/state.js";
9
8
  import { getCliName } from "../utils/cli_name.js";
9
+ import { isClaimableEnvTarget } from "../claimable/state.js";
10
10
  import { helpEpilogue } from "../utils/help_text.js";
11
11
  import { hasNeonConfigFile, projectDir } from "../project.js";
12
12
  import { writer } from "../writer.js";
13
13
  import { createBranch, pickBranchInteractively } from "../utils/branch_picker.js";
14
14
  import { looksLikeBranchId } from "../utils/formats.js";
15
15
  import { listAllProjectBranches } from "../utils/enrichers.js";
16
- import { n as autoPullEnvAfterPin } from "./env-DxcO3oJk.js";
17
- import { h as initCmd } from "./config-CUWOp44_.js";
16
+ import { n as autoPullEnvAfterPin } from "./env-6tb3p9iY.js";
17
+ import { h as initCmd } from "./config-Cc0NZ9Rn.js";
18
18
  import { formatLinkSummary } from "../commands/link_output.js";
19
19
  import { r as REGIONS } from "./projects-a3X4OFEJ.js";
20
20
  import prompts from "prompts";
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
- import { a as computes_exports } from "./computes-OKFUNFee.js";
2
+ import { a as computes_exports } from "./computes-Cgc9-J33.js";
3
3
  import { o as connection_string_exports } from "./connection_string-6WhV4WFx.js";
4
4
  import { s as databases_exports } from "./databases-B-qY303S.js";
5
5
  import { o as psql_exports } from "./psql-BcxiPR4W.js";
@@ -11,7 +11,7 @@ import { auth, revokeToken } from "../auth.js";
11
11
  import { t as credentialInputs } from "./auth_selection-D81EvEz9.js";
12
12
  import { hostUpdateFor, hostsForProfile, issuingHosts } from "../hosts.js";
13
13
  import { readOutgoingCredential, retirePreviousCredential, revokeTokenSet, withdrawKey } from "../retire_credential.js";
14
- import { m as usableCredential, n as authFlow } from "./auth-CEb642X3.js";
14
+ import { m as usableCredential, n as authFlow } from "./auth-SCu1foxg.js";
15
15
  import { identityFromAuthDetails, isApiKeyMethod, mintedKeyName, notAnApiKeyMessage } from "../profile_keys.js";
16
16
  import { writer } from "../writer.js";
17
17
  import { noPassthrough, single } from "../utils/flags.js";
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
2
  import { fillSingleProject } from "../utils/enrichers.js";
3
- import { y as status } from "./config-CUWOp44_.js";
3
+ import { y as status } from "./config-Cc0NZ9Rn.js";
4
4
  // src/commands/status.ts
5
5
  var status_exports = /* @__PURE__ */ __exportAll({
6
6
  builder: () => builder,
package/dist/auth.js CHANGED
@@ -1,7 +1,9 @@
1
+ import { hasTerminal, isAgentContext } from "./env.js";
1
2
  import { log } from "./log.js";
2
3
  import { matchErrorCode } from "./errors.js";
3
4
  import { sendError } from "./analytics.js";
4
5
  import { extendTokenSet } from "./utils/auth.js";
6
+ import { getCliName } from "./utils/cli_name.js";
5
7
  import { createReadStream } from "node:fs";
6
8
  import { join } from "node:path";
7
9
  import { fileURLToPath } from "node:url";
@@ -212,6 +214,7 @@ const auth = async ({ oauthHost, clientId, allowUnsafeTls }) => {
212
214
  });
213
215
  log.info(`Awaiting authentication in web browser (up to 10 minutes).`);
214
216
  log.info(`Auth Url: ${authUrl}`);
217
+ if (isAgentContext(process.env, hasTerminal())) log.info(`Sign-in finishes only in a browser on this machine. If that isn't possible, stop this command and run \`${getCliName()} me\` for other ways to authenticate.`);
215
218
  open(authUrl.href).catch((err) => {
216
219
  const msg = `Failed to open web browser. Please copy & paste auth url to authenticate in browser.`;
217
220
  const typedErr = err && err instanceof Error ? err : void 0;
@@ -28,12 +28,26 @@ const clearAuthContext = () => {
28
28
  const authFailureMessage = (context) => {
29
29
  const profile = context?.profile ?? "the selected profile";
30
30
  const where = context?.storage === "keyring" ? " (OS keyring)" : context?.credentialsPath !== void 0 ? ` (${context.credentialsPath})` : "";
31
- if (context?.source === "profile-api-key") return `Authentication failed: the Neon API rejected profile "${profile}"'s API key${where}. Replace it with \`neon profile create ${profile} --mint\`, or store another with \`neon profile create ${profile} --api-key -\`.`;
31
+ if (context?.source === "profile-api-key") return `Authentication failed: the Neon API rejected profile "${profile}"'s API key${where}. Save a valid key with \`${saveKeyCommand("neon", profile)}\`, or sign in with a browser on this machine to mint one with \`neon profile create ${profile} --mint\`.`;
32
32
  if (context?.source === "claimable") return `Authentication failed: Claimable Neon rejected the linked project's short-lived access token${where}. Retry the command to exchange the saved identity assertion again; if it still fails, run \`neon claim status\`.`;
33
33
  if (context?.source === "stored-credentials") {
34
34
  if (context.storage === "keyring") return `Authentication failed: the Neon API rejected profile "${profile}"'s stored session (OS keyring). Sign in again with \`neon login --profile ${profile}\`.`;
35
35
  return `Authentication failed: the Neon API rejected profile "${profile}"'s stored session${where}. Sign in again with \`neon login --profile ${profile}\`.`;
36
36
  }
37
+ if (context?.apiKeyFrom === "env") return "Authentication failed: the Neon API rejected NEON_API_KEY. It takes precedence over a saved sign-in, so unset it to use that session, or set a valid key.";
38
+ if (context?.apiKeyFrom === "flag") return "Authentication failed: the Neon API rejected the key passed with --api-key. Pass a valid key, or drop --api-key to use a saved sign-in.";
37
39
  return "Authentication failed: the Neon API rejected the API key. Check --api-key or NEON_API_KEY.";
38
40
  };
39
- export { authFailureMessage, clearAuthContext, getAuthContext, locationFromContext, setAuthContext };
41
+ /** `--api-key -` refuses a terminal on stdin, so the key is piped in. */
42
+ const saveKeyCommand = (cli, profile) => `echo "$KEY" | ${cli} profile create ${profile} --api-key -`;
43
+ /**
44
+ * The ways to authenticate when the CLI has no usable credential, one per line. Claimable
45
+ * Neon makes a separate, temporary project, so it is offered only when nothing was ever
46
+ * stored (an expired session means the user has an account) and the directory isn't linked
47
+ * to a project.
48
+ */
49
+ const signInGuidance = (input) => {
50
+ const { cli, profile } = input;
51
+ return [...input.ci ? [input.explicitProfile ? `Save an API key to this profile: \`${saveKeyCommand(cli, profile)}\`` : "Set NEON_API_KEY to an API key."] : [`Sign in with a browser on this machine: \`${cli} login${input.explicitProfile ? ` --profile ${profile}` : ""}\``, `Or save an API key you already have: \`${saveKeyCommand(cli, profile)}\``], ...input.offerClaimable ? [`Or create a temporary project without an account: \`${cli} claim create\` (it expires in 72 hours unless claimed)`] : []].join("\n");
52
+ };
53
+ export { authFailureMessage, clearAuthContext, getAuthContext, locationFromContext, saveKeyCommand, setAuthContext, signInGuidance };
@@ -2,7 +2,7 @@ import { t as storeFor } from "./_chunks/credential_io-BHwacMdt.js";
2
2
  import { log } from "./log.js";
3
3
  import { authFailureMessage, getAuthContext, locationFromContext } from "./auth_context.js";
4
4
  import { AuthRefreshError } from "./auth.js";
5
- import { d as isAccessTokenUsable, p as refreshStoredCredentials } from "./_chunks/auth-CEb642X3.js";
5
+ import { d as isAccessTokenUsable, p as refreshStoredCredentials } from "./_chunks/auth-SCu1foxg.js";
6
6
  // src/auth_recovery.ts
7
7
  const supersededOnDisk = (rejectedToken) => {
8
8
  if (rejectedToken === void 0) return false;
@@ -1 +1 @@
1
- export { t as aliases, n as authFlow, i as builder, a as command, o as deleteCredentialsAt, s as describe, c as ensureAuth, l as existingApiClient, u as handler, d as isAccessTokenUsable, f as locationForAuth, p as refreshStoredCredentials, m as usableCredential } from "../_chunks/auth-CEb642X3.js";
1
+ export { t as aliases, n as authFlow, i as builder, a as command, o as deleteCredentialsAt, s as describe, c as ensureAuth, l as existingApiClient, u as handler, d as isAccessTokenUsable, f as locationForAuth, p as refreshStoredCredentials, m as usableCredential } from "../_chunks/auth-SCu1foxg.js";
@@ -1 +1 @@
1
- export { t as builder, r as command, i as describe, a as formatCheckoutPolicyFailure, o as handler } from "../_chunks/checkout-9zUY4N8W.js";
1
+ export { t as builder, r as command, i as describe, a as formatCheckoutPolicyFailure, o as handler } from "../_chunks/checkout-CC3Y_LUJ.js";
@@ -1 +1 @@
1
- export { t as CLAIM_CREATE_FIELDS, n as CLAIM_LIST_FIELDS, r as aliases, i as builder, a as claimCreateFields, s as claimableCapabilities, c as command, l as create, u as describe, d as handler } from "../_chunks/claim-D7fATGLw.js";
1
+ export { t as CLAIM_CREATE_FIELDS, n as CLAIM_LIST_FIELDS, r as aliases, i as builder, a as claimCreateFields, s as claimableCapabilities, c as command, l as create, u as describe, d as handler } from "../_chunks/claim-C4DWuUCK.js";
@@ -1 +1 @@
1
- export { t as aliases, n as builder, r as builderFor, i as command, o as deleteCompute, s as describe, c as get, l as handler, u as list, d as restart, f as start, p as suspend, m as update } from "../_chunks/computes-OKFUNFee.js";
1
+ export { t as aliases, n as builder, r as builderFor, i as command, o as deleteCompute, s as describe, c as get, l as handler, u as list, d as restart, f as start, p as suspend, m as update } from "../_chunks/computes-Cgc9-J33.js";
@@ -1 +1 @@
1
- export { t as ConfigInstallFailed, n as addCmd, r as applyCmd, i as applyFlags, a as applyPolicyOnCreate, o as builder, s as command, l as createBranchFromPolicyOnCheckout, u as describe, d as ensureConfigPackages, f as envFlag, p as envPullFlag, m as handler, h as initCmd, g as installCommandFrom, _ as missingDependencies, v as planCmd, y as status } from "../_chunks/config-CUWOp44_.js";
1
+ export { t as ConfigInstallFailed, n as addCmd, r as applyCmd, i as applyFlags, a as applyPolicyOnCreate, o as builder, s as command, l as createBranchFromPolicyOnCheckout, u as describe, d as ensureConfigPackages, f as envFlag, p as envPullFlag, m as handler, h as initCmd, g as installCommandFrom, _ as missingDependencies, v as planCmd, y as status } from "../_chunks/config-Cc0NZ9Rn.js";
@@ -1 +1 @@
1
- export { t as builder, n as command, i as describe, a as handler } from "../_chunks/deploy-BUkXtacE.js";
1
+ export { t as builder, n as command, i as describe, a as handler } from "../_chunks/deploy-CKKy88xM.js";
@@ -1 +1 @@
1
- export { t as builder, n as captureShellEnv, r as command, i as describe, a as devBundleDir, o as devEnvContext, c as diffUnits, l as formatEnvFiles, u as formatEnvSummary, d as handler, f as loadDevEnvFiles, p as localFunctionPortsEnv, m as planFunctionsToUnits, h as reportDevCredential, g as sourceFunctionUrlOverlay } from "../_chunks/dev-Dp6LuAe2.js";
1
+ export { t as builder, n as captureShellEnv, r as command, i as describe, a as devBundleDir, o as devEnvContext, c as diffUnits, l as formatEnvFiles, u as formatEnvSummary, d as handler, f as loadDevEnvFiles, p as localFunctionPortsEnv, m as planFunctionsToUnits, h as reportDevCredential, g as sourceFunctionUrlOverlay } from "../_chunks/dev-BeaZHcw_.js";
@@ -1 +1 @@
1
- export { t as ENV_PULL_SKIPPED_HINT, n as autoPullEnvAfterPin, r as builder, i as command, a as describe, s as handler, c as pull } from "../_chunks/env-DxcO3oJk.js";
1
+ export { t as ENV_PULL_SKIPPED_HINT, n as autoPullEnvAfterPin, r as builder, i as command, a as describe, s as handler, c as pull } from "../_chunks/env-6tb3p9iY.js";
@@ -9,7 +9,7 @@ import { writer } from "../writer.js";
9
9
  import { formatInitDone, printInitDone } from "../init/chrome.js";
10
10
  import { FUNCTION_SLUG_PATTERN, deriveFunctionSlug } from "../utils/function_slug.js";
11
11
  import { displayPath } from "./env_output.js";
12
- import { _ as missingDependencies, d as ensureConfigPackages, g as installCommandFrom } from "../_chunks/config-CUWOp44_.js";
12
+ import { _ as missingDependencies, d as ensureConfigPackages, g as installCommandFrom } from "../_chunks/config-Cc0NZ9Rn.js";
13
13
  import { recommendedOperations } from "../functions/registry.js";
14
14
  import { collidingFiles, operationsFromFlags, planConfigRegistration, planEnvExample, planScaffold, writeScaffold } from "../functions/scaffold.js";
15
15
  import { describeRegistrySources, openRegistry } from "../functions/source.js";
@@ -1 +1 @@
1
- export { t as aliases, n as builder, r as cleanup, i as command, a as describe, s as handler, c as install, l as partitionBranchesToPrune, u as status, d as sync, f as uninstall } from "../_chunks/git-BISnX9MB.js";
1
+ export { t as aliases, n as builder, r as cleanup, i as command, a as describe, s as handler, c as install, l as partitionBranchesToPrune, u as status, d as sync, f as uninstall } from "../_chunks/git-D1hFEGIH.js";
@@ -1,30 +1,30 @@
1
- import { r as auth_exports } from "../_chunks/auth-CEb642X3.js";
1
+ import { r as auth_exports } from "../_chunks/auth-SCu1foxg.js";
2
2
  import { t as api_exports } from "../_chunks/api-1MKsfpY3.js";
3
3
  import { n as api_keys_exports } from "../_chunks/api_keys-CTFHd5m_.js";
4
4
  import { n as ask_exports } from "../_chunks/ask-Xlek1Pxh.js";
5
- import { o as env_exports } from "../_chunks/env-DxcO3oJk.js";
6
- import { c as config_exports } from "../_chunks/config-CUWOp44_.js";
5
+ import { o as env_exports } from "../_chunks/env-6tb3p9iY.js";
6
+ import { c as config_exports } from "../_chunks/config-Cc0NZ9Rn.js";
7
7
  import { u as projects_exports } from "../_chunks/projects-a3X4OFEJ.js";
8
- import { a as link_exports } from "../_chunks/link-CfbTC-or.js";
8
+ import { a as link_exports } from "../_chunks/link-Dz9ROPcr.js";
9
9
  import { o as mcp_exports } from "../_chunks/mcp-SvqWzHnT.js";
10
10
  import { c as plugins_exports } from "../_chunks/plugins-BwUZQ6Ic.js";
11
11
  import { l as skills_exports } from "../_chunks/skills-Bv8oKKwE.js";
12
12
  import { t as bootstrap_exports } from "../_chunks/bootstrap-B73qVB39.js";
13
13
  import { r as branches_exports } from "../_chunks/branches-Bp-5z1lM.js";
14
14
  import { n as bucket_exports } from "../_chunks/bucket-D06bvDSa.js";
15
- import { n as checkout_exports } from "../_chunks/checkout-9zUY4N8W.js";
16
- import { o as claim_exports } from "../_chunks/claim-D7fATGLw.js";
15
+ import { n as checkout_exports } from "../_chunks/checkout-CC3Y_LUJ.js";
16
+ import { o as claim_exports } from "../_chunks/claim-C4DWuUCK.js";
17
17
  import { o as connection_string_exports } from "../_chunks/connection_string-6WhV4WFx.js";
18
18
  import { a as credentials_exports } from "../_chunks/credentials-KV1jlK-n.js";
19
19
  import { r as data_api_exports } from "../_chunks/data_api-BpSGbdZf.js";
20
20
  import { s as databases_exports } from "../_chunks/databases-B-qY303S.js";
21
- import { r as deploy_exports } from "../_chunks/deploy-BUkXtacE.js";
22
- import { s as dev_exports } from "../_chunks/dev-Dp6LuAe2.js";
21
+ import { r as deploy_exports } from "../_chunks/deploy-CKKy88xM.js";
22
+ import { s as dev_exports } from "../_chunks/dev-BeaZHcw_.js";
23
23
  import { i as diff_exports } from "../_chunks/diff-dnxneH0u.js";
24
24
  import { c as docs_exports } from "../_chunks/docs-DjYRHjGY.js";
25
25
  import { o as feedback_exports } from "../_chunks/feedback-mQmdTRFn.js";
26
26
  import { o as functions_exports } from "../_chunks/functions-PHaU-kRb.js";
27
- import { o as git_exports } from "../_chunks/git-BISnX9MB.js";
27
+ import { o as git_exports } from "../_chunks/git-D1hFEGIH.js";
28
28
  import { o as incidents_exports } from "../_chunks/incidents-BSFkUu1P.js";
29
29
  import { a as init_exports } from "../_chunks/init-BSwLzxjX.js";
30
30
  import { o as inspect_exports } from "../_chunks/inspect-yFAb61qo.js";
@@ -36,12 +36,12 @@ import { c as operations_exports } from "../_chunks/operations-D7qGkKo3.js";
36
36
  import { o as orgs_exports } from "../_chunks/orgs-BrvAWM8Z.js";
37
37
  import { o as psql_exports } from "../_chunks/psql-BcxiPR4W.js";
38
38
  import { f as roles_exports } from "../_chunks/roles-BELJqjTy.js";
39
- import { o as postgres_exports } from "../_chunks/postgres-BhR1vUFM.js";
40
- import { o as profile_exports } from "../_chunks/profile-BVkmMwHO.js";
39
+ import { o as postgres_exports } from "../_chunks/postgres-BbEt_7c9.js";
40
+ import { o as profile_exports } from "../_chunks/profile-Bcs3EiSZ.js";
41
41
  import { s as realtime_exports } from "../_chunks/realtime-cV7-c2-O.js";
42
42
  import { a as set_context_exports } from "../_chunks/set_context-ompB6d2D.js";
43
43
  import { s as snapshots_exports } from "../_chunks/snapshots-DxNhjcco.js";
44
- import { a as status_exports } from "../_chunks/status-BM42rYe1.js";
44
+ import { a as status_exports } from "../_chunks/status-ts-VXi7s.js";
45
45
  import { d as triggers_exports } from "../_chunks/triggers-m3IBjiph.js";
46
46
  import { s as user_exports } from "../_chunks/user-C1pTJS9O.js";
47
47
  import { i as vpc_endpoints_exports } from "../_chunks/vpc_endpoints-C-Y4WK2M.js";
@@ -1 +1 @@
1
- export { t as builder, n as command, r as describe, i as handler, o as quoteFlagValue, s as runLink, c as shouldOfferConfigInit } from "../_chunks/link-CfbTC-or.js";
1
+ export { t as builder, n as command, r as describe, i as handler, o as quoteFlagValue, s as runLink, c as shouldOfferConfigInit } from "../_chunks/link-Dz9ROPcr.js";
@@ -1 +1 @@
1
- export { t as aliases, n as builder, r as command, i as describe, a as handler } from "../_chunks/postgres-BhR1vUFM.js";
1
+ export { t as aliases, n as builder, r as command, i as describe, a as handler } from "../_chunks/postgres-BbEt_7c9.js";
@@ -1 +1 @@
1
- export { t as aliases, n as builder, r as command, i as describe, a as handler } from "../_chunks/profile-BVkmMwHO.js";
1
+ export { t as aliases, n as builder, r as command, i as describe, a as handler } from "../_chunks/profile-Bcs3EiSZ.js";
@@ -1 +1 @@
1
- export { t as builder, n as command, r as describe, i as handler } from "../_chunks/status-BM42rYe1.js";
1
+ export { t as builder, n as command, r as describe, i as handler } from "../_chunks/status-ts-VXi7s.js";
@@ -1,6 +1,6 @@
1
1
  import { writer } from "../writer.js";
2
- import { branchIdFromProps } from "../utils/enrichers.js";
3
2
  import { o as resolveNeonEnvVars } from "../_chunks/env-CFBmcKyo.js";
3
+ import { branchIdFromProps } from "../utils/enrichers.js";
4
4
  import YAML from "yaml";
5
5
  // src/commands/subscribe.ts
6
6
  const builder = (argv) => argv.usage("$0 realtime subscribe \"<query>\" [options]").positional("query", {
package/dist/env.js CHANGED
@@ -33,6 +33,12 @@ const getCliAgent = (env) => {
33
33
  const declared = env.AI_AGENT?.trim().toLowerCase();
34
34
  return declared && AI_AGENT_NAME.test(declared) ? declared : void 0;
35
35
  };
36
+ /**
37
+ * A coding agent runs the CLI, or no stdio stream has a terminal a person could be watching.
38
+ * Nested agents whose markers conflict are not attributed by `getCliAgent`, so with a terminal
39
+ * they get the human text.
40
+ */
41
+ const isAgentContext = (env, terminal) => getCliAgent(env) !== void 0 || !terminal;
36
42
  const getGithubEnvVars = (env) => {
37
43
  const vars = [
38
44
  "GITHUB_ACTION_PATH",
@@ -54,4 +60,4 @@ const getGithubEnvVars = (env) => {
54
60
  });
55
61
  return Object.fromEntries(map);
56
62
  };
57
- export { getCliAgent, getGithubEnvVars, getTty, hasTerminal, isCi, isDebug, isInteractiveTerminal };
63
+ export { getCliAgent, getGithubEnvVars, getTty, hasTerminal, isAgentContext, isCi, isDebug, isInteractiveTerminal };
package/dist/index.js CHANGED
@@ -7,10 +7,10 @@ import { ensureConfigDir } from "./config.js";
7
7
  import { currentContextFile, enrichFromContext } from "./context.js";
8
8
  import { NETWORK_ERROR_MESSAGE, isNetworkError, matchErrorCode } from "./errors.js";
9
9
  import { analyticsMiddleware, closeAnalytics, initAnalyticsClientMiddleware, isAnalyticsActive, recordCommandSuccessExtras, sendError, takeCommandSuccessExtras, trackCommandSuccess } from "./analytics.js";
10
+ import { getCliName } from "./utils/cli_name.js";
10
11
  import { AuthRefreshError, defaultClientID } from "./auth.js";
11
12
  import { invocationHosts } from "./hosts.js";
12
- import { getCliName } from "./utils/cli_name.js";
13
- import { c as ensureAuth } from "./_chunks/auth-CEb642X3.js";
13
+ import { c as ensureAuth } from "./_chunks/auth-SCu1foxg.js";
14
14
  import { recoverFrom401 } from "./auth_recovery.js";
15
15
  import { UsageError, failOnUsageError, isBareParentCommand, showHelp, showUsageErrorHelp } from "./help.js";
16
16
  import { lazyCommands, preloadCommand } from "./commands/manifest.js";
package/dist/init/auth.js CHANGED
@@ -2,9 +2,9 @@ import { isNeonApiError } from "../api.js";
2
2
  import { r as defaultDir } from "../_chunks/paths-B55ZfOg1.js";
3
3
  import "../config.js";
4
4
  import "../auth.js";
5
- import { c as ensureAuth, l as existingApiClient } from "../_chunks/auth-CEb642X3.js";
5
+ import { c as ensureAuth, l as existingApiClient } from "../_chunks/auth-SCu1foxg.js";
6
6
  import { recoverFrom401 } from "../auth_recovery.js";
7
- import { c as pull } from "../_chunks/env-DxcO3oJk.js";
7
+ import { c as pull } from "../_chunks/env-6tb3p9iY.js";
8
8
  import { c as setupNeonMcp } from "../_chunks/mcp-SvqWzHnT.js";
9
9
  // src/init/auth.ts
10
10
  const isUnauthorized = (error) => isNeonApiError(error) && error.status === 401;
package/dist/init/copy.js CHANGED
@@ -79,25 +79,39 @@ const PROGRESS = {
79
79
  install: (pm) => `Installing Neon dependencies with ${pm}...`,
80
80
  env: "Pulling Neon environment variables..."
81
81
  };
82
- /** `deferred` carries the account and credential flags init was given. */
83
- const unattendedUnauthedNext = (deferred) => deferred === void 0 ? [
84
- "Link a project with a Neon account and an authenticated CLI.",
85
- "Sign up: https://neon.com/signup",
86
- `${getCliName()} login`,
87
- `${getCliName()} link`,
82
+ const saveKeyNext = (saveKey) => [
88
83
  "",
89
- "Or create a claimable project without an account. It expires in 72 hours unless claimed.",
90
- `${getCliName()} claim create`
91
- ] : [
92
- "Link the project once the CLI is authenticated.",
93
- deferred.login,
94
- deferred.link
84
+ "No browser on this machine? Save an API key you already have instead of signing in:",
85
+ saveKey
95
86
  ];
87
+ /** `deferred` carries the account and credential flags init was given. */
88
+ const unattendedUnauthedNext = (saveKey, deferred, claimable = true) => {
89
+ const cli = getCliName();
90
+ if (deferred !== void 0) return [
91
+ "Link the project once the CLI is authenticated.",
92
+ deferred.login,
93
+ deferred.link,
94
+ ...saveKeyNext(saveKey)
95
+ ];
96
+ return [
97
+ "Link a project with a Neon account and an authenticated CLI.",
98
+ "Sign up: https://neon.com/signup",
99
+ `${cli} login`,
100
+ `${cli} link`,
101
+ ...saveKeyNext(saveKey),
102
+ ...claimable ? [
103
+ "",
104
+ "Or create a claimable project without an account. It expires in 72 hours unless claimed.",
105
+ `${cli} claim create`
106
+ ] : []
107
+ ];
108
+ };
96
109
  const PROJECT_PINNED_OFFLINE = "linked, not verified";
97
110
  const offlinePinNext = (input) => [
98
111
  "The link was written without contacting Neon. Sign in to use it:",
99
112
  input.login,
100
- ...input.envPull !== void 0 ? ["Then pull the branch's environment variables:", input.envPull] : []
113
+ ...input.envPull !== void 0 ? ["Then pull the branch's environment variables:", input.envPull] : [],
114
+ ...saveKeyNext(input.saveKey)
101
115
  ];
102
116
  const skippedLinkNext = () => ["To connect this directory to a Neon project:", `${getCliName()} link`];
103
117
  const newConfigNext = (input) => [
@@ -1,10 +1,10 @@
1
1
  import { isNeonApiError } from "../api.js";
2
2
  import { contextBranch, readContextFile } from "../context.js";
3
- import { c as ensureAuth } from "../_chunks/auth-CEb642X3.js";
3
+ import { c as ensureAuth } from "../_chunks/auth-SCu1foxg.js";
4
4
  import { recoverFrom401 } from "../auth_recovery.js";
5
5
  import { loadProjectConfig } from "../project.js";
6
6
  import { loadEnvFileIntoProcess } from "../env_file.js";
7
- import { r as applyCmd } from "../_chunks/config-CUWOp44_.js";
7
+ import { r as applyCmd } from "../_chunks/config-Cc0NZ9Rn.js";
8
8
  import { authContext } from "./auth.js";
9
9
  import { existsSync } from "node:fs";
10
10
  import { missingFunctionEnv } from "@neon/config";
package/dist/init/link.js CHANGED
@@ -2,9 +2,9 @@ import { isNeonApiError } from "../api.js";
2
2
  import { r as defaultDir } from "../_chunks/paths-B55ZfOg1.js";
3
3
  import "../config.js";
4
4
  import "../auth.js";
5
- import { c as ensureAuth } from "../_chunks/auth-CEb642X3.js";
5
+ import { c as ensureAuth } from "../_chunks/auth-SCu1foxg.js";
6
6
  import { recoverFrom401 } from "../auth_recovery.js";
7
- import { s as runLink } from "../_chunks/link-CfbTC-or.js";
7
+ import { s as runLink } from "../_chunks/link-Dz9ROPcr.js";
8
8
  // src/init/link.ts
9
9
  const isUnauthorized = (error) => isNeonApiError(error) && error.status === 401;
10
10
  const authenticationFailed = () => /* @__PURE__ */ new Error("Authentication failed.");
package/dist/init/run.js CHANGED
@@ -3,19 +3,20 @@ import { r as defaultDir } from "../_chunks/paths-B55ZfOg1.js";
3
3
  import "../config.js";
4
4
  import { contextBranch, readContextFile } from "../context.js";
5
5
  import { recordCommandSuccessExtras, takeCommandSuccessExtras } from "../analytics.js";
6
+ import { getCliName } from "../utils/cli_name.js";
6
7
  import "../claimable/api.js";
7
8
  import { readLinkedClaimableCredentials } from "../claimable/state.js";
8
- import { getCliName } from "../utils/cli_name.js";
9
9
  import { servicesFlagValue } from "../neon_services.js";
10
10
  import { CONFIG_INIT_SERVICES, parseConfigInitServices } from "../config_template.js";
11
11
  import { hasNeonConfigFile, neonConfigFilename } from "../project.js";
12
12
  import { inferPackageManager, resolvePackageManager } from "../utils/package_manager.js";
13
+ import { selectProfileName } from "../_shared/profiles.js";
13
14
  import { getAgentDisplayName } from "../mcp/agents.js";
14
15
  import { missingPluginsCommands, pluginsCommandProblemText, pluginsInstallableAgents, unusablePluginsCommands } from "../plugins/targets.js";
15
16
  import { AGENTS_NOT_INSTALLED, CANCELLED_BODY, CLAIMABLE_ACCOUNT_FLAGS, CLAIMABLE_ALREADY_LINKED, CLAIMABLE_MCP_API_KEY, CLAIMABLE_NO_LINK, MCP_API_KEY_NEEDS_AUTH, MCP_SCOPED_NEEDS_PROJECT, NON_TTY_LINK_NEEDS_AUTH, NO_AGENTS_FALLBACK_STATUS, PROGRESS, PROJECT_PINNED_OFFLINE, claimableNext, claimableThenServicesNext, configInitNext, envPullFailedNext, existingConfigNext, installFailedNext, mcpAfterLinkNext, mcpConfigLocationSkipped, mcpConfigLocationUnavailable, mcpKeyFailedNext, namedAgentsUnavailable, newConfigNext, offlinePinNext, skippedLinkNext, toolingFailedNext, unattendedUnauthedNext } from "./copy.js";
16
17
  import { agentsRowValue, configRowValue, formatInitDone, headingForKind, printInitBanner, printInitDone, printInitProgress, projectRowValue, shouldPrintInitBanner } from "./chrome.js";
17
- import { h as initCmd, t as ConfigInstallFailed } from "../_chunks/config-CUWOp44_.js";
18
- import { o as quoteFlagValue, s as runLink } from "../_chunks/link-CfbTC-or.js";
18
+ import { h as initCmd, t as ConfigInstallFailed } from "../_chunks/config-Cc0NZ9Rn.js";
19
+ import { o as quoteFlagValue, s as runLink } from "../_chunks/link-Dz9ROPcr.js";
19
20
  import { runAuthenticatedLink } from "./link.js";
20
21
  import { mcpInstallableAgents } from "../mcp/targets.js";
21
22
  import { skillsInstallableAgents } from "../skills/targets.js";
@@ -25,7 +26,7 @@ import { pullInitEnv, resolveInitConfigApi } from "./auth.js";
25
26
  import { InitCancelled, raceSigint, restoreCursor } from "./cancelled.js";
26
27
  import { pickAgentSetupInteractively, pickInitAgentsInteractively, pickInitConfigInteractively, pickInitMcpAuthInteractively, pickInitMcpConfigLocationInteractively, pickInitModeInteractively, pickInitPackageManagerInteractively, pickInitProjectSetupInteractively, pickInitServicesInteractively, pickInitSkillsInteractively } from "./wizard.js";
27
28
  import { runToolingSteps, toolingStepCommandText } from "./tooling.js";
28
- import { l as create } from "../_chunks/claim-D7fATGLw.js";
29
+ import { l as create } from "../_chunks/claim-C4DWuUCK.js";
29
30
  import { INIT_CONFIG_SERVICES_CONFLICT, configPlanFromResolution, initEnvPullAfterConfig, resolveInitConfigChoice } from "./choices.js";
30
31
  import { detectInitEnvironment } from "./detect.js";
31
32
  import { createInitFunnel, emitInitStart, finishInitFunnel, initStartProperties, recordInitError, recordInitExit } from "./funnel.js";
@@ -51,7 +52,8 @@ const deferredLinkCommands = (props, inputs) => {
51
52
  ...context,
52
53
  ...session
53
54
  ]),
54
- envPull: commandLine("env pull", [...context, ...session])
55
+ envPull: commandLine("env pull", [...context, ...session]),
56
+ saveKey: `echo "$KEY" | ${commandLine(`profile create ${quoteFlagValue(selectProfileName(props.profile))}`, [["--api-key", "-"], session[1]])}`
55
57
  };
56
58
  };
57
59
  const expandTelemetryServices = (services) => {
@@ -668,14 +670,14 @@ const runInit = async (props) => {
668
670
  const pendingExisting = funnel.config === "existing" && linked && !wroteNewFile;
669
671
  const pending = pinnedOffline || pendingUnauthed || pendingServices || pendingClaimable && extraServices || pendingExisting;
670
672
  const next = [];
671
- if (pinnedOffline) {
672
- const commands = deferredLinkCommands(props, linkInputs);
673
- next.push(...offlinePinNext({
674
- login: commands.login,
675
- ...extraServices || existingConfig ? {} : { envPull: commands.envPull }
676
- }));
677
- } else if (pendingUnauthed) {
678
- next.push(...unattendedUnauthedNext(hasExplicitLinkInputs ? deferredLinkCommands(props, linkInputs) : void 0));
673
+ const commands = deferredLinkCommands(props, linkInputs);
674
+ if (pinnedOffline) next.push(...offlinePinNext({
675
+ login: commands.login,
676
+ ...extraServices || existingConfig ? {} : { envPull: commands.envPull },
677
+ saveKey: commands.saveKey
678
+ }));
679
+ else if (pendingUnauthed) {
680
+ next.push(...unattendedUnauthedNext(commands.saveKey, hasExplicitLinkInputs ? commands : void 0, readContextFile(contextFile).projectId === void 0 && readContextFile(contextFile).orgId === void 0));
679
681
  const deferredMcp = mcpDeferredNext();
680
682
  if (deferredMcp.length > 0) next.push("", ...deferredMcp);
681
683
  } else if (noLink && !alreadyLinked) next.push(...skippedLinkNext());
@@ -215,7 +215,7 @@ const runInspectQuery = async (connectionUri, sql, options = {}) => {
215
215
  try {
216
216
  const ext = options.requiresExtension;
217
217
  if (ext) {
218
- if ((await connection.query(`SELECT 1 FROM pg_extension WHERE extname = '${ext}';`)).rows.length === 0) throw new Error(`This query needs the "${ext}" extension, which is not installed. Enable it with: CREATE EXTENSION ${ext};`);
218
+ if ((await connection.query(`SELECT /* neon inspect */ 1 FROM pg_extension WHERE extname = '${ext}';`)).rows.length === 0) throw new Error(`This query needs the "${ext}" extension, which is not installed. Enable it with: CREATE EXTENSION ${ext};`);
219
219
  }
220
220
  const result = await connection.query(sql);
221
221
  return rowsFrom(result);
@@ -1,4 +1,28 @@
1
1
  // src/utils/inspect_queries.ts
2
+ /**
3
+ * Drops `pg_stat_statements` rows (alias `s`) that the user's workload did not
4
+ * run: Neon's compute manager runs its setup as `cloud_admin`; Neon's proxy
5
+ * resets each pooled session it serves HTTP queries on with the listed
6
+ * statements, as the user's role; and every diagnostic here carries the
7
+ * `neon inspect` comment. The comment has to follow the statement's first
8
+ * keyword: Postgres drops a leading comment from the text it stores.
9
+ * `@neon/tools` keeps an identical copy for `database.inspect`.
10
+ *
11
+ * The role is matched by name because `--db-url` runs this against any
12
+ * Postgres, where an app may well log in as a superuser. `query` is NULL when
13
+ * Postgres cannot read its stored text, hence `COALESCE`.
14
+ */
15
+ const WORKLOAD_STATEMENTS_FILTER = `
16
+ NOT EXISTS (
17
+ SELECT 1 FROM pg_roles r
18
+ WHERE r.oid = s.userid AND r.rolname = 'cloud_admin'
19
+ )
20
+ AND COALESCE(s.query, '') NOT IN (
21
+ 'CLOSE ALL', 'SET SESSION AUTHORIZATION DEFAULT', 'RESET ALL',
22
+ 'DEALLOCATE ALL', 'UNLISTEN *', 'SELECT pg_advisory_unlock_all()',
23
+ 'DISCARD TEMP', 'DISCARD SEQUENCES'
24
+ )
25
+ AND COALESCE(s.query, '') NOT LIKE '%/* neon inspect */%'`;
2
26
  const INSPECT_QUERIES = {
3
27
  "table-sizes": {
4
28
  describe: "Size of each table (including TOAST), largest first (pg_table_size)",
@@ -10,7 +34,7 @@ const INSPECT_QUERIES = {
10
34
  ],
11
35
  emptyMessage: "No user tables found.",
12
36
  sql: `
13
- SELECT
37
+ SELECT /* neon inspect */
14
38
  n.nspname AS schema,
15
39
  c.relname AS name,
16
40
  pg_size_pretty(pg_table_size(c.oid)) AS size
@@ -32,7 +56,7 @@ const INSPECT_QUERIES = {
32
56
  ],
33
57
  emptyMessage: "No indexes found.",
34
58
  sql: `
35
- SELECT
59
+ SELECT /* neon inspect */
36
60
  n.nspname AS schema,
37
61
  c.relname AS name,
38
62
  pg_size_pretty(pg_relation_size(c.oid)) AS size
@@ -55,7 +79,7 @@ const INSPECT_QUERIES = {
55
79
  ],
56
80
  emptyMessage: "No unused indexes detected.",
57
81
  sql: `
58
- SELECT
82
+ SELECT /* neon inspect */
59
83
  s.schemaname || '.' || s.relname AS "table",
60
84
  s.indexrelname AS index,
61
85
  pg_size_pretty(pg_relation_size(s.indexrelid)) AS index_size,
@@ -78,7 +102,7 @@ const INSPECT_QUERIES = {
78
102
  ],
79
103
  emptyMessage: "No user tables found.",
80
104
  sql: `
81
- SELECT
105
+ SELECT /* neon inspect */
82
106
  schemaname AS schema,
83
107
  relname AS name,
84
108
  seq_scan AS count
@@ -98,7 +122,7 @@ const INSPECT_QUERIES = {
98
122
  emptyMessage: "No long-running queries in this database.",
99
123
  emptyMessageAll: "No long-running queries in any database.",
100
124
  sql: `
101
- SELECT
125
+ SELECT /* neon inspect */
102
126
  pid,
103
127
  (now() - query_start)::text AS duration,
104
128
  state,
@@ -124,7 +148,7 @@ const INSPECT_QUERIES = {
124
148
  ],
125
149
  emptyMessage: "No active queries running longer than 30 seconds.",
126
150
  sql: `
127
- WITH activity AS MATERIALIZED (
151
+ WITH /* neon inspect */ activity AS MATERIALIZED (
128
152
  SELECT *
129
153
  FROM pg_stat_activity
130
154
  WHERE state = 'active'
@@ -180,7 +204,7 @@ const INSPECT_QUERIES = {
180
204
  emptyMessage: "No locks held in this database.",
181
205
  emptyMessageAll: "No locks held in any database.",
182
206
  sql: `
183
- SELECT
207
+ SELECT /* neon inspect */
184
208
  a.pid,
185
209
  c.relname,
186
210
  l.mode,
@@ -198,7 +222,7 @@ const INSPECT_QUERIES = {
198
222
  `
199
223
  },
200
224
  outliers: {
201
- describe: "Queries taking the most cumulative execution time (needs pg_stat_statements)",
225
+ describe: "Queries taking the most cumulative execution time, leaving out Neon's own setup and session-reset statements and inspect's own queries (needs pg_stat_statements)",
202
226
  scope: "database",
203
227
  fields: [
204
228
  "total_exec_time",
@@ -209,7 +233,7 @@ const INSPECT_QUERIES = {
209
233
  emptyMessage: "No statements recorded yet.",
210
234
  requiresExtension: "pg_stat_statements",
211
235
  sql: `
212
- SELECT
236
+ SELECT /* neon inspect */
213
237
  (interval '1 millisecond' * total_exec_time)::text AS total_exec_time,
214
238
  to_char(
215
239
  (total_exec_time / nullif(sum(total_exec_time) OVER (), 0)) * 100,
@@ -220,12 +244,13 @@ const INSPECT_QUERIES = {
220
244
  FROM pg_stat_statements s
221
245
  JOIN pg_database d ON d.oid = s.dbid
222
246
  WHERE d.datname = current_database()
247
+ AND ${WORKLOAD_STATEMENTS_FILTER}
223
248
  ORDER BY total_exec_time DESC
224
249
  LIMIT 25;
225
250
  `
226
251
  },
227
252
  calls: {
228
- describe: "Most frequently called queries (needs pg_stat_statements)",
253
+ describe: "Most frequently called queries, leaving out Neon's own setup and session-reset statements and inspect's own queries (needs pg_stat_statements)",
229
254
  scope: "database",
230
255
  fields: [
231
256
  "ncalls",
@@ -236,7 +261,7 @@ const INSPECT_QUERIES = {
236
261
  emptyMessage: "No statements recorded yet.",
237
262
  requiresExtension: "pg_stat_statements",
238
263
  sql: `
239
- SELECT
264
+ SELECT /* neon inspect */
240
265
  calls AS ncalls,
241
266
  (interval '1 millisecond' * total_exec_time)::text AS total_exec_time,
242
267
  to_char(
@@ -247,6 +272,7 @@ const INSPECT_QUERIES = {
247
272
  FROM pg_stat_statements s
248
273
  JOIN pg_database d ON d.oid = s.dbid
249
274
  WHERE d.datname = current_database()
275
+ AND ${WORKLOAD_STATEMENTS_FILTER}
250
276
  ORDER BY calls DESC
251
277
  LIMIT 25;
252
278
  `
@@ -258,7 +284,7 @@ const INSPECT_QUERIES = {
258
284
  emptyMessage: "No LFC stats available.",
259
285
  requiresExtension: "neon",
260
286
  sql: `
261
- WITH lfc AS (
287
+ WITH /* neon inspect */ lfc AS (
262
288
  SELECT lfc_key AS k, lfc_value AS v
263
289
  FROM neon_get_lfc_stats() t(lfc_key text, lfc_value bigint)
264
290
  )
@@ -285,7 +311,7 @@ const INSPECT_QUERIES = {
285
311
  emptyMessage: "No working-set estimate available.",
286
312
  requiresExtension: "neon",
287
313
  sql: `
288
- SELECT
314
+ SELECT /* neon inspect */
289
315
  w.window,
290
316
  pg_size_pretty(w.working_set_bytes) AS working_set,
291
317
  pg_size_pretty(pg_size_bytes(current_setting('neon.file_cache_size_limit'))) AS lfc_size,
@@ -319,7 +345,7 @@ const INSPECT_QUERIES = {
319
345
  ],
320
346
  emptyMessage: "No user tables found.",
321
347
  sql: `
322
- SELECT
348
+ SELECT /* neon inspect */
323
349
  n.nspname AS schema,
324
350
  c.relname AS "table",
325
351
  to_char(psut.last_vacuum, 'YYYY-MM-DD HH24:MI') AS last_vacuum,
@@ -352,7 +378,7 @@ const INSPECT_QUERIES = {
352
378
  ],
353
379
  emptyMessage: "No bloat estimate available.",
354
380
  sql: `
355
- WITH constants AS (
381
+ WITH /* neon inspect */ constants AS (
356
382
  SELECT current_setting('block_size')::numeric AS bs, 23 AS hdr, 8 AS ma
357
383
  ),
358
384
  bloat_info AS (
@@ -417,7 +443,7 @@ const INSPECT_QUERIES = {
417
443
  ],
418
444
  emptyMessage: "No replication slots found.",
419
445
  sql: `
420
- SELECT
446
+ SELECT /* neon inspect */
421
447
  s.slot_name,
422
448
  s.slot_type,
423
449
  CASE
@@ -460,7 +486,7 @@ const INSPECT_QUERIES = {
460
486
  emptyMessage: "No subscriptions found on this database.",
461
487
  emptyMessageAll: "No subscriptions found on any database.",
462
488
  sql: `
463
- SELECT
489
+ SELECT /* neon inspect */
464
490
  sub.subname AS subscription,
465
491
  sr.srrelid::regclass::text AS table_name,
466
492
  CASE sr.srsubstate
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neon",
3
- "version": "9.9.0",
3
+ "version": "9.9.2",
4
4
  "description": "CLI tool for Neon, the cloud backend primitives built around Lakebase Postgres",
5
5
  "keywords": [
6
6
  "neon",
@@ -73,9 +73,9 @@
73
73
  "yaml": "^2.9.0",
74
74
  "yargs": "17.7.2",
75
75
  "yoctocolors": "^2.1.2",
76
- "@neon/sdk": "7.14.3",
77
- "@neon/config": "1.14.5",
78
- "@neon/config-runtime": "1.12.8",
76
+ "@neon/sdk": "7.15.0",
77
+ "@neon/config": "1.14.6",
78
+ "@neon/config-runtime": "1.12.9",
79
79
  "@neon/realtime": "0.2.1"
80
80
  },
81
81
  "optionalDependencies": {
@@ -113,9 +113,9 @@
113
113
  "typescript": "^5.9.0",
114
114
  "vitest": "^3.0.9",
115
115
  "@neon-internals/cli-core": "0.0.0",
116
- "@neon-internals/env-core": "0.0.56",
116
+ "@neon-internals/env-core": "0.0.57",
117
117
  "@neon/e2e-harness": "0.0.0",
118
- "@neon/env": "2.1.8",
118
+ "@neon/env": "2.1.9",
119
119
  "@neon/functions": "0.11.0"
120
120
  },
121
121
  "publishConfig": {
@@ -1,14 +1,14 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
2
  import { log } from "../log.js";
3
3
  import { ensureGitignored } from "../context.js";
4
- import { isClaimableEnvTarget } from "../claimable/state.js";
5
4
  import { getCliName } from "../utils/cli_name.js";
5
+ import { isClaimableEnvTarget } from "../claimable/state.js";
6
6
  import { deprecatedServiceMessage, parseServices, servicesFlagValue, servicesOption } from "../neon_services.js";
7
7
  import { mergeEnvFile, readEnvFile, resolveEnvFilePath } from "../env_file.js";
8
8
  import { n as NEON_ENV_VAR_KEYS } from "./env-EJU-0InB.js";
9
9
  import { ENV_PULL_KEY_HELP, ENV_PULL_SERVICES, envKeysForSelection, envPullFlagValue, isLegacyFunctionBaseUrlKey, ownedEnvServiceKeys, parseEnvPullKeys } from "../env_services.js";
10
- import { fillSingleProject, resolveBranchRef } from "../utils/enrichers.js";
11
10
  import { i as dropClaimableUnsupported, o as resolveNeonEnvVars } from "./env-CFBmcKyo.js";
11
+ import { fillSingleProject, resolveBranchRef } from "../utils/enrichers.js";
12
12
  import { warnAiGateway } from "../utils/ai_gateway_notice.js";
13
13
  import { formatPulledEnv, pulledBranch } from "../commands/env_output.js";
14
14
  import { existsSync } from "node:fs";