@neon/tools 2.14.4 → 2.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/README.md +78 -1
  2. package/dist/effect.d.ts +22 -0
  3. package/dist/effect.d.ts.map +1 -0
  4. package/dist/effect.js +3 -0
  5. package/dist/generated/output.gen.d.ts +3418 -0
  6. package/dist/generated/output.gen.d.ts.map +1 -0
  7. package/dist/generated/output.gen.js +1498 -0
  8. package/dist/lib/custom/auth-config.d.ts +63 -1
  9. package/dist/lib/custom/auth-config.d.ts.map +1 -1
  10. package/dist/lib/custom/auth-config.js +21 -1
  11. package/dist/lib/custom/docs.d.ts +32 -2
  12. package/dist/lib/custom/docs.d.ts.map +1 -1
  13. package/dist/lib/custom/docs.js +16 -1
  14. package/dist/lib/custom/feedback.d.ts +7 -2
  15. package/dist/lib/custom/feedback.d.ts.map +1 -1
  16. package/dist/lib/custom/feedback.js +2 -0
  17. package/dist/lib/custom/fetch.d.ts +15 -1
  18. package/dist/lib/custom/fetch.d.ts.map +1 -1
  19. package/dist/lib/custom/fetch.js +9 -1
  20. package/dist/lib/custom/organizations.d.ts +23 -1
  21. package/dist/lib/custom/organizations.d.ts.map +1 -1
  22. package/dist/lib/custom/organizations.js +2 -0
  23. package/dist/lib/custom/resources.d.ts +15 -1
  24. package/dist/lib/custom/resources.d.ts.map +1 -1
  25. package/dist/lib/custom/resources.js +7 -1
  26. package/dist/lib/custom/sql/connection.js +1 -1
  27. package/dist/lib/custom/sql/describe-branch.d.ts +99 -1
  28. package/dist/lib/custom/sql/describe-branch.d.ts.map +1 -1
  29. package/dist/lib/custom/sql/describe-branch.js +9 -0
  30. package/dist/lib/custom/sql/inspect/inspect.d.ts +27 -1
  31. package/dist/lib/custom/sql/inspect/inspect.d.ts.map +1 -1
  32. package/dist/lib/custom/sql/inspect/inspect.js +15 -1
  33. package/dist/lib/custom/sql/migrations.d.ts +46 -2
  34. package/dist/lib/custom/sql/migrations.d.ts.map +1 -1
  35. package/dist/lib/custom/sql/migrations.js +26 -2
  36. package/dist/lib/custom/sql/query-tuning.d.ts +90 -2
  37. package/dist/lib/custom/sql/query-tuning.d.ts.map +1 -1
  38. package/dist/lib/custom/sql/query-tuning.js +28 -3
  39. package/dist/lib/custom/sql/run.d.ts +30 -3
  40. package/dist/lib/custom/sql/run.d.ts.map +1 -1
  41. package/dist/lib/custom/sql/run.js +11 -1
  42. package/dist/lib/custom/sql/schema.d.ts +76 -2
  43. package/dist/lib/custom/sql/schema.d.ts.map +1 -1
  44. package/dist/lib/custom/sql/schema.js +31 -2
  45. package/dist/lib/custom/sql/slow-queries.d.ts +15 -1
  46. package/dist/lib/custom/sql/slow-queries.d.ts.map +1 -1
  47. package/dist/lib/custom/sql/slow-queries.js +9 -1
  48. package/dist/lib/effect/errors.d.ts +51 -0
  49. package/dist/lib/effect/errors.d.ts.map +1 -0
  50. package/dist/lib/effect/errors.js +37 -0
  51. package/dist/lib/effect/tools.d.ts +56 -0
  52. package/dist/lib/effect/tools.d.ts.map +1 -0
  53. package/dist/lib/effect/tools.js +67 -0
  54. package/dist/lib/ergonomic/bind.d.ts +20 -6
  55. package/dist/lib/ergonomic/bind.d.ts.map +1 -1
  56. package/dist/lib/ergonomic/bind.js +2 -1
  57. package/dist/lib/ergonomic/catalog.d.ts +5333 -172
  58. package/dist/lib/ergonomic/catalog.d.ts.map +1 -1
  59. package/dist/lib/ergonomic/catalog.js +186 -1
  60. package/dist/lib/ergonomic/composed.d.ts +866 -12
  61. package/dist/lib/ergonomic/composed.d.ts.map +1 -1
  62. package/dist/lib/ergonomic/composed.js +34 -0
  63. package/dist/lib/mcp-json-schema.d.ts +20 -0
  64. package/dist/lib/mcp-json-schema.d.ts.map +1 -1
  65. package/dist/lib/mcp-json-schema.js +89 -1
  66. package/dist/lib/mcp-register.d.ts +1 -1
  67. package/dist/lib/mcp-register.d.ts.map +1 -1
  68. package/dist/lib/mcp-register.js +2 -1
  69. package/dist/lib/operation.d.ts +6 -1
  70. package/dist/lib/operation.d.ts.map +1 -1
  71. package/dist/mcp-v1.d.ts.map +1 -1
  72. package/dist/mcp-v1.js +3 -1
  73. package/dist/mcp.d.ts +3 -3
  74. package/dist/mcp.d.ts.map +1 -1
  75. package/dist/mcp.js +3 -3
  76. package/dist/operations.gen.d.ts +194 -194
  77. package/package.json +22 -3
@@ -4,9 +4,9 @@ import { bindTool, publishedId } from "../../../ergonomic/bind.js";
4
4
  import { SQL_METADATA, branchIdField, computeIdField, projectIdField, resolveConnection, sqlClient } from "../connection.js";
5
5
  import { sqlReadAnnotations } from "../schema.js";
6
6
  import { formatInspectQueryError, selectInspectTargets } from "./targets.js";
7
- import { NeonClientError } from "@neon/sdk";
8
7
  import { NeonDbError } from "@neondatabase/serverless";
9
8
  import * as z from "zod";
9
+ import { NeonClientError } from "@neon/sdk";
10
10
  // src/lib/custom/sql/inspect/inspect.ts
11
11
  /**
12
12
  * Postgres rejected one of the package's own diagnostic queries. That is a bug
@@ -66,12 +66,26 @@ const rethrowInspectError = (error, wrapped) => {
66
66
  }
67
67
  throw new Error(wrapped, { cause: error });
68
68
  };
69
+ const inspectDatabaseOutputSchema = z.looseObject({
70
+ check: z.string().describe("The check that ran."),
71
+ describe: z.string().describe("What the check reports."),
72
+ projectId: z.string(),
73
+ branchId: z.string(),
74
+ databaseName: z.string().nullish(),
75
+ databases: z.array(z.string()).describe("Databases the check covered."),
76
+ fields: z.array(z.string()).describe("Column names in rows."),
77
+ totalRowCount: z.number(),
78
+ rows: z.array(z.record(z.string(), z.unknown())),
79
+ truncated: z.boolean(),
80
+ note: z.string().nullish()
81
+ });
69
82
  const inspectDatabaseTool = (options) => bindTool(options, {
70
83
  operationId: "database.inspect",
71
84
  id: publishedId("database.inspect"),
72
85
  title: "Inspect Database",
73
86
  description: "Runs one read-only neon inspect db check; some are compute-wide. outliers ranks queries by total time and calls by count, both via pg_stat_statements; lfc-hit-rate and working-set need the neon extension. If one is missing, the error gives the CREATE EXTENSION; ask before running it. Other SQL: {{sql.run}}; one plan: {{sql.explain}}; new indexes: {{queryTuning.prepare}}.",
74
87
  inputSchema: inspectDatabaseInputSchema,
88
+ outputSchema: inspectDatabaseOutputSchema,
75
89
  annotations: sqlReadAnnotations,
76
90
  requiresApproval: false,
77
91
  metadata: SQL_METADATA
@@ -44,7 +44,39 @@ export declare const prepareMigrationTool: (options: ToolClientOptions) => impor
44
44
  migration_result: {
45
45
  [x: string]: unknown;
46
46
  }[][];
47
- }>;
47
+ }, z.ZodObject<{
48
+ complete: z.ZodObject<{
49
+ migration_id: z.ZodString;
50
+ migration_sql: z.ZodString;
51
+ database_name: z.ZodString;
52
+ project_id: z.ZodString;
53
+ temporary_branch_id: z.ZodString;
54
+ parent_branch_id: z.ZodString;
55
+ }, z.core.$loose>;
56
+ temporary_branch: z.ZodObject<{
57
+ id: z.ZodString;
58
+ name: z.ZodString;
59
+ parent_id: z.ZodString;
60
+ }, z.core.$loose>;
61
+ migration_result: z.ZodArray<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
62
+ }, z.core.$loose>> & {
63
+ outputSchema: z.ZodObject<{
64
+ complete: z.ZodObject<{
65
+ migration_id: z.ZodString;
66
+ migration_sql: z.ZodString;
67
+ database_name: z.ZodString;
68
+ project_id: z.ZodString;
69
+ temporary_branch_id: z.ZodString;
70
+ parent_branch_id: z.ZodString;
71
+ }, z.core.$loose>;
72
+ temporary_branch: z.ZodObject<{
73
+ id: z.ZodString;
74
+ name: z.ZodString;
75
+ parent_id: z.ZodString;
76
+ }, z.core.$loose>;
77
+ migration_result: z.ZodArray<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
78
+ }, z.core.$loose>;
79
+ };
48
80
  export declare const completeMigrationTool: (options: ToolClientOptions) => import("../../operation.js").NeonTool<z.ZodObject<{
49
81
  migration_id: z.ZodString;
50
82
  migration_sql: z.ZodString;
@@ -65,5 +97,17 @@ export declare const completeMigrationTool: (options: ToolClientOptions) => impo
65
97
  }[][] | null | undefined;
66
98
  cleanupError: string;
67
99
  applied: boolean;
68
- }>;
100
+ }, z.ZodObject<{
101
+ applied: z.ZodBoolean;
102
+ migrationResult: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>>>;
103
+ deletedBranchId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
104
+ cleanupError: z.ZodOptional<z.ZodNullable<z.ZodString>>;
105
+ }, z.core.$loose>> & {
106
+ outputSchema: z.ZodObject<{
107
+ applied: z.ZodBoolean;
108
+ migrationResult: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>>>;
109
+ deletedBranchId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
110
+ cleanupError: z.ZodOptional<z.ZodNullable<z.ZodString>>;
111
+ }, z.core.$loose>;
112
+ };
69
113
  //# sourceMappingURL=migrations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../../src/lib/custom/sql/migrations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,UAAU,EAAmB,MAAM,WAAW,CAAC;AAE1E,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,yBAAyB,CAAC;AAUjC,mFAAmF;AACnF,eAAO,MAAM,kBAAkB,GAAI,KAAK,MAAM,KAAG,MAAM,EACxB,CAAC;AA8BhC;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAU,CAAC,EAC1C,YAAY,UAAU,CAAC,IAAI,CAAC,EAC5B,WAAW,MAAM,EACjB,MAAM,MAAM,GAAG,SAAS,EACxB,QAAQ,WAAW,GAAG,SAAS,EAC/B,KAAK,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,KACjC,OAAO,CAAC,CAAC,C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1,8 @@
1
1
  import { bindTool, publishedId } from "../../ergonomic/bind.js";
2
2
  import { DATABASE_NAME_DESCRIPTION, SQL_METADATA, defaultDatabase, projectIdField, refuseInReadOnly } from "./connection.js";
3
- import { runTransaction, sqlWriteAnnotations } from "./run.js";
4
- import { NeonClientError } from "@neon/sdk";
3
+ import { runTransaction, sqlRowsOutputSchema, sqlWriteAnnotations } from "./run.js";
5
4
  import * as z from "zod";
5
+ import { NeonClientError } from "@neon/sdk";
6
6
  import { createProjectBranch } from "@neon/sdk/raw";
7
7
  import { randomUUID } from "node:crypto";
8
8
  // src/lib/custom/sql/migrations.ts
@@ -63,12 +63,29 @@ const completeMigrationInputSchema = z.strictObject({
63
63
  parent_branch_id: z.string().describe("The branch the migration is applied to."),
64
64
  apply_changes: z.boolean().default(true).describe("Apply the migration to the parent branch. false only deletes the temporary branch.")
65
65
  });
66
+ const prepareMigrationOutputSchema = z.looseObject({
67
+ complete: z.looseObject({
68
+ migration_id: z.string(),
69
+ migration_sql: z.string(),
70
+ database_name: z.string(),
71
+ project_id: z.string(),
72
+ temporary_branch_id: z.string(),
73
+ parent_branch_id: z.string()
74
+ }).describe("The values that apply or discard the migration."),
75
+ temporary_branch: z.looseObject({
76
+ id: z.string(),
77
+ name: z.string(),
78
+ parent_id: z.string()
79
+ }).describe("The branch the migration ran on."),
80
+ migration_result: z.array(sqlRowsOutputSchema).describe("Rows per statement.")
81
+ });
66
82
  const prepareMigrationTool = (options) => bindTool(options, {
67
83
  operationId: "migrations.prepare",
68
84
  id: publishedId("migrations.prepare"),
69
85
  title: "Prepare Database Migration",
70
86
  description: "Applies a schema change on a new temporary branch and returns a migration_id. Test it there with {{sql.run}}, ask the user, then always call {{migrations.complete}} with the response's complete object so the branch is deleted.",
71
87
  inputSchema: prepareMigrationInputSchema,
88
+ outputSchema: prepareMigrationOutputSchema,
72
89
  annotations: {
73
90
  readOnlyHint: false,
74
91
  destructiveHint: false,
@@ -110,12 +127,19 @@ const prepareMigrationTool = (options) => bindTool(options, {
110
127
  };
111
128
  });
112
129
  });
130
+ const completeMigrationOutputSchema = z.looseObject({
131
+ applied: z.boolean().describe("Whether the migration ran on the parent branch."),
132
+ migrationResult: z.array(sqlRowsOutputSchema).nullish(),
133
+ deletedBranchId: z.string().nullish(),
134
+ cleanupError: z.string().nullish().describe("Set when the temporary branch could not be deleted.")
135
+ });
113
136
  const completeMigrationTool = (options) => bindTool(options, {
114
137
  operationId: "migrations.complete",
115
138
  id: publishedId("migrations.complete"),
116
139
  title: "Complete Database Migration",
117
140
  description: "Applies or discards a prepared migration and deletes the temporary branch. NEVER run autonomously; always ask the user first. Pass the complete object from {{migrations.prepare}}; apply_changes false discards.",
118
141
  inputSchema: completeMigrationInputSchema,
142
+ outputSchema: completeMigrationOutputSchema,
119
143
  annotations: sqlWriteAnnotations,
120
144
  requiresApproval: true,
121
145
  metadata: SQL_METADATA
@@ -85,7 +85,83 @@ export declare const prepareQueryTuningTool: (options: ToolClientOptions) => imp
85
85
  };
86
86
  };
87
87
  };
88
- }>;
88
+ }, z.ZodObject<{
89
+ complete: z.ZodObject<{
90
+ tuning_id: z.ZodString;
91
+ database_name: z.ZodString;
92
+ project_id: z.ZodString;
93
+ temporary_branch_id: z.ZodString;
94
+ role_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
95
+ }, z.core.$loose>;
96
+ execution_plan: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
97
+ table_schemas: z.ZodArray<z.ZodObject<{
98
+ tableName: z.ZodString;
99
+ schema: z.ZodObject<{
100
+ columns: z.ZodArray<z.ZodObject<{
101
+ name: z.ZodString;
102
+ type: z.ZodString;
103
+ nullable: z.ZodBoolean;
104
+ default: z.ZodNullable<z.ZodString>;
105
+ description: z.ZodNullable<z.ZodString>;
106
+ }, z.core.$loose>>;
107
+ indexes: z.ZodArray<z.ZodObject<{
108
+ name: z.ZodString;
109
+ definition: z.ZodString;
110
+ size: z.ZodString;
111
+ }, z.core.$loose>>;
112
+ constraints: z.ZodArray<z.ZodObject<{
113
+ name: z.ZodString;
114
+ type: z.ZodString;
115
+ definition: z.ZodString;
116
+ }, z.core.$loose>>;
117
+ tableSize: z.ZodString;
118
+ indexSize: z.ZodString;
119
+ totalSize: z.ZodString;
120
+ }, z.core.$loose>;
121
+ formatted: z.ZodString;
122
+ }, z.core.$loose>>;
123
+ sql: z.ZodString;
124
+ baseline_metrics: z.ZodObject<{}, z.core.$loose>;
125
+ }, z.core.$loose>> & {
126
+ outputSchema: z.ZodObject<{
127
+ complete: z.ZodObject<{
128
+ tuning_id: z.ZodString;
129
+ database_name: z.ZodString;
130
+ project_id: z.ZodString;
131
+ temporary_branch_id: z.ZodString;
132
+ role_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
133
+ }, z.core.$loose>;
134
+ execution_plan: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
135
+ table_schemas: z.ZodArray<z.ZodObject<{
136
+ tableName: z.ZodString;
137
+ schema: z.ZodObject<{
138
+ columns: z.ZodArray<z.ZodObject<{
139
+ name: z.ZodString;
140
+ type: z.ZodString;
141
+ nullable: z.ZodBoolean;
142
+ default: z.ZodNullable<z.ZodString>;
143
+ description: z.ZodNullable<z.ZodString>;
144
+ }, z.core.$loose>>;
145
+ indexes: z.ZodArray<z.ZodObject<{
146
+ name: z.ZodString;
147
+ definition: z.ZodString;
148
+ size: z.ZodString;
149
+ }, z.core.$loose>>;
150
+ constraints: z.ZodArray<z.ZodObject<{
151
+ name: z.ZodString;
152
+ type: z.ZodString;
153
+ definition: z.ZodString;
154
+ }, z.core.$loose>>;
155
+ tableSize: z.ZodString;
156
+ indexSize: z.ZodString;
157
+ totalSize: z.ZodString;
158
+ }, z.core.$loose>;
159
+ formatted: z.ZodString;
160
+ }, z.core.$loose>>;
161
+ sql: z.ZodString;
162
+ baseline_metrics: z.ZodObject<{}, z.core.$loose>;
163
+ }, z.core.$loose>;
164
+ };
89
165
  export declare const completeQueryTuningTool: (options: ToolClientOptions) => import("../../operation.js").NeonTool<z.ZodObject<{
90
166
  suggested_sql_statements: z.ZodArray<z.ZodString>;
91
167
  apply_changes: z.ZodDefault<z.ZodBoolean>;
@@ -103,5 +179,17 @@ export declare const completeQueryTuningTool: (options: ToolClientOptions) => im
103
179
  [x: string]: unknown;
104
180
  }[][] | null | undefined;
105
181
  appliedChanges?: string[] | null | undefined;
106
- }>;
182
+ }, z.ZodObject<{
183
+ message: z.ZodString;
184
+ appliedChanges: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
185
+ results: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>>>;
186
+ deletedBranches: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
187
+ }, z.core.$loose>> & {
188
+ outputSchema: z.ZodObject<{
189
+ message: z.ZodString;
190
+ appliedChanges: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
191
+ results: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>>>;
192
+ deletedBranches: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
193
+ }, z.core.$loose>;
194
+ };
107
195
  //# sourceMappingURL=query-tuning.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"query-tuning.d.ts","sourceRoot":"","sources":["../../../../src/lib/custom/sql/query-tuning.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,yBAAyB,CAAC;AAgBjC,eAAO,MAAM,6BAA6B;;;;;kBAQxC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;kBAsCzC,CAAC;AAEH,eAAO,MAAM,sBAAsB,GAAI,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8F/D,CAAC;AAEH,eAAO,MAAM,uBAAuB,GAAI,SAAS,iBAAiB;;;;;;;;;;;;;;;;;EAmEhE,CAAC"}
1
+ {"version":3,"file":"query-tuning.d.ts","sourceRoot":"","sources":["../../../../src/lib/custom/sql/query-tuning.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,yBAAyB,CAAC;AAiBjC,eAAO,MAAM,6BAA6B;;;;;kBAQxC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;kBAsCzC,CAAC;AA4BH,eAAO,MAAM,sBAAsB,GAAI,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+F/D,CAAC;AASH,eAAO,MAAM,uBAAuB,GAAI,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoEhE,CAAC"}
@@ -1,12 +1,12 @@
1
1
  import { pathInputDescriptions } from "../../../descriptions.gen.js";
2
2
  import { bindTool, publishedId } from "../../ergonomic/bind.js";
3
3
  import { SQL_METADATA, projectIdField, refuseInReadOnly, resolveConnection } from "./connection.js";
4
- import { describeTableAt } from "./schema.js";
5
- import { explainStatement, runTransaction, sqlWriteAnnotations } from "./run.js";
4
+ import { describeTableAt, tableSchemaOutputSchema } from "./schema.js";
5
+ import { explainStatement, runTransaction, sqlRowsOutputSchema, sqlWriteAnnotations } from "./run.js";
6
6
  import { withTemporaryBranch } from "./migrations.js";
7
7
  import { extractExecutionMetrics, extractTablesFromPlan } from "./plan.js";
8
- import { NeonClientError } from "@neon/sdk";
9
8
  import * as z from "zod";
9
+ import { NeonClientError } from "@neon/sdk";
10
10
  import { randomUUID } from "node:crypto";
11
11
  // src/lib/custom/sql/query-tuning.ts
12
12
  const prepareQueryTuningInputSchema = z.strictObject({
@@ -26,12 +26,30 @@ const completeQueryTuningInputSchema = z.strictObject({
26
26
  temporary_branch_id: z.string().describe("The temporary_branch_id from {{queryTuning.prepare}}."),
27
27
  branch_id: z.string().optional().describe(`${pathInputDescriptions.branch_id} The branch that receives the changes; omit it for the default branch.`)
28
28
  });
29
+ const prepareQueryTuningOutputSchema = z.looseObject({
30
+ complete: z.looseObject({
31
+ tuning_id: z.string(),
32
+ database_name: z.string(),
33
+ project_id: z.string(),
34
+ temporary_branch_id: z.string(),
35
+ role_name: z.string().nullish()
36
+ }).describe("The values that apply or discard the tuning."),
37
+ execution_plan: sqlRowsOutputSchema.describe("EXPLAIN ANALYZE output."),
38
+ table_schemas: z.array(z.looseObject({
39
+ tableName: z.string(),
40
+ schema: tableSchemaOutputSchema,
41
+ formatted: z.string()
42
+ })).describe("Schemas of the tables the query reads."),
43
+ sql: z.string(),
44
+ baseline_metrics: z.looseObject({}).describe("Execution and planning time, cost, rows, and buffer usage.")
45
+ });
29
46
  const prepareQueryTuningTool = (options) => bindTool(options, {
30
47
  operationId: "queryTuning.prepare",
31
48
  id: publishedId("queryTuning.prepare"),
32
49
  title: "Prepare Query Tuning",
33
50
  description: "Runs EXPLAIN ANALYZE for a slow query on a new temporary branch; returns the plan, table schemas, and a tuning_id. Try changes there with {{sql.run}} and {{sql.explain}}, then always call {{queryTuning.complete}} with the complete object so the branch is deleted. Not {{migrations.prepare}}.",
34
51
  inputSchema: prepareQueryTuningInputSchema,
52
+ outputSchema: prepareQueryTuningOutputSchema,
35
53
  annotations: {
36
54
  readOnlyHint: false,
37
55
  destructiveHint: false,
@@ -88,12 +106,19 @@ const prepareQueryTuningTool = (options) => bindTool(options, {
88
106
  };
89
107
  });
90
108
  });
109
+ const completeQueryTuningOutputSchema = z.looseObject({
110
+ message: z.string().describe("What ran, one step per line."),
111
+ appliedChanges: z.array(z.string()).nullish(),
112
+ results: z.array(sqlRowsOutputSchema).nullish(),
113
+ deletedBranches: z.array(z.string()).nullish()
114
+ });
91
115
  const completeQueryTuningTool = (options) => bindTool(options, {
92
116
  operationId: "queryTuning.complete",
93
117
  id: publishedId("queryTuning.complete"),
94
118
  title: "Complete Query Tuning",
95
119
  description: "Applies or discards query-tuning changes and deletes the temporary branch. NEVER run autonomously. Pass the complete object from {{queryTuning.prepare}} and suggested_sql_statements; apply_changes true applies, omitted discards. Call it even when the user rejects.",
96
120
  inputSchema: completeQueryTuningInputSchema,
121
+ outputSchema: completeQueryTuningOutputSchema,
97
122
  annotations: sqlWriteAnnotations,
98
123
  requiresApproval: true,
99
124
  metadata: SQL_METADATA
@@ -37,6 +37,7 @@ export declare const explainStatement: (neonClient: NeonClient<true>, input: {
37
37
  sql: string;
38
38
  analyze: boolean;
39
39
  } & ConnectionTarget, context: NeonToolExecutionContext, signal?: AbortSignal) => Promise<Row[]>;
40
+ export declare const sqlRowsOutputSchema: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
40
41
  export declare const runSqlTool: (options: ToolClientOptions) => import("../../operation.js").NeonTool<z.ZodObject<{
41
42
  sql: z.ZodString;
42
43
  project_id: z.ZodString;
@@ -52,7 +53,19 @@ export declare const runSqlTool: (options: ToolClientOptions) => import("../../o
52
53
  totalRowCount: number;
53
54
  truncated: boolean;
54
55
  note?: string | null | undefined;
55
- }>;
56
+ }, z.ZodObject<{
57
+ rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
58
+ totalRowCount: z.ZodNumber;
59
+ truncated: z.ZodBoolean;
60
+ note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
61
+ }, z.core.$loose>> & {
62
+ outputSchema: z.ZodObject<{
63
+ rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
64
+ totalRowCount: z.ZodNumber;
65
+ truncated: z.ZodBoolean;
66
+ note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
67
+ }, z.core.$loose>;
68
+ };
56
69
  export declare const runSqlTransactionTool: (options: ToolClientOptions) => import("../../operation.js").NeonTool<z.ZodObject<{
57
70
  sql_statements: z.ZodArray<z.ZodString>;
58
71
  project_id: z.ZodString;
@@ -68,7 +81,19 @@ export declare const runSqlTransactionTool: (options: ToolClientOptions) => impo
68
81
  totalRowCount: number;
69
82
  truncated: boolean;
70
83
  note?: string | null | undefined;
71
- }[]>;
84
+ }[], z.ZodArray<z.ZodObject<{
85
+ rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
86
+ totalRowCount: z.ZodNumber;
87
+ truncated: z.ZodBoolean;
88
+ note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
89
+ }, z.core.$loose>>> & {
90
+ outputSchema: z.ZodArray<z.ZodObject<{
91
+ rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
92
+ totalRowCount: z.ZodNumber;
93
+ truncated: z.ZodBoolean;
94
+ note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
95
+ }, z.core.$loose>>;
96
+ };
72
97
  export declare const explainSqlTool: (options: ToolClientOptions) => import("../../operation.js").NeonTool<z.ZodObject<{
73
98
  sql: z.ZodString;
74
99
  project_id: z.ZodString;
@@ -77,5 +102,7 @@ export declare const explainSqlTool: (options: ToolClientOptions) => import("../
77
102
  analyze: z.ZodDefault<z.ZodBoolean>;
78
103
  }, z.core.$strict>, "explain_sql", {
79
104
  [x: string]: unknown;
80
- }[]>;
105
+ }[], z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>> & {
106
+ outputSchema: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
107
+ };
81
108
  //# sourceMappingURL=run.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../../src/lib/custom/sql/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KA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OAAO,CAAC;CACjB,GAAG,gBAAgB,EACpB,SAAS,wBAAwB,EACjC,SAAS,WAAW,KAClB,OAAO,CAAC,GAAG,EAAE,CAWf,CAAC;AAEF,eAAO,MAAM,mBAAmB,oDAA6C,CAAC;AAW9E,eAAO,MAAM,UAAU,GAAI,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BnD,CAAC;AAEH,eAAO,MAAM,qBAAqB,GAAI,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0B9D,CAAC;AAEH,eAAO,MAAM,cAAc,GAAI,SAAS,iBAAiB;;;;;;;;;;CAiBvD,CAAC"}
@@ -54,12 +54,20 @@ const explainStatement = (neonClient, input, context, signal) => {
54
54
  const prefix = input.analyze ? "EXPLAIN (ANALYZE, VERBOSE, BUFFERS, FILECACHE, FORMAT JSON)" : "EXPLAIN (VERBOSE, FORMAT JSON)";
55
55
  return runStatement(neonClient, input, `${prefix} ${input.sql}`, context, signal);
56
56
  };
57
+ const sqlRowsOutputSchema = z.array(z.record(z.string(), z.unknown()));
58
+ const sqlResultOutputSchema = z.looseObject({
59
+ rows: sqlRowsOutputSchema.describe("Result rows, keyed by column name."),
60
+ totalRowCount: z.number().describe("Rows the statement returned."),
61
+ truncated: z.boolean().describe("Whether rows holds fewer than totalRowCount."),
62
+ note: z.string().nullish()
63
+ });
57
64
  const runSqlTool = (options) => bindTool(options, {
58
65
  operationId: "sql.run",
59
66
  id: publishedId("sql.run"),
60
67
  title: "Run SQL",
61
68
  description: "Runs one SQL statement on a branch's database and returns its rows. After a prepare step, pass its temporary branch_id. NEVER run destructive SQL autonomously; always ask the user first.",
62
69
  inputSchema: runSqlInputSchema,
70
+ outputSchema: sqlResultOutputSchema,
63
71
  annotations: sqlWriteAnnotations,
64
72
  requiresApproval: true,
65
73
  metadata: SQL_METADATA
@@ -70,6 +78,7 @@ const runSqlTransactionTool = (options) => bindTool(options, {
70
78
  title: "Run SQL Transaction",
71
79
  description: "Runs several SQL statements in one transaction and returns each one's rows. After a prepare step, pass its temporary branch_id. NEVER run destructive SQL autonomously; always ask the user first.",
72
80
  inputSchema: runSqlTransactionInputSchema,
81
+ outputSchema: z.array(sqlResultOutputSchema),
73
82
  annotations: sqlWriteAnnotations,
74
83
  requiresApproval: true,
75
84
  metadata: SQL_METADATA
@@ -83,8 +92,9 @@ const explainSqlTool = (options) => bindTool(options, {
83
92
  title: "Explain SQL Statement",
84
93
  description: "Returns a statement's execution plan as JSON. analyze true executes it, side effects included, so never analyze potentially destructive SQL autonomously. For rows, use {{sql.run}}.",
85
94
  inputSchema: explainSqlInputSchema,
95
+ outputSchema: sqlRowsOutputSchema,
86
96
  annotations: sqlWriteAnnotations,
87
97
  requiresApproval: true,
88
98
  metadata: SQL_METADATA
89
99
  }, (neonClient, input, signal, context) => explainStatement(neonClient, input, context, signal));
90
- export { explainSqlInputSchema, explainSqlTool, explainStatement, runSqlInputSchema, runSqlTool, runSqlTransactionInputSchema, runSqlTransactionTool, runStatement, runTransaction, sqlWriteAnnotations };
100
+ export { explainSqlInputSchema, explainSqlTool, explainStatement, runSqlInputSchema, runSqlTool, runSqlTransactionInputSchema, runSqlTransactionTool, runStatement, runTransaction, sqlRowsOutputSchema, sqlWriteAnnotations };
@@ -49,7 +49,31 @@ export declare const listTablesTool: (options: ToolClientOptions) => import("../
49
49
  database_name: z.ZodOptional<z.ZodString>;
50
50
  }, z.core.$strict>, "list_tables_schema", {
51
51
  [x: string]: unknown;
52
- }[]>;
52
+ }[], z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>> & {
53
+ outputSchema: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
54
+ };
55
+ export declare const tableSchemaOutputSchema: z.ZodObject<{
56
+ columns: z.ZodArray<z.ZodObject<{
57
+ name: z.ZodString;
58
+ type: z.ZodString;
59
+ nullable: z.ZodBoolean;
60
+ default: z.ZodNullable<z.ZodString>;
61
+ description: z.ZodNullable<z.ZodString>;
62
+ }, z.core.$loose>>;
63
+ indexes: z.ZodArray<z.ZodObject<{
64
+ name: z.ZodString;
65
+ definition: z.ZodString;
66
+ size: z.ZodString;
67
+ }, z.core.$loose>>;
68
+ constraints: z.ZodArray<z.ZodObject<{
69
+ name: z.ZodString;
70
+ type: z.ZodString;
71
+ definition: z.ZodString;
72
+ }, z.core.$loose>>;
73
+ tableSize: z.ZodString;
74
+ indexSize: z.ZodString;
75
+ totalSize: z.ZodString;
76
+ }, z.core.$loose>;
53
77
  export declare const describeTableTool: (options: ToolClientOptions) => import("../../operation.js").NeonTool<z.ZodObject<{
54
78
  table_name: z.ZodString;
55
79
  project_id: z.ZodString;
@@ -79,6 +103,56 @@ export declare const describeTableTool: (options: ToolClientOptions) => import("
79
103
  totalSize: string;
80
104
  };
81
105
  formatted: string;
82
- }>;
106
+ }, z.ZodObject<{
107
+ raw: z.ZodObject<{
108
+ columns: z.ZodArray<z.ZodObject<{
109
+ name: z.ZodString;
110
+ type: z.ZodString;
111
+ nullable: z.ZodBoolean;
112
+ default: z.ZodNullable<z.ZodString>;
113
+ description: z.ZodNullable<z.ZodString>;
114
+ }, z.core.$loose>>;
115
+ indexes: z.ZodArray<z.ZodObject<{
116
+ name: z.ZodString;
117
+ definition: z.ZodString;
118
+ size: z.ZodString;
119
+ }, z.core.$loose>>;
120
+ constraints: z.ZodArray<z.ZodObject<{
121
+ name: z.ZodString;
122
+ type: z.ZodString;
123
+ definition: z.ZodString;
124
+ }, z.core.$loose>>;
125
+ tableSize: z.ZodString;
126
+ indexSize: z.ZodString;
127
+ totalSize: z.ZodString;
128
+ }, z.core.$loose>;
129
+ formatted: z.ZodString;
130
+ }, z.core.$loose>> & {
131
+ outputSchema: z.ZodObject<{
132
+ raw: z.ZodObject<{
133
+ columns: z.ZodArray<z.ZodObject<{
134
+ name: z.ZodString;
135
+ type: z.ZodString;
136
+ nullable: z.ZodBoolean;
137
+ default: z.ZodNullable<z.ZodString>;
138
+ description: z.ZodNullable<z.ZodString>;
139
+ }, z.core.$loose>>;
140
+ indexes: z.ZodArray<z.ZodObject<{
141
+ name: z.ZodString;
142
+ definition: z.ZodString;
143
+ size: z.ZodString;
144
+ }, z.core.$loose>>;
145
+ constraints: z.ZodArray<z.ZodObject<{
146
+ name: z.ZodString;
147
+ type: z.ZodString;
148
+ definition: z.ZodString;
149
+ }, z.core.$loose>>;
150
+ tableSize: z.ZodString;
151
+ indexSize: z.ZodString;
152
+ totalSize: z.ZodString;
153
+ }, z.core.$loose>;
154
+ formatted: z.ZodString;
155
+ }, z.core.$loose>;
156
+ };
83
157
  export {};
84
158
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/lib/custom/sql/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAU9D,eAAO,MAAM,kBAAkB,EAAE,mBAKhC,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;kBAIhC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;kBASnC,CAAC;AAyGH,UAAU,iBAAiB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,UAAU,gBAAgB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACb;AAED,UAAU,qBAAqB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WA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../../ergonomic/bind.js";
2
2
  import { SQL_METADATA, branchIdField, databaseNameField, projectIdField, resolveConnection, sqlClient } from "./connection.js";
3
- import { NeonClientError } from "@neon/sdk";
4
3
  import * as z from "zod";
4
+ import { NeonClientError } from "@neon/sdk";
5
5
  // src/lib/custom/sql/schema.ts
6
6
  const sqlReadAnnotations = {
7
7
  readOnlyHint: true,
@@ -185,12 +185,14 @@ const describeTableAt = async (uri, tableName, signal) => {
185
185
  formatted: formatTableDescription(description)
186
186
  };
187
187
  };
188
+ const listTablesOutputSchema = z.array(z.record(z.string(), z.unknown())).describe("One row per table: table_schema, table_name, table_type.");
188
189
  const listTablesTool = (options) => bindTool(options, {
189
190
  operationId: "schema.listTables",
190
191
  id: publishedId("schema.listTables"),
191
192
  title: "Get Database Tables",
192
193
  description: "Lists a database's tables and views outside the system schemas. For one table's columns, use {{schema.describeTable}}.",
193
194
  inputSchema: listTablesInputSchema,
195
+ outputSchema: listTablesOutputSchema,
194
196
  annotations: sqlReadAnnotations,
195
197
  requiresApproval: false,
196
198
  metadata: SQL_METADATA
@@ -198,12 +200,39 @@ const listTablesTool = (options) => bindTool(options, {
198
200
  const connection = await resolveConnection(neonClient, input, context, signal);
199
201
  return sqlClient(connection.uri, signal).query(LIST_TABLES_SQL);
200
202
  });
203
+ const tableSchemaOutputSchema = z.looseObject({
204
+ columns: z.array(z.looseObject({
205
+ name: z.string(),
206
+ type: z.string(),
207
+ nullable: z.boolean(),
208
+ default: z.string().nullable(),
209
+ description: z.string().nullable()
210
+ })),
211
+ indexes: z.array(z.looseObject({
212
+ name: z.string(),
213
+ definition: z.string(),
214
+ size: z.string()
215
+ })),
216
+ constraints: z.array(z.looseObject({
217
+ name: z.string(),
218
+ type: z.string(),
219
+ definition: z.string()
220
+ })),
221
+ tableSize: z.string(),
222
+ indexSize: z.string(),
223
+ totalSize: z.string()
224
+ });
225
+ const describeTableOutputSchema = z.looseObject({
226
+ raw: tableSchemaOutputSchema.describe("Columns, indexes, constraints, and sizes."),
227
+ formatted: z.string().describe("The same, as text.")
228
+ });
201
229
  const describeTableTool = (options) => bindTool(options, {
202
230
  operationId: "schema.describeTable",
203
231
  id: publishedId("schema.describeTable"),
204
232
  title: "Describe Table Schema",
205
233
  description: "Returns a table's columns, indexes, constraints, and sizes. For every table, use {{schema.listTables}}.",
206
234
  inputSchema: describeTableInputSchema,
235
+ outputSchema: describeTableOutputSchema,
207
236
  annotations: sqlReadAnnotations,
208
237
  requiresApproval: false,
209
238
  metadata: SQL_METADATA
@@ -211,4 +240,4 @@ const describeTableTool = (options) => bindTool(options, {
211
240
  const connection = await resolveConnection(neonClient, input, context, signal);
212
241
  return describeTableAt(connection.uri, input.table_name, signal);
213
242
  });
214
- export { describeTableAt, describeTableInputSchema, describeTableTool, formatTableDescription, listTablesInputSchema, listTablesTool, sqlReadAnnotations };
243
+ export { describeTableAt, describeTableInputSchema, describeTableTool, formatTableDescription, listTablesInputSchema, listTablesTool, sqlReadAnnotations, tableSchemaOutputSchema };
@@ -39,5 +39,19 @@ export declare const listSlowQueriesTool: (options: ToolClientOptions) => import
39
39
  };
40
40
  }[];
41
41
  total_queries_found: number;
42
- }>;
42
+ }, z.ZodObject<{
43
+ slow_queries: z.ZodArray<z.ZodObject<{
44
+ query: z.ZodUnknown;
45
+ calls: z.ZodUnknown;
46
+ }, z.core.$loose>>;
47
+ total_queries_found: z.ZodNumber;
48
+ }, z.core.$loose>> & {
49
+ outputSchema: z.ZodObject<{
50
+ slow_queries: z.ZodArray<z.ZodObject<{
51
+ query: z.ZodUnknown;
52
+ calls: z.ZodUnknown;
53
+ }, z.core.$loose>>;
54
+ total_queries_found: z.ZodNumber;
55
+ }, z.core.$loose>;
56
+ };
43
57
  //# sourceMappingURL=slow-queries.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"slow-queries.d.ts","sourceRoot":"","sources":["../../../../src/lib/custom/sql/slow-queries.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,yBAAyB,CAAC;AAWjC,eAAO,MAAM,0BAA0B;;;;;;;kBAarC,CAAC;AA+BH,eAAO,MAAM,mBAAmB,GAAI,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+D5D,CAAC"}
1
+ {"version":3,"file":"slow-queries.d.ts","sourceRoot":"","sources":["../../../../src/lib/custom/sql/slow-queries.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,yBAAyB,CAAC;AAWjC,eAAO,MAAM,0BAA0B;;;;;;;kBAarC,CAAC;AAwCH,eAAO,MAAM,mBAAmB,GAAI,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgE5D,CAAC"}