juneau 0.1.0 → 0.1.3
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/README.md +394 -118
- package/dist/adapters/createFetchStreamAdapter.d.ts +88 -0
- package/dist/adapters/createFetchStreamAdapter.d.ts.map +1 -0
- package/dist/adapters/createSseAdapter.d.ts +94 -0
- package/dist/adapters/createSseAdapter.d.ts.map +1 -0
- package/dist/components/AiChat/AiChat.d.ts +2 -1
- package/dist/components/AiChat/AiChat.d.ts.map +1 -1
- package/dist/components/AiMessageList/AiMessageList.d.ts +3 -1
- package/dist/components/AiMessageList/AiMessageList.d.ts.map +1 -1
- package/dist/components/AiSidebar/AiSidebar.d.ts.map +1 -1
- package/dist/components/AiTypingIndicator/AiTypingIndicator.d.ts +6 -1
- package/dist/components/AiTypingIndicator/AiTypingIndicator.d.ts.map +1 -1
- package/dist/core/stream.d.ts +16 -1
- package/dist/core/stream.d.ts.map +1 -1
- package/dist/hooks/useAiChat.d.ts +6 -0
- package/dist/hooks/useAiChat.d.ts.map +1 -1
- package/dist/i18n/locales/cs.d.ts.map +1 -1
- package/dist/i18n/locales/en.d.ts.map +1 -1
- package/dist/i18n/types.d.ts +2 -0
- package/dist/i18n/types.d.ts.map +1 -1
- package/dist/index.cjs +39 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3459 -3292
- package/dist/index.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { AiBackendAdapter, AiAdapterInput, AiStreamEvent } from '../core/types';
|
|
2
|
+
/**
|
|
3
|
+
* How to map a raw text chunk from the response body to Juneau stream events.
|
|
4
|
+
*
|
|
5
|
+
* Return an array — a chunk may produce one event, multiple, or none (empty array to skip).
|
|
6
|
+
* The chunk is whatever the server sent — could be a full JSON line, a partial one,
|
|
7
|
+
* or plain text depending on your backend.
|
|
8
|
+
*/
|
|
9
|
+
export type FetchChunkParser = (chunk: string) => AiStreamEvent[];
|
|
10
|
+
/**
|
|
11
|
+
* Options for createFetchStreamAdapter.
|
|
12
|
+
*/
|
|
13
|
+
export type FetchStreamAdapterOptions = {
|
|
14
|
+
/**
|
|
15
|
+
* HTTP method. Defaults to 'POST'.
|
|
16
|
+
*/
|
|
17
|
+
method?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Static headers merged with Content-Type. Use for auth tokens etc.
|
|
20
|
+
* For dynamic headers (e.g. per-request auth), use getHeaders instead.
|
|
21
|
+
*
|
|
22
|
+
* @example { Authorization: 'Bearer sk-...' }
|
|
23
|
+
*/
|
|
24
|
+
headers?: Record<string, string>;
|
|
25
|
+
/**
|
|
26
|
+
* Dynamic headers — called before every request with the current adapter input.
|
|
27
|
+
* Merged on top of `headers`. Use this when the token is fetched at runtime.
|
|
28
|
+
*/
|
|
29
|
+
getHeaders?: (input: AiAdapterInput) => Record<string, string> | Promise<Record<string, string>>;
|
|
30
|
+
/**
|
|
31
|
+
* Override the request body. By default sends `{ messages, context }`.
|
|
32
|
+
* Return anything JSON-serialisable.
|
|
33
|
+
*/
|
|
34
|
+
getBody?: (input: AiAdapterInput) => unknown;
|
|
35
|
+
/**
|
|
36
|
+
* How to parse each chunk from the response stream into Juneau events.
|
|
37
|
+
*
|
|
38
|
+
* Defaults to a newline-delimited JSON (NDJSON) parser that expects each
|
|
39
|
+
* line to be either `{ text: "..." }` or `{ done: true }`.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* // Plain text streaming — treat every chunk as raw text:
|
|
43
|
+
* parseChunk: (chunk) => chunk ? [{ type: 'text', text: chunk }] : []
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* // Custom JSON lines format:
|
|
47
|
+
* parseChunk: (chunk) => {
|
|
48
|
+
* try {
|
|
49
|
+
* const json = JSON.parse(chunk);
|
|
50
|
+
* if (json.error) return [{ type: 'error', message: json.error }];
|
|
51
|
+
* if (json.done) return [{ type: 'done' }];
|
|
52
|
+
* if (json.delta) return [{ type: 'text', text: json.delta }];
|
|
53
|
+
* return [];
|
|
54
|
+
* } catch { return []; }
|
|
55
|
+
* }
|
|
56
|
+
*/
|
|
57
|
+
parseChunk?: FetchChunkParser;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Creates an adapter that connects to a **raw chunked HTTP streaming** endpoint —
|
|
61
|
+
* for backends that stream newline-delimited JSON (NDJSON) or plain text,
|
|
62
|
+
* rather than SSE.
|
|
63
|
+
*
|
|
64
|
+
* Use `createSseAdapter` instead if your backend streams Server-Sent Events
|
|
65
|
+
* (the format used by OpenAI, Anthropic, and most AI APIs).
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* // NDJSON backend streaming { text: "..." } lines — works with zero config:
|
|
69
|
+
* const adapter = createFetchStreamAdapter('/api/chat');
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* // Plain text streaming (each chunk is raw text, no JSON):
|
|
73
|
+
* const adapter = createFetchStreamAdapter('/api/chat', {
|
|
74
|
+
* parseChunk: (chunk) => chunk ? [{ type: 'text', text: chunk }] : [],
|
|
75
|
+
* });
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* // Custom body + auth:
|
|
79
|
+
* const adapter = createFetchStreamAdapter('/api/chat', {
|
|
80
|
+
* getHeaders: async () => ({ Authorization: `Bearer ${await getToken()}` }),
|
|
81
|
+
* getBody: ({ messages, context }) => ({
|
|
82
|
+
* history: messages,
|
|
83
|
+
* model: context?.model ?? 'default',
|
|
84
|
+
* }),
|
|
85
|
+
* });
|
|
86
|
+
*/
|
|
87
|
+
export declare function createFetchStreamAdapter(url: string, options?: FetchStreamAdapterOptions): AiBackendAdapter;
|
|
88
|
+
//# sourceMappingURL=createFetchStreamAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFetchStreamAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/createFetchStreamAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAErF;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,aAAa,EAAE,CAAC;AAElE;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAEjG;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC;IAE7C;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,yBAA8B,GACtC,gBAAgB,CAyClB"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { AiBackendAdapter, AiAdapterInput, AiStreamEvent } from '../core/types';
|
|
2
|
+
/**
|
|
3
|
+
* How to map a parsed SSE data payload to Juneau stream events.
|
|
4
|
+
*
|
|
5
|
+
* Return an array — most lines produce one event, but you can return multiple
|
|
6
|
+
* or an empty array to skip a line entirely.
|
|
7
|
+
*/
|
|
8
|
+
export type SseEventParser = (data: string) => AiStreamEvent[];
|
|
9
|
+
/**
|
|
10
|
+
* Options for createSseAdapter.
|
|
11
|
+
*/
|
|
12
|
+
export type SseAdapterOptions = {
|
|
13
|
+
/**
|
|
14
|
+
* HTTP method. Defaults to 'POST'.
|
|
15
|
+
*/
|
|
16
|
+
method?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Static headers merged with Content-Type. Use for auth tokens etc.
|
|
19
|
+
* For dynamic headers (e.g. per-request auth), use getHeaders instead.
|
|
20
|
+
*
|
|
21
|
+
* @example { Authorization: 'Bearer sk-...' }
|
|
22
|
+
*/
|
|
23
|
+
headers?: Record<string, string>;
|
|
24
|
+
/**
|
|
25
|
+
* Dynamic headers — called before every request with the current adapter input.
|
|
26
|
+
* Merged on top of `headers`. Use this when the token is fetched at runtime.
|
|
27
|
+
*/
|
|
28
|
+
getHeaders?: (input: AiAdapterInput) => Record<string, string> | Promise<Record<string, string>>;
|
|
29
|
+
/**
|
|
30
|
+
* Override the request body. By default sends `{ messages, context }`.
|
|
31
|
+
* Return anything JSON-serialisable.
|
|
32
|
+
*/
|
|
33
|
+
getBody?: (input: AiAdapterInput) => unknown;
|
|
34
|
+
/**
|
|
35
|
+
* Custom SSE line parser. Receives the raw string after `data: ` and returns
|
|
36
|
+
* zero or more Juneau stream events.
|
|
37
|
+
*
|
|
38
|
+
* Defaults to an OpenAI-compatible parser that reads
|
|
39
|
+
* `choices[0].delta.content` and handles `[DONE]`.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* // For a backend that streams { text: "..." } JSON lines:
|
|
43
|
+
* parseEvent: (data) => {
|
|
44
|
+
* const json = JSON.parse(data);
|
|
45
|
+
* return json.text ? [{ type: 'text', text: json.text }] : [];
|
|
46
|
+
* }
|
|
47
|
+
*/
|
|
48
|
+
parseEvent?: SseEventParser;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Creates an adapter that connects to a **Server-Sent Events (SSE)** streaming
|
|
52
|
+
* endpoint — the format used by OpenAI, Anthropic, and most AI backend proxies.
|
|
53
|
+
*
|
|
54
|
+
* The default parser understands OpenAI's streaming format out of the box.
|
|
55
|
+
* Override `parseEvent` for any other SSE schema.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* // OpenAI-compatible backend proxy — works with zero configuration:
|
|
59
|
+
* const adapter = createSseAdapter('/api/chat');
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* // With auth header:
|
|
63
|
+
* const adapter = createSseAdapter('/api/chat', {
|
|
64
|
+
* getHeaders: async () => ({
|
|
65
|
+
* Authorization: `Bearer ${await getToken()}`,
|
|
66
|
+
* }),
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* // Custom body shape:
|
|
71
|
+
* const adapter = createSseAdapter('/api/chat', {
|
|
72
|
+
* getBody: ({ messages, context }) => ({
|
|
73
|
+
* messages,
|
|
74
|
+
* model: 'gpt-4o',
|
|
75
|
+
* stream: true,
|
|
76
|
+
* ...(context?.systemPrompt ? { system: context.systemPrompt } : {}),
|
|
77
|
+
* }),
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* // Custom SSE schema (backend streams { text: "..." }):
|
|
82
|
+
* const adapter = createSseAdapter('/api/chat', {
|
|
83
|
+
* parseEvent: (data) => {
|
|
84
|
+
* try {
|
|
85
|
+
* const json = JSON.parse(data);
|
|
86
|
+
* return json.text ? [{ type: 'text', text: json.text }] : [];
|
|
87
|
+
* } catch {
|
|
88
|
+
* return [];
|
|
89
|
+
* }
|
|
90
|
+
* },
|
|
91
|
+
* });
|
|
92
|
+
*/
|
|
93
|
+
export declare function createSseAdapter(url: string, options?: SseAdapterOptions): AiBackendAdapter;
|
|
94
|
+
//# sourceMappingURL=createSseAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSseAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/createSseAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAErF;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,aAAa,EAAE,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAEjG;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC;IAE7C;;;;;;;;;;;;;OAaG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,gBAAgB,CAyC/F"}
|
|
@@ -5,6 +5,7 @@ type Props = {
|
|
|
5
5
|
messages: AiMessage[];
|
|
6
6
|
input: string;
|
|
7
7
|
isLoading: boolean;
|
|
8
|
+
isConnecting: boolean;
|
|
8
9
|
error: string | null;
|
|
9
10
|
onInputChange: (value: string) => void;
|
|
10
11
|
onSend: () => void;
|
|
@@ -34,6 +35,6 @@ type Props = {
|
|
|
34
35
|
* Used by AiSidebar (inside the sidebar chrome) and directly in dashboard
|
|
35
36
|
* or any other layout where you want chat without the sidebar wrapper.
|
|
36
37
|
*/
|
|
37
|
-
export declare function AiChat({ messages, input, isLoading, error, onInputChange, onSend, onStop, onProposalConfirm, onProposalCancel, placeholder, assistantIcon, actions, sendIcon, className, style, }: Props): import("react").JSX.Element;
|
|
38
|
+
export declare function AiChat({ messages, input, isLoading, isConnecting, error, onInputChange, onSend, onStop, onProposalConfirm, onProposalCancel, placeholder, assistantIcon, actions, sendIcon, className, style, }: Props): import("react").JSX.Element;
|
|
38
39
|
export {};
|
|
39
40
|
//# sourceMappingURL=AiChat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiChat.d.ts","sourceRoot":"","sources":["../../../src/components/AiChat/AiChat.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMxD,KAAK,KAAK,GAAG;IACX,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,iGAAiG;IACjG,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,iBAAiB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAClE,gBAAgB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6EAA6E;IAC7E,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B;;;;OAIG;IACH,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAC1B,qEAAqE;IACrE,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACv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E,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,EACrB,QAAQ,EACR,KAAK,EACL,SAAS,EACT,YAAY,EACZ,KAAK,EACL,aAAa,EACb,MAAM,EACN,MAAM,EACN,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,OAAO,EACP,QAAQ,EACR,SAAS,EACT,KAAK,GACN,EAAE,KAAK,+BA6BP"}
|
|
@@ -3,11 +3,13 @@ import type { AiMessage } from '../../core/types';
|
|
|
3
3
|
type Props = {
|
|
4
4
|
messages: AiMessage[];
|
|
5
5
|
isLoading: boolean;
|
|
6
|
+
/** True while waiting for the first token — shows a "connecting" label inside the typing indicator. */
|
|
7
|
+
isConnecting: boolean;
|
|
6
8
|
onProposalConfirm: (proposalId: string, payload: unknown) => void;
|
|
7
9
|
onProposalCancel: (proposalId: string) => void;
|
|
8
10
|
/** Override the assistant avatar icon. Forwarded to every AiMessageBubble. */
|
|
9
11
|
assistantIcon?: ReactNode;
|
|
10
12
|
};
|
|
11
|
-
export declare function AiMessageList({ messages, isLoading, onProposalConfirm, onProposalCancel, assistantIcon }: Props): import("react").JSX.Element;
|
|
13
|
+
export declare function AiMessageList({ messages, isLoading, isConnecting, onProposalConfirm, onProposalCancel, assistantIcon }: Props): import("react").JSX.Element;
|
|
12
14
|
export {};
|
|
13
15
|
//# sourceMappingURL=AiMessageList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiMessageList.d.ts","sourceRoot":"","sources":["../../../src/components/AiMessageList/AiMessageList.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAMlD,KAAK,KAAK,GAAG;IACX,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAClE,gBAAgB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,8EAA8E;IAC9E,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,aAAa,EAAE,EAAE,KAAK,+
|
|
1
|
+
{"version":3,"file":"AiMessageList.d.ts","sourceRoot":"","sources":["../../../src/components/AiMessageList/AiMessageList.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAMlD,KAAK,KAAK,GAAG;IACX,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,uGAAuG;IACvG,YAAY,EAAE,OAAO,CAAC;IACtB,iBAAiB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAClE,gBAAgB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,8EAA8E;IAC9E,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,aAAa,EAAE,EAAE,KAAK,+BAmC7H"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiSidebar.d.ts","sourceRoot":"","sources":["../../../src/components/AiSidebar/AiSidebar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAA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,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,iBAAiB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACnE,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,+EAA+E;IAC/E,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAC1B,qEAAqE;IACrE,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,CAAC;AAEF,wBAAgB,SAAS,CAAC,EACxB,OAAO,EACP,KAAK,EACL,OAAO,EACP,iBAAiB,EACjB,gBAAgB,EAChB,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,SAAS,EACT,KAAK,GACN,EAAE,KAAK,+BAiDP"}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
type Props = {
|
|
2
|
+
/** When true, shows a "Connecting…" label instead of just the dots. */
|
|
3
|
+
connecting?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare function AiTypingIndicator({ connecting }: Props): import("react").JSX.Element;
|
|
6
|
+
export {};
|
|
2
7
|
//# sourceMappingURL=AiTypingIndicator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiTypingIndicator.d.ts","sourceRoot":"","sources":["../../../src/components/AiTypingIndicator/AiTypingIndicator.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AiTypingIndicator.d.ts","sourceRoot":"","sources":["../../../src/components/AiTypingIndicator/AiTypingIndicator.tsx"],"names":[],"mappings":"AAGA,KAAK,KAAK,GAAG;IACX,uEAAuE;IACvE,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EAAE,UAAkB,EAAE,EAAE,KAAK,+BAgB9D"}
|
package/dist/core/stream.d.ts
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
|
-
import type { AiStreamEvent } from './types';
|
|
1
|
+
import type { AiMessage, AiStreamEvent } from './types';
|
|
2
2
|
export declare const delay: (ms: number) => Promise<void>;
|
|
3
|
+
/**
|
|
4
|
+
* Extracts the plain text content from a message.
|
|
5
|
+
*
|
|
6
|
+
* Concatenates all `text` parts in order. Non-text parts (tables, proposals,
|
|
7
|
+
* errors) are skipped. Returns an empty string if the message has no text parts.
|
|
8
|
+
*
|
|
9
|
+
* Use this in your adapter when you need to read a message's text without
|
|
10
|
+
* digging into the parts array yourself:
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const { messages } = input;
|
|
14
|
+
* const lastUser = [...messages].reverse().find(m => m.role === 'user');
|
|
15
|
+
* const text = lastUser ? getMessageText(lastUser) : '';
|
|
16
|
+
*/
|
|
17
|
+
export declare function getMessageText(message: AiMessage): string;
|
|
3
18
|
/**
|
|
4
19
|
* Iterates over an AsyncIterable of stream events and calls the handler for each.
|
|
5
20
|
* Automatically handles cancellation via AbortSignal.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/core/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/core/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExD,eAAO,MAAM,KAAK,GAAI,IAAI,MAAM,KAAG,OAAO,CAAC,IAAI,CACE,CAAC;AAElD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,SAAS,GAAG,MAAM,CAKzD;AAED;;;GAGG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,aAAa,CAAC,aAAa,CAAC,EACtC,OAAO,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,EACvC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC,CAMf"}
|
|
@@ -24,6 +24,12 @@ export type UseAiChatReturn = {
|
|
|
24
24
|
/** Aborts the in-flight stream. No-op if nothing is streaming. */
|
|
25
25
|
stop: () => void;
|
|
26
26
|
isLoading: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* True from the moment a message is sent until the first token arrives from the stream.
|
|
29
|
+
* Use this to show a "connecting…" state distinct from the typing indicator shown
|
|
30
|
+
* while tokens are actively streaming in.
|
|
31
|
+
*/
|
|
32
|
+
isConnecting: boolean;
|
|
27
33
|
error: string | null;
|
|
28
34
|
reset: () => void;
|
|
29
35
|
confirmProposal: (proposalId: string, payload: unknown) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAiChat.d.ts","sourceRoot":"","sources":["../../src/hooks/useAiChat.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,SAAS,EAET,gBAAgB,EAEjB,MAAM,eAAe,CAAC;AAKvB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,0CAA0C;IAC1C,iBAAiB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACnE,0CAA0C;IAC1C,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAA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AM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,mHAAmH;IACnH,mBAAmB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD;;;;OAIG;IACH,YAAY,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,kEAAkE;IAClE,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,eAAe,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAChE,cAAc,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C,CAAC;AAEF,wBAAgB,SAAS,CAAC,EACxB,OAAO,EACP,OAAO,EACP,iBAAiB,EACjB,gBAAgB,EACjB,EAAE,gBAAgB,GAAG,eAAe,CAuMpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cs.d.ts","sourceRoot":"","sources":["../../../src/i18n/locales/cs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,eAAO,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"cs.d.ts","sourceRoot":"","sources":["../../../src/i18n/locales/cs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,eAAO,MAAM,QAAQ,EAAE,YAkBtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../src/i18n/locales/en.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,eAAO,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../src/i18n/locales/en.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,eAAO,MAAM,QAAQ,EAAE,YAkBtB,CAAC"}
|
package/dist/i18n/types.d.ts
CHANGED
package/dist/i18n/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/i18n/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG;IAEzB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAG1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/i18n/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG;IAEzB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAG1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IAGpB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IAGpB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IAGvB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IAGvB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC"}
|