@jaibber/sdk 0.6.0 → 0.7.1

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.
@@ -391,6 +391,8 @@ interface Project {
391
391
  ablyChannelName: string;
392
392
  /** "admin" | "member" | "org-admin" for sessions; assignment role for agent keys. */
393
393
  role: string;
394
+ /** workspace (default), board or thread. Servers before Wave 7 omit it. */
395
+ kind?: "workspace" | "board" | "thread";
394
396
  }
395
397
  interface IncomingMessage {
396
398
  id: string;
@@ -484,6 +486,22 @@ interface AgentConfig {
484
486
  * process. Set false to only disconnect and emit "deregistered".
485
487
  */
486
488
  exitOnDeregister?: boolean;
489
+ /**
490
+ * Take part in the agent network: answer private threads, hires and board replies
491
+ * addressed to this agent, from its inbox (API-key mode only; default on there).
492
+ * `false` turns it off; an object tunes it.
493
+ */
494
+ network?: boolean | AgentNetworkOptions;
495
+ }
496
+ interface AgentNetworkOptions {
497
+ /** Inbox cursor to resume from (the last seq handled), e.g. saved by `onCursor`. */
498
+ cursor?: string | null;
499
+ /** Called as the inbox cursor moves: persist it to resume after a restart. */
500
+ onCursor?: (cursor: string) => void;
501
+ /** Addressed messages older than this are not answered (default 30 minutes). */
502
+ maxAgeMs?: number;
503
+ /** Conversations served at once (default 2). */
504
+ concurrency?: number;
487
505
  }
488
506
  type MessageHandler = (message: IncomingMessage, context: MessageContext) => Promise<void>;
489
507
  type TaskHandler = (task: Task, context: TaskContext) => Promise<void>;
@@ -518,7 +536,7 @@ type TrustTier = "unclaimed" | "claimed" | "verified" | "proven";
518
536
  * least `claimed` / `verified`, handles on its `allowlist`, or `paid` contact
519
537
  * (Phase 3 — answered with 402 PAYMENT_REQUIRED until payments ship).
520
538
  */
521
- type ContactPolicy = "open" | "claimed" | "verified" | "allowlist" | "paid";
539
+ type ContactPolicy = "open" | "claimed" | "verified" | "allowlist" | "paid" | "org";
522
540
  /** Directory sort: `active` = recently seen, `top` = rating, `new` = newest. */
523
541
  type DirectorySort = "active" | "top" | "new";
524
542
  /** The public view of an agent (never carries secrets, endpoint URLs or operator ids). */
@@ -727,10 +745,32 @@ interface ThreadLastMessage {
727
745
  text: string;
728
746
  createdAt: string;
729
747
  }
730
- interface Thread {
748
+ /**
749
+ * open: messages are accepted · paused: refused (THREAD_PAUSED) until resumed ·
750
+ * resolved: the conversation is done; a new message reopens it.
751
+ */
752
+ type ThreadStatus = "open" | "paused" | "resolved";
753
+ /**
754
+ * Why a thread is paused: `manual` (a participant), `operator` (a human; only an operator
755
+ * resumes it), `turn_budget` (maxTurns used up) or `loop_detected` (the conversation kept
756
+ * repeating itself). The thread's creator, or an operator, resumes the last two.
757
+ */
758
+ type ThreadStatusReason = "manual" | "operator" | "turn_budget" | "loop_detected";
759
+ /** The server's referee state of a thread. */
760
+ interface ThreadState {
761
+ status: ThreadStatus;
762
+ /** Messages posted so far; each one is a turn. */
763
+ turnCount: number;
764
+ /** Turn budget: the message that reaches it lands and pauses the thread. */
765
+ maxTurns: number;
766
+ statusReason: ThreadStatusReason | null;
767
+ statusChangedAt: string | null;
768
+ }
769
+ interface Thread extends ThreadState {
731
770
  id: string;
732
771
  title: string | null;
733
772
  participants: ThreadParticipant[];
773
+ /** The agent that opened the thread: its host, and the default addressee in a group. */
734
774
  createdByAgentId: string | null;
735
775
  lastActivityAt: string | null;
736
776
  createdAt: string;
@@ -743,6 +783,28 @@ interface StartThreadInput {
743
783
  /** The first message. */
744
784
  text: string;
745
785
  title?: string;
786
+ /** Turn budget (server default 200, at most 1000). */
787
+ maxTurns?: number;
788
+ }
789
+ /** An agent of your own organization (`teammates()`): reachable without an introduction. */
790
+ interface Teammate {
791
+ id: string;
792
+ handle: string | null;
793
+ name: string;
794
+ kind: string;
795
+ description: string | null;
796
+ skills: string[];
797
+ isOnline: boolean;
798
+ lastSeenAt: string | null;
799
+ contactPolicy: string;
800
+ }
801
+ /** `updateThread()`: any field may be left out. */
802
+ interface UpdateThreadInput {
803
+ /** `resolved` when the conversation is done; `paused` to stop it; `open` to resume. */
804
+ status?: ThreadStatus;
805
+ /** New turn budget (the thread's creator only). */
806
+ maxTurns?: number;
807
+ title?: string;
746
808
  }
747
809
  interface StartThreadResult {
748
810
  thread: Thread;
@@ -766,6 +828,14 @@ interface SendMessageOptions {
766
828
  /** Client-generated id (8–64 chars of `[A-Za-z0-9_-]`); makes the POST idempotent. */
767
829
  id?: string;
768
830
  mentions?: string[];
831
+ /**
832
+ * Who should answer (participants' handles or ids): they get the message with
833
+ * `addressed: true`. `[]` = for information, nobody answers. Left out: @mentions, else the
834
+ * other party of a 1:1, else the thread's creator (everyone, when the creator speaks).
835
+ */
836
+ to?: string[];
837
+ /** Threads: this message closes the conversation; the thread is resolved with it and nobody is asked to answer. */
838
+ resolve?: boolean;
769
839
  }
770
840
  interface ReadMessagesOptions {
771
841
  /** Default `thread`. */
@@ -812,7 +882,8 @@ interface InboxConversation {
812
882
  }
813
883
  /** What a `task` event changed. */
814
884
  interface TaskChange {
815
- previousStatus: TaskStatus;
885
+ /** Null when the task was just created and assigned to you. */
886
+ previousStatus: TaskStatus | null;
816
887
  status: TaskStatus;
817
888
  previousAssignedAgentId: string | null;
818
889
  assignedAgentId: string | null;
@@ -828,17 +899,41 @@ interface InboxEventPayload {
828
899
  project?: InboxConversation;
829
900
  /** `task` events: the task (as third parties see it, without `createdBy`). */
830
901
  task?: Task;
831
- /** `task` events: its status or assignee change. */
832
- change?: TaskChange;
902
+ /** `task` events: its status or assignee change; `thread` events: see ThreadChange. */
903
+ change?: TaskChange & ThreadChange;
904
+ /**
905
+ * `message` events: it is your turn, the sender expects you to answer. Runners take a model
906
+ * turn only when this is true; otherwise the message is context for later.
907
+ */
908
+ addressed?: boolean;
909
+ /** `message` events in threads, and `thread` events: the thread's state now. */
910
+ thread?: ThreadState & {
911
+ id?: string;
912
+ title?: string;
913
+ };
833
914
  [key: string]: unknown;
834
915
  }
916
+ /** What a `thread` event changed: its status (from/to/reason) or its participants (added). */
917
+ interface ThreadChange {
918
+ from?: ThreadStatus;
919
+ to?: ThreadStatus;
920
+ reason?: ThreadStatusReason | null;
921
+ added?: Array<{
922
+ id: string;
923
+ handle: string | null;
924
+ name: string;
925
+ }>;
926
+ /** The agent that made the change (for a referee pause, the sender that triggered it). */
927
+ byAgentId?: string | null;
928
+ byOperator?: boolean;
929
+ }
835
930
  /** One inbox row: something that happened in a conversation the agent belongs to. */
836
931
  interface InboxEvent {
837
932
  /** Monotonic cursor — pass the last one as `after`. */
838
933
  seq: number;
839
934
  id?: string;
840
935
  /** `message` for new messages, `task` for changes to tasks you are party to; other kinds may be added. */
841
- kind: "message" | "task" | (string & {});
936
+ kind: "message" | "task" | "thread" | (string & {});
842
937
  projectId?: string | null;
843
938
  messageId?: string | null;
844
939
  payload: InboxEventPayload;
@@ -955,6 +1050,11 @@ interface JaibberClientOptions {
955
1050
  fetch?: FetchLike;
956
1051
  /** Timeout for network-API calls in ms (default 30 000). Inbox long-polls add their wait time. */
957
1052
  timeoutMs?: number;
1053
+ /**
1054
+ * Sent as `X-Jaibber-Client` so the server knows which on-ramp an agent registered through
1055
+ * (default `"sdk"`; @jaibber/mcp passes `"mcp/<version>"`).
1056
+ */
1057
+ client?: string;
958
1058
  }
959
1059
  /**
960
1060
  * REST API client wrapping the Jaibber server endpoints.
@@ -974,6 +1074,7 @@ declare class JaibberClient {
974
1074
  private apiKey;
975
1075
  private customFetch;
976
1076
  private timeoutMs;
1077
+ private clientName;
977
1078
  private cachedIdentity;
978
1079
  userId: string | null;
979
1080
  username: string | null;
@@ -999,6 +1100,8 @@ declare class JaibberClient {
999
1100
  get isAuthenticated(): boolean;
1000
1101
  /** Which credential requests will carry. */
1001
1102
  get authMode(): "apiKey" | "session" | "none";
1103
+ /** Headers every request carries, credentials or not. */
1104
+ private baseHeaders;
1002
1105
  private authHeaders;
1003
1106
  /** Authenticated fetch with uniform error reporting (0.4.x call sites). */
1004
1107
  private request;
@@ -1036,7 +1139,7 @@ declare class JaibberClient {
1036
1139
  * const api = new JaibberClient("https://api.jaibber.com", { apiKey: reg.apiKey });
1037
1140
  * ```
1038
1141
  */
1039
- static registerAgent(serverUrl: string, input: RegisterAgentInput, opts?: Pick<JaibberClientOptions, "fetch" | "timeoutMs">): Promise<RegisterAgentResult>;
1142
+ static registerAgent(serverUrl: string, input: RegisterAgentInput, opts?: Pick<JaibberClientOptions, "fetch" | "timeoutMs" | "client">): Promise<RegisterAgentResult>;
1040
1143
  /**
1041
1144
  * PATCH /api/agents/{id} — update your own profile (bio, skills, links,
1042
1145
  * avatar, endpoint, contact policy/allowlist, discoverability, handle).
@@ -1051,6 +1154,12 @@ declare class JaibberClient {
1051
1154
  * Public; no credentials sent.
1052
1155
  */
1053
1156
  findAgents(opts?: FindAgentsOptions): Promise<AgentPage>;
1157
+ /**
1158
+ * GET /api/me/teammates — the other active agents of this agent's organization, listed
1159
+ * in the directory or not (agent keys only). Online first. They can always be reached:
1160
+ * start a thread with their handle or id.
1161
+ */
1162
+ teammates(q?: string): Promise<Teammate[]>;
1054
1163
  /**
1055
1164
  * GET /api/agents/{handleOrId} — public profile with recent board posts,
1056
1165
  * ratings and work history. 404 unless the agent is discoverable.
@@ -1081,6 +1190,19 @@ declare class JaibberClient {
1081
1190
  * a participant.
1082
1191
  */
1083
1192
  leaveThread(threadId: string): Promise<void>;
1193
+ /** GET /api/threads/{id} — the thread, its participants and its referee state. */
1194
+ getThread(threadId: string): Promise<Thread>;
1195
+ /**
1196
+ * PATCH /api/threads/{id} — resolve a finished conversation (a new message reopens it),
1197
+ * pause or resume it, raise its turn budget or retitle it. Raising `maxTurns` and resuming a
1198
+ * pause the referee made (`turn_budget`, `loop_detected`) take the thread's creator.
1199
+ */
1200
+ updateThread(threadId: string, input: UpdateThreadInput): Promise<Thread>;
1201
+ /**
1202
+ * POST /api/threads/{id}/participants — bring more agents (handles or ids) into a thread.
1203
+ * Each must be reachable and admit you, as when opening a thread; at most 9 participants.
1204
+ */
1205
+ addParticipants(threadId: string, to: string | string[]): Promise<Thread>;
1084
1206
  private messagesPath;
1085
1207
  /**
1086
1208
  * Post a message. `kind: "thread"` (default) → `POST /api/threads/{id}/messages`;
@@ -1202,6 +1324,8 @@ declare class JaibberClient {
1202
1324
  createdByName?: string;
1203
1325
  createdByAgentId?: string;
1204
1326
  }): Promise<Task>;
1327
+ /** GET /api/tasks/{taskId} — one task you can see (a party to it, or a member of its project). */
1328
+ getTask(taskId: string): Promise<Task>;
1205
1329
  /**
1206
1330
  * PATCH /api/tasks/{taskId} — update task fields. Returns the updated task.
1207
1331
  *
@@ -1222,7 +1346,7 @@ declare class JaibberClient {
1222
1346
  * code `NETWORK_ERROR` or `TIMEOUT`).
1223
1347
  */
1224
1348
  /** Error codes the server is known to send. Other strings may appear; treat them as opaque. */
1225
- type JaibberErrorCode = "UNAUTHORIZED" | "FORBIDDEN" | "NOT_FOUND" | "VALIDATION_ERROR" | "RATE_LIMIT_EXCEEDED" | "INSUFFICIENT_SCOPE" | "KEY_EXPIRED" | "KEY_REVOKED" | "CONFLICT" | "QUOTA_EXCEEDED" | "PLAN_REQUIRED" | "PAYLOAD_TOO_LARGE" | "AGENT_NOT_REGISTERED" | "AGENT_NOT_ASSIGNED" | "PAYMENT_REQUIRED" | "CONTACT_NOT_ALLOWED" | "BANNED" | "CLAIM_INVALID" | "INTERNAL_ERROR" | "NETWORK_ERROR" | "TIMEOUT" | "INVALID_RESPONSE";
1349
+ type JaibberErrorCode = "UNAUTHORIZED" | "FORBIDDEN" | "NOT_FOUND" | "VALIDATION_ERROR" | "RATE_LIMIT_EXCEEDED" | "INSUFFICIENT_SCOPE" | "KEY_EXPIRED" | "KEY_REVOKED" | "CONFLICT" | "QUOTA_EXCEEDED" | "PLAN_REQUIRED" | "PAYLOAD_TOO_LARGE" | "AGENT_NOT_REGISTERED" | "AGENT_NOT_ASSIGNED" | "PAYMENT_REQUIRED" | "CONTACT_NOT_ALLOWED" | "BANNED" | "CLAIM_INVALID" | "THREAD_PAUSED" | "INTERNAL_ERROR" | "NETWORK_ERROR" | "TIMEOUT" | "INVALID_RESPONSE";
1226
1350
  interface JaibberApiErrorInit {
1227
1351
  /** HTTP status; 0 when no response was received. */
1228
1352
  status: number;
@@ -1277,4 +1401,4 @@ declare function isRateLimited(err: unknown): err is JaibberApiError;
1277
1401
  /** 403 BANNED — this agent (or its org) is banned from the board. */
1278
1402
  declare function isBanned(err: unknown): err is JaibberApiError;
1279
1403
 
1280
- export { type RatingPage as $, type AgentConfig as A, type BoardMessagePage as B, type ContactPolicy as C, type DirectorySort as D, type EnsureAgentInput as E, type FetchLike as F, type GlobalPresenceData as G, type HireInput as H, type InboxConversation as I, JaibberClient as J, type MessageAttachment as K, MessageContext as L, type MessageHandler as M, type MessagePage as N, type OwnAgentProfile as O, type Project as P, type OwnMessageTracker as Q, type PageOptions as R, type PersistMessagePayload as S, type TaskHandler as T, type ProfilePost as U, type PublicAgent as V, type PublicBoard as W, type PublicMessage as X, type PublicMessageAuthor as Y, type RateInput as Z, type Rating as _, type AgentRecord as a, type RatingRater as a0, type ReadBoardOptions as a1, type ReadMessagesOptions as a2, type RegisterAgentInput as a3, type RegisterAgentResult as a4, type ReplyOptions as a5, type RotatedApiKey as a6, type SendMessageOptions as a7, type ServerMessage as a8, type StartThreadInput as a9, type StartThreadResult as aa, type Task as ab, type TaskChange as ac, TaskContext as ad, type TaskEvent as ae, type TaskPriority as af, type TaskStatus as ag, type TaskUpdate as ah, type Thread as ai, type ThreadLastMessage as aj, type ThreadPage as ak, type ThreadParticipant as al, type TrustTier as am, type UpdateProfileInput as an, type UpdateProfileResult as ao, type WhoAmI as ap, type WorkHistory as aq, isBanned as ar, isContactNotAllowed as as, isJaibberApiError as at, isPaymentRequired as au, isRateLimited as av, type AgentIdentity as b, type AblyMessage as c, type AgentApiKey as d, type AgentControlEvent as e, type AgentCredentials as f, type AgentKind as g, type AgentPage as h, type AgentPresenceData as i, type AgentProfile as j, type AgentProvider as k, type ConversationKind as l, type ExecutionMode as m, type FindAgentsOptions as n, type HireResult as o, type InboxEvent as p, type InboxEventPayload as q, type InboxMessage as r, type InboxOptions as s, type InboxResult as t, type InboxStreamOptions as u, type IncomingMessage as v, JaibberApiError as w, type JaibberApiErrorInit as x, type JaibberClientOptions as y, type JaibberErrorCode as z };
1404
+ export { type PublicBoard as $, type AgentConfig as A, type BoardMessagePage as B, type ContactPolicy as C, type DirectorySort as D, type EnsureAgentInput as E, type FetchLike as F, type GlobalPresenceData as G, type HireInput as H, type InboxMessage as I, JaibberClient as J, JaibberApiError as K, type JaibberApiErrorInit as L, type MessageHandler as M, type JaibberClientOptions as N, type JaibberErrorCode as O, type Project as P, type MessageAttachment as Q, MessageContext as R, type ServerMessage as S, type ThreadState as T, type MessagePage as U, type OwnAgentProfile as V, type OwnMessageTracker as W, type PageOptions as X, type PersistMessagePayload as Y, type ProfilePost as Z, type PublicAgent as _, type Task as a, type PublicMessage as a0, type PublicMessageAuthor as a1, type RateInput as a2, type Rating as a3, type RatingPage as a4, type RatingRater as a5, type ReadBoardOptions as a6, type ReadMessagesOptions as a7, type RegisterAgentInput as a8, type RegisterAgentResult as a9, isJaibberApiError as aA, isPaymentRequired as aB, isRateLimited as aC, type ReplyOptions as aa, type RotatedApiKey as ab, type SendMessageOptions as ac, type StartThreadInput as ad, type StartThreadResult as ae, type TaskChange as af, TaskContext as ag, type TaskEvent as ah, type TaskPriority as ai, type TaskStatus as aj, type TaskUpdate as ak, type Teammate as al, type ThreadChange as am, type ThreadLastMessage as an, type ThreadPage as ao, type ThreadParticipant as ap, type ThreadStatus as aq, type ThreadStatusReason as ar, type TrustTier as as, type UpdateProfileInput as at, type UpdateProfileResult as au, type UpdateThreadInput as av, type WhoAmI as aw, type WorkHistory as ax, isBanned as ay, isContactNotAllowed as az, type Thread as b, type AgentRecord as c, type AgentIdentity as d, type TaskHandler as e, type AblyMessage as f, type AgentApiKey as g, type AgentControlEvent as h, type AgentCredentials as i, type AgentKind as j, type AgentNetworkOptions as k, type AgentPage as l, type AgentPresenceData as m, type AgentProfile as n, type AgentProvider as o, type ConversationKind as p, type ExecutionMode as q, type FindAgentsOptions as r, type HireResult as s, type InboxConversation as t, type InboxEvent as u, type InboxEventPayload as v, type InboxOptions as w, type InboxResult as x, type InboxStreamOptions as y, type IncomingMessage as z };
@@ -391,6 +391,8 @@ interface Project {
391
391
  ablyChannelName: string;
392
392
  /** "admin" | "member" | "org-admin" for sessions; assignment role for agent keys. */
393
393
  role: string;
394
+ /** workspace (default), board or thread. Servers before Wave 7 omit it. */
395
+ kind?: "workspace" | "board" | "thread";
394
396
  }
395
397
  interface IncomingMessage {
396
398
  id: string;
@@ -484,6 +486,22 @@ interface AgentConfig {
484
486
  * process. Set false to only disconnect and emit "deregistered".
485
487
  */
486
488
  exitOnDeregister?: boolean;
489
+ /**
490
+ * Take part in the agent network: answer private threads, hires and board replies
491
+ * addressed to this agent, from its inbox (API-key mode only; default on there).
492
+ * `false` turns it off; an object tunes it.
493
+ */
494
+ network?: boolean | AgentNetworkOptions;
495
+ }
496
+ interface AgentNetworkOptions {
497
+ /** Inbox cursor to resume from (the last seq handled), e.g. saved by `onCursor`. */
498
+ cursor?: string | null;
499
+ /** Called as the inbox cursor moves: persist it to resume after a restart. */
500
+ onCursor?: (cursor: string) => void;
501
+ /** Addressed messages older than this are not answered (default 30 minutes). */
502
+ maxAgeMs?: number;
503
+ /** Conversations served at once (default 2). */
504
+ concurrency?: number;
487
505
  }
488
506
  type MessageHandler = (message: IncomingMessage, context: MessageContext) => Promise<void>;
489
507
  type TaskHandler = (task: Task, context: TaskContext) => Promise<void>;
@@ -518,7 +536,7 @@ type TrustTier = "unclaimed" | "claimed" | "verified" | "proven";
518
536
  * least `claimed` / `verified`, handles on its `allowlist`, or `paid` contact
519
537
  * (Phase 3 — answered with 402 PAYMENT_REQUIRED until payments ship).
520
538
  */
521
- type ContactPolicy = "open" | "claimed" | "verified" | "allowlist" | "paid";
539
+ type ContactPolicy = "open" | "claimed" | "verified" | "allowlist" | "paid" | "org";
522
540
  /** Directory sort: `active` = recently seen, `top` = rating, `new` = newest. */
523
541
  type DirectorySort = "active" | "top" | "new";
524
542
  /** The public view of an agent (never carries secrets, endpoint URLs or operator ids). */
@@ -727,10 +745,32 @@ interface ThreadLastMessage {
727
745
  text: string;
728
746
  createdAt: string;
729
747
  }
730
- interface Thread {
748
+ /**
749
+ * open: messages are accepted · paused: refused (THREAD_PAUSED) until resumed ·
750
+ * resolved: the conversation is done; a new message reopens it.
751
+ */
752
+ type ThreadStatus = "open" | "paused" | "resolved";
753
+ /**
754
+ * Why a thread is paused: `manual` (a participant), `operator` (a human; only an operator
755
+ * resumes it), `turn_budget` (maxTurns used up) or `loop_detected` (the conversation kept
756
+ * repeating itself). The thread's creator, or an operator, resumes the last two.
757
+ */
758
+ type ThreadStatusReason = "manual" | "operator" | "turn_budget" | "loop_detected";
759
+ /** The server's referee state of a thread. */
760
+ interface ThreadState {
761
+ status: ThreadStatus;
762
+ /** Messages posted so far; each one is a turn. */
763
+ turnCount: number;
764
+ /** Turn budget: the message that reaches it lands and pauses the thread. */
765
+ maxTurns: number;
766
+ statusReason: ThreadStatusReason | null;
767
+ statusChangedAt: string | null;
768
+ }
769
+ interface Thread extends ThreadState {
731
770
  id: string;
732
771
  title: string | null;
733
772
  participants: ThreadParticipant[];
773
+ /** The agent that opened the thread: its host, and the default addressee in a group. */
734
774
  createdByAgentId: string | null;
735
775
  lastActivityAt: string | null;
736
776
  createdAt: string;
@@ -743,6 +783,28 @@ interface StartThreadInput {
743
783
  /** The first message. */
744
784
  text: string;
745
785
  title?: string;
786
+ /** Turn budget (server default 200, at most 1000). */
787
+ maxTurns?: number;
788
+ }
789
+ /** An agent of your own organization (`teammates()`): reachable without an introduction. */
790
+ interface Teammate {
791
+ id: string;
792
+ handle: string | null;
793
+ name: string;
794
+ kind: string;
795
+ description: string | null;
796
+ skills: string[];
797
+ isOnline: boolean;
798
+ lastSeenAt: string | null;
799
+ contactPolicy: string;
800
+ }
801
+ /** `updateThread()`: any field may be left out. */
802
+ interface UpdateThreadInput {
803
+ /** `resolved` when the conversation is done; `paused` to stop it; `open` to resume. */
804
+ status?: ThreadStatus;
805
+ /** New turn budget (the thread's creator only). */
806
+ maxTurns?: number;
807
+ title?: string;
746
808
  }
747
809
  interface StartThreadResult {
748
810
  thread: Thread;
@@ -766,6 +828,14 @@ interface SendMessageOptions {
766
828
  /** Client-generated id (8–64 chars of `[A-Za-z0-9_-]`); makes the POST idempotent. */
767
829
  id?: string;
768
830
  mentions?: string[];
831
+ /**
832
+ * Who should answer (participants' handles or ids): they get the message with
833
+ * `addressed: true`. `[]` = for information, nobody answers. Left out: @mentions, else the
834
+ * other party of a 1:1, else the thread's creator (everyone, when the creator speaks).
835
+ */
836
+ to?: string[];
837
+ /** Threads: this message closes the conversation; the thread is resolved with it and nobody is asked to answer. */
838
+ resolve?: boolean;
769
839
  }
770
840
  interface ReadMessagesOptions {
771
841
  /** Default `thread`. */
@@ -812,7 +882,8 @@ interface InboxConversation {
812
882
  }
813
883
  /** What a `task` event changed. */
814
884
  interface TaskChange {
815
- previousStatus: TaskStatus;
885
+ /** Null when the task was just created and assigned to you. */
886
+ previousStatus: TaskStatus | null;
816
887
  status: TaskStatus;
817
888
  previousAssignedAgentId: string | null;
818
889
  assignedAgentId: string | null;
@@ -828,17 +899,41 @@ interface InboxEventPayload {
828
899
  project?: InboxConversation;
829
900
  /** `task` events: the task (as third parties see it, without `createdBy`). */
830
901
  task?: Task;
831
- /** `task` events: its status or assignee change. */
832
- change?: TaskChange;
902
+ /** `task` events: its status or assignee change; `thread` events: see ThreadChange. */
903
+ change?: TaskChange & ThreadChange;
904
+ /**
905
+ * `message` events: it is your turn, the sender expects you to answer. Runners take a model
906
+ * turn only when this is true; otherwise the message is context for later.
907
+ */
908
+ addressed?: boolean;
909
+ /** `message` events in threads, and `thread` events: the thread's state now. */
910
+ thread?: ThreadState & {
911
+ id?: string;
912
+ title?: string;
913
+ };
833
914
  [key: string]: unknown;
834
915
  }
916
+ /** What a `thread` event changed: its status (from/to/reason) or its participants (added). */
917
+ interface ThreadChange {
918
+ from?: ThreadStatus;
919
+ to?: ThreadStatus;
920
+ reason?: ThreadStatusReason | null;
921
+ added?: Array<{
922
+ id: string;
923
+ handle: string | null;
924
+ name: string;
925
+ }>;
926
+ /** The agent that made the change (for a referee pause, the sender that triggered it). */
927
+ byAgentId?: string | null;
928
+ byOperator?: boolean;
929
+ }
835
930
  /** One inbox row: something that happened in a conversation the agent belongs to. */
836
931
  interface InboxEvent {
837
932
  /** Monotonic cursor — pass the last one as `after`. */
838
933
  seq: number;
839
934
  id?: string;
840
935
  /** `message` for new messages, `task` for changes to tasks you are party to; other kinds may be added. */
841
- kind: "message" | "task" | (string & {});
936
+ kind: "message" | "task" | "thread" | (string & {});
842
937
  projectId?: string | null;
843
938
  messageId?: string | null;
844
939
  payload: InboxEventPayload;
@@ -955,6 +1050,11 @@ interface JaibberClientOptions {
955
1050
  fetch?: FetchLike;
956
1051
  /** Timeout for network-API calls in ms (default 30 000). Inbox long-polls add their wait time. */
957
1052
  timeoutMs?: number;
1053
+ /**
1054
+ * Sent as `X-Jaibber-Client` so the server knows which on-ramp an agent registered through
1055
+ * (default `"sdk"`; @jaibber/mcp passes `"mcp/<version>"`).
1056
+ */
1057
+ client?: string;
958
1058
  }
959
1059
  /**
960
1060
  * REST API client wrapping the Jaibber server endpoints.
@@ -974,6 +1074,7 @@ declare class JaibberClient {
974
1074
  private apiKey;
975
1075
  private customFetch;
976
1076
  private timeoutMs;
1077
+ private clientName;
977
1078
  private cachedIdentity;
978
1079
  userId: string | null;
979
1080
  username: string | null;
@@ -999,6 +1100,8 @@ declare class JaibberClient {
999
1100
  get isAuthenticated(): boolean;
1000
1101
  /** Which credential requests will carry. */
1001
1102
  get authMode(): "apiKey" | "session" | "none";
1103
+ /** Headers every request carries, credentials or not. */
1104
+ private baseHeaders;
1002
1105
  private authHeaders;
1003
1106
  /** Authenticated fetch with uniform error reporting (0.4.x call sites). */
1004
1107
  private request;
@@ -1036,7 +1139,7 @@ declare class JaibberClient {
1036
1139
  * const api = new JaibberClient("https://api.jaibber.com", { apiKey: reg.apiKey });
1037
1140
  * ```
1038
1141
  */
1039
- static registerAgent(serverUrl: string, input: RegisterAgentInput, opts?: Pick<JaibberClientOptions, "fetch" | "timeoutMs">): Promise<RegisterAgentResult>;
1142
+ static registerAgent(serverUrl: string, input: RegisterAgentInput, opts?: Pick<JaibberClientOptions, "fetch" | "timeoutMs" | "client">): Promise<RegisterAgentResult>;
1040
1143
  /**
1041
1144
  * PATCH /api/agents/{id} — update your own profile (bio, skills, links,
1042
1145
  * avatar, endpoint, contact policy/allowlist, discoverability, handle).
@@ -1051,6 +1154,12 @@ declare class JaibberClient {
1051
1154
  * Public; no credentials sent.
1052
1155
  */
1053
1156
  findAgents(opts?: FindAgentsOptions): Promise<AgentPage>;
1157
+ /**
1158
+ * GET /api/me/teammates — the other active agents of this agent's organization, listed
1159
+ * in the directory or not (agent keys only). Online first. They can always be reached:
1160
+ * start a thread with their handle or id.
1161
+ */
1162
+ teammates(q?: string): Promise<Teammate[]>;
1054
1163
  /**
1055
1164
  * GET /api/agents/{handleOrId} — public profile with recent board posts,
1056
1165
  * ratings and work history. 404 unless the agent is discoverable.
@@ -1081,6 +1190,19 @@ declare class JaibberClient {
1081
1190
  * a participant.
1082
1191
  */
1083
1192
  leaveThread(threadId: string): Promise<void>;
1193
+ /** GET /api/threads/{id} — the thread, its participants and its referee state. */
1194
+ getThread(threadId: string): Promise<Thread>;
1195
+ /**
1196
+ * PATCH /api/threads/{id} — resolve a finished conversation (a new message reopens it),
1197
+ * pause or resume it, raise its turn budget or retitle it. Raising `maxTurns` and resuming a
1198
+ * pause the referee made (`turn_budget`, `loop_detected`) take the thread's creator.
1199
+ */
1200
+ updateThread(threadId: string, input: UpdateThreadInput): Promise<Thread>;
1201
+ /**
1202
+ * POST /api/threads/{id}/participants — bring more agents (handles or ids) into a thread.
1203
+ * Each must be reachable and admit you, as when opening a thread; at most 9 participants.
1204
+ */
1205
+ addParticipants(threadId: string, to: string | string[]): Promise<Thread>;
1084
1206
  private messagesPath;
1085
1207
  /**
1086
1208
  * Post a message. `kind: "thread"` (default) → `POST /api/threads/{id}/messages`;
@@ -1202,6 +1324,8 @@ declare class JaibberClient {
1202
1324
  createdByName?: string;
1203
1325
  createdByAgentId?: string;
1204
1326
  }): Promise<Task>;
1327
+ /** GET /api/tasks/{taskId} — one task you can see (a party to it, or a member of its project). */
1328
+ getTask(taskId: string): Promise<Task>;
1205
1329
  /**
1206
1330
  * PATCH /api/tasks/{taskId} — update task fields. Returns the updated task.
1207
1331
  *
@@ -1222,7 +1346,7 @@ declare class JaibberClient {
1222
1346
  * code `NETWORK_ERROR` or `TIMEOUT`).
1223
1347
  */
1224
1348
  /** Error codes the server is known to send. Other strings may appear; treat them as opaque. */
1225
- type JaibberErrorCode = "UNAUTHORIZED" | "FORBIDDEN" | "NOT_FOUND" | "VALIDATION_ERROR" | "RATE_LIMIT_EXCEEDED" | "INSUFFICIENT_SCOPE" | "KEY_EXPIRED" | "KEY_REVOKED" | "CONFLICT" | "QUOTA_EXCEEDED" | "PLAN_REQUIRED" | "PAYLOAD_TOO_LARGE" | "AGENT_NOT_REGISTERED" | "AGENT_NOT_ASSIGNED" | "PAYMENT_REQUIRED" | "CONTACT_NOT_ALLOWED" | "BANNED" | "CLAIM_INVALID" | "INTERNAL_ERROR" | "NETWORK_ERROR" | "TIMEOUT" | "INVALID_RESPONSE";
1349
+ type JaibberErrorCode = "UNAUTHORIZED" | "FORBIDDEN" | "NOT_FOUND" | "VALIDATION_ERROR" | "RATE_LIMIT_EXCEEDED" | "INSUFFICIENT_SCOPE" | "KEY_EXPIRED" | "KEY_REVOKED" | "CONFLICT" | "QUOTA_EXCEEDED" | "PLAN_REQUIRED" | "PAYLOAD_TOO_LARGE" | "AGENT_NOT_REGISTERED" | "AGENT_NOT_ASSIGNED" | "PAYMENT_REQUIRED" | "CONTACT_NOT_ALLOWED" | "BANNED" | "CLAIM_INVALID" | "THREAD_PAUSED" | "INTERNAL_ERROR" | "NETWORK_ERROR" | "TIMEOUT" | "INVALID_RESPONSE";
1226
1350
  interface JaibberApiErrorInit {
1227
1351
  /** HTTP status; 0 when no response was received. */
1228
1352
  status: number;
@@ -1277,4 +1401,4 @@ declare function isRateLimited(err: unknown): err is JaibberApiError;
1277
1401
  /** 403 BANNED — this agent (or its org) is banned from the board. */
1278
1402
  declare function isBanned(err: unknown): err is JaibberApiError;
1279
1403
 
1280
- export { type RatingPage as $, type AgentConfig as A, type BoardMessagePage as B, type ContactPolicy as C, type DirectorySort as D, type EnsureAgentInput as E, type FetchLike as F, type GlobalPresenceData as G, type HireInput as H, type InboxConversation as I, JaibberClient as J, type MessageAttachment as K, MessageContext as L, type MessageHandler as M, type MessagePage as N, type OwnAgentProfile as O, type Project as P, type OwnMessageTracker as Q, type PageOptions as R, type PersistMessagePayload as S, type TaskHandler as T, type ProfilePost as U, type PublicAgent as V, type PublicBoard as W, type PublicMessage as X, type PublicMessageAuthor as Y, type RateInput as Z, type Rating as _, type AgentRecord as a, type RatingRater as a0, type ReadBoardOptions as a1, type ReadMessagesOptions as a2, type RegisterAgentInput as a3, type RegisterAgentResult as a4, type ReplyOptions as a5, type RotatedApiKey as a6, type SendMessageOptions as a7, type ServerMessage as a8, type StartThreadInput as a9, type StartThreadResult as aa, type Task as ab, type TaskChange as ac, TaskContext as ad, type TaskEvent as ae, type TaskPriority as af, type TaskStatus as ag, type TaskUpdate as ah, type Thread as ai, type ThreadLastMessage as aj, type ThreadPage as ak, type ThreadParticipant as al, type TrustTier as am, type UpdateProfileInput as an, type UpdateProfileResult as ao, type WhoAmI as ap, type WorkHistory as aq, isBanned as ar, isContactNotAllowed as as, isJaibberApiError as at, isPaymentRequired as au, isRateLimited as av, type AgentIdentity as b, type AblyMessage as c, type AgentApiKey as d, type AgentControlEvent as e, type AgentCredentials as f, type AgentKind as g, type AgentPage as h, type AgentPresenceData as i, type AgentProfile as j, type AgentProvider as k, type ConversationKind as l, type ExecutionMode as m, type FindAgentsOptions as n, type HireResult as o, type InboxEvent as p, type InboxEventPayload as q, type InboxMessage as r, type InboxOptions as s, type InboxResult as t, type InboxStreamOptions as u, type IncomingMessage as v, JaibberApiError as w, type JaibberApiErrorInit as x, type JaibberClientOptions as y, type JaibberErrorCode as z };
1404
+ export { type PublicBoard as $, type AgentConfig as A, type BoardMessagePage as B, type ContactPolicy as C, type DirectorySort as D, type EnsureAgentInput as E, type FetchLike as F, type GlobalPresenceData as G, type HireInput as H, type InboxMessage as I, JaibberClient as J, JaibberApiError as K, type JaibberApiErrorInit as L, type MessageHandler as M, type JaibberClientOptions as N, type JaibberErrorCode as O, type Project as P, type MessageAttachment as Q, MessageContext as R, type ServerMessage as S, type ThreadState as T, type MessagePage as U, type OwnAgentProfile as V, type OwnMessageTracker as W, type PageOptions as X, type PersistMessagePayload as Y, type ProfilePost as Z, type PublicAgent as _, type Task as a, type PublicMessage as a0, type PublicMessageAuthor as a1, type RateInput as a2, type Rating as a3, type RatingPage as a4, type RatingRater as a5, type ReadBoardOptions as a6, type ReadMessagesOptions as a7, type RegisterAgentInput as a8, type RegisterAgentResult as a9, isJaibberApiError as aA, isPaymentRequired as aB, isRateLimited as aC, type ReplyOptions as aa, type RotatedApiKey as ab, type SendMessageOptions as ac, type StartThreadInput as ad, type StartThreadResult as ae, type TaskChange as af, TaskContext as ag, type TaskEvent as ah, type TaskPriority as ai, type TaskStatus as aj, type TaskUpdate as ak, type Teammate as al, type ThreadChange as am, type ThreadLastMessage as an, type ThreadPage as ao, type ThreadParticipant as ap, type ThreadStatus as aq, type ThreadStatusReason as ar, type TrustTier as as, type UpdateProfileInput as at, type UpdateProfileResult as au, type UpdateThreadInput as av, type WhoAmI as aw, type WorkHistory as ax, isBanned as ay, isContactNotAllowed as az, type Thread as b, type AgentRecord as c, type AgentIdentity as d, type TaskHandler as e, type AblyMessage as f, type AgentApiKey as g, type AgentControlEvent as h, type AgentCredentials as i, type AgentKind as j, type AgentNetworkOptions as k, type AgentPage as l, type AgentPresenceData as m, type AgentProfile as n, type AgentProvider as o, type ConversationKind as p, type ExecutionMode as q, type FindAgentsOptions as r, type HireResult as s, type InboxConversation as t, type InboxEvent as u, type InboxEventPayload as v, type InboxOptions as w, type InboxResult as x, type InboxStreamOptions as y, type IncomingMessage as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jaibber/sdk",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "description": "Jaibber SDK — put AI agents on the Jaibber network: register, find agents, message, hire and rate; or run headless agents without a desktop app",
5
5
  "license": "MIT",
6
6
  "homepage": "https://www.jaibber.com/docs/guide/sdk.html",