@perspectask/sdk 0.0.4 → 0.0.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/README.md CHANGED
@@ -185,15 +185,32 @@ await pt.tasks.update('<child-id>', {
185
185
  });
186
186
  ```
187
187
 
188
+ ### Pull requests
189
+
190
+ A GitHub PR whose branch name or title contains the task's `pr_token` (returned by `tasks.get`, `create` and `update`, e.g. `pt-a3f91c2`) links itself to the task. These methods cover the rest:
191
+
192
+ ```ts
193
+ const { data: task } = await pt.tasks.get('abc');
194
+ console.log(task?.pr_token); // "pt-abc12f4" — put it in the branch or PR title
195
+
196
+ const { data: prs } = await pt.tasks.pullRequests.list('abc');
197
+ // [{ id, repo, number, title, url, state, checks?, review?, preview_url?, draft?, linked_by }]
198
+
199
+ await pt.tasks.pullRequests.link('abc', 'https://github.com/owner/repo/pull/12'); // or 'owner/repo#12'
200
+ await pt.tasks.pullRequests.unlink('abc', prs![0].id);
201
+ ```
202
+
203
+ Needs the PerspecTask GitHub app on the repository; `link` answers 404 with `code: "not_installed"` otherwise.
204
+
188
205
  ## Scopes
189
206
 
190
207
  API keys carry scopes that control access:
191
208
 
192
209
  | Scope | Allows |
193
210
  | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
194
- | `tasks:read` | `list`, `get` |
195
- | `tasks:write` | `create`, `update` (including title/description) |
196
- | `tasks:write:meta` | `create`, `update` everything **except** editing title/description of existing tasks. Built for AI agents that manage workflow without rewriting your content. |
211
+ | `tasks:read` | `list`, `get`, `pullRequests.list` |
212
+ | `tasks:write` | `create`, `update` (including title/description), `pullRequests.link` / `unlink` |
213
+ | `tasks:write:meta` | `create`, `update` everything **except** editing title/description of existing tasks, plus `pullRequests.link` / `unlink`. Built for AI agents. |
197
214
 
198
215
  A call missing the required scope returns `403`.
199
216
 
@@ -205,6 +222,10 @@ End-to-end encrypted tasks are returned with `encrypted: true` and no `title`/`d
205
222
 
206
223
  All task IDs in responses are shortened to the minimum unique prefix (like git commit hashes). This keeps payloads small, saves tokens when used with LLMs and agents, and makes tasks easy to reference in the [CLI](https://www.npmjs.com/package/@perspectask/cli) and scripts. You can use these short prefixes anywhere an id is accepted. The API resolves them automatically. If a prefix is ambiguous, the API returns `400` asking you to be more specific.
207
224
 
225
+ ## Runtime schemas
226
+
227
+ The SDK also exports [Zod Mini](https://zod.dev/packages/mini) schemas generated from the same OpenAPI spec as its types (`zTask`, `zListTasksQuery`, `zCreateTaskBody`, `zUpdateTaskBody`, ...). Use them to validate input before it hits the API, or convert them with `toJSONSchema` (that's how [`@perspectask/mcp`](https://www.npmjs.com/package/@perspectask/mcp) advertises its tool inputs).
228
+
208
229
  ## License
209
230
 
210
231
  [Apache-2.0](./LICENSE)
package/dist/index.cjs CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,14 +17,42 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
21
31
  var index_exports = {};
22
32
  __export(index_exports, {
23
33
  PerspecTask: () => PerspecTask,
34
+ PullRequests: () => PullRequests,
24
35
  Tasks: () => Tasks,
25
- default: () => index_default
36
+ default: () => index_default,
37
+ zCreateTaskBody: () => zCreateTaskBody,
38
+ zCreateTaskResponse: () => zCreateTaskResponse,
39
+ zGetTaskPath: () => zGetTaskPath,
40
+ zGetTaskQuery: () => zGetTaskQuery,
41
+ zGetTaskResponse: () => zGetTaskResponse,
42
+ zLinkTaskPullRequestBody: () => zLinkTaskPullRequestBody,
43
+ zLinkTaskPullRequestPath: () => zLinkTaskPullRequestPath,
44
+ zLinkTaskPullRequestResponse: () => zLinkTaskPullRequestResponse,
45
+ zListTaskPullRequestsPath: () => zListTaskPullRequestsPath,
46
+ zListTaskPullRequestsResponse: () => zListTaskPullRequestsResponse,
47
+ zListTasksQuery: () => zListTasksQuery,
48
+ zListTasksResponse: () => zListTasksResponse,
49
+ zPullRequest: () => zPullRequest,
50
+ zTask: () => zTask,
51
+ zUnlinkTaskPullRequestPath: () => zUnlinkTaskPullRequestPath,
52
+ zUnlinkTaskPullRequestResponse: () => zUnlinkTaskPullRequestResponse,
53
+ zUpdateTaskBody: () => zUpdateTaskBody,
54
+ zUpdateTaskPath: () => zUpdateTaskPath,
55
+ zUpdateTaskResponse: () => zUpdateTaskResponse
26
56
  });
27
57
  module.exports = __toCommonJS(index_exports);
28
58
 
@@ -865,6 +895,265 @@ var Tasks = class {
865
895
  });
866
896
  }
867
897
  };
898
+ var PullRequests = class {
899
+ /**
900
+ * List pull requests linked to a task
901
+ *
902
+ * The GitHub pull requests linked to this task, with their state, CI result, review decision and preview deploy, kept up to date by GitHub webhooks. Needs the PerspecTask GitHub app installed on the repository (Account → GitHub in the web app).
903
+ */
904
+ static listTaskPullRequests(options) {
905
+ return (options.client ?? client).get({
906
+ security: [{ scheme: "bearer", type: "http" }],
907
+ url: "/tasks/{id}/pull-requests",
908
+ ...options
909
+ });
910
+ }
911
+ /**
912
+ * Link a pull request to a task
913
+ *
914
+ * Link a PR by its URL. Usually unnecessary: a PR whose title, branch or description contains the task's `pr_token` links itself. Linking an already-linked PR refreshes it. Needs the PerspecTask GitHub app installed on the repository (Account → GitHub in the web app). Answers 404 with `code: "not_installed"` when the app isn't on that repository or your GitHub account can't read it.
915
+ */
916
+ static linkTaskPullRequest(options) {
917
+ return (options.client ?? client).post({
918
+ security: [{ scheme: "bearer", type: "http" }],
919
+ url: "/tasks/{id}/pull-requests",
920
+ ...options,
921
+ headers: {
922
+ "Content-Type": "application/json",
923
+ ...options.headers
924
+ }
925
+ });
926
+ }
927
+ /**
928
+ * Unlink a pull request from a task
929
+ *
930
+ * Remove a link (`prId` is the `id` from the list). It stays unlinked: later pushes to the PR do not link it again, only linking it by URL does.
931
+ */
932
+ static unlinkTaskPullRequest(options) {
933
+ return (options.client ?? client).delete({
934
+ security: [{ scheme: "bearer", type: "http" }],
935
+ url: "/tasks/{id}/pull-requests/{prId}",
936
+ ...options
937
+ });
938
+ }
939
+ };
940
+
941
+ // src/generated/zod.gen.ts
942
+ var z = __toESM(require("zod/mini"), 1);
943
+ var zTask = z.object({
944
+ id: z.optional(z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)).register(z.globalRegistry, {
945
+ description: 'Short id: the minimum unique prefix of the task UUID (e.g. "a3f"). Accepted anywhere an id is.'
946
+ })),
947
+ pr_token: z.optional(z.string().check(z.regex(/^pt-[0-9a-f]{7,32}$/)).register(z.globalRegistry, {
948
+ description: 'Put this code (e.g. "pt-a3f91c2") in a GitHub pull request title or branch name and the PR links itself to this task (needs the PerspecTask GitHub app on the repo). It is longer than the short id on purpose, so it stays unambiguous as more tasks are added. Returned on single-task responses (get, create, update), not on lists.'
949
+ })),
950
+ title: z.optional(z.string()),
951
+ description: z.optional(z.string()),
952
+ encrypted: z.optional(z.boolean().register(z.globalRegistry, {
953
+ description: "True for end-to-end-encrypted tasks. Their title and description are omitted over this API (the keys are absent, not empty) \u2014 decrypt them in the web app."
954
+ })),
955
+ deadline: z.optional(z.string().register(z.globalRegistry, {
956
+ description: `The task's column id \u2014 d-20-11-2026, w-23-2026, m-6-2026, q-2-2026, y-2026, or "l" (lifetime). This is the same canonical form accepted as input on create/update.`
957
+ })),
958
+ deadline_date: z.optional(z.iso.datetime().register(z.globalRegistry, {
959
+ description: "The actual end-of-period timestamp (e.g. Sunday 23:59:59 for a weekly task). Omitted for lifetime tasks and tasks without a schedule."
960
+ })),
961
+ status: z.optional(z.enum([
962
+ "ACTIVE",
963
+ "COMPLETED",
964
+ "CANCELLED",
965
+ "READY",
966
+ "IN_PROGRESS",
967
+ "WAITING",
968
+ "DELEGATED"
969
+ ])),
970
+ completion: z.optional(z.string().register(z.globalRegistry, {
971
+ description: 'Percentage complete (e.g. "52%"), computed recursively over the ENTIRE subtree \u2014 children, their children, and so on to the leaves \u2014 not just direct children. PerspecTask maintains this automatically so the user sees true progress at a glance. It can read 100% when every descendant is completed even if this task itself is not yet checked. Conversely, if this task is itself marked completed, its completion is forced to 100% regardless of any unfinished descendants (the task-level status overrides the rollup). Only present when the task has children.'
972
+ })),
973
+ worked_time: z.optional(z.number().register(z.globalRegistry, {
974
+ description: "Total time tracked on this task, in seconds, summed across all its timers. Only present when greater than 0."
975
+ })),
976
+ priority: z.nullish(z.union([
977
+ z.literal(1),
978
+ z.literal(2),
979
+ z.literal(3)
980
+ ])),
981
+ created: z.optional(z.string().register(z.globalRegistry, {
982
+ description: 'When the task was created. Omitted by default. Present only when requested: `?showCreated=true` returns a relative time (e.g. "5 minutes ago"), `?showCreatedDate=true` returns an absolute ISO 8601 timestamp.'
983
+ })),
984
+ blocked_by: z.optional(z.array(z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/))).register(z.globalRegistry, {
985
+ description: "Tasks that should be done before this one (short ids), set with `block` / `removeBlock` on update. Just a flag, nothing is enforced. Only present when the task is blocked."
986
+ })),
987
+ children: z.optional(z.array(z.union([z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)), z.lazy(() => zTask)]))),
988
+ parents: z.optional(z.array(z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/))))
989
+ });
990
+ var zPullRequest = z.object({
991
+ id: z.uuid().register(z.globalRegistry, {
992
+ description: "Id of this task\u2194PR link. Pass it to unlink."
993
+ }),
994
+ repo: z.string(),
995
+ number: z.int(),
996
+ title: z.string(),
997
+ url: z.string().register(z.globalRegistry, {
998
+ description: "The PR on github.com."
999
+ }),
1000
+ state: z.enum([
1001
+ "open",
1002
+ "closed",
1003
+ "merged"
1004
+ ]),
1005
+ draft: z.optional(z.literal(true).register(z.globalRegistry, {
1006
+ description: "Only present when the PR is a draft."
1007
+ })),
1008
+ checks: z.optional(z.enum([
1009
+ "pending",
1010
+ "success",
1011
+ "failure"
1012
+ ]).register(z.globalRegistry, {
1013
+ description: "Combined CI result of the PR's head commit (check runs + commit statuses). Omitted when the commit has no CI."
1014
+ })),
1015
+ review: z.optional(z.enum(["approved", "changes_requested"]).register(z.globalRegistry, {
1016
+ description: "Reviewers' current decision. Omitted when nobody approved or requested changes."
1017
+ })),
1018
+ preview_url: z.optional(z.string().register(z.globalRegistry, {
1019
+ description: "Latest successful preview deployment (Vercel, Netlify, \u2026). Omitted when there is none."
1020
+ })),
1021
+ linked_by: z.enum(["auto", "manual"]).register(z.globalRegistry, {
1022
+ description: "`auto` = linked by the pt- code in the PR; `manual` = linked by URL."
1023
+ })
1024
+ });
1025
+ var zListTasksQuery = z.object({
1026
+ includeEncrypted: z.optional(z.boolean().register(z.globalRegistry, {
1027
+ description: "Defaults to false. In tree mode, encrypted tasks are pruned UNLESS they lie on the path to an unencrypted task \u2014 so an encrypted parent of a readable task is kept (with `encrypted: true` and no title/description keys) to preserve structure, while fully-encrypted branches are hidden. In flat mode, encrypted tasks are simply omitted. Set to true to include ALL end-to-end-encrypted tasks for full visibility."
1028
+ })),
1029
+ tree: z.optional(z.boolean().register(z.globalRegistry, {
1030
+ description: "Defaults to false. When true, each task's `children` are returned as full nested task objects (recursively) instead of id strings. A task that was already expanded elsewhere in the tree will not be expanded again \u2014 only its short id string will appear in the `children` array of subsequent parent tasks, preserving the relationship without repeating the full object."
1031
+ })),
1032
+ treeFull: z.optional(z.boolean().register(z.globalRegistry, {
1033
+ description: "Like `tree` but without deduplication: a task with multiple parents appears under each parent. Mutually exclusive with `tree`."
1034
+ })),
1035
+ showCreated: z.optional(z.boolean().register(z.globalRegistry, {
1036
+ description: 'Defaults to false. Set to true to include `created` as a human-friendly relative time (e.g. "5 minutes ago"). Ignored when `showCreatedDate` is true.'
1037
+ })),
1038
+ showCreatedDate: z.optional(z.boolean().register(z.globalRegistry, {
1039
+ description: "Defaults to false. Set to true to include `created` as an absolute ISO 8601 timestamp. Takes precedence over `showCreated` when both are set."
1040
+ })),
1041
+ showCompleted: z.optional(z.boolean().register(z.globalRegistry, {
1042
+ description: "Defaults to false. By default the list omits done tasks (status COMPLETED and CANCELLED) so an agent sees only open work and to save context. Set to true to include all completed and cancelled tasks. Exception in tree mode: a completed task is kept if any of its descendants is still open \u2014 this preserves the path/context to that open task even when showCompleted is false."
1043
+ }))
1044
+ });
1045
+ var zListTasksResponse = z.array(zTask).register(z.globalRegistry, {
1046
+ description: "List of tasks"
1047
+ });
1048
+ var zCreateTaskBody = z.object({
1049
+ title: z.string().check(z.minLength(1)),
1050
+ description: z.optional(z.string()),
1051
+ priority: z.optional(z.union([
1052
+ z.literal(0),
1053
+ z.literal(1),
1054
+ z.literal(2),
1055
+ z.literal(3)
1056
+ ])),
1057
+ deadline: z.optional(z.string().register(z.globalRegistry, {
1058
+ description: "When this task is due. A single shorthand token that sets both the period type and the date. Accepts: today, tomorrow, this/next week|month|quarter|year, lifetime, the bare letters d/w/m/q/y/l (= today, this week, this month, this quarter, this year, lifetime), or a column id (d-20-11-2026, w-23-2026, m-6-2026, q-2-2026, y-2026; trailing parts may be omitted to default to current month/year; the first number may be glued: q2, w23, d20)."
1059
+ })),
1060
+ parent_id: z.optional(z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)).register(z.globalRegistry, {
1061
+ description: "Parent task id \u2014 full UUID or a short id prefix."
1062
+ }))
1063
+ });
1064
+ var zCreateTaskResponse = zTask;
1065
+ var zGetTaskPath = z.object({
1066
+ id: z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/))
1067
+ });
1068
+ var zGetTaskQuery = z.object({
1069
+ includeEncrypted: z.optional(z.boolean().register(z.globalRegistry, {
1070
+ description: "Defaults to false. In tree mode, encrypted descendants are pruned unless they lie on the path to an unencrypted task (so you see the structure leading to a task you can read). Set to true to keep ALL encrypted tasks in the subtree (returned with `encrypted: true` and no title/description keys). The requested task itself is always returned regardless."
1071
+ })),
1072
+ tree: z.optional(z.boolean().register(z.globalRegistry, {
1073
+ description: "Defaults to false. When true, this task's `children` are returned as full nested task objects (recursively) instead of id strings. A task that was already expanded elsewhere in the subtree will not be expanded again \u2014 only its short id string will appear in subsequent parents' `children`, preserving the relationship without repeating the full object."
1074
+ })),
1075
+ treeFull: z.optional(z.boolean().register(z.globalRegistry, {
1076
+ description: "Like `tree` but without deduplication: a task with multiple parents appears under each parent. Mutually exclusive with `tree`."
1077
+ })),
1078
+ showCreated: z.optional(z.boolean().register(z.globalRegistry, {
1079
+ description: 'Defaults to false. Set to true to include `created` as a human-friendly relative time (e.g. "5 minutes ago"). Ignored when `showCreatedDate` is true.'
1080
+ })),
1081
+ showCreatedDate: z.optional(z.boolean().register(z.globalRegistry, {
1082
+ description: "Defaults to false. Set to true to include `created` as an absolute ISO 8601 timestamp. Takes precedence over `showCreated` when both are set."
1083
+ })),
1084
+ showCompleted: z.optional(z.boolean().register(z.globalRegistry, {
1085
+ description: "Defaults to false. By default completed and cancelled subtasks are pruned from the tree. Exception: a completed task is kept if any of its descendants is still open (to preserve context/path). Set to true to include all completed and cancelled tasks regardless."
1086
+ }))
1087
+ });
1088
+ var zGetTaskResponse = zTask;
1089
+ var zUpdateTaskBody = z.object({
1090
+ title: z.optional(z.string()),
1091
+ description: z.optional(z.string()),
1092
+ deadline: z.optional(z.string().register(z.globalRegistry, {
1093
+ description: "When this task is due \u2014 same shorthand grammar as on create (today, lifetime, q-2-2026, q2, d-20-11, \u2026)."
1094
+ })),
1095
+ status: z.optional(z.enum([
1096
+ "ACTIVE",
1097
+ "COMPLETED",
1098
+ "CANCELLED",
1099
+ "READY",
1100
+ "IN_PROGRESS",
1101
+ "WAITING",
1102
+ "DELEGATED"
1103
+ ])),
1104
+ priority: z.optional(z.union([
1105
+ z.literal(0),
1106
+ z.literal(1),
1107
+ z.literal(2),
1108
+ z.literal(3)
1109
+ ])),
1110
+ add_parent: z.optional(z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)).register(z.globalRegistry, {
1111
+ description: "Attach this task as a child of the given parent (full UUID or short id prefix)."
1112
+ })),
1113
+ remove_parent: z.optional(z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)).register(z.globalRegistry, {
1114
+ description: "Detach this task from the given parent (full UUID or short id prefix)."
1115
+ })),
1116
+ replace_parent: z.optional(z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)).register(z.globalRegistry, {
1117
+ description: "Replace the task's existing parent with this new one (full UUID or short id prefix). If the task has exactly one parent, that one is replaced. If it has multiple, you must also pass `replace_parent_from` to say which to replace."
1118
+ })),
1119
+ replace_parent_from: z.optional(z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)).register(z.globalRegistry, {
1120
+ description: "When replacing among multiple parents, the existing parent to replace (full UUID or short id prefix; used with `replace_parent`)."
1121
+ })),
1122
+ block: z.optional(z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)).register(z.globalRegistry, {
1123
+ description: "Mark the given task as blocking this one \u2014 it should be done first (full UUID or short id prefix). Just a flag; nothing is enforced."
1124
+ })),
1125
+ removeBlock: z.optional(z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)).register(z.globalRegistry, {
1126
+ description: 'Remove the given task from this task\u2019s "blocked by" list (full UUID or short id prefix).'
1127
+ }))
1128
+ });
1129
+ var zUpdateTaskPath = z.object({
1130
+ id: z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/))
1131
+ });
1132
+ var zUpdateTaskResponse = zTask;
1133
+ var zListTaskPullRequestsPath = z.object({
1134
+ id: z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/))
1135
+ });
1136
+ var zListTaskPullRequestsResponse = z.array(zPullRequest).register(z.globalRegistry, {
1137
+ description: "Linked pull requests (oldest first)"
1138
+ });
1139
+ var zLinkTaskPullRequestBody = z.object({
1140
+ url: z.string().check(z.minLength(1)).register(z.globalRegistry, {
1141
+ description: "The pull request: `https://github.com/owner/repo/pull/123` or `owner/repo#123`."
1142
+ })
1143
+ });
1144
+ var zLinkTaskPullRequestPath = z.object({
1145
+ id: z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/))
1146
+ });
1147
+ var zLinkTaskPullRequestResponse = zPullRequest;
1148
+ var zUnlinkTaskPullRequestPath = z.object({
1149
+ id: z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)),
1150
+ prId: z.uuid().register(z.globalRegistry, {
1151
+ description: "The link id (`id` from the pull request list)."
1152
+ })
1153
+ });
1154
+ var zUnlinkTaskPullRequestResponse = z.void().register(z.globalRegistry, {
1155
+ description: "Unlinked"
1156
+ });
868
1157
 
869
1158
  // src/index.ts
870
1159
  var PerspecTask = class {
@@ -894,13 +1183,46 @@ function createTasksNamespace(client2) {
894
1183
  /** Create a task (`title` required). Wraps `Tasks.createTask`. */
895
1184
  create: (body) => Tasks.createTask({ client: client2, body }),
896
1185
  /** Update editable fields on a task by id. Wraps `Tasks.updateTask`. */
897
- update: (id, body) => Tasks.updateTask({ client: client2, path: { id }, body })
1186
+ update: (id, body) => Tasks.updateTask({ client: client2, path: { id }, body }),
1187
+ /**
1188
+ * GitHub pull requests linked to a task. Usually you don't need these: put
1189
+ * the task's `pr_token` (e.g. `pt-a3f91c2`, on `tasks.get`) in a PR title
1190
+ * or branch name and the PR links itself.
1191
+ */
1192
+ pullRequests: {
1193
+ /** List the task's linked PRs (state, checks, review, preview). Wraps `PullRequests.listTaskPullRequests`. */
1194
+ list: (id) => PullRequests.listTaskPullRequests({ client: client2, path: { id } }),
1195
+ /** Link a PR by URL (`https://github.com/o/r/pull/12` or `o/r#12`). Wraps `PullRequests.linkTaskPullRequest`. */
1196
+ link: (id, url) => PullRequests.linkTaskPullRequest({ client: client2, path: { id }, body: { url } }),
1197
+ /** Unlink by the link `id` from `list`. Wraps `PullRequests.unlinkTaskPullRequest`. */
1198
+ unlink: (id, prId) => PullRequests.unlinkTaskPullRequest({ client: client2, path: { id, prId } })
1199
+ }
898
1200
  };
899
1201
  }
900
1202
  var index_default = PerspecTask;
901
1203
  // Annotate the CommonJS export names for ESM import in node:
902
1204
  0 && (module.exports = {
903
1205
  PerspecTask,
904
- Tasks
1206
+ PullRequests,
1207
+ Tasks,
1208
+ zCreateTaskBody,
1209
+ zCreateTaskResponse,
1210
+ zGetTaskPath,
1211
+ zGetTaskQuery,
1212
+ zGetTaskResponse,
1213
+ zLinkTaskPullRequestBody,
1214
+ zLinkTaskPullRequestPath,
1215
+ zLinkTaskPullRequestResponse,
1216
+ zListTaskPullRequestsPath,
1217
+ zListTaskPullRequestsResponse,
1218
+ zListTasksQuery,
1219
+ zListTasksResponse,
1220
+ zPullRequest,
1221
+ zTask,
1222
+ zUnlinkTaskPullRequestPath,
1223
+ zUnlinkTaskPullRequestResponse,
1224
+ zUpdateTaskBody,
1225
+ zUpdateTaskPath,
1226
+ zUpdateTaskResponse
905
1227
  });
906
1228
  //# sourceMappingURL=index.cjs.map