@devpad/api 2.3.4 → 2.3.6

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.
@@ -44,7 +44,8 @@ var isUnauthorizedError = (e) => hasKind(e, "unauthorized");
44
44
  var isScanError = (e) => hasKind(e, "scan_error");
45
45
  var isGithubError = (e) => hasKind(e, "github_error");
46
46
  var isValidationFieldError = (e) => hasKind(e, "validation_error");
47
- var isServiceError = (e) => isNotFoundError(e) || isForbiddenError(e) || isValidationError(e) || isValidationFieldError(e) || isRateLimitedError(e) || isStoreError(e) || isNetworkError(e) || isAuthExpiredError(e) || isApiError(e) || isParseError(e) || isEncryptionError(e) || isDatabaseError(e) || isConflictError(e) || isProtectedError(e) || isBadRequestError(e) || isUnauthorizedError(e) || isScanError(e) || isGithubError(e);
47
+ var isApprovalChannelError = (e) => hasKind(e, "approval_channel");
48
+ var isServiceError = (e) => isNotFoundError(e) || isForbiddenError(e) || isValidationError(e) || isValidationFieldError(e) || isRateLimitedError(e) || isStoreError(e) || isNetworkError(e) || isAuthExpiredError(e) || isApiError(e) || isParseError(e) || isEncryptionError(e) || isDatabaseError(e) || isConflictError(e) || isProtectedError(e) || isBadRequestError(e) || isUnauthorizedError(e) || isScanError(e) || isGithubError(e) || isApprovalChannelError(e);
48
49
  var isRetryableError = (e) => isRateLimitedError(e) || isNetworkError(e);
49
50
  var notFound = (resource, id, ctx) => logAndReturn({ kind: "not_found", resource, ...id && { id } }, ctx);
50
51
  var forbidden = (reason, ctx) => logAndReturn({ kind: "forbidden", ...reason && { reason, message: reason } }, ctx);
@@ -70,6 +71,11 @@ var unauthorized = (message, ctx) => logAndReturn({ kind: "unauthorized", ...mes
70
71
  var scanError = (message, ctx) => logAndReturn({ kind: "scan_error", ...message && { message } }, ctx);
71
72
  var githubError = (message, ctx) => logAndReturn({ kind: "github_error", ...message && { message } }, ctx);
72
73
  var validationFieldError = (field, message, ctx) => logAndReturn({ kind: "validation_error", field, ...message && { message } }, ctx);
74
+ var approvalChannel = (task_id, message, ctx) => logAndReturn({
75
+ kind: "approval_channel",
76
+ task_id,
77
+ message: message ?? `Task ${task_id} is an approval node \u2014 only a human (auth_channel=user) may complete it`
78
+ }, ctx);
73
79
  var errors = {
74
80
  notFound,
75
81
  forbidden,
@@ -89,6 +95,7 @@ var errors = {
89
95
  scanError,
90
96
  githubError,
91
97
  validationFieldError,
98
+ approvalChannel,
92
99
  is: {
93
100
  notFound: isNotFoundError,
94
101
  forbidden: isForbiddenError,
@@ -108,6 +115,7 @@ var errors = {
108
115
  unauthorized: isUnauthorizedError,
109
116
  scanError: isScanError,
110
117
  githubError: isGithubError,
118
+ approvalChannel: isApprovalChannelError,
111
119
  serviceError: isServiceError,
112
120
  retryable: isRetryableError
113
121
  }
@@ -133,6 +141,7 @@ export {
133
141
  isScanError,
134
142
  isGithubError,
135
143
  isValidationFieldError,
144
+ isApprovalChannelError,
136
145
  isServiceError,
137
146
  isRetryableError,
138
147
  notFound,
@@ -153,5 +162,6 @@ export {
153
162
  scanError,
154
163
  githubError,
155
164
  validationFieldError,
165
+ approvalChannel,
156
166
  errors
157
167
  };
@@ -52,6 +52,11 @@ var api_keys = sqliteTable("api_keys", {
52
52
  name: text("name"),
53
53
  note: text("note"),
54
54
  scope: text("scope", { enum: ["devpad", "blog", "media", "pulse", "all"] }).notNull().default("all"),
55
+ // v2.4 (task A3.1): nullable project scope. `null` = legacy all-projects
56
+ // key, behaves exactly as before. Non-null keys are rejected by the
57
+ // scope guard (`packages/worker/src/middleware/scope-guard.ts`) on any
58
+ // resource belonging to a different project.
59
+ project_id: text("project_id").references(() => project.id),
55
60
  enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
56
61
  last_used_at: text("last_used_at"),
57
62
  ...timestamps(),
@@ -71,7 +76,11 @@ var project = sqliteTable("project", {
71
76
  link_text: text("link_text"),
72
77
  visibility: text("visibility", { enum: ["PUBLIC", "PRIVATE", "HIDDEN", "ARCHIVED", "DRAFT", "DELETED"] }).notNull().default("PRIVATE"),
73
78
  current_version: text("current_version"),
74
- scan_branch: text("scan_branch")
79
+ scan_branch: text("scan_branch"),
80
+ // v2.4 (task A3.6) — per-project opt-in, OFF by default: a merged PR
81
+ // completes its linked task automatically via the GitHub App inbound
82
+ // webhook. Diff-linked status because agents are unreliable narrators.
83
+ github_autoclose: integer("github_autoclose", { mode: "boolean" }).notNull().default(false)
75
84
  });
76
85
  var ACTIONS = [
77
86
  "CREATE_TASK",
@@ -91,7 +100,11 @@ var ACTIONS = [
91
100
  "DELETE_MILESTONE",
92
101
  "CREATE_CHECKLIST",
93
102
  "UPDATE_CHECKLIST",
94
- "DELETE_CHECKLIST"
103
+ "DELETE_CHECKLIST",
104
+ // v2.4 (task A4.5) — audit row for every stage transition, gated or
105
+ // overridden. Written regardless of auth_channel so the AI Activity Feed
106
+ // (`channel` column) can distinguish an agent-driven override.
107
+ "ADVANCE_STAGE"
95
108
  ];
96
109
  var action = sqliteTable("action", {
97
110
  ...owned_entity("action"),
@@ -148,6 +161,7 @@ var TASK_KINDS = ["task", "phase", "approval"];
148
161
  var COMPLETION_POLICIES = ["manual", "auto_children"];
149
162
  var COMPLETED_VIA_VALUES = ["user", "api", "policy"];
150
163
  var TASK_LINK_KINDS = ["blocks", "relates_to", "references", "discovered_from", "tracks_metric"];
164
+ var SDLC_STAGES = ["ideate", "plan", "build", "review", "deploy", "live"];
151
165
  var task = sqliteTable("task", {
152
166
  ...owned_entity("task"),
153
167
  title: text("title").notNull(),
@@ -171,7 +185,10 @@ var task = sqliteTable("task", {
171
185
  completion_policy: text("completion_policy", { enum: COMPLETION_POLICIES }).notNull().default("manual"),
172
186
  completed_via: text("completed_via", { enum: COMPLETED_VIA_VALUES }),
173
187
  claimed_by: text("claimed_by"),
174
- claimed_at: text("claimed_at")
188
+ claimed_at: text("claimed_at"),
189
+ // v2.4 (task A4.5) — nullable: opting a task into SDLC stage tracking is
190
+ // per-task, not a blanket migration.
191
+ stage: text("stage", { enum: SDLC_STAGES })
175
192
  }, (table) => [index("task_parent_id_idx").on(table.parent_id)]);
176
193
  var task_link = sqliteTable("task_link", {
177
194
  ...entity("link"),
@@ -208,7 +225,15 @@ var TASK_EVENT_KINDS = [
208
225
  "edge.removed",
209
226
  "node.children_all_done",
210
227
  "policy.fired",
211
- "node.completion_stale"
228
+ "node.completion_stale",
229
+ // v2.4 (task A4) — docs/annotation/signoff/stage events. Hooks can bind to
230
+ // any of these exactly like a graph event; no new dispatch machinery.
231
+ "doc.pushed",
232
+ "thread.opened",
233
+ "thread.resolved",
234
+ "signoff.requested",
235
+ "signoff.decided",
236
+ "stage.advanced"
212
237
  ];
213
238
  var TASK_EVENT_ACTORS = ["user", "api", "policy", "github"];
214
239
  var TASK_EVENT_DISPATCH_STATUSES = ["pending", "dispatched"];
@@ -227,6 +252,88 @@ var task_event = sqliteTable("task_event", {
227
252
  index("task_event_subject_id_idx").on(table.subject_id),
228
253
  index("task_event_dispatch_status_idx").on(table.dispatch_status)
229
254
  ]);
255
+ var hook = sqliteTable("hook", {
256
+ ...entity("hook"),
257
+ project_id: text("project_id").notNull().references(() => project.id),
258
+ enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
259
+ // HookTrigger: { kinds: TaskEventKind[], selector: { subject_kind?, tag?, ancestor_id? } }
260
+ trigger: text("trigger", { mode: "json" }).notNull(),
261
+ // HookAction: { kind: "webhook", url, secret_encrypted? } | { kind: "vault", scope, op, args? } | { kind: "pipeline", package_id }
262
+ action: text("action", { mode: "json" }).notNull()
263
+ }, (table) => [index("hook_project_id_idx").on(table.project_id)]);
264
+ var HOOK_DELIVERY_STATUSES = ["pending", "delivered", "failed_transient", "failed_permanent"];
265
+ var hook_delivery = sqliteTable("hook_delivery", {
266
+ // PK = sha256(`${event_id}:${hook_id}`) — see hooks/dispatch.ts's
267
+ // `hook_delivery_id`. Never generated any other way.
268
+ id: text("id").primaryKey(),
269
+ hook_id: text("hook_id").notNull().references(() => hook.id),
270
+ event_id: text("event_id").notNull(),
271
+ status: text("status", { enum: HOOK_DELIVERY_STATUSES }).notNull().default("pending"),
272
+ attempts: integer("attempts").notNull().default(0),
273
+ last_error: text("last_error"),
274
+ ...timestamps()
275
+ }, (table) => [
276
+ index("hook_delivery_hook_id_idx").on(table.hook_id),
277
+ index("hook_delivery_status_idx").on(table.status)
278
+ ]);
279
+ var github_webhook_event = sqliteTable("github_webhook_event", {
280
+ id: text("id").primaryKey(),
281
+ delivery_guid: text("delivery_guid").notNull(),
282
+ event_type: text("event_type").notNull(),
283
+ processed_at: text("processed_at").notNull().default(sql`(CURRENT_TIMESTAMP)`)
284
+ }, (table) => [index("github_webhook_event_delivery_guid_idx").on(table.delivery_guid)]);
285
+ var DOCUMENT_KINDS = ["plan", "design", "interface"];
286
+ var DOCUMENT_STATUSES = ["draft", "in_review", "approved"];
287
+ var document = sqliteTable("document", {
288
+ ...entity("doc"),
289
+ project_id: text("project_id").notNull().references(() => project.id),
290
+ // Nullable subject node — a doc need not be tied to a specific task
291
+ // (e.g. a project-level design doc).
292
+ task_id: text("task_id").references(() => task.id),
293
+ kind: text("kind", { enum: DOCUMENT_KINDS }).notNull(),
294
+ title: text("title").notNull(),
295
+ // Corpus version pointer cache — the DB never stores content, only the
296
+ // latest corpus snapshot version for this document's dedicated store
297
+ // (`docStoreId`). Null until the first push.
298
+ head_version: text("head_version"),
299
+ status: text("status", { enum: DOCUMENT_STATUSES }).notNull().default("draft")
300
+ }, (table) => [index("document_project_id_idx").on(table.project_id), index("document_task_id_idx").on(table.task_id)]);
301
+ var THREAD_STATUSES = ["open", "addressed", "resolved", "orphaned"];
302
+ var annotation_thread = sqliteTable("annotation_thread", {
303
+ ...id("thread"),
304
+ document_id: text("document_id").notNull().references(() => document.id),
305
+ // The marker's own `id` field (embedded in the doc) — stable across
306
+ // versions/re-anchoring, distinct from this row's own DB id.
307
+ thread_id: text("thread_id").notNull(),
308
+ status: text("status", { enum: THREAD_STATUSES }).notNull().default("open"),
309
+ blocking: int("blocking", { mode: "boolean" }).notNull().default(false),
310
+ ...timestamps()
311
+ }, (table) => [
312
+ unique("annotation_thread_unique").on(table.document_id, table.thread_id),
313
+ index("annotation_thread_document_id_idx").on(table.document_id),
314
+ index("annotation_thread_status_idx").on(table.status)
315
+ ]);
316
+ var SIGNOFF_SUBJECT_KINDS = ["doc_version", "stage", "pipeline_gate"];
317
+ var SIGNOFF_CHECKPOINTS = ["plan", "types", "design"];
318
+ var SIGNOFF_DECISIONS = ["approved", "changes_requested", "auto"];
319
+ var signoff = sqliteTable("signoff", {
320
+ ...entity("signoff"),
321
+ subject_kind: text("subject_kind", { enum: SIGNOFF_SUBJECT_KINDS }).notNull(),
322
+ subject_id: text("subject_id").notNull(),
323
+ checkpoint: text("checkpoint", { enum: SIGNOFF_CHECKPOINTS }).notNull(),
324
+ // The `kind:"approval"` task node this checkpoint projects into the
325
+ // graph — null only for the brief window before `request_checkpoint`
326
+ // finishes creating it (never persisted mid-transaction in practice).
327
+ task_id: text("task_id").references(() => task.id),
328
+ decision: text("decision", { enum: SIGNOFF_DECISIONS }),
329
+ decided_by: text("decided_by").references(() => user.id),
330
+ decided_at: text("decided_at"),
331
+ reason: text("reason"),
332
+ content_hash: text("content_hash")
333
+ }, (table) => [
334
+ index("signoff_subject_idx").on(table.subject_kind, table.subject_id),
335
+ index("signoff_task_id_idx").on(table.task_id)
336
+ ]);
230
337
  var checklist = sqliteTable("checklist", {
231
338
  ...entity("checklist"),
232
339
  task_id: text("task_id").notNull().references(() => task.id),
@@ -425,6 +532,13 @@ var task_rollup_relations = relations(task_rollup, ({ one }) => ({
425
532
  var task_event_relations = relations(task_event, ({ one }) => ({
426
533
  subject: one(task, { fields: [task_event.subject_id], references: [task.id] })
427
534
  }));
535
+ var hook_relations = relations(hook, ({ one, many }) => ({
536
+ project: one(project, { fields: [hook.project_id], references: [project.id] }),
537
+ deliveries: many(hook_delivery)
538
+ }));
539
+ var hook_delivery_relations = relations(hook_delivery, ({ one }) => ({
540
+ hook: one(hook, { fields: [hook_delivery.hook_id], references: [hook.id] })
541
+ }));
428
542
  var checklist_relations = relations(checklist, ({ one, many }) => ({
429
543
  task: one(task, { fields: [checklist.task_id], references: [task.id] }),
430
544
  items: many(checklist_item)
@@ -466,6 +580,18 @@ var pipeline_analysis_template_relations = relations(pipeline_analysis_template,
466
580
  var pipeline_oidc_trust_relations = relations(pipeline_oidc_trust, ({ one }) => ({
467
581
  owner: one(user, { fields: [pipeline_oidc_trust.owner_id], references: [user.id] })
468
582
  }));
583
+ var document_relations = relations(document, ({ one, many }) => ({
584
+ project: one(project, { fields: [document.project_id], references: [project.id] }),
585
+ task: one(task, { fields: [document.task_id], references: [task.id] }),
586
+ threads: many(annotation_thread)
587
+ }));
588
+ var annotation_thread_relations = relations(annotation_thread, ({ one }) => ({
589
+ document: one(document, { fields: [annotation_thread.document_id], references: [document.id] })
590
+ }));
591
+ var signoff_relations = relations(signoff, ({ one }) => ({
592
+ task: one(task, { fields: [signoff.task_id], references: [task.id] }),
593
+ decided_by_user: one(user, { fields: [signoff.decided_by], references: [user.id] })
594
+ }));
469
595
 
470
596
  // ../schema/dist/validation.js
471
597
  import { z } from "zod";
@@ -803,8 +929,156 @@ var task_event_payload = z.discriminatedUnion("kind", [
803
929
  z.object({ kind: z.literal("edge.removed"), link_kind: task_link_kind, dst_id: z.string().nullable() }),
804
930
  z.object({ kind: z.literal("node.children_all_done") }),
805
931
  z.object({ kind: z.literal("policy.fired"), policy: z.enum(COMPLETION_POLICIES) }),
806
- z.object({ kind: z.literal("node.completion_stale"), child_id: z.string() })
932
+ z.object({ kind: z.literal("node.completion_stale"), child_id: z.string() }),
933
+ z.object({ kind: z.literal("doc.pushed"), document_id: z.string(), version: z.string() }),
934
+ z.object({ kind: z.literal("thread.opened"), document_id: z.string(), thread_id: z.string() }),
935
+ z.object({ kind: z.literal("thread.resolved"), document_id: z.string(), thread_id: z.string() }),
936
+ z.object({
937
+ kind: z.literal("signoff.requested"),
938
+ subject_kind: z.enum(SIGNOFF_SUBJECT_KINDS),
939
+ subject_id: z.string(),
940
+ checkpoint: z.enum(SIGNOFF_CHECKPOINTS)
941
+ }),
942
+ z.object({
943
+ kind: z.literal("signoff.decided"),
944
+ subject_kind: z.enum(SIGNOFF_SUBJECT_KINDS),
945
+ subject_id: z.string(),
946
+ checkpoint: z.enum(SIGNOFF_CHECKPOINTS),
947
+ decision: z.enum(SIGNOFF_DECISIONS)
948
+ }),
949
+ z.object({
950
+ kind: z.literal("stage.advanced"),
951
+ from: z.enum(SDLC_STAGES).nullable(),
952
+ to: z.enum(SDLC_STAGES),
953
+ override: z.boolean()
954
+ })
807
955
  ]);
956
+ var document_kind = z.enum(DOCUMENT_KINDS);
957
+ var push_doc_request = z.object({
958
+ document_id: z.string().optional(),
959
+ project_id: z.string(),
960
+ task_id: z.string().nullable().optional(),
961
+ kind: document_kind,
962
+ title: z.string().min(1),
963
+ html: z.string()
964
+ });
965
+ var thread_anchor = z.object({
966
+ quote: z.string().min(1),
967
+ prefix: z.string(),
968
+ suffix: z.string(),
969
+ start: z.number().int().nonnegative(),
970
+ end: z.number().int().nonnegative()
971
+ });
972
+ var thread_entry = z.object({
973
+ author: z.string().min(1),
974
+ channel: z.enum(["user", "api"]),
975
+ body: z.string().min(1),
976
+ at: z.string()
977
+ });
978
+ var thread_status = z.enum(THREAD_STATUSES);
979
+ var thread_marker = z.object({
980
+ id: z.string().min(1),
981
+ anchor: thread_anchor,
982
+ status: thread_status,
983
+ blocking: z.boolean(),
984
+ entries: z.array(thread_entry).min(1)
985
+ });
986
+ var create_thread_request = z.object({
987
+ quote: z.string().min(1),
988
+ prefix: z.string(),
989
+ suffix: z.string(),
990
+ start: z.number().int().nonnegative(),
991
+ end: z.number().int().nonnegative(),
992
+ body: z.string().min(1),
993
+ blocking: z.boolean().optional().default(false)
994
+ });
995
+ var reply_thread_request = z.object({ body: z.string().min(1) });
996
+ var toggle_blocking_request = z.object({ blocking: z.boolean() });
997
+ var signoff_subject_kind = z.enum(SIGNOFF_SUBJECT_KINDS);
998
+ var signoff_checkpoint = z.enum(SIGNOFF_CHECKPOINTS);
999
+ var request_checkpoint_request = z.object({
1000
+ project_id: z.string(),
1001
+ subject_kind: signoff_subject_kind,
1002
+ subject_id: z.string(),
1003
+ checkpoint: signoff_checkpoint,
1004
+ // Explicit, not inferred (architecture-decisions) — the caller names the
1005
+ // downstream task ids this checkpoint's approval node blocks.
1006
+ blocks: z.array(z.string()).default([])
1007
+ });
1008
+ var decide_checkpoint_request = z.object({
1009
+ decision: z.union([z.literal("approved"), z.literal("changes_requested")]),
1010
+ reason: z.string().optional()
1011
+ });
1012
+ var sdlc_stage = z.enum(SDLC_STAGES);
1013
+ var advance_stage_request = z.object({
1014
+ to: sdlc_stage,
1015
+ override: z.boolean().optional().default(false),
1016
+ reason: z.string().optional()
1017
+ });
1018
+ var push_interface_report_request = z.object({
1019
+ document_id: z.string().optional(),
1020
+ project_id: z.string(),
1021
+ task_id: z.string().nullable().optional(),
1022
+ title: z.string().min(1),
1023
+ normalized: z.string()
1024
+ });
1025
+ var INTERFACE_DIFF_CLASSES = ["additive", "breaking", "unchanged"];
1026
+ var REVIEW_ITEM_KINDS = ["signoff", "annotation", "pipeline_gate", "scan_diff"];
1027
+ var review_item = z.object({
1028
+ kind: z.enum(REVIEW_ITEM_KINDS),
1029
+ subject_id: z.string(),
1030
+ title: z.string(),
1031
+ project_id: z.string().nullable(),
1032
+ created_at: z.string(),
1033
+ path: z.string()
1034
+ });
1035
+ var reviews_pending_response = z.object({ items: z.array(review_item) });
1036
+ var hook_selector = z.object({
1037
+ subject_kind: z.enum(TASK_KINDS).optional(),
1038
+ tag: z.string().optional(),
1039
+ ancestor_id: z.string().optional()
1040
+ });
1041
+ var hook_trigger = z.object({
1042
+ kinds: z.array(z.enum(TASK_EVENT_KINDS)).min(1),
1043
+ selector: hook_selector.default({})
1044
+ });
1045
+ var hook_action_input = z.discriminatedUnion("kind", [
1046
+ z.object({ kind: z.literal("webhook"), url: z.string().url(), secret: z.string().min(1).optional() }),
1047
+ z.object({
1048
+ kind: z.literal("vault"),
1049
+ scope: z.string().min(1),
1050
+ op: z.string().min(1),
1051
+ args: z.record(z.string(), z.unknown()).optional()
1052
+ }),
1053
+ z.object({ kind: z.literal("pipeline"), package_id: z.string().min(1) })
1054
+ ]);
1055
+ var hook_action_stored = z.discriminatedUnion("kind", [
1056
+ z.object({ kind: z.literal("webhook"), url: z.string().url(), secret_encrypted: z.string().optional() }),
1057
+ z.object({
1058
+ kind: z.literal("vault"),
1059
+ scope: z.string().min(1),
1060
+ op: z.string().min(1),
1061
+ args: z.record(z.string(), z.unknown()).optional()
1062
+ }),
1063
+ z.object({ kind: z.literal("pipeline"), package_id: z.string().min(1) })
1064
+ ]);
1065
+ var hook_action_public = z.discriminatedUnion("kind", [
1066
+ z.object({ kind: z.literal("webhook"), url: z.string().url(), has_secret: z.boolean() }),
1067
+ z.object({
1068
+ kind: z.literal("vault"),
1069
+ scope: z.string().min(1),
1070
+ op: z.string().min(1),
1071
+ args: z.record(z.string(), z.unknown()).optional()
1072
+ }),
1073
+ z.object({ kind: z.literal("pipeline"), package_id: z.string().min(1) })
1074
+ ]);
1075
+ var upsert_hook = z.object({
1076
+ id: z.string().optional(),
1077
+ project_id: z.string(),
1078
+ enabled: z.boolean().default(true),
1079
+ trigger: hook_trigger,
1080
+ action: hook_action_input
1081
+ });
808
1082
 
809
1083
  export {
810
1084
  GRAPH_DEPTH_CAP,
@@ -852,5 +1126,31 @@ export {
852
1126
  claim_request,
853
1127
  done_request,
854
1128
  task_event_actor,
855
- task_event_payload
1129
+ task_event_payload,
1130
+ document_kind,
1131
+ push_doc_request,
1132
+ thread_anchor,
1133
+ thread_entry,
1134
+ thread_status,
1135
+ thread_marker,
1136
+ create_thread_request,
1137
+ reply_thread_request,
1138
+ toggle_blocking_request,
1139
+ signoff_subject_kind,
1140
+ signoff_checkpoint,
1141
+ request_checkpoint_request,
1142
+ decide_checkpoint_request,
1143
+ sdlc_stage,
1144
+ advance_stage_request,
1145
+ push_interface_report_request,
1146
+ INTERFACE_DIFF_CLASSES,
1147
+ REVIEW_ITEM_KINDS,
1148
+ review_item,
1149
+ reviews_pending_response,
1150
+ hook_selector,
1151
+ hook_trigger,
1152
+ hook_action_input,
1153
+ hook_action_stored,
1154
+ hook_action_public,
1155
+ upsert_hook
856
1156
  };
@@ -73,7 +73,11 @@ type ValidationFieldError = BaseError & {
73
73
  kind: "validation_error";
74
74
  field: string;
75
75
  };
76
- type ServiceError = NotFoundError | ForbiddenError | ValidationError | ValidationFieldError | RateLimitedError | StoreError | NetworkError | AuthExpiredError | ApiError | ParseError | EncryptionError | DatabaseError | ConflictError | ProtectedError | BadRequestError | UnauthorizedError | ScanError | GithubError;
76
+ type ApprovalChannelError = BaseError & {
77
+ kind: "approval_channel";
78
+ task_id: string;
79
+ };
80
+ type ServiceError = NotFoundError | ForbiddenError | ValidationError | ValidationFieldError | RateLimitedError | StoreError | NetworkError | AuthExpiredError | ApiError | ParseError | EncryptionError | DatabaseError | ConflictError | ProtectedError | BadRequestError | UnauthorizedError | ScanError | GithubError | ApprovalChannelError;
77
81
  type ProviderError = RateLimitedError | AuthExpiredError | NetworkError | ApiError | ParseError;
78
82
  type CronError = StoreError | NetworkError | AuthExpiredError | EncryptionError;
79
83
  type ErrorContext = {
@@ -111,6 +115,7 @@ declare const isUnauthorizedError: (e: unknown) => e is UnauthorizedError;
111
115
  declare const isScanError: (e: unknown) => e is ScanError;
112
116
  declare const isGithubError: (e: unknown) => e is GithubError;
113
117
  declare const isValidationFieldError: (e: unknown) => e is ValidationFieldError;
118
+ declare const isApprovalChannelError: (e: unknown) => e is ApprovalChannelError;
114
119
  declare const isServiceError: (e: unknown) => e is ServiceError;
115
120
  declare const isRetryableError: (e: unknown) => boolean;
116
121
  declare const notFound: (resource: string, id?: string, ctx?: Record<string, unknown>) => Result<never, NotFoundError>;
@@ -131,6 +136,7 @@ declare const unauthorized: (message?: string, ctx?: Record<string, unknown>) =>
131
136
  declare const scanError: (message?: string, ctx?: Record<string, unknown>) => Result<never, ScanError>;
132
137
  declare const githubError: (message?: string, ctx?: Record<string, unknown>) => Result<never, GithubError>;
133
138
  declare const validationFieldError: (field: string, message?: string, ctx?: Record<string, unknown>) => Result<never, ValidationFieldError>;
139
+ declare const approvalChannel: (task_id: string, message?: string, ctx?: Record<string, unknown>) => Result<never, ApprovalChannelError>;
134
140
  declare const errors: {
135
141
  readonly notFound: (resource: string, id?: string, ctx?: Record<string, unknown>) => Result<never, NotFoundError>;
136
142
  readonly forbidden: (reason?: string, ctx?: Record<string, unknown>) => Result<never, ForbiddenError>;
@@ -150,6 +156,7 @@ declare const errors: {
150
156
  readonly scanError: (message?: string, ctx?: Record<string, unknown>) => Result<never, ScanError>;
151
157
  readonly githubError: (message?: string, ctx?: Record<string, unknown>) => Result<never, GithubError>;
152
158
  readonly validationFieldError: (field: string, message?: string, ctx?: Record<string, unknown>) => Result<never, ValidationFieldError>;
159
+ readonly approvalChannel: (task_id: string, message?: string, ctx?: Record<string, unknown>) => Result<never, ApprovalChannelError>;
153
160
  readonly is: {
154
161
  readonly notFound: (e: unknown) => e is NotFoundError;
155
162
  readonly forbidden: (e: unknown) => e is ForbiddenError;
@@ -169,9 +176,10 @@ declare const errors: {
169
176
  readonly unauthorized: (e: unknown) => e is UnauthorizedError;
170
177
  readonly scanError: (e: unknown) => e is ScanError;
171
178
  readonly githubError: (e: unknown) => e is GithubError;
179
+ readonly approvalChannel: (e: unknown) => e is ApprovalChannelError;
172
180
  readonly serviceError: (e: unknown) => e is ServiceError;
173
181
  readonly retryable: (e: unknown) => boolean;
174
182
  };
175
183
  };
176
184
 
177
- export { isValidationFieldError as $, type ApiError as A, type BadRequestError as B, type ConflictError as C, type DatabaseError as D, type EncryptionError as E, type ForbiddenError as F, type GithubError as G, isEncryptionError as H, isForbiddenError as I, isGithubError as J, isNetworkError as K, isNotFoundError as L, isParseError as M, type NetworkError as N, isProtectedError as O, type ParseError as P, isRateLimitedError as Q, type RateLimitedError as R, type ScanError as S, isRetryableError as T, type UnauthorizedError as U, type ValidationError as V, isScanError as W, isServiceError as X, isStoreError as Y, isUnauthorizedError as Z, isValidationError as _, type AuthExpiredError as a, networkError as a0, notFound as a1, parseError as a2, protectedEntity as a3, rateLimited as a4, scanError as a5, storeError as a6, unauthorized as a7, validation as a8, validationFieldError as a9, type BaseError as b, type CronError as c, type ErrorContext as d, type ErrorLogEntry as e, type NotFoundError as f, type ProtectedError as g, type ProviderError as h, type ServiceError as i, type StoreError as j, type ValidationFieldError as k, apiError as l, authExpired as m, badRequest as n, configureErrorLogging as o, conflict as p, dbError as q, encryptionError as r, errors as s, forbidden as t, githubError as u, isApiError as v, isAuthExpiredError as w, isBadRequestError as x, isConflictError as y, isDatabaseError as z };
185
+ export { isStoreError as $, type ApiError as A, type BadRequestError as B, type ConflictError as C, type DatabaseError as D, type EncryptionError as E, type ForbiddenError as F, type GithubError as G, isBadRequestError as H, isConflictError as I, isDatabaseError as J, isEncryptionError as K, isForbiddenError as L, isGithubError as M, type NetworkError as N, isNetworkError as O, type ParseError as P, isNotFoundError as Q, type RateLimitedError as R, type ScanError as S, isParseError as T, type UnauthorizedError as U, type ValidationError as V, isProtectedError as W, isRateLimitedError as X, isRetryableError as Y, isScanError as Z, isServiceError as _, type ApprovalChannelError as a, isUnauthorizedError as a0, isValidationError as a1, isValidationFieldError as a2, networkError as a3, notFound as a4, parseError as a5, protectedEntity as a6, rateLimited as a7, scanError as a8, storeError as a9, unauthorized as aa, validation as ab, validationFieldError as ac, type AuthExpiredError as b, type BaseError as c, type CronError as d, type ErrorContext as e, type ErrorLogEntry as f, type NotFoundError as g, type ProtectedError as h, type ProviderError as i, type ServiceError as j, type StoreError as k, type ValidationFieldError as l, apiError as m, approvalChannel as n, authExpired as o, badRequest as p, configureErrorLogging as q, conflict as r, dbError as s, encryptionError as t, errors as u, forbidden as v, githubError as w, isApiError as x, isApprovalChannelError as y, isAuthExpiredError as z };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { G as PostListParams, T as PostsResponse, x as Post, D as PostCreate, Q as PostUpdate, Z as VersionInfo, y as PostContent, C as Category, k as CategoryCreate, A as AccessKey } from './types.d-BhWQru2j.js';
2
- import { ai as Profile, u as CreateProfileInput, aw as UpdateProfileInput, aj as ProfileFilter, c as AddFilterInput, aq as Timeline, A as Account, ae as PlatformSettings } from './types.d-ip2SzstN.js';
1
+ import { G as PostListParams, T as PostsResponse, x as Post, D as PostCreate, Q as PostUpdate, Z as VersionInfo, y as PostContent, C as Category, k as CategoryCreate, A as AccessKey } from './types.d-DbgtG-w1.js';
2
+ import { ai as Profile, u as CreateProfileInput, aw as UpdateProfileInput, aj as ProfileFilter, c as AddFilterInput, aq as Timeline, A as Account, ae as PlatformSettings } from './types.d-CsYeI1BE.js';
3
3
  import { z } from 'zod';
4
- import { a as ApiKey, q as Project, a7 as UpsertProject, G as GetConfigResult, S as SaveConfigRequest, W as TodoUpdate, H as HistoryAction, M as Milestone, i as Goal, V as TaskWithDetails, aa as UpsertTodo, a8 as UpsertTag, F as Task, L as TaskLink, C as ClaimRequest, h as DoneRequest, a9 as UpsertTaskLink, d as ApplyRequest, c as ApplyOp, B as TagWithTypedColor, D as DashboardResponse, o as PipelineRun, p as PipelineStageEvent, l as PipelineGrant, n as PipelinePackage, P as PipelineAnalysisTemplate, m as PipelineOidcTrust } from './types.d-BJ3g4B0G.js';
5
- export { r as ProjectConfig } from './types.d-BJ3g4B0G.js';
4
+ import { c as ApiKey, O as Project, aA as UpsertProject, G as GetConfigResult, a0 as SaveConfigRequest, al as TodoUpdate, H as HistoryAction, M as Milestone, o as Goal, p as Hook, v as HookTrigger, r as HookActionPublic, as as UpsertHook, t as HookDelivery, ah as TaskWithDetails, aD as UpsertTodo, aB as UpsertTag, aa as Task, ad as TaskLink, C as ClaimRequest, m as DoneRequest, a as AdvanceStageRequest, aC as UpsertTaskLink, f as ApplyRequest, e as ApplyOp, a9 as TagWithTypedColor, l as Document, S as PushDocRequest, ak as ThreadMarker, i as CreateThreadRequest, b as AnnotationThread, T as PushInterfaceReportRequest, y as InterfaceDiffClass, a3 as Signoff, W as RequestCheckpointRequest, k as DecideCheckpointRequest, X as ReviewItem, D as DashboardResponse, K as PipelineRun, L as PipelineStageEvent, B as PipelineGrant, J as PipelinePackage, P as PipelineAnalysisTemplate, F as PipelineOidcTrust } from './types.d-CEmFf0kh.js';
5
+ export { Q as ProjectConfig } from './types.d-CEmFf0kh.js';
6
6
  import { Result } from '@f0rbit/corpus';
7
7
  export { Result, err, ok } from '@f0rbit/corpus';
8
- import { C as CompletedVia, S as StageEventKind } from './schema.d-DfzLWuRW.js';
8
+ import { H as HookDeliveryStatus, C as CompletedVia, i as StageEventKind } from './schema.d-7jUA2Hd2.js';
9
9
  import 'drizzle-orm';
10
10
  import './media.d-R87HGuRp.js';
11
11
  import 'drizzle-orm/sqlite-core';
@@ -678,6 +678,32 @@ type ApiResultError = {
678
678
  type ApiResult<T> = Result<T, ApiResultError>;
679
679
  declare function wrap<T>(fn: () => Promise<T>): Promise<ApiResult<T>>;
680
680
 
681
+ /** Wire shape returned by every hooks route — `secret_encrypted` never round-trips (see `packages/core/src/services/hooks/registry.ts`'s `PublicHook`). */
682
+ type PublicHook = Omit<Hook, "action" | "trigger"> & {
683
+ trigger: HookTrigger;
684
+ action: HookActionPublic;
685
+ };
686
+ type DocContent = {
687
+ title: string;
688
+ html: string;
689
+ };
690
+ type DocVersionInfo = {
691
+ version: string;
692
+ parent: string | null;
693
+ created_at: string;
694
+ tags: string[];
695
+ };
696
+ type PullDocResponse = {
697
+ document: Document;
698
+ content: DocContent | null;
699
+ threads: ThreadMarker[];
700
+ orphaned: ThreadMarker[];
701
+ };
702
+ type PushInterfaceReportResult = {
703
+ document: Document;
704
+ classification: InterfaceDiffClass;
705
+ signoff: Signoff | null;
706
+ };
681
707
  type ReadyResponse = {
682
708
  items: Task[];
683
709
  next_cursor: string | null;
@@ -804,6 +830,7 @@ declare class ApiClient {
804
830
  create: (input?: string | {
805
831
  name?: string;
806
832
  scope?: "devpad" | "blog" | "media" | "pulse" | "all";
833
+ project_id?: string;
807
834
  }) => Promise<ApiResult<{
808
835
  message: string;
809
836
  key: {
@@ -953,6 +980,18 @@ declare class ApiClient {
953
980
  */
954
981
  goals: (id: string) => Promise<ApiResult<Goal[]>>;
955
982
  };
983
+ /**
984
+ * Hooks namespace (task A3.2) — automation registry + delivery ledger.
985
+ * Webhook secrets are write-only: `secret_encrypted` never round-trips.
986
+ */
987
+ readonly hooks: {
988
+ list: (project_id: string) => Promise<ApiResult<PublicHook[]>>;
989
+ upsert: (data: UpsertHook) => Promise<ApiResult<PublicHook>>;
990
+ delete: (id: string) => Promise<ApiResult<{
991
+ success: boolean;
992
+ }>>;
993
+ deliveries: (id: string, status?: HookDeliveryStatus) => Promise<ApiResult<HookDelivery[]>>;
994
+ };
956
995
  /**
957
996
  * Goals namespace with Result-wrapped operations
958
997
  */
@@ -1069,6 +1108,12 @@ declare class ApiClient {
1069
1108
  * until phase A3.
1070
1109
  */
1071
1110
  done: (id: string, data: DoneRequest) => Promise<ApiResult<DoneResponse>>;
1111
+ /**
1112
+ * SDLC stage transition (v2.4, task A4.5) — gently enforced: a gated
1113
+ * hop missing its checkpoint 409s naming what's missing; `override:
1114
+ * true` always succeeds but audits.
1115
+ */
1116
+ advanceStage: (id: string, data: AdvanceStageRequest) => Promise<ApiResult<Task>>;
1072
1117
  /** Create a typed edge between two tasks (or a task and an external ref). */
1073
1118
  link: (data: UpsertTaskLink) => Promise<ApiResult<TaskLink>>;
1074
1119
  /** Remove a typed edge by its own id. */
@@ -1092,6 +1137,74 @@ declare class ApiClient {
1092
1137
  */
1093
1138
  list: () => Promise<ApiResult<TagWithTypedColor[]>>;
1094
1139
  };
1140
+ /**
1141
+ * Docs namespace (v2.4, task A4.1) — corpus-backed doc store. `push`
1142
+ * creates a new document (omit `document_id`) or a new version on an
1143
+ * existing one; content is sanitized server-side before it ever reaches
1144
+ * corpus.
1145
+ */
1146
+ readonly docs: {
1147
+ list: (filters: {
1148
+ project_id: string;
1149
+ task_id?: string;
1150
+ }) => Promise<ApiResult<Document[]>>;
1151
+ push: (data: PushDocRequest) => Promise<ApiResult<Document>>;
1152
+ /** Pulls a document's content at `version` (default: head). `content` is null for a document that's never been pushed to. */
1153
+ pull: (id: string, version?: string) => Promise<ApiResult<PullDocResponse>>;
1154
+ /** Full version history, newest first — the lineage walk. */
1155
+ versions: (id: string) => Promise<ApiResult<DocVersionInfo[]>>;
1156
+ /**
1157
+ * Annotation engine (task A4.2) — markers-in-doc threads. Every
1158
+ * mutation pushes a new corpus version; the doc itself is the thread
1159
+ * history (locked decision 3).
1160
+ */
1161
+ createThread: (document_id: string, data: CreateThreadRequest) => Promise<ApiResult<Document>>;
1162
+ replyThread: (document_id: string, thread_id: string, body: string) => Promise<ApiResult<Document>>;
1163
+ resolveThread: (document_id: string, thread_id: string) => Promise<ApiResult<Document>>;
1164
+ toggleBlocking: (document_id: string, thread_id: string, blocking: boolean) => Promise<ApiResult<Document>>;
1165
+ /** Pending annotation threads (anything not `resolved`) — scope to one document, or every document in a project. */
1166
+ unresolved: (filters: {
1167
+ project_id?: string;
1168
+ document_id?: string;
1169
+ }) => Promise<ApiResult<AnnotationThread[]>>;
1170
+ /**
1171
+ * Interface report v1 (task A4.4). `push` submits already-normalized
1172
+ * declaration text; the server independently recomputes the
1173
+ * additive-vs-breaking classification against its own stored previous
1174
+ * content and auto-approves additive diffs against an approved base.
1175
+ */
1176
+ pushInterfaceReport: (data: PushInterfaceReportRequest) => Promise<ApiResult<PushInterfaceReportResult>>;
1177
+ interfaceStatus: (filters: {
1178
+ project_id: string;
1179
+ task_id?: string;
1180
+ title: string;
1181
+ }) => Promise<ApiResult<{
1182
+ document_id: string | null;
1183
+ approved_content_hash: string | null;
1184
+ }>>;
1185
+ };
1186
+ /**
1187
+ * Signoffs namespace (v2.4, task A4.3) — the generalized human-approval
1188
+ * ledger. `decide` is human-only; an api-channel key gets 403.
1189
+ */
1190
+ readonly signoffs: {
1191
+ request: (data: RequestCheckpointRequest) => Promise<ApiResult<{
1192
+ signoff: Signoff;
1193
+ task_id: string;
1194
+ }>>;
1195
+ find: (id: string) => Promise<ApiResult<Signoff>>;
1196
+ decide: (id: string, data: DecideCheckpointRequest) => Promise<ApiResult<Signoff>>;
1197
+ };
1198
+ /**
1199
+ * Reviews namespace (v2.4, task A4.6) — the human's queue: one typed
1200
+ * aggregate across pending signoffs, open blocking annotation threads,
1201
+ * pending pipeline manual gates, and pending scanner diffs.
1202
+ */
1203
+ readonly reviews: {
1204
+ pending: () => Promise<ApiResult<{
1205
+ items: ReviewItem[];
1206
+ }>>;
1207
+ };
1095
1208
  /**
1096
1209
  * GitHub namespace with Result-wrapped operations
1097
1210
  */
@@ -1735,4 +1848,4 @@ declare const tools: Record<string, ToolDefinition>;
1735
1848
  declare const toolNames: string[];
1736
1849
  declare function getTool(name: string): ToolDefinition | undefined;
1737
1850
 
1738
- export { AccessKey, Account, AddFilterInput, ApiClient, ApiError, type ApiResult, type ApiResultError, type AuthMode, AuthenticationError, Category, CategoryCreate, CreateProfileInput, NetworkError, PlatformSettings, Post, PostContent, PostCreate, PostListParams, PostUpdate, PostsResponse, Profile, ProfileFilter, Project, type PulseErrorIssue, type PulseErrorsResult, type PulseEventRow, type PulseEventsPage, type PulseLatencyByMinute, type PulseLatencyResult, type PulseLogsResult, type PulseSummary, type PulseSummaryByDay, type RequestHistoryEntry, type RequestOptions, SaveConfigRequest, Task, TaskWithDetails, Timeline, type ToolDefinition, UpdateProfileInput, UpsertProject, UpsertTag, UpsertTodo, ValidationError, VersionInfo, ApiClient as default, getTool, getUserFriendlyErrorMessage, parseZodErrors, pulseSummaryHasData, toolNames, tools, wrap };
1851
+ export { AccessKey, Account, AddFilterInput, ApiClient, ApiError, type ApiResult, type ApiResultError, type AuthMode, AuthenticationError, Category, CategoryCreate, CreateProfileInput, NetworkError, PlatformSettings, Post, PostContent, PostCreate, PostListParams, PostUpdate, PostsResponse, Profile, ProfileFilter, Project, type PublicHook, type PulseErrorIssue, type PulseErrorsResult, type PulseEventRow, type PulseEventsPage, type PulseLatencyByMinute, type PulseLatencyResult, type PulseLogsResult, type PulseSummary, type PulseSummaryByDay, type RequestHistoryEntry, type RequestOptions, SaveConfigRequest, Task, TaskWithDetails, Timeline, type ToolDefinition, UpdateProfileInput, UpsertProject, UpsertTag, UpsertTodo, ValidationError, VersionInfo, ApiClient as default, getTool, getUserFriendlyErrorMessage, parseZodErrors, pulseSummaryHasData, toolNames, tools, wrap };