@neon/tools 0.5.0 → 0.6.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.
- package/README.md +55 -109
- package/dist/index.d.ts +24 -50
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -43
- package/dist/lib/ergonomic/bind.d.ts +54 -0
- package/dist/lib/ergonomic/bind.d.ts.map +1 -0
- package/dist/lib/ergonomic/bind.js +121 -0
- package/dist/lib/ergonomic/catalog.d.ts +2601 -0
- package/dist/lib/ergonomic/catalog.d.ts.map +1 -0
- package/dist/lib/ergonomic/catalog.js +703 -0
- package/dist/lib/ergonomic/composed.d.ts +450 -0
- package/dist/lib/ergonomic/composed.d.ts.map +1 -0
- package/dist/lib/ergonomic/composed.js +186 -0
- package/dist/lib/ergonomic/ids.d.ts +7 -0
- package/dist/lib/ergonomic/ids.d.ts.map +1 -0
- package/dist/lib/ergonomic/ids.js +122 -0
- package/dist/lib/ergonomic/index.d.ts +4 -0
- package/dist/lib/ergonomic/index.d.ts.map +1 -0
- package/dist/lib/ergonomic/index.js +4 -0
- package/package.json +2 -2
- package/dist/lib/workflows.d.ts +0 -315
- package/dist/lib/workflows.d.ts.map +0 -1
- package/dist/lib/workflows.js +0 -113
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# `@neon/tools`
|
|
2
2
|
|
|
3
|
-
Agent tools for the
|
|
3
|
+
Agent tools for the `@neon/sdk` ergonomic client. Select the methods an agent needs, then use the descriptors directly or adapt them for MCP, Eve, and Mastra.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
npm install @neon/tools
|
|
@@ -8,7 +8,7 @@ npm install @neon/tools
|
|
|
8
8
|
|
|
9
9
|
## Create tools
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Selectors are SDK paths. The returned record is keyed by those paths. Each tool's published `id` is the path in snake_case (`projects.list` → `projects_list`). `toolIds` lists every published selector.
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
14
|
import { createNeonTools } from "@neon/tools";
|
|
@@ -16,111 +16,77 @@ import { createNeonTools } from "@neon/tools";
|
|
|
16
16
|
const apiKey = process.env.NEON_API_KEY;
|
|
17
17
|
if (!apiKey) throw new Error("NEON_API_KEY is required");
|
|
18
18
|
|
|
19
|
-
const operations = ["listProjects", "createProject"] as const;
|
|
20
|
-
|
|
21
19
|
const tools = createNeonTools({
|
|
22
20
|
apiKey,
|
|
23
|
-
|
|
21
|
+
tools: [
|
|
22
|
+
"projects.list",
|
|
23
|
+
"projects.createAndConnect",
|
|
24
|
+
"branches.createWithCompute",
|
|
25
|
+
],
|
|
24
26
|
});
|
|
25
27
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
+
const listed = await tools["projects.list"].execute({ limit: 10 });
|
|
29
|
+
const created = await tools["projects.createAndConnect"].execute({
|
|
30
|
+
name: "agent-project",
|
|
31
|
+
region_id: "aws-us-east-1",
|
|
28
32
|
});
|
|
29
33
|
```
|
|
30
34
|
|
|
31
|
-
|
|
35
|
+
`limit` on a list tool caps how many items come back.
|
|
36
|
+
|
|
37
|
+
MCP and Mastra publish `tool.id` (`projects_list`), not the record key.
|
|
38
|
+
|
|
39
|
+
`apiKey` is a Bearer credential: a Neon API key or a Neon OAuth access token. A function is called on every request, which is how short-lived OAuth tokens get refreshed. A credential is required when a tool executes — at construction, on `execute()`, or from MCP `authInfo` — and an empty value is rejected rather than ignored.
|
|
32
40
|
|
|
33
41
|
```ts
|
|
34
42
|
const tools = createNeonTools({
|
|
35
43
|
apiKey: () => oauth.getAccessToken(),
|
|
36
|
-
|
|
44
|
+
tools: ["projects.list"],
|
|
37
45
|
});
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Or supply the token per call:
|
|
41
|
-
|
|
42
|
-
```ts
|
|
43
|
-
const tools = createNeonTools({ operations });
|
|
44
46
|
|
|
45
|
-
await tools.
|
|
47
|
+
await tools["projects.list"].execute(
|
|
46
48
|
{ limit: 10 },
|
|
47
49
|
{ apiKey: oauthAccessToken },
|
|
48
50
|
);
|
|
49
51
|
```
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
Each tool includes its Zod 4 `inputSchema`, published `id`, title, description, safety annotations, stability metadata, and `execute()`. Inputs are snake_case at the tool boundary. `execute()` strictly validates the input, rejects unknown fields, and returns typed, JSON-safe `{ data }`. Neon SDK errors remain typed and are thrown to the caller.
|
|
52
54
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
## Workflows
|
|
56
|
-
|
|
57
|
-
`workflows` selects methods from the `@neon/sdk` ergonomic client. These are not OpenAPI operations: they attach a default compute, wait until the resource is ready, and return a connection string. `operations` is the generated Management API. At least one of the two arrays is required.
|
|
58
|
-
|
|
59
|
-
Both workflow tools poll until the resource is ready. The default deadline is five minutes (`wait.timeoutMs`). Pass `wait: { timeoutMs: 30_000 }` on `createNeonTools` or `createNeonTool` to bound that. Set it below the host's own tool-call timeout, otherwise the host gives up first. An abort `signal` on `execute` or a wait timeout stops the poll, not the create: the branch or project may already exist, and the error does not include its id. List before retrying. `metadata.method` and `metadata.path` name the first request; extra readiness GETs are not listed there. `inject.projectId` still works on `createBranchWithCompute` because its path is `/projects/{project_id}/branches`.
|
|
55
|
+
Paginated lists call `.all()` and return the item array. Do not pass a cursor; those fields are omitted from the input schema.
|
|
60
56
|
|
|
61
57
|
```ts
|
|
62
|
-
const
|
|
63
|
-
apiKey,
|
|
64
|
-
operations: ["listProjects"],
|
|
65
|
-
workflows: ["createBranchWithCompute", "createProjectAndConnect"],
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
const { data } = await tools.createBranchWithCompute.execute({
|
|
69
|
-
project_id: "project-id",
|
|
70
|
-
name: "feature-x",
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
await tools.createProjectAndConnect.execute({
|
|
74
|
-
name: "agent-project",
|
|
75
|
-
region_id: "aws-us-east-1",
|
|
76
|
-
});
|
|
58
|
+
const createBranch = createNeonTool("branches.createWithCompute", { apiKey });
|
|
77
59
|
```
|
|
78
60
|
|
|
79
|
-
|
|
61
|
+
## Writes and waiting
|
|
80
62
|
|
|
81
|
-
|
|
82
|
-
const createBranch = createNeonTool("createBranchWithCompute", { apiKey });
|
|
83
|
-
```
|
|
63
|
+
Tools run with `waitForReadiness: true`. When a mutation response includes an `operations` array, the call waits until those operations finish. The default deadline is five minutes (`wait.timeoutMs`). Pass `wait: { timeoutMs: 30_000 }` on `createNeonTools` or `createNeonTool` to bound that. Set it below the host's own tool-call timeout, otherwise the host gives up first.
|
|
84
64
|
|
|
85
|
-
|
|
65
|
+
An abort `signal` on `execute` or a wait timeout stops the poll, not the create: the branch or project may already exist, and the error does not include its id. List before retrying.
|
|
86
66
|
|
|
87
|
-
|
|
88
|
-
const tools = createNeonTools({
|
|
89
|
-
apiKey,
|
|
90
|
-
workflows: ["createBranchWithCompute"],
|
|
91
|
-
names: { createBranchWithCompute: "create_branch" },
|
|
92
|
-
});
|
|
67
|
+
`functions.deploy` can still return `pending`. Its response has no `operations` array, so the tool does not poll.
|
|
93
68
|
|
|
94
|
-
|
|
95
|
-
```
|
|
69
|
+
`metadata.method` and `metadata.path` name the first request; extra readiness GETs are not listed there.
|
|
96
70
|
|
|
97
|
-
|
|
71
|
+
These public client methods are not tools: `projects.create`, `branches.create`, `operations.waitFor`, `postgres.roles.password`, and `storage.objects.get`. Use `projects.createAndConnect` and `branches.createWithCompute` for creates that attach compute and return a connection string. Waiting is what the write tools already do.
|
|
98
72
|
|
|
99
73
|
## Optional host add-ons
|
|
100
74
|
|
|
101
|
-
None of these change the default `createNeonTools({ apiKey, operations })` path. They exist so a host can replace hand-written Management API tools without losing descriptions, call tracking, or a grant-scoped project/branch.
|
|
102
|
-
|
|
103
75
|
### Descriptions
|
|
104
76
|
|
|
105
|
-
Pass a map keyed by
|
|
77
|
+
Pass a map keyed by SDK path or published `id`, or a function that can append to the generated text:
|
|
106
78
|
|
|
107
79
|
```ts
|
|
108
80
|
const tools = createNeonTools({
|
|
109
81
|
apiKey,
|
|
110
|
-
|
|
82
|
+
tools: ["projects.list", "projects.delete"],
|
|
111
83
|
descriptions: {
|
|
112
|
-
|
|
84
|
+
"projects.list":
|
|
113
85
|
"List Neon projects in your account. Do not use for projects shared with you.",
|
|
114
|
-
|
|
86
|
+
projects_delete:
|
|
115
87
|
"Delete a Neon project and all its data. NEVER run autonomously; always ask the user first.",
|
|
116
88
|
},
|
|
117
89
|
});
|
|
118
|
-
|
|
119
|
-
const noticed = createNeonTools({
|
|
120
|
-
apiKey,
|
|
121
|
-
operations,
|
|
122
|
-
descriptions: (tool) => `${tool.description}\nNotice: scoped to one project.`,
|
|
123
|
-
});
|
|
124
90
|
```
|
|
125
91
|
|
|
126
92
|
### Tracking
|
|
@@ -130,9 +96,8 @@ const noticed = createNeonTools({
|
|
|
130
96
|
```ts
|
|
131
97
|
const tools = createNeonTools({
|
|
132
98
|
apiKey,
|
|
133
|
-
|
|
99
|
+
tools: ["projects.list"],
|
|
134
100
|
onExecute: async ({ id, execute }) => {
|
|
135
|
-
// record `id`, wrap in a span, then:
|
|
136
101
|
return execute();
|
|
137
102
|
},
|
|
138
103
|
});
|
|
@@ -142,38 +107,35 @@ This package does not send analytics. Mutating `event.input` does not change a g
|
|
|
142
107
|
|
|
143
108
|
### Names
|
|
144
109
|
|
|
145
|
-
`name` rewrites every published tool `id`. `names` overrides one tool first, keyed by
|
|
110
|
+
`name` rewrites every published tool `id`. `names` overrides one tool first, keyed by SDK path or the generated snake-case `id`:
|
|
146
111
|
|
|
147
112
|
```ts
|
|
148
113
|
const tools = createNeonTools({
|
|
149
114
|
apiKey,
|
|
150
|
-
|
|
151
|
-
names: {
|
|
115
|
+
tools: ["branches.createWithCompute", "projects.list"] as const,
|
|
116
|
+
names: { "branches.createWithCompute": "create_branch" },
|
|
152
117
|
name: (id) => `neon_${id}`,
|
|
153
118
|
});
|
|
154
|
-
|
|
155
|
-
tools.createProjectBranch.id; // "neon_create_branch"
|
|
156
|
-
tools.listProjects.id; // "neon_list_projects"
|
|
157
119
|
```
|
|
158
120
|
|
|
159
|
-
The record is still keyed by
|
|
121
|
+
Those tools publish as `neon_create_branch` and `neon_projects_list`. The record is still keyed by SDK path (`tools["branches.createWithCompute"]`). MCP and Mastra publish `tool.id`. Eve uses the filename as the model-facing name, so name the file after the published `id`. Duplicate or non-snake-case ids throw, and a `names` key that matches no selected tool throws.
|
|
160
122
|
|
|
161
123
|
### Project and branch injection
|
|
162
124
|
|
|
163
|
-
Tools take path parameters as `project_id` and `branch_id`. A host that already knows those values can inject them, including on `
|
|
125
|
+
Tools take path parameters as `project_id` and `branch_id`. A host that already knows those values can inject them, including on `branches.createWithCompute`. Without `omitFromSchema`, the published field becomes optional and a caller-supplied value wins. With `omitFromSchema: true`, the field is removed from the published schema and the injector is the only source:
|
|
164
126
|
|
|
165
127
|
```ts
|
|
166
128
|
const tools = createNeonTools({
|
|
167
129
|
apiKey,
|
|
168
|
-
|
|
130
|
+
tools: ["projects.get", "branches.delete"] as const,
|
|
169
131
|
inject: {
|
|
170
132
|
projectId: "project-id",
|
|
171
133
|
omitFromSchema: true,
|
|
172
134
|
},
|
|
173
135
|
});
|
|
174
136
|
|
|
175
|
-
await tools.
|
|
176
|
-
await tools.
|
|
137
|
+
await tools["projects.get"].execute({});
|
|
138
|
+
await tools["branches.delete"].execute({ branch_id: "br-id" });
|
|
177
139
|
```
|
|
178
140
|
|
|
179
141
|
Use a getter when the value is request-scoped. The getter can read the host's own `AsyncLocalStorage` (this package does not export one):
|
|
@@ -184,21 +146,21 @@ import { AsyncLocalStorage } from "node:async_hooks";
|
|
|
184
146
|
const grant = new AsyncLocalStorage<{ projectId: string }>();
|
|
185
147
|
|
|
186
148
|
const tools = createNeonTools({
|
|
187
|
-
|
|
149
|
+
tools: ["projects.get"] as const,
|
|
188
150
|
inject: {
|
|
189
151
|
projectId: () => grant.getStore()?.projectId,
|
|
190
152
|
omitFromSchema: true,
|
|
191
153
|
},
|
|
192
154
|
});
|
|
193
155
|
|
|
194
|
-
await grant.run({ projectId: "project-id" }, () =>
|
|
156
|
+
await grant.run({ projectId: "project-id" }, () =>
|
|
157
|
+
tools["projects.get"].execute({}),
|
|
158
|
+
);
|
|
195
159
|
```
|
|
196
160
|
|
|
197
|
-
Injectors only apply to tools that have that path key. `
|
|
198
|
-
|
|
199
|
-
`onExecute` and `inject` apply to workflow tools the same way they apply to generated tools. Grant filtering, read-only filtering, and access-control notices stay in the host.
|
|
161
|
+
Injectors only apply to tools that have that path key. `projects.list` is unchanged. Empty inject values fail closed. Invalid ids still fail the original path schema before fetch.
|
|
200
162
|
|
|
201
|
-
Injection reads the URL template, so it fills path `project_id` and `branch_id` only. Query and body fields with those names stay caller-supplied, including `
|
|
163
|
+
Injection reads the URL template, so it fills path `project_id` and `branch_id` only. Query and body fields with those names stay caller-supplied, including `postgres.connectionString`'s `branch_id`. `omitFromSchema: true` does not hide those fields.
|
|
202
164
|
|
|
203
165
|
## Request schemas
|
|
204
166
|
|
|
@@ -216,7 +178,7 @@ const body = zCreateProjectBody.parse({
|
|
|
216
178
|
});
|
|
217
179
|
```
|
|
218
180
|
|
|
219
|
-
These are the raw OpenAPI request shapes, not the
|
|
181
|
+
These are the raw OpenAPI request shapes, not the tool input. `zCreateProjectBody` still wraps fields in `project`. `projects.createAndConnect` does not.
|
|
220
182
|
|
|
221
183
|
These schemas are strict. If a newly added API field is not recognized, upgrade `@neon/tools`; use `@neon/sdk` directly until a matching tools release is available.
|
|
222
184
|
|
|
@@ -235,7 +197,7 @@ if (!apiKey) throw new Error("NEON_API_KEY is required");
|
|
|
235
197
|
const server = new McpServer({ name: "neon", version: "1.0.0" });
|
|
236
198
|
const tools = createNeonTools({
|
|
237
199
|
apiKey,
|
|
238
|
-
|
|
200
|
+
tools: ["projects.list", "projects.createAndConnect"] as const,
|
|
239
201
|
});
|
|
240
202
|
|
|
241
203
|
registerNeonTools(server, tools);
|
|
@@ -245,7 +207,7 @@ For a remote MCP server that already authenticated the client, omit `apiKey` at
|
|
|
245
207
|
|
|
246
208
|
```ts
|
|
247
209
|
const tools = createNeonTools({
|
|
248
|
-
|
|
210
|
+
tools: ["projects.list", "projects.createAndConnect"] as const,
|
|
249
211
|
});
|
|
250
212
|
registerNeonTools(server, tools);
|
|
251
213
|
```
|
|
@@ -267,7 +229,6 @@ MCP annotations are advisory; the protocol does not enforce approval. Tools expo
|
|
|
267
229
|
Eve requires Node.js 24 or later.
|
|
268
230
|
|
|
269
231
|
```ts
|
|
270
|
-
// agent/tools/create_project.ts
|
|
271
232
|
import { defineTool } from "eve/tools";
|
|
272
233
|
import { createNeonTool } from "@neon/tools";
|
|
273
234
|
import { toEveTool } from "@neon/tools/eve";
|
|
@@ -277,7 +238,7 @@ if (!apiKey) throw new Error("NEON_API_KEY is required");
|
|
|
277
238
|
|
|
278
239
|
export default defineTool(
|
|
279
240
|
toEveTool(
|
|
280
|
-
createNeonTool("
|
|
241
|
+
createNeonTool("projects.createAndConnect", {
|
|
281
242
|
apiKey,
|
|
282
243
|
}),
|
|
283
244
|
),
|
|
@@ -300,19 +261,19 @@ if (!apiKey) throw new Error("NEON_API_KEY is required");
|
|
|
300
261
|
|
|
301
262
|
const neonTools = createNeonTools({
|
|
302
263
|
apiKey,
|
|
303
|
-
|
|
264
|
+
tools: ["projects.list", "projects.createAndConnect"] as const,
|
|
304
265
|
});
|
|
305
266
|
const configs = toMastraTools(neonTools);
|
|
306
267
|
|
|
307
|
-
const listProjects = createTool(configs.
|
|
308
|
-
const createProject = createTool(configs.
|
|
268
|
+
const listProjects = createTool(configs.projects_list);
|
|
269
|
+
const createProject = createTool(configs.projects_create_and_connect);
|
|
309
270
|
```
|
|
310
271
|
|
|
311
272
|
The adapter maps approval requirements to Mastra's `requireApproval` field and forwards its abort signal.
|
|
312
273
|
|
|
313
274
|
## Safety and binary data
|
|
314
275
|
|
|
315
|
-
Every non-read operation is conservatively marked as potentially destructive and requires approval. Reads that return connection credentials
|
|
276
|
+
Every non-read operation is conservatively marked as potentially destructive and requires approval. Reads that return connection credentials also require approval.
|
|
316
277
|
|
|
317
278
|
Binary request fields accept base64 strings:
|
|
318
279
|
|
|
@@ -322,10 +283,7 @@ import { createNeonTool } from "@neon/tools";
|
|
|
322
283
|
const apiKey = process.env.NEON_API_KEY;
|
|
323
284
|
if (!apiKey) throw new Error("NEON_API_KEY is required");
|
|
324
285
|
|
|
325
|
-
const deployFunction = createNeonTool(
|
|
326
|
-
"createProjectBranchFunctionDeployment",
|
|
327
|
-
{ apiKey },
|
|
328
|
-
);
|
|
286
|
+
const deployFunction = createNeonTool("functions.deploy", { apiKey });
|
|
329
287
|
|
|
330
288
|
await deployFunction.execute({
|
|
331
289
|
project_id: "project-id",
|
|
@@ -335,16 +293,4 @@ await deployFunction.execute({
|
|
|
335
293
|
});
|
|
336
294
|
```
|
|
337
295
|
|
|
338
|
-
Binary responses are JSON-safe:
|
|
339
|
-
|
|
340
|
-
```ts
|
|
341
|
-
{
|
|
342
|
-
data: {
|
|
343
|
-
base64: "aGVsbG8=",
|
|
344
|
-
contentType: "application/octet-stream",
|
|
345
|
-
size: 5,
|
|
346
|
-
},
|
|
347
|
-
}
|
|
348
|
-
```
|
|
349
|
-
|
|
350
296
|
`@neon/tools` supports Node.js 20.19 or later. Framework integrations also require the Node.js version supported by that framework.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,67 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type NeonBearerCredential } from "./lib/auth.js";
|
|
1
|
+
import { NeonError } from "@neon/sdk";
|
|
3
2
|
import { type InjectedNeonTool, type NeonToolCustomizeOptions, type NeonToolInjectOptions, type NeonToolNameOverrides } from "./lib/customize.js";
|
|
4
|
-
import { type
|
|
5
|
-
import { type NeonOperationId, operationFactories, operationIds } from "./operations.gen.js";
|
|
3
|
+
import { type NeonToolId, type ToolClientOptions, toolFactories, toolIds } from "./lib/ergonomic/index.js";
|
|
6
4
|
export type { NeonBearerCredential } from "./lib/auth.js";
|
|
7
5
|
export type { InjectedNeonTool, NeonToolCustomizeOptions, NeonToolDescriptionOverrides, NeonToolDescriptionSource, NeonToolInjectOptions, NeonToolInjectValue, NeonToolNameOverrides, NeonToolNameSource, NeonToolOnExecute, NeonToolOnExecuteEvent, } from "./lib/customize.js";
|
|
8
6
|
export type { JsonSafe, JsonSafeBlob, NeonTool, NeonToolAnnotations, NeonToolExecutionContext, NeonToolMetadata, NeonToolResult, } from "./lib/operation.js";
|
|
9
|
-
export type {
|
|
10
|
-
export { NeonError,
|
|
11
|
-
type
|
|
12
|
-
export type NeonTools<
|
|
13
|
-
[
|
|
14
|
-
} & {
|
|
15
|
-
[Workflow in Workflows[number]]: ReturnType<WorkflowFactories[Workflow]>;
|
|
7
|
+
export type { NeonToolId };
|
|
8
|
+
export { NeonError, toolIds };
|
|
9
|
+
type ToolFactories = typeof toolFactories;
|
|
10
|
+
export type NeonTools<Tools extends readonly NeonToolId[] = []> = {
|
|
11
|
+
[Tool in Tools[number]]: ReturnType<ToolFactories[Tool]>;
|
|
16
12
|
};
|
|
17
|
-
export type InjectedNeonTools<
|
|
18
|
-
[
|
|
19
|
-
} & {
|
|
20
|
-
[Workflow in Workflows[number]]: InjectedNeonTool<ReturnType<WorkflowFactories[Workflow]>, Inject>;
|
|
13
|
+
export type InjectedNeonTools<Tools extends readonly NeonToolId[], Inject> = {
|
|
14
|
+
[Tool in Tools[number]]: InjectedNeonTool<ReturnType<ToolFactories[Tool]>, Inject>;
|
|
21
15
|
};
|
|
22
16
|
type WithPublishedId<Tool> = Tool extends {
|
|
23
17
|
id: string;
|
|
24
18
|
} ? Omit<Tool, "id"> & {
|
|
25
19
|
id: string;
|
|
26
20
|
} : Tool;
|
|
27
|
-
export interface NeonToolsClientOptions extends
|
|
28
|
-
apiKey?: NeonBearerCredential;
|
|
21
|
+
export interface NeonToolsClientOptions extends ToolClientOptions, Omit<NeonToolCustomizeOptions, "name" | "names"> {
|
|
29
22
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
workflows: Workflows;
|
|
44
|
-
operations?: Operations;
|
|
45
|
-
} : {
|
|
46
|
-
operations: Operations;
|
|
47
|
-
workflows: Workflows;
|
|
48
|
-
});
|
|
49
|
-
type SelectedOperations<T> = T extends {
|
|
50
|
-
operations: infer O extends readonly NeonOperationId[];
|
|
51
|
-
} ? O : [];
|
|
52
|
-
type SelectedWorkflows<T> = T extends {
|
|
53
|
-
workflows: infer W extends readonly NeonWorkflowId[];
|
|
54
|
-
} ? W : [];
|
|
55
|
-
type NeonToolsFor<T, Inject> = T extends CreateNeonToolsInput ? Inject extends NeonToolInjectOptions ? InjectedNeonTools<SelectedOperations<T>, Inject, SelectedWorkflows<T>> : NeonTools<SelectedOperations<T>, SelectedWorkflows<T>> : never;
|
|
56
|
-
type NeonToolId = NeonOperationId | NeonWorkflowId;
|
|
57
|
-
type ToolForId<Id extends NeonToolId> = Id extends NeonWorkflowId ? ReturnType<WorkflowFactories[Id]> : Id extends NeonOperationId ? ReturnType<OperationFactories[Id]> : never;
|
|
58
|
-
type NamedNeonTools<Operations extends readonly NeonOperationId[], Workflows extends readonly NeonWorkflowId[], Inject> = {
|
|
59
|
-
[Operation in Operations[number]]: WithPublishedId<Inject extends NeonToolInjectOptions ? InjectedNeonTool<ReturnType<OperationFactories[Operation]>, Inject> : ReturnType<OperationFactories[Operation]>>;
|
|
60
|
-
} & {
|
|
61
|
-
[Workflow in Workflows[number]]: WithPublishedId<Inject extends NeonToolInjectOptions ? InjectedNeonTool<ReturnType<WorkflowFactories[Workflow]>, Inject> : ReturnType<WorkflowFactories[Workflow]>>;
|
|
23
|
+
type CreateNeonToolsInput = NeonToolsClientOptions & {
|
|
24
|
+
tools: readonly NeonToolId[];
|
|
25
|
+
};
|
|
26
|
+
export type CreateNeonToolsOptions<Tools extends readonly NeonToolId[] = readonly NeonToolId[]> = NeonToolsClientOptions & {
|
|
27
|
+
tools: Tools;
|
|
28
|
+
};
|
|
29
|
+
type SelectedTools<T> = T extends {
|
|
30
|
+
tools: infer S extends readonly NeonToolId[];
|
|
31
|
+
} ? S : [];
|
|
32
|
+
type NeonToolsFor<T, Inject> = T extends CreateNeonToolsInput ? Inject extends NeonToolInjectOptions ? InjectedNeonTools<SelectedTools<T>, Inject> : NeonTools<SelectedTools<T>> : never;
|
|
33
|
+
type ToolForId<Id extends NeonToolId> = ReturnType<ToolFactories[Id]>;
|
|
34
|
+
type NamedNeonTools<Tools extends readonly NeonToolId[], Inject> = {
|
|
35
|
+
[Tool in Tools[number]]: WithPublishedId<Inject extends NeonToolInjectOptions ? InjectedNeonTool<ReturnType<ToolFactories[Tool]>, Inject> : ReturnType<ToolFactories[Tool]>>;
|
|
62
36
|
};
|
|
63
37
|
type NamedNeonTool<Id extends NeonToolId, Inject> = WithPublishedId<Inject extends NeonToolInjectOptions ? InjectedNeonTool<ToolForId<Id>, Inject> : ToolForId<Id>>;
|
|
64
|
-
type NamedNeonToolsFor<T, Inject> = T extends CreateNeonToolsInput ? NamedNeonTools<
|
|
38
|
+
type NamedNeonToolsFor<T, Inject> = T extends CreateNeonToolsInput ? NamedNeonTools<SelectedTools<T>, Inject> : never;
|
|
65
39
|
export declare function createNeonTools<const T extends CreateNeonToolsInput, const Inject extends NeonToolInjectOptions | undefined = undefined>(options: T & {
|
|
66
40
|
inject?: Inject;
|
|
67
41
|
} & ({
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAIN,KAAK,gBAAgB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I,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,qBAAqB,CAAA;CAAE,GAC/D;IAAE,KAAK,EAAE,qBAAqB,CAAC;IAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,CAAA;CAAE,CACjE,GACA,aAAa,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;AAC7B,wBAAgB,cAAc,CAC7B,KAAK,CAAC,EAAE,SAAS,UAAU,EAC3B,KAAK,CAAC,MAAM,SAAS,qBAAqB,GAAG,SAAS,GAAG,SAAS,EAElE,EAAE,EAAE,EAAE,EACN,OAAO,EAAE,sBAAsB,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GACnD,MAAM,SAAS,qBAAqB,GACpC,gBAAgB,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,GACvC,SAAS,CAAC,EAAE,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,49 +1,33 @@
|
|
|
1
|
-
import { missingBearerCredential, requireBearerCredential } from "./lib/auth.js";
|
|
2
1
|
import { applyToolCustomization, assertToolCustomizeOptions, hasToolCustomization } from "./lib/customize.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { NeonError
|
|
2
|
+
import { toolFactories } from "./lib/ergonomic/catalog.js";
|
|
3
|
+
import { isNeonToolId, toolIds, unpublishedToolError } from "./lib/ergonomic/ids.js";
|
|
4
|
+
import { NeonError } from "@neon/sdk";
|
|
6
5
|
//#region src/index.ts
|
|
7
|
-
const createRawClient = (options) => createNeonClient({
|
|
8
|
-
apiKey: options.apiKey === void 0 ? missingBearerCredential : requireBearerCredential(options.apiKey),
|
|
9
|
-
...options.baseUrl === void 0 ? {} : { baseUrl: options.baseUrl },
|
|
10
|
-
...options.fetch === void 0 ? {} : { fetch: options.fetch },
|
|
11
|
-
...options.wait === void 0 ? {} : { wait: options.wait }
|
|
12
|
-
}).client;
|
|
13
|
-
const operationFactoryFor = (operationId) => {
|
|
14
|
-
const knownOperationId = operationIds.find((candidate) => candidate === operationId);
|
|
15
|
-
if (knownOperationId === void 0) throw new TypeError(`Unknown Neon operation "${operationId}".`);
|
|
16
|
-
return operationFactories[knownOperationId];
|
|
17
|
-
};
|
|
18
6
|
const assertKnownNameKeys = (names, tools) => {
|
|
19
7
|
if (names === void 0 || typeof names === "function") return;
|
|
20
8
|
const known = new Set(tools.flatMap((tool) => [tool.operationId, tool.id]));
|
|
21
9
|
const unknown = Object.keys(names).filter((key) => !known.has(key));
|
|
22
10
|
if (unknown.length > 0) throw new TypeError(`Unknown Neon tool name override: ${unknown.join(", ")}`);
|
|
23
11
|
};
|
|
24
|
-
function assertNeonTools(value,
|
|
25
|
-
if (typeof value !== "object" || value === null) throw new TypeError("Expected
|
|
26
|
-
for (const
|
|
27
|
-
for (const workflowId of workflows) if (!(workflowId in value)) throw new TypeError(`Missing Neon workflow tool "${workflowId}".`);
|
|
12
|
+
function assertNeonTools(value, tools) {
|
|
13
|
+
if (typeof value !== "object" || value === null) throw new TypeError("Expected Neon tools to be an object.");
|
|
14
|
+
for (const toolId of tools) if (!(toolId in value)) throw new TypeError(`Missing Neon tool "${toolId}".`);
|
|
28
15
|
}
|
|
16
|
+
const factoryFor = (id) => {
|
|
17
|
+
const known = toolIds.find((candidate) => candidate === id);
|
|
18
|
+
if (known === void 0) throw unpublishedToolError(id);
|
|
19
|
+
return toolFactories[known];
|
|
20
|
+
};
|
|
29
21
|
const bindTools = (options) => {
|
|
30
22
|
assertToolCustomizeOptions(options);
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return [operationId, operationFactoryFor(operationId)(createRawClient(options))];
|
|
23
|
+
const selected = options.tools;
|
|
24
|
+
if (selected === void 0 || selected.length === 0) throw new TypeError("createNeonTools requires at least one tool");
|
|
25
|
+
const seen = /* @__PURE__ */ new Set();
|
|
26
|
+
const rawEntries = selected.map((toolId) => {
|
|
27
|
+
if (seen.has(toolId)) throw new Error(`Duplicate Neon tool "${toolId}"`);
|
|
28
|
+
seen.add(toolId);
|
|
29
|
+
return [toolId, factoryFor(toolId)(options)];
|
|
39
30
|
});
|
|
40
|
-
const selectedWorkflows = /* @__PURE__ */ new Set();
|
|
41
|
-
const workflowEntries = workflows.map((workflowId) => {
|
|
42
|
-
if (selectedWorkflows.has(workflowId)) throw new Error(`Duplicate Neon workflow "${workflowId}"`);
|
|
43
|
-
selectedWorkflows.add(workflowId);
|
|
44
|
-
return [workflowId, workflowFactoryFor(workflowId)(options)];
|
|
45
|
-
});
|
|
46
|
-
const rawEntries = [...operationEntries, ...workflowEntries];
|
|
47
31
|
assertKnownNameKeys(options.names, rawEntries.map(([, tool]) => tool));
|
|
48
32
|
const entries = rawEntries.map(([id, tool]) => {
|
|
49
33
|
return [id, hasToolCustomization(options) ? applyToolCustomization(tool, options) : tool];
|
|
@@ -55,23 +39,18 @@ const bindTools = (options) => {
|
|
|
55
39
|
publishedIds.set(tool.id, id);
|
|
56
40
|
}
|
|
57
41
|
const tools = Object.fromEntries(entries);
|
|
58
|
-
assertNeonTools(tools,
|
|
42
|
+
assertNeonTools(tools, selected);
|
|
59
43
|
return tools;
|
|
60
44
|
};
|
|
61
45
|
function createNeonTools(options) {
|
|
62
46
|
return bindTools(options);
|
|
63
47
|
}
|
|
64
48
|
function createNeonTool(id, options) {
|
|
49
|
+
if (!isNeonToolId(id)) throw unpublishedToolError(id);
|
|
65
50
|
assertToolCustomizeOptions(options);
|
|
66
|
-
|
|
67
|
-
if (isNeonWorkflowId(id)) tool = workflowFactoryFor(id)(options);
|
|
68
|
-
else {
|
|
69
|
-
const knownOperationId = operationIds.find((candidate) => candidate === id);
|
|
70
|
-
if (knownOperationId === void 0) throw new TypeError(`Unknown Neon operation or workflow "${id}".`);
|
|
71
|
-
tool = operationFactories[knownOperationId](createRawClient(options));
|
|
72
|
-
}
|
|
51
|
+
const tool = factoryFor(id)(options);
|
|
73
52
|
assertKnownNameKeys(options.names, [tool]);
|
|
74
53
|
return hasToolCustomization(options) ? applyToolCustomization(tool, options) : tool;
|
|
75
54
|
}
|
|
76
55
|
//#endregion
|
|
77
|
-
export { NeonError, createNeonTool, createNeonTools,
|
|
56
|
+
export { NeonError, createNeonTool, createNeonTools, toolIds };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type NeonClient, type NeonConfig, type Paginated } from "@neon/sdk";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
import { type NeonOperationId, operationFactories } from "../../operations.gen.js";
|
|
4
|
+
import { type NeonBearerCredential } from "../auth.js";
|
|
5
|
+
import type { JsonSafe, NeonTool, NeonToolAnnotations, NeonToolExecutionContext } from "../operation.js";
|
|
6
|
+
import type { NeonToolId } from "./ids.js";
|
|
7
|
+
export interface ToolClientOptions {
|
|
8
|
+
apiKey?: NeonBearerCredential;
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
fetch?: typeof fetch;
|
|
11
|
+
wait?: NeonConfig["wait"];
|
|
12
|
+
}
|
|
13
|
+
type Snake<S extends string> = S extends `${infer Head}${infer Rest}` ? Head extends Uppercase<Head> ? Head extends Lowercase<Head> ? `${Head}${Snake<Rest>}` : `_${Lowercase<Head>}${Snake<Rest>}` : `${Head}${Snake<Rest>}` : S;
|
|
14
|
+
export type PublishedId<Id extends string> = Id extends `${infer Head}.${infer Rest}` ? `${Snake<Head>}_${PublishedId<Rest>}` : Snake<Id>;
|
|
15
|
+
export declare const publishedId: <Id extends string>(id: Id) => PublishedId<Id>;
|
|
16
|
+
export declare const toolClient: (options: ToolClientOptions, context?: NeonToolExecutionContext) => NeonClient<true>;
|
|
17
|
+
export declare const collectObjectList: (neon: NeonClient<true>, input: {
|
|
18
|
+
project_id: string;
|
|
19
|
+
branch_id: string;
|
|
20
|
+
bucket_name: string;
|
|
21
|
+
prefix?: string;
|
|
22
|
+
delimiter?: string;
|
|
23
|
+
limit?: number;
|
|
24
|
+
}, signal?: AbortSignal) => Promise<{
|
|
25
|
+
folders: string[];
|
|
26
|
+
objects: import("@neon/sdk").BucketObject[];
|
|
27
|
+
prefix: string;
|
|
28
|
+
}>;
|
|
29
|
+
export declare const collectPages: <T>(list: Paginated<T>, maxItems?: number) => Promise<T[]>;
|
|
30
|
+
export declare const bindTool: <const InputSchema extends z.ZodType, const Id extends string, Output>(options: ToolClientOptions, tool: Omit<NeonTool<InputSchema, Id, JsonSafe<Awaited<Output>>>, "execute">, run: (neon: NeonClient<true>, input: z.output<InputSchema>, signal?: AbortSignal) => Promise<Output>) => NeonTool<InputSchema, Id, JsonSafe<Awaited<Output>>>;
|
|
31
|
+
type GeneratedTool<G extends NeonOperationId> = ReturnType<(typeof operationFactories)[G]>;
|
|
32
|
+
type GeneratedSchema<G extends NeonOperationId> = GeneratedTool<G>["inputSchema"];
|
|
33
|
+
type GeneratedInput<G extends NeonOperationId> = z.output<GeneratedSchema<G>>;
|
|
34
|
+
type GeneratedArg<G extends NeonOperationId> = z.input<GeneratedSchema<G>>;
|
|
35
|
+
type FromGeneratedMeta = {
|
|
36
|
+
list?: boolean;
|
|
37
|
+
annotations?: NeonToolAnnotations;
|
|
38
|
+
requiresApproval?: boolean;
|
|
39
|
+
};
|
|
40
|
+
type OmittedInput<G extends NeonOperationId, Keys extends string> = Omit<GeneratedInput<G>, Keys>;
|
|
41
|
+
type OmittedArg<G extends NeonOperationId, Keys extends string> = Omit<GeneratedArg<G>, Keys>;
|
|
42
|
+
export declare function fromGenerated<const Id extends NeonToolId, const G extends NeonOperationId, Output>(options: ToolClientOptions, spec: FromGeneratedMeta & {
|
|
43
|
+
id: Id;
|
|
44
|
+
generated: G;
|
|
45
|
+
run: (neon: NeonClient<true>, input: GeneratedInput<G>, signal?: AbortSignal) => Promise<Output>;
|
|
46
|
+
}): NeonTool<GeneratedSchema<G>, PublishedId<Id>, JsonSafe<Awaited<Output>>>;
|
|
47
|
+
export declare function fromGenerated<const Id extends NeonToolId, const G extends NeonOperationId, const Keys extends keyof GeneratedInput<G> & string, Output>(options: ToolClientOptions, spec: FromGeneratedMeta & {
|
|
48
|
+
id: Id;
|
|
49
|
+
generated: G;
|
|
50
|
+
omit: readonly Keys[];
|
|
51
|
+
run: (neon: NeonClient<true>, input: OmittedInput<G, Keys>, signal?: AbortSignal) => Promise<Output>;
|
|
52
|
+
}): NeonTool<z.ZodType<OmittedInput<G, Keys>, OmittedArg<G, Keys>>, PublishedId<Id>, JsonSafe<Awaited<Output>>>;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=bind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bind.d.ts","sourceRoot":"","sources":["../../../src/lib/ergonomic/bind.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,UAAU,EACf,KAAK,UAAU,EAEf,KAAK,SAAS,EACd,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EACN,KAAK,eAAe,EACpB,kBAAkB,EAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEN,KAAK,oBAAoB,EAEzB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EACX,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,wBAAwB,EACxB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,WAAW,iBAAiB;IACjC,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,IAAI,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;CAC1B;AASD,KAAK,KAAK,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,GAAG,MAAM,IAAI,GAAG,MAAM,IAAI,EAAE,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