@devpad/api 2.2.9 → 2.2.12

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/dist/index.js CHANGED
@@ -7,7 +7,13 @@ import {
7
7
  upsert_milestone,
8
8
  upsert_project,
9
9
  upsert_todo
10
- } from "./chunk-TEOIDOOX.js";
10
+ } from "./chunk-DIX4XVUQ.js";
11
+ import {
12
+ CategoryCreateSchema,
13
+ PostCreateSchema,
14
+ PostListParamsSchema,
15
+ PostUpdateSchema
16
+ } from "./chunk-5L3AUVMM.js";
11
17
 
12
18
  // src/errors.ts
13
19
  var ApiError = class _ApiError extends Error {
@@ -73,7 +79,7 @@ async function handleResponseError(response) {
73
79
  } catch {
74
80
  }
75
81
  if (response.status === HTTP_STATUS.BAD_REQUEST && parsedError?.error?.name === "ZodError") {
76
- const zodErrorDetails = parsedError.error?.issues ? JSON.stringify(parsedError.error) : errorMessage;
82
+ const zodErrorDetails = parsedError.error.issues ? JSON.stringify(parsedError.error) : errorMessage;
77
83
  throw new ValidationError(zodErrorDetails);
78
84
  }
79
85
  throw new ApiError(errorMessage, { statusCode: response.status });
@@ -91,48 +97,50 @@ function isAuthenticationError(error) {
91
97
  function isNetworkError(error) {
92
98
  return error instanceof NetworkError;
93
99
  }
100
+ function tryParseZodErrorString(errorMessage) {
101
+ const zodErrorMatch = errorMessage.match(/ZodError: (.+)/);
102
+ if (!zodErrorMatch?.[1]) return null;
103
+ try {
104
+ return JSON.parse(zodErrorMatch[1]);
105
+ } catch {
106
+ const issuesMatch = errorMessage.match(/issues:\s*(\[.*\])/s);
107
+ if (!issuesMatch?.[1]) return null;
108
+ try {
109
+ return { issues: JSON.parse(issuesMatch[1]) };
110
+ } catch {
111
+ return null;
112
+ }
113
+ }
114
+ }
94
115
  function parseZodErrors(errorMessage) {
95
116
  try {
96
117
  let parsedError = null;
97
118
  try {
98
119
  parsedError = JSON.parse(errorMessage);
99
120
  } catch {
100
- const zodErrorMatch = errorMessage.match(/ZodError: (.+)/);
101
- if (zodErrorMatch && zodErrorMatch[1]) {
102
- try {
103
- parsedError = JSON.parse(zodErrorMatch[1]);
104
- } catch {
105
- const issuesMatch = errorMessage.match(/issues:\s*(\[.*\])/s);
106
- if (issuesMatch && issuesMatch[1]) {
107
- try {
108
- parsedError = { issues: JSON.parse(issuesMatch[1]) };
109
- } catch {
110
- }
111
- }
112
- }
113
- }
121
+ parsedError = tryParseZodErrorString(errorMessage);
114
122
  }
115
123
  if (parsedError?.issues && Array.isArray(parsedError.issues)) {
116
124
  const friendlyMessages = parsedError.issues.map((issue) => {
117
- const path = issue.path && issue.path.length > 0 ? issue.path.join(".") : "field";
125
+ const path = issue.path.length > 0 ? issue.path.join(".") : "field";
118
126
  const message = issue.message || "is invalid";
119
127
  switch (issue.code) {
120
128
  case "invalid_type":
121
129
  return `${path} must be a ${issue.expected} (received ${issue.received})`;
122
130
  case "too_small":
123
131
  if (issue.type === "string") {
124
- return `${path} must be at least ${issue.minimum} characters long`;
132
+ return `${path} must be at least ${String(issue.minimum)} characters long`;
125
133
  }
126
134
  if (issue.type === "number") {
127
- return `${path} must be at least ${issue.minimum}`;
135
+ return `${path} must be at least ${String(issue.minimum)}`;
128
136
  }
129
137
  return `${path} is too small`;
130
138
  case "too_big":
131
139
  if (issue.type === "string") {
132
- return `${path} must be no more than ${issue.maximum} characters long`;
140
+ return `${path} must be no more than ${String(issue.maximum)} characters long`;
133
141
  }
134
142
  if (issue.type === "number") {
135
- return `${path} must be no more than ${issue.maximum}`;
143
+ return `${path} must be no more than ${String(issue.maximum)}`;
136
144
  }
137
145
  return `${path} is too large`;
138
146
  case "invalid_string":
@@ -148,12 +156,23 @@ function parseZodErrors(errorMessage) {
148
156
  return `${path} format is invalid`;
149
157
  case "custom":
150
158
  return `${path}: ${message}`;
159
+ case "invalid_literal":
160
+ case "unrecognized_keys":
161
+ case "invalid_union":
162
+ case "invalid_union_discriminator":
163
+ case "invalid_enum_value":
164
+ case "invalid_arguments":
165
+ case "invalid_return_type":
166
+ case "invalid_date":
167
+ case "invalid_intersection_types":
168
+ case "not_multiple_of":
169
+ case "not_finite":
151
170
  default:
152
171
  return `${path}: ${message}`;
153
172
  }
154
173
  });
155
174
  if (friendlyMessages.length === 1) {
156
- return friendlyMessages[0];
175
+ return friendlyMessages[0] ?? errorMessage;
157
176
  }
158
177
  return `Validation failed:
159
178
  \u2022 ${friendlyMessages.join("\n\u2022 ")}`;
@@ -187,41 +206,41 @@ function getUserFriendlyErrorMessage(error) {
187
206
 
188
207
  // src/request.ts
189
208
  var ArrayBufferedQueue = class {
190
- constructor(_capacity) {
191
- this._capacity = _capacity;
192
- this._entries = [];
193
- this._head = 0;
194
- this._tail = 0;
195
- this._size = 0;
209
+ constructor(capacity) {
210
+ this.capacity = capacity;
211
+ this.entries = [];
212
+ this.head = 0;
213
+ this.tail = 0;
214
+ this.count = 0;
196
215
  }
197
216
  latest() {
198
- if (this._size === 0) return null;
199
- return this._entries[this._tail - 1] ?? null;
217
+ if (this.count === 0) return null;
218
+ return this.entries[this.tail - 1] ?? null;
200
219
  }
201
220
  list() {
202
- if (this._size === 0) return [];
203
- if (this._head < this._tail) {
204
- return this._entries.slice(this._head, this._tail);
221
+ if (this.count === 0) return [];
222
+ if (this.head < this.tail) {
223
+ return this.entries.slice(this.head, this.tail);
205
224
  }
206
- return this._entries.slice(this._head).concat(this._entries.slice(0, this._tail));
225
+ return this.entries.slice(this.head).concat(this.entries.slice(0, this.tail));
207
226
  }
208
227
  add(item) {
209
- if (this._size === this._capacity) {
210
- this._head = (this._head + 1) % this._capacity;
228
+ if (this.count === this.capacity) {
229
+ this.head = (this.head + 1) % this.capacity;
211
230
  } else {
212
- this._size++;
231
+ this.count++;
213
232
  }
214
- this._entries[this._tail] = item;
215
- this._tail = (this._tail + 1) % this._capacity;
233
+ this.entries[this.tail] = item;
234
+ this.tail = (this.tail + 1) % this.capacity;
216
235
  }
217
236
  size() {
218
- return this._size;
237
+ return this.count;
219
238
  }
220
239
  clear() {
221
- this._entries = [];
222
- this._head = 0;
223
- this._tail = 0;
224
- this._size = 0;
240
+ this.entries = [];
241
+ this.head = 0;
242
+ this.tail = 0;
243
+ this.count = 0;
225
244
  }
226
245
  };
227
246
  var ApiClient = class {
@@ -251,7 +270,7 @@ var ApiClient = class {
251
270
  return url.toString();
252
271
  }
253
272
  generateRequestId() {
254
- return `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
273
+ return `${String(Date.now())}-${Math.random().toString(36).substring(2, 11)}`;
255
274
  }
256
275
  async request(path, options = {}) {
257
276
  const { method = "GET", headers = {}, body, query } = options;
@@ -302,7 +321,7 @@ var ApiClient = class {
302
321
  if (this.debug) {
303
322
  console.log(`[ERROR][${this.category}] ${method} ${path} [${requestId}] failed`, {
304
323
  status: response.status,
305
- duration: `${duration}ms`,
324
+ duration: `${String(duration)}ms`,
306
325
  body,
307
326
  query
308
327
  });
@@ -322,21 +341,21 @@ var ApiClient = class {
322
341
  if (response.status === HTTP_STATUS.NO_CONTENT) {
323
342
  result = void 0;
324
343
  } else {
325
- const text = await response.text();
326
- if (!text || text.trim() === "" || text.trim() === "null") {
344
+ const text2 = await response.text();
345
+ if (!text2 || text2.trim() === "" || text2.trim() === "null") {
327
346
  result = void 0;
328
347
  } else {
329
348
  try {
330
- result = JSON.parse(text);
331
- } catch (parseError) {
332
- result = text;
349
+ result = JSON.parse(text2);
350
+ } catch {
351
+ result = text2;
333
352
  }
334
353
  }
335
354
  }
336
355
  if (this.debug) {
337
356
  console.log(`[INFO][${this.category}] ${method} ${path} [${requestId}] completed`, {
338
357
  status: response.status,
339
- duration: `${duration}ms`
358
+ duration: `${String(duration)}ms`
340
359
  });
341
360
  }
342
361
  return result;
@@ -345,7 +364,7 @@ var ApiClient = class {
345
364
  if (this.debug) {
346
365
  console.log(`[ERROR][${this.category}] ${method} ${path} [${requestId}] failed`, {
347
366
  url,
348
- duration: `${duration}ms`,
367
+ duration: `${String(duration)}ms`,
349
368
  error: error instanceof Error ? error.message : String(error),
350
369
  body,
351
370
  query
@@ -401,12 +420,22 @@ var ApiClient = class {
401
420
 
402
421
  // src/result.ts
403
422
  import { err, ok } from "@f0rbit/corpus";
423
+ var string_field = (value, key) => {
424
+ if (typeof value !== "object" || value === null || !(key in value)) return void 0;
425
+ const field = value[key];
426
+ return typeof field === "string" ? field : void 0;
427
+ };
428
+ var number_field = (value, key) => {
429
+ if (typeof value !== "object" || value === null || !(key in value)) return void 0;
430
+ const field = value[key];
431
+ return typeof field === "number" ? field : void 0;
432
+ };
404
433
  function wrap(fn) {
405
434
  return fn().then((data) => ok(data)).catch(
406
435
  (error) => err({
407
- message: error.message || "Unknown error",
408
- code: error.code,
409
- status_code: error.statusCode || error.status_code
436
+ message: error instanceof Error ? error.message : "Unknown error",
437
+ code: string_field(error, "code"),
438
+ status_code: number_field(error, "statusCode") ?? number_field(error, "status_code")
410
439
  })
411
440
  );
412
441
  }
@@ -425,7 +454,9 @@ var ApiClient2 = class {
425
454
  list: () => wrap(() => this.clients.auth.get("/keys")),
426
455
  create: (input) => {
427
456
  const body = typeof input === "string" ? { name: input } : input ?? {};
428
- return wrap(() => this.clients.auth.post("/keys", { body }));
457
+ return wrap(
458
+ () => this.clients.auth.post("/keys", { body })
459
+ );
429
460
  },
430
461
  revoke: (key_id) => wrap(() => this.clients.auth.delete(`/keys/${key_id}`)),
431
462
  remove: (key_id) => wrap(() => this.clients.auth.delete(`/keys/${key_id}`))
@@ -445,13 +476,10 @@ var ApiClient2 = class {
445
476
  map: async (filters) => wrap(async () => {
446
477
  const result = await this.projects.list(filters);
447
478
  if (!result.ok) throw new Error(result.error.message);
448
- return result.value.reduce(
449
- (acc, project) => {
450
- acc[project.id] = project;
451
- return acc;
452
- },
453
- {}
454
- );
479
+ return result.value.reduce((acc, project) => {
480
+ acc[project.id] = project;
481
+ return acc;
482
+ }, {});
455
483
  }),
456
484
  /**
457
485
  * Get project by ID
@@ -606,7 +634,7 @@ var ApiClient2 = class {
606
634
  find: (id) => wrap(async () => {
607
635
  try {
608
636
  return await this.clients.milestones.get(`/milestones/${id}`);
609
- } catch (error) {
637
+ } catch {
610
638
  return null;
611
639
  }
612
640
  }),
@@ -860,7 +888,10 @@ var ApiClient2 = class {
860
888
  const query = {};
861
889
  if (params?.limit) query.limit = String(params.limit);
862
890
  if (params?.before) query.before = params.before;
863
- return this.clients.media.get(`/profiles/${slug}/timeline`, Object.keys(query).length ? { query } : {});
891
+ return this.clients.media.get(
892
+ `/profiles/${slug}/timeline`,
893
+ Object.keys(query).length ? { query } : {}
894
+ );
864
895
  })
865
896
  },
866
897
  connections: {
@@ -900,8 +931,12 @@ var ApiClient2 = class {
900
931
  check: (platform, profile_id) => wrap(
901
932
  () => this.clients.media.get(`/credentials/${platform}`, { query: { profile_id } })
902
933
  ),
903
- save: (platform, data) => wrap(() => this.clients.media.post(`/credentials/${platform}`, { body: data })),
904
- delete: (platform, profile_id) => wrap(() => this.clients.media.delete(`/credentials/${platform}`, { query: { profile_id } }))
934
+ save: (platform, data) => wrap(
935
+ () => this.clients.media.post(`/credentials/${platform}`, { body: data })
936
+ ),
937
+ delete: (platform, profile_id) => wrap(
938
+ () => this.clients.media.delete(`/credentials/${platform}`, { query: { profile_id } })
939
+ )
905
940
  },
906
941
  timeline: {
907
942
  get: (user_id, params) => wrap(() => {
@@ -925,7 +960,10 @@ var ApiClient2 = class {
925
960
  const query = {};
926
961
  if (options?.limit) query.limit = String(options.limit);
927
962
  if (options?.since) query.since = options.since;
928
- return this.clients.projects.get("/activity/ai", Object.keys(query).length ? { query } : {});
963
+ return this.clients.projects.get(
964
+ "/activity/ai",
965
+ Object.keys(query).length ? { query } : {}
966
+ );
929
967
  })
930
968
  };
931
969
  this.user = {
@@ -936,7 +974,11 @@ var ApiClient2 = class {
936
974
  /**
937
975
  * Update user preferences
938
976
  */
939
- preferences: (data) => wrap(() => this.clients.auth.patch("/user/preferences", { body: data }))
977
+ preferences: (data) => wrap(
978
+ () => this.clients.auth.patch("/user/preferences", {
979
+ body: data
980
+ })
981
+ )
940
982
  };
941
983
  /**
942
984
  * Pulse analytics and monitoring namespace
@@ -962,7 +1004,9 @@ var ApiClient2 = class {
962
1004
  if (input.search) query.search = input.search;
963
1005
  if (input.limit) query.limit = String(input.limit);
964
1006
  if (input.cursor) query.cursor = input.cursor;
965
- return this.clients.pulse.get("/events/:project_id".replace(":project_id", input.project_id), { query });
1007
+ return this.clients.pulse.get("/events/:project_id".replace(":project_id", input.project_id), {
1008
+ query
1009
+ });
966
1010
  }),
967
1011
  /**
968
1012
  * List error issues for a project
@@ -976,7 +1020,9 @@ var ApiClient2 = class {
976
1020
  query.to = String(input.range.to);
977
1021
  }
978
1022
  if (input.group_by_fingerprint) query.group_by_fingerprint = "true";
979
- return this.clients.pulse.get("/errors/:project_id".replace(":project_id", input.project_id), { query });
1023
+ return this.clients.pulse.get("/errors/:project_id".replace(":project_id", input.project_id), {
1024
+ query
1025
+ });
980
1026
  }),
981
1027
  /**
982
1028
  * List logs for a project
@@ -1006,7 +1052,9 @@ var ApiClient2 = class {
1006
1052
  }
1007
1053
  if (input.route) query.route = input.route;
1008
1054
  if (input.percentiles && input.percentiles.length > 0) query.percentiles = input.percentiles.join(",");
1009
- return this.clients.pulse.get("/latency/:project_id".replace(":project_id", input.project_id), { query });
1055
+ return this.clients.pulse.get("/latency/:project_id".replace(":project_id", input.project_id), {
1056
+ query
1057
+ });
1010
1058
  }),
1011
1059
  /**
1012
1060
  * Subscription management
@@ -1066,7 +1114,11 @@ var ApiClient2 = class {
1066
1114
  /**
1067
1115
  * Delete an ingest key
1068
1116
  */
1069
- delete: (id, input) => wrap(() => this.clients.pulse.delete(`/admin/keys/${id}`, { query: { project_id: input.project_id } }))
1117
+ delete: (id, input) => wrap(
1118
+ () => this.clients.pulse.delete(`/admin/keys/${id}`, {
1119
+ query: { project_id: input.project_id }
1120
+ })
1121
+ )
1070
1122
  }
1071
1123
  };
1072
1124
  /**
@@ -1088,7 +1140,12 @@ var ApiClient2 = class {
1088
1140
  get: (input) => {
1089
1141
  const query = { project_id: input.project_id };
1090
1142
  if (input.window_ms !== void 0) query.window_ms = String(input.window_ms);
1091
- return wrap(() => this.clients.pipelines.get("/pipelines/dashboard", { query }));
1143
+ return wrap(
1144
+ () => this.clients.pipelines.get(
1145
+ "/pipelines/dashboard",
1146
+ { query }
1147
+ )
1148
+ );
1092
1149
  }
1093
1150
  },
1094
1151
  /**
@@ -1101,7 +1158,9 @@ var ApiClient2 = class {
1101
1158
  if (filter?.package_id !== void 0) query.package_id = filter.package_id;
1102
1159
  if (filter?.status !== void 0) query.status = filter.status;
1103
1160
  if (filter?.limit !== void 0) query.limit = String(filter.limit);
1104
- return wrap(() => this.clients.pipelines.get("/runs", Object.keys(query).length > 0 ? { query } : void 0));
1161
+ return wrap(
1162
+ () => this.clients.pipelines.get("/runs", Object.keys(query).length > 0 ? { query } : void 0)
1163
+ );
1105
1164
  },
1106
1165
  /**
1107
1166
  * Get a pipeline run by ID
@@ -1144,7 +1203,11 @@ var ApiClient2 = class {
1144
1203
  * `list` is read-only and returns the run's events newest-first.
1145
1204
  */
1146
1205
  events: {
1147
- ingest: (run_id, input) => wrap(() => this.clients.pipelines.post(`/runs/${run_id}/events`, { body: input })),
1206
+ ingest: (run_id, input) => wrap(
1207
+ () => this.clients.pipelines.post(`/runs/${run_id}/events`, {
1208
+ body: input
1209
+ })
1210
+ ),
1148
1211
  list: (run_id) => wrap(() => this.clients.pipelines.get(`/runs/${run_id}/events`))
1149
1212
  },
1150
1213
  /**
@@ -1189,7 +1252,12 @@ var ApiClient2 = class {
1189
1252
  list: (filter) => {
1190
1253
  const query = {};
1191
1254
  if (filter?.project_id !== void 0) query.project_id = filter.project_id;
1192
- return wrap(() => this.clients.pipelines.get("/packages", Object.keys(query).length > 0 ? { query } : void 0));
1255
+ return wrap(
1256
+ () => this.clients.pipelines.get(
1257
+ "/packages",
1258
+ Object.keys(query).length > 0 ? { query } : void 0
1259
+ )
1260
+ );
1193
1261
  },
1194
1262
  /**
1195
1263
  * Get a single package by id
@@ -1224,12 +1292,20 @@ var ApiClient2 = class {
1224
1292
  /**
1225
1293
  * List templates for an owner.
1226
1294
  */
1227
- list: (input) => wrap(() => this.clients.pipelines.get("/analysis-templates", { query: { owner_id: input.owner_id } })),
1295
+ list: (input) => wrap(
1296
+ () => this.clients.pipelines.get("/analysis-templates", {
1297
+ query: { owner_id: input.owner_id }
1298
+ })
1299
+ ),
1228
1300
  /**
1229
1301
  * Get a single template by id, scoped to its owner. 404 when
1230
1302
  * unknown or owned by a different user.
1231
1303
  */
1232
- get: (id, input) => wrap(() => this.clients.pipelines.get(`/analysis-templates/${id}`, { query: { owner_id: input.owner_id } })),
1304
+ get: (id, input) => wrap(
1305
+ () => this.clients.pipelines.get(`/analysis-templates/${id}`, {
1306
+ query: { owner_id: input.owner_id }
1307
+ })
1308
+ ),
1233
1309
  /**
1234
1310
  * Create a new analysis template. `threshold_dsl` is parsed
1235
1311
  * server-side; parse failure returns 400 `validation_error`
@@ -1242,14 +1318,20 @@ var ApiClient2 = class {
1242
1318
  * Re-validates `threshold_dsl` when supplied; same
1243
1319
  * `validation_error` shape as create on parse failure.
1244
1320
  */
1245
- update: (id, input) => wrap(() => this.clients.pipelines.patch(`/analysis-templates/${id}`, { body: input })),
1321
+ update: (id, input) => wrap(
1322
+ () => this.clients.pipelines.patch(`/analysis-templates/${id}`, { body: input })
1323
+ ),
1246
1324
  /**
1247
1325
  * Hard-delete the template. Does NOT consult
1248
1326
  * `pipeline_run.resolved_gates` — runs snapshot their gate
1249
1327
  * template at resolve-time, so deletion never orphans
1250
1328
  * in-flight runs.
1251
1329
  */
1252
- delete: (id, input) => wrap(() => this.clients.pipelines.delete(`/analysis-templates/${id}`, { query: { owner_id: input.owner_id } }))
1330
+ delete: (id, input) => wrap(
1331
+ () => this.clients.pipelines.delete(`/analysis-templates/${id}`, {
1332
+ query: { owner_id: input.owner_id }
1333
+ })
1334
+ )
1253
1335
  },
1254
1336
  /**
1255
1337
  * OIDC trust-policy namespace — admin-gated CRUD for the
@@ -1264,12 +1346,16 @@ var ApiClient2 = class {
1264
1346
  * matches the trust-matcher resolution order so the management UI
1265
1347
  * shows the policy that would be picked first.
1266
1348
  */
1267
- list: (input) => wrap(() => this.clients.pipelines.get("/oidc-trust", { query: { owner_id: input.owner_id } })),
1349
+ list: (input) => wrap(
1350
+ () => this.clients.pipelines.get("/oidc-trust", { query: { owner_id: input.owner_id } })
1351
+ ),
1268
1352
  /**
1269
1353
  * Get a single policy by id, scoped to its owner. 404 when
1270
1354
  * unknown, soft-deleted, or owned by a different user.
1271
1355
  */
1272
- get: (id, input) => wrap(() => this.clients.pipelines.get(`/oidc-trust/${id}`, { query: { owner_id: input.owner_id } })),
1356
+ get: (id, input) => wrap(
1357
+ () => this.clients.pipelines.get(`/oidc-trust/${id}`, { query: { owner_id: input.owner_id } })
1358
+ ),
1273
1359
  /**
1274
1360
  * Create a new policy. Defaults per plan §I.5: `repo_pattern: "*"`,
1275
1361
  * `allowed_actions: ["artifacts:upload","runs:start"]`,
@@ -1286,17 +1372,21 @@ var ApiClient2 = class {
1286
1372
  * audit). The matcher and management list both skip soft-deleted
1287
1373
  * rows.
1288
1374
  */
1289
- delete: (id, input) => wrap(() => this.clients.pipelines.delete(`/oidc-trust/${id}`, { query: { owner_id: input.owner_id } }))
1375
+ delete: (id, input) => wrap(
1376
+ () => this.clients.pipelines.delete(`/oidc-trust/${id}`, {
1377
+ query: { owner_id: input.owner_id }
1378
+ })
1379
+ )
1290
1380
  }
1291
1381
  };
1292
1382
  const base_url = options.base_url || "http://localhost:4321/api/v1";
1293
- this._api_key = options.api_key ?? "";
1294
- this._auth_mode = options.auth_mode ?? (options.api_key?.startsWith("jwt:") ? "session" : options.api_key ? "key" : "cookie");
1383
+ this.api_key_field = options.api_key ?? "";
1384
+ this.auth_mode_field = options.auth_mode ?? (options.api_key?.startsWith("jwt:") ? "session" : options.api_key ? "key" : "cookie");
1295
1385
  const clientOptions = {
1296
1386
  base_url,
1297
1387
  api_key: options.api_key,
1298
1388
  max_history_size: options.max_history_size,
1299
- auth_mode: this._auth_mode,
1389
+ auth_mode: this.auth_mode_field,
1300
1390
  credentials: options.credentials,
1301
1391
  default_headers: options.default_headers,
1302
1392
  custom_fetch: options.custom_fetch
@@ -1331,16 +1421,66 @@ var ApiClient2 = class {
1331
1421
  * Get the API key
1332
1422
  */
1333
1423
  getApiKey() {
1334
- return this._api_key;
1424
+ return this.api_key_field;
1335
1425
  }
1336
1426
  /**
1337
1427
  * Get the authentication mode
1338
1428
  */
1339
1429
  getAuthMode() {
1340
- return this._auth_mode;
1430
+ return this.auth_mode_field;
1341
1431
  }
1342
1432
  };
1343
1433
 
1434
+ // ../schema/dist/blog/index.js
1435
+ import { create_cloudflare_backend, create_corpus, create_memory_backend, define_store, err as err2, json_codec, ok as ok2 } from "@f0rbit/corpus";
1436
+
1437
+ // ../schema/dist/database/blog.js
1438
+ import { sql } from "drizzle-orm";
1439
+ import { integer, primaryKey, sqliteTable, text, unique } from "drizzle-orm/sqlite-core";
1440
+ var blog_posts = sqliteTable("blog_posts", {
1441
+ id: integer("id").primaryKey({ autoIncrement: true }),
1442
+ uuid: text("uuid").notNull().unique(),
1443
+ author_id: text("author_id").notNull(),
1444
+ slug: text("slug").notNull(),
1445
+ corpus_version: text("corpus_version"),
1446
+ category: text("category").notNull().default("root"),
1447
+ archived: integer("archived", { mode: "boolean" }).notNull().default(false),
1448
+ publish_at: integer("publish_at", { mode: "timestamp" }),
1449
+ created_at: integer("created_at", { mode: "timestamp" }).notNull().default(sql`(unixepoch())`),
1450
+ updated_at: integer("updated_at", { mode: "timestamp" }).notNull().default(sql`(unixepoch())`)
1451
+ }, (table) => [unique("posts_author_slug_unique").on(table.author_id, table.slug)]);
1452
+ var blog_categories = sqliteTable("blog_categories", {
1453
+ id: integer("id").primaryKey({ autoIncrement: true }),
1454
+ owner_id: text("owner_id").notNull(),
1455
+ name: text("name").notNull(),
1456
+ parent: text("parent").default("root")
1457
+ }, (table) => [unique("categories_owner_name_unique").on(table.owner_id, table.name)]);
1458
+ var blog_tags = sqliteTable("blog_tags", {
1459
+ post_id: integer("post_id").notNull().references(() => blog_posts.id, { onDelete: "cascade" }),
1460
+ tag: text("tag").notNull()
1461
+ }, (table) => [primaryKey({ columns: [table.post_id, table.tag] })]);
1462
+ var blog_integrations = sqliteTable("blog_integrations", {
1463
+ id: integer("id").primaryKey({ autoIncrement: true }),
1464
+ user_id: text("user_id").notNull(),
1465
+ source: text("source").notNull(),
1466
+ location: text("location").notNull(),
1467
+ data: text("data", { mode: "json" }).$type(),
1468
+ last_fetch: integer("last_fetch", { mode: "timestamp" }),
1469
+ status: text("status").default("pending"),
1470
+ created_at: integer("created_at", { mode: "timestamp" }).notNull().default(sql`(unixepoch())`)
1471
+ });
1472
+ var blog_fetch_links = sqliteTable("blog_fetch_links", {
1473
+ id: integer("id").primaryKey({ autoIncrement: true }),
1474
+ post_id: integer("post_id").notNull().references(() => blog_posts.id, { onDelete: "cascade" }),
1475
+ integration_id: integer("integration_id").notNull().references(() => blog_integrations.id, { onDelete: "cascade" }),
1476
+ identifier: text("identifier").notNull()
1477
+ }, (table) => [unique("fetch_links_integration_identifier_unique").on(table.integration_id, table.identifier)]);
1478
+ var blog_post_projects = sqliteTable("blog_post_projects", {
1479
+ post_id: integer("post_id").notNull().references(() => blog_posts.id, { onDelete: "cascade" }),
1480
+ project_id: text("project_id").notNull(),
1481
+ created_at: integer("created_at", { mode: "timestamp" }).notNull().default(sql`(unixepoch())`)
1482
+ }, (table) => [primaryKey({ columns: [table.post_id, table.project_id] })]);
1483
+
1344
1484
  // src/tools.ts
1345
1485
  import { z } from "zod";
1346
1486
  function unwrap(result) {
@@ -1376,27 +1516,32 @@ var github_branches = z.object({
1376
1516
  owner: z.string().describe("Repository owner"),
1377
1517
  repo: z.string().describe("Repository name")
1378
1518
  });
1519
+ var define_tool = (def) => def;
1379
1520
  var tools = {
1380
1521
  // Projects
1381
- devpad_projects_list: {
1522
+ devpad_projects_list: define_tool({
1382
1523
  name: "devpad_projects_list",
1383
1524
  description: "List all projects (or only public ones)",
1384
1525
  inputSchema: project_filters,
1385
1526
  execute: async (client, input) => unwrap(await client.projects.list(input))
1386
- },
1387
- devpad_projects_get: {
1527
+ }),
1528
+ devpad_projects_get: define_tool({
1388
1529
  name: "devpad_projects_get",
1389
1530
  description: "Get project by ID or name",
1390
1531
  inputSchema: project_by_id_or_name,
1391
- execute: async (client, input) => unwrap(input.id ? await client.projects.getById(input.id) : await client.projects.getByName(input.name))
1392
- },
1393
- devpad_projects_upsert: {
1532
+ execute: async (client, input) => {
1533
+ if (input.id) return unwrap(await client.projects.getById(input.id));
1534
+ if (!input.name) throw new Error("either id or name must be provided");
1535
+ return unwrap(await client.projects.getByName(input.name));
1536
+ }
1537
+ }),
1538
+ devpad_projects_upsert: define_tool({
1394
1539
  name: "devpad_projects_upsert",
1395
1540
  description: "Create or update a project (set deleted=true to delete). Returns 409 if entity is protected by user - pass force=true to override.",
1396
1541
  inputSchema: upsert_project,
1397
1542
  execute: async (client, input) => unwrap(await client.projects.upsert(input))
1398
- },
1399
- devpad_projects_config_save: {
1543
+ }),
1544
+ devpad_projects_config_save: define_tool({
1400
1545
  name: "devpad_projects_config_save",
1401
1546
  description: "Save project configuration",
1402
1547
  inputSchema: save_config_request,
@@ -1404,27 +1549,27 @@ var tools = {
1404
1549
  unwrap(await client.projects.config.save(input));
1405
1550
  return { success: true };
1406
1551
  }
1407
- },
1552
+ }),
1408
1553
  // Tasks
1409
- devpad_tasks_list: {
1554
+ devpad_tasks_list: define_tool({
1410
1555
  name: "devpad_tasks_list",
1411
1556
  description: "List tasks, optionally filtered by project or tag",
1412
1557
  inputSchema: task_filters,
1413
1558
  execute: async (client, input) => unwrap(await client.tasks.list(input))
1414
- },
1415
- devpad_tasks_get: {
1559
+ }),
1560
+ devpad_tasks_get: define_tool({
1416
1561
  name: "devpad_tasks_get",
1417
1562
  description: "Get task by ID",
1418
1563
  inputSchema: task_by_id,
1419
1564
  execute: async (client, input) => unwrap(await client.tasks.find(input.id))
1420
- },
1421
- devpad_tasks_upsert: {
1565
+ }),
1566
+ devpad_tasks_upsert: define_tool({
1422
1567
  name: "devpad_tasks_upsert",
1423
1568
  description: "Create or update a task (set deleted=true to delete). Returns 409 if entity is protected by user - pass force=true to override.",
1424
1569
  inputSchema: upsert_todo,
1425
1570
  execute: async (client, input) => unwrap(await client.tasks.upsert(input))
1426
- },
1427
- devpad_tasks_save_tags: {
1571
+ }),
1572
+ devpad_tasks_save_tags: define_tool({
1428
1573
  name: "devpad_tasks_save_tags",
1429
1574
  description: "Save tags for tasks",
1430
1575
  inputSchema: save_tags_request,
@@ -1432,21 +1577,23 @@ var tools = {
1432
1577
  unwrap(await client.tasks.saveTags(input));
1433
1578
  return { success: true };
1434
1579
  }
1435
- },
1580
+ }),
1436
1581
  // Milestones
1437
- devpad_milestones_list: {
1582
+ devpad_milestones_list: define_tool({
1438
1583
  name: "devpad_milestones_list",
1439
1584
  description: "List milestones for authenticated user or by project",
1440
1585
  inputSchema: milestone_filters,
1441
- execute: async (client, input) => unwrap(input.project_id ? await client.milestones.getByProject(input.project_id) : await client.milestones.list())
1442
- },
1443
- devpad_milestones_get: {
1586
+ execute: async (client, input) => unwrap(
1587
+ input.project_id ? await client.milestones.getByProject(input.project_id) : await client.milestones.list()
1588
+ )
1589
+ }),
1590
+ devpad_milestones_get: define_tool({
1444
1591
  name: "devpad_milestones_get",
1445
1592
  description: "Get milestone by ID",
1446
1593
  inputSchema: milestone_by_id,
1447
1594
  execute: async (client, input) => unwrap(await client.milestones.find(input.id))
1448
- },
1449
- devpad_milestones_upsert: {
1595
+ }),
1596
+ devpad_milestones_upsert: define_tool({
1450
1597
  name: "devpad_milestones_upsert",
1451
1598
  description: "Create or update a milestone. Returns 409 if entity is protected by user - pass force=true to override.",
1452
1599
  inputSchema: upsert_milestone,
@@ -1466,21 +1613,21 @@ var tools = {
1466
1613
  finished_at: input.finished_at
1467
1614
  })
1468
1615
  )
1469
- },
1616
+ }),
1470
1617
  // Goals
1471
- devpad_goals_list: {
1618
+ devpad_goals_list: define_tool({
1472
1619
  name: "devpad_goals_list",
1473
1620
  description: "List goals for authenticated user",
1474
1621
  inputSchema: z.object({}),
1475
1622
  execute: async (client) => unwrap(await client.goals.list())
1476
- },
1477
- devpad_goals_get: {
1623
+ }),
1624
+ devpad_goals_get: define_tool({
1478
1625
  name: "devpad_goals_get",
1479
1626
  description: "Get goal by ID",
1480
1627
  inputSchema: goal_by_id,
1481
1628
  execute: async (client, input) => unwrap(await client.goals.find(input.id))
1482
- },
1483
- devpad_goals_upsert: {
1629
+ }),
1630
+ devpad_goals_upsert: define_tool({
1484
1631
  name: "devpad_goals_upsert",
1485
1632
  description: "Create or update a goal. Returns 409 if entity is protected by user - pass force=true to override.",
1486
1633
  inputSchema: upsert_goal,
@@ -1498,29 +1645,29 @@ var tools = {
1498
1645
  finished_at: input.finished_at
1499
1646
  })
1500
1647
  )
1501
- },
1648
+ }),
1502
1649
  // Tags
1503
- devpad_tags_list: {
1650
+ devpad_tags_list: define_tool({
1504
1651
  name: "devpad_tags_list",
1505
1652
  description: "List tags for authenticated user",
1506
1653
  inputSchema: z.object({}),
1507
1654
  execute: async (client) => unwrap(await client.tags.list())
1508
- },
1655
+ }),
1509
1656
  // GitHub integration
1510
- devpad_github_repos: {
1657
+ devpad_github_repos: define_tool({
1511
1658
  name: "devpad_github_repos",
1512
1659
  description: "List GitHub repositories for authenticated user",
1513
1660
  inputSchema: z.object({}),
1514
1661
  execute: async (client) => unwrap(await client.github.repos())
1515
- },
1516
- devpad_github_branches: {
1662
+ }),
1663
+ devpad_github_branches: define_tool({
1517
1664
  name: "devpad_github_branches",
1518
1665
  description: "List branches for a GitHub repository",
1519
1666
  inputSchema: github_branches,
1520
1667
  execute: async (client, input) => unwrap(await client.github.branches(input.owner, input.repo))
1521
- },
1668
+ }),
1522
1669
  // Additional project operations
1523
- devpad_projects_delete: {
1670
+ devpad_projects_delete: define_tool({
1524
1671
  name: "devpad_projects_delete",
1525
1672
  description: "Delete a project",
1526
1673
  inputSchema: z.object({
@@ -1532,59 +1679,59 @@ var tools = {
1532
1679
  unwrap(await client.projects.deleteProject(project));
1533
1680
  return { success: true };
1534
1681
  }
1535
- },
1536
- devpad_projects_history: {
1682
+ }),
1683
+ devpad_projects_history: define_tool({
1537
1684
  name: "devpad_projects_history",
1538
1685
  description: "Get project history",
1539
1686
  inputSchema: z.object({
1540
1687
  project_id: z.string().describe("Project ID")
1541
1688
  }),
1542
1689
  execute: async (client, input) => unwrap(await client.projects.history(input.project_id))
1543
- },
1544
- devpad_projects_specification: {
1690
+ }),
1691
+ devpad_projects_specification: define_tool({
1545
1692
  name: "devpad_projects_specification",
1546
1693
  description: "Fetch project specification from GitHub",
1547
1694
  inputSchema: z.object({
1548
1695
  project_id: z.string().describe("Project ID")
1549
1696
  }),
1550
1697
  execute: async (client, input) => unwrap(await client.projects.specification(input.project_id))
1551
- },
1552
- devpad_projects_config_load: {
1698
+ }),
1699
+ devpad_projects_config_load: define_tool({
1553
1700
  name: "devpad_projects_config_load",
1554
1701
  description: "Load project configuration",
1555
1702
  inputSchema: z.object({
1556
1703
  project_id: z.string().describe("Project ID")
1557
1704
  }),
1558
1705
  execute: async (client, input) => unwrap(await client.projects.config.load(input.project_id))
1559
- },
1706
+ }),
1560
1707
  // Additional milestone operations
1561
- devpad_milestones_delete: {
1708
+ devpad_milestones_delete: define_tool({
1562
1709
  name: "devpad_milestones_delete",
1563
1710
  description: "Delete a milestone",
1564
1711
  inputSchema: z.object({
1565
1712
  id: z.string().describe("Milestone ID")
1566
1713
  }),
1567
1714
  execute: async (client, input) => unwrap(await client.milestones.delete(input.id))
1568
- },
1569
- devpad_milestones_goals: {
1715
+ }),
1716
+ devpad_milestones_goals: define_tool({
1570
1717
  name: "devpad_milestones_goals",
1571
1718
  description: "Get goals for a milestone",
1572
1719
  inputSchema: z.object({
1573
1720
  id: z.string().describe("Milestone ID")
1574
1721
  }),
1575
1722
  execute: async (client, input) => unwrap(await client.milestones.goals(input.id))
1576
- },
1723
+ }),
1577
1724
  // Additional goal operations
1578
- devpad_goals_delete: {
1725
+ devpad_goals_delete: define_tool({
1579
1726
  name: "devpad_goals_delete",
1580
1727
  description: "Delete a goal",
1581
1728
  inputSchema: z.object({
1582
1729
  id: z.string().describe("Goal ID")
1583
1730
  }),
1584
1731
  execute: async (client, input) => unwrap(await client.goals.delete(input.id))
1585
- },
1732
+ }),
1586
1733
  // Additional task operations
1587
- devpad_tasks_delete: {
1734
+ devpad_tasks_delete: define_tool({
1588
1735
  name: "devpad_tasks_delete",
1589
1736
  description: "Delete a task",
1590
1737
  inputSchema: z.object({
@@ -1596,23 +1743,23 @@ var tools = {
1596
1743
  unwrap(await client.tasks.deleteTask(task));
1597
1744
  return { success: true };
1598
1745
  }
1599
- },
1600
- devpad_tasks_history: {
1746
+ }),
1747
+ devpad_tasks_history: define_tool({
1601
1748
  name: "devpad_tasks_history",
1602
1749
  description: "Get task history",
1603
1750
  inputSchema: z.object({
1604
1751
  task_id: z.string().describe("Task ID")
1605
1752
  }),
1606
1753
  execute: async (client, input) => unwrap(await client.tasks.history.get(input.task_id))
1607
- },
1754
+ }),
1608
1755
  // User operations
1609
- devpad_user_history: {
1756
+ devpad_user_history: define_tool({
1610
1757
  name: "devpad_user_history",
1611
1758
  description: "Get user activity history",
1612
1759
  inputSchema: z.object({}),
1613
1760
  execute: async (client) => unwrap(await client.user.history())
1614
- },
1615
- devpad_user_preferences: {
1761
+ }),
1762
+ devpad_user_preferences: define_tool({
1616
1763
  name: "devpad_user_preferences",
1617
1764
  description: "Update user preferences",
1618
1765
  inputSchema: z.object({
@@ -1620,8 +1767,8 @@ var tools = {
1620
1767
  task_view: z.enum(["list", "grid"]).describe("Task view preference")
1621
1768
  }),
1622
1769
  execute: async (client, input) => unwrap(await client.user.preferences(input))
1623
- },
1624
- devpad_activity_ai: {
1770
+ }),
1771
+ devpad_activity_ai: define_tool({
1625
1772
  name: "devpad_activity_ai",
1626
1773
  description: "Get AI activity feed - shows recent actions made via API/MCP grouped into sessions by time window",
1627
1774
  inputSchema: z.object({
@@ -1629,104 +1776,69 @@ var tools = {
1629
1776
  since: z.string().optional().describe("Only show activity after this ISO date")
1630
1777
  }),
1631
1778
  execute: async (client, input) => unwrap(await client.activity.ai(input))
1632
- },
1633
- devpad_blog_posts_list: {
1779
+ }),
1780
+ devpad_blog_posts_list: define_tool({
1634
1781
  name: "devpad_blog_posts_list",
1635
1782
  description: "List blog posts with optional filters",
1636
- inputSchema: z.object({
1637
- category: z.string().optional().describe("Filter by category"),
1638
- tag: z.string().optional().describe("Filter by tag"),
1639
- project: z.string().optional().describe("Filter by project ID"),
1640
- status: z.enum(["draft", "published"]).optional().describe("Filter by status"),
1641
- archived: z.boolean().optional().describe("Filter by archived state"),
1642
- limit: z.number().optional().describe("Max posts to return"),
1643
- offset: z.number().optional().describe("Offset for pagination"),
1644
- sort: z.string().optional().describe("Sort order")
1645
- }),
1783
+ inputSchema: PostListParamsSchema.partial(),
1646
1784
  execute: async (client, input) => unwrap(await client.blog.posts.list(input))
1647
- },
1648
- devpad_blog_posts_get: {
1785
+ }),
1786
+ devpad_blog_posts_get: define_tool({
1649
1787
  name: "devpad_blog_posts_get",
1650
1788
  description: "Get a blog post by slug",
1651
1789
  inputSchema: z.object({
1652
1790
  slug: z.string().describe("Post slug")
1653
1791
  }),
1654
1792
  execute: async (client, input) => unwrap(await client.blog.posts.getBySlug(input.slug))
1655
- },
1656
- devpad_blog_posts_create: {
1793
+ }),
1794
+ devpad_blog_posts_create: define_tool({
1657
1795
  name: "devpad_blog_posts_create",
1658
1796
  description: "Create a new blog post",
1659
- inputSchema: z.object({
1660
- title: z.string().describe("Post title"),
1661
- content: z.string().describe("Post content"),
1662
- format: z.enum(["markdown", "html"]).describe("Content format"),
1663
- slug: z.string().optional().describe("Custom slug"),
1664
- category: z.string().optional().describe("Category name"),
1665
- tags: z.array(z.string()).optional().describe("Tag names"),
1666
- description: z.string().optional().describe("Post description"),
1667
- publish_at: z.string().optional().describe("Scheduled publish date (ISO string)"),
1668
- project_ids: z.array(z.string()).optional().describe("Associated project IDs"),
1669
- archived: z.boolean().optional().describe("Whether post is archived")
1670
- }),
1797
+ inputSchema: PostCreateSchema,
1671
1798
  execute: async (client, input) => unwrap(await client.blog.posts.create(input))
1672
- },
1673
- devpad_blog_posts_update: {
1799
+ }),
1800
+ devpad_blog_posts_update: define_tool({
1674
1801
  name: "devpad_blog_posts_update",
1675
1802
  description: "Update a blog post by UUID",
1676
- inputSchema: z.object({
1677
- uuid: z.string().describe("Post UUID"),
1678
- title: z.string().optional().describe("Post title"),
1679
- content: z.string().optional().describe("Post content"),
1680
- format: z.enum(["markdown", "html"]).optional().describe("Content format"),
1681
- slug: z.string().optional().describe("Custom slug"),
1682
- category: z.string().optional().describe("Category name"),
1683
- tags: z.array(z.string()).optional().describe("Tag names"),
1684
- description: z.string().optional().describe("Post description"),
1685
- publish_at: z.string().optional().describe("Scheduled publish date (ISO string)"),
1686
- project_ids: z.array(z.string()).optional().describe("Associated project IDs"),
1687
- archived: z.boolean().optional().describe("Whether post is archived")
1688
- }),
1803
+ inputSchema: PostUpdateSchema.extend({ uuid: z.string().describe("Post UUID") }),
1689
1804
  execute: async (client, input) => {
1690
1805
  const { uuid, ...data } = input;
1691
1806
  return unwrap(await client.blog.posts.update(uuid, data));
1692
1807
  }
1693
- },
1694
- devpad_blog_posts_delete: {
1808
+ }),
1809
+ devpad_blog_posts_delete: define_tool({
1695
1810
  name: "devpad_blog_posts_delete",
1696
1811
  description: "Delete a blog post by UUID",
1697
1812
  inputSchema: z.object({
1698
1813
  uuid: z.string().describe("Post UUID")
1699
1814
  }),
1700
1815
  execute: async (client, input) => unwrap(await client.blog.posts.delete(input.uuid))
1701
- },
1702
- devpad_blog_tags_list: {
1816
+ }),
1817
+ devpad_blog_tags_list: define_tool({
1703
1818
  name: "devpad_blog_tags_list",
1704
1819
  description: "List all blog tags with post counts",
1705
1820
  inputSchema: z.object({}),
1706
1821
  execute: async (client) => unwrap(await client.blog.tags.list())
1707
- },
1708
- devpad_blog_categories_tree: {
1822
+ }),
1823
+ devpad_blog_categories_tree: define_tool({
1709
1824
  name: "devpad_blog_categories_tree",
1710
1825
  description: "Get the blog category tree",
1711
1826
  inputSchema: z.object({}),
1712
1827
  execute: async (client) => unwrap(await client.blog.categories.tree())
1713
- },
1714
- devpad_blog_categories_create: {
1828
+ }),
1829
+ devpad_blog_categories_create: define_tool({
1715
1830
  name: "devpad_blog_categories_create",
1716
1831
  description: "Create a blog category",
1717
- inputSchema: z.object({
1718
- name: z.string().describe("Category name"),
1719
- parent: z.string().optional().describe("Parent category name")
1720
- }),
1832
+ inputSchema: CategoryCreateSchema,
1721
1833
  execute: async (client, input) => unwrap(await client.blog.categories.create(input))
1722
- },
1723
- devpad_blog_tokens_list: {
1834
+ }),
1835
+ devpad_blog_tokens_list: define_tool({
1724
1836
  name: "devpad_blog_tokens_list",
1725
1837
  description: "List blog access tokens",
1726
1838
  inputSchema: z.object({}),
1727
1839
  execute: async (client) => unwrap(await client.blog.tokens.list())
1728
- },
1729
- devpad_blog_tokens_create: {
1840
+ }),
1841
+ devpad_blog_tokens_create: define_tool({
1730
1842
  name: "devpad_blog_tokens_create",
1731
1843
  description: "Create a blog access token",
1732
1844
  inputSchema: z.object({
@@ -1734,14 +1846,14 @@ var tools = {
1734
1846
  note: z.string().optional().describe("Optional note")
1735
1847
  }),
1736
1848
  execute: async (client, input) => unwrap(await client.blog.tokens.create(input))
1737
- },
1738
- devpad_media_profiles_list: {
1849
+ }),
1850
+ devpad_media_profiles_list: define_tool({
1739
1851
  name: "devpad_media_profiles_list",
1740
1852
  description: "List media profiles",
1741
1853
  inputSchema: z.object({}),
1742
1854
  execute: async (client) => unwrap(await client.media.profiles.list())
1743
- },
1744
- devpad_media_profiles_create: {
1855
+ }),
1856
+ devpad_media_profiles_create: define_tool({
1745
1857
  name: "devpad_media_profiles_create",
1746
1858
  description: "Create a media profile",
1747
1859
  inputSchema: z.object({
@@ -1749,16 +1861,16 @@ var tools = {
1749
1861
  slug: z.string().describe("Profile slug")
1750
1862
  }),
1751
1863
  execute: async (client, input) => unwrap(await client.media.profiles.create(input))
1752
- },
1753
- devpad_media_profiles_get: {
1864
+ }),
1865
+ devpad_media_profiles_get: define_tool({
1754
1866
  name: "devpad_media_profiles_get",
1755
1867
  description: "Get a media profile by ID",
1756
1868
  inputSchema: z.object({
1757
1869
  id: z.string().describe("Profile ID")
1758
1870
  }),
1759
1871
  execute: async (client, input) => unwrap(await client.media.profiles.get(input.id))
1760
- },
1761
- devpad_media_profiles_update: {
1872
+ }),
1873
+ devpad_media_profiles_update: define_tool({
1762
1874
  name: "devpad_media_profiles_update",
1763
1875
  description: "Update a media profile by ID",
1764
1876
  inputSchema: z.object({
@@ -1770,32 +1882,32 @@ var tools = {
1770
1882
  const { id, ...data } = input;
1771
1883
  return unwrap(await client.media.profiles.update(id, data));
1772
1884
  }
1773
- },
1774
- devpad_media_profiles_delete: {
1885
+ }),
1886
+ devpad_media_profiles_delete: define_tool({
1775
1887
  name: "devpad_media_profiles_delete",
1776
1888
  description: "Delete a media profile by ID",
1777
1889
  inputSchema: z.object({
1778
1890
  id: z.string().describe("Profile ID")
1779
1891
  }),
1780
1892
  execute: async (client, input) => unwrap(await client.media.profiles.delete(input.id))
1781
- },
1782
- devpad_media_connections_list: {
1893
+ }),
1894
+ devpad_media_connections_list: define_tool({
1783
1895
  name: "devpad_media_connections_list",
1784
1896
  description: "List connections for a media profile",
1785
1897
  inputSchema: z.object({
1786
1898
  profile_id: z.string().describe("Profile ID")
1787
1899
  }),
1788
1900
  execute: async (client, input) => unwrap(await client.media.connections.list(input.profile_id))
1789
- },
1790
- devpad_media_connections_refresh: {
1901
+ }),
1902
+ devpad_media_connections_refresh: define_tool({
1791
1903
  name: "devpad_media_connections_refresh",
1792
1904
  description: "Refresh a media connection",
1793
1905
  inputSchema: z.object({
1794
1906
  account_id: z.string().describe("Account/connection ID")
1795
1907
  }),
1796
1908
  execute: async (client, input) => unwrap(await client.media.connections.refresh(input.account_id))
1797
- },
1798
- devpad_media_timeline_get: {
1909
+ }),
1910
+ devpad_media_timeline_get: define_tool({
1799
1911
  name: "devpad_media_timeline_get",
1800
1912
  description: "Get media timeline for a user",
1801
1913
  inputSchema: z.object({
@@ -1807,9 +1919,9 @@ var tools = {
1807
1919
  const { user_id, ...params } = input;
1808
1920
  return unwrap(await client.media.timeline.get(user_id, params));
1809
1921
  }
1810
- },
1922
+ }),
1811
1923
  // Pulse analytics tools
1812
- devpad_pulse_summary: {
1924
+ devpad_pulse_summary: define_tool({
1813
1925
  name: "devpad_pulse_summary",
1814
1926
  description: "Get summary analytics for a project (pageviews, sessions, errors, latency)",
1815
1927
  inputSchema: z.object({
@@ -1817,8 +1929,8 @@ var tools = {
1817
1929
  range: z.enum(["24h", "7d", "30d", "90d"]).describe("Time range")
1818
1930
  }),
1819
1931
  execute: async (client, input) => unwrap(await client.pulse.summary({ project_id: input.project_id, range: input.range }))
1820
- },
1821
- devpad_pulse_events: {
1932
+ }),
1933
+ devpad_pulse_events: define_tool({
1822
1934
  name: "devpad_pulse_events",
1823
1935
  description: "List events for a project with optional filtering",
1824
1936
  inputSchema: z.object({
@@ -1832,8 +1944,8 @@ var tools = {
1832
1944
  cursor: z.string().optional().describe("Pagination cursor")
1833
1945
  }),
1834
1946
  execute: async (client, input) => unwrap(await client.pulse.events(input))
1835
- },
1836
- devpad_pulse_errors: {
1947
+ }),
1948
+ devpad_pulse_errors: define_tool({
1837
1949
  name: "devpad_pulse_errors",
1838
1950
  description: "List error issues for a project, optionally grouped by fingerprint",
1839
1951
  inputSchema: z.object({
@@ -1841,9 +1953,15 @@ var tools = {
1841
1953
  range: z.enum(["24h", "7d", "30d", "90d"]).describe("Time range"),
1842
1954
  group_by_fingerprint: z.boolean().optional().describe("Group by error fingerprint (true) or list all (false)")
1843
1955
  }),
1844
- execute: async (client, input) => unwrap(await client.pulse.errors({ project_id: input.project_id, range: input.range, group_by_fingerprint: input.group_by_fingerprint }))
1845
- },
1846
- devpad_pulse_logs: {
1956
+ execute: async (client, input) => unwrap(
1957
+ await client.pulse.errors({
1958
+ project_id: input.project_id,
1959
+ range: input.range,
1960
+ group_by_fingerprint: input.group_by_fingerprint
1961
+ })
1962
+ )
1963
+ }),
1964
+ devpad_pulse_logs: define_tool({
1847
1965
  name: "devpad_pulse_logs",
1848
1966
  description: "List logs for a project with optional level and message filtering",
1849
1967
  inputSchema: z.object({
@@ -1853,8 +1971,8 @@ var tools = {
1853
1971
  search: z.string().optional().describe("Search in log messages")
1854
1972
  }),
1855
1973
  execute: async (client, input) => unwrap(await client.pulse.logs(input))
1856
- },
1857
- devpad_pulse_latency: {
1974
+ }),
1975
+ devpad_pulse_latency: define_tool({
1858
1976
  name: "devpad_pulse_latency",
1859
1977
  description: "Get request latency metrics (p50, p95, p99) for a project",
1860
1978
  inputSchema: z.object({
@@ -1864,16 +1982,16 @@ var tools = {
1864
1982
  percentiles: z.array(z.number()).optional().describe("Percentiles to compute (default [50, 95, 99])")
1865
1983
  }),
1866
1984
  execute: async (client, input) => unwrap(await client.pulse.latency(input))
1867
- },
1868
- devpad_alerts_list: {
1985
+ }),
1986
+ devpad_alerts_list: define_tool({
1869
1987
  name: "devpad_alerts_list",
1870
1988
  description: "List notification subscriptions (alerts) for a project",
1871
1989
  inputSchema: z.object({
1872
1990
  project_id: z.string().describe("Project ID")
1873
1991
  }),
1874
1992
  execute: async (client, input) => unwrap(await client.pulse.subs.list(input))
1875
- },
1876
- devpad_alerts_subscribe: {
1993
+ }),
1994
+ devpad_alerts_subscribe: define_tool({
1877
1995
  name: "devpad_alerts_subscribe",
1878
1996
  description: "Create a new notification subscription (alert) for events",
1879
1997
  inputSchema: z.object({
@@ -1884,16 +2002,16 @@ var tools = {
1884
2002
  cooldown_seconds: z.number().optional().describe("Cooldown between notifications (default 60)")
1885
2003
  }),
1886
2004
  execute: async (client, input) => unwrap(await client.pulse.subs.create(input))
1887
- },
1888
- devpad_alerts_unsubscribe: {
2005
+ }),
2006
+ devpad_alerts_unsubscribe: define_tool({
1889
2007
  name: "devpad_alerts_unsubscribe",
1890
2008
  description: "Delete a notification subscription by ID",
1891
2009
  inputSchema: z.object({
1892
2010
  id: z.string().describe("Subscription ID")
1893
2011
  }),
1894
2012
  execute: async (client, input) => unwrap(await client.pulse.subs.delete(input.id))
1895
- },
1896
- devpad_pulse_key_create: {
2013
+ }),
2014
+ devpad_pulse_key_create: define_tool({
1897
2015
  name: "devpad_pulse_key_create",
1898
2016
  description: "Create a new ingest key for a project (returns plaintext once)",
1899
2017
  inputSchema: z.object({
@@ -1902,8 +2020,8 @@ var tools = {
1902
2020
  rate_limit_per_min: z.number().optional().describe("Rate limit in requests per minute (default 600)")
1903
2021
  }),
1904
2022
  execute: async (client, input) => unwrap(await client.pulse.keys.create(input))
1905
- },
1906
- devpad_pipelines_list: {
2023
+ }),
2024
+ devpad_pipelines_list: define_tool({
1907
2025
  name: "devpad_pipelines_list",
1908
2026
  description: "List pipeline runs (newest first). Optionally filter by package and/or status; cap limit at 200.",
1909
2027
  inputSchema: z.object({
@@ -1912,16 +2030,16 @@ var tools = {
1912
2030
  limit: z.number().int().positive().max(200).optional().describe("Max rows to return (default 50, cap 200)")
1913
2031
  }),
1914
2032
  execute: async (client, input) => unwrap(await client.pipelines.list(input))
1915
- },
1916
- devpad_pipelines_get: {
2033
+ }),
2034
+ devpad_pipelines_get: define_tool({
1917
2035
  name: "devpad_pipelines_get",
1918
2036
  description: "Get a pipeline run by ID",
1919
2037
  inputSchema: z.object({
1920
2038
  run_id: z.string().describe("Pipeline run ID")
1921
2039
  }),
1922
2040
  execute: async (client, input) => unwrap(await client.pipelines.get(input.run_id))
1923
- },
1924
- devpad_pipelines_create: {
2041
+ }),
2042
+ devpad_pipelines_create: define_tool({
1925
2043
  name: "devpad_pipelines_create",
1926
2044
  description: "Create a new pipeline run",
1927
2045
  inputSchema: z.object({
@@ -1929,8 +2047,8 @@ var tools = {
1929
2047
  version_set_id: z.string().describe("Version set ID to deploy")
1930
2048
  }),
1931
2049
  execute: async (client, input) => unwrap(await client.pipelines.create(input))
1932
- },
1933
- devpad_pipelines_approve: {
2050
+ }),
2051
+ devpad_pipelines_approve: define_tool({
1934
2052
  name: "devpad_pipelines_approve",
1935
2053
  description: "Approve or deny a stage in a pipeline run",
1936
2054
  inputSchema: z.object({
@@ -1944,8 +2062,8 @@ var tools = {
1944
2062
  unwrap(await client.pipelines.approve(input.run_id, input));
1945
2063
  return { success: true };
1946
2064
  }
1947
- },
1948
- devpad_pipelines_cancel: {
2065
+ }),
2066
+ devpad_pipelines_cancel: define_tool({
1949
2067
  name: "devpad_pipelines_cancel",
1950
2068
  description: "Cancel a pipeline run",
1951
2069
  inputSchema: z.object({
@@ -1955,8 +2073,8 @@ var tools = {
1955
2073
  unwrap(await client.pipelines.cancel(input.run_id));
1956
2074
  return { success: true };
1957
2075
  }
1958
- },
1959
- devpad_pipelines_rollback: {
2076
+ }),
2077
+ devpad_pipelines_rollback: define_tool({
1960
2078
  name: "devpad_pipelines_rollback",
1961
2079
  description: "Rollback a completed or failed pipeline run",
1962
2080
  inputSchema: z.object({
@@ -1966,8 +2084,8 @@ var tools = {
1966
2084
  unwrap(await client.pipelines.rollback(input.run_id));
1967
2085
  return { success: true };
1968
2086
  }
1969
- },
1970
- devpad_pipelines_runs_events_ingest: {
2087
+ }),
2088
+ devpad_pipelines_runs_events_ingest: define_tool({
1971
2089
  name: "devpad_pipelines_runs_events_ingest",
1972
2090
  description: 'Ingest an external webhook event against an in-flight pipeline run. Idempotent on (idempotency_key, payload). Server-side stamps payload.source = "external".',
1973
2091
  inputSchema: z.object({
@@ -1985,24 +2103,24 @@ var tools = {
1985
2103
  idempotency_key: input.idempotency_key
1986
2104
  })
1987
2105
  )
1988
- },
1989
- devpad_pipelines_runs_events_list: {
2106
+ }),
2107
+ devpad_pipelines_runs_events_list: define_tool({
1990
2108
  name: "devpad_pipelines_runs_events_list",
1991
2109
  description: "List stored stage events for a pipeline run, newest-first",
1992
2110
  inputSchema: z.object({
1993
2111
  run_id: z.string().describe("Pipeline run ID")
1994
2112
  }),
1995
2113
  execute: async (client, input) => unwrap(await client.pipelines.events.list(input.run_id))
1996
- },
1997
- devpad_pipelines_grants_list: {
2114
+ }),
2115
+ devpad_pipelines_grants_list: define_tool({
1998
2116
  name: "devpad_pipelines_grants_list",
1999
2117
  description: "List vault grants for a pipeline package",
2000
2118
  inputSchema: z.object({
2001
2119
  package_id: z.string().describe("Package ID to filter grants by")
2002
2120
  }),
2003
2121
  execute: async (client, input) => unwrap(await client.pipelines.grants.list(input.package_id))
2004
- },
2005
- devpad_pipelines_grants_approve: {
2122
+ }),
2123
+ devpad_pipelines_grants_approve: define_tool({
2006
2124
  name: "devpad_pipelines_grants_approve",
2007
2125
  description: "Approve a pending vault grant request for a pipeline package",
2008
2126
  inputSchema: z.object({
@@ -2010,8 +2128,8 @@ var tools = {
2010
2128
  user_id: z.string().describe("User ID making the approval decision")
2011
2129
  }),
2012
2130
  execute: async (client, input) => unwrap(await client.pipelines.grants.approve(input.grant_id, input.user_id))
2013
- },
2014
- devpad_pipelines_grants_deny: {
2131
+ }),
2132
+ devpad_pipelines_grants_deny: define_tool({
2015
2133
  name: "devpad_pipelines_grants_deny",
2016
2134
  description: "Deny a pending vault grant request for a pipeline package",
2017
2135
  inputSchema: z.object({
@@ -2020,24 +2138,24 @@ var tools = {
2020
2138
  reason: z.string().optional().describe("Optional reason for the denial")
2021
2139
  }),
2022
2140
  execute: async (client, input) => unwrap(await client.pipelines.grants.deny(input.grant_id, input.user_id, input.reason))
2023
- },
2024
- devpad_pipelines_packages_list: {
2141
+ }),
2142
+ devpad_pipelines_packages_list: define_tool({
2025
2143
  name: "devpad_pipelines_packages_list",
2026
2144
  description: "List pipeline packages. Optionally filter by linked devpad project_id; unlinked packages have project_id = null.",
2027
2145
  inputSchema: z.object({
2028
2146
  project_id: z.string().optional().describe("Filter packages by linked devpad project")
2029
2147
  }),
2030
2148
  execute: async (client, input) => unwrap(await client.pipelines.packages.list(input))
2031
- },
2032
- devpad_pipelines_packages_get: {
2149
+ }),
2150
+ devpad_pipelines_packages_get: define_tool({
2033
2151
  name: "devpad_pipelines_packages_get",
2034
2152
  description: "Get a pipeline package by ID",
2035
2153
  inputSchema: z.object({
2036
2154
  package_id: z.string().describe("Pipeline package ID")
2037
2155
  }),
2038
2156
  execute: async (client, input) => unwrap(await client.pipelines.packages.get(input.package_id))
2039
- },
2040
- devpad_pipelines_packages_create: {
2157
+ }),
2158
+ devpad_pipelines_packages_create: define_tool({
2041
2159
  name: "devpad_pipelines_packages_create",
2042
2160
  description: "Register a new pipeline-managed package. By convention `id` equals the package `name`. `project_id` optionally links the package to a devpad project.",
2043
2161
  inputSchema: z.object({
@@ -2049,8 +2167,8 @@ var tools = {
2049
2167
  default_template_ref: z.string().optional().describe("Optional default pipeline template ref")
2050
2168
  }),
2051
2169
  execute: async (client, input) => unwrap(await client.pipelines.packages.create(input))
2052
- },
2053
- devpad_pipelines_packages_update: {
2170
+ }),
2171
+ devpad_pipelines_packages_update: define_tool({
2054
2172
  name: "devpad_pipelines_packages_update",
2055
2173
  description: "Partially update a pipeline package. Only the provided fields are touched.",
2056
2174
  inputSchema: z.object({
@@ -2064,24 +2182,24 @@ var tools = {
2064
2182
  const { id, ...patch } = input;
2065
2183
  return unwrap(await client.pipelines.packages.update(id, patch));
2066
2184
  }
2067
- },
2068
- devpad_pipelines_packages_delete: {
2185
+ }),
2186
+ devpad_pipelines_packages_delete: define_tool({
2069
2187
  name: "devpad_pipelines_packages_delete",
2070
2188
  description: "Delete a pipeline package. Refuses with conflict if existing pipeline_run rows still reference the package.",
2071
2189
  inputSchema: z.object({
2072
2190
  id: z.string().describe("Pipeline package ID")
2073
2191
  }),
2074
2192
  execute: async (client, input) => unwrap(await client.pipelines.packages.delete(input.id))
2075
- },
2076
- devpad_pipelines_analysis_templates_list: {
2193
+ }),
2194
+ devpad_pipelines_analysis_templates_list: define_tool({
2077
2195
  name: "devpad_pipelines_analysis_templates_list",
2078
2196
  description: "List pipeline analysis templates for an owner. Each row encodes the threshold DSL + window referenced by analysis-gate evaluations.",
2079
2197
  inputSchema: z.object({
2080
2198
  owner_id: z.string().describe("Devpad user ID whose templates to list")
2081
2199
  }),
2082
2200
  execute: async (client, input) => unwrap(await client.pipelines.analysis_templates.list(input))
2083
- },
2084
- devpad_pipelines_analysis_templates_get: {
2201
+ }),
2202
+ devpad_pipelines_analysis_templates_get: define_tool({
2085
2203
  name: "devpad_pipelines_analysis_templates_get",
2086
2204
  description: "Get a single pipeline analysis template by id, scoped to its owner.",
2087
2205
  inputSchema: z.object({
@@ -2089,8 +2207,8 @@ var tools = {
2089
2207
  owner_id: z.string().describe("Owner ID (must match the template's owner)")
2090
2208
  }),
2091
2209
  execute: async (client, input) => unwrap(await client.pipelines.analysis_templates.get(input.id, { owner_id: input.owner_id }))
2092
- },
2093
- devpad_pipelines_analysis_templates_create: {
2210
+ }),
2211
+ devpad_pipelines_analysis_templates_create: define_tool({
2094
2212
  name: "devpad_pipelines_analysis_templates_create",
2095
2213
  description: 'Create a new pipeline analysis template. `threshold_dsl` is a multi-line DSL: `metric_name OP value [: pending]` (OPs: > < >= <= =). Trailing ": pending" marks a breach as Pending rather than Fail. Server-side parse failure surfaces as `validation_error` with field=threshold_dsl. `window_ms` defaults to 600000 (10 min).',
2096
2214
  inputSchema: z.object({
@@ -2101,8 +2219,8 @@ var tools = {
2101
2219
  window_ms: z.number().int().positive().optional().describe("Analysis window in milliseconds. Default: 600000")
2102
2220
  }),
2103
2221
  execute: async (client, input) => unwrap(await client.pipelines.analysis_templates.create(input))
2104
- },
2105
- devpad_pipelines_analysis_templates_update: {
2222
+ }),
2223
+ devpad_pipelines_analysis_templates_update: define_tool({
2106
2224
  name: "devpad_pipelines_analysis_templates_update",
2107
2225
  description: "Partially update a pipeline analysis template. Only the supplied fields are touched. Re-validates threshold_dsl when present.",
2108
2226
  inputSchema: z.object({
@@ -2117,8 +2235,8 @@ var tools = {
2117
2235
  const { id, ...patch } = input;
2118
2236
  return unwrap(await client.pipelines.analysis_templates.update(id, patch));
2119
2237
  }
2120
- },
2121
- devpad_pipelines_analysis_templates_delete: {
2238
+ }),
2239
+ devpad_pipelines_analysis_templates_delete: define_tool({
2122
2240
  name: "devpad_pipelines_analysis_templates_delete",
2123
2241
  description: "Hard-delete a pipeline analysis template. Does NOT consult pipeline_run.resolved_gates \u2014 runs snapshot their gate template at resolve-time, so deletion never orphans in-flight runs.",
2124
2242
  inputSchema: z.object({
@@ -2126,16 +2244,16 @@ var tools = {
2126
2244
  owner_id: z.string().describe("Owner ID (must match the template's owner)")
2127
2245
  }),
2128
2246
  execute: async (client, input) => unwrap(await client.pipelines.analysis_templates.delete(input.id, { owner_id: input.owner_id }))
2129
- },
2130
- devpad_pipelines_oidc_trust_list: {
2247
+ }),
2248
+ devpad_pipelines_oidc_trust_list: define_tool({
2131
2249
  name: "devpad_pipelines_oidc_trust_list",
2132
2250
  description: "List GitHub Actions OIDC trust policies for an owner. Returned ordered by created_at DESC, id ASC to match the orchestrator's trust-matcher resolution order.",
2133
2251
  inputSchema: z.object({
2134
2252
  owner_id: z.string().describe("User ID whose trust policies to list")
2135
2253
  }),
2136
2254
  execute: async (client, input) => unwrap(await client.pipelines.oidc_trust.list(input))
2137
- },
2138
- devpad_pipelines_oidc_trust_create: {
2255
+ }),
2256
+ devpad_pipelines_oidc_trust_create: define_tool({
2139
2257
  name: "devpad_pipelines_oidc_trust_create",
2140
2258
  description: 'Create a GitHub Actions OIDC trust policy. Authorises CI in repos owned by `github_owner` (filtered by `repo_pattern` and optional ref/environment lists) to mint orchestrator session tokens. Defaults: repo_pattern="*", allowed_actions=["artifacts:upload","runs:start"], session_ttl_seconds=900.',
2141
2259
  inputSchema: z.object({
@@ -2149,8 +2267,8 @@ var tools = {
2149
2267
  session_ttl_seconds: z.number().int().positive().optional().describe("Session token TTL. Default: 900 (15 min)")
2150
2268
  }),
2151
2269
  execute: async (client, input) => unwrap(await client.pipelines.oidc_trust.create(input))
2152
- },
2153
- devpad_pipelines_oidc_trust_update: {
2270
+ }),
2271
+ devpad_pipelines_oidc_trust_update: define_tool({
2154
2272
  name: "devpad_pipelines_oidc_trust_update",
2155
2273
  description: "Partially update a GitHub Actions OIDC trust policy. Only the supplied fields are touched; validation runs server-side against the merged record.",
2156
2274
  inputSchema: z.object({
@@ -2168,8 +2286,8 @@ var tools = {
2168
2286
  const { id, ...patch } = input;
2169
2287
  return unwrap(await client.pipelines.oidc_trust.update(id, patch));
2170
2288
  }
2171
- },
2172
- devpad_pipelines_oidc_trust_delete: {
2289
+ }),
2290
+ devpad_pipelines_oidc_trust_delete: define_tool({
2173
2291
  name: "devpad_pipelines_oidc_trust_delete",
2174
2292
  description: "Soft-delete a GitHub Actions OIDC trust policy. The row is preserved for audit; the matcher and list operations skip soft-deleted rows.",
2175
2293
  inputSchema: z.object({
@@ -2177,7 +2295,7 @@ var tools = {
2177
2295
  owner_id: z.string().describe("Owner ID (must match the policy's owner)")
2178
2296
  }),
2179
2297
  execute: async (client, input) => unwrap(await client.pipelines.oidc_trust.delete(input.id, { owner_id: input.owner_id }))
2180
- }
2298
+ })
2181
2299
  };
2182
2300
  var toolNames = Object.keys(tools);
2183
2301
  function getTool(name) {