@lambforge/agent-chat 0.0.3 → 0.0.5

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,16 +1,16 @@
1
1
  {
2
2
  "name": "@lambforge/agent-chat",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "<lambforge-agent-chat>: a chat with your Lambforge agent on any site - one script tag or a web component (@rhtml/component + @rxdi/redux-store)",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.mjs",
8
- "types": "dist/index.d.ts",
8
+ "types": "types/index.d.ts",
9
9
  "unpkg": "dist/agent-chat.js",
10
10
  "jsdelivr": "dist/agent-chat.js",
11
11
  "exports": {
12
12
  ".": {
13
- "types": "./dist/index.d.ts",
13
+ "types": "./types/index.d.ts",
14
14
  "import": "./dist/index.mjs",
15
15
  "require": "./dist/index.cjs"
16
16
  },
@@ -19,6 +19,7 @@
19
19
  "sideEffects": true,
20
20
  "files": [
21
21
  "dist",
22
+ "types",
22
23
  "README.md"
23
24
  ],
24
25
  "repository": {
@@ -38,12 +39,12 @@
38
39
  "access": "public"
39
40
  },
40
41
  "scripts": {
41
- "build": "rm -rf dist && node scripts/build.mjs && tsc -p tsconfig.build.json",
42
+ "build": "rm -rf dist && node scripts/build.mjs",
42
43
  "lint": "tsc --noEmit -p tsconfig.json",
43
44
  "test": "node scripts/test.mjs"
44
45
  },
45
46
  "dependencies": {
46
- "@lambforge/agents": "^0.0.2",
47
+ "@lambforge/agents": "^0.0.3",
47
48
  "rxjs": "^7.8.2"
48
49
  },
49
50
  "devDependencies": {
@@ -53,5 +54,5 @@
53
54
  "happy-dom": "^21.0.4",
54
55
  "ts-action": "^11.0.0"
55
56
  },
56
- "gitHead": "01763fd9c2e883e45e6026adb8ec22c447724cea"
57
+ "gitHead": "bf64a1b9123164ecc48d8356f8cd146f182ef464"
57
58
  }
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Public types of @lambforge/agent-chat. Hand-written on purpose: the
3
+ * element is built with @rhtml/component + @rxdi/lit-html + a redux store,
4
+ * all bundled into the package - their types must not leak to your app.
5
+ * `test/public-types.check.ts` keeps this file in sync with the element.
6
+ */
7
+ import type { AgentClient, AgentErrorCode, SessionToken } from '@lambforge/agents';
8
+
9
+ export declare const TAG = 'lambforge-agent-chat';
10
+
11
+ /** Every text the chat shows - override any with `.strings`. */
12
+ export interface ChatStrings {
13
+ title: string;
14
+ open: string;
15
+ close: string;
16
+ newChat: string;
17
+ placeholder: string;
18
+ send: string;
19
+ stop: string;
20
+ thinking: string;
21
+ connecting: string;
22
+ pickAgent: string;
23
+ usedTools: string;
24
+ verifying: string;
25
+ errors: Record<AgentErrorCode | 'default', string>;
26
+ }
27
+
28
+ export declare const LOCALES: Record<string, ChatStrings>;
29
+
30
+ /** The locale's strings (by language, `bg-BG` -> `bg`) with overrides. */
31
+ export declare function stringsFor(
32
+ locale: string | null | undefined,
33
+ overrides?: Partial<ChatStrings>,
34
+ ): ChatStrings;
35
+
36
+ export declare const HOSTED_TURNSTILE_URL: string;
37
+
38
+ /** A Cloudflare Turnstile token: your own widget (sitekey) or the hosted page. */
39
+ export declare function turnstileToken(opts: {
40
+ host: HTMLElement;
41
+ sitekey?: string | null;
42
+ hostedUrl?: string | null;
43
+ }): Promise<string>;
44
+
45
+ export interface AgentChatAnswerDetail {
46
+ text: string;
47
+ agent: string;
48
+ conversationId: string;
49
+ }
50
+
51
+ /** The events of <lambforge-agent-chat> (`error` here is a CustomEvent, not the DOM ErrorEvent). */
52
+ export interface AgentChatEventMap {
53
+ /** the drawer opened or closed */
54
+ 'open-change': CustomEvent<{ open: boolean }>;
55
+ /** an answer is complete */
56
+ answer: CustomEvent<AgentChatAnswerDetail>;
57
+ error: CustomEvent<{ code: AgentErrorCode | string }>;
58
+ }
59
+
60
+ /**
61
+ * A chat with your Lambforge agent.
62
+ *
63
+ * @customElement lambforge-agent-chat
64
+ * @fires open-change - `{ open }`
65
+ * @fires answer - `{ text, agent, conversationId }`
66
+ * @fires error - `{ code }`
67
+ */
68
+ export declare class LambforgeAgentChat extends HTMLElement {
69
+ /** drawer only: the panel is open */
70
+ open: boolean;
71
+ /** drawer (launcher + panel) | inline | fullscreen */
72
+ mode: 'drawer' | 'inline' | 'fullscreen';
73
+ position: 'bottom-right' | 'bottom-left';
74
+ theme: 'light' | 'dark';
75
+ /** preferred agent (id or name) */
76
+ agent: string;
77
+ /** only these agents (comma list of ids or names); a picker when > 1 */
78
+ agents: string;
79
+ /** `en`, `bg` (default: the page's `lang`) */
80
+ locale: string;
81
+ /** the header text, attribute `title` (default: the agent's name) */
82
+ heading: string;
83
+ /** API base URL (default https://api.lambforge.com) */
84
+ url: string;
85
+ /** attribute `publishable-key`: anonymous visitors of a public page */
86
+ publishableKey: string;
87
+ /** attribute `token-url`: your endpoint answering `{ token, expiresAt }` */
88
+ tokenUrl: string;
89
+ /** attribute `turnstile-sitekey`: your own Turnstile widget */
90
+ turnstileSitekey: string;
91
+ /** attribute `turnstile-url`: another hosted Turnstile page */
92
+ turnstileUrl: string;
93
+ /** An AgentClient you built yourself (wins over the attributes). */
94
+ client?: AgentClient;
95
+ /** Your token source, when not using `token-url`. */
96
+ getToken?: () => Promise<SessionToken | string> | SessionToken | string;
97
+ /** Override any text (see ChatStrings). */
98
+ strings: Partial<ChatStrings>;
99
+ /** The texts in use (locale + overrides). */
100
+ readonly t: ChatStrings;
101
+ /** Switch to another agent of the session. */
102
+ pick(agentId: string): void;
103
+ /** Start a new conversation. */
104
+ startOver(): void;
105
+ /** Open or close the drawer. */
106
+ setOpen(open: boolean): void;
107
+
108
+ addEventListener<K extends keyof AgentChatEventMap>(
109
+ type: K,
110
+ listener: (this: LambforgeAgentChat, ev: AgentChatEventMap[K]) => unknown,
111
+ options?: boolean | AddEventListenerOptions,
112
+ ): void;
113
+ addEventListener<K extends Exclude<keyof HTMLElementEventMap, keyof AgentChatEventMap>>(
114
+ type: K,
115
+ listener: (this: LambforgeAgentChat, ev: HTMLElementEventMap[K]) => unknown,
116
+ options?: boolean | AddEventListenerOptions,
117
+ ): void;
118
+ addEventListener(
119
+ type: string,
120
+ listener: EventListenerOrEventListenerObject,
121
+ options?: boolean | AddEventListenerOptions,
122
+ ): void;
123
+ removeEventListener<K extends keyof AgentChatEventMap>(
124
+ type: K,
125
+ listener: (this: LambforgeAgentChat, ev: AgentChatEventMap[K]) => unknown,
126
+ options?: boolean | EventListenerOptions,
127
+ ): void;
128
+ removeEventListener<K extends Exclude<keyof HTMLElementEventMap, keyof AgentChatEventMap>>(
129
+ type: K,
130
+ listener: (this: LambforgeAgentChat, ev: HTMLElementEventMap[K]) => unknown,
131
+ options?: boolean | EventListenerOptions,
132
+ ): void;
133
+ removeEventListener(
134
+ type: string,
135
+ listener: EventListenerOrEventListenerObject,
136
+ options?: boolean | EventListenerOptions,
137
+ ): void;
138
+ }
139
+
140
+ declare global {
141
+ interface HTMLElementTagNameMap {
142
+ 'lambforge-agent-chat': LambforgeAgentChat;
143
+ }
144
+ }
package/dist/auto.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/dist/element.d.ts DELETED
@@ -1,142 +0,0 @@
1
- import { AgentClient, SessionToken } from '@lambforge/agents';
2
- import { LitElement } from '@rxdi/lit-html';
3
- import { Observable } from 'rxjs';
4
- import { ChatAction, ChatState, Notice } from './store';
5
- import { ChatStrings } from './strings';
6
- export declare const TAG = "lambforge-agent-chat";
7
- /** An action that needs things from the render (`Reader` of @rhtml/di). */
8
- export type Reader<T extends unknown[], R> = (deps: T) => R;
9
- /**
10
- * A visitor chat with a Lambforge agent (plan 51): a launcher + panel
11
- * (drawer), a block in the page (inline) or the whole screen.
12
- *
13
- * Style A (`@rhtml/component`) over its own `@rxdi/redux-store` store
14
- * (store/): `State` is the store's state, the view only renders it and
15
- * dispatches; requests live in ChatEffects. The store is created when
16
- * `State` starts and destroyed with the element.
17
- *
18
- * Give it ONE session source: `publishable-key` (anonymous visitors),
19
- * `token-url`, `.getToken` or `.client`.
20
- *
21
- * @customElement lambforge-agent-chat
22
- *
23
- * @attr {string} publishable-key - `lfp_...` key: anonymous visitors (Turnstile bot check)
24
- * @attr {string} token-url - your endpoint answering `{ token, expiresAt }` (signed-in visitors)
25
- * @attr {string} agent - the agent to start with (id or name)
26
- * @attr {string} agents - only these agents, comma list of ids or names (a picker when more than one)
27
- * @attr {'drawer'|'inline'|'fullscreen'} mode - default `drawer`
28
- * @attr {'bottom-right'|'bottom-left'} position - where the drawer's launcher sits
29
- * @attr {boolean} open - the drawer is open
30
- * @attr {'light'|'dark'} theme
31
- * @attr {string} locale - `en`, `bg` (default: the page's `lang`)
32
- * @attr {string} title - the header (default: the agent's name)
33
- * @attr {string} url - the API (default `https://api.lambforge.com`)
34
- * @attr {string} turnstile-sitekey - your own Turnstile widget instead of the hosted one
35
- * @attr {string} turnstile-url - the hosted bot check page
36
- *
37
- * @prop {AgentClient} client - an AgentClient you built yourself (wins over the attributes)
38
- * @prop {() => Promise<SessionToken | string>} getToken - your token source
39
- * @prop {Partial<ChatStrings>} strings - override any text
40
- *
41
- * @fires open-change - `{ open }` the drawer opened or closed
42
- * @fires answer - `{ text, agent, conversationId }` an answer arrived
43
- * @fires error - `{ code }` something failed (`cap-reached`, `limit-reached`, ...)
44
- *
45
- * @slot launcher - the drawer button's content (default: a chat icon)
46
- *
47
- * @csspart launcher
48
- * @csspart panel
49
- * @csspart header
50
- * @csspart picker
51
- * @csspart new
52
- * @csspart close
53
- * @csspart messages
54
- * @csspart message - every bubble (also `user` / `assistant`)
55
- * @csspart suggestion
56
- * @csspart status
57
- * @csspart composer
58
- * @csspart input
59
- * @csspart send
60
- *
61
- * @cssprop --lf-chat-accent - buttons, the visitor's bubbles (#4f46e5)
62
- * @cssprop --lf-chat-accent-fg
63
- * @cssprop --lf-chat-bg
64
- * @cssprop --lf-chat-fg
65
- * @cssprop --lf-chat-muted
66
- * @cssprop --lf-chat-border
67
- * @cssprop --lf-chat-bot-bg
68
- * @cssprop --lf-chat-bot-fg
69
- * @cssprop --lf-chat-user-bg
70
- * @cssprop --lf-chat-user-fg
71
- * @cssprop --lf-chat-error
72
- * @cssprop --lf-chat-radius
73
- * @cssprop --lf-chat-font
74
- * @cssprop --lf-chat-width - drawer width (380px)
75
- * @cssprop --lf-chat-height
76
- * @cssprop --lf-chat-offset - distance from the corner (20px)
77
- * @cssprop --lf-chat-z-index
78
- * @cssprop --lf-chat-launcher-size
79
- * @cssprop --lf-chat-shadow
80
- */
81
- export declare class LambforgeAgentChat extends LitElement {
82
- /** drawer only: the panel is open */
83
- open: boolean;
84
- /** drawer (launcher + panel) | inline | fullscreen */
85
- mode: 'drawer' | 'inline' | 'fullscreen';
86
- position: 'bottom-right' | 'bottom-left';
87
- theme: 'light' | 'dark';
88
- /** preferred agent (id or name) */
89
- agent: string;
90
- /** only these agents (comma list of ids or names); a picker when > 1 */
91
- agents: string;
92
- locale: string;
93
- /** the header text (default: the agent's name) */
94
- heading: string;
95
- url: string;
96
- publishableKey: string;
97
- tokenUrl: string;
98
- turnstileSitekey: string;
99
- turnstileUrl: string;
100
- /** An AgentClient you built yourself (wins over the attributes). */
101
- client?: AgentClient;
102
- /** Your token source, when not using `token-url`. */
103
- getToken?: () => Promise<SessionToken | string> | SessionToken | string;
104
- /** Override any text (see ChatStrings). */
105
- strings: Partial<ChatStrings>;
106
- private store?;
107
- private lastCount;
108
- private get shown();
109
- get t(): ChatStrings;
110
- /** Cold: <r-renderer> subscribes once; the store lives as long as that. */
111
- connect(): Observable<ChatState>;
112
- dispatch(action: ChatAction): void;
113
- OnUpdate(): void;
114
- private resolveClient;
115
- private verifyHuman;
116
- /** The (rendered) box the challenge goes into. */
117
- private turnstileBox;
118
- /** Send a message to the selected agent. */
119
- send(text: string): Reader<[ChatState], void>;
120
- /** Stop the answer in progress. */
121
- stopAnswer(): Reader<[ChatState], void>;
122
- pick(agentId: string): void;
123
- startOver(): void;
124
- setOpen(open: boolean): void;
125
- private focusInput;
126
- private submit;
127
- private onInputKey;
128
- private autosize;
129
- /** Escape closes the drawer; Tab stays inside the open dialog. */
130
- private onPanelKey;
131
- private emit;
132
- noticeText(notice: Notice | null): string;
133
- view(state: ChatState): import("lit-html").TemplateResult<1>;
134
- private bubble;
135
- private intro;
136
- private scrollDown;
137
- }
138
- declare global {
139
- interface HTMLElementTagNameMap {
140
- 'lambforge-agent-chat': LambforgeAgentChat;
141
- }
142
- }
package/dist/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export { LambforgeAgentChat, Reader, TAG } from './element';
2
- export { inline, renderMarkdown } from './markdown';
3
- export * from './store';
4
- export { ChatStrings, LOCALES, stringsFor } from './strings';
5
- export { HOSTED_TURNSTILE_URL, turnstileToken } from './turnstile';
@@ -1,3 +0,0 @@
1
- import { TemplateResult } from '@rxdi/lit-html';
2
- export declare function renderMarkdown(text: string): TemplateResult[];
3
- export declare function inline(text: string): (TemplateResult | string)[];
@@ -1,121 +0,0 @@
1
- import type { AgentEvent, ConversationDetail, EmbedAgent } from '@lambforge/agents';
2
- /** The panel is on screen (nothing loads before the first time). */
3
- export declare const shown: ((payload: boolean) => {
4
- payload: boolean;
5
- } & {
6
- type: "[chat] shown";
7
- }) & {
8
- type: "[chat] shown";
9
- };
10
- export declare const connecting: (() => {
11
- type: "[chat] connecting";
12
- }) & {
13
- type: "[chat] connecting";
14
- };
15
- export declare const failed: ((payload: string) => {
16
- payload: string;
17
- } & {
18
- type: "[chat] failed";
19
- }) & {
20
- type: "[chat] failed";
21
- };
22
- export declare const verifying: ((payload: boolean) => {
23
- payload: boolean;
24
- } & {
25
- type: "[chat] verifying";
26
- }) & {
27
- type: "[chat] verifying";
28
- };
29
- export declare const agentsLoaded: ((payload: {
30
- agents: EmbedAgent[];
31
- agentId: string | null;
32
- }) => {
33
- payload: {
34
- agents: EmbedAgent[];
35
- agentId: string | null;
36
- };
37
- } & {
38
- type: "[chat] agents loaded";
39
- }) & {
40
- type: "[chat] agents loaded";
41
- };
42
- export declare const pickAgent: ((payload: string) => {
43
- payload: string;
44
- } & {
45
- type: "[chat] pick agent";
46
- }) & {
47
- type: "[chat] pick agent";
48
- };
49
- export declare const historyLoaded: ((payload: {
50
- agentId: string;
51
- detail: ConversationDetail;
52
- }) => {
53
- payload: {
54
- agentId: string;
55
- detail: ConversationDetail;
56
- };
57
- } & {
58
- type: "[chat] history loaded";
59
- }) & {
60
- type: "[chat] history loaded";
61
- };
62
- export declare const newConversation: (() => {
63
- type: "[chat] new conversation";
64
- }) & {
65
- type: "[chat] new conversation";
66
- };
67
- /** Where a message goes / what to stop (from the state the view shows). */
68
- export interface RunTarget {
69
- agentId: string;
70
- /** null = a new conversation */
71
- conversationId: string | null;
72
- }
73
- /** The visitor sends a message (shown at once; the run effect sends it). */
74
- export declare const sendMessage: ((payload: RunTarget & {
75
- text: string;
76
- }) => {
77
- payload: RunTarget & {
78
- text: string;
79
- };
80
- } & {
81
- type: "[chat] send";
82
- }) & {
83
- type: "[chat] send";
84
- };
85
- /** Follow an answer that was already running (a page reload). */
86
- export declare const resume: ((payload: {
87
- agentId: string;
88
- conversationId: string;
89
- afterSeq: number;
90
- }) => {
91
- payload: {
92
- agentId: string;
93
- conversationId: string;
94
- afterSeq: number;
95
- };
96
- } & {
97
- type: "[chat] resume";
98
- }) & {
99
- type: "[chat] resume";
100
- };
101
- export declare const agentEvent: ((payload: AgentEvent) => {
102
- payload: AgentEvent;
103
- } & {
104
- type: "[chat] event";
105
- }) & {
106
- type: "[chat] event";
107
- };
108
- export declare const runEnded: (() => {
109
- type: "[chat] run ended";
110
- }) & {
111
- type: "[chat] run ended";
112
- };
113
- /** Stop the answer in progress (the abort effect tells the server). */
114
- export declare const stop: ((payload: RunTarget) => {
115
- payload: RunTarget;
116
- } & {
117
- type: "[chat] stop";
118
- }) & {
119
- type: "[chat] stop";
120
- };
121
- export type ChatAction = ReturnType<typeof shown | typeof connecting | typeof failed | typeof verifying | typeof agentsLoaded | typeof pickAgent | typeof historyLoaded | typeof newConversation | typeof sendMessage | typeof resume | typeof agentEvent | typeof runEnded | typeof stop>;
@@ -1,44 +0,0 @@
1
- import type { AgentClient, EmbedAgent } from '@lambforge/agents';
2
- import { ChatAction } from './chat-actions';
3
- import type { ChatState } from './chat-state';
4
- /** What the effects need from the element (no DI: one store per chat). */
5
- export interface ChatContext {
6
- /** null = no session source configured */
7
- client: AgentClient | null;
8
- /** preferred agent (id or name) */
9
- agent: string;
10
- /** only these agents (ids or names); empty = all the session allows */
11
- agents: string[];
12
- /** DOM events on the element */
13
- emit(type: 'answer' | 'error', detail: Record<string, unknown>): void;
14
- }
15
- export declare const errorCode: (e: unknown) => string;
16
- export declare function pickAgents(all: EmbedAgent[], ctx: Pick<ChatContext, 'agent' | 'agents'>): {
17
- agents: EmbedAgent[];
18
- agentId: string;
19
- };
20
- /**
21
- * The chat's side effects: every request goes through here (the element
22
- * only dispatches). Registered in ChatStore's `createEpicRegistry(...)` -
23
- * an effect not listed there never runs.
24
- */
25
- export declare class ChatEffects {
26
- private readonly ctx;
27
- constructor(ctx: ChatContext);
28
- /** The first time the panel is on screen: the agents this session may use. */
29
- connect$: import("@rxdi/redux-store").EffectFactory<ChatAction, ChatState>;
30
- /** The selected agent's latest conversation (resuming a running answer). */
31
- select$: import("@rxdi/redux-store").EffectFactory<ChatAction, ChatState>;
32
- /**
33
- * One run at a time: a sent message or a resumed answer, its events as
34
- * actions until done / error, cancelled by stop, another agent or a new
35
- * conversation.
36
- */
37
- run$: import("@rxdi/redux-store").EffectFactory<ChatAction, ChatState>;
38
- /** Tell the server to stop the answer. */
39
- abort$: import("@rxdi/redux-store").EffectFactory<ChatAction, ChatState>;
40
- /** Failures also reach the page as an `error` event. */
41
- failures$: import("@rxdi/redux-store").EffectFactory<ChatAction, ChatState>;
42
- private conversation;
43
- private follow$;
44
- }
@@ -1,2 +0,0 @@
1
- import { ChatState } from './chat-state';
2
- export declare const chatReducer: import("ts-action").Reducer<ChatState>;
@@ -1,31 +0,0 @@
1
- import type { AgentErrorCode, AgentMessage, EmbedAgent } from '@lambforge/agents';
2
- export interface ChatMessage {
3
- id: string;
4
- role: 'user' | 'assistant';
5
- text: string;
6
- /** distinct tool names the answer used */
7
- tools: string[];
8
- }
9
- export type Notice = {
10
- kind: 'busy';
11
- what: 'connecting' | 'thinking' | 'verifying';
12
- } | {
13
- kind: 'error';
14
- code: AgentErrorCode | string;
15
- } | {
16
- kind: 'info';
17
- what: 'stopped';
18
- };
19
- export interface ChatState {
20
- /** the panel has been / is on screen */
21
- shown: boolean;
22
- agents: EmbedAgent[];
23
- agentId: string | null;
24
- /** null = a new conversation (created by the first message) */
25
- conversationId: string | null;
26
- messages: ChatMessage[];
27
- answering: boolean;
28
- notice: Notice | null;
29
- }
30
- export declare const initialChatState: ChatState;
31
- export declare function toMessage(m: AgentMessage): ChatMessage;
@@ -1,18 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- import { ChatAction } from './chat-actions';
3
- import { ChatContext } from './chat-effects';
4
- import { ChatState } from './chat-state';
5
- /**
6
- * One chat's store (`@rxdi/redux-store`, like legends' AdminStore): one
7
- * reducer, the effects in ChatEffects. One per element - a page may show
8
- * several chats - created when the element's State stream starts and
9
- * destroyed when it ends.
10
- */
11
- export declare class ChatStore {
12
- private readonly destroy$;
13
- private readonly store;
14
- readonly state$: Observable<ChatState>;
15
- constructor(ctx: ChatContext, initial?: Partial<ChatState>);
16
- dispatch(action: ChatAction): void;
17
- destroy(): void;
18
- }
@@ -1,5 +0,0 @@
1
- export * from './chat-actions';
2
- export * from './chat-effects';
3
- export * from './chat-reducer';
4
- export * from './chat-state';
5
- export * from './chat-store';
package/dist/strings.d.ts DELETED
@@ -1,20 +0,0 @@
1
- import type { AgentErrorCode } from '@lambforge/agents';
2
- /** Every text the chat shows - override any with `.strings`. */
3
- export interface ChatStrings {
4
- title: string;
5
- open: string;
6
- close: string;
7
- newChat: string;
8
- placeholder: string;
9
- send: string;
10
- stop: string;
11
- thinking: string;
12
- connecting: string;
13
- pickAgent: string;
14
- usedTools: string;
15
- verifying: string;
16
- errors: Record<AgentErrorCode | 'default', string>;
17
- }
18
- export declare const LOCALES: Record<string, ChatStrings>;
19
- /** The locale's strings (by language, `bg-BG` -> `bg`) with overrides. */
20
- export declare function stringsFor(locale: string | null | undefined, overrides?: Partial<ChatStrings>): ChatStrings;
package/dist/styles.d.ts DELETED
@@ -1,2 +0,0 @@
1
- /** Shadow-DOM styles. Theme with `--lf-chat-*` variables or `::part()`. */
2
- export declare const STYLES = "\n:host {\n --_accent: var(--lf-chat-accent, #4f46e5);\n --_accent-fg: var(--lf-chat-accent-fg, #ffffff);\n --_bg: var(--lf-chat-bg, #ffffff);\n --_fg: var(--lf-chat-fg, #111827);\n --_muted: var(--lf-chat-muted, #6b7280);\n --_border: var(--lf-chat-border, #e5e7eb);\n --_bot-bg: var(--lf-chat-bot-bg, #f3f4f6);\n --_bot-fg: var(--lf-chat-bot-fg, var(--_fg));\n --_user-bg: var(--lf-chat-user-bg, var(--_accent));\n --_user-fg: var(--lf-chat-user-fg, var(--_accent-fg));\n --_error: var(--lf-chat-error, #b91c1c);\n --_radius: var(--lf-chat-radius, 12px);\n --_font: var(--lf-chat-font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);\n --_width: var(--lf-chat-width, 380px);\n --_height: var(--lf-chat-height, min(640px, calc(100vh - 120px)));\n --_offset: var(--lf-chat-offset, 20px);\n --_z: var(--lf-chat-z-index, 2147483000);\n --_launcher: var(--lf-chat-launcher-size, 56px);\n --_shadow: var(--lf-chat-shadow, 0 12px 40px rgba(0, 0, 0, 0.18));\n font-family: var(--_font);\n color: var(--_fg);\n font-size: 15px;\n line-height: 1.45;\n}\n:host([theme='dark']) {\n --_bg: var(--lf-chat-bg, #111827);\n --_fg: var(--lf-chat-fg, #f9fafb);\n --_muted: var(--lf-chat-muted, #9ca3af);\n --_border: var(--lf-chat-border, #374151);\n --_bot-bg: var(--lf-chat-bot-bg, #1f2937);\n --_error: var(--lf-chat-error, #f87171);\n}\n* { box-sizing: border-box; }\n[hidden] { display: none !important; }\nbutton { font: inherit; cursor: pointer; }\n\n.launcher {\n position: fixed;\n bottom: var(--_offset);\n right: var(--_offset);\n width: var(--_launcher);\n height: var(--_launcher);\n border-radius: 50%;\n border: 0;\n background: var(--_accent);\n color: var(--_accent-fg);\n box-shadow: var(--_shadow);\n z-index: var(--_z);\n display: grid;\n place-items: center;\n}\n:host([position='bottom-left']) .launcher { right: auto; left: var(--_offset); }\n.launcher svg { width: 26px; height: 26px; }\n\n.panel {\n display: flex;\n flex-direction: column;\n background: var(--_bg);\n color: var(--_fg);\n border: 1px solid var(--_border);\n border-radius: var(--_radius);\n overflow: hidden;\n}\n:host(:not([mode])) .panel,\n:host([mode='drawer']) .panel {\n position: fixed;\n bottom: calc(var(--_offset) + var(--_launcher) + 12px);\n right: var(--_offset);\n width: var(--_width);\n height: var(--_height);\n box-shadow: var(--_shadow);\n z-index: var(--_z);\n}\n:host([position='bottom-left']) .panel { right: auto; left: var(--_offset); }\n:host([mode='inline']) .panel { width: 100%; height: var(--lf-chat-height, 560px); }\n:host([mode='fullscreen']) .panel {\n position: fixed; inset: 0; border-radius: 0; border: 0; z-index: var(--_z);\n}\n@media (max-width: 640px) {\n :host(:not([mode])) .panel,\n :host([mode='drawer']) .panel {\n inset: 0; width: auto; height: auto; border-radius: 0; border: 0;\n height: 100dvh;\n }\n}\n\nheader {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 10px 12px;\n border-bottom: 1px solid var(--_border);\n}\nheader .title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\nheader select {\n font: inherit; color: inherit; background: transparent;\n border: 1px solid var(--_border); border-radius: 8px; padding: 4px 6px; max-width: 45%;\n}\n.icon {\n border: 0; background: transparent; color: var(--_muted);\n width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;\n}\n.icon:hover, .icon:focus-visible { background: var(--_bot-bg); color: var(--_fg); }\n.icon svg { width: 18px; height: 18px; }\n:host([mode='inline']) .close { display: none; }\n\n.messages {\n flex: 1;\n overflow-y: auto;\n padding: 14px 12px;\n display: flex;\n flex-direction: column;\n gap: 10px;\n scrollbar-width: thin;\n}\n.msg { max-width: 85%; padding: 8px 12px; border-radius: var(--_radius); overflow-wrap: anywhere; }\n.msg.user { align-self: flex-end; background: var(--_user-bg); color: var(--_user-fg); white-space: pre-wrap; }\n.msg.assistant { align-self: flex-start; background: var(--_bot-bg); color: var(--_bot-fg); }\n.msg p { margin: 0 0 6px; }\n.msg p:last-child { margin-bottom: 0; }\n.msg ul, .msg ol { margin: 4px 0 6px; padding-left: 20px; }\n.msg pre { margin: 6px 0; padding: 8px; overflow-x: auto; border-radius: 8px; background: rgba(0,0,0,0.06); font-size: 13px; }\n.msg code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }\n.msg a { color: inherit; }\n.tools { font-size: 12px; color: var(--_muted); margin-top: 4px; }\n\n.welcome { color: var(--_muted); }\n.suggestions { display: flex; flex-wrap: wrap; gap: 6px; }\n.suggestions button {\n border: 1px solid var(--_border); background: transparent; color: var(--_fg);\n border-radius: 999px; padding: 6px 10px; font-size: 13px; text-align: left;\n}\n.suggestions button:hover, .suggestions button:focus-visible { border-color: var(--_accent); }\n\n.status { font-size: 13px; color: var(--_muted); padding: 0 12px 6px; min-height: 0; }\n.status.error { color: var(--_error); }\n.dots::after { content: '...'; animation: dots 1.2s steps(4, end) infinite; display: inline-block; width: 1.2em; overflow: hidden; vertical-align: bottom; }\n@keyframes dots { from { width: 0; } to { width: 1.2em; } }\n@media (prefers-reduced-motion: reduce) { .dots::after { animation: none; } }\n\n.turnstile { padding: 0 12px 6px; }\n.turnstile iframe { border: 0; width: 100%; height: 70px; }\n\nform {\n display: flex;\n gap: 8px;\n padding: 10px 12px;\n border-top: 1px solid var(--_border);\n align-items: flex-end;\n}\ntextarea {\n flex: 1;\n resize: none;\n font: inherit;\n color: inherit;\n background: transparent;\n border: 1px solid var(--_border);\n border-radius: 10px;\n padding: 8px 10px;\n max-height: 140px;\n min-height: 40px;\n}\ntextarea:focus-visible { outline: 2px solid var(--_accent); outline-offset: 0; border-color: transparent; }\n.send {\n border: 0; border-radius: 10px; background: var(--_accent); color: var(--_accent-fg);\n padding: 0 14px; height: 40px; font-weight: 600;\n}\n.send:disabled { opacity: 0.5; cursor: default; }\n.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n";
@@ -1,12 +0,0 @@
1
- /**
2
- * A Cloudflare Turnstile token for an anonymous session. Either the site's
3
- * own widget (`sitekey`; its hostname must be one of the publishable key's
4
- * sites) or Lambforge's hosted challenge page in an iframe, which posts
5
- * the token back to this page only (`postMessage` to our origin).
6
- */
7
- export declare const HOSTED_TURNSTILE_URL = "https://lambforge.com/agent-turnstile.html";
8
- export declare function turnstileToken(opts: {
9
- host: HTMLElement;
10
- sitekey?: string | null;
11
- hostedUrl?: string | null;
12
- }): Promise<string>;