@wix/legends-platform-sdk 1.34.0 → 1.36.0

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 (57) hide show
  1. package/README.md +18 -1
  2. package/dist/cjs/components/LegendsPlatform/LegendsPlatform.js +10 -7
  3. package/dist/cjs/components/LegendsPlatform/LegendsPlatform.js.map +1 -1
  4. package/dist/cjs/components/LegendsPlatformCore/LegendsPlatformCore.js +73 -0
  5. package/dist/cjs/components/LegendsPlatformCore/LegendsPlatformCore.js.map +1 -0
  6. package/dist/cjs/components/LegendsPlatformCore/index.js +10 -0
  7. package/dist/cjs/components/LegendsPlatformCore/index.js.map +1 -0
  8. package/dist/cjs/hooks/useTextChat/chatFunctionCalls.js +24 -0
  9. package/dist/cjs/hooks/useTextChat/chatFunctionCalls.js.map +1 -0
  10. package/dist/cjs/hooks/useTextChat/useToolAwareSend.js +15 -3
  11. package/dist/cjs/hooks/useTextChat/useToolAwareSend.js.map +1 -1
  12. package/dist/cjs/sdk.js +7 -1
  13. package/dist/cjs/sdk.js.map +1 -1
  14. package/dist/cjs/services/BearerPersonaChatService.js +187 -0
  15. package/dist/cjs/services/BearerPersonaChatService.js.map +1 -0
  16. package/dist/cjs/services/FetchPersonaChatService.js +10 -4
  17. package/dist/cjs/services/FetchPersonaChatService.js.map +1 -1
  18. package/dist/cjs/types/index.js.map +1 -1
  19. package/dist/cjs/types/service.js.map +1 -1
  20. package/dist/esm/components/LegendsPlatform/LegendsPlatform.js +5 -2
  21. package/dist/esm/components/LegendsPlatform/LegendsPlatform.js.map +1 -1
  22. package/dist/esm/components/LegendsPlatformCore/LegendsPlatformCore.js +40 -0
  23. package/dist/esm/components/LegendsPlatformCore/LegendsPlatformCore.js.map +1 -0
  24. package/dist/esm/components/LegendsPlatformCore/index.js +2 -0
  25. package/dist/esm/components/LegendsPlatformCore/index.js.map +1 -0
  26. package/dist/esm/hooks/useTextChat/chatFunctionCalls.js +19 -0
  27. package/dist/esm/hooks/useTextChat/chatFunctionCalls.js.map +1 -0
  28. package/dist/esm/hooks/useTextChat/useToolAwareSend.js +15 -3
  29. package/dist/esm/hooks/useTextChat/useToolAwareSend.js.map +1 -1
  30. package/dist/esm/sdk.js +2 -0
  31. package/dist/esm/sdk.js.map +1 -1
  32. package/dist/esm/services/BearerPersonaChatService.js +177 -0
  33. package/dist/esm/services/BearerPersonaChatService.js.map +1 -0
  34. package/dist/esm/services/FetchPersonaChatService.js +12 -3
  35. package/dist/esm/services/FetchPersonaChatService.js.map +1 -1
  36. package/dist/esm/types/index.js.map +1 -1
  37. package/dist/esm/types/service.js.map +1 -1
  38. package/dist/types/components/LegendsPlatform/LegendsPlatform.d.ts +3 -0
  39. package/dist/types/components/LegendsPlatform/LegendsPlatform.d.ts.map +1 -1
  40. package/dist/types/components/LegendsPlatformCore/LegendsPlatformCore.d.ts +23 -0
  41. package/dist/types/components/LegendsPlatformCore/LegendsPlatformCore.d.ts.map +1 -0
  42. package/dist/types/components/LegendsPlatformCore/index.d.ts +2 -0
  43. package/dist/types/components/LegendsPlatformCore/index.d.ts.map +1 -0
  44. package/dist/types/hooks/useTextChat/chatFunctionCalls.d.ts +4 -0
  45. package/dist/types/hooks/useTextChat/chatFunctionCalls.d.ts.map +1 -0
  46. package/dist/types/hooks/useTextChat/useToolAwareSend.d.ts.map +1 -1
  47. package/dist/types/sdk.d.ts +4 -0
  48. package/dist/types/sdk.d.ts.map +1 -1
  49. package/dist/types/services/BearerPersonaChatService.d.ts +37 -0
  50. package/dist/types/services/BearerPersonaChatService.d.ts.map +1 -0
  51. package/dist/types/services/FetchPersonaChatService.d.ts +13 -3
  52. package/dist/types/services/FetchPersonaChatService.d.ts.map +1 -1
  53. package/dist/types/types/index.d.ts +1 -1
  54. package/dist/types/types/index.d.ts.map +1 -1
  55. package/dist/types/types/service.d.ts +15 -2
  56. package/dist/types/types/service.d.ts.map +1 -1
  57. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { HttpError } from '../types/http';
3
- const BASE_URL = 'https://www.wixapis.com';
3
+ export const DEFAULT_BASE_URL = 'https://www.wixapis.com';
4
4
  function resolveLimitMs(limitation) {
5
5
  if (!limitation) {
6
6
  return undefined;
@@ -16,9 +16,18 @@ function resolveLimitMs(limitation) {
16
16
  }
17
17
  }
18
18
  export class FetchPersonaChatService {
19
- constructor(apiKey) {
19
+ /**
20
+ * Server side only: a namespace API key skips owner checks and must never
21
+ * reach a browser. A browser uses BearerPersonaChatService with a visitor token.
22
+ */
23
+ constructor(apiKey, options) {
24
+ if (options === void 0) {
25
+ options = {};
26
+ }
20
27
  _defineProperty(this, "apiKey", void 0);
28
+ _defineProperty(this, "baseUrl", void 0);
21
29
  this.apiKey = apiKey;
30
+ this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, '');
22
31
  }
23
32
  headers() {
24
33
  return {
@@ -27,7 +36,7 @@ export class FetchPersonaChatService {
27
36
  };
28
37
  }
29
38
  async post(path, body) {
30
- const response = await fetch(`${BASE_URL}${path}`, {
39
+ const response = await fetch(`${this.baseUrl}${path}`, {
31
40
  method: 'POST',
32
41
  headers: this.headers(),
33
42
  body: JSON.stringify(body)
@@ -1 +1 @@
1
- {"version":3,"names":["HttpError","BASE_URL","resolveLimitMs","limitation","undefined","type","limit","FetchPersonaChatService","constructor","apiKey","_defineProperty","headers","Authorization","post","path","body","response","fetch","method","JSON","stringify","ok","text","catch","status","parseJson","json","createVoiceConversation","params","chatId","namespace","chatConfig","conversationLanguage","data","url","conversationUrl","id","interactiveConversationId","createInteractiveConversation","endInteractiveConversation","conversationId","sendChatMessage","message","functionCallResults","attachments","queryChatMessages","_data$pagingMetadata","_params$limit","cursor","query","cursorPaging","messages","chatMessages","map","m","content","role","createdAt","nextCursor","pagingMetadata","cursors","next","parse"],"sources":["../../../src/services/FetchPersonaChatService.ts"],"sourcesContent":["import { HttpError } from '../types/http';\nimport type {\n IPersonaChatService,\n CreateConversationParams,\n ConversationResult,\n EndConversationParams,\n SendMessageParams,\n QueryMessagesParams,\n QueryMessagesResult,\n FunctionCall,\n ChatMessage,\n Limitation,\n} from '../types';\n\nconst BASE_URL = 'https://www.wixapis.com';\n\nfunction resolveLimitMs(limitation?: Limitation): number | undefined {\n if (!limitation) {\n return undefined;\n }\n switch (limitation.type) {\n case 'MINUTES':\n return (limitation.limit ?? 0) * 60 * 1000;\n case 'SECONDS':\n return (limitation.limit ?? 0) * 1000;\n case 'TOKENS':\n default:\n return 0;\n }\n}\n\nexport class FetchPersonaChatService implements IPersonaChatService {\n private readonly apiKey: string;\n\n constructor(apiKey: string) {\n this.apiKey = apiKey;\n }\n\n private headers(): Record<string, string> {\n return {\n 'Content-Type': 'application/json',\n Authorization: `Api-Key ${this.apiKey}`,\n };\n }\n\n private async post<T>(path: string, body: unknown): Promise<T> {\n const response = await fetch(`${BASE_URL}${path}`, {\n method: 'POST',\n headers: this.headers(),\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n const text = await response.text().catch(() => '');\n throw new HttpError(\n response.status,\n `Request failed: ${response.status} ${text}`,\n parseJson(text),\n );\n }\n\n return response.json() as Promise<T>;\n }\n\n async createVoiceConversation(\n params: CreateConversationParams,\n ): Promise<ConversationResult> {\n const { chatId, namespace, chatConfig, conversationLanguage } = params;\n\n const data = await this.post<{\n conversationUrl?: string;\n interactiveConversationId?: string;\n limitation?: Limitation;\n }>(\n `/_api/persona-chat-service/v1/chats/${chatId}/create-voice-conversation`,\n {\n namespace,\n ...(chatConfig ? { chatConfig } : {}),\n ...(conversationLanguage !== undefined ? { conversationLanguage } : {}),\n },\n );\n\n return {\n url: data.conversationUrl ?? '',\n id: data.interactiveConversationId ?? '',\n limit: resolveLimitMs(data.limitation),\n };\n }\n\n async createInteractiveConversation(\n params: CreateConversationParams,\n ): Promise<ConversationResult> {\n const { chatId, namespace, chatConfig, conversationLanguage } = params;\n\n const data = await this.post<{\n conversationUrl?: string;\n interactiveConversationId?: string;\n limitation?: Limitation;\n }>(\n `/_api/persona-chat-service/v1/chats/${chatId}/create-interactive-conversation`,\n {\n namespace,\n ...(chatConfig ? { chatConfig } : {}),\n ...(conversationLanguage !== undefined ? { conversationLanguage } : {}),\n },\n );\n\n return {\n url: data.conversationUrl ?? '',\n id: data.interactiveConversationId ?? '',\n limit: resolveLimitMs(data.limitation),\n };\n }\n\n async endInteractiveConversation(\n params: EndConversationParams,\n ): Promise<void> {\n const { chatId, conversationId, namespace } = params;\n\n await this.post(\n `/_api/persona-chat-service/v1/chats/${chatId}/end-interactive-conversation`,\n { namespace, interactiveConversationId: conversationId },\n ).catch(() => {\n // best-effort\n });\n }\n\n async sendChatMessage(\n params: SendMessageParams,\n ): Promise<{ functionCalls?: FunctionCall[]; messages?: ChatMessage[] }> {\n const {\n chatId,\n namespace,\n message,\n functionCallResults,\n chatConfig,\n attachments,\n conversationLanguage,\n } = params;\n\n return this.post<{\n functionCalls?: FunctionCall[];\n messages?: ChatMessage[];\n }>(`/_api/persona-chat-service/v1/chats/${chatId}/messages`, {\n namespace,\n message,\n ...(functionCallResults ? { functionCallResults } : {}),\n ...(chatConfig ? { chatConfig } : {}),\n ...(attachments ? { attachments } : {}),\n ...(conversationLanguage !== undefined ? { conversationLanguage } : {}),\n });\n }\n\n async queryChatMessages(\n params: QueryMessagesParams,\n ): Promise<QueryMessagesResult> {\n const { chatId, namespace, limit = 100, cursor } = params;\n\n const data = await this.post<{\n chatMessages?: {\n id: string;\n content: string;\n role: string;\n createdAt?: string;\n }[];\n pagingMetadata?: { cursors?: { next?: string } };\n }>(`/_api/persona-chat-service/v1/chats/${chatId}/messages/query`, {\n namespace,\n query: { cursorPaging: { limit, ...(cursor ? { cursor } : {}) } },\n });\n\n return {\n messages: (data.chatMessages ?? []).map((m) => ({\n id: m.id,\n content: m.content,\n role: m.role as 'USER' | 'ASSISTANT',\n createdAt: m.createdAt,\n })),\n nextCursor: data.pagingMetadata?.cursors?.next,\n };\n }\n}\n\nfunction parseJson(text: string): unknown {\n try {\n return JSON.parse(text);\n } catch {\n return undefined;\n }\n}\n"],"mappings":";AAAA,SAASA,SAAS,QAAQ,eAAe;AAczC,MAAMC,QAAQ,GAAG,yBAAyB;AAE1C,SAASC,cAAcA,CAACC,UAAuB,EAAsB;EACnE,IAAI,CAACA,UAAU,EAAE;IACf,OAAOC,SAAS;EAClB;EACA,QAAQD,UAAU,CAACE,IAAI;IACrB,KAAK,SAAS;MACZ,OAAO,CAACF,UAAU,CAACG,KAAK,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI;IAC5C,KAAK,SAAS;MACZ,OAAO,CAACH,UAAU,CAACG,KAAK,IAAI,CAAC,IAAI,IAAI;IACvC,KAAK,QAAQ;IACb;MACE,OAAO,CAAC;EACZ;AACF;AAEA,OAAO,MAAMC,uBAAuB,CAAgC;EAGlEC,WAAWA,CAACC,MAAc,EAAE;IAAAC,eAAA;IAC1B,IAAI,CAACD,MAAM,GAAGA,MAAM;EACtB;EAEQE,OAAOA,CAAA,EAA2B;IACxC,OAAO;MACL,cAAc,EAAE,kBAAkB;MAClCC,aAAa,EAAE,WAAW,IAAI,CAACH,MAAM;IACvC,CAAC;EACH;EAEA,MAAcI,IAAIA,CAAIC,IAAY,EAAEC,IAAa,EAAc;IAC7D,MAAMC,QAAQ,GAAG,MAAMC,KAAK,CAAC,GAAGhB,QAAQ,GAAGa,IAAI,EAAE,EAAE;MACjDI,MAAM,EAAE,MAAM;MACdP,OAAO,EAAE,IAAI,CAACA,OAAO,CAAC,CAAC;MACvBI,IAAI,EAAEI,IAAI,CAACC,SAAS,CAACL,IAAI;IAC3B,CAAC,CAAC;IAEF,IAAI,CAACC,QAAQ,CAACK,EAAE,EAAE;MAChB,MAAMC,IAAI,GAAG,MAAMN,QAAQ,CAACM,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC,MAAM,EAAE,CAAC;MAClD,MAAM,IAAIvB,SAAS,CACjBgB,QAAQ,CAACQ,MAAM,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MAAM;IACN,OAAOlB,SAAS;EAClB;AACF","ignoreList":[]}
1
+ {"version":3,"names":["HttpError","DEFAULT_BASE_URL","resolveLimitMs","limitation","undefined","type","limit","FetchPersonaChatService","constructor","apiKey","options","_defineProperty","baseUrl","replace","headers","Authorization","post","path","body","response","fetch","method","JSON","stringify","ok","text","catch","status","parseJson","json","createVoiceConversation","params","chatId","namespace","chatConfig","conversationLanguage","data","url","conversationUrl","id","interactiveConversationId","createInteractiveConversation","endInteractiveConversation","conversationId","sendChatMessage","message","functionCallResults","attachments","queryChatMessages","_data$pagingMetadata","_params$limit","cursor","query","cursorPaging","messages","chatMessages","map","m","content","role","createdAt","nextCursor","pagingMetadata","cursors","next","parse"],"sources":["../../../src/services/FetchPersonaChatService.ts"],"sourcesContent":["import { HttpError } from '../types/http';\nimport type {\n IPersonaChatService,\n CreateConversationParams,\n ConversationResult,\n EndConversationParams,\n SendMessageParams,\n QueryMessagesParams,\n QueryMessagesResult,\n FunctionCall,\n ChatFunctionCall,\n ChatMessage,\n Limitation,\n} from '../types';\n\nexport const DEFAULT_BASE_URL = 'https://www.wixapis.com';\n\nexport interface FetchPersonaChatServiceOptions {\n /** API host, e.g. a local or test gateway. Defaults to https://www.wixapis.com. */\n baseUrl?: string;\n}\n\nfunction resolveLimitMs(limitation?: Limitation): number | undefined {\n if (!limitation) {\n return undefined;\n }\n switch (limitation.type) {\n case 'MINUTES':\n return (limitation.limit ?? 0) * 60 * 1000;\n case 'SECONDS':\n return (limitation.limit ?? 0) * 1000;\n case 'TOKENS':\n default:\n return 0;\n }\n}\n\nexport class FetchPersonaChatService implements IPersonaChatService {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n\n /**\n * Server side only: a namespace API key skips owner checks and must never\n * reach a browser. A browser uses BearerPersonaChatService with a visitor token.\n */\n constructor(apiKey: string, options: FetchPersonaChatServiceOptions = {}) {\n this.apiKey = apiKey;\n this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, '');\n }\n\n private headers(): Record<string, string> {\n return {\n 'Content-Type': 'application/json',\n Authorization: `Api-Key ${this.apiKey}`,\n };\n }\n\n private async post<T>(path: string, body: unknown): Promise<T> {\n const response = await fetch(`${this.baseUrl}${path}`, {\n method: 'POST',\n headers: this.headers(),\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n const text = await response.text().catch(() => '');\n throw new HttpError(\n response.status,\n `Request failed: ${response.status} ${text}`,\n parseJson(text),\n );\n }\n\n return response.json() as Promise<T>;\n }\n\n async createVoiceConversation(\n params: CreateConversationParams,\n ): Promise<ConversationResult> {\n const { chatId, namespace, chatConfig, conversationLanguage } = params;\n\n const data = await this.post<{\n conversationUrl?: string;\n interactiveConversationId?: string;\n limitation?: Limitation;\n }>(\n `/_api/persona-chat-service/v1/chats/${chatId}/create-voice-conversation`,\n {\n namespace,\n ...(chatConfig ? { chatConfig } : {}),\n ...(conversationLanguage !== undefined ? { conversationLanguage } : {}),\n },\n );\n\n return {\n url: data.conversationUrl ?? '',\n id: data.interactiveConversationId ?? '',\n limit: resolveLimitMs(data.limitation),\n };\n }\n\n async createInteractiveConversation(\n params: CreateConversationParams,\n ): Promise<ConversationResult> {\n const { chatId, namespace, chatConfig, conversationLanguage } = params;\n\n const data = await this.post<{\n conversationUrl?: string;\n interactiveConversationId?: string;\n limitation?: Limitation;\n }>(\n `/_api/persona-chat-service/v1/chats/${chatId}/create-interactive-conversation`,\n {\n namespace,\n ...(chatConfig ? { chatConfig } : {}),\n ...(conversationLanguage !== undefined ? { conversationLanguage } : {}),\n },\n );\n\n return {\n url: data.conversationUrl ?? '',\n id: data.interactiveConversationId ?? '',\n limit: resolveLimitMs(data.limitation),\n };\n }\n\n async endInteractiveConversation(\n params: EndConversationParams,\n ): Promise<void> {\n const { chatId, conversationId, namespace } = params;\n\n await this.post(\n `/_api/persona-chat-service/v1/chats/${chatId}/end-interactive-conversation`,\n { namespace, interactiveConversationId: conversationId },\n ).catch(() => {\n // best-effort\n });\n }\n\n async sendChatMessage(params: SendMessageParams): Promise<{\n functionCalls?: (FunctionCall | ChatFunctionCall)[];\n messages?: ChatMessage[];\n }> {\n const {\n chatId,\n namespace,\n message,\n functionCallResults,\n chatConfig,\n attachments,\n conversationLanguage,\n } = params;\n\n return this.post<{\n functionCalls?: ChatFunctionCall[];\n messages?: ChatMessage[];\n }>(`/_api/persona-chat-service/v1/chats/${chatId}/messages`, {\n namespace,\n message,\n ...(functionCallResults ? { functionCallResults } : {}),\n ...(chatConfig ? { chatConfig } : {}),\n ...(attachments ? { attachments } : {}),\n ...(conversationLanguage !== undefined ? { conversationLanguage } : {}),\n });\n }\n\n async queryChatMessages(\n params: QueryMessagesParams,\n ): Promise<QueryMessagesResult> {\n const { chatId, namespace, limit = 100, cursor } = params;\n\n const data = await this.post<{\n chatMessages?: {\n id: string;\n content: string;\n role: string;\n createdAt?: string;\n }[];\n pagingMetadata?: { cursors?: { next?: string } };\n }>(`/_api/persona-chat-service/v1/chats/${chatId}/messages/query`, {\n namespace,\n query: { cursorPaging: { limit, ...(cursor ? { cursor } : {}) } },\n });\n\n return {\n messages: (data.chatMessages ?? []).map((m) => ({\n id: m.id,\n content: m.content,\n role: m.role as 'USER' | 'ASSISTANT',\n createdAt: m.createdAt,\n })),\n nextCursor: data.pagingMetadata?.cursors?.next,\n };\n }\n}\n\nfunction parseJson(text: string): unknown {\n try {\n return JSON.parse(text);\n } catch {\n return undefined;\n }\n}\n"],"mappings":";AAAA,SAASA,SAAS,QAAQ,eAAe;AAezC,OAAO,MAAMC,gBAAgB,GAAG,yBAAyB;AAOzD,SAASC,cAAcA,CAACC,UAAuB,EAAsB;EACnE,IAAI,CAACA,UAAU,EAAE;IACf,OAAOC,SAAS;EAClB;EACA,QAAQD,UAAU,CAACE,IAAI;IACrB,KAAK,SAAS;MACZ,OAAO,CAACF,UAAU,CAACG,KAAK,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI;IAC5C,KAAK,SAAS;MACZ,OAAO,CAACH,UAAU,CAACG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oBAAA;IAC9B,MAAQjB,MAAM,GAAqCD,MAAM,CAAjDC,MAAM;MAAEC,SAAS,GAA0BF,MAAM,CAAzCE,SAAS;MAAAiB,aAAA,GAA0BnB,MAAM,CAA9BzB,KAAK;MAALA,KAAK,GAAA4C,aAAA,cAAG,GAAG,GAAAA,aAAA;MAAEC,MAAM,GAAKpB,MAAM,CAAjBoB,MAAM;IAE9C,MAAMf,IAAI,GAAG,MAAM,IAAI,CAACpB,IAAI,CAQzB,uCAAuCgB,MAAM,iBAAiB,EAAE;MACjEC,SAAS;MACTmB,KAAK,EAAE;QAAEC,YAAY,EAAE;UAAE/C,KAAK;UAAE,IAAI6C,MAAM,GAAG;YAAEA;UAAO,CAAC,GAAG,CAAC,CAAC;QAAE;MAAE;IAClE,CAAC,CAAC;IAEF,OAAO;MACLG,QAAQ,EAAE,CAAClB,IAAI,CAACmB,YAAY,IAAI,EAAE,EAAEC,GAAG,CAAEC,CAAC,KAAM;QAC9ClB,EAAE,EAAEkB,CAAC,CAAClB,EAAE;QACRmB,OAAO,EAAED,CAAC,CAACC,OAAO;QAClBC,IAAI,EAAEF,CAAC,CAACE,IAA4B;QACpCC,SAAS,EAAEH,CAAC,CAACG;MACf,CAAC,CAAC,CAAC;MACHC,UAAU,GAAAZ,oBAAA,GAAEb,IAAI,CAAC0B,cAAc,cAAAb,oBAAA,GAAnBA,oBAAA,CAAqBc,OAAO,qBAA5Bd,oBAAA,CAA8Be;IAC5C,CAAC;EACH;AACF;AAEA,SAASpC,SAASA,CAACH,IAAY,EAAW;EACxC,IAAI;IACF,OAAOH,IAAI,CAAC2C,KAAK,CAACxC,IAAI,CAAC;EACzB,CAAC,CAAC,MAAM;IACN,OAAOrB,SAAS;EAClB;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["HttpError"],"sources":["../../../src/types/index.ts"],"sourcesContent":["export type { IHttpClient, HttpRequestConfig } from './http';\nexport { HttpError } from './http';\nexport type {\n IPersonaChatService,\n ConversationResult,\n CreateConversationParams,\n EndConversationParams,\n SendMessageParams,\n SendMessageMetadata,\n AdditionalMetadata,\n ChatMessage,\n ChatMessageAttachment,\n QueryMessagesParams,\n QueryMessagesResult,\n FunctionCall,\n FunctionCallResult,\n Limitation,\n LimitationType,\n} from './service';\n"],"mappings":"AACA,SAASA,SAAS,QAAQ,QAAQ","ignoreList":[]}
1
+ {"version":3,"names":["HttpError"],"sources":["../../../src/types/index.ts"],"sourcesContent":["export type { IHttpClient, HttpRequestConfig } from './http';\nexport { HttpError } from './http';\nexport type {\n IPersonaChatService,\n ConversationResult,\n CreateConversationParams,\n EndConversationParams,\n SendMessageParams,\n SendMessageMetadata,\n AdditionalMetadata,\n ChatMessage,\n ChatMessageAttachment,\n QueryMessagesParams,\n QueryMessagesResult,\n FunctionCall,\n FunctionCallResult,\n ChatFunctionCall,\n ChatFunctionCallResult,\n Limitation,\n LimitationType,\n} from './service';\n"],"mappings":"AACA,SAASA,SAAS,QAAQ,QAAQ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../../../src/types/service.ts"],"sourcesContent":["export type FunctionCall = {\n functionCallId: string;\n name: string;\n arguments: string;\n};\n\nexport type FunctionCallResult = {\n functionCallId: string;\n result: string;\n error?: string;\n};\n\nexport type LimitationType = 'MINUTES' | 'SECONDS' | 'TOKENS';\n\nexport interface Limitation {\n type?: LimitationType;\n limit?: number;\n}\n\nexport interface ConversationResult {\n url: string;\n id: string;\n limit?: number;\n}\n\nexport interface CreateConversationParams {\n chatId: string;\n namespace: string;\n chatConfig?: object;\n /** Whether this is the visitor's first-ever conversation with the persona (drives the opening message). */\n firstConversation?: boolean;\n /** Title of the visitor's last meaningful conversation, for a returning-visitor greeting. */\n lastConversationTopic?: string;\n /** Language or locale for a new voice/video call, e.g. es or en-GB. Omit to keep the default behavior. */\n conversationLanguage?: string;\n}\n\nexport interface EndConversationParams {\n chatId: string;\n conversationId: string;\n namespace: string;\n}\n\nexport interface ChatMessageAttachment {\n fileName?: string;\n url?: string | null;\n mimeType?: string;\n textFileContent?: string | null;\n}\n\nexport interface AdditionalMetadata {\n key?: string | null;\n value?: string | null;\n excludeFromPrompt?: boolean | null;\n}\n\nexport interface SendMessageMetadata {\n additionalMetadata?: AdditionalMetadata[];\n}\n\nexport interface SendMessageParams {\n chatId: string;\n namespace: string;\n message: string;\n functionCallResults?: FunctionCallResult[];\n chatConfig?: object;\n attachments?: ChatMessageAttachment[];\n metadata?: SendMessageMetadata;\n /** Language or locale for the persona's text reply, e.g. es or en-GB. Omit to keep the default behavior. */\n conversationLanguage?: string;\n}\n\nexport interface ChatMessage {\n id: string;\n content: string;\n role: 'USER' | 'ASSISTANT';\n createdAt?: string;\n attachments?: ChatMessageAttachment[];\n}\n\nexport interface QueryMessagesParams {\n chatId: string;\n namespace: string;\n limit?: number;\n cursor?: string;\n}\n\nexport interface QueryMessagesResult {\n messages: ChatMessage[];\n nextCursor?: string;\n}\n\nexport interface IPersonaChatService {\n createVoiceConversation(\n params: CreateConversationParams,\n ): Promise<ConversationResult>;\n createInteractiveConversation(\n params: CreateConversationParams,\n ): Promise<ConversationResult>;\n endInteractiveConversation(params: EndConversationParams): Promise<void>;\n sendChatMessage(\n params: SendMessageParams,\n ): Promise<{ functionCalls?: FunctionCall[]; messages?: ChatMessage[] }>;\n queryChatMessages(params: QueryMessagesParams): Promise<QueryMessagesResult>;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["../../../src/types/service.ts"],"sourcesContent":["export type FunctionCall = {\n functionCallId: string;\n name: string;\n arguments: string;\n};\n\nexport type FunctionCallResult = {\n functionCallId: string;\n result: string;\n error?: string;\n};\n\n/** A function call as persona-chat's text chat returns it. */\nexport type ChatFunctionCall = {\n id: string;\n name: string;\n arguments?: Record<string, unknown> | null;\n};\n\n/** A function call result as persona-chat's text chat expects it. */\nexport type ChatFunctionCallResult = {\n id: string;\n name: string;\n content: string;\n success: boolean;\n};\n\nexport type LimitationType = 'MINUTES' | 'SECONDS' | 'TOKENS';\n\nexport interface Limitation {\n type?: LimitationType;\n limit?: number;\n}\n\nexport interface ConversationResult {\n url: string;\n id: string;\n limit?: number;\n}\n\nexport interface CreateConversationParams {\n chatId: string;\n namespace: string;\n chatConfig?: object;\n /** Whether this is the visitor's first-ever conversation with the persona (drives the opening message). */\n firstConversation?: boolean;\n /** Title of the visitor's last meaningful conversation, for a returning-visitor greeting. */\n lastConversationTopic?: string;\n /** Language or locale for a new voice/video call, e.g. es or en-GB. Omit to keep the default behavior. */\n conversationLanguage?: string;\n}\n\nexport interface EndConversationParams {\n chatId: string;\n conversationId: string;\n namespace: string;\n}\n\nexport interface ChatMessageAttachment {\n fileName?: string;\n url?: string | null;\n mimeType?: string;\n textFileContent?: string | null;\n}\n\nexport interface AdditionalMetadata {\n key?: string | null;\n value?: string | null;\n excludeFromPrompt?: boolean | null;\n}\n\nexport interface SendMessageMetadata {\n additionalMetadata?: AdditionalMetadata[];\n}\n\nexport interface SendMessageParams {\n chatId: string;\n namespace: string;\n message: string;\n functionCallResults?: (FunctionCallResult | ChatFunctionCallResult)[];\n chatConfig?: object;\n attachments?: ChatMessageAttachment[];\n metadata?: SendMessageMetadata;\n /** Language or locale for the persona's text reply, e.g. es or en-GB. Omit to keep the default behavior. */\n conversationLanguage?: string;\n}\n\nexport interface ChatMessage {\n id: string;\n content: string;\n role: 'USER' | 'ASSISTANT';\n createdAt?: string;\n attachments?: ChatMessageAttachment[];\n}\n\nexport interface QueryMessagesParams {\n chatId: string;\n namespace: string;\n limit?: number;\n cursor?: string;\n}\n\nexport interface QueryMessagesResult {\n messages: ChatMessage[];\n nextCursor?: string;\n}\n\nexport interface IPersonaChatService {\n createVoiceConversation(\n params: CreateConversationParams,\n ): Promise<ConversationResult>;\n createInteractiveConversation(\n params: CreateConversationParams,\n ): Promise<ConversationResult>;\n endInteractiveConversation(params: EndConversationParams): Promise<void>;\n sendChatMessage(params: SendMessageParams): Promise<{\n functionCalls?: (FunctionCall | ChatFunctionCall)[];\n messages?: ChatMessage[];\n }>;\n queryChatMessages(params: QueryMessagesParams): Promise<QueryMessagesResult>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -8,7 +8,10 @@ export type LegendsPlatformProps = {
8
8
  startupTelemetry?: StartupTelemetryOptions;
9
9
  chatId: string;
10
10
  namespace: string;
11
+ /** Server-side only: a namespace API key never reaches a browser (use personaChatService with a BearerPersonaChatService there). */
11
12
  apiKey?: string;
13
+ /** API host for the apiKey service. Defaults to https://www.wixapis.com. */
14
+ baseUrl?: string;
12
15
  personaChatService?: IPersonaChatService;
13
16
  store?: Store;
14
17
  tools?: ToolsRegistry;
@@ -1 +1 @@
1
- {"version":3,"file":"LegendsPlatform.d.ts","sourceRoot":"","sources":["../../../../src/components/LegendsPlatform/LegendsPlatform.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0B,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAuB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG/D,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,iCAAiC,CAAC;AAEzC,MAAM,MAAM,oBAAoB,GAAG;IACjC,gBAAgB,CAAC,EAAE,uBAAuB,CAAC;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,mBAAmB,CAAC;IACzC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,qBAuF1D"}
1
+ {"version":3,"file":"LegendsPlatform.d.ts","sourceRoot":"","sources":["../../../../src/components/LegendsPlatform/LegendsPlatform.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0B,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAuB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG/D,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,iCAAiC,CAAC;AAEzC,MAAM,MAAM,oBAAoB,GAAG;IACjC,gBAAgB,CAAC,EAAE,uBAAuB,CAAC;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,oIAAoI;IACpI,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,mBAAmB,CAAC;IACzC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,qBAwF1D"}
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { type Store } from 'jotai/vanilla/store';
3
+ import { QueryClient } from '@tanstack/react-query';
4
+ import type { ToolsRegistry } from '../../hooks/useTools/model/types';
5
+ import type { IPersonaChatService } from '../../types/service';
6
+ export type LegendsPlatformCoreProps = {
7
+ chatId: string;
8
+ namespace: string;
9
+ /** Required: in a browser, a BearerPersonaChatService with the caller's own token. */
10
+ personaChatService: IPersonaChatService;
11
+ tools?: ToolsRegistry;
12
+ /** Pass the same store and query client to LegendsPlatform when a call starts, to keep the chat state. */
13
+ store?: Store;
14
+ queryClient?: QueryClient;
15
+ children: React.ReactNode;
16
+ };
17
+ /**
18
+ * The text-chat providers without LiveKit, from the main entry: for a page that
19
+ * loads LiveKit only when a call starts (`@wix/legends-platform-sdk/livekit/sdk`'s
20
+ * LegendsPlatform then wraps the call, with the same store and query client).
21
+ */
22
+ export declare function LegendsPlatformCore(props: LegendsPlatformCoreProps): React.JSX.Element;
23
+ //# sourceMappingURL=LegendsPlatformCore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LegendsPlatformCore.d.ts","sourceRoot":"","sources":["../../../../src/components/LegendsPlatformCore/LegendsPlatformCore.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAuB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG/D,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,sFAAsF;IACtF,kBAAkB,EAAE,mBAAmB,CAAC;IACxC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,0GAA0G;IAC1G,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,qBA6BlE"}
@@ -0,0 +1,2 @@
1
+ export * from './LegendsPlatformCore';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/LegendsPlatformCore/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ChatFunctionCall, ChatFunctionCallResult, FunctionCall, FunctionCallResult } from '../../types';
2
+ export declare function fromChatFunctionCall(call: FunctionCall | ChatFunctionCall): FunctionCall;
3
+ export declare function toChatFunctionCallResult(result: FunctionCallResult, name: string): ChatFunctionCallResult;
4
+ //# sourceMappingURL=chatFunctionCalls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chatFunctionCalls.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTextChat/chatFunctionCalls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,sBAAsB,EACtB,YAAY,EACZ,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAErB,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,YAAY,GAAG,gBAAgB,GACpC,YAAY,CAUd;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,MAAM,GACX,sBAAsB,CAOxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"useToolAwareSend.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTextChat/useToolAwareSend.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,qBAAqB,EAErB,mBAAmB,EACpB,MAAM,aAAa,CAAC;AAMrB,MAAM,WAAW,uBAAuB;IACtC,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;CAChC;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,oBAAoB,CAAC,EAAE,MAAM,aAmCO;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACtC,QAAQ,CAAC,EAAE,mBAAmB,CAAC;CAChC,sCA4BF"}
1
+ {"version":3,"file":"useToolAwareSend.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTextChat/useToolAwareSend.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,qBAAqB,EAErB,mBAAmB,EACpB,MAAM,aAAa,CAAC;AAUrB,MAAM,WAAW,uBAAuB;IACtC,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;CAChC;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,oBAAoB,CAAC,EAAE,MAAM,aAmCO;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACtC,QAAQ,CAAC,EAAE,mBAAmB,CAAC;CAChC,sCA2CF"}
@@ -16,6 +16,10 @@ export * from './hooks/usePictureInPicture';
16
16
  export * from './hooks/useMediaPermissions';
17
17
  export * from './hooks/useTools';
18
18
  export * from './conversation/types';
19
+ export { BearerPersonaChatService } from './services/BearerPersonaChatService';
20
+ export type { BearerPersonaChatServiceOptions } from './services/BearerPersonaChatService';
21
+ export { LegendsPlatformCore } from './components/LegendsPlatformCore';
22
+ export type { LegendsPlatformCoreProps } from './components/LegendsPlatformCore';
19
23
  export { createStartupIntent, StartupAttempt, } from './startup-telemetry/attempt';
20
24
  export type { StartupIntent, StartupReport, StartupTelemetryOptions, } from './startup-telemetry/attempt';
21
25
  //# sourceMappingURL=sdk.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAExB,cAAc,qBAAq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qC,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,YAAY,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAEjF,OAAO,EACL,mBAAmB,EACnB,cAAc,GACf,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,aAAa,EACb,aAAa,EACb,uBAAuB,GACxB,MAAM,6BAA6B,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { IPersonaChatService, CreateConversationParams, ConversationResult, EndConversationParams, SendMessageParams, QueryMessagesParams, QueryMessagesResult, ChatFunctionCall, ChatMessage } from '../types';
2
+ export interface BearerPersonaChatServiceOptions {
3
+ /** API host. Defaults to https://www.wixapis.com. */
4
+ baseUrl?: string;
5
+ /**
6
+ * The caller's own access token, e.g. a visitor token minted by the Legend's
7
+ * sign-in app. Sent as the Authorization header, the way Wix's headless
8
+ * clients send it. Called for every request, so a refreshed token is used.
9
+ */
10
+ getAccessToken: () => string | Promise<string>;
11
+ /**
12
+ * Called once when a request answers 401. Refresh the token and resolve true
13
+ * to retry the request with the new token; resolve false to fail it.
14
+ */
15
+ onUnauthorized?: () => Promise<boolean>;
16
+ }
17
+ /**
18
+ * The persona-chat service for a browser: authenticated with the caller's own
19
+ * bearer token (never a namespace API key), on the same REST paths the
20
+ * Legend's own page uses for a visitor.
21
+ */
22
+ export declare class BearerPersonaChatService implements IPersonaChatService {
23
+ private readonly options;
24
+ private readonly baseUrl;
25
+ constructor(options: BearerPersonaChatServiceOptions);
26
+ private request;
27
+ private createConversation;
28
+ createVoiceConversation(params: CreateConversationParams): Promise<ConversationResult>;
29
+ createInteractiveConversation(params: CreateConversationParams): Promise<ConversationResult>;
30
+ endInteractiveConversation(params: EndConversationParams): Promise<void>;
31
+ sendChatMessage(params: SendMessageParams): Promise<{
32
+ functionCalls?: ChatFunctionCall[];
33
+ messages?: ChatMessage[];
34
+ }>;
35
+ queryChatMessages(params: QueryMessagesParams): Promise<QueryMessagesResult>;
36
+ }
37
+ //# sourceMappingURL=BearerPersonaChatService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BearerPersonaChatService.d.ts","sourceRoot":"","sources":["../../../src/services/BearerPersonaChatService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EAEZ,MAAM,UAAU,CAAC;AAGlB,MAAM,WAAW,+BAA+B;IAC9C,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,cAAc,EAAE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CACzC;AA8CD;;;;GAIG;AACH,qBAAa,wBAAyB,YAAW,mBAAmB;IAGtD,OAAO,CAAC,QAAQ,CAAC,OAAO;IAFpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAEJ,OAAO,EAAE,+BAA+B;YAIvD,OAAO;YAqCP,kBAAkB;IA8BhC,uBAAuB,CACrB,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,kBAAkB,CAAC;IAI9B,6BAA6B,CAC3B,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,kBAAkB,CAAC;IAIxB,0BAA0B,CAC9B,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,IAAI,CAAC;IAaV,eAAe,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC;QACxD,aAAa,CAAC,EAAE,gBAAgB,EAAE,CAAC;QACnC,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;KAC1B,CAAC;IA8BI,iBAAiB,CACrB,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,mBAAmB,CAAC;CAmBhC"}
@@ -1,14 +1,24 @@
1
- import type { IPersonaChatService, CreateConversationParams, ConversationResult, EndConversationParams, SendMessageParams, QueryMessagesParams, QueryMessagesResult, FunctionCall, ChatMessage } from '../types';
1
+ import type { IPersonaChatService, CreateConversationParams, ConversationResult, EndConversationParams, SendMessageParams, QueryMessagesParams, QueryMessagesResult, FunctionCall, ChatFunctionCall, ChatMessage } from '../types';
2
+ export declare const DEFAULT_BASE_URL = "https://www.wixapis.com";
3
+ export interface FetchPersonaChatServiceOptions {
4
+ /** API host, e.g. a local or test gateway. Defaults to https://www.wixapis.com. */
5
+ baseUrl?: string;
6
+ }
2
7
  export declare class FetchPersonaChatService implements IPersonaChatService {
3
8
  private readonly apiKey;
4
- constructor(apiKey: string);
9
+ private readonly baseUrl;
10
+ /**
11
+ * Server side only: a namespace API key skips owner checks and must never
12
+ * reach a browser. A browser uses BearerPersonaChatService with a visitor token.
13
+ */
14
+ constructor(apiKey: string, options?: FetchPersonaChatServiceOptions);
5
15
  private headers;
6
16
  private post;
7
17
  createVoiceConversation(params: CreateConversationParams): Promise<ConversationResult>;
8
18
  createInteractiveConversation(params: CreateConversationParams): Promise<ConversationResult>;
9
19
  endInteractiveConversation(params: EndConversationParams): Promise<void>;
10
20
  sendChatMessage(params: SendMessageParams): Promise<{
11
- functionCalls?: FunctionCall[];
21
+ functionCalls?: (FunctionCall | ChatFunctionCall)[];
12
22
  messages?: ChatMessage[];
13
23
  }>;
14
24
  queryChatMessages(params: QueryMessagesParams): Promise<QueryMessagesResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"FetchPersonaChatService.d.ts","sourceRoot":"","sources":["../../../src/services/FetchPersonaChatService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,WAAW,EAEZ,MAAM,UAAU,CAAC;AAmBlB,qBAAa,uBAAwB,YAAW,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AC3B,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,kBAAkB,CAAC;IAuBxB,6BAA6B,CACjC,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,kBAAkB,CAAC;IAuBxB,0BAA0B,CAC9B,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,IAAI,CAAC;IAWV,eAAe,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC;QACxD,aAAa,CAAC,EAAE,CAAC,YAAY,GAAG,gBAAgB,CAAC,EAAE,CAAC;QACpD,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;KAC1B,CAAC;IAwBI,iBAAiB,CACrB,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,mBAAmB,CAAC;CA0BhC"}
@@ -1,4 +1,4 @@
1
1
  export type { IHttpClient, HttpRequestConfig } from './http';
2
2
  export { HttpError } from './http';
3
- export type { IPersonaChatService, ConversationResult, CreateConversationParams, EndConversationParams, SendMessageParams, SendMessageMetadata, AdditionalMetadata, ChatMessage, ChatMessageAttachment, QueryMessagesParams, QueryMessagesResult, FunctionCall, FunctionCallResult, Limitation, LimitationType, } from './service';
3
+ export type { IPersonaChatService, ConversationResult, CreateConversationParams, EndConversationParams, SendMessageParams, SendMessageMetadata, AdditionalMetadata, ChatMessage, ChatMessageAttachment, QueryMessagesParams, QueryMessagesResult, FunctionCall, FunctionCallResult, ChatFunctionCall, ChatFunctionCallResult, Limitation, LimitationType, } from './service';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,cAAc,GACf,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,UAAU,EACV,cAAc,GACf,MAAM,WAAW,CAAC"}
@@ -8,6 +8,19 @@ export type FunctionCallResult = {
8
8
  result: string;
9
9
  error?: string;
10
10
  };
11
+ /** A function call as persona-chat's text chat returns it. */
12
+ export type ChatFunctionCall = {
13
+ id: string;
14
+ name: string;
15
+ arguments?: Record<string, unknown> | null;
16
+ };
17
+ /** A function call result as persona-chat's text chat expects it. */
18
+ export type ChatFunctionCallResult = {
19
+ id: string;
20
+ name: string;
21
+ content: string;
22
+ success: boolean;
23
+ };
11
24
  export type LimitationType = 'MINUTES' | 'SECONDS' | 'TOKENS';
12
25
  export interface Limitation {
13
26
  type?: LimitationType;
@@ -52,7 +65,7 @@ export interface SendMessageParams {
52
65
  chatId: string;
53
66
  namespace: string;
54
67
  message: string;
55
- functionCallResults?: FunctionCallResult[];
68
+ functionCallResults?: (FunctionCallResult | ChatFunctionCallResult)[];
56
69
  chatConfig?: object;
57
70
  attachments?: ChatMessageAttachment[];
58
71
  metadata?: SendMessageMetadata;
@@ -81,7 +94,7 @@ export interface IPersonaChatService {
81
94
  createInteractiveConversation(params: CreateConversationParams): Promise<ConversationResult>;
82
95
  endInteractiveConversation(params: EndConversationParams): Promise<void>;
83
96
  sendChatMessage(params: SendMessageParams): Promise<{
84
- functionCalls?: FunctionCall[];
97
+ functionCalls?: (FunctionCall | ChatFunctionCall)[];
85
98
  messages?: ChatMessage[];
86
99
  }>;
87
100
  queryChatMessages(params: QueryMessagesParams): Promise<QueryMessagesResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/types/service.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE9D,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2GAA2G;IAC3G,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,6FAA6F;IAC7F,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,0GAA0G;IAC1G,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,qBAAqB;IACpC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B,GAAG,OAAO,CAAC;QAClD,aAAa,CAAC,EAAE,CAAC,YAAY,GAAG,gBAAgB,CAAC,EAAE,CAAC;QACpD,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;KAC1B,CAAC,CAAC;IACH,iBAAiB,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAC9E"}
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.34.0",
2
+ "version": "1.36.0",
3
3
  "name": "@wix/legends-platform-sdk",
4
4
  "license": "MIT",
5
5
  "author": {
@@ -103,5 +103,5 @@
103
103
  "wallaby": {
104
104
  "autoDetect": true
105
105
  },
106
- "falconPackageHash": "654211ce8164d8cfba33c86c9224c804503759a0ec5df717134cce86"
106
+ "falconPackageHash": "4f974d90de9401ebfbe0a6cd71f0ee0242f5fa87cb45ad31825e1c22"
107
107
  }