@devpad/api 2.3.5 → 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,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-KRYLGBPJ.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
  */
@@ -1560,7 +1640,10 @@ var ApiClient2 = class {
1560
1640
  media: new ApiClient({ ...clientOptions, category: "media" }),
1561
1641
  pulse: new ApiClient({ ...clientOptions, base_url: `${base_url}/pulse`, category: "pulse" }),
1562
1642
  pipelines: new ApiClient({ ...clientOptions, category: "pipelines" }),
1563
- hooks: new ApiClient({ ...clientOptions, category: "hooks" })
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" })
1564
1647
  };
1565
1648
  }
1566
1649
  /**
@@ -2000,6 +2083,15 @@ var tools = {
2000
2083
  }),
2001
2084
  execute: async (client, input) => unwrap(await client.tasks.unlink(input.id))
2002
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
+ }),
2003
2095
  devpad_tasks_apply: define_tool({
2004
2096
  name: "devpad_tasks_apply",
2005
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.",
@@ -2555,6 +2647,131 @@ var tools = {
2555
2647
  owner_id: z2.string().describe("Owner ID (must match the policy's owner)")
2556
2648
  }),
2557
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
+ }
2558
2775
  })
2559
2776
  };
2560
2777
  var toolNames = Object.keys(tools);