@devpad/api 2.3.2 → 2.3.4

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.
@@ -1,9 +1,6 @@
1
- // ../schema/dist/validation.js
2
- import { z } from "zod";
3
-
4
1
  // ../schema/dist/database/schema.js
5
2
  import { relations, sql } from "drizzle-orm";
6
- import { int, integer, primaryKey, sqliteTable, text, unique } from "drizzle-orm/sqlite-core";
3
+ import { index, int, integer, primaryKey, sqliteTable, text, unique } from "drizzle-orm/sqlite-core";
7
4
  var timestamps = () => ({
8
5
  created_at: text("created_at").notNull().default(sql`(CURRENT_TIMESTAMP)`),
9
6
  updated_at: text("updated_at").notNull().default(sql`(CURRENT_TIMESTAMP)`)
@@ -145,6 +142,12 @@ var goal = sqliteTable("goal", {
145
142
  target_time: text("target_time"),
146
143
  finished_at: text("finished_at")
147
144
  });
145
+ var GRAPH_DEPTH_CAP = 8;
146
+ var GRAPH_CHILDREN_CAP = 100;
147
+ var TASK_KINDS = ["task", "phase", "approval"];
148
+ var COMPLETION_POLICIES = ["manual", "auto_children"];
149
+ var COMPLETED_VIA_VALUES = ["user", "api", "policy"];
150
+ var TASK_LINK_KINDS = ["blocks", "relates_to", "references", "discovered_from", "tracks_metric"];
148
151
  var task = sqliteTable("task", {
149
152
  ...owned_entity("task"),
150
153
  title: text("title").notNull(),
@@ -157,8 +160,73 @@ var task = sqliteTable("task", {
157
160
  end_time: text("end_time"),
158
161
  summary: text("summary"),
159
162
  codebase_task_id: text("codebase_task_id").references(() => codebase_tasks.id),
160
- priority: text("priority", { enum: ["LOW", "MEDIUM", "HIGH"] }).notNull().default("LOW")
161
- });
163
+ priority: text("priority", { enum: ["LOW", "MEDIUM", "HIGH"] }).notNull().default("LOW"),
164
+ // graph columns (v2.4) — self-FK omitted deliberately (mirrors
165
+ // checklist_item.parent_id): guarded writes in the graph service own
166
+ // the invariant, not a DB-level FK constraint.
167
+ parent_id: text("parent_id"),
168
+ rank: text("rank").notNull().default(""),
169
+ rev: integer("rev").notNull().default(0),
170
+ kind: text("kind", { enum: TASK_KINDS }).notNull().default("task"),
171
+ completion_policy: text("completion_policy", { enum: COMPLETION_POLICIES }).notNull().default("manual"),
172
+ completed_via: text("completed_via", { enum: COMPLETED_VIA_VALUES }),
173
+ claimed_by: text("claimed_by"),
174
+ claimed_at: text("claimed_at")
175
+ }, (table) => [index("task_parent_id_idx").on(table.parent_id)]);
176
+ var task_link = sqliteTable("task_link", {
177
+ ...entity("link"),
178
+ src_id: text("src_id").notNull().references(() => task.id),
179
+ dst_id: text("dst_id").references(() => task.id),
180
+ kind: text("kind", { enum: TASK_LINK_KINDS }).notNull(),
181
+ ref: text("ref", { mode: "json" }),
182
+ note: text("note")
183
+ }, (table) => [
184
+ unique("task_link_unique").on(table.src_id, table.dst_id, table.kind),
185
+ index("task_link_src_id_idx").on(table.src_id),
186
+ index("task_link_dst_id_idx").on(table.dst_id)
187
+ ]);
188
+ var task_rollup = sqliteTable("task_rollup", {
189
+ task_id: text("task_id").primaryKey().references(() => task.id),
190
+ direct_done: integer("direct_done").notNull().default(0),
191
+ direct_total: integer("direct_total").notNull().default(0),
192
+ subtree_done: integer("subtree_done").notNull().default(0),
193
+ subtree_total: integer("subtree_total").notNull().default(0)
194
+ });
195
+ var apply_log = sqliteTable("apply_log", {
196
+ idempotency_key: text("idempotency_key").primaryKey(),
197
+ owner_id: text("owner_id").notNull().references(() => user.id),
198
+ response: text("response", { mode: "json" }).notNull(),
199
+ created_at: text("created_at").notNull().default(sql`(CURRENT_TIMESTAMP)`)
200
+ });
201
+ var TASK_EVENT_KINDS = [
202
+ "task.created",
203
+ "task.updated",
204
+ "task.completed",
205
+ "task.reopened",
206
+ "task.claimed",
207
+ "edge.created",
208
+ "edge.removed",
209
+ "node.children_all_done",
210
+ "policy.fired",
211
+ "node.completion_stale"
212
+ ];
213
+ var TASK_EVENT_ACTORS = ["user", "api", "policy", "github"];
214
+ var TASK_EVENT_DISPATCH_STATUSES = ["pending", "dispatched"];
215
+ var task_event = sqliteTable("task_event", {
216
+ id: integer("id").primaryKey({ autoIncrement: true }),
217
+ event_id: text("event_id").notNull().unique().$defaultFn(() => `evt_${crypto.randomUUID()}`),
218
+ kind: text("kind", { enum: TASK_EVENT_KINDS }).notNull(),
219
+ subject_id: text("subject_id").notNull(),
220
+ project_id: text("project_id"),
221
+ actor: text("actor", { enum: TASK_EVENT_ACTORS }).notNull(),
222
+ payload: text("payload", { mode: "json" }).notNull(),
223
+ occurred_at: text("occurred_at").notNull().default(sql`(CURRENT_TIMESTAMP)`),
224
+ dispatch_status: text("dispatch_status", { enum: TASK_EVENT_DISPATCH_STATUSES }).notNull().default("pending"),
225
+ dispatched_at: text("dispatched_at")
226
+ }, (table) => [
227
+ index("task_event_subject_id_idx").on(table.subject_id),
228
+ index("task_event_dispatch_status_idx").on(table.dispatch_status)
229
+ ]);
162
230
  var checklist = sqliteTable("checklist", {
163
231
  ...entity("checklist"),
164
232
  task_id: text("task_id").notNull().references(() => task.id),
@@ -342,7 +410,20 @@ var task_relations = relations(task, ({ one, many }) => ({
342
410
  owner: one(user, { fields: [task.owner_id], references: [user.id] }),
343
411
  goal: one(goal, { fields: [task.goal_id], references: [goal.id] }),
344
412
  codebase_task: one(codebase_tasks, { fields: [task.codebase_task_id], references: [codebase_tasks.id] }),
345
- checklists: many(checklist)
413
+ checklists: many(checklist),
414
+ outgoing_links: many(task_link, { relationName: "task_link_src" }),
415
+ incoming_links: many(task_link, { relationName: "task_link_dst" }),
416
+ rollup: one(task_rollup, { fields: [task.id], references: [task_rollup.task_id] })
417
+ }));
418
+ var task_link_relations = relations(task_link, ({ one }) => ({
419
+ src: one(task, { fields: [task_link.src_id], references: [task.id], relationName: "task_link_src" }),
420
+ dst: one(task, { fields: [task_link.dst_id], references: [task.id], relationName: "task_link_dst" })
421
+ }));
422
+ var task_rollup_relations = relations(task_rollup, ({ one }) => ({
423
+ task: one(task, { fields: [task_rollup.task_id], references: [task.id] })
424
+ }));
425
+ var task_event_relations = relations(task_event, ({ one }) => ({
426
+ subject: one(task, { fields: [task_event.subject_id], references: [task.id] })
346
427
  }));
347
428
  var checklist_relations = relations(checklist, ({ one, many }) => ({
348
429
  task: one(task, { fields: [checklist.task_id], references: [task.id] }),
@@ -387,6 +468,7 @@ var pipeline_oidc_trust_relations = relations(pipeline_oidc_trust, ({ one }) =>
387
468
  }));
388
469
 
389
470
  // ../schema/dist/validation.js
471
+ import { z } from "zod";
390
472
  var upsert_project = z.object({
391
473
  id: z.string().optional().nullable(),
392
474
  project_id: z.string(),
@@ -440,6 +522,13 @@ var upsert_todo = z.object({
440
522
  owner_id: z.string(),
441
523
  project_id: z.string().optional().nullable(),
442
524
  goal_id: z.string().optional().nullable(),
525
+ // v2.4 graph fields. `completed_via` is deliberately absent — it's
526
+ // engine-owned (CompletionEngine, phase A2) and must never be settable
527
+ // from client input.
528
+ parent_id: z.string().optional().nullable(),
529
+ rank: z.string().optional(),
530
+ kind: z.union([z.literal("task"), z.literal("phase"), z.literal("approval")]).optional(),
531
+ completion_policy: z.union([z.literal("manual"), z.literal("auto_children")]).optional(),
443
532
  force: z.boolean().optional().describe("Override protection on user-modified entities")
444
533
  });
445
534
  var update_action = z.union([
@@ -666,8 +755,60 @@ var dashboard_response = z.object({
666
755
  approval_turnaround_p50_ms: z.number().nonnegative().nullable(),
667
756
  rollback_rate: z.number().min(0).max(1).nullable()
668
757
  });
758
+ var external_ref = z.discriminatedUnion("type", [
759
+ z.object({ type: z.literal("pr"), url: z.string().min(1) }),
760
+ z.object({ type: z.literal("commit"), sha: z.string().min(1) }),
761
+ z.object({ type: z.literal("file"), path: z.string().min(1) }),
762
+ z.object({ type: z.literal("doc"), doc_id: z.string().min(1) }),
763
+ z.object({ type: z.literal("metric"), name: z.string().min(1) }),
764
+ z.object({ type: z.literal("pipeline_run"), run_id: z.string().min(1) })
765
+ ]);
766
+ var task_link_kind = z.enum(TASK_LINK_KINDS);
767
+ var upsert_task_link = z.object({
768
+ id: z.string().optional().nullable(),
769
+ src_id: z.string(),
770
+ dst_id: z.string().nullable().optional(),
771
+ kind: task_link_kind,
772
+ ref: external_ref.nullable().optional(),
773
+ note: z.string().nullable().optional()
774
+ });
775
+ var apply_op = z.discriminatedUnion("op", [
776
+ z.object({
777
+ op: z.literal("create"),
778
+ handle: z.string().optional().describe("Temp handle (e.g. '$0') other ops in this batch may reference"),
779
+ data: upsert_todo
780
+ }),
781
+ z.object({ op: z.literal("update"), id: z.string(), base_rev: z.number().int(), data: upsert_todo.partial() }),
782
+ z.object({ op: z.literal("reparent"), id: z.string(), parent_id: z.string().nullable(), base_rev: z.number().int() }),
783
+ z.object({ op: z.literal("link"), link: upsert_task_link }),
784
+ z.object({ op: z.literal("unlink"), id: z.string() }),
785
+ z.object({ op: z.literal("claim"), id: z.string(), actor: z.string(), base_rev: z.number().int() }),
786
+ z.object({ op: z.literal("complete"), id: z.string(), base_rev: z.number().int() })
787
+ ]);
788
+ var apply_request = z.object({
789
+ idempotency_key: z.string().min(1),
790
+ base_revs: z.record(z.string(), z.number().int()).optional(),
791
+ ops: z.array(apply_op).min(1)
792
+ });
793
+ var claim_request = z.object({ actor: z.string().min(1), base_rev: z.number().int() });
794
+ var done_request = z.object({ base_rev: z.number().int() });
795
+ var task_event_actor = z.enum(TASK_EVENT_ACTORS);
796
+ var task_event_payload = z.discriminatedUnion("kind", [
797
+ z.object({ kind: z.literal("task.created"), title: z.string() }),
798
+ z.object({ kind: z.literal("task.updated"), fields: z.array(z.string()) }),
799
+ z.object({ kind: z.literal("task.completed"), via: z.enum(COMPLETED_VIA_VALUES) }),
800
+ z.object({ kind: z.literal("task.reopened"), via: z.enum(COMPLETED_VIA_VALUES) }),
801
+ z.object({ kind: z.literal("task.claimed"), actor: z.string() }),
802
+ z.object({ kind: z.literal("edge.created"), link_kind: task_link_kind, dst_id: z.string().nullable() }),
803
+ z.object({ kind: z.literal("edge.removed"), link_kind: task_link_kind, dst_id: z.string().nullable() }),
804
+ z.object({ kind: z.literal("node.children_all_done") }),
805
+ 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() })
807
+ ]);
669
808
 
670
809
  export {
810
+ GRAPH_DEPTH_CAP,
811
+ GRAPH_CHILDREN_CAP,
671
812
  RUN_STATUSES,
672
813
  STAGE_EVENT_KINDS,
673
814
  upsert_project,
@@ -702,5 +843,14 @@ export {
702
843
  upsert_pipeline_oidc_trust,
703
844
  webhook_event_body,
704
845
  dashboard_window_query,
705
- dashboard_response
846
+ dashboard_response,
847
+ external_ref,
848
+ task_link_kind,
849
+ upsert_task_link,
850
+ apply_op,
851
+ apply_request,
852
+ claim_request,
853
+ done_request,
854
+ task_event_actor,
855
+ task_event_payload
706
856
  };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
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-ELBwaLBA.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';
3
3
  import { z } from 'zod';
4
- import { a as ApiKey, l as Project, Z as UpsertProject, G as GetConfigResult, S as SaveConfigRequest, B as TodoUpdate, H as HistoryAction, M as Milestone, d as Goal, z as TaskWithDetails, $ as UpsertTodo, _ as UpsertTag, v as TagWithTypedColor, D as DashboardResponse, j as PipelineRun, k as PipelineStageEvent, g as PipelineGrant, i as PipelinePackage, P as PipelineAnalysisTemplate, h as PipelineOidcTrust } from './types.d-DUtDEHYM.js';
5
- export { m as ProjectConfig, w as Task } from './types.d-DUtDEHYM.js';
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';
6
6
  import { Result } from '@f0rbit/corpus';
7
7
  export { Result, err, ok } from '@f0rbit/corpus';
8
- import { S as StageEventKind } from './schema.d-BeVFWenc.js';
8
+ import { C as CompletedVia, S as StageEventKind } from './schema.d-DfzLWuRW.js';
9
9
  import 'drizzle-orm';
10
10
  import './media.d-R87HGuRp.js';
11
11
  import 'drizzle-orm/sqlite-core';
@@ -678,6 +678,36 @@ 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
+ type ReadyResponse = {
682
+ items: Task[];
683
+ next_cursor: string | null;
684
+ };
685
+ type TreeResponse = {
686
+ task: Task;
687
+ descendants: Task[];
688
+ };
689
+ type NearResponse = {
690
+ links: TaskLink[];
691
+ tasks: Task[];
692
+ };
693
+ type ApplyOpResult = {
694
+ op: ApplyOp["op"];
695
+ id: string;
696
+ };
697
+ type ApplyResponse = {
698
+ idempotency_key: string;
699
+ results: ApplyOpResult[];
700
+ };
701
+ type BubbleStep = {
702
+ task: Task;
703
+ via: CompletedVia;
704
+ };
705
+ type DoneResponse = {
706
+ completed: Task;
707
+ bubbled: BubbleStep[];
708
+ hooks_fired: string[];
709
+ };
710
+
681
711
  type TagWithCount = {
682
712
  tag: string;
683
713
  count: number;
@@ -1016,6 +1046,42 @@ declare class ApiClient {
1016
1046
  */
1017
1047
  get: (task_id: string) => Promise<ApiResult<HistoryAction[]>>;
1018
1048
  };
1049
+ /**
1050
+ * Ready-to-work tasks: not completed, not blocked by an incomplete
1051
+ * `blocks` edge, no incomplete children, start_time null-or-passed.
1052
+ */
1053
+ ready: (filters?: {
1054
+ project_id?: string;
1055
+ limit?: number;
1056
+ cursor?: string;
1057
+ }) => Promise<ApiResult<ReadyResponse>>;
1058
+ /** Bounded descendant subtree of a task. */
1059
+ tree: (id: string, depth?: number) => Promise<ApiResult<TreeResponse>>;
1060
+ /** depth-2 link neighborhood around a task, including backlinks. */
1061
+ near: (id: string) => Promise<ApiResult<NearResponse>>;
1062
+ /** Atomic claim: sets claimed_by/claimed_at + IN_PROGRESS, guarded on claimed_by IS NULL and base_rev. */
1063
+ claim: (id: string, data: ClaimRequest) => Promise<ApiResult<Task>>;
1064
+ /**
1065
+ * Completes a task through the single completion entrypoint
1066
+ * (CompletionEngine) — the response's `bubbled` chain is the ordered
1067
+ * list of ancestors an auto_children cascade also completed, exactly
1068
+ * what a ripple animation would replay. `hooks_fired` is a placeholder
1069
+ * until phase A3.
1070
+ */
1071
+ done: (id: string, data: DoneRequest) => Promise<ApiResult<DoneResponse>>;
1072
+ /** Create a typed edge between two tasks (or a task and an external ref). */
1073
+ link: (data: UpsertTaskLink) => Promise<ApiResult<TaskLink>>;
1074
+ /** Remove a typed edge by its own id. */
1075
+ unlink: (link_id: string) => Promise<ApiResult<{
1076
+ success: boolean;
1077
+ }>>;
1078
+ /**
1079
+ * Batch apply — create/update/reparent/link/unlink/claim/complete in one
1080
+ * atomic call, with `$0`/`$1`… temp handles for subtree creation.
1081
+ * Replaying the same `idempotency_key` returns the stored response
1082
+ * verbatim rather than re-executing.
1083
+ */
1084
+ apply: (data: ApplyRequest) => Promise<ApiResult<ApplyResponse>>;
1019
1085
  };
1020
1086
  /**
1021
1087
  * Tags namespace with Result-wrapped operations
@@ -1669,4 +1735,4 @@ declare const tools: Record<string, ToolDefinition>;
1669
1735
  declare const toolNames: string[];
1670
1736
  declare function getTool(name: string): ToolDefinition | undefined;
1671
1737
 
1672
- 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, TaskWithDetails, Timeline, type ToolDefinition, UpdateProfileInput, UpsertProject, UpsertTag, UpsertTodo, ValidationError, VersionInfo, ApiClient as default, getTool, getUserFriendlyErrorMessage, parseZodErrors, pulseSummaryHasData, toolNames, tools, wrap };
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 };
package/dist/index.js CHANGED
@@ -1,13 +1,15 @@
1
1
  import {
2
2
  RUN_STATUSES,
3
3
  STAGE_EVENT_KINDS,
4
+ apply_request,
4
5
  save_config_request,
5
6
  save_tags_request,
6
7
  upsert_goal,
7
8
  upsert_milestone,
8
9
  upsert_project,
10
+ upsert_task_link,
9
11
  upsert_todo
10
- } from "./chunk-DIX4XVUQ.js";
12
+ } from "./chunk-XHTCNYWS.js";
11
13
  import {
12
14
  CategoryCreateSchema,
13
15
  PostCreateSchema,
@@ -858,7 +860,45 @@ var ApiClient2 = class {
858
860
  * Get task history by task ID
859
861
  */
860
862
  get: (task_id) => wrap(() => this.clients.tasks.get(`/tasks/history/${task_id}`))
861
- }
863
+ },
864
+ /**
865
+ * Ready-to-work tasks: not completed, not blocked by an incomplete
866
+ * `blocks` edge, no incomplete children, start_time null-or-passed.
867
+ */
868
+ ready: (filters) => wrap(() => {
869
+ const query = {};
870
+ if (filters?.project_id) query.project = filters.project_id;
871
+ if (filters?.limit) query.limit = String(filters.limit);
872
+ if (filters?.cursor) query.cursor = filters.cursor;
873
+ return this.clients.tasks.get("/tasks/ready", Object.keys(query).length > 0 ? { query } : {});
874
+ }),
875
+ /** Bounded descendant subtree of a task. */
876
+ tree: (id, depth) => wrap(
877
+ () => this.clients.tasks.get(`/tasks/${id}/tree`, depth ? { query: { depth: String(depth) } } : {})
878
+ ),
879
+ /** depth-2 link neighborhood around a task, including backlinks. */
880
+ near: (id) => wrap(() => this.clients.tasks.get(`/tasks/${id}/near`)),
881
+ /** Atomic claim: sets claimed_by/claimed_at + IN_PROGRESS, guarded on claimed_by IS NULL and base_rev. */
882
+ claim: (id, data) => wrap(() => this.clients.tasks.post(`/tasks/${id}/claim`, { body: data })),
883
+ /**
884
+ * Completes a task through the single completion entrypoint
885
+ * (CompletionEngine) — the response's `bubbled` chain is the ordered
886
+ * list of ancestors an auto_children cascade also completed, exactly
887
+ * what a ripple animation would replay. `hooks_fired` is a placeholder
888
+ * until phase A3.
889
+ */
890
+ done: (id, data) => wrap(() => this.clients.tasks.post(`/tasks/${id}/done`, { body: data })),
891
+ /** Create a typed edge between two tasks (or a task and an external ref). */
892
+ link: (data) => wrap(() => this.clients.tasks.post("/tasks/link", { body: data })),
893
+ /** Remove a typed edge by its own id. */
894
+ unlink: (link_id) => wrap(() => this.clients.tasks.delete(`/tasks/link/${link_id}`)),
895
+ /**
896
+ * Batch apply — create/update/reparent/link/unlink/claim/complete in one
897
+ * atomic call, with `$0`/`$1`… temp handles for subtree creation.
898
+ * Replaying the same `idempotency_key` returns the stored response
899
+ * verbatim rather than re-executing.
900
+ */
901
+ apply: (data) => wrap(() => this.clients.tasks.post("/tasks/apply", { body: data }))
862
902
  };
863
903
  /**
864
904
  * Tags namespace with Result-wrapped operations
@@ -1848,6 +1888,73 @@ var tools = {
1848
1888
  }),
1849
1889
  execute: async (client, input) => unwrap(await client.tasks.history.get(input.task_id))
1850
1890
  }),
1891
+ // Graph operations (v2.4)
1892
+ devpad_tasks_ready: define_tool({
1893
+ name: "devpad_tasks_ready",
1894
+ description: "List tasks ready to work: not completed, not blocked by an incomplete 'blocks' edge, no incomplete children, start_time null-or-passed",
1895
+ inputSchema: z2.object({
1896
+ project_id: z2.string().optional().describe("Filter by project ID"),
1897
+ limit: z2.number().int().positive().optional().describe("Page size (default 20, max 100)"),
1898
+ cursor: z2.string().optional().describe("Pagination cursor from a previous page's next_cursor")
1899
+ }),
1900
+ execute: async (client, input) => unwrap(await client.tasks.ready(input))
1901
+ }),
1902
+ devpad_tasks_tree: define_tool({
1903
+ name: "devpad_tasks_tree",
1904
+ description: "Get a task and its bounded descendant subtree",
1905
+ inputSchema: z2.object({
1906
+ id: z2.string().describe("Task ID"),
1907
+ depth: z2.number().int().positive().optional().describe("Max hops down (default/cap: GRAPH_DEPTH_CAP)")
1908
+ }),
1909
+ execute: async (client, input) => unwrap(await client.tasks.tree(input.id, input.depth))
1910
+ }),
1911
+ devpad_tasks_near: define_tool({
1912
+ name: "devpad_tasks_near",
1913
+ description: "Get the depth-2 link neighborhood around a task, including backlinks",
1914
+ inputSchema: z2.object({
1915
+ id: z2.string().describe("Task ID")
1916
+ }),
1917
+ execute: async (client, input) => unwrap(await client.tasks.near(input.id))
1918
+ }),
1919
+ devpad_tasks_claim: define_tool({
1920
+ name: "devpad_tasks_claim",
1921
+ description: "Atomically claim a task for an agent (sets claimed_by + IN_PROGRESS); 409 if already claimed or stale base_rev",
1922
+ inputSchema: z2.object({
1923
+ id: z2.string().describe("Task ID"),
1924
+ actor: z2.string().describe("Identifier for the claiming agent"),
1925
+ base_rev: z2.number().int().describe("Expected current rev \u2014 optimistic concurrency guard")
1926
+ }),
1927
+ execute: async (client, input) => unwrap(await client.tasks.claim(input.id, { actor: input.actor, base_rev: input.base_rev }))
1928
+ }),
1929
+ devpad_tasks_done: define_tool({
1930
+ name: "devpad_tasks_done",
1931
+ description: "Complete a task through the single completion entrypoint (CompletionEngine). Returns { completed, bubbled, hooks_fired } \u2014 bubbled is the ordered chain of ancestors an auto_children cascade also completed. 409 on stale base_rev or if already completed.",
1932
+ inputSchema: z2.object({
1933
+ id: z2.string().describe("Task ID"),
1934
+ base_rev: z2.number().int().describe("Expected current rev \u2014 optimistic concurrency guard")
1935
+ }),
1936
+ execute: async (client, input) => unwrap(await client.tasks.done(input.id, { base_rev: input.base_rev }))
1937
+ }),
1938
+ devpad_tasks_link: define_tool({
1939
+ name: "devpad_tasks_link",
1940
+ description: "Create a typed edge between two tasks (blocks | relates_to | references | discovered_from | tracks_metric)",
1941
+ inputSchema: upsert_task_link,
1942
+ execute: async (client, input) => unwrap(await client.tasks.link(input))
1943
+ }),
1944
+ devpad_tasks_unlink: define_tool({
1945
+ name: "devpad_tasks_unlink",
1946
+ description: "Remove a typed edge by its own id",
1947
+ inputSchema: z2.object({
1948
+ id: z2.string().describe("task_link ID")
1949
+ }),
1950
+ execute: async (client, input) => unwrap(await client.tasks.unlink(input.id))
1951
+ }),
1952
+ devpad_tasks_apply: define_tool({
1953
+ name: "devpad_tasks_apply",
1954
+ 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.",
1955
+ inputSchema: apply_request,
1956
+ execute: async (client, input) => unwrap(await client.tasks.apply(input))
1957
+ }),
1851
1958
  // User operations
1852
1959
  devpad_user_me: define_tool({
1853
1960
  name: "devpad_user_me",