@neon/skills 3.0.2 → 3.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neon/skills",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
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.2",
4
+ "version": "3.0.4",
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",
@@ -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.
@@ -190,18 +190,20 @@ export default defineConfig({
190
190
 
191
191
  Neon injects branch-scoped connection strings and service URLs at runtime — you don't declare these or pass them at deploy time:
192
192
 
193
- | Variable | Notes |
194
- | ----------------------- | -------------------------------------------------------------------------------------------------- |
195
- | `NEON_BRANCH` | The branch **name** (e.g. `main`, `preview/foo`). Injected on every branch, including the default. |
196
- | `DATABASE_URL` | Pooled connection string. Use for most queries. Present only if the branch has Postgres. |
197
- | `DATABASE_URL_UNPOOLED` | Direct connection. Use for migrations, `LISTEN`/`NOTIFY`, multi-round-trip transactions. |
198
- | `NEON_AUTH_BASE_URL` | Present when Neon Auth is enabled on the branch. |
199
- | `NEON_AUTH_JWKS_URL` | Present when Neon Auth is enabled on the branch. JWKS for verifying Managed Auth JWTs. |
200
- | `NEON_DATA_API_URL` | Present when the Data API is enabled on the branch. |
193
+ | Variable | Notes |
194
+ | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
195
+ | `NEON_BRANCH` | The branch **name** (e.g. `main`, `preview/foo`). Injected on every branch, including the default. |
196
+ | `NEON_BRANCH_ID` | The branch **id** (`br-…`). Injected on every branch. |
197
+ | `NEON_FUNCTION_HOST_SUFFIX` | The hostname suffix every function on the branch shares (`.compute.c-2.us-east-2.aws.neon.tech`). See [How to get the function URL](#how-to-get-the-function-url). |
198
+ | `DATABASE_URL` | Pooled connection string. Use for most queries. Present only if the branch has Postgres. |
199
+ | `DATABASE_URL_UNPOOLED` | Direct connection. Use for migrations, `LISTEN`/`NOTIFY`, multi-round-trip transactions. |
200
+ | `NEON_AUTH_BASE_URL` | Present when Neon Auth is enabled on the branch. |
201
+ | `NEON_AUTH_JWKS_URL` | Present when Neon Auth is enabled on the branch. JWKS for verifying Managed Auth JWTs. |
202
+ | `NEON_DATA_API_URL` | Present when the Data API is enabled on the branch. |
201
203
 
202
204
  Object storage (`AWS_*`) and AI Gateway (`NEON_AI_GATEWAY_*`) vars are also injected when those services are declared — see the `neon-object-storage` and `neon-ai-gateway` skills.
203
205
 
204
- `neon env pull` / `neon-env run` / `neon dev` emit `NEON_BRANCH` (and the connection strings) into your local dev environment too, so local runs mirror the deployed runtime.
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.
205
207
 
206
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:
207
209
 
@@ -219,6 +221,33 @@ functions: {
219
221
 
220
222
  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.
221
223
 
224
+ ## How to get the function URL
225
+
226
+ A function answers at `https://<NEON_BRANCH_ID>-<slug><NEON_FUNCTION_HOST_SUFFIX>`, for example `https://br-cool-lab-a1b2c3d4-todos.compute.c-2.us-east-2.aws.neon.tech`. Each branch has its own URL.
227
+
228
+ **From a terminal:** `neon functions get <slug>` prints it as `invocation_url`. `neon deploy` prints it for each function it deploys.
229
+
230
+ **From code** (another function, a script, or an app after `neon env pull`): call `functionBaseUrl(slug)` from `@neon/env` (2.0.0 or later). It returns the base URL with no trailing slash:
231
+
232
+ ```typescript
233
+ import { functionBaseUrl } from "@neon/env";
234
+
235
+ const res = await fetch(`${functionBaseUrl("todos")}/api/todos`);
236
+ ```
237
+
238
+ | Where the code runs | `functionBaseUrl("todos")` returns |
239
+ | ------------------------------------------ | --------------------------------------------------- |
240
+ | A deployed function on the branch | `https://<branch_id>-todos.compute.…` (runtime env) |
241
+ | An app or script after `neon env pull` | the same URL, from the pulled env |
242
+ | `neon dev`, when it serves `todos` | `http://localhost:<port>` |
243
+ | `neon dev`, when it does not serve `todos` | the deployed URL on the linked branch |
244
+
245
+ It reads `process.env` by default. Pass the two variables explicitly when they come from elsewhere: `functionBaseUrl("todos", { NEON_BRANCH_ID, NEON_FUNCTION_HOST_SUFFIX })`. It throws when either variable is missing; run `neon env pull` (or `neon env pull -s functions` for only the branch variables) to fix that locally. The function does not have to be deployed for the URL to resolve, but the request fails until it is.
246
+
247
+ Browser code has no access to these variables. Build the URL on the server with `functionBaseUrl` and pass it to the client.
248
+
249
+ Older releases wrote one `NEON_FUNCTION_<SLUG>_BASE_URL` per function and exposed `env.functions.<slug>.baseUrl`. `neon` 9 and `@neon/env` 2 removed both, and `neon env pull` deletes those lines. Replace them with `functionBaseUrl("<slug>")`.
250
+
222
251
  ## Connecting to Postgres
223
252
 
224
253
  When the branch has Postgres, Neon **injects the connection strings at runtime** — you don't declare them, pass them at deploy time, or hardcode anything. The two you'll use: