/** * Typed REST client for the agent endpoints: the queue, claims, comments and * the status and handback writes. One method per existing server route; it * invents no endpoints and adds no fields. * * Two ways to authenticate, the same two the generated workflows use: * - `{ token }`: an agent-bound token (`astrid_mcp_…` or an agent consent * token), sent as `Authorization: Bearer`. Writes are signed as that agent * and the claim route can tell which agent is claiming. * - `{ clientId, clientSecret }`: client credentials, exchanged once at * `/api/v1/oauth/token` and sent as `X-OAuth-Token`. Such a token carries * no agent binding, so the generic claim route answers `forbidden`; use * `claimFixallTask` or an agent-bound token for claims. */ import type { AgentQueueQuery, AgentQueueResponse, AstridComment, AstridTask, ClaimRequest, ClaimResult, FixallClaimRequest, FixallClaimResult, SignedWrite } from './types.js'; export type AstridAuth = { token: string; } | { clientId: string; clientSecret: string; scope?: string; }; export interface AstridClientOptions { /** Origin, e.g. `https://www.astrid.cc`. Defaults to ASTRID_API_URL, then production. */ origin?: string; auth: AstridAuth; /** Injected for tests and non-global runtimes. */ fetch?: typeof fetch; } /** A response the server refused. `status` is the HTTP status; the message carries its reason. */ export declare class AstridApiError extends Error { readonly status: number; readonly body: unknown; constructor(status: number, message: string, body?: unknown); } export declare class AstridClient { readonly origin: string; private readonly auth; private readonly fetchImpl; private exchanged; constructor(options: AstridClientOptions); private authHeaders; /** One request; returns status and parsed body without judging either. */ private send; /** A request that must succeed. */ private request; /** `GET /api/v1/agent-queue`: Ready work plus unanswered comments and messages. */ getQueue(query: AgentQueueQuery): Promise; /** * `POST /api/v1/tasks/:id/claim`: atomic claim, resume or release. Every * documented outcome is returned, not thrown, so a caller can branch on a * conflict; only an undocumented answer throws. */ claimTask(taskId: string, request: ClaimRequest): Promise; /** * Renew this agent's claim lease. Send it every few minutes while working: * a claim with no heartbeat for its lease (15 minutes by default) returns to * Ready. `renewed` means keep going; anything else means the claim is gone. */ heartbeatTask(taskId: string, options?: { agentMailbox?: string; leaseSeconds?: number; }): Promise; /** Give a Doing claim back: the task returns to Ready and this agent is unassigned. */ releaseTask(taskId: string, agentMailbox?: string): Promise; /** * `POST /api/v1/tasks/:id/claim-fixall`: the claim Astrid's own scheduled * loops use. Allowlisted boards and harness mailboxes only; works with * client credentials. A 409 is returned as `claimed: false` with the * server's reason. */ claimFixallTask(taskId: string, request: FixallClaimRequest): Promise; getTask(taskId: string): Promise; getComments(taskId: string): Promise; addComment(taskId: string, content: string, options?: SignedWrite): Promise; /** Move the task's board column (`ready`, `doing`, `waiting`, or null for the Inbox). */ setStatus(taskId: string, statusRole: string | null, options?: SignedWrite): Promise; /** * Hand the task back to a person: the Inbox, assigned to them, in one write * (astrid-core's `handBack`). Never Waiting, which holds only tasks waiting * on a date or another task. `completed` is left out so a task someone * finished meanwhile is not reopened. */ handBack(taskId: string, personId: string, options?: SignedWrite): Promise; private updateTask; } //# sourceMappingURL=client.d.ts.map