@agent-native/toolkit 0.6.0 → 0.8.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 (174) hide show
  1. package/README.md +17 -1
  2. package/agent-native.eject.json +411 -0
  3. package/dist/chat-history/ChatHistoryList.d.ts +103 -0
  4. package/dist/chat-history/ChatHistoryList.d.ts.map +1 -0
  5. package/dist/chat-history/ChatHistoryList.js +109 -0
  6. package/dist/chat-history/ChatHistoryList.js.map +1 -0
  7. package/dist/chat-history/ChatHistoryList.spec.d.ts +2 -0
  8. package/dist/chat-history/ChatHistoryList.spec.d.ts.map +1 -0
  9. package/dist/chat-history/ChatHistoryList.spec.js +283 -0
  10. package/dist/chat-history/ChatHistoryList.spec.js.map +1 -0
  11. package/dist/chat-history/index.d.ts +2 -0
  12. package/dist/chat-history/index.d.ts.map +1 -0
  13. package/dist/chat-history/index.js +2 -0
  14. package/dist/chat-history/index.js.map +1 -0
  15. package/dist/chat-history.css +314 -0
  16. package/package.json +20 -1
  17. package/src/app-shell/header-actions.tsx +84 -0
  18. package/src/app-shell/index.ts +1 -0
  19. package/src/chat-history/ChatHistoryList.spec.tsx +453 -0
  20. package/src/chat-history/ChatHistoryList.tsx +469 -0
  21. package/src/chat-history/index.ts +7 -0
  22. package/src/chat-history.css +314 -0
  23. package/src/collab-ui/AgentPresenceChip.tsx +69 -0
  24. package/src/collab-ui/LiveCursorOverlay.tsx +241 -0
  25. package/src/collab-ui/PresenceBar.tsx +346 -0
  26. package/src/collab-ui/RecentEditHighlights.tsx +225 -0
  27. package/src/collab-ui/RemoteSelectionRings.tsx +227 -0
  28. package/src/collab-ui/agent-identity.ts +16 -0
  29. package/src/collab-ui/index.ts +39 -0
  30. package/src/collab-ui/lead-client.ts +32 -0
  31. package/src/collab-ui/types.spec.ts +18 -0
  32. package/src/collab-ui/types.ts +96 -0
  33. package/src/composer/AgentComposerFrame.tsx +59 -0
  34. package/src/composer/ComposerPlusMenu.tsx +983 -0
  35. package/src/composer/MentionPopover.tsx +412 -0
  36. package/src/composer/PastedTextChip.tsx +150 -0
  37. package/src/composer/PromptComposer.spec.ts +73 -0
  38. package/src/composer/PromptComposer.tsx +718 -0
  39. package/src/composer/RealtimeVoiceMode.spec.tsx +771 -0
  40. package/src/composer/RealtimeVoiceMode.tsx +856 -0
  41. package/src/composer/TiptapComposer.spec.ts +390 -0
  42. package/src/composer/TiptapComposer.tsx +2936 -0
  43. package/src/composer/VoiceButton.spec.ts +33 -0
  44. package/src/composer/VoiceButton.tsx +255 -0
  45. package/src/composer/asset-picker-url.spec.ts +56 -0
  46. package/src/composer/asset-picker-url.ts +80 -0
  47. package/src/composer/attachment-accept.spec.ts +22 -0
  48. package/src/composer/attachment-accept.ts +71 -0
  49. package/src/composer/draft-key.spec.ts +19 -0
  50. package/src/composer/draft-key.ts +7 -0
  51. package/src/composer/extensions/FileReference.tsx +55 -0
  52. package/src/composer/extensions/MentionReference.tsx +93 -0
  53. package/src/composer/extensions/SkillReference.tsx +56 -0
  54. package/src/composer/index.ts +79 -0
  55. package/src/composer/pasted-text.spec.ts +162 -0
  56. package/src/composer/pasted-text.ts +160 -0
  57. package/src/composer/prompt-attachments.spec.ts +80 -0
  58. package/src/composer/prompt-attachments.ts +93 -0
  59. package/src/composer/realtime-voice-audio-level.spec.ts +32 -0
  60. package/src/composer/realtime-voice-audio-level.ts +64 -0
  61. package/src/composer/realtime-voice-transcript.spec.ts +95 -0
  62. package/src/composer/realtime-voice-transcript.ts +134 -0
  63. package/src/composer/runtime-adapters.tsx +343 -0
  64. package/src/composer/types.ts +66 -0
  65. package/src/composer/use-file-search.ts +64 -0
  66. package/src/composer/use-mention-search.ts +90 -0
  67. package/src/composer/use-skills.ts +45 -0
  68. package/src/composer/useRealtimeVoiceMode.spec.ts +818 -0
  69. package/src/composer/useRealtimeVoiceMode.tsx +2117 -0
  70. package/src/composer/useVoiceDictation.spec.ts +45 -0
  71. package/src/composer/useVoiceDictation.ts +1191 -0
  72. package/src/context-ui/ContextMeter.tsx +101 -0
  73. package/src/context-ui/ContextSegmentRow.tsx +184 -0
  74. package/src/context-ui/ContextTreemap.tsx +125 -0
  75. package/src/context-ui/ContextXRayPanel.tsx +377 -0
  76. package/src/context-ui/format.ts +42 -0
  77. package/src/context-ui/index.ts +15 -0
  78. package/src/context-ui/types.ts +43 -0
  79. package/src/design-tweaks/index.ts +1 -0
  80. package/src/design-tweaks/visual-style-controls.tsx +1084 -0
  81. package/src/editor/BubbleToolbar.tsx +253 -0
  82. package/src/editor/CodeBlockNode.tsx +254 -0
  83. package/src/editor/DragHandle.spec.ts +588 -0
  84. package/src/editor/DragHandle.ts +1437 -0
  85. package/src/editor/ImageExtension.roundtrip.spec.ts +117 -0
  86. package/src/editor/ImageExtension.ts +306 -0
  87. package/src/editor/RegistryBlockContext.tsx +107 -0
  88. package/src/editor/RegistryBlockNode.spec.ts +279 -0
  89. package/src/editor/RegistryBlockNode.tsx +652 -0
  90. package/src/editor/RichMarkdownEditor.collab.spec.ts +79 -0
  91. package/src/editor/RichMarkdownEditor.roundtrip.spec.ts +226 -0
  92. package/src/editor/RichMarkdownEditor.tsx +81 -0
  93. package/src/editor/RunId.ts +61 -0
  94. package/src/editor/SharedRichEditor.tsx +321 -0
  95. package/src/editor/SlashCommandMenu.tsx +310 -0
  96. package/src/editor/disableHistory.spec.ts +85 -0
  97. package/src/editor/extensions.ts +402 -0
  98. package/src/editor/gfmDoc.spec.ts +230 -0
  99. package/src/editor/gfmDoc.ts +92 -0
  100. package/src/editor/index.ts +93 -0
  101. package/src/editor/registrySlashCommands.ts +131 -0
  102. package/src/editor/structuralReorderUndo.spec.ts +144 -0
  103. package/src/editor/surgical-apply.spec.ts +279 -0
  104. package/src/editor/surgical-apply.ts +192 -0
  105. package/src/editor/useCollabReconcile.concurrent.spec.ts +422 -0
  106. package/src/editor/useCollabReconcile.idempotent.spec.ts +324 -0
  107. package/src/editor/useCollabReconcile.ts +589 -0
  108. package/src/editor.css +510 -0
  109. package/src/hooks/index.ts +2 -0
  110. package/src/hooks/use-mobile.tsx +21 -0
  111. package/src/hooks/use-toast.ts +188 -0
  112. package/src/index.ts +8 -0
  113. package/src/onboarding/index.ts +1 -0
  114. package/src/provider.tsx +47 -0
  115. package/src/sharing/VisibilityBadge.spec.ts +96 -0
  116. package/src/sharing/VisibilityBadge.tsx +37 -0
  117. package/src/sharing/index.ts +4 -0
  118. package/src/styles.css +21 -0
  119. package/src/ui/accordion.tsx +56 -0
  120. package/src/ui/alert-dialog.tsx +141 -0
  121. package/src/ui/alert.tsx +59 -0
  122. package/src/ui/aspect-ratio.tsx +5 -0
  123. package/src/ui/avatar.tsx +48 -0
  124. package/src/ui/badge.tsx +37 -0
  125. package/src/ui/breadcrumb.tsx +115 -0
  126. package/src/ui/button.tsx +78 -0
  127. package/src/ui/calendar.tsx +214 -0
  128. package/src/ui/card.tsx +86 -0
  129. package/src/ui/carousel.tsx +260 -0
  130. package/src/ui/chart.tsx +375 -0
  131. package/src/ui/checkbox.tsx +28 -0
  132. package/src/ui/collapsible.tsx +9 -0
  133. package/src/ui/command.spec.tsx +51 -0
  134. package/src/ui/command.tsx +174 -0
  135. package/src/ui/context-menu.tsx +202 -0
  136. package/src/ui/date-picker.tsx +64 -0
  137. package/src/ui/dialog.spec.tsx +43 -0
  138. package/src/ui/dialog.tsx +146 -0
  139. package/src/ui/drawer.tsx +126 -0
  140. package/src/ui/dropdown-menu.tsx +218 -0
  141. package/src/ui/form.tsx +177 -0
  142. package/src/ui/hover-card.tsx +27 -0
  143. package/src/ui/index.ts +52 -0
  144. package/src/ui/input-otp.tsx +69 -0
  145. package/src/ui/input.tsx +22 -0
  146. package/src/ui/label.tsx +24 -0
  147. package/src/ui/logo.tsx +36 -0
  148. package/src/ui/menubar.tsx +235 -0
  149. package/src/ui/navigation-menu.tsx +128 -0
  150. package/src/ui/pagination.tsx +121 -0
  151. package/src/ui/popover.tsx +44 -0
  152. package/src/ui/progress.tsx +26 -0
  153. package/src/ui/radio-group.tsx +42 -0
  154. package/src/ui/resizable.tsx +43 -0
  155. package/src/ui/scroll-area.tsx +46 -0
  156. package/src/ui/select.tsx +158 -0
  157. package/src/ui/separator.tsx +29 -0
  158. package/src/ui/sheet.tsx +160 -0
  159. package/src/ui/sidebar.tsx +777 -0
  160. package/src/ui/skeleton.tsx +18 -0
  161. package/src/ui/slider.tsx +26 -0
  162. package/src/ui/sonner.tsx +58 -0
  163. package/src/ui/spinner.tsx +17 -0
  164. package/src/ui/switch.tsx +27 -0
  165. package/src/ui/table.tsx +117 -0
  166. package/src/ui/tabs.tsx +53 -0
  167. package/src/ui/textarea.tsx +23 -0
  168. package/src/ui/toast.tsx +127 -0
  169. package/src/ui/toaster.tsx +33 -0
  170. package/src/ui/toggle-group.tsx +59 -0
  171. package/src/ui/toggle.tsx +43 -0
  172. package/src/ui/tooltip.tsx +53 -0
  173. package/src/ui/use-toast.ts +3 -0
  174. package/src/utils.ts +8 -0
@@ -0,0 +1,64 @@
1
+ import { useState, useEffect, useRef } from "react";
2
+
3
+ import { useComposerRuntimeAdapters } from "./runtime-adapters.js";
4
+ import type { FileResult } from "./types.js";
5
+
6
+ export function useFileSearch(query: string, enabled: boolean) {
7
+ const { resolvePath = (path) => path } = useComposerRuntimeAdapters();
8
+ const [files, setFiles] = useState<FileResult[]>([]);
9
+ const [isLoading, setIsLoading] = useState(false);
10
+ const requestIdRef = useRef(0);
11
+ const abortRef = useRef<AbortController | null>(null);
12
+
13
+ useEffect(() => {
14
+ if (!enabled) {
15
+ setFiles([]);
16
+ setIsLoading(false);
17
+ return;
18
+ }
19
+
20
+ setIsLoading(true);
21
+ const id = ++requestIdRef.current;
22
+ // Abort any in-flight request so a superseded/unmounted query stops fetching
23
+ // (mirrors use-mention-search). The requestId guard still protects state.
24
+ abortRef.current?.abort();
25
+ const abort = new AbortController();
26
+ abortRef.current = abort;
27
+
28
+ const timer = setTimeout(
29
+ async () => {
30
+ try {
31
+ const res = await fetch(
32
+ resolvePath(
33
+ `/_agent-native/agent-chat/files?q=${encodeURIComponent(query)}`,
34
+ ),
35
+ { signal: abort.signal },
36
+ );
37
+ if (!res.ok) throw new Error();
38
+ const data = await res.json();
39
+ // Only update if this is still the latest request
40
+ if (id === requestIdRef.current) {
41
+ setFiles(data.files || []);
42
+ }
43
+ } catch (err) {
44
+ if ((err as Error)?.name === "AbortError") return;
45
+ if (id === requestIdRef.current) {
46
+ setFiles([]);
47
+ }
48
+ } finally {
49
+ if (id === requestIdRef.current) {
50
+ setIsLoading(false);
51
+ }
52
+ }
53
+ },
54
+ query.length === 0 ? 0 : 200,
55
+ );
56
+
57
+ return () => {
58
+ clearTimeout(timer);
59
+ abort.abort();
60
+ };
61
+ }, [query, enabled, resolvePath]);
62
+
63
+ return { files, isLoading };
64
+ }
@@ -0,0 +1,90 @@
1
+ import { useState, useEffect, useRef } from "react";
2
+
3
+ import { useComposerRuntimeAdapters } from "./runtime-adapters.js";
4
+ import type { MentionItem } from "./types.js";
5
+
6
+ export function useMentionSearch(
7
+ query: string,
8
+ enabled: boolean,
9
+ resolvePathOverride?: (path: string) => string,
10
+ ) {
11
+ const { resolvePath = (path) => path } = useComposerRuntimeAdapters();
12
+ const resolveRequestPath = resolvePathOverride ?? resolvePath;
13
+ const [items, setItems] = useState<MentionItem[]>([]);
14
+ const [isLoading, setIsLoading] = useState(false);
15
+ const abortRef = useRef<AbortController | null>(null);
16
+ const requestIdRef = useRef(0);
17
+
18
+ useEffect(() => {
19
+ if (!enabled) {
20
+ setItems([]);
21
+ setIsLoading(false);
22
+ return;
23
+ }
24
+
25
+ // Cancel any in-flight stream
26
+ abortRef.current?.abort();
27
+ const abort = new AbortController();
28
+ abortRef.current = abort;
29
+ const id = ++requestIdRef.current;
30
+
31
+ setItems([]);
32
+ setIsLoading(true);
33
+
34
+ const debounceMs = query.length === 0 ? 0 : 150;
35
+
36
+ const timer = setTimeout(async () => {
37
+ try {
38
+ const res = await fetch(
39
+ resolveRequestPath(
40
+ `/_agent-native/agent-chat/mentions?q=${encodeURIComponent(query)}`,
41
+ ),
42
+ { signal: abort.signal },
43
+ );
44
+ if (!res.ok || !res.body) throw new Error();
45
+
46
+ const reader = res.body.getReader();
47
+ const decoder = new TextDecoder();
48
+ let buf = "";
49
+
50
+ while (true) {
51
+ const { done, value } = await reader.read();
52
+ if (done) break;
53
+
54
+ buf += decoder.decode(value, { stream: true });
55
+ const lines = buf.split("\n");
56
+ buf = lines.pop()!; // last line may be incomplete
57
+
58
+ for (const line of lines) {
59
+ if (!line.trim()) continue;
60
+ try {
61
+ const { items: batch } = JSON.parse(line) as {
62
+ items: MentionItem[];
63
+ };
64
+ if (id === requestIdRef.current && batch?.length) {
65
+ setItems((prev) => {
66
+ // Deduplicate by id
67
+ const seen = new Set(prev.map((x) => x.id));
68
+ const fresh = batch.filter((x) => !seen.has(x.id));
69
+ return fresh.length ? [...prev, ...fresh] : prev;
70
+ });
71
+ }
72
+ } catch {}
73
+ }
74
+ }
75
+ } catch (err: unknown) {
76
+ if (err instanceof Error && err.name === "AbortError") return;
77
+ if (id === requestIdRef.current) setItems([]);
78
+ } finally {
79
+ if (id === requestIdRef.current) setIsLoading(false);
80
+ }
81
+ }, debounceMs);
82
+
83
+ return () => {
84
+ clearTimeout(timer);
85
+ abort.abort();
86
+ };
87
+ }, [query, enabled, resolveRequestPath]);
88
+
89
+ return { items, isLoading };
90
+ }
@@ -0,0 +1,45 @@
1
+ import { useState, useEffect, useRef } from "react";
2
+
3
+ import { useComposerRuntimeAdapters } from "./runtime-adapters.js";
4
+ import type { SkillResult } from "./types.js";
5
+
6
+ export function useSkills(enabled: boolean) {
7
+ const { resolvePath = (path) => path } = useComposerRuntimeAdapters();
8
+ const [skills, setSkills] = useState<SkillResult[]>([]);
9
+ const [hint, setHint] = useState<string | undefined>();
10
+ const [isLoading, setIsLoading] = useState(false);
11
+ const requestIdRef = useRef(0);
12
+
13
+ useEffect(() => {
14
+ if (!enabled) {
15
+ return;
16
+ }
17
+
18
+ setIsLoading(true);
19
+ const id = ++requestIdRef.current;
20
+
21
+ fetch(resolvePath("/_agent-native/agent-chat/skills"))
22
+ .then((res) => {
23
+ if (!res.ok) throw new Error();
24
+ return res.json();
25
+ })
26
+ .then((data) => {
27
+ if (id === requestIdRef.current) {
28
+ setSkills(data.skills || []);
29
+ setHint(data.hint);
30
+ }
31
+ })
32
+ .catch(() => {
33
+ if (id === requestIdRef.current) {
34
+ setSkills([]);
35
+ }
36
+ })
37
+ .finally(() => {
38
+ if (id === requestIdRef.current) {
39
+ setIsLoading(false);
40
+ }
41
+ });
42
+ }, [enabled, resolvePath]);
43
+
44
+ return { skills, hint, isLoading };
45
+ }