@devpad/api 2.2.7 → 2.2.8

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
@@ -1,11 +1,13 @@
1
1
  import {
2
+ RUN_STATUSES,
3
+ STAGE_EVENT_KINDS,
2
4
  save_config_request,
3
5
  save_tags_request,
4
6
  upsert_goal,
5
7
  upsert_milestone,
6
8
  upsert_project,
7
9
  upsert_todo
8
- } from "./chunk-ZPEX7KVX.js";
10
+ } from "./chunk-TEOIDOOX.js";
9
11
 
10
12
  // src/errors.ts
11
13
  var ApiError = class _ApiError extends Error {
@@ -320,14 +322,14 @@ var ApiClient = class {
320
322
  if (response.status === HTTP_STATUS.NO_CONTENT) {
321
323
  result = void 0;
322
324
  } else {
323
- const text2 = await response.text();
324
- if (!text2 || text2.trim() === "" || text2.trim() === "null") {
325
+ const text = await response.text();
326
+ if (!text || text.trim() === "" || text.trim() === "null") {
325
327
  result = void 0;
326
328
  } else {
327
329
  try {
328
- result = JSON.parse(text2);
330
+ result = JSON.parse(text);
329
331
  } catch (parseError) {
330
- result = text2;
332
+ result = text;
331
333
  }
332
334
  }
333
335
  }
@@ -423,9 +425,7 @@ var ApiClient2 = class {
423
425
  list: () => wrap(() => this.clients.auth.get("/keys")),
424
426
  create: (input) => {
425
427
  const body = typeof input === "string" ? { name: input } : input ?? {};
426
- return wrap(
427
- () => this.clients.auth.post("/keys", { body })
428
- );
428
+ return wrap(() => this.clients.auth.post("/keys", { body }));
429
429
  },
430
430
  revoke: (key_id) => wrap(() => this.clients.auth.delete(`/keys/${key_id}`)),
431
431
  remove: (key_id) => wrap(() => this.clients.auth.delete(`/keys/${key_id}`))
@@ -446,8 +446,8 @@ var ApiClient2 = class {
446
446
  const result = await this.projects.list(filters);
447
447
  if (!result.ok) throw new Error(result.error.message);
448
448
  return result.value.reduce(
449
- (acc, project2) => {
450
- acc[project2.id] = project2;
449
+ (acc, project) => {
450
+ acc[project.id] = project;
451
451
  return acc;
452
452
  },
453
453
  {}
@@ -456,7 +456,7 @@ var ApiClient2 = class {
456
456
  /**
457
457
  * Get project by ID
458
458
  */
459
- find: (id2) => wrap(() => this.clients.projects.get("/projects", { query: { id: id2 } })),
459
+ find: (id) => wrap(() => this.clients.projects.get("/projects", { query: { id } })),
460
460
  /**
461
461
  * Get project by name
462
462
  */
@@ -464,7 +464,7 @@ var ApiClient2 = class {
464
464
  /**
465
465
  * Get project by ID (throws if not found)
466
466
  */
467
- getById: (id2) => wrap(() => this.clients.projects.get("/projects", { query: { id: id2 } })),
467
+ getById: (id) => wrap(() => this.clients.projects.get("/projects", { query: { id } })),
468
468
  /**
469
469
  * Create a new project
470
470
  */
@@ -478,30 +478,30 @@ var ApiClient2 = class {
478
478
  body: idOrData
479
479
  });
480
480
  }
481
- const id2 = idOrData;
481
+ const id = idOrData;
482
482
  if (!changes) {
483
483
  throw new Error("Changes parameter required for update");
484
484
  }
485
- const result = await this.projects.find(id2);
485
+ const result = await this.projects.find(id);
486
486
  if (!result.ok) throw new Error(result.error.message);
487
- if (!result.value) throw new Error(`Project with id ${id2} not found`);
488
- const project2 = result.value;
487
+ if (!result.value) throw new Error(`Project with id ${id} not found`);
488
+ const project = result.value;
489
489
  const updateData = {
490
- id: project2.id,
491
- project_id: project2.project_id,
492
- owner_id: project2.owner_id,
493
- name: project2.name,
494
- description: project2.description,
495
- specification: project2.specification,
496
- repo_url: project2.repo_url,
497
- repo_id: project2.repo_id,
498
- icon_url: project2.icon_url,
499
- status: project2.status,
500
- deleted: project2.deleted,
501
- link_url: project2.link_url,
502
- link_text: project2.link_text,
503
- visibility: project2.visibility,
504
- current_version: project2.current_version,
490
+ id: project.id,
491
+ project_id: project.project_id,
492
+ owner_id: project.owner_id,
493
+ name: project.name,
494
+ description: project.description,
495
+ specification: project.specification,
496
+ repo_url: project.repo_url,
497
+ repo_id: project.repo_id,
498
+ icon_url: project.icon_url,
499
+ status: project.status,
500
+ deleted: project.deleted,
501
+ link_url: project.link_url,
502
+ link_text: project.link_text,
503
+ visibility: project.visibility,
504
+ current_version: project.current_version,
505
505
  ...changes
506
506
  };
507
507
  return this.clients.projects.patch("/projects", {
@@ -582,9 +582,9 @@ var ApiClient2 = class {
582
582
  /**
583
583
  * Delete project (soft delete)
584
584
  */
585
- deleteProject: (project2) => wrap(
585
+ deleteProject: (project) => wrap(
586
586
  () => this.clients.projects.patch("/projects", {
587
- body: { ...project2, deleted: true }
587
+ body: { ...project, deleted: true }
588
588
  })
589
589
  )
590
590
  };
@@ -603,9 +603,9 @@ var ApiClient2 = class {
603
603
  /**
604
604
  * Get milestone by ID
605
605
  */
606
- find: (id2) => wrap(async () => {
606
+ find: (id) => wrap(async () => {
607
607
  try {
608
- return await this.clients.milestones.get(`/milestones/${id2}`);
608
+ return await this.clients.milestones.get(`/milestones/${id}`);
609
609
  } catch (error) {
610
610
  return null;
611
611
  }
@@ -617,32 +617,32 @@ var ApiClient2 = class {
617
617
  /**
618
618
  * Update milestone
619
619
  */
620
- update: async (id2, data) => wrap(async () => {
621
- const result = await this.milestones.find(id2);
620
+ update: async (id, data) => wrap(async () => {
621
+ const result = await this.milestones.find(id);
622
622
  if (!result.ok) throw new Error(result.error.message);
623
- if (!result.value) throw new Error(`Milestone with id ${id2} not found`);
624
- const milestone2 = result.value;
623
+ if (!result.value) throw new Error(`Milestone with id ${id} not found`);
624
+ const milestone = result.value;
625
625
  const updateData = {
626
- id: milestone2.id,
627
- project_id: milestone2.project_id,
628
- name: data.name ?? milestone2.name,
629
- description: data.description ?? milestone2.description,
630
- target_time: data.target_time ?? milestone2.target_time,
631
- target_version: data.target_version ?? milestone2.target_version,
632
- finished_at: data.finished_at !== void 0 ? data.finished_at : milestone2.finished_at
626
+ id: milestone.id,
627
+ project_id: milestone.project_id,
628
+ name: data.name ?? milestone.name,
629
+ description: data.description ?? milestone.description,
630
+ target_time: data.target_time ?? milestone.target_time,
631
+ target_version: data.target_version ?? milestone.target_version,
632
+ finished_at: data.finished_at !== void 0 ? data.finished_at : milestone.finished_at
633
633
  };
634
- return this.clients.milestones.patch(`/milestones/${id2}`, {
634
+ return this.clients.milestones.patch(`/milestones/${id}`, {
635
635
  body: updateData
636
636
  });
637
637
  }),
638
638
  /**
639
639
  * Delete milestone (soft delete)
640
640
  */
641
- delete: (id2) => wrap(() => this.clients.milestones.delete(`/milestones/${id2}`)),
641
+ delete: (id) => wrap(() => this.clients.milestones.delete(`/milestones/${id}`)),
642
642
  /**
643
643
  * Get goals for a milestone
644
644
  */
645
- goals: (id2) => wrap(() => this.clients.milestones.get(`/milestones/${id2}/goals`))
645
+ goals: (id) => wrap(() => this.clients.milestones.get(`/milestones/${id}/goals`))
646
646
  };
647
647
  /**
648
648
  * Goals namespace with Result-wrapped operations
@@ -655,7 +655,7 @@ var ApiClient2 = class {
655
655
  /**
656
656
  * Get goal by ID
657
657
  */
658
- find: (id2) => wrap(() => this.clients.goals.get(`/goals/${id2}`)),
658
+ find: (id) => wrap(() => this.clients.goals.get(`/goals/${id}`)),
659
659
  /**
660
660
  * Create new goal
661
661
  */
@@ -663,27 +663,27 @@ var ApiClient2 = class {
663
663
  /**
664
664
  * Update goal
665
665
  */
666
- update: async (id2, data) => wrap(async () => {
667
- const result = await this.goals.find(id2);
666
+ update: async (id, data) => wrap(async () => {
667
+ const result = await this.goals.find(id);
668
668
  if (!result.ok) throw new Error(result.error.message);
669
- if (!result.value) throw new Error(`Goal with id ${id2} not found`);
670
- const goal2 = result.value;
669
+ if (!result.value) throw new Error(`Goal with id ${id} not found`);
670
+ const goal = result.value;
671
671
  const updateData = {
672
- id: goal2.id,
673
- milestone_id: goal2.milestone_id,
674
- name: data.name ?? goal2.name,
675
- description: data.description ?? goal2.description,
676
- target_time: data.target_time ?? goal2.target_time,
677
- finished_at: data.finished_at !== void 0 ? data.finished_at : goal2.finished_at
672
+ id: goal.id,
673
+ milestone_id: goal.milestone_id,
674
+ name: data.name ?? goal.name,
675
+ description: data.description ?? goal.description,
676
+ target_time: data.target_time ?? goal.target_time,
677
+ finished_at: data.finished_at !== void 0 ? data.finished_at : goal.finished_at
678
678
  };
679
- return this.clients.goals.patch(`/goals/${id2}`, {
679
+ return this.clients.goals.patch(`/goals/${id}`, {
680
680
  body: updateData
681
681
  });
682
682
  }),
683
683
  /**
684
684
  * Delete goal (soft delete)
685
685
  */
686
- delete: (id2) => wrap(() => this.clients.goals.delete(`/goals/${id2}`))
686
+ delete: (id) => wrap(() => this.clients.goals.delete(`/goals/${id}`))
687
687
  };
688
688
  /**
689
689
  * Tasks namespace with Result-wrapped operations
@@ -701,7 +701,7 @@ var ApiClient2 = class {
701
701
  /**
702
702
  * Get task by ID
703
703
  */
704
- find: (id2) => wrap(() => this.clients.tasks.get("/tasks", { query: { id: id2 } })),
704
+ find: (id) => wrap(() => this.clients.tasks.get("/tasks", { query: { id } })),
705
705
  /**
706
706
  * Get tasks by project ID
707
707
  */
@@ -717,23 +717,23 @@ var ApiClient2 = class {
717
717
  /**
718
718
  * Update an existing task
719
719
  */
720
- update: async (id2, changes) => wrap(async () => {
721
- const result = await this.tasks.find(id2);
720
+ update: async (id, changes) => wrap(async () => {
721
+ const result = await this.tasks.find(id);
722
722
  if (!result.ok) throw new Error(result.error.message);
723
- if (!result.value) throw new Error(`Task with id ${id2} not found`);
724
- const task2 = result.value;
723
+ if (!result.value) throw new Error(`Task with id ${id} not found`);
724
+ const task = result.value;
725
725
  const updateData = {
726
- id: id2,
727
- title: task2.task.title,
728
- summary: task2.task.summary,
729
- description: task2.task.description,
730
- progress: task2.task.progress,
731
- visibility: task2.task.visibility,
732
- start_time: task2.task.start_time,
733
- end_time: task2.task.end_time,
734
- priority: task2.task.priority,
735
- owner_id: task2.task.owner_id,
736
- project_id: task2.task.project_id,
726
+ id,
727
+ title: task.task.title,
728
+ summary: task.task.summary,
729
+ description: task.task.description,
730
+ progress: task.task.progress,
731
+ visibility: task.task.visibility,
732
+ start_time: task.task.start_time,
733
+ end_time: task.task.end_time,
734
+ priority: task.task.priority,
735
+ owner_id: task.task.owner_id,
736
+ project_id: task.task.project_id,
737
737
  ...changes
738
738
  };
739
739
  return this.clients.tasks.patch("/tasks", {
@@ -751,9 +751,9 @@ var ApiClient2 = class {
751
751
  /**
752
752
  * Delete task (soft delete)
753
753
  */
754
- deleteTask: (task2) => wrap(
754
+ deleteTask: (task) => wrap(
755
755
  () => this.clients.tasks.patch("/tasks", {
756
- body: { ...task2.task, deleted: true }
756
+ body: { ...task.task, deleted: true }
757
757
  })
758
758
  ),
759
759
  /**
@@ -815,7 +815,7 @@ var ApiClient2 = class {
815
815
  getForPost: (uuid) => wrap(() => this.clients.blog.get(`/blog/tags/posts/${uuid}/tags`)),
816
816
  setForPost: (uuid, tags) => wrap(() => this.clients.blog.put(`/blog/tags/posts/${uuid}/tags`, { body: { tags } })),
817
817
  addToPost: (uuid, tags) => wrap(() => this.clients.blog.post(`/blog/tags/posts/${uuid}/tags`, { body: { tags } })),
818
- removeFromPost: (uuid, tag2) => wrap(() => this.clients.blog.delete(`/blog/tags/posts/${uuid}/tags/${tag2}`))
818
+ removeFromPost: (uuid, tag) => wrap(() => this.clients.blog.delete(`/blog/tags/posts/${uuid}/tags/${tag}`))
819
819
  },
820
820
  categories: {
821
821
  tree: () => wrap(() => this.clients.blog.get("/blog/categories")),
@@ -830,12 +830,12 @@ var ApiClient2 = class {
830
830
  tokens: {
831
831
  list: () => wrap(() => this.clients.blog.get("/blog/tokens")),
832
832
  create: (data) => wrap(() => this.clients.blog.post("/blog/tokens", { body: data })),
833
- update: (id2, data) => wrap(
834
- () => this.clients.blog.put(`/blog/tokens/${id2}`, {
833
+ update: (id, data) => wrap(
834
+ () => this.clients.blog.put(`/blog/tokens/${id}`, {
835
835
  body: data
836
836
  })
837
837
  ),
838
- delete: (id2) => wrap(() => this.clients.blog.delete(`/blog/tokens/${id2}`))
838
+ delete: (id) => wrap(() => this.clients.blog.delete(`/blog/tokens/${id}`))
839
839
  }
840
840
  };
841
841
  this.media = {
@@ -845,9 +845,9 @@ var ApiClient2 = class {
845
845
  return res.profiles;
846
846
  }),
847
847
  create: (data) => wrap(() => this.clients.media.post("/profiles", { body: data })),
848
- get: (id2) => wrap(() => this.clients.media.get(`/profiles/${id2}`)),
849
- update: (id2, data) => wrap(() => this.clients.media.patch(`/profiles/${id2}`, { body: data })),
850
- delete: (id2) => wrap(() => this.clients.media.delete(`/profiles/${id2}`)),
848
+ get: (id) => wrap(() => this.clients.media.get(`/profiles/${id}`)),
849
+ update: (id, data) => wrap(() => this.clients.media.patch(`/profiles/${id}`, { body: data })),
850
+ delete: (id) => wrap(() => this.clients.media.delete(`/profiles/${id}`)),
851
851
  filters: {
852
852
  list: (profile_id) => wrap(async () => {
853
853
  const res = await this.clients.media.get(`/profiles/${profile_id}/filters`);
@@ -1033,15 +1033,15 @@ var ApiClient2 = class {
1033
1033
  /**
1034
1034
  * Get a subscription by ID
1035
1035
  */
1036
- get: (id2) => wrap(() => this.clients.pulse.get(`/admin/subs/${id2}`)),
1036
+ get: (id) => wrap(() => this.clients.pulse.get(`/admin/subs/${id}`)),
1037
1037
  /**
1038
1038
  * Update a subscription
1039
1039
  */
1040
- update: (id2, patch) => wrap(() => this.clients.pulse.patch(`/admin/subs/${id2}`, { body: patch })),
1040
+ update: (id, patch) => wrap(() => this.clients.pulse.patch(`/admin/subs/${id}`, { body: patch })),
1041
1041
  /**
1042
1042
  * Delete a subscription
1043
1043
  */
1044
- delete: (id2) => wrap(() => this.clients.pulse.delete(`/admin/subs/${id2}`))
1044
+ delete: (id) => wrap(() => this.clients.pulse.delete(`/admin/subs/${id}`))
1045
1045
  },
1046
1046
  /**
1047
1047
  * Ingest key management
@@ -1066,13 +1066,31 @@ var ApiClient2 = class {
1066
1066
  /**
1067
1067
  * Delete an ingest key
1068
1068
  */
1069
- delete: (id2, input) => wrap(() => this.clients.pulse.delete(`/admin/keys/${id2}`, { query: { project_id: input.project_id } }))
1069
+ delete: (id, input) => wrap(() => this.clients.pulse.delete(`/admin/keys/${id}`, { query: { project_id: input.project_id } }))
1070
1070
  }
1071
1071
  };
1072
1072
  /**
1073
1073
  * Pipelines namespace with Result-wrapped operations
1074
1074
  */
1075
1075
  this.pipelines = {
1076
+ /**
1077
+ * Dashboard namespace — Phase 2.D observability slice. Aggregates
1078
+ * `pipeline_run`, `pipeline_stage_event`, and `pipeline_approval`
1079
+ * for the project's pipeline_package(s) over `window_ms` and
1080
+ * enriches the response with pulse `/summary` when configured.
1081
+ *
1082
+ * Lives at `GET /v1/pipelines/dashboard?project_id=...&window_ms=...`
1083
+ * on the main worker (unified D1 binding — no orchestrator hop).
1084
+ * Auth: session cookie + ownership check on the project_id.
1085
+ * Cache: `public, max-age=30`.
1086
+ */
1087
+ dashboard: {
1088
+ get: (input) => {
1089
+ const query = { project_id: input.project_id };
1090
+ if (input.window_ms !== void 0) query.window_ms = String(input.window_ms);
1091
+ return wrap(() => this.clients.pipelines.get("/pipelines/dashboard", { query }));
1092
+ }
1093
+ },
1076
1094
  /**
1077
1095
  * List pipeline runs ordered by `created_at` DESC. Optional filters
1078
1096
  * narrow by package and/or status; `limit` defaults to 50 server-side
@@ -1113,6 +1131,22 @@ var ApiClient2 = class {
1113
1131
  * Rollback a pipeline run
1114
1132
  */
1115
1133
  rollback: (run_id) => wrap(() => this.clients.pipelines.post(`/runs/${run_id}/rollback`, { body: {} })),
1134
+ /**
1135
+ * Stage-event namespace — Phase 2.C webhook ingestion + read-back.
1136
+ *
1137
+ * `ingest` posts a webhook event against an in-flight run; auth
1138
+ * mode is the standard bearer/session header (admin bypass; session
1139
+ * must carry `runs:events` and matching `package_id`). Server-side
1140
+ * stamps `payload.source = "external"`. Idempotency: same
1141
+ * `idempotency_key` + same payload returns `{ duplicated: true }`;
1142
+ * same key + different payload returns a 400 validation_error.
1143
+ *
1144
+ * `list` is read-only and returns the run's events newest-first.
1145
+ */
1146
+ events: {
1147
+ ingest: (run_id, input) => wrap(() => this.clients.pipelines.post(`/runs/${run_id}/events`, { body: input })),
1148
+ list: (run_id) => wrap(() => this.clients.pipelines.get(`/runs/${run_id}/events`))
1149
+ },
1116
1150
  /**
1117
1151
  * Grants namespace
1118
1152
  */
@@ -1178,6 +1212,45 @@ var ApiClient2 = class {
1178
1212
  */
1179
1213
  delete: (package_id) => wrap(() => this.clients.pipelines.delete(`/packages/${package_id}`))
1180
1214
  },
1215
+ /**
1216
+ * Analysis-template namespace — admin-gated CRUD for the
1217
+ * `pipeline_analysis_template` table. Phase 2.A surface; each
1218
+ * call requires the orchestrator's bearer token (literal
1219
+ * `PIPELINES_TOKEN`). `owner_id` is required on every operation
1220
+ * — single-tenant today, but the column is in place so multi-user
1221
+ * ACLs slot in later.
1222
+ */
1223
+ analysis_templates: {
1224
+ /**
1225
+ * List templates for an owner.
1226
+ */
1227
+ list: (input) => wrap(() => this.clients.pipelines.get("/analysis-templates", { query: { owner_id: input.owner_id } })),
1228
+ /**
1229
+ * Get a single template by id, scoped to its owner. 404 when
1230
+ * unknown or owned by a different user.
1231
+ */
1232
+ get: (id, input) => wrap(() => this.clients.pipelines.get(`/analysis-templates/${id}`, { query: { owner_id: input.owner_id } })),
1233
+ /**
1234
+ * Create a new analysis template. `threshold_dsl` is parsed
1235
+ * server-side; parse failure returns 400 `validation_error`
1236
+ * with `field: "threshold_dsl"` and a descriptive message.
1237
+ * `window_ms` defaults to 600_000 (10 min) when omitted.
1238
+ */
1239
+ create: (input) => wrap(() => this.clients.pipelines.post("/analysis-templates", { body: input })),
1240
+ /**
1241
+ * Partial patch — only the supplied fields are touched.
1242
+ * Re-validates `threshold_dsl` when supplied; same
1243
+ * `validation_error` shape as create on parse failure.
1244
+ */
1245
+ update: (id, input) => wrap(() => this.clients.pipelines.patch(`/analysis-templates/${id}`, { body: input })),
1246
+ /**
1247
+ * Hard-delete the template. Does NOT consult
1248
+ * `pipeline_run.resolved_gates` — runs snapshot their gate
1249
+ * template at resolve-time, so deletion never orphans
1250
+ * in-flight runs.
1251
+ */
1252
+ delete: (id, input) => wrap(() => this.clients.pipelines.delete(`/analysis-templates/${id}`, { query: { owner_id: input.owner_id } }))
1253
+ },
1181
1254
  /**
1182
1255
  * OIDC trust-policy namespace — admin-gated CRUD for the
1183
1256
  * `pipeline_oidc_trust` table. Phase 15.D surface; each call requires
@@ -1196,7 +1269,7 @@ var ApiClient2 = class {
1196
1269
  * Get a single policy by id, scoped to its owner. 404 when
1197
1270
  * unknown, soft-deleted, or owned by a different user.
1198
1271
  */
1199
- get: (id2, input) => wrap(() => this.clients.pipelines.get(`/oidc-trust/${id2}`, { query: { owner_id: input.owner_id } })),
1272
+ get: (id, input) => wrap(() => this.clients.pipelines.get(`/oidc-trust/${id}`, { query: { owner_id: input.owner_id } })),
1200
1273
  /**
1201
1274
  * Create a new policy. Defaults per plan §I.5: `repo_pattern: "*"`,
1202
1275
  * `allowed_actions: ["artifacts:upload","runs:start"]`,
@@ -1207,13 +1280,13 @@ var ApiClient2 = class {
1207
1280
  * Partial patch — only the supplied fields are touched. Validation
1208
1281
  * runs against the merged record server-side.
1209
1282
  */
1210
- update: (id2, input) => wrap(() => this.clients.pipelines.patch(`/oidc-trust/${id2}`, { body: input })),
1283
+ update: (id, input) => wrap(() => this.clients.pipelines.patch(`/oidc-trust/${id}`, { body: input })),
1211
1284
  /**
1212
1285
  * Soft-delete a policy (sets `deleted = true`; row preserved for
1213
1286
  * audit). The matcher and management list both skip soft-deleted
1214
1287
  * rows.
1215
1288
  */
1216
- delete: (id2, input) => wrap(() => this.clients.pipelines.delete(`/oidc-trust/${id2}`, { query: { owner_id: input.owner_id } }))
1289
+ delete: (id, input) => wrap(() => this.clients.pipelines.delete(`/oidc-trust/${id}`, { query: { owner_id: input.owner_id } }))
1217
1290
  }
1218
1291
  };
1219
1292
  const base_url = options.base_url || "http://localhost:4321/api/v1";
@@ -1268,394 +1341,6 @@ var ApiClient2 = class {
1268
1341
  }
1269
1342
  };
1270
1343
 
1271
- // ../schema/dist/database/schema.js
1272
- import { relations, sql } from "drizzle-orm";
1273
- import { int, integer, primaryKey, sqliteTable, text, unique } from "drizzle-orm/sqlite-core";
1274
- var timestamps = () => ({
1275
- created_at: text("created_at").notNull().default(sql`(CURRENT_TIMESTAMP)`),
1276
- updated_at: text("updated_at").notNull().default(sql`(CURRENT_TIMESTAMP)`)
1277
- });
1278
- var deleted = () => ({
1279
- deleted: int("deleted", { mode: "boolean" }).notNull().default(false)
1280
- });
1281
- var provenance = () => ({
1282
- created_by: text("created_by", { enum: ["user", "api"] }).notNull().default("user"),
1283
- modified_by: text("modified_by", { enum: ["user", "api"] }).notNull().default("user"),
1284
- protected: int("protected", { mode: "boolean" }).notNull().default(false)
1285
- });
1286
- var owner_id = () => ({
1287
- owner_id: text("owner_id").notNull().references(() => user.id)
1288
- });
1289
- var id = (prefix) => ({
1290
- id: text("id").primaryKey().$defaultFn(() => `${prefix}_${crypto.randomUUID()}`)
1291
- });
1292
- var entity = (prefix) => ({
1293
- ...id(prefix),
1294
- ...timestamps(),
1295
- ...deleted(),
1296
- ...provenance()
1297
- });
1298
- var owned_entity = (prefix) => ({
1299
- ...entity(prefix),
1300
- ...owner_id()
1301
- });
1302
- var user = sqliteTable("user", {
1303
- id: text("id").primaryKey().$defaultFn(() => `user_${crypto.randomUUID()}`),
1304
- github_id: integer("github_id"),
1305
- name: text("name"),
1306
- email: text("email").unique(),
1307
- email_verified: text("email_verified"),
1308
- // timestamp
1309
- image_url: text("image_url"),
1310
- task_view: text("task_view", { enum: ["list", "grid"] }).notNull().default("list")
1311
- });
1312
- var session = sqliteTable("session", {
1313
- id: text("id").notNull().primaryKey(),
1314
- userId: text("user_id").notNull().references(() => user.id),
1315
- expiresAt: integer("expires_at").notNull(),
1316
- access_token: text("access_token")
1317
- });
1318
- var api_keys = sqliteTable("api_keys", {
1319
- ...id("apikey"),
1320
- user_id: text("user_id").notNull().references(() => user.id),
1321
- key_hash: text("key_hash").notNull().unique(),
1322
- name: text("name"),
1323
- note: text("note"),
1324
- scope: text("scope", { enum: ["devpad", "blog", "media", "pulse", "all"] }).notNull().default("all"),
1325
- enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
1326
- last_used_at: text("last_used_at"),
1327
- ...timestamps(),
1328
- deleted: integer("deleted", { mode: "boolean" }).notNull().default(false)
1329
- });
1330
- var project = sqliteTable("project", {
1331
- ...owned_entity("project"),
1332
- project_id: text("project_id").notNull(),
1333
- name: text("name").notNull(),
1334
- description: text("description"),
1335
- specification: text("specification"),
1336
- repo_url: text("repo_url"),
1337
- repo_id: integer("repo_id"),
1338
- icon_url: text("icon_url"),
1339
- status: text("status", { enum: ["DEVELOPMENT", "PAUSED", "RELEASED", "LIVE", "FINISHED", "ABANDONED", "STOPPED"] }).notNull().default("DEVELOPMENT"),
1340
- link_url: text("link_url"),
1341
- link_text: text("link_text"),
1342
- visibility: text("visibility", { enum: ["PUBLIC", "PRIVATE", "HIDDEN", "ARCHIVED", "DRAFT", "DELETED"] }).notNull().default("PRIVATE"),
1343
- current_version: text("current_version"),
1344
- scan_branch: text("scan_branch")
1345
- });
1346
- var ACTIONS = [
1347
- "CREATE_TASK",
1348
- "UPDATE_TASK",
1349
- "DELETE_TASK",
1350
- "CREATE_PROJECT",
1351
- "UPDATE_PROJECT",
1352
- "DELETE_PROJECT",
1353
- "CREATE_TAG",
1354
- "UPDATE_TAG",
1355
- "DELETE_TAG",
1356
- "CREATE_GOAL",
1357
- "UPDATE_GOAL",
1358
- "DELETE_GOAL",
1359
- "CREATE_MILESTONE",
1360
- "UPDATE_MILESTONE",
1361
- "DELETE_MILESTONE",
1362
- "CREATE_CHECKLIST",
1363
- "UPDATE_CHECKLIST",
1364
- "DELETE_CHECKLIST"
1365
- ];
1366
- var action = sqliteTable("action", {
1367
- ...owned_entity("action"),
1368
- type: text("type", { enum: ACTIONS }).notNull(),
1369
- description: text("description").notNull(),
1370
- data: text("data", { mode: "json" }),
1371
- channel: text("channel", { enum: ["user", "api"] }).notNull().default("user")
1372
- });
1373
- var tracker_result = sqliteTable("tracker_result", {
1374
- id: integer("id").primaryKey({ autoIncrement: true }),
1375
- project_id: text("project_id").notNull().references(() => project.id),
1376
- created_at: text("created_at").notNull().default(sql`(CURRENT_TIMESTAMP)`),
1377
- data: text("data", { mode: "json" }).notNull(),
1378
- accepted: integer("accepted", { mode: "boolean" }).notNull().default(false)
1379
- });
1380
- var todo_updates = sqliteTable("todo_updates", {
1381
- id: integer("id").primaryKey({ autoIncrement: true }),
1382
- project_id: text("project_id").notNull().references(() => project.id),
1383
- created_at: text("created_at").notNull().default(sql`(CURRENT_TIMESTAMP)`),
1384
- old_id: integer("old_id").references(() => tracker_result.id),
1385
- new_id: integer("new_id").notNull().references(() => tracker_result.id),
1386
- data: text("data", { mode: "json" }).notNull(),
1387
- status: text("status", { enum: ["PENDING", "ACCEPTED", "REJECTED", "IGNORED"] }).notNull().default("PENDING"),
1388
- branch: text("branch"),
1389
- commit_sha: text("commit_sha"),
1390
- commit_msg: text("commit_msg"),
1391
- commit_url: text("commit_url")
1392
- });
1393
- var update_tracker_relations = relations(todo_updates, ({ one }) => ({
1394
- old: one(tracker_result, { fields: [todo_updates.old_id], references: [tracker_result.id] }),
1395
- new: one(tracker_result, { fields: [todo_updates.new_id], references: [tracker_result.id] })
1396
- }));
1397
- var milestone = sqliteTable("milestone", {
1398
- ...entity("milestone"),
1399
- project_id: text("project_id").notNull().references(() => project.id),
1400
- name: text("name").notNull(),
1401
- description: text("description"),
1402
- target_time: text("target_time"),
1403
- target_version: text("target_version"),
1404
- finished_at: text("finished_at"),
1405
- after_id: text("after_id")
1406
- });
1407
- var goal = sqliteTable("goal", {
1408
- ...entity("goal"),
1409
- milestone_id: text("milestone_id").notNull().references(() => milestone.id),
1410
- name: text("name").notNull(),
1411
- description: text("description"),
1412
- target_time: text("target_time"),
1413
- finished_at: text("finished_at")
1414
- });
1415
- var task = sqliteTable("task", {
1416
- ...owned_entity("task"),
1417
- title: text("title").notNull(),
1418
- progress: text("progress", { enum: ["UNSTARTED", "IN_PROGRESS", "COMPLETED"] }).notNull().default("UNSTARTED"),
1419
- visibility: text("visibility", { enum: ["PUBLIC", "PRIVATE", "HIDDEN", "ARCHIVED", "DRAFT", "DELETED"] }).notNull().default("PRIVATE"),
1420
- goal_id: text("goal_id").references(() => goal.id),
1421
- project_id: text("project_id").references(() => project.id),
1422
- description: text("description"),
1423
- start_time: text("start_time"),
1424
- end_time: text("end_time"),
1425
- summary: text("summary"),
1426
- codebase_task_id: text("codebase_task_id").references(() => codebase_tasks.id),
1427
- priority: text("priority", { enum: ["LOW", "MEDIUM", "HIGH"] }).notNull().default("LOW")
1428
- });
1429
- var checklist = sqliteTable("checklist", {
1430
- ...entity("checklist"),
1431
- task_id: text("task_id").notNull().references(() => task.id),
1432
- name: text("name").notNull()
1433
- });
1434
- var checklist_item = sqliteTable("checklist_item", {
1435
- ...entity("checklist-item"),
1436
- checklist_id: text("checklist_id").notNull().references(() => checklist.id),
1437
- parent_id: text("parent_id"),
1438
- name: text("name").notNull(),
1439
- checked: int("checked", { mode: "boolean" }).notNull().default(false)
1440
- });
1441
- var codebase_tasks = sqliteTable("codebase_tasks", {
1442
- ...entity("codebase-task"),
1443
- branch: text("branch"),
1444
- commit_sha: text("commit_sha"),
1445
- commit_msg: text("commit_msg"),
1446
- commit_url: text("commit_url"),
1447
- type: text("type"),
1448
- text: text("text"),
1449
- file: text("file"),
1450
- line: integer("line"),
1451
- context: text("context", { mode: "json" }),
1452
- recent_scan_id: integer("recent_scan_id").references(() => tracker_result.id)
1453
- });
1454
- var tag = sqliteTable("tag", {
1455
- ...owned_entity("tag"),
1456
- title: text("title").notNull(),
1457
- color: text("color"),
1458
- render: int("render", { mode: "boolean" }).notNull().default(true)
1459
- }, (table) => ({
1460
- tag_unique: unique("tag_unique").on(table.owner_id, table.title)
1461
- }));
1462
- var task_tag = sqliteTable("task_tag", {
1463
- task_id: text("task_id").notNull().references(() => task.id),
1464
- tag_id: text("tag_id").notNull().references(() => tag.id),
1465
- ...timestamps()
1466
- }, (table) => ({
1467
- task_tag_unique: primaryKey({ columns: [table.task_id, table.tag_id] })
1468
- }));
1469
- var commit_detail = sqliteTable("commit_detail", {
1470
- sha: text("sha").primaryKey(),
1471
- message: text("message").notNull(),
1472
- url: text("url").notNull(),
1473
- avatar_url: text("avatar_url"),
1474
- author_user: text("author_user").notNull(),
1475
- author_name: text("author_name"),
1476
- author_email: text("author_email").notNull(),
1477
- date: text("date").notNull()
1478
- });
1479
- var tag_config = sqliteTable("tag_config", {
1480
- ...id("tag_config"),
1481
- project_id: text("project_id").notNull().references(() => project.id),
1482
- // Foreign key to projects
1483
- tag_id: text("tag_id").notNull().references(() => tag.id),
1484
- // Foreign key to tags
1485
- match: text("match").notNull(),
1486
- // Match pattern for this tag
1487
- ...timestamps()
1488
- });
1489
- var ignore_path = sqliteTable("ignore_path", {
1490
- ...id("ignore_path"),
1491
- project_id: text("project_id").notNull().references(() => project.id),
1492
- // Foreign key to projects
1493
- path: text("path").notNull(),
1494
- // Ignore path
1495
- ...timestamps()
1496
- });
1497
- var ROLLOUT_SHAPES = ["gradual", "atomic"];
1498
- var RUN_KINDS = ["deploy", "rollback"];
1499
- var RUN_STATUSES = ["queued", "deploying", "baking", "awaiting_approval", "rolling_back", "completed", "rolled_back", "failed", "cancelled"];
1500
- var FORCED_ATOMIC_REASONS = ["do_migrations", "asset_affinity_none"];
1501
- var STAGE_EVENT_KINDS = ["deploy_started", "deploy_completed", "bake_started", "bake_completed", "gate_verdict", "approval_requested", "rollback_started", "rollback_completed", "warning", "error"];
1502
- var APPROVAL_DECISIONS = ["approved", "denied"];
1503
- var pipeline_package = sqliteTable("pipeline_package", {
1504
- ...entity("pipeline-package"),
1505
- owner_id: text("owner_id").notNull().references(() => user.id),
1506
- name: text("name").notNull(),
1507
- repo_url: text("repo_url"),
1508
- default_template_ref: text("default_template_ref"),
1509
- script_name_overrides: text("script_name_overrides", { mode: "json" }),
1510
- project_id: text("project_id").references(() => project.id)
1511
- });
1512
- var pipeline_run = sqliteTable("pipeline_run", {
1513
- ...entity("pipeline-run"),
1514
- package_id: text("package_id").notNull().references(() => pipeline_package.id),
1515
- version_set_id: text("version_set_id").notNull(),
1516
- shape: text("shape", { enum: ROLLOUT_SHAPES }).notNull(),
1517
- kind: text("kind", { enum: RUN_KINDS }).notNull().default("deploy"),
1518
- status: text("status", { enum: RUN_STATUSES }).notNull().default("queued"),
1519
- current_stage: text("current_stage"),
1520
- resolved_rollout: text("resolved_rollout", { mode: "json" }).notNull(),
1521
- resolved_gates: text("resolved_gates", { mode: "json" }).notNull(),
1522
- forced_atomic_reason: text("forced_atomic_reason", { enum: FORCED_ATOMIC_REASONS }),
1523
- started_at: text("started_at"),
1524
- finished_at: text("finished_at")
1525
- });
1526
- var pipeline_stage_event = sqliteTable("pipeline_stage_event", {
1527
- ...id("pipeline-stage-event"),
1528
- run_id: text("run_id").notNull().references(() => pipeline_run.id),
1529
- stage_name: text("stage_name").notNull(),
1530
- kind: text("kind", { enum: STAGE_EVENT_KINDS }).notNull(),
1531
- payload: text("payload", { mode: "json" }),
1532
- ts: text("ts").notNull().default(sql`(CURRENT_TIMESTAMP)`)
1533
- });
1534
- var pipeline_grant = sqliteTable("pipeline_grant", {
1535
- ...entity("pipeline-grant"),
1536
- package_id: text("package_id").notNull().references(() => pipeline_package.id),
1537
- stage_name: text("stage_name").notNull(),
1538
- scope: text("scope").notNull(),
1539
- granted_by: text("granted_by").references(() => user.id),
1540
- granted_at: text("granted_at")
1541
- });
1542
- var pipeline_approval = sqliteTable("pipeline_approval", {
1543
- ...id("pipeline-approval"),
1544
- run_id: text("run_id").notNull().references(() => pipeline_run.id),
1545
- stage_name: text("stage_name").notNull(),
1546
- decision: text("decision", { enum: APPROVAL_DECISIONS }),
1547
- reason: text("reason"),
1548
- decided_by: text("decided_by").references(() => user.id),
1549
- decided_at: text("decided_at"),
1550
- ...timestamps()
1551
- });
1552
- var pipeline_analysis_template = sqliteTable("pipeline_analysis_template", {
1553
- ...entity("pipeline-analysis-template"),
1554
- owner_id: text("owner_id").notNull().references(() => user.id),
1555
- name: text("name").notNull(),
1556
- query_dsl: text("query_dsl", { mode: "json" }).notNull(),
1557
- threshold_dsl: text("threshold_dsl", { mode: "json" }).notNull(),
1558
- window_ms: integer("window_ms").notNull().default(6e5)
1559
- });
1560
- var PIPELINE_OIDC_PROVIDERS = ["github"];
1561
- var pipeline_oidc_trust = sqliteTable("pipeline_oidc_trust", {
1562
- ...entity("pipeline-oidc-trust"),
1563
- owner_id: text("owner_id").notNull().references(() => user.id),
1564
- provider: text("provider", { enum: PIPELINE_OIDC_PROVIDERS }).notNull().default("github"),
1565
- github_owner: text("github_owner").notNull(),
1566
- repo_pattern: text("repo_pattern").notNull().default("*"),
1567
- allowed_refs: text("allowed_refs", { mode: "json" }).$type().notNull().default(sql`'[]'`),
1568
- allowed_environments: text("allowed_environments", { mode: "json" }).$type().notNull().default(sql`'[]'`),
1569
- expected_audience: text("expected_audience").notNull(),
1570
- allowed_actions: text("allowed_actions", { mode: "json" }).$type().notNull().default(sql`'["artifacts:upload","runs:start"]'`),
1571
- session_ttl_seconds: integer("session_ttl_seconds").notNull().default(900),
1572
- last_used_at: text("last_used_at")
1573
- });
1574
- var user_relations = relations(user, ({ many }) => ({
1575
- sessions: many(session),
1576
- api_keys: many(api_keys),
1577
- actions: many(action),
1578
- tasks: many(task),
1579
- tags: many(tag)
1580
- }));
1581
- var session_relations = relations(session, ({ one }) => ({
1582
- user: one(user, { fields: [session.userId], references: [user.id] })
1583
- }));
1584
- var api_keys_relations = relations(api_keys, ({ one }) => ({
1585
- owner: one(user, { fields: [api_keys.user_id], references: [user.id] })
1586
- }));
1587
- var project_relations = relations(project, ({ one, many }) => ({
1588
- owner: one(user, { fields: [project.owner_id], references: [user.id] }),
1589
- tracker_results: many(tracker_result),
1590
- milestones: many(milestone),
1591
- todo_updates: many(todo_updates)
1592
- }));
1593
- var action_relations = relations(action, ({ one }) => ({
1594
- owner: one(user, { fields: [action.owner_id], references: [user.id] })
1595
- }));
1596
- var tracker_result_relations = relations(tracker_result, ({ one }) => ({
1597
- project: one(project, { fields: [tracker_result.project_id], references: [project.id] })
1598
- }));
1599
- var todoUpdatesRelations = relations(todo_updates, ({ one }) => ({
1600
- project: one(project, { fields: [todo_updates.project_id], references: [project.id] }),
1601
- oldTrackerResult: one(tracker_result, { fields: [todo_updates.old_id], references: [tracker_result.id] }),
1602
- newTrackerResult: one(tracker_result, { fields: [todo_updates.new_id], references: [tracker_result.id] })
1603
- }));
1604
- var milestone_relations = relations(milestone, ({ one, many }) => ({
1605
- project: one(project, { fields: [milestone.project_id], references: [project.id] }),
1606
- goals: many(goal)
1607
- }));
1608
- var goal_relations = relations(goal, ({ one }) => ({
1609
- milestone: one(milestone, { fields: [goal.milestone_id], references: [milestone.id] })
1610
- }));
1611
- var task_relations = relations(task, ({ one, many }) => ({
1612
- owner: one(user, { fields: [task.owner_id], references: [user.id] }),
1613
- goal: one(goal, { fields: [task.goal_id], references: [goal.id] }),
1614
- codebase_task: one(codebase_tasks, { fields: [task.codebase_task_id], references: [codebase_tasks.id] }),
1615
- checklists: many(checklist)
1616
- }));
1617
- var checklist_relations = relations(checklist, ({ one, many }) => ({
1618
- task: one(task, { fields: [checklist.task_id], references: [task.id] }),
1619
- items: many(checklist_item)
1620
- }));
1621
- var checklist_item_relations = relations(checklist_item, ({ one }) => ({
1622
- checklist: one(checklist, { fields: [checklist_item.checklist_id], references: [checklist.id] })
1623
- }));
1624
- var tag_relations = relations(tag, ({ one }) => ({
1625
- owner: one(user, { fields: [tag.owner_id], references: [user.id] })
1626
- }));
1627
- var task_tag_relations = relations(task_tag, ({ one }) => ({
1628
- task: one(task, { fields: [task_tag.task_id], references: [task.id] }),
1629
- tag: one(tag, { fields: [task_tag.tag_id], references: [tag.id] })
1630
- }));
1631
- var pipeline_package_relations = relations(pipeline_package, ({ one, many }) => ({
1632
- owner: one(user, { fields: [pipeline_package.owner_id], references: [user.id] }),
1633
- runs: many(pipeline_run),
1634
- grants: many(pipeline_grant)
1635
- }));
1636
- var pipeline_run_relations = relations(pipeline_run, ({ one, many }) => ({
1637
- package: one(pipeline_package, { fields: [pipeline_run.package_id], references: [pipeline_package.id] }),
1638
- events: many(pipeline_stage_event),
1639
- approvals: many(pipeline_approval)
1640
- }));
1641
- var pipeline_stage_event_relations = relations(pipeline_stage_event, ({ one }) => ({
1642
- run: one(pipeline_run, { fields: [pipeline_stage_event.run_id], references: [pipeline_run.id] })
1643
- }));
1644
- var pipeline_grant_relations = relations(pipeline_grant, ({ one }) => ({
1645
- package: one(pipeline_package, { fields: [pipeline_grant.package_id], references: [pipeline_package.id] }),
1646
- granted_by_user: one(user, { fields: [pipeline_grant.granted_by], references: [user.id] })
1647
- }));
1648
- var pipeline_approval_relations = relations(pipeline_approval, ({ one }) => ({
1649
- run: one(pipeline_run, { fields: [pipeline_approval.run_id], references: [pipeline_run.id] }),
1650
- decided_by_user: one(user, { fields: [pipeline_approval.decided_by], references: [user.id] })
1651
- }));
1652
- var pipeline_analysis_template_relations = relations(pipeline_analysis_template, ({ one }) => ({
1653
- owner: one(user, { fields: [pipeline_analysis_template.owner_id], references: [user.id] })
1654
- }));
1655
- var pipeline_oidc_trust_relations = relations(pipeline_oidc_trust, ({ one }) => ({
1656
- owner: one(user, { fields: [pipeline_oidc_trust.owner_id], references: [user.id] })
1657
- }));
1658
-
1659
1344
  // src/tools.ts
1660
1345
  import { z } from "zod";
1661
1346
  function unwrap(result) {
@@ -1842,9 +1527,9 @@ var tools = {
1842
1527
  id: z.string().describe("Project ID")
1843
1528
  }),
1844
1529
  execute: async (client, input) => {
1845
- const project2 = unwrap(await client.projects.find(input.id));
1846
- if (!project2) throw new Error(`Project ${input.id} not found`);
1847
- unwrap(await client.projects.deleteProject(project2));
1530
+ const project = unwrap(await client.projects.find(input.id));
1531
+ if (!project) throw new Error(`Project ${input.id} not found`);
1532
+ unwrap(await client.projects.deleteProject(project));
1848
1533
  return { success: true };
1849
1534
  }
1850
1535
  },
@@ -1906,9 +1591,9 @@ var tools = {
1906
1591
  id: z.string().describe("Task ID")
1907
1592
  }),
1908
1593
  execute: async (client, input) => {
1909
- const task2 = unwrap(await client.tasks.find(input.id));
1910
- if (!task2) throw new Error(`Task ${input.id} not found`);
1911
- unwrap(await client.tasks.deleteTask(task2));
1594
+ const task = unwrap(await client.tasks.find(input.id));
1595
+ if (!task) throw new Error(`Task ${input.id} not found`);
1596
+ unwrap(await client.tasks.deleteTask(task));
1912
1597
  return { success: true };
1913
1598
  }
1914
1599
  },
@@ -2082,8 +1767,8 @@ var tools = {
2082
1767
  slug: z.string().optional().describe("Profile slug")
2083
1768
  }),
2084
1769
  execute: async (client, input) => {
2085
- const { id: id2, ...data } = input;
2086
- return unwrap(await client.media.profiles.update(id2, data));
1770
+ const { id, ...data } = input;
1771
+ return unwrap(await client.media.profiles.update(id, data));
2087
1772
  }
2088
1773
  },
2089
1774
  devpad_media_profiles_delete: {
@@ -2282,6 +1967,33 @@ var tools = {
2282
1967
  return { success: true };
2283
1968
  }
2284
1969
  },
1970
+ devpad_pipelines_runs_events_ingest: {
1971
+ name: "devpad_pipelines_runs_events_ingest",
1972
+ description: 'Ingest an external webhook event against an in-flight pipeline run. Idempotent on (idempotency_key, payload). Server-side stamps payload.source = "external".',
1973
+ inputSchema: z.object({
1974
+ run_id: z.string().describe("Pipeline run ID"),
1975
+ stage_name: z.string().min(1).describe("Stage the event is associated with"),
1976
+ kind: z.enum(STAGE_EVENT_KINDS).describe("Event kind from STAGE_EVENT_KINDS"),
1977
+ payload: z.unknown().optional().describe("Arbitrary JSON payload \u2014 server-side stamps source = external"),
1978
+ idempotency_key: z.string().uuid().describe("UUID idempotency key; reuse with the same payload returns duplicated:true")
1979
+ }),
1980
+ execute: async (client, input) => unwrap(
1981
+ await client.pipelines.events.ingest(input.run_id, {
1982
+ stage_name: input.stage_name,
1983
+ kind: input.kind,
1984
+ payload: input.payload,
1985
+ idempotency_key: input.idempotency_key
1986
+ })
1987
+ )
1988
+ },
1989
+ devpad_pipelines_runs_events_list: {
1990
+ name: "devpad_pipelines_runs_events_list",
1991
+ description: "List stored stage events for a pipeline run, newest-first",
1992
+ inputSchema: z.object({
1993
+ run_id: z.string().describe("Pipeline run ID")
1994
+ }),
1995
+ execute: async (client, input) => unwrap(await client.pipelines.events.list(input.run_id))
1996
+ },
2285
1997
  devpad_pipelines_grants_list: {
2286
1998
  name: "devpad_pipelines_grants_list",
2287
1999
  description: "List vault grants for a pipeline package",
@@ -2349,8 +2061,8 @@ var tools = {
2349
2061
  script_name_overrides: z.record(z.string(), z.string()).nullable().optional()
2350
2062
  }),
2351
2063
  execute: async (client, input) => {
2352
- const { id: id2, ...patch } = input;
2353
- return unwrap(await client.pipelines.packages.update(id2, patch));
2064
+ const { id, ...patch } = input;
2065
+ return unwrap(await client.pipelines.packages.update(id, patch));
2354
2066
  }
2355
2067
  },
2356
2068
  devpad_pipelines_packages_delete: {
@@ -2361,6 +2073,60 @@ var tools = {
2361
2073
  }),
2362
2074
  execute: async (client, input) => unwrap(await client.pipelines.packages.delete(input.id))
2363
2075
  },
2076
+ devpad_pipelines_analysis_templates_list: {
2077
+ name: "devpad_pipelines_analysis_templates_list",
2078
+ description: "List pipeline analysis templates for an owner. Each row encodes the threshold DSL + window referenced by analysis-gate evaluations.",
2079
+ inputSchema: z.object({
2080
+ owner_id: z.string().describe("Devpad user ID whose templates to list")
2081
+ }),
2082
+ execute: async (client, input) => unwrap(await client.pipelines.analysis_templates.list(input))
2083
+ },
2084
+ devpad_pipelines_analysis_templates_get: {
2085
+ name: "devpad_pipelines_analysis_templates_get",
2086
+ description: "Get a single pipeline analysis template by id, scoped to its owner.",
2087
+ inputSchema: z.object({
2088
+ id: z.string().describe("Pipeline analysis template ID"),
2089
+ owner_id: z.string().describe("Owner ID (must match the template's owner)")
2090
+ }),
2091
+ 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: {
2094
+ name: "devpad_pipelines_analysis_templates_create",
2095
+ 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
+ inputSchema: z.object({
2097
+ owner_id: z.string().describe("Devpad user ID who owns this template"),
2098
+ name: z.string().describe('Human-readable name (e.g. "default-analysis")'),
2099
+ threshold_dsl: z.string().describe("Multi-line threshold DSL"),
2100
+ query_dsl: z.unknown().optional().describe("Optional structured query DSL stored alongside thresholds"),
2101
+ window_ms: z.number().int().positive().optional().describe("Analysis window in milliseconds. Default: 600000")
2102
+ }),
2103
+ execute: async (client, input) => unwrap(await client.pipelines.analysis_templates.create(input))
2104
+ },
2105
+ devpad_pipelines_analysis_templates_update: {
2106
+ name: "devpad_pipelines_analysis_templates_update",
2107
+ description: "Partially update a pipeline analysis template. Only the supplied fields are touched. Re-validates threshold_dsl when present.",
2108
+ inputSchema: z.object({
2109
+ id: z.string().describe("Pipeline analysis template ID"),
2110
+ owner_id: z.string().describe("Owner ID (must match the template's owner)"),
2111
+ name: z.string().optional(),
2112
+ threshold_dsl: z.string().optional(),
2113
+ query_dsl: z.unknown().optional(),
2114
+ window_ms: z.number().int().positive().optional()
2115
+ }),
2116
+ execute: async (client, input) => {
2117
+ const { id, ...patch } = input;
2118
+ return unwrap(await client.pipelines.analysis_templates.update(id, patch));
2119
+ }
2120
+ },
2121
+ devpad_pipelines_analysis_templates_delete: {
2122
+ name: "devpad_pipelines_analysis_templates_delete",
2123
+ 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
+ inputSchema: z.object({
2125
+ id: z.string().describe("Pipeline analysis template ID"),
2126
+ owner_id: z.string().describe("Owner ID (must match the template's owner)")
2127
+ }),
2128
+ execute: async (client, input) => unwrap(await client.pipelines.analysis_templates.delete(input.id, { owner_id: input.owner_id }))
2129
+ },
2364
2130
  devpad_pipelines_oidc_trust_list: {
2365
2131
  name: "devpad_pipelines_oidc_trust_list",
2366
2132
  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.",
@@ -2399,8 +2165,8 @@ var tools = {
2399
2165
  session_ttl_seconds: z.number().int().positive().optional()
2400
2166
  }),
2401
2167
  execute: async (client, input) => {
2402
- const { id: id2, ...patch } = input;
2403
- return unwrap(await client.pipelines.oidc_trust.update(id2, patch));
2168
+ const { id, ...patch } = input;
2169
+ return unwrap(await client.pipelines.oidc_trust.update(id, patch));
2404
2170
  }
2405
2171
  },
2406
2172
  devpad_pipelines_oidc_trust_delete: {