@jaibber/sdk 0.4.1 → 0.5.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/README.md +198 -8
- package/dist/cli.js +1043 -63
- package/dist/client.cjs +1054 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +1 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +1021 -0
- package/dist/client.js.map +1 -0
- package/dist/index.cjs +753 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -600
- package/dist/index.d.ts +3 -600
- package/dist/index.js +744 -53
- package/dist/index.js.map +1 -1
- package/dist/rest-M7dEtPCT.d.cts +1274 -0
- package/dist/rest-M7dEtPCT.d.ts +1274 -0
- package/package.json +14 -5
package/dist/index.d.cts
CHANGED
|
@@ -1,603 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
interface AgentPresenceData {
|
|
5
|
-
/** Hosting user id (absent in API-key mode). */
|
|
6
|
-
userId?: string;
|
|
7
|
-
username: string;
|
|
8
|
-
isAgent: boolean;
|
|
9
|
-
agentName: string;
|
|
10
|
-
/** The agent's server-side id. */
|
|
11
|
-
agentId?: string;
|
|
12
|
-
agentInstructions?: string;
|
|
13
|
-
agents?: Array<{
|
|
14
|
-
agentId?: string;
|
|
15
|
-
agentName: string;
|
|
16
|
-
agentInstructions?: string;
|
|
17
|
-
}>;
|
|
18
|
-
machineName?: string;
|
|
19
|
-
}
|
|
20
|
-
/** Presence data entered on the global `jaibber:presence` channel. */
|
|
21
|
-
interface GlobalPresenceData {
|
|
22
|
-
userId?: string;
|
|
23
|
-
agentId?: string;
|
|
24
|
-
username: string;
|
|
25
|
-
projectIds: string[];
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Manages the Ably Realtime connection, channel subscriptions, and presence.
|
|
29
|
-
* Node.js equivalent of the frontend's src/lib/ably.ts + useAbly.ts subscription logic.
|
|
30
|
-
*/
|
|
31
|
-
declare class AblyManager {
|
|
32
|
-
private client;
|
|
33
|
-
private opts;
|
|
34
|
-
private ably;
|
|
35
|
-
private channels;
|
|
36
|
-
private presenceChannel;
|
|
37
|
-
constructor(client: JaibberClient, opts: {
|
|
38
|
-
/**
|
|
39
|
-
* Explicit Ably clientId. Session mode passes the userId (the token's
|
|
40
|
-
* clientId). API-key mode leaves it unset so the connection adopts the
|
|
41
|
-
* token's clientId (`agent:{agentId}`).
|
|
42
|
-
*/
|
|
43
|
-
clientId?: string;
|
|
44
|
-
username: string;
|
|
45
|
-
});
|
|
46
|
-
/** Create Ably Realtime client with token auth callback. */
|
|
47
|
-
connect(timeoutMs?: number): Promise<void>;
|
|
48
|
-
/** Enter global presence channel (jaibber:presence). */
|
|
49
|
-
enterGlobalPresence(data: GlobalPresenceData): Promise<void>;
|
|
50
|
-
/**
|
|
51
|
-
* Subscribe to a project channel (`message`, `task` and server-published
|
|
52
|
-
* `agent-control` events) and enter per-project presence.
|
|
53
|
-
* Returns an unsubscribe function.
|
|
54
|
-
*/
|
|
55
|
-
subscribeToProject(project: Project, presenceData: AgentPresenceData, onMessage: (msg: AblyMessage) => void | Promise<void>, onTask: (data: TaskEvent) => void | Promise<void>, onControl?: (data: AgentControlEvent) => void | Promise<void>, onError?: (err: unknown, event: string) => void): Promise<() => void>;
|
|
56
|
-
/**
|
|
57
|
-
* Publish a client-side event on a project channel. Only `typing` and
|
|
58
|
-
* `chunk` are client-published; final messages go through the REST API
|
|
59
|
-
* and are echoed by the server.
|
|
60
|
-
*/
|
|
61
|
-
publish(channelName: string, eventName: string, data: AblyMessage): Promise<void>;
|
|
62
|
-
/** Get the Ably connection ID (used for skip logic). */
|
|
63
|
-
get connectionId(): string | undefined;
|
|
64
|
-
/** The clientId this connection authenticated as (from the token in API-key mode). */
|
|
65
|
-
get clientId(): string | undefined;
|
|
66
|
-
/** Leave presence on all channels and close the connection. */
|
|
67
|
-
disconnect(): Promise<void>;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
type PostedType = "message" | "response" | "error";
|
|
71
|
-
/**
|
|
72
|
-
* Lets the owning agent learn about messages this context POSTs, so it can
|
|
73
|
-
* (a) dedupe the server's Ably echo by message id and (b) feed the agent's own
|
|
74
|
-
* replies back into conversation history.
|
|
75
|
-
*/
|
|
76
|
-
interface OwnMessageTracker {
|
|
77
|
-
/** Called with the client-generated id right before the POST. */
|
|
78
|
-
begin(id: string, projectId: string, text: string, type: PostedType, parentMessageId?: string): void;
|
|
79
|
-
/** Called after the server accepted the message. */
|
|
80
|
-
posted(id: string): void;
|
|
81
|
-
/** Called when the POST failed (the message never existed server-side). */
|
|
82
|
-
failed(id: string): void;
|
|
83
|
-
}
|
|
84
|
-
interface ReplyOptions {
|
|
85
|
-
/**
|
|
86
|
-
* Thread the reply under this message id. Replies default to the message
|
|
87
|
-
* being answered — that link is how agent-to-agent chains are tracked.
|
|
88
|
-
*/
|
|
89
|
-
parentMessageId?: string;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Context passed to message handlers.
|
|
93
|
-
* Provides `reply()` for one-shot responses and `stream()` for streaming.
|
|
94
|
-
*
|
|
95
|
-
* Protocol: `typing` and `chunk` events are published to Ably by the client;
|
|
96
|
-
* the final message is POSTed to the server, which persists it, attributes it
|
|
97
|
-
* to the agent, and publishes the echo to Ably itself.
|
|
98
|
-
*/
|
|
99
|
-
declare class MessageContext {
|
|
100
|
-
/** Formatted conversation history for LLM prompts. */
|
|
101
|
-
readonly conversationHistory: string;
|
|
102
|
-
/** The project ID this message was received on. */
|
|
103
|
-
readonly projectId: string;
|
|
104
|
-
/** The agent's server-side id (sent as `agentId` on every save). */
|
|
105
|
-
readonly agentId: string;
|
|
106
|
-
/** The agent's display name. */
|
|
107
|
-
readonly agentName: string;
|
|
108
|
-
/** Id of the message being responded to (if any). */
|
|
109
|
-
readonly incomingMessageId?: string;
|
|
110
|
-
/**
|
|
111
|
-
* The id the final reply will be stored under. Also the `responseId` sent
|
|
112
|
-
* with `typing` so clients can pre-create the bubble.
|
|
113
|
-
*/
|
|
114
|
-
readonly messageId: string;
|
|
115
|
-
private ablyManager;
|
|
116
|
-
private channelName;
|
|
117
|
-
private from;
|
|
118
|
-
private client;
|
|
119
|
-
private responseDepth;
|
|
120
|
-
private respondingChain;
|
|
121
|
-
private chunkBatchMs;
|
|
122
|
-
private tracker?;
|
|
123
|
-
/** Set by `stream()` when its generator threw. */
|
|
124
|
-
private streamError;
|
|
125
|
-
constructor(opts: {
|
|
126
|
-
projectId: string;
|
|
127
|
-
channelName: string;
|
|
128
|
-
conversationHistory: string;
|
|
129
|
-
ablyManager: AblyManager;
|
|
130
|
-
/** Sender id for client-published events (userId, or `agent:{id}` in API-key mode). */
|
|
131
|
-
from: string;
|
|
132
|
-
agentId: string;
|
|
133
|
-
agentName: string;
|
|
134
|
-
client: JaibberClient;
|
|
135
|
-
incomingMessageId?: string;
|
|
136
|
-
incomingDepth: number;
|
|
137
|
-
incomingChain: string[];
|
|
138
|
-
chunkBatchMs: number;
|
|
139
|
-
tracker?: OwnMessageTracker;
|
|
140
|
-
});
|
|
141
|
-
/** Agent-to-agent hop count this reply will carry (informational). */
|
|
142
|
-
get depth(): number;
|
|
143
|
-
/** Agents that have already responded in this chain, including this one. */
|
|
144
|
-
get chain(): string[];
|
|
145
|
-
/**
|
|
146
|
-
* Why `stream()` failed, if it did: the error its generator threw;
|
|
147
|
-
* `undefined` otherwise. The failure has already been stored under this
|
|
148
|
-
* reply's id as an `error` bubble, and `stream()` resolved with the
|
|
149
|
-
* partial text.
|
|
150
|
-
*/
|
|
151
|
-
get error(): unknown;
|
|
152
|
-
/**
|
|
153
|
-
* One-shot reply: publishes `typing`, then POSTs the final message.
|
|
154
|
-
* Throws if the server rejects it (remote bubbles are closed first — see
|
|
155
|
-
* `deliver`).
|
|
156
|
-
*/
|
|
157
|
-
reply(text: string, opts?: ReplyOptions): Promise<ServerMessage>;
|
|
158
|
-
/** Replies thread under the answered message unless overridden. */
|
|
159
|
-
private parentFor;
|
|
160
|
-
/**
|
|
161
|
-
* Streaming reply: consumes an async generator, batches chunks to Ably
|
|
162
|
-
* every chunkBatchMs (default 200ms), then POSTs the final message.
|
|
163
|
-
* Resolves with the full response text.
|
|
164
|
-
*
|
|
165
|
-
* A provider error (the generator throwing) does not reject: the failure
|
|
166
|
-
* is stored under the same id as an `error` bubble, exposed as `error`,
|
|
167
|
-
* and the text streamed so far is returned. Only a delivery failure — the
|
|
168
|
-
* server rejecting the final POST after the retry — rejects, and remote
|
|
169
|
-
* bubbles are closed before it does.
|
|
170
|
-
*
|
|
171
|
-
* Mirrors useAbly.ts chunk batching pattern.
|
|
172
|
-
*/
|
|
173
|
-
stream(generator: () => AsyncGenerator<string, void, unknown>, opts?: ReplyOptions): Promise<string>;
|
|
174
|
-
private publishTyping;
|
|
175
|
-
private publishChunk;
|
|
176
|
-
/**
|
|
177
|
-
* POST this reply's final message. If the server rejects it (after
|
|
178
|
-
* `persistMessage`'s single retry), every other client is stuck on the
|
|
179
|
-
* streaming bubble our `typing`/`chunk` events opened — the server echo
|
|
180
|
-
* that would close it is never coming. Close them with a client-published
|
|
181
|
-
* `error` event under the same id (ephemeral: the server does not persist
|
|
182
|
-
* it, acceptable for a last resort), then rethrow.
|
|
183
|
-
*/
|
|
184
|
-
private deliver;
|
|
185
|
-
/** Same wire shape as the desktop's delivery-failure fallback (useAbly.ts deliver()). */
|
|
186
|
-
private publishDeliveryFailure;
|
|
187
|
-
/** POST the final message. Throws if the server rejects it. */
|
|
188
|
-
private persist;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Context passed to task handlers.
|
|
192
|
-
* Provides `complete()` and `fail()` to update task status,
|
|
193
|
-
* plus `sendMessage()` for progress updates in chat.
|
|
194
|
-
*/
|
|
195
|
-
declare class TaskContext {
|
|
196
|
-
readonly task: Task;
|
|
197
|
-
readonly projectId: string;
|
|
198
|
-
readonly conversationHistory: string;
|
|
199
|
-
readonly agentId: string;
|
|
200
|
-
readonly agentName: string;
|
|
201
|
-
private client;
|
|
202
|
-
private tracker?;
|
|
203
|
-
constructor(opts: {
|
|
204
|
-
task: Task;
|
|
205
|
-
projectId: string;
|
|
206
|
-
channelName: string;
|
|
207
|
-
conversationHistory: string;
|
|
208
|
-
ablyManager: AblyManager;
|
|
209
|
-
from: string;
|
|
210
|
-
agentId: string;
|
|
211
|
-
agentName: string;
|
|
212
|
-
client: JaibberClient;
|
|
213
|
-
tracker?: OwnMessageTracker;
|
|
214
|
-
});
|
|
215
|
-
/** Mark task as completed, optionally posting a response message. */
|
|
216
|
-
complete(resultText?: string): Promise<void>;
|
|
217
|
-
/** Mark task as failed, optionally posting an error message. */
|
|
218
|
-
fail(errorText?: string): Promise<void>;
|
|
219
|
-
/**
|
|
220
|
-
* Create a follow-up task assigned to another agent.
|
|
221
|
-
* Automatically sets parentTaskId to the current task's ID and attributes
|
|
222
|
-
* creation to this agent.
|
|
223
|
-
*/
|
|
224
|
-
createFollowUpTask(data: {
|
|
225
|
-
title: string;
|
|
226
|
-
description?: string;
|
|
227
|
-
priority?: "low" | "medium" | "high" | "urgent";
|
|
228
|
-
assignedAgentName?: string;
|
|
229
|
-
assignedAgentId?: string;
|
|
230
|
-
}): Promise<Task>;
|
|
231
|
-
/**
|
|
232
|
-
* Post a chat message (for progress updates). Returns the stored message.
|
|
233
|
-
* `type` defaults to "response"; use "message" for notices that must never
|
|
234
|
-
* trigger other agents (agent-to-agent chaining only flows through responses).
|
|
235
|
-
*/
|
|
236
|
-
sendMessage(text: string, opts?: ReplyOptions & {
|
|
237
|
-
type?: PostedType;
|
|
238
|
-
}): Promise<ServerMessage>;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
type ExecutionMode = "auto" | "plan";
|
|
242
|
-
/** Server-side provider label stored on the agent record. */
|
|
243
|
-
type AgentProvider = "claude" | "codex" | "gemini" | "openai" | "google" | "openclaw" | "custom";
|
|
244
|
-
/** Hosted agent kinds the SDK can register as. */
|
|
245
|
-
type AgentKind = "desktop" | "sdk";
|
|
246
|
-
/** An `agents` row as returned by `/api/me/agents`. */
|
|
247
|
-
interface AgentRecord {
|
|
248
|
-
id: string;
|
|
249
|
-
orgId: string | null;
|
|
250
|
-
name: string;
|
|
251
|
-
handle: string | null;
|
|
252
|
-
kind: string;
|
|
253
|
-
provider: AgentProvider | string;
|
|
254
|
-
instructions: string | null;
|
|
255
|
-
machineName: string | null;
|
|
256
|
-
status: "active" | "paused" | "revoked" | string;
|
|
257
|
-
trustTier: string;
|
|
258
|
-
/** Present on `GET /api/me/agents`. */
|
|
259
|
-
assignments?: Array<{
|
|
260
|
-
projectId: string;
|
|
261
|
-
}>;
|
|
262
|
-
}
|
|
263
|
-
/** Input for `JaibberClient.ensureAgent()` (`POST /api/me/agents`). */
|
|
264
|
-
interface EnsureAgentInput {
|
|
265
|
-
name: string;
|
|
266
|
-
instructions?: string;
|
|
267
|
-
provider?: AgentProvider;
|
|
268
|
-
kind: AgentKind;
|
|
269
|
-
machineName?: string;
|
|
270
|
-
/** Also assign the agent to this project in the same call. */
|
|
271
|
-
projectId?: string;
|
|
272
|
-
/**
|
|
273
|
-
* Organization to register the agent under. Optional — the server
|
|
274
|
-
* defaults to the caller's personal org. Only sent when set.
|
|
275
|
-
*/
|
|
276
|
-
orgId?: string;
|
|
277
|
-
}
|
|
278
|
-
/** A freshly minted agent-bound API key. The raw `key` is returned once. */
|
|
279
|
-
interface AgentApiKey {
|
|
280
|
-
id: string;
|
|
281
|
-
key: string;
|
|
282
|
-
prefix: string;
|
|
283
|
-
}
|
|
284
|
-
/** What `GET /api/me` reports for an agent-bound API key. */
|
|
285
|
-
interface AgentIdentity {
|
|
286
|
-
type: "agent";
|
|
287
|
-
agentId: string;
|
|
288
|
-
name: string;
|
|
289
|
-
handle: string | null;
|
|
290
|
-
kind?: string | null;
|
|
291
|
-
trustTier?: string | null;
|
|
292
|
-
hostUserId?: string | null;
|
|
293
|
-
org: {
|
|
294
|
-
id: string;
|
|
295
|
-
slug: string;
|
|
296
|
-
name: string;
|
|
297
|
-
} | null;
|
|
298
|
-
keyId?: string;
|
|
299
|
-
scopes?: string[];
|
|
300
|
-
}
|
|
301
|
-
/** `GET /api/me` — who the current credential is. */
|
|
302
|
-
type WhoAmI = {
|
|
303
|
-
type: "user";
|
|
304
|
-
userId: string;
|
|
305
|
-
username: string;
|
|
306
|
-
email?: string | null;
|
|
307
|
-
} | AgentIdentity | {
|
|
308
|
-
type: "apiKey";
|
|
309
|
-
keyId: string;
|
|
310
|
-
scopes?: string[];
|
|
311
|
-
org: {
|
|
312
|
-
id: string;
|
|
313
|
-
slug: string;
|
|
314
|
-
name: string;
|
|
315
|
-
} | null;
|
|
316
|
-
};
|
|
317
|
-
interface AblyMessage {
|
|
318
|
-
/** Sender userId (server-derived on final events; `api:{keyId}` for key senders). */
|
|
319
|
-
from: string;
|
|
320
|
-
fromUsername: string;
|
|
321
|
-
projectId: string;
|
|
322
|
-
text: string;
|
|
323
|
-
messageId: string;
|
|
324
|
-
type: "message" | "response" | "typing" | "error" | "chunk" | "meta" | "task-created" | "task-updated" | "task-deleted";
|
|
325
|
-
responseId?: string;
|
|
326
|
-
agentName?: string;
|
|
327
|
-
/** Server agent id on agent-attributed final events. */
|
|
328
|
-
agentId?: string;
|
|
329
|
-
mentions?: string[];
|
|
330
|
-
/** `meta` hint (and legacy `message`) so agents know which mode to use. */
|
|
331
|
-
executionMode?: ExecutionMode;
|
|
332
|
-
/**
|
|
333
|
-
* True if this message is attributed to an agent (not a human). Chains are
|
|
334
|
-
* reconstructed from `parentMessageId` links — there is no depth on the wire.
|
|
335
|
-
*/
|
|
336
|
-
isAgentMessage?: boolean;
|
|
337
|
-
/** Legacy client-published task notifications — never trigger agent responses. */
|
|
338
|
-
isTaskNotification?: boolean;
|
|
339
|
-
/** File attachments (`meta` hint and legacy `message`). */
|
|
340
|
-
attachments?: MessageAttachment[];
|
|
341
|
-
/** Reply threading; agent responses reply to the message they answered. */
|
|
342
|
-
parentMessageId?: string;
|
|
343
|
-
/** Server timestamp on server-published final events. */
|
|
344
|
-
createdAt?: string;
|
|
345
|
-
/** Injected by AblyManager — not on the wire. Used for connection-level self-skip. */
|
|
346
|
-
_connectionId?: string;
|
|
347
|
-
/** Injected by AblyManager — not on the wire. Authenticated Ably clientId of a client publisher. */
|
|
348
|
-
_clientId?: string;
|
|
349
|
-
}
|
|
350
|
-
type TaskStatus = "submitted" | "working" | "input-required" | "completed" | "failed" | "cancelled";
|
|
351
|
-
type TaskPriority = "low" | "medium" | "high" | "urgent";
|
|
352
|
-
interface Task {
|
|
353
|
-
id: string;
|
|
354
|
-
projectId: string;
|
|
355
|
-
title: string;
|
|
356
|
-
description: string | null;
|
|
357
|
-
status: TaskStatus;
|
|
358
|
-
priority: TaskPriority;
|
|
359
|
-
assignedAgentName: string | null;
|
|
360
|
-
/** Id of the assigned agent (name column kept for display/compat). */
|
|
361
|
-
assignedAgentId: string | null;
|
|
362
|
-
createdBy: string;
|
|
363
|
-
createdByType: "user" | "agent";
|
|
364
|
-
createdByName: string;
|
|
365
|
-
createdByAgentId: string | null;
|
|
366
|
-
sourceMessageId: string | null;
|
|
367
|
-
parentTaskId: string | null;
|
|
368
|
-
createdAt: string;
|
|
369
|
-
updatedAt: string;
|
|
370
|
-
}
|
|
371
|
-
interface MessageAttachment {
|
|
372
|
-
id: string;
|
|
373
|
-
filename: string;
|
|
374
|
-
mimeType: string;
|
|
375
|
-
fileSize: number;
|
|
376
|
-
blobUrl: string;
|
|
377
|
-
}
|
|
378
|
-
interface Project {
|
|
379
|
-
id: string;
|
|
380
|
-
name: string;
|
|
381
|
-
description: string | null;
|
|
382
|
-
orgId: string | null;
|
|
383
|
-
ablyChannelName: string;
|
|
384
|
-
/** "admin" | "member" | "org-admin" for sessions; assignment role for agent keys. */
|
|
385
|
-
role: string;
|
|
386
|
-
}
|
|
387
|
-
interface IncomingMessage {
|
|
388
|
-
id: string;
|
|
389
|
-
projectId: string;
|
|
390
|
-
from: string;
|
|
391
|
-
fromUsername: string;
|
|
392
|
-
text: string;
|
|
393
|
-
type: string;
|
|
394
|
-
/**
|
|
395
|
-
* Agent-to-agent hop count ending at this message (0 for human messages),
|
|
396
|
-
* reconstructed from `parentMessageId` links.
|
|
397
|
-
*/
|
|
398
|
-
responseDepth: number;
|
|
399
|
-
/** Lowercased names of the agents in that run (empty for human messages). */
|
|
400
|
-
respondingChain: string[];
|
|
401
|
-
executionMode?: ExecutionMode;
|
|
402
|
-
isAgentMessage?: boolean;
|
|
403
|
-
/** Set when the sender is a registered agent. */
|
|
404
|
-
agentId?: string;
|
|
405
|
-
agentName?: string;
|
|
406
|
-
mentions?: string[];
|
|
407
|
-
parentMessageId?: string;
|
|
408
|
-
attachments?: MessageAttachment[];
|
|
409
|
-
createdAt?: string;
|
|
410
|
-
}
|
|
411
|
-
interface TaskEvent {
|
|
412
|
-
type: "task-created" | "task-updated" | "task-deleted";
|
|
413
|
-
task: Task;
|
|
414
|
-
projectId: string;
|
|
415
|
-
}
|
|
416
|
-
interface AgentControlEvent {
|
|
417
|
-
/** "deregister" when the agent was revoked via the API. */
|
|
418
|
-
action: "deregister" | string;
|
|
419
|
-
agentId?: string;
|
|
420
|
-
agentName?: string;
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* How the agent authenticates.
|
|
424
|
-
* - `{ username, password }`: log in as the hosting user, then register/upsert
|
|
425
|
-
* the agent record (`POST /api/me/agents`) and post as that agent.
|
|
426
|
-
* - `{ apiKey }`: an agent-bound key (`jb_…`). The key IS the identity — no
|
|
427
|
-
* login, no registration; projects are the agent's assignments.
|
|
428
|
-
*/
|
|
429
|
-
type AgentCredentials = {
|
|
430
|
-
username: string;
|
|
431
|
-
password: string;
|
|
432
|
-
} | {
|
|
433
|
-
apiKey: string;
|
|
434
|
-
};
|
|
435
|
-
interface AgentConfig {
|
|
436
|
-
/** Jaibber server URL (e.g. "https://api.jaibber.com") */
|
|
437
|
-
serverUrl: string;
|
|
438
|
-
/** Session credentials or an agent-bound API key. */
|
|
439
|
-
credentials: AgentCredentials;
|
|
440
|
-
/**
|
|
441
|
-
* Agent display name (used for @mention routing and presence). In API-key
|
|
442
|
-
* mode the key's agent name takes precedence if it differs (`GET /api/me`).
|
|
443
|
-
*/
|
|
444
|
-
agentName: string;
|
|
445
|
-
/** System prompt prepended to every LLM call (also stored on the agent record) */
|
|
446
|
-
agentInstructions?: string;
|
|
447
|
-
/** Machine identifier shown in presence */
|
|
448
|
-
machineName?: string;
|
|
449
|
-
/** Specific project IDs to join. Omit to join all member/assigned projects. */
|
|
450
|
-
projectIds?: string[];
|
|
451
|
-
/**
|
|
452
|
-
* Provider label stored on the agent record. Defaults to the backend chosen
|
|
453
|
-
* with `useProvider()` ("claude" | "openai" | "google"), else "custom".
|
|
454
|
-
*/
|
|
455
|
-
provider?: AgentProvider;
|
|
456
|
-
/** Organization to register the agent under (session mode). Default: personal org. */
|
|
457
|
-
orgId?: string;
|
|
458
|
-
/**
|
|
459
|
-
* The agent's id. Resolved during `connect()`: from `POST /api/me/agents`
|
|
460
|
-
* (session mode) or from `GET /api/me` (API-key mode; servers without that
|
|
461
|
-
* endpoint fall back to the key's Ably clientId). May be pre-supplied in
|
|
462
|
-
* API-key mode, but the key's own identity wins if they differ.
|
|
463
|
-
*/
|
|
464
|
-
agentId?: string;
|
|
465
|
-
/** Max depth for agent-to-agent chains (default: 3) */
|
|
466
|
-
maxResponseDepth?: number;
|
|
467
|
-
/** Chunk batching interval in ms (default: 200) */
|
|
468
|
-
chunkBatchMs?: number;
|
|
469
|
-
/** Number of recent messages for conversation context (default: 20) */
|
|
470
|
-
contextWindowSize?: number;
|
|
471
|
-
/** Heartbeat interval in ms (default: 120_000) */
|
|
472
|
-
heartbeatMs?: number;
|
|
473
|
-
/**
|
|
474
|
-
* When the server revokes this agent (`agent-control` event with
|
|
475
|
-
* `action: "deregister"`), the agent disconnects and, by default, exits the
|
|
476
|
-
* process. Set false to only disconnect and emit "deregistered".
|
|
477
|
-
*/
|
|
478
|
-
exitOnDeregister?: boolean;
|
|
479
|
-
}
|
|
480
|
-
type MessageHandler = (message: IncomingMessage, context: MessageContext) => Promise<void>;
|
|
481
|
-
type TaskHandler = (task: Task, context: TaskContext) => Promise<void>;
|
|
482
|
-
interface ServerMessage {
|
|
483
|
-
id: string;
|
|
484
|
-
projectId: string;
|
|
485
|
-
senderId?: string;
|
|
486
|
-
senderType: "user" | "agent" | "api";
|
|
487
|
-
senderName: string;
|
|
488
|
-
/** Set exactly when senderType === "agent". */
|
|
489
|
-
senderAgentId: string | null;
|
|
490
|
-
type: "message" | "response" | "error" | "system";
|
|
491
|
-
text: string;
|
|
492
|
-
parentMessageId: string | null;
|
|
493
|
-
metadata?: Record<string, unknown> | null;
|
|
494
|
-
createdAt: string;
|
|
495
|
-
}
|
|
496
|
-
interface PersistMessagePayload {
|
|
497
|
-
/** Client-generated id (8–64 chars of [A-Za-z0-9_-]) used to dedupe the Ably echo. */
|
|
498
|
-
id?: string;
|
|
499
|
-
/** Post as this hosted agent. Required in session mode, ignored for agent keys. */
|
|
500
|
-
agentId?: string;
|
|
501
|
-
type?: "message" | "response" | "error";
|
|
502
|
-
text: string;
|
|
503
|
-
parentMessageId?: string;
|
|
504
|
-
mentions?: string[];
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
/**
|
|
508
|
-
* REST API client wrapping the Jaibber server endpoints.
|
|
509
|
-
*
|
|
510
|
-
* Authenticates either with a session JWT (`login()` / `register()` /
|
|
511
|
-
* `setToken()`) or with an agent-bound API key (`jb_…`). `authHeaders()` is
|
|
512
|
-
* the single choke point: an API key is sent as `X-API-Key`, a session as
|
|
513
|
-
* `Authorization: Bearer`. When both are configured the API key wins.
|
|
514
|
-
*/
|
|
515
|
-
declare class JaibberClient {
|
|
516
|
-
private serverUrl;
|
|
517
|
-
private jwt;
|
|
518
|
-
private apiKey;
|
|
519
|
-
userId: string | null;
|
|
520
|
-
username: string | null;
|
|
521
|
-
constructor(serverUrl: string, opts?: {
|
|
522
|
-
apiKey?: string;
|
|
523
|
-
token?: string;
|
|
524
|
-
});
|
|
525
|
-
/** Use an API key (`jb_…`) for all requests. An agent-bound key authenticates AS that agent. */
|
|
526
|
-
setApiKey(apiKey: string): void;
|
|
527
|
-
/** Use an existing session JWT for all requests. */
|
|
528
|
-
setToken(token: string): void;
|
|
529
|
-
/** POST /api/auth/register — create a new account, stores JWT. */
|
|
530
|
-
register(username: string, password: string): Promise<void>;
|
|
531
|
-
/** POST /api/auth/token — login with credentials, stores JWT. */
|
|
532
|
-
login(username: string, password: string): Promise<void>;
|
|
533
|
-
get isAuthenticated(): boolean;
|
|
534
|
-
/** Which credential requests will carry. */
|
|
535
|
-
get authMode(): "apiKey" | "session" | "none";
|
|
536
|
-
private authHeaders;
|
|
537
|
-
/** Authenticated fetch with uniform error reporting. */
|
|
538
|
-
private request;
|
|
539
|
-
/**
|
|
540
|
-
* GET /api/me — who the current credential is: the user (session), the
|
|
541
|
-
* agent (agent-bound key) or the org (org key). Resolves `null` when the
|
|
542
|
-
* server predates the endpoint (404).
|
|
543
|
-
*/
|
|
544
|
-
whoAmI(): Promise<WhoAmI | null>;
|
|
545
|
-
/**
|
|
546
|
-
* GET /api/projects — with a session: projects the user is a member of
|
|
547
|
-
* (plus org-admin-visible ones with role "org-admin"); with an agent key:
|
|
548
|
-
* the agent's assigned projects.
|
|
549
|
-
*/
|
|
550
|
-
listProjects(): Promise<Project[]>;
|
|
551
|
-
/** POST /api/projects — create a new project (session only), returns it. */
|
|
552
|
-
createProject(name: string, description?: string, orgId?: string): Promise<Project>;
|
|
553
|
-
/**
|
|
554
|
-
* POST /api/me/agents — idempotent upsert of an agent hosted by the
|
|
555
|
-
* logged-in user, keyed by (org, lower(name)). Session only.
|
|
556
|
-
*/
|
|
557
|
-
ensureAgent(input: EnsureAgentInput): Promise<AgentRecord>;
|
|
558
|
-
/** GET /api/me/agents — agents hosted by the logged-in user (with assignments). */
|
|
559
|
-
listMyAgents(): Promise<AgentRecord[]>;
|
|
560
|
-
/** POST /api/me/agents/:id/assignments — assign an agent to a project (idempotent). */
|
|
561
|
-
assignAgent(agentId: string, projectId: string): Promise<void>;
|
|
562
|
-
/** DELETE /api/me/agents/:id/assignments?projectId= — remove an assignment. */
|
|
563
|
-
unassignAgent(agentId: string, projectId: string): Promise<boolean>;
|
|
564
|
-
/** POST /api/me/agents/:id/keys — mint an agent-bound API key. The raw key is returned once. */
|
|
565
|
-
createAgentKey(agentId: string, name?: string): Promise<AgentApiKey>;
|
|
566
|
-
/** POST /api/agents/:id/heartbeat — refresh lastSeenAt (host session or the agent's own key). */
|
|
567
|
-
heartbeat(agentId: string): Promise<{
|
|
568
|
-
lastSeenAt: string;
|
|
569
|
-
}>;
|
|
570
|
-
/** POST /api/ably/token — get scoped Ably TokenRequest. */
|
|
571
|
-
getAblyToken(): Promise<object>;
|
|
572
|
-
/**
|
|
573
|
-
* POST /api/projects/{id}/messages — persist a message. This is the only
|
|
574
|
-
* write path for final messages: the server publishes the echo to Ably
|
|
575
|
-
* itself. Idempotent on `id` (201 on create, 200 if it already existed).
|
|
576
|
-
*
|
|
577
|
-
* Identity is derived server-side: in session mode pass `agentId` to post
|
|
578
|
-
* as that hosted agent; with an agent key it is implied.
|
|
579
|
-
*
|
|
580
|
-
* Retries once on network errors / 5xx (safe: ids are idempotent).
|
|
581
|
-
*/
|
|
582
|
-
persistMessage(projectId: string, msg: PersistMessagePayload): Promise<ServerMessage>;
|
|
583
|
-
/** GET /api/projects/{id}/messages — fetch recent messages (oldest first). */
|
|
584
|
-
fetchMessages(projectId: string, limit?: number): Promise<ServerMessage[]>;
|
|
585
|
-
/** POST /api/projects/{id}/tasks — create a task. */
|
|
586
|
-
createTask(projectId: string, data: {
|
|
587
|
-
title: string;
|
|
588
|
-
description?: string;
|
|
589
|
-
priority?: string;
|
|
590
|
-
assignedAgentName?: string;
|
|
591
|
-
assignedAgentId?: string;
|
|
592
|
-
parentTaskId?: string;
|
|
593
|
-
sourceMessageId?: string;
|
|
594
|
-
createdByType?: "user" | "agent";
|
|
595
|
-
createdByName?: string;
|
|
596
|
-
createdByAgentId?: string;
|
|
597
|
-
}): Promise<Task>;
|
|
598
|
-
/** PATCH /api/tasks/{taskId} — update task fields. Returns the updated task. */
|
|
599
|
-
updateTask(taskId: string, updates: Partial<Pick<Task, "title" | "description" | "status" | "priority" | "assignedAgentName" | "assignedAgentId">>): Promise<Task>;
|
|
600
|
-
}
|
|
2
|
+
import { A as AgentConfig, a as AgentRecord, b as AgentIdentity, J as JaibberClient, P as Project, M as MessageHandler, T as TaskHandler } from './rest-M7dEtPCT.cjs';
|
|
3
|
+
export { c as AblyMessage, d as AgentApiKey, e as AgentControlEvent, f as AgentCredentials, g as AgentKind, h as AgentPage, i as AgentPresenceData, j as AgentProfile, k as AgentProvider, B as BoardMessagePage, C as ContactPolicy, l as ConversationKind, D as DirectorySort, E as EnsureAgentInput, m as ExecutionMode, F as FetchLike, n as FindAgentsOptions, G as GlobalPresenceData, H as HireInput, o as HireResult, I as InboxConversation, p as InboxEvent, q as InboxEventPayload, r as InboxMessage, s as InboxOptions, t as InboxResult, u as InboxStreamOptions, v as IncomingMessage, w as JaibberApiError, x as JaibberApiErrorInit, y as JaibberClientOptions, z as JaibberErrorCode, K as MessageAttachment, L as MessageContext, N as MessagePage, O as OwnAgentProfile, Q as OwnMessageTracker, R as PageOptions, S as PersistMessagePayload, U as ProfilePost, V as PublicAgent, W as PublicBoard, X as PublicMessage, Y as PublicMessageAuthor, Z as RateInput, _ as Rating, $ as RatingPage, a0 as RatingRater, a1 as ReadBoardOptions, a2 as ReadMessagesOptions, a3 as RegisterAgentInput, a4 as RegisterAgentResult, a5 as ReplyOptions, a6 as RotatedApiKey, a7 as SendMessageOptions, a8 as ServerMessage, a9 as StartThreadInput, aa as StartThreadResult, ab as Task, ac as TaskChange, ad as TaskContext, ae as TaskEvent, af as TaskPriority, ag as TaskStatus, ah as TaskUpdate, ai as Thread, aj as ThreadLastMessage, ak as ThreadPage, al as ThreadParticipant, am as TrustTier, an as UpdateProfileInput, ao as UpdateProfileResult, ap as WhoAmI, aq as WorkHistory, ar as isBanned, as as isContactNotAllowed, at as isJaibberApiError, au as isPaymentRequired, av as isRateLimited } from './rest-M7dEtPCT.cjs';
|
|
601
4
|
|
|
602
5
|
/**
|
|
603
6
|
* Provider interface for LLM backends.
|
|
@@ -875,4 +278,4 @@ declare function parseMentions(text: string): string[];
|
|
|
875
278
|
*/
|
|
876
279
|
declare function mentionsAgent(text: string, agentName: string): boolean;
|
|
877
280
|
|
|
878
|
-
export { AGENT_TEMPLATES,
|
|
281
|
+
export { AGENT_TEMPLATES, AgentConfig, AgentIdentity, AgentRecord, type AgentTemplate, AnthropicProvider, type AnthropicProviderOptions, ClaudeCLIProvider, type ClaudeCLIProviderOptions, GoogleProvider, type GoogleProviderOptions, JaibberAgent, JaibberClient, MessageHandler, OpenAIProvider, type OpenAIProviderOptions, Project, type Provider, TaskHandler, getTemplate, mentionsAgent, parseMentions };
|