@heroui/agent 0.2.0-beta.7 → 0.2.0-beta.8

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.
@@ -0,0 +1,56 @@
1
+ // src/embed/composer-draft.ts
2
+ var AGENT_COMPOSER_DRAFT_MARKER = ":composer-draft:";
3
+ function agentComposerDraftStorageKey(conversationStorageKey, conversationId) {
4
+ return `${conversationStorageKey}${AGENT_COMPOSER_DRAFT_MARKER}${conversationId}:v1`;
5
+ }
6
+ async function readAgentComposerImageDraft(key, now = Date.now()) {
7
+ try {
8
+ const drafts = await import("./composer-image-draft-IVJ352E6.js");
9
+ return await drafts.readAgentComposerImageDraft(key, now);
10
+ } catch {
11
+ return [];
12
+ }
13
+ }
14
+ async function saveAgentComposerImageDraft(key, files, now = Date.now()) {
15
+ try {
16
+ const drafts = await import("./composer-image-draft-IVJ352E6.js");
17
+ await drafts.saveAgentComposerImageDraft(key, files, now);
18
+ } catch {
19
+ }
20
+ }
21
+ async function clearAgentComposerDraft(key) {
22
+ try {
23
+ localStorage.removeItem(key);
24
+ } catch {
25
+ }
26
+ try {
27
+ const drafts = await import("./composer-image-draft-IVJ352E6.js");
28
+ await drafts.clearAgentComposerImageDraft(key);
29
+ } catch {
30
+ }
31
+ }
32
+ async function clearAgentComposerDraftsForProject(agentId) {
33
+ const prefix = `heroui-agent:conversation:${agentId}:`;
34
+ try {
35
+ for (let index = localStorage.length - 1; index >= 0; index -= 1) {
36
+ const key = localStorage.key(index);
37
+ if (key?.startsWith(prefix) && key.includes(AGENT_COMPOSER_DRAFT_MARKER)) {
38
+ localStorage.removeItem(key);
39
+ }
40
+ }
41
+ } catch {
42
+ }
43
+ try {
44
+ const drafts = await import("./composer-image-draft-IVJ352E6.js");
45
+ await drafts.clearAgentComposerImageDraftsForProject(prefix);
46
+ } catch {
47
+ }
48
+ }
49
+
50
+ export {
51
+ agentComposerDraftStorageKey,
52
+ readAgentComposerImageDraft,
53
+ saveAgentComposerImageDraft,
54
+ clearAgentComposerDraft,
55
+ clearAgentComposerDraftsForProject
56
+ };
@@ -62,55 +62,15 @@ function ScrollShadow({
62
62
  );
63
63
  }
64
64
 
65
- // ../agent-ui/src/utils/inline-markdown.tsx
66
- import { jsx as jsx2 } from "react/jsx-runtime";
67
- var INLINE_TOKEN = /(\*\*[^*\n]+\*\*|\*[^*\s][^*\n]*\*|_[^_\s][^_\n]*_|`[^`\n]+`|\[[^\]\n]+\]\([^\s)\n]+\))/g;
68
- var LINK_TOKEN = /^\[([^\]]+)\]\(([^\s)]+)\)$/;
69
- var BARE_DOMAIN = /^(?:[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?\.)+[a-z]{2,63}(?::\d{1,5})?(?:[/?#][^\s]*)?$/i;
70
- function resolveLinkHref(target) {
71
- const href = /^https?:\/\//i.test(target) ? target : BARE_DOMAIN.test(target) ? `https://${target}` : void 0;
72
- if (!href) return void 0;
73
- try {
74
- const url = new URL(href);
75
- return url.protocol === "http:" || url.protocol === "https:" ? href : void 0;
76
- } catch {
77
- return void 0;
78
- }
79
- }
80
- function renderInlineMarkdown(text) {
81
- const parts = text.split(INLINE_TOKEN);
82
- if (parts.length === 1) return text;
83
- const occurrences = /* @__PURE__ */ new Map();
84
- return parts.map((part) => {
85
- const occurrence = (occurrences.get(part) ?? 0) + 1;
86
- const key = `${part}:${occurrence}`;
87
- occurrences.set(part, occurrence);
88
- if (part.startsWith("**") && part.endsWith("**") && part.length > 4)
89
- return /* @__PURE__ */ jsx2("strong", { children: part.slice(2, -2) }, key);
90
- if (part.startsWith("*") && part.endsWith("*") && part.length > 2)
91
- return /* @__PURE__ */ jsx2("em", { children: part.slice(1, -1) }, key);
92
- if (part.startsWith("_") && part.endsWith("_") && part.length > 2)
93
- return /* @__PURE__ */ jsx2("em", { children: part.slice(1, -1) }, key);
94
- if (part.startsWith("`") && part.endsWith("`") && part.length > 2)
95
- return /* @__PURE__ */ jsx2("code", { children: part.slice(1, -1) }, key);
96
- const link = LINK_TOKEN.exec(part);
97
- const target = link?.[2];
98
- const href = target ? resolveLinkHref(target) : void 0;
99
- if (link && href)
100
- return /* @__PURE__ */ jsx2("a", { href, rel: "noopener noreferrer", target: "_blank", children: link[1] }, key);
101
- return part;
102
- });
103
- }
104
-
105
65
  // ../agent-ui/src/components/actions/action-button.tsx
106
- import { jsx as jsx3 } from "react/jsx-runtime";
66
+ import { jsx as jsx2 } from "react/jsx-runtime";
107
67
  function ActionButton({
108
68
  className,
109
69
  size = "sm",
110
70
  variant = "secondary",
111
71
  ...props
112
72
  }) {
113
- return /* @__PURE__ */ jsx3(
73
+ return /* @__PURE__ */ jsx2(
114
74
  "button",
115
75
  {
116
76
  className: mergeClassNames("aui-button", className),
@@ -126,7 +86,7 @@ function ActionButton({
126
86
  // ../agent-ui/src/components/display-information/code-block.tsx
127
87
  import { Button } from "@heroui/react";
128
88
  import { useEffect as useEffect2, useRef as useRef2, useState } from "react";
129
- import { jsx as jsx4, jsxs } from "react/jsx-runtime";
89
+ import { jsx as jsx3, jsxs } from "react/jsx-runtime";
130
90
  var COPY_RESET_DELAY = 2e3;
131
91
  var DEFAULT_DARK_THEME = "github-dark";
132
92
  var DEFAULT_LIGHT_THEME = "github-light";
@@ -207,7 +167,7 @@ async function copyText(text) {
207
167
  }
208
168
  }
209
169
  function CodeGlyph() {
210
- return /* @__PURE__ */ jsx4("svg", { "aria-hidden": "true", fill: "none", viewBox: "0 0 16 16", children: /* @__PURE__ */ jsx4(
170
+ return /* @__PURE__ */ jsx3("svg", { "aria-hidden": "true", fill: "none", viewBox: "0 0 16 16", children: /* @__PURE__ */ jsx3(
211
171
  "path",
212
172
  {
213
173
  clipRule: "evenodd",
@@ -218,7 +178,7 @@ function CodeGlyph() {
218
178
  ) });
219
179
  }
220
180
  function CopyGlyph() {
221
- return /* @__PURE__ */ jsx4("svg", { "aria-hidden": "true", fill: "none", viewBox: "0 0 16 16", children: /* @__PURE__ */ jsx4(
181
+ return /* @__PURE__ */ jsx3("svg", { "aria-hidden": "true", fill: "none", viewBox: "0 0 16 16", children: /* @__PURE__ */ jsx3(
222
182
  "path",
223
183
  {
224
184
  clipRule: "evenodd",
@@ -229,7 +189,7 @@ function CopyGlyph() {
229
189
  ) });
230
190
  }
231
191
  function CheckGlyph() {
232
- return /* @__PURE__ */ jsx4("svg", { "aria-hidden": "true", fill: "none", viewBox: "0 0 16 16", children: /* @__PURE__ */ jsx4(
192
+ return /* @__PURE__ */ jsx3("svg", { "aria-hidden": "true", fill: "none", viewBox: "0 0 16 16", children: /* @__PURE__ */ jsx3(
233
193
  "path",
234
194
  {
235
195
  clipRule: "evenodd",
@@ -278,10 +238,10 @@ function CodeBlock({ code, language = "text" }) {
278
238
  return /* @__PURE__ */ jsxs("div", { className: "aui-code", "data-slot": "agent-ui-code-block", children: [
279
239
  /* @__PURE__ */ jsxs("header", { className: "aui-code__header", "data-slot": "agent-ui-code-header", children: [
280
240
  /* @__PURE__ */ jsxs("span", { className: "aui-code__language", children: [
281
- /* @__PURE__ */ jsx4(CodeGlyph, {}),
282
- /* @__PURE__ */ jsx4("span", { children: language.toUpperCase() })
241
+ /* @__PURE__ */ jsx3(CodeGlyph, {}),
242
+ /* @__PURE__ */ jsx3("span", { children: language.toUpperCase() })
283
243
  ] }),
284
- /* @__PURE__ */ jsx4(
244
+ /* @__PURE__ */ jsx3(
285
245
  Button,
286
246
  {
287
247
  isIconOnly: true,
@@ -298,28 +258,27 @@ function CodeBlock({ code, language = "text" }) {
298
258
  "data-copied": copied || void 0,
299
259
  "data-slot": "agent-ui-code-copy-icon",
300
260
  children: [
301
- /* @__PURE__ */ jsx4("span", { className: "aui-code__copy-icon aui-code__copy-icon--copy", children: /* @__PURE__ */ jsx4(CopyGlyph, {}) }),
302
- /* @__PURE__ */ jsx4("span", { className: "aui-code__copy-icon aui-code__copy-icon--check", children: /* @__PURE__ */ jsx4(CheckGlyph, {}) })
261
+ /* @__PURE__ */ jsx3("span", { className: "aui-code__copy-icon aui-code__copy-icon--copy", children: /* @__PURE__ */ jsx3(CopyGlyph, {}) }),
262
+ /* @__PURE__ */ jsx3("span", { className: "aui-code__copy-icon aui-code__copy-icon--check", children: /* @__PURE__ */ jsx3(CheckGlyph, {}) })
303
263
  ]
304
264
  }
305
265
  )
306
266
  }
307
267
  )
308
268
  ] }),
309
- highlighted?.key === highlightKey ? /* @__PURE__ */ jsx4(
269
+ highlighted?.key === highlightKey ? /* @__PURE__ */ jsx3(
310
270
  "div",
311
271
  {
312
272
  className: "aui-code__content",
313
273
  dangerouslySetInnerHTML: { __html: highlighted.html },
314
274
  "data-slot": "agent-ui-code"
315
275
  }
316
- ) : /* @__PURE__ */ jsx4("div", { className: "aui-code__content", "data-slot": "agent-ui-code", children: /* @__PURE__ */ jsx4("pre", { children: /* @__PURE__ */ jsx4("code", { children: code }) }) })
276
+ ) : /* @__PURE__ */ jsx3("div", { className: "aui-code__content", "data-slot": "agent-ui-code", children: /* @__PURE__ */ jsx3("pre", { children: /* @__PURE__ */ jsx3("code", { children: code }) }) })
317
277
  ] });
318
278
  }
319
279
 
320
280
  export {
321
281
  ActionButton,
322
282
  ScrollShadow,
323
- renderInlineMarkdown,
324
283
  CodeBlock
325
284
  };
@@ -0,0 +1,43 @@
1
+ // ../agent-ui/src/utils/inline-markdown.tsx
2
+ import { jsx } from "react/jsx-runtime";
3
+ var INLINE_TOKEN = /(\*\*[^*\n]+\*\*|\*[^*\s][^*\n]*\*|_[^_\s][^_\n]*_|`[^`\n]+`|\[[^\]\n]+\]\([^\s)\n]+\))/g;
4
+ var LINK_TOKEN = /^\[([^\]]+)\]\(([^\s)]+)\)$/;
5
+ var BARE_DOMAIN = /^(?:[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?\.)+[a-z]{2,63}(?::\d{1,5})?(?:[/?#][^\s]*)?$/i;
6
+ function resolveLinkHref(target) {
7
+ const href = /^https?:\/\//i.test(target) ? target : BARE_DOMAIN.test(target) ? `https://${target}` : void 0;
8
+ if (!href) return void 0;
9
+ try {
10
+ const url = new URL(href);
11
+ return url.protocol === "http:" || url.protocol === "https:" ? href : void 0;
12
+ } catch {
13
+ return void 0;
14
+ }
15
+ }
16
+ function renderInlineMarkdown(text) {
17
+ const parts = text.split(INLINE_TOKEN);
18
+ if (parts.length === 1) return text;
19
+ const occurrences = /* @__PURE__ */ new Map();
20
+ return parts.map((part) => {
21
+ const occurrence = (occurrences.get(part) ?? 0) + 1;
22
+ const key = `${part}:${occurrence}`;
23
+ occurrences.set(part, occurrence);
24
+ if (part.startsWith("**") && part.endsWith("**") && part.length > 4)
25
+ return /* @__PURE__ */ jsx("strong", { children: part.slice(2, -2) }, key);
26
+ if (part.startsWith("*") && part.endsWith("*") && part.length > 2)
27
+ return /* @__PURE__ */ jsx("em", { children: part.slice(1, -1) }, key);
28
+ if (part.startsWith("_") && part.endsWith("_") && part.length > 2)
29
+ return /* @__PURE__ */ jsx("em", { children: part.slice(1, -1) }, key);
30
+ if (part.startsWith("`") && part.endsWith("`") && part.length > 2)
31
+ return /* @__PURE__ */ jsx("code", { children: part.slice(1, -1) }, key);
32
+ const link = LINK_TOKEN.exec(part);
33
+ const target = link?.[2];
34
+ const href = target ? resolveLinkHref(target) : void 0;
35
+ if (link && href)
36
+ return /* @__PURE__ */ jsx("a", { href, rel: "noopener noreferrer", target: "_blank", children: link[1] }, key);
37
+ return part;
38
+ });
39
+ }
40
+
41
+ export {
42
+ renderInlineMarkdown
43
+ };
@@ -0,0 +1,42 @@
1
+ // src/embed/composer-prompt-draft.ts
2
+ var AGENT_COMPOSER_DRAFT_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1e3;
3
+ function readAgentComposerPromptDraft(key, now = Date.now()) {
4
+ if (typeof window === "undefined") return "";
5
+ try {
6
+ const raw = window.localStorage.getItem(key);
7
+ if (!raw) return "";
8
+ const parsed = JSON.parse(raw);
9
+ const isFresh = typeof parsed.savedAt === "number" && now - parsed.savedAt <= AGENT_COMPOSER_DRAFT_MAX_AGE_MS;
10
+ if (!isFresh || typeof parsed.prompt !== "string" || !parsed.prompt.trim()) {
11
+ window.localStorage.removeItem(key);
12
+ return "";
13
+ }
14
+ return parsed.prompt;
15
+ } catch {
16
+ try {
17
+ window.localStorage.removeItem(key);
18
+ } catch {
19
+ }
20
+ return "";
21
+ }
22
+ }
23
+ function saveAgentComposerPromptDraft(key, prompt, now = Date.now()) {
24
+ if (typeof window === "undefined") return;
25
+ try {
26
+ if (!prompt.trim()) {
27
+ window.localStorage.removeItem(key);
28
+ return;
29
+ }
30
+ window.localStorage.setItem(
31
+ key,
32
+ JSON.stringify({ prompt, savedAt: now })
33
+ );
34
+ } catch {
35
+ }
36
+ }
37
+
38
+ export {
39
+ AGENT_COMPOSER_DRAFT_MAX_AGE_MS,
40
+ readAgentComposerPromptDraft,
41
+ saveAgentComposerPromptDraft
42
+ };