@lumerahq/ui 0.7.7 → 0.8.0-dev.1

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 (40) hide show
  1. package/dist/RecordSheet-DjPTM9r2.js +38195 -0
  2. package/dist/{api-DXN1wKkz.js → api-Da1IIWDG.js} +1 -1
  3. package/dist/{automations-OzVpAuzv.js → automations-BEBG7FqJ.js} +118 -24
  4. package/dist/components/agent-chat/AgentChat.d.ts +3 -0
  5. package/dist/components/agent-chat/AgentChat.d.ts.map +1 -0
  6. package/dist/components/agent-chat/index.d.ts +5 -0
  7. package/dist/components/agent-chat/index.d.ts.map +1 -0
  8. package/dist/components/agent-chat/lumera-agent-transport.d.ts +20 -0
  9. package/dist/components/agent-chat/lumera-agent-transport.d.ts.map +1 -0
  10. package/dist/components/agent-chat/types.d.ts +400 -0
  11. package/dist/components/agent-chat/types.d.ts.map +1 -0
  12. package/dist/components/index.d.ts +2 -0
  13. package/dist/components/index.d.ts.map +1 -1
  14. package/dist/components/index.js +8 -6
  15. package/dist/components/ui/button.d.ts +1 -1
  16. package/dist/{formatters-Baj7FkeG.js → formatters-D4T821Dv.js} +2 -1
  17. package/dist/highlighted-body-OFNGDK62-B8uWyiQv.js +19 -0
  18. package/dist/hooks/index.d.ts +2 -0
  19. package/dist/hooks/index.d.ts.map +1 -1
  20. package/dist/hooks/index.js +11 -9
  21. package/dist/hooks/use-agent-chat-sessions.d.ts +21 -0
  22. package/dist/hooks/use-agent-chat-sessions.d.ts.map +1 -0
  23. package/dist/hooks/use-agent-chat.d.ts +47 -0
  24. package/dist/hooks/use-agent-chat.d.ts.map +1 -0
  25. package/dist/index.js +54 -49
  26. package/dist/lib/bridge.d.ts +46 -0
  27. package/dist/lib/bridge.d.ts.map +1 -1
  28. package/dist/lib/index.d.ts +1 -1
  29. package/dist/lib/index.d.ts.map +1 -1
  30. package/dist/lib/index.js +27 -26
  31. package/dist/logo.svg +15 -0
  32. package/dist/mermaid-GHXKKRXX-Cm-NNxwL.js +4 -0
  33. package/dist/ui.css +254 -2
  34. package/dist/use-automation-run-rhYZZhj7.js +746 -0
  35. package/dist/{use-sql-table-DSt5nL70.js → use-sql-table-MilCekNQ.js} +104 -9
  36. package/package.json +2 -1
  37. package/dist/RecordSheet-M1ux7vW7.js +0 -12241
  38. package/dist/logo.png +0 -0
  39. package/dist/lumera-logo.png +0 -0
  40. package/dist/use-automation-run-hQ7DMZ8f.js +0 -134
@@ -1,4 +1,4 @@
1
- import { p as parentApiRequest, B as BridgeError } from "./automations-OzVpAuzv.js";
1
+ import { p as parentApiRequest, B as BridgeError } from "./automations-BEBG7FqJ.js";
2
2
  const API_PREFIX = "/api";
3
3
  const buildUrl = (path) => {
4
4
  const normalized = path.startsWith("/") ? path : `/${path}`;
@@ -65,6 +65,7 @@ class BridgeError extends Error {
65
65
  }
66
66
  }
67
67
  const pendingRequests = /* @__PURE__ */ new Map();
68
+ const pendingStreams = /* @__PURE__ */ new Map();
68
69
  const initListeners = /* @__PURE__ */ new Set();
69
70
  let listenerAttached = false;
70
71
  let routeSyncAttached = false;
@@ -216,6 +217,14 @@ const playgroundApiRequest = async (request2) => {
216
217
  };
217
218
  }
218
219
  };
220
+ const playgroundApiStream = (handlers) => {
221
+ const id = "playground-stream";
222
+ setTimeout(() => {
223
+ handlers.onError?.(new BridgeError("Streaming is not available in playground mode", 501));
224
+ handlers.onClose?.();
225
+ }, 0);
226
+ return { id, close: () => void 0 };
227
+ };
219
228
  const isStandaloneDevMode = () => false;
220
229
  const getCurrentRouteSnapshot = () => ({
221
230
  pathname: window.location.pathname,
@@ -302,6 +311,40 @@ const ensureRouteSync = () => {
302
311
  postRouteChange("replace");
303
312
  });
304
313
  };
314
+ const clearPendingStream = (id) => {
315
+ const stream = pendingStreams.get(id);
316
+ if (!stream) return void 0;
317
+ pendingStreams.delete(id);
318
+ if (stream.timeoutId) clearTimeout(stream.timeoutId);
319
+ return stream;
320
+ };
321
+ const handleStreamResponse = (payload) => {
322
+ if (!payload?.id) return;
323
+ const stream = pendingStreams.get(payload.id);
324
+ if (!stream) {
325
+ log("No pending stream found for response id", payload.id);
326
+ return;
327
+ }
328
+ switch (payload.type) {
329
+ case "open":
330
+ stream.handlers.onOpen?.(payload);
331
+ return;
332
+ case "chunk":
333
+ stream.handlers.onChunk(payload.chunk);
334
+ return;
335
+ case "error": {
336
+ clearPendingStream(payload.id);
337
+ stream.handlers.onError?.(new BridgeError(payload.error, payload.status));
338
+ stream.handlers.onClose?.();
339
+ return;
340
+ }
341
+ case "close": {
342
+ clearPendingStream(payload.id);
343
+ stream.handlers.onClose?.();
344
+ return;
345
+ }
346
+ }
347
+ };
305
348
  const handleMessage = (event) => {
306
349
  const allowedOrigins = trustedParentOrigins();
307
350
  if (!isAllowedParentOrigin(event.origin, window.location.origin)) {
@@ -331,6 +374,10 @@ const handleMessage = (event) => {
331
374
  }
332
375
  return;
333
376
  }
377
+ if (type === "stream-response") {
378
+ handleStreamResponse(payload);
379
+ return;
380
+ }
334
381
  if (type === "route-sync") {
335
382
  applyRouteSyncFromParent(payload);
336
383
  }
@@ -435,13 +482,59 @@ const parentApiRequest = async (request2) => {
435
482
  ...request2.headers
436
483
  },
437
484
  body: request2.body,
438
- isBase64: request2.isBase64
485
+ isBase64: request2.isBase64,
486
+ fileName: request2.fileName,
487
+ formFieldName: request2.formFieldName
439
488
  }
440
489
  },
441
490
  "*"
442
491
  );
443
492
  });
444
493
  };
494
+ const parentApiStream = (request2, handlers) => {
495
+ if (isPlaygroundMode()) {
496
+ return playgroundApiStream(handlers);
497
+ }
498
+ if (typeof window === "undefined" || !isEmbedded()) {
499
+ throw new BridgeError("App must be embedded in the Lumera host to stream API responses");
500
+ }
501
+ ensureListener();
502
+ const id = generateId();
503
+ const timeout = request2.timeout;
504
+ const timeoutId = timeout ? setTimeout(() => {
505
+ clearPendingStream(id);
506
+ window.parent.postMessage({ type: "stream-cancel", payload: { id } }, "*");
507
+ handlers.onError?.(new BridgeError(`Stream timed out after ${timeout}ms`, 408));
508
+ handlers.onClose?.();
509
+ }, timeout) : void 0;
510
+ pendingStreams.set(id, { handlers, timeoutId });
511
+ window.parent.postMessage(
512
+ {
513
+ type: "stream-request",
514
+ payload: {
515
+ id,
516
+ method: request2.method,
517
+ url: request2.url,
518
+ headers: {
519
+ Accept: "text/event-stream",
520
+ "X-Lumera-Client": "lumera-custom-app",
521
+ ...request2.headers
522
+ },
523
+ body: request2.body,
524
+ isBase64: request2.isBase64
525
+ }
526
+ },
527
+ "*"
528
+ );
529
+ return {
530
+ id,
531
+ close: () => {
532
+ const stream = clearPendingStream(id);
533
+ if (!stream) return;
534
+ window.parent.postMessage({ type: "stream-cancel", payload: { id } }, "*");
535
+ }
536
+ };
537
+ };
445
538
  const API_PREFIX = "/api";
446
539
  const TERMINAL_STATUSES = ["succeeded", "failed", "cancelled"];
447
540
  const ACTIVE_STATUSES = ["preparing", "queued", "running", "cancelling"];
@@ -671,36 +764,37 @@ async function listRunsByExternalId(params) {
671
764
  });
672
765
  }
673
766
  export {
674
- listRunsByAgent as A,
767
+ listRuns as A,
675
768
  BridgeError as B,
676
- listRunsByExternalId as C,
677
- pollAutomationRun as D,
769
+ listRunsByAgent as C,
770
+ listRunsByExternalId as D,
678
771
  EXPECTED_PARENT_ORIGIN as E,
679
- pollRun as F,
772
+ pollAutomationRun as F,
773
+ pollRun as G,
680
774
  getShareableAppUrl as a,
681
- postReadyMessage as b,
775
+ parentApiStream as b,
682
776
  configureBridge as c,
683
- automationStatuses as d,
684
- cancelAutomationRun as e,
685
- cancelRun as f,
777
+ postReadyMessage as d,
778
+ automationStatuses as e,
779
+ cancelAutomationRun as f,
686
780
  getAppProjectExternalId as g,
687
- clearAutomationCache as h,
781
+ cancelRun as h,
688
782
  isEmbedded as i,
689
- createAutomationRun as j,
690
- createRun as k,
691
- ensureAutomationRun as l,
692
- ensureRun as m,
693
- getAutomationByExternalId as n,
783
+ clearAutomationCache as j,
784
+ createAutomationRun as k,
785
+ createRun as l,
786
+ ensureAutomationRun as m,
787
+ ensureRun as n,
694
788
  onInitMessage as o,
695
789
  parentApiRequest as p,
696
- getAutomationRun as q,
697
- getAutomationRunFileDownloadUrl as r,
790
+ getAutomationByExternalId as q,
791
+ getAutomationRun as r,
698
792
  serializeBridgeRuntimeConfig as s,
699
- getRun as t,
700
- getRunFiles as u,
701
- getRunFileUrl as v,
702
- isActiveStatus as w,
703
- isTerminalStatus as x,
704
- listAutomationRunFiles as y,
705
- listRuns as z
793
+ getAutomationRunFileDownloadUrl as t,
794
+ getRun as u,
795
+ getRunFiles as v,
796
+ getRunFileUrl as w,
797
+ isActiveStatus as x,
798
+ isTerminalStatus as y,
799
+ listAutomationRunFiles as z
706
800
  };
@@ -0,0 +1,3 @@
1
+ import { AgentChatMetadata, AgentChatProps } from './types';
2
+ export declare function AgentChat<TMeta extends AgentChatMetadata = AgentChatMetadata, TToolInput = unknown, TActionData = unknown>({ agentId, sessionId, agent, name, description, transport, initialMessages, initialPage, historyLimit, maxBufferedMessages, maxQueuedMessages, disabled, className, labels: labelOverrides, features, renderers, onMessagesChange, onTurnComplete, onError, children, }: AgentChatProps<TMeta, TToolInput, TActionData>): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=AgentChat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentChat.d.ts","sourceRoot":"","sources":["../../../src/components/agent-chat/AgentChat.tsx"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAMV,iBAAiB,EAEjB,cAAc,EAIf,MAAM,SAAS,CAAC;AAajB,wBAAgB,SAAS,CACvB,KAAK,SAAS,iBAAiB,GAAG,iBAAiB,EACnD,UAAU,GAAG,OAAO,EACpB,WAAW,GAAG,OAAO,EACrB,EACA,OAAO,EACP,SAAS,EACT,KAAK,EACL,IAAI,EACJ,WAAW,EACX,SAAS,EACT,eAAe,EACf,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,QAAQ,EACR,SAAS,EACT,MAAM,EAAE,cAAc,EACtB,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,OAAO,EACP,QAAQ,GACT,EAAE,cAAc,CAAC,KAAK,EAAE,UAAU,EAAE,WAAW,CAAC,2CAyNhD"}
@@ -0,0 +1,5 @@
1
+ export { AgentChat } from './AgentChat';
2
+ export type { LumeraAgentChatTransportOptions } from './lumera-agent-transport';
3
+ export { createLumeraAgentChatTransport } from './lumera-agent-transport';
4
+ export type { AgentChatAbortRequest, AgentChatAction, AgentChatActionBlock, AgentChatActiveStatus, AgentChatAgentProfile, AgentChatAgentRequest, AgentChatBlockRendererProps, AgentChatComposerActions, AgentChatComposerRendererProps, AgentChatComposerState, AgentChatContentBlock, AgentChatCustomBlock, AgentChatFeatureFlags, AgentChatFile, AgentChatFileBlock, AgentChatHistoryPage, AgentChatHistoryRequest, AgentChatHistoryResult, AgentChatID, AgentChatInfoBlock, AgentChatLabels, AgentChatLoadEarlierRequest, AgentChatMessage, AgentChatMessageRendererProps, AgentChatMessageRole, AgentChatMetadata, AgentChatOperationStatus, AgentChatPendingFile, AgentChatPhase, AgentChatProps, AgentChatRenameSessionRequest, AgentChatRenderers, AgentChatResizableWidthOptions, AgentChatSession, AgentChatSessionListRequest, AgentChatSessionListResult, AgentChatStreamEvent, AgentChatStreamHandlers, AgentChatSubmitInput, AgentChatSubmitResult, AgentChatSubscription, AgentChatTerminalStatus, AgentChatTextBlock, AgentChatThinkingBlock, AgentChatTokenUsage, AgentChatToolCall, AgentChatToolCallBlock, AgentChatTransport, AgentChatTurn, AgentChatTurnStatus, } from './types';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/agent-chat/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,+BAA+B,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAE1E,YAAY,EACV,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,EAC3B,wBAAwB,EACxB,8BAA8B,EAC9B,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,2BAA2B,EAC3B,gBAAgB,EAChB,6BAA6B,EAC7B,oBAAoB,EACpB,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,6BAA6B,EAC7B,kBAAkB,EAClB,8BAA8B,EAC9B,gBAAgB,EAChB,2BAA2B,EAC3B,0BAA0B,EAC1B,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,aAAa,EACb,mBAAmB,GACpB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { BridgeRequest, BridgeResponse, BridgeStream, parentApiStream } from '../../lib/bridge';
2
+ import { AgentChatMetadata, AgentChatSubmitInput, AgentChatTransport } from './types';
3
+ export interface LumeraAgentChatTransportOptions {
4
+ agentId: string;
5
+ sessionId?: string;
6
+ historyLimit?: number;
7
+ streamWaitMs?: number;
8
+ reconnectDelayMs?: number;
9
+ maxReconnects?: number;
10
+ model?: string;
11
+ systemPrompt?: string;
12
+ webSearchEnabled?: boolean;
13
+ startBody?: (input: AgentChatSubmitInput, body: Record<string, unknown>) => Record<string, unknown>;
14
+ request?: (request: BridgeRequest) => Promise<BridgeResponse>;
15
+ stream?: (request: BridgeRequest, handlers: LumeraBridgeStreamHandlers) => BridgeStream;
16
+ }
17
+ type LumeraBridgeStreamHandlers = Parameters<typeof parentApiStream>[1];
18
+ export declare function createLumeraAgentChatTransport(options: LumeraAgentChatTransportOptions): AgentChatTransport<AgentChatMetadata, unknown, unknown>;
19
+ export {};
20
+ //# sourceMappingURL=lumera-agent-transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lumera-agent-transport.d.ts","sourceRoot":"","sources":["../../../src/components/agent-chat/lumera-agent-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,EAAiC,eAAe,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EAQV,iBAAiB,EAOjB,oBAAoB,EAIpB,kBAAkB,EAEnB,MAAM,SAAS,CAAC;AAQjB,MAAM,WAAW,+BAA+B;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpG,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IAC9D,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,0BAA0B,KAAK,YAAY,CAAC;CACzF;AAED,KAAK,0BAA0B,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AAkGxE,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,+BAA+B,GACvC,kBAAkB,CAAC,iBAAiB,EAAE,OAAO,EAAE,OAAO,CAAC,CAkIzD"}
@@ -0,0 +1,400 @@
1
+ import { ComponentType, ReactNode } from 'react';
2
+ /** Stable string id used by Lumera chat transports. */
3
+ export type AgentChatID = string;
4
+ /** JSON-compatible metadata bag for app-specific extensions. */
5
+ export type AgentChatMetadata = Record<string, unknown>;
6
+ /** Chat roles understood by the base component. */
7
+ export type AgentChatMessageRole = 'user' | 'assistant' | 'system';
8
+ /** Live/queued statuses for a user request turn. */
9
+ export type AgentChatActiveStatus = 'queued' | 'claimed' | 'preparing' | 'submitting' | 'running';
10
+ /** Terminal statuses for a user request turn. */
11
+ export type AgentChatTerminalStatus = 'completed' | 'failed' | 'interrupted' | 'aborted';
12
+ /** Any request-turn status the component can render. */
13
+ export type AgentChatTurnStatus = AgentChatActiveStatus | AgentChatTerminalStatus;
14
+ /** Coarse UI phase for the chat surface. */
15
+ export type AgentChatPhase = 'idle' | 'loading-history' | 'loading-earlier' | 'submitting' | 'streaming' | 'aborting' | 'error';
16
+ export interface AgentChatAgentProfile<TMeta extends AgentChatMetadata = AgentChatMetadata> {
17
+ id?: AgentChatID;
18
+ name?: string;
19
+ description?: string;
20
+ avatarUrl?: string;
21
+ metadata?: TMeta;
22
+ }
23
+ export interface AgentChatAgentRequest {
24
+ agentId?: string;
25
+ }
26
+ /** Agent conversation metadata shown in a session picker. */
27
+ export interface AgentChatSession<TMeta extends AgentChatMetadata = AgentChatMetadata> {
28
+ id: AgentChatID;
29
+ name?: string;
30
+ createdAt?: string;
31
+ lastUsedAt?: string;
32
+ metadata?: TMeta;
33
+ }
34
+ export interface AgentChatSessionListRequest {
35
+ agentId?: string;
36
+ }
37
+ export interface AgentChatSessionListResult<TMeta extends AgentChatMetadata = AgentChatMetadata> {
38
+ sessions: AgentChatSession<TMeta>[];
39
+ /** Backend-selected/default active session, usually the most recently used session. */
40
+ activeSessionId?: AgentChatID;
41
+ metadata?: TMeta;
42
+ }
43
+ export interface AgentChatRenameSessionRequest {
44
+ agentId?: string;
45
+ sessionId: AgentChatID;
46
+ name: string;
47
+ }
48
+ /** Token accounting reported by a transport or stream. */
49
+ export interface AgentChatTokenUsage {
50
+ input: number;
51
+ output: number;
52
+ cacheRead?: number;
53
+ cacheWrite?: number;
54
+ total?: number;
55
+ cost?: {
56
+ input?: number;
57
+ output?: number;
58
+ cacheRead?: number;
59
+ cacheWrite?: number;
60
+ total?: number;
61
+ };
62
+ }
63
+ /** File or artifact shown in the chat transcript. */
64
+ export interface AgentChatFile {
65
+ id?: AgentChatID;
66
+ name: string;
67
+ url?: string;
68
+ mimeType?: string;
69
+ size?: number;
70
+ objectKey?: string;
71
+ metadata?: AgentChatMetadata;
72
+ }
73
+ /** File selected by the user before submit. */
74
+ export interface AgentChatPendingFile {
75
+ id: AgentChatID;
76
+ file?: File;
77
+ name: string;
78
+ mimeType?: string;
79
+ size?: number;
80
+ previewUrl?: string;
81
+ upload?: AgentChatFile;
82
+ status?: 'pending' | 'uploading' | 'uploaded' | 'failed';
83
+ error?: string;
84
+ metadata?: AgentChatMetadata;
85
+ }
86
+ /** Lifecycle state for a tool/action block. */
87
+ export type AgentChatOperationStatus = 'running' | 'completed' | 'error';
88
+ /** Tool call emitted by an agent runtime. */
89
+ export interface AgentChatToolCall<TInput = unknown, TMeta extends AgentChatMetadata = AgentChatMetadata> {
90
+ id: AgentChatID;
91
+ name: string;
92
+ input?: TInput;
93
+ output?: string;
94
+ status: AgentChatOperationStatus;
95
+ error?: string;
96
+ startedAt?: string;
97
+ completedAt?: string;
98
+ exploratory?: boolean;
99
+ metadata?: TMeta;
100
+ }
101
+ /** Human-readable semantic action, optionally linked to a raw tool call. */
102
+ export interface AgentChatAction<TData = unknown, TMeta extends AgentChatMetadata = AgentChatMetadata> {
103
+ id: AgentChatID;
104
+ type: string;
105
+ label: string;
106
+ status: AgentChatOperationStatus;
107
+ icon?: string;
108
+ toolCallId?: AgentChatID;
109
+ data?: TData;
110
+ error?: string;
111
+ metadata?: TMeta;
112
+ }
113
+ export interface AgentChatTextBlock {
114
+ type: 'text';
115
+ content: string;
116
+ }
117
+ export interface AgentChatThinkingBlock {
118
+ type: 'thinking';
119
+ content: string;
120
+ }
121
+ export interface AgentChatToolCallBlock<TToolInput = unknown, TMeta extends AgentChatMetadata = AgentChatMetadata> {
122
+ type: 'tool_call';
123
+ toolCall: AgentChatToolCall<TToolInput, TMeta>;
124
+ }
125
+ export interface AgentChatActionBlock<TActionData = unknown, TMeta extends AgentChatMetadata = AgentChatMetadata> {
126
+ type: 'action';
127
+ action: AgentChatAction<TActionData, TMeta>;
128
+ }
129
+ export interface AgentChatFileBlock {
130
+ type: 'file';
131
+ file: AgentChatFile;
132
+ }
133
+ export interface AgentChatInfoBlock {
134
+ type: 'info';
135
+ content: string;
136
+ tone?: 'default' | 'success' | 'warning' | 'error';
137
+ }
138
+ export interface AgentChatCustomBlock<TPayload = unknown> {
139
+ type: 'custom';
140
+ kind: string;
141
+ payload: TPayload;
142
+ }
143
+ /** Chronological block content inside assistant/system messages. */
144
+ export type AgentChatContentBlock<TToolInput = unknown, TActionData = unknown, TMeta extends AgentChatMetadata = AgentChatMetadata> = AgentChatTextBlock | AgentChatThinkingBlock | AgentChatToolCallBlock<TToolInput, TMeta> | AgentChatActionBlock<TActionData, TMeta> | AgentChatFileBlock | AgentChatInfoBlock | AgentChatCustomBlock;
145
+ /** A message row in the chat transcript. */
146
+ export interface AgentChatMessage<TMeta extends AgentChatMetadata = AgentChatMetadata, TToolInput = unknown, TActionData = unknown> {
147
+ id: AgentChatID;
148
+ role: AgentChatMessageRole;
149
+ content: string;
150
+ /** ISO 8601 timestamp. */
151
+ timestamp?: string;
152
+ /** Lumera request/turn id. Unique for user prompts; grouping-only for assistant rows. */
153
+ requestId?: AgentChatID;
154
+ /** Backend-backed status for the request turn, usually present on user rows. */
155
+ status?: AgentChatTurnStatus;
156
+ error?: string;
157
+ errorCategory?: string;
158
+ blocks?: AgentChatContentBlock<TToolInput, TActionData, TMeta>[];
159
+ toolCalls?: AgentChatToolCall<TToolInput, TMeta>[];
160
+ files?: AgentChatFile[];
161
+ metadata?: TMeta;
162
+ }
163
+ /** Stable request/response render grouping derived from messages. */
164
+ export interface AgentChatTurn<TMeta extends AgentChatMetadata = AgentChatMetadata, TToolInput = unknown, TActionData = unknown> {
165
+ id: AgentChatID;
166
+ requestId?: AgentChatID;
167
+ user?: AgentChatMessage<TMeta, TToolInput, TActionData>;
168
+ assistants: AgentChatMessage<TMeta, TToolInput, TActionData>[];
169
+ systems?: AgentChatMessage<TMeta, TToolInput, TActionData>[];
170
+ status?: AgentChatTurnStatus;
171
+ metadata?: TMeta;
172
+ }
173
+ /** Pagination metadata returned by a history transport. */
174
+ export interface AgentChatHistoryPage {
175
+ limit: number;
176
+ hasMoreBefore: boolean;
177
+ beforeCursor?: string;
178
+ source?: string;
179
+ contextBoundary?: 'start' | 'compaction' | 'tail_limit' | string;
180
+ truncated?: boolean;
181
+ windowBytes?: number;
182
+ totalBytes?: number;
183
+ }
184
+ /** History result consumed by the chat controller. */
185
+ export interface AgentChatHistoryResult<TMeta extends AgentChatMetadata = AgentChatMetadata, TToolInput = unknown, TActionData = unknown> {
186
+ messages: AgentChatMessage<TMeta, TToolInput, TActionData>[];
187
+ /** Live/pending rows that have not yet been fully represented in messages. */
188
+ pending?: AgentChatMessage<TMeta, TToolInput, TActionData>[];
189
+ page?: AgentChatHistoryPage;
190
+ }
191
+ export interface AgentChatHistoryRequest {
192
+ agentId?: string;
193
+ sessionId: string;
194
+ limit?: number;
195
+ beforeCursor?: string;
196
+ }
197
+ export interface AgentChatSubmitInput {
198
+ message: string;
199
+ requestId?: AgentChatID;
200
+ sessionId: string;
201
+ files?: AgentChatPendingFile[];
202
+ metadata?: AgentChatMetadata;
203
+ }
204
+ export interface AgentChatSubmitResult<TMeta extends AgentChatMetadata = AgentChatMetadata, TToolInput = unknown, TActionData = unknown> {
205
+ accepted: boolean;
206
+ requestId?: AgentChatID;
207
+ sessionId?: string;
208
+ pending?: AgentChatMessage<TMeta, TToolInput, TActionData>;
209
+ error?: string;
210
+ metadata?: TMeta;
211
+ }
212
+ export interface AgentChatAbortRequest {
213
+ agentId?: string;
214
+ sessionId: string;
215
+ requestId?: AgentChatID;
216
+ }
217
+ export interface AgentChatLoadEarlierRequest {
218
+ agentId?: string;
219
+ sessionId: string;
220
+ beforeCursor: string;
221
+ limit?: number;
222
+ }
223
+ export type AgentChatStreamEvent<TMeta extends AgentChatMetadata = AgentChatMetadata, TToolInput = unknown, TActionData = unknown> = {
224
+ type: 'text_delta' | 'thinking_delta';
225
+ requestId?: AgentChatID;
226
+ delta: string;
227
+ metadata?: TMeta;
228
+ } | {
229
+ type: 'message';
230
+ message: AgentChatMessage<TMeta, TToolInput, TActionData>;
231
+ metadata?: TMeta;
232
+ } | {
233
+ type: 'tool_start' | 'tool_update' | 'tool_end';
234
+ requestId?: AgentChatID;
235
+ toolCall: AgentChatToolCall<TToolInput, TMeta>;
236
+ metadata?: TMeta;
237
+ } | {
238
+ type: 'action';
239
+ requestId?: AgentChatID;
240
+ action: AgentChatAction<TActionData, TMeta>;
241
+ metadata?: TMeta;
242
+ } | {
243
+ type: 'file';
244
+ requestId?: AgentChatID;
245
+ file: AgentChatFile;
246
+ metadata?: TMeta;
247
+ } | {
248
+ type: 'info';
249
+ requestId?: AgentChatID;
250
+ content: string;
251
+ tone?: 'default' | 'success' | 'warning' | 'error';
252
+ metadata?: TMeta;
253
+ } | {
254
+ type: 'usage';
255
+ requestId?: AgentChatID;
256
+ usage: AgentChatTokenUsage;
257
+ metadata?: TMeta;
258
+ } | {
259
+ type: 'terminal';
260
+ requestId?: AgentChatID;
261
+ status?: AgentChatTerminalStatus;
262
+ error?: string;
263
+ metadata?: TMeta;
264
+ } | {
265
+ type: 'error';
266
+ requestId?: AgentChatID;
267
+ error: string;
268
+ metadata?: TMeta;
269
+ } | {
270
+ type: 'custom';
271
+ kind: string;
272
+ payload: unknown;
273
+ requestId?: AgentChatID;
274
+ metadata?: TMeta;
275
+ };
276
+ export interface AgentChatStreamHandlers<TMeta extends AgentChatMetadata = AgentChatMetadata, TToolInput = unknown, TActionData = unknown> {
277
+ onEvent: (event: AgentChatStreamEvent<TMeta, TToolInput, TActionData>) => void;
278
+ onError?: (error: unknown) => void;
279
+ onClose?: () => void;
280
+ }
281
+ export interface AgentChatSubscription {
282
+ close: () => void;
283
+ }
284
+ /** Transport boundary for app-specific agent backends. */
285
+ export interface AgentChatTransport<TMeta extends AgentChatMetadata = AgentChatMetadata, TToolInput = unknown, TActionData = unknown> {
286
+ loadAgent?: (request: AgentChatAgentRequest) => Promise<AgentChatAgentProfile<TMeta>>;
287
+ listSessions?: (request: AgentChatSessionListRequest) => Promise<AgentChatSessionListResult<TMeta>>;
288
+ renameSession?: (request: AgentChatRenameSessionRequest) => Promise<AgentChatSession<TMeta>>;
289
+ loadHistory: (request: AgentChatHistoryRequest) => Promise<AgentChatHistoryResult<TMeta, TToolInput, TActionData>>;
290
+ sendMessage: (input: AgentChatSubmitInput) => Promise<AgentChatSubmitResult<TMeta, TToolInput, TActionData>>;
291
+ loadEarlier?: (request: AgentChatLoadEarlierRequest) => Promise<AgentChatHistoryResult<TMeta, TToolInput, TActionData>>;
292
+ subscribe?: (request: {
293
+ agentId?: string;
294
+ sessionId: string;
295
+ requestId?: AgentChatID;
296
+ }, handlers: AgentChatStreamHandlers<TMeta, TToolInput, TActionData>) => AgentChatSubscription;
297
+ abort?: (request: AgentChatAbortRequest) => Promise<void>;
298
+ uploadFile?: (file: File) => Promise<AgentChatFile>;
299
+ }
300
+ export interface AgentChatComposerState {
301
+ value: string;
302
+ pendingFiles: AgentChatPendingFile[];
303
+ disabled: boolean;
304
+ phase: AgentChatPhase;
305
+ queueLength: number;
306
+ canSubmit: boolean;
307
+ canAbort: boolean;
308
+ placeholder: string;
309
+ }
310
+ export interface AgentChatComposerActions {
311
+ setValue: (value: string) => void;
312
+ submit: () => void | Promise<void>;
313
+ abort: () => void | Promise<void>;
314
+ attachFiles?: (files: File[]) => void | Promise<void>;
315
+ removePendingFile?: (id: AgentChatID) => void;
316
+ }
317
+ export interface AgentChatMessageRendererProps<TMeta extends AgentChatMetadata = AgentChatMetadata, TToolInput = unknown, TActionData = unknown> {
318
+ message: AgentChatMessage<TMeta, TToolInput, TActionData>;
319
+ turn?: AgentChatTurn<TMeta, TToolInput, TActionData>;
320
+ isStreaming?: boolean;
321
+ isLast?: boolean;
322
+ }
323
+ export interface AgentChatBlockRendererProps<TMeta extends AgentChatMetadata = AgentChatMetadata, TToolInput = unknown, TActionData = unknown> {
324
+ block: AgentChatContentBlock<TToolInput, TActionData, TMeta>;
325
+ message: AgentChatMessage<TMeta, TToolInput, TActionData>;
326
+ isStreaming?: boolean;
327
+ }
328
+ export interface AgentChatComposerRendererProps {
329
+ state: AgentChatComposerState;
330
+ actions: AgentChatComposerActions;
331
+ }
332
+ /** Render slots for applications that need deeper visual customization. */
333
+ export interface AgentChatRenderers<TMeta extends AgentChatMetadata = AgentChatMetadata, TToolInput = unknown, TActionData = unknown> {
334
+ UserMessage?: ComponentType<AgentChatMessageRendererProps<TMeta, TToolInput, TActionData>>;
335
+ AssistantMessage?: ComponentType<AgentChatMessageRendererProps<TMeta, TToolInput, TActionData>>;
336
+ SystemMessage?: ComponentType<AgentChatMessageRendererProps<TMeta, TToolInput, TActionData>>;
337
+ ContentBlock?: ComponentType<AgentChatBlockRendererProps<TMeta, TToolInput, TActionData>>;
338
+ Composer?: ComponentType<AgentChatComposerRendererProps>;
339
+ EmptyState?: ComponentType;
340
+ ErrorState?: ComponentType<{
341
+ error: unknown;
342
+ retry?: () => void;
343
+ }>;
344
+ LoadingState?: ComponentType;
345
+ LoadEarlierButton?: ComponentType<{
346
+ loading: boolean;
347
+ onClick: () => void;
348
+ }>;
349
+ }
350
+ export interface AgentChatLabels {
351
+ placeholder?: string;
352
+ send?: string;
353
+ stop?: string;
354
+ queue?: string;
355
+ retry?: string;
356
+ loadEarlier?: string;
357
+ emptyTitle?: string;
358
+ emptyDescription?: string;
359
+ }
360
+ export interface AgentChatResizableWidthOptions {
361
+ enabled?: boolean;
362
+ defaultWidth?: number;
363
+ minWidth?: number;
364
+ maxWidth?: number;
365
+ edge?: 'left' | 'right';
366
+ storageKey?: string;
367
+ }
368
+ export interface AgentChatFeatureFlags {
369
+ attachments?: boolean;
370
+ webSearch?: boolean;
371
+ tokenUsage?: boolean;
372
+ toolDetails?: boolean;
373
+ loadEarlier?: boolean;
374
+ queueWhileStreaming?: boolean;
375
+ resizableWidth?: boolean | AgentChatResizableWidthOptions;
376
+ }
377
+ /** Public props for the future AgentChat component. */
378
+ export interface AgentChatProps<TMeta extends AgentChatMetadata = AgentChatMetadata, TToolInput = unknown, TActionData = unknown> {
379
+ agentId?: string;
380
+ sessionId?: string;
381
+ agent?: AgentChatAgentProfile<TMeta>;
382
+ name?: string;
383
+ description?: string;
384
+ transport: AgentChatTransport<TMeta, TToolInput, TActionData>;
385
+ initialMessages?: AgentChatMessage<TMeta, TToolInput, TActionData>[];
386
+ initialPage?: AgentChatHistoryPage;
387
+ historyLimit?: number;
388
+ maxBufferedMessages?: number;
389
+ maxQueuedMessages?: number;
390
+ disabled?: boolean;
391
+ className?: string;
392
+ labels?: AgentChatLabels;
393
+ features?: AgentChatFeatureFlags;
394
+ renderers?: AgentChatRenderers<TMeta, TToolInput, TActionData>;
395
+ onMessagesChange?: (messages: AgentChatMessage<TMeta, TToolInput, TActionData>[]) => void;
396
+ onTurnComplete?: (turn: AgentChatTurn<TMeta, TToolInput, TActionData>) => void;
397
+ onError?: (error: unknown) => void;
398
+ children?: ReactNode;
399
+ }
400
+ //# sourceMappingURL=types.d.ts.map