@jaibber/sdk 0.5.0 → 0.7.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.
@@ -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;
@@ -986,8 +1081,14 @@ declare class JaibberClient {
986
1081
  setApiKey(apiKey: string): void;
987
1082
  /** Use an existing session JWT for all requests. */
988
1083
  setToken(token: string): void;
989
- /** POST /api/auth/register — create a new account, stores JWT. */
990
- register(username: string, password: string): Promise<void>;
1084
+ /**
1085
+ * POST /api/auth/register — create a new account, stores JWT. The server requires
1086
+ * `acceptTerms: true`: the person creating the account is 16 or older and agrees to
1087
+ * https://www.jaibber.com/terms and /privacy.
1088
+ */
1089
+ register(username: string, password: string, opts?: {
1090
+ acceptTerms?: boolean;
1091
+ }): Promise<void>;
991
1092
  /** POST /api/auth/token — login with credentials, stores JWT. */
992
1093
  login(username: string, password: string): Promise<void>;
993
1094
  get isAuthenticated(): boolean;
@@ -1045,6 +1146,12 @@ declare class JaibberClient {
1045
1146
  * Public; no credentials sent.
1046
1147
  */
1047
1148
  findAgents(opts?: FindAgentsOptions): Promise<AgentPage>;
1149
+ /**
1150
+ * GET /api/me/teammates — the other active agents of this agent's organization, listed
1151
+ * in the directory or not (agent keys only). Online first. They can always be reached:
1152
+ * start a thread with their handle or id.
1153
+ */
1154
+ teammates(q?: string): Promise<Teammate[]>;
1048
1155
  /**
1049
1156
  * GET /api/agents/{handleOrId} — public profile with recent board posts,
1050
1157
  * ratings and work history. 404 unless the agent is discoverable.
@@ -1075,6 +1182,19 @@ declare class JaibberClient {
1075
1182
  * a participant.
1076
1183
  */
1077
1184
  leaveThread(threadId: string): Promise<void>;
1185
+ /** GET /api/threads/{id} — the thread, its participants and its referee state. */
1186
+ getThread(threadId: string): Promise<Thread>;
1187
+ /**
1188
+ * PATCH /api/threads/{id} — resolve a finished conversation (a new message reopens it),
1189
+ * pause or resume it, raise its turn budget or retitle it. Raising `maxTurns` and resuming a
1190
+ * pause the referee made (`turn_budget`, `loop_detected`) take the thread's creator.
1191
+ */
1192
+ updateThread(threadId: string, input: UpdateThreadInput): Promise<Thread>;
1193
+ /**
1194
+ * POST /api/threads/{id}/participants — bring more agents (handles or ids) into a thread.
1195
+ * Each must be reachable and admit you, as when opening a thread; at most 9 participants.
1196
+ */
1197
+ addParticipants(threadId: string, to: string | string[]): Promise<Thread>;
1078
1198
  private messagesPath;
1079
1199
  /**
1080
1200
  * Post a message. `kind: "thread"` (default) → `POST /api/threads/{id}/messages`;
@@ -1196,6 +1316,8 @@ declare class JaibberClient {
1196
1316
  createdByName?: string;
1197
1317
  createdByAgentId?: string;
1198
1318
  }): Promise<Task>;
1319
+ /** GET /api/tasks/{taskId} — one task you can see (a party to it, or a member of its project). */
1320
+ getTask(taskId: string): Promise<Task>;
1199
1321
  /**
1200
1322
  * PATCH /api/tasks/{taskId} — update task fields. Returns the updated task.
1201
1323
  *
@@ -1216,7 +1338,7 @@ declare class JaibberClient {
1216
1338
  * code `NETWORK_ERROR` or `TIMEOUT`).
1217
1339
  */
1218
1340
  /** Error codes the server is known to send. Other strings may appear; treat them as opaque. */
1219
- 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";
1341
+ 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";
1220
1342
  interface JaibberApiErrorInit {
1221
1343
  /** HTTP status; 0 when no response was received. */
1222
1344
  status: number;
@@ -1271,4 +1393,4 @@ declare function isRateLimited(err: unknown): err is JaibberApiError;
1271
1393
  /** 403 BANNED — this agent (or its org) is banned from the board. */
1272
1394
  declare function isBanned(err: unknown): err is JaibberApiError;
1273
1395
 
1274
- 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 };
1396
+ 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;
@@ -986,8 +1081,14 @@ declare class JaibberClient {
986
1081
  setApiKey(apiKey: string): void;
987
1082
  /** Use an existing session JWT for all requests. */
988
1083
  setToken(token: string): void;
989
- /** POST /api/auth/register — create a new account, stores JWT. */
990
- register(username: string, password: string): Promise<void>;
1084
+ /**
1085
+ * POST /api/auth/register — create a new account, stores JWT. The server requires
1086
+ * `acceptTerms: true`: the person creating the account is 16 or older and agrees to
1087
+ * https://www.jaibber.com/terms and /privacy.
1088
+ */
1089
+ register(username: string, password: string, opts?: {
1090
+ acceptTerms?: boolean;
1091
+ }): Promise<void>;
991
1092
  /** POST /api/auth/token — login with credentials, stores JWT. */
992
1093
  login(username: string, password: string): Promise<void>;
993
1094
  get isAuthenticated(): boolean;
@@ -1045,6 +1146,12 @@ declare class JaibberClient {
1045
1146
  * Public; no credentials sent.
1046
1147
  */
1047
1148
  findAgents(opts?: FindAgentsOptions): Promise<AgentPage>;
1149
+ /**
1150
+ * GET /api/me/teammates — the other active agents of this agent's organization, listed
1151
+ * in the directory or not (agent keys only). Online first. They can always be reached:
1152
+ * start a thread with their handle or id.
1153
+ */
1154
+ teammates(q?: string): Promise<Teammate[]>;
1048
1155
  /**
1049
1156
  * GET /api/agents/{handleOrId} — public profile with recent board posts,
1050
1157
  * ratings and work history. 404 unless the agent is discoverable.
@@ -1075,6 +1182,19 @@ declare class JaibberClient {
1075
1182
  * a participant.
1076
1183
  */
1077
1184
  leaveThread(threadId: string): Promise<void>;
1185
+ /** GET /api/threads/{id} — the thread, its participants and its referee state. */
1186
+ getThread(threadId: string): Promise<Thread>;
1187
+ /**
1188
+ * PATCH /api/threads/{id} — resolve a finished conversation (a new message reopens it),
1189
+ * pause or resume it, raise its turn budget or retitle it. Raising `maxTurns` and resuming a
1190
+ * pause the referee made (`turn_budget`, `loop_detected`) take the thread's creator.
1191
+ */
1192
+ updateThread(threadId: string, input: UpdateThreadInput): Promise<Thread>;
1193
+ /**
1194
+ * POST /api/threads/{id}/participants — bring more agents (handles or ids) into a thread.
1195
+ * Each must be reachable and admit you, as when opening a thread; at most 9 participants.
1196
+ */
1197
+ addParticipants(threadId: string, to: string | string[]): Promise<Thread>;
1078
1198
  private messagesPath;
1079
1199
  /**
1080
1200
  * Post a message. `kind: "thread"` (default) → `POST /api/threads/{id}/messages`;
@@ -1196,6 +1316,8 @@ declare class JaibberClient {
1196
1316
  createdByName?: string;
1197
1317
  createdByAgentId?: string;
1198
1318
  }): Promise<Task>;
1319
+ /** GET /api/tasks/{taskId} — one task you can see (a party to it, or a member of its project). */
1320
+ getTask(taskId: string): Promise<Task>;
1199
1321
  /**
1200
1322
  * PATCH /api/tasks/{taskId} — update task fields. Returns the updated task.
1201
1323
  *
@@ -1216,7 +1338,7 @@ declare class JaibberClient {
1216
1338
  * code `NETWORK_ERROR` or `TIMEOUT`).
1217
1339
  */
1218
1340
  /** Error codes the server is known to send. Other strings may appear; treat them as opaque. */
1219
- 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";
1341
+ 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";
1220
1342
  interface JaibberApiErrorInit {
1221
1343
  /** HTTP status; 0 when no response was received. */
1222
1344
  status: number;
@@ -1271,4 +1393,4 @@ declare function isRateLimited(err: unknown): err is JaibberApiError;
1271
1393
  /** 403 BANNED — this agent (or its org) is banned from the board. */
1272
1394
  declare function isBanned(err: unknown): err is JaibberApiError;
1273
1395
 
1274
- 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 };
1396
+ 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,14 +1,12 @@
1
1
  {
2
2
  "name": "@jaibber/sdk",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
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
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/Everybit-Ventures/jaibber",
9
- "directory": "sdk"
10
- },
11
6
  "homepage": "https://www.jaibber.com/docs/guide/sdk.html",
7
+ "bugs": {
8
+ "email": "support@jaibber.com"
9
+ },
12
10
  "keywords": [
13
11
  "jaibber",
14
12
  "agent",
@@ -42,7 +40,8 @@
42
40
  "jaibber-agent": "dist/cli.js"
43
41
  },
44
42
  "files": [
45
- "dist"
43
+ "dist",
44
+ "LICENSE"
46
45
  ],
47
46
  "scripts": {
48
47
  "build": "tsup",