@neon/skills 3.0.3 → 3.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neon/skills",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "Agent Skills for Neon: Lakebase Postgres, Managed Better Auth, Realtime, Object Storage, Functions, the Data API, and AI Gateway",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "neon-postgres",
4
- "version": "3.0.3",
4
+ "version": "3.0.5",
5
5
  "description": "Manage your Neon backend with the Neon agent skills and the Neon MCP Server: Lakebase Postgres, Managed Better Auth, Realtime, Object Storage, Functions, the Data API, and AI Gateway",
6
6
  "author": {
7
7
  "name": "Neon",
@@ -377,7 +377,7 @@ neon deploy --env <file> # apply neon.ts. Pass --env when Function env reads pr
377
377
 
378
378
  `<file>` is the gitignored file `neon env pull` already writes (`.env` if that file exists, otherwise `.env.local`). Env pull writes Neon-managed vars only (`DATABASE_URL`, `NEON_AI_GATEWAY_*`, …). Add every key under `functions.*.env` to that file yourself, then pass the same path to `--env`.
379
379
 
380
- Every declared Function env key must be a defined string. `undefined` (an unset `process.env.X`) means you listed a key you want written but the value is missing: `defineConfig` throws. Omit the key from `neon.ts` if you do not want to write it. Never coerce a missing `process.env` value to an empty string: that uploads `""` and deletes the live key. An empty assignment in the file (`KEY=`) is also `""`. If TypeScript needs a type assertion, use `process.env.X!` and make sure the file actually has the value.
380
+ Declare each Function secret as `{ value: process.env.X, required: true }` (`@neon/config` 1.13.0 and `neon` 9.2.0 or later; `@neon/env` 2.1.0 or later for `parseEnv`). An unset required value fails `neon deploy` and `neon dev` before anything changes, and never fails an import of `neon.ts`. Use `required: false` for an optional value, or `required: "default-branch"` for one only the default branch's deployment needs; when unset, either is removed from the deployment unless it also sets `onUndefined: "skip"`. Never coerce a missing value to an empty string: that uploads `""` and deletes the live key. An empty assignment in the file (`KEY=`) counts as unset. See the `neon-functions` skill for the full table.
381
381
 
382
382
  Use `neon functions deploy` when you are not applying `neon.ts`: a single function by slug, or a targeted `--env KEY=VALUE` update (that flag is not a file path).
383
383
 
@@ -20,7 +20,17 @@ neon logs field-values service_name --since 1h
20
20
  neon logs query --since 1h --logql '{entity_type="function"} |= "timeout"'
21
21
  ```
22
22
 
23
- If the CLI is unavailable, fall back to the Neon MCP server's read-only `query_logs`, `list_log_fields`, and `list_log_field_values` tools.
23
+ `neon logs loki` (Neon CLI 9.1 or newer) reads the same records through the Loki-compatible API below and prints Loki's JSON response: lines grouped by stream labels, with nanosecond timestamp strings where `logs query` rounds to the second. Use it when ordering within a second matters or a tool expects Loki output:
24
+
25
+ ```bash
26
+ neon logs loki '{entity_type="function"} |= "timeout"' --since 30m --limit 100
27
+ neon logs loki --endpoint labels
28
+ neon logs loki '{entity_type="function"}' --endpoint label/scope_name/values --since 6h
29
+ ```
30
+
31
+ It has no cursor. A result with `--limit` lines, or 10,000 lines (the server's cap, which adds no `warnings` entry), may be incomplete, so narrow `--since` or the selector instead of trusting it as complete.
32
+
33
+ If the CLI is unavailable, fall back to the Neon MCP server's read-only `query_logs`, `query_loki_logs`, `list_log_fields`, and `list_log_field_values` tools.
24
34
 
25
35
  ## Loki-compatible read API
26
36
 
@@ -40,22 +50,45 @@ This is a read-only Loki-compatible subset, not a push endpoint or complete Loki
40
50
 
41
51
  The paths above are the ones to call directly. A Loki client that builds its own paths — a Grafana data source appends `/loki/api/v1` to whatever URL it is given — may need a different root, so confirm the data-source URL against the Neon docs rather than pasting this base.
42
52
 
43
- In TypeScript applications, use `@neon/sdk`. Project and branch are positional, and `query` returns a lazy paginated iterable rather than a promise:
53
+ In TypeScript applications, use `@neon/sdk`. Every method takes one named parameter object, and `query` returns a lazy paginated iterable rather than a promise:
44
54
 
45
55
  ```typescript
46
- for await (const record of neon.logs.query(projectId, branchId, {
56
+ for await (const record of neon.logs.query({
57
+ projectId,
58
+ branchId,
47
59
  since: "1h",
48
60
  source: "function",
49
61
  })) {
50
62
  console.log(record.timestamp, record.severity_text, record.message);
51
63
  }
52
64
 
53
- const { data: fields } = await neon.logs.fields(projectId, branchId);
54
- const { data: serviceNames } = await neon.logs.fieldValues(
65
+ const { data: fields } = await neon.logs.fields({ projectId, branchId });
66
+ const { data: serviceNames } = await neon.logs.fieldValues({
55
67
  projectId,
56
68
  branchId,
57
- "service_name",
58
- );
69
+ fieldName: "service_name",
70
+ });
59
71
  ```
60
72
 
61
73
  `query`'s iterator always throws on error, but `fields` and `fieldValues` follow the client's `throwOnError`, which defaults to `false` and hands back `{ data, error }`. `fieldValues` resolves to the whole response, not a bare array: read `serviceNames.values`, and treat them as an arbitrary subset whenever `serviceNames.is_truncated` is true.
74
+
75
+ `neon.logs.loki` (`@neon/sdk` 7.11 or newer) calls the Loki-compatible API with the client's key and returns Loki's response body unchanged:
76
+
77
+ ```typescript
78
+ const { data, error } = await neon.logs.loki.queryRange({
79
+ projectId,
80
+ branchId,
81
+ query: '{entity_type="function"} |= "timeout"',
82
+ since: "30m",
83
+ limit: 100,
84
+ });
85
+ if (error) throw error;
86
+ for (const { stream, values } of data.data.result) {
87
+ for (const [timestampNs, line] of values) console.log(timestampNs, stream.service_name, line);
88
+ }
89
+
90
+ await neon.logs.loki.labels({ projectId, branchId });
91
+ await neon.logs.loki.labelValues({ projectId, branchId, name: "service_name" });
92
+ ```
93
+
94
+ A rejected query, such as one with a parser stage, comes back as a `NeonApiError` carrying Loki's message.
@@ -147,7 +147,7 @@ neon dev # serves every function in neon.ts with hot reload; injects DATABA
147
147
  neon deploy --env <file> # preferred full deploy from neon.ts; --env is the file Function env is read from
148
148
  ```
149
149
 
150
- Keep `.env` or `.env.local` up to date with every key under `functions.*.env`. `neon env pull` writes Neon-managed vars only; add Function secrets to that file, then pass it as `--env`. `neon deploy --env <file>` loads that file into `process.env` each time, then uploads those values. A missing value is `undefined` and `defineConfig` throws. Omit the key from `neon.ts` if you do not want to write it. Never coerce a missing `process.env` value to an empty string (that uploads `""` and deletes the live key). An empty assignment (`KEY=`) is also `""`. Use `process.env.X!` when TypeScript needs an assertion.
150
+ Keep `.env` or `.env.local` up to date with every key under `functions.*.env`. `neon env pull` writes Neon-managed vars only; add Function secrets to that file, then pass it as `--env`. `neon deploy --env <file>` loads that file into `process.env` each time, then uploads the declared values. Declare each secret as `{ value: process.env.X, required: true }` (see "Your own secrets" below): an unset required value fails `neon deploy` and `neon dev` before anything changes, and never fails an import of `neon.ts`. Never coerce a missing value to `""` (that uploads `""` and deletes the live key); an empty assignment (`KEY=`) counts as unset.
151
151
 
152
152
  To deploy a single function without applying `neon.ts`: `neon functions deploy <slug> --src src/index.ts` (`--src` takes either the entry file or a directory containing `index.ts`, `index.mjs`, or `index.js`). That command's `--env` is `KEY=VALUE` (repeatable), not a file path. Use it for a targeted env update. Retrieve the public URL with `neon functions get <slug>` (the `invocation_url` field, of the form `https://<branch_id>-<slug>.compute.<cell>.us-east-2.aws.neon.tech`). Manage with `neon functions list|get|delete`.
153
153
 
@@ -205,18 +205,32 @@ Object storage (`AWS_*`) and AI Gateway (`NEON_AI_GATEWAY_*`) vars are also inje
205
205
 
206
206
  `neon env pull` / `neon-env run` / `neon dev` emit `NEON_BRANCH`, `NEON_BRANCH_ID`, `NEON_FUNCTION_HOST_SUFFIX` (and the connection strings) into your local dev environment too, so local runs mirror the deployed runtime.
207
207
 
208
- **Your own secrets** are per-deployment. Preferred path: declare them in `neon.ts` and run `neon deploy --env <file>`. `<file>` is the gitignored file env pull already writes (`.env` if that file exists, otherwise `.env.local`). Env pull writes Neon-managed vars only; add Function secrets to that file. All declared Function env keys must be present. Omit a key from `neon.ts` if you do not want to write it. `undefined` means you asked to write the key and the value is missing (`defineConfig` throws). Never coerce a missing `process.env` value to an empty string: that uploads `""` and deletes the live key. An empty assignment in the file (`KEY=`) is also `""`. If TypeScript needs an assertion, use `process.env.X!` and make sure the file has the value:
208
+ **Your own secrets** are per-deployment. Preferred path: declare them in `neon.ts` and run `neon deploy --env <file>`. `<file>` is the gitignored file env pull already writes (`.env` if that file exists, otherwise `.env.local`). Env pull writes Neon-managed vars only; add Function secrets to that file. Declare each one with both `value` and `required` (needs `@neon/config` 1.13.0 and `neon` 9.2.0 or later, and `@neon/env` 2.1.0 or later where the function calls `parseEnv`; older `parseEnv` treats every declared key as required):
209
209
 
210
210
  ```typescript
211
211
  functions: {
212
212
  todos: {
213
213
  name: "todo api",
214
214
  source: "src/index.ts",
215
- env: { RESEND_API_KEY: process.env.RESEND_API_KEY! },
215
+ env: {
216
+ RESEND_API_KEY: { value: process.env.RESEND_API_KEY, required: true },
217
+ SENTRY_DSN: { value: process.env.SENTRY_DSN, required: "default-branch" },
218
+ LOG_LEVEL: "info",
219
+ },
216
220
  },
217
221
  }
218
222
  ```
219
223
 
224
+ | `required` | Unset deploying the default branch | Unset deploying another branch | Unset in `neon dev` | `parseEnv(config, slug).function` |
225
+ | --- | --- | --- | --- | --- |
226
+ | `true` | fails before any change | fails before any change | fails before any function starts | `string` |
227
+ | `"default-branch"` | fails before any change | removed from the deployment | runs without it | `string \| undefined` |
228
+ | `false` | removed from the deployment | removed from the deployment | runs without it | `string \| undefined` |
229
+
230
+ An undefined or empty value counts as unset; put a fallback in `value` (`process.env.X ?? "1"`). `"default-branch"` is the branch Neon marks as default, not a branch name. Add `onUndefined: "skip"` to a `required: false` or `"default-branch"` variable to keep its deployed value instead of removing it, for a value set with `neon functions deploy --env`. Keys `neon.ts` does not declare are left alone.
231
+
232
+ Prefer a declaration over a string such as `process.env.X!`. A string is validated wherever `neon.ts` is imported, so a function that calls `parseEnv(config, "<slug>")` fails to load when another function's secret is missing from its runtime. A declaration is checked only when a command needs its value.
233
+
220
234
  `neon functions deploy --env KEY=VALUE` is the manual path (repeatable; `--env KEY=` deletes a key; unmentioned keys carry over). Use it for a targeted env update, not a full `neon.ts` apply.
221
235
 
222
236
  Load Function secrets into the same file env pull wrote, then `neon deploy --env <file>`. Pull the branch's Neon-managed vars onto disk for local dev with `neon env pull` (`link`/`checkout` do this automatically; pass `--no-env-pull` to skip and use `neon-env run -- <cmd>` for runtime injection). Limits: ≤1,000 vars, ≤64 KiB total, and the `NEON_` prefix is reserved.
@@ -93,7 +93,7 @@ Two gotchas:
93
93
 
94
94
  ## 5. Pass the creds via `neon.ts` (third-party env)
95
95
 
96
- Neon-injected vars (`DATABASE_URL`, AI Gateway `NEON_AI_GATEWAY_*`) are automatic. Declare only third-party vars under the function's `env`, resolved from `process.env` at deploy time:
96
+ Neon-injected vars (`DATABASE_URL`, AI Gateway `NEON_AI_GATEWAY_*`) are automatic. Declare only third-party vars under the function's `env`, each with `value` and `required`:
97
97
 
98
98
  ```typescript
99
99
  // neon.ts
@@ -102,8 +102,11 @@ functions: {
102
102
  name: "my app",
103
103
  source: "src/index.ts",
104
104
  env: {
105
- MASTRA_PROJECT_ID: process.env.MASTRA_PROJECT_ID!,
106
- MASTRA_PLATFORM_ACCESS_TOKEN: process.env.MASTRA_PLATFORM_ACCESS_TOKEN!,
105
+ MASTRA_PROJECT_ID: { value: process.env.MASTRA_PROJECT_ID, required: true },
106
+ MASTRA_PLATFORM_ACCESS_TOKEN: {
107
+ value: process.env.MASTRA_PLATFORM_ACCESS_TOKEN,
108
+ required: true,
109
+ },
107
110
  },
108
111
  },
109
112
  }