@gracefultools/astrid-sdk 0.8.1 → 1.0.0

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.
Files changed (88) hide show
  1. package/README.md +173 -127
  2. package/dist/bin.d.ts +3 -0
  3. package/dist/bin.d.ts.map +1 -0
  4. package/dist/bin.js +13 -0
  5. package/dist/bin.js.map +1 -0
  6. package/dist/cli.d.ts +41 -0
  7. package/dist/cli.d.ts.map +1 -0
  8. package/dist/cli.js +326 -0
  9. package/dist/cli.js.map +1 -0
  10. package/dist/client.d.ts +87 -0
  11. package/dist/client.d.ts.map +1 -0
  12. package/dist/client.js +212 -0
  13. package/dist/client.js.map +1 -0
  14. package/dist/config/api-base.d.ts +21 -0
  15. package/dist/config/api-base.d.ts.map +1 -0
  16. package/dist/config/api-base.js +41 -0
  17. package/dist/config/api-base.js.map +1 -0
  18. package/dist/index.d.ts +13 -9
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +22 -57
  21. package/dist/index.js.map +1 -1
  22. package/dist/types.d.ts +103 -0
  23. package/dist/types.d.ts.map +1 -0
  24. package/dist/types.js +7 -0
  25. package/dist/types.js.map +1 -0
  26. package/dist/verdict.d.ts +88 -0
  27. package/dist/verdict.d.ts.map +1 -0
  28. package/dist/verdict.js +90 -0
  29. package/dist/verdict.js.map +1 -0
  30. package/package.json +56 -65
  31. package/dist/adapters/astrid-oauth.d.ts +0 -114
  32. package/dist/adapters/astrid-oauth.d.ts.map +0 -1
  33. package/dist/adapters/astrid-oauth.js +0 -287
  34. package/dist/adapters/astrid-oauth.js.map +0 -1
  35. package/dist/channel/channel.d.ts +0 -33
  36. package/dist/channel/channel.d.ts.map +0 -1
  37. package/dist/channel/channel.js +0 -90
  38. package/dist/channel/channel.js.map +0 -1
  39. package/dist/channel/index.d.ts +0 -13
  40. package/dist/channel/index.d.ts.map +0 -1
  41. package/dist/channel/index.js +0 -23
  42. package/dist/channel/index.js.map +0 -1
  43. package/dist/channel/message-formatter.d.ts +0 -14
  44. package/dist/channel/message-formatter.d.ts.map +0 -1
  45. package/dist/channel/message-formatter.js +0 -71
  46. package/dist/channel/message-formatter.js.map +0 -1
  47. package/dist/channel/oauth-client.d.ts +0 -15
  48. package/dist/channel/oauth-client.d.ts.map +0 -1
  49. package/dist/channel/oauth-client.js +0 -45
  50. package/dist/channel/oauth-client.js.map +0 -1
  51. package/dist/channel/rest-client.d.ts +0 -16
  52. package/dist/channel/rest-client.d.ts.map +0 -1
  53. package/dist/channel/rest-client.js +0 -66
  54. package/dist/channel/rest-client.js.map +0 -1
  55. package/dist/channel/session-mapper.d.ts +0 -14
  56. package/dist/channel/session-mapper.d.ts.map +0 -1
  57. package/dist/channel/session-mapper.js +0 -37
  58. package/dist/channel/session-mapper.js.map +0 -1
  59. package/dist/channel/sse-client.d.ts +0 -31
  60. package/dist/channel/sse-client.d.ts.map +0 -1
  61. package/dist/channel/sse-client.js +0 -171
  62. package/dist/channel/sse-client.js.map +0 -1
  63. package/dist/channel/types.d.ts +0 -65
  64. package/dist/channel/types.d.ts.map +0 -1
  65. package/dist/channel/types.js +0 -3
  66. package/dist/channel/types.js.map +0 -1
  67. package/dist/config/agent-workflow.d.ts +0 -78
  68. package/dist/config/agent-workflow.d.ts.map +0 -1
  69. package/dist/config/agent-workflow.js +0 -217
  70. package/dist/config/agent-workflow.js.map +0 -1
  71. package/dist/config/index.d.ts +0 -194
  72. package/dist/config/index.d.ts.map +0 -1
  73. package/dist/config/index.js +0 -284
  74. package/dist/config/index.js.map +0 -1
  75. package/dist/deploy/vercel.d.ts +0 -27
  76. package/dist/deploy/vercel.d.ts.map +0 -1
  77. package/dist/deploy/vercel.js +0 -268
  78. package/dist/deploy/vercel.js.map +0 -1
  79. package/dist/types/index.d.ts +0 -157
  80. package/dist/types/index.d.ts.map +0 -1
  81. package/dist/types/index.js +0 -6
  82. package/dist/types/index.js.map +0 -1
  83. package/dist/utils/agent-config.d.ts +0 -56
  84. package/dist/utils/agent-config.d.ts.map +0 -1
  85. package/dist/utils/agent-config.js +0 -138
  86. package/dist/utils/agent-config.js.map +0 -1
  87. package/templates/.astrid.config.json +0 -60
  88. package/templates/ASTRID.template.md +0 -74
package/dist/cli.js ADDED
@@ -0,0 +1,326 @@
1
+ "use strict";
2
+ /**
3
+ * `astrid-agent`: the runner command a scheduler or a GitHub Actions job calls.
4
+ * Its exit codes are the interface:
5
+ *
6
+ * queue 0 there is work, start a run
7
+ * 3 nothing to do, skip this tick
8
+ * 1 could not tell (network, auth); never treat this as idle
9
+ * claim 0 claimed, start the task
10
+ * heartbeat 0 lease renewed, keep working
11
+ * release 0 released
12
+ * 2 someone else has it, or it is no longer eligible; move on
13
+ * 1 error
14
+ *
15
+ * These match astrid-web's scripts/agent-queue-status.ts and
16
+ * scripts/claim-fixall-task.ts, which this command is meant to replace.
17
+ *
18
+ * Credentials come from the environment and are never printed:
19
+ * ASTRID_TOKEN an agent-bound token (preferred)
20
+ * ASTRID_CLIENT_ID + ASTRID_CLIENT_SECRET client credentials
21
+ * (ASTRID_OAUTH_CLIENT_ID / ASTRID_OAUTH_CLIENT_SECRET are accepted too)
22
+ * ASTRID_API_URL the server origin
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.USAGE = exports.EXIT = void 0;
26
+ exports.runCli = runCli;
27
+ const node_fs_1 = require("node:fs");
28
+ const node_path_1 = require("node:path");
29
+ const client_js_1 = require("./client.js");
30
+ const verdict_js_1 = require("./verdict.js");
31
+ exports.EXIT = {
32
+ /** Work to do / the write succeeded. */
33
+ WORK: 0,
34
+ ERROR: 1,
35
+ /** Claim or release refused: another worker has it, or it is not eligible. */
36
+ CONFLICT: 2,
37
+ /** The queue is idle. */
38
+ IDLE: 3,
39
+ };
40
+ exports.USAGE = `Usage: astrid-agent <command> [options]
41
+
42
+ Commands:
43
+ queue --agent <mailbox> [--list <listId>] [--include-unassigned]
44
+ [--seen <file> [--write-seen]]
45
+ Print the queue verdict as JSON. Exit 0 work, 3 idle, 1 could not tell.
46
+ claim <taskId> [--agent <mailbox>] [--resume] [--lease-seconds <n>]
47
+ Atomic claim (POST /api/v1/tasks/:id/claim). Exit 0 claimed, 2 taken, 1 error.
48
+ The claim holds a lease (15 min by default): heartbeat while you work.
49
+ heartbeat <taskId> [--agent <mailbox>] [--lease-seconds <n>]
50
+ Renew the claim lease. Exit 0 renewed, 2 the claim is gone (stop), 1 error.
51
+ claim <taskId> --fixall [--agent <mailbox>] [--list <listId>]
52
+ Claim through /claim-fixall (Astrid's allowlisted boards).
53
+ release <taskId> [--agent <mailbox>] [--comment <text>]
54
+ Give a Doing claim back to Ready. Exit 0 released, 2 not yours, 1 error.
55
+
56
+ Options:
57
+ --origin <url> Server origin (default: ASTRID_API_URL, then production)
58
+ -h, --help Show this help
59
+ -v, --version Show the version
60
+
61
+ Environment:
62
+ ASTRID_TOKEN, or ASTRID_CLIENT_ID and ASTRID_CLIENT_SECRET`;
63
+ const VALUED = new Set(['--agent', '--list', '--seen', '--origin', '--comment', '--lease-seconds']);
64
+ const BOOLEAN = new Set(['--include-unassigned', '--write-seen', '--resume', '--fixall', '--help', '-h', '--version', '-v']);
65
+ /** One left-to-right pass, so a flag's value is never read as a positional (AWTD-922). */
66
+ function parse(argv) {
67
+ const positional = [];
68
+ const flags = new Map();
69
+ const switches = new Set();
70
+ for (let i = 0; i < argv.length; i++) {
71
+ const arg = argv[i];
72
+ if (VALUED.has(arg)) {
73
+ const value = argv[i + 1];
74
+ if (value === undefined || value.startsWith('--'))
75
+ throw new UsageError(`${arg} requires a value`);
76
+ flags.set(arg, value);
77
+ i++;
78
+ }
79
+ else if (BOOLEAN.has(arg)) {
80
+ switches.add(arg);
81
+ }
82
+ else if (arg.startsWith('-')) {
83
+ throw new UsageError(`Unknown option ${arg}`);
84
+ }
85
+ else {
86
+ positional.push(arg);
87
+ }
88
+ }
89
+ return { positional, flags, switches };
90
+ }
91
+ class UsageError extends Error {
92
+ }
93
+ function authFrom(env) {
94
+ const token = env.ASTRID_TOKEN?.trim();
95
+ if (token)
96
+ return { token };
97
+ const clientId = (env.ASTRID_CLIENT_ID || env.ASTRID_OAUTH_CLIENT_ID)?.trim();
98
+ const clientSecret = (env.ASTRID_CLIENT_SECRET || env.ASTRID_OAUTH_CLIENT_SECRET)?.trim();
99
+ if (clientId && clientSecret)
100
+ return { clientId, clientSecret };
101
+ throw new UsageError('Set ASTRID_TOKEN, or ASTRID_CLIENT_ID and ASTRID_CLIENT_SECRET');
102
+ }
103
+ function readSeen(file) {
104
+ if (!(0, node_fs_1.existsSync)(file))
105
+ return new Set();
106
+ try {
107
+ const parsed = JSON.parse((0, node_fs_1.readFileSync)(file, 'utf8'));
108
+ // An unreadable file is an empty memory: the worst case is one extra run.
109
+ return new Set(Array.isArray(parsed) ? parsed.filter((key) => typeof key === 'string') : []);
110
+ }
111
+ catch {
112
+ return new Set();
113
+ }
114
+ }
115
+ function message(error) {
116
+ return error instanceof Error ? error.message : String(error);
117
+ }
118
+ function packageVersion() {
119
+ try {
120
+ // Built as CommonJS: dist/cli.js sits one level under package.json.
121
+ const pkg = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, '..', 'package.json'), 'utf8'));
122
+ return pkg.version ?? 'unknown';
123
+ }
124
+ catch {
125
+ return 'unknown';
126
+ }
127
+ }
128
+ async function queue(client, args, io) {
129
+ const agent = args.flags.get('--agent');
130
+ if (!agent)
131
+ throw new UsageError('queue needs --agent <mailbox>');
132
+ const seenFile = args.flags.get('--seen');
133
+ if (args.switches.has('--write-seen') && !seenFile)
134
+ throw new UsageError('--write-seen needs --seen <file>');
135
+ let snapshot;
136
+ try {
137
+ snapshot = await client.getQueue({
138
+ agent,
139
+ listId: args.flags.get('--list'),
140
+ includeUnassigned: args.switches.has('--include-unassigned'),
141
+ });
142
+ }
143
+ catch (error) {
144
+ io.stderr(`QUEUE: unknown — ${message(error)}`);
145
+ return exports.EXIT.ERROR;
146
+ }
147
+ for (const skipped of snapshot.attention?.skipped ?? [])
148
+ io.stderr(`ATTENTION: ${skipped}`);
149
+ const verdict = (0, verdict_js_1.decideQueueVerdict)({ snapshot, seen: seenFile ? readSeen(seenFile) : new Set() });
150
+ // stdout is one JSON document a caller can pipe to jq; the log line goes to stderr.
151
+ io.stdout(JSON.stringify({
152
+ version: 1,
153
+ work: verdict.work,
154
+ reason: verdict.reason,
155
+ summary: verdict.line,
156
+ wakeKeys: verdict.keys,
157
+ snapshot,
158
+ }, null, 2));
159
+ io.stderr(verdict.line);
160
+ if (seenFile && args.switches.has('--write-seen')) {
161
+ // The CURRENT set, not an accumulation: an answered reply drops out.
162
+ try {
163
+ (0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(seenFile), { recursive: true });
164
+ (0, node_fs_1.writeFileSync)(seenFile, `${JSON.stringify(verdict.keys, null, 2)}\n`);
165
+ }
166
+ catch (error) {
167
+ io.stderr(`SEEN: could not write ${seenFile} — ${message(error)}`);
168
+ }
169
+ }
170
+ return verdict.work ? exports.EXIT.WORK : exports.EXIT.IDLE;
171
+ }
172
+ async function claim(client, args, io) {
173
+ const taskId = args.positional[1];
174
+ if (!taskId)
175
+ throw new UsageError('claim needs a task id');
176
+ const agent = args.flags.get('--agent');
177
+ const resume = args.switches.has('--resume');
178
+ if (args.switches.has('--fixall')) {
179
+ if (resume)
180
+ throw new UsageError('--fixall --resume needs a watermark and resume context; use scripts/claim-fixall-task.ts');
181
+ const result = await client.claimFixallTask(taskId, {
182
+ action: 'ready',
183
+ ...(agent ? { agent } : {}),
184
+ ...(args.flags.get('--list') ? { listId: args.flags.get('--list') } : {}),
185
+ });
186
+ if (!result.claimed) {
187
+ // A lost race and "no active agent account" are both 409; print the
188
+ // server's reason so a caller does not chase a peer that is not there.
189
+ io.stderr(`CLAIM_CONFLICT ${taskId}: claimed by someone else, or no longer eligible${result.error ? ` — server said: ${result.error}` : ''}`);
190
+ return exports.EXIT.CONFLICT;
191
+ }
192
+ io.stdout(`CLAIMED ${taskId}`);
193
+ // A scheduled runner collects its claims and releases any left in Doing after the run.
194
+ const claimsFile = io.env.ASTRID_FIXALL_CLAIMS_FILE;
195
+ if (claimsFile)
196
+ (0, node_fs_1.appendFileSync)(claimsFile, `${taskId}\n`);
197
+ return exports.EXIT.WORK;
198
+ }
199
+ const leaseSeconds = resume ? undefined : leaseSecondsOf(args);
200
+ const result = await client.claimTask(taskId, {
201
+ action: resume ? 'resume' : 'claim',
202
+ ...(agent ? { agentMailbox: agent } : {}),
203
+ ...(leaseSeconds !== undefined ? { leaseSeconds } : {}),
204
+ });
205
+ if (result.outcome === 'claimed' || (resume && result.outcome === 'already_yours')) {
206
+ io.stdout(`${resume ? 'RESUMED' : 'CLAIMED'} ${taskId}`);
207
+ return exports.EXIT.WORK;
208
+ }
209
+ if (result.outcome === 'unavailable') {
210
+ io.stderr(`CLAIM ${taskId}: the claim API is unavailable on this server (HTTP ${result.status})`);
211
+ return exports.EXIT.ERROR;
212
+ }
213
+ // already_yours on a fresh claim means another worker on this mailbox holds it.
214
+ // A 409 is a lost race, a task no longer Ready, or a bound board at capacity.
215
+ if (result.outcome === 'already_yours' || result.status === 409) {
216
+ io.stderr(`CLAIM_CONFLICT ${taskId}: ${result.outcome}`);
217
+ return exports.EXIT.CONFLICT;
218
+ }
219
+ io.stderr(`CLAIM ${taskId}: ${result.outcome} (HTTP ${result.status})`);
220
+ return exports.EXIT.ERROR;
221
+ }
222
+ function leaseSecondsOf(args) {
223
+ const raw = args.flags.get('--lease-seconds');
224
+ if (raw === undefined)
225
+ return undefined;
226
+ const seconds = Number(raw);
227
+ if (!Number.isInteger(seconds) || seconds < 60 || seconds > 3600) {
228
+ throw new UsageError('--lease-seconds must be a whole number from 60 to 3600');
229
+ }
230
+ return seconds;
231
+ }
232
+ async function heartbeat(client, args, io) {
233
+ const taskId = args.positional[1];
234
+ if (!taskId)
235
+ throw new UsageError('heartbeat needs a task id');
236
+ const agent = args.flags.get('--agent');
237
+ const leaseSeconds = leaseSecondsOf(args);
238
+ const result = await client.heartbeatTask(taskId, {
239
+ ...(agent ? { agentMailbox: agent } : {}),
240
+ ...(leaseSeconds !== undefined ? { leaseSeconds } : {}),
241
+ });
242
+ if (result.outcome === 'renewed') {
243
+ io.stdout(`RENEWED ${taskId}${result.task?.claimLeaseExpiresAt ? ` until ${result.task.claimLeaseExpiresAt}` : ''}`);
244
+ return exports.EXIT.WORK;
245
+ }
246
+ if (result.outcome === 'unavailable') {
247
+ io.stderr(`HEARTBEAT ${taskId}: the claim API is unavailable on this server (HTTP ${result.status})`);
248
+ return exports.EXIT.ERROR;
249
+ }
250
+ // The task left Doing, or someone else holds it: the claim is gone, stop work.
251
+ if (result.status === 409) {
252
+ io.stderr(`HEARTBEAT_LOST ${taskId}: ${result.outcome}`);
253
+ return exports.EXIT.CONFLICT;
254
+ }
255
+ io.stderr(`HEARTBEAT ${taskId}: ${result.outcome} (HTTP ${result.status})`);
256
+ return exports.EXIT.ERROR;
257
+ }
258
+ async function release(client, args, io) {
259
+ const taskId = args.positional[1];
260
+ if (!taskId)
261
+ throw new UsageError('release needs a task id');
262
+ const comment = args.flags.get('--comment');
263
+ // Say why before the claim goes: after release the task may leave this agent's view.
264
+ if (comment)
265
+ await client.addComment(taskId, comment);
266
+ const result = await client.releaseTask(taskId, args.flags.get('--agent'));
267
+ if (result.outcome === 'released') {
268
+ io.stdout(`RELEASED ${taskId}`);
269
+ return exports.EXIT.WORK;
270
+ }
271
+ if (result.outcome === 'unavailable') {
272
+ io.stderr(`RELEASE ${taskId}: the claim API is unavailable on this server (HTTP ${result.status})`);
273
+ return exports.EXIT.ERROR;
274
+ }
275
+ if (result.status === 409) {
276
+ io.stderr(`RELEASE_CONFLICT ${taskId}: ${result.outcome}`);
277
+ return exports.EXIT.CONFLICT;
278
+ }
279
+ io.stderr(`RELEASE ${taskId}: ${result.outcome} (HTTP ${result.status})`);
280
+ return exports.EXIT.ERROR;
281
+ }
282
+ /** Runs one command and resolves to its exit code. Never calls process.exit. */
283
+ async function runCli(argv, io) {
284
+ let args;
285
+ try {
286
+ args = parse(argv);
287
+ }
288
+ catch (error) {
289
+ io.stderr(`${message(error)}\n\n${exports.USAGE}`);
290
+ return exports.EXIT.ERROR;
291
+ }
292
+ if (args.switches.has('--help') || args.switches.has('-h')) {
293
+ io.stdout(exports.USAGE);
294
+ return 0;
295
+ }
296
+ if (args.switches.has('--version') || args.switches.has('-v')) {
297
+ io.stdout(packageVersion());
298
+ return 0;
299
+ }
300
+ const command = args.positional[0];
301
+ const handlers = { queue, claim, heartbeat, release };
302
+ const handler = command ? handlers[command] : undefined;
303
+ if (!handler) {
304
+ io.stderr(`${command ? `Unknown command "${command}"` : 'No command given'}\n\n${exports.USAGE}`);
305
+ return exports.EXIT.ERROR;
306
+ }
307
+ try {
308
+ const client = new client_js_1.AstridClient({
309
+ origin: args.flags.get('--origin') || io.env.ASTRID_API_URL || io.env.ASTRID_API_BASE_URL,
310
+ auth: authFrom(io.env),
311
+ ...(io.fetch ? { fetch: io.fetch } : {}),
312
+ });
313
+ return await handler(client, args, io);
314
+ }
315
+ catch (error) {
316
+ if (error instanceof UsageError) {
317
+ io.stderr(`${error.message}\n\n${exports.USAGE}`);
318
+ }
319
+ else {
320
+ const status = error instanceof client_js_1.AstridApiError ? ` (HTTP ${error.status})` : '';
321
+ io.stderr(`${command}: failed${status} — ${message(error)}`);
322
+ }
323
+ return exports.EXIT.ERROR;
324
+ }
325
+ }
326
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;AA8QH,wBAyCC;AArTD,qCAA4F;AAC5F,yCAAyC;AAEzC,2CAA2E;AAC3E,6CAAiD;AAEpC,QAAA,IAAI,GAAG;IAClB,wCAAwC;IACxC,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;IACR,8EAA8E;IAC9E,QAAQ,EAAE,CAAC;IACX,yBAAy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AkB,OAAO,aAAK,EAAE,CAAC,CAAA;QACzF,OAAO,YAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,wBAAY,CAAC;YAC9B,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,cAAc,IAAI,EAAE,CAAC,GAAG,CAAC,mBAAmB;YACzF,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC;YACtB,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACzC,CAAC,CAAA;QACF,OAAO,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;IACxC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;YAChC,EAAE,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,OAAO,aAAK,EAAE,CAAC,CAAA;QAC3C,CAAC;aAAM,CAAC;YACN,MAAM,MAAM,GAAG,KAAK,YAAY,0BAAc,CAAC,CAAC,CAAC,UAAU,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;YAC/E,EAAE,CAAC,MAAM,CAAC,GAAG,OAAO,WAAW,MAAM,MAAM,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAC9D,CAAC;QACD,OAAO,YAAI,CAAC,KAAK,CAAA;IACnB,CAAC;AACH,CAAC"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Typed REST client for the agent endpoints: the queue, claims, comments and
3
+ * the status and handback writes. One method per existing server route; it
4
+ * invents no endpoints and adds no fields.
5
+ *
6
+ * Two ways to authenticate, the same two the generated workflows use:
7
+ * - `{ token }`: an agent-bound token (`astrid_mcp_…` or an agent consent
8
+ * token), sent as `Authorization: Bearer`. Writes are signed as that agent
9
+ * and the claim route can tell which agent is claiming.
10
+ * - `{ clientId, clientSecret }`: client credentials, exchanged once at
11
+ * `/api/v1/oauth/token` and sent as `X-OAuth-Token`. Such a token carries
12
+ * no agent binding, so the generic claim route answers `forbidden`; use
13
+ * `claimFixallTask` or an agent-bound token for claims.
14
+ */
15
+ import type { AgentQueueQuery, AgentQueueResponse, AstridComment, AstridTask, ClaimRequest, ClaimResult, FixallClaimRequest, FixallClaimResult, SignedWrite } from './types.js';
16
+ export type AstridAuth = {
17
+ token: string;
18
+ } | {
19
+ clientId: string;
20
+ clientSecret: string;
21
+ scope?: string;
22
+ };
23
+ export interface AstridClientOptions {
24
+ /** Origin, e.g. `https://www.astrid.cc`. Defaults to ASTRID_API_URL, then production. */
25
+ origin?: string;
26
+ auth: AstridAuth;
27
+ /** Injected for tests and non-global runtimes. */
28
+ fetch?: typeof fetch;
29
+ }
30
+ /** A response the server refused. `status` is the HTTP status; the message carries its reason. */
31
+ export declare class AstridApiError extends Error {
32
+ readonly status: number;
33
+ readonly body: unknown;
34
+ constructor(status: number, message: string, body?: unknown);
35
+ }
36
+ export declare class AstridClient {
37
+ readonly origin: string;
38
+ private readonly auth;
39
+ private readonly fetchImpl;
40
+ private exchanged;
41
+ constructor(options: AstridClientOptions);
42
+ private authHeaders;
43
+ /** One request; returns status and parsed body without judging either. */
44
+ private send;
45
+ /** A request that must succeed. */
46
+ private request;
47
+ /** `GET /api/v1/agent-queue`: Ready work plus unanswered comments and messages. */
48
+ getQueue(query: AgentQueueQuery): Promise<AgentQueueResponse>;
49
+ /**
50
+ * `POST /api/v1/tasks/:id/claim`: atomic claim, resume or release. Every
51
+ * documented outcome is returned, not thrown, so a caller can branch on a
52
+ * conflict; only an undocumented answer throws.
53
+ */
54
+ claimTask(taskId: string, request: ClaimRequest): Promise<ClaimResult>;
55
+ /**
56
+ * Renew this agent's claim lease. Send it every few minutes while working:
57
+ * a claim with no heartbeat for its lease (15 minutes by default) returns to
58
+ * Ready. `renewed` means keep going; anything else means the claim is gone.
59
+ */
60
+ heartbeatTask(taskId: string, options?: {
61
+ agentMailbox?: string;
62
+ leaseSeconds?: number;
63
+ }): Promise<ClaimResult>;
64
+ /** Give a Doing claim back: the task returns to Ready and this agent is unassigned. */
65
+ releaseTask(taskId: string, agentMailbox?: string): Promise<ClaimResult>;
66
+ /**
67
+ * `POST /api/v1/tasks/:id/claim-fixall`: the claim Astrid's own scheduled
68
+ * loops use. Allowlisted boards and harness mailboxes only; works with
69
+ * client credentials. A 409 is returned as `claimed: false` with the
70
+ * server's reason.
71
+ */
72
+ claimFixallTask(taskId: string, request: FixallClaimRequest): Promise<FixallClaimResult>;
73
+ getTask(taskId: string): Promise<AstridTask>;
74
+ getComments(taskId: string): Promise<AstridComment[]>;
75
+ addComment(taskId: string, content: string, options?: SignedWrite): Promise<AstridComment>;
76
+ /** Move the task's board column (`ready`, `doing`, `waiting`, or null for the Inbox). */
77
+ setStatus(taskId: string, statusRole: string | null, options?: SignedWrite): Promise<AstridTask>;
78
+ /**
79
+ * Hand the task back to a person: the Inbox, assigned to them, in one write
80
+ * (astrid-core's `handBack`). Never Waiting, which holds only tasks waiting
81
+ * on a date or another task. `completed` is left out so a task someone
82
+ * finished meanwhile is not reopened.
83
+ */
84
+ handBack(taskId: string, personId: string, options?: SignedWrite): Promise<AstridTask>;
85
+ private updateTask;
86
+ }
87
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,UAAU,EAEV,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACZ,MAAM,YAAY,CAAA;AAEnB,MAAM,MAAM,UAAU,GAClB;IAAE,KAAK,EA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EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAI9E;;;;;OAKG;IACG,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAqBxF,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAK5C,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAKrD,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;IAQpG,yFAAyF;IACnF,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;IAI1G;;;;;OAKG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;YAKlF,UAAU;CAOzB"}
package/dist/client.js ADDED
@@ -0,0 +1,212 @@
1
+ "use strict";
2
+ /**
3
+ * Typed REST client for the agent endpoints: the queue, claims, comments and
4
+ * the status and handback writes. One method per existing server route; it
5
+ * invents no endpoints and adds no fields.
6
+ *
7
+ * Two ways to authenticate, the same two the generated workflows use:
8
+ * - `{ token }`: an agent-bound token (`astrid_mcp_…` or an agent consent
9
+ * token), sent as `Authorization: Bearer`. Writes are signed as that agent
10
+ * and the claim route can tell which agent is claiming.
11
+ * - `{ clientId, clientSecret }`: client credentials, exchanged once at
12
+ * `/api/v1/oauth/token` and sent as `X-OAuth-Token`. Such a token carries
13
+ * no agent binding, so the generic claim route answers `forbidden`; use
14
+ * `claimFixallTask` or an agent-bound token for claims.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.AstridClient = exports.AstridApiError = void 0;
18
+ const api_base_js_1 = require("./config/api-base.js");
19
+ /** A response the server refused. `status` is the HTTP status; the message carries its reason. */
20
+ class AstridApiError extends Error {
21
+ status;
22
+ body;
23
+ constructor(status, message, body = null) {
24
+ super(message);
25
+ this.status = status;
26
+ this.body = body;
27
+ this.name = 'AstridApiError';
28
+ }
29
+ }
30
+ exports.AstridApiError = AstridApiError;
31
+ const CLAIM_OUTCOMES = new Set([
32
+ 'claimed', 'already_yours', 'released', 'renewed', 'conflict', 'not_ready', 'not_found', 'forbidden', 'binding_denied',
33
+ ]);
34
+ function reasonOf(body) {
35
+ if (body && typeof body === 'object' && 'error' in body && typeof body.error === 'string')
36
+ return body.error;
37
+ return undefined;
38
+ }
39
+ async function readJson(response) {
40
+ return response.json().catch(() => null);
41
+ }
42
+ class AstridClient {
43
+ origin;
44
+ auth;
45
+ fetchImpl;
46
+ exchanged = null;
47
+ constructor(options) {
48
+ this.origin = (0, api_base_js_1.resolveOrigin)(options.origin);
49
+ this.auth = options.auth;
50
+ this.fetchImpl = options.fetch ?? globalThis.fetch;
51
+ }
52
+ async authHeaders() {
53
+ if ('token' in this.auth)
54
+ return { Authorization: `Bearer ${this.auth.token}` };
55
+ if (!this.exchanged || Date.now() >= this.exchanged.expiresAt) {
56
+ const response = await this.fetchImpl(`${this.origin}/api/v1/oauth/token`, {
57
+ method: 'POST',
58
+ headers: { 'Content-Type': 'application/json' },
59
+ body: JSON.stringify({
60
+ grant_type: 'client_credentials',
61
+ client_id: this.auth.clientId,
62
+ client_secret: this.auth.clientSecret,
63
+ ...(this.auth.scope ? { scope: this.auth.scope } : {}),
64
+ }),
65
+ });
66
+ const body = await readJson(response);
67
+ if (!response.ok) {
68
+ throw new AstridApiError(response.status, `OAuth token request failed: HTTP ${response.status}`, body);
69
+ }
70
+ const { access_token: token, expires_in: expiresIn } = (body ?? {});
71
+ if (!token)
72
+ throw new AstridApiError(response.status, 'OAuth token response had no access_token', null);
73
+ // Refresh five minutes early, as the old clients did.
74
+ this.exchanged = { token, expiresAt: Date.now() + Math.max(0, (expiresIn ?? 3600) - 300) * 1000 };
75
+ }
76
+ return { 'X-OAuth-Token': this.exchanged.token };
77
+ }
78
+ /** One request; returns status and parsed body without judging either. */
79
+ async send(path, init = {}) {
80
+ const headers = { ...(await this.authHeaders()) };
81
+ if (init.body !== undefined)
82
+ headers['Content-Type'] = 'application/json';
83
+ const response = await this.fetchImpl(`${this.origin}${path}`, {
84
+ method: init.method ?? 'GET',
85
+ headers,
86
+ ...(init.body !== undefined ? { body: JSON.stringify(init.body) } : {}),
87
+ });
88
+ return { status: response.status, ok: response.ok, body: await readJson(response) };
89
+ }
90
+ /** A request that must succeed. */
91
+ async request(path, init = {}) {
92
+ const { status, ok, body } = await this.send(path, init);
93
+ if (!ok) {
94
+ const reason = reasonOf(body);
95
+ throw new AstridApiError(status, `HTTP ${status} from ${path.split('?')[0]}${reason ? `: ${reason}` : ''}`, body);
96
+ }
97
+ return body;
98
+ }
99
+ /** `GET /api/v1/agent-queue`: Ready work plus unanswered comments and messages. */
100
+ async getQueue(query) {
101
+ const params = new URLSearchParams({ agent: query.agent });
102
+ if (query.listId)
103
+ params.set('listId', query.listId);
104
+ if (query.includeUnassigned)
105
+ params.set('includeUnassigned', 'true');
106
+ return this.request(`/api/v1/agent-queue?${params}`);
107
+ }
108
+ /**
109
+ * `POST /api/v1/tasks/:id/claim`: atomic claim, resume or release. Every
110
+ * documented outcome is returned, not thrown, so a caller can branch on a
111
+ * conflict; only an undocumented answer throws.
112
+ */
113
+ async claimTask(taskId, request) {
114
+ const { status, body } = await this.send(`/api/v1/tasks/${encodeURIComponent(taskId)}/claim`, {
115
+ method: 'POST',
116
+ body: {
117
+ action: request.action,
118
+ // The route compares the mailbox with the token identity's local part,
119
+ // so a Custom Agent address is sent without its domain.
120
+ ...(request.agentMailbox ? { agentMailbox: request.agentMailbox.split('@')[0] } : {}),
121
+ ...(request.leaseSeconds !== undefined ? { leaseSeconds: request.leaseSeconds } : {}),
122
+ },
123
+ });
124
+ if (body && typeof body === 'object' && 'outcome' in body && typeof body.outcome === 'string' && CLAIM_OUTCOMES.has(body.outcome)) {
125
+ const task = 'task' in body ? body.task : null;
126
+ return { status, outcome: body.outcome, task: task ?? null };
127
+ }
128
+ // The route is absent on this server (or an older one still gates it).
129
+ if ([404, 405, 501].includes(status))
130
+ return { status, outcome: 'unavailable', task: null };
131
+ const reason = reasonOf(body);
132
+ throw new AstridApiError(status, `HTTP ${status} from claim${reason ? `: ${reason}` : ''}`, body);
133
+ }
134
+ /**
135
+ * Renew this agent's claim lease. Send it every few minutes while working:
136
+ * a claim with no heartbeat for its lease (15 minutes by default) returns to
137
+ * Ready. `renewed` means keep going; anything else means the claim is gone.
138
+ */
139
+ async heartbeatTask(taskId, options = {}) {
140
+ return this.claimTask(taskId, { action: 'heartbeat', ...options });
141
+ }
142
+ /** Give a Doing claim back: the task returns to Ready and this agent is unassigned. */
143
+ async releaseTask(taskId, agentMailbox) {
144
+ return this.claimTask(taskId, { action: 'release', ...(agentMailbox ? { agentMailbox } : {}) });
145
+ }
146
+ /**
147
+ * `POST /api/v1/tasks/:id/claim-fixall`: the claim Astrid's own scheduled
148
+ * loops use. Allowlisted boards and harness mailboxes only; works with
149
+ * client credentials. A 409 is returned as `claimed: false` with the
150
+ * server's reason.
151
+ */
152
+ async claimFixallTask(taskId, request) {
153
+ const { status, ok, body } = await this.send(`/api/v1/tasks/${encodeURIComponent(taskId)}/claim-fixall`, {
154
+ method: 'POST',
155
+ body: {
156
+ action: request.action,
157
+ commentWatermark: request.commentWatermark ?? null,
158
+ ...(request.agent ? { agent: request.agent } : {}),
159
+ ...(request.resume !== undefined ? { resume: request.resume } : {}),
160
+ ...(request.listId ? { listId: request.listId } : {}),
161
+ },
162
+ });
163
+ if (ok) {
164
+ const assigneeEmail = body && typeof body === 'object' && 'assigneeEmail' in body && typeof body.assigneeEmail === 'string'
165
+ ? body.assigneeEmail : undefined;
166
+ return { status, claimed: true, ...(assigneeEmail ? { assigneeEmail } : {}) };
167
+ }
168
+ const reason = reasonOf(body);
169
+ if (status === 409)
170
+ return { status, claimed: false, ...(reason ? { error: reason } : {}) };
171
+ throw new AstridApiError(status, `HTTP ${status} from claim-fixall${reason ? `: ${reason}` : ''}`, body);
172
+ }
173
+ async getTask(taskId) {
174
+ const body = await this.request(`/api/v1/tasks/${encodeURIComponent(taskId)}`);
175
+ return body.task;
176
+ }
177
+ async getComments(taskId) {
178
+ const body = await this.request(`/api/v1/tasks/${encodeURIComponent(taskId)}/comments`);
179
+ return body.comments;
180
+ }
181
+ async addComment(taskId, content, options = {}) {
182
+ const body = await this.request(`/api/v1/tasks/${encodeURIComponent(taskId)}/comments`, {
183
+ method: 'POST',
184
+ body: { content, ...(options.aiAgentId ? { aiAgentId: options.aiAgentId } : {}) },
185
+ });
186
+ return body.comment;
187
+ }
188
+ /** Move the task's board column (`ready`, `doing`, `waiting`, or null for the Inbox). */
189
+ async setStatus(taskId, statusRole, options = {}) {
190
+ return this.updateTask(taskId, { statusRole }, options);
191
+ }
192
+ /**
193
+ * Hand the task back to a person: the Inbox, assigned to them, in one write
194
+ * (astrid-core's `handBack`). Never Waiting, which holds only tasks waiting
195
+ * on a date or another task. `completed` is left out so a task someone
196
+ * finished meanwhile is not reopened.
197
+ */
198
+ async handBack(taskId, personId, options = {}) {
199
+ if (!personId.trim())
200
+ throw new Error('A handback needs the person to hand it to');
201
+ return this.updateTask(taskId, { statusRole: null, assigneeId: personId }, options);
202
+ }
203
+ async updateTask(taskId, fields, options) {
204
+ const body = await this.request(`/api/v1/tasks/${encodeURIComponent(taskId)}`, {
205
+ method: 'PUT',
206
+ body: { ...fields, ...(options.aiAgentId ? { aiAgentId: options.aiAgentId } : {}) },
207
+ });
208
+ return body.task;
209
+ }
210
+ }
211
+ exports.AstridClient = AstridClient;
212
+ //# sourceMappingURL=client.js.map