@aigentyc/chat-sdk 0.3.1 → 0.5.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 (97) hide show
  1. package/AGENTS.md +24 -1
  2. package/claude-skill/aigentyc-chat-sdk/SKILL.md +1 -1
  3. package/context7.json +1 -1
  4. package/dist/{ChatInterface-f8ftS56n.d.ts → ChatInterface-2MN5cpYB.d.ts} +1 -1
  5. package/dist/{ChatInterface-B0zbA3Lm.d.cts → ChatInterface-BnVyOUG5.d.cts} +1 -1
  6. package/dist/{SlotsContext-BjiX1mRx.d.ts → SlotsContext-BZBi51ZT.d.ts} +89 -4
  7. package/dist/{SlotsContext-CEOBjzfh.d.cts → SlotsContext-D_C7zlUA.d.cts} +89 -4
  8. package/dist/ai-elements.cjs +163 -566
  9. package/dist/ai-elements.cjs.map +1 -1
  10. package/dist/ai-elements.d.cts +10 -2
  11. package/dist/ai-elements.d.ts +10 -2
  12. package/dist/ai-elements.js +16 -461
  13. package/dist/ai-elements.js.map +1 -1
  14. package/dist/{chunk-M4YRNNGB.js → chunk-3H4CX3MS.js} +29 -6
  15. package/dist/chunk-3H4CX3MS.js.map +1 -0
  16. package/dist/{chunk-BPV66QNM.cjs → chunk-52ZHMTAA.cjs} +30 -8
  17. package/dist/chunk-52ZHMTAA.cjs.map +1 -0
  18. package/dist/{chunk-B27JIQ4Z.js → chunk-5XF3NEFB.js} +576 -6
  19. package/dist/chunk-5XF3NEFB.js.map +1 -0
  20. package/dist/{chunk-5XF7KH6B.cjs → chunk-7ESWDFF5.cjs} +94 -60
  21. package/dist/chunk-7ESWDFF5.cjs.map +1 -0
  22. package/dist/{chunk-YG2COKFR.js → chunk-BWWN5LSE.js} +65 -31
  23. package/dist/chunk-BWWN5LSE.js.map +1 -0
  24. package/dist/chunk-BYTPAQ7F.js +70 -0
  25. package/dist/chunk-BYTPAQ7F.js.map +1 -0
  26. package/dist/{chunk-FPQ3UCCJ.js → chunk-D75TDRBH.js} +30 -8
  27. package/dist/chunk-D75TDRBH.js.map +1 -0
  28. package/dist/chunk-DDATCJ3O.cjs +75 -0
  29. package/dist/chunk-DDATCJ3O.cjs.map +1 -0
  30. package/dist/{chunk-NYQSM3EB.cjs → chunk-DVWX2UGY.cjs} +16 -2
  31. package/dist/chunk-DVWX2UGY.cjs.map +1 -0
  32. package/dist/{chunk-TZ7EM3EG.cjs → chunk-EMVZ7HWM.cjs} +44 -2
  33. package/dist/chunk-EMVZ7HWM.cjs.map +1 -0
  34. package/dist/{chunk-AD6XWKWB.js → chunk-FJZL33KP.js} +3 -3
  35. package/dist/{chunk-AD6XWKWB.js.map → chunk-FJZL33KP.js.map} +1 -1
  36. package/dist/{chunk-JHWSG5IB.js → chunk-JAOD6CNW.js} +38 -3
  37. package/dist/chunk-JAOD6CNW.js.map +1 -0
  38. package/dist/{chunk-4WOBNRRB.cjs → chunk-KTYYLZN7.cjs} +592 -8
  39. package/dist/chunk-KTYYLZN7.cjs.map +1 -0
  40. package/dist/{chunk-3HGOLNGG.cjs → chunk-NBZDBH4M.cjs} +29 -6
  41. package/dist/chunk-NBZDBH4M.cjs.map +1 -0
  42. package/dist/{chunk-5F3O3ZJH.js → chunk-P7UR37HP.js} +17 -4
  43. package/dist/chunk-P7UR37HP.js.map +1 -0
  44. package/dist/{chunk-7IFBPXT3.cjs → chunk-Q3UJEIBN.cjs} +6 -6
  45. package/dist/{chunk-7IFBPXT3.cjs.map → chunk-Q3UJEIBN.cjs.map} +1 -1
  46. package/dist/{chunk-3KSMOHNY.js → chunk-R3TYC66R.js} +46 -81
  47. package/dist/chunk-R3TYC66R.js.map +1 -0
  48. package/dist/{chunk-OU5OZKYH.cjs → chunk-Y4B45DW4.cjs} +48 -90
  49. package/dist/chunk-Y4B45DW4.cjs.map +1 -0
  50. package/dist/components.cjs +18 -18
  51. package/dist/components.d.cts +3 -3
  52. package/dist/components.d.ts +3 -3
  53. package/dist/components.js +7 -7
  54. package/dist/core.d.cts +2 -2
  55. package/dist/core.d.ts +2 -2
  56. package/dist/hooks.cjs +31 -10
  57. package/dist/hooks.cjs.map +1 -1
  58. package/dist/hooks.d.cts +2 -2
  59. package/dist/hooks.d.ts +2 -2
  60. package/dist/hooks.js +4 -3
  61. package/dist/hooks.js.map +1 -1
  62. package/dist/i18n.d.cts +1 -1
  63. package/dist/i18n.d.ts +1 -1
  64. package/dist/index.cjs +64 -32
  65. package/dist/index.cjs.map +1 -1
  66. package/dist/index.d.cts +4 -4
  67. package/dist/index.d.ts +4 -4
  68. package/dist/index.js +23 -11
  69. package/dist/index.js.map +1 -1
  70. package/dist/llms-full.txt +34 -11
  71. package/dist/styles.css +1 -1
  72. package/dist/theme.d.cts +1 -1
  73. package/dist/theme.d.ts +1 -1
  74. package/dist/tools.cjs +5 -5
  75. package/dist/tools.d.cts +2 -2
  76. package/dist/tools.d.ts +2 -2
  77. package/dist/tools.js +2 -2
  78. package/dist/{types-DlNwk-bG.d.ts → types-bsR_-fq8.d.cts} +43 -2
  79. package/dist/{types-DlNwk-bG.d.cts → types-bsR_-fq8.d.ts} +43 -2
  80. package/dist/ui.cjs +52 -52
  81. package/dist/ui.js +2 -2
  82. package/llms.txt +1 -1
  83. package/package.json +1 -1
  84. package/dist/chunk-3HGOLNGG.cjs.map +0 -1
  85. package/dist/chunk-3KSMOHNY.js.map +0 -1
  86. package/dist/chunk-4WOBNRRB.cjs.map +0 -1
  87. package/dist/chunk-5F3O3ZJH.js.map +0 -1
  88. package/dist/chunk-5XF7KH6B.cjs.map +0 -1
  89. package/dist/chunk-B27JIQ4Z.js.map +0 -1
  90. package/dist/chunk-BPV66QNM.cjs.map +0 -1
  91. package/dist/chunk-FPQ3UCCJ.js.map +0 -1
  92. package/dist/chunk-JHWSG5IB.js.map +0 -1
  93. package/dist/chunk-M4YRNNGB.js.map +0 -1
  94. package/dist/chunk-NYQSM3EB.cjs.map +0 -1
  95. package/dist/chunk-OU5OZKYH.cjs.map +0 -1
  96. package/dist/chunk-TZ7EM3EG.cjs.map +0 -1
  97. package/dist/chunk-YG2COKFR.js.map +0 -1
package/AGENTS.md CHANGED
@@ -40,7 +40,7 @@ export default function Page() {
40
40
  return (
41
41
  <Chat
42
42
  projectId="YOUR_PROJECT_ID"
43
- apiEndpoint="https://api.aigentyc.com"
43
+ apiEndpoint="https://api.aigentyc.ai"
44
44
  apiKey="YOUR_API_KEY"
45
45
  />
46
46
  )
@@ -140,6 +140,29 @@ Requires `socket.io-client`. Omit both props for AI-only mode.
140
140
 
141
141
  ---
142
142
 
143
+ ## Page context (answering about the page the widget is on)
144
+
145
+ Tell the assistant where the visitor is standing, and it can answer "show me these in 22 AWG"
146
+ without being told which "these".
147
+
148
+ ```tsx
149
+ <ChatWidget
150
+ projectId="..." apiEndpoint="..."
151
+ pageUrl={url} // current page URL
152
+ pageTitle={title} // current page title
153
+ pageContext={{ category, filters }} // any JSON your project's system prompt reads
154
+ />
155
+ ```
156
+
157
+ All three are read **fresh on every message**, so a single-page host can update them on route
158
+ change without remounting the widget — an in-flight stream survives the navigation.
159
+
160
+ `pageContext` is free-form: shape it to whatever your system prompt expects. Keep it small (it
161
+ is re-sent every turn), and note it is client-supplied — the backend renders it as data, never
162
+ as instructions.
163
+
164
+ ---
165
+
143
166
  ## Rules for agents editing consumer projects
144
167
 
145
168
  **Do:**
@@ -24,7 +24,7 @@ Component props are identical between `<Chat>` and `<ChatWidget>` — swap freel
24
24
  2. Import CSS once: `import "@aigentyc/chat-sdk/theme/styles.css"`
25
25
  3. Pass **three** props: `projectId`, `apiEndpoint`, `apiKey`
26
26
 
27
- **`apiKey` IS required for third-party domain embeds.** Without it, `/api/kb/chat` returns 401. The "no apiKey needed" path only works inside `app.aigentyc.com`. Get a project-scoped key from the dashboard (Settings → API Keys) with permission `Chat: Full` and add the embed domain to Allowed Origins.
27
+ **`apiKey` IS required for third-party domain embeds.** Without it, `/api/kb/chat` returns 401. The "no apiKey needed" path only works inside `app.aigentyc.ai`. Get a project-scoped key from the dashboard (Settings → API Keys) with permission `Chat: Full` and add the embed domain to Allowed Origins.
28
28
 
29
29
  Environment-variable pattern:
30
30
  - Next.js: `NEXT_PUBLIC_AIGENTYC_API_KEY`
package/context7.json CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
- "url": "https://context7.com/llmstxt/cdn_jsdelivr_net_npm_aigentyc_chat-sdk_0_3_1_llms_txt",
2
+ "url": "https://context7.com/llmstxt/cdn_jsdelivr_net_npm_aigentyc_chat-sdk_0_5_0_llms_txt",
3
3
  "public_key": "pk_dHiyF4hGXkgbb1jdrT7TU"
4
4
  }
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Q as QuestionConfig } from './types-DlNwk-bG.js';
2
+ import { Q as QuestionConfig } from './types-bsR_-fq8.js';
3
3
 
4
4
  interface ChatInterfaceProps {
5
5
  /** Allow per-instance overrides of any context value */
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Q as QuestionConfig } from './types-DlNwk-bG.cjs';
2
+ import { Q as QuestionConfig } from './types-bsR_-fq8.cjs';
3
3
 
4
4
  interface ChatInterfaceProps {
5
5
  /** Allow per-instance overrides of any context value */
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { RefObject, ComponentType } from 'react';
3
- import { f as LiveChatState, e as LiveChatMessage, C as ChatProviderProps, c as ChatMessage, a as ChatConfig, b as ChatEventCallbacks } from './types-DlNwk-bG.js';
3
+ import { g as LiveChatState, f as LiveChatMessage, C as ChatProviderProps, d as ChatMessage, a as ChatAttachmentInput, b as ChatConfig, c as ChatEventCallbacks } from './types-bsR_-fq8.js';
4
4
 
5
5
  type ChatStatus$1 = "idle" | "streaming" | "error";
6
6
  interface ActiveTool$1 {
@@ -34,7 +34,11 @@ interface UseAigentycChatReturn {
34
34
  status: ChatStatus$1;
35
35
  error: Error | undefined;
36
36
  sessionId: string;
37
- sendMessage: (content: string) => void;
37
+ /**
38
+ * Sends a user turn. `files` travel with it as message parts; a turn carrying
39
+ * files may have empty text — an image on its own is a question.
40
+ */
41
+ sendMessage: (content: string, files?: ChatAttachmentInput[]) => void;
38
42
  stopGeneration: () => void;
39
43
  newConversation: () => void;
40
44
  clearMessages: () => void;
@@ -66,7 +70,11 @@ interface ChatContextValue {
66
70
  sessionId: string;
67
71
  config: ChatConfig;
68
72
  activeTools: ActiveTool[];
69
- sendMessage: (content: string) => void;
73
+ /**
74
+ * Sends a user turn. `files` travel with it as message parts; a turn carrying
75
+ * files may have empty text — an image on its own is a question.
76
+ */
77
+ sendMessage: (content: string, files?: ChatAttachmentInput[]) => void;
70
78
  stopGeneration: () => void;
71
79
  newConversation: () => void;
72
80
  clearMessages: () => void;
@@ -123,6 +131,83 @@ interface LiveChatContextValue {
123
131
  */
124
132
  declare function useLiveChat(): LiveChatContextValue | null;
125
133
 
134
+ interface AutoResizeOptions {
135
+ /** Height of a single row, in px, before padding. */
136
+ minHeight?: number;
137
+ /** Where growth stops and the textarea starts scrolling internally. */
138
+ maxHeight?: number;
139
+ }
140
+ /**
141
+ * Grows a textarea with its content, up to a ceiling.
142
+ *
143
+ * Height is recomputed from `scrollHeight`, which only reports the content's
144
+ * real height once the element has been collapsed first — hence the reset to
145
+ * `auto` before every measurement. Runs in a layout effect so the box is already
146
+ * the right size on the frame the character appears, with no visible reflow.
147
+ *
148
+ * Returns the ref to attach and a manual `resize()` for the cases React does not
149
+ * see: a value set imperatively, or a font that finishes loading late.
150
+ */
151
+ declare function useAutoResize<T extends HTMLTextAreaElement>(value: string, { minHeight, maxHeight }?: AutoResizeOptions): {
152
+ ref: React.RefObject<T | null>;
153
+ resize: () => void;
154
+ };
155
+
156
+ /**
157
+ * The scripts we can tell apart from a single character, mapped to the BCP-47
158
+ * tag a speech recogniser wants.
159
+ *
160
+ * Deliberately short. A script the visitor is not typing in cannot be guessed
161
+ * from their text, and a wrong guess is worse than the fallback — dictation in
162
+ * the wrong language produces confident nonsense rather than an obvious failure.
163
+ */
164
+ /** Reported for Latin script, which pins a keyboard but not a language. */
165
+ declare const LATIN = "latin";
166
+ /**
167
+ * The BCP-47 tag implied by a character's script, {@link LATIN} when the script
168
+ * is Latin, or null when the character says nothing (digits, punctuation,
169
+ * whitespace, emoji).
170
+ */
171
+ declare function scriptLanguageOf(char: string): string | null;
172
+ /**
173
+ * The language of the last character in `text` whose script is identifiable.
174
+ *
175
+ * Read from the end because that is what the visitor is typing now: a Hebrew
176
+ * question that opens with an English part number is still a Hebrew question.
177
+ */
178
+ declare function detectLanguage(text: string): string | null;
179
+ interface KeyboardLanguageOptions {
180
+ /**
181
+ * Used until the visitor has typed something identifiable. Defaults to the
182
+ * browser's own language.
183
+ */
184
+ fallback?: string;
185
+ /**
186
+ * Tags this consumer can actually act on, e.g. the languages a recogniser is
187
+ * configured for. A detection outside the list is ignored rather than
188
+ * switching to something unsupported.
189
+ */
190
+ supported?: string[];
191
+ /** Latin text is ambiguous; this is which Latin language to call it. */
192
+ latin?: string;
193
+ }
194
+ /**
195
+ * Tracks which keyboard the visitor is typing on, by the script of what they type.
196
+ *
197
+ * The web exposes no keyboard-layout API, so the characters themselves are the
198
+ * signal — and they are a good one: a visitor typing Hebrew has a Hebrew
199
+ * keyboard active, which is exactly what dictation should follow. The answer is
200
+ * sticky, so clearing the box or dictating into it does not reset the language
201
+ * back to a default the visitor never chose.
202
+ *
203
+ * Feed it every value the composer sees via `observe`.
204
+ */
205
+ declare function useKeyboardLanguage({ fallback, supported, latin, }?: KeyboardLanguageOptions): {
206
+ lang: string;
207
+ setLang: React.Dispatch<React.SetStateAction<string>>;
208
+ observe: (text: string) => void;
209
+ };
210
+
126
211
  /**
127
212
  * All available slot names that can be overridden.
128
213
  */
@@ -160,4 +245,4 @@ declare function useSlot<P = Record<string, unknown>>(name: SlotName): SlotCompo
160
245
  */
161
246
  declare function renderSlot<P>(name: SlotName, props: P, DefaultComponent: ComponentType<P>, slots: SlotMap): React.ReactElement;
162
247
 
163
- export { type LiveChatReturn as L, type SlotComponent as S, type UseAigentycChatOptions as U, type SlotName as a, type UseAigentycChatReturn as b, useChatContext as c, useLiveChat as d, useSlot as e, useSlots as f, renderSlot as r, useAigentycChat as u };
248
+ export { type AutoResizeOptions as A, type KeyboardLanguageOptions as K, LATIN as L, type SlotComponent as S, type UseAigentycChatOptions as U, type LiveChatReturn as a, type SlotName as b, type UseAigentycChatReturn as c, detectLanguage as d, useAutoResize as e, useChatContext as f, useKeyboardLanguage as g, useLiveChat as h, useSlot as i, useSlots as j, renderSlot as r, scriptLanguageOf as s, useAigentycChat as u };
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { RefObject, ComponentType } from 'react';
3
- import { f as LiveChatState, e as LiveChatMessage, C as ChatProviderProps, c as ChatMessage, a as ChatConfig, b as ChatEventCallbacks } from './types-DlNwk-bG.cjs';
3
+ import { g as LiveChatState, f as LiveChatMessage, C as ChatProviderProps, d as ChatMessage, a as ChatAttachmentInput, b as ChatConfig, c as ChatEventCallbacks } from './types-bsR_-fq8.cjs';
4
4
 
5
5
  type ChatStatus$1 = "idle" | "streaming" | "error";
6
6
  interface ActiveTool$1 {
@@ -34,7 +34,11 @@ interface UseAigentycChatReturn {
34
34
  status: ChatStatus$1;
35
35
  error: Error | undefined;
36
36
  sessionId: string;
37
- sendMessage: (content: string) => void;
37
+ /**
38
+ * Sends a user turn. `files` travel with it as message parts; a turn carrying
39
+ * files may have empty text — an image on its own is a question.
40
+ */
41
+ sendMessage: (content: string, files?: ChatAttachmentInput[]) => void;
38
42
  stopGeneration: () => void;
39
43
  newConversation: () => void;
40
44
  clearMessages: () => void;
@@ -66,7 +70,11 @@ interface ChatContextValue {
66
70
  sessionId: string;
67
71
  config: ChatConfig;
68
72
  activeTools: ActiveTool[];
69
- sendMessage: (content: string) => void;
73
+ /**
74
+ * Sends a user turn. `files` travel with it as message parts; a turn carrying
75
+ * files may have empty text — an image on its own is a question.
76
+ */
77
+ sendMessage: (content: string, files?: ChatAttachmentInput[]) => void;
70
78
  stopGeneration: () => void;
71
79
  newConversation: () => void;
72
80
  clearMessages: () => void;
@@ -123,6 +131,83 @@ interface LiveChatContextValue {
123
131
  */
124
132
  declare function useLiveChat(): LiveChatContextValue | null;
125
133
 
134
+ interface AutoResizeOptions {
135
+ /** Height of a single row, in px, before padding. */
136
+ minHeight?: number;
137
+ /** Where growth stops and the textarea starts scrolling internally. */
138
+ maxHeight?: number;
139
+ }
140
+ /**
141
+ * Grows a textarea with its content, up to a ceiling.
142
+ *
143
+ * Height is recomputed from `scrollHeight`, which only reports the content's
144
+ * real height once the element has been collapsed first — hence the reset to
145
+ * `auto` before every measurement. Runs in a layout effect so the box is already
146
+ * the right size on the frame the character appears, with no visible reflow.
147
+ *
148
+ * Returns the ref to attach and a manual `resize()` for the cases React does not
149
+ * see: a value set imperatively, or a font that finishes loading late.
150
+ */
151
+ declare function useAutoResize<T extends HTMLTextAreaElement>(value: string, { minHeight, maxHeight }?: AutoResizeOptions): {
152
+ ref: React.RefObject<T | null>;
153
+ resize: () => void;
154
+ };
155
+
156
+ /**
157
+ * The scripts we can tell apart from a single character, mapped to the BCP-47
158
+ * tag a speech recogniser wants.
159
+ *
160
+ * Deliberately short. A script the visitor is not typing in cannot be guessed
161
+ * from their text, and a wrong guess is worse than the fallback — dictation in
162
+ * the wrong language produces confident nonsense rather than an obvious failure.
163
+ */
164
+ /** Reported for Latin script, which pins a keyboard but not a language. */
165
+ declare const LATIN = "latin";
166
+ /**
167
+ * The BCP-47 tag implied by a character's script, {@link LATIN} when the script
168
+ * is Latin, or null when the character says nothing (digits, punctuation,
169
+ * whitespace, emoji).
170
+ */
171
+ declare function scriptLanguageOf(char: string): string | null;
172
+ /**
173
+ * The language of the last character in `text` whose script is identifiable.
174
+ *
175
+ * Read from the end because that is what the visitor is typing now: a Hebrew
176
+ * question that opens with an English part number is still a Hebrew question.
177
+ */
178
+ declare function detectLanguage(text: string): string | null;
179
+ interface KeyboardLanguageOptions {
180
+ /**
181
+ * Used until the visitor has typed something identifiable. Defaults to the
182
+ * browser's own language.
183
+ */
184
+ fallback?: string;
185
+ /**
186
+ * Tags this consumer can actually act on, e.g. the languages a recogniser is
187
+ * configured for. A detection outside the list is ignored rather than
188
+ * switching to something unsupported.
189
+ */
190
+ supported?: string[];
191
+ /** Latin text is ambiguous; this is which Latin language to call it. */
192
+ latin?: string;
193
+ }
194
+ /**
195
+ * Tracks which keyboard the visitor is typing on, by the script of what they type.
196
+ *
197
+ * The web exposes no keyboard-layout API, so the characters themselves are the
198
+ * signal — and they are a good one: a visitor typing Hebrew has a Hebrew
199
+ * keyboard active, which is exactly what dictation should follow. The answer is
200
+ * sticky, so clearing the box or dictating into it does not reset the language
201
+ * back to a default the visitor never chose.
202
+ *
203
+ * Feed it every value the composer sees via `observe`.
204
+ */
205
+ declare function useKeyboardLanguage({ fallback, supported, latin, }?: KeyboardLanguageOptions): {
206
+ lang: string;
207
+ setLang: React.Dispatch<React.SetStateAction<string>>;
208
+ observe: (text: string) => void;
209
+ };
210
+
126
211
  /**
127
212
  * All available slot names that can be overridden.
128
213
  */
@@ -160,4 +245,4 @@ declare function useSlot<P = Record<string, unknown>>(name: SlotName): SlotCompo
160
245
  */
161
246
  declare function renderSlot<P>(name: SlotName, props: P, DefaultComponent: ComponentType<P>, slots: SlotMap): React.ReactElement;
162
247
 
163
- export { type LiveChatReturn as L, type SlotComponent as S, type UseAigentycChatOptions as U, type SlotName as a, type UseAigentycChatReturn as b, useChatContext as c, useLiveChat as d, useSlot as e, useSlots as f, renderSlot as r, useAigentycChat as u };
248
+ export { type AutoResizeOptions as A, type KeyboardLanguageOptions as K, LATIN as L, type SlotComponent as S, type UseAigentycChatOptions as U, type LiveChatReturn as a, type SlotName as b, type UseAigentycChatReturn as c, detectLanguage as d, useAutoResize as e, useChatContext as f, useKeyboardLanguage as g, useLiveChat as h, useSlot as i, useSlots as j, renderSlot as r, scriptLanguageOf as s, useAigentycChat as u };