neon 8.23.2 → 8.23.4
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 +1 -1
- package/dist/_chunks/{checkout-CNBIS3gA.js → checkout-OEE3GTc_.js} +3 -3
- package/dist/_chunks/{claim-DhV0f_5o.js → claim-C-9or54_.js} +1 -1
- package/dist/_chunks/{config-CgtJH8xE.js → config-DPuP7ywm.js} +11 -51
- package/dist/_chunks/{deploy-Bs5gmi4Q.js → deploy-CpF33Ij-.js} +1 -1
- package/dist/_chunks/{dev-DxiIp4c9.js → dev-BE5TL7ZH.js} +1 -1
- package/dist/_chunks/{env-BtG4vH55.js → env-C4-EYFmE.js} +1 -2
- package/dist/_chunks/{git-DRUZBCmZ.js → git-R8RebFpF.js} +2 -2
- package/dist/_chunks/{link-CNO-HxHN.js → link-PLk7-vwB.js} +2 -2
- package/dist/_chunks/{status-BlrzeKyA.js → status-BjaHpnTV.js} +1 -1
- package/dist/commands/checkout.js +1 -1
- package/dist/commands/claim.js +1 -1
- package/dist/commands/config.js +1 -1
- package/dist/commands/deploy.js +1 -1
- package/dist/commands/dev.js +1 -1
- package/dist/commands/env.js +1 -1
- package/dist/commands/functions_new.js +3 -3
- package/dist/commands/git.js +1 -1
- package/dist/commands/index.js +9 -9
- package/dist/commands/link.js +1 -1
- package/dist/commands/status.js +1 -1
- package/dist/errors.js +18 -2
- package/dist/init/auth.js +1 -1
- package/dist/init/copy.js +2 -2
- package/dist/init/deploy.js +1 -1
- package/dist/init/funnel.js +2 -1
- package/dist/init/link.js +1 -1
- package/dist/init/run.js +4 -4
- package/dist/utils/ai_gateway_notice.js +47 -114
- package/dist/utils/package_manager.js +126 -7
- package/dist/utils/service_picker.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -694,7 +694,7 @@ export default defineConfig({
|
|
|
694
694
|
◯ Object Storage
|
|
695
695
|
S3-compatible blob storage that branches with your projects.
|
|
696
696
|
◯ AI Gateway
|
|
697
|
-
All models, one API, one bill. Powered by Databricks.
|
|
697
|
+
All models, one API, one bill. Powered by Databricks.
|
|
698
698
|
```
|
|
699
699
|
|
|
700
700
|
Postgres cannot be unselected. Selecting nothing else is a valid answer: you get the starter policy, which is also what a non-interactive run (CI, no TTY) writes. Pass `--services` to skip the prompt anywhere:
|
|
@@ -11,9 +11,9 @@ 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-
|
|
15
|
-
import { a as applyPolicyOnCreate, f as envFlag, l as createBranchFromPolicyOnCheckout } from "./config-
|
|
16
|
-
import { i as handler$1 } from "./link-
|
|
14
|
+
import { n as autoPullEnvAfterPin } from "./env-C4-EYFmE.js";
|
|
15
|
+
import { a as applyPolicyOnCreate, f as envFlag, l as createBranchFromPolicyOnCheckout } from "./config-DPuP7ywm.js";
|
|
16
|
+
import { i as handler$1 } from "./link-PLk7-vwB.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-
|
|
15
|
+
import { c as pull } from "./env-C4-EYFmE.js";
|
|
16
16
|
import { existsSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
17
17
|
import open from "open";
|
|
18
18
|
import prompts from "prompts";
|
|
@@ -5,6 +5,7 @@ import { getApiClient } from "../api.js";
|
|
|
5
5
|
import { r as defaultDir } from "./paths-B55ZfOg1.js";
|
|
6
6
|
import "../config.js";
|
|
7
7
|
import { contextBranch, ensureDirectoryGitignored, readContextFile } from "../context.js";
|
|
8
|
+
import { DetailedError } from "../errors.js";
|
|
8
9
|
import { getCliName } from "../utils/cli_name.js";
|
|
9
10
|
import { l as existingApiClient } from "./auth-rup6nemJ.js";
|
|
10
11
|
import { NEON_SERVICES, NEON_SERVICE_LABELS, deprecatedServiceMessage, servicesFlagValue, servicesOption } from "../neon_services.js";
|
|
@@ -14,10 +15,9 @@ import { toNeonConfigView } from "../config_format.js";
|
|
|
14
15
|
import { declaredNeonServices } from "../config_services.js";
|
|
15
16
|
import { loadProjectConfig, neonConfigFilename, projectConfigPath, projectDir } from "../project.js";
|
|
16
17
|
import { loadEnvFileIntoProcess } from "../env_file.js";
|
|
17
|
-
import { formatInstallCommand, installArgs, resolvePackageManager,
|
|
18
|
+
import { formatInstallCommand, installArgs, resolvePackageManager, runCommandWithDetail } from "../utils/package_manager.js";
|
|
18
19
|
import { writer } from "../writer.js";
|
|
19
20
|
import { fillSingleProject, resolveBranchRef } from "../utils/enrichers.js";
|
|
20
|
-
import { assertAiGatewayProvisionable, warnAiGateway } from "../utils/ai_gateway_notice.js";
|
|
21
21
|
import { announceTargetBranch } from "../utils/branch_notice.js";
|
|
22
22
|
import { renderAppliedChanges, renderBranchSettingConflicts, renderCustomDomainFollowup } from "../utils/config_diff.js";
|
|
23
23
|
import { bundleEntry } from "../utils/esbuild.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-
|
|
29
|
+
import { n as autoPullEnvAfterPin } from "./env-C4-EYFmE.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";
|
|
@@ -128,9 +128,9 @@ const DEPENDENCY_FIELDS = [
|
|
|
128
128
|
"peerDependencies",
|
|
129
129
|
"optionalDependencies"
|
|
130
130
|
];
|
|
131
|
-
var ConfigInstallFailed = class extends
|
|
132
|
-
constructor(command) {
|
|
133
|
-
super(
|
|
131
|
+
var ConfigInstallFailed = class extends DetailedError {
|
|
132
|
+
constructor(command, pm, detail) {
|
|
133
|
+
super(`Could not install the Neon dependencies with ${pm} (${detail}).`, detail);
|
|
134
134
|
this.name = "ConfigInstallFailed";
|
|
135
135
|
this.command = command;
|
|
136
136
|
}
|
|
@@ -268,7 +268,7 @@ const installCommandFrom = (dir, pm, missing, options) => {
|
|
|
268
268
|
};
|
|
269
269
|
/** Install the config packages the project is missing, or say how to. */
|
|
270
270
|
const ensureConfigPackages = async (cwd, props) => {
|
|
271
|
-
const run = props.run ??
|
|
271
|
+
const run = props.run ?? runCommandWithDetail;
|
|
272
272
|
const missing = missingDependencies(cwd);
|
|
273
273
|
if (missing.length === 0) {
|
|
274
274
|
if (!props.silent) log.info("%s are already installed.", REQUIRED_PACKAGES.join(" and "));
|
|
@@ -288,9 +288,10 @@ const ensureConfigPackages = async (cwd, props) => {
|
|
|
288
288
|
}
|
|
289
289
|
ensureDirectoryGitignored(join(cwd, "node_modules"));
|
|
290
290
|
if (!props.silent) log.info("Installing %s with %s…", missing.join(", "), pm);
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
291
|
+
const result = await run(pm, args, cwd);
|
|
292
|
+
if (!result.ok) {
|
|
293
|
+
if (props.requireInstall) throw new ConfigInstallFailed(installHint, pm, result.detail);
|
|
294
|
+
log.warning("Could not install the config packages automatically with %s (%s). Run by hand: %s", pm, result.detail, installHint);
|
|
294
295
|
}
|
|
295
296
|
};
|
|
296
297
|
/**
|
|
@@ -738,11 +739,6 @@ const planCmd = async (props) => {
|
|
|
738
739
|
const services = utilizedServices(config);
|
|
739
740
|
reportPushResult(props, result, "plan", services);
|
|
740
741
|
if (result.conflicts.some((conflict) => conflict.field === "customDomain" && !reasonAllowsUpdateExisting(conflict.reason))) process.exitCode = 1;
|
|
741
|
-
if (services.includes("AI Gateway")) await warnAiGateway({
|
|
742
|
-
apiClient: props.apiClient,
|
|
743
|
-
projectId: props.projectId,
|
|
744
|
-
branchId
|
|
745
|
-
});
|
|
746
742
|
};
|
|
747
743
|
const warnDeprecatedPreview = (config, target) => {
|
|
748
744
|
const message = previewGaWarningForConfig(config, target);
|
|
@@ -815,10 +811,6 @@ const applyCmd = async (props) => {
|
|
|
815
811
|
announceTargetBranch(props, branch, "Applying to branch");
|
|
816
812
|
warnDeprecatedPreview(config, warningTargetFromResolved(branch));
|
|
817
813
|
const branchId = branch.branchId;
|
|
818
|
-
if (utilizedServices(config).includes("AI Gateway")) await assertAiGatewayProvisionable({
|
|
819
|
-
apiClient: props.apiClient,
|
|
820
|
-
projectId: props.projectId
|
|
821
|
-
});
|
|
822
814
|
const cwd = process.cwd();
|
|
823
815
|
const git = readGitContext(cwd);
|
|
824
816
|
const event = { type: "neon-deploy" };
|
|
@@ -992,24 +984,6 @@ const reportConflicts = (props, conflicts) => {
|
|
|
992
984
|
for (const conflict of conflicts) if (!reasonAllowsUpdateExisting(conflict.reason)) out.text(` ! ${conflict.field}: ${conflict.reason}\n`);
|
|
993
985
|
};
|
|
994
986
|
/**
|
|
995
|
-
* Block provisioning the AI Gateway on a Free plan from the `checkout` policy paths, which
|
|
996
|
-
* carry raw credentials (`apiKey`/`apiHost`) rather than the CLI's api client. Builds a client
|
|
997
|
-
* from them and defers to {@link assertAiGatewayProvisionable}. Skipped when a `runtimeApi` is
|
|
998
|
-
* injected (tests) or no `apiKey` is available; the interactive commands always have a key.
|
|
999
|
-
*/
|
|
1000
|
-
const assertAiGatewayProvisionableFromCreds = async (props) => {
|
|
1001
|
-
if (props.runtimeApi || !props.apiKey) return;
|
|
1002
|
-
if (!utilizedServices(props.config).includes("AI Gateway")) return;
|
|
1003
|
-
const apiClient = getApiClient({
|
|
1004
|
-
apiKey: props.apiKey,
|
|
1005
|
-
...props.apiHost ? { apiHost: props.apiHost } : {}
|
|
1006
|
-
});
|
|
1007
|
-
await assertAiGatewayProvisionable({
|
|
1008
|
-
apiClient,
|
|
1009
|
-
projectId: props.projectId
|
|
1010
|
-
});
|
|
1011
|
-
};
|
|
1012
|
-
/**
|
|
1013
987
|
* Apply a `neon.ts` policy to a **freshly created** branch (used by `neonctl checkout`
|
|
1014
988
|
* when it creates a branch). No-op when there is no `neon.ts` on the path from cwd up to
|
|
1015
989
|
* the repo root — checkout still succeeds, it just has no policy to apply.
|
|
@@ -1043,13 +1017,6 @@ const applyPolicyOnCreate = async (props) => {
|
|
|
1043
1017
|
} catch {
|
|
1044
1018
|
warnDeprecatedPreview(config);
|
|
1045
1019
|
}
|
|
1046
|
-
await assertAiGatewayProvisionableFromCreds({
|
|
1047
|
-
projectId: props.projectId,
|
|
1048
|
-
...props.apiKey ? { apiKey: props.apiKey } : {},
|
|
1049
|
-
...props.apiHost ? { apiHost: props.apiHost } : {},
|
|
1050
|
-
...props.runtimeApi ? { runtimeApi: props.runtimeApi } : {},
|
|
1051
|
-
config
|
|
1052
|
-
});
|
|
1053
1020
|
log.info("Applying neon.ts policy to the new branch…");
|
|
1054
1021
|
const result = await apply(config, {
|
|
1055
1022
|
projectId: props.projectId,
|
|
@@ -1115,13 +1082,6 @@ const createBranchFromPolicyOnCheckout = async (props) => {
|
|
|
1115
1082
|
if (/Could not find a Neon config file/i.test(message)) return null;
|
|
1116
1083
|
throw err;
|
|
1117
1084
|
}
|
|
1118
|
-
await assertAiGatewayProvisionableFromCreds({
|
|
1119
|
-
projectId: props.projectId,
|
|
1120
|
-
...props.apiKey ? { apiKey: props.apiKey } : {},
|
|
1121
|
-
...props.apiHost ? { apiHost: props.apiHost } : {},
|
|
1122
|
-
...props.runtimeApi ? { runtimeApi: props.runtimeApi } : {},
|
|
1123
|
-
config
|
|
1124
|
-
});
|
|
1125
1085
|
try {
|
|
1126
1086
|
const { branchId, branchName, result } = await createBranch(config, {
|
|
1127
1087
|
projectId: props.projectId,
|
|
@@ -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-
|
|
3
|
+
import { f as envFlag, i as applyFlags, p as envPullFlag, r as applyCmd } from "./config-DPuP7ywm.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({
|
|
@@ -7,7 +7,7 @@ import { l as functionBaseUrlKey } from "./env-JgoSsmyt.js";
|
|
|
7
7
|
import { branchIdResolve } from "../utils/enrichers.js";
|
|
8
8
|
import { bundleEntry } from "../utils/esbuild.js";
|
|
9
9
|
import { a as resolveDevEnv } from "./env-CIFMBEon.js";
|
|
10
|
-
import { f as envFlag } from "./config-
|
|
10
|
+
import { f as envFlag } from "./config-DPuP7ywm.js";
|
|
11
11
|
import { findConfigFunctionBySource, resolveFunctionsFromConfig } from "../dev/functions.js";
|
|
12
12
|
import { resolveWatchInputs } from "../dev/inputs.js";
|
|
13
13
|
import { existsSync, mkdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
@@ -8,8 +8,8 @@ import { mergeEnvFile, readEnvFile, resolveEnvFilePath } from "../env_file.js";
|
|
|
8
8
|
import { t as NEON_ENV_VAR_KEYS, u as isFunctionBaseUrlKey } from "./env-JgoSsmyt.js";
|
|
9
9
|
import { ENV_PULL_KEY_HELP, ENV_PULL_SERVICES, envKeysForSelection, envPullFlagValue, ownedEnvServiceKeys, parseEnvPullKeys } from "../env_services.js";
|
|
10
10
|
import { fillSingleProject, resolveBranchRef } from "../utils/enrichers.js";
|
|
11
|
-
import { warnAiGateway } from "../utils/ai_gateway_notice.js";
|
|
12
11
|
import { i as dropClaimableUnsupported, o as resolveNeonEnvVars } from "./env-CIFMBEon.js";
|
|
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";
|
|
15
15
|
import chalk from "chalk";
|
|
@@ -179,7 +179,6 @@ const pull = async (props, opts = {}) => {
|
|
|
179
179
|
const gatewayBaseUrl = neonVars.NEON_AI_GATEWAY_BASE_URL;
|
|
180
180
|
const gatewayToken = neonVars.NEON_AI_GATEWAY_TOKEN;
|
|
181
181
|
if (gatewayBaseUrl && gatewayToken) await warnAiGateway({
|
|
182
|
-
apiClient: props.apiClient,
|
|
183
182
|
projectId: props.projectId,
|
|
184
183
|
branchId,
|
|
185
184
|
gateway: {
|
|
@@ -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-
|
|
9
|
-
import { o as handler$1 } from "./checkout-
|
|
8
|
+
import { o as quoteFlagValue } from "./link-PLk7-vwB.js";
|
|
9
|
+
import { o as handler$1 } from "./checkout-OEE3GTc_.js";
|
|
10
10
|
import { existsSync } from "node:fs";
|
|
11
11
|
import { join } from "node:path";
|
|
12
12
|
import chalk from "chalk";
|
|
@@ -13,8 +13,8 @@ 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-
|
|
17
|
-
import { h as initCmd } from "./config-
|
|
16
|
+
import { n as autoPullEnvAfterPin } from "./env-C4-EYFmE.js";
|
|
17
|
+
import { h as initCmd } from "./config-DPuP7ywm.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,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-
|
|
3
|
+
import { y as status } from "./config-DPuP7ywm.js";
|
|
4
4
|
// src/commands/status.ts
|
|
5
5
|
var status_exports = /* @__PURE__ */ __exportAll({
|
|
6
6
|
builder: () => builder,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as builder, r as command, i as describe, a as formatCheckoutPolicyFailure, o as handler } from "../_chunks/checkout-
|
|
1
|
+
export { t as builder, r as command, i as describe, a as formatCheckoutPolicyFailure, o as handler } from "../_chunks/checkout-OEE3GTc_.js";
|
package/dist/commands/claim.js
CHANGED
|
@@ -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-
|
|
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-C-9or54_.js";
|
package/dist/commands/config.js
CHANGED
|
@@ -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-
|
|
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-DPuP7ywm.js";
|
package/dist/commands/deploy.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as builder, n as command, i as describe, a as handler } from "../_chunks/deploy-
|
|
1
|
+
export { t as builder, n as command, i as describe, a as handler } from "../_chunks/deploy-CpF33Ij-.js";
|
package/dist/commands/dev.js
CHANGED
|
@@ -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 localFunctionUrlEnv, m as planFunctionsToUnits, h as reportDevCredential, g as sourceFunctionUrlOverlay } from "../_chunks/dev-
|
|
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 localFunctionUrlEnv, m as planFunctionsToUnits, h as reportDevCredential, g as sourceFunctionUrlOverlay } from "../_chunks/dev-BE5TL7ZH.js";
|
package/dist/commands/env.js
CHANGED
|
@@ -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-
|
|
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-C4-EYFmE.js";
|
|
@@ -3,12 +3,12 @@ import { log } from "../log.js";
|
|
|
3
3
|
import { getCliName } from "../utils/cli_name.js";
|
|
4
4
|
import { projectConfigPath, projectDir } from "../project.js";
|
|
5
5
|
import { resolveEnvFilePath } from "../env_file.js";
|
|
6
|
-
import { installArgs, resolvePackageManager,
|
|
6
|
+
import { installArgs, resolvePackageManager, runCommandWithDetail } from "../utils/package_manager.js";
|
|
7
7
|
import { writer } from "../writer.js";
|
|
8
8
|
import { formatInitDone, printInitDone } from "../init/chrome.js";
|
|
9
9
|
import { FUNCTION_SLUG_PATTERN, deriveFunctionSlug } from "../utils/function_slug.js";
|
|
10
10
|
import { displayPath } from "./env_output.js";
|
|
11
|
-
import { _ as missingDependencies, d as ensureConfigPackages, g as installCommandFrom } from "../_chunks/config-
|
|
11
|
+
import { _ as missingDependencies, d as ensureConfigPackages, g as installCommandFrom } from "../_chunks/config-DPuP7ywm.js";
|
|
12
12
|
import { recommendedOperations } from "../functions/registry.js";
|
|
13
13
|
import { collidingFiles, operationsFromFlags, planConfigRegistration, planEnvExample, planScaffold, writeScaffold } from "../functions/scaffold.js";
|
|
14
14
|
import { describeRegistrySource, openRegistry } from "../functions/source.js";
|
|
@@ -143,7 +143,7 @@ const scaffoldFromTemplate = async (options) => {
|
|
|
143
143
|
});
|
|
144
144
|
let installed = false;
|
|
145
145
|
if (install && dependencies.length > 0) {
|
|
146
|
-
installed = await (options.run ??
|
|
146
|
+
installed = (await (options.run ?? runCommandWithDetail)(pm, installArgs(pm, dependencies, { exact: true }), projectRoot)).ok;
|
|
147
147
|
if (!installed) log.warning("Could not install %s. Run by hand: `%s`", dependencies.join(", "), installHint(dependencies, true));
|
|
148
148
|
}
|
|
149
149
|
const cli = getCliName();
|
package/dist/commands/git.js
CHANGED
|
@@ -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-
|
|
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-R8RebFpF.js";
|
package/dist/commands/index.js
CHANGED
|
@@ -2,29 +2,29 @@ import { r as auth_exports } from "../_chunks/auth-rup6nemJ.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-
|
|
6
|
-
import { c as config_exports } from "../_chunks/config-
|
|
5
|
+
import { o as env_exports } from "../_chunks/env-C4-EYFmE.js";
|
|
6
|
+
import { c as config_exports } from "../_chunks/config-DPuP7ywm.js";
|
|
7
7
|
import { u as projects_exports } from "../_chunks/projects-a3X4OFEJ.js";
|
|
8
|
-
import { a as link_exports } from "../_chunks/link-
|
|
8
|
+
import { a as link_exports } from "../_chunks/link-PLk7-vwB.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-
|
|
16
|
-
import { o as claim_exports } from "../_chunks/claim-
|
|
15
|
+
import { n as checkout_exports } from "../_chunks/checkout-OEE3GTc_.js";
|
|
16
|
+
import { o as claim_exports } from "../_chunks/claim-C-9or54_.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-BMBNmW0t.js";
|
|
19
19
|
import { r as data_api_exports } from "../_chunks/data_api-CHDwvMTG.js";
|
|
20
20
|
import { s as databases_exports } from "../_chunks/databases-B-qY303S.js";
|
|
21
|
-
import { r as deploy_exports } from "../_chunks/deploy-
|
|
22
|
-
import { s as dev_exports } from "../_chunks/dev-
|
|
21
|
+
import { r as deploy_exports } from "../_chunks/deploy-CpF33Ij-.js";
|
|
22
|
+
import { s as dev_exports } from "../_chunks/dev-BE5TL7ZH.js";
|
|
23
23
|
import { i as diff_exports } from "../_chunks/diff-dnxneH0u.js";
|
|
24
24
|
import { c as docs_exports } from "../_chunks/docs-BpLiSTmm.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-
|
|
27
|
+
import { o as git_exports } from "../_chunks/git-R8RebFpF.js";
|
|
28
28
|
import { a as init_exports } from "../_chunks/init-D2fClHtC.js";
|
|
29
29
|
import { o as inspect_exports } from "../_chunks/inspect-yFAb61qo.js";
|
|
30
30
|
import { a as ip_allow_exports } from "../_chunks/ip_allow-DBdxNEUa.js";
|
|
@@ -40,7 +40,7 @@ import { o as profile_exports } from "../_chunks/profile-CArcjyS4.js";
|
|
|
40
40
|
import { s as realtime_exports } from "../_chunks/realtime-BwtzYf5a.js";
|
|
41
41
|
import { a as set_context_exports } from "../_chunks/set_context-ompB6d2D.js";
|
|
42
42
|
import { s as snapshots_exports } from "../_chunks/snapshots-DxNhjcco.js";
|
|
43
|
-
import { a as status_exports } from "../_chunks/status-
|
|
43
|
+
import { a as status_exports } from "../_chunks/status-BjaHpnTV.js";
|
|
44
44
|
import { d as triggers_exports } from "../_chunks/triggers-BfvyeJUC.js";
|
|
45
45
|
import { s as user_exports } from "../_chunks/user-D9mC430O.js";
|
|
46
46
|
import { i as vpc_endpoints_exports } from "../_chunks/vpc_endpoints-C-Y4WK2M.js";
|
package/dist/commands/link.js
CHANGED
|
@@ -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-
|
|
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-PLk7-vwB.js";
|
package/dist/commands/status.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as builder, n as command, r as describe, i as handler } from "../_chunks/status-
|
|
1
|
+
export { t as builder, n as command, r as describe, i as handler } from "../_chunks/status-BjaHpnTV.js";
|
package/dist/errors.js
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
// src/errors.ts
|
|
2
|
+
/** An error whose cause is known as a bounded code (`ERESOLVE`, `ENOENT`, `exit code 1`). */
|
|
3
|
+
var DetailedError = class extends Error {
|
|
4
|
+
constructor(message, detail) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.detail = detail;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
2
9
|
const ERROR_MATCHERS = [
|
|
3
10
|
[/^Unknown command: (.*)$/, "UNKNOWN_COMMAND"],
|
|
4
11
|
[/^Missing required argument: (.*)$/, "MISSING_ARGUMENT"],
|
|
5
12
|
[/^Failed to open web browser. (.*)$/, "AUTH_BROWSER_FAILED"],
|
|
6
|
-
[/^Setup did not finish\.$/, "NEON_INIT_FAILED"]
|
|
13
|
+
[/^Setup did not finish\.$/, "NEON_INIT_FAILED"],
|
|
14
|
+
[/^No interactive terminal\./, "NON_INTERACTIVE"],
|
|
15
|
+
[/^Authentication timed out after /, "AUTH_TIMEOUT"],
|
|
16
|
+
[/^neon skills needs Node\.js /, "NODE_VERSION_UNSUPPORTED"],
|
|
17
|
+
[/needs npx \(Node\.js\)/, "NPX_NOT_FOUND"],
|
|
18
|
+
[/spawn git ENOENT/, "GIT_NOT_FOUND"],
|
|
19
|
+
[/^(Failed to install Neon agent skills|skills CLI failed)/, "SKILLS_CLI_FAILED"],
|
|
20
|
+
[/^Cannot install the Neon plugin for /, "AGENT_COMMAND_UNAVAILABLE"],
|
|
21
|
+
[/^(Failed to install the Neon plugin for: |plugins CLI (failed|timed out))/, "PLUGINS_CLI_FAILED"],
|
|
22
|
+
[/^Could not install the Neon dependencies/, "DEPENDENCY_INSTALL_FAILED"]
|
|
7
23
|
];
|
|
8
24
|
const matchErrorCode = (message) => {
|
|
9
25
|
if (!message) return "UNKNOWN_ERROR";
|
|
@@ -72,4 +88,4 @@ const isNetworkError = (err) => {
|
|
|
72
88
|
}
|
|
73
89
|
return false;
|
|
74
90
|
};
|
|
75
|
-
export { NETWORK_ERROR_MESSAGE, isNetworkError, isUnexpectedError, matchErrorCode };
|
|
91
|
+
export { DetailedError, NETWORK_ERROR_MESSAGE, isNetworkError, isUnexpectedError, matchErrorCode };
|
package/dist/init/auth.js
CHANGED
|
@@ -4,7 +4,7 @@ import "../config.js";
|
|
|
4
4
|
import "../auth.js";
|
|
5
5
|
import { c as ensureAuth, l as existingApiClient } from "../_chunks/auth-rup6nemJ.js";
|
|
6
6
|
import { recoverFrom401 } from "../auth_recovery.js";
|
|
7
|
-
import { c as pull } from "../_chunks/env-
|
|
7
|
+
import { c as pull } from "../_chunks/env-C4-EYFmE.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
|
@@ -136,9 +136,9 @@ const claimableThenServicesNext = (expiresAt) => [
|
|
|
136
136
|
"Refresh local environment variables:",
|
|
137
137
|
`${getCliName()} env pull`
|
|
138
138
|
];
|
|
139
|
-
const installFailedNext = (command, envPull) => ({
|
|
139
|
+
const installFailedNext = (command, envPull, reason) => ({
|
|
140
140
|
heading: HEADING_FAILED,
|
|
141
|
-
body:
|
|
141
|
+
body: reason,
|
|
142
142
|
next: [
|
|
143
143
|
"Install the dependencies, then run neon init again:",
|
|
144
144
|
command,
|
package/dist/init/deploy.js
CHANGED
|
@@ -4,7 +4,7 @@ import { c as ensureAuth } from "../_chunks/auth-rup6nemJ.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-
|
|
7
|
+
import { r as applyCmd } from "../_chunks/config-DPuP7ywm.js";
|
|
8
8
|
import { authContext } from "./auth.js";
|
|
9
9
|
import { existsSync } from "node:fs";
|
|
10
10
|
// src/init/deploy.ts
|
package/dist/init/funnel.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import pkg_default from "../pkg.js";
|
|
2
2
|
import { codeFromBody, isNeonApiError } from "../api.js";
|
|
3
|
-
import { isNetworkError, matchErrorCode } from "../errors.js";
|
|
3
|
+
import { DetailedError, isNetworkError, matchErrorCode } from "../errors.js";
|
|
4
4
|
import { redactCredentialTokenIds, trackEvent } from "../analytics.js";
|
|
5
5
|
import { AuthRefreshError } from "../auth.js";
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
@@ -110,6 +110,7 @@ const initEndProperties = (input) => {
|
|
|
110
110
|
error_step: reported?.step ?? null,
|
|
111
111
|
error_code: reported === void 0 ? null : initErrorCode(reported.error),
|
|
112
112
|
error_message: reported === void 0 ? null : initErrorMessage(reported.error),
|
|
113
|
+
error_detail: reported?.error instanceof DetailedError ? reported.error.detail : null,
|
|
113
114
|
error_steps: [...new Set(input.errors.map((entry) => entry.step))]
|
|
114
115
|
};
|
|
115
116
|
};
|
package/dist/init/link.js
CHANGED
|
@@ -4,7 +4,7 @@ import "../config.js";
|
|
|
4
4
|
import "../auth.js";
|
|
5
5
|
import { c as ensureAuth } from "../_chunks/auth-rup6nemJ.js";
|
|
6
6
|
import { recoverFrom401 } from "../auth_recovery.js";
|
|
7
|
-
import { s as runLink } from "../_chunks/link-
|
|
7
|
+
import { s as runLink } from "../_chunks/link-PLk7-vwB.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
|
@@ -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-
|
|
18
|
-
import { o as quoteFlagValue, s as runLink } from "../_chunks/link-
|
|
17
|
+
import { h as initCmd, t as ConfigInstallFailed } from "../_chunks/config-DPuP7ywm.js";
|
|
18
|
+
import { o as quoteFlagValue, s as runLink } from "../_chunks/link-PLk7-vwB.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-
|
|
28
|
+
import { l as create } from "../_chunks/claim-C-9or54_.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";
|
|
@@ -587,7 +587,7 @@ const runInit = async (props) => {
|
|
|
587
587
|
});
|
|
588
588
|
} catch (error) {
|
|
589
589
|
if (error instanceof ConfigInstallFailed) {
|
|
590
|
-
const failed = installFailedNext(error.command, linkDeferredPull);
|
|
590
|
+
const failed = installFailedNext(error.command, linkDeferredPull, error.message);
|
|
591
591
|
printInitDone(formatInitDone({
|
|
592
592
|
heading: failed.heading,
|
|
593
593
|
body: failed.body,
|
|
@@ -1,41 +1,18 @@
|
|
|
1
1
|
import { log } from "../log.js";
|
|
2
2
|
// src/utils/ai_gateway_notice.ts
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
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
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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:
|
|
68
|
-
};
|
|
69
|
-
if (
|
|
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
|
-
*
|
|
78
|
-
* `
|
|
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
|
|
46
|
+
const parseGatewayCatalog = (body) => {
|
|
83
47
|
if (!isRecord(body) || !Array.isArray(body.data)) return null;
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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,
|
|
82
|
+
export { aiGatewayModelsUrl, buildAiGatewayNotice, fetchGatewayCatalog, hasFlagshipModels, parseGatewayCatalog, warnAiGateway };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { log } from "../log.js";
|
|
2
2
|
import { existsSync, realpathSync } from "node:fs";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
|
+
import { stripVTControlCharacters } from "node:util";
|
|
4
5
|
import { spawn, spawnSync } from "node:child_process";
|
|
5
6
|
import which from "which";
|
|
6
7
|
// src/utils/package_manager.ts
|
|
@@ -328,20 +329,138 @@ const commandEnv = (overlay, base = process.env) => {
|
|
|
328
329
|
* exited cleanly; a non-zero exit is reported but never throws — the caller
|
|
329
330
|
* decides whether to treat it as fatal.
|
|
330
331
|
*/
|
|
331
|
-
const runCommand = (cmd, args, cwd, env) =>
|
|
332
|
+
const runCommand = (cmd, args, cwd, env) => runCommandWithDetail(cmd, args, cwd, env).then((result) => result.ok);
|
|
333
|
+
const PACKAGE_MANAGER_ERROR_LINES = [{
|
|
334
|
+
pattern: /^npm (?:ERR!|error) code (\S+)$/gm,
|
|
335
|
+
known: /* @__PURE__ */ new Set([
|
|
336
|
+
"CERT_HAS_EXPIRED",
|
|
337
|
+
"E401",
|
|
338
|
+
"E403",
|
|
339
|
+
"E404",
|
|
340
|
+
"E500",
|
|
341
|
+
"E502",
|
|
342
|
+
"E503",
|
|
343
|
+
"EACCES",
|
|
344
|
+
"EAI_AGAIN",
|
|
345
|
+
"EBADENGINE",
|
|
346
|
+
"EBADPLATFORM",
|
|
347
|
+
"ECONNREFUSED",
|
|
348
|
+
"ECONNRESET",
|
|
349
|
+
"EEXIST",
|
|
350
|
+
"EINTEGRITY",
|
|
351
|
+
"EJSONPARSE",
|
|
352
|
+
"ENOENT",
|
|
353
|
+
"ENOSPC",
|
|
354
|
+
"ENOTEMPTY",
|
|
355
|
+
"ENOTFOUND",
|
|
356
|
+
"ENOTSUP",
|
|
357
|
+
"ENOWORKSPACES",
|
|
358
|
+
"EOVERRIDE",
|
|
359
|
+
"EPERM",
|
|
360
|
+
"ERESOLVE",
|
|
361
|
+
"ERR_SOCKET_TIMEOUT",
|
|
362
|
+
"ETARGET",
|
|
363
|
+
"ETIMEDOUT",
|
|
364
|
+
"EUNSUPPORTEDPROTOCOL",
|
|
365
|
+
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
366
|
+
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY"
|
|
367
|
+
])
|
|
368
|
+
}, {
|
|
369
|
+
pattern: /^\s*(ERR_PNPM_[A-Z0-9_]+)\b/gm,
|
|
370
|
+
known: /* @__PURE__ */ new Set([
|
|
371
|
+
"ERR_PNPM_ADDING_TO_ROOT",
|
|
372
|
+
"ERR_PNPM_BAD_PM_VERSION",
|
|
373
|
+
"ERR_PNPM_EACCES",
|
|
374
|
+
"ERR_PNPM_ENOENT",
|
|
375
|
+
"ERR_PNPM_EPERM",
|
|
376
|
+
"ERR_PNPM_FETCH_401",
|
|
377
|
+
"ERR_PNPM_FETCH_403",
|
|
378
|
+
"ERR_PNPM_FETCH_404",
|
|
379
|
+
"ERR_PNPM_IGNORED_BUILDS",
|
|
380
|
+
"ERR_PNPM_LOCKFILE_BREAKING_CHANGE",
|
|
381
|
+
"ERR_PNPM_META_FETCH_FAIL",
|
|
382
|
+
"ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND",
|
|
383
|
+
"ERR_PNPM_NO_MATCHING_VERSION",
|
|
384
|
+
"ERR_PNPM_NO_OFFLINE_META",
|
|
385
|
+
"ERR_PNPM_NO_OFFLINE_TARBALL",
|
|
386
|
+
"ERR_PNPM_OUTDATED_LOCKFILE",
|
|
387
|
+
"ERR_PNPM_PEER_DEP_ISSUES",
|
|
388
|
+
"ERR_PNPM_TARBALL_INTEGRITY",
|
|
389
|
+
"ERR_PNPM_UNSUPPORTED_ENGINE",
|
|
390
|
+
"ERR_PNPM_WORKSPACE_PKG_NOT_FOUND"
|
|
391
|
+
])
|
|
392
|
+
}];
|
|
393
|
+
/** The most specific failure code available, without any of the child's free-form output. */
|
|
394
|
+
const installFailureDetail = (input) => {
|
|
395
|
+
if (input.spawnErrorCode !== void 0) return input.spawnErrorCode;
|
|
396
|
+
const output = stripVTControlCharacters(input.output);
|
|
397
|
+
for (const { pattern, known } of PACKAGE_MANAGER_ERROR_LINES) for (const match of output.matchAll(pattern)) {
|
|
398
|
+
const code = match[1];
|
|
399
|
+
if (code !== void 0 && known.has(code)) return code;
|
|
400
|
+
}
|
|
401
|
+
return input.exitCode === null ? "killed" : `exit code ${input.exitCode}`;
|
|
402
|
+
};
|
|
403
|
+
/**
|
|
404
|
+
* {@link runCommand} that also says why the command failed. Each of stdout and stderr that is
|
|
405
|
+
* not a terminal is piped, copied to ours as it arrives, and scanned for the package manager's
|
|
406
|
+
* error code (pnpm prints its code on stdout). A terminal stream stays inherited, so prompts
|
|
407
|
+
* and colors are unchanged.
|
|
408
|
+
*/
|
|
409
|
+
const runCommandWithDetail = (cmd, args, cwd, env) => new Promise((resolvePromise) => {
|
|
410
|
+
const pipeUnlessTerminal = (stream) => stream.isTTY === true ? "inherit" : "pipe";
|
|
332
411
|
const child = spawn(cmd, args, {
|
|
333
412
|
cwd,
|
|
334
|
-
stdio:
|
|
413
|
+
stdio: [
|
|
414
|
+
"inherit",
|
|
415
|
+
pipeUnlessTerminal(process.stdout),
|
|
416
|
+
pipeUnlessTerminal(process.stderr)
|
|
417
|
+
],
|
|
335
418
|
shell: process.platform === "win32",
|
|
336
419
|
env: commandEnv(env)
|
|
337
420
|
});
|
|
421
|
+
let output = "";
|
|
422
|
+
const forward = (source, target) => {
|
|
423
|
+
source.on("data", (chunk) => {
|
|
424
|
+
output = (output + chunk.toString("utf8")).slice(-65536);
|
|
425
|
+
if (!target.write(chunk)) {
|
|
426
|
+
source.pause();
|
|
427
|
+
target.once("drain", () => source.resume());
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
};
|
|
431
|
+
if (child.stdout) forward(child.stdout, process.stdout);
|
|
432
|
+
if (child.stderr) forward(child.stderr, process.stderr);
|
|
433
|
+
const flushed = (stream) => new Promise((resolveFlush) => stream.write("", () => resolveFlush()));
|
|
434
|
+
let settled = false;
|
|
435
|
+
const settle = (result) => {
|
|
436
|
+
if (settled) return;
|
|
437
|
+
settled = true;
|
|
438
|
+
Promise.all([flushed(process.stdout), flushed(process.stderr)]).then(() => resolvePromise(result));
|
|
439
|
+
};
|
|
338
440
|
child.on("error", (err) => {
|
|
339
|
-
log.warning("Could not run `%s %s`: %s", cmd, args.join(" "), err
|
|
340
|
-
|
|
441
|
+
log.warning("Could not run `%s %s`: %s", cmd, args.join(" "), err.message);
|
|
442
|
+
settle({
|
|
443
|
+
ok: false,
|
|
444
|
+
detail: installFailureDetail({
|
|
445
|
+
spawnErrorCode: "code" in err && typeof err.code === "string" ? `spawn ${err.code}` : "spawn failed",
|
|
446
|
+
exitCode: null,
|
|
447
|
+
output
|
|
448
|
+
})
|
|
449
|
+
});
|
|
341
450
|
});
|
|
342
451
|
child.on("close", (code) => {
|
|
343
|
-
if (code
|
|
344
|
-
|
|
452
|
+
if (code === 0) {
|
|
453
|
+
settle({ ok: true });
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
log.warning("`%s %s` exited with code %d.", cmd, args.join(" "), code);
|
|
457
|
+
settle({
|
|
458
|
+
ok: false,
|
|
459
|
+
detail: installFailureDetail({
|
|
460
|
+
exitCode: code,
|
|
461
|
+
output
|
|
462
|
+
})
|
|
463
|
+
});
|
|
345
464
|
});
|
|
346
465
|
});
|
|
347
|
-
export { DO_NOT_SUBSTITUTE_HINT, MISSING_BINARY_HINT, commandEnv, detectCliInstallMethod, detectInvokingPackageManager, detectProjectPackageManager, formatExecCommand, formatInstallCommand, globalInstallCommand, inferPackageManager, installArgs, installedPackageManagers, recommendedCliUpgradeCommand, resolveInvokingPackageManager, resolvePackageManager, runCommand };
|
|
466
|
+
export { DO_NOT_SUBSTITUTE_HINT, MISSING_BINARY_HINT, commandEnv, detectCliInstallMethod, detectInvokingPackageManager, detectProjectPackageManager, formatExecCommand, formatInstallCommand, globalInstallCommand, inferPackageManager, installArgs, installFailureDetail, installedPackageManagers, recommendedCliUpgradeCommand, resolveInvokingPackageManager, resolvePackageManager, runCommand, runCommandWithDetail };
|
|
@@ -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.
|
|
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
|
+
"version": "8.23.4",
|
|
4
4
|
"description": "CLI tool for Neon, the cloud backend primitives built around Lakebase Postgres",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"neon",
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"yoctocolors": "^2.1.2",
|
|
76
76
|
"@neon/config-runtime": "1.11.7",
|
|
77
77
|
"@neon/realtime": "0.2.0",
|
|
78
|
-
"@neon/
|
|
79
|
-
"@neon/
|
|
78
|
+
"@neon/config": "1.11.3",
|
|
79
|
+
"@neon/sdk": "7.10.0"
|
|
80
80
|
},
|
|
81
81
|
"optionalDependencies": {
|
|
82
82
|
"@napi-rs/keyring": "1.3.0",
|