@bodhiapp/bodhi-js-ext 0.0.15 → 0.0.17
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/bodhi-ext.cjs.js +1 -1
- package/dist/bodhi-ext.esm.js +465 -421
- package/dist/bodhi-js-sdk/ext/src/constants.d.ts +6 -0
- package/dist/bodhi-js-sdk/ext/src/direct-client.d.ts +3 -2
- package/dist/bodhi-js-sdk/ext/src/ext-client.d.ts +5 -2
- package/dist/bodhi-js-sdk/ext/src/ext2ext-client.d.ts +3 -2
- package/dist/bodhi-js-sdk/ext/src/facade-client.d.ts +2 -0
- package/package.json +3 -3
|
@@ -23,3 +23,9 @@ export declare const DISCOVERY_TIMEOUT_MS = 5000;
|
|
|
23
23
|
export declare const DISCOVERY_ATTEMPTS = 3;
|
|
24
24
|
export declare const DISCOVERY_ATTEMPT_WAIT_MS = 500;
|
|
25
25
|
export declare const DISCOVERY_ATTEMPT_TIMEOUT = 500;
|
|
26
|
+
/**
|
|
27
|
+
* Default API request timeout in milliseconds
|
|
28
|
+
* Used for API requests through extension communication
|
|
29
|
+
* Default: 30 seconds
|
|
30
|
+
*/
|
|
31
|
+
export declare const DEFAULT_API_TIMEOUT_MS = 30000;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DirectClientBase, AuthState, LogLevel, StateChangeCallback } from '../../core/src/index.ts';
|
|
1
|
+
import { DirectClientBase, AuthState, LoginOptions, LogLevel, StateChangeCallback } from '../../core/src/index.ts';
|
|
2
2
|
/**
|
|
3
3
|
* Configuration for DirectExtClient
|
|
4
4
|
*/
|
|
@@ -8,13 +8,14 @@ export interface DirectExtClientConfig {
|
|
|
8
8
|
userScope: string;
|
|
9
9
|
basePath: string;
|
|
10
10
|
logLevel: LogLevel;
|
|
11
|
+
apiTimeoutMs?: number;
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
14
|
* DirectExtClient - Extension mode implementation using chrome.identity OAuth
|
|
14
15
|
*/
|
|
15
16
|
export declare class DirectExtClient extends DirectClientBase {
|
|
16
17
|
constructor(config: DirectExtClientConfig, onStateChange?: StateChangeCallback);
|
|
17
|
-
login(): Promise<AuthState>;
|
|
18
|
+
login(options?: LoginOptions): Promise<AuthState>;
|
|
18
19
|
logout(): Promise<AuthState>;
|
|
19
20
|
protected exchangeCodeForTokens(code: string): Promise<void>;
|
|
20
21
|
protected _storageGet(key: string): Promise<string | null>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IExtensionClient, Chat, Models, Embeddings, ApiResponseResult, AuthState, BackendServerState, ClientState, ExtensionState, InitParams, LogLevel, StateChangeCallback } from '../../core/src/index.ts';
|
|
1
|
+
import { IExtensionClient, Chat, Models, Embeddings, ApiResponseResult, AuthState, BackendServerState, ClientState, ExtensionState, InitParams, LoginOptions, LogLevel, StateChangeCallback } from '../../core/src/index.ts';
|
|
2
2
|
export type SerializedExt2ExtState = {
|
|
3
3
|
extensionId?: string;
|
|
4
4
|
};
|
|
@@ -7,6 +7,7 @@ export type SerializedExt2ExtState = {
|
|
|
7
7
|
*/
|
|
8
8
|
export interface ExtClientConfig {
|
|
9
9
|
logLevel?: LogLevel;
|
|
10
|
+
apiTimeoutMs?: number;
|
|
10
11
|
initParams?: {
|
|
11
12
|
extension?: {
|
|
12
13
|
timeoutMs?: number;
|
|
@@ -32,6 +33,7 @@ export declare class ExtClient implements IExtensionClient {
|
|
|
32
33
|
private extensionId;
|
|
33
34
|
private broadcastListenerActive;
|
|
34
35
|
private config;
|
|
36
|
+
private apiTimeoutMs;
|
|
35
37
|
private _chat;
|
|
36
38
|
private _models;
|
|
37
39
|
private _embeddings;
|
|
@@ -97,10 +99,11 @@ export declare class ExtClient implements IExtensionClient {
|
|
|
97
99
|
sendApiRequest<TReq = void, TRes = unknown>(method: string, endpoint: string, body?: TReq, headers?: Record<string, string>, authenticated?: boolean): Promise<ApiResponseResult<TRes>>;
|
|
98
100
|
/**
|
|
99
101
|
* Login user via OAuth
|
|
102
|
+
* @param options - Optional login parameters including toolsetScopeIds
|
|
100
103
|
* @throws ExtError if login fails
|
|
101
104
|
* @returns AuthState with login state and user info
|
|
102
105
|
*/
|
|
103
|
-
login(): Promise<AuthState>;
|
|
106
|
+
login(options?: LoginOptions): Promise<AuthState>;
|
|
104
107
|
/**
|
|
105
108
|
* Logout current user
|
|
106
109
|
* @throws ExtError if logout fails
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExtClientApiRequestMessage, ExtClientApiResponseMessage, ExtClientRequestMessage, ExtClientResponseMessage } from './messages';
|
|
2
|
-
import { AuthState, LogLevel, UserScope } from '../../core/src/index.ts';
|
|
2
|
+
import { AuthState, LoginOptions, LogLevel, UserScope } from '../../core/src/index.ts';
|
|
3
3
|
export type ClientExtState = 'setup' | 'ready' | 'error';
|
|
4
4
|
export interface BodhiExtClientConfig {
|
|
5
5
|
authServerUrl?: string;
|
|
@@ -102,9 +102,10 @@ export declare class BodhiExtClient {
|
|
|
102
102
|
handleAction<TReq = unknown, TRes = unknown>(message: ExtClientApiRequestMessage<TReq>): Promise<ExtClientApiResponseMessage<TRes>>;
|
|
103
103
|
/**
|
|
104
104
|
* Login user via OAuth2 + PKCE flow
|
|
105
|
+
* @param options - Optional login options (toolsetScopeIds, version)
|
|
105
106
|
* @throws Error if login fails
|
|
106
107
|
*/
|
|
107
|
-
login(): Promise<void>;
|
|
108
|
+
login(options?: LoginOptions): Promise<void>;
|
|
108
109
|
/**
|
|
109
110
|
* Exchange authorization code for tokens (private helper for login)
|
|
110
111
|
* @param code Authorization code from OAuth callback
|
|
@@ -10,6 +10,7 @@ export interface ExtUIClientConfig {
|
|
|
10
10
|
userScope: string;
|
|
11
11
|
basePath: string;
|
|
12
12
|
logLevel: LogLevel;
|
|
13
|
+
apiTimeoutMs?: number;
|
|
13
14
|
initParams?: {
|
|
14
15
|
extension?: {
|
|
15
16
|
timeoutMs?: number;
|
|
@@ -28,6 +29,7 @@ export interface ExtUIClientParams {
|
|
|
28
29
|
userScope?: UserScope;
|
|
29
30
|
basePath?: string;
|
|
30
31
|
logLevel?: LogLevel;
|
|
32
|
+
apiTimeoutMs?: number;
|
|
31
33
|
initParams?: {
|
|
32
34
|
extension?: {
|
|
33
35
|
timeoutMs?: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bodhiapp/bodhi-js-ext",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"description": "Extension SDK for Bodhi Browser - chrome.runtime communication",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/bodhi-ext.cjs.js",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"typecheck": "tsc --noEmit"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@bodhiapp/bodhi-js-core": "0.0.
|
|
41
|
-
"@bodhiapp/ts-client": "0.1.
|
|
40
|
+
"@bodhiapp/bodhi-js-core": "0.0.17",
|
|
41
|
+
"@bodhiapp/ts-client": "0.1.14"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@eslint/js": "^9.23.0",
|