@pellux/goodvibes-sdk 0.18.47 → 0.18.49

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.
Files changed (38) hide show
  1. package/README.md +15 -13
  2. package/dist/_internal/errors/index.d.ts +86 -0
  3. package/dist/_internal/errors/index.d.ts.map +1 -1
  4. package/dist/_internal/errors/index.js +86 -0
  5. package/dist/_internal/platform/daemon/facade-composition.d.ts +24 -0
  6. package/dist/_internal/platform/daemon/facade-composition.d.ts.map +1 -1
  7. package/dist/_internal/platform/daemon/facade-composition.js +93 -0
  8. package/dist/_internal/platform/daemon/facade.d.ts +1 -0
  9. package/dist/_internal/platform/daemon/facade.d.ts.map +1 -1
  10. package/dist/_internal/platform/daemon/facade.js +3 -0
  11. package/dist/_internal/platform/version.js +1 -1
  12. package/dist/_internal/transport-http/http-core.d.ts +2 -0
  13. package/dist/_internal/transport-http/http-core.d.ts.map +1 -1
  14. package/dist/_internal/transport-http/http-core.js +29 -2
  15. package/dist/_internal/transport-http/http.d.ts.map +1 -1
  16. package/dist/_internal/transport-http/http.js +50 -2
  17. package/dist/auth.d.ts +49 -0
  18. package/dist/auth.d.ts.map +1 -1
  19. package/dist/auth.js +49 -0
  20. package/dist/browser.d.ts +23 -0
  21. package/dist/browser.d.ts.map +1 -1
  22. package/dist/browser.js +23 -0
  23. package/dist/client.d.ts +108 -0
  24. package/dist/client.d.ts.map +1 -1
  25. package/dist/client.js +20 -0
  26. package/dist/expo.d.ts +14 -0
  27. package/dist/expo.d.ts.map +1 -1
  28. package/dist/expo.js +14 -0
  29. package/dist/node.d.ts +22 -0
  30. package/dist/node.d.ts.map +1 -1
  31. package/dist/node.js +22 -0
  32. package/dist/react-native.d.ts +26 -0
  33. package/dist/react-native.d.ts.map +1 -1
  34. package/dist/react-native.js +26 -0
  35. package/dist/web.d.ts +12 -0
  36. package/dist/web.d.ts.map +1 -1
  37. package/dist/web.js +12 -0
  38. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  // Synced from packages/transport-http/src/http.ts
2
- import { ConfigurationError, ContractError, createHttpStatusError } from '../errors/index.js';
2
+ import { ConfigurationError, ContractError, HttpStatusError, createHttpStatusError } from '../errors/index.js';
3
3
  import { mergeHeaders, resolveAuthToken, resolveHeaders, } from './auth.js';
4
4
  import { computeBackoffDelay, normalizeBackoffPolicy, sleepWithSignal, } from './backoff.js';
5
5
  import { DEFAULT_HTTP_RETRY_POLICY, getHttpRetryDelay, isRetryableHttpStatus, isRetryableNetworkError, normalizeHttpRetryPolicy, resolveHttpRetryPolicy, } from './retry.js';
@@ -14,9 +14,57 @@ function isTransportError(error) {
14
14
  && typeof error.transport.status === 'number'
15
15
  && typeof error.transport.url === 'string');
16
16
  }
17
+ function inferTransportHint(status, url, retryAfterMs) {
18
+ if (status === 0)
19
+ return `Transport could not reach ${url}. Verify the baseUrl is reachable.`;
20
+ if (status === 401)
21
+ return 'Check your authentication token or credentials.';
22
+ if (status === 403)
23
+ return 'Valid credentials but insufficient permissions for this operation.';
24
+ if (status === 404)
25
+ return 'The requested resource was not found.';
26
+ if (status === 408)
27
+ return 'The request timed out. Consider retrying.';
28
+ if (status === 429) {
29
+ return retryAfterMs !== undefined
30
+ ? `Rate limit exceeded. Retry after ${retryAfterMs}ms.`
31
+ : 'Rate limit exceeded. Back off and retry.';
32
+ }
33
+ if (status >= 500)
34
+ return 'Remote server error. The service may be temporarily unavailable.';
35
+ return undefined;
36
+ }
17
37
  export function normalizeTransportError(error) {
18
38
  if (isTransportError(error)) {
19
- return Object.assign(createHttpStatusError(error.transport.status, error.transport.url, typeof error.transport.method === 'string' ? error.transport.method : 'GET', error.transport.body), { transport: error.transport });
39
+ const { status, url, body, method, retryAfterMs, cause } = error.transport;
40
+ const resolvedMethod = typeof method === 'string' ? method : 'GET';
41
+ const hint = inferTransportHint(status, url, retryAfterMs);
42
+ if (status === 0) {
43
+ // Network-level failure: no HTTP response received
44
+ const networkError = new HttpStatusError(error instanceof Error ? error.message : `Transport could not reach ${url}`, {
45
+ status: undefined,
46
+ url,
47
+ method: resolvedMethod,
48
+ body,
49
+ category: 'network',
50
+ source: 'transport',
51
+ recoverable: true,
52
+ hint,
53
+ ...(retryAfterMs !== undefined ? { retryAfterMs } : {}),
54
+ });
55
+ if (cause !== undefined) {
56
+ Object.defineProperty(networkError, 'cause', { value: cause, writable: true, configurable: true });
57
+ }
58
+ return Object.assign(networkError, { transport: error.transport });
59
+ }
60
+ const baseError = createHttpStatusError(status, url, resolvedMethod, body);
61
+ // Only apply inferred hint if the daemon body didn't supply one already
62
+ const effectiveHint = baseError.hint ?? hint;
63
+ return Object.assign(baseError, {
64
+ transport: error.transport,
65
+ ...(effectiveHint !== undefined ? { hint: effectiveHint } : {}),
66
+ ...(retryAfterMs !== undefined ? { retryAfterMs } : {}),
67
+ });
20
68
  }
21
69
  if (error instanceof Error) {
22
70
  if (error.message === 'Fetch implementation is required' || error.message === 'Transport baseUrl is required') {
package/dist/auth.d.ts CHANGED
@@ -24,7 +24,56 @@ export interface GoodVibesAuthClient {
24
24
  setToken(token: string | null): Promise<void>;
25
25
  clearToken(): Promise<void>;
26
26
  }
27
+ /**
28
+ * Create a simple in-memory token store.
29
+ *
30
+ * The token is held in a closure variable — it does not survive page
31
+ * refreshes or process restarts. Suitable for server-side scripts and tests.
32
+ *
33
+ * @example
34
+ * import { createMemoryTokenStore } from '@pellux/goodvibes-sdk';
35
+ *
36
+ * const store = createMemoryTokenStore('initial-token');
37
+ * const sdk = createGoodVibesSdk({ baseUrl: '...', tokenStore: store });
38
+ * await sdk.auth.clearToken(); // clears only in-memory
39
+ */
27
40
  export declare function createMemoryTokenStore(initialToken?: string | null): GoodVibesTokenStore;
41
+ /**
42
+ * Create a token store backed by `localStorage` (or a custom `Storage`).
43
+ *
44
+ * The token is persisted across page refreshes under the key
45
+ * `'goodvibes.token'` (overridable via `options.key`).
46
+ * Pass `options.storage` to use `sessionStorage` or a custom adapter.
47
+ *
48
+ * @example
49
+ * import { createBrowserTokenStore, createBrowserGoodVibesSdk } from '@pellux/goodvibes-sdk/browser';
50
+ *
51
+ * const tokenStore = createBrowserTokenStore({ storage: sessionStorage });
52
+ * const sdk = createBrowserGoodVibesSdk({ tokenStore });
53
+ * await sdk.auth.login({ username: 'alice', password: 's3cr3t' });
54
+ * // token is now stored in sessionStorage
55
+ */
28
56
  export declare function createBrowserTokenStore(options?: BrowserTokenStoreOptions): GoodVibesTokenStore;
57
+ /**
58
+ * Create the auth client attached to an SDK instance.
59
+ *
60
+ * Normally called internally by `createGoodVibesSdk`. Access the result via
61
+ * `sdk.auth`.
62
+ *
63
+ * @example
64
+ * import { createGoodVibesSdk, createBrowserTokenStore } from '@pellux/goodvibes-sdk';
65
+ *
66
+ * const sdk = createGoodVibesSdk({
67
+ * baseUrl: 'https://daemon.example.com',
68
+ * tokenStore: createBrowserTokenStore(),
69
+ * });
70
+ *
71
+ * // Login and persist the token automatically:
72
+ * const { token } = await sdk.auth.login({ username: 'alice', password: 's3cr3t' });
73
+ * console.log('logged in, token stored:', token.slice(0, 8) + '...');
74
+ *
75
+ * // Later: clear the session
76
+ * await sdk.auth.clearToken();
77
+ */
29
78
  export declare function createGoodVibesAuthClient(operator: OperatorSdk, tokenStore: GoodVibesTokenStore | null, getAuthToken?: AuthTokenResolver): GoodVibesAuthClient;
30
79
  //# sourceMappingURL=auth.d.ts.map
@@ -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;AAEjE,MAAM,MAAM,oBAAoB,GAAG,oBAAoB,CAAC,sBAAsB,CAAC,CAAC;AAChF,MAAM,MAAM,mBAAmB,GAAG,mBAAmB,CA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AyB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACtG,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B;AAYD;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,GAAE,MAAM,GAAG,IAAW,GAAG,mBAAmB,CAa9F;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CAAC,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
@@ -6,6 +6,19 @@ function requireStorage(storage) {
6
6
  }
7
7
  return resolved;
8
8
  }
9
+ /**
10
+ * Create a simple in-memory token store.
11
+ *
12
+ * The token is held in a closure variable — it does not survive page
13
+ * refreshes or process restarts. Suitable for server-side scripts and tests.
14
+ *
15
+ * @example
16
+ * import { createMemoryTokenStore } from '@pellux/goodvibes-sdk';
17
+ *
18
+ * const store = createMemoryTokenStore('initial-token');
19
+ * const sdk = createGoodVibesSdk({ baseUrl: '...', tokenStore: store });
20
+ * await sdk.auth.clearToken(); // clears only in-memory
21
+ */
9
22
  export function createMemoryTokenStore(initialToken = null) {
10
23
  let token = initialToken;
11
24
  return {
@@ -20,6 +33,21 @@ export function createMemoryTokenStore(initialToken = null) {
20
33
  },
21
34
  };
22
35
  }
36
+ /**
37
+ * Create a token store backed by `localStorage` (or a custom `Storage`).
38
+ *
39
+ * The token is persisted across page refreshes under the key
40
+ * `'goodvibes.token'` (overridable via `options.key`).
41
+ * Pass `options.storage` to use `sessionStorage` or a custom adapter.
42
+ *
43
+ * @example
44
+ * import { createBrowserTokenStore, createBrowserGoodVibesSdk } from '@pellux/goodvibes-sdk/browser';
45
+ *
46
+ * const tokenStore = createBrowserTokenStore({ storage: sessionStorage });
47
+ * const sdk = createBrowserGoodVibesSdk({ tokenStore });
48
+ * await sdk.auth.login({ username: 'alice', password: 's3cr3t' });
49
+ * // token is now stored in sessionStorage
50
+ */
23
51
  export function createBrowserTokenStore(options = {}) {
24
52
  const storage = requireStorage(options.storage);
25
53
  const key = options.key?.trim() || 'goodvibes.token';
@@ -55,6 +83,27 @@ function assertWritableTokenStore(tokenStore) {
55
83
  }
56
84
  return tokenStore;
57
85
  }
86
+ /**
87
+ * Create the auth client attached to an SDK instance.
88
+ *
89
+ * Normally called internally by `createGoodVibesSdk`. Access the result via
90
+ * `sdk.auth`.
91
+ *
92
+ * @example
93
+ * import { createGoodVibesSdk, createBrowserTokenStore } from '@pellux/goodvibes-sdk';
94
+ *
95
+ * const sdk = createGoodVibesSdk({
96
+ * baseUrl: 'https://daemon.example.com',
97
+ * tokenStore: createBrowserTokenStore(),
98
+ * });
99
+ *
100
+ * // Login and persist the token automatically:
101
+ * const { token } = await sdk.auth.login({ username: 'alice', password: 's3cr3t' });
102
+ * console.log('logged in, token stored:', token.slice(0, 8) + '...');
103
+ *
104
+ * // Later: clear the session
105
+ * await sdk.auth.clearToken();
106
+ */
58
107
  export function createGoodVibesAuthClient(operator, tokenStore, getAuthToken) {
59
108
  return {
60
109
  writable: tokenStore !== null,
package/dist/browser.d.ts CHANGED
@@ -4,5 +4,28 @@ 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
+ */
7
30
  export declare function createBrowserGoodVibesSdk(options?: BrowserGoodVibesSdkOptions): GoodVibesSdk;
8
31
  //# sourceMappingURL=browser.d.ts.map
@@ -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,wBAAgB,yBAAyB,CACvC,OAAO,GAAE,0BAA+B,GACvC,YAAY,CAiCd"}
package/dist/browser.js CHANGED
@@ -9,6 +9,29 @@ 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
+ */
12
35
  export function createBrowserGoodVibesSdk(options = {}) {
13
36
  return createGoodVibesSdk({
14
37
  baseUrl: resolveBrowserBaseUrl(options.baseUrl),
package/dist/client.d.ts CHANGED
@@ -22,32 +22,140 @@ 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
+ */
27
52
  readonly authToken?: string | null;
53
+ /**
54
+ * Async token resolver called before every authenticated request.
55
+ * Use this when your token lives outside the SDK (e.g. retrieved from a
56
+ * framework session or an external secret store).
57
+ *
58
+ * When this option is set, `sdk.auth.writable` is `false` — calling
59
+ * `setToken` / `clearToken` throws a `ConfigurationError`.
60
+ *
61
+ * Takes precedence over `authToken`; ignored when `tokenStore` is provided.
62
+ */
28
63
  readonly getAuthToken?: AuthTokenResolver;
64
+ /**
65
+ * A mutable token store implementing `getToken / setToken / clearToken`.
66
+ * The SDK calls `getToken()` before every request and writes back via
67
+ * `setToken()` after a successful `sdk.auth.login()`.
68
+ *
69
+ * Highest-precedence auth option — overrides both `getAuthToken` and
70
+ * `authToken`. Use `createBrowserTokenStore()` (localStorage) or
71
+ * `createMemoryTokenStore()` for common cases.
72
+ */
29
73
  readonly tokenStore?: GoodVibesTokenStore;
74
+ /**
75
+ * Custom `fetch` implementation. Falls back to `globalThis.fetch`.
76
+ * Required in environments without a native fetch (e.g. older Node.js).
77
+ */
30
78
  readonly fetch?: typeof fetch;
79
+ /**
80
+ * Static extra headers sent on every request, e.g.
81
+ * `{ 'X-Tenant-Id': 'acme' }`.
82
+ */
31
83
  readonly headers?: HeadersInit;
84
+ /**
85
+ * Async resolver for per-request headers. Called on each request after the
86
+ * auth header is set. Useful for adding request-scoped tracing headers.
87
+ */
32
88
  readonly getHeaders?: HeaderResolver;
89
+ /**
90
+ * HTTP retry policy for transient failures (408, 429, 5xx).
91
+ * Runtime-specific factories (e.g. `createNodeGoodVibesSdk`) apply
92
+ * sensible defaults; pass this to override.
93
+ */
33
94
  readonly retry?: HttpRetryPolicy;
95
+ /**
96
+ * Custom `WebSocket` constructor. Falls back to `globalThis.WebSocket`.
97
+ * Required in Node.js < 21 or when using a polyfill.
98
+ */
34
99
  readonly WebSocketImpl?: typeof WebSocket;
100
+ /**
101
+ * Options that control realtime transport behaviour (SSE and WebSocket
102
+ * reconnect policies, error callback).
103
+ */
35
104
  readonly realtime?: GoodVibesRealtimeOptions;
36
105
  }
106
+ /**
107
+ * Options controlling realtime transport behaviour.
108
+ */
37
109
  export interface GoodVibesRealtimeOptions {
38
110
  readonly sseReconnect?: StreamReconnectPolicy;
39
111
  readonly webSocketReconnect?: StreamReconnectPolicy;
40
112
  readonly onError?: (error: unknown) => void;
41
113
  }
114
+ /**
115
+ * Realtime event subscriptions for the GoodVibes daemon.
116
+ * Choose SSE for read-only event streams or WebSocket for bidirectional use.
117
+ */
42
118
  export interface GoodVibesRealtime {
43
119
  viaSse(): RemoteRuntimeEvents<RuntimeEventRecord>;
44
120
  viaWebSocket(webSocketImpl?: typeof WebSocket): RemoteRuntimeEvents<RuntimeEventRecord>;
45
121
  }
122
+ /**
123
+ * The GoodVibes SDK instance returned by `createGoodVibesSdk` (and its
124
+ * runtime-specific wrappers).
125
+ *
126
+ * Three primary namespaces:
127
+ * - **`operator`** — full control-plane API (daemon admin, agent management,
128
+ * session lifecycle, config). Requires an operator-level auth token.
129
+ * - **`peer`** — peer-to-peer and collaboration APIs (pairing, channels,
130
+ * shared sessions). May be used with peer-scoped tokens.
131
+ * - **`realtime`** — subscribe to live daemon events via SSE or WebSocket.
132
+ * - **`auth`** — login, logout, and token management helpers.
133
+ */
46
134
  export interface GoodVibesSdk {
47
135
  readonly operator: OperatorSdk;
48
136
  readonly peer: PeerSdk;
49
137
  readonly auth: GoodVibesAuthClient;
50
138
  readonly realtime: GoodVibesRealtime;
51
139
  }
140
+ /**
141
+ * Create a GoodVibes SDK instance.
142
+ *
143
+ * This is the runtime-agnostic constructor. For environments with sensible
144
+ * defaults already configured, prefer the platform-specific wrappers:
145
+ * `createNodeGoodVibesSdk`, `createBrowserGoodVibesSdk`,
146
+ * `createReactNativeGoodVibesSdk`.
147
+ *
148
+ * @example
149
+ * // Example only: replace baseUrl and authToken with your own values.
150
+ * import { createGoodVibesSdk } from '@pellux/goodvibes-sdk';
151
+ *
152
+ * const sdk = createGoodVibesSdk({
153
+ * baseUrl: 'https://daemon.example.com',
154
+ * authToken: process.env.GV_TOKEN,
155
+ * });
156
+ *
157
+ * const agents = await sdk.operator.agents.list();
158
+ * console.log(agents);
159
+ */
52
160
  export declare function createGoodVibesSdk(options: GoodVibesSdkOptions): GoodVibesSdk;
53
161
  //# sourceMappingURL=client.d.ts.map
@@ -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,K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QAAQ,CAAC,UAAU,CAAC,EAAE,cAAc,CAAC;IAErC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC;IAEjC;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,SAAS,CAAC;IAE1C;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,wBAAwB,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,YAAY,CAAC,EAAE,qBAAqB,CAAC;IAC9C,QAAQ,CAAC,kBAAkB,CAAC,EAAE,qBAAqB,CAAC;IACpD,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAC7C;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,IAAI,mBAAmB,CAAC,kBAAkB,CAAC,CAAC;IAClD,YAAY,CAAC,aAAa,CAAC,EAAE,OAAO,SAAS,GAAG,mBAAmB,CAAC,kBAAkB,CAAC,CAAC;CACzF;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;CACtC;AA4DD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,mBAAmB,GAC3B,YAAY,CA+Cd"}
package/dist/client.js CHANGED
@@ -53,6 +53,26 @@ function createPeerOptions(options) {
53
53
  ...(options.retry ? { retry: options.retry } : {}),
54
54
  };
55
55
  }
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
+ * @example
65
+ * // Example only: replace baseUrl and authToken with your own values.
66
+ * import { createGoodVibesSdk } from '@pellux/goodvibes-sdk';
67
+ *
68
+ * const sdk = createGoodVibesSdk({
69
+ * baseUrl: 'https://daemon.example.com',
70
+ * authToken: process.env.GV_TOKEN,
71
+ * });
72
+ *
73
+ * const agents = await sdk.operator.agents.list();
74
+ * console.log(agents);
75
+ */
56
76
  export function createGoodVibesSdk(options) {
57
77
  const baseUrl = requireBaseUrl(options.baseUrl);
58
78
  const tokenStore = options.tokenStore ?? (options.getAuthToken ? null : createMemoryTokenStore(options.authToken ?? null));
package/dist/expo.d.ts CHANGED
@@ -1,5 +1,19 @@
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
+ */
4
18
  export declare function createExpoGoodVibesSdk(options: ExpoGoodVibesSdkOptions): ReactNativeGoodVibesSdk;
5
19
  //# sourceMappingURL=expo.d.ts.map
@@ -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,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,uBAAuB,GAAG,uBAAuB,CAEhG"}
package/dist/expo.js CHANGED
@@ -1,4 +1,18 @@
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
+ */
2
16
  export function createExpoGoodVibesSdk(options) {
3
17
  return createReactNativeGoodVibesSdk(options);
4
18
  }
package/dist/node.d.ts CHANGED
@@ -1,5 +1,27 @@
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
+ */
4
26
  export declare function createNodeGoodVibesSdk(options: NodeGoodVibesSdkOptions): GoodVibesSdk;
5
27
  //# sourceMappingURL=node.d.ts.map
@@ -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,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,uBAAuB,GAC/B,YAAY,CAwBd"}
package/dist/node.js CHANGED
@@ -1,4 +1,26 @@
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
+ */
2
24
  export function createNodeGoodVibesSdk(options) {
3
25
  return createGoodVibesSdk({
4
26
  ...options,
@@ -10,5 +10,31 @@ 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
+ */
13
39
  export declare function createReactNativeGoodVibesSdk(options: ReactNativeGoodVibesSdkOptions): ReactNativeGoodVibesSdk;
14
40
  //# 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,6BAA6B,CAC3C,OAAO,EAAE,8BAA8B,GACtC,uBAAuB,CA0DzB"}
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;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,8BAA8B,GACtC,uBAAuB,CA0DzB"}
@@ -8,6 +8,32 @@ function requireReactNativeWebSocket(webSocketImpl) {
8
8
  }
9
9
  return resolved;
10
10
  }
11
+ /**
12
+ * Create a GoodVibes SDK instance for React Native.
13
+ *
14
+ * Key differences from the browser factory:
15
+ * - Realtime is WebSocket-only (`realtime.runtime()` / `realtime.viaWebSocket()`).
16
+ * SSE is not available in React Native.
17
+ * - Requires a `WebSocket` implementation (e.g. the global provided by the
18
+ * React Native runtime or the `react-native` package). Pass
19
+ * `options.WebSocketImpl` when the global is not available.
20
+ * - Returns `ReactNativeGoodVibesSdk` (extends `GoodVibesSdk` with a
21
+ * React-Native-specific `realtime` namespace).
22
+ *
23
+ * `createExpoGoodVibesSdk` is an alias for this function.
24
+ *
25
+ * @example
26
+ * // Example only: replace baseUrl and authToken with your own values.
27
+ * import { createReactNativeGoodVibesSdk } from '@pellux/goodvibes-sdk/react-native';
28
+ *
29
+ * const sdk = createReactNativeGoodVibesSdk({
30
+ * baseUrl: 'https://daemon.example.com',
31
+ * authToken: await SecureStore.getItemAsync('token'),
32
+ * });
33
+ *
34
+ * const events = sdk.realtime.runtime();
35
+ * events.agents.on('AGENT_SPAWNING', ({ agentId }) => console.log(agentId));
36
+ */
11
37
  export function createReactNativeGoodVibesSdk(options) {
12
38
  const base = createGoodVibesSdk({
13
39
  ...options,
package/dist/web.d.ts CHANGED
@@ -2,5 +2,17 @@ import { type BrowserGoodVibesSdkOptions } from './browser.js';
2
2
  import type { GoodVibesSdk } from './client.js';
3
3
  export interface WebGoodVibesSdkOptions extends BrowserGoodVibesSdkOptions {
4
4
  }
5
+ /**
6
+ * Alias for `createBrowserGoodVibesSdk`. Use this entry-point when importing
7
+ * from `@pellux/goodvibes-sdk/web`.
8
+ *
9
+ * @example
10
+ * // Example only: replace with your own auth strategy.
11
+ * import { createWebGoodVibesSdk } from '@pellux/goodvibes-sdk/web';
12
+ *
13
+ * const sdk = createWebGoodVibesSdk({ authToken: myToken });
14
+ * const events = sdk.realtime.viaSse();
15
+ * events.agents.on('AGENT_SPAWNING', ({ agentId }) => console.log(agentId));
16
+ */
5
17
  export declare function createWebGoodVibesSdk(options?: WebGoodVibesSdkOptions): GoodVibesSdk;
6
18
  //# sourceMappingURL=web.d.ts.map
package/dist/web.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,0BAA0B,EAChC,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,WAAW,sBAAuB,SAAQ,0BAA0B;CAAG;AAE7E,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,sBAA2B,GAAG,YAAY,CAExF"}
1
+ {"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,0BAA0B,EAChC,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,WAAW,sBAAuB,SAAQ,0BAA0B;CAAG;AAE7E;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,sBAA2B,GAAG,YAAY,CAExF"}