@arbidocs/sdk 0.3.65 → 0.3.67

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.
@@ -84,16 +84,40 @@ interface CliConfig {
84
84
  }
85
85
  interface CliCredentials {
86
86
  email: string;
87
+ /** User's external ID (``usr-*`` or ``agt-*``). Needed by features
88
+ * that key on user identity (DM crypto, contact resolution, etc.).
89
+ * Set on every login from the API's response; required by
90
+ * ``buildAuthFromCache`` to restore the session client-side
91
+ * without a server round-trip. */
92
+ userExtId?: string;
87
93
  signingPrivateKeyBase64: string;
88
94
  serverSessionKeyBase64: string;
89
- /** Cached access token from last successful resolveWorkspace() */
95
+ /** Cached access token for the live server session. Valid as long as
96
+ * ``tokenTimestamp`` is within ``TOKEN_MAX_AGE_MS``. */
90
97
  accessToken?: string;
91
- /** Cached session-sealed workspace key from last successful resolveWorkspace() */
92
- sealedWorkspaceKey?: string;
93
- /** Workspace ID the cached token was issued for */
94
- workspaceId?: string;
95
- /** ISO timestamp when the token was cached */
98
+ /** ISO timestamp when ``accessToken`` was issued. Used for client-side
99
+ * TTL — the server enforces JWT exp independently. */
96
100
  tokenTimestamp?: string;
101
+ /**
102
+ * Workspaces whose keys are already deposited on the current server
103
+ * session — i.e. the keys of ``session.workspaces`` in the backend's
104
+ * Redis entry. Client-side mirror so we can skip a redundant `/open`
105
+ * round-trip when we've already deposited a workspace's key during
106
+ * this session's lifetime.
107
+ *
108
+ * Both grant types end up in this set:
109
+ * - **Permanent** — first `/open` for the workspace POSTs the
110
+ * wrapped_key and the server adds it to ``session.workspaces``.
111
+ * - **Session-only** (PA agents, temporary shares) — the backend
112
+ * pre-deposits via ``store_workspace_key_for_session_pubkey``,
113
+ * then the client's `/open` is just a metadata fetch.
114
+ *
115
+ * Cleared on every event that invalidates the session: fresh login,
116
+ * auto-relogin on 401, logout. The new session starts with an empty
117
+ * ``session.workspaces`` server-side, so this client mirror must
118
+ * start empty too.
119
+ */
120
+ openedWorkspaces?: string[];
97
121
  /** Auth0 SSO token — needed for session recovery of SSO users */
98
122
  ssoToken?: string;
99
123
  /** Parent user ext_id — set for persistent agent accounts */
@@ -152,7 +176,6 @@ interface AuthContext {
152
176
  interface WorkspaceContext extends AuthContext {
153
177
  workspaceId: string;
154
178
  accessToken: string;
155
- sealedWorkspaceKey: string;
156
179
  }
157
180
  /** Minimal workspace shape required by formatWorkspaceChoices. */
158
181
  interface WorkspaceForChoice {
@@ -232,23 +255,40 @@ declare function generateNewWorkspaceKey(arbi: ArbiClient, serverSessionKey: Uin
232
255
  * never log, persist, or transmit it over the wire.
233
256
  */
234
257
  declare function getRawWorkspaceKey(arbi: ArbiClient, workspaceId: string, signingPrivateKeyBase64: string): Promise<Uint8Array>;
235
- /**
236
- * Find a workspace by ID in the user's workspace list, select it, and return workspace info.
237
- */
238
258
  declare function selectWorkspaceById(arbi: ArbiClient, workspaceId: string, serverSessionKey: Uint8Array, signingPrivateKeyBase64: string): Promise<{
239
259
  external_id: string;
240
260
  name: string;
241
- wrapped_key: string;
261
+ wrapped_key: string | null;
262
+ /** The session-sealed workspace key — `null` for session-only grants */
263
+ sealed_key: string | null;
242
264
  }>;
243
265
  /**
244
266
  * Authenticate and return the SDK client + config.
245
- * Throws ArbiError instead of calling process.exit.
267
+ *
268
+ * Fast path: reuse the live server session via cached accessToken.
269
+ * Slow path: fresh ``loginWithKey`` (mints a new session, clears
270
+ * ``openedWorkspaces``).
246
271
  */
247
272
  declare function resolveAuth(store: ConfigStore): Promise<AuthContext>;
248
273
  /**
249
- * Authenticate, resolve workspace, and set up headers.
250
- * Uses cached JWT when available for the same workspace and not expired.
251
- * Throws ArbiError instead of calling process.exit.
274
+ * Authenticate, ensure the workspace's key is deposited on the current
275
+ * server session, and return everything callers need.
276
+ *
277
+ * Decisions are independent:
278
+ * 1. **Session aliveness** — reuse the live session if its accessToken
279
+ * is within TTL; otherwise fresh login. (Fresh login = new session
280
+ * = ``openedWorkspaces`` reset to ``[]``.)
281
+ * 2. **Workspace deposit** — if ``workspaceId`` already appears in
282
+ * ``creds.openedWorkspaces``, the server's session already holds
283
+ * its key; no ``/open`` needed. Otherwise call ``/open`` once and
284
+ * append to the set.
285
+ *
286
+ * Splitting these matters: previously the cache was gated on
287
+ * ``creds.workspaceId === workspaceId``, so any switch between
288
+ * workspaces forced a re-login. That orphaned PA-agent session
289
+ * deposits and broke ``arbi docs`` for them. Now switching workspaces
290
+ * within a live session just adds another entry to
291
+ * ``openedWorkspaces`` — no re-login, no orphaned deposits.
252
292
  */
253
293
  declare function resolveWorkspace(store: ConfigStore, workspaceOpt?: string): Promise<WorkspaceContext>;
254
294
 
@@ -540,6 +580,7 @@ declare function formatUserName(user: UserInfo | null | undefined): string;
540
580
  type MessageMetadataPayload = components['schemas']['MessageMetadataPayload'];
541
581
  type CitationData$2 = components['schemas']['CitationData'];
542
582
  type Chunk$1 = components['schemas']['Chunk'];
583
+
543
584
  /** A fully resolved citation with its source chunks. */
544
585
  interface ResolvedCitation {
545
586
  /** Citation number as a string (e.g. "1", "2") */
@@ -681,6 +722,11 @@ declare function sanitizeFolderPath(folderPath: string): string;
681
722
  interface UploadOptions {
682
723
  folder?: string;
683
724
  configExtId?: string;
725
+ /** Work-product type for the uploaded doc — ``source`` (default),
726
+ * ``skill``, ``memory``, ``artifact``. Skills must be uploaded with
727
+ * ``wp_type='skill'`` AND in a ``skills/<slug>`` folder so the
728
+ * backend's ``SkillManager`` recognises them. */
729
+ wpType?: 'source' | 'skill' | 'memory' | 'artifact' | 'webpage';
684
730
  }
685
731
  interface SkippedFile {
686
732
  file_name: string;
@@ -1131,20 +1177,100 @@ declare function queryAssistant(options: AssistantQueryOptions): Promise<Respons
1131
1177
  * The assistant_message_ext_id identifies which agent message to answer.
1132
1178
  */
1133
1179
  declare function respondToAgent(arbi: ArbiClient, assistantMessageExtId: string, answer: string): Promise<unknown>;
1180
+ /** A single user-invocable skill as exposed by ``GET /v1/assistant/skills``.
1181
+ * Re-exported with the schema-generated shape so callers don't have to
1182
+ * reach into ``components['schemas']`` themselves. */
1183
+ type SkillSummary = components['schemas']['SkillSummaryResponse'];
1184
+ /**
1185
+ * List the skills the caller can invoke in the active workspace.
1186
+ *
1187
+ * Powers slash-command autocomplete in the TUI, CLI, and React UI.
1188
+ * Returns lightweight metadata only (name, description, args hint) —
1189
+ * never the SKILL.md body. To read the body, fetch the document via
1190
+ * ``getParsedContent(authHeaders, doc_ext_id, 'content')``.
1191
+ *
1192
+ * Scoped to the workspace the caller has open (the backend uses the
1193
+ * session's ``active_workspace``); cross-workspace listing isn't
1194
+ * supported because each workspace has its own encryption key.
1195
+ *
1196
+ * @param includeHidden When ``true``, returns skills with
1197
+ * ``user-invocable: false`` in their frontmatter. Off by default —
1198
+ * those are typically agent-only or in-progress skills that
1199
+ * shouldn't surface in slash menus.
1200
+ */
1201
+ declare function listSkills(arbi: ArbiClient, options?: {
1202
+ includeHidden?: boolean;
1203
+ }): Promise<SkillSummary[]>;
1204
+ /** Parsed slash-command shape, regardless of frontend. */
1205
+ interface ParsedSlashCommand {
1206
+ /** The lowercased token immediately after ``/``. */
1207
+ slug: string;
1208
+ /** Everything after the first whitespace, untrimmed. ``""`` when the
1209
+ * user hasn't typed any arguments yet. */
1210
+ args: string;
1211
+ }
1212
+ /**
1213
+ * Parse a *submitted* slash command (or anything that walks like one).
1214
+ *
1215
+ * Permissive about whitespace: leading whitespace is tolerated so
1216
+ * pasted snippets like `` /summarize foo`` still parse. The slug
1217
+ * grammar matches the backend's ``SkillManager._slug`` output (alnum
1218
+ * + underscore + dash), which is also what the autocomplete menus
1219
+ * surface, so there's exactly one definition of "valid slug."
1220
+ *
1221
+ * Returns ``null`` if the input doesn't start with ``/<slug>``.
1222
+ *
1223
+ * Use this in **dispatchers** (TUI command-registry) and **pre-flight
1224
+ * hint** paths where you want to react to any in-progress or
1225
+ * submitted slash command. For the narrower "user is typing a slug
1226
+ * with no args yet" UX, use ``parseSlashTokenInProgress``.
1227
+ */
1228
+ declare function parseSlashCommand(input: string): ParsedSlashCommand | null;
1229
+ /**
1230
+ * Parse a slash-command **in progress** — the buffer is just
1231
+ * ``/<token>`` with no committed arguments yet (no space after the
1232
+ * slug). This is the trigger condition for the autocomplete menu:
1233
+ * the moment the user types a space, the slug is "committed" and the
1234
+ * menu should hide so further keystrokes form the arguments.
1235
+ *
1236
+ * Empty token is allowed (a bare ``/``) so the menu opens immediately
1237
+ * and lists everything — same UX as Slack/Discord.
1238
+ */
1239
+ declare function parseSlashTokenInProgress(buffer: string): string | null;
1240
+ /**
1241
+ * Filter a list of skill summaries by a typed query and sort by
1242
+ * relevance: prefix matches first, then substring matches, alphabetic
1243
+ * within each bucket. Pinned slugs (the user's favourites — surfaced
1244
+ * by the React library modal) float to the very top.
1245
+ *
1246
+ * Pure function — same logic used by the React popover, the TUI
1247
+ * autocomplete, and the CLI. Pulling it out of the React component
1248
+ * means a change to the matching rules lands in one place.
1249
+ */
1250
+ declare function filterSkills<T extends {
1251
+ slug?: string;
1252
+ name: string;
1253
+ }>(items: ReadonlyArray<T>, query: string, pinned?: ReadonlyArray<string>): T[];
1134
1254
 
1135
1255
  type assistant_AssistantQueryOptions = AssistantQueryOptions;
1136
1256
  type assistant_Chunk = Chunk;
1137
1257
  type assistant_ChunkMetadata = ChunkMetadata;
1258
+ type assistant_ParsedSlashCommand = ParsedSlashCommand;
1138
1259
  type assistant_RetrieveOptions = RetrieveOptions;
1139
1260
  type assistant_RetrieveResult = RetrieveResult;
1261
+ type assistant_SkillSummary = SkillSummary;
1140
1262
  declare const assistant_buildRetrievalChunkTool: typeof buildRetrievalChunkTool;
1141
1263
  declare const assistant_buildRetrievalFullContextTool: typeof buildRetrievalFullContextTool;
1142
1264
  declare const assistant_buildRetrievalTocTool: typeof buildRetrievalTocTool;
1265
+ declare const assistant_filterSkills: typeof filterSkills;
1266
+ declare const assistant_listSkills: typeof listSkills;
1267
+ declare const assistant_parseSlashCommand: typeof parseSlashCommand;
1268
+ declare const assistant_parseSlashTokenInProgress: typeof parseSlashTokenInProgress;
1143
1269
  declare const assistant_queryAssistant: typeof queryAssistant;
1144
1270
  declare const assistant_respondToAgent: typeof respondToAgent;
1145
1271
  declare const assistant_retrieve: typeof retrieve;
1146
1272
  declare namespace assistant {
1147
- export { type assistant_AssistantQueryOptions as AssistantQueryOptions, type assistant_Chunk as Chunk, type assistant_ChunkMetadata as ChunkMetadata, type assistant_RetrieveOptions as RetrieveOptions, type assistant_RetrieveResult as RetrieveResult, assistant_buildRetrievalChunkTool as buildRetrievalChunkTool, assistant_buildRetrievalFullContextTool as buildRetrievalFullContextTool, assistant_buildRetrievalTocTool as buildRetrievalTocTool, assistant_queryAssistant as queryAssistant, assistant_respondToAgent as respondToAgent, assistant_retrieve as retrieve };
1273
+ export { type assistant_AssistantQueryOptions as AssistantQueryOptions, type assistant_Chunk as Chunk, type assistant_ChunkMetadata as ChunkMetadata, type assistant_ParsedSlashCommand as ParsedSlashCommand, type assistant_RetrieveOptions as RetrieveOptions, type assistant_RetrieveResult as RetrieveResult, type assistant_SkillSummary as SkillSummary, assistant_buildRetrievalChunkTool as buildRetrievalChunkTool, assistant_buildRetrievalFullContextTool as buildRetrievalFullContextTool, assistant_buildRetrievalTocTool as buildRetrievalTocTool, assistant_filterSkills as filterSkills, assistant_listSkills as listSkills, assistant_parseSlashCommand as parseSlashCommand, assistant_parseSlashTokenInProgress as parseSlashTokenInProgress, assistant_queryAssistant as queryAssistant, assistant_respondToAgent as respondToAgent, assistant_retrieve as retrieve };
1148
1274
  }
1149
1275
 
1150
1276
  /**
@@ -4220,4 +4346,4 @@ declare namespace responses {
4220
4346
  export { type responses_SubmitBackgroundQueryOptions as SubmitBackgroundQueryOptions, responses_extractResponseText as extractResponseText, responses_getResponse as getResponse, responses_submitBackgroundQuery as submitBackgroundQuery };
4221
4347
  }
4222
4348
 
4223
- export { type UserInputRequestEvent as $, type AuthHeaders as A, type ReconnectableWsConnection as B, type ConfigStore as C, type DmCryptoContext as D, type ResolvedCitation as E, type FormattedWsMessage as F, type ResponseCompletedEvent as G, type ResponseContentPartAddedEvent as H, type ResponseCreatedEvent as I, type ResponseFailedEvent as J, type ResponseOutputItemAddedEvent as K, type ListAllOptions as L, type MessageLevel as M, type ResponseOutputItemDoneEvent as N, type OutputTokensDetails as O, type ResponseOutputTextDeltaEvent as P, type QueryOptions as Q, type ReconnectOptions as R, type SkippedFile as S, type ResponseOutputTextDoneEvent as T, type UploadResult as U, type ResponseUsage as V, type SSEEvent as W, type SSEStreamCallbacks as X, type SSEStreamResult as Y, type SSEStreamStartData as Z, type UserInfo as _, type CliConfig as a, type UserMessageEvent as a0, type WorkspaceContext as a1, type WsConnection as a2, agentconfig as a3, assistant as a4, authenticatedFetch as a5, buildRetrievalChunkTool as a6, buildRetrievalFullContextTool as a7, buildRetrievalTocTool as a8, connectWebSocket as a9, performSsoDeviceFlowLogin as aA, requireData as aB, requireOk as aC, resolveAuth as aD, resolveCitations as aE, resolveWorkspace as aF, responses as aG, selectWorkspace as aH, selectWorkspaceById as aI, settings as aJ, streamSSE as aK, stripCitationMarkdown as aL, summarizeCitations as aM, tags as aN, workspaces as aO, type ArbiErrorEvent as aP, connectWithReconnect as aa, consumeSSEStream as ab, contacts as ac, conversations as ad, countCitations as ae, createAuthenticatedClient as af, createDocumentWaiter as ag, dm as ah, doctags as ai, documents as aj, files as ak, formatAgentStepLabel as al, formatFileSize as am, formatStreamSummary as an, formatUserName as ao, formatWorkspaceChoices as ap, formatWsMessage as aq, generateEncryptedWorkspaceKey as ar, generateNewWorkspaceKey as as, getErrorCode as at, getErrorMessage as au, getRawWorkspaceKey as av, health as aw, parseSSEEvents as ax, performPasswordLogin as ay, performSigningKeyLogin as az, type CliCredentials as b, type ChatSession as c, type UploadBatchResult as d, type UploadOptions as e, type UploadDirectOptions as f, type UploadDirectResult as g, SUPPORTED_EXTENSIONS as h, type AgentStepEvent as i, Arbi as j, ArbiApiError as k, ArbiError as l, type ArbiOptions as m, type ArtifactEvent as n, type AuthContext as o, type AuthenticatedClient as p, type CitationSummary as q, type ConnectOptions as r, DOC_TERMINAL_STATUSES as s, type DocumentListFields as t, type DocumentListOrder as u, type DocumentWaiter as v, type DocumentWaiterOptions as w, type ListPaginatedOptions as x, type MessageMetadataPayload$1 as y, type MessageQueuedEvent as z };
4349
+ export { type SkillSummary as $, type AuthHeaders as A, type ReconnectableWsConnection as B, type ConfigStore as C, type DmCryptoContext as D, type ResolvedCitation as E, type FormattedWsMessage as F, type ResponseCompletedEvent as G, type ResponseContentPartAddedEvent as H, type ResponseCreatedEvent as I, type ResponseFailedEvent as J, type ResponseOutputItemAddedEvent as K, type ListAllOptions as L, type MessageLevel as M, type ResponseOutputItemDoneEvent as N, type OutputTokensDetails as O, type ParsedSlashCommand as P, type QueryOptions as Q, type ReconnectOptions as R, type SkippedFile as S, type ResponseOutputTextDeltaEvent as T, type UploadResult as U, type ResponseOutputTextDoneEvent as V, type ResponseUsage as W, type SSEEvent as X, type SSEStreamCallbacks as Y, type SSEStreamResult as Z, type SSEStreamStartData as _, type CliConfig as a, type UserInfo as a0, type UserInputRequestEvent as a1, type UserMessageEvent as a2, type WorkspaceContext as a3, type WsConnection as a4, agentconfig as a5, assistant as a6, authenticatedFetch as a7, buildRetrievalChunkTool as a8, buildRetrievalFullContextTool as a9, parseSSEEvents as aA, parseSlashCommand as aB, parseSlashTokenInProgress as aC, performPasswordLogin as aD, performSigningKeyLogin as aE, performSsoDeviceFlowLogin as aF, requireData as aG, requireOk as aH, resolveAuth as aI, resolveCitations as aJ, resolveWorkspace as aK, responses as aL, selectWorkspace as aM, selectWorkspaceById as aN, settings as aO, streamSSE as aP, stripCitationMarkdown as aQ, summarizeCitations as aR, tags as aS, workspaces as aT, type ArbiErrorEvent as aU, buildRetrievalTocTool as aa, connectWebSocket as ab, connectWithReconnect as ac, consumeSSEStream as ad, contacts as ae, conversations as af, countCitations as ag, createAuthenticatedClient as ah, createDocumentWaiter as ai, dm as aj, doctags as ak, documents as al, files as am, filterSkills as an, formatAgentStepLabel as ao, formatFileSize as ap, formatStreamSummary as aq, formatUserName as ar, formatWorkspaceChoices as as, formatWsMessage as at, generateEncryptedWorkspaceKey as au, generateNewWorkspaceKey as av, getErrorCode as aw, getErrorMessage as ax, getRawWorkspaceKey as ay, health as az, type CliCredentials as b, type ChatSession as c, type UploadBatchResult as d, type UploadOptions as e, type UploadDirectOptions as f, type UploadDirectResult as g, SUPPORTED_EXTENSIONS as h, type AgentStepEvent as i, Arbi as j, ArbiApiError as k, ArbiError as l, type ArbiOptions as m, type ArtifactEvent as n, type AuthContext as o, type AuthenticatedClient as p, type CitationSummary as q, type ConnectOptions as r, DOC_TERMINAL_STATUSES as s, type DocumentListFields as t, type DocumentListOrder as u, type DocumentWaiter as v, type DocumentWaiterOptions as w, type ListPaginatedOptions as x, type MessageMetadataPayload$1 as y, type MessageQueuedEvent as z };
@@ -84,16 +84,40 @@ interface CliConfig {
84
84
  }
85
85
  interface CliCredentials {
86
86
  email: string;
87
+ /** User's external ID (``usr-*`` or ``agt-*``). Needed by features
88
+ * that key on user identity (DM crypto, contact resolution, etc.).
89
+ * Set on every login from the API's response; required by
90
+ * ``buildAuthFromCache`` to restore the session client-side
91
+ * without a server round-trip. */
92
+ userExtId?: string;
87
93
  signingPrivateKeyBase64: string;
88
94
  serverSessionKeyBase64: string;
89
- /** Cached access token from last successful resolveWorkspace() */
95
+ /** Cached access token for the live server session. Valid as long as
96
+ * ``tokenTimestamp`` is within ``TOKEN_MAX_AGE_MS``. */
90
97
  accessToken?: string;
91
- /** Cached session-sealed workspace key from last successful resolveWorkspace() */
92
- sealedWorkspaceKey?: string;
93
- /** Workspace ID the cached token was issued for */
94
- workspaceId?: string;
95
- /** ISO timestamp when the token was cached */
98
+ /** ISO timestamp when ``accessToken`` was issued. Used for client-side
99
+ * TTL — the server enforces JWT exp independently. */
96
100
  tokenTimestamp?: string;
101
+ /**
102
+ * Workspaces whose keys are already deposited on the current server
103
+ * session — i.e. the keys of ``session.workspaces`` in the backend's
104
+ * Redis entry. Client-side mirror so we can skip a redundant `/open`
105
+ * round-trip when we've already deposited a workspace's key during
106
+ * this session's lifetime.
107
+ *
108
+ * Both grant types end up in this set:
109
+ * - **Permanent** — first `/open` for the workspace POSTs the
110
+ * wrapped_key and the server adds it to ``session.workspaces``.
111
+ * - **Session-only** (PA agents, temporary shares) — the backend
112
+ * pre-deposits via ``store_workspace_key_for_session_pubkey``,
113
+ * then the client's `/open` is just a metadata fetch.
114
+ *
115
+ * Cleared on every event that invalidates the session: fresh login,
116
+ * auto-relogin on 401, logout. The new session starts with an empty
117
+ * ``session.workspaces`` server-side, so this client mirror must
118
+ * start empty too.
119
+ */
120
+ openedWorkspaces?: string[];
97
121
  /** Auth0 SSO token — needed for session recovery of SSO users */
98
122
  ssoToken?: string;
99
123
  /** Parent user ext_id — set for persistent agent accounts */
@@ -152,7 +176,6 @@ interface AuthContext {
152
176
  interface WorkspaceContext extends AuthContext {
153
177
  workspaceId: string;
154
178
  accessToken: string;
155
- sealedWorkspaceKey: string;
156
179
  }
157
180
  /** Minimal workspace shape required by formatWorkspaceChoices. */
158
181
  interface WorkspaceForChoice {
@@ -232,23 +255,40 @@ declare function generateNewWorkspaceKey(arbi: ArbiClient, serverSessionKey: Uin
232
255
  * never log, persist, or transmit it over the wire.
233
256
  */
234
257
  declare function getRawWorkspaceKey(arbi: ArbiClient, workspaceId: string, signingPrivateKeyBase64: string): Promise<Uint8Array>;
235
- /**
236
- * Find a workspace by ID in the user's workspace list, select it, and return workspace info.
237
- */
238
258
  declare function selectWorkspaceById(arbi: ArbiClient, workspaceId: string, serverSessionKey: Uint8Array, signingPrivateKeyBase64: string): Promise<{
239
259
  external_id: string;
240
260
  name: string;
241
- wrapped_key: string;
261
+ wrapped_key: string | null;
262
+ /** The session-sealed workspace key — `null` for session-only grants */
263
+ sealed_key: string | null;
242
264
  }>;
243
265
  /**
244
266
  * Authenticate and return the SDK client + config.
245
- * Throws ArbiError instead of calling process.exit.
267
+ *
268
+ * Fast path: reuse the live server session via cached accessToken.
269
+ * Slow path: fresh ``loginWithKey`` (mints a new session, clears
270
+ * ``openedWorkspaces``).
246
271
  */
247
272
  declare function resolveAuth(store: ConfigStore): Promise<AuthContext>;
248
273
  /**
249
- * Authenticate, resolve workspace, and set up headers.
250
- * Uses cached JWT when available for the same workspace and not expired.
251
- * Throws ArbiError instead of calling process.exit.
274
+ * Authenticate, ensure the workspace's key is deposited on the current
275
+ * server session, and return everything callers need.
276
+ *
277
+ * Decisions are independent:
278
+ * 1. **Session aliveness** — reuse the live session if its accessToken
279
+ * is within TTL; otherwise fresh login. (Fresh login = new session
280
+ * = ``openedWorkspaces`` reset to ``[]``.)
281
+ * 2. **Workspace deposit** — if ``workspaceId`` already appears in
282
+ * ``creds.openedWorkspaces``, the server's session already holds
283
+ * its key; no ``/open`` needed. Otherwise call ``/open`` once and
284
+ * append to the set.
285
+ *
286
+ * Splitting these matters: previously the cache was gated on
287
+ * ``creds.workspaceId === workspaceId``, so any switch between
288
+ * workspaces forced a re-login. That orphaned PA-agent session
289
+ * deposits and broke ``arbi docs`` for them. Now switching workspaces
290
+ * within a live session just adds another entry to
291
+ * ``openedWorkspaces`` — no re-login, no orphaned deposits.
252
292
  */
253
293
  declare function resolveWorkspace(store: ConfigStore, workspaceOpt?: string): Promise<WorkspaceContext>;
254
294
 
@@ -540,6 +580,7 @@ declare function formatUserName(user: UserInfo | null | undefined): string;
540
580
  type MessageMetadataPayload = components['schemas']['MessageMetadataPayload'];
541
581
  type CitationData$2 = components['schemas']['CitationData'];
542
582
  type Chunk$1 = components['schemas']['Chunk'];
583
+
543
584
  /** A fully resolved citation with its source chunks. */
544
585
  interface ResolvedCitation {
545
586
  /** Citation number as a string (e.g. "1", "2") */
@@ -681,6 +722,11 @@ declare function sanitizeFolderPath(folderPath: string): string;
681
722
  interface UploadOptions {
682
723
  folder?: string;
683
724
  configExtId?: string;
725
+ /** Work-product type for the uploaded doc — ``source`` (default),
726
+ * ``skill``, ``memory``, ``artifact``. Skills must be uploaded with
727
+ * ``wp_type='skill'`` AND in a ``skills/<slug>`` folder so the
728
+ * backend's ``SkillManager`` recognises them. */
729
+ wpType?: 'source' | 'skill' | 'memory' | 'artifact' | 'webpage';
684
730
  }
685
731
  interface SkippedFile {
686
732
  file_name: string;
@@ -1131,20 +1177,100 @@ declare function queryAssistant(options: AssistantQueryOptions): Promise<Respons
1131
1177
  * The assistant_message_ext_id identifies which agent message to answer.
1132
1178
  */
1133
1179
  declare function respondToAgent(arbi: ArbiClient, assistantMessageExtId: string, answer: string): Promise<unknown>;
1180
+ /** A single user-invocable skill as exposed by ``GET /v1/assistant/skills``.
1181
+ * Re-exported with the schema-generated shape so callers don't have to
1182
+ * reach into ``components['schemas']`` themselves. */
1183
+ type SkillSummary = components['schemas']['SkillSummaryResponse'];
1184
+ /**
1185
+ * List the skills the caller can invoke in the active workspace.
1186
+ *
1187
+ * Powers slash-command autocomplete in the TUI, CLI, and React UI.
1188
+ * Returns lightweight metadata only (name, description, args hint) —
1189
+ * never the SKILL.md body. To read the body, fetch the document via
1190
+ * ``getParsedContent(authHeaders, doc_ext_id, 'content')``.
1191
+ *
1192
+ * Scoped to the workspace the caller has open (the backend uses the
1193
+ * session's ``active_workspace``); cross-workspace listing isn't
1194
+ * supported because each workspace has its own encryption key.
1195
+ *
1196
+ * @param includeHidden When ``true``, returns skills with
1197
+ * ``user-invocable: false`` in their frontmatter. Off by default —
1198
+ * those are typically agent-only or in-progress skills that
1199
+ * shouldn't surface in slash menus.
1200
+ */
1201
+ declare function listSkills(arbi: ArbiClient, options?: {
1202
+ includeHidden?: boolean;
1203
+ }): Promise<SkillSummary[]>;
1204
+ /** Parsed slash-command shape, regardless of frontend. */
1205
+ interface ParsedSlashCommand {
1206
+ /** The lowercased token immediately after ``/``. */
1207
+ slug: string;
1208
+ /** Everything after the first whitespace, untrimmed. ``""`` when the
1209
+ * user hasn't typed any arguments yet. */
1210
+ args: string;
1211
+ }
1212
+ /**
1213
+ * Parse a *submitted* slash command (or anything that walks like one).
1214
+ *
1215
+ * Permissive about whitespace: leading whitespace is tolerated so
1216
+ * pasted snippets like `` /summarize foo`` still parse. The slug
1217
+ * grammar matches the backend's ``SkillManager._slug`` output (alnum
1218
+ * + underscore + dash), which is also what the autocomplete menus
1219
+ * surface, so there's exactly one definition of "valid slug."
1220
+ *
1221
+ * Returns ``null`` if the input doesn't start with ``/<slug>``.
1222
+ *
1223
+ * Use this in **dispatchers** (TUI command-registry) and **pre-flight
1224
+ * hint** paths where you want to react to any in-progress or
1225
+ * submitted slash command. For the narrower "user is typing a slug
1226
+ * with no args yet" UX, use ``parseSlashTokenInProgress``.
1227
+ */
1228
+ declare function parseSlashCommand(input: string): ParsedSlashCommand | null;
1229
+ /**
1230
+ * Parse a slash-command **in progress** — the buffer is just
1231
+ * ``/<token>`` with no committed arguments yet (no space after the
1232
+ * slug). This is the trigger condition for the autocomplete menu:
1233
+ * the moment the user types a space, the slug is "committed" and the
1234
+ * menu should hide so further keystrokes form the arguments.
1235
+ *
1236
+ * Empty token is allowed (a bare ``/``) so the menu opens immediately
1237
+ * and lists everything — same UX as Slack/Discord.
1238
+ */
1239
+ declare function parseSlashTokenInProgress(buffer: string): string | null;
1240
+ /**
1241
+ * Filter a list of skill summaries by a typed query and sort by
1242
+ * relevance: prefix matches first, then substring matches, alphabetic
1243
+ * within each bucket. Pinned slugs (the user's favourites — surfaced
1244
+ * by the React library modal) float to the very top.
1245
+ *
1246
+ * Pure function — same logic used by the React popover, the TUI
1247
+ * autocomplete, and the CLI. Pulling it out of the React component
1248
+ * means a change to the matching rules lands in one place.
1249
+ */
1250
+ declare function filterSkills<T extends {
1251
+ slug?: string;
1252
+ name: string;
1253
+ }>(items: ReadonlyArray<T>, query: string, pinned?: ReadonlyArray<string>): T[];
1134
1254
 
1135
1255
  type assistant_AssistantQueryOptions = AssistantQueryOptions;
1136
1256
  type assistant_Chunk = Chunk;
1137
1257
  type assistant_ChunkMetadata = ChunkMetadata;
1258
+ type assistant_ParsedSlashCommand = ParsedSlashCommand;
1138
1259
  type assistant_RetrieveOptions = RetrieveOptions;
1139
1260
  type assistant_RetrieveResult = RetrieveResult;
1261
+ type assistant_SkillSummary = SkillSummary;
1140
1262
  declare const assistant_buildRetrievalChunkTool: typeof buildRetrievalChunkTool;
1141
1263
  declare const assistant_buildRetrievalFullContextTool: typeof buildRetrievalFullContextTool;
1142
1264
  declare const assistant_buildRetrievalTocTool: typeof buildRetrievalTocTool;
1265
+ declare const assistant_filterSkills: typeof filterSkills;
1266
+ declare const assistant_listSkills: typeof listSkills;
1267
+ declare const assistant_parseSlashCommand: typeof parseSlashCommand;
1268
+ declare const assistant_parseSlashTokenInProgress: typeof parseSlashTokenInProgress;
1143
1269
  declare const assistant_queryAssistant: typeof queryAssistant;
1144
1270
  declare const assistant_respondToAgent: typeof respondToAgent;
1145
1271
  declare const assistant_retrieve: typeof retrieve;
1146
1272
  declare namespace assistant {
1147
- export { type assistant_AssistantQueryOptions as AssistantQueryOptions, type assistant_Chunk as Chunk, type assistant_ChunkMetadata as ChunkMetadata, type assistant_RetrieveOptions as RetrieveOptions, type assistant_RetrieveResult as RetrieveResult, assistant_buildRetrievalChunkTool as buildRetrievalChunkTool, assistant_buildRetrievalFullContextTool as buildRetrievalFullContextTool, assistant_buildRetrievalTocTool as buildRetrievalTocTool, assistant_queryAssistant as queryAssistant, assistant_respondToAgent as respondToAgent, assistant_retrieve as retrieve };
1273
+ export { type assistant_AssistantQueryOptions as AssistantQueryOptions, type assistant_Chunk as Chunk, type assistant_ChunkMetadata as ChunkMetadata, type assistant_ParsedSlashCommand as ParsedSlashCommand, type assistant_RetrieveOptions as RetrieveOptions, type assistant_RetrieveResult as RetrieveResult, type assistant_SkillSummary as SkillSummary, assistant_buildRetrievalChunkTool as buildRetrievalChunkTool, assistant_buildRetrievalFullContextTool as buildRetrievalFullContextTool, assistant_buildRetrievalTocTool as buildRetrievalTocTool, assistant_filterSkills as filterSkills, assistant_listSkills as listSkills, assistant_parseSlashCommand as parseSlashCommand, assistant_parseSlashTokenInProgress as parseSlashTokenInProgress, assistant_queryAssistant as queryAssistant, assistant_respondToAgent as respondToAgent, assistant_retrieve as retrieve };
1148
1274
  }
1149
1275
 
1150
1276
  /**
@@ -4220,4 +4346,4 @@ declare namespace responses {
4220
4346
  export { type responses_SubmitBackgroundQueryOptions as SubmitBackgroundQueryOptions, responses_extractResponseText as extractResponseText, responses_getResponse as getResponse, responses_submitBackgroundQuery as submitBackgroundQuery };
4221
4347
  }
4222
4348
 
4223
- export { type UserInputRequestEvent as $, type AuthHeaders as A, type ReconnectableWsConnection as B, type ConfigStore as C, type DmCryptoContext as D, type ResolvedCitation as E, type FormattedWsMessage as F, type ResponseCompletedEvent as G, type ResponseContentPartAddedEvent as H, type ResponseCreatedEvent as I, type ResponseFailedEvent as J, type ResponseOutputItemAddedEvent as K, type ListAllOptions as L, type MessageLevel as M, type ResponseOutputItemDoneEvent as N, type OutputTokensDetails as O, type ResponseOutputTextDeltaEvent as P, type QueryOptions as Q, type ReconnectOptions as R, type SkippedFile as S, type ResponseOutputTextDoneEvent as T, type UploadResult as U, type ResponseUsage as V, type SSEEvent as W, type SSEStreamCallbacks as X, type SSEStreamResult as Y, type SSEStreamStartData as Z, type UserInfo as _, type CliConfig as a, type UserMessageEvent as a0, type WorkspaceContext as a1, type WsConnection as a2, agentconfig as a3, assistant as a4, authenticatedFetch as a5, buildRetrievalChunkTool as a6, buildRetrievalFullContextTool as a7, buildRetrievalTocTool as a8, connectWebSocket as a9, performSsoDeviceFlowLogin as aA, requireData as aB, requireOk as aC, resolveAuth as aD, resolveCitations as aE, resolveWorkspace as aF, responses as aG, selectWorkspace as aH, selectWorkspaceById as aI, settings as aJ, streamSSE as aK, stripCitationMarkdown as aL, summarizeCitations as aM, tags as aN, workspaces as aO, type ArbiErrorEvent as aP, connectWithReconnect as aa, consumeSSEStream as ab, contacts as ac, conversations as ad, countCitations as ae, createAuthenticatedClient as af, createDocumentWaiter as ag, dm as ah, doctags as ai, documents as aj, files as ak, formatAgentStepLabel as al, formatFileSize as am, formatStreamSummary as an, formatUserName as ao, formatWorkspaceChoices as ap, formatWsMessage as aq, generateEncryptedWorkspaceKey as ar, generateNewWorkspaceKey as as, getErrorCode as at, getErrorMessage as au, getRawWorkspaceKey as av, health as aw, parseSSEEvents as ax, performPasswordLogin as ay, performSigningKeyLogin as az, type CliCredentials as b, type ChatSession as c, type UploadBatchResult as d, type UploadOptions as e, type UploadDirectOptions as f, type UploadDirectResult as g, SUPPORTED_EXTENSIONS as h, type AgentStepEvent as i, Arbi as j, ArbiApiError as k, ArbiError as l, type ArbiOptions as m, type ArtifactEvent as n, type AuthContext as o, type AuthenticatedClient as p, type CitationSummary as q, type ConnectOptions as r, DOC_TERMINAL_STATUSES as s, type DocumentListFields as t, type DocumentListOrder as u, type DocumentWaiter as v, type DocumentWaiterOptions as w, type ListPaginatedOptions as x, type MessageMetadataPayload$1 as y, type MessageQueuedEvent as z };
4349
+ export { type SkillSummary as $, type AuthHeaders as A, type ReconnectableWsConnection as B, type ConfigStore as C, type DmCryptoContext as D, type ResolvedCitation as E, type FormattedWsMessage as F, type ResponseCompletedEvent as G, type ResponseContentPartAddedEvent as H, type ResponseCreatedEvent as I, type ResponseFailedEvent as J, type ResponseOutputItemAddedEvent as K, type ListAllOptions as L, type MessageLevel as M, type ResponseOutputItemDoneEvent as N, type OutputTokensDetails as O, type ParsedSlashCommand as P, type QueryOptions as Q, type ReconnectOptions as R, type SkippedFile as S, type ResponseOutputTextDeltaEvent as T, type UploadResult as U, type ResponseOutputTextDoneEvent as V, type ResponseUsage as W, type SSEEvent as X, type SSEStreamCallbacks as Y, type SSEStreamResult as Z, type SSEStreamStartData as _, type CliConfig as a, type UserInfo as a0, type UserInputRequestEvent as a1, type UserMessageEvent as a2, type WorkspaceContext as a3, type WsConnection as a4, agentconfig as a5, assistant as a6, authenticatedFetch as a7, buildRetrievalChunkTool as a8, buildRetrievalFullContextTool as a9, parseSSEEvents as aA, parseSlashCommand as aB, parseSlashTokenInProgress as aC, performPasswordLogin as aD, performSigningKeyLogin as aE, performSsoDeviceFlowLogin as aF, requireData as aG, requireOk as aH, resolveAuth as aI, resolveCitations as aJ, resolveWorkspace as aK, responses as aL, selectWorkspace as aM, selectWorkspaceById as aN, settings as aO, streamSSE as aP, stripCitationMarkdown as aQ, summarizeCitations as aR, tags as aS, workspaces as aT, type ArbiErrorEvent as aU, buildRetrievalTocTool as aa, connectWebSocket as ab, connectWithReconnect as ac, consumeSSEStream as ad, contacts as ae, conversations as af, countCitations as ag, createAuthenticatedClient as ah, createDocumentWaiter as ai, dm as aj, doctags as ak, documents as al, files as am, filterSkills as an, formatAgentStepLabel as ao, formatFileSize as ap, formatStreamSummary as aq, formatUserName as ar, formatWorkspaceChoices as as, formatWsMessage as at, generateEncryptedWorkspaceKey as au, generateNewWorkspaceKey as av, getErrorCode as aw, getErrorMessage as ax, getRawWorkspaceKey as ay, health as az, type CliCredentials as b, type ChatSession as c, type UploadBatchResult as d, type UploadOptions as e, type UploadDirectOptions as f, type UploadDirectResult as g, SUPPORTED_EXTENSIONS as h, type AgentStepEvent as i, Arbi as j, ArbiApiError as k, ArbiError as l, type ArbiOptions as m, type ArtifactEvent as n, type AuthContext as o, type AuthenticatedClient as p, type CitationSummary as q, type ConnectOptions as r, DOC_TERMINAL_STATUSES as s, type DocumentListFields as t, type DocumentListOrder as u, type DocumentWaiter as v, type DocumentWaiterOptions as w, type ListPaginatedOptions as x, type MessageMetadataPayload$1 as y, type MessageQueuedEvent as z };