@pellux/goodvibes-sdk 0.18.48 → 0.18.50
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/README.md +15 -13
- package/dist/_internal/errors/index.d.ts +111 -0
- package/dist/_internal/errors/index.d.ts.map +1 -1
- package/dist/_internal/errors/index.js +128 -0
- package/dist/_internal/platform/auth/index.d.ts +6 -0
- package/dist/_internal/platform/auth/index.d.ts.map +1 -0
- package/dist/_internal/platform/auth/index.js +4 -0
- package/dist/_internal/platform/auth/oauth-client.d.ts +45 -0
- package/dist/_internal/platform/auth/oauth-client.d.ts.map +1 -0
- package/dist/_internal/platform/auth/oauth-client.js +45 -0
- package/dist/_internal/platform/auth/permission-resolver.d.ts +35 -0
- package/dist/_internal/platform/auth/permission-resolver.d.ts.map +1 -0
- package/dist/_internal/platform/auth/permission-resolver.js +57 -0
- package/dist/_internal/platform/auth/session-manager.d.ts +31 -0
- package/dist/_internal/platform/auth/session-manager.d.ts.map +1 -0
- package/dist/_internal/platform/auth/session-manager.js +44 -0
- package/dist/_internal/platform/auth/token-store.d.ts +23 -0
- package/dist/_internal/platform/auth/token-store.d.ts.map +1 -0
- package/dist/_internal/platform/auth/token-store.js +34 -0
- package/dist/_internal/platform/core/orchestrator.d.ts +75 -11
- package/dist/_internal/platform/core/orchestrator.d.ts.map +1 -1
- package/dist/_internal/platform/core/orchestrator.js +29 -8
- package/dist/_internal/platform/version.js +1 -1
- package/dist/_internal/transport-http/http-core.d.ts +2 -0
- package/dist/_internal/transport-http/http-core.d.ts.map +1 -1
- package/dist/_internal/transport-http/http-core.js +29 -2
- package/dist/_internal/transport-http/http.d.ts.map +1 -1
- package/dist/_internal/transport-http/http.js +50 -2
- package/dist/_internal/transport-realtime/domain-events.d.ts +26 -0
- package/dist/_internal/transport-realtime/domain-events.d.ts.map +1 -1
- package/dist/_internal/transport-realtime/domain-events.js +63 -0
- package/dist/_internal/transport-realtime/index.d.ts +2 -2
- package/dist/_internal/transport-realtime/index.d.ts.map +1 -1
- package/dist/_internal/transport-realtime/index.js +2 -2
- package/dist/_internal/transport-realtime/runtime-events.d.ts +27 -1
- package/dist/_internal/transport-realtime/runtime-events.d.ts.map +1 -1
- package/dist/_internal/transport-realtime/runtime-events.js +27 -0
- package/dist/auth.d.ts +77 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +52 -0
- package/dist/browser.d.ts +24 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +24 -0
- package/dist/client.d.ts +158 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +22 -0
- package/dist/expo.d.ts +15 -0
- package/dist/expo.d.ts.map +1 -1
- package/dist/expo.js +15 -0
- package/dist/node.d.ts +23 -0
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +23 -0
- package/dist/react-native.d.ts +27 -0
- package/dist/react-native.d.ts.map +1 -1
- package/dist/react-native.js +27 -0
- package/dist/web.d.ts +13 -0
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +13 -0
- package/package.json +1 -1
package/dist/auth.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { OperatorMethodInput, OperatorMethodOutput } from './_internal/contracts/index.js';
|
|
2
2
|
import type { AuthTokenResolver } from './_internal/transport-http/index.js';
|
|
3
3
|
import type { OperatorSdk } from './_internal/operator/index.js';
|
|
4
|
+
export { OAuthClient, PermissionResolver, SessionManager, TokenStore, } from './_internal/platform/auth/index.js';
|
|
5
|
+
export type { OAuthStartState, OAuthTokenPayload } from './_internal/platform/auth/index.js';
|
|
4
6
|
export type GoodVibesCurrentAuth = OperatorMethodOutput<'control.auth.current'>;
|
|
5
7
|
export type GoodVibesLoginInput = OperatorMethodInput<'control.auth.login'>;
|
|
6
8
|
export type GoodVibesLoginOutput = OperatorMethodOutput<'control.auth.login'>;
|
|
@@ -16,15 +18,90 @@ export interface BrowserTokenStoreOptions {
|
|
|
16
18
|
export interface GoodVibesAuthLoginOptions {
|
|
17
19
|
readonly persistToken?: boolean;
|
|
18
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* The combined auth client attached to an SDK instance.
|
|
23
|
+
*
|
|
24
|
+
* This interface aggregates token storage and session management behind a
|
|
25
|
+
* single object for convenience. For focused single-responsibility access,
|
|
26
|
+
* use the split classes exported from this module:
|
|
27
|
+
* - Token persistence: `TokenStore`
|
|
28
|
+
* - Login / session lifecycle: `SessionManager`
|
|
29
|
+
* - OAuth 2.0 flows: `OAuthClient`
|
|
30
|
+
* - Role / scope checks: `PermissionResolver`
|
|
31
|
+
*/
|
|
19
32
|
export interface GoodVibesAuthClient {
|
|
20
33
|
readonly writable: boolean;
|
|
21
34
|
current(): Promise<GoodVibesCurrentAuth>;
|
|
22
35
|
login(input: GoodVibesLoginInput, options?: GoodVibesAuthLoginOptions): Promise<GoodVibesLoginOutput>;
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated Prefer `TokenStore.getToken()` for direct token access.
|
|
38
|
+
* `GoodVibesAuthClient.getToken()` remains supported and delegates to the
|
|
39
|
+
* same underlying store.
|
|
40
|
+
*/
|
|
23
41
|
getToken(): Promise<string | null>;
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated Prefer `TokenStore.setToken()` for direct token mutation.
|
|
44
|
+
* `GoodVibesAuthClient.setToken()` remains supported and delegates to the
|
|
45
|
+
* same underlying store.
|
|
46
|
+
*/
|
|
24
47
|
setToken(token: string | null): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated Prefer `TokenStore.clearToken()` for direct token mutation.
|
|
50
|
+
* `GoodVibesAuthClient.clearToken()` remains supported and delegates to the
|
|
51
|
+
* same underlying store.
|
|
52
|
+
*/
|
|
25
53
|
clearToken(): Promise<void>;
|
|
26
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Create a simple in-memory token store.
|
|
57
|
+
*
|
|
58
|
+
* The token is held in a closure variable — it does not survive page
|
|
59
|
+
* refreshes or process restarts. Suitable for server-side scripts and tests.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* import { createMemoryTokenStore } from '@pellux/goodvibes-sdk';
|
|
63
|
+
*
|
|
64
|
+
* const store = createMemoryTokenStore('initial-token');
|
|
65
|
+
* const sdk = createGoodVibesSdk({ baseUrl: '...', tokenStore: store });
|
|
66
|
+
* await sdk.auth.clearToken(); // clears only in-memory
|
|
67
|
+
*/
|
|
27
68
|
export declare function createMemoryTokenStore(initialToken?: string | null): GoodVibesTokenStore;
|
|
69
|
+
/**
|
|
70
|
+
* Create a token store backed by `localStorage` (or a custom `Storage`).
|
|
71
|
+
*
|
|
72
|
+
* The token is persisted across page refreshes under the key
|
|
73
|
+
* `'goodvibes.token'` (overridable via `options.key`).
|
|
74
|
+
* Pass `options.storage` to use `sessionStorage` or a custom adapter.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* import { createBrowserTokenStore, createBrowserGoodVibesSdk } from '@pellux/goodvibes-sdk/browser';
|
|
78
|
+
*
|
|
79
|
+
* const tokenStore = createBrowserTokenStore({ storage: sessionStorage });
|
|
80
|
+
* const sdk = createBrowserGoodVibesSdk({ tokenStore });
|
|
81
|
+
* await sdk.auth.login({ username: 'alice', password: 's3cr3t' });
|
|
82
|
+
* // token is now stored in sessionStorage
|
|
83
|
+
*/
|
|
28
84
|
export declare function createBrowserTokenStore(options?: BrowserTokenStoreOptions): GoodVibesTokenStore;
|
|
85
|
+
/**
|
|
86
|
+
* Create the auth client attached to an SDK instance.
|
|
87
|
+
*
|
|
88
|
+
* Normally called internally by `createGoodVibesSdk`. Access the result via
|
|
89
|
+
* `sdk.auth`.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* import { createGoodVibesSdk, createBrowserTokenStore } from '@pellux/goodvibes-sdk';
|
|
93
|
+
*
|
|
94
|
+
* const sdk = createGoodVibesSdk({
|
|
95
|
+
* baseUrl: 'https://daemon.example.com',
|
|
96
|
+
* tokenStore: createBrowserTokenStore(),
|
|
97
|
+
* });
|
|
98
|
+
*
|
|
99
|
+
* // Login and persist the token automatically:
|
|
100
|
+
* const { token } = await sdk.auth.login({ username: 'alice', password: 's3cr3t' });
|
|
101
|
+
* console.log('logged in, token stored:', token.slice(0, 8) + '...');
|
|
102
|
+
*
|
|
103
|
+
* // Later: clear the session
|
|
104
|
+
* await sdk.auth.clearToken();
|
|
105
|
+
*/
|
|
29
106
|
export declare function createGoodVibesAuthClient(operator: OperatorSdk, tokenStore: GoodVibesTokenStore | null, getAuthToken?: AuthTokenResolver): GoodVibesAuthClient;
|
|
30
107
|
//# sourceMappingURL=auth.d.ts.map
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAIjE,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,cAAc,EACd,UAAU,GACX,MAAM,oCAAoC,CAAC;AAC5C,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAE7F,MAAM,MAAM,oBAAoB,GAAG,oBAAoB,CAAC,sBAAsB,CAAC,CAAC;AAChF,MAAM,MAAM,mBAAmB,GAAG,mBAAmB,CAAC,oBAAoB,C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,OAAO,GAAE,wBAA6B,GAAG,mBAAmB,CAmBnG;AAwBD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,WAAW,EACrB,UAAU,EAAE,mBAAmB,GAAG,IAAI,EACtC,YAAY,CAAC,EAAE,iBAAiB,GAC/B,mBAAmB,CA0BrB"}
|
package/dist/auth.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { ConfigurationError } from './_internal/errors/index.js';
|
|
2
|
+
// Re-export focused responsibility classes for consumers who prefer
|
|
3
|
+
// narrower, single-concern APIs over the combined GoodVibesAuthClient facade.
|
|
4
|
+
export { OAuthClient, PermissionResolver, SessionManager, TokenStore, } from './_internal/platform/auth/index.js';
|
|
2
5
|
function requireStorage(storage) {
|
|
3
6
|
const resolved = storage ?? globalThis.localStorage;
|
|
4
7
|
if (!resolved) {
|
|
@@ -6,6 +9,19 @@ function requireStorage(storage) {
|
|
|
6
9
|
}
|
|
7
10
|
return resolved;
|
|
8
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Create a simple in-memory token store.
|
|
14
|
+
*
|
|
15
|
+
* The token is held in a closure variable — it does not survive page
|
|
16
|
+
* refreshes or process restarts. Suitable for server-side scripts and tests.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* import { createMemoryTokenStore } from '@pellux/goodvibes-sdk';
|
|
20
|
+
*
|
|
21
|
+
* const store = createMemoryTokenStore('initial-token');
|
|
22
|
+
* const sdk = createGoodVibesSdk({ baseUrl: '...', tokenStore: store });
|
|
23
|
+
* await sdk.auth.clearToken(); // clears only in-memory
|
|
24
|
+
*/
|
|
9
25
|
export function createMemoryTokenStore(initialToken = null) {
|
|
10
26
|
let token = initialToken;
|
|
11
27
|
return {
|
|
@@ -20,6 +36,21 @@ export function createMemoryTokenStore(initialToken = null) {
|
|
|
20
36
|
},
|
|
21
37
|
};
|
|
22
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Create a token store backed by `localStorage` (or a custom `Storage`).
|
|
41
|
+
*
|
|
42
|
+
* The token is persisted across page refreshes under the key
|
|
43
|
+
* `'goodvibes.token'` (overridable via `options.key`).
|
|
44
|
+
* Pass `options.storage` to use `sessionStorage` or a custom adapter.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* import { createBrowserTokenStore, createBrowserGoodVibesSdk } from '@pellux/goodvibes-sdk/browser';
|
|
48
|
+
*
|
|
49
|
+
* const tokenStore = createBrowserTokenStore({ storage: sessionStorage });
|
|
50
|
+
* const sdk = createBrowserGoodVibesSdk({ tokenStore });
|
|
51
|
+
* await sdk.auth.login({ username: 'alice', password: 's3cr3t' });
|
|
52
|
+
* // token is now stored in sessionStorage
|
|
53
|
+
*/
|
|
23
54
|
export function createBrowserTokenStore(options = {}) {
|
|
24
55
|
const storage = requireStorage(options.storage);
|
|
25
56
|
const key = options.key?.trim() || 'goodvibes.token';
|
|
@@ -55,6 +86,27 @@ function assertWritableTokenStore(tokenStore) {
|
|
|
55
86
|
}
|
|
56
87
|
return tokenStore;
|
|
57
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Create the auth client attached to an SDK instance.
|
|
91
|
+
*
|
|
92
|
+
* Normally called internally by `createGoodVibesSdk`. Access the result via
|
|
93
|
+
* `sdk.auth`.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* import { createGoodVibesSdk, createBrowserTokenStore } from '@pellux/goodvibes-sdk';
|
|
97
|
+
*
|
|
98
|
+
* const sdk = createGoodVibesSdk({
|
|
99
|
+
* baseUrl: 'https://daemon.example.com',
|
|
100
|
+
* tokenStore: createBrowserTokenStore(),
|
|
101
|
+
* });
|
|
102
|
+
*
|
|
103
|
+
* // Login and persist the token automatically:
|
|
104
|
+
* const { token } = await sdk.auth.login({ username: 'alice', password: 's3cr3t' });
|
|
105
|
+
* console.log('logged in, token stored:', token.slice(0, 8) + '...');
|
|
106
|
+
*
|
|
107
|
+
* // Later: clear the session
|
|
108
|
+
* await sdk.auth.clearToken();
|
|
109
|
+
*/
|
|
58
110
|
export function createGoodVibesAuthClient(operator, tokenStore, getAuthToken) {
|
|
59
111
|
return {
|
|
60
112
|
writable: tokenStore !== null,
|
package/dist/browser.d.ts
CHANGED
|
@@ -4,5 +4,29 @@ export interface BrowserGoodVibesSdkOptions extends Omit<GoodVibesSdkOptions, 'b
|
|
|
4
4
|
readonly fetch?: typeof fetch;
|
|
5
5
|
readonly WebSocketImpl?: typeof WebSocket;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Create a GoodVibes SDK instance for browser environments.
|
|
9
|
+
*
|
|
10
|
+
* Differences from `createGoodVibesSdk`:
|
|
11
|
+
* - `baseUrl` defaults to `location.origin` when omitted.
|
|
12
|
+
* - HTTP retry and realtime reconnect are pre-configured with
|
|
13
|
+
* browser-appropriate defaults.
|
|
14
|
+
* - Relies on the native browser `fetch` and `WebSocket` globals; pass
|
|
15
|
+
* `options.fetch` / `options.WebSocketImpl` to override.
|
|
16
|
+
*
|
|
17
|
+
* `createWebGoodVibesSdk` is an alias for this function — use whichever name
|
|
18
|
+
* reads more naturally in your project.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Example only: baseUrl defaults to location.origin in a real browser app.
|
|
22
|
+
* import { createBrowserGoodVibesSdk } from '@pellux/goodvibes-sdk/browser';
|
|
23
|
+
*
|
|
24
|
+
* const sdk = createBrowserGoodVibesSdk({
|
|
25
|
+
* authToken: sessionStorage.getItem('gv-token') ?? undefined,
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* const agents = await sdk.operator.agents.list();
|
|
29
|
+
*/
|
|
30
|
+
export { forSession } from './transport-realtime.js';
|
|
7
31
|
export declare function createBrowserGoodVibesSdk(options?: BrowserGoodVibesSdkOptions): GoodVibesSdk;
|
|
8
32
|
//# sourceMappingURL=browser.d.ts.map
|
package/dist/browser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,0BACf,SAAQ,IAAI,CAAC,mBAAmB,EAAE,SAAS,GAAG,OAAO,GAAG,eAAe,CAAC;IACxE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IAC9B,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,SAAS,CAAC;CAC3C;AAaD,wBAAgB,yBAAyB,CACvC,OAAO,GAAE,0BAA+B,GACvC,YAAY,CAiCd"}
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,0BACf,SAAQ,IAAI,CAAC,mBAAmB,EAAE,SAAS,GAAG,OAAO,GAAG,eAAe,CAAC;IACxE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IAC9B,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,SAAS,CAAC;CAC3C;AAaD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,wBAAgB,yBAAyB,CACvC,OAAO,GAAE,0BAA+B,GACvC,YAAY,CAiCd"}
|
package/dist/browser.js
CHANGED
|
@@ -9,6 +9,30 @@ function resolveBrowserBaseUrl(baseUrl) {
|
|
|
9
9
|
}
|
|
10
10
|
throw new ConfigurationError('Browser baseUrl is required when location.origin is unavailable.');
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Create a GoodVibes SDK instance for browser environments.
|
|
14
|
+
*
|
|
15
|
+
* Differences from `createGoodVibesSdk`:
|
|
16
|
+
* - `baseUrl` defaults to `location.origin` when omitted.
|
|
17
|
+
* - HTTP retry and realtime reconnect are pre-configured with
|
|
18
|
+
* browser-appropriate defaults.
|
|
19
|
+
* - Relies on the native browser `fetch` and `WebSocket` globals; pass
|
|
20
|
+
* `options.fetch` / `options.WebSocketImpl` to override.
|
|
21
|
+
*
|
|
22
|
+
* `createWebGoodVibesSdk` is an alias for this function — use whichever name
|
|
23
|
+
* reads more naturally in your project.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Example only: baseUrl defaults to location.origin in a real browser app.
|
|
27
|
+
* import { createBrowserGoodVibesSdk } from '@pellux/goodvibes-sdk/browser';
|
|
28
|
+
*
|
|
29
|
+
* const sdk = createBrowserGoodVibesSdk({
|
|
30
|
+
* authToken: sessionStorage.getItem('gv-token') ?? undefined,
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* const agents = await sdk.operator.agents.list();
|
|
34
|
+
*/
|
|
35
|
+
export { forSession } from './transport-realtime.js';
|
|
12
36
|
export function createBrowserGoodVibesSdk(options = {}) {
|
|
13
37
|
return createGoodVibesSdk({
|
|
14
38
|
baseUrl: resolveBrowserBaseUrl(options.baseUrl),
|
package/dist/client.d.ts
CHANGED
|
@@ -22,32 +22,190 @@ import { type GoodVibesAuthClient, type GoodVibesTokenStore } from './auth.js';
|
|
|
22
22
|
* @see AnyRuntimeEvent for the full discriminated union type.
|
|
23
23
|
*/
|
|
24
24
|
export type RuntimeEventRecord = AnyRuntimeEvent;
|
|
25
|
+
/**
|
|
26
|
+
* Options for constructing a GoodVibes SDK instance.
|
|
27
|
+
*
|
|
28
|
+
* ### Auth token precedence (highest → lowest)
|
|
29
|
+
* 1. **`tokenStore`** — when present, `getToken()` is called on every request.
|
|
30
|
+
* Mutations (`login`, `setToken`, `clearToken`) persist back to the store.
|
|
31
|
+
* 2. **`getAuthToken`** — a read-only async resolver. No persistence; mutations
|
|
32
|
+
* throw `ConfigurationError`.
|
|
33
|
+
* 3. **`authToken`** — a static string (or `null`). Wrapped in a
|
|
34
|
+
* `createMemoryTokenStore` internally so mutations work in-process.
|
|
35
|
+
*
|
|
36
|
+
* Only provide one of the three. If none are supplied the SDK operates without
|
|
37
|
+
* credentials (useful for public endpoints).
|
|
38
|
+
*/
|
|
25
39
|
export interface GoodVibesSdkOptions {
|
|
40
|
+
/**
|
|
41
|
+
* Base URL of the GoodVibes daemon, e.g. `'https://my-daemon.example.com'`.
|
|
42
|
+
* Must be a non-empty string. A trailing slash is trimmed automatically.
|
|
43
|
+
*/
|
|
26
44
|
readonly baseUrl: string;
|
|
45
|
+
/**
|
|
46
|
+
* Static auth token string. Internally wrapped in an in-memory token store,
|
|
47
|
+
* so `sdk.auth.setToken()` / `sdk.auth.clearToken()` work.
|
|
48
|
+
*
|
|
49
|
+
* Lowest-precedence auth option — ignored when `tokenStore` or `getAuthToken`
|
|
50
|
+
* is also provided.
|
|
51
|
+
*
|
|
52
|
+
* @see https://github.com/mgd34msu/goodvibes-sdk/blob/main/docs/authentication.md
|
|
53
|
+
*/
|
|
27
54
|
readonly authToken?: string | null;
|
|
55
|
+
/**
|
|
56
|
+
* Async token resolver called before every authenticated request.
|
|
57
|
+
* Use this when your token lives outside the SDK (e.g. retrieved from a
|
|
58
|
+
* framework session or an external secret store).
|
|
59
|
+
*
|
|
60
|
+
* When this option is set, `sdk.auth.writable` is `false` — calling
|
|
61
|
+
* `setToken` / `clearToken` throws a `ConfigurationError`.
|
|
62
|
+
*
|
|
63
|
+
* Takes precedence over `authToken`; ignored when `tokenStore` is provided.
|
|
64
|
+
*
|
|
65
|
+
* @see https://github.com/mgd34msu/goodvibes-sdk/blob/main/docs/authentication.md
|
|
66
|
+
*/
|
|
28
67
|
readonly getAuthToken?: AuthTokenResolver;
|
|
68
|
+
/**
|
|
69
|
+
* A mutable token store implementing `getToken / setToken / clearToken`.
|
|
70
|
+
* The SDK calls `getToken()` before every request and writes back via
|
|
71
|
+
* `setToken()` after a successful `sdk.auth.login()`.
|
|
72
|
+
*
|
|
73
|
+
* Highest-precedence auth option — overrides both `getAuthToken` and
|
|
74
|
+
* `authToken`. Use `createBrowserTokenStore()` (localStorage) or
|
|
75
|
+
* `createMemoryTokenStore()` for common cases.
|
|
76
|
+
*
|
|
77
|
+
* @see https://github.com/mgd34msu/goodvibes-sdk/blob/main/docs/authentication.md
|
|
78
|
+
*/
|
|
29
79
|
readonly tokenStore?: GoodVibesTokenStore;
|
|
80
|
+
/**
|
|
81
|
+
* Custom `fetch` implementation. Falls back to `globalThis.fetch`.
|
|
82
|
+
* Required in environments without a native fetch (e.g. older Node.js).
|
|
83
|
+
*/
|
|
30
84
|
readonly fetch?: typeof fetch;
|
|
85
|
+
/**
|
|
86
|
+
* Static extra headers sent on every request, e.g.
|
|
87
|
+
* `{ 'X-Tenant-Id': 'acme' }`.
|
|
88
|
+
*/
|
|
31
89
|
readonly headers?: HeadersInit;
|
|
90
|
+
/**
|
|
91
|
+
* Async resolver for per-request headers. Called on each request after the
|
|
92
|
+
* auth header is set. Useful for adding request-scoped tracing headers.
|
|
93
|
+
*/
|
|
32
94
|
readonly getHeaders?: HeaderResolver;
|
|
95
|
+
/**
|
|
96
|
+
* HTTP retry policy for transient failures (408, 429, 5xx).
|
|
97
|
+
* Runtime-specific factories (e.g. `createNodeGoodVibesSdk`) apply
|
|
98
|
+
* sensible defaults; pass this to override.
|
|
99
|
+
*/
|
|
33
100
|
readonly retry?: HttpRetryPolicy;
|
|
101
|
+
/**
|
|
102
|
+
* Custom `WebSocket` constructor. Falls back to `globalThis.WebSocket`.
|
|
103
|
+
* Required in Node.js < 21 or when using a polyfill.
|
|
104
|
+
*/
|
|
34
105
|
readonly WebSocketImpl?: typeof WebSocket;
|
|
106
|
+
/**
|
|
107
|
+
* Options that control realtime transport behaviour (SSE and WebSocket
|
|
108
|
+
* reconnect policies, error callback).
|
|
109
|
+
*/
|
|
35
110
|
readonly realtime?: GoodVibesRealtimeOptions;
|
|
36
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Options controlling realtime transport behaviour.
|
|
114
|
+
*/
|
|
37
115
|
export interface GoodVibesRealtimeOptions {
|
|
38
116
|
readonly sseReconnect?: StreamReconnectPolicy;
|
|
39
117
|
readonly webSocketReconnect?: StreamReconnectPolicy;
|
|
40
118
|
readonly onError?: (error: unknown) => void;
|
|
41
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Realtime event subscriptions for the GoodVibes daemon.
|
|
122
|
+
* Choose SSE for read-only event streams or WebSocket for bidirectional use.
|
|
123
|
+
*
|
|
124
|
+
* ### Filtering by session
|
|
125
|
+
*
|
|
126
|
+
* When multiple sessions share one SSE/WebSocket connection, use
|
|
127
|
+
* `forSession(events, sessionId)` to get a pre-filtered view instead of
|
|
128
|
+
* manually guarding every callback with `if (e.sessionId !== mine) return`.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* import { createNodeGoodVibesSdk, forSession } from '@pellux/goodvibes-sdk';
|
|
132
|
+
*
|
|
133
|
+
* const sdk = createNodeGoodVibesSdk({ baseUrl: 'http://127.0.0.1:3210' });
|
|
134
|
+
* const session = await sdk.operator.sessions.create({ title: 'demo' });
|
|
135
|
+
* const sessionId = session.session.id;
|
|
136
|
+
*
|
|
137
|
+
* const events = sdk.realtime.viaSse();
|
|
138
|
+
* const sessionEvents = forSession(events, sessionId);
|
|
139
|
+
*
|
|
140
|
+
* sessionEvents.turn.onEnvelope('STREAM_DELTA', (e) => {
|
|
141
|
+
* process.stdout.write(e.payload.content); // only fires for this session
|
|
142
|
+
* });
|
|
143
|
+
*/
|
|
42
144
|
export interface GoodVibesRealtime {
|
|
43
145
|
viaSse(): RemoteRuntimeEvents<RuntimeEventRecord>;
|
|
44
146
|
viaWebSocket(webSocketImpl?: typeof WebSocket): RemoteRuntimeEvents<RuntimeEventRecord>;
|
|
45
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* The GoodVibes SDK instance returned by `createGoodVibesSdk` (and its
|
|
150
|
+
* runtime-specific wrappers).
|
|
151
|
+
*
|
|
152
|
+
* Three primary namespaces:
|
|
153
|
+
* - **`operator`** — full control-plane API (daemon admin, agent management,
|
|
154
|
+
* session lifecycle, config). Requires an operator-level auth token.
|
|
155
|
+
* - **`peer`** — peer-to-peer and collaboration APIs (pairing, channels,
|
|
156
|
+
* shared sessions). May be used with peer-scoped tokens.
|
|
157
|
+
* - **`realtime`** — subscribe to live daemon events via SSE or WebSocket.
|
|
158
|
+
* - **`auth`** — login, logout, and token management helpers.
|
|
159
|
+
*/
|
|
46
160
|
export interface GoodVibesSdk {
|
|
161
|
+
/**
|
|
162
|
+
* Full control-plane API: daemon admin, agent management, session lifecycle,
|
|
163
|
+
* config. Requires an operator-level auth token.
|
|
164
|
+
*
|
|
165
|
+
* @see https://github.com/mgd34msu/goodvibes-sdk/blob/main/docs/reference-operator.md
|
|
166
|
+
*/
|
|
47
167
|
readonly operator: OperatorSdk;
|
|
168
|
+
/**
|
|
169
|
+
* Peer-to-peer and collaboration APIs: pairing, channels, shared sessions.
|
|
170
|
+
* May be used with peer-scoped tokens.
|
|
171
|
+
*
|
|
172
|
+
* @see https://github.com/mgd34msu/goodvibes-sdk/blob/main/docs/reference-peer.md
|
|
173
|
+
*/
|
|
48
174
|
readonly peer: PeerSdk;
|
|
175
|
+
/**
|
|
176
|
+
* Login, logout, and token management helpers.
|
|
177
|
+
*
|
|
178
|
+
* @see https://github.com/mgd34msu/goodvibes-sdk/blob/main/docs/authentication.md
|
|
179
|
+
*/
|
|
49
180
|
readonly auth: GoodVibesAuthClient;
|
|
181
|
+
/**
|
|
182
|
+
* Subscribe to live daemon events via SSE or WebSocket.
|
|
183
|
+
*
|
|
184
|
+
* @see https://github.com/mgd34msu/goodvibes-sdk/blob/main/docs/realtime-and-telemetry.md
|
|
185
|
+
*/
|
|
50
186
|
readonly realtime: GoodVibesRealtime;
|
|
51
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* Create a GoodVibes SDK instance.
|
|
190
|
+
*
|
|
191
|
+
* This is the runtime-agnostic constructor. For environments with sensible
|
|
192
|
+
* defaults already configured, prefer the platform-specific wrappers:
|
|
193
|
+
* `createNodeGoodVibesSdk`, `createBrowserGoodVibesSdk`,
|
|
194
|
+
* `createReactNativeGoodVibesSdk`.
|
|
195
|
+
*
|
|
196
|
+
* @see https://github.com/mgd34msu/goodvibes-sdk/blob/main/docs/getting-started.md
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* // Example only: replace baseUrl and authToken with your own values.
|
|
200
|
+
* import { createGoodVibesSdk } from '@pellux/goodvibes-sdk';
|
|
201
|
+
*
|
|
202
|
+
* const sdk = createGoodVibesSdk({
|
|
203
|
+
* baseUrl: 'https://daemon.example.com',
|
|
204
|
+
* authToken: process.env.GV_TOKEN,
|
|
205
|
+
* });
|
|
206
|
+
*
|
|
207
|
+
* const agents = await sdk.operator.agents.list();
|
|
208
|
+
* console.log(agents);
|
|
209
|
+
*/
|
|
52
210
|
export declare function createGoodVibesSdk(options: GoodVibesSdkOptions): GoodVibesSdk;
|
|
53
211
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,WAAW,EAEjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAEL,KAAK,OAAO,EAEb,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,qBAAqB,EACtB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAIL,KAAK,mBAAmB,EACzB,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AACpF,OAAO,EAGL,KAAK,mBAAmB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
|
|
56
|
+
/**
|
|
57
|
+
* Create a GoodVibes SDK instance.
|
|
58
|
+
*
|
|
59
|
+
* This is the runtime-agnostic constructor. For environments with sensible
|
|
60
|
+
* defaults already configured, prefer the platform-specific wrappers:
|
|
61
|
+
* `createNodeGoodVibesSdk`, `createBrowserGoodVibesSdk`,
|
|
62
|
+
* `createReactNativeGoodVibesSdk`.
|
|
63
|
+
*
|
|
64
|
+
* @see https://github.com/mgd34msu/goodvibes-sdk/blob/main/docs/getting-started.md
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* // Example only: replace baseUrl and authToken with your own values.
|
|
68
|
+
* import { createGoodVibesSdk } from '@pellux/goodvibes-sdk';
|
|
69
|
+
*
|
|
70
|
+
* const sdk = createGoodVibesSdk({
|
|
71
|
+
* baseUrl: 'https://daemon.example.com',
|
|
72
|
+
* authToken: process.env.GV_TOKEN,
|
|
73
|
+
* });
|
|
74
|
+
*
|
|
75
|
+
* const agents = await sdk.operator.agents.list();
|
|
76
|
+
* console.log(agents);
|
|
77
|
+
*/
|
|
56
78
|
export function createGoodVibesSdk(options) {
|
|
57
79
|
const baseUrl = requireBaseUrl(options.baseUrl);
|
|
58
80
|
const tokenStore = options.tokenStore ?? (options.getAuthToken ? null : createMemoryTokenStore(options.authToken ?? null));
|
package/dist/expo.d.ts
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { type ReactNativeGoodVibesSdk, type ReactNativeGoodVibesSdkOptions } from './react-native.js';
|
|
2
2
|
export interface ExpoGoodVibesSdkOptions extends ReactNativeGoodVibesSdkOptions {
|
|
3
3
|
}
|
|
4
|
+
/**
|
|
5
|
+
* Alias for `createReactNativeGoodVibesSdk`. Use this entry-point when
|
|
6
|
+
* importing from `@pellux/goodvibes-sdk/expo`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* // Example only: uses expo-secure-store; replace with your own storage.
|
|
10
|
+
* import { createExpoGoodVibesSdk } from '@pellux/goodvibes-sdk/expo';
|
|
11
|
+
* import * as SecureStore from 'expo-secure-store';
|
|
12
|
+
*
|
|
13
|
+
* const sdk = createExpoGoodVibesSdk({
|
|
14
|
+
* baseUrl: process.env.EXPO_PUBLIC_GV_URL!,
|
|
15
|
+
* authToken: await SecureStore.getItemAsync('gv-token'),
|
|
16
|
+
* });
|
|
17
|
+
*/
|
|
18
|
+
export { forSession } from './transport-realtime.js';
|
|
4
19
|
export declare function createExpoGoodVibesSdk(options: ExpoGoodVibesSdkOptions): ReactNativeGoodVibesSdk;
|
|
5
20
|
//# sourceMappingURL=expo.d.ts.map
|
package/dist/expo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expo.d.ts","sourceRoot":"","sources":["../src/expo.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,8BAA8B,EACpC,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,uBAAwB,SAAQ,8BAA8B;CAAG;AAElF,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,uBAAuB,GAAG,uBAAuB,CAEhG"}
|
|
1
|
+
{"version":3,"file":"expo.d.ts","sourceRoot":"","sources":["../src/expo.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,8BAA8B,EACpC,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,uBAAwB,SAAQ,8BAA8B;CAAG;AAElF;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,uBAAuB,GAAG,uBAAuB,CAEhG"}
|
package/dist/expo.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import { createReactNativeGoodVibesSdk, } from './react-native.js';
|
|
2
|
+
/**
|
|
3
|
+
* Alias for `createReactNativeGoodVibesSdk`. Use this entry-point when
|
|
4
|
+
* importing from `@pellux/goodvibes-sdk/expo`.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // Example only: uses expo-secure-store; replace with your own storage.
|
|
8
|
+
* import { createExpoGoodVibesSdk } from '@pellux/goodvibes-sdk/expo';
|
|
9
|
+
* import * as SecureStore from 'expo-secure-store';
|
|
10
|
+
*
|
|
11
|
+
* const sdk = createExpoGoodVibesSdk({
|
|
12
|
+
* baseUrl: process.env.EXPO_PUBLIC_GV_URL!,
|
|
13
|
+
* authToken: await SecureStore.getItemAsync('gv-token'),
|
|
14
|
+
* });
|
|
15
|
+
*/
|
|
16
|
+
export { forSession } from './transport-realtime.js';
|
|
2
17
|
export function createExpoGoodVibesSdk(options) {
|
|
3
18
|
return createReactNativeGoodVibesSdk(options);
|
|
4
19
|
}
|
package/dist/node.d.ts
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
import { type GoodVibesSdkOptions, type GoodVibesSdk } from './client.js';
|
|
2
2
|
export interface NodeGoodVibesSdkOptions extends GoodVibesSdkOptions {
|
|
3
3
|
}
|
|
4
|
+
/**
|
|
5
|
+
* Create a GoodVibes SDK instance configured for Node.js.
|
|
6
|
+
*
|
|
7
|
+
* Applies Node-friendly defaults on top of `createGoodVibesSdk`:
|
|
8
|
+
* - HTTP retry: 3 attempts, 200 ms base delay, 2 s max.
|
|
9
|
+
* - SSE and WebSocket reconnect enabled (500 ms base, 5 s max).
|
|
10
|
+
*
|
|
11
|
+
* Uses `globalThis.fetch` (available in Node 18+). For older runtimes pass
|
|
12
|
+
* `options.fetch` explicitly.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Example only: replace baseUrl and authToken with your own values.
|
|
16
|
+
* import { createNodeGoodVibesSdk } from '@pellux/goodvibes-sdk/node';
|
|
17
|
+
*
|
|
18
|
+
* const sdk = createNodeGoodVibesSdk({
|
|
19
|
+
* baseUrl: process.env.GV_BASE_URL!,
|
|
20
|
+
* authToken: process.env.GV_TOKEN,
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* const session = await sdk.operator.sessions.create({ name: 'my-session' });
|
|
24
|
+
* console.log(session.id);
|
|
25
|
+
*/
|
|
26
|
+
export { forSession } from './transport-realtime.js';
|
|
4
27
|
export declare function createNodeGoodVibesSdk(options: NodeGoodVibesSdkOptions): GoodVibesSdk;
|
|
5
28
|
//# sourceMappingURL=node.d.ts.map
|
package/dist/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,uBAAwB,SAAQ,mBAAmB;CAAG;AAEvE,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,uBAAuB,GAC/B,YAAY,CAwBd"}
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,uBAAwB,SAAQ,mBAAmB;CAAG;AAEvE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,uBAAuB,GAC/B,YAAY,CAwBd"}
|
package/dist/node.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
import { createGoodVibesSdk, } from './client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Create a GoodVibes SDK instance configured for Node.js.
|
|
4
|
+
*
|
|
5
|
+
* Applies Node-friendly defaults on top of `createGoodVibesSdk`:
|
|
6
|
+
* - HTTP retry: 3 attempts, 200 ms base delay, 2 s max.
|
|
7
|
+
* - SSE and WebSocket reconnect enabled (500 ms base, 5 s max).
|
|
8
|
+
*
|
|
9
|
+
* Uses `globalThis.fetch` (available in Node 18+). For older runtimes pass
|
|
10
|
+
* `options.fetch` explicitly.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Example only: replace baseUrl and authToken with your own values.
|
|
14
|
+
* import { createNodeGoodVibesSdk } from '@pellux/goodvibes-sdk/node';
|
|
15
|
+
*
|
|
16
|
+
* const sdk = createNodeGoodVibesSdk({
|
|
17
|
+
* baseUrl: process.env.GV_BASE_URL!,
|
|
18
|
+
* authToken: process.env.GV_TOKEN,
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* const session = await sdk.operator.sessions.create({ name: 'my-session' });
|
|
22
|
+
* console.log(session.id);
|
|
23
|
+
*/
|
|
24
|
+
export { forSession } from './transport-realtime.js';
|
|
2
25
|
export function createNodeGoodVibesSdk(options) {
|
|
3
26
|
return createGoodVibesSdk({
|
|
4
27
|
...options,
|
package/dist/react-native.d.ts
CHANGED
|
@@ -10,5 +10,32 @@ export interface ReactNativeGoodVibesRealtime {
|
|
|
10
10
|
export type ReactNativeGoodVibesSdk = Omit<GoodVibesSdk, 'realtime'> & {
|
|
11
11
|
readonly realtime: ReactNativeGoodVibesRealtime;
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Create a GoodVibes SDK instance for React Native.
|
|
15
|
+
*
|
|
16
|
+
* Key differences from the browser factory:
|
|
17
|
+
* - Realtime is WebSocket-only (`realtime.runtime()` / `realtime.viaWebSocket()`).
|
|
18
|
+
* SSE is not available in React Native.
|
|
19
|
+
* - Requires a `WebSocket` implementation (e.g. the global provided by the
|
|
20
|
+
* React Native runtime or the `react-native` package). Pass
|
|
21
|
+
* `options.WebSocketImpl` when the global is not available.
|
|
22
|
+
* - Returns `ReactNativeGoodVibesSdk` (extends `GoodVibesSdk` with a
|
|
23
|
+
* React-Native-specific `realtime` namespace).
|
|
24
|
+
*
|
|
25
|
+
* `createExpoGoodVibesSdk` is an alias for this function.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Example only: replace baseUrl and authToken with your own values.
|
|
29
|
+
* import { createReactNativeGoodVibesSdk } from '@pellux/goodvibes-sdk/react-native';
|
|
30
|
+
*
|
|
31
|
+
* const sdk = createReactNativeGoodVibesSdk({
|
|
32
|
+
* baseUrl: 'https://daemon.example.com',
|
|
33
|
+
* authToken: await SecureStore.getItemAsync('token'),
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* const events = sdk.realtime.runtime();
|
|
37
|
+
* events.agents.on('AGENT_SPAWNING', ({ agentId }) => console.log(agentId));
|
|
38
|
+
*/
|
|
39
|
+
export { forSession } from './transport-realtime.js';
|
|
13
40
|
export declare function createReactNativeGoodVibesSdk(options: ReactNativeGoodVibesSdkOptions): ReactNativeGoodVibesSdk;
|
|
14
41
|
//# sourceMappingURL=react-native.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-native.d.ts","sourceRoot":"","sources":["../src/react-native.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,8BACf,SAAQ,IAAI,CAAC,mBAAmB,EAAE,eAAe,CAAC;IAClD,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,SAAS,CAAC;CAC3C;AAED,MAAM,WAAW,4BAA4B;IAC3C,OAAO,IAAI,mBAAmB,CAAC,kBAAkB,CAAC,CAAC;IACnD,YAAY,CAAC,aAAa,CAAC,EAAE,OAAO,SAAS,GAAG,mBAAmB,CAAC,kBAAkB,CAAC,CAAC;CACzF;AAED,MAAM,MAAM,uBAAuB,GACjC,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,GAAG;IAC/B,QAAQ,CAAC,QAAQ,EAAE,4BAA4B,CAAC;CACjD,CAAC;AAYJ,wBAAgB,6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