@bytexbyte/nxtlinq-ai-agent-web-development 0.1.6 → 0.1.7

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.
@@ -1 +1 @@
1
- {"version":3,"file":"nxtlinq-api.d.ts","sourceRoot":"","sources":["../../../src/legacy/api/nxtlinq-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8CAA8C,CAAC;AAU3E,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,8CAA8C,CAAC;AAEtD,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAE9F,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,WAAW,MAAM,KAAG,MASpE,CAAC"}
1
+ {"version":3,"file":"nxtlinq-api.d.ts","sourceRoot":"","sources":["../../../src/legacy/api/nxtlinq-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8CAA8C,CAAC;AAU3E,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,8CAA8C,CAAC;AAEtD,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAM9F,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,WAAW,MAAM,KAAG,MAWpE,CAAC"}
@@ -1,13 +1,18 @@
1
1
  import { createBrowserStoragePort, createDefaultHttpPort, createNxtlinqApiWithDeps, getAiAgentApiHost, } from '@bytexbyte/nxtlinq-ai-agent-core-development';
2
2
  import { createVoiceApi } from './voice';
3
3
  export { setApiHosts, getAiAgentApiHost, createNxtlinqApiWithDeps, createBrowserStoragePort, } from '@bytexbyte/nxtlinq-ai-agent-core-development';
4
+ function inferEnvironmentFromHost(host) {
5
+ return host.includes('staging') ? 'staging' : 'production';
6
+ }
4
7
  export const createNxtlinqApi = (apiKey, apiSecret) => {
5
8
  const core = createNxtlinqApiWithDeps(apiKey, apiSecret, {
6
9
  storage: createBrowserStoragePort(),
7
10
  http: createDefaultHttpPort(),
8
11
  });
12
+ const aiAgentHost = getAiAgentApiHost();
13
+ const environment = inferEnvironmentFromHost(aiAgentHost);
9
14
  return {
10
15
  ...core,
11
- voice: createVoiceApi(() => getAiAgentApiHost()),
16
+ voice: createVoiceApi(() => aiAgentHost, environment),
12
17
  };
13
18
  };
@@ -4,8 +4,8 @@ import type { StartVoiceSessionOptions, VoiceSession } from '@bytexbyte/nxtlinq-
4
4
  /**
5
5
  * Start a cascade voice agent session. Browser-only (uses {@link createBrowserWebRTCPort}).
6
6
  */
7
- export declare function startVoiceSession(apiAgentHost: string, options: StartVoiceSessionOptions): Promise<VoiceSession>;
8
- export declare const createVoiceApi: (apiAgentHost: string | (() => string)) => {
7
+ export declare function startVoiceSession(apiAgentHost: string, options: StartVoiceSessionOptions, environment?: 'production' | 'staging'): Promise<VoiceSession>;
8
+ export declare const createVoiceApi: (apiAgentHost: string | (() => string), environment?: "production" | "staging") => {
9
9
  startSession: (options: StartVoiceSessionOptions) => Promise<VoiceSession>;
10
10
  };
11
11
  //# sourceMappingURL=voice.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"voice.d.ts","sourceRoot":"","sources":["../../../src/legacy/api/voice.ts"],"names":[],"mappings":"AASA,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,8CAA8C,CAAC;AAEtD,YAAY,EACV,UAAU,EACV,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,4BAA4B,EAC5B,wBAAwB,EACxB,iBAAiB,EACjB,cAAc,EACd,wBAAwB,EACxB,YAAY,GACb,MAAM,8CAA8C,CAAC;AAEtD,OAAO,KAAK,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC;AAE3G;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,YAAY,CAAC,CAyBvB;AAED,eAAO,MAAM,cAAc,GAAI,cAAc,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC;4BAC1C,wBAAwB,KAAG,OAAO,CAAC,YAAY,CAAC;CAKxE,CAAC"}
1
+ {"version":3,"file":"voice.d.ts","sourceRoot":"","sources":["../../../src/legacy/api/voice.ts"],"names":[],"mappings":"AASA,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,8CAA8C,CAAC;AAEtD,YAAY,EACV,UAAU,EACV,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,4BAA4B,EAC5B,wBAAwB,EACxB,iBAAiB,EACjB,cAAc,EACd,wBAAwB,EACxB,YAAY,GACb,MAAM,8CAA8C,CAAC;AAEtD,OAAO,KAAK,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC;AAE3G;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,wBAAwB,EACjC,WAAW,CAAC,EAAE,YAAY,GAAG,SAAS,GACrC,OAAO,CAAC,YAAY,CAAC,CAyBvB;AAED,eAAO,MAAM,cAAc,GAAI,cAAc,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,EAAE,cAAc,YAAY,GAAG,SAAS;4BAClF,wBAAwB,KAAG,OAAO,CAAC,YAAY,CAAC;CAMxE,CAAC"}
@@ -6,14 +6,14 @@ export { normalizeTranscriptKey, mergeStreamingTranscript, appendTranscriptSegme
6
6
  /**
7
7
  * Start a cascade voice agent session. Browser-only (uses {@link createBrowserWebRTCPort}).
8
8
  */
9
- export async function startVoiceSession(apiAgentHost, options) {
9
+ export async function startVoiceSession(apiAgentHost, options, environment) {
10
10
  const baseUrl = (options.baseUrl ?? apiAgentHost ?? '').replace(/\/+$/, '');
11
11
  if (!baseUrl) {
12
12
  throw new Error('startVoiceSession: API host is empty. Did you forget to call setApiHosts() before createNxtlinqApi()?');
13
13
  }
14
14
  const transport = options.transport ?? 'ws-realtime';
15
15
  if (transport === 'ws-realtime') {
16
- return startWsRealtimeSession({ baseUrl, fetchFn: fetch }, { ...options, baseUrl, transport });
16
+ return startWsRealtimeSession({ baseUrl, fetchFn: fetch, environment }, { ...options, baseUrl, transport });
17
17
  }
18
18
  return startVoiceSessionWithPort({
19
19
  baseUrl,
@@ -21,6 +21,6 @@ export async function startVoiceSession(apiAgentHost, options) {
21
21
  fetchFn: fetch,
22
22
  }, { ...options, baseUrl });
23
23
  }
24
- export const createVoiceApi = (apiAgentHost) => ({
25
- startSession: (options) => startVoiceSession(typeof apiAgentHost === 'function' ? apiAgentHost() : apiAgentHost, options),
24
+ export const createVoiceApi = (apiAgentHost, environment) => ({
25
+ startSession: (options) => startVoiceSession(typeof apiAgentHost === 'function' ? apiAgentHost() : apiAgentHost, options, environment),
26
26
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytexbyte/nxtlinq-ai-agent-web-development",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "React Web headless SDK for nxtlinq AI Agent — hooks and browser ports",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -37,7 +37,7 @@
37
37
  "react-dom": ">=18.0.0"
38
38
  },
39
39
  "dependencies": {
40
- "@bytexbyte/nxtlinq-ai-agent-core-development": "0.3.9",
40
+ "@bytexbyte/nxtlinq-ai-agent-core-development": "0.4.1",
41
41
  "ethers": "^6.16.0",
42
42
  "fast-json-stable-stringify": "^2.1.0",
43
43
  "metakeep": "^2.2.8",
@@ -45,7 +45,6 @@
45
45
  "universal-cookie": "^8.0.1"
46
46
  },
47
47
  "devDependencies": {
48
- "@bytexbyte/nxtlinq-ai-agent-core-development": "workspace:^",
49
48
  "@types/react": "^18.2.64",
50
49
  "@types/react-dom": "^18.2.25",
51
50
  "react": "^18.2.0",
@@ -20,13 +20,19 @@ export {
20
20
 
21
21
  export type { CoreAITApi, ApiClientDeps } from '@bytexbyte/nxtlinq-ai-agent-core-development';
22
22
 
23
+ function inferEnvironmentFromHost(host: string): 'production' | 'staging' {
24
+ return host.includes('staging') ? 'staging' : 'production';
25
+ }
26
+
23
27
  export const createNxtlinqApi = (apiKey: string, apiSecret: string): AITApi => {
24
28
  const core = createNxtlinqApiWithDeps(apiKey, apiSecret, {
25
29
  storage: createBrowserStoragePort(),
26
30
  http: createDefaultHttpPort(),
27
31
  });
32
+ const aiAgentHost = getAiAgentApiHost();
33
+ const environment = inferEnvironmentFromHost(aiAgentHost);
28
34
  return {
29
35
  ...core,
30
- voice: createVoiceApi(() => getAiAgentApiHost()),
36
+ voice: createVoiceApi(() => aiAgentHost, environment),
31
37
  };
32
38
  };
@@ -36,6 +36,7 @@ import type { StartVoiceSessionOptions, VoiceSession } from '@bytexbyte/nxtlinq-
36
36
  export async function startVoiceSession(
37
37
  apiAgentHost: string,
38
38
  options: StartVoiceSessionOptions,
39
+ environment?: 'production' | 'staging',
39
40
  ): Promise<VoiceSession> {
40
41
  const baseUrl = (options.baseUrl ?? apiAgentHost ?? '').replace(/\/+$/, '');
41
42
  if (!baseUrl) {
@@ -48,7 +49,7 @@ export async function startVoiceSession(
48
49
 
49
50
  if (transport === 'ws-realtime') {
50
51
  return startWsRealtimeSession(
51
- { baseUrl, fetchFn: fetch },
52
+ { baseUrl, fetchFn: fetch, environment },
52
53
  { ...options, baseUrl, transport },
53
54
  );
54
55
  }
@@ -63,10 +64,11 @@ export async function startVoiceSession(
63
64
  );
64
65
  }
65
66
 
66
- export const createVoiceApi = (apiAgentHost: string | (() => string)) => ({
67
+ export const createVoiceApi = (apiAgentHost: string | (() => string), environment?: 'production' | 'staging') => ({
67
68
  startSession: (options: StartVoiceSessionOptions): Promise<VoiceSession> =>
68
69
  startVoiceSession(
69
70
  typeof apiAgentHost === 'function' ? apiAgentHost() : apiAgentHost,
70
71
  options,
72
+ environment,
71
73
  ),
72
74
  });