@tangle-network/ui 11.10.0 → 11.11.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 (132) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +4 -1
  3. package/dist/active-sessions-store-Gt1R0rFG.js +262 -0
  4. package/dist/{active-sessions-store-CeOmXgv5.d.ts → active-sessions-store-nl70ZnMC.d.ts} +40 -41
  5. package/dist/artifact-pane-BL_DFWNl.d.ts +32 -0
  6. package/dist/artifact-pane-DMXT9a8U.js +70 -0
  7. package/dist/auth-DOETfnd9.js +154 -0
  8. package/dist/auth.d.ts +2 -74
  9. package/dist/auth.js +2 -16
  10. package/dist/branding-26d5ARIr.d.ts +14 -0
  11. package/dist/button-C87nEe2R.js +78 -0
  12. package/dist/button-yoIv77e2.d.ts +16 -0
  13. package/dist/chat-D4jAfEmj.js +667 -0
  14. package/dist/chat.d.ts +2 -201
  15. package/dist/chat.js +2 -31
  16. package/dist/code-block-B36KVUSN.js +165 -0
  17. package/dist/code-block-B9miUPht.d.ts +23 -0
  18. package/dist/diff-preview-BcK3nRXb.js +533 -0
  19. package/dist/document-editor-pane-BcoABlhn.d.ts +131 -0
  20. package/dist/document-editor-pane-BxlPjaTP.js +1287 -0
  21. package/dist/dropdown-menu-BpcLa5vF.js +101 -0
  22. package/dist/editor.d.ts +76 -78
  23. package/dist/editor.js +2 -34
  24. package/dist/file-format-BgXbr-Ib.js +160 -0
  25. package/dist/files-Bug33qCl.js +743 -0
  26. package/dist/files.d.ts +2 -243
  27. package/dist/files.js +3 -41
  28. package/dist/focus-BcE_SHqz.js +57 -0
  29. package/dist/format-DfcLWqMa.js +54 -0
  30. package/dist/hooks.d.ts +30 -37
  31. package/dist/hooks.js +111 -46
  32. package/dist/index-2UntyjBb.d.ts +52 -0
  33. package/dist/index-BgUHilZm.d.ts +108 -0
  34. package/dist/index-COgqsFAQ.d.ts +42 -0
  35. package/dist/index-CPDET_s1.d.ts +549 -0
  36. package/dist/index-CUhfHT_V.d.ts +204 -0
  37. package/dist/index-Cg6gYAqh.d.ts +73 -0
  38. package/dist/index-Cq-EJzqW.d.ts +16 -0
  39. package/dist/index-DhYmSaLF.d.ts +245 -0
  40. package/dist/index-DjKxO357.d.ts +128 -0
  41. package/dist/index.d.ts +26 -43
  42. package/dist/index.js +35 -472
  43. package/dist/markdown-BGqicV82.js +45 -0
  44. package/dist/markdown.d.ts +3 -18
  45. package/dist/markdown.js +3 -15
  46. package/dist/message-vhUI0c5G.d.ts +16 -0
  47. package/dist/nav.d.ts +6 -8
  48. package/dist/nav.js +29 -11
  49. package/dist/openui-artifact-renderer-D3E5bIAI.d.ts +114 -0
  50. package/dist/openui-artifact-renderer-DrU1AdVk.js +266 -0
  51. package/dist/openui.d.ts +2 -115
  52. package/dist/openui.js +2 -13
  53. package/dist/parts-5mhy9yJ3.d.ts +37 -0
  54. package/dist/primitives-Cb8GGVKr.js +1239 -0
  55. package/dist/primitives.d.ts +5 -525
  56. package/dist/primitives.js +9 -212
  57. package/dist/redaction-CGGB2ENG.js +74 -0
  58. package/dist/redaction.d.ts +2 -42
  59. package/dist/redaction.js +2 -7
  60. package/dist/run-OyWmIDqu.d.ts +41 -0
  61. package/dist/run-ZsIKPA6J.js +17 -0
  62. package/dist/run-group-BACLbCFl.js +410 -0
  63. package/dist/run.d.ts +3 -126
  64. package/dist/run.js +5 -40
  65. package/dist/sdk-hooks.d.ts +2 -285
  66. package/dist/sdk-hooks.js +3 -36
  67. package/dist/stores.d.ts +13 -14
  68. package/dist/stores.js +34 -76
  69. package/dist/table-Bss73DhB.js +146 -0
  70. package/dist/tabs-BVHR6NkO.js +40 -0
  71. package/dist/text-shimmer-BUUo6I-g.js +64 -0
  72. package/dist/tool-call-feed-BeB1_4pX.d.ts +47 -0
  73. package/dist/tool-call-feed-Djt2q11V.js +109 -0
  74. package/dist/tool-call-step-DNebqhmX.js +434 -0
  75. package/dist/tool-display-BAuAVa43.js +158 -0
  76. package/dist/{tool-display-z4JcDmMQ.d.ts → tool-display-DgmL5rIU.d.ts} +16 -16
  77. package/dist/tool-previews.d.ts +2 -48
  78. package/dist/tool-previews.js +2 -23
  79. package/dist/types.d.ts +6 -19
  80. package/dist/types.js +0 -1
  81. package/dist/use-auto-scroll-C5Pjeqon.js +153 -0
  82. package/dist/use-sse-stream-BVgO1QBN.js +884 -0
  83. package/dist/use-sse-stream-Dm6R5YWz.d.ts +282 -0
  84. package/dist/utils-Bl_CZ0Qp.js +37 -0
  85. package/dist/{chunk-RQHJBTEU.js → utils-C_uf36nf.js} +4 -6
  86. package/dist/utils.d.ts +2 -104
  87. package/dist/utils.js +6 -44
  88. package/package.json +39 -41
  89. package/src/lib/focus.ts +2 -1
  90. package/dist/artifact-pane-DpuWcAiF.d.ts +0 -33
  91. package/dist/button-CMQuQEW_.d.ts +0 -17
  92. package/dist/chunk-34A66VBG.js +0 -214
  93. package/dist/chunk-3OI2QKFD.js +0 -0
  94. package/dist/chunk-3XXBZL53.js +0 -174
  95. package/dist/chunk-42PAH5D2.js +0 -112
  96. package/dist/chunk-4CLN43XT.js +0 -45
  97. package/dist/chunk-55WHV7SS.js +0 -1604
  98. package/dist/chunk-565EATZZ.js +0 -156
  99. package/dist/chunk-5Z5ZYMOJ.js +0 -0
  100. package/dist/chunk-6BGQA4BQ.js +0 -0
  101. package/dist/chunk-BEBXZPHW.js +0 -299
  102. package/dist/chunk-C5WF4WMV.js +0 -734
  103. package/dist/chunk-HFL6R6IF.js +0 -37
  104. package/dist/chunk-HGML45QH.js +0 -104
  105. package/dist/chunk-HMAPIH7L.js +0 -595
  106. package/dist/chunk-K5XFRUS4.js +0 -1401
  107. package/dist/chunk-KFQGHD73.js +0 -198
  108. package/dist/chunk-L57WRIND.js +0 -59
  109. package/dist/chunk-LTEKI7YJ.js +0 -59
  110. package/dist/chunk-M3QZK62R.js +0 -233
  111. package/dist/chunk-ND3ZFXQK.js +0 -179
  112. package/dist/chunk-OEX7NZE3.js +0 -321
  113. package/dist/chunk-OL5GYLHV.js +0 -60
  114. package/dist/chunk-QGFYBNSO.js +0 -133
  115. package/dist/chunk-R7B3UWPF.js +0 -550
  116. package/dist/chunk-R7SUY4E3.js +0 -65
  117. package/dist/chunk-REJESC5U.js +0 -117
  118. package/dist/chunk-RQGKSCEZ.js +0 -0
  119. package/dist/chunk-SNLR2AEA.js +0 -40
  120. package/dist/chunk-WKWBTL2V.js +0 -15
  121. package/dist/chunk-X7CU776B.js +0 -1048
  122. package/dist/chunk-XU3HB5QL.js +0 -127
  123. package/dist/chunk-YTO5V6QS.js +0 -19
  124. package/dist/chunk-YU4E5J2N.js +0 -437
  125. package/dist/chunk-YZ6AK25N.js +0 -886
  126. package/dist/code-block-0kSpWMnf.d.ts +0 -25
  127. package/dist/document-editor-pane-IAEQn_Dl.d.ts +0 -128
  128. package/dist/document-editor-pane-QHDOBA43.js +0 -13
  129. package/dist/message-BHWbxBtT.d.ts +0 -15
  130. package/dist/parts-dj7AcUg0.d.ts +0 -36
  131. package/dist/run-PfLmDAox.d.ts +0 -41
  132. package/dist/tool-call-feed-D9iofJgW.d.ts +0 -46
package/dist/files.d.ts CHANGED
@@ -1,243 +1,2 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { GitStatusEntry, ContextMenuItem, ContextMenuOpenContext, GitStatus } from '@pierre/trees';
3
- import { ReactNode, CSSProperties } from 'react';
4
- import { b as DocumentEditorMode, D as DocumentEditorBackend, d as DocumentEditorPaneCollaborationConfig } from './document-editor-pane-IAEQn_Dl.js';
5
- import { a as ArtifactPaneProps } from './artifact-pane-DpuWcAiF.js';
6
- import '@hocuspocus/provider';
7
- import 'yjs';
8
-
9
- /**
10
- * FileTree — directory browser with file type icons.
11
- *
12
- * Renders a hierarchical file system view. Clicking a file
13
- * triggers onSelect with the full path.
14
- */
15
- interface FileNode {
16
- name: string;
17
- path: string;
18
- type: "file" | "directory";
19
- children?: FileNode[];
20
- size?: number;
21
- mimeType?: string;
22
- }
23
- interface FileTreeProps {
24
- root: FileNode;
25
- selectedPath?: string;
26
- onSelect?: (path: string, node: FileNode) => void;
27
- className?: string;
28
- defaultExpanded?: boolean;
29
- visibility?: FileTreeVisibilityOptions;
30
- }
31
- interface FileTreeVisibilityOptions {
32
- hiddenPaths?: string[];
33
- hiddenPathPrefixes?: string[];
34
- isVisible?: (node: FileNode) => boolean;
35
- }
36
- declare function filterFileTree(root: FileNode, visibility?: FileTreeVisibilityOptions): FileNode | null;
37
- declare function FileTree({ root, selectedPath, onSelect, className, defaultExpanded, visibility, }: FileTreeProps): react_jsx_runtime.JSX.Element | null;
38
-
39
- /**
40
- * Re-export Pierre's git-status union under a stable name so consumers
41
- * don't import directly from the dep. If we ever swap the underlying
42
- * implementation, only this file changes.
43
- */
44
- type RichFileTreeGitStatus = GitStatus;
45
- type RichFileTreeGitEntry = GitStatusEntry;
46
- interface RichFileTreeProps {
47
- /**
48
- * Either a recursive `FileNode` tree (matches the existing FileTree
49
- * input) or a flat list of canonical paths. Pass exactly one.
50
- */
51
- root?: FileNode;
52
- paths?: ReadonlyArray<string>;
53
- /** Currently-selected path. Pierre supports multi-select internally; the
54
- * wrapper exposes a single string for parity with FileTree. */
55
- selectedPath?: string;
56
- /** Called whenever the selection changes (single-select fan-out). */
57
- onSelect?: (path: string) => void;
58
- /** Show the inline search input. Defaults to true. */
59
- search?: boolean;
60
- /** Open / closed initial expansion. Defaults to "open" — match FileTree. */
61
- initialExpansion?: "open" | "closed";
62
- /** Optional git-status decorations per path. */
63
- gitStatus?: ReadonlyArray<RichFileTreeGitEntry>;
64
- /**
65
- * Right-click / button-lane menu content. Receives the row and the
66
- * trigger context (which interaction opened the menu).
67
- */
68
- renderContextMenu?: (item: ContextMenuItem, context: ContextMenuOpenContext) => ReactNode;
69
- /** Optional header rendered above the tree rows. */
70
- header?: ReactNode;
71
- /**
72
- * Theme override map for shadow-DOM CSS variables. Most consumers can
73
- * leave this — defaults derive from the host element's computed
74
- * tokens via `cssVarFromToken()`.
75
- */
76
- themeOverrides?: Partial<RichFileTreeThemeVars>;
77
- className?: string;
78
- style?: CSSProperties;
79
- /** Inline height (or set via `style.height`). Defaults to 100% of parent. */
80
- height?: number | string;
81
- }
82
- interface RichFileTreeThemeVars {
83
- /** Selected-row background. */
84
- selectedBg: string;
85
- /** Selected-row foreground. */
86
- selectedFg: string;
87
- /** Default row foreground. */
88
- fg: string;
89
- /** Hover background. */
90
- hoverBg: string;
91
- /** Border / divider color. */
92
- border: string;
93
- /** Muted (parent path, breadcrumb) foreground. */
94
- mutedFg: string;
95
- }
96
- declare function RichFileTree({ root, paths, selectedPath, onSelect, search, initialExpansion, gitStatus, renderContextMenu, header, themeOverrides, className, style, height, }: RichFileTreeProps): react_jsx_runtime.JSX.Element;
97
-
98
- /**
99
- * FilePreview — universal file renderer.
100
- *
101
- * Renders any file type:
102
- * - PDF: embedded viewer at full pane height
103
- * - Images: fit to the pane on a checker ground; click toggles natural size
104
- * - Video / audio: native players
105
- * - CSV: sticky-header table, capped at CSV_PREVIEW_ROW_LIMIT rows
106
- * - XLSX / XLS: download card
107
- * - Code (py/json/yaml/ts/js): syntax-highlighted, line-numbered viewer
108
- * - Markdown: rendered prose
109
- * - Text: monospace preview
110
- * - Anything else: text when content is a string, otherwise a download card
111
- */
112
- interface FilePreviewProps {
113
- filename: string;
114
- content?: string;
115
- /** Object URL or remote URL for binary content: images, PDF, video, audio. */
116
- blobUrl?: string;
117
- mimeType?: string;
118
- /** Size in bytes; download cards show it when known. */
119
- size?: number;
120
- onClose?: () => void;
121
- onDownload?: () => void;
122
- hideHeader?: boolean;
123
- className?: string;
124
- }
125
- /** Rows rendered by the CSV preview; the count line reports the total. */
126
- declare const CSV_PREVIEW_ROW_LIMIT = 500;
127
- /**
128
- * Split CSV text into rows of cells (RFC 4180): a quoted cell may hold commas,
129
- * line breaks, and doubled quotes. Unquoted cells are trimmed; blank lines and
130
- * a trailing line break add no row.
131
- */
132
- declare function parseCsv(content: string): string[][];
133
- declare function FilePreview({ filename, content, blobUrl, mimeType, size, onClose, onDownload, hideHeader, className, }: FilePreviewProps): react_jsx_runtime.JSX.Element;
134
-
135
- /**
136
- * FileTabs — tab bar for open files in the preview panel.
137
- */
138
- interface FileTabData {
139
- id: string;
140
- name: string;
141
- path: string;
142
- dirty?: boolean;
143
- }
144
- interface FileTabsProps {
145
- tabs: FileTabData[];
146
- activeId?: string;
147
- onSelect: (id: string) => void;
148
- onClose: (id: string) => void;
149
- className?: string;
150
- }
151
- declare function FileTabs({ tabs, activeId, onSelect, onClose, className }: FileTabsProps): react_jsx_runtime.JSX.Element | null;
152
-
153
- interface FileArtifactPaneEditorOptions {
154
- enabled?: boolean;
155
- mode?: DocumentEditorMode;
156
- defaultMode?: DocumentEditorMode;
157
- onModeChange?: (mode: DocumentEditorMode) => void;
158
- backend?: DocumentEditorBackend;
159
- collaboration?: DocumentEditorPaneCollaborationConfig;
160
- placeholder?: string;
161
- autoFocus?: boolean;
162
- readOnly?: boolean;
163
- saving?: boolean;
164
- saveLabel?: string;
165
- onChange?: (markdown: string) => void;
166
- onSave?: (markdown: string) => Promise<void> | void;
167
- previewClassName?: string;
168
- editorClassName?: string;
169
- }
170
- interface FileArtifactPaneProps extends Omit<FilePreviewProps, "className"> {
171
- path?: string;
172
- tabs?: FileTabData[];
173
- activeTabId?: string;
174
- onTabSelect?: (id: string) => void;
175
- onTabClose?: (id: string) => void;
176
- eyebrow?: ArtifactPaneProps["eyebrow"];
177
- meta?: ArtifactPaneProps["meta"];
178
- toolbar?: ArtifactPaneProps["toolbar"];
179
- footer?: ArtifactPaneProps["footer"];
180
- className?: string;
181
- headerClassName?: ArtifactPaneProps["headerClassName"];
182
- hideTitleBlock?: ArtifactPaneProps["hideTitleBlock"];
183
- editor?: FileArtifactPaneEditorOptions;
184
- }
185
- /**
186
- * FileArtifactPane — opinionated artifact frame for file previews with tabs and
187
- * header actions. The body is `FilePreview`, so every kind it renders (image,
188
- * PDF, video, audio, CSV, spreadsheet, markdown, code, text) renders here too;
189
- * `onDownload` drives both the header button and the body's download cards.
190
- */
191
- declare function FileArtifactPane({ filename, content, blobUrl, mimeType, size, onClose, onDownload, path, tabs, activeTabId, onTabSelect, onTabClose, eyebrow, meta, toolbar, footer, className, headerClassName, hideTitleBlock, editor, }: FileArtifactPaneProps): react_jsx_runtime.JSX.Element;
192
-
193
- /**
194
- * Shared file-format detection for every file surface — the preview pane, the
195
- * artifact pane, and code rendering. Centralising extension/MIME → format logic
196
- * keeps chat and artifact views consistent and avoids the same mapping drifting
197
- * across components.
198
- */
199
- type FileFormat = "pdf" | "image" | "video" | "audio" | "csv" | "spreadsheet" | "code" | "json" | "yaml" | "markdown" | "text" | "unknown";
200
- /**
201
- * How a file surface renders a file. Every format maps to its own renderer;
202
- * `unknown` becomes `binary`, which renders string content as text and offers a
203
- * download for anything else.
204
- */
205
- type FilePreviewKind = Exclude<FileFormat, "unknown"> | "binary";
206
- /**
207
- * Lowercased trailing extension. Returns "" for a name with no extension
208
- * ("README", "json" → ""), and the post-dot name for a dotfile (".bashrc" →
209
- * "bashrc"). Directory components are ignored so dots in a directory name don't
210
- * leak in ("my.config/file" → "").
211
- */
212
- declare function fileExtension(filename: string): string;
213
- /**
214
- * Resolve a filename + optional MIME type to the renderer format. A specific,
215
- * authoritative MIME type wins over the extension; otherwise the extension
216
- * decides; a generic text/plain payload is the final fallback.
217
- */
218
- declare function detectFileFormat(filename: string, mimeType?: string): FileFormat;
219
- /**
220
- * The preview renderer for a file, from its name and optional MIME type only.
221
- * Same precedence as `detectFileFormat` (MIME outranks extension); a file that
222
- * matches nothing is `binary`. Content is not an input: the preview renders a
223
- * `binary` file's string content as text and offers a download otherwise.
224
- */
225
- declare function resolveFilePreviewKind(filename: string, mimeType?: string): FilePreviewKind;
226
- /** Human-facing label for a detected format or preview kind. */
227
- declare function getFormatLabel(format: FileFormat | FilePreviewKind): string;
228
- /**
229
- * Map a filename (or path) to a highlight.js language id for CodeBlock. Returns
230
- * undefined when there is no confident mapping; CodeBlock then renders themed
231
- * monospace and lets the highlighter auto-detect, so callers never need a
232
- * bespoke language table.
233
- */
234
- declare function getSyntaxLanguage(filename: string): string | undefined;
235
- /**
236
- * Highlight language for a file already classified as a code-like format.
237
- * `json`/`yaml` are their own highlight language even when detected purely from
238
- * a MIME type on an extensionless file (where the extension can't reveal it);
239
- * any other code format keys off the extension.
240
- */
241
- declare function getCodeLanguage(filename: string, format: FileFormat | FilePreviewKind): string | undefined;
242
-
243
- export { CSV_PREVIEW_ROW_LIMIT, FileArtifactPane, type FileArtifactPaneProps, type FileFormat, type FileNode, FilePreview, type FilePreviewKind, type FilePreviewProps, type FileTabData, FileTabs, type FileTabsProps, FileTree, type FileTreeProps, type FileTreeVisibilityOptions, RichFileTree, type RichFileTreeGitEntry, type RichFileTreeGitStatus, type RichFileTreeProps, type RichFileTreeThemeVars, detectFileFormat, fileExtension, filterFileTree, getCodeLanguage, getFormatLabel, getSyntaxLanguage, parseCsv, resolveFilePreviewKind };
1
+ import { C as FileNode, D as filterFileTree, E as FileTreeVisibilityOptions, S as RichFileTreeThemeVars, T as FileTreeProps, _ as parseCsv, a as getCodeLanguage, b as RichFileTreeGitStatus, c as resolveFilePreviewKind, d as FileTabData, f as FileTabs, g as FilePreviewProps, h as FilePreview, i as fileExtension, l as FileArtifactPane, m as CSV_PREVIEW_ROW_LIMIT, n as FilePreviewKind, o as getFormatLabel, p as FileTabsProps, r as detectFileFormat, s as getSyntaxLanguage, t as FileFormat, u as FileArtifactPaneProps, v as RichFileTree, w as FileTree, x as RichFileTreeProps, y as RichFileTreeGitEntry } from "./index-DhYmSaLF.js";
2
+ export { CSV_PREVIEW_ROW_LIMIT, FileArtifactPane, type FileArtifactPaneProps, type FileFormat, type FileNode, FilePreview, type FilePreviewKind, type FilePreviewProps, type FileTabData, FileTabs, type FileTabsProps, FileTree, type FileTreeProps, type FileTreeVisibilityOptions, RichFileTree, type RichFileTreeGitEntry, type RichFileTreeGitStatus, type RichFileTreeProps, type RichFileTreeThemeVars, detectFileFormat, fileExtension, filterFileTree, getCodeLanguage, getFormatLabel, getSyntaxLanguage, parseCsv, resolveFilePreviewKind };
package/dist/files.js CHANGED
@@ -1,41 +1,3 @@
1
- import {
2
- CSV_PREVIEW_ROW_LIMIT,
3
- FileArtifactPane,
4
- FilePreview,
5
- FileTabs,
6
- FileTree,
7
- RichFileTree,
8
- filterFileTree,
9
- parseCsv
10
- } from "./chunk-YZ6AK25N.js";
11
- import "./chunk-4CLN43XT.js";
12
- import {
13
- detectFileFormat,
14
- fileExtension,
15
- getCodeLanguage,
16
- getFormatLabel,
17
- getSyntaxLanguage,
18
- resolveFilePreviewKind
19
- } from "./chunk-XU3HB5QL.js";
20
- import "./chunk-42PAH5D2.js";
21
- import "./chunk-LTEKI7YJ.js";
22
- import "./chunk-OL5GYLHV.js";
23
- import "./chunk-3XXBZL53.js";
24
- import "./chunk-WKWBTL2V.js";
25
- import "./chunk-RQHJBTEU.js";
26
- export {
27
- CSV_PREVIEW_ROW_LIMIT,
28
- FileArtifactPane,
29
- FilePreview,
30
- FileTabs,
31
- FileTree,
32
- RichFileTree,
33
- detectFileFormat,
34
- fileExtension,
35
- filterFileTree,
36
- getCodeLanguage,
37
- getFormatLabel,
38
- getSyntaxLanguage,
39
- parseCsv,
40
- resolveFilePreviewKind
41
- };
1
+ import { a as getSyntaxLanguage, i as getFormatLabel, n as fileExtension, o as resolveFilePreviewKind, r as getCodeLanguage, t as detectFileFormat } from "./file-format-BgXbr-Ib.js";
2
+ import { a as parseCsv, c as filterFileTree, i as FilePreview, n as FileTabs, o as RichFileTree, r as CSV_PREVIEW_ROW_LIMIT, s as FileTree, t as FileArtifactPane } from "./files-Bug33qCl.js";
3
+ export { CSV_PREVIEW_ROW_LIMIT, FileArtifactPane, FilePreview, FileTabs, FileTree, RichFileTree, detectFileFormat, fileExtension, filterFileTree, getCodeLanguage, getFormatLabel, getSyntaxLanguage, parseCsv, resolveFilePreviewKind };
@@ -0,0 +1,57 @@
1
+ //#region src/lib/focus.ts
2
+ /**
3
+ * The focus treatment every control shares, in two shapes over one palette
4
+ * (`--focus-border`, `--focus-halo` and `--border-strong` from
5
+ * `@tangle-network/brand`'s tokens.css).
6
+ *
7
+ * A FIELD — input, textarea, select trigger, composer — shows focus on its own
8
+ * border: the hairline shifts to `--focus-border` and a 3px `--focus-halo` ring
9
+ * spreads outside it. It keys off `:focus`, because a caret in a field needs the
10
+ * cue whether the field was clicked or tabbed into.
11
+ *
12
+ * A CONTROL — button, tab, switch, link, card — has no border to shift, so it
13
+ * draws a 1px `--focus-border` outline with the same 3px halo beyond it. It keys
14
+ * off `:focus-visible`, so a mouse click leaves no ring.
15
+ *
16
+ * The halo is a Tailwind ring, which renders as box-shadow: it follows
17
+ * border-radius and never moves layout, and a consumer removes it with
18
+ * `focus:ring-0` / `focus-visible:ring-0`, which tailwind-merge resolves against
19
+ * these classes. The control's line is an outline so that forced-colors mode,
20
+ * which drops box-shadows, still paints it. A field has its border for that, so
21
+ * it hides the outline with `outline-hidden`, which stays transparent-but-present
22
+ * in forced-colors mode.
23
+ */
24
+ /**
25
+ * Resting hairline, neutral hover, and `:focus` border plus halo for a text
26
+ * field. The hover is a plain `hover:` class so a consumer's `hover:border-*`
27
+ * replaces it through tailwind-merge; the focus border outranks it because
28
+ * Tailwind emits `focus:` after `hover:`.
29
+ */
30
+ const focusField = "border-border transition-[border-color,box-shadow] duration-150 ease-out hover:border-[var(--border-strong)] focus:outline-hidden focus:border-[var(--focus-border)] focus:ring-3 focus:ring-[var(--focus-halo)]";
31
+ /**
32
+ * The field treatment for a container that wraps a borderless field, such as a
33
+ * composer around a textarea and its buttons. It lights while a FIELD inside
34
+ * has focus: a text input, textarea, native select or contenteditable editor. A
35
+ * focused button, checkbox or button-type input inside the container shows only
36
+ * its own ring, so a click on the send button does not read as field focus and
37
+ * a tab to it does not stack two indicators. `:focus-within` cannot tell the
38
+ * two apart, so the rule keys off `:has()`; a consumer's `focus-within:*` class
39
+ * therefore does not replace it. To style that container's focus differently,
40
+ * compose your own classes instead of this helper. The field selector is
41
+ * written out in full because Tailwind reads class names statically.
42
+ * Base styles use its marker class to clear the inner editor fallback outline.
43
+ */
44
+ const focusFieldWithin = "focus-field-within border-border transition-[border-color,box-shadow] duration-150 ease-out hover:border-[var(--border-strong)] has-[:is(textarea,select,[contenteditable]:not([contenteditable=false]),input:not([type=button],[type=submit],[type=reset],[type=image],[type=checkbox],[type=radio],[type=range],[type=color],[type=file])):focus]:border-[var(--focus-border)] has-[:is(textarea,select,[contenteditable]:not([contenteditable=false]),input:not([type=button],[type=submit],[type=reset],[type=image],[type=checkbox],[type=radio],[type=range],[type=color],[type=file])):focus]:ring-3 has-[:is(textarea,select,[contenteditable]:not([contenteditable=false]),input:not([type=button],[type=submit],[type=reset],[type=image],[type=checkbox],[type=radio],[type=range],[type=color],[type=file])):focus]:ring-[var(--focus-halo)]";
45
+ /** Error state for a field: a danger hairline and the same focus shape in danger. Compose after `focusField`. */
46
+ const focusFieldInvalid = "border-[var(--surface-danger-border)] hover:border-[var(--surface-danger-border)] focus:border-[var(--focus-border-danger)] focus:ring-[var(--focus-halo-danger)]";
47
+ const focusRingBase = "focus-visible:outline-1 focus-visible:outline-[var(--focus-border)] focus-visible:ring-4 focus-visible:ring-[var(--focus-halo)]";
48
+ /** Keyboard-only focus for a control: a 1px focus line with the halo beyond it. */
49
+ const focusRing = `${focusRingBase} focus-visible:outline-offset-0`;
50
+ /**
51
+ * `focusRing` drawn inside the box, for a control flush against a scroll
52
+ * container or its neighbours (a tab strip, a list row), where an outer ring
53
+ * would be clipped or would overlap them.
54
+ */
55
+ const focusRingInset = `${focusRingBase} focus-visible:-outline-offset-1 focus-visible:ring-inset`;
56
+ //#endregion
57
+ export { focusRingInset as a, focusRing as i, focusFieldInvalid as n, focusFieldWithin as r, focusField as t };
@@ -0,0 +1,54 @@
1
+ //#region src/utils/format.ts
2
+ /** Format a duration in milliseconds to a human-readable string. */
3
+ function formatDuration(ms) {
4
+ if (ms < 1e3) return "<1s";
5
+ const seconds = Math.floor(ms / 1e3);
6
+ if (seconds < 60) return `${seconds}s`;
7
+ const minutes = Math.floor(seconds / 60);
8
+ const remaining = seconds % 60;
9
+ return remaining > 0 ? `${minutes}m ${remaining}s` : `${minutes}m`;
10
+ }
11
+ /** Truncate text to `max` characters, appending "..." if truncated. */
12
+ function truncateText(text, max) {
13
+ const cleaned = text.replace(/\s+/g, " ").trim();
14
+ if (cleaned.length <= max) return cleaned;
15
+ return cleaned.slice(0, max).trim() + "...";
16
+ }
17
+ /**
18
+ * Format an uptime duration in milliseconds with progressive
19
+ * granularity, so short-lived sandboxes don't render as "0d 0h".
20
+ * - < 60s → "Ns"
21
+ * - < 60m → "Nm Ss"
22
+ * - < 24h → "Nh Mm"
23
+ * - otherwise → "Nd Hh"
24
+ */
25
+ function formatUptime(ms) {
26
+ if (!Number.isFinite(ms) || ms < 0) return "—";
27
+ const totalSeconds = Math.floor(ms / 1e3);
28
+ if (totalSeconds < 60) return `${totalSeconds}s`;
29
+ const minutes = Math.floor(totalSeconds / 60);
30
+ const seconds = totalSeconds % 60;
31
+ if (minutes < 60) return `${minutes}m ${seconds}s`;
32
+ const hours = Math.floor(minutes / 60);
33
+ const remMinutes = minutes % 60;
34
+ if (hours < 24) return `${hours}h ${remMinutes}m`;
35
+ return `${Math.floor(hours / 24)}d ${hours % 24}h`;
36
+ }
37
+ /**
38
+ * Format a byte count using binary units (KiB/MiB/GiB, surfaced as
39
+ * "KB/MB/GB" for readability). KB and MB use one decimal below 10 and
40
+ * round above; GB keeps two decimals below 10 so half-GB changes stay
41
+ * visible on memory dashboards, and drops to one decimal above.
42
+ */
43
+ function formatBytes(bytes) {
44
+ if (!Number.isFinite(bytes) || bytes < 0) return "—";
45
+ if (bytes < 1024) return `${Math.round(bytes)} B`;
46
+ const kb = bytes / 1024;
47
+ if (kb < 1024) return `${kb < 10 ? kb.toFixed(1) : Math.round(kb)} KB`;
48
+ const mb = kb / 1024;
49
+ if (mb < 1024) return `${mb < 10 ? mb.toFixed(1) : Math.round(mb)} MB`;
50
+ const gb = mb / 1024;
51
+ return `${gb < 10 ? gb.toFixed(2) : gb.toFixed(1)} GB`;
52
+ }
53
+ //#endregion
54
+ export { truncateText as i, formatDuration as n, formatUptime as r, formatBytes as t };
package/dist/hooks.d.ts CHANGED
@@ -1,56 +1,49 @@
1
- export { AgentStreamEvent, AppendUserMessageOptions, ApplySdkEventOptions, AutomationStreamEvent, BeginAssistantMessageOptions, BotStreamEvent, CompleteAssistantMessageOptions, ConnectionState, RealtimeSessionOptions, RealtimeSessionRegistry, RealtimeSessionRegistryProps, RealtimeSessionState, RealtimeSessionTarget, SSEEvent, SdkSessionAttachment, SdkSessionEvent, SdkSessionSeed, TaskStreamEvent, TerminalStreamEvent, UseRunGroupsOptions, UseSSEStreamOptions, UseSSEStreamResult, UseSdkSessionOptions, UseSdkSessionReturn, UseToolCallStreamReturn, useAutoScroll, useDropdownMenu, useRealtimeSession, useRunCollapseState, useRunGroups, useSSEStream, useSdkSession, useToolCallStream } from './sdk-hooks.js';
2
- import 'react';
3
- import './run-PfLmDAox.js';
4
- import './message-BHWbxBtT.js';
5
- import './parts-dj7AcUg0.js';
6
- import './active-sessions-store-CeOmXgv5.js';
7
- import 'nanostores';
8
- import './tool-call-feed-D9iofJgW.js';
9
- import 'react/jsx-runtime';
10
-
1
+ import { A as useRunGroups, C as SdkSessionSeed, D as UseToolCallStreamReturn, E as useSdkSession, M as useDropdownMenu, N as useAutoScroll, O as useToolCallStream, S as SdkSessionEvent, T as UseSdkSessionReturn, _ as AppendUserMessageOptions, a as SSEEvent, b as CompleteAssistantMessageOptions, c as UseSSEStreamOptions, d as RealtimeSessionOptions, f as RealtimeSessionRegistry, g as useRealtimeSession, h as RealtimeSessionTarget, i as ConnectionState, j as useRunCollapseState, k as UseRunGroupsOptions, l as UseSSEStreamResult, m as RealtimeSessionState, n as AutomationStreamEvent, o as TaskStreamEvent, p as RealtimeSessionRegistryProps, r as BotStreamEvent, s as TerminalStreamEvent, t as AgentStreamEvent, u as useSSEStream, v as ApplySdkEventOptions, w as UseSdkSessionOptions, x as SdkSessionAttachment, y as BeginAssistantMessageOptions } from "./use-sse-stream-Dm6R5YWz.js";
2
+ //#region src/hooks/use-live-time.d.ts
11
3
  /**
12
4
  * Returns `Date.now()` and re-renders every `intervalMs` so derived
13
5
  * values like "uptime" tick forward without polling upstream data.
14
6
  */
15
- declare function useLiveTime(intervalMs?: number): number;
16
-
17
- interface AuthUser {
18
- customer_id: string;
19
- email: string;
20
- name?: string;
21
- tier: string;
22
- github?: {
23
- login: string;
24
- connected: boolean;
25
- } | null;
26
- session_expires_at?: string;
7
+ export declare function useLiveTime(intervalMs?: number): number;
8
+ //#endregion
9
+ //#region src/hooks/use-auth.d.ts
10
+ export interface AuthUser {
11
+ customer_id: string;
12
+ email: string;
13
+ name?: string;
14
+ tier: string;
15
+ github?: {
16
+ login: string;
17
+ connected: boolean;
18
+ } | null;
19
+ session_expires_at?: string;
27
20
  }
28
- interface UseAuthOptions {
29
- apiBaseUrl: string;
30
- revalidateOnFocus?: boolean;
31
- shouldRetryOnError?: boolean;
21
+ export interface UseAuthOptions {
22
+ apiBaseUrl: string;
23
+ revalidateOnFocus?: boolean;
24
+ shouldRetryOnError?: boolean;
32
25
  }
33
- interface UseAuthResult {
34
- user: AuthUser | null;
35
- isLoading: boolean;
36
- isError: boolean;
37
- error: Error | null;
38
- mutate: () => Promise<void>;
26
+ export interface UseAuthResult {
27
+ user: AuthUser | null;
28
+ isLoading: boolean;
29
+ isError: boolean;
30
+ error: Error | null;
31
+ mutate: () => Promise<void>;
39
32
  }
40
33
  /**
41
34
  * Hook for managing authentication state.
42
35
  * Fetches user session from the API and provides loading/error states.
43
36
  */
44
- declare function useAuth({ apiBaseUrl, revalidateOnFocus, shouldRetryOnError, }: UseAuthOptions): UseAuthResult;
37
+ export declare function useAuth({ apiBaseUrl, revalidateOnFocus, shouldRetryOnError }: UseAuthOptions): UseAuthResult;
45
38
  /**
46
39
  * Creates a fetcher function that includes auth credentials.
47
40
  * Uses both cookie-based session and localStorage API key for backwards compatibility.
48
41
  */
49
- declare function createAuthFetcher(_apiBaseUrl: string): <T = unknown>(url: string, options?: RequestInit) => Promise<T>;
42
+ export declare function createAuthFetcher(_apiBaseUrl: string): <T = unknown>(url: string, options?: RequestInit) => Promise<T>;
50
43
  /**
51
44
  * Hook to get the API key from localStorage.
52
45
  * For backwards compatibility with API key-based auth.
53
46
  */
54
- declare function useApiKey(): string | null;
55
-
56
- export { type AuthUser, type UseAuthOptions, type UseAuthResult, createAuthFetcher, useApiKey, useAuth, useLiveTime };
47
+ export declare function useApiKey(): string | null;
48
+ //#endregion
49
+ export { AgentStreamEvent, AppendUserMessageOptions, ApplySdkEventOptions, AutomationStreamEvent, BeginAssistantMessageOptions, BotStreamEvent, CompleteAssistantMessageOptions, ConnectionState, RealtimeSessionOptions, RealtimeSessionRegistry, RealtimeSessionRegistryProps, RealtimeSessionState, RealtimeSessionTarget, SSEEvent, SdkSessionAttachment, SdkSessionEvent, SdkSessionSeed, TaskStreamEvent, TerminalStreamEvent, UseRunGroupsOptions, UseSSEStreamOptions, UseSSEStreamResult, UseSdkSessionOptions, UseSdkSessionReturn, UseToolCallStreamReturn, useAutoScroll, useDropdownMenu, useRealtimeSession, useRunCollapseState, useRunGroups, useSSEStream, useSdkSession, useToolCallStream };
package/dist/hooks.js CHANGED
@@ -1,46 +1,111 @@
1
- import {
2
- createAuthFetcher,
3
- useApiKey,
4
- useAuth,
5
- useLiveTime
6
- } from "./chunk-REJESC5U.js";
7
- import {
8
- RealtimeSessionRegistry,
9
- useDropdownMenu,
10
- useRealtimeSession,
11
- useSSEStream,
12
- useSdkSession,
13
- useToolCallStream
14
- } from "./chunk-X7CU776B.js";
15
- import "./chunk-OEX7NZE3.js";
16
- import {
17
- useAutoScroll,
18
- useRunCollapseState,
19
- useRunGroups
20
- } from "./chunk-565EATZZ.js";
21
- import "./chunk-QGFYBNSO.js";
22
- import "./chunk-R7B3UWPF.js";
23
- import "./chunk-ND3ZFXQK.js";
24
- import "./chunk-HMAPIH7L.js";
25
- import "./chunk-L57WRIND.js";
26
- import "./chunk-4CLN43XT.js";
27
- import "./chunk-XU3HB5QL.js";
28
- import "./chunk-OL5GYLHV.js";
29
- import "./chunk-3XXBZL53.js";
30
- import "./chunk-WKWBTL2V.js";
31
- import "./chunk-RQHJBTEU.js";
32
- export {
33
- RealtimeSessionRegistry,
34
- createAuthFetcher,
35
- useApiKey,
36
- useAuth,
37
- useAutoScroll,
38
- useDropdownMenu,
39
- useLiveTime,
40
- useRealtimeSession,
41
- useRunCollapseState,
42
- useRunGroups,
43
- useSSEStream,
44
- useSdkSession,
45
- useToolCallStream
46
- };
1
+ import { n as useRunCollapseState, r as useRunGroups, t as useAutoScroll } from "./use-auto-scroll-C5Pjeqon.js";
2
+ import { a as useToolCallStream, i as useRealtimeSession, n as useSdkSession, o as useDropdownMenu, r as RealtimeSessionRegistry, t as useSSEStream } from "./use-sse-stream-BVgO1QBN.js";
3
+ import * as React from "react";
4
+ //#region src/hooks/use-live-time.ts
5
+ /**
6
+ * Returns `Date.now()` and re-renders every `intervalMs` so derived
7
+ * values like "uptime" tick forward without polling upstream data.
8
+ */
9
+ function useLiveTime(intervalMs = 1e3) {
10
+ const [now, setNow] = React.useState(() => Date.now());
11
+ React.useEffect(() => {
12
+ const delay = Math.max(Number.isFinite(intervalMs) && intervalMs > 0 ? intervalMs : 1e3, 100);
13
+ const id = window.setInterval(() => {
14
+ setNow(Date.now());
15
+ }, delay);
16
+ return () => {
17
+ window.clearInterval(id);
18
+ };
19
+ }, [intervalMs]);
20
+ return now;
21
+ }
22
+ //#endregion
23
+ //#region src/hooks/use-auth.ts
24
+ /**
25
+ * Hook for managing authentication state.
26
+ * Fetches user session from the API and provides loading/error states.
27
+ */
28
+ function useAuth({ apiBaseUrl, revalidateOnFocus = false, shouldRetryOnError = false }) {
29
+ const [user, setUser] = React.useState(null);
30
+ const [isLoading, setIsLoading] = React.useState(true);
31
+ const [error, setError] = React.useState(null);
32
+ const retryTimerRef = React.useRef(null);
33
+ const abortRef = React.useRef(null);
34
+ const fetchSession = React.useCallback(async () => {
35
+ abortRef.current?.abort();
36
+ const controller = new AbortController();
37
+ abortRef.current = controller;
38
+ setIsLoading(true);
39
+ setError(null);
40
+ try {
41
+ const res = await fetch(`${apiBaseUrl}/auth/session`, {
42
+ credentials: "include",
43
+ signal: controller.signal
44
+ });
45
+ if (!res.ok) throw new Error("Not authenticated");
46
+ const data = await res.json();
47
+ if (data.success && data.data) setUser(data.data);
48
+ else setUser(null);
49
+ } catch (err) {
50
+ if (err.name === "AbortError") return;
51
+ setError(err instanceof Error ? err : /* @__PURE__ */ new Error("Unknown error"));
52
+ setUser(null);
53
+ if (shouldRetryOnError) {
54
+ if (retryTimerRef.current) clearTimeout(retryTimerRef.current);
55
+ retryTimerRef.current = setTimeout(fetchSession, 5e3);
56
+ }
57
+ } finally {
58
+ if (!controller.signal.aborted) setIsLoading(false);
59
+ }
60
+ }, [apiBaseUrl, shouldRetryOnError]);
61
+ React.useEffect(() => {
62
+ fetchSession();
63
+ return () => {
64
+ abortRef.current?.abort();
65
+ if (retryTimerRef.current) clearTimeout(retryTimerRef.current);
66
+ };
67
+ }, [fetchSession]);
68
+ React.useEffect(() => {
69
+ if (!revalidateOnFocus) return;
70
+ const handleFocus = () => {
71
+ fetchSession();
72
+ };
73
+ window.addEventListener("focus", handleFocus);
74
+ return () => window.removeEventListener("focus", handleFocus);
75
+ }, [revalidateOnFocus, fetchSession]);
76
+ return {
77
+ user,
78
+ isLoading,
79
+ isError: !!error,
80
+ error,
81
+ mutate: fetchSession
82
+ };
83
+ }
84
+ /**
85
+ * Creates a fetcher function that includes auth credentials.
86
+ * Uses both cookie-based session and localStorage API key for backwards compatibility.
87
+ */
88
+ function createAuthFetcher(_apiBaseUrl) {
89
+ return async function authFetcher(url, options) {
90
+ const res = await fetch(url, {
91
+ ...options,
92
+ credentials: "include",
93
+ headers: { ...options?.headers }
94
+ });
95
+ if (!res.ok) throw new Error(`Request failed with status ${res.status}`);
96
+ return res.json();
97
+ };
98
+ }
99
+ /**
100
+ * Hook to get the API key from localStorage.
101
+ * For backwards compatibility with API key-based auth.
102
+ */
103
+ function useApiKey() {
104
+ const [apiKey, setApiKey] = React.useState(null);
105
+ React.useEffect(() => {
106
+ if (typeof window !== "undefined") setApiKey(localStorage.getItem("apiKey"));
107
+ }, []);
108
+ return apiKey;
109
+ }
110
+ //#endregion
111
+ export { RealtimeSessionRegistry, createAuthFetcher, useApiKey, useAuth, useAutoScroll, useDropdownMenu, useLiveTime, useRealtimeSession, useRunCollapseState, useRunGroups, useSSEStream, useSdkSession, useToolCallStream };