@devpad/api 2.3.5 → 2.3.7

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,7 +1,13 @@
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,
@@ -10,7 +16,7 @@ import {
10
16
  upsert_project,
11
17
  upsert_task_link,
12
18
  upsert_todo
13
- } from "./chunk-A7B2SE7T.js";
19
+ } from "./chunk-HWPYBI52.js";
14
20
  import {
15
21
  CategoryCreateSchema,
16
22
  PostCreateSchema,
@@ -127,12 +133,8 @@ function handleHttpResponse(response) {
127
133
  throw new AuthenticationError("Invalid or expired API key");
128
134
  case HTTP_STATUS.NOT_FOUND:
129
135
  throw new ApiError("Resource not found", { statusCode: HTTP_STATUS.NOT_FOUND });
130
- case HTTP_STATUS.BAD_REQUEST:
131
- break;
132
136
  default:
133
- if (!response.ok) {
134
- throw new ApiError(`Request failed: ${response.statusText}`, { statusCode: response.status });
135
- }
137
+ break;
136
138
  }
137
139
  }
138
140
  async function handleResponseError(response) {
@@ -144,11 +146,13 @@ async function handleResponseError(response) {
144
146
  parsedError = raw;
145
147
  } catch {
146
148
  }
147
- if (response.status === HTTP_STATUS.BAD_REQUEST && parsedError?.error?.name === "ZodError") {
148
- 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;
149
152
  throw new ValidationError(zodErrorDetails);
150
153
  }
151
- 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 });
152
156
  }
153
157
  function handleNetworkError(error) {
154
158
  const message = error instanceof Error ? error.message : "Unknown network error";
@@ -903,6 +907,12 @@ var ApiClient2 = class {
903
907
  * until phase A3.
904
908
  */
905
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 })),
906
916
  /** Create a typed edge between two tasks (or a task and an external ref). */
907
917
  link: (data) => wrap(() => this.clients.tasks.post("/tasks/link", { body: data })),
908
918
  /** Remove a typed edge by its own id. */
@@ -924,6 +934,76 @@ var ApiClient2 = class {
924
934
  */
925
935
  list: () => wrap(() => this.clients.tags.get("/tags"))
926
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
+ };
927
1007
  /**
928
1008
  * GitHub namespace with Result-wrapped operations
929
1009
  */
@@ -1087,6 +1167,10 @@ var ApiClient2 = class {
1087
1167
  );
1088
1168
  })
1089
1169
  };
1170
+ /** v2.4 (task A5.3) — the fold's dual-read verification verb. */
1171
+ this.admin = {
1172
+ verifyFold: () => wrap(() => this.clients.admin.get("/admin/verify-fold"))
1173
+ };
1090
1174
  this.user = {
1091
1175
  /**
1092
1176
  * Get the authenticated user's identity (id, name, github_id, task_view).
@@ -1560,7 +1644,11 @@ var ApiClient2 = class {
1560
1644
  media: new ApiClient({ ...clientOptions, category: "media" }),
1561
1645
  pulse: new ApiClient({ ...clientOptions, base_url: `${base_url}/pulse`, category: "pulse" }),
1562
1646
  pipelines: new ApiClient({ ...clientOptions, category: "pipelines" }),
1563
- hooks: new ApiClient({ ...clientOptions, category: "hooks" })
1647
+ hooks: new ApiClient({ ...clientOptions, category: "hooks" }),
1648
+ docs: new ApiClient({ ...clientOptions, category: "docs" }),
1649
+ signoffs: new ApiClient({ ...clientOptions, category: "signoffs" }),
1650
+ reviews: new ApiClient({ ...clientOptions, category: "reviews" }),
1651
+ admin: new ApiClient({ ...clientOptions, category: "admin" })
1564
1652
  };
1565
1653
  }
1566
1654
  /**
@@ -1853,6 +1941,13 @@ var tools = {
1853
1941
  inputSchema: github_branches,
1854
1942
  execute: async (client, input) => unwrap(await client.github.branches(input.owner, input.repo))
1855
1943
  }),
1944
+ // Admin (task A5.3) — v2.4 fold dual-read verification
1945
+ devpad_admin_verify_fold: define_tool({
1946
+ name: "devpad_admin_verify_fold",
1947
+ description: "Compare the frozen milestone/goal tables against their task-row projections (the v2.4 fold) for the authenticated account and report any divergence",
1948
+ inputSchema: z2.object({}),
1949
+ execute: async (client) => unwrap(await client.admin.verifyFold())
1950
+ }),
1856
1951
  // Additional project operations
1857
1952
  devpad_projects_delete: define_tool({
1858
1953
  name: "devpad_projects_delete",
@@ -2000,6 +2095,15 @@ var tools = {
2000
2095
  }),
2001
2096
  execute: async (client, input) => unwrap(await client.tasks.unlink(input.id))
2002
2097
  }),
2098
+ devpad_tasks_advance_stage: define_tool({
2099
+ name: "devpad_tasks_advance_stage",
2100
+ 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.",
2101
+ inputSchema: advance_stage_request.extend({ id: z2.string().describe("Task ID") }),
2102
+ execute: async (client, input) => {
2103
+ const { id, ...rest } = input;
2104
+ return unwrap(await client.tasks.advanceStage(id, rest));
2105
+ }
2106
+ }),
2003
2107
  devpad_tasks_apply: define_tool({
2004
2108
  name: "devpad_tasks_apply",
2005
2109
  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.",
@@ -2555,6 +2659,131 @@ var tools = {
2555
2659
  owner_id: z2.string().describe("Owner ID (must match the policy's owner)")
2556
2660
  }),
2557
2661
  execute: async (client, input) => unwrap(await client.pipelines.oidc_trust.delete(input.id, { owner_id: input.owner_id }))
2662
+ }),
2663
+ // Docs (v2.4, task A4.1) — corpus-backed doc store
2664
+ devpad_docs_list: define_tool({
2665
+ name: "devpad_docs_list",
2666
+ description: "List documents for a project (optionally filtered to one task)",
2667
+ inputSchema: z2.object({
2668
+ project_id: z2.string().describe("Project ID"),
2669
+ task_id: z2.string().optional().describe("Filter to documents attached to this task")
2670
+ }),
2671
+ execute: async (client, input) => unwrap(await client.docs.list(input))
2672
+ }),
2673
+ devpad_docs_push: define_tool({
2674
+ name: "devpad_docs_push",
2675
+ 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.",
2676
+ inputSchema: push_doc_request,
2677
+ execute: async (client, input) => unwrap(await client.docs.push(input))
2678
+ }),
2679
+ devpad_docs_pull: define_tool({
2680
+ name: "devpad_docs_pull",
2681
+ description: "Pull a document's content at a specific version (default: head)",
2682
+ inputSchema: z2.object({
2683
+ id: z2.string().describe("Document ID"),
2684
+ version: z2.string().optional().describe("Corpus version \u2014 defaults to head")
2685
+ }),
2686
+ execute: async (client, input) => unwrap(await client.docs.pull(input.id, input.version))
2687
+ }),
2688
+ devpad_docs_versions: define_tool({
2689
+ name: "devpad_docs_versions",
2690
+ description: "Full version history for a document, newest first (the lineage walk)",
2691
+ inputSchema: z2.object({
2692
+ id: z2.string().describe("Document ID")
2693
+ }),
2694
+ execute: async (client, input) => unwrap(await client.docs.versions(input.id))
2695
+ }),
2696
+ // Annotation engine (v2.4, task A4.2) — markers-in-doc threads
2697
+ devpad_annotations_create: define_tool({
2698
+ name: "devpad_annotations_create",
2699
+ 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)",
2700
+ inputSchema: create_thread_request.extend({ document_id: z2.string().describe("Document ID") }),
2701
+ execute: async (client, input) => {
2702
+ const { document_id, ...rest } = input;
2703
+ return unwrap(await client.docs.createThread(document_id, rest));
2704
+ }
2705
+ }),
2706
+ devpad_annotations_reply: define_tool({
2707
+ name: "devpad_annotations_reply",
2708
+ description: "Reply to an existing annotation thread",
2709
+ inputSchema: z2.object({
2710
+ document_id: z2.string().describe("Document ID"),
2711
+ thread_id: z2.string().describe("Thread ID (from the marker JSON, not the document ID)"),
2712
+ body: z2.string().min(1).describe("Reply text")
2713
+ }),
2714
+ execute: async (client, input) => unwrap(await client.docs.replyThread(input.document_id, input.thread_id, input.body))
2715
+ }),
2716
+ devpad_annotations_resolve: define_tool({
2717
+ name: "devpad_annotations_resolve",
2718
+ description: "Mark an annotation thread resolved",
2719
+ inputSchema: z2.object({
2720
+ document_id: z2.string().describe("Document ID"),
2721
+ thread_id: z2.string().describe("Thread ID")
2722
+ }),
2723
+ execute: async (client, input) => unwrap(await client.docs.resolveThread(input.document_id, input.thread_id))
2724
+ }),
2725
+ devpad_annotations_toggle_blocking: define_tool({
2726
+ name: "devpad_annotations_toggle_blocking",
2727
+ description: "Toggle whether an annotation thread blocks approval",
2728
+ inputSchema: z2.object({
2729
+ document_id: z2.string().describe("Document ID"),
2730
+ thread_id: z2.string().describe("Thread ID"),
2731
+ blocking: z2.boolean()
2732
+ }),
2733
+ execute: async (client, input) => unwrap(await client.docs.toggleBlocking(input.document_id, input.thread_id, input.blocking))
2734
+ }),
2735
+ devpad_interface_push: define_tool({
2736
+ name: "devpad_interface_push",
2737
+ 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.",
2738
+ inputSchema: push_interface_report_request,
2739
+ execute: async (client, input) => unwrap(await client.docs.pushInterfaceReport(input))
2740
+ }),
2741
+ devpad_interface_status: define_tool({
2742
+ name: "devpad_interface_status",
2743
+ description: "Get the approved/auto content_hash for an interface doc, for a client-side hash comparison (the `check` verb)",
2744
+ inputSchema: z2.object({
2745
+ project_id: z2.string().describe("Project ID"),
2746
+ task_id: z2.string().optional().describe("Task ID"),
2747
+ title: z2.string().describe("The interface document's title (package name)")
2748
+ }),
2749
+ execute: async (client, input) => unwrap(await client.docs.interfaceStatus(input))
2750
+ }),
2751
+ devpad_reviews_pending: define_tool({
2752
+ name: "devpad_reviews_pending",
2753
+ 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",
2754
+ inputSchema: z2.object({}),
2755
+ execute: async (client) => unwrap(await client.reviews.pending())
2756
+ }),
2757
+ devpad_annotations_unresolved: define_tool({
2758
+ name: "devpad_annotations_unresolved",
2759
+ description: "List pending annotation threads (anything not resolved) for a project or a specific document",
2760
+ inputSchema: z2.object({
2761
+ project_id: z2.string().optional().describe("Project ID"),
2762
+ document_id: z2.string().optional().describe("Document ID")
2763
+ }),
2764
+ execute: async (client, input) => unwrap(await client.docs.unresolved(input))
2765
+ }),
2766
+ // Signoffs (v2.4, task A4.3) — generalized human-approval ledger
2767
+ devpad_signoffs_request: define_tool({
2768
+ name: "devpad_signoffs_request",
2769
+ description: "Request a human signoff checkpoint \u2014 creates a pending approval node that blocks the named downstream tasks until decided",
2770
+ inputSchema: request_checkpoint_request,
2771
+ execute: async (client, input) => unwrap(await client.signoffs.request(input))
2772
+ }),
2773
+ devpad_signoffs_get: define_tool({
2774
+ name: "devpad_signoffs_get",
2775
+ description: "Get a signoff checkpoint's current state",
2776
+ inputSchema: z2.object({ id: z2.string().describe("Signoff ID") }),
2777
+ execute: async (client, input) => unwrap(await client.signoffs.find(input.id))
2778
+ }),
2779
+ devpad_signoffs_decide: define_tool({
2780
+ name: "devpad_signoffs_decide",
2781
+ 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.",
2782
+ inputSchema: decide_checkpoint_request.extend({ id: z2.string().describe("Signoff ID") }),
2783
+ execute: async (client, input) => {
2784
+ const { id, ...rest } = input;
2785
+ return unwrap(await client.signoffs.decide(id, rest));
2786
+ }
2558
2787
  })
2559
2788
  };
2560
2789
  var toolNames = Object.keys(tools);