rystem.playframework.client 0.1.4 → 10.1.0-beta.2

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 CHANGED
@@ -37,6 +37,7 @@ So for the `default` factory it calls:
37
37
 
38
38
  - `POST http://localhost:5158/api/ai/default`
39
39
  - `POST http://localhost:5158/api/ai/default/streaming`
40
+ - `GET http://localhost:5158/api/ai/default/discovery`
40
41
  - `GET http://localhost:5158/api/ai/default/conversations`
41
42
  - `POST http://localhost:5158/api/ai/default/voice`
42
43
 
@@ -97,6 +98,157 @@ If you only configure one factory, `resolve()` with no name returns the first co
97
98
  const defaultClient = PlayFrameworkServices.resolve();
98
99
  ```
99
100
 
101
+ ## Example: custom fetch adapter (Angular, Node.js, test spy)
102
+
103
+ By default the client uses `globalThis.fetch`. Call `settings.setFetch(fn)` to replace it with any
104
+ function that matches the native Fetch API signature `(input, init?) => Promise<Response>`.
105
+ Callers that never invoke `setFetch()` are **not affected** — zero breaking change.
106
+
107
+ ### Generic / framework-agnostic
108
+
109
+ ```typescript
110
+ await PlayFrameworkServices.configure("default", "https://api.example.com/api/ai", settings => {
111
+ settings.setFetch(async (url, init) => {
112
+ const token = localStorage.getItem("token");
113
+ const headers = new Headers(init?.headers);
114
+ if (token) headers.set("Authorization", `Bearer ${token}`);
115
+ return fetch(url, { ...init, headers });
116
+ });
117
+ });
118
+ ```
119
+
120
+ ### Angular — reuse the same refresh-token logic as your HttpInterceptor
121
+
122
+ Angular's `HttpInterceptor` only intercepts requests made via `HttpClient` (XHR / managed fetch).
123
+ Because PlayFramework uses native `fetch` for SSE streaming it bypasses Angular's pipeline entirely.
124
+ The solution is to register a **fetch bridge** on `PlayFrameworkSettings` that contains the same
125
+ token-attach + refresh logic you already have in your interceptor, without importing any Angular
126
+ module into the library.
127
+
128
+ ```typescript
129
+ // play-framework-setup.service.ts
130
+ import { Injectable } from '@angular/core';
131
+ import { firstValueFrom } from 'rxjs';
132
+ import { PlayFrameworkServices } from 'rystem.playframework.client';
133
+ import { AuthService } from './auth.service';
134
+ import { GlobalService } from '../shared/service/global.service';
135
+
136
+ @Injectable({ providedIn: 'root' })
137
+ export class PlayFrameworkSetupService {
138
+ private isRefreshing = false;
139
+ private refreshPromise: Promise<string | null> | null = null;
140
+
141
+ constructor(
142
+ private authService: AuthService,
143
+ private globalService: GlobalService,
144
+ ) {}
145
+
146
+ /** Call once during application startup (e.g. APP_INITIALIZER). */
147
+ async configure(factoryName: string, baseUrl: string): Promise<void> {
148
+ await PlayFrameworkServices.configure(factoryName, baseUrl, (settings) => {
149
+ settings.setFetch(this.createFetchBridge());
150
+ });
151
+ }
152
+
153
+ private createFetchBridge(): typeof fetch {
154
+ return async (url: RequestInfo | URL, init?: RequestInit): Promise<Response> => {
155
+ // 1. Attach current Bearer token (mirrors addAuthorizationHeader)
156
+ const headers = new Headers(init?.headers);
157
+ const token = this.authService.token;
158
+ if (token) headers.set('Authorization', `Bearer ${token}`);
159
+
160
+ const response = await fetch(url, { ...init, headers });
161
+
162
+ // 2. If not 401, return immediately
163
+ if (response.status !== 401) return response;
164
+
165
+ // 3. Token expired → refresh once (mirrors handle401Error, deduplicates concurrent calls)
166
+ if (!this.isRefreshing) {
167
+ this.isRefreshing = true;
168
+ this.refreshPromise = firstValueFrom(this.globalService.getRefreshToken())
169
+ .then((r: any) => {
170
+ const newToken = r?.accessToken;
171
+ if (!newToken) { window.location.reload(); return null; }
172
+ this.authService.token = newToken;
173
+ localStorage.setItem('token', newToken);
174
+ if (r?.refreshToken) localStorage.setItem('refreshToken', r.refreshToken);
175
+ return newToken;
176
+ })
177
+ .catch(() => { window.location.reload(); return null; })
178
+ .finally(() => { this.isRefreshing = false; this.refreshPromise = null; });
179
+ }
180
+
181
+ const newToken = await this.refreshPromise;
182
+ if (!newToken) return response; // reload already triggered
183
+
184
+ // 4. Retry original request with fresh token
185
+ const retryHeaders = new Headers(init?.headers);
186
+ retryHeaders.set('Authorization', `Bearer ${newToken}`);
187
+ return fetch(url, { ...init, headers: retryHeaders });
188
+ };
189
+ }
190
+ }
191
+ ```
192
+
193
+ Wire it via `APP_INITIALIZER` so the factory is ready before any component calls `resolve()`:
194
+
195
+ ```typescript
196
+ // app.config.ts
197
+ import { ApplicationConfig, APP_INITIALIZER } from '@angular/core';
198
+ import { PlayFrameworkSetupService } from './services/play-framework-setup.service';
199
+
200
+ function initPlayFramework(svc: PlayFrameworkSetupService) {
201
+ return () => svc.configure('default', 'https://api.example.com/api/ai');
202
+ }
203
+
204
+ export const appConfig: ApplicationConfig = {
205
+ providers: [
206
+ {
207
+ provide: APP_INITIALIZER,
208
+ useFactory: initPlayFramework,
209
+ deps: [PlayFrameworkSetupService],
210
+ multi: true,
211
+ },
212
+ ],
213
+ };
214
+ ```
215
+
216
+ Then use the client anywhere as normal — the Angular interceptor is **not needed** for PlayFramework
217
+ requests since the fetch bridge handles auth directly:
218
+
219
+ ```typescript
220
+ // your-chat.component.ts
221
+ import { usePlayFramework } from 'rystem.playframework.client';
222
+
223
+ const client = usePlayFramework('default');
224
+ for await (const step of client.executeStepByStep({ message: userInput })) {
225
+ if (step.message) appendText(step.message);
226
+ }
227
+ ```
228
+
229
+ ### Node.js (SSR / server-side)
230
+
231
+ ```typescript
232
+ import nodeFetch from 'node-fetch';
233
+
234
+ await PlayFrameworkServices.configure("default", "https://api.example.com/api/ai", settings => {
235
+ settings.setFetch(nodeFetch as unknown as typeof fetch);
236
+ });
237
+ ```
238
+
239
+ ### Testing — intercept and assert outgoing requests
240
+
241
+ ```typescript
242
+ const calls: { url: RequestInfo | URL; init?: RequestInit }[] = [];
243
+
244
+ settings.setFetch(async (url, init) => {
245
+ calls.push({ url, init });
246
+ return new Response(JSON.stringify({ status: 'completed' }), {
247
+ headers: { 'Content-Type': 'application/json' },
248
+ });
249
+ });
250
+ ```
251
+
100
252
  ## Example: configure multiple factories
101
253
 
102
254
  The sample workspace in `src/AI/Rystem.PlayFramework.Client/src/App.tsx` configures both `default` and `foundry` against the same base path.
@@ -117,6 +269,34 @@ const localClient = PlayFrameworkServices.resolve("foundry");
117
269
 
118
270
  This is useful when the backend exposes multiple PlayFramework factories with different scenes or model providers.
119
271
 
272
+ ## Example: load scenes and tool metadata from the server
273
+
274
+ Use `getDiscovery()` when the frontend needs to know which scenes, DI tools, client tools, or MCP tools are currently available for a factory.
275
+
276
+ ```typescript
277
+ const metadata = await client.getDiscovery();
278
+
279
+ for (const scene of metadata.scenes ?? []) {
280
+ console.log(scene.name, scene.description);
281
+
282
+ for (const tool of scene.tools ?? []) {
283
+ console.log(tool.toolName, tool.sourceType, tool.sourceName, tool.memberName);
284
+ }
285
+ }
286
+ ```
287
+
288
+ This calls:
289
+
290
+ ```text
291
+ GET {baseUrl}/{factoryName}/discovery
292
+ ```
293
+
294
+ Typical uses:
295
+
296
+ - populate a scene dropdown with the normalized names expected by `settings.sceneName`
297
+ - show which tools come from DI services, client interactions, or MCP servers
298
+ - build `forcedTools` values without hardcoding service or MCP metadata in the frontend
299
+
120
300
  ## Example: step-by-step streaming
121
301
 
122
302
  `executeStepByStep(...)` yields full `AiSceneResponse` events as the backend progresses through planning, scene execution, tool calls, and final output.
@@ -216,6 +396,7 @@ The `settings` object mirrors the server-side `SceneRequestSettings`, including:
216
396
 
217
397
  - `executionMode`
218
398
  - `sceneName`
399
+ - `forcedTools`
219
400
  - `conversationKey`
220
401
  - `clientInteractionResults`
221
402
  - `enableStreaming`
@@ -225,6 +406,43 @@ The `settings` object mirrors the server-side `SceneRequestSettings`, including:
225
406
 
226
407
  The request can also include `contents` for multi-modal inputs.
227
408
 
409
+ ## Example: force specific tools for a selected scene
410
+
411
+ The discovery payload returns the exact values you can send back inside `settings.forcedTools`.
412
+
413
+ ```typescript
414
+ const discovery = await client.getDiscovery();
415
+ const calculatorScene = discovery.scenes?.find(scene => scene.name === "Calculator");
416
+ const addTool = calculatorScene?.tools?.find(tool => tool.toolName === "Add");
417
+ const subtractTool = calculatorScene?.tools?.find(tool => tool.toolName === "Subtract");
418
+
419
+ for await (const step of client.executeStepByStep({
420
+ message: "Use only add and subtract",
421
+ settings: {
422
+ executionMode: "Scene",
423
+ sceneName: "Calculator",
424
+ forcedTools: [addTool, subtractTool]
425
+ .filter((tool): tool is NonNullable<typeof tool> => Boolean(tool))
426
+ .map(tool => ({
427
+ sceneName: tool.sceneName,
428
+ toolName: tool.toolName,
429
+ sourceType: tool.sourceType,
430
+ sourceName: tool.sourceName,
431
+ memberName: tool.memberName
432
+ }))
433
+ }
434
+ })) {
435
+ console.log(step.status, step.message);
436
+ }
437
+ ```
438
+
439
+ Notes:
440
+
441
+ - `sceneName` must use the normalized server name from discovery
442
+ - `toolName` must use the normalized tool name from discovery
443
+ - `sourceName` is usually the DI service type name for service tools or the MCP server/factory name for MCP tools
444
+ - `memberName` is usually the service method name or the original MCP tool name
445
+
228
446
  ## Example: send files and multi-modal contents
229
447
 
230
448
  The request model accepts `ContentItem[]`, while `AIContentConverter` helps you build the base64 payloads in the browser.
@@ -4,6 +4,7 @@ import { PlayFrameworkSettings } from "../servicecollection/PlayFrameworkSetting
4
4
  import { ClientInteractionRegistry } from "./ClientInteractionRegistry";
5
5
  import type { StoredConversation, ConversationQueryParameters } from "../models/StoredConversation";
6
6
  import type { VoiceEvent, VoiceRequestOptions } from "../models/VoiceResponse";
7
+ import type { PlayFrameworkDiscoveryResponse } from "../models/PlayFrameworkDiscovery";
7
8
  /**
8
9
  * PlayFramework HTTP client with step-by-step and token-level streaming support.
9
10
  * Supports client-side tool execution with continuation tokens.
@@ -44,6 +45,10 @@ export declare class PlayFrameworkClient {
44
45
  * and automatic reconnection on network failures.
45
46
  */
46
47
  private streamSSE;
48
+ /**
49
+ * Returns scenes, tools, services, and MCP sources exposed by the selected factory.
50
+ */
51
+ getDiscovery(signal?: AbortSignal): Promise<PlayFrameworkDiscoveryResponse>;
47
52
  /**
48
53
  * Lists conversations with filtering, sorting, and pagination.
49
54
  *
@@ -1 +1 @@
1
- {"version":3,"file":"PlayFrame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AW,GACrB,qBAAqB,CAAC,eAAe,CAAC;IAKzC;;;;;;;OAOG;IACW,qBAAqB,CAC/B,OAAO,EAAE,oBAAoB,EAC7B,MAAM,CAAC,EAAE,WAAW,GACrB,qBAAqB,CAAC,eAAe,CAAC;IAKzC;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAuB3B;;;OAGG;YACY,SAAS;IAwMxB;;OAEG;IACU,YAAY,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,8BAA8B,CAAC;IAkBxF;;;;;;OAMG;IACU,iBAAiB,CAC1B,MAAM,CAAC,EAAE,2BAA2B,EACpC,MAAM,CAAC,EAAE,WAAW,GACrB,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAmBhC;;;;;;;OAOG;IACU,eAAe,CACxB,eAAe,EAAE,MAAM,EACvB,eAAe,GAAE,OAAe,EAChC,MAAM,CAAC,EAAE,WAAW,GACrB,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAuBrC;;;;;;OAMG;IACU,kBAAkB,CAC3B,eAAe,EAAE,MAAM,EACvB,MAAM,CAAC,EAAE,WAAW,GACrB,OAAO,CAAC,IAAI,CAAC;IAgBhB;;;;;;;OAOG;IACU,4BAA4B,CACrC,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,OAAO,EACjB,MAAM,CAAC,EAAE,WAAW,GACrB,OAAO,CAAC,kBAAkB,CAAC;IAoB9B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAoCxB;;;;;;;;;;;;;;;;OAgBG;IACW,YAAY,CACtB,OAAO,EAAE,mBAAmB,GAC7B,qBAAqB,CAAC,UAAU,CAAC;CAgFvC"}
@@ -84,7 +84,7 @@ class PlayFrameworkClient {
84
84
  let shouldRetry = true;
85
85
  while (shouldRetry) {
86
86
  try {
87
- const response = await fetch(url, {
87
+ const response = await this.settings.getFetch()(url, {
88
88
  method: "POST",
89
89
  headers,
90
90
  body: JSON.stringify(currentRequest),
@@ -235,6 +235,23 @@ class PlayFrameworkClient {
235
235
  }
236
236
  }
237
237
  // ─── Conversation Management Methods ────────────────────────────────────────
238
+ /**
239
+ * Returns scenes, tools, services, and MCP sources exposed by the selected factory.
240
+ */
241
+ async getDiscovery(signal) {
242
+ const url = `${this.settings.baseUrl}/${this.settings.factoryName}/discovery`;
243
+ const headers = await this.settings.enrichHeaders(url, "GET", undefined, undefined);
244
+ const effectiveSignal = this.createTimeoutSignal(signal);
245
+ const response = await this.settings.getFetch()(url, {
246
+ method: "GET",
247
+ headers,
248
+ signal: effectiveSignal
249
+ });
250
+ if (!response.ok) {
251
+ throw new Error(`Failed to get discovery metadata: ${response.statusText}`);
252
+ }
253
+ return await response.json();
254
+ }
238
255
  /**
239
256
  * Lists conversations with filtering, sorting, and pagination.
240
257
  *
@@ -247,7 +264,7 @@ class PlayFrameworkClient {
247
264
  const url = `${this.settings.baseUrl}/${this.settings.factoryName}/conversations${queryString}`;
248
265
  const headers = await this.settings.enrichHeaders(url, "GET", undefined, undefined);
249
266
  const effectiveSignal = this.createTimeoutSignal(signal);
250
- const response = await fetch(url, {
267
+ const response = await this.settings.getFetch()(url, {
251
268
  method: "GET",
252
269
  headers,
253
270
  signal: effectiveSignal
@@ -270,7 +287,7 @@ class PlayFrameworkClient {
270
287
  const url = `${this.settings.baseUrl}/${this.settings.factoryName}/conversations/${conversationKey}${queryString}`;
271
288
  const headers = await this.settings.enrichHeaders(url, "GET", undefined, undefined);
272
289
  const effectiveSignal = this.createTimeoutSignal(signal);
273
- const response = await fetch(url, {
290
+ const response = await this.settings.getFetch()(url, {
274
291
  method: "GET",
275
292
  headers,
276
293
  signal: effectiveSignal
@@ -294,7 +311,7 @@ class PlayFrameworkClient {
294
311
  const url = `${this.settings.baseUrl}/${this.settings.factoryName}/conversations/${conversationKey}`;
295
312
  const headers = await this.settings.enrichHeaders(url, "DELETE", undefined, undefined);
296
313
  const effectiveSignal = this.createTimeoutSignal(signal);
297
- const response = await fetch(url, {
314
+ const response = await this.settings.getFetch()(url, {
298
315
  method: "DELETE",
299
316
  headers,
300
317
  signal: effectiveSignal
@@ -316,7 +333,7 @@ class PlayFrameworkClient {
316
333
  const body = { isPublic };
317
334
  const headers = await this.settings.enrichHeaders(url, "PATCH", undefined, body);
318
335
  const effectiveSignal = this.createTimeoutSignal(signal);
319
- const response = await fetch(url, {
336
+ const response = await this.settings.getFetch()(url, {
320
337
  method: "PATCH",
321
338
  headers,
322
339
  body: JSON.stringify(body),
@@ -392,7 +409,7 @@ class PlayFrameworkClient {
392
409
  const baseHeaders = await this.settings.enrichHeaders(url, "POST", undefined, undefined);
393
410
  const headers = new Headers(baseHeaders);
394
411
  headers.delete('Content-Type'); // Let browser set multipart boundary
395
- const response = await fetch(url, {
412
+ const response = await this.settings.getFetch()(url, {
396
413
  method: 'POST',
397
414
  headers,
398
415
  body: formData,
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnI,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC3H,YAAY,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAClF,YAAY,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC3F,YAAY,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,mCAAmC,EAAE,MAAM,6BAA6B,CAAC;AACxI,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,YAAY,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,YAAY,EAAE,aAAa,EAAE,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6B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC9G,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,YAAY,EAAE,8BAA8B,EAAE,gCAAgC,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AACjJ,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,YAAY,EAAE,+BAA+B,EAAE,iCAAiC,EAAE,MAAM,kCAAkC,CAAC;AAC3H,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAGxI,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAGlF,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
@@ -3,7 +3,7 @@ import { ClientInteractionRequest } from "./ClientInteractionRequest";
3
3
  * Response status from PlayFramework execution.
4
4
  * Serialized as camelCase from C# JsonStringEnumConverter.
5
5
  */
6
- export type AiResponseStatus = "initializing" | "loadingCache" | "executingMainActors" | "planning" | "executingScene" | "functionRequest" | "functionCompleted" | "toolSkipped" | "streaming" | "running" | "summarizing" | "directorDecision" | "generatingFinalResponse" | "savingCache" | "savingMemory" | "awaitingClient" | "commandClient" | "completed" | "budgetExceeded" | "error" | "unauthorized";
6
+ export type AiResponseStatus = "initializing" | "loadingCache" | "executingMainActors" | "planning" | "executingScene" | "functionRequest" | "functionCompleted" | "toolSkipped" | "streaming" | "running" | "summarizing" | "directorDecision" | "generatingFinalResponse" | "finalResponse" | "savingCache" | "savingMemory" | "awaitingClient" | "commandClient" | "completed" | "budgetExceeded" | "error" | "unauthorized";
7
7
  /**
8
8
  * Single step response from PlayFramework (used in step-by-step streaming).
9
9
  * Matches C# AiSceneResponse contract.
@@ -1 +1 @@
1
- {"version":3,"file":"AiSceneResponse.d.ts","sourceRoot":"","sources":["../../src/models/AiSceneResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GACtB,cAAc,GACd,cAAc,GACd,qBAAqB,GACrB,UAAU,GACV,gBAAgB,GAChB,iBAAiB,GACjB,mBAAmB,GACnB,aAAa,GACb,WAAW,GACX,SAAS,GACT,aAAa,GACb,kBAAkB,GAClB,yBAAyB,GACzB,aAAa,GACb,cAAc,GACd,gBAAgB,GAChB,eAAe,GACf,WAAW,GACX,gBAAgB,GAChB,OAAO,GACP,cAAc,CAAC;AAErB;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC5B;;OAEG;IACH,MAAM,EAAE,gBAAgB,CAAC;IAEzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;OAGG;IACH,wBAAwB,CAAC,EAAE,wBAAwB,CAAC;IAEpD;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE/B;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC,CAAC;CACN;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,MAAM,EAAE,WAAW,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,eAAe,GAAG,gBAAgB,GAAG,WAAW,CAAC"}
1
+ {"version":3,"file":"AiSceneResponse.d.ts","sourceRoot":"","sources":["../../src/models/AiSceneResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GACtB,cAAc,GACd,cAAc,GACd,qBAAqB,GACrB,UAAU,GACV,gBAAgB,GAChB,iBAAiB,GACjB,mBAAmB,GACnB,aAAa,GACb,WAAW,GACX,SAAS,GACT,aAAa,GACb,kBAAkB,GAClB,yBAAyB,GACzB,eAAe,GACf,aAAa,GACb,cAAc,GACd,gBAAgB,GAChB,eAAe,GACf,WAAW,GACX,gBAAgB,GACh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CAAC,CAAC;CACN;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,MAAM,EAAE,WAAW,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,eAAe,GAAG,gBAAgB,GAAG,WAAW,CAAC"}
@@ -2,7 +2,7 @@
2
2
  * Execution phase enum (matches C# ExecutionPhase).
3
3
  * Serialized as camelCase from JsonStringEnumConverter.
4
4
  */
5
- export type ExecutionPhase = "notStarted" | "initialized" | "sceneSelected" | "executingScene" | "awaitingClient" | "sceneCompleted" | "chaining" | "generatingFinalResponse" | "completed" | "completedNoResponse" | "budgetExceeded" | "sceneNotFound" | "tooManyToolRequests" | "break" | "unauthorized";
5
+ export type ExecutionPhase = "notStarted" | "initialized" | "sceneSelected" | "executingScene" | "awaitingClient" | "sceneCompleted" | "chaining" | "generatingFinalResponse" | "finalResponse" | "completed" | "completedNoResponse" | "budgetExceeded" | "sceneNotFound" | "tooManyToolRequests" | "break" | "unauthorized";
6
6
  /**
7
7
  * Execution state for resuming conversations.
8
8
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ExecutionState.d.ts","sourceRoot":"","sources":["../../src/models/ExecutionState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,cAAc,GACpB,YAAY,GACZ,aAAa,GACb,eAAe,GACf,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,GAChB,UAAU,GACV,yBAAyB,GACzB,WAAW,GACX,qBAAqB,GACrB,gBAAgB,GAChB,eAAe,GACf,qBAAqB,GACrB,OAAO,GACP,cAAc,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B;;OAEG;IACH,KAAK,EAAE,cAAc,CAAC;IAEtB;;OAEG;IACH,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAE7B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;IAEtC;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE,CAAC;IAExB;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC"}
1
+ {"version":3,"file":"ExecutionState.d.ts","sourceRoot":"","sources":["../../src/models/ExecutionState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,cAAc,GACpB,YAAY,GACZ,aAAa,GACb,eAAe,GACf,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,GAChB,UAAU,GACV,yBAAyB,GACzB,eAAe,GACf,WAAW,GACX,qBAAqB,GACrB,gBAAgB,GAChB,eAAe,GACf,qBAAqB,GACrB,OAAO,GACP,cAAc,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B;;OAEG;IACH,KAAK,EAAE,cAAc,CAAC;IAEtB;;OAEG;IACH,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAE7B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;IAEtC;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE,CAAC;IAExB;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC"}
@@ -0,0 +1,39 @@
1
+ export type PlayFrameworkToolSourceType = "service" | "client" | "mcp" | "other";
2
+ export interface ForcedToolRequest {
3
+ sceneName: string;
4
+ toolName: string;
5
+ sourceType?: PlayFrameworkToolSourceType;
6
+ sourceName?: string;
7
+ memberName?: string;
8
+ }
9
+ export interface PlayFrameworkToolInfo {
10
+ sceneName: string;
11
+ toolName: string;
12
+ description?: string;
13
+ sourceType: PlayFrameworkToolSourceType;
14
+ sourceName?: string;
15
+ memberName?: string;
16
+ isCommand?: boolean;
17
+ jsonSchema?: string;
18
+ }
19
+ export interface PlayFrameworkToolSourceInfo {
20
+ name: string;
21
+ sourceType: PlayFrameworkToolSourceType;
22
+ isAvailable?: boolean;
23
+ errorMessage?: string;
24
+ tools?: PlayFrameworkToolInfo[];
25
+ }
26
+ export interface PlayFrameworkSceneInfo {
27
+ name: string;
28
+ description: string;
29
+ tools?: PlayFrameworkToolInfo[];
30
+ }
31
+ export interface PlayFrameworkDiscoveryResponse {
32
+ factoryName: string;
33
+ scenes?: PlayFrameworkSceneInfo[];
34
+ services?: PlayFrameworkToolSourceInfo[];
35
+ clients?: PlayFrameworkToolSourceInfo[];
36
+ mcpServers?: PlayFrameworkToolSourceInfo[];
37
+ others?: PlayFrameworkToolInfo[];
38
+ }
39
+ //# sourceMappingURL=PlayFrameworkDiscovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlayFrameworkDiscovery.d.ts","sourceRoot":"","sources":["../../src/models/PlayFrameworkDiscovery.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,2BAA2B,GAAG,SAAS,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAC;AAEjF,MAAM,WAAW,iBAAiB;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,2BAA2B,CAAC;IACzC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,qBAAqB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,2BAA2B,CAAC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,2BAA2B;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,2BAA2B,CAAC;IACxC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,qBAAqB,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,sBAAsB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,qBAAqB,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,8BAA8B;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAClC,QAAQ,CAAC,EAAE,2BAA2B,EAAE,CAAC;IACzC,OAAO,CAAC,EAAE,2BAA2B,EAAE,CAAC;IACxC,UAAU,CAAC,EAAE,2BAA2B,EAAE,CAAC;IAC3C,MAAM,CAAC,EAAE,qBAAqB,EAAE,CAAC;CACpC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,6 @@
1
1
  import { ContentItem } from "./ContentItem";
2
2
  import { ClientInteractionResult } from "./ClientInteractionResult";
3
+ import { ForcedToolRequest } from "./PlayFrameworkDiscovery";
3
4
  /**
4
5
  * Execution mode for the scene.
5
6
  */
@@ -40,6 +41,8 @@ export interface SceneRequestSettings {
40
41
  sceneName?: string;
41
42
  /** Results from client-side tool executions. */
42
43
  clientInteractionResults?: ClientInteractionResult[];
44
+ /** Optional scene-scoped tools to expose/force for this request. */
45
+ forcedTools?: ForcedToolRequest[];
43
46
  /**
44
47
  * Additional system-level instructions appended to the system prompt.
45
48
  * Used by voice pipeline to inject conversational style and language instructions.
@@ -1 +1 @@
1
- {"version":3,"file":"PlayFrameworkRequest.d.ts","sourceRoot":"","sources":["../../src/models/PlayFrameworkRequest.ts"],"names":[],"mappings":"AAAA,OAAO,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C,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,sEAAsE;IACtE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mEAAmE;IACnE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,wBAAwB,CAAC,EAAE,uBAAuB,EAAE,CAAC;IACrD,oEAAoE;IACpE,WAAW,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAClC;;;OAGG;IACH,4BAA4B,CAAC,EAAE,MAAM,EAAE,CAAC;IACxC;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACjC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAEhC;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,wBAAwB,CAAC,EAAE,uBAAuB,EAAE,CAAC;CACxD"}
@@ -36,6 +36,12 @@ export declare class PlayFrameworkSettings {
36
36
  * Error handlers for retry logic.
37
37
  */
38
38
  private errorHandlers;
39
+ /**
40
+ * Underlying fetch implementation.
41
+ * Defaults to globalThis.fetch. Override via setFetch() to plug in a custom adapter
42
+ * (e.g., an Angular HTTP interceptor bridge, a Node.js fetch polyfill, or a test spy).
43
+ */
44
+ private fetchFn;
39
45
  constructor(factoryName: string, baseUrl: string);
40
46
  /**
41
47
  * Add a header enricher function (e.g., dynamic Authorization token).
@@ -45,6 +51,42 @@ export declare class PlayFrameworkSettings {
45
51
  * Add an error handler for retry logic.
46
52
  */
47
53
  addErrorHandler(handler: (url: string, method: string, headers: HeadersInit, body: any, error: any) => Promise<boolean>): this;
54
+ /**
55
+ * Replace the underlying fetch function used by PlayFrameworkClient for every HTTP request,
56
+ * including SSE streaming, conversation management and voice endpoints.
57
+ *
58
+ * Use this to plug in a custom adapter that wraps each request — for example:
59
+ * - An Angular fetch bridge that attaches Bearer tokens and handles 401 token refresh
60
+ * - A Node.js fetch polyfill (e.g., `node-fetch` for SSR)
61
+ * - A test spy that records and intercepts outgoing requests
62
+ *
63
+ * The adapter receives the same `(input, init?)` arguments as the native Fetch API
64
+ * and MUST return a `Promise<Response>`. Callers that never invoke `setFetch()` use
65
+ * `globalThis.fetch` transparently — no behaviour change.
66
+ *
67
+ * @example Generic token injection (framework-agnostic):
68
+ * ```typescript
69
+ * settings.setFetch(async (url, init) => {
70
+ * const token = localStorage.getItem("token");
71
+ * const headers = new Headers(init?.headers);
72
+ * if (token) headers.set("Authorization", `Bearer ${token}`);
73
+ * return fetch(url, { ...init, headers });
74
+ * });
75
+ * ```
76
+ *
77
+ * @example Angular — bridge the existing HttpInterceptor logic:
78
+ * ```typescript
79
+ * // In an Angular @Injectable service:
80
+ * settings.setFetch(this.createFetchBridge());
81
+ * // See README "Custom fetch adapter" section for the full Angular example.
82
+ * ```
83
+ */
84
+ setFetch(fn: typeof fetch): this;
85
+ /**
86
+ * Returns the active fetch implementation (custom or globalThis.fetch).
87
+ * Used internally by PlayFrameworkClient — not intended for direct use.
88
+ */
89
+ getFetch(): typeof fetch;
48
90
  /**
49
91
  * Enrich headers with all registered enrichers.
50
92
  */
@@ -1 +1 @@
1
- {"version":3,"file":"PlayFrameworkSettings.d.ts","sourceRoot":"","sources":["../../src/servicecollection/PlayFrameworkSettings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,qBAAqB;IAC9B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;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E,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC;CAWvH"}
@@ -39,6 +39,12 @@ class PlayFrameworkSettings {
39
39
  * Error handlers for retry logic.
40
40
  */
41
41
  errorHandlers;
42
+ /**
43
+ * Underlying fetch implementation.
44
+ * Defaults to globalThis.fetch. Override via setFetch() to plug in a custom adapter
45
+ * (e.g., an Angular HTTP interceptor bridge, a Node.js fetch polyfill, or a test spy).
46
+ */
47
+ fetchFn;
42
48
  constructor(factoryName, baseUrl) {
43
49
  this.factoryName = factoryName;
44
50
  this.baseUrl = baseUrl;
@@ -50,6 +56,7 @@ class PlayFrameworkSettings {
50
56
  this.reconnectBaseDelay = 1000;
51
57
  this.headersEnrichers = [];
52
58
  this.errorHandlers = [];
59
+ this.fetchFn = globalThis.fetch.bind(globalThis);
53
60
  }
54
61
  /**
55
62
  * Add a header enricher function (e.g., dynamic Authorization token).
@@ -65,6 +72,47 @@ class PlayFrameworkSettings {
65
72
  this.errorHandlers.push(handler);
66
73
  return this;
67
74
  }
75
+ /**
76
+ * Replace the underlying fetch function used by PlayFrameworkClient for every HTTP request,
77
+ * including SSE streaming, conversation management and voice endpoints.
78
+ *
79
+ * Use this to plug in a custom adapter that wraps each request — for example:
80
+ * - An Angular fetch bridge that attaches Bearer tokens and handles 401 token refresh
81
+ * - A Node.js fetch polyfill (e.g., `node-fetch` for SSR)
82
+ * - A test spy that records and intercepts outgoing requests
83
+ *
84
+ * The adapter receives the same `(input, init?)` arguments as the native Fetch API
85
+ * and MUST return a `Promise<Response>`. Callers that never invoke `setFetch()` use
86
+ * `globalThis.fetch` transparently — no behaviour change.
87
+ *
88
+ * @example Generic token injection (framework-agnostic):
89
+ * ```typescript
90
+ * settings.setFetch(async (url, init) => {
91
+ * const token = localStorage.getItem("token");
92
+ * const headers = new Headers(init?.headers);
93
+ * if (token) headers.set("Authorization", `Bearer ${token}`);
94
+ * return fetch(url, { ...init, headers });
95
+ * });
96
+ * ```
97
+ *
98
+ * @example Angular — bridge the existing HttpInterceptor logic:
99
+ * ```typescript
100
+ * // In an Angular @Injectable service:
101
+ * settings.setFetch(this.createFetchBridge());
102
+ * // See README "Custom fetch adapter" section for the full Angular example.
103
+ * ```
104
+ */
105
+ setFetch(fn) {
106
+ this.fetchFn = fn;
107
+ return this;
108
+ }
109
+ /**
110
+ * Returns the active fetch implementation (custom or globalThis.fetch).
111
+ * Used internally by PlayFrameworkClient — not intended for direct use.
112
+ */
113
+ getFetch() {
114
+ return this.fetchFn;
115
+ }
68
116
  /**
69
117
  * Enrich headers with all registered enrichers.
70
118
  */
@@ -126,7 +126,7 @@ class BrowserVoiceClient {
126
126
  'executingMainActors', 'executingScene', 'planning',
127
127
  'functionRequest', 'functionCompleted', 'toolSkipped',
128
128
  'awaitingClient', 'commandClient',
129
- 'directorDecision', 'summarizing', 'generatingFinalResponse',
129
+ 'directorDecision', 'summarizing', 'generatingFinalResponse', 'finalResponse',
130
130
  'error', 'budgetExceeded', 'unauthorized',
131
131
  ];
132
132
  if (!nonSpeakableStatuses.includes(response.status)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rystem.playframework.client",
3
- "version": "0.1.4",
3
+ "version": "10.1.0-beta.2",
4
4
  "author": "Alessandro Rapiti <alessandro.rapiti44@gmail.com>",
5
5
  "license": "MIT",
6
6
  "description": "TypeScript client for Rystem PlayFramework HTTP API with step-by-step and token-level streaming support.",
@@ -1,28 +0,0 @@
1
- import { PlayFrameworkClient } from "../engine/PlayFrameworkClient";
2
- /**
3
- * Get a PlayFrameworkClient instance by optional factory name.
4
- *
5
- * If `name` is provided, returns the client for that specific factory.
6
- * If `name` is omitted, returns the default (first configured) client.
7
- *
8
- * Framework-agnostic — works with React, Vue, Angular, Svelte, or plain TypeScript.
9
- *
10
- * @param name - Optional factory name. Omit to use the default client.
11
- * @returns PlayFrameworkClient instance.
12
- *
13
- * @example
14
- * ```ts
15
- * // Use default (first configured) client
16
- * const client = usePlayFramework();
17
- *
18
- * // Use a specific factory
19
- * const chatClient = usePlayFramework("chat");
20
- *
21
- * // Execute
22
- * for await (const step of client.executeStepByStep({ message: "Hello" })) {
23
- * console.log(step.message);
24
- * }
25
- * ```
26
- */
27
- export declare function usePlayFramework(name?: string): PlayFrameworkClient;
28
- //# sourceMappingURL=hooks.d.ts.map
package/lib/index.d.ts DELETED
@@ -1,29 +0,0 @@
1
- export type { ContentItem } from "./models/ContentItem";
2
- export type { PlayFrameworkRequest, SceneRequestSettings, SceneExecutionMode, CacheBehavior } from "./models/PlayFrameworkRequest";
3
- export type { AiSceneResponse, AiResponseStatus, SSEEvent, CompletionMarker, ErrorMarker } from "./models/AiSceneResponse";
4
- export type { ClientInteractionRequest } from "./models/ClientInteractionRequest";
5
- export type { ClientInteractionResult, AIContent } from "./models/ClientInteractionResult";
6
- export type { StoredConversation, ConversationQueryParameters, UpdateConversationVisibilityRequest } from "./models/StoredConversation";
7
- export { ConversationSortOrder } from "./models/StoredConversation";
8
- export type { StoredMessage } from "./models/StoredMessage";
9
- export type { ExecutionState } from "./models/ExecutionState";
10
- export type { CommandResult } from "./models/CommandResult";
11
- export { CommandResult as CommandResultHelper } from "./models/CommandResult";
12
- export type { VoiceEvent, VoiceRequestOptions, VoiceResponseType } from "./models/VoiceResponse";
13
- export { PlayFrameworkClient } from "./engine/PlayFrameworkClient";
14
- export { ClientInteractionRegistry } from "./engine/ClientInteractionRegistry";
15
- export type { ClientTool, ClientCommand, CommandFeedbackMode, CommandOptions } from "./engine/ClientInteractionRegistry";
16
- export { AIContentConverter } from "./utils/AIContentConverter";
17
- export { ContentUrlConverter } from "./utils/ContentUrlConverter";
18
- export { VoiceRecorder } from "./utils/VoiceRecorder";
19
- export type { VoiceRecordingMode, VoiceRecorderOptions, VoiceRecorderCallbacks } from "./utils/VoiceRecorder";
20
- export { BrowserSpeechRecognizer } from "./utils/BrowserSpeechRecognizer";
21
- export type { BrowserSpeechRecognizerOptions, BrowserSpeechRecognizerCallbacks, SpeechRecognitionResult } from "./utils/BrowserSpeechRecognizer";
22
- export { BrowserSpeechSynthesizer } from "./utils/BrowserSpeechSynthesizer";
23
- export type { BrowserSpeechSynthesizerOptions, BrowserSpeechSynthesizerCallbacks } from "./utils/BrowserSpeechSynthesizer";
24
- export { BrowserVoiceClient } from "./utils/BrowserVoiceClient";
25
- export type { BrowserVoiceOptions, BrowserVoiceEvent, BrowserVoiceStatus, BrowserVoiceStreamingMode } from "./utils/BrowserVoiceClient";
26
- export { PlayFrameworkSettings } from "./servicecollection/PlayFrameworkSettings";
27
- export { PlayFrameworkServices } from "./servicecollection/PlayFrameworkServices";
28
- export { usePlayFramework } from "./hooks/hooks";
29
- //# sourceMappingURL=index.d.ts.map