@arbidocs/sdk 0.3.19 → 0.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{browser-D8aF-wkt.d.cts → browser-z9a2abGo.d.cts} +315 -52
- package/dist/{browser-D8aF-wkt.d.ts → browser-z9a2abGo.d.ts} +315 -52
- package/dist/browser.cjs +7795 -69
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +7796 -70
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +8107 -86
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +232 -4
- package/dist/index.d.ts +232 -4
- package/dist/index.js +8103 -90
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as ConfigStore, a as CliConfig, b as CliCredentials, c as ChatSession, A as AuthHeaders, U as UploadBatchResult, d as UploadOptions, e as UploadResult } from './browser-
|
|
2
|
-
export { f as AgentStepEvent, g as Arbi, h as ArbiApiError, i as ArbiError, j as ArbiOptions, k as ArtifactEvent, l as AuthContext, m as AuthenticatedClient, n as CitationSummary, o as ConnectOptions,
|
|
3
|
-
import '@arbidocs/client';
|
|
1
|
+
import { C as ConfigStore, a as CliConfig, b as CliCredentials, c as ChatSession, A as AuthHeaders, U as UploadBatchResult, d as UploadOptions, e as UploadResult, D as DmCryptoContext } from './browser-z9a2abGo.cjs';
|
|
2
|
+
export { f as AgentStepEvent, g as Arbi, h as ArbiApiError, i as ArbiError, j as ArbiOptions, k as ArtifactEvent, l as AuthContext, m as AuthenticatedClient, n as CitationSummary, o as ConnectOptions, p as DocumentWaiter, q as DocumentWaiterOptions, F as FormattedWsMessage, M as MessageLevel, r as MessageMetadataPayload, s as MessageQueuedEvent, O as OutputTokensDetails, Q as QueryOptions, R as ReconnectOptions, t as ReconnectableWsConnection, u as ResolvedCitation, v as ResponseCompletedEvent, w as ResponseContentPartAddedEvent, x as ResponseCreatedEvent, y as ResponseFailedEvent, z as ResponseOutputItemAddedEvent, B as ResponseOutputItemDoneEvent, E as ResponseOutputTextDeltaEvent, G as ResponseOutputTextDoneEvent, H as ResponseUsage, S as SSEEvent, I as SSEStreamCallbacks, J as SSEStreamResult, K as SSEStreamStartData, L as UserInfo, N as UserInputRequestEvent, P as UserMessageEvent, W as WorkspaceContext, T as WsConnection, V as agentconfig, X as assistant, Y as authenticatedFetch, Z as buildRetrievalChunkTool, _ as buildRetrievalFullContextTool, $ as buildRetrievalTocTool, a0 as connectWebSocket, a1 as connectWithReconnect, a2 as consumeSSEStream, a3 as contacts, a4 as conversations, a5 as countCitations, a6 as createAuthenticatedClient, a7 as createDocumentWaiter, a8 as dm, a9 as doctags, aa as documents, ab as files, ac as formatAgentStepLabel, ad as formatFileSize, ae as formatStreamSummary, af as formatUserName, ag as formatWorkspaceChoices, ah as formatWsMessage, ai as generateEncryptedWorkspaceKey, aj as generateNewWorkspaceKey, ak as getErrorCode, al as getErrorMessage, am as health, an as parseSSEEvents, ao as performPasswordLogin, ap as performSsoDeviceFlowLogin, aq as requireData, ar as requireOk, as as resolveAuth, at as resolveCitations, au as resolveWorkspace, av as responses, aw as selectWorkspace, ax as selectWorkspaceById, ay as settings, az as streamSSE, aA as stripCitationMarkdown, aB as summarizeCitations, aC as tags, aD as workspaces } from './browser-z9a2abGo.cjs';
|
|
3
|
+
import { ArbiClient, components } from '@arbidocs/client';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Configuration persistence — file-based implementation for Node.js environments.
|
|
@@ -150,4 +150,232 @@ declare namespace documentsNode {
|
|
|
150
150
|
export { documentsNode_uploadDirectory as uploadDirectory, documentsNode_uploadLocalFile as uploadLocalFile, documentsNode_uploadZip as uploadZip };
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Agent operations — list, delete persistent agents.
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
type UserResponse = components['schemas']['UserResponse'];
|
|
158
|
+
declare function listAgents(arbi: ArbiClient): Promise<UserResponse[]>;
|
|
159
|
+
declare function deleteAgents(arbi: ArbiClient, agentExtIds: string[]): Promise<{
|
|
160
|
+
[x: string]: unknown;
|
|
161
|
+
}>;
|
|
162
|
+
|
|
163
|
+
declare const agents_deleteAgents: typeof deleteAgents;
|
|
164
|
+
declare const agents_listAgents: typeof listAgents;
|
|
165
|
+
declare namespace agents {
|
|
166
|
+
export { agents_deleteAgents as deleteAgents, agents_listAgents as listAgents };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Session operations — list active sessions, authorize delegation, claim codes.
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
type SessionInfoResponse = components['schemas']['SessionInfoResponse'];
|
|
174
|
+
type AuthorizeResponse = components['schemas']['AuthorizeResponse'];
|
|
175
|
+
type LoginResponse = components['schemas']['LoginResponse'];
|
|
176
|
+
/**
|
|
177
|
+
* List all active sessions for the current user.
|
|
178
|
+
* Agents/delegated sessions see only their own session.
|
|
179
|
+
*/
|
|
180
|
+
declare function listSessions(arbi: ArbiClient): Promise<SessionInfoResponse[]>;
|
|
181
|
+
/**
|
|
182
|
+
* Create a delegated session with pre-populated workspace keys.
|
|
183
|
+
* Returns a 3-word claim code for the recipient.
|
|
184
|
+
*
|
|
185
|
+
* @param workspaces - Map of workspace_ext_id to SealedBox-encrypted workspace key
|
|
186
|
+
* @param options.activeWorkspace - Which workspace to set active (defaults to first)
|
|
187
|
+
* @param options.ttl - Session TTL in seconds (60-604800, default 3600)
|
|
188
|
+
* @param options.persistIdentity - If true, claim creates a persistent Agent identity
|
|
189
|
+
* @param options.name - Human-readable name for persistent agents
|
|
190
|
+
*/
|
|
191
|
+
declare function authorizeSession(arbi: ArbiClient, workspaces: Record<string, string>, options?: {
|
|
192
|
+
activeWorkspace?: string;
|
|
193
|
+
ttl?: number;
|
|
194
|
+
persistIdentity?: boolean;
|
|
195
|
+
name?: string;
|
|
196
|
+
}): Promise<AuthorizeResponse>;
|
|
197
|
+
/**
|
|
198
|
+
* Claim an agent session using a 3-word code.
|
|
199
|
+
* Returns a JWT token and optionally an agent_ext_id for persistent agents.
|
|
200
|
+
*
|
|
201
|
+
* @param claimCode - The 3-word claim code (e.g. "purple-mountain-river")
|
|
202
|
+
* @param signingKey - Ed25519 public key (required for persistent agents)
|
|
203
|
+
*/
|
|
204
|
+
declare function claimSession(arbi: ArbiClient, claimCode: string, signingKey?: string): Promise<LoginResponse>;
|
|
205
|
+
|
|
206
|
+
declare const sessions_authorizeSession: typeof authorizeSession;
|
|
207
|
+
declare const sessions_claimSession: typeof claimSession;
|
|
208
|
+
declare const sessions_listSessions: typeof listSessions;
|
|
209
|
+
declare namespace sessions {
|
|
210
|
+
export { sessions_authorizeSession as authorizeSession, sessions_claimSession as claimSession, sessions_listSessions as listSessions };
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Orchestrator interface for `arbi listen`.
|
|
215
|
+
*
|
|
216
|
+
* An orchestrator is an external agent that receives prompts and returns responses.
|
|
217
|
+
* ARBI acts as the transport layer (encrypted DMs); the orchestrator does the thinking.
|
|
218
|
+
*/
|
|
219
|
+
interface Orchestrator {
|
|
220
|
+
/** Human-readable name (e.g. "claude", "openclaw") */
|
|
221
|
+
readonly name: string;
|
|
222
|
+
/**
|
|
223
|
+
* Send a prompt to the orchestrator and collect the response.
|
|
224
|
+
*
|
|
225
|
+
* @param prompt - The decrypted DM content to process
|
|
226
|
+
* @param context - Optional metadata about the message
|
|
227
|
+
* @returns The orchestrator's text response
|
|
228
|
+
*/
|
|
229
|
+
prompt(prompt: string, context?: PromptContext): Promise<string>;
|
|
230
|
+
/** Clean up resources (kill child processes, close connections, etc.) */
|
|
231
|
+
close?(): Promise<void>;
|
|
232
|
+
}
|
|
233
|
+
interface PromptContext {
|
|
234
|
+
/** Sender's external_id */
|
|
235
|
+
senderExtId?: string;
|
|
236
|
+
/** Sender's email */
|
|
237
|
+
senderEmail?: string;
|
|
238
|
+
/** Workspace context (if any) */
|
|
239
|
+
workspaceId?: string;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Claude Code integration.
|
|
244
|
+
*
|
|
245
|
+
* Spawns `claude -p <prompt> --output-format text` as a child process for each prompt.
|
|
246
|
+
* The prompt is passed as a CLI argument (not stdin).
|
|
247
|
+
*
|
|
248
|
+
* Conversation continuity: first prompt uses --session-id to create a session,
|
|
249
|
+
* subsequent prompts use --resume to continue it. The session ID is derived
|
|
250
|
+
* from the agent's ext_id so it's stable across restarts.
|
|
251
|
+
*
|
|
252
|
+
* The ARBI SKILL.md is injected via --append-system-prompt so Claude knows
|
|
253
|
+
* which CLI commands are available.
|
|
254
|
+
*/
|
|
255
|
+
|
|
256
|
+
interface ClaudeOrchestratorOptions {
|
|
257
|
+
/** Path to the claude CLI binary (defaults to "claude") */
|
|
258
|
+
binaryPath?: string;
|
|
259
|
+
/** ARBI session identifier — used to maintain Claude conversation continuity */
|
|
260
|
+
sessionId: string;
|
|
261
|
+
/** Additional CLI flags (e.g. ["--model", "opus"]) */
|
|
262
|
+
extraArgs?: string[];
|
|
263
|
+
/** Timeout in ms per prompt (defaults to 300_000 = 5 min) */
|
|
264
|
+
timeoutMs?: number;
|
|
265
|
+
/** Override SKILL.md content (defaults to loading from arbi-cli package) */
|
|
266
|
+
skillPrompt?: string;
|
|
267
|
+
}
|
|
268
|
+
declare class ClaudeOrchestrator implements Orchestrator {
|
|
269
|
+
readonly name = "claude";
|
|
270
|
+
private readonly binaryPath;
|
|
271
|
+
private readonly extraArgs;
|
|
272
|
+
private readonly timeoutMs;
|
|
273
|
+
private readonly claudeSessionId;
|
|
274
|
+
private readonly skillPrompt;
|
|
275
|
+
private sessionStarted;
|
|
276
|
+
constructor(options: ClaudeOrchestratorOptions);
|
|
277
|
+
prompt(prompt: string, _context?: PromptContext): Promise<string>;
|
|
278
|
+
private spawnClaude;
|
|
279
|
+
close(): Promise<void>;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* OpenClaw integration.
|
|
284
|
+
*
|
|
285
|
+
* Spawns `openclaw agent --agent <id> --message <prompt> --json` as a child
|
|
286
|
+
* process for each prompt. The gateway handles routing, model selection, and
|
|
287
|
+
* session memory.
|
|
288
|
+
*
|
|
289
|
+
* Session isolation: uses `--session-id` to keep conversations separate per
|
|
290
|
+
* ARBI user. The OpenClaw agent id (e.g. "arbi") is created once during
|
|
291
|
+
* `arbi connect --agent openclaw` via `openclaw agents add`.
|
|
292
|
+
*
|
|
293
|
+
* The ARBI SKILL.md is installed as BOOTSTRAP.md in the agent's workspace
|
|
294
|
+
* during setup, so the agent always has context about arbi commands.
|
|
295
|
+
*/
|
|
296
|
+
|
|
297
|
+
interface OpenClawOrchestratorOptions {
|
|
298
|
+
/** Path to the openclaw CLI binary (defaults to "openclaw") */
|
|
299
|
+
binaryPath?: string;
|
|
300
|
+
/** ARBI session identifier — used for OpenClaw session isolation */
|
|
301
|
+
sessionId: string;
|
|
302
|
+
/** OpenClaw agent id (defaults to "arbi") */
|
|
303
|
+
agentId?: string;
|
|
304
|
+
/** Timeout in ms per prompt (defaults to 300_000 = 5 min) */
|
|
305
|
+
timeoutMs?: number;
|
|
306
|
+
}
|
|
307
|
+
declare class OpenClawOrchestrator implements Orchestrator {
|
|
308
|
+
readonly name = "openclaw";
|
|
309
|
+
private readonly binaryPath;
|
|
310
|
+
private readonly agentId;
|
|
311
|
+
private readonly sessionKey;
|
|
312
|
+
private readonly timeoutMs;
|
|
313
|
+
constructor(options: OpenClawOrchestratorOptions);
|
|
314
|
+
prompt(prompt: string, _context?: PromptContext): Promise<string>;
|
|
315
|
+
close(): Promise<void>;
|
|
316
|
+
private spawnOpenClaw;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* DM Listener Loop.
|
|
321
|
+
*
|
|
322
|
+
* Connects to the WebSocket, listens for incoming DMs, decrypts them,
|
|
323
|
+
* routes to an orchestrator, encrypts the reply, and sends it back.
|
|
324
|
+
*
|
|
325
|
+
* Only processes messages from the agent's parent user (owner).
|
|
326
|
+
*/
|
|
327
|
+
|
|
328
|
+
interface DmListenerOptions {
|
|
329
|
+
/** Authenticated ArbiClient instance */
|
|
330
|
+
arbi: ArbiClient;
|
|
331
|
+
/** Access token for WebSocket auth */
|
|
332
|
+
accessToken: string;
|
|
333
|
+
/** Base URL of the ARBI server */
|
|
334
|
+
baseUrl: string;
|
|
335
|
+
/** DM crypto context for encrypt/decrypt */
|
|
336
|
+
crypto: DmCryptoContext;
|
|
337
|
+
/** Orchestrator to route prompts to */
|
|
338
|
+
orchestrator: Orchestrator;
|
|
339
|
+
/** Parent user ext_id — only process messages from this sender */
|
|
340
|
+
parentExtId: string;
|
|
341
|
+
/** Called when a log-worthy event happens (verbose output) */
|
|
342
|
+
onLog?: (message: string) => void;
|
|
343
|
+
/** Called when an error occurs during processing */
|
|
344
|
+
onError?: (message: string, error?: unknown) => void;
|
|
345
|
+
}
|
|
346
|
+
interface DmListener {
|
|
347
|
+
/** Stop listening and clean up */
|
|
348
|
+
close(): void;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Start listening for DMs and routing them to the orchestrator.
|
|
352
|
+
*
|
|
353
|
+
* Connects via WebSocket with auto-reconnect. For each incoming DM:
|
|
354
|
+
* 1. Filters to parent user only
|
|
355
|
+
* 2. Decrypts the message
|
|
356
|
+
* 3. Sends plaintext to orchestrator.prompt()
|
|
357
|
+
* 4. Encrypts the response
|
|
358
|
+
* 5. Sends encrypted reply via DM
|
|
359
|
+
*/
|
|
360
|
+
declare function startDmListener(options: DmListenerOptions): Promise<DmListener>;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Listen module — integration interface, implementations, and DM listener loop.
|
|
364
|
+
*/
|
|
365
|
+
|
|
366
|
+
type index_ClaudeOrchestrator = ClaudeOrchestrator;
|
|
367
|
+
declare const index_ClaudeOrchestrator: typeof ClaudeOrchestrator;
|
|
368
|
+
type index_ClaudeOrchestratorOptions = ClaudeOrchestratorOptions;
|
|
369
|
+
type index_DmListener = DmListener;
|
|
370
|
+
type index_DmListenerOptions = DmListenerOptions;
|
|
371
|
+
type index_OpenClawOrchestrator = OpenClawOrchestrator;
|
|
372
|
+
declare const index_OpenClawOrchestrator: typeof OpenClawOrchestrator;
|
|
373
|
+
type index_OpenClawOrchestratorOptions = OpenClawOrchestratorOptions;
|
|
374
|
+
type index_Orchestrator = Orchestrator;
|
|
375
|
+
type index_PromptContext = PromptContext;
|
|
376
|
+
declare const index_startDmListener: typeof startDmListener;
|
|
377
|
+
declare namespace index {
|
|
378
|
+
export { index_ClaudeOrchestrator as ClaudeOrchestrator, type index_ClaudeOrchestratorOptions as ClaudeOrchestratorOptions, type index_DmListener as DmListener, type index_DmListenerOptions as DmListenerOptions, index_OpenClawOrchestrator as OpenClawOrchestrator, type index_OpenClawOrchestratorOptions as OpenClawOrchestratorOptions, type index_Orchestrator as Orchestrator, type index_PromptContext as PromptContext, index_startDmListener as startDmListener };
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export { AuthHeaders, ChatSession, ClaudeOrchestrator, type ClaudeOrchestratorOptions, CliConfig, CliCredentials, ConfigStore, DmCryptoContext, type DmListener, type DmListenerOptions, FileConfigStore, OpenClawOrchestrator, type OpenClawOrchestratorOptions, type Orchestrator, type PromptContext, agents, deviceFlow, documentsNode, index as listen, sessions, startDmListener };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as ConfigStore, a as CliConfig, b as CliCredentials, c as ChatSession, A as AuthHeaders, U as UploadBatchResult, d as UploadOptions, e as UploadResult } from './browser-
|
|
2
|
-
export { f as AgentStepEvent, g as Arbi, h as ArbiApiError, i as ArbiError, j as ArbiOptions, k as ArtifactEvent, l as AuthContext, m as AuthenticatedClient, n as CitationSummary, o as ConnectOptions,
|
|
3
|
-
import '@arbidocs/client';
|
|
1
|
+
import { C as ConfigStore, a as CliConfig, b as CliCredentials, c as ChatSession, A as AuthHeaders, U as UploadBatchResult, d as UploadOptions, e as UploadResult, D as DmCryptoContext } from './browser-z9a2abGo.js';
|
|
2
|
+
export { f as AgentStepEvent, g as Arbi, h as ArbiApiError, i as ArbiError, j as ArbiOptions, k as ArtifactEvent, l as AuthContext, m as AuthenticatedClient, n as CitationSummary, o as ConnectOptions, p as DocumentWaiter, q as DocumentWaiterOptions, F as FormattedWsMessage, M as MessageLevel, r as MessageMetadataPayload, s as MessageQueuedEvent, O as OutputTokensDetails, Q as QueryOptions, R as ReconnectOptions, t as ReconnectableWsConnection, u as ResolvedCitation, v as ResponseCompletedEvent, w as ResponseContentPartAddedEvent, x as ResponseCreatedEvent, y as ResponseFailedEvent, z as ResponseOutputItemAddedEvent, B as ResponseOutputItemDoneEvent, E as ResponseOutputTextDeltaEvent, G as ResponseOutputTextDoneEvent, H as ResponseUsage, S as SSEEvent, I as SSEStreamCallbacks, J as SSEStreamResult, K as SSEStreamStartData, L as UserInfo, N as UserInputRequestEvent, P as UserMessageEvent, W as WorkspaceContext, T as WsConnection, V as agentconfig, X as assistant, Y as authenticatedFetch, Z as buildRetrievalChunkTool, _ as buildRetrievalFullContextTool, $ as buildRetrievalTocTool, a0 as connectWebSocket, a1 as connectWithReconnect, a2 as consumeSSEStream, a3 as contacts, a4 as conversations, a5 as countCitations, a6 as createAuthenticatedClient, a7 as createDocumentWaiter, a8 as dm, a9 as doctags, aa as documents, ab as files, ac as formatAgentStepLabel, ad as formatFileSize, ae as formatStreamSummary, af as formatUserName, ag as formatWorkspaceChoices, ah as formatWsMessage, ai as generateEncryptedWorkspaceKey, aj as generateNewWorkspaceKey, ak as getErrorCode, al as getErrorMessage, am as health, an as parseSSEEvents, ao as performPasswordLogin, ap as performSsoDeviceFlowLogin, aq as requireData, ar as requireOk, as as resolveAuth, at as resolveCitations, au as resolveWorkspace, av as responses, aw as selectWorkspace, ax as selectWorkspaceById, ay as settings, az as streamSSE, aA as stripCitationMarkdown, aB as summarizeCitations, aC as tags, aD as workspaces } from './browser-z9a2abGo.js';
|
|
3
|
+
import { ArbiClient, components } from '@arbidocs/client';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Configuration persistence — file-based implementation for Node.js environments.
|
|
@@ -150,4 +150,232 @@ declare namespace documentsNode {
|
|
|
150
150
|
export { documentsNode_uploadDirectory as uploadDirectory, documentsNode_uploadLocalFile as uploadLocalFile, documentsNode_uploadZip as uploadZip };
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Agent operations — list, delete persistent agents.
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
type UserResponse = components['schemas']['UserResponse'];
|
|
158
|
+
declare function listAgents(arbi: ArbiClient): Promise<UserResponse[]>;
|
|
159
|
+
declare function deleteAgents(arbi: ArbiClient, agentExtIds: string[]): Promise<{
|
|
160
|
+
[x: string]: unknown;
|
|
161
|
+
}>;
|
|
162
|
+
|
|
163
|
+
declare const agents_deleteAgents: typeof deleteAgents;
|
|
164
|
+
declare const agents_listAgents: typeof listAgents;
|
|
165
|
+
declare namespace agents {
|
|
166
|
+
export { agents_deleteAgents as deleteAgents, agents_listAgents as listAgents };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Session operations — list active sessions, authorize delegation, claim codes.
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
type SessionInfoResponse = components['schemas']['SessionInfoResponse'];
|
|
174
|
+
type AuthorizeResponse = components['schemas']['AuthorizeResponse'];
|
|
175
|
+
type LoginResponse = components['schemas']['LoginResponse'];
|
|
176
|
+
/**
|
|
177
|
+
* List all active sessions for the current user.
|
|
178
|
+
* Agents/delegated sessions see only their own session.
|
|
179
|
+
*/
|
|
180
|
+
declare function listSessions(arbi: ArbiClient): Promise<SessionInfoResponse[]>;
|
|
181
|
+
/**
|
|
182
|
+
* Create a delegated session with pre-populated workspace keys.
|
|
183
|
+
* Returns a 3-word claim code for the recipient.
|
|
184
|
+
*
|
|
185
|
+
* @param workspaces - Map of workspace_ext_id to SealedBox-encrypted workspace key
|
|
186
|
+
* @param options.activeWorkspace - Which workspace to set active (defaults to first)
|
|
187
|
+
* @param options.ttl - Session TTL in seconds (60-604800, default 3600)
|
|
188
|
+
* @param options.persistIdentity - If true, claim creates a persistent Agent identity
|
|
189
|
+
* @param options.name - Human-readable name for persistent agents
|
|
190
|
+
*/
|
|
191
|
+
declare function authorizeSession(arbi: ArbiClient, workspaces: Record<string, string>, options?: {
|
|
192
|
+
activeWorkspace?: string;
|
|
193
|
+
ttl?: number;
|
|
194
|
+
persistIdentity?: boolean;
|
|
195
|
+
name?: string;
|
|
196
|
+
}): Promise<AuthorizeResponse>;
|
|
197
|
+
/**
|
|
198
|
+
* Claim an agent session using a 3-word code.
|
|
199
|
+
* Returns a JWT token and optionally an agent_ext_id for persistent agents.
|
|
200
|
+
*
|
|
201
|
+
* @param claimCode - The 3-word claim code (e.g. "purple-mountain-river")
|
|
202
|
+
* @param signingKey - Ed25519 public key (required for persistent agents)
|
|
203
|
+
*/
|
|
204
|
+
declare function claimSession(arbi: ArbiClient, claimCode: string, signingKey?: string): Promise<LoginResponse>;
|
|
205
|
+
|
|
206
|
+
declare const sessions_authorizeSession: typeof authorizeSession;
|
|
207
|
+
declare const sessions_claimSession: typeof claimSession;
|
|
208
|
+
declare const sessions_listSessions: typeof listSessions;
|
|
209
|
+
declare namespace sessions {
|
|
210
|
+
export { sessions_authorizeSession as authorizeSession, sessions_claimSession as claimSession, sessions_listSessions as listSessions };
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Orchestrator interface for `arbi listen`.
|
|
215
|
+
*
|
|
216
|
+
* An orchestrator is an external agent that receives prompts and returns responses.
|
|
217
|
+
* ARBI acts as the transport layer (encrypted DMs); the orchestrator does the thinking.
|
|
218
|
+
*/
|
|
219
|
+
interface Orchestrator {
|
|
220
|
+
/** Human-readable name (e.g. "claude", "openclaw") */
|
|
221
|
+
readonly name: string;
|
|
222
|
+
/**
|
|
223
|
+
* Send a prompt to the orchestrator and collect the response.
|
|
224
|
+
*
|
|
225
|
+
* @param prompt - The decrypted DM content to process
|
|
226
|
+
* @param context - Optional metadata about the message
|
|
227
|
+
* @returns The orchestrator's text response
|
|
228
|
+
*/
|
|
229
|
+
prompt(prompt: string, context?: PromptContext): Promise<string>;
|
|
230
|
+
/** Clean up resources (kill child processes, close connections, etc.) */
|
|
231
|
+
close?(): Promise<void>;
|
|
232
|
+
}
|
|
233
|
+
interface PromptContext {
|
|
234
|
+
/** Sender's external_id */
|
|
235
|
+
senderExtId?: string;
|
|
236
|
+
/** Sender's email */
|
|
237
|
+
senderEmail?: string;
|
|
238
|
+
/** Workspace context (if any) */
|
|
239
|
+
workspaceId?: string;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Claude Code integration.
|
|
244
|
+
*
|
|
245
|
+
* Spawns `claude -p <prompt> --output-format text` as a child process for each prompt.
|
|
246
|
+
* The prompt is passed as a CLI argument (not stdin).
|
|
247
|
+
*
|
|
248
|
+
* Conversation continuity: first prompt uses --session-id to create a session,
|
|
249
|
+
* subsequent prompts use --resume to continue it. The session ID is derived
|
|
250
|
+
* from the agent's ext_id so it's stable across restarts.
|
|
251
|
+
*
|
|
252
|
+
* The ARBI SKILL.md is injected via --append-system-prompt so Claude knows
|
|
253
|
+
* which CLI commands are available.
|
|
254
|
+
*/
|
|
255
|
+
|
|
256
|
+
interface ClaudeOrchestratorOptions {
|
|
257
|
+
/** Path to the claude CLI binary (defaults to "claude") */
|
|
258
|
+
binaryPath?: string;
|
|
259
|
+
/** ARBI session identifier — used to maintain Claude conversation continuity */
|
|
260
|
+
sessionId: string;
|
|
261
|
+
/** Additional CLI flags (e.g. ["--model", "opus"]) */
|
|
262
|
+
extraArgs?: string[];
|
|
263
|
+
/** Timeout in ms per prompt (defaults to 300_000 = 5 min) */
|
|
264
|
+
timeoutMs?: number;
|
|
265
|
+
/** Override SKILL.md content (defaults to loading from arbi-cli package) */
|
|
266
|
+
skillPrompt?: string;
|
|
267
|
+
}
|
|
268
|
+
declare class ClaudeOrchestrator implements Orchestrator {
|
|
269
|
+
readonly name = "claude";
|
|
270
|
+
private readonly binaryPath;
|
|
271
|
+
private readonly extraArgs;
|
|
272
|
+
private readonly timeoutMs;
|
|
273
|
+
private readonly claudeSessionId;
|
|
274
|
+
private readonly skillPrompt;
|
|
275
|
+
private sessionStarted;
|
|
276
|
+
constructor(options: ClaudeOrchestratorOptions);
|
|
277
|
+
prompt(prompt: string, _context?: PromptContext): Promise<string>;
|
|
278
|
+
private spawnClaude;
|
|
279
|
+
close(): Promise<void>;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* OpenClaw integration.
|
|
284
|
+
*
|
|
285
|
+
* Spawns `openclaw agent --agent <id> --message <prompt> --json` as a child
|
|
286
|
+
* process for each prompt. The gateway handles routing, model selection, and
|
|
287
|
+
* session memory.
|
|
288
|
+
*
|
|
289
|
+
* Session isolation: uses `--session-id` to keep conversations separate per
|
|
290
|
+
* ARBI user. The OpenClaw agent id (e.g. "arbi") is created once during
|
|
291
|
+
* `arbi connect --agent openclaw` via `openclaw agents add`.
|
|
292
|
+
*
|
|
293
|
+
* The ARBI SKILL.md is installed as BOOTSTRAP.md in the agent's workspace
|
|
294
|
+
* during setup, so the agent always has context about arbi commands.
|
|
295
|
+
*/
|
|
296
|
+
|
|
297
|
+
interface OpenClawOrchestratorOptions {
|
|
298
|
+
/** Path to the openclaw CLI binary (defaults to "openclaw") */
|
|
299
|
+
binaryPath?: string;
|
|
300
|
+
/** ARBI session identifier — used for OpenClaw session isolation */
|
|
301
|
+
sessionId: string;
|
|
302
|
+
/** OpenClaw agent id (defaults to "arbi") */
|
|
303
|
+
agentId?: string;
|
|
304
|
+
/** Timeout in ms per prompt (defaults to 300_000 = 5 min) */
|
|
305
|
+
timeoutMs?: number;
|
|
306
|
+
}
|
|
307
|
+
declare class OpenClawOrchestrator implements Orchestrator {
|
|
308
|
+
readonly name = "openclaw";
|
|
309
|
+
private readonly binaryPath;
|
|
310
|
+
private readonly agentId;
|
|
311
|
+
private readonly sessionKey;
|
|
312
|
+
private readonly timeoutMs;
|
|
313
|
+
constructor(options: OpenClawOrchestratorOptions);
|
|
314
|
+
prompt(prompt: string, _context?: PromptContext): Promise<string>;
|
|
315
|
+
close(): Promise<void>;
|
|
316
|
+
private spawnOpenClaw;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* DM Listener Loop.
|
|
321
|
+
*
|
|
322
|
+
* Connects to the WebSocket, listens for incoming DMs, decrypts them,
|
|
323
|
+
* routes to an orchestrator, encrypts the reply, and sends it back.
|
|
324
|
+
*
|
|
325
|
+
* Only processes messages from the agent's parent user (owner).
|
|
326
|
+
*/
|
|
327
|
+
|
|
328
|
+
interface DmListenerOptions {
|
|
329
|
+
/** Authenticated ArbiClient instance */
|
|
330
|
+
arbi: ArbiClient;
|
|
331
|
+
/** Access token for WebSocket auth */
|
|
332
|
+
accessToken: string;
|
|
333
|
+
/** Base URL of the ARBI server */
|
|
334
|
+
baseUrl: string;
|
|
335
|
+
/** DM crypto context for encrypt/decrypt */
|
|
336
|
+
crypto: DmCryptoContext;
|
|
337
|
+
/** Orchestrator to route prompts to */
|
|
338
|
+
orchestrator: Orchestrator;
|
|
339
|
+
/** Parent user ext_id — only process messages from this sender */
|
|
340
|
+
parentExtId: string;
|
|
341
|
+
/** Called when a log-worthy event happens (verbose output) */
|
|
342
|
+
onLog?: (message: string) => void;
|
|
343
|
+
/** Called when an error occurs during processing */
|
|
344
|
+
onError?: (message: string, error?: unknown) => void;
|
|
345
|
+
}
|
|
346
|
+
interface DmListener {
|
|
347
|
+
/** Stop listening and clean up */
|
|
348
|
+
close(): void;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Start listening for DMs and routing them to the orchestrator.
|
|
352
|
+
*
|
|
353
|
+
* Connects via WebSocket with auto-reconnect. For each incoming DM:
|
|
354
|
+
* 1. Filters to parent user only
|
|
355
|
+
* 2. Decrypts the message
|
|
356
|
+
* 3. Sends plaintext to orchestrator.prompt()
|
|
357
|
+
* 4. Encrypts the response
|
|
358
|
+
* 5. Sends encrypted reply via DM
|
|
359
|
+
*/
|
|
360
|
+
declare function startDmListener(options: DmListenerOptions): Promise<DmListener>;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Listen module — integration interface, implementations, and DM listener loop.
|
|
364
|
+
*/
|
|
365
|
+
|
|
366
|
+
type index_ClaudeOrchestrator = ClaudeOrchestrator;
|
|
367
|
+
declare const index_ClaudeOrchestrator: typeof ClaudeOrchestrator;
|
|
368
|
+
type index_ClaudeOrchestratorOptions = ClaudeOrchestratorOptions;
|
|
369
|
+
type index_DmListener = DmListener;
|
|
370
|
+
type index_DmListenerOptions = DmListenerOptions;
|
|
371
|
+
type index_OpenClawOrchestrator = OpenClawOrchestrator;
|
|
372
|
+
declare const index_OpenClawOrchestrator: typeof OpenClawOrchestrator;
|
|
373
|
+
type index_OpenClawOrchestratorOptions = OpenClawOrchestratorOptions;
|
|
374
|
+
type index_Orchestrator = Orchestrator;
|
|
375
|
+
type index_PromptContext = PromptContext;
|
|
376
|
+
declare const index_startDmListener: typeof startDmListener;
|
|
377
|
+
declare namespace index {
|
|
378
|
+
export { index_ClaudeOrchestrator as ClaudeOrchestrator, type index_ClaudeOrchestratorOptions as ClaudeOrchestratorOptions, type index_DmListener as DmListener, type index_DmListenerOptions as DmListenerOptions, index_OpenClawOrchestrator as OpenClawOrchestrator, type index_OpenClawOrchestratorOptions as OpenClawOrchestratorOptions, type index_Orchestrator as Orchestrator, type index_PromptContext as PromptContext, index_startDmListener as startDmListener };
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export { AuthHeaders, ChatSession, ClaudeOrchestrator, type ClaudeOrchestratorOptions, CliConfig, CliCredentials, ConfigStore, DmCryptoContext, type DmListener, type DmListenerOptions, FileConfigStore, OpenClawOrchestrator, type OpenClawOrchestratorOptions, type Orchestrator, type PromptContext, agents, deviceFlow, documentsNode, index as listen, sessions, startDmListener };
|