@agent-native/toolkit 0.6.0 → 0.7.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.
- package/README.md +17 -1
- package/dist/chat-history/ChatHistoryList.d.ts +103 -0
- package/dist/chat-history/ChatHistoryList.d.ts.map +1 -0
- package/dist/chat-history/ChatHistoryList.js +109 -0
- package/dist/chat-history/ChatHistoryList.js.map +1 -0
- package/dist/chat-history/ChatHistoryList.spec.d.ts +2 -0
- package/dist/chat-history/ChatHistoryList.spec.d.ts.map +1 -0
- package/dist/chat-history/ChatHistoryList.spec.js +283 -0
- package/dist/chat-history/ChatHistoryList.spec.js.map +1 -0
- package/dist/chat-history/index.d.ts +2 -0
- package/dist/chat-history/index.d.ts.map +1 -0
- package/dist/chat-history/index.js +2 -0
- package/dist/chat-history/index.js.map +1 -0
- package/dist/chat-history.css +314 -0
- package/package.json +17 -1
- package/src/app-shell/header-actions.tsx +84 -0
- package/src/app-shell/index.ts +1 -0
- package/src/chat-history/ChatHistoryList.spec.tsx +453 -0
- package/src/chat-history/ChatHistoryList.tsx +469 -0
- package/src/chat-history/index.ts +7 -0
- package/src/chat-history.css +314 -0
- package/src/collab-ui/AgentPresenceChip.tsx +69 -0
- package/src/collab-ui/LiveCursorOverlay.tsx +241 -0
- package/src/collab-ui/PresenceBar.tsx +346 -0
- package/src/collab-ui/RecentEditHighlights.tsx +225 -0
- package/src/collab-ui/RemoteSelectionRings.tsx +227 -0
- package/src/collab-ui/agent-identity.ts +16 -0
- package/src/collab-ui/index.ts +39 -0
- package/src/collab-ui/lead-client.ts +32 -0
- package/src/collab-ui/types.spec.ts +18 -0
- package/src/collab-ui/types.ts +96 -0
- package/src/composer/AgentComposerFrame.tsx +59 -0
- package/src/composer/ComposerPlusMenu.tsx +983 -0
- package/src/composer/MentionPopover.tsx +412 -0
- package/src/composer/PastedTextChip.tsx +150 -0
- package/src/composer/PromptComposer.spec.ts +73 -0
- package/src/composer/PromptComposer.tsx +718 -0
- package/src/composer/RealtimeVoiceMode.spec.tsx +771 -0
- package/src/composer/RealtimeVoiceMode.tsx +856 -0
- package/src/composer/TiptapComposer.spec.ts +390 -0
- package/src/composer/TiptapComposer.tsx +2936 -0
- package/src/composer/VoiceButton.spec.ts +33 -0
- package/src/composer/VoiceButton.tsx +255 -0
- package/src/composer/asset-picker-url.spec.ts +56 -0
- package/src/composer/asset-picker-url.ts +80 -0
- package/src/composer/attachment-accept.spec.ts +22 -0
- package/src/composer/attachment-accept.ts +71 -0
- package/src/composer/draft-key.spec.ts +19 -0
- package/src/composer/draft-key.ts +7 -0
- package/src/composer/extensions/FileReference.tsx +55 -0
- package/src/composer/extensions/MentionReference.tsx +93 -0
- package/src/composer/extensions/SkillReference.tsx +56 -0
- package/src/composer/index.ts +79 -0
- package/src/composer/pasted-text.spec.ts +162 -0
- package/src/composer/pasted-text.ts +160 -0
- package/src/composer/prompt-attachments.spec.ts +80 -0
- package/src/composer/prompt-attachments.ts +93 -0
- package/src/composer/realtime-voice-audio-level.spec.ts +32 -0
- package/src/composer/realtime-voice-audio-level.ts +64 -0
- package/src/composer/realtime-voice-transcript.spec.ts +95 -0
- package/src/composer/realtime-voice-transcript.ts +134 -0
- package/src/composer/runtime-adapters.tsx +343 -0
- package/src/composer/types.ts +66 -0
- package/src/composer/use-file-search.ts +64 -0
- package/src/composer/use-mention-search.ts +90 -0
- package/src/composer/use-skills.ts +45 -0
- package/src/composer/useRealtimeVoiceMode.spec.ts +818 -0
- package/src/composer/useRealtimeVoiceMode.tsx +2117 -0
- package/src/composer/useVoiceDictation.spec.ts +45 -0
- package/src/composer/useVoiceDictation.ts +1191 -0
- package/src/context-ui/ContextMeter.tsx +101 -0
- package/src/context-ui/ContextSegmentRow.tsx +184 -0
- package/src/context-ui/ContextTreemap.tsx +125 -0
- package/src/context-ui/ContextXRayPanel.tsx +377 -0
- package/src/context-ui/format.ts +42 -0
- package/src/context-ui/index.ts +15 -0
- package/src/context-ui/types.ts +43 -0
- package/src/design-tweaks/index.ts +1 -0
- package/src/design-tweaks/visual-style-controls.tsx +1084 -0
- package/src/editor/BubbleToolbar.tsx +253 -0
- package/src/editor/CodeBlockNode.tsx +254 -0
- package/src/editor/DragHandle.spec.ts +588 -0
- package/src/editor/DragHandle.ts +1437 -0
- package/src/editor/ImageExtension.roundtrip.spec.ts +117 -0
- package/src/editor/ImageExtension.ts +306 -0
- package/src/editor/RegistryBlockContext.tsx +107 -0
- package/src/editor/RegistryBlockNode.spec.ts +279 -0
- package/src/editor/RegistryBlockNode.tsx +652 -0
- package/src/editor/RichMarkdownEditor.collab.spec.ts +79 -0
- package/src/editor/RichMarkdownEditor.roundtrip.spec.ts +226 -0
- package/src/editor/RichMarkdownEditor.tsx +81 -0
- package/src/editor/RunId.ts +61 -0
- package/src/editor/SharedRichEditor.tsx +321 -0
- package/src/editor/SlashCommandMenu.tsx +310 -0
- package/src/editor/disableHistory.spec.ts +85 -0
- package/src/editor/extensions.ts +402 -0
- package/src/editor/gfmDoc.spec.ts +230 -0
- package/src/editor/gfmDoc.ts +92 -0
- package/src/editor/index.ts +93 -0
- package/src/editor/registrySlashCommands.ts +131 -0
- package/src/editor/structuralReorderUndo.spec.ts +144 -0
- package/src/editor/surgical-apply.spec.ts +279 -0
- package/src/editor/surgical-apply.ts +192 -0
- package/src/editor/useCollabReconcile.concurrent.spec.ts +422 -0
- package/src/editor/useCollabReconcile.idempotent.spec.ts +324 -0
- package/src/editor/useCollabReconcile.ts +589 -0
- package/src/editor.css +510 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/use-mobile.tsx +21 -0
- package/src/hooks/use-toast.ts +188 -0
- package/src/index.ts +8 -0
- package/src/onboarding/index.ts +1 -0
- package/src/provider.tsx +47 -0
- package/src/sharing/VisibilityBadge.spec.ts +96 -0
- package/src/sharing/VisibilityBadge.tsx +37 -0
- package/src/sharing/index.ts +4 -0
- package/src/styles.css +21 -0
- package/src/ui/accordion.tsx +56 -0
- package/src/ui/alert-dialog.tsx +141 -0
- package/src/ui/alert.tsx +59 -0
- package/src/ui/aspect-ratio.tsx +5 -0
- package/src/ui/avatar.tsx +48 -0
- package/src/ui/badge.tsx +37 -0
- package/src/ui/breadcrumb.tsx +115 -0
- package/src/ui/button.tsx +78 -0
- package/src/ui/calendar.tsx +214 -0
- package/src/ui/card.tsx +86 -0
- package/src/ui/carousel.tsx +260 -0
- package/src/ui/chart.tsx +375 -0
- package/src/ui/checkbox.tsx +28 -0
- package/src/ui/collapsible.tsx +9 -0
- package/src/ui/command.spec.tsx +51 -0
- package/src/ui/command.tsx +174 -0
- package/src/ui/context-menu.tsx +202 -0
- package/src/ui/date-picker.tsx +64 -0
- package/src/ui/dialog.spec.tsx +43 -0
- package/src/ui/dialog.tsx +146 -0
- package/src/ui/drawer.tsx +126 -0
- package/src/ui/dropdown-menu.tsx +218 -0
- package/src/ui/form.tsx +177 -0
- package/src/ui/hover-card.tsx +27 -0
- package/src/ui/index.ts +52 -0
- package/src/ui/input-otp.tsx +69 -0
- package/src/ui/input.tsx +22 -0
- package/src/ui/label.tsx +24 -0
- package/src/ui/logo.tsx +36 -0
- package/src/ui/menubar.tsx +235 -0
- package/src/ui/navigation-menu.tsx +128 -0
- package/src/ui/pagination.tsx +121 -0
- package/src/ui/popover.tsx +44 -0
- package/src/ui/progress.tsx +26 -0
- package/src/ui/radio-group.tsx +42 -0
- package/src/ui/resizable.tsx +43 -0
- package/src/ui/scroll-area.tsx +46 -0
- package/src/ui/select.tsx +158 -0
- package/src/ui/separator.tsx +29 -0
- package/src/ui/sheet.tsx +160 -0
- package/src/ui/sidebar.tsx +777 -0
- package/src/ui/skeleton.tsx +18 -0
- package/src/ui/slider.tsx +26 -0
- package/src/ui/sonner.tsx +58 -0
- package/src/ui/spinner.tsx +17 -0
- package/src/ui/switch.tsx +27 -0
- package/src/ui/table.tsx +117 -0
- package/src/ui/tabs.tsx +53 -0
- package/src/ui/textarea.tsx +23 -0
- package/src/ui/toast.tsx +127 -0
- package/src/ui/toaster.tsx +33 -0
- package/src/ui/toggle-group.tsx +59 -0
- package/src/ui/toggle.tsx +43 -0
- package/src/ui/tooltip.tsx +53 -0
- package/src/ui/use-toast.ts +3 -0
- 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
|
+
}
|