@jaibber/sdk 0.4.0 → 0.4.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.
- package/README.md +44 -2
- package/dist/cli.js +209 -44
- package/dist/index.cjs +195 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +101 -10
- package/dist/index.d.ts +101 -10
- package/dist/index.js +195 -41
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -52,7 +52,7 @@ declare class AblyManager {
|
|
|
52
52
|
* `agent-control` events) and enter per-project presence.
|
|
53
53
|
* Returns an unsubscribe function.
|
|
54
54
|
*/
|
|
55
|
-
subscribeToProject(project: Project, presenceData: AgentPresenceData, onMessage: (msg: AblyMessage) => void
|
|
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
56
|
/**
|
|
57
57
|
* Publish a client-side event on a project channel. Only `typing` and
|
|
58
58
|
* `chunk` are client-published; final messages go through the REST API
|
|
@@ -120,6 +120,8 @@ declare class MessageContext {
|
|
|
120
120
|
private respondingChain;
|
|
121
121
|
private chunkBatchMs;
|
|
122
122
|
private tracker?;
|
|
123
|
+
/** Set by `stream()` when its generator threw. */
|
|
124
|
+
private streamError;
|
|
123
125
|
constructor(opts: {
|
|
124
126
|
projectId: string;
|
|
125
127
|
channelName: string;
|
|
@@ -140,7 +142,18 @@ declare class MessageContext {
|
|
|
140
142
|
get depth(): number;
|
|
141
143
|
/** Agents that have already responded in this chain, including this one. */
|
|
142
144
|
get chain(): string[];
|
|
143
|
-
/**
|
|
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
|
+
*/
|
|
144
157
|
reply(text: string, opts?: ReplyOptions): Promise<ServerMessage>;
|
|
145
158
|
/** Replies thread under the answered message unless overridden. */
|
|
146
159
|
private parentFor;
|
|
@@ -149,11 +162,28 @@ declare class MessageContext {
|
|
|
149
162
|
* every chunkBatchMs (default 200ms), then POSTs the final message.
|
|
150
163
|
* Resolves with the full response text.
|
|
151
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
|
+
*
|
|
152
171
|
* Mirrors useAbly.ts chunk batching pattern.
|
|
153
172
|
*/
|
|
154
173
|
stream(generator: () => AsyncGenerator<string, void, unknown>, opts?: ReplyOptions): Promise<string>;
|
|
155
174
|
private publishTyping;
|
|
156
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;
|
|
157
187
|
/** POST the final message. Throws if the server rejects it. */
|
|
158
188
|
private persist;
|
|
159
189
|
}
|
|
@@ -251,6 +281,39 @@ interface AgentApiKey {
|
|
|
251
281
|
key: string;
|
|
252
282
|
prefix: string;
|
|
253
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
|
+
};
|
|
254
317
|
interface AblyMessage {
|
|
255
318
|
/** Sender userId (server-derived on final events; `api:{keyId}` for key senders). */
|
|
256
319
|
from: string;
|
|
@@ -374,7 +437,10 @@ interface AgentConfig {
|
|
|
374
437
|
serverUrl: string;
|
|
375
438
|
/** Session credentials or an agent-bound API key. */
|
|
376
439
|
credentials: AgentCredentials;
|
|
377
|
-
/**
|
|
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
|
+
*/
|
|
378
444
|
agentName: string;
|
|
379
445
|
/** System prompt prepended to every LLM call (also stored on the agent record) */
|
|
380
446
|
agentInstructions?: string;
|
|
@@ -391,8 +457,9 @@ interface AgentConfig {
|
|
|
391
457
|
orgId?: string;
|
|
392
458
|
/**
|
|
393
459
|
* The agent's id. Resolved during `connect()`: from `POST /api/me/agents`
|
|
394
|
-
* (session mode) or from
|
|
395
|
-
*
|
|
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.
|
|
396
463
|
*/
|
|
397
464
|
agentId?: string;
|
|
398
465
|
/** Max depth for agent-to-agent chains (default: 3) */
|
|
@@ -469,6 +536,12 @@ declare class JaibberClient {
|
|
|
469
536
|
private authHeaders;
|
|
470
537
|
/** Authenticated fetch with uniform error reporting. */
|
|
471
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>;
|
|
472
545
|
/**
|
|
473
546
|
* GET /api/projects — with a session: projects the user is a member of
|
|
474
547
|
* (plus org-admin-visible ones with role "org-admin"); with an agent key:
|
|
@@ -536,7 +609,7 @@ interface Provider {
|
|
|
536
609
|
interface AnthropicProviderOptions {
|
|
537
610
|
/** Anthropic API key (sk-ant-...) */
|
|
538
611
|
apiKey: string;
|
|
539
|
-
/** Model ID (default: "claude-sonnet-
|
|
612
|
+
/** Model ID (default: "claude-sonnet-5"; e.g. "claude-opus-5" for the most capable tier) */
|
|
540
613
|
model?: string;
|
|
541
614
|
/** Max tokens (default: 8192) */
|
|
542
615
|
maxTokens?: number;
|
|
@@ -576,9 +649,9 @@ interface ClaudeCLIProviderOptions {
|
|
|
576
649
|
* - Session credentials: logs in as the hosting user, upserts the agent record
|
|
577
650
|
* (`POST /api/me/agents`), assigns it to the joined projects, and posts
|
|
578
651
|
* replies with `agentId` so the server attributes them to the agent.
|
|
579
|
-
* - API key credentials: the agent-bound key IS the identity; the agent id
|
|
580
|
-
*
|
|
581
|
-
* agent's assignments.
|
|
652
|
+
* - API key credentials: the agent-bound key IS the identity; the agent id
|
|
653
|
+
* and name come from `GET /api/me` (older servers: the key's Ably clientId
|
|
654
|
+
* `agent:{id}`) and projects are the agent's assignments.
|
|
582
655
|
*
|
|
583
656
|
* Final messages are POSTed to the server (which publishes the Ably echo);
|
|
584
657
|
* only `typing` and `chunk` events are published by the client. Replies are
|
|
@@ -606,6 +679,7 @@ declare class JaibberAgent extends EventEmitter {
|
|
|
606
679
|
private heartbeatTimer;
|
|
607
680
|
private agentId;
|
|
608
681
|
private agentRecord;
|
|
682
|
+
private keyIdentity;
|
|
609
683
|
/** In-memory conversation history per project. */
|
|
610
684
|
private history;
|
|
611
685
|
/** Recent messages per project (id → author/parent) for chain reconstruction. */
|
|
@@ -626,10 +700,20 @@ declare class JaibberAgent extends EventEmitter {
|
|
|
626
700
|
*/
|
|
627
701
|
private unthreadedHops;
|
|
628
702
|
constructor(config: AgentConfig);
|
|
703
|
+
/**
|
|
704
|
+
* Default `"error"` listener, registered by the constructor: logs the error
|
|
705
|
+
* and keeps the process alive. To handle errors yourself without the log,
|
|
706
|
+
* remove it: `agent.off("error", JaibberAgent.defaultErrorListener)`.
|
|
707
|
+
*/
|
|
708
|
+
static readonly defaultErrorListener: (err: unknown) => void;
|
|
709
|
+
/** Emit `"error"` without ever throwing, even if every listener was removed. */
|
|
710
|
+
private emitError;
|
|
629
711
|
/** The agent's server-side id (available after `connect()`). */
|
|
630
712
|
get id(): string | null;
|
|
631
713
|
/** The agent record returned by the server (session mode only). */
|
|
632
714
|
get record(): AgentRecord | null;
|
|
715
|
+
/** The key's agent identity from `GET /api/me` (API-key mode, on servers that have it). */
|
|
716
|
+
get identity(): AgentIdentity | null;
|
|
633
717
|
/** The underlying REST client (authenticated after `connect()`). */
|
|
634
718
|
get api(): JaibberClient;
|
|
635
719
|
/** Projects this agent has joined. */
|
|
@@ -639,6 +723,13 @@ declare class JaibberAgent extends EventEmitter {
|
|
|
639
723
|
private get maxDepth();
|
|
640
724
|
/** Authenticate, register/resolve the agent, connect Ably, subscribe to project channels. */
|
|
641
725
|
connect(): Promise<void>;
|
|
726
|
+
/**
|
|
727
|
+
* API-key mode: ask the server who the key is (`GET /api/me`) so the agent
|
|
728
|
+
* id and name are known before Ably connects. Servers that predate the
|
|
729
|
+
* endpoint answer 404; the id is then read from the Ably token's clientId
|
|
730
|
+
* (`agent:{id}`) once connected, as in 0.4.0.
|
|
731
|
+
*/
|
|
732
|
+
private resolveKeyIdentity;
|
|
642
733
|
/** Stop heartbeats, leave presence, disconnect Ably. */
|
|
643
734
|
disconnect(): Promise<void>;
|
|
644
735
|
/** Register a handler for incoming messages. */
|
|
@@ -784,4 +875,4 @@ declare function parseMentions(text: string): string[];
|
|
|
784
875
|
*/
|
|
785
876
|
declare function mentionsAgent(text: string, agentName: string): boolean;
|
|
786
877
|
|
|
787
|
-
export { AGENT_TEMPLATES, type AblyMessage, type AgentApiKey, type AgentConfig, type AgentControlEvent, type AgentCredentials, type AgentKind, type AgentPresenceData, type AgentProvider, type AgentRecord, type AgentTemplate, AnthropicProvider, type AnthropicProviderOptions, ClaudeCLIProvider, type ClaudeCLIProviderOptions, type EnsureAgentInput, type ExecutionMode, type GlobalPresenceData, GoogleProvider, type GoogleProviderOptions, type IncomingMessage, JaibberAgent, JaibberClient, type MessageAttachment, MessageContext, type MessageHandler, OpenAIProvider, type OpenAIProviderOptions, type OwnMessageTracker, type PersistMessagePayload, type Project, type Provider, type ReplyOptions, type ServerMessage, type Task, TaskContext, type TaskEvent, type TaskHandler, type TaskPriority, type TaskStatus, getTemplate, mentionsAgent, parseMentions };
|
|
878
|
+
export { AGENT_TEMPLATES, type AblyMessage, type AgentApiKey, type AgentConfig, type AgentControlEvent, type AgentCredentials, type AgentIdentity, type AgentKind, type AgentPresenceData, type AgentProvider, type AgentRecord, type AgentTemplate, AnthropicProvider, type AnthropicProviderOptions, ClaudeCLIProvider, type ClaudeCLIProviderOptions, type EnsureAgentInput, type ExecutionMode, type GlobalPresenceData, GoogleProvider, type GoogleProviderOptions, type IncomingMessage, JaibberAgent, JaibberClient, type MessageAttachment, MessageContext, type MessageHandler, OpenAIProvider, type OpenAIProviderOptions, type OwnMessageTracker, type PersistMessagePayload, type Project, type Provider, type ReplyOptions, type ServerMessage, type Task, TaskContext, type TaskEvent, type TaskHandler, type TaskPriority, type TaskStatus, type WhoAmI, getTemplate, mentionsAgent, parseMentions };
|
package/dist/index.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ declare class AblyManager {
|
|
|
52
52
|
* `agent-control` events) and enter per-project presence.
|
|
53
53
|
* Returns an unsubscribe function.
|
|
54
54
|
*/
|
|
55
|
-
subscribeToProject(project: Project, presenceData: AgentPresenceData, onMessage: (msg: AblyMessage) => void
|
|
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
56
|
/**
|
|
57
57
|
* Publish a client-side event on a project channel. Only `typing` and
|
|
58
58
|
* `chunk` are client-published; final messages go through the REST API
|
|
@@ -120,6 +120,8 @@ declare class MessageContext {
|
|
|
120
120
|
private respondingChain;
|
|
121
121
|
private chunkBatchMs;
|
|
122
122
|
private tracker?;
|
|
123
|
+
/** Set by `stream()` when its generator threw. */
|
|
124
|
+
private streamError;
|
|
123
125
|
constructor(opts: {
|
|
124
126
|
projectId: string;
|
|
125
127
|
channelName: string;
|
|
@@ -140,7 +142,18 @@ declare class MessageContext {
|
|
|
140
142
|
get depth(): number;
|
|
141
143
|
/** Agents that have already responded in this chain, including this one. */
|
|
142
144
|
get chain(): string[];
|
|
143
|
-
/**
|
|
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
|
+
*/
|
|
144
157
|
reply(text: string, opts?: ReplyOptions): Promise<ServerMessage>;
|
|
145
158
|
/** Replies thread under the answered message unless overridden. */
|
|
146
159
|
private parentFor;
|
|
@@ -149,11 +162,28 @@ declare class MessageContext {
|
|
|
149
162
|
* every chunkBatchMs (default 200ms), then POSTs the final message.
|
|
150
163
|
* Resolves with the full response text.
|
|
151
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
|
+
*
|
|
152
171
|
* Mirrors useAbly.ts chunk batching pattern.
|
|
153
172
|
*/
|
|
154
173
|
stream(generator: () => AsyncGenerator<string, void, unknown>, opts?: ReplyOptions): Promise<string>;
|
|
155
174
|
private publishTyping;
|
|
156
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;
|
|
157
187
|
/** POST the final message. Throws if the server rejects it. */
|
|
158
188
|
private persist;
|
|
159
189
|
}
|
|
@@ -251,6 +281,39 @@ interface AgentApiKey {
|
|
|
251
281
|
key: string;
|
|
252
282
|
prefix: string;
|
|
253
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
|
+
};
|
|
254
317
|
interface AblyMessage {
|
|
255
318
|
/** Sender userId (server-derived on final events; `api:{keyId}` for key senders). */
|
|
256
319
|
from: string;
|
|
@@ -374,7 +437,10 @@ interface AgentConfig {
|
|
|
374
437
|
serverUrl: string;
|
|
375
438
|
/** Session credentials or an agent-bound API key. */
|
|
376
439
|
credentials: AgentCredentials;
|
|
377
|
-
/**
|
|
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
|
+
*/
|
|
378
444
|
agentName: string;
|
|
379
445
|
/** System prompt prepended to every LLM call (also stored on the agent record) */
|
|
380
446
|
agentInstructions?: string;
|
|
@@ -391,8 +457,9 @@ interface AgentConfig {
|
|
|
391
457
|
orgId?: string;
|
|
392
458
|
/**
|
|
393
459
|
* The agent's id. Resolved during `connect()`: from `POST /api/me/agents`
|
|
394
|
-
* (session mode) or from
|
|
395
|
-
*
|
|
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.
|
|
396
463
|
*/
|
|
397
464
|
agentId?: string;
|
|
398
465
|
/** Max depth for agent-to-agent chains (default: 3) */
|
|
@@ -469,6 +536,12 @@ declare class JaibberClient {
|
|
|
469
536
|
private authHeaders;
|
|
470
537
|
/** Authenticated fetch with uniform error reporting. */
|
|
471
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>;
|
|
472
545
|
/**
|
|
473
546
|
* GET /api/projects — with a session: projects the user is a member of
|
|
474
547
|
* (plus org-admin-visible ones with role "org-admin"); with an agent key:
|
|
@@ -536,7 +609,7 @@ interface Provider {
|
|
|
536
609
|
interface AnthropicProviderOptions {
|
|
537
610
|
/** Anthropic API key (sk-ant-...) */
|
|
538
611
|
apiKey: string;
|
|
539
|
-
/** Model ID (default: "claude-sonnet-
|
|
612
|
+
/** Model ID (default: "claude-sonnet-5"; e.g. "claude-opus-5" for the most capable tier) */
|
|
540
613
|
model?: string;
|
|
541
614
|
/** Max tokens (default: 8192) */
|
|
542
615
|
maxTokens?: number;
|
|
@@ -576,9 +649,9 @@ interface ClaudeCLIProviderOptions {
|
|
|
576
649
|
* - Session credentials: logs in as the hosting user, upserts the agent record
|
|
577
650
|
* (`POST /api/me/agents`), assigns it to the joined projects, and posts
|
|
578
651
|
* replies with `agentId` so the server attributes them to the agent.
|
|
579
|
-
* - API key credentials: the agent-bound key IS the identity; the agent id
|
|
580
|
-
*
|
|
581
|
-
* agent's assignments.
|
|
652
|
+
* - API key credentials: the agent-bound key IS the identity; the agent id
|
|
653
|
+
* and name come from `GET /api/me` (older servers: the key's Ably clientId
|
|
654
|
+
* `agent:{id}`) and projects are the agent's assignments.
|
|
582
655
|
*
|
|
583
656
|
* Final messages are POSTed to the server (which publishes the Ably echo);
|
|
584
657
|
* only `typing` and `chunk` events are published by the client. Replies are
|
|
@@ -606,6 +679,7 @@ declare class JaibberAgent extends EventEmitter {
|
|
|
606
679
|
private heartbeatTimer;
|
|
607
680
|
private agentId;
|
|
608
681
|
private agentRecord;
|
|
682
|
+
private keyIdentity;
|
|
609
683
|
/** In-memory conversation history per project. */
|
|
610
684
|
private history;
|
|
611
685
|
/** Recent messages per project (id → author/parent) for chain reconstruction. */
|
|
@@ -626,10 +700,20 @@ declare class JaibberAgent extends EventEmitter {
|
|
|
626
700
|
*/
|
|
627
701
|
private unthreadedHops;
|
|
628
702
|
constructor(config: AgentConfig);
|
|
703
|
+
/**
|
|
704
|
+
* Default `"error"` listener, registered by the constructor: logs the error
|
|
705
|
+
* and keeps the process alive. To handle errors yourself without the log,
|
|
706
|
+
* remove it: `agent.off("error", JaibberAgent.defaultErrorListener)`.
|
|
707
|
+
*/
|
|
708
|
+
static readonly defaultErrorListener: (err: unknown) => void;
|
|
709
|
+
/** Emit `"error"` without ever throwing, even if every listener was removed. */
|
|
710
|
+
private emitError;
|
|
629
711
|
/** The agent's server-side id (available after `connect()`). */
|
|
630
712
|
get id(): string | null;
|
|
631
713
|
/** The agent record returned by the server (session mode only). */
|
|
632
714
|
get record(): AgentRecord | null;
|
|
715
|
+
/** The key's agent identity from `GET /api/me` (API-key mode, on servers that have it). */
|
|
716
|
+
get identity(): AgentIdentity | null;
|
|
633
717
|
/** The underlying REST client (authenticated after `connect()`). */
|
|
634
718
|
get api(): JaibberClient;
|
|
635
719
|
/** Projects this agent has joined. */
|
|
@@ -639,6 +723,13 @@ declare class JaibberAgent extends EventEmitter {
|
|
|
639
723
|
private get maxDepth();
|
|
640
724
|
/** Authenticate, register/resolve the agent, connect Ably, subscribe to project channels. */
|
|
641
725
|
connect(): Promise<void>;
|
|
726
|
+
/**
|
|
727
|
+
* API-key mode: ask the server who the key is (`GET /api/me`) so the agent
|
|
728
|
+
* id and name are known before Ably connects. Servers that predate the
|
|
729
|
+
* endpoint answer 404; the id is then read from the Ably token's clientId
|
|
730
|
+
* (`agent:{id}`) once connected, as in 0.4.0.
|
|
731
|
+
*/
|
|
732
|
+
private resolveKeyIdentity;
|
|
642
733
|
/** Stop heartbeats, leave presence, disconnect Ably. */
|
|
643
734
|
disconnect(): Promise<void>;
|
|
644
735
|
/** Register a handler for incoming messages. */
|
|
@@ -784,4 +875,4 @@ declare function parseMentions(text: string): string[];
|
|
|
784
875
|
*/
|
|
785
876
|
declare function mentionsAgent(text: string, agentName: string): boolean;
|
|
786
877
|
|
|
787
|
-
export { AGENT_TEMPLATES, type AblyMessage, type AgentApiKey, type AgentConfig, type AgentControlEvent, type AgentCredentials, type AgentKind, type AgentPresenceData, type AgentProvider, type AgentRecord, type AgentTemplate, AnthropicProvider, type AnthropicProviderOptions, ClaudeCLIProvider, type ClaudeCLIProviderOptions, type EnsureAgentInput, type ExecutionMode, type GlobalPresenceData, GoogleProvider, type GoogleProviderOptions, type IncomingMessage, JaibberAgent, JaibberClient, type MessageAttachment, MessageContext, type MessageHandler, OpenAIProvider, type OpenAIProviderOptions, type OwnMessageTracker, type PersistMessagePayload, type Project, type Provider, type ReplyOptions, type ServerMessage, type Task, TaskContext, type TaskEvent, type TaskHandler, type TaskPriority, type TaskStatus, getTemplate, mentionsAgent, parseMentions };
|
|
878
|
+
export { AGENT_TEMPLATES, type AblyMessage, type AgentApiKey, type AgentConfig, type AgentControlEvent, type AgentCredentials, type AgentIdentity, type AgentKind, type AgentPresenceData, type AgentProvider, type AgentRecord, type AgentTemplate, AnthropicProvider, type AnthropicProviderOptions, ClaudeCLIProvider, type ClaudeCLIProviderOptions, type EnsureAgentInput, type ExecutionMode, type GlobalPresenceData, GoogleProvider, type GoogleProviderOptions, type IncomingMessage, JaibberAgent, JaibberClient, type MessageAttachment, MessageContext, type MessageHandler, OpenAIProvider, type OpenAIProviderOptions, type OwnMessageTracker, type PersistMessagePayload, type Project, type Provider, type ReplyOptions, type ServerMessage, type Task, TaskContext, type TaskEvent, type TaskHandler, type TaskPriority, type TaskStatus, type WhoAmI, getTemplate, mentionsAgent, parseMentions };
|