@arbidocs/sdk 0.3.17 → 0.3.18

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/index.d.cts CHANGED
@@ -1,5 +1,5 @@
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-BtAHbiq_.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, D as DocumentWaiter, p as DocumentWaiterOptions, F as FormattedWsMessage, L as LIFECYCLE_LABELS, M as MessageLevel, q as MessageMetadataPayload, r as MessageQueuedEvent, O as OutputTokensDetails, Q as QueryOptions, R as ReconnectOptions, s as ReconnectableWsConnection, t as ResolvedCitation, u as ResponseCompletedEvent, v as ResponseContentPartAddedEvent, w as ResponseCreatedEvent, x as ResponseFailedEvent, y as ResponseOutputItemAddedEvent, z as ResponseOutputItemDoneEvent, B as ResponseOutputTextDeltaEvent, E as ResponseOutputTextDoneEvent, G as ResponseUsage, S as SSEEvent, H as SSEStreamCallbacks, I as SSEStreamResult, J as SSEStreamStartData, T as TOOL_LABELS, K as UserInfo, N as UserInputRequestEvent, P as UserMessageEvent, W as WorkspaceContext, V as WsConnection, X as agentconfig, Y as assistant, Z as authenticatedFetch, _ as buildRetrievalChunkTool, $ as buildRetrievalFullContextTool, a0 as buildRetrievalTocTool, a1 as connectWebSocket, a2 as connectWithReconnect, a3 as consumeSSEStream, a4 as contacts, a5 as conversations, a6 as countCitations, a7 as createAuthenticatedClient, a8 as createDocumentWaiter, a9 as dm, aa as doctags, ab as documents, ac as files, ad as formatAgentStepLabel, ae as formatFileSize, af as formatStreamSummary, ag as formatUserName, ah as formatWorkspaceChoices, ai as formatWsMessage, aj as generateEncryptedWorkspaceKey, ak as getErrorCode, al as getErrorMessage, am as health, an as parseSSEEvents, ao as performPasswordLogin, ap as requireData, aq as requireOk, ar as resolveAuth, as as resolveCitations, at as resolveWorkspace, au as responses, av as selectWorkspace, aw as selectWorkspaceById, ax as settings, ay as streamSSE, az as stripCitationMarkdown, aA as summarizeCitations, aB as tags, aC as workspaces } from './browser-BtAHbiq_.cjs';
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-DUQ3Eyvd.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, D as DocumentWaiter, p as DocumentWaiterOptions, F as FormattedWsMessage, L as LIFECYCLE_LABELS, M as MessageLevel, q as MessageMetadataPayload, r as MessageQueuedEvent, O as OutputTokensDetails, Q as QueryOptions, R as ReconnectOptions, s as ReconnectableWsConnection, t as ResolvedCitation, u as ResponseCompletedEvent, v as ResponseContentPartAddedEvent, w as ResponseCreatedEvent, x as ResponseFailedEvent, y as ResponseOutputItemAddedEvent, z as ResponseOutputItemDoneEvent, B as ResponseOutputTextDeltaEvent, E as ResponseOutputTextDoneEvent, G as ResponseUsage, S as SSEEvent, H as SSEStreamCallbacks, I as SSEStreamResult, J as SSEStreamStartData, T as TOOL_LABELS, K as UserInfo, N as UserInputRequestEvent, P as UserMessageEvent, W as WorkspaceContext, V as WsConnection, X as agentconfig, Y as assistant, Z as authenticatedFetch, _ as buildRetrievalChunkTool, $ as buildRetrievalFullContextTool, a0 as buildRetrievalTocTool, a1 as connectWebSocket, a2 as connectWithReconnect, a3 as consumeSSEStream, a4 as contacts, a5 as conversations, a6 as countCitations, a7 as createAuthenticatedClient, a8 as createDocumentWaiter, a9 as dm, aa as doctags, ab as documents, ac as files, ad as formatAgentStepLabel, ae as formatFileSize, af as formatStreamSummary, ag as formatUserName, ah as formatWorkspaceChoices, ai as formatWsMessage, aj as generateEncryptedWorkspaceKey, 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-DUQ3Eyvd.cjs';
3
3
  import '@arbidocs/client';
4
4
 
5
5
  /**
@@ -58,6 +58,66 @@ declare class FileConfigStore implements ConfigStore {
58
58
  private readPublicConfigDomain;
59
59
  }
60
60
 
61
+ /**
62
+ * OAuth 2.0 Device Authorization Grant (RFC 8628) for Auth0.
63
+ *
64
+ * Enables headless CLI login: the user authorizes in a browser while the CLI polls for a token.
65
+ */
66
+ interface SsoConfig {
67
+ ssoEnabled: boolean;
68
+ domain: string;
69
+ clientId: string;
70
+ audience: string;
71
+ }
72
+ interface DeviceCodeResponse {
73
+ device_code: string;
74
+ user_code: string;
75
+ verification_uri: string;
76
+ verification_uri_complete: string;
77
+ expires_in: number;
78
+ interval: number;
79
+ }
80
+ declare class DeviceFlowError extends Error {
81
+ constructor(message: string);
82
+ }
83
+ declare class DeviceFlowExpired extends DeviceFlowError {
84
+ constructor();
85
+ }
86
+ declare class DeviceFlowAccessDenied extends DeviceFlowError {
87
+ constructor();
88
+ }
89
+ /**
90
+ * Fetch SSO configuration from the ARBI deployment.
91
+ */
92
+ declare function fetchSsoConfig(baseUrl: string): Promise<SsoConfig>;
93
+ /**
94
+ * Request a device code from Auth0.
95
+ *
96
+ * POST https://{domain}/oauth/device/code
97
+ */
98
+ declare function requestDeviceCode(domain: string, clientId: string, audience?: string, scope?: string): Promise<DeviceCodeResponse>;
99
+ /**
100
+ * Poll Auth0 token endpoint until the user authorizes (or the code expires).
101
+ *
102
+ * Returns the Auth0 access_token (JWT).
103
+ */
104
+ declare function pollForToken(domain: string, clientId: string, deviceCode: string, interval: number, expiresIn: number, onPoll?: (elapsedMs: number) => void): Promise<string>;
105
+
106
+ type deviceFlow_DeviceCodeResponse = DeviceCodeResponse;
107
+ type deviceFlow_DeviceFlowAccessDenied = DeviceFlowAccessDenied;
108
+ declare const deviceFlow_DeviceFlowAccessDenied: typeof DeviceFlowAccessDenied;
109
+ type deviceFlow_DeviceFlowError = DeviceFlowError;
110
+ declare const deviceFlow_DeviceFlowError: typeof DeviceFlowError;
111
+ type deviceFlow_DeviceFlowExpired = DeviceFlowExpired;
112
+ declare const deviceFlow_DeviceFlowExpired: typeof DeviceFlowExpired;
113
+ type deviceFlow_SsoConfig = SsoConfig;
114
+ declare const deviceFlow_fetchSsoConfig: typeof fetchSsoConfig;
115
+ declare const deviceFlow_pollForToken: typeof pollForToken;
116
+ declare const deviceFlow_requestDeviceCode: typeof requestDeviceCode;
117
+ declare namespace deviceFlow {
118
+ export { type deviceFlow_DeviceCodeResponse as DeviceCodeResponse, deviceFlow_DeviceFlowAccessDenied as DeviceFlowAccessDenied, deviceFlow_DeviceFlowError as DeviceFlowError, deviceFlow_DeviceFlowExpired as DeviceFlowExpired, type deviceFlow_SsoConfig as SsoConfig, deviceFlow_fetchSsoConfig as fetchSsoConfig, deviceFlow_pollForToken as pollForToken, deviceFlow_requestDeviceCode as requestDeviceCode };
119
+ }
120
+
61
121
  /**
62
122
  * Document operations — Node.js file system operations.
63
123
  *
@@ -90,4 +150,4 @@ declare namespace documentsNode {
90
150
  export { documentsNode_uploadDirectory as uploadDirectory, documentsNode_uploadLocalFile as uploadLocalFile, documentsNode_uploadZip as uploadZip };
91
151
  }
92
152
 
93
- export { AuthHeaders, ChatSession, CliConfig, CliCredentials, ConfigStore, FileConfigStore, documentsNode };
153
+ export { AuthHeaders, ChatSession, CliConfig, CliCredentials, ConfigStore, FileConfigStore, deviceFlow, documentsNode };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
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-BtAHbiq_.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, D as DocumentWaiter, p as DocumentWaiterOptions, F as FormattedWsMessage, L as LIFECYCLE_LABELS, M as MessageLevel, q as MessageMetadataPayload, r as MessageQueuedEvent, O as OutputTokensDetails, Q as QueryOptions, R as ReconnectOptions, s as ReconnectableWsConnection, t as ResolvedCitation, u as ResponseCompletedEvent, v as ResponseContentPartAddedEvent, w as ResponseCreatedEvent, x as ResponseFailedEvent, y as ResponseOutputItemAddedEvent, z as ResponseOutputItemDoneEvent, B as ResponseOutputTextDeltaEvent, E as ResponseOutputTextDoneEvent, G as ResponseUsage, S as SSEEvent, H as SSEStreamCallbacks, I as SSEStreamResult, J as SSEStreamStartData, T as TOOL_LABELS, K as UserInfo, N as UserInputRequestEvent, P as UserMessageEvent, W as WorkspaceContext, V as WsConnection, X as agentconfig, Y as assistant, Z as authenticatedFetch, _ as buildRetrievalChunkTool, $ as buildRetrievalFullContextTool, a0 as buildRetrievalTocTool, a1 as connectWebSocket, a2 as connectWithReconnect, a3 as consumeSSEStream, a4 as contacts, a5 as conversations, a6 as countCitations, a7 as createAuthenticatedClient, a8 as createDocumentWaiter, a9 as dm, aa as doctags, ab as documents, ac as files, ad as formatAgentStepLabel, ae as formatFileSize, af as formatStreamSummary, ag as formatUserName, ah as formatWorkspaceChoices, ai as formatWsMessage, aj as generateEncryptedWorkspaceKey, ak as getErrorCode, al as getErrorMessage, am as health, an as parseSSEEvents, ao as performPasswordLogin, ap as requireData, aq as requireOk, ar as resolveAuth, as as resolveCitations, at as resolveWorkspace, au as responses, av as selectWorkspace, aw as selectWorkspaceById, ax as settings, ay as streamSSE, az as stripCitationMarkdown, aA as summarizeCitations, aB as tags, aC as workspaces } from './browser-BtAHbiq_.js';
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-DUQ3Eyvd.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, D as DocumentWaiter, p as DocumentWaiterOptions, F as FormattedWsMessage, L as LIFECYCLE_LABELS, M as MessageLevel, q as MessageMetadataPayload, r as MessageQueuedEvent, O as OutputTokensDetails, Q as QueryOptions, R as ReconnectOptions, s as ReconnectableWsConnection, t as ResolvedCitation, u as ResponseCompletedEvent, v as ResponseContentPartAddedEvent, w as ResponseCreatedEvent, x as ResponseFailedEvent, y as ResponseOutputItemAddedEvent, z as ResponseOutputItemDoneEvent, B as ResponseOutputTextDeltaEvent, E as ResponseOutputTextDoneEvent, G as ResponseUsage, S as SSEEvent, H as SSEStreamCallbacks, I as SSEStreamResult, J as SSEStreamStartData, T as TOOL_LABELS, K as UserInfo, N as UserInputRequestEvent, P as UserMessageEvent, W as WorkspaceContext, V as WsConnection, X as agentconfig, Y as assistant, Z as authenticatedFetch, _ as buildRetrievalChunkTool, $ as buildRetrievalFullContextTool, a0 as buildRetrievalTocTool, a1 as connectWebSocket, a2 as connectWithReconnect, a3 as consumeSSEStream, a4 as contacts, a5 as conversations, a6 as countCitations, a7 as createAuthenticatedClient, a8 as createDocumentWaiter, a9 as dm, aa as doctags, ab as documents, ac as files, ad as formatAgentStepLabel, ae as formatFileSize, af as formatStreamSummary, ag as formatUserName, ah as formatWorkspaceChoices, ai as formatWsMessage, aj as generateEncryptedWorkspaceKey, 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-DUQ3Eyvd.js';
3
3
  import '@arbidocs/client';
4
4
 
5
5
  /**
@@ -58,6 +58,66 @@ declare class FileConfigStore implements ConfigStore {
58
58
  private readPublicConfigDomain;
59
59
  }
60
60
 
61
+ /**
62
+ * OAuth 2.0 Device Authorization Grant (RFC 8628) for Auth0.
63
+ *
64
+ * Enables headless CLI login: the user authorizes in a browser while the CLI polls for a token.
65
+ */
66
+ interface SsoConfig {
67
+ ssoEnabled: boolean;
68
+ domain: string;
69
+ clientId: string;
70
+ audience: string;
71
+ }
72
+ interface DeviceCodeResponse {
73
+ device_code: string;
74
+ user_code: string;
75
+ verification_uri: string;
76
+ verification_uri_complete: string;
77
+ expires_in: number;
78
+ interval: number;
79
+ }
80
+ declare class DeviceFlowError extends Error {
81
+ constructor(message: string);
82
+ }
83
+ declare class DeviceFlowExpired extends DeviceFlowError {
84
+ constructor();
85
+ }
86
+ declare class DeviceFlowAccessDenied extends DeviceFlowError {
87
+ constructor();
88
+ }
89
+ /**
90
+ * Fetch SSO configuration from the ARBI deployment.
91
+ */
92
+ declare function fetchSsoConfig(baseUrl: string): Promise<SsoConfig>;
93
+ /**
94
+ * Request a device code from Auth0.
95
+ *
96
+ * POST https://{domain}/oauth/device/code
97
+ */
98
+ declare function requestDeviceCode(domain: string, clientId: string, audience?: string, scope?: string): Promise<DeviceCodeResponse>;
99
+ /**
100
+ * Poll Auth0 token endpoint until the user authorizes (or the code expires).
101
+ *
102
+ * Returns the Auth0 access_token (JWT).
103
+ */
104
+ declare function pollForToken(domain: string, clientId: string, deviceCode: string, interval: number, expiresIn: number, onPoll?: (elapsedMs: number) => void): Promise<string>;
105
+
106
+ type deviceFlow_DeviceCodeResponse = DeviceCodeResponse;
107
+ type deviceFlow_DeviceFlowAccessDenied = DeviceFlowAccessDenied;
108
+ declare const deviceFlow_DeviceFlowAccessDenied: typeof DeviceFlowAccessDenied;
109
+ type deviceFlow_DeviceFlowError = DeviceFlowError;
110
+ declare const deviceFlow_DeviceFlowError: typeof DeviceFlowError;
111
+ type deviceFlow_DeviceFlowExpired = DeviceFlowExpired;
112
+ declare const deviceFlow_DeviceFlowExpired: typeof DeviceFlowExpired;
113
+ type deviceFlow_SsoConfig = SsoConfig;
114
+ declare const deviceFlow_fetchSsoConfig: typeof fetchSsoConfig;
115
+ declare const deviceFlow_pollForToken: typeof pollForToken;
116
+ declare const deviceFlow_requestDeviceCode: typeof requestDeviceCode;
117
+ declare namespace deviceFlow {
118
+ export { type deviceFlow_DeviceCodeResponse as DeviceCodeResponse, deviceFlow_DeviceFlowAccessDenied as DeviceFlowAccessDenied, deviceFlow_DeviceFlowError as DeviceFlowError, deviceFlow_DeviceFlowExpired as DeviceFlowExpired, type deviceFlow_SsoConfig as SsoConfig, deviceFlow_fetchSsoConfig as fetchSsoConfig, deviceFlow_pollForToken as pollForToken, deviceFlow_requestDeviceCode as requestDeviceCode };
119
+ }
120
+
61
121
  /**
62
122
  * Document operations — Node.js file system operations.
63
123
  *
@@ -90,4 +150,4 @@ declare namespace documentsNode {
90
150
  export { documentsNode_uploadDirectory as uploadDirectory, documentsNode_uploadLocalFile as uploadLocalFile, documentsNode_uploadZip as uploadZip };
91
151
  }
92
152
 
93
- export { AuthHeaders, ChatSession, CliConfig, CliCredentials, ConfigStore, FileConfigStore, documentsNode };
153
+ export { AuthHeaders, ChatSession, CliConfig, CliCredentials, ConfigStore, FileConfigStore, deviceFlow, documentsNode };
package/dist/index.js CHANGED
@@ -277,6 +277,107 @@ var FileConfigStore = class {
277
277
  return null;
278
278
  }
279
279
  };
280
+
281
+ // src/device-flow.ts
282
+ var device_flow_exports = {};
283
+ __export(device_flow_exports, {
284
+ DeviceFlowAccessDenied: () => DeviceFlowAccessDenied,
285
+ DeviceFlowError: () => DeviceFlowError,
286
+ DeviceFlowExpired: () => DeviceFlowExpired,
287
+ fetchSsoConfig: () => fetchSsoConfig,
288
+ pollForToken: () => pollForToken,
289
+ requestDeviceCode: () => requestDeviceCode
290
+ });
291
+ var DeviceFlowError = class extends Error {
292
+ constructor(message) {
293
+ super(message);
294
+ this.name = "DeviceFlowError";
295
+ }
296
+ };
297
+ var DeviceFlowExpired = class extends DeviceFlowError {
298
+ constructor() {
299
+ super("Device code expired \u2014 please try again");
300
+ this.name = "DeviceFlowExpired";
301
+ }
302
+ };
303
+ var DeviceFlowAccessDenied = class extends DeviceFlowError {
304
+ constructor() {
305
+ super("Authorization was denied by the user");
306
+ this.name = "DeviceFlowAccessDenied";
307
+ }
308
+ };
309
+ async function fetchSsoConfig(baseUrl) {
310
+ const arbi = createArbiClient({ baseUrl, deploymentDomain: "", credentials: "omit" });
311
+ const { data, error } = await arbi.fetch.GET("/v1/user/sso-config");
312
+ if (error || !data) {
313
+ throw new DeviceFlowError(`Failed to fetch SSO config`);
314
+ }
315
+ return {
316
+ ssoEnabled: data.sso_enabled,
317
+ domain: data.domain,
318
+ clientId: data.cli_client_id || data.client_id,
319
+ audience: data.audience
320
+ };
321
+ }
322
+ async function requestDeviceCode(domain, clientId, audience, scope = "openid email profile") {
323
+ const body = new URLSearchParams({
324
+ client_id: clientId,
325
+ scope,
326
+ ...audience ? { audience } : {}
327
+ });
328
+ const res = await fetch(`https://${domain}/oauth/device/code`, {
329
+ method: "POST",
330
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
331
+ body
332
+ });
333
+ if (!res.ok) {
334
+ const text = await res.text();
335
+ throw new DeviceFlowError(`Device code request failed: ${res.status} ${text}`);
336
+ }
337
+ return await res.json();
338
+ }
339
+ async function pollForToken(domain, clientId, deviceCode, interval, expiresIn, onPoll) {
340
+ const deadline = Date.now() + expiresIn * 1e3;
341
+ let pollInterval = interval * 1e3;
342
+ while (Date.now() < deadline) {
343
+ await sleep(pollInterval);
344
+ onPoll?.(Date.now());
345
+ const res = await fetch(`https://${domain}/oauth/token`, {
346
+ method: "POST",
347
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
348
+ body: new URLSearchParams({
349
+ grant_type: "urn:ietf:params:oauth:grant-type:device_code",
350
+ client_id: clientId,
351
+ device_code: deviceCode
352
+ })
353
+ });
354
+ if (res.ok) {
355
+ const data = await res.json();
356
+ return data.access_token;
357
+ }
358
+ const errBody = await res.json().catch(() => ({ error: "unknown" }));
359
+ if (errBody.error === "authorization_pending") {
360
+ continue;
361
+ } else if (errBody.error === "slow_down") {
362
+ pollInterval += 5e3;
363
+ continue;
364
+ } else if (errBody.error === "expired_token") {
365
+ throw new DeviceFlowExpired();
366
+ } else if (errBody.error === "access_denied") {
367
+ throw new DeviceFlowAccessDenied();
368
+ } else {
369
+ throw new DeviceFlowError(
370
+ `Token polling error: ${errBody.error} \u2014 ${errBody.error_description ?? ""}`
371
+ );
372
+ }
373
+ }
374
+ throw new DeviceFlowExpired();
375
+ }
376
+ function sleep(ms) {
377
+ return new Promise((resolve) => setTimeout(resolve, ms));
378
+ }
379
+
380
+ // src/auth.ts
280
381
  function formatWorkspaceChoices(wsList) {
281
382
  return wsList.map((ws) => {
282
383
  const totalDocs = ws.shared_document_count + ws.private_document_count;
@@ -297,7 +398,8 @@ async function createAuthenticatedClient(config, creds, store) {
297
398
  const signingPrivateKey = base64ToBytes(creds.signingPrivateKeyBase64);
298
399
  const loginResult = await arbi.auth.loginWithKey({
299
400
  email: creds.email,
300
- signingPrivateKey
401
+ signingPrivateKey,
402
+ ssoToken: creds.ssoToken
301
403
  });
302
404
  store.saveCredentials({
303
405
  ...creds,
@@ -329,6 +431,40 @@ async function performPasswordLogin(config, email, password, store) {
329
431
  });
330
432
  return { arbi, loginResult, config };
331
433
  }
434
+ async function performSsoDeviceFlowLogin(config, email, password, store, callbacks) {
435
+ const ssoConfig = await fetchSsoConfig(config.baseUrl);
436
+ if (!ssoConfig.ssoEnabled) {
437
+ throw new ArbiError("SSO is not enabled on this deployment");
438
+ }
439
+ const dc = await requestDeviceCode(ssoConfig.domain, ssoConfig.clientId, ssoConfig.audience);
440
+ callbacks?.onUserCode?.(dc.user_code, dc.verification_uri_complete);
441
+ const ssoToken = await pollForToken(
442
+ ssoConfig.domain,
443
+ ssoConfig.clientId,
444
+ dc.device_code,
445
+ dc.interval,
446
+ dc.expires_in,
447
+ callbacks?.onPoll
448
+ );
449
+ const arbi = createArbiClient({
450
+ baseUrl: config.baseUrl,
451
+ deploymentDomain: config.deploymentDomain,
452
+ credentials: "omit"
453
+ });
454
+ await arbi.crypto.initSodium();
455
+ const loginResult = await arbi.auth.login({ email, password, ssoToken });
456
+ store.saveCredentials({
457
+ email,
458
+ signingPrivateKeyBase64: arbi.crypto.bytesToBase64(loginResult.signingPrivateKey),
459
+ serverSessionKeyBase64: arbi.crypto.bytesToBase64(loginResult.serverSessionKey),
460
+ ssoToken,
461
+ accessToken: void 0,
462
+ workspaceKeyHeader: void 0,
463
+ workspaceId: void 0,
464
+ tokenTimestamp: void 0
465
+ });
466
+ return { arbi, loginResult, config };
467
+ }
332
468
  async function selectWorkspace(arbi, workspaceId, wrappedKey, serverSessionKey, signingPrivateKeyBase64) {
333
469
  const signingPrivateKey = base64ToBytes(signingPrivateKeyBase64);
334
470
  const ed25519PublicKey = signingPrivateKey.slice(32, 64);
@@ -2069,6 +2205,6 @@ function extractResponseText(response) {
2069
2205
  return parts.join("");
2070
2206
  }
2071
2207
 
2072
- export { Arbi, ArbiApiError, ArbiError, FileConfigStore, LIFECYCLE_LABELS, TOOL_LABELS, agentconfig_exports as agentconfig, assistant_exports as assistant, authenticatedFetch, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, connectWebSocket, connectWithReconnect, consumeSSEStream, contacts_exports as contacts, conversations_exports as conversations, countCitations, createAuthenticatedClient, createDocumentWaiter, dm_exports as dm, doctags_exports as doctags, documents_exports as documents, documents_node_exports as documentsNode, files_exports as files, formatAgentStepLabel, formatFileSize, formatStreamSummary, formatUserName, formatWorkspaceChoices, formatWsMessage, generateEncryptedWorkspaceKey, getErrorCode, getErrorMessage, health_exports as health, parseSSEEvents, performPasswordLogin, requireData, requireOk, resolveAuth, resolveCitations, resolveWorkspace, responses_exports as responses, selectWorkspace, selectWorkspaceById, settings_exports as settings, streamSSE, stripCitationMarkdown, summarizeCitations, tags_exports as tags, workspaces_exports as workspaces };
2208
+ export { Arbi, ArbiApiError, ArbiError, FileConfigStore, LIFECYCLE_LABELS, TOOL_LABELS, agentconfig_exports as agentconfig, assistant_exports as assistant, authenticatedFetch, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, connectWebSocket, connectWithReconnect, consumeSSEStream, contacts_exports as contacts, conversations_exports as conversations, countCitations, createAuthenticatedClient, createDocumentWaiter, device_flow_exports as deviceFlow, dm_exports as dm, doctags_exports as doctags, documents_exports as documents, documents_node_exports as documentsNode, files_exports as files, formatAgentStepLabel, formatFileSize, formatStreamSummary, formatUserName, formatWorkspaceChoices, formatWsMessage, generateEncryptedWorkspaceKey, getErrorCode, getErrorMessage, health_exports as health, parseSSEEvents, performPasswordLogin, performSsoDeviceFlowLogin, requireData, requireOk, resolveAuth, resolveCitations, resolveWorkspace, responses_exports as responses, selectWorkspace, selectWorkspaceById, settings_exports as settings, streamSSE, stripCitationMarkdown, summarizeCitations, tags_exports as tags, workspaces_exports as workspaces };
2073
2209
  //# sourceMappingURL=index.js.map
2074
2210
  //# sourceMappingURL=index.js.map