chatbotlite 0.2.0 → 0.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chatbotlite",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Drop-in AI chatbot SDK + React widget. Multi-LLM with fallback, business config, anti-hallucination guards. One import, one config — your site has a chatbot.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "agents.io",
@@ -54,6 +54,11 @@
54
54
  "types": "./dist/react/index.d.ts",
55
55
  "import": "./dist/react/index.js",
56
56
  "require": "./dist/react/index.cjs"
57
+ },
58
+ "./node": {
59
+ "types": "./dist/node/index.d.ts",
60
+ "import": "./dist/node/index.js",
61
+ "require": "./dist/node/index.cjs"
57
62
  }
58
63
  },
59
64
  "files": [
@@ -1,82 +0,0 @@
1
- type Provider = "openai" | "deepseek" | "groq" | "gemini" | "anthropic" | "cerebras" | "sambanova" | "fireworks" | "mistral" | "openrouter" | "moonshot";
2
- /**
3
- * One step in the fallback chain. Either a string spec or an object.
4
- *
5
- * - **String**: `"provider/model"` (e.g. `"openai/gpt-4o"`), or bare `"provider"` (uses provider's default model).
6
- * - **Object**: `{ provider, model? }` — type-safe alternative.
7
- */
8
- type ChainEntry = string | {
9
- provider: Provider;
10
- model?: string;
11
- };
12
- /**
13
- * Provider configuration.
14
- *
15
- * `keys` are auth credentials (one key per provider — that key covers all that provider's models).
16
- * `chain` is the ordered fallback list. Each entry is `"provider/model"` (string) or `{ provider, model }` (object).
17
- *
18
- * @example String form (compact, paste-friendly)
19
- * ```ts
20
- * providers: {
21
- * keys: {
22
- * deepseek: "sk-...",
23
- * groq: "gsk-...",
24
- * openai: "sk-..."
25
- * },
26
- * chain: [
27
- * "deepseek/deepseek-chat", // try first
28
- * "groq/llama-3.3-70b-versatile", // fallback 1
29
- * "openai/gpt-4o-mini" // fallback 2
30
- * ]
31
- * }
32
- * ```
33
- *
34
- * @example Object form (type-safe, IDE autocomplete on `provider`)
35
- * ```ts
36
- * providers: {
37
- * keys: { deepseek: "sk-...", openai: "sk-..." },
38
- * chain: [
39
- * { provider: "deepseek" }, // default model
40
- * { provider: "openai", model: "gpt-4o" },
41
- * { provider: "openai", model: "gpt-4o-mini" } // same key, cheaper model
42
- * ]
43
- * }
44
- * ```
45
- *
46
- * If `chain` is omitted, defaults to `[<each provider in keys> with its default model]`
47
- * in key insertion order.
48
- */
49
- interface ProviderConfig {
50
- /** API keys per provider. One key covers all that provider's models. */
51
- keys: Partial<Record<Provider, string>>;
52
- /**
53
- * Ordered fallback chain. Each entry: string `"provider/model"` OR object `{ provider, model? }`.
54
- * Defaults to `[provider/defaultModel]` for each key in insertion order.
55
- */
56
- chain?: ChainEntry[];
57
- }
58
- interface ClientOptions {
59
- fetch?: typeof globalThis.fetch;
60
- timeoutMs?: number;
61
- maxRetries?: number;
62
- }
63
- interface ChainStep {
64
- provider: Provider;
65
- model: string;
66
- /** Original spec string for diagnostics. */
67
- spec: string;
68
- }
69
- interface AttemptInfo {
70
- provider: Provider;
71
- model: string;
72
- status: "ok" | "error";
73
- error?: string;
74
- latencyMs: number;
75
- }
76
- declare function parseChainSpec(spec: string): {
77
- provider: Provider;
78
- model: string | null;
79
- };
80
- declare function isKnownProvider(name: string): name is Provider;
81
-
82
- export { type AttemptInfo as A, type ChainEntry as C, type Provider as P, type ChainStep as a, type ClientOptions as b, type ProviderConfig as c, isKnownProvider as i, parseChainSpec as p };
@@ -1,82 +0,0 @@
1
- type Provider = "openai" | "deepseek" | "groq" | "gemini" | "anthropic" | "cerebras" | "sambanova" | "fireworks" | "mistral" | "openrouter" | "moonshot";
2
- /**
3
- * One step in the fallback chain. Either a string spec or an object.
4
- *
5
- * - **String**: `"provider/model"` (e.g. `"openai/gpt-4o"`), or bare `"provider"` (uses provider's default model).
6
- * - **Object**: `{ provider, model? }` — type-safe alternative.
7
- */
8
- type ChainEntry = string | {
9
- provider: Provider;
10
- model?: string;
11
- };
12
- /**
13
- * Provider configuration.
14
- *
15
- * `keys` are auth credentials (one key per provider — that key covers all that provider's models).
16
- * `chain` is the ordered fallback list. Each entry is `"provider/model"` (string) or `{ provider, model }` (object).
17
- *
18
- * @example String form (compact, paste-friendly)
19
- * ```ts
20
- * providers: {
21
- * keys: {
22
- * deepseek: "sk-...",
23
- * groq: "gsk-...",
24
- * openai: "sk-..."
25
- * },
26
- * chain: [
27
- * "deepseek/deepseek-chat", // try first
28
- * "groq/llama-3.3-70b-versatile", // fallback 1
29
- * "openai/gpt-4o-mini" // fallback 2
30
- * ]
31
- * }
32
- * ```
33
- *
34
- * @example Object form (type-safe, IDE autocomplete on `provider`)
35
- * ```ts
36
- * providers: {
37
- * keys: { deepseek: "sk-...", openai: "sk-..." },
38
- * chain: [
39
- * { provider: "deepseek" }, // default model
40
- * { provider: "openai", model: "gpt-4o" },
41
- * { provider: "openai", model: "gpt-4o-mini" } // same key, cheaper model
42
- * ]
43
- * }
44
- * ```
45
- *
46
- * If `chain` is omitted, defaults to `[<each provider in keys> with its default model]`
47
- * in key insertion order.
48
- */
49
- interface ProviderConfig {
50
- /** API keys per provider. One key covers all that provider's models. */
51
- keys: Partial<Record<Provider, string>>;
52
- /**
53
- * Ordered fallback chain. Each entry: string `"provider/model"` OR object `{ provider, model? }`.
54
- * Defaults to `[provider/defaultModel]` for each key in insertion order.
55
- */
56
- chain?: ChainEntry[];
57
- }
58
- interface ClientOptions {
59
- fetch?: typeof globalThis.fetch;
60
- timeoutMs?: number;
61
- maxRetries?: number;
62
- }
63
- interface ChainStep {
64
- provider: Provider;
65
- model: string;
66
- /** Original spec string for diagnostics. */
67
- spec: string;
68
- }
69
- interface AttemptInfo {
70
- provider: Provider;
71
- model: string;
72
- status: "ok" | "error";
73
- error?: string;
74
- latencyMs: number;
75
- }
76
- declare function parseChainSpec(spec: string): {
77
- provider: Provider;
78
- model: string | null;
79
- };
80
- declare function isKnownProvider(name: string): name is Provider;
81
-
82
- export { type AttemptInfo as A, type ChainEntry as C, type Provider as P, type ChainStep as a, type ClientOptions as b, type ProviderConfig as c, isKnownProvider as i, parseChainSpec as p };
@@ -1,39 +0,0 @@
1
- interface BusinessConfig {
2
- /** Business name shown in greetings. */
3
- name: string;
4
- /** Optional one-line description (e.g. "Plumbing service in Vancouver"). */
5
- description?: string;
6
- /** Services offered with optional pricing. */
7
- services?: ServiceItem[];
8
- /** Operating hours (free text or structured). */
9
- hours?: string;
10
- /** Geographic service area names (e.g. ["Vancouver", "Burnaby"]). */
11
- serviceArea?: string[];
12
- /** Known policies (cancellation, payment, etc) the bot can quote. */
13
- policies?: PolicyItem[];
14
- /** What the bot should NOT promise (e.g. dispatch times). */
15
- doNotPromise?: string[];
16
- /** Custom system instructions appended to the default prompt. */
17
- customInstructions?: string;
18
- /** Language hint — default English. */
19
- language?: "en" | "zh" | "es" | "fr" | string;
20
- }
21
- interface ServiceItem {
22
- name: string;
23
- price?: string;
24
- notes?: string;
25
- }
26
- interface PolicyItem {
27
- topic: string;
28
- answer: string;
29
- }
30
- interface Message {
31
- role: "user" | "assistant" | "system";
32
- content: string;
33
- }
34
- interface GuardResult {
35
- ok: boolean;
36
- violations: string[];
37
- }
38
-
39
- export type { BusinessConfig as B, GuardResult as G, Message as M, PolicyItem as P, ServiceItem as S };
@@ -1,39 +0,0 @@
1
- interface BusinessConfig {
2
- /** Business name shown in greetings. */
3
- name: string;
4
- /** Optional one-line description (e.g. "Plumbing service in Vancouver"). */
5
- description?: string;
6
- /** Services offered with optional pricing. */
7
- services?: ServiceItem[];
8
- /** Operating hours (free text or structured). */
9
- hours?: string;
10
- /** Geographic service area names (e.g. ["Vancouver", "Burnaby"]). */
11
- serviceArea?: string[];
12
- /** Known policies (cancellation, payment, etc) the bot can quote. */
13
- policies?: PolicyItem[];
14
- /** What the bot should NOT promise (e.g. dispatch times). */
15
- doNotPromise?: string[];
16
- /** Custom system instructions appended to the default prompt. */
17
- customInstructions?: string;
18
- /** Language hint — default English. */
19
- language?: "en" | "zh" | "es" | "fr" | string;
20
- }
21
- interface ServiceItem {
22
- name: string;
23
- price?: string;
24
- notes?: string;
25
- }
26
- interface PolicyItem {
27
- topic: string;
28
- answer: string;
29
- }
30
- interface Message {
31
- role: "user" | "assistant" | "system";
32
- content: string;
33
- }
34
- interface GuardResult {
35
- ok: boolean;
36
- violations: string[];
37
- }
38
-
39
- export type { BusinessConfig as B, GuardResult as G, Message as M, PolicyItem as P, ServiceItem as S };