neon 8.23.3 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +9 -8
  2. package/dist/_chunks/{checkout-Bsfl-B0h.js → checkout-B_gbS0nD.js} +3 -3
  3. package/dist/_chunks/{claim-B3tMeMuo.js → claim-BVEwQ65H.js} +1 -1
  4. package/dist/_chunks/{config-DZ3cDaOS.js → config-BClSMzco.js} +1 -43
  5. package/dist/_chunks/{deploy-CF4PxuNX.js → deploy-CJ22hy3i.js} +1 -1
  6. package/dist/_chunks/{dev-BnHQENZM.js → dev-CSoQfCuS.js} +21 -22
  7. package/dist/_chunks/{env-CIFMBEon.js → env-CFBmcKyo.js} +18 -45
  8. package/dist/_chunks/{env-BOt9AZ1j.js → env-DxcO3oJk.js} +21 -24
  9. package/dist/_chunks/{env-JgoSsmyt.js → env-EJU-0InB.js} +49 -110
  10. package/dist/_chunks/{git-CRYW7ku0.js → git-C6XPViK5.js} +2 -2
  11. package/dist/_chunks/{link-VYCSKqU-.js → link-n40BxbmK.js} +2 -2
  12. package/dist/_chunks/{status-rt-0bUaQ.js → status-TDYLPWRO.js} +1 -1
  13. package/dist/commands/checkout.js +1 -1
  14. package/dist/commands/claim.js +1 -1
  15. package/dist/commands/config.js +1 -1
  16. package/dist/commands/deploy.js +1 -1
  17. package/dist/commands/dev.js +1 -1
  18. package/dist/commands/env.js +1 -1
  19. package/dist/commands/env_output.js +4 -4
  20. package/dist/commands/functions_new.js +1 -1
  21. package/dist/commands/git.js +1 -1
  22. package/dist/commands/index.js +9 -9
  23. package/dist/commands/link.js +1 -1
  24. package/dist/commands/status.js +1 -1
  25. package/dist/commands/subscribe.js +1 -1
  26. package/dist/dev/env.js +1 -1
  27. package/dist/env_services.js +30 -23
  28. package/dist/errors.js +2 -1
  29. package/dist/init/auth.js +1 -1
  30. package/dist/init/choices.js +8 -6
  31. package/dist/init/deploy.js +1 -1
  32. package/dist/init/link.js +1 -1
  33. package/dist/init/run.js +3 -3
  34. package/dist/utils/ai_gateway_notice.js +47 -114
  35. package/dist/utils/hooks.js +9 -4
  36. package/dist/utils/service_picker.js +1 -1
  37. package/package.json +8 -8
package/dist/init/run.js CHANGED
@@ -14,8 +14,8 @@ import { getAgentDisplayName } from "../mcp/agents.js";
14
14
  import { missingPluginsCommands, pluginsCommandProblemText, pluginsInstallableAgents, unusablePluginsCommands } from "../plugins/targets.js";
15
15
  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
16
  import { agentsRowValue, configRowValue, formatInitDone, headingForKind, printInitBanner, printInitDone, printInitProgress, projectRowValue, shouldPrintInitBanner } from "./chrome.js";
17
- import { h as initCmd, t as ConfigInstallFailed } from "../_chunks/config-DZ3cDaOS.js";
18
- import { o as quoteFlagValue, s as runLink } from "../_chunks/link-VYCSKqU-.js";
17
+ import { h as initCmd, t as ConfigInstallFailed } from "../_chunks/config-BClSMzco.js";
18
+ import { o as quoteFlagValue, s as runLink } from "../_chunks/link-n40BxbmK.js";
19
19
  import { runAuthenticatedLink } from "./link.js";
20
20
  import { mcpInstallableAgents } from "../mcp/targets.js";
21
21
  import { skillsInstallableAgents } from "../skills/targets.js";
@@ -25,7 +25,7 @@ import { pullInitEnv, resolveInitConfigApi } from "./auth.js";
25
25
  import { InitCancelled, raceSigint, restoreCursor } from "./cancelled.js";
26
26
  import { pickAgentSetupInteractively, pickInitAgentsInteractively, pickInitConfigInteractively, pickInitMcpAuthInteractively, pickInitMcpConfigLocationInteractively, pickInitModeInteractively, pickInitPackageManagerInteractively, pickInitProjectSetupInteractively, pickInitServicesInteractively, pickInitSkillsInteractively } from "./wizard.js";
27
27
  import { runToolingSteps, toolingStepCommandText } from "./tooling.js";
28
- import { l as create } from "../_chunks/claim-B3tMeMuo.js";
28
+ import { l as create } from "../_chunks/claim-BVEwQ65H.js";
29
29
  import { INIT_CONFIG_SERVICES_CONFLICT, configPlanFromResolution, initEnvPullAfterConfig, resolveInitConfigChoice } from "./choices.js";
30
30
  import { detectInitEnvironment } from "./detect.js";
31
31
  import { createInitFunnel, emitInitStart, finishInitFunnel, initStartProperties, recordInitError, recordInitExit } from "./funnel.js";
@@ -1,41 +1,18 @@
1
1
  import { log } from "../log.js";
2
2
  // src/utils/ai_gateway_notice.ts
3
3
  /**
4
- * Friendly guidance shown when a branch enables the AI Gateway (`aiGateway`).
5
- *
6
- * The gateway is credential-gated, not provisioned: enabling it always mints a working
7
- * branch credential, so `apply` / `checkout` / `env pull` succeed regardless of plan. The
8
- * two things that *do* gate the gateway happen at serving time and are invisible in the
9
- * provisioning result, so we surface them as a courtesy notice instead:
10
- *
11
- * - **Free plan** — credentials provision, but the gateway does not *serve* model requests.
12
- * The account needs to upgrade to a paid plan.
13
- * - **Reduced model set** — on a paid plan, an account still ramping up on the beta gets a
14
- * trimmed model catalog (flagship models are listed but `enabled: false` on `/v1/models`).
15
- * They can request access to more models.
16
- *
17
- * This is deliberately phrased for the user: it never mentions account "verification" or any
18
- * other internal gating mechanism.
4
+ * A minted gateway credential says nothing about whether the account can serve a model:
5
+ * that is decided per request, so the branch's own `/v1/models` is the only source for it.
19
6
  */
7
+ /** Despite the name, adding a card and buying AI Gateway credits clears it on any plan. */
8
+ const CREDITS_REQUIRED_REASON = "paid_plan_required";
9
+ const PREPAID_CREDITS_DOCS_URL = "https://neon.com/docs/ai-gateway/prepaid-credits";
20
10
  /**
21
- * `BillingSubscriptionType` values that mean the account is on a Free plan (the gateway
22
- * won't serve requests). Everything else — `launch`, `scale`, `business`, the `*_v3`
23
- * variants, marketplace plans — is treated as paid.
24
- */
25
- const FREE_SUBSCRIPTION_TYPES = /* @__PURE__ */ new Set(["free_v2", "free_v3"]);
26
- /**
27
- * The Neon Console billing page to upgrade a Free-plan account so the gateway can serve. It's
28
- * org-scoped when the project belongs to an org; projects on a personal account (which is
29
- * where Free plans usually live) have no org id, so we fall back to the account-level page.
30
- */
31
- const aiGatewayUpgradeUrl = (orgId) => orgId ? `https://console.neon.tech/app/${orgId}/billing` : "https://console.neon.tech/app/billing";
32
- /**
33
- * The branch's AI Gateway page in the Neon Console — where a paid user with a reduced model
34
- * set requests access to more models. It's branch-scoped, so it's built from the linked
35
- * project and branch ids.
11
+ * The branch's AI Gateway page in the Neon Console — where a user with a reduced model set
12
+ * requests access to more models. It's branch-scoped, so it's built from the linked project
13
+ * and branch ids.
36
14
  */
37
15
  const aiGatewayModelsUrl = (projectId, branchId) => `https://console.neon.tech/app/projects/${projectId}/branches/${branchId}/ai-gateway`;
38
- const isFreePlan = (subscriptionType) => subscriptionType !== void 0 && FREE_SUBSCRIPTION_TYPES.has(subscriptionType);
39
16
  /**
40
17
  * Whether the model catalog includes at least one flagship model enabled. Flagship models
41
18
  * (Anthropic Opus, OpenAI Codex / `*-pro`) are the first to be held back for an account still
@@ -44,29 +21,18 @@ const isFreePlan = (subscriptionType) => subscriptionType !== void 0 && FREE_SUB
44
21
  * version bumps (e.g. `claude-opus-4-8`).
45
22
  */
46
23
  const hasFlagshipModels = (modelIds) => modelIds.some((id) => id.includes("opus") || id.includes("codex") || id.endsWith("-pro"));
47
- /**
48
- * The message shown when a `neon.ts` that enables the AI Gateway is applied on a Free plan.
49
- * Provisioning is refused up front (see {@link assertAiGatewayProvisionable}) because the
50
- * gateway won't serve model requests until the account is on a paid plan. `upgradeUrl` is the
51
- * org-scoped Console billing page (see {@link aiGatewayUpgradeUrl}).
52
- */
53
- const freePlanBlockMessage = (upgradeUrl) => `This neon.ts enables the AI Gateway, which isn't available on the Free plan — the gateway won't serve model requests. Upgrade to a paid plan and re-run, or remove \`aiGateway\` from neon.ts. Upgrade here: ${upgradeUrl}`;
54
- /**
55
- * Build the AI Gateway courtesy notice for an account's plan and (optionally) its live model
56
- * catalog, or `null` when nothing needs saying.
57
- *
58
- * `modelIds` is `undefined` when the catalog wasn't probed (e.g. a dry-run `plan`, or a probe
59
- * that failed); in that case only the plan-based (Free) notice can be produced — never a
60
- * false "reduced models" warning. `upgradeUrl` is the org-scoped Console billing page
61
- * (Free notice); `moreModelsUrl` is the branch's Console AI Gateway page
62
- * (see {@link aiGatewayModelsUrl}), shown when the catalog is reduced.
63
- */
64
- const buildAiGatewayNotice = ({ subscriptionType, modelIds, upgradeUrl, moreModelsUrl }) => {
65
- if (isFreePlan(subscriptionType)) return {
24
+ const noEnabledModelsMessage = (unavailable) => {
25
+ if (unavailable.reason === CREDITS_REQUIRED_REASON) return `AI Gateway is enabled, but no models are available to this account until it has AI Gateway credits. Credits work on every Neon plan, including Free. Add a card and buy credits on the Billing page: ${unavailable.recoveryUrl ?? PREPAID_CREDITS_DOCS_URL}`;
26
+ return `AI Gateway is enabled, but no models are available to this account yet (${unavailable.reason}). ` + (unavailable.recoveryUrl ? `Resolve it here: ${unavailable.recoveryUrl}` : "See https://neon.com/docs/ai-gateway/troubleshooting");
27
+ };
28
+ /** An unreadable catalog (`undefined`) stays silent rather than risk a false warning. */
29
+ const buildAiGatewayNotice = ({ catalog, moreModelsUrl }) => {
30
+ if (catalog === void 0) return null;
31
+ if (catalog.enabledIds.length === 0) return catalog.unavailable ? {
66
32
  level: "warning",
67
- message: `AI Gateway is enabled, but the gateway does not serve model requests on the Free plan. Upgrade to a paid plan to start making requests: ${upgradeUrl}`
68
- };
69
- if (modelIds !== void 0 && modelIds.length > 0 && !hasFlagshipModels(modelIds)) return {
33
+ message: noEnabledModelsMessage(catalog.unavailable)
34
+ } : null;
35
+ if (!hasFlagshipModels(catalog.enabledIds)) return {
70
36
  level: "warning",
71
37
  message: `Not every model is enabled for your account yet, so some models are missing from the catalog. Request access to more models here: ${moreModelsUrl}`
72
38
  };
@@ -74,76 +40,43 @@ const buildAiGatewayNotice = ({ subscriptionType, modelIds, upgradeUrl, moreMode
74
40
  };
75
41
  const isRecord = (value) => typeof value === "object" && value !== null;
76
42
  /**
77
- * Pull the `id`s of enabled models out of an OpenAI-compatible
78
- * `{ object: "list", data: [{ id, enabled, ... }] }` body. The gateway lists every model in
79
- * the catalog but marks ones the account can't serve yet with `enabled: false`; only the
80
- * enabled set is used to detect a reduced catalog.
43
+ * The gateway lists every catalog model, and marks the ones the account can't serve with
44
+ * `enabled: false`, an `unavailable_reason`, and a `recovery_url`.
81
45
  */
82
- const extractEnabledModelIds = (body) => {
46
+ const parseGatewayCatalog = (body) => {
83
47
  if (!isRecord(body) || !Array.isArray(body.data)) return null;
84
- const ids = [];
85
- for (const entry of body.data) if (isRecord(entry) && typeof entry.id === "string" && entry.enabled === true) ids.push(entry.id);
86
- return ids;
48
+ const enabledIds = [];
49
+ let unavailable;
50
+ for (const entry of body.data) {
51
+ if (!isRecord(entry) || typeof entry.id !== "string") continue;
52
+ if (entry.enabled === true) enabledIds.push(entry.id);
53
+ else if (unavailable === void 0 && typeof entry.unavailable_reason === "string") unavailable = {
54
+ reason: entry.unavailable_reason,
55
+ ...typeof entry.recovery_url === "string" ? { recoveryUrl: entry.recovery_url } : {}
56
+ };
57
+ }
58
+ return unavailable ? {
59
+ enabledIds,
60
+ unavailable
61
+ } : { enabledIds };
87
62
  };
88
- /**
89
- * `GET {baseUrl}/v1/models` → the enabled model ids, or `null` if the catalog can't be read
90
- * (network / HTTP / parse failure). Returning `null` keeps the notice silent rather than
91
- * risking a false "reduced models" warning. `/v1/models` is served only on the unified
92
- * dialect (the `/openai/v1` Responses dialect returns 404).
93
- */
94
- const fetchGatewayModelIds = async (baseUrl, token) => {
63
+ /** `/v1/models` is served only on the unified dialect; `/openai/v1` returns 404. */
64
+ const fetchGatewayCatalog = async (baseUrl, token) => {
95
65
  try {
96
66
  const res = await fetch(`${baseUrl.replace(/\/+$/, "")}/v1/models`, { headers: { Authorization: `Bearer ${token}` } });
97
67
  if (!res.ok) return null;
98
- return extractEnabledModelIds(await res.json());
68
+ return parseGatewayCatalog(await res.json());
99
69
  } catch {
100
70
  return null;
101
71
  }
102
72
  };
103
- /**
104
- * Refuse to provision the AI Gateway on a Free plan. Called before the `neon.ts` lifecycle
105
- * commands provision a branch (`config apply` / `deploy`, `checkout`), so a Free-plan user
106
- * gets a clear "upgrade first" error instead of a credential that can't serve requests.
107
- *
108
- * Best-effort on the plan lookup: if the plan can't be determined (network / API failure) we
109
- * do NOT block, so a transient error never wrongly refuses a paid user's deploy. Only a
110
- * positively-identified Free plan throws.
111
- */
112
- const assertAiGatewayProvisionable = async (params) => {
113
- let subscriptionType;
114
- let orgId;
115
- try {
116
- const { data } = await params.apiClient.getProject(params.projectId);
117
- subscriptionType = data.project.owner?.subscription_type;
118
- orgId = data.project.org_id ?? void 0;
119
- } catch {
120
- return;
121
- }
122
- if (isFreePlan(subscriptionType)) throw new Error(freePlanBlockMessage(aiGatewayUpgradeUrl(orgId)));
123
- };
124
- /**
125
- * Resolve the account's plan (and, when gateway credentials are on hand, its live model
126
- * catalog) and print the AI Gateway courtesy notice — used by the `neon.ts` lifecycle and
127
- * `env pull` whenever a branch has the gateway enabled.
128
- *
129
- * Pass `gateway` (base URL + token) to enable the reduced-model-set check; omit it (e.g. a
130
- * dry-run `plan`) to get only the Free-plan notice. This is best-effort: any failure while
131
- * fetching the plan or catalog is swallowed so it can never break the underlying command.
132
- */
73
+ /** A courtesy notice: no failure here may fail the env pull that called it. */
133
74
  const warnAiGateway = async (params) => {
134
- const modelsRead = params.gateway ? fetchGatewayModelIds(params.gateway.baseUrl, params.gateway.token) : null;
135
- try {
136
- const { data } = await params.apiClient.getProject(params.projectId);
137
- const subscriptionType = data.project.owner?.subscription_type;
138
- const orgId = data.project.org_id ?? void 0;
139
- const modelIds = modelsRead ? await modelsRead ?? void 0 : void 0;
140
- const notice = buildAiGatewayNotice({
141
- subscriptionType,
142
- modelIds,
143
- upgradeUrl: aiGatewayUpgradeUrl(orgId),
144
- moreModelsUrl: aiGatewayModelsUrl(params.projectId, params.branchId)
145
- });
146
- if (notice) log.warning(notice.message);
147
- } catch {}
75
+ const catalog = await fetchGatewayCatalog(params.gateway.baseUrl, params.gateway.token);
76
+ const notice = buildAiGatewayNotice({
77
+ catalog: catalog ?? void 0,
78
+ moreModelsUrl: aiGatewayModelsUrl(params.projectId, params.branchId)
79
+ });
80
+ if (notice) log.warning(notice.message);
148
81
  };
149
- export { aiGatewayModelsUrl, aiGatewayUpgradeUrl, assertAiGatewayProvisionable, buildAiGatewayNotice, extractEnabledModelIds, fetchGatewayModelIds, freePlanBlockMessage, hasFlagshipModels, isFreePlan, warnAiGateway };
82
+ export { aiGatewayModelsUrl, buildAiGatewayNotice, fetchGatewayCatalog, hasFlagshipModels, parseGatewayCatalog, warnAiGateway };
@@ -1,6 +1,6 @@
1
1
  import { log } from "../log.js";
2
2
  import { loadProjectConfig } from "../project.js";
3
- import { s as fetchEnvKeys } from "../_chunks/env-JgoSsmyt.js";
3
+ import { c as fetchEnvKeys } from "../_chunks/env-EJU-0InB.js";
4
4
  import { runHook } from "@neon/config-runtime";
5
5
  // src/utils/hooks.ts
6
6
  /**
@@ -170,7 +170,11 @@ const shapeHookEnv = (resolved) => ({
170
170
  databaseUrl: resolved.postgres?.databaseUrl ?? "",
171
171
  databaseUrlUnpooled: resolved.postgres?.databaseUrlUnpooled ?? ""
172
172
  },
173
- ...resolved.branch?.name ? { branch: { name: resolved.branch.name } } : {},
173
+ ...resolved.branch?.name ? { branch: {
174
+ name: resolved.branch.name,
175
+ ...resolved.branch.id ? { id: resolved.branch.id } : {},
176
+ ...resolved.branch.functionHostSuffix ? { functionHostSuffix: resolved.branch.functionHostSuffix } : {}
177
+ } } : {},
174
178
  ...resolved.auth?.baseUrl !== void 0 && resolved.auth.jwksUrl !== void 0 ? { auth: {
175
179
  baseUrl: resolved.auth.baseUrl,
176
180
  jwksUrl: resolved.auth.jwksUrl
@@ -185,8 +189,7 @@ const shapeHookEnv = (resolved) => ({
185
189
  ...resolved.aiGateway?.apiKey !== void 0 && resolved.aiGateway.baseUrl !== void 0 ? { aiGateway: {
186
190
  apiKey: resolved.aiGateway.apiKey,
187
191
  baseUrl: resolved.aiGateway.baseUrl
188
- } } : {},
189
- ...resolved.functions ? { functions: Object.fromEntries(Object.entries(resolved.functions).map(([slug, fn]) => [slug, { baseUrl: fn.baseUrl }])) } : {}
192
+ } } : {}
190
193
  });
191
194
  /** Re-derive the OS-level env vars from a {@link HookEnv} for shell-hook injection. */
192
195
  const hookEnvToProcessEnv = (env) => {
@@ -195,6 +198,8 @@ const hookEnvToProcessEnv = (env) => {
195
198
  DATABASE_URL_UNPOOLED: env.postgres.databaseUrlUnpooled
196
199
  };
197
200
  if (env.branch?.name) out.NEON_BRANCH = env.branch.name;
201
+ if (env.branch?.id) out.NEON_BRANCH_ID = env.branch.id;
202
+ if (env.branch?.functionHostSuffix) out.NEON_FUNCTION_HOST_SUFFIX = env.branch.functionHostSuffix;
198
203
  if (env.auth) {
199
204
  out.NEON_AUTH_BASE_URL = env.auth.baseUrl;
200
205
  out.NEON_AUTH_JWKS_URL = env.auth.jwksUrl;
@@ -51,7 +51,7 @@ const CHOICES = [
51
51
  {
52
52
  value: "ai-gateway",
53
53
  title: "AI Gateway",
54
- description: "All models, one API, one bill. Powered by Databricks. Not available on the Neon free plan."
54
+ description: "All models, one API, one bill. Powered by Databricks."
55
55
  }
56
56
  ];
57
57
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neon",
3
- "version": "8.23.3",
3
+ "version": "9.0.0",
4
4
  "description": "CLI tool for Neon, the cloud backend primitives built around Lakebase Postgres",
5
5
  "keywords": [
6
6
  "neon",
@@ -73,10 +73,10 @@
73
73
  "yaml": "^2.9.0",
74
74
  "yargs": "17.7.2",
75
75
  "yoctocolors": "^2.1.2",
76
- "@neon/config-runtime": "1.11.7",
77
- "@neon/config": "1.11.3",
78
- "@neon/sdk": "7.10.0",
79
- "@neon/realtime": "0.2.0"
76
+ "@neon/config-runtime": "1.11.8",
77
+ "@neon/config": "1.12.0",
78
+ "@neon/realtime": "0.2.0",
79
+ "@neon/sdk": "7.10.0"
80
80
  },
81
81
  "optionalDependencies": {
82
82
  "@napi-rs/keyring": "1.3.0",
@@ -113,10 +113,10 @@
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.45",
116
+ "@neon-internals/env-core": "0.0.46",
117
+ "@neon/e2e-harness": "0.0.0",
117
118
  "@neon/functions": "0.11.0",
118
- "@neon/env": "1.6.15",
119
- "@neon/e2e-harness": "0.0.0"
119
+ "@neon/env": "2.0.0"
120
120
  },
121
121
  "publishConfig": {
122
122
  "access": "public",