mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-03 20:09:33 +01:00
feat(board): add task assign, atomic handoff, claim filters, cancel/reopen, mid-flight deps, and channel admin (#23415)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Headless channels, fenced task queues, `@paperclipai/shared/sdk`, and the `pc` CLI landed in #23330 to coordinate multi-agent swarms and inbox/queue patterns. > - Real multi-stage workflows immediately hit gaps: there was no `assign` command to push existing channel posts to managed agents, no atomic `handoff`/`move` across channels with CAS labels and lease release, `claim --ready` could not opt into `backlog`/`in_review` or `--assignee me`, there was no `cancel`/`reopen` or mid-flight `--needs` dependency linking, and `pc channels` could not update queue config, manage private members, or bind event-driven managed pools. > - Without these primitives, operators had to drop back to raw `issue update` calls or non-atomic two-step scripts that race on crash. > - This pull request adds the complete workflow lifecycle across shared schemas, modular server services/routes, SDK methods, `pc` CLI commands, and the `.agents/skills/channels-queues-and-workflows` skill. > - The benefit is end-to-end single-command support for inbox triage, single-thread relays, chained channel assembly lines, mid-flight DAG dependencies, and Day-2 graduation to managed Paperclip agent pools. ## Linked Issues or Issue Description Refs #23330 **Subsystem affected** Cross-cutting (multiple of the above) **Problem or motivation** Building multi-agent queues and chained workflows on Paperclip channels required workarounds: assigning an existing post to a registered agent required raw `issue update --assignee-agent-id <uuid>`; moving an issue across stage channels with a label update and lease release required non-atomic multi-step calls; triage or review workers could not opt into claiming `backlog`, `in_review`, or their own assigned tasks (`--mine`); tasks could not be cancelled, reopened, or given mid-flight `--needs` blockers; and channels lacked CLI/API administration for `queueConfig`, private `channel_access_members`, and `managedPool` auto-dispatch. **Proposed solution** Add cohesive REST endpoints, modular services (`headless-task-workflows.ts`, `headless-channel-admin.ts`), SDK methods, `pc` CLI subcommands, and the `channels-queues-and-workflows` skill covering `assign`, `handoff`/`move`, `cancel`, `reopen`, `block --needs`/`deps`, opt-in `claim --status`/`--assignee`, and `channels update`/`members` with event-driven `managedPool` dispatch. **Alternatives considered** Leaving these operations to raw `PATCH /api/issues/:id` calls was rejected because it bypasses fenced claim tokens (`claimEpoch` + `claimToken`), lacks atomic channel+label+lease transactions, and does not enforce CAS preconditions or dependency cycle checks. **Roadmap alignment** Directly extends the headless channels and queues coordination primitive introduced in #23330. ## What Changed - **Shared schemas & SDK (`packages/shared/src/headless/`, `packages/shared/src/sdk/`):** - Added pure zero-zod constants `CLAIMABLE_TASK_STATUSES` and `TASK_CLAIM_ASSIGNEE_MODES` in `pure.ts`, upgraded `TaskClaimRequestSchema` (`status`/`statuses`, `assignee`) and `TaskReleaseSchema` (`status`, `channel`, `labels`, `unsetLabels`), and added `TaskAssignSchema`, `TaskHandoffSchema`, `TaskCancelSchema`, `TaskReopenSchema`, `TaskDependenciesMutationSchema`, `updateChannelInputSchema`, and `channelMemberInputSchema`. - Added `task.assigned`, `task.handed_off`, `task.cancelled`, `task.reopened`, and `task.dependencies_changed` to `BOARD_EVENT_TYPES`. - Exposed matching SDK methods on `paperclip().tasks`, `ClaimedTask`, and `paperclip().channels`. - **Server services & routes (`server/src/services/`, `server/src/routes/`):** - Upgraded `claimTask` and `releaseTaskClaim` in `headless-task-queue.ts` to support opt-in `status` (`todo`, `backlog`, `in_review` excluding pending interactions), `assignee` (`unassigned`, `me`, `any`), and atomic channel/label/status updates on release. - Added `server/src/services/headless-task-workflows.ts` implementing `assignTask`, `handoffTask`, `cancelTask`, `reopenTask`, `listTaskDependencies`, and `mutateTaskDependencies` (with BFS cycle detection and fenced lease release). - Added `server/src/services/headless-channel-admin.ts` implementing `updateChannel`, `listChannelMembers`, `addChannelMember`, `removeChannelMember`, and event-driven `dispatchManagedChannelPool` (zero idle polling). - Wired routes in `headless-queues-events.ts` and `headless-channels-schemas.ts`. - **CLI (`cli/src/commands/board/`):** - Added `cli/src/commands/board/tasks-workflows.ts` (`pc tasks assign`, `handoff`/`move`, `cancel`, `reopen`, `deps list|add|remove`). - Upgraded `pc tasks claim`/`run` (`--status`, `--assignee`, `--mine`), `pc tasks release` (`--channel`, `--label`, `--unset`, `--status`), `pc tasks block` (`--needs`), and `pc channels` (`update`/`config`, `members list|add|remove`). - **Skill & Tests:** - Added `.agents/skills/channels-queues-and-workflows/SKILL.md` and `examples.md`. - Added `server/src/__tests__/headless-task-workflows.test.ts` and updated `tests/runner-e2e/source-sdk-public-inputs.json`. ## Verification - `pnpm --filter @paperclipai/shared build && pnpm --filter @paperclipai/server typecheck && pnpm --filter paperclipai typecheck` — passed. - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/headless-task-workflows.test.ts src/__tests__/headless-queues-leases-events.test.ts src/__tests__/headless-channels-schemas-batch.test.ts src/__tests__/headless-e2e-sdk-cli.test.ts` — 4 files, 27 tests passed. - `pnpm --filter @paperclipai/shared exec vitest run src/headless/headless.test.ts src/sdk/sdk.test.ts` — 2 files, 20 tests passed. - Live headless CLI test-drive (`pc up --port 3299` in isolated `PAPERCLIP_HOME`) verifying `agent connect`, `post`, `tasks assign`, `tasks claim --mine`, `tasks handoff`, `tasks release --status in_review`, `tasks claim --status in_review`, `tasks block --needs`, `tasks deps list`, blocker completion auto-unblock, `tasks cancel`, `tasks reopen`, `tasks claim --status backlog`, `channels members add/list/remove`, and `channels update --managed-pool` — all 11 scenarios passed. ## Risks - Low risk. No database migrations are required; existing `channels.queue_config`, `channel_access_members`, `issue_relations`, and `issues` lease columns are reused. - Default `claim --ready` behavior (`status = todo`, `assignee = unassigned`) is unchanged; `--status` and `--assignee` are strictly opt-in, and `--assignee me`/`any` never allows claiming tasks assigned to another agent or user. - Note on file size: `server/src/services/headless-task-queue.ts` and `cli/src/commands/board/tasks.ts` were already over 1,000 lines before this PR; all new workflow/admin operations were placed in dedicated sibling modules (`headless-task-workflows.ts`, `headless-channel-admin.ts`, `tasks-workflows.ts`) to keep existing files bounded. ## Model Used - Google Gemini (Antigravity agentic runtime, Gemini 4 Neon Medium, extended thinking with tool use and code execution) ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge
This commit is contained in:
1 parent
fcb8fc5deb
commit
0434e7f3aa
30 files changed
+5985
-67
No files matched your search
@@ -112,3 +112,47 @@ export const channelPostInputSchema = z
|
||||
.strict();
|
||||
|
||||
export type ChannelPostInput = z.input<typeof channelPostInputSchema>;
|
||||
|
||||
export const updateChannelInputSchema = z
|
||||
.object({
|
||||
channel: exactChannelPathSchema.optional(),
|
||||
description: z.string().max(1000).nullable().optional(),
|
||||
defaultProjectId: z.string().min(1).nullable().optional(),
|
||||
archived: z.boolean().optional(),
|
||||
queueConfig: channelQueueConfigSchema.nullable().optional(),
|
||||
managedPool: z
|
||||
.union([
|
||||
z
|
||||
.object({
|
||||
agent: z.string().min(1),
|
||||
maxConcurrency: z.number().int().min(1).max(100).default(1),
|
||||
})
|
||||
.strict(),
|
||||
z.null(),
|
||||
])
|
||||
.optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export type UpdateChannelInput = z.input<typeof updateChannelInputSchema>;
|
||||
|
||||
export const channelMemberInputSchema = z
|
||||
.object({
|
||||
channel: exactChannelPathSchema,
|
||||
agent: z.string().min(1).optional(),
|
||||
userId: z.string().min(1).optional(),
|
||||
subjectType: z.enum(["user", "agent"]).optional(),
|
||||
subjectId: z.string().min(1).optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export type ChannelMemberInput = z.input<typeof channelMemberInputSchema>;
|
||||
|
||||
export interface ChannelMemberView {
|
||||
id: string;
|
||||
channelId: string;
|
||||
subjectType: "user" | "agent";
|
||||
subjectId: string;
|
||||
displayName: string | null;
|
||||
createdAt: string;
|
||||
}
|
||||
@@ -17,6 +17,11 @@ export const BOARD_EVENT_TYPES = [
|
||||
"task.failed",
|
||||
"task.blocked",
|
||||
"task.unblocked",
|
||||
"task.assigned",
|
||||
"task.handed_off",
|
||||
"task.cancelled",
|
||||
"task.reopened",
|
||||
"task.dependencies_changed",
|
||||
"labels.changed",
|
||||
"interaction.created",
|
||||
"interaction.resolved",
|
||||
|
||||
@@ -1,10 +1,23 @@
|
||||
import { z } from "zod";
|
||||
import type { IssuePriority, IssueStatus } from "../constants.js";
|
||||
import { ISSUE_PRIORITIES, type IssuePriority, type IssueStatus } from "../constants.js";
|
||||
import type { IssueScope } from "./identity.js";
|
||||
import { parseDurationMs } from "./pure.js";
|
||||
import { writableKvLabelsRecordSchema } from "./labels.js";
|
||||
import {
|
||||
CLAIMABLE_TASK_STATUSES,
|
||||
parseDurationMs,
|
||||
TASK_CLAIM_ASSIGNEE_MODES,
|
||||
type ClaimableTaskStatus,
|
||||
type TaskClaimAssigneeMode,
|
||||
} from "./pure.js";
|
||||
import { SCHEMA_REF_REGEX, schemaBlockSchema, type SchemaBlock } from "./schemas.js";
|
||||
|
||||
export { parseDurationMs };
|
||||
export {
|
||||
CLAIMABLE_TASK_STATUSES,
|
||||
parseDurationMs,
|
||||
TASK_CLAIM_ASSIGNEE_MODES,
|
||||
type ClaimableTaskStatus,
|
||||
type TaskClaimAssigneeMode,
|
||||
};
|
||||
|
||||
export const durationValueSchema = z
|
||||
.union([z.number().finite().nonnegative(), z.string().min(1)])
|
||||
@@ -27,6 +40,9 @@ export const TaskClaimRequestSchema = z
|
||||
channel: z.string().min(1).optional(),
|
||||
projectId: z.string().min(1).optional(),
|
||||
labels: z.array(z.string().min(1)).optional(),
|
||||
status: z.union([z.enum(CLAIMABLE_TASK_STATUSES), z.array(z.enum(CLAIMABLE_TASK_STATUSES))]).optional(),
|
||||
statuses: z.array(z.enum(CLAIMABLE_TASK_STATUSES)).optional(),
|
||||
assignee: z.enum(TASK_CLAIM_ASSIGNEE_MODES).optional(),
|
||||
leaseSec: z.number().int().min(1).max(86400).optional(),
|
||||
lease: z.union([z.number().finite().positive(), z.string().min(1)]).optional(),
|
||||
waitSec: z.number().finite().nonnegative().optional(),
|
||||
@@ -53,11 +69,102 @@ export const TaskReleaseSchema = z
|
||||
claimToken: z.string().min(1).optional(),
|
||||
claimEpoch: z.number().int().nonnegative().optional(),
|
||||
comment: z.string().optional(),
|
||||
status: z.enum(CLAIMABLE_TASK_STATUSES).optional(),
|
||||
channel: z.string().min(1).optional(),
|
||||
labels: writableKvLabelsRecordSchema.optional(),
|
||||
unsetLabels: z.array(z.string().min(1)).optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export type TaskReleaseInput = z.input<typeof TaskReleaseSchema>;
|
||||
|
||||
export const TaskAssignSchema = z
|
||||
.object({
|
||||
assignee: z.string().min(1).nullable().optional(),
|
||||
assigneeAgentId: z.string().uuid().nullable().optional(),
|
||||
unassign: z.boolean().optional(),
|
||||
keepStatus: z.boolean().optional(),
|
||||
force: z.boolean().optional(),
|
||||
comment: z.string().optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export type TaskAssignInput = z.input<typeof TaskAssignSchema>;
|
||||
|
||||
export const TaskHandoffSchema = z
|
||||
.object({
|
||||
claimToken: z.string().min(1).optional(),
|
||||
claimEpoch: z.number().int().nonnegative().optional(),
|
||||
channel: z.string().min(1).optional(),
|
||||
status: z.enum(CLAIMABLE_TASK_STATUSES).optional(),
|
||||
labels: writableKvLabelsRecordSchema.optional(),
|
||||
unsetLabels: z.array(z.string().min(1)).optional(),
|
||||
ifLabels: z.record(z.string().min(1), z.string().nullable()).optional(),
|
||||
assignee: z.string().min(1).nullable().optional(),
|
||||
unassign: z.boolean().optional(),
|
||||
priority: z.enum(ISSUE_PRIORITIES).optional(),
|
||||
resultSchema: z
|
||||
.string()
|
||||
.refine((v) => SCHEMA_REF_REGEX.test(v.trim()), {
|
||||
message: "Invalid resultSchema ref",
|
||||
})
|
||||
.nullable()
|
||||
.optional(),
|
||||
comment: z.string().optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export type TaskHandoffInput = z.input<typeof TaskHandoffSchema>;
|
||||
|
||||
export const TaskCancelSchema = z
|
||||
.object({
|
||||
claimToken: z.string().min(1).optional(),
|
||||
claimEpoch: z.number().int().nonnegative().optional(),
|
||||
reason: z.string().optional(),
|
||||
force: z.boolean().optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export type TaskCancelInput = z.input<typeof TaskCancelSchema>;
|
||||
|
||||
export const TaskReopenSchema = z
|
||||
.object({
|
||||
status: z.enum(["todo", "backlog"]).optional(),
|
||||
comment: z.string().optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export type TaskReopenInput = z.input<typeof TaskReopenSchema>;
|
||||
|
||||
export const TaskDependenciesMutationSchema = z
|
||||
.object({
|
||||
add: z.array(z.string().min(1)).max(50).optional(),
|
||||
remove: z.array(z.string().min(1)).max(50).optional(),
|
||||
releaseLease: z.boolean().optional(),
|
||||
claimToken: z.string().min(1).optional(),
|
||||
claimEpoch: z.number().int().nonnegative().optional(),
|
||||
comment: z.string().optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export type TaskDependenciesMutationInput = z.input<typeof TaskDependenciesMutationSchema>;
|
||||
|
||||
export interface TaskDependencyItemView {
|
||||
id: string;
|
||||
identifier: string;
|
||||
title: string;
|
||||
status: IssueStatus;
|
||||
}
|
||||
|
||||
export interface TaskDependenciesView {
|
||||
issueId: string;
|
||||
identifier: string;
|
||||
status: IssueStatus;
|
||||
blockedBy: TaskDependencyItemView[];
|
||||
blocks: TaskDependencyItemView[];
|
||||
cursor: string;
|
||||
}
|
||||
|
||||
export const TaskCompleteSchema = z
|
||||
.object({
|
||||
claimToken: z.string().min(1).optional(),
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
export const CHANNEL_PATH_REGEX = /^[a-z0-9][a-z0-9_-]*(\/[a-z0-9][a-z0-9_-]*)*$/;
|
||||
|
||||
export const CLAIMABLE_TASK_STATUSES = ["todo", "backlog", "in_review"] as const;
|
||||
export type ClaimableTaskStatus = (typeof CLAIMABLE_TASK_STATUSES)[number];
|
||||
|
||||
export const TASK_CLAIM_ASSIGNEE_MODES = ["unassigned", "me", "any"] as const;
|
||||
export type TaskClaimAssigneeMode = (typeof TASK_CLAIM_ASSIGNEE_MODES)[number];
|
||||
|
||||
export interface NormalizedChannelPath {
|
||||
path: string;
|
||||
isSubtreePrefix: boolean;
|
||||
|
||||
@@ -2,6 +2,7 @@ import { parseDurationMs, parseSchemaRef } from "../headless/pure.js";
|
||||
import type {
|
||||
BatchCreateIssuesResult,
|
||||
BoardEventView,
|
||||
ChannelMemberView,
|
||||
ChannelPage,
|
||||
ChannelView,
|
||||
ClientScopes,
|
||||
@@ -19,8 +20,12 @@ import type {
|
||||
SchemaBlock,
|
||||
SchedulePostInput,
|
||||
ScheduleView,
|
||||
TaskAssignInput,
|
||||
TaskCancelInput,
|
||||
TaskClaimView,
|
||||
TaskCompleteInput,
|
||||
TaskDependenciesView,
|
||||
TaskReleaseInput,
|
||||
ThreadDetailView,
|
||||
WhoAmIView,
|
||||
} from "../headless/index.js";
|
||||
@@ -317,21 +322,42 @@ function createHandle(state: InternalClientState): PaperclipHandle {
|
||||
return view;
|
||||
},
|
||||
|
||||
async release(comment) {
|
||||
async release(commentOrOpts) {
|
||||
const payload: Omit<TaskReleaseInput, "claimToken" | "claimEpoch"> =
|
||||
typeof commentOrOpts === "string"
|
||||
? { comment: commentOrOpts }
|
||||
: { ...(commentOrOpts ?? {}) };
|
||||
return requestJson<{ released: boolean; cursor: string }>(
|
||||
`/api/issues/${encodeURIComponent(currentTask.id)}/claim/release`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: { "x-paperclip-claim-token": currentClaimToken },
|
||||
body: JSON.stringify({
|
||||
...payload,
|
||||
claimToken: currentClaimToken,
|
||||
claimEpoch: currentClaimEpoch,
|
||||
...(comment !== undefined ? { comment } : {}),
|
||||
}),
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
async handoff(opts) {
|
||||
const updated = await requestJson<HeadlessIssueView>(
|
||||
`/api/issues/${encodeURIComponent(currentTask.id)}/handoff`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: { "x-paperclip-claim-token": currentClaimToken },
|
||||
body: JSON.stringify({
|
||||
...opts,
|
||||
claimToken: currentClaimToken,
|
||||
claimEpoch: currentClaimEpoch,
|
||||
}),
|
||||
},
|
||||
);
|
||||
currentTask = updated;
|
||||
return updated;
|
||||
},
|
||||
|
||||
async complete(opts) {
|
||||
const payload: TaskCompleteInput =
|
||||
typeof opts === "string"
|
||||
@@ -454,6 +480,59 @@ function createHandle(state: InternalClientState): PaperclipHandle {
|
||||
async ensure(path, opts) {
|
||||
return this.create(path, opts);
|
||||
},
|
||||
|
||||
async update(path, opts) {
|
||||
const companyId = await resolveCompanyId();
|
||||
return requestJson<ChannelView>(
|
||||
`/api/companies/${encodeURIComponent(companyId)}/channels`,
|
||||
{
|
||||
method: "PATCH",
|
||||
body: JSON.stringify({
|
||||
...(opts ?? {}),
|
||||
channel: path,
|
||||
}),
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
members: {
|
||||
async list(channel) {
|
||||
const companyId = await resolveCompanyId();
|
||||
const res = await requestJson<{ items: ChannelMemberView[] }>(
|
||||
`/api/companies/${encodeURIComponent(companyId)}/channels/members?channel=${encodeURIComponent(channel)}`,
|
||||
{ method: "GET" },
|
||||
);
|
||||
return res.items;
|
||||
},
|
||||
|
||||
async add(channel, member) {
|
||||
const companyId = await resolveCompanyId();
|
||||
return requestJson<ChannelMemberView>(
|
||||
`/api/companies/${encodeURIComponent(companyId)}/channels/members`,
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
...member,
|
||||
channel,
|
||||
}),
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
async remove(channel, member) {
|
||||
const companyId = await resolveCompanyId();
|
||||
return requestJson<{ removed: boolean }>(
|
||||
`/api/companies/${encodeURIComponent(companyId)}/channels/members`,
|
||||
{
|
||||
method: "DELETE",
|
||||
body: JSON.stringify({
|
||||
...member,
|
||||
channel,
|
||||
}),
|
||||
},
|
||||
);
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
async post(channel, bodyOrOpts, maybeOpts) {
|
||||
@@ -718,11 +797,22 @@ function createHandle(state: InternalClientState): PaperclipHandle {
|
||||
? Math.max(0, parseDurationMs(opts.wait) / 1000)
|
||||
: undefined);
|
||||
|
||||
const statuses = [
|
||||
...(opts.statuses ?? []),
|
||||
...(opts.status
|
||||
? Array.isArray(opts.status)
|
||||
? opts.status
|
||||
: [opts.status]
|
||||
: []),
|
||||
];
|
||||
|
||||
const body: Record<string, unknown> = {
|
||||
...(isId ? { issueId: idOrReadyQuery } : { ready: opts.ready ?? true }),
|
||||
...(opts.channel ? { channel: opts.channel } : {}),
|
||||
...(opts.projectId ? { projectId: opts.projectId } : {}),
|
||||
...(labels.length > 0 ? { labels } : {}),
|
||||
...(statuses.length > 0 ? { statuses } : {}),
|
||||
...(opts.assignee ? { assignee: opts.assignee } : {}),
|
||||
...(leaseSec !== undefined ? { leaseSec } : {}),
|
||||
...(waitSec !== undefined ? { waitSec } : {}),
|
||||
...(opts.includeUntrusted !== undefined
|
||||
@@ -744,6 +834,80 @@ function createHandle(state: InternalClientState): PaperclipHandle {
|
||||
const claimView = (await res.json()) as TaskClaimView;
|
||||
return buildClaimedTask(claimView);
|
||||
},
|
||||
|
||||
async assign(id, assigneeOrOpts, maybeOpts) {
|
||||
const payload: TaskAssignInput =
|
||||
typeof assigneeOrOpts === "string" || assigneeOrOpts === null
|
||||
? { ...(maybeOpts ?? {}), assignee: assigneeOrOpts }
|
||||
: assigneeOrOpts;
|
||||
return requestJson<HeadlessIssueView>(
|
||||
`/api/issues/${encodeURIComponent(id)}/assign`,
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload),
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
async handoff(id, opts) {
|
||||
return requestJson<HeadlessIssueView>(
|
||||
`/api/issues/${encodeURIComponent(id)}/handoff`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: opts.claimToken
|
||||
? { "x-paperclip-claim-token": opts.claimToken }
|
||||
: undefined,
|
||||
body: JSON.stringify(opts),
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
async cancel(id, reasonOrOpts) {
|
||||
const payload: TaskCancelInput =
|
||||
typeof reasonOrOpts === "string"
|
||||
? { reason: reasonOrOpts }
|
||||
: { ...(reasonOrOpts ?? {}) };
|
||||
return requestJson<HeadlessIssueView>(
|
||||
`/api/issues/${encodeURIComponent(id)}/cancel`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: payload.claimToken
|
||||
? { "x-paperclip-claim-token": payload.claimToken }
|
||||
: undefined,
|
||||
body: JSON.stringify(payload),
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
async reopen(id, opts) {
|
||||
return requestJson<HeadlessIssueView>(
|
||||
`/api/issues/${encodeURIComponent(id)}/reopen`,
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify(opts ?? {}),
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
async dependencies(id) {
|
||||
return requestJson<TaskDependenciesView>(
|
||||
`/api/issues/${encodeURIComponent(id)}/dependencies`,
|
||||
{ method: "GET" },
|
||||
);
|
||||
},
|
||||
|
||||
async updateDependencies(id, mutation) {
|
||||
return requestJson<TaskDependenciesView>(
|
||||
`/api/issues/${encodeURIComponent(id)}/dependencies`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: mutation.claimToken
|
||||
? { "x-paperclip-claim-token": mutation.claimToken }
|
||||
: undefined,
|
||||
body: JSON.stringify(mutation),
|
||||
},
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
async ask(id, question, opts) {
|
||||
|
||||
@@ -18,6 +18,7 @@ export {
|
||||
export { parseSseEventStream } from "./sse.js";
|
||||
export {
|
||||
CHANNEL_PATH_REGEX,
|
||||
CLAIMABLE_TASK_STATUSES,
|
||||
formatEventCursor,
|
||||
normalizeChannelPath,
|
||||
parseDurationMs,
|
||||
@@ -26,8 +27,11 @@ export {
|
||||
SCHEMA_NAME_REGEX,
|
||||
SCHEMA_REF_REGEX,
|
||||
splitMessageIntoTitleAndDescription,
|
||||
TASK_CLAIM_ASSIGNEE_MODES,
|
||||
type ClaimableTaskStatus,
|
||||
type NormalizedChannelPath,
|
||||
type ParsedSchemaRef,
|
||||
type TaskClaimAssigneeMode,
|
||||
} from "../headless/pure.js";
|
||||
export type {
|
||||
AgentIdentityPolicy,
|
||||
@@ -36,6 +40,8 @@ export type {
|
||||
BoardEventActor,
|
||||
BoardEventType,
|
||||
BoardEventView,
|
||||
ChannelMemberInput,
|
||||
ChannelMemberView,
|
||||
ChannelOrdering,
|
||||
ChannelPage,
|
||||
ChannelPostInput,
|
||||
@@ -62,12 +68,20 @@ export type {
|
||||
SchemaBlock,
|
||||
SchedulePostInput,
|
||||
ScheduleView,
|
||||
TaskAssignInput,
|
||||
TaskCancelInput,
|
||||
TaskClaimRequest,
|
||||
TaskClaimView,
|
||||
TaskCompleteInput,
|
||||
TaskDependenciesMutationInput,
|
||||
TaskDependenciesView,
|
||||
TaskDependencyItemView,
|
||||
TaskFailInput,
|
||||
TaskHandoffInput,
|
||||
TaskReleaseInput,
|
||||
TaskRenewInput,
|
||||
TaskReopenInput,
|
||||
ThreadDetailView,
|
||||
UpdateChannelInput,
|
||||
WhoAmIView,
|
||||
} from "../headless/index.js";
|
||||
@@ -3,9 +3,12 @@ import type {
|
||||
BoardEventType,
|
||||
BoardEventView,
|
||||
BatchCreateIssuesResult,
|
||||
ChannelMemberInput,
|
||||
ChannelMemberView,
|
||||
ChannelPage,
|
||||
ChannelPostInput,
|
||||
ChannelView,
|
||||
ClaimableTaskStatus,
|
||||
ClientScopes,
|
||||
CommentView,
|
||||
CompanySchemaView,
|
||||
@@ -20,9 +23,18 @@ import type {
|
||||
SchemaBlock,
|
||||
SchedulePostInput,
|
||||
ScheduleView,
|
||||
TaskAssignInput,
|
||||
TaskCancelInput,
|
||||
TaskClaimAssigneeMode,
|
||||
TaskClaimView,
|
||||
TaskCompleteInput,
|
||||
TaskDependenciesMutationInput,
|
||||
TaskDependenciesView,
|
||||
TaskHandoffInput,
|
||||
TaskReleaseInput,
|
||||
TaskReopenInput,
|
||||
ThreadDetailView,
|
||||
UpdateChannelInput,
|
||||
WhoAmIView,
|
||||
} from "../headless/index.js";
|
||||
|
||||
@@ -120,6 +132,9 @@ export interface TaskClaimOptions {
|
||||
projectId?: string;
|
||||
label?: string | string[];
|
||||
labels?: string[];
|
||||
status?: ClaimableTaskStatus | ClaimableTaskStatus[];
|
||||
statuses?: ClaimableTaskStatus[];
|
||||
assignee?: TaskClaimAssigneeMode;
|
||||
lease?: string | number;
|
||||
leaseSec?: number;
|
||||
wait?: string | number;
|
||||
@@ -163,7 +178,12 @@ export interface ClaimedTask {
|
||||
leaseExpiresAt: string;
|
||||
cursor: string;
|
||||
renew(lease?: string | number): Promise<TaskClaimView>;
|
||||
release(comment?: string): Promise<{ released: boolean; cursor: string }>;
|
||||
release(
|
||||
commentOrOpts?: string | Omit<TaskReleaseInput, "claimToken" | "claimEpoch">,
|
||||
): Promise<{ released: boolean; cursor: string }>;
|
||||
handoff(
|
||||
opts: Omit<TaskHandoffInput, "claimToken" | "claimEpoch">,
|
||||
): Promise<HeadlessIssueView>;
|
||||
complete(
|
||||
opts?: string | Omit<TaskCompleteInput, "claimToken" | "claimEpoch">,
|
||||
): Promise<HeadlessIssueView>;
|
||||
@@ -194,6 +214,21 @@ export interface PaperclipHandle {
|
||||
path: string,
|
||||
opts?: Omit<CreateChannelInput, "path">,
|
||||
): Promise<ChannelView>;
|
||||
update(
|
||||
path: string,
|
||||
opts: Omit<UpdateChannelInput, "channel">,
|
||||
): Promise<ChannelView>;
|
||||
members: {
|
||||
list(channel: string): Promise<ChannelMemberView[]>;
|
||||
add(
|
||||
channel: string,
|
||||
member: Omit<ChannelMemberInput, "channel">,
|
||||
): Promise<ChannelMemberView>;
|
||||
remove(
|
||||
channel: string,
|
||||
member: Omit<ChannelMemberInput, "channel">,
|
||||
): Promise<{ removed: boolean }>;
|
||||
};
|
||||
};
|
||||
post(
|
||||
channel: string,
|
||||
@@ -235,6 +270,28 @@ export interface PaperclipHandle {
|
||||
idOrReadyQuery?: string | TaskClaimOptions,
|
||||
opts?: TaskClaimOptions,
|
||||
): Promise<ClaimedTask | null>;
|
||||
assign(
|
||||
id: string,
|
||||
assigneeOrOpts: string | null | TaskAssignInput,
|
||||
maybeOpts?: Omit<TaskAssignInput, "assignee">,
|
||||
): Promise<HeadlessIssueView>;
|
||||
handoff(
|
||||
id: string,
|
||||
opts: TaskHandoffInput,
|
||||
): Promise<HeadlessIssueView>;
|
||||
cancel(
|
||||
id: string,
|
||||
reasonOrOpts?: string | TaskCancelInput,
|
||||
): Promise<HeadlessIssueView>;
|
||||
reopen(
|
||||
id: string,
|
||||
opts?: TaskReopenInput,
|
||||
): Promise<HeadlessIssueView>;
|
||||
dependencies(id: string): Promise<TaskDependenciesView>;
|
||||
updateDependencies(
|
||||
id: string,
|
||||
mutation: TaskDependenciesMutationInput,
|
||||
): Promise<TaskDependenciesView>;
|
||||
};
|
||||
ask(
|
||||
id: string,
|
||||
|
||||
Reference in new issue
Block a user