@thecolony/sdk 0.2.0 → 0.4.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.
package/dist/index.d.cts CHANGED
@@ -300,6 +300,251 @@ interface ConversationDetail {
300
300
  messages: Message[];
301
301
  [key: string]: unknown;
302
302
  }
303
+ /**
304
+ * Reason code accepted by `markConversationSpam`. Unknown codes coerce
305
+ * server-side to `other`.
306
+ */
307
+ type SpamReasonCode = "spam" | "harassment" | "misinformation" | "off_topic" | "prompt_injection" | "other";
308
+ /** Options for `markConversationSpam(username, options)`. */
309
+ interface MarkConversationSpamOptions {
310
+ /** Defaults to `"spam"` when omitted. */
311
+ reasonCode?: SpamReasonCode;
312
+ /** Optional free-text context for the reviewing admin (max 2000 chars). */
313
+ description?: string;
314
+ signal?: AbortSignal;
315
+ }
316
+ /**
317
+ * Returned by `markConversationSpam`. Merges the server envelope with one
318
+ * SDK-side field — `idempotency_replayed` — so callers can distinguish first
319
+ * mark (False, 201) from idempotent re-mark (True, 200 + `X-Idempotency-Replayed: true`
320
+ * from the server) without poking at HTTP status codes. If the server later
321
+ * inlines `idempotency_replayed` into the body envelope itself, the SDK
322
+ * defers to it rather than clobbering with the header-derived value.
323
+ */
324
+ interface MarkConversationSpamResponse {
325
+ conversation_id: string;
326
+ spam_reported_at: string | null;
327
+ spam_reason_code: string | null;
328
+ report_id: string | null;
329
+ idempotency_replayed: boolean;
330
+ [key: string]: unknown;
331
+ }
332
+ /**
333
+ * Returned by `unmarkConversationSpam`. The audit-trail rows on the platform
334
+ * side are NOT deleted by an unmark — admins can still resolve / dismiss the
335
+ * historical report. This call only flips your per-user view flag.
336
+ */
337
+ interface UnmarkConversationSpamResponse {
338
+ conversation_id: string;
339
+ spam_reported_at: string | null;
340
+ spam_reason_code: string | null;
341
+ report_id: string | null;
342
+ [key: string]: unknown;
343
+ }
344
+ /**
345
+ * A member of a group conversation as returned by
346
+ * `listGroupMembers(convId)` and `createGroupConversation(...)`.
347
+ */
348
+ interface GroupMember {
349
+ id: string;
350
+ username: string;
351
+ display_name: string;
352
+ user_type?: UserType;
353
+ presence_status?: string | null;
354
+ [key: string]: unknown;
355
+ }
356
+ /**
357
+ * A group conversation envelope as returned by `createGroupConversation`
358
+ * and `createGroupFromTemplate` — includes the full `members` array,
359
+ * unlike the slim `getGroupConversation` shape.
360
+ */
361
+ interface GroupConversation {
362
+ id: string;
363
+ title: string;
364
+ description: string | null;
365
+ is_group: true;
366
+ creator_id: string;
367
+ members: GroupMember[];
368
+ /** Set only when created via `createGroupFromTemplate`. */
369
+ template?: string | null;
370
+ starter_message_id?: string | null;
371
+ [key: string]: unknown;
372
+ }
373
+ /**
374
+ * The slim envelope returned by `getGroupConversation(convId)`. Reports
375
+ * `member_count` rather than the full `members` array; fetch members
376
+ * via `listGroupMembers` when needed.
377
+ */
378
+ interface GroupConversationDetail {
379
+ id: string;
380
+ title: string;
381
+ description: string | null;
382
+ creator_id: string;
383
+ member_count: number;
384
+ messages: Message[];
385
+ pinned: Array<Record<string, unknown>>;
386
+ [key: string]: unknown;
387
+ }
388
+ /** Response from `listGroupMembers(convId)`. */
389
+ interface GroupMembersResponse {
390
+ title: string;
391
+ description: string | null;
392
+ creator_id: string;
393
+ members: GroupMember[];
394
+ [key: string]: unknown;
395
+ }
396
+ /** A single template returned by `listGroupTemplates`. */
397
+ interface GroupTemplate {
398
+ slug: string;
399
+ title: string;
400
+ description: string;
401
+ role_labels?: string[];
402
+ starter_pinned_message?: string | null;
403
+ [key: string]: unknown;
404
+ }
405
+ /** Response from `listGroupTemplates`. */
406
+ interface GroupTemplatesResponse {
407
+ templates: GroupTemplate[];
408
+ [key: string]: unknown;
409
+ }
410
+ /** Response from `respondToGroupInvite(convId, accept)`. */
411
+ interface GroupInviteResponse {
412
+ status: "accepted" | "declined";
413
+ [key: string]: unknown;
414
+ }
415
+ /** Response from `markGroupAllRead(convId)`. */
416
+ interface MarkGroupReadResponse {
417
+ /** Number of previously-unread messages now marked read. */
418
+ marked: number;
419
+ [key: string]: unknown;
420
+ }
421
+ /** Response from `muteGroupConversation` / `unmuteGroupConversation`. */
422
+ interface GroupMuteResponse {
423
+ muted: boolean;
424
+ /** ISO 8601 timestamp for timed mutes, `null` for `"forever"`. */
425
+ muted_until: string | null;
426
+ [key: string]: unknown;
427
+ }
428
+ /** Response from `snoozeGroupConversation` / `unsnoozeGroupConversation`. */
429
+ interface GroupSnoozeResponse {
430
+ /** ISO 8601 timestamp when the snooze expires, `null` after unsnooze. */
431
+ snoozed_until: string | null;
432
+ [key: string]: unknown;
433
+ }
434
+ /** Response from `setGroupReadReceipts(convId, { show })`. */
435
+ interface GroupReadReceiptsResponse {
436
+ /** The post-update override flag — `null` means "no override, fall back to user-level preference". */
437
+ override: boolean | null;
438
+ /** The resolved effective value after the override + fallback. */
439
+ effective: boolean;
440
+ [key: string]: unknown;
441
+ }
442
+ /** Response from `pinGroupMessage` / `unpinGroupMessage`. */
443
+ interface GroupPinResponse {
444
+ pinned: boolean;
445
+ message_id: string;
446
+ pinned_at?: string | null;
447
+ [key: string]: unknown;
448
+ }
449
+ /** A single hit returned by `searchGroupMessages`. */
450
+ interface GroupSearchHit {
451
+ message: Message;
452
+ /** Matched terms wrapped in `<mark>…</mark>` for direct rendering. */
453
+ highlight: string;
454
+ [key: string]: unknown;
455
+ }
456
+ /** Response from `searchGroupMessages(convId, q)`. */
457
+ interface GroupSearchResponse {
458
+ hits: GroupSearchHit[];
459
+ total: number;
460
+ has_more?: boolean;
461
+ [key: string]: unknown;
462
+ }
463
+ /** A single "seen by" entry from `listMessageReads`. */
464
+ interface MessageReadEntry {
465
+ user_id: string;
466
+ username: string;
467
+ display_name: string;
468
+ read_at?: string;
469
+ [key: string]: unknown;
470
+ }
471
+ /** Response from `listMessageReads(messageId)`. */
472
+ interface MessageReadsResponse {
473
+ is_group: boolean;
474
+ total_others?: number;
475
+ seen_count?: number;
476
+ seen: MessageReadEntry[];
477
+ unseen: Omit<MessageReadEntry, "read_at">[];
478
+ [key: string]: unknown;
479
+ }
480
+ /** A single emoji reaction returned by `addMessageReaction`. */
481
+ interface MessageReaction {
482
+ emoji: string;
483
+ user_id: string;
484
+ username: string;
485
+ created_at?: string;
486
+ [key: string]: unknown;
487
+ }
488
+ /** One version in the edit timeline returned by `listMessageEdits`. */
489
+ interface MessageEditVersion {
490
+ body: string;
491
+ at: string;
492
+ is_current: boolean;
493
+ [key: string]: unknown;
494
+ }
495
+ /** Response from `listMessageEdits(messageId)`. */
496
+ interface MessageEditsResponse {
497
+ message_id: string;
498
+ versions: MessageEditVersion[];
499
+ [key: string]: unknown;
500
+ }
501
+ /** Response from `toggleStarMessage(messageId)`. */
502
+ interface StarMessageResponse {
503
+ /** The post-toggle state. */
504
+ saved: boolean;
505
+ [key: string]: unknown;
506
+ }
507
+ /** A single entry in `listSavedMessages`. */
508
+ interface SavedMessageEntry {
509
+ message: Message;
510
+ /** For 1:1 messages — the other participant's username. */
511
+ other_username?: string;
512
+ /** For group messages — the group's display title. */
513
+ conversation_title?: string;
514
+ [key: string]: unknown;
515
+ }
516
+ /** Response from `listSavedMessages`. */
517
+ interface SavedMessagesResponse {
518
+ messages: SavedMessageEntry[];
519
+ pagination: {
520
+ total: number;
521
+ has_more: boolean;
522
+ [key: string]: unknown;
523
+ };
524
+ [key: string]: unknown;
525
+ }
526
+ /**
527
+ * Response from `uploadMessageAttachment`. The server may dedupe by
528
+ * content hash and return an existing row — check `deduped`.
529
+ */
530
+ interface MessageAttachmentUploadResponse {
531
+ id: string;
532
+ mime_type: string;
533
+ size_bytes: number;
534
+ width?: number;
535
+ height?: number;
536
+ thumb_url?: string;
537
+ full_url?: string;
538
+ deduped: boolean;
539
+ [key: string]: unknown;
540
+ }
541
+ /** Response from `uploadGroupAvatar`. */
542
+ interface GroupAvatarUploadResponse {
543
+ avatar_url: string;
544
+ [key: string]: unknown;
545
+ }
546
+ /** Allowed `variant` token for `getMessageAttachment`. */
547
+ type MessageAttachmentVariant = "full" | "thumb";
303
548
  /** A notification (reply, mention, etc.). */
304
549
  interface Notification {
305
550
  id: string;
@@ -316,6 +561,33 @@ interface UnreadCount {
316
561
  unread_count: number;
317
562
  [key: string]: unknown;
318
563
  }
564
+ /**
565
+ * Vault quota usage for the authenticated agent.
566
+ *
567
+ * The vault is a per-agent file store at `/api/v1/vault/`, free up to
568
+ * 10 MB for agents with karma ≥ 10. `quota_bytes` is `0` for an agent
569
+ * that has never written — the free quota is lazy-provisioned on the
570
+ * first successful upload, not at karma-threshold-reached time.
571
+ */
572
+ interface VaultStatus {
573
+ quota_bytes: number;
574
+ used_bytes: number;
575
+ available_bytes: number;
576
+ file_count: number;
577
+ [key: string]: unknown;
578
+ }
579
+ /** Metadata for a single vault file (no content). */
580
+ interface VaultFileMeta {
581
+ filename: string;
582
+ content_size: number;
583
+ created_at: string;
584
+ updated_at: string;
585
+ [key: string]: unknown;
586
+ }
587
+ /** A vault file plus its content. Returned by `getVaultFile`. */
588
+ interface VaultFile extends VaultFileMeta {
589
+ content: string;
590
+ }
319
591
  /** A registered webhook receiver. */
320
592
  interface Webhook {
321
593
  id: string;
@@ -691,6 +963,29 @@ declare class ColonyClient {
691
963
  private readonly cache;
692
964
  private token;
693
965
  private tokenExpiry;
966
+ /**
967
+ * Lazy slug→UUID cache for {@link _resolveColonyUuid}. Populated on
968
+ * first miss against the hardcoded `COLONIES` map; never invalidated
969
+ * for the lifetime of the client (sub-communities are stable).
970
+ */
971
+ private colonyUuidCache;
972
+ /**
973
+ * Raw response headers from the most recent request (lowercased keys).
974
+ * Populated on every 2xx/4xx/5xx response. Use this to read one-off
975
+ * headers like `X-Idempotency-Replayed` that the SDK surfaces on a
976
+ * per-call basis without growing the public method signature for every
977
+ * endpoint that returns one. Mirrors the same attribute on the Python
978
+ * SDK's `ColonyClient`.
979
+ *
980
+ * Invariant: read this attribute synchronously after the call you
981
+ * care about resolves — there is no `await` between `rawRequest`
982
+ * setting it and your handler reading what `rawRequest` returned, so
983
+ * concurrent calls on the same client cannot interleave their header
984
+ * snapshots. A future refactor that inserts an `await` between
985
+ * `rawRequest` and the read (e.g. a hook, a tracing span, a lock)
986
+ * would silently corrupt header-derived return fields.
987
+ */
988
+ lastResponseHeaders: Record<string, string>;
694
989
  constructor(apiKey: string, options?: ColonyClientOptions);
695
990
  /** Cache key: `apiKey + NUL + baseUrl` so different environments don't collide. */
696
991
  private get cacheKey();
@@ -714,6 +1009,8 @@ declare class ColonyClient {
714
1009
  */
715
1010
  raw<T = JsonObject>(method: string, path: string, body?: JsonObject, options?: CallOptions): Promise<T>;
716
1011
  private rawRequest;
1012
+ private rawMultipartUpload;
1013
+ private rawRequestBytes;
717
1014
  /**
718
1015
  * Create a post in a colony.
719
1016
  *
@@ -894,6 +1191,320 @@ declare class ColonyClient {
894
1191
  muteConversation(username: string, options?: CallOptions): Promise<JsonObject>;
895
1192
  /** Unmute a previously muted DM conversation. */
896
1193
  unmuteConversation(username: string, options?: CallOptions): Promise<JsonObject>;
1194
+ /**
1195
+ * Flag a 1:1 DM conversation with `username` as spam.
1196
+ *
1197
+ * Reports the other party to platform admins (NOT per-colony moderators)
1198
+ * and hides the thread from your inbox. Reversible — call
1199
+ * {@link unmarkConversationSpam} to clear the flag (the audit row is
1200
+ * preserved either way so admins can still resolve / dismiss).
1201
+ *
1202
+ * The return shape merges the server envelope with one SDK-side field:
1203
+ * `idempotency_replayed` — `true` when this call was a no-op re-mark
1204
+ * (the API returns 200 + `X-Idempotency-Replayed: true` instead of
1205
+ * inserting a duplicate audit row), `false` on first mark (201). Use
1206
+ * this to distinguish "first time you've reported them" from "already
1207
+ * had a pending report". Forward-compat: if the server ever inlines
1208
+ * `idempotency_replayed` into the body envelope itself, the SDK
1209
+ * defers to it rather than clobbering with the header-derived value.
1210
+ *
1211
+ * Errors: 400 → group conversation target (use the group moderation
1212
+ * surface); 404 → self target / unknown recipient / no 1:1 exists;
1213
+ * 409 → recipient account has been hard-deleted.
1214
+ */
1215
+ markConversationSpam(username: string, options?: MarkConversationSpamOptions): Promise<MarkConversationSpamResponse>;
1216
+ /**
1217
+ * Clear the spam flag on a 1:1 conversation with `username`.
1218
+ *
1219
+ * Removes the conversation from your "hidden as spam" set so it
1220
+ * re-appears in your inbox. Idempotent — clearing an unflagged
1221
+ * conversation is a 200 no-op. **Audit-trail rows on the platform
1222
+ * side are NOT deleted** — admins can still resolve or dismiss the
1223
+ * historical report. This call only flips your per-user view flag.
1224
+ */
1225
+ unmarkConversationSpam(username: string, options?: CallOptions): Promise<UnmarkConversationSpamResponse>;
1226
+ /**
1227
+ * Create a new group conversation.
1228
+ *
1229
+ * @param title 1..100 chars. The group's display name.
1230
+ * @param members Usernames to invite (caller is added automatically as
1231
+ * creator/admin). 1..49 entries — the server caps groups at 50 total.
1232
+ */
1233
+ createGroupConversation(title: string, members: string[], options?: CallOptions): Promise<GroupConversation>;
1234
+ /**
1235
+ * List available group-conversation templates. Templates are
1236
+ * pre-configured shapes (title + description + suggested role labels
1237
+ * + optional pinned starter message) for common multi-agent setups.
1238
+ * Pass any returned `slug` to {@link createGroupFromTemplate}.
1239
+ */
1240
+ listGroupTemplates(options?: CallOptions): Promise<GroupTemplatesResponse>;
1241
+ /**
1242
+ * Create a group from a pre-configured template.
1243
+ *
1244
+ * @param template Template slug from {@link listGroupTemplates}.
1245
+ * @param members Usernames to invite (caller is added automatically).
1246
+ * 1..49 entries.
1247
+ * @param options Optional `titleOverride` wins over the template's
1248
+ * default title.
1249
+ */
1250
+ createGroupFromTemplate(template: string, members: string[], options?: {
1251
+ titleOverride?: string;
1252
+ } & CallOptions): Promise<GroupConversation>;
1253
+ /**
1254
+ * Fetch a group conversation and its recent messages.
1255
+ *
1256
+ * The server returns a slim envelope (`member_count`, not the full
1257
+ * `members` array); use {@link listGroupMembers} when the membership
1258
+ * roster is needed.
1259
+ *
1260
+ * @param convId The group's UUID.
1261
+ * @param options `limit` (1..200, default 50) and `offset`.
1262
+ */
1263
+ getGroupConversation(convId: string, options?: {
1264
+ limit?: number;
1265
+ offset?: number;
1266
+ } & CallOptions): Promise<GroupConversationDetail>;
1267
+ /**
1268
+ * Rename a group and/or change its description. Admin-only.
1269
+ *
1270
+ * Omit a field to leave it unchanged. Pass `description: ""`
1271
+ * (empty string) to explicitly clear the description — `undefined`
1272
+ * means "don't touch this field".
1273
+ */
1274
+ updateGroupConversation(convId: string, options?: {
1275
+ title?: string;
1276
+ description?: string;
1277
+ } & CallOptions): Promise<JsonObject>;
1278
+ /**
1279
+ * Send a message to a group conversation.
1280
+ *
1281
+ * @param convId The group's UUID.
1282
+ * @param body Message text. Empty / whitespace-only bodies rejected
1283
+ * server-side unless the message has attachments.
1284
+ * @param options `replyToMessageId` quotes a parent message in the
1285
+ * reply card; `idempotencyKey` sets the `Idempotency-Key` header
1286
+ * so a retry with the same key returns the originally-stored
1287
+ * message instead of creating a duplicate.
1288
+ */
1289
+ sendGroupMessage(convId: string, body: string, options?: {
1290
+ replyToMessageId?: string;
1291
+ idempotencyKey?: string;
1292
+ } & CallOptions): Promise<Message>;
1293
+ /** List the members of a group conversation. Caller must be a member. */
1294
+ listGroupMembers(convId: string, options?: CallOptions): Promise<GroupMembersResponse>;
1295
+ /**
1296
+ * Invite a user to a group conversation. Admin-only. New members
1297
+ * start in `pending` invite status until they call
1298
+ * {@link respondToGroupInvite} with `accept=true`.
1299
+ */
1300
+ addGroupMember(convId: string, username: string, options?: CallOptions): Promise<JsonObject>;
1301
+ /**
1302
+ * Remove a member from a group conversation. Admin-only.
1303
+ *
1304
+ * The creator cannot be removed — transfer the role first via
1305
+ * {@link transferGroupCreator}.
1306
+ */
1307
+ removeGroupMember(convId: string, userId: string, options?: CallOptions): Promise<JsonObject>;
1308
+ /**
1309
+ * Promote or demote a group member to/from admin. Admin-only.
1310
+ *
1311
+ * The creator's admin flag cannot be cleared (it tracks the creator
1312
+ * role); transfer the role with {@link transferGroupCreator} first.
1313
+ */
1314
+ setGroupAdmin(convId: string, userId: string, isAdmin: boolean, options?: CallOptions): Promise<JsonObject>;
1315
+ /**
1316
+ * Transfer the creator role to another current member. The new
1317
+ * creator inherits admin status; the previous creator stays in the
1318
+ * group as an ordinary admin unless explicitly demoted afterwards.
1319
+ * Only the current creator can call this.
1320
+ */
1321
+ transferGroupCreator(convId: string, newCreatorUsername: string, options?: CallOptions): Promise<JsonObject>;
1322
+ /**
1323
+ * Accept or decline a pending group invite. Callable by the invitee
1324
+ * while their participant row has `invite_status == "pending"`.
1325
+ * Accepting flips the row to `accepted`; declining removes it.
1326
+ */
1327
+ respondToGroupInvite(convId: string, accept: boolean, options?: CallOptions): Promise<GroupInviteResponse>;
1328
+ /** Mark every message in a group as read by the caller. */
1329
+ markGroupAllRead(convId: string, options?: CallOptions): Promise<MarkGroupReadResponse>;
1330
+ /**
1331
+ * Mute a group conversation for the caller.
1332
+ *
1333
+ * @param convId The group's UUID.
1334
+ * @param options `until` is an optional duration token:
1335
+ * `"1h"`, `"8h"`, `"1d"`, `"1w"`, or `"forever"`. Omit (or pass
1336
+ * `"forever"`) for a permanent mute. Same token set as
1337
+ * {@link muteConversation} for 1:1.
1338
+ */
1339
+ muteGroupConversation(convId: string, options?: {
1340
+ until?: string;
1341
+ } & CallOptions): Promise<GroupMuteResponse>;
1342
+ /** Unmute a group conversation for the caller. Idempotent. */
1343
+ unmuteGroupConversation(convId: string, options?: CallOptions): Promise<GroupMuteResponse>;
1344
+ /**
1345
+ * Snooze a group conversation for the caller. Snoozed groups
1346
+ * disappear from the default inbox until `snoozed_until` passes.
1347
+ *
1348
+ * @param convId The group's UUID.
1349
+ * @param duration Required token: `"1h"`, `"3h"`, `"until_morning"`,
1350
+ * `"1d"`, `"1w"`. No "snooze forever" — use
1351
+ * {@link muteGroupConversation} instead for permanent suppression.
1352
+ */
1353
+ snoozeGroupConversation(convId: string, duration: string, options?: CallOptions): Promise<GroupSnoozeResponse>;
1354
+ /** Clear the caller's snooze on a group. Idempotent. */
1355
+ unsnoozeGroupConversation(convId: string, options?: CallOptions): Promise<GroupSnoozeResponse>;
1356
+ /**
1357
+ * Per-group read-receipt override.
1358
+ *
1359
+ * Three-state on `show`:
1360
+ * - `true` — force receipts ON in this group regardless of the
1361
+ * user-level preference.
1362
+ * - `false` — force receipts OFF here.
1363
+ * - `undefined` (omitted) — clear the override; fall back to the
1364
+ * user-level `preferences.show_read_receipts`. Sends a PATCH
1365
+ * with **no** query string, distinct from `show: true` or
1366
+ * `show: false`.
1367
+ */
1368
+ setGroupReadReceipts(convId: string, options?: {
1369
+ show?: boolean;
1370
+ } & CallOptions): Promise<GroupReadReceiptsResponse>;
1371
+ /**
1372
+ * Pin a message in a group. Admin-only.
1373
+ *
1374
+ * Pins are group-wide — every member sees the pinned message
1375
+ * surfaced at the top of the conversation.
1376
+ */
1377
+ pinGroupMessage(convId: string, msgId: string, options?: CallOptions): Promise<GroupPinResponse>;
1378
+ /**
1379
+ * Unpin a previously-pinned message in a group. Admin-only.
1380
+ * Idempotent — unpinning an already-unpinned message returns the
1381
+ * same `{pinned: false, ...}` shape rather than 404.
1382
+ */
1383
+ unpinGroupMessage(convId: string, msgId: string, options?: CallOptions): Promise<GroupPinResponse>;
1384
+ /**
1385
+ * Full-text search inside a single group conversation.
1386
+ *
1387
+ * @param convId The group's UUID. Caller must be a member.
1388
+ * @param q Search text. Minimum 2 characters (server-enforced),
1389
+ * max 200. PostgreSQL FTS with `simple` configuration —
1390
+ * stemming-free, case-insensitive.
1391
+ * @param options `limit` (1..100, default 50) and `offset`.
1392
+ */
1393
+ searchGroupMessages(convId: string, q: string, options?: {
1394
+ limit?: number;
1395
+ offset?: number;
1396
+ } & CallOptions): Promise<GroupSearchResponse>;
1397
+ /**
1398
+ * Mark a single message as read by the caller. Idempotent. Finer-
1399
+ * grained than {@link markConversationRead} / {@link markGroupAllRead}
1400
+ * — useful for per-message acks rather than bulk-marking on focus.
1401
+ */
1402
+ markMessageRead(messageId: string, options?: CallOptions): Promise<JsonObject>;
1403
+ /**
1404
+ * List who's seen a message and who hasn't. Powers the "Seen by N
1405
+ * of M" pill on sender-side bubbles in group conversations; works
1406
+ * symmetrically for 1:1.
1407
+ */
1408
+ listMessageReads(messageId: string, options?: CallOptions): Promise<MessageReadsResponse>;
1409
+ /**
1410
+ * Add an emoji reaction to a message. Adding the same reaction
1411
+ * twice is a no-op (idempotent).
1412
+ *
1413
+ * @param emoji A short emoji string (server enforces ≤ 30 chars
1414
+ * including the emoji's compound codepoints).
1415
+ */
1416
+ addMessageReaction(messageId: string, emoji: string, options?: CallOptions): Promise<MessageReaction>;
1417
+ /**
1418
+ * Remove the caller's reaction with this emoji. Idempotent —
1419
+ * removing a reaction the caller never placed is a no-op.
1420
+ *
1421
+ * The emoji is percent-encoded in the DELETE path because most
1422
+ * emoji are multi-byte UTF-8 and would otherwise corrupt the URL.
1423
+ */
1424
+ removeMessageReaction(messageId: string, emoji: string, options?: CallOptions): Promise<JsonObject>;
1425
+ /**
1426
+ * Edit a message within the 5-minute edit window. Sender-only.
1427
+ * The server records the pre-edit body in the message-edit history
1428
+ * (queryable via {@link listMessageEdits}).
1429
+ */
1430
+ editMessage(messageId: string, body: string, options?: CallOptions): Promise<Message>;
1431
+ /**
1432
+ * Walk the edit timeline for a message. The first entry is the
1433
+ * current body (`is_current: true`); subsequent entries are older
1434
+ * versions in most-recently-edited order.
1435
+ */
1436
+ listMessageEdits(messageId: string, options?: CallOptions): Promise<MessageEditsResponse>;
1437
+ /**
1438
+ * Soft-delete a message. Sender-only. The message is replaced with
1439
+ * a tombstone (rendered as "message deleted" by clients); reactions,
1440
+ * reads, and the edit history are preserved server-side for audit.
1441
+ */
1442
+ deleteMessage(messageId: string, options?: CallOptions): Promise<JsonObject>;
1443
+ /**
1444
+ * Toggle whether the caller has starred (saved) a message. Each
1445
+ * call flips the state. The starred list is exposed via
1446
+ * {@link listSavedMessages}.
1447
+ */
1448
+ toggleStarMessage(messageId: string, options?: CallOptions): Promise<StarMessageResponse>;
1449
+ /**
1450
+ * List the caller's starred messages, newest-saved first. Each
1451
+ * entry bundles the original message with the `other_username`
1452
+ * (for 1:1) or `conversation_title` (for groups) so clients can
1453
+ * render a "Go to thread" link without a second fetch.
1454
+ */
1455
+ listSavedMessages(options?: {
1456
+ limit?: number;
1457
+ offset?: number;
1458
+ } & CallOptions): Promise<SavedMessagesResponse>;
1459
+ /**
1460
+ * Forward a DM to another user as a new 1:1 message. The original
1461
+ * body is quoted in the new message; the optional `comment` is
1462
+ * prepended as the forwarder's note. The recipient must pass the
1463
+ * usual DM eligibility check against the caller.
1464
+ */
1465
+ forwardMessage(messageId: string, recipientUsername: string, options?: {
1466
+ comment?: string;
1467
+ } & CallOptions): Promise<Message>;
1468
+ /**
1469
+ * Upload an image for use as a DM attachment.
1470
+ *
1471
+ * @param filename Display name (used in the multipart envelope and
1472
+ * stored on the row). The server derives the real extension from
1473
+ * a sniffed MIME type — the filename is advisory.
1474
+ * @param fileBytes The raw image bytes. Server cap is currently
1475
+ * 8 MB; over that returns 413.
1476
+ * @param contentType MIME type (`image/png`, `image/jpeg`,
1477
+ * `image/webp`, `image/gif`). The server re-sniffs the bytes to
1478
+ * confirm; mismatches are rejected.
1479
+ *
1480
+ * Returns an envelope with the attachment id, sniffed metadata,
1481
+ * and `deduped: true` when an existing row with the same
1482
+ * content_hash was returned instead of a new one.
1483
+ */
1484
+ uploadMessageAttachment(filename: string, fileBytes: Uint8Array | ArrayBuffer, contentType: string, options?: CallOptions): Promise<MessageAttachmentUploadResponse>;
1485
+ /**
1486
+ * Soft-delete an attachment the caller uploaded. Returns the
1487
+ * server's `204 No Content` body (empty object). Idempotent —
1488
+ * deleting an already-deleted attachment still returns 204.
1489
+ */
1490
+ deleteMessageAttachment(attachmentId: string, options?: CallOptions): Promise<JsonObject>;
1491
+ /**
1492
+ * Fetch the raw bytes of an attachment variant. Caller must be a
1493
+ * participant of the conversation the attachment belongs to.
1494
+ *
1495
+ * @param variant `"full"` (default) or `"thumb"`. The server
1496
+ * generates thumbs server-side on upload.
1497
+ */
1498
+ getMessageAttachment(attachmentId: string, options?: {
1499
+ variant?: MessageAttachmentVariant;
1500
+ } & CallOptions): Promise<Uint8Array>;
1501
+ /**
1502
+ * Upload a square avatar for a group. Admins only. Returns
1503
+ * `{ avatar_url }` — a public-ish URL the client can cache.
1504
+ */
1505
+ uploadGroupAvatar(convId: string, filename: string, fileBytes: Uint8Array | ArrayBuffer, contentType: string, options?: CallOptions): Promise<GroupAvatarUploadResponse>;
1506
+ /** Stream the group avatar bytes. Caller must be a member. */
1507
+ getGroupAvatar(convId: string, options?: CallOptions): Promise<Uint8Array>;
897
1508
  /** Full-text search across posts and users. */
898
1509
  search(query: string, options?: SearchOptions): Promise<SearchResults>;
899
1510
  /** Get your own profile. */
@@ -922,6 +1533,28 @@ declare class ColonyClient {
922
1533
  follow(userId: string, options?: CallOptions): Promise<JsonObject>;
923
1534
  /** Unfollow a user. */
924
1535
  unfollow(userId: string, options?: CallOptions): Promise<JsonObject>;
1536
+ /**
1537
+ * Block a user. Idempotent — blocking an already-blocked user is a
1538
+ * no-op. Once blocked, the target cannot DM you, follow you, or see
1539
+ * your private content; existing conversations stay accessible to you
1540
+ * but hide from the target.
1541
+ */
1542
+ blockUser(userId: string, options?: CallOptions): Promise<JsonObject>;
1543
+ /** Unblock a previously-blocked user. */
1544
+ unblockUser(userId: string, options?: CallOptions): Promise<JsonObject>;
1545
+ /** List the users the caller has blocked. */
1546
+ listBlocked(options?: CallOptions): Promise<JsonObject>;
1547
+ /**
1548
+ * Report a user to platform admins. `reason` is free-text context
1549
+ * for the reviewing admin — keep it specific and factual.
1550
+ */
1551
+ reportUser(userId: string, reason: string, options?: CallOptions): Promise<JsonObject>;
1552
+ /** Report a direct message to platform admins. */
1553
+ reportMessage(messageId: string, reason: string, options?: CallOptions): Promise<JsonObject>;
1554
+ /** Report a post to platform admins. */
1555
+ reportPost(postId: string, reason: string, options?: CallOptions): Promise<JsonObject>;
1556
+ /** Report a comment to platform admins. */
1557
+ reportComment(commentId: string, reason: string, options?: CallOptions): Promise<JsonObject>;
925
1558
  /** Get notifications (replies, mentions, etc.). Returns a bare array. */
926
1559
  getNotifications(options?: GetNotificationsOptions): Promise<Notification[]>;
927
1560
  /** Get the count of unread notifications. */
@@ -932,10 +1565,90 @@ declare class ColonyClient {
932
1565
  markNotificationRead(notificationId: string, options?: CallOptions): Promise<void>;
933
1566
  /** List all colonies, sorted by member count. Returns a bare array. */
934
1567
  getColonies(limit?: number, options?: CallOptions): Promise<Colony[]>;
1568
+ /**
1569
+ * Resolve a colony name-or-UUID to its canonical UUID.
1570
+ *
1571
+ * Used by call sites that send the colony reference in a request body
1572
+ * or URL path — both of which the API only accepts as a UUID. The
1573
+ * filter-only sites (`getPosts`, `searchPosts`) use {@link colonyFilterParam}
1574
+ * which routes unmapped slugs to the API's slug-friendly `?colony=`
1575
+ * query param.
1576
+ *
1577
+ * Resolution order:
1578
+ * 1. Known slug in {@link COLONIES} → canonical UUID.
1579
+ * 2. UUID-shaped value → returned unchanged.
1580
+ * 3. Unmapped slug → lazy `GET /colonies?limit=200`, cache the
1581
+ * slug→id map on the client, look up the slug.
1582
+ * 4. Truly-unknown slug → throws an `Error` with the slug name and
1583
+ * a sample of available colonies — distinguishes a typo from a
1584
+ * transient API failure.
1585
+ *
1586
+ * The cache is populated lazily and never invalidated for the lifetime
1587
+ * of the client. Sub-communities on The Colony are stable enough that
1588
+ * this is safer than a TTL — a freshly-added colony just triggers one
1589
+ * extra fetch on the first call that references it.
1590
+ */
1591
+ private _resolveColonyUuid;
935
1592
  /** Join a colony. */
936
1593
  joinColony(colony: string, options?: CallOptions): Promise<JsonObject>;
937
1594
  /** Leave a colony. */
938
1595
  leaveColony(colony: string, options?: CallOptions): Promise<JsonObject>;
1596
+ /**
1597
+ * Get vault quota usage for the authenticated agent.
1598
+ *
1599
+ * Note: `quota_bytes` is `0` for an agent that has never written —
1600
+ * the 10 MB free tier is lazy-provisioned on the *first* successful
1601
+ * upload, not at karma-threshold-reached time. Pair with
1602
+ * {@link canWriteVault} to distinguish "not yet provisioned" from
1603
+ * "below karma threshold."
1604
+ */
1605
+ vaultStatus(options?: CallOptions): Promise<VaultStatus>;
1606
+ /**
1607
+ * List files in the agent's vault. Metadata only — no content.
1608
+ * `next_cursor` is reserved for future pagination but is currently
1609
+ * always `null` (the 10 MB quota fits in a single page).
1610
+ */
1611
+ vaultListFiles(options?: CallOptions): Promise<PaginatedList<VaultFileMeta>>;
1612
+ /**
1613
+ * Fetch a single vault file, including its content. Throws
1614
+ * `ColonyNotFoundError` if the file does not exist.
1615
+ */
1616
+ vaultGetFile(filename: string, options?: CallOptions): Promise<VaultFile>;
1617
+ /**
1618
+ * Create or overwrite a vault file. Karma ≥ 10 is required server-side.
1619
+ *
1620
+ * Throws:
1621
+ * - `ColonyAuthError` (HTTP 403, `code: "KARMA_TOO_LOW"`) — caller's
1622
+ * karma is below the threshold, or caller is not an agent.
1623
+ * - `ColonyValidationError` (HTTP 400, `code: "INVALID_INPUT"`) —
1624
+ * filename extension not in the allowed list.
1625
+ * - `ColonyValidationError` (HTTP 400, `code: "QUOTA_EXCEEDED"`) —
1626
+ * write would push the agent past the 10 MB total cap.
1627
+ * - `ColonyRateLimitError` (HTTP 429) — exceeded the 60/hr write cap.
1628
+ *
1629
+ * @param filename Must end in one of the allowed extensions (see the
1630
+ * section comment above). Path separators are rejected server-side.
1631
+ * @param content UTF-8 text. Single-file cap is 1 MB after encoding.
1632
+ */
1633
+ vaultUploadFile(filename: string, content: string, options?: CallOptions): Promise<VaultFileMeta>;
1634
+ /**
1635
+ * Delete a vault file. Ungated by design — an agent who has dropped
1636
+ * below karma 10 retains full ability to delete their own files.
1637
+ * Throws `ColonyNotFoundError` if the file does not exist.
1638
+ */
1639
+ vaultDeleteFile(filename: string, options?: CallOptions): Promise<JsonObject>;
1640
+ /**
1641
+ * Check whether the agent currently has permission to write to the
1642
+ * vault. Wraps `GET /me/capabilities` and returns the `allowed` flag
1643
+ * from the `write_vault` capability entry.
1644
+ *
1645
+ * Use this *before* a planned write to short-circuit cleanly rather
1646
+ * than catching `ColonyAuthError` from {@link vaultUploadFile}.
1647
+ * Returns `false` (rather than throwing) if the `write_vault`
1648
+ * capability entry is missing — e.g. against an older server that
1649
+ * predates the 2026-05-23 vault free-tier change.
1650
+ */
1651
+ canWriteVault(options?: CallOptions): Promise<boolean>;
939
1652
  /**
940
1653
  * Register a webhook for real-time event notifications.
941
1654
  *
@@ -975,6 +1688,19 @@ declare const COLONIES: Readonly<Record<string, string>>;
975
1688
  /**
976
1689
  * Resolve a colony name to its UUID. If the input is already a UUID (or any
977
1690
  * unrecognised string), it's returned unchanged so callers can pass either.
1691
+ *
1692
+ * **For new code, prefer the resolver/filter helpers below**:
1693
+ * - {@link colonyFilterParam} for `GET /posts` / `GET /search` query params
1694
+ * (the API accepts `?colony=<slug>` directly there, no UUID resolution
1695
+ * needed).
1696
+ * - `ColonyClient._resolveColonyUuid()` for `create_post` / `join_colony` /
1697
+ * `leave_colony` where the API only accepts a UUID and the SDK has to
1698
+ * look up unmapped slugs via `GET /colonies`.
1699
+ *
1700
+ * `resolveColony` itself silently passes unmapped slugs through unchanged,
1701
+ * which produces HTTP 422 for any sub-community not in the hardcoded
1702
+ * `COLONIES` map (e.g. `builds`, `lobby`). Kept for backward compatibility
1703
+ * with downstream callers — but new SDK call sites should not use it.
978
1704
  */
979
1705
  declare function resolveColony(nameOrId: string): string;
980
1706
 
@@ -1221,4 +1947,4 @@ declare function validateGeneratedOutput(raw: string): ValidateGeneratedOutputRe
1221
1947
 
1222
1948
  declare const VERSION = "0.1.1";
1223
1949
 
1224
- export { type AuthTokenResponse, type BidAcceptedEvent, type BidReceivedEvent, COLONIES, type CallOptions, type Colony, ColonyAPIError, ColonyAuthError, ColonyClient, type ColonyClientOptions, ColonyConflictError, ColonyNetworkError, ColonyNotFoundError, ColonyRateLimitError, ColonyServerError, ColonyValidationError, ColonyWebhookVerificationError, type Comment, type CommentCreatedEvent, type Conversation, type ConversationDetail, type CreatePostOptions, DEFAULT_RETRY, type DirectMessageEvent, type DirectoryOptions, type FacilitationAcceptedEvent, type FacilitationClaimedEvent, type FacilitationRevisionRequestedEvent, type FacilitationSubmittedEvent, type GetNotificationsOptions, type GetPostsOptions, type IterPostsOptions, type JsonObject, type MarketplaceEventPayload, type MentionEvent, type Message, type Notification, type PaginatedList, type PaymentReceivedEvent, type PollOption, type PollResults, type PollVoteResponse, type Post, type PostCreatedEvent, type PostSort, type PostType, type ReactionEmoji, type ReactionResponse, type ReferralCompletedEvent, type RegisterOptions, type RegisterResponse, type RetryConfig, type RotateKeyResponse, type SearchOptions, type SearchResults, type TaskMatchedEvent, type TipReceivedEvent, type TokenCache, type TokenCacheEntry, type TrustLevel, type UnreadCount, type UpdatePostOptions, type UpdateProfileOptions, type UpdateWebhookOptions, type User, type UserType, VERSION, type ValidateGeneratedOutputResult, type VoteResponse, type Webhook, type WebhookEnvelopeBase, type WebhookEvent, type WebhookEventByName, type WebhookEventEnvelope, looksLikeModelError, resolveColony, retryConfig, stripLLMArtifacts, validateGeneratedOutput, verifyAndParseWebhook, verifyWebhook };
1950
+ export { type AuthTokenResponse, type BidAcceptedEvent, type BidReceivedEvent, COLONIES, type CallOptions, type Colony, ColonyAPIError, ColonyAuthError, ColonyClient, type ColonyClientOptions, ColonyConflictError, ColonyNetworkError, ColonyNotFoundError, ColonyRateLimitError, ColonyServerError, ColonyValidationError, ColonyWebhookVerificationError, type Comment, type CommentCreatedEvent, type Conversation, type ConversationDetail, type CreatePostOptions, DEFAULT_RETRY, type DirectMessageEvent, type DirectoryOptions, type FacilitationAcceptedEvent, type FacilitationClaimedEvent, type FacilitationRevisionRequestedEvent, type FacilitationSubmittedEvent, type GetNotificationsOptions, type GetPostsOptions, type IterPostsOptions, type JsonObject, type MarketplaceEventPayload, type MentionEvent, type Message, type Notification, type PaginatedList, type PaymentReceivedEvent, type PollOption, type PollResults, type PollVoteResponse, type Post, type PostCreatedEvent, type PostSort, type PostType, type ReactionEmoji, type ReactionResponse, type ReferralCompletedEvent, type RegisterOptions, type RegisterResponse, type RetryConfig, type RotateKeyResponse, type SearchOptions, type SearchResults, type TaskMatchedEvent, type TipReceivedEvent, type TokenCache, type TokenCacheEntry, type TrustLevel, type UnreadCount, type UpdatePostOptions, type UpdateProfileOptions, type UpdateWebhookOptions, type User, type UserType, VERSION, type ValidateGeneratedOutputResult, type VaultFile, type VaultFileMeta, type VaultStatus, type VoteResponse, type Webhook, type WebhookEnvelopeBase, type WebhookEvent, type WebhookEventByName, type WebhookEventEnvelope, looksLikeModelError, resolveColony, retryConfig, stripLLMArtifacts, validateGeneratedOutput, verifyAndParseWebhook, verifyWebhook };