obi-sdk 0.17.0 → 0.18.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 (58) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +62 -0
  3. package/dist/obi-sdk.standalone.iife.js +62 -2646
  4. package/dist/src/loader.d.ts +11 -0
  5. package/dist/src/mount.d.ts +1 -0
  6. package/dist/src/sdk.d.ts +77 -0
  7. package/dist/src/types.d.ts +12 -0
  8. package/dist/src/widget.d.ts +6 -0
  9. package/package.json +13 -31
  10. package/dist/core/config-logger.d.ts +0 -30
  11. package/dist/core/constants.d.ts +0 -1
  12. package/dist/core/index.d.ts +0 -3
  13. package/dist/core/init.d.ts +0 -1
  14. package/dist/core/types.d.ts +0 -46
  15. package/dist/empty-loader.d.ts +0 -5
  16. package/dist/index.d.ts +0 -2
  17. package/dist/loader.d.ts +0 -33
  18. package/dist/modular/chunks/index-a481947c.js +0 -6
  19. package/dist/modular/chunks/index-a481947c.js.map +0 -1
  20. package/dist/modular/chunks/obi-widget-eab5da7a.js +0 -22450
  21. package/dist/modular/chunks/obi-widget-eab5da7a.js.map +0 -1
  22. package/dist/modular/chunks/types-f38a47f6.js +0 -22431
  23. package/dist/modular/chunks/types-f38a47f6.js.map +0 -1
  24. package/dist/modular/core.js +0 -4086
  25. package/dist/modular/core.js.map +0 -1
  26. package/dist/modular/index.js +0 -361
  27. package/dist/modular/index.js.map +0 -1
  28. package/dist/modular/ui.js +0 -110
  29. package/dist/modular/ui.js.map +0 -1
  30. package/dist/obi-sdk.standalone.iife.js.map +0 -1
  31. package/dist/react.d.ts +0 -6
  32. package/dist/react.es.js +0 -32910
  33. package/dist/react.es.js.map +0 -1
  34. package/dist/react.umd.js +0 -2843
  35. package/dist/react.umd.js.map +0 -1
  36. package/dist/ui/components/audio-equalizer.d.ts +0 -21
  37. package/dist/ui/components/courses/course-modal.d.ts +0 -20
  38. package/dist/ui/components/courses/courses.d.ts +0 -31
  39. package/dist/ui/components/courses/index.d.ts +0 -1
  40. package/dist/ui/components/dot-loader.d.ts +0 -20
  41. package/dist/ui/components/icons.d.ts +0 -6
  42. package/dist/ui/components/index.d.ts +0 -10
  43. package/dist/ui/components/nav-icon.d.ts +0 -10
  44. package/dist/ui/components/navigation-bar.d.ts +0 -19
  45. package/dist/ui/components/obi-widget/index.d.ts +0 -1
  46. package/dist/ui/components/obi-widget/obi-widget.d.ts +0 -104
  47. package/dist/ui/components/obi-widget/user-update.test.d.ts +0 -1
  48. package/dist/ui/components/searching-loader.d.ts +0 -5
  49. package/dist/ui/components/status-widget.d.ts +0 -8
  50. package/dist/ui/index.d.ts +0 -1
  51. package/dist/utils/index.d.ts +0 -2
  52. package/dist/utils/storage.d.ts +0 -45
  53. package/index.d.ts +0 -8
  54. /package/dist/{test/setup.d.ts → src/empty.test.d.ts} +0 -0
  55. /package/dist/{ui/components/obi-widget/obi-widget.test.d.ts → src/index.d.ts} +0 -0
  56. /package/dist/{sentry.d.ts → src/sentry.d.ts} +0 -0
  57. /package/dist/{utils → src}/url-matcher.d.ts +0 -0
  58. /package/dist/{utils → src}/url-matcher.test.d.ts +0 -0
@@ -0,0 +1,11 @@
1
+ import { ObiSDK } from "./sdk";
2
+ /**
3
+ * Load the Obi SDK onto the current window. This takes care of any queued commands that may have
4
+ * been added to the window object by the loader script, and assigns the SDK class instance to the
5
+ * window object at "ObiSDK".
6
+ */
7
+ export declare function loadObiSDK(appToken?: string): Promise<ObiSDK | undefined>;
8
+ export declare function loadObiSDKWithWindow({ appToken, window, }: {
9
+ appToken?: string;
10
+ window: any;
11
+ }): Promise<ObiSDK | undefined>;
@@ -0,0 +1 @@
1
+ export declare function mountWidget(sdk?: any): void;
@@ -0,0 +1,77 @@
1
+ import { EventEmitter } from "eventemitter3";
2
+ import type { Identity } from "@obi/obi-client";
3
+ import { ObiClient } from "@obi/obi-client";
4
+ import { Command, CommandType, Config } from "./types";
5
+ export declare const PLAN_URL_PARAM = "49206C6F7665204F6269_session";
6
+ export declare const STORAGE_KEY = "obi-url-params";
7
+ export type ObiSDKEvents = {
8
+ initialised: () => void;
9
+ error: (err: Error) => void;
10
+ };
11
+ export type InitialiseArgs = {
12
+ queuedCommands?: Command[];
13
+ };
14
+ export declare class ObiSDK extends EventEmitter {
15
+ client: ObiClient;
16
+ isActive: boolean;
17
+ primaryColour: string;
18
+ private commandQueue;
19
+ /** HACK: Need to prevent initialisation from being called if resumed. */
20
+ private _resumed;
21
+ /**
22
+ * Creates a client that should persist for the lifetime of the SDK.
23
+ * Resumes an ongoing session if one exists.
24
+ */
25
+ constructor(appToken: string);
26
+ initialise(args?: InitialiseArgs): Promise<void>;
27
+ /**
28
+ * Update the SDK configuration. This is typically called before a plan starts,
29
+ * but it is possible to update the configuration during a plan.
30
+ */
31
+ updateConfig(config: Config): void;
32
+ /**
33
+ * Update the SDK activity state. Activity controls whether the SDK is continuously
34
+ * visible or not.
35
+ * Ignores updates if the active state is undefined or the same as the current active state.
36
+ */
37
+ updateActive(isActive?: boolean): void;
38
+ /**
39
+ * Update the SDK primary colour. This is typically called before a plan starts,
40
+ * but it is possible to update the primary colour during a plan.
41
+ * Ignores updates if the primary colour is undefined or the same as the current primary colour.
42
+ */
43
+ updatePrimaryColour(primaryColour?: string): void;
44
+ /**
45
+ * Update the identity of the onboardee. This is typically called before a plan starts,
46
+ * but it is possible to update the identity during a plan.
47
+ * Ignores updates if the identity is undefined or the same as the current identity.
48
+ */
49
+ updateIdentity(identity?: Identity | null): void;
50
+ /**
51
+ * Say a message to the onboardee.
52
+ */
53
+ say(message: string): Promise<void>;
54
+ /**
55
+ * Start a new session.
56
+ */
57
+ startSession(): Promise<void>;
58
+ /**
59
+ * Dispatch all queued commands in the order they were added.
60
+ */
61
+ dispatchCommandQueue(): void;
62
+ /**
63
+ * This gets set on the window object by the loader script. It is used as an abstraction to allow
64
+ * users to call commands without having to wait for the client to be ready. This works in tandem
65
+ * with the loader script, which will queue any commands that are called before the client is ready.
66
+ */
67
+ dispatchCommand: (commandType: CommandType, ...args: any[]) => void;
68
+ /**
69
+ * Parse passive initiation parameters from the URL and/or local storage.
70
+ * Passive initiation parameters are values that indicate a plan & app token to use immediately.
71
+ */
72
+ parsePassiveParams(): string | null;
73
+ mountWidget(): void;
74
+ captureScreen(): Promise<string>;
75
+ save(): void;
76
+ load(): string | null;
77
+ }
@@ -0,0 +1,12 @@
1
+ import { Identity } from "@obi/obi-client";
2
+ export type CommandType = "update" | "say" | "endSession";
3
+ export type Command = {
4
+ type: CommandType;
5
+ args: any[];
6
+ };
7
+ export type Config = {
8
+ apiKey?: string;
9
+ isActive?: boolean;
10
+ primaryColour?: string;
11
+ user?: Identity;
12
+ };
@@ -0,0 +1,6 @@
1
+ import { ObiSDK } from "./sdk";
2
+ export type WidgetProps = {
3
+ sdk: ObiSDK;
4
+ shadowHost: HTMLDivElement;
5
+ };
6
+ export declare function Widget(props: WidgetProps): import("preact").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "obi-sdk",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "JavaScript SDK for Obi",
5
5
  "type": "module",
6
6
  "main": "dist/obi-sdk.umd.js",
@@ -8,18 +8,13 @@
8
8
  "types": "index.d.ts",
9
9
  "exports": {
10
10
  ".": {
11
- "types": "./index.d.ts",
11
+ "types": "./dist/index.d.ts",
12
12
  "import": "./dist/obi-sdk.es.js",
13
13
  "require": "./dist/obi-sdk.umd.js"
14
- },
15
- "./react": {
16
- "types": "./dist/react.d.ts",
17
- "import": "./dist/react.es.js"
18
14
  }
19
15
  },
20
16
  "files": [
21
- "dist",
22
- "index.d.ts"
17
+ "dist"
23
18
  ],
24
19
  "keywords": [
25
20
  "obi",
@@ -39,30 +34,20 @@
39
34
  "@sentry/browser": "^9.23.0",
40
35
  "@sentry/vite-plugin": "^3.5.0",
41
36
  "@types/jsdom": "^21.1.7",
37
+ "eventemitter3": "^5.0.1",
42
38
  "html2canvas-pro": "^1.5.11",
43
39
  "lit": "^3.0.0",
40
+ "preact": ">=10.0.0",
44
41
  "ts-pattern": "^5.7.0",
45
42
  "zod": "^3.22.0",
46
43
  "@obi/obi-client": "0.7.0",
47
- "@obi/obi-session": "0.3.8",
48
- "@obi/obi-components": "0.1.0",
49
- "@obi/utils": "0.2.0"
50
- },
51
- "peerDependencies": {
52
- "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
53
- "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
54
- },
55
- "peerDependenciesMeta": {
56
- "react": {
57
- "optional": true
58
- },
59
- "react-dom": {
60
- "optional": true
61
- }
44
+ "@obi/utils": "0.2.0",
45
+ "@obi/obi-components": "0.1.0"
62
46
  },
63
47
  "devDependencies": {
64
48
  "@chromatic-com/storybook": "^4.0.0-0",
65
49
  "@eslint/js": "^8.56.0",
50
+ "@preact/preset-vite": "^2.10.1",
66
51
  "@storybook/addon-docs": "^9.0.0",
67
52
  "@storybook/web-components-vite": "^9.0.0",
68
53
  "@types/node": "^22.15.18",
@@ -70,7 +55,6 @@
70
55
  "@types/react-dom": "^18.0.0",
71
56
  "@typescript-eslint/eslint-plugin": "^6.0.0",
72
57
  "@typescript-eslint/parser": "^6.0.0",
73
- "@vitejs/plugin-react": "^4.0.3",
74
58
  "@vitest/coverage-v8": "^2.1.8",
75
59
  "@vitest/ui": "^2.1.8",
76
60
  "eslint": "^8.45.0",
@@ -89,13 +73,11 @@
89
73
  "vitest": "^2.1.8"
90
74
  },
91
75
  "scripts": {
92
- "dev": "vite",
93
- "build": "pnpm build:old && pnpm build:react && pnpm build:modular && pnpm build:standalone",
94
- "build:old": "vite build",
95
- "build:standalone": "vite build --config vite.standalone.config.js",
96
- "build:modular": "vite build --config vite.modular.config.js",
97
- "build:react": "vite build --config vite.react.config.ts",
98
- "build:publish": "pnpm build && pnpm build:react && pnpm build:modular && pnpm build:standalone",
76
+ "dev": "vite --mode development",
77
+ "dev:staging": "VITE_API_BASE_URL=https://staging.coragents.ai vite --mode staging",
78
+ "build": "vite build --mode production",
79
+ "build:staging": "VITE_API_BASE_URL=https://staging.coragents.ai vite build --mode staging",
80
+ "build:publish": "pnpm build --mode production",
99
81
  "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
100
82
  "format": "prettier --write \"src/**/*.{ts,tsx}\"",
101
83
  "preview": "vite preview",
@@ -1,30 +0,0 @@
1
- import { ObiAssistantConfig } from "../types/sdk";
2
- export interface ConfigLogEntry {
3
- timestamp: number;
4
- source: 'initial' | 'update';
5
- previousConfig: ObiAssistantConfig | null;
6
- newConfig: ObiAssistantConfig;
7
- diff: ConfigDiff;
8
- }
9
- export interface ConfigDiff {
10
- added: Record<string, any>;
11
- modified: Record<string, {
12
- from: any;
13
- to: any;
14
- }>;
15
- removed: Record<string, any>;
16
- }
17
- export declare class ConfigLogger {
18
- private history;
19
- private currentConfig;
20
- logInitialConfig(config: ObiAssistantConfig): void;
21
- logConfigUpdate(newConfig: ObiAssistantConfig): void;
22
- getHistory(): ConfigLogEntry[];
23
- getLatest(): ObiAssistantConfig | null;
24
- getDiff(index: number): ConfigDiff | null;
25
- clear(): void;
26
- getFormattedHistory(): string;
27
- private deepClone;
28
- private calculateDiff;
29
- private isEqual;
30
- }
@@ -1 +0,0 @@
1
- export declare const API_BASE_URL: string;
@@ -1,3 +0,0 @@
1
- export * from "./types";
2
- export * from "./constants";
3
- export { SDKState } from "@obi/obi-session";
@@ -1 +0,0 @@
1
- export declare const initializeObiWidget: () => Promise<void>;
@@ -1,46 +0,0 @@
1
- import { z } from "zod";
2
- export declare const ObiSDKConfigSchema: z.ZodObject<{
3
- apiKey: z.ZodOptional<z.ZodString>;
4
- enableVoice: z.ZodDefault<z.ZodBoolean>;
5
- enableScreenCapture: z.ZodDefault<z.ZodBoolean>;
6
- debug: z.ZodDefault<z.ZodBoolean>;
7
- user: z.ZodOptional<z.ZodObject<{
8
- id: z.ZodString;
9
- email: z.ZodOptional<z.ZodString>;
10
- metadata: z.ZodOptional<z.ZodAny>;
11
- }, "strip", z.ZodTypeAny, {
12
- id: string;
13
- email?: string | undefined;
14
- metadata?: any;
15
- }, {
16
- id: string;
17
- email?: string | undefined;
18
- metadata?: any;
19
- }>>;
20
- }, "strip", z.ZodTypeAny, {
21
- debug: boolean;
22
- enableVoice: boolean;
23
- enableScreenCapture: boolean;
24
- apiKey?: string | undefined;
25
- user?: {
26
- id: string;
27
- email?: string | undefined;
28
- metadata?: any;
29
- } | undefined;
30
- }, {
31
- apiKey?: string | undefined;
32
- debug?: boolean | undefined;
33
- enableVoice?: boolean | undefined;
34
- enableScreenCapture?: boolean | undefined;
35
- user?: {
36
- id: string;
37
- email?: string | undefined;
38
- metadata?: any;
39
- } | undefined;
40
- }>;
41
- export type ObiSDKConfig = z.infer<typeof ObiSDKConfigSchema>;
42
- export interface ObiError {
43
- code: string;
44
- message: string;
45
- details?: unknown;
46
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * @deprecated The loader functionality has been moved to a separate package.
3
- * Please install and use the 'obi-loader' package instead.
4
- */
5
- export declare const initObi: () => never;
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export { ObiWidget } from "./ui/components/obi-widget";
2
- import "./core/init";
package/dist/loader.d.ts DELETED
@@ -1,33 +0,0 @@
1
- /**
2
- * Obi Widget Loader Script
3
- *
4
- * This script dynamically loads the Obi Widget web component on any webpage
5
- * with a simple script tag inclusion.
6
- */
7
- interface ObiWidgetConfig {
8
- apiKey: string;
9
- position?: "bottom-right" | "bottom-left" | "bottom-center" | "top-right" | "top-left" | "top-center" | "middle-left" | "middle-right";
10
- user?: {
11
- id: string;
12
- email?: string;
13
- metadata?: Record<string, any>;
14
- } | null;
15
- isActive?: boolean;
16
- linkOnlyAccess?: boolean;
17
- showMenu?: boolean;
18
- primaryColor?: string;
19
- urlBlacklist?: string[];
20
- }
21
- declare class ObiWidgetLoader {
22
- private config;
23
- private widget;
24
- constructor(config?: Partial<ObiWidgetConfig>);
25
- private init;
26
- private loadScript;
27
- private fetchLatestVersion;
28
- private createWidget;
29
- private initializeWidget;
30
- initialize(): void;
31
- getWidget(): HTMLElement | null;
32
- }
33
- export { ObiWidgetLoader };
@@ -1,6 +0,0 @@
1
- import { O } from "./obi-widget-eab5da7a.js";
2
- import "./types-f38a47f6.js";
3
- export {
4
- O as ObiWidget
5
- };
6
- //# sourceMappingURL=index-a481947c.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-a481947c.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}