@lumerahq/ui 0.7.6 → 0.8.0-dev.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 (38) hide show
  1. package/dist/RecordSheet-CI_6QC-a.js +38151 -0
  2. package/dist/{api-BrhR_Jjl.js → api-Da1IIWDG.js} +1 -1
  3. package/dist/{automations-XN4WPV_g.js → automations-BEBG7FqJ.js} +160 -26
  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 +376 -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-38mi922Z.js +19 -0
  18. package/dist/hooks/index.d.ts +1 -0
  19. package/dist/hooks/index.d.ts.map +1 -1
  20. package/dist/hooks/index.js +6 -5
  21. package/dist/hooks/use-agent-chat.d.ts +47 -0
  22. package/dist/hooks/use-agent-chat.d.ts.map +1 -0
  23. package/dist/index.js +51 -45
  24. package/dist/lib/bridge.d.ts +71 -5
  25. package/dist/lib/bridge.d.ts.map +1 -1
  26. package/dist/lib/index.d.ts +1 -1
  27. package/dist/lib/index.d.ts.map +1 -1
  28. package/dist/lib/index.js +29 -26
  29. package/dist/logo.svg +15 -0
  30. package/dist/mermaid-GHXKKRXX-CdpO_nzu.js +4 -0
  31. package/dist/ui.css +254 -2
  32. package/dist/use-automation-run-rhYZZhj7.js +746 -0
  33. package/dist/{use-sql-table-B7C06_An.js → use-sql-table-1EiZ9qCa.js} +2 -2
  34. package/package.json +2 -1
  35. package/dist/RecordSheet-BvHHP8P4.js +0 -12241
  36. package/dist/logo.png +0 -0
  37. package/dist/lumera-logo.png +0 -0
  38. package/dist/use-automation-run-Cecvf4Aq.js +0 -134
@@ -1,4 +1,4 @@
1
- import { p as parentApiRequest, B as BridgeError } from "./automations-XN4WPV_g.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}`;
@@ -20,6 +20,40 @@ const EXPECTED_PARENT_ORIGINS = uniqueStrings([
20
20
  ...parseParentOrigins(void 0),
21
21
  EXPECTED_PARENT_ORIGIN
22
22
  ]);
23
+ const BRIDGE_WINDOW_NAME_PREFIX = "__lumera_bridge__=";
24
+ const normalizeConfiguredParentOrigins = (origins) => uniqueStrings((origins ?? []).map((origin) => origin.trim()).filter(Boolean));
25
+ const mergeBridgeRuntimeConfig = (current, next) => ({
26
+ parentOrigins: normalizeConfiguredParentOrigins([...current.parentOrigins ?? [], ...next?.parentOrigins ?? []])
27
+ });
28
+ const parseBridgeRuntimeConfig = (raw) => {
29
+ try {
30
+ const parsed = JSON.parse(raw);
31
+ return {
32
+ parentOrigins: normalizeConfiguredParentOrigins(parsed.parentOrigins)
33
+ };
34
+ } catch {
35
+ return {};
36
+ }
37
+ };
38
+ const readBridgeRuntimeConfigFromWindowName = () => {
39
+ if (typeof window === "undefined") return {};
40
+ const token = window.name.split(/\s+/).find((part) => part.startsWith(BRIDGE_WINDOW_NAME_PREFIX));
41
+ if (!token) return {};
42
+ const encoded = token.slice(BRIDGE_WINDOW_NAME_PREFIX.length);
43
+ if (!encoded) return {};
44
+ try {
45
+ return parseBridgeRuntimeConfig(decodeURIComponent(encoded));
46
+ } catch {
47
+ return {};
48
+ }
49
+ };
50
+ let bridgeRuntimeConfig = readBridgeRuntimeConfigFromWindowName();
51
+ const trustedParentOrigins = () => uniqueStrings([...EXPECTED_PARENT_ORIGINS, ...bridgeRuntimeConfig.parentOrigins ?? []]);
52
+ const serializeBridgeRuntimeConfig = (config) => {
53
+ const normalized = normalizeConfiguredParentOrigins(config.parentOrigins);
54
+ if (normalized.length === 0) return "";
55
+ return `${BRIDGE_WINDOW_NAME_PREFIX}${encodeURIComponent(JSON.stringify({ parentOrigins: normalized }))}`;
56
+ };
23
57
  class BridgeError extends Error {
24
58
  status;
25
59
  response;
@@ -31,6 +65,7 @@ class BridgeError extends Error {
31
65
  }
32
66
  }
33
67
  const pendingRequests = /* @__PURE__ */ new Map();
68
+ const pendingStreams = /* @__PURE__ */ new Map();
34
69
  const initListeners = /* @__PURE__ */ new Set();
35
70
  let listenerAttached = false;
36
71
  let routeSyncAttached = false;
@@ -132,7 +167,7 @@ const matchesOriginPattern = (origin, pattern) => {
132
167
  const isAllowedParentOrigin = (origin, currentOrigin) => {
133
168
  if (!origin) return false;
134
169
  if (origin === currentOrigin) return true;
135
- return EXPECTED_PARENT_ORIGINS.some((pattern) => matchesOriginPattern(origin, pattern));
170
+ return trustedParentOrigins().some((pattern) => matchesOriginPattern(origin, pattern));
136
171
  };
137
172
  const PLAYGROUND_FLAG = "__playground__";
138
173
  const isPlaygroundMode = () => typeof window !== "undefined" && window.self !== window.top && window.name.includes(PLAYGROUND_FLAG);
@@ -182,6 +217,14 @@ const playgroundApiRequest = async (request2) => {
182
217
  };
183
218
  }
184
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
+ };
185
228
  const isStandaloneDevMode = () => false;
186
229
  const getCurrentRouteSnapshot = () => ({
187
230
  pathname: window.location.pathname,
@@ -268,10 +311,45 @@ const ensureRouteSync = () => {
268
311
  postRouteChange("replace");
269
312
  });
270
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
+ };
271
348
  const handleMessage = (event) => {
349
+ const allowedOrigins = trustedParentOrigins();
272
350
  if (!isAllowedParentOrigin(event.origin, window.location.origin)) {
273
351
  log("Ignoring message from unexpected origin", {
274
- expected: EXPECTED_PARENT_ORIGINS,
352
+ expected: allowedOrigins,
275
353
  received: event.origin,
276
354
  current: window.location.origin
277
355
  });
@@ -296,6 +374,10 @@ const handleMessage = (event) => {
296
374
  }
297
375
  return;
298
376
  }
377
+ if (type === "stream-response") {
378
+ handleStreamResponse(payload);
379
+ return;
380
+ }
299
381
  if (type === "route-sync") {
300
382
  applyRouteSyncFromParent(payload);
301
383
  }
@@ -306,6 +388,9 @@ const ensureListener = () => {
306
388
  window.addEventListener("message", handleMessage);
307
389
  ensureRouteSync();
308
390
  };
391
+ const configureBridge = (config) => {
392
+ bridgeRuntimeConfig = mergeBridgeRuntimeConfig(bridgeRuntimeConfig, config);
393
+ };
309
394
  const isEmbedded = () => typeof window !== "undefined" && window.self !== window.top;
310
395
  const postReadyMessage = () => {
311
396
  if (typeof window === "undefined") return;
@@ -397,13 +482,59 @@ const parentApiRequest = async (request2) => {
397
482
  ...request2.headers
398
483
  },
399
484
  body: request2.body,
400
- isBase64: request2.isBase64
485
+ isBase64: request2.isBase64,
486
+ fileName: request2.fileName,
487
+ formFieldName: request2.formFieldName
401
488
  }
402
489
  },
403
490
  "*"
404
491
  );
405
492
  });
406
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
+ };
407
538
  const API_PREFIX = "/api";
408
539
  const TERMINAL_STATUSES = ["succeeded", "failed", "cancelled"];
409
540
  const ACTIVE_STATUSES = ["preparing", "queued", "running", "cancelling"];
@@ -633,34 +764,37 @@ async function listRunsByExternalId(params) {
633
764
  });
634
765
  }
635
766
  export {
636
- pollAutomationRun as A,
767
+ listRuns as A,
637
768
  BridgeError as B,
638
- pollRun as C,
769
+ listRunsByAgent as C,
770
+ listRunsByExternalId as D,
639
771
  EXPECTED_PARENT_ORIGIN as E,
772
+ pollAutomationRun as F,
773
+ pollRun as G,
640
774
  getShareableAppUrl as a,
641
- postReadyMessage as b,
642
- automationStatuses as c,
643
- cancelAutomationRun as d,
644
- cancelRun as e,
645
- clearAutomationCache as f,
775
+ parentApiStream as b,
776
+ configureBridge as c,
777
+ postReadyMessage as d,
778
+ automationStatuses as e,
779
+ cancelAutomationRun as f,
646
780
  getAppProjectExternalId as g,
647
- createAutomationRun as h,
781
+ cancelRun as h,
648
782
  isEmbedded as i,
649
- createRun as j,
650
- ensureAutomationRun as k,
651
- ensureRun as l,
652
- getAutomationByExternalId as m,
653
- getAutomationRun as n,
783
+ clearAutomationCache as j,
784
+ createAutomationRun as k,
785
+ createRun as l,
786
+ ensureAutomationRun as m,
787
+ ensureRun as n,
654
788
  onInitMessage as o,
655
789
  parentApiRequest as p,
656
- getAutomationRunFileDownloadUrl as q,
657
- getRun as r,
658
- getRunFiles as s,
659
- getRunFileUrl as t,
660
- isActiveStatus as u,
661
- isTerminalStatus as v,
662
- listAutomationRunFiles as w,
663
- listRuns as x,
664
- listRunsByAgent as y,
665
- listRunsByExternalId as z
790
+ getAutomationByExternalId as q,
791
+ getAutomationRun as r,
792
+ serializeBridgeRuntimeConfig as s,
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
666
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, AgentChatRenderers, AgentChatResizableWidthOptions, 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,kBAAkB,EAClB,8BAA8B,EAC9B,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,EAKjB,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;AAkFxE,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,+BAA+B,GACvC,kBAAkB,CAAC,iBAAiB,EAAE,OAAO,EAAE,OAAO,CAAC,CA4GzD"}