@cimulate/copilot-sdk 3.8.0 → 3.10.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 (28) hide show
  1. package/README.md +16 -0
  2. package/dist/{bundle.cimulate.copilot-sdk.4785f073.umd.js → bundle.cimulate.copilot-sdk.3dd9816e.umd.js} +2 -2
  3. package/dist/{bundle.cimulate.copilot-sdk.beae54c9.cjs.js.map → bundle.cimulate.copilot-sdk.3dd9816e.umd.js.map} +1 -1
  4. package/dist/{bundle.cimulate.copilot-sdk.270124b4.esm.js → bundle.cimulate.copilot-sdk.6b5f7916.esm.js} +2 -2
  5. package/dist/{bundle.cimulate.copilot-sdk.270124b4.esm.js.map → bundle.cimulate.copilot-sdk.6b5f7916.esm.js.map} +1 -1
  6. package/dist/{bundle.cimulate.copilot-sdk.beae54c9.cjs.js → bundle.cimulate.copilot-sdk.d76caf1d.cjs.js} +2 -2
  7. package/dist/{bundle.cimulate.copilot-sdk.4785f073.umd.js.map → bundle.cimulate.copilot-sdk.d76caf1d.cjs.js.map} +1 -1
  8. package/dist/index.cjs.js +1 -1
  9. package/dist/index.cjs.js.map +1 -1
  10. package/dist/index.esm.js +1 -1
  11. package/dist/index.esm.js.map +1 -1
  12. package/dist/index.umd.js +1 -1
  13. package/dist/index.umd.js.map +1 -1
  14. package/dist/types/copilot.d.ts +4 -1
  15. package/dist/types/model/ConversationEvents.d.ts +8 -0
  16. package/dist/types/model/CopilotAPIEvent.d.ts +2 -1
  17. package/dist/types/model/CopilotEvent.d.ts +2 -1
  18. package/dist/types/model/RefinedBrowse.d.ts +16 -0
  19. package/dist/types/model/ReturnedFields.d.ts +1 -0
  20. package/dist/types/model/index.d.ts +2 -0
  21. package/package.json +1 -1
  22. package/src/copilot.ts +23 -0
  23. package/src/model/ConversationEvents.ts +9 -0
  24. package/src/model/CopilotAPIEvent.ts +2 -0
  25. package/src/model/CopilotEvent.ts +2 -1
  26. package/src/model/RefinedBrowse.ts +17 -0
  27. package/src/model/ReturnedFields.ts +1 -0
  28. package/src/model/index.ts +2 -0
@@ -0,0 +1,8 @@
1
+ interface ConversationEvents {
2
+ conversationId: string;
3
+ limit?: number;
4
+ since?: string;
5
+ includeEvents?: string[];
6
+ excludeEvents?: string[];
7
+ }
8
+ export { ConversationEvents };
@@ -11,7 +11,8 @@ import { FollowUp } from "./FollowUp";
11
11
  import { Inquiry } from "./Inquiry";
12
12
  import { PartialInquiry } from "./PartialInquiry";
13
13
  import { Progress } from "./Progress";
14
+ import { RefinedBrowse } from "./RefinedBrowse";
14
15
  import { RefinedSearch } from "./RefinedSearch";
15
16
  import { ReturnedFields } from "./ReturnedFields";
16
- export type CopilotAPIEvent<TReturnedFields extends ReturnedFields = ReturnedFields> = ConnectAck | ConnectError | DisplayProducts<TReturnedFields> | Done | CopilotError | FollowUp | Inquiry | PartialInquiry | Progress | RefinedSearch<TReturnedFields>;
17
+ export type CopilotAPIEvent<TReturnedFields extends ReturnedFields = ReturnedFields> = ConnectAck | ConnectError | DisplayProducts<TReturnedFields> | Done | CopilotError | FollowUp | Inquiry | PartialInquiry | Progress | RefinedBrowse<TReturnedFields> | RefinedSearch<TReturnedFields>;
17
18
  export type CopilotEventName = CopilotAPIEvent["name"];
@@ -6,6 +6,7 @@ import { Done } from './Done';
6
6
  import { FollowUp } from './FollowUp';
7
7
  import { Inquiry } from './Inquiry';
8
8
  import { Progress } from './Progress';
9
+ import { RefinedBrowse } from './RefinedBrowse';
9
10
  import { RefinedSearch } from './RefinedSearch';
10
11
  import { ReturnedFields } from "./ReturnedFields";
11
12
  interface CopilotEvent<TReturnedFields extends ReturnedFields = ReturnedFields> {
@@ -13,7 +14,7 @@ interface CopilotEvent<TReturnedFields extends ReturnedFields = ReturnedFields>
13
14
  sessionId: string;
14
15
  name: string;
15
16
  eventSourceId: string;
16
- data: ConnectAck | FollowUp | Inquiry | DisplayProducts<TReturnedFields> | RefinedSearch<TReturnedFields> | Progress | Done | CopilotError;
17
+ data: ConnectAck | FollowUp | Inquiry | DisplayProducts<TReturnedFields> | RefinedBrowse<TReturnedFields> | RefinedSearch<TReturnedFields> | Progress | Done | CopilotError;
17
18
  createdAt: string;
18
19
  metadata: CommonMetadata;
19
20
  }
@@ -0,0 +1,16 @@
1
+ import { BrowseParams } from './BrowseParams';
2
+ import { Facet } from './Facet';
3
+ import { ReturnedFields } from "./ReturnedFields";
4
+ interface RefinedBrowse<TReturnedFields extends ReturnedFields = ReturnedFields> {
5
+ sessionId: string;
6
+ id: string;
7
+ createdAt: string;
8
+ eventSourceId: string;
9
+ message: string;
10
+ name: 'refined_browse';
11
+ browseParams: BrowseParams;
12
+ hits?: TReturnedFields;
13
+ totalHits?: number;
14
+ facets?: Facet[];
15
+ }
16
+ export { RefinedBrowse };
@@ -2,5 +2,6 @@
2
2
  * @generic
3
3
  * @overrides DisplayProducts.products
4
4
  * @overrides RefinedSearch.hits
5
+ * @overrides RefinedBrowse.hits
5
6
  */
6
7
  export type ReturnedFields = Record<string, any>[];
@@ -7,6 +7,7 @@ export * from './CommonRequiredFields';
7
7
  export * from './ConnectAck';
8
8
  export * from './ConnectAckMetadata';
9
9
  export * from './ConnectError';
10
+ export * from './ConversationEvents';
10
11
  export * from './ConversationReset';
11
12
  export * from './ConversationResetAck';
12
13
  export * from './CopilotApiAck';
@@ -36,6 +37,7 @@ export * from './ProductViewAck';
36
37
  export * from './ProductViewSuggestion';
37
38
  export * from './Progress';
38
39
  export * from './ProgressToolKwargs';
40
+ export * from './RefinedBrowse';
39
41
  export * from './RefinedSearch';
40
42
  export * from './ReturnedFields';
41
43
  export * from './SearchParams';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cimulate/copilot-sdk",
3
- "version": "3.8.0",
3
+ "version": "3.10.0",
4
4
  "description": "A lightweight API client SDK for Cimulate Copilot",
5
5
  "files": [
6
6
  "dist/**",
package/src/copilot.ts CHANGED
@@ -9,7 +9,9 @@ import type {
9
9
  CopilotBrowse,
10
10
  CopilotBrowseAck,
11
11
  ConnectError,
12
+ ConversationEvents,
12
13
  CopilotAPIEvent,
14
+ CopilotEvent,
13
15
  CopilotEventName,
14
16
  CopilotSearch,
15
17
  CopilotSearchAck,
@@ -38,6 +40,7 @@ interface CommonOptions {
38
40
  }
39
41
 
40
42
  type CimulateCopilotOptions = (ApiKeyAuth | ApiTokenAuth) & CommonOptions;
43
+ type CopilotEvents = CopilotEvent[]
41
44
 
42
45
  const socketDefaults: SocketIOOptions = {
43
46
  path: "/api/v1/socket.io",
@@ -328,6 +331,26 @@ export default class CimulateCopilot<
328
331
  });
329
332
  }
330
333
 
334
+ async getConversationEvents(
335
+ args: ConversationEvents
336
+ ): Promise<CopilotEvents>;
337
+ async getConversationEvents(
338
+ args: ConversationEvents,
339
+ callback?: (events: CopilotEvents) => void
340
+ ): Promise<void>;
341
+ async getConversationEvents(
342
+ args: ConversationEvents,
343
+ callback?: (events: CopilotEvents) => void
344
+ ): Promise<CopilotEvents | void> {
345
+ return new Promise((resolve) => {
346
+ this.socket.emit("conversation_events", args, (response: CopilotEvents) => {
347
+ if (callback) callback(response);
348
+ // TODO - error handling
349
+ resolve(response as CopilotEvents);
350
+ });
351
+ });
352
+ }
353
+
331
354
  on<E extends CopilotEventName>(
332
355
  name: E,
333
356
  handler: (event: Extract<CopilotAPIEvent<T>, { name: E }>) => void
@@ -0,0 +1,9 @@
1
+
2
+ interface ConversationEvents {
3
+ conversationId: string;
4
+ limit?: number;
5
+ since?: string;
6
+ includeEvents?: string[];
7
+ excludeEvents?: string[];
8
+ }
9
+ export { ConversationEvents };
@@ -11,6 +11,7 @@ import { FollowUp } from "./FollowUp";
11
11
  import { Inquiry } from "./Inquiry";
12
12
  import { PartialInquiry } from "./PartialInquiry";
13
13
  import { Progress } from "./Progress";
14
+ import { RefinedBrowse } from "./RefinedBrowse";
14
15
  import { RefinedSearch } from "./RefinedSearch";
15
16
  import { ReturnedFields } from "./ReturnedFields";
16
17
 
@@ -26,6 +27,7 @@ export type CopilotAPIEvent<
26
27
  | Inquiry
27
28
  | PartialInquiry
28
29
  | Progress
30
+ | RefinedBrowse<TReturnedFields>
29
31
  | RefinedSearch<TReturnedFields>;
30
32
 
31
33
  export type CopilotEventName = CopilotAPIEvent["name"];
@@ -6,6 +6,7 @@ import { Done } from './Done';
6
6
  import { FollowUp } from './FollowUp';
7
7
  import { Inquiry } from './Inquiry';
8
8
  import { Progress } from './Progress';
9
+ import { RefinedBrowse } from './RefinedBrowse';
9
10
  import { RefinedSearch } from './RefinedSearch';
10
11
  import { ReturnedFields } from "./ReturnedFields";
11
12
 
@@ -14,7 +15,7 @@ interface CopilotEvent<TReturnedFields extends ReturnedFields = ReturnedFields>
14
15
  sessionId: string;
15
16
  name: string;
16
17
  eventSourceId: string;
17
- data: ConnectAck | FollowUp | Inquiry | DisplayProducts<TReturnedFields> | RefinedSearch<TReturnedFields> | Progress | Done | CopilotError;
18
+ data: ConnectAck | FollowUp | Inquiry | DisplayProducts<TReturnedFields> | RefinedBrowse<TReturnedFields> | RefinedSearch<TReturnedFields> | Progress | Done | CopilotError;
18
19
  createdAt: string;
19
20
  metadata: CommonMetadata;
20
21
  }
@@ -0,0 +1,17 @@
1
+ import { BrowseParams } from './BrowseParams';
2
+ import { Facet } from './Facet';
3
+ import { ReturnedFields } from "./ReturnedFields";
4
+
5
+ interface RefinedBrowse<TReturnedFields extends ReturnedFields = ReturnedFields> {
6
+ sessionId: string;
7
+ id: string;
8
+ createdAt: string;
9
+ eventSourceId: string;
10
+ message: string;
11
+ name: 'refined_browse';
12
+ browseParams: BrowseParams;
13
+ hits?: TReturnedFields;
14
+ totalHits?: number;
15
+ facets?: Facet[];
16
+ }
17
+ export { RefinedBrowse };
@@ -2,5 +2,6 @@
2
2
  * @generic
3
3
  * @overrides DisplayProducts.products
4
4
  * @overrides RefinedSearch.hits
5
+ * @overrides RefinedBrowse.hits
5
6
  */
6
7
  export type ReturnedFields = Record<string, any>[];
@@ -7,6 +7,7 @@ export * from './CommonRequiredFields';
7
7
  export * from './ConnectAck';
8
8
  export * from './ConnectAckMetadata';
9
9
  export * from './ConnectError';
10
+ export * from './ConversationEvents';
10
11
  export * from './ConversationReset';
11
12
  export * from './ConversationResetAck';
12
13
  export * from './CopilotApiAck';
@@ -36,6 +37,7 @@ export * from './ProductViewAck';
36
37
  export * from './ProductViewSuggestion';
37
38
  export * from './Progress';
38
39
  export * from './ProgressToolKwargs';
40
+ export * from './RefinedBrowse';
39
41
  export * from './RefinedSearch';
40
42
  export * from './ReturnedFields';
41
43
  export * from './SearchParams';