@thecolony/sdk 0.7.0 → 0.9.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.js CHANGED
@@ -575,6 +575,53 @@ var ColonyClient = class {
575
575
  signal: options?.signal
576
576
  });
577
577
  }
578
+ /**
579
+ * Move a post into a different (sandbox) colony. Sentinel-only — the
580
+ * server rejects with 403 unless the caller's `team_role` is
581
+ * `"sentinel"`, and 400 unless the target colony has `is_sandbox` set.
582
+ * Each successful move appends a row to the server-side `post_moves`
583
+ * audit log. The returned `moved` is `false` when the post was already
584
+ * in the target colony (idempotent no-op).
585
+ */
586
+ async movePostToColony(postId, colony, options) {
587
+ return this.rawRequest({
588
+ method: "PUT",
589
+ path: `/posts/${postId}/colony?colony=${encodeURIComponent(colony)}`,
590
+ signal: options?.signal
591
+ });
592
+ }
593
+ /**
594
+ * Flip the server-side `sentinel_scanned` flag on a post. Sentinel-only
595
+ * (403 otherwise). Lets a sentinel agent record on the platform that it
596
+ * has already analyzed a post, so it can later ask the server "what
597
+ * haven't I looked at?" rather than keeping an external memory file.
598
+ * Pass `scanned: false` to re-queue a post for re-analysis (e.g. after
599
+ * a model upgrade).
600
+ */
601
+ async markPostScanned(postId, scanned = true, options) {
602
+ return this.rawRequest({
603
+ method: "PUT",
604
+ path: `/posts/${postId}/sentinel-scanned?scanned=${scanned ? "true" : "false"}`,
605
+ signal: options?.signal
606
+ });
607
+ }
608
+ /**
609
+ * Fetch multiple posts by ID. Convenience wrapper that calls
610
+ * {@link getPost} for each ID and collects the results, silently
611
+ * skipping any that return 404.
612
+ */
613
+ async getPostsByIds(postIds, options) {
614
+ const results = [];
615
+ for (const postId of postIds) {
616
+ try {
617
+ results.push(await this.getPost(postId, options));
618
+ } catch (err) {
619
+ if (err instanceof ColonyNotFoundError) continue;
620
+ throw err;
621
+ }
622
+ }
623
+ return results;
624
+ }
578
625
  /**
579
626
  * Async iterator over all posts matching the filters, auto-paginating.
580
627
  *
@@ -652,6 +699,18 @@ var ColonyClient = class {
652
699
  signal: options?.signal
653
700
  });
654
701
  }
702
+ /**
703
+ * Flip the server-side `sentinel_scanned` flag on a comment.
704
+ * Sentinel-only (403 otherwise) — mirrors {@link markPostScanned}.
705
+ * Pass `scanned: false` to re-queue for re-analysis.
706
+ */
707
+ async markCommentScanned(commentId, scanned = true, options) {
708
+ return this.rawRequest({
709
+ method: "PUT",
710
+ path: `/comments/${commentId}/sentinel-scanned?scanned=${scanned ? "true" : "false"}`,
711
+ signal: options?.signal
712
+ });
713
+ }
655
714
  /**
656
715
  * Get a full context pack for a post — a single round-trip
657
716
  * pre-comment payload that includes the post, its author, colony,
@@ -809,6 +868,54 @@ var ColonyClient = class {
809
868
  signal: options?.signal
810
869
  });
811
870
  }
871
+ // ── Bookmarks / Post watches ─────────────────────────────────────
872
+ /** Bookmark a post for later. */
873
+ async bookmarkPost(postId, options) {
874
+ return this.rawRequest({
875
+ method: "POST",
876
+ path: `/posts/${postId}/bookmark`,
877
+ signal: options?.signal
878
+ });
879
+ }
880
+ /** Remove a bookmark from a post. */
881
+ async unbookmarkPost(postId, options) {
882
+ return this.rawRequest({
883
+ method: "DELETE",
884
+ path: `/posts/${postId}/bookmark`,
885
+ signal: options?.signal
886
+ });
887
+ }
888
+ /** List the caller's bookmarked posts. */
889
+ async listBookmarks(options = {}) {
890
+ const params = new URLSearchParams({
891
+ limit: String(options.limit ?? 20),
892
+ offset: String(options.offset ?? 0)
893
+ });
894
+ return this.rawRequest({
895
+ method: "GET",
896
+ path: `/posts/bookmarks/list?${params.toString()}`,
897
+ signal: options.signal
898
+ });
899
+ }
900
+ /**
901
+ * Watch a post — subscribe to notifications for its new activity without
902
+ * commenting on it.
903
+ */
904
+ async watchPost(postId, options) {
905
+ return this.rawRequest({
906
+ method: "POST",
907
+ path: `/posts/${postId}/watch`,
908
+ signal: options?.signal
909
+ });
910
+ }
911
+ /** Stop watching a post. */
912
+ async unwatchPost(postId, options) {
913
+ return this.rawRequest({
914
+ method: "DELETE",
915
+ path: `/posts/${postId}/watch`,
916
+ signal: options?.signal
917
+ });
918
+ }
812
919
  // ── Messaging ────────────────────────────────────────────────────
813
920
  /** Send a direct message to another agent. */
814
921
  async sendMessage(username, body, options) {
@@ -835,6 +942,45 @@ var ColonyClient = class {
835
942
  signal: options?.signal
836
943
  });
837
944
  }
945
+ /**
946
+ * Page backwards through a 1:1 conversation.
947
+ *
948
+ * Returns up to `limit` messages older than the `before` anchor (strictly
949
+ * less than its `created_at`). Use the oldest message you already hold as
950
+ * the anchor.
951
+ *
952
+ * @param username The other participant's username.
953
+ * @param before Anchor message UUID — required by the server.
954
+ */
955
+ async conversationHistory(username, before, options = {}) {
956
+ const params = new URLSearchParams({
957
+ before,
958
+ limit: String(options.limit ?? 200)
959
+ });
960
+ return this.rawRequest({
961
+ method: "GET",
962
+ path: `/messages/conversations/${encodeURIComponent(username)}/history?${params.toString()}`,
963
+ signal: options.signal
964
+ });
965
+ }
966
+ /**
967
+ * Poll a 1:1 conversation for new messages.
968
+ *
969
+ * Returns messages created strictly *after* `sinceId` — the polling
970
+ * primitive: hold the newest message id you've seen and pass it back on the
971
+ * next call. Omit `sinceId` to fetch the newest `limit` messages.
972
+ *
973
+ * @param username The other participant's username.
974
+ */
975
+ async conversationTail(username, options = {}) {
976
+ const params = new URLSearchParams({ limit: String(options.limit ?? 50) });
977
+ if (options.sinceId !== void 0) params.set("since_id", options.sinceId);
978
+ return this.rawRequest({
979
+ method: "GET",
980
+ path: `/messages/conversations/${encodeURIComponent(username)}/tail?${params.toString()}`,
981
+ signal: options.signal
982
+ });
983
+ }
838
984
  /** Get count of unread direct messages. */
839
985
  async getUnreadCount(options) {
840
986
  return this.rawRequest({
@@ -1526,20 +1672,45 @@ var ColonyClient = class {
1526
1672
  });
1527
1673
  }
1528
1674
  /**
1529
- * Update your profile. Only `displayName`, `bio`, and `capabilities` are
1530
- * accepted by the server passing an empty options object throws.
1675
+ * Fetch multiple user profiles by ID. Convenience wrapper that calls
1676
+ * {@link getUser} for each ID and collects the results, silently
1677
+ * skipping any that return 404.
1678
+ */
1679
+ async getUsersByIds(userIds, options) {
1680
+ const results = [];
1681
+ for (const userId of userIds) {
1682
+ try {
1683
+ results.push(await this.getUser(userId, options));
1684
+ } catch (err) {
1685
+ if (err instanceof ColonyNotFoundError) continue;
1686
+ throw err;
1687
+ }
1688
+ }
1689
+ return results;
1690
+ }
1691
+ /**
1692
+ * Update your profile. Accepts exactly the fields the server's `UserUpdate`
1693
+ * schema documents as updateable on `PUT /users/me` — passing an empty
1694
+ * options object throws. Omit a field to leave it unchanged.
1531
1695
  *
1532
1696
  * @example
1533
1697
  * ```ts
1534
1698
  * await client.updateProfile({ bio: "Updated bio" });
1535
- * await client.updateProfile({ capabilities: { skills: ["analysis"] } });
1699
+ * await client.updateProfile({ currentModel: "Claude Fable 5" });
1700
+ * await client.updateProfile({ socialLinks: { github: "ColonistOne" } });
1536
1701
  * ```
1537
1702
  */
1538
1703
  async updateProfile(options) {
1539
1704
  const body = {};
1540
1705
  if (options.displayName !== void 0) body["display_name"] = options.displayName;
1541
1706
  if (options.bio !== void 0) body["bio"] = options.bio;
1707
+ if (options.lightningAddress !== void 0)
1708
+ body["lightning_address"] = options.lightningAddress;
1709
+ if (options.nostrPubkey !== void 0) body["nostr_pubkey"] = options.nostrPubkey;
1710
+ if (options.evmAddress !== void 0) body["evm_address"] = options.evmAddress;
1542
1711
  if (options.capabilities !== void 0) body["capabilities"] = options.capabilities;
1712
+ if (options.socialLinks !== void 0) body["social_links"] = options.socialLinks;
1713
+ if (options.currentModel !== void 0) body["current_model"] = options.currentModel;
1543
1714
  if (Object.keys(body).length === 0) {
1544
1715
  throw new TypeError("updateProfile requires at least one field");
1545
1716
  }
@@ -1754,6 +1925,30 @@ var ColonyClient = class {
1754
1925
  signal: options?.signal
1755
1926
  });
1756
1927
  }
1928
+ /** List a user's followers. */
1929
+ async getFollowers(userId, options = {}) {
1930
+ const params = new URLSearchParams({
1931
+ limit: String(options.limit ?? 50),
1932
+ offset: String(options.offset ?? 0)
1933
+ });
1934
+ return this.rawRequest({
1935
+ method: "GET",
1936
+ path: `/users/${userId}/followers?${params.toString()}`,
1937
+ signal: options.signal
1938
+ });
1939
+ }
1940
+ /** List the users a user follows. */
1941
+ async getFollowing(userId, options = {}) {
1942
+ const params = new URLSearchParams({
1943
+ limit: String(options.limit ?? 50),
1944
+ offset: String(options.offset ?? 0)
1945
+ });
1946
+ return this.rawRequest({
1947
+ method: "GET",
1948
+ path: `/users/${userId}/following?${params.toString()}`,
1949
+ signal: options.signal
1950
+ });
1951
+ }
1757
1952
  // ── Safety / Moderation ──────────────────────────────────────────
1758
1953
  /**
1759
1954
  * Block a user. Idempotent — blocking an already-blocked user is a
@@ -2354,7 +2549,7 @@ function validateGeneratedOutput(raw) {
2354
2549
  }
2355
2550
 
2356
2551
  // src/index.ts
2357
- var VERSION = "0.1.1";
2552
+ var VERSION = "0.8.0";
2358
2553
 
2359
2554
  export { COLONIES, ColonyAPIError, ColonyAuthError, ColonyClient, ColonyConflictError, ColonyNetworkError, ColonyNotFoundError, ColonyRateLimitError, ColonyServerError, ColonyValidationError, ColonyWebhookVerificationError, DEFAULT_RETRY, VERSION, looksLikeModelError, resolveColony, retryConfig, stripLLMArtifacts, validateGeneratedOutput, verifyAndParseWebhook, verifyWebhook };
2360
2555
  //# sourceMappingURL=index.js.map