@arbidocs/sdk 0.3.17 → 0.3.19
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-BtAHbiq_.d.cts → browser-D8aF-wkt.d.cts} +22 -7
- package/dist/{browser-BtAHbiq_.d.ts → browser-D8aF-wkt.d.ts} +22 -7
- package/dist/browser.cjs +11 -25
- 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 +12 -24
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +146 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +63 -3
- package/dist/index.d.ts +63 -3
- package/dist/index.js +145 -24
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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-
|
|
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,
|
|
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-D8aF-wkt.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, 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, K as UserInfo, L as UserInputRequestEvent, N as UserMessageEvent, W as WorkspaceContext, P as WsConnection, T as agentconfig, V as assistant, X as authenticatedFetch, Y as buildRetrievalChunkTool, Z as buildRetrievalFullContextTool, _ as buildRetrievalTocTool, $ as connectWebSocket, a0 as connectWithReconnect, a1 as consumeSSEStream, a2 as contacts, a3 as conversations, a4 as countCitations, a5 as createAuthenticatedClient, a6 as createDocumentWaiter, a7 as dm, a8 as doctags, a9 as documents, aa as files, ab as formatAgentStepLabel, ac as formatFileSize, ad as formatStreamSummary, ae as formatUserName, af as formatWorkspaceChoices, ag as formatWsMessage, ah as generateEncryptedWorkspaceKey, ai as getErrorCode, aj as getErrorMessage, ak as health, al as parseSSEEvents, am as performPasswordLogin, an as performSsoDeviceFlowLogin, ao as requireData, ap as requireOk, aq as resolveAuth, ar as resolveCitations, as as resolveWorkspace, at as responses, au as selectWorkspace, av as selectWorkspaceById, aw as settings, ax as streamSSE, ay as stripCitationMarkdown, az as summarizeCitations, aA as tags, aB as workspaces } from './browser-D8aF-wkt.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-
|
|
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,
|
|
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-D8aF-wkt.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, 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, K as UserInfo, L as UserInputRequestEvent, N as UserMessageEvent, W as WorkspaceContext, P as WsConnection, T as agentconfig, V as assistant, X as authenticatedFetch, Y as buildRetrievalChunkTool, Z as buildRetrievalFullContextTool, _ as buildRetrievalTocTool, $ as connectWebSocket, a0 as connectWithReconnect, a1 as consumeSSEStream, a2 as contacts, a3 as conversations, a4 as countCitations, a5 as createAuthenticatedClient, a6 as createDocumentWaiter, a7 as dm, a8 as doctags, a9 as documents, aa as files, ab as formatAgentStepLabel, ac as formatFileSize, ad as formatStreamSummary, ae as formatUserName, af as formatWorkspaceChoices, ag as formatWsMessage, ah as generateEncryptedWorkspaceKey, ai as getErrorCode, aj as getErrorMessage, ak as health, al as parseSSEEvents, am as performPasswordLogin, an as performSsoDeviceFlowLogin, ao as requireData, ap as requireOk, aq as resolveAuth, ar as resolveCitations, as as resolveWorkspace, at as responses, au as selectWorkspace, av as selectWorkspaceById, aw as settings, ax as streamSSE, ay as stripCitationMarkdown, az as summarizeCitations, aA as tags, aB as workspaces } from './browser-D8aF-wkt.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);
|
|
@@ -448,23 +584,7 @@ async function resolveWorkspace(store, workspaceOpt) {
|
|
|
448
584
|
}
|
|
449
585
|
|
|
450
586
|
// src/sse.ts
|
|
451
|
-
var
|
|
452
|
-
search_documents: "Searching documents",
|
|
453
|
-
get_document_passages: "Reading document",
|
|
454
|
-
get_table_of_contents: "Getting table of contents",
|
|
455
|
-
view_document_pages: "Viewing document pages",
|
|
456
|
-
get_full_document: "Reading full document",
|
|
457
|
-
web_search: "Searching the web",
|
|
458
|
-
read_url: "Reading web pages",
|
|
459
|
-
ask_user: "Asking user",
|
|
460
|
-
compaction: "Compacting conversation",
|
|
461
|
-
personal_agent: "Running agent",
|
|
462
|
-
create_artifact: "Creating artifact",
|
|
463
|
-
create_plan: "Creating plan",
|
|
464
|
-
save_skill: "Saving skill",
|
|
465
|
-
run_code: "Running code"
|
|
466
|
-
};
|
|
467
|
-
var LIFECYCLE_LABELS = {
|
|
587
|
+
var LIFECYCLE_LABELS_FALLBACK = {
|
|
468
588
|
evaluation: "Evaluating results",
|
|
469
589
|
answering: "Writing answer",
|
|
470
590
|
reviewing: "Reviewing answer",
|
|
@@ -473,18 +593,19 @@ var LIFECYCLE_LABELS = {
|
|
|
473
593
|
};
|
|
474
594
|
function formatAgentStepLabel(step) {
|
|
475
595
|
if (step.focus) return step.focus;
|
|
596
|
+
if (step.label) return step.label;
|
|
476
597
|
const detail = step.detail;
|
|
477
598
|
if (step.step === "tool_progress" && detail && detail.length > 0) {
|
|
478
|
-
const
|
|
479
|
-
const label = toolName && TOOL_LABELS[toolName] || LIFECYCLE_LABELS.tool_progress;
|
|
599
|
+
const label = detail[0].label || LIFECYCLE_LABELS_FALLBACK.tool_progress;
|
|
480
600
|
const message = detail[0].message;
|
|
481
601
|
return message ? `${label}: ${message}` : label;
|
|
482
602
|
}
|
|
483
603
|
if (step.step) {
|
|
484
|
-
return
|
|
604
|
+
return LIFECYCLE_LABELS_FALLBACK[step.step] || step.step;
|
|
485
605
|
}
|
|
486
|
-
if (detail && detail.length > 0
|
|
487
|
-
|
|
606
|
+
if (detail && detail.length > 0) {
|
|
607
|
+
if (detail[0].label) return detail[0].label;
|
|
608
|
+
if (detail[0].tool) return detail[0].tool;
|
|
488
609
|
}
|
|
489
610
|
return "";
|
|
490
611
|
}
|
|
@@ -2069,6 +2190,6 @@ function extractResponseText(response) {
|
|
|
2069
2190
|
return parts.join("");
|
|
2070
2191
|
}
|
|
2071
2192
|
|
|
2072
|
-
export { Arbi, ArbiApiError, ArbiError, FileConfigStore,
|
|
2193
|
+
export { Arbi, ArbiApiError, ArbiError, FileConfigStore, 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
2194
|
//# sourceMappingURL=index.js.map
|
|
2074
2195
|
//# sourceMappingURL=index.js.map
|