@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.
package/dist/index.js CHANGED
@@ -1,15 +1,22 @@
1
1
  import {
2
2
  RUN_STATUSES,
3
3
  STAGE_EVENT_KINDS,
4
+ advance_stage_request,
4
5
  apply_request,
6
+ create_thread_request,
7
+ decide_checkpoint_request,
8
+ push_doc_request,
9
+ push_interface_report_request,
10
+ request_checkpoint_request,
5
11
  save_config_request,
6
12
  save_tags_request,
7
13
  upsert_goal,
14
+ upsert_hook,
8
15
  upsert_milestone,
9
16
  upsert_project,
10
17
  upsert_task_link,
11
18
  upsert_todo
12
- } from "./chunk-XHTCNYWS.js";
19
+ } from "./chunk-KRYLGBPJ.js";
13
20
  import {
14
21
  CategoryCreateSchema,
15
22
  PostCreateSchema,
@@ -126,12 +133,8 @@ function handleHttpResponse(response) {
126
133
  throw new AuthenticationError("Invalid or expired API key");
127
134
  case HTTP_STATUS.NOT_FOUND:
128
135
  throw new ApiError("Resource not found", { statusCode: HTTP_STATUS.NOT_FOUND });
129
- case HTTP_STATUS.BAD_REQUEST:
130
- break;
131
136
  default:
132
- if (!response.ok) {
133
- throw new ApiError(`Request failed: ${response.statusText}`, { statusCode: response.status });
134
- }
137
+ break;
135
138
  }
136
139
  }
137
140
  async function handleResponseError(response) {
@@ -143,11 +146,13 @@ async function handleResponseError(response) {
143
146
  parsedError = raw;
144
147
  } catch {
145
148
  }
146
- if (response.status === HTTP_STATUS.BAD_REQUEST && parsedError?.error?.name === "ZodError") {
147
- const zodErrorDetails = parsedError.error.issues ? JSON.stringify(parsedError.error) : errorMessage;
149
+ const structuredError = typeof parsedError?.error === "object" ? parsedError.error : void 0;
150
+ if (response.status === HTTP_STATUS.BAD_REQUEST && structuredError?.name === "ZodError") {
151
+ const zodErrorDetails = structuredError.issues ? JSON.stringify(structuredError) : errorMessage;
148
152
  throw new ValidationError(zodErrorDetails);
149
153
  }
150
- throw new ApiError(errorMessage, { statusCode: response.status });
154
+ const message = typeof parsedError?.error === "string" ? parsedError.error : errorMessage;
155
+ throw new ApiError(message, { statusCode: response.status });
151
156
  }
152
157
  function handleNetworkError(error) {
153
158
  const message = error instanceof Error ? error.message : "Unknown network error";
@@ -740,6 +745,20 @@ var ApiClient2 = class {
740
745
  */
741
746
  goals: (id) => wrap(() => this.clients.milestones.get(`/milestones/${id}/goals`))
742
747
  };
748
+ /**
749
+ * Hooks namespace (task A3.2) — automation registry + delivery ledger.
750
+ * Webhook secrets are write-only: `secret_encrypted` never round-trips.
751
+ */
752
+ this.hooks = {
753
+ list: (project_id) => wrap(() => this.clients.hooks.get("/hooks", { query: { project_id } })),
754
+ upsert: (data) => wrap(
755
+ () => data.id ? this.clients.hooks.patch(`/hooks/${data.id}`, { body: data }) : this.clients.hooks.post("/hooks", { body: data })
756
+ ),
757
+ delete: (id) => wrap(() => this.clients.hooks.delete(`/hooks/${id}`)),
758
+ deliveries: (id, status) => wrap(
759
+ () => this.clients.hooks.get(`/hooks/${id}/deliveries`, status ? { query: { status } } : {})
760
+ )
761
+ };
743
762
  /**
744
763
  * Goals namespace with Result-wrapped operations
745
764
  */
@@ -888,6 +907,12 @@ var ApiClient2 = class {
888
907
  * until phase A3.
889
908
  */
890
909
  done: (id, data) => wrap(() => this.clients.tasks.post(`/tasks/${id}/done`, { body: data })),
910
+ /**
911
+ * SDLC stage transition (v2.4, task A4.5) — gently enforced: a gated
912
+ * hop missing its checkpoint 409s naming what's missing; `override:
913
+ * true` always succeeds but audits.
914
+ */
915
+ advanceStage: (id, data) => wrap(() => this.clients.tasks.post(`/tasks/${id}/stage`, { body: data })),
891
916
  /** Create a typed edge between two tasks (or a task and an external ref). */
892
917
  link: (data) => wrap(() => this.clients.tasks.post("/tasks/link", { body: data })),
893
918
  /** Remove a typed edge by its own id. */
@@ -909,6 +934,76 @@ var ApiClient2 = class {
909
934
  */
910
935
  list: () => wrap(() => this.clients.tags.get("/tags"))
911
936
  };
937
+ /**
938
+ * Docs namespace (v2.4, task A4.1) — corpus-backed doc store. `push`
939
+ * creates a new document (omit `document_id`) or a new version on an
940
+ * existing one; content is sanitized server-side before it ever reaches
941
+ * corpus.
942
+ */
943
+ this.docs = {
944
+ list: (filters) => wrap(() => {
945
+ const query = { project_id: filters.project_id };
946
+ if (filters.task_id) query.task_id = filters.task_id;
947
+ return this.clients.docs.get("/docs", { query });
948
+ }),
949
+ push: (data) => wrap(() => this.clients.docs.post("/docs", { body: data })),
950
+ /** Pulls a document's content at `version` (default: head). `content` is null for a document that's never been pushed to. */
951
+ pull: (id, version) => wrap(() => this.clients.docs.get(`/docs/${id}`, version ? { query: { version } } : {})),
952
+ /** Full version history, newest first — the lineage walk. */
953
+ versions: (id) => wrap(() => this.clients.docs.get(`/docs/${id}/versions`)),
954
+ /**
955
+ * Annotation engine (task A4.2) — markers-in-doc threads. Every
956
+ * mutation pushes a new corpus version; the doc itself is the thread
957
+ * history (locked decision 3).
958
+ */
959
+ createThread: (document_id, data) => wrap(() => this.clients.docs.post(`/docs/${document_id}/threads`, { body: data })),
960
+ replyThread: (document_id, thread_id, body) => wrap(
961
+ () => this.clients.docs.post(`/docs/${document_id}/threads/${thread_id}/reply`, { body: { body } })
962
+ ),
963
+ resolveThread: (document_id, thread_id) => wrap(() => this.clients.docs.post(`/docs/${document_id}/threads/${thread_id}/resolve`, {})),
964
+ toggleBlocking: (document_id, thread_id, blocking) => wrap(
965
+ () => this.clients.docs.post(`/docs/${document_id}/threads/${thread_id}/blocking`, { body: { blocking } })
966
+ ),
967
+ /** Pending annotation threads (anything not `resolved`) — scope to one document, or every document in a project. */
968
+ unresolved: (filters) => wrap(() => {
969
+ const query = {};
970
+ if (filters.project_id) query.project_id = filters.project_id;
971
+ if (filters.document_id) query.document_id = filters.document_id;
972
+ return this.clients.docs.get("/docs/annotations/unresolved", { query });
973
+ }),
974
+ /**
975
+ * Interface report v1 (task A4.4). `push` submits already-normalized
976
+ * declaration text; the server independently recomputes the
977
+ * additive-vs-breaking classification against its own stored previous
978
+ * content and auto-approves additive diffs against an approved base.
979
+ */
980
+ pushInterfaceReport: (data) => wrap(() => this.clients.docs.post("/docs/interface", { body: data })),
981
+ interfaceStatus: (filters) => wrap(() => {
982
+ const query = { project_id: filters.project_id, title: filters.title };
983
+ if (filters.task_id) query.task_id = filters.task_id;
984
+ return this.clients.docs.get(
985
+ "/docs/interface/status",
986
+ { query }
987
+ );
988
+ })
989
+ };
990
+ /**
991
+ * Signoffs namespace (v2.4, task A4.3) — the generalized human-approval
992
+ * ledger. `decide` is human-only; an api-channel key gets 403.
993
+ */
994
+ this.signoffs = {
995
+ request: (data) => wrap(() => this.clients.signoffs.post("/signoffs", { body: data })),
996
+ find: (id) => wrap(() => this.clients.signoffs.get(`/signoffs/${id}`)),
997
+ decide: (id, data) => wrap(() => this.clients.signoffs.post(`/signoffs/${id}/decide`, { body: data }))
998
+ };
999
+ /**
1000
+ * Reviews namespace (v2.4, task A4.6) — the human's queue: one typed
1001
+ * aggregate across pending signoffs, open blocking annotation threads,
1002
+ * pending pipeline manual gates, and pending scanner diffs.
1003
+ */
1004
+ this.reviews = {
1005
+ pending: () => wrap(() => this.clients.reviews.get("/reviews/pending"))
1006
+ };
912
1007
  /**
913
1008
  * GitHub namespace with Result-wrapped operations
914
1009
  */
@@ -1544,7 +1639,11 @@ var ApiClient2 = class {
1544
1639
  blog: new ApiClient({ ...clientOptions, category: "blog" }),
1545
1640
  media: new ApiClient({ ...clientOptions, category: "media" }),
1546
1641
  pulse: new ApiClient({ ...clientOptions, base_url: `${base_url}/pulse`, category: "pulse" }),
1547
- pipelines: new ApiClient({ ...clientOptions, category: "pipelines" })
1642
+ pipelines: new ApiClient({ ...clientOptions, category: "pipelines" }),
1643
+ hooks: new ApiClient({ ...clientOptions, category: "hooks" }),
1644
+ docs: new ApiClient({ ...clientOptions, category: "docs" }),
1645
+ signoffs: new ApiClient({ ...clientOptions, category: "signoffs" }),
1646
+ reviews: new ApiClient({ ...clientOptions, category: "reviews" })
1548
1647
  };
1549
1648
  }
1550
1649
  /**
@@ -1648,6 +1747,16 @@ var milestone_by_id = z2.object({
1648
1747
  var goal_by_id = z2.object({
1649
1748
  id: z2.string().describe("Goal ID")
1650
1749
  });
1750
+ var hook_filters = z2.object({
1751
+ project_id: z2.string().describe("Project ID to list hooks for")
1752
+ });
1753
+ var hook_by_id = z2.object({
1754
+ id: z2.string().describe("Hook ID")
1755
+ });
1756
+ var hook_deliveries_input = z2.object({
1757
+ id: z2.string().describe("Hook ID"),
1758
+ status: z2.enum(["pending", "delivered", "failed_transient", "failed_permanent"]).optional().describe("Filter by delivery status \u2014 use failed_permanent to see the DLQ")
1759
+ });
1651
1760
  var github_branches = z2.object({
1652
1761
  owner: z2.string().describe("Repository owner"),
1653
1762
  repo: z2.string().describe("Repository name")
@@ -1750,6 +1859,31 @@ var tools = {
1750
1859
  })
1751
1860
  )
1752
1861
  }),
1862
+ // Hooks (task A3.2) — project-scoped automation registry + delivery ledger
1863
+ devpad_hooks_list: define_tool({
1864
+ name: "devpad_hooks_list",
1865
+ description: "List hooks configured for a project",
1866
+ inputSchema: hook_filters,
1867
+ execute: async (client, input) => unwrap(await client.hooks.list(input.project_id))
1868
+ }),
1869
+ devpad_hooks_upsert: define_tool({
1870
+ name: "devpad_hooks_upsert",
1871
+ description: "Create or update a hook (webhook/vault/pipeline action fired on matching task_event kinds). Pass 'id' to update.",
1872
+ inputSchema: upsert_hook,
1873
+ execute: async (client, input) => unwrap(await client.hooks.upsert(input))
1874
+ }),
1875
+ devpad_hooks_delete: define_tool({
1876
+ name: "devpad_hooks_delete",
1877
+ description: "Delete a hook",
1878
+ inputSchema: hook_by_id,
1879
+ execute: async (client, input) => unwrap(await client.hooks.delete(input.id))
1880
+ }),
1881
+ devpad_hooks_deliveries: define_tool({
1882
+ name: "devpad_hooks_deliveries",
1883
+ description: "List delivery attempts for a hook, optionally filtered by status (the DLQ is status=failed_permanent)",
1884
+ inputSchema: hook_deliveries_input,
1885
+ execute: async (client, input) => unwrap(await client.hooks.deliveries(input.id, input.status))
1886
+ }),
1753
1887
  // Goals
1754
1888
  devpad_goals_list: define_tool({
1755
1889
  name: "devpad_goals_list",
@@ -1949,6 +2083,15 @@ var tools = {
1949
2083
  }),
1950
2084
  execute: async (client, input) => unwrap(await client.tasks.unlink(input.id))
1951
2085
  }),
2086
+ devpad_tasks_advance_stage: define_tool({
2087
+ name: "devpad_tasks_advance_stage",
2088
+ description: "Advance a task's SDLC stage (ideate|plan|build|review|deploy|live). Gated hops (plan->build needs an approved plan checkpoint; review->deploy needs approved types + design when a design doc exists) 409 naming what's missing unless override:true, which always succeeds but is audited.",
2089
+ inputSchema: advance_stage_request.extend({ id: z2.string().describe("Task ID") }),
2090
+ execute: async (client, input) => {
2091
+ const { id, ...rest } = input;
2092
+ return unwrap(await client.tasks.advanceStage(id, rest));
2093
+ }
2094
+ }),
1952
2095
  devpad_tasks_apply: define_tool({
1953
2096
  name: "devpad_tasks_apply",
1954
2097
  description: "Batch apply create/update/reparent/link/unlink/claim/complete ops atomically, with $0/$1\u2026 temp handles for subtree creation. Replaying the same idempotency_key returns the prior response verbatim.",
@@ -2504,6 +2647,131 @@ var tools = {
2504
2647
  owner_id: z2.string().describe("Owner ID (must match the policy's owner)")
2505
2648
  }),
2506
2649
  execute: async (client, input) => unwrap(await client.pipelines.oidc_trust.delete(input.id, { owner_id: input.owner_id }))
2650
+ }),
2651
+ // Docs (v2.4, task A4.1) — corpus-backed doc store
2652
+ devpad_docs_list: define_tool({
2653
+ name: "devpad_docs_list",
2654
+ description: "List documents for a project (optionally filtered to one task)",
2655
+ inputSchema: z2.object({
2656
+ project_id: z2.string().describe("Project ID"),
2657
+ task_id: z2.string().optional().describe("Filter to documents attached to this task")
2658
+ }),
2659
+ execute: async (client, input) => unwrap(await client.docs.list(input))
2660
+ }),
2661
+ devpad_docs_push: define_tool({
2662
+ name: "devpad_docs_push",
2663
+ description: "Push HTML content as a new document (omit document_id) or a new version on an existing one. HTML is sanitized server-side before storage \u2014 script/iframe/object/embed/form, event handlers, and javascript:/data: URLs never survive.",
2664
+ inputSchema: push_doc_request,
2665
+ execute: async (client, input) => unwrap(await client.docs.push(input))
2666
+ }),
2667
+ devpad_docs_pull: define_tool({
2668
+ name: "devpad_docs_pull",
2669
+ description: "Pull a document's content at a specific version (default: head)",
2670
+ inputSchema: z2.object({
2671
+ id: z2.string().describe("Document ID"),
2672
+ version: z2.string().optional().describe("Corpus version \u2014 defaults to head")
2673
+ }),
2674
+ execute: async (client, input) => unwrap(await client.docs.pull(input.id, input.version))
2675
+ }),
2676
+ devpad_docs_versions: define_tool({
2677
+ name: "devpad_docs_versions",
2678
+ description: "Full version history for a document, newest first (the lineage walk)",
2679
+ inputSchema: z2.object({
2680
+ id: z2.string().describe("Document ID")
2681
+ }),
2682
+ execute: async (client, input) => unwrap(await client.docs.versions(input.id))
2683
+ }),
2684
+ // Annotation engine (v2.4, task A4.2) — markers-in-doc threads
2685
+ devpad_annotations_create: define_tool({
2686
+ name: "devpad_annotations_create",
2687
+ description: "Open a new annotation thread on a document, anchored to an exact quote (with prefix/suffix context + char offsets for re-anchoring across edits)",
2688
+ inputSchema: create_thread_request.extend({ document_id: z2.string().describe("Document ID") }),
2689
+ execute: async (client, input) => {
2690
+ const { document_id, ...rest } = input;
2691
+ return unwrap(await client.docs.createThread(document_id, rest));
2692
+ }
2693
+ }),
2694
+ devpad_annotations_reply: define_tool({
2695
+ name: "devpad_annotations_reply",
2696
+ description: "Reply to an existing annotation thread",
2697
+ inputSchema: z2.object({
2698
+ document_id: z2.string().describe("Document ID"),
2699
+ thread_id: z2.string().describe("Thread ID (from the marker JSON, not the document ID)"),
2700
+ body: z2.string().min(1).describe("Reply text")
2701
+ }),
2702
+ execute: async (client, input) => unwrap(await client.docs.replyThread(input.document_id, input.thread_id, input.body))
2703
+ }),
2704
+ devpad_annotations_resolve: define_tool({
2705
+ name: "devpad_annotations_resolve",
2706
+ description: "Mark an annotation thread resolved",
2707
+ inputSchema: z2.object({
2708
+ document_id: z2.string().describe("Document ID"),
2709
+ thread_id: z2.string().describe("Thread ID")
2710
+ }),
2711
+ execute: async (client, input) => unwrap(await client.docs.resolveThread(input.document_id, input.thread_id))
2712
+ }),
2713
+ devpad_annotations_toggle_blocking: define_tool({
2714
+ name: "devpad_annotations_toggle_blocking",
2715
+ description: "Toggle whether an annotation thread blocks approval",
2716
+ inputSchema: z2.object({
2717
+ document_id: z2.string().describe("Document ID"),
2718
+ thread_id: z2.string().describe("Thread ID"),
2719
+ blocking: z2.boolean()
2720
+ }),
2721
+ execute: async (client, input) => unwrap(await client.docs.toggleBlocking(input.document_id, input.thread_id, input.blocking))
2722
+ }),
2723
+ devpad_interface_push: define_tool({
2724
+ name: "devpad_interface_push",
2725
+ description: "Push already-normalized declaration text as a new interface-doc version. The server independently recomputes additive-vs-breaking against its own stored previous content and auto-approves additive diffs against an approved base.",
2726
+ inputSchema: push_interface_report_request,
2727
+ execute: async (client, input) => unwrap(await client.docs.pushInterfaceReport(input))
2728
+ }),
2729
+ devpad_interface_status: define_tool({
2730
+ name: "devpad_interface_status",
2731
+ description: "Get the approved/auto content_hash for an interface doc, for a client-side hash comparison (the `check` verb)",
2732
+ inputSchema: z2.object({
2733
+ project_id: z2.string().describe("Project ID"),
2734
+ task_id: z2.string().optional().describe("Task ID"),
2735
+ title: z2.string().describe("The interface document's title (package name)")
2736
+ }),
2737
+ execute: async (client, input) => unwrap(await client.docs.interfaceStatus(input))
2738
+ }),
2739
+ devpad_reviews_pending: define_tool({
2740
+ name: "devpad_reviews_pending",
2741
+ description: "The human's queue \u2014 one typed aggregate across pending signoff checkpoints, open blocking annotation threads, pending pipeline manual gates, and pending scanner diffs, scoped to the authenticated user",
2742
+ inputSchema: z2.object({}),
2743
+ execute: async (client) => unwrap(await client.reviews.pending())
2744
+ }),
2745
+ devpad_annotations_unresolved: define_tool({
2746
+ name: "devpad_annotations_unresolved",
2747
+ description: "List pending annotation threads (anything not resolved) for a project or a specific document",
2748
+ inputSchema: z2.object({
2749
+ project_id: z2.string().optional().describe("Project ID"),
2750
+ document_id: z2.string().optional().describe("Document ID")
2751
+ }),
2752
+ execute: async (client, input) => unwrap(await client.docs.unresolved(input))
2753
+ }),
2754
+ // Signoffs (v2.4, task A4.3) — generalized human-approval ledger
2755
+ devpad_signoffs_request: define_tool({
2756
+ name: "devpad_signoffs_request",
2757
+ description: "Request a human signoff checkpoint \u2014 creates a pending approval node that blocks the named downstream tasks until decided",
2758
+ inputSchema: request_checkpoint_request,
2759
+ execute: async (client, input) => unwrap(await client.signoffs.request(input))
2760
+ }),
2761
+ devpad_signoffs_get: define_tool({
2762
+ name: "devpad_signoffs_get",
2763
+ description: "Get a signoff checkpoint's current state",
2764
+ inputSchema: z2.object({ id: z2.string().describe("Signoff ID") }),
2765
+ execute: async (client, input) => unwrap(await client.signoffs.find(input.id))
2766
+ }),
2767
+ devpad_signoffs_decide: define_tool({
2768
+ name: "devpad_signoffs_decide",
2769
+ description: "Decide a signoff checkpoint (approved | changes_requested). Human-only \u2014 an api-channel key gets 403. Approving a doc_version subject is vetoed by any open blocking annotation thread.",
2770
+ inputSchema: decide_checkpoint_request.extend({ id: z2.string().describe("Signoff ID") }),
2771
+ execute: async (client, input) => {
2772
+ const { id, ...rest } = input;
2773
+ return unwrap(await client.signoffs.decide(id, rest));
2774
+ }
2507
2775
  })
2508
2776
  };
2509
2777
  var toolNames = Object.keys(tools);