@arbidocs/react 0.4.12 → 0.4.14
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/dist/artifacts/index.cjs +40 -14
- package/dist/artifacts/index.cjs.map +1 -1
- package/dist/artifacts/index.d.cts +15 -5
- package/dist/artifacts/index.d.ts +15 -5
- package/dist/artifacts/index.js +24 -6
- package/dist/artifacts/index.js.map +1 -1
- package/dist/{chunk-QFELRTTG.js → chunk-4XWSLFMN.js} +153 -25
- package/dist/chunk-4XWSLFMN.js.map +1 -0
- package/dist/{chunk-VZLGOA4A.cjs → chunk-MQRBPFOZ.cjs} +154 -24
- package/dist/chunk-MQRBPFOZ.cjs.map +1 -0
- package/dist/{chunk-NVMQLJI4.js → chunk-RTULVZOS.js} +3 -3
- package/dist/{chunk-NVMQLJI4.js.map → chunk-RTULVZOS.js.map} +1 -1
- package/dist/{chunk-K5TOB34Q.cjs → chunk-TA3IZP7I.cjs} +3 -3
- package/dist/{chunk-K5TOB34Q.cjs.map → chunk-TA3IZP7I.cjs.map} +1 -1
- package/dist/index.cjs +376 -368
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/stored-markdown-Bp18vrbr.d.cts +125 -0
- package/dist/stored-markdown-Bp18vrbr.d.ts +125 -0
- package/dist/ui/index.cjs +147 -147
- package/dist/ui/index.js +2 -2
- package/package.json +3 -3
- package/dist/chunk-QFELRTTG.js.map +0 -1
- package/dist/chunk-VZLGOA4A.cjs.map +0 -1
- package/dist/stored-markdown-DMwFzWhc.d.cts +0 -75
- package/dist/stored-markdown-DMwFzWhc.d.ts +0 -75
package/dist/index.d.cts
CHANGED
|
@@ -12,7 +12,7 @@ import { ab as EntityIconComponent } from './index-4WLy-KDK.cjs';
|
|
|
12
12
|
export { A as AgentBadge, a as AiMarkdown, b as Avatar, c as AvatarFallback, d as AvatarImage, B as BASE_COLORS, e as Badge, f as BadgeProps, g as Button, h as ButtonProps, C as Card, i as CardContent, j as CardDescription, k as CardFooter, l as CardHeader, m as CardProps, n as CardTitle, o as Checkbox, p as Collapsible, q as CollapsibleContent, r as CollapsibleTrigger, s as Command, t as CommandDialog, u as CommandEmpty, v as CommandGroup, w as CommandInput, x as CommandItem, y as CommandList, z as CommandSeparator, D as CommandShortcut, E as Dialog, F as DialogClose, G as DialogContent, H as DialogDescription, I as DialogFooter, J as DialogHeader, K as DialogOverlay, L as DialogPortal, M as DialogPresentation, N as DialogTitle, O as DialogTrigger, P as DictateContextValue, Q as DictateProvider, R as DocumentCard, S as DocumentCardProps, T as DocumentEntity, U as DocumentEntityProps, V as DocumentLike, W as DropdownMenu, X as DropdownMenuCheckboxItem, Y as DropdownMenuContent, Z as DropdownMenuGroup, _ as DropdownMenuItem, $ as DropdownMenuLabel, a0 as DropdownMenuPortal, a1 as DropdownMenuRadioGroup, a2 as DropdownMenuRadioItem, a3 as DropdownMenuSeparator, a4 as DropdownMenuShortcut, a5 as DropdownMenuSub, a6 as DropdownMenuSubContent, a7 as DropdownMenuSubTrigger, a8 as DropdownMenuTrigger, a9 as ENTITY_MAPPINGS, aa as EntityIcon, ac as EntityPill, ad as EntityRegistryOverride, ae as EntityType, af as HoverCard, ag as HoverCardContent, ah as HoverCardTrigger, ai as IconToggle, aj as IconToggleProps, ak as Input, al as InputProps, am as Label, an as MarkMenu, ao as MarkMenuItem, ap as MarkMenuProps, aq as MarkdownRenderer, ar as MarkdownRendererProps, as as MarkdownStreamingContext, at as NEUTRAL_GRAY, au as PLACEHOLDER_COLOR, av as PassageCard, aw as PassageCardProps, ax as Popover, ay as PopoverAnchor, az as PopoverContent, aA as PopoverTrigger, aB as PresenceDisplayStatus, aC as PresenceLabel, aD as Progress, aE as ProjectEntity, aF as ProjectEntityProps, aG as ProjectRelation, aH as RadioGroup, aI as RadioGroupItem, aJ as Rag, aK as RagDot, aL as RelevanceDot, aM as ScrollArea, aN as ScrollBar, aO as Select, aP as SelectContent, aQ as SelectGroup, aR as SelectItem, aS as SelectLabel, aT as SelectScrollDownButton, aU as SelectScrollUpButton, aV as SelectSeparator, aW as SelectTrigger, aX as SelectValue, aY as Separator, aZ as Slider, a_ as StatusBadgeComponent, a$ as StatusBadgeProps, b0 as StatusPill, b1 as StatusPillProps, b2 as StatusVariant, b3 as Switch, b4 as TAG_TYPE_ICONS, b5 as TAG_TYPE_LABELS, b6 as Table, b7 as TableBody, b8 as TableCaption, b9 as TableCell, ba as TableFooter, bb as TableHead, bc as TableHeader, bd as TableRow, be as Tabs, bf as TabsContent, bg as TabsList, bh as TabsTrigger, bi as TagEntity, bj as TagEntityProps, bk as TagLike, bl as Textarea, bm as TextareaProps, bn as Toggle, bo as ToggleGroup, bp as ToggleGroupItem, bq as Tooltip, br as TooltipContent, bs as TooltipProvider, bt as TooltipTrigger, bu as UserEntity, bv as UserEntityProps, bw as UserMenu, bx as UserMenuItem, by as UserMenuProps, bz as UserMenuStatus, bA as VISIBILITY_ICONS, bB as VisibilityIcon, bC as badgeVariants, bD as buttonVariants, bE as cardVariants, bF as closeOpenEmphasis, bG as cn, bH as configureEntityRegistry, bI as configureRagLabels, bJ as configureStatusRegistry, bK as getDocIcon, bL as getEntityColor, bM as getEntityColorStyles, bN as getEntityIcon, bO as getEntityLabel, bP as getStatusVariant, bQ as getTagTypeIcon, bR as getTagTypeLabel, bS as getWorkspaceColor, bT as markdownBaseComponents, bU as normalizeCitationMarkup, bV as splitMarkdownBlocks, bW as toggleVariants, bX as trimOpenCitation } from './index-4WLy-KDK.cjs';
|
|
13
13
|
import { LucideIcon } from 'lucide-react';
|
|
14
14
|
import { Components } from 'react-markdown';
|
|
15
|
-
export { c as cleanDraftMarkdown, p as promoteBoldTitle, r as repairParsedTitle, s as stripAgentPreamble, u as unescapeMarkdown,
|
|
15
|
+
export { D as DraftCleanReport, a as DraftCleanStage, c as cleanDraftMarkdown, b as cleanDraftWithReport, p as promoteBoldTitle, r as repairParsedStructure, d as repairParsedTitle, s as stripAgentPreamble, u as unescapeMarkdown, e as unwrapCitationLinks } from './stored-markdown-Bp18vrbr.cjs';
|
|
16
16
|
export { A as AppNotification, D as DEFAULT_NOTIFY_TONE, N as NotificationBell, a as NotificationBellProps, b as NotificationBellTriggerState, c as NotifyOptions, d as NotifyVariant, T as Toaster, n as notify, s as seedNotifications, e as selectUnread, u as useNotify } from './index-CcbVSNSP.cjs';
|
|
17
17
|
import { ColDef } from 'ag-grid-community';
|
|
18
18
|
export { ToasterProps, toast } from 'sonner';
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { ab as EntityIconComponent } from './index-4WLy-KDK.js';
|
|
|
12
12
|
export { A as AgentBadge, a as AiMarkdown, b as Avatar, c as AvatarFallback, d as AvatarImage, B as BASE_COLORS, e as Badge, f as BadgeProps, g as Button, h as ButtonProps, C as Card, i as CardContent, j as CardDescription, k as CardFooter, l as CardHeader, m as CardProps, n as CardTitle, o as Checkbox, p as Collapsible, q as CollapsibleContent, r as CollapsibleTrigger, s as Command, t as CommandDialog, u as CommandEmpty, v as CommandGroup, w as CommandInput, x as CommandItem, y as CommandList, z as CommandSeparator, D as CommandShortcut, E as Dialog, F as DialogClose, G as DialogContent, H as DialogDescription, I as DialogFooter, J as DialogHeader, K as DialogOverlay, L as DialogPortal, M as DialogPresentation, N as DialogTitle, O as DialogTrigger, P as DictateContextValue, Q as DictateProvider, R as DocumentCard, S as DocumentCardProps, T as DocumentEntity, U as DocumentEntityProps, V as DocumentLike, W as DropdownMenu, X as DropdownMenuCheckboxItem, Y as DropdownMenuContent, Z as DropdownMenuGroup, _ as DropdownMenuItem, $ as DropdownMenuLabel, a0 as DropdownMenuPortal, a1 as DropdownMenuRadioGroup, a2 as DropdownMenuRadioItem, a3 as DropdownMenuSeparator, a4 as DropdownMenuShortcut, a5 as DropdownMenuSub, a6 as DropdownMenuSubContent, a7 as DropdownMenuSubTrigger, a8 as DropdownMenuTrigger, a9 as ENTITY_MAPPINGS, aa as EntityIcon, ac as EntityPill, ad as EntityRegistryOverride, ae as EntityType, af as HoverCard, ag as HoverCardContent, ah as HoverCardTrigger, ai as IconToggle, aj as IconToggleProps, ak as Input, al as InputProps, am as Label, an as MarkMenu, ao as MarkMenuItem, ap as MarkMenuProps, aq as MarkdownRenderer, ar as MarkdownRendererProps, as as MarkdownStreamingContext, at as NEUTRAL_GRAY, au as PLACEHOLDER_COLOR, av as PassageCard, aw as PassageCardProps, ax as Popover, ay as PopoverAnchor, az as PopoverContent, aA as PopoverTrigger, aB as PresenceDisplayStatus, aC as PresenceLabel, aD as Progress, aE as ProjectEntity, aF as ProjectEntityProps, aG as ProjectRelation, aH as RadioGroup, aI as RadioGroupItem, aJ as Rag, aK as RagDot, aL as RelevanceDot, aM as ScrollArea, aN as ScrollBar, aO as Select, aP as SelectContent, aQ as SelectGroup, aR as SelectItem, aS as SelectLabel, aT as SelectScrollDownButton, aU as SelectScrollUpButton, aV as SelectSeparator, aW as SelectTrigger, aX as SelectValue, aY as Separator, aZ as Slider, a_ as StatusBadgeComponent, a$ as StatusBadgeProps, b0 as StatusPill, b1 as StatusPillProps, b2 as StatusVariant, b3 as Switch, b4 as TAG_TYPE_ICONS, b5 as TAG_TYPE_LABELS, b6 as Table, b7 as TableBody, b8 as TableCaption, b9 as TableCell, ba as TableFooter, bb as TableHead, bc as TableHeader, bd as TableRow, be as Tabs, bf as TabsContent, bg as TabsList, bh as TabsTrigger, bi as TagEntity, bj as TagEntityProps, bk as TagLike, bl as Textarea, bm as TextareaProps, bn as Toggle, bo as ToggleGroup, bp as ToggleGroupItem, bq as Tooltip, br as TooltipContent, bs as TooltipProvider, bt as TooltipTrigger, bu as UserEntity, bv as UserEntityProps, bw as UserMenu, bx as UserMenuItem, by as UserMenuProps, bz as UserMenuStatus, bA as VISIBILITY_ICONS, bB as VisibilityIcon, bC as badgeVariants, bD as buttonVariants, bE as cardVariants, bF as closeOpenEmphasis, bG as cn, bH as configureEntityRegistry, bI as configureRagLabels, bJ as configureStatusRegistry, bK as getDocIcon, bL as getEntityColor, bM as getEntityColorStyles, bN as getEntityIcon, bO as getEntityLabel, bP as getStatusVariant, bQ as getTagTypeIcon, bR as getTagTypeLabel, bS as getWorkspaceColor, bT as markdownBaseComponents, bU as normalizeCitationMarkup, bV as splitMarkdownBlocks, bW as toggleVariants, bX as trimOpenCitation } from './index-4WLy-KDK.js';
|
|
13
13
|
import { LucideIcon } from 'lucide-react';
|
|
14
14
|
import { Components } from 'react-markdown';
|
|
15
|
-
export { c as cleanDraftMarkdown, p as promoteBoldTitle, r as repairParsedTitle, s as stripAgentPreamble, u as unescapeMarkdown,
|
|
15
|
+
export { D as DraftCleanReport, a as DraftCleanStage, c as cleanDraftMarkdown, b as cleanDraftWithReport, p as promoteBoldTitle, r as repairParsedStructure, d as repairParsedTitle, s as stripAgentPreamble, u as unescapeMarkdown, e as unwrapCitationLinks } from './stored-markdown-Bp18vrbr.js';
|
|
16
16
|
export { A as AppNotification, D as DEFAULT_NOTIFY_TONE, N as NotificationBell, a as NotificationBellProps, b as NotificationBellTriggerState, c as NotifyOptions, d as NotifyVariant, T as Toaster, n as notify, s as seedNotifications, e as selectUnread, u as useNotify } from './index-CcbVSNSP.js';
|
|
17
17
|
import { ColDef } from 'ag-grid-community';
|
|
18
18
|
export { ToasterProps, toast } from 'sonner';
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import { useDocuments, useConversations, useAssistantQuery, useConversationThreads, arbiQueryKeys, useWorkspaces, useParsedDocument, useTags, useActivity, useThumbnails } from './chunk-4XWSLFMN.js';
|
|
2
|
+
export { DEFAULT_USD_PER_CREDIT, arbiQueryKeys, cleanDraftMarkdown, cleanDraftWithReport, creditsToUsd, formatCredits, isUsageMetered, promoteBoldTitle, repairParsedStructure, repairParsedTitle, stripAgentPreamble, unescapeMarkdown, unwrapCitationLinks, useActivity, useAgents, useAssistantQuery, useConfigs, useConversationThreads, useConversations, useDeleteAgents, useDocuments, useFacts, useHealth, useParsedDocument, useProjectInvoices, useProjectUsage, useProjects, useProjectsUsage, useSessions, useTags, useTasks, useThumbnails, useUserUsageToday, useWorkspaces } from './chunk-4XWSLFMN.js';
|
|
1
3
|
import { formatRelativeTime } from './chunk-FSMIN5VX.js';
|
|
2
4
|
export { DEFAULT_NOTIFY_TONE, NotificationBell, Toaster, formatRelativeTime, notify, seedNotifications, selectUnread, toast, useNotify } from './chunk-FSMIN5VX.js';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
5
|
-
import { MarkMenu, AiMarkdown, Card, Button, Badge, TagEntity, Input, FILE_TYPE_COLORS, getEntityIcon, UserEntity, getEntityColorStyles, AgentBadge, Textarea, Label, Slider, Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, DocumentEntity, DocumentCard, useAudioRecorder, MicWaveformIndicator, IconToggle, classifyMediaError, formatElapsed, PassageCard } from './chunk-NVMQLJI4.js';
|
|
6
|
-
export { AgentBadge, AiMarkdown, ArbiBotHeadIcon, AudIcon, Avatar, AvatarFallback, AvatarImage, BASE_COLORS, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DictateProvider, DocumentCard, DocumentEntity, ENTITY_MAPPINGS, EmlIcon, EntityIcon, EntityPill, FILE_TYPE_COLORS, HoverCard, HoverCardContent, HoverCardTrigger, IconToggle, ImgIcon, InlineMicButton, Input, Label, MarkMenu, MicRecordingOverlay, MicWaveformIndicator, NEUTRAL_GRAY, PLACEHOLDER_COLOR, PassageCard, PdfIcon, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, PresenceLabel, Progress, ProjectEntity, RadioGroup, RadioGroupItem, RagDot, RelevanceDot, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Slider, StatusPill, Switch, TAG_TYPE_ICONS, TAG_TYPE_LABELS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, TagEntity, Textarea, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UserEntity, UserMenu, VISIBILITY_ICONS, VidIcon, VisibilityIcon, badgeVariants, buttonVariants, cardVariants, configureEntityRegistry, configureRagLabels, configureStatusRegistry, formatElapsed, getDocIcon, getEntityColor, getEntityColorStyles, getEntityIcon, getEntityLabel, getStatusVariant, getTagTypeIcon, getTagTypeLabel, getWorkspaceColor, toggleVariants, useAudioRecorder } from './chunk-NVMQLJI4.js';
|
|
7
|
-
import { ScrollArea, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator } from './chunk-N5SVBDLC.js';
|
|
8
|
-
export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, ScrollArea, ScrollBar } from './chunk-N5SVBDLC.js';
|
|
5
|
+
import { MarkMenu, AiMarkdown, Card, Button, Badge, TagEntity, Input, FILE_TYPE_COLORS, getEntityIcon, UserEntity, getEntityColorStyles, AgentBadge, Textarea, Label, Slider, Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, DocumentEntity, DocumentCard, useAudioRecorder, MicWaveformIndicator, IconToggle, classifyMediaError, formatElapsed, PassageCard } from './chunk-RTULVZOS.js';
|
|
6
|
+
export { AgentBadge, AiMarkdown, ArbiBotHeadIcon, AudIcon, Avatar, AvatarFallback, AvatarImage, BASE_COLORS, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DictateProvider, DocumentCard, DocumentEntity, ENTITY_MAPPINGS, EmlIcon, EntityIcon, EntityPill, FILE_TYPE_COLORS, HoverCard, HoverCardContent, HoverCardTrigger, IconToggle, ImgIcon, InlineMicButton, Input, Label, MarkMenu, MicRecordingOverlay, MicWaveformIndicator, NEUTRAL_GRAY, PLACEHOLDER_COLOR, PassageCard, PdfIcon, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, PresenceLabel, Progress, ProjectEntity, RadioGroup, RadioGroupItem, RagDot, RelevanceDot, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Slider, StatusPill, Switch, TAG_TYPE_ICONS, TAG_TYPE_LABELS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, TagEntity, Textarea, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UserEntity, UserMenu, VISIBILITY_ICONS, VidIcon, VisibilityIcon, badgeVariants, buttonVariants, cardVariants, configureEntityRegistry, configureRagLabels, configureStatusRegistry, formatElapsed, getDocIcon, getEntityColor, getEntityColorStyles, getEntityIcon, getEntityLabel, getStatusVariant, getTagTypeIcon, getTagTypeLabel, getWorkspaceColor, toggleVariants, useAudioRecorder } from './chunk-RTULVZOS.js';
|
|
9
7
|
import { normalizeCitationMarkup, MarkdownRenderer } from './chunk-TGGQGFS3.js';
|
|
10
8
|
export { MarkdownRenderer, MarkdownStreamingContext, closeOpenEmphasis, markdownBaseComponents, normalizeCitationMarkup, splitMarkdownBlocks, trimOpenCitation } from './chunk-TGGQGFS3.js';
|
|
9
|
+
import { ScrollArea, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator } from './chunk-N5SVBDLC.js';
|
|
10
|
+
export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, ScrollArea, ScrollBar } from './chunk-N5SVBDLC.js';
|
|
11
11
|
import { cn } from './chunk-SN5YV6FF.js';
|
|
12
12
|
export { cn } from './chunk-SN5YV6FF.js';
|
|
13
13
|
import { AudioViewer, ImageViewer, VideoViewer } from './chunk-HDCRPPBW.js';
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for markdown that is STORED (an agent's draft saved as an artifact, then read back from
|
|
3
|
+
* the backend's parse). Pure and SDK-free; they sit next to `normalizeCitationMarkup`, which they
|
|
4
|
+
* build on.
|
|
5
|
+
*
|
|
6
|
+
* Two directions:
|
|
7
|
+
*
|
|
8
|
+
* - Going in (`cleanDraftMarkdown` = `unwrapCitationLinks` + `stripAgentPreamble` +
|
|
9
|
+
* `promoteBoldTitle`): a streamed draft carries citation links, `(*Source: ...*)` notes and
|
|
10
|
+
* sometimes narration before the document. A stored letter should hold only the letter.
|
|
11
|
+
* - Coming out (`unescapeMarkdown`): the backend's parse of a stored `.md` returns the text with
|
|
12
|
+
* markdown punctuation backslash-escaped (`**Fees.**` comes back as `\*\*Fees\.\*\*`).
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Undo the backend's escaping of a markdown artifact: `\*\*Scope\.\*\*` becomes `**Scope.**`.
|
|
16
|
+
*
|
|
17
|
+
* THE RULE. Apply this ONLY to text of an artifact that was stored from markdown (an agent draft
|
|
18
|
+
* or an edited version, always uploaded as `.md`): for those the parser escapes every markdown
|
|
19
|
+
* punctuation character, including the backslash itself, so removing one level of escaping is the
|
|
20
|
+
* exact inverse (an author's literal `\*` is stored as `\\\*` and comes back as `\*`). Do not
|
|
21
|
+
* apply it to a PDF or Word parse, where a backslash is just a character.
|
|
22
|
+
*
|
|
23
|
+
* Details:
|
|
24
|
+
* - Only a backslash followed by markdown punctuation (``\ ` * _ { } [ ] ( ) # + - . ! | > ~ <``)
|
|
25
|
+
* is removed; `\n`, `C:\temp` and a trailing backslash are left alone.
|
|
26
|
+
* - Pairs are read left to right, so `\\*` is an escaped backslash followed by a bare `*`.
|
|
27
|
+
* - Fenced code blocks are never touched (the parser does not escape inside them).
|
|
28
|
+
* - Inline code spans: the parser DOES escape `*` and `_` there (`` `a*b` `` comes back as
|
|
29
|
+
* `` `a\*b` ``), so only `\*` and `\_` are undone inside a span; any other backslash in code
|
|
30
|
+
* (`` `re\.x` ``) is a literal and stays.
|
|
31
|
+
*/
|
|
32
|
+
declare function unescapeMarkdown(text: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* The parser also mangles the TITLE of a stored markdown document (seen on a real backend): the
|
|
35
|
+
* first heading comes back doubled (`## # Title`) or alone inside a code fence
|
|
36
|
+
* (a fence, `# Title`, a fence). Both are repaired, on the first non-blank line only, so a code
|
|
37
|
+
* block or heading later in the text is never touched. Like `unescapeMarkdown`, apply it only to
|
|
38
|
+
* artifacts stored from markdown.
|
|
39
|
+
*/
|
|
40
|
+
declare function repairParsedTitle(text: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Undo how the backend's parse of a stored `.md` restructures it (seen on a real backend):
|
|
43
|
+
* - a heading comes back doubled (`## # Title`) or as a list item (`- # Title`);
|
|
44
|
+
* - every list item gets a `- ` of its own on top of the original marker, so `* a` returns as
|
|
45
|
+
* `- * a` and `1. a` as `- 1. a`, which a markdown editor loads as a list inside a list item
|
|
46
|
+
* (and saves as `- - a`); a run of ordinals can come back on one line (`- 1. a 2. b`);
|
|
47
|
+
* - a table comes back on one line.
|
|
48
|
+
* List nesting and the bullet/ordered difference of a flat `- x` cannot be recovered, so items
|
|
49
|
+
* stay flat. Items of one list are kept tight (no blank line between them). Fenced code is
|
|
50
|
+
* never touched. Like `unescapeMarkdown`, apply it only to artifacts stored from markdown.
|
|
51
|
+
*/
|
|
52
|
+
declare function repairParsedStructure(text: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Text for storage from text that carries citations: `normalizeCitationMarkup` first (it hoists
|
|
55
|
+
* list, heading and bold tokens out of the link so unwrapping cannot orphan half of a `**` pair),
|
|
56
|
+
* then `[text](#cite-N)` becomes `text`, `(*Source: ...*)` notes are dropped, and a bold or
|
|
57
|
+
* heading marker that lost its partner is repaired. Fenced code is left alone.
|
|
58
|
+
*/
|
|
59
|
+
declare function unwrapCitationLinks(text: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* Cut the agent's narration written BEFORE the document. Strictly non-destructive: if in doubt the
|
|
62
|
+
* text is returned whole (a stray sentence is easy to delete, a lost clause is not recoverable).
|
|
63
|
+
*
|
|
64
|
+
* Text is removed only when ALL of these hold:
|
|
65
|
+
* 1. a real markdown heading line (`# Title`, any level) follows it, and the cut stops exactly at
|
|
66
|
+
* the FIRST such line (never at a bold line, never at a line that merely contains `**`);
|
|
67
|
+
* 2. what precedes it is at most 4 paragraphs and 900 characters of plain prose (horizontal rules
|
|
68
|
+
* between them are ignored): no list, table, quote, code, heading, bold or link;
|
|
69
|
+
* 3. EVERY paragraph opens with an allow-listed narration opener: first person ("I'll ...",
|
|
70
|
+
* "I now have ..."), "Let me", "Here is/are", "Below is", "Sure", "Based on the ...", "Per the
|
|
71
|
+
* instructions", "As requested", "The workspace ...", "No (relevant) documents ...", "There is
|
|
72
|
+
* no document ...", "After reviewing ...".
|
|
73
|
+
* Anything else (a dateline, an address, a salutation, a sentence of the letter) keeps the text whole.
|
|
74
|
+
*/
|
|
75
|
+
declare function stripAgentPreamble(text: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* Make the document's title a real heading: the FIRST non-blank line of the text, when it is a
|
|
78
|
+
* short whole-line bold title (`**Letter**`, even with a stray inner `**`), becomes `# Letter`.
|
|
79
|
+
* Nothing else is ever promoted: not a later line, not a mid-sentence fragment (the title must
|
|
80
|
+
* start with a capital or digit, be at most 100 characters, hold no sentence break and not end in
|
|
81
|
+
* `,` `;` or `:`), and a document that already opens with a heading is left alone.
|
|
82
|
+
*/
|
|
83
|
+
declare function promoteBoldTitle(text: string): string;
|
|
84
|
+
/** Which stage of the cleanup produced the text that is returned. */
|
|
85
|
+
type DraftCleanStage = 'cleaned' | 'unwrapped' | 'raw';
|
|
86
|
+
interface DraftCleanReport {
|
|
87
|
+
/** What to store. */
|
|
88
|
+
text: string;
|
|
89
|
+
/**
|
|
90
|
+
* `cleaned`: the full cleanup. `unwrapped`: only the citation links were removed (the preamble or
|
|
91
|
+
* title step was rejected by the guard). `raw`: the input as streamed (even link removal was
|
|
92
|
+
* rejected).
|
|
93
|
+
*/
|
|
94
|
+
stage: DraftCleanStage;
|
|
95
|
+
/** Length of the returned text over the length of the input without its citation markup. */
|
|
96
|
+
ratio: number;
|
|
97
|
+
/** Which steps changed the text before the guard (for logs). */
|
|
98
|
+
changedBy: ('citations' | 'preamble' | 'title')[];
|
|
99
|
+
/** The guard rejected a step because it would have lost content. */
|
|
100
|
+
guarded: boolean;
|
|
101
|
+
}
|
|
102
|
+
/** The three text steps of the cleanup; replaceable so the guard can be tested. */
|
|
103
|
+
interface DraftCleanSteps {
|
|
104
|
+
unwrap: (text: string) => string;
|
|
105
|
+
strip: (text: string) => string;
|
|
106
|
+
promote: (text: string) => string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* `cleanDraftMarkdown` with a safety net and a report, for storing a streamed draft. Each stage is
|
|
110
|
+
* accepted only if it provably cost nothing but narration and citation markup:
|
|
111
|
+
* - links removed: at least 70% of the text length remains and no heading or numbered item is lost
|
|
112
|
+
* (else `raw`, the input exactly as streamed);
|
|
113
|
+
* - narration removed: only a pure prefix of the text may go, and nothing structural;
|
|
114
|
+
* - title and heading tidy: at least 70% of the text remains and no heading or numbered item is lost.
|
|
115
|
+
* A rejected stage falls back to the previous one (`cleaned` -> `unwrapped` -> `raw`).
|
|
116
|
+
*/
|
|
117
|
+
declare function cleanDraftWithReport(raw: string, steps?: DraftCleanSteps): DraftCleanReport;
|
|
118
|
+
/**
|
|
119
|
+
* Everything a streamed draft needs before it is stored as the artifact's first version:
|
|
120
|
+
* `unwrapCitationLinks`, `stripAgentPreamble`, `promoteBoldTitle`, clean headings, collapsed blank
|
|
121
|
+
* runs, trimmed, under the guard of `cleanDraftWithReport` (use it to know which stage was kept).
|
|
122
|
+
*/
|
|
123
|
+
declare function cleanDraftMarkdown(raw: string): string;
|
|
124
|
+
|
|
125
|
+
export { type DraftCleanReport as D, type DraftCleanStage as a, cleanDraftWithReport as b, cleanDraftMarkdown as c, repairParsedTitle as d, unwrapCitationLinks as e, promoteBoldTitle as p, repairParsedStructure as r, stripAgentPreamble as s, unescapeMarkdown as u };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for markdown that is STORED (an agent's draft saved as an artifact, then read back from
|
|
3
|
+
* the backend's parse). Pure and SDK-free; they sit next to `normalizeCitationMarkup`, which they
|
|
4
|
+
* build on.
|
|
5
|
+
*
|
|
6
|
+
* Two directions:
|
|
7
|
+
*
|
|
8
|
+
* - Going in (`cleanDraftMarkdown` = `unwrapCitationLinks` + `stripAgentPreamble` +
|
|
9
|
+
* `promoteBoldTitle`): a streamed draft carries citation links, `(*Source: ...*)` notes and
|
|
10
|
+
* sometimes narration before the document. A stored letter should hold only the letter.
|
|
11
|
+
* - Coming out (`unescapeMarkdown`): the backend's parse of a stored `.md` returns the text with
|
|
12
|
+
* markdown punctuation backslash-escaped (`**Fees.**` comes back as `\*\*Fees\.\*\*`).
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Undo the backend's escaping of a markdown artifact: `\*\*Scope\.\*\*` becomes `**Scope.**`.
|
|
16
|
+
*
|
|
17
|
+
* THE RULE. Apply this ONLY to text of an artifact that was stored from markdown (an agent draft
|
|
18
|
+
* or an edited version, always uploaded as `.md`): for those the parser escapes every markdown
|
|
19
|
+
* punctuation character, including the backslash itself, so removing one level of escaping is the
|
|
20
|
+
* exact inverse (an author's literal `\*` is stored as `\\\*` and comes back as `\*`). Do not
|
|
21
|
+
* apply it to a PDF or Word parse, where a backslash is just a character.
|
|
22
|
+
*
|
|
23
|
+
* Details:
|
|
24
|
+
* - Only a backslash followed by markdown punctuation (``\ ` * _ { } [ ] ( ) # + - . ! | > ~ <``)
|
|
25
|
+
* is removed; `\n`, `C:\temp` and a trailing backslash are left alone.
|
|
26
|
+
* - Pairs are read left to right, so `\\*` is an escaped backslash followed by a bare `*`.
|
|
27
|
+
* - Fenced code blocks are never touched (the parser does not escape inside them).
|
|
28
|
+
* - Inline code spans: the parser DOES escape `*` and `_` there (`` `a*b` `` comes back as
|
|
29
|
+
* `` `a\*b` ``), so only `\*` and `\_` are undone inside a span; any other backslash in code
|
|
30
|
+
* (`` `re\.x` ``) is a literal and stays.
|
|
31
|
+
*/
|
|
32
|
+
declare function unescapeMarkdown(text: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* The parser also mangles the TITLE of a stored markdown document (seen on a real backend): the
|
|
35
|
+
* first heading comes back doubled (`## # Title`) or alone inside a code fence
|
|
36
|
+
* (a fence, `# Title`, a fence). Both are repaired, on the first non-blank line only, so a code
|
|
37
|
+
* block or heading later in the text is never touched. Like `unescapeMarkdown`, apply it only to
|
|
38
|
+
* artifacts stored from markdown.
|
|
39
|
+
*/
|
|
40
|
+
declare function repairParsedTitle(text: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Undo how the backend's parse of a stored `.md` restructures it (seen on a real backend):
|
|
43
|
+
* - a heading comes back doubled (`## # Title`) or as a list item (`- # Title`);
|
|
44
|
+
* - every list item gets a `- ` of its own on top of the original marker, so `* a` returns as
|
|
45
|
+
* `- * a` and `1. a` as `- 1. a`, which a markdown editor loads as a list inside a list item
|
|
46
|
+
* (and saves as `- - a`); a run of ordinals can come back on one line (`- 1. a 2. b`);
|
|
47
|
+
* - a table comes back on one line.
|
|
48
|
+
* List nesting and the bullet/ordered difference of a flat `- x` cannot be recovered, so items
|
|
49
|
+
* stay flat. Items of one list are kept tight (no blank line between them). Fenced code is
|
|
50
|
+
* never touched. Like `unescapeMarkdown`, apply it only to artifacts stored from markdown.
|
|
51
|
+
*/
|
|
52
|
+
declare function repairParsedStructure(text: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Text for storage from text that carries citations: `normalizeCitationMarkup` first (it hoists
|
|
55
|
+
* list, heading and bold tokens out of the link so unwrapping cannot orphan half of a `**` pair),
|
|
56
|
+
* then `[text](#cite-N)` becomes `text`, `(*Source: ...*)` notes are dropped, and a bold or
|
|
57
|
+
* heading marker that lost its partner is repaired. Fenced code is left alone.
|
|
58
|
+
*/
|
|
59
|
+
declare function unwrapCitationLinks(text: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* Cut the agent's narration written BEFORE the document. Strictly non-destructive: if in doubt the
|
|
62
|
+
* text is returned whole (a stray sentence is easy to delete, a lost clause is not recoverable).
|
|
63
|
+
*
|
|
64
|
+
* Text is removed only when ALL of these hold:
|
|
65
|
+
* 1. a real markdown heading line (`# Title`, any level) follows it, and the cut stops exactly at
|
|
66
|
+
* the FIRST such line (never at a bold line, never at a line that merely contains `**`);
|
|
67
|
+
* 2. what precedes it is at most 4 paragraphs and 900 characters of plain prose (horizontal rules
|
|
68
|
+
* between them are ignored): no list, table, quote, code, heading, bold or link;
|
|
69
|
+
* 3. EVERY paragraph opens with an allow-listed narration opener: first person ("I'll ...",
|
|
70
|
+
* "I now have ..."), "Let me", "Here is/are", "Below is", "Sure", "Based on the ...", "Per the
|
|
71
|
+
* instructions", "As requested", "The workspace ...", "No (relevant) documents ...", "There is
|
|
72
|
+
* no document ...", "After reviewing ...".
|
|
73
|
+
* Anything else (a dateline, an address, a salutation, a sentence of the letter) keeps the text whole.
|
|
74
|
+
*/
|
|
75
|
+
declare function stripAgentPreamble(text: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* Make the document's title a real heading: the FIRST non-blank line of the text, when it is a
|
|
78
|
+
* short whole-line bold title (`**Letter**`, even with a stray inner `**`), becomes `# Letter`.
|
|
79
|
+
* Nothing else is ever promoted: not a later line, not a mid-sentence fragment (the title must
|
|
80
|
+
* start with a capital or digit, be at most 100 characters, hold no sentence break and not end in
|
|
81
|
+
* `,` `;` or `:`), and a document that already opens with a heading is left alone.
|
|
82
|
+
*/
|
|
83
|
+
declare function promoteBoldTitle(text: string): string;
|
|
84
|
+
/** Which stage of the cleanup produced the text that is returned. */
|
|
85
|
+
type DraftCleanStage = 'cleaned' | 'unwrapped' | 'raw';
|
|
86
|
+
interface DraftCleanReport {
|
|
87
|
+
/** What to store. */
|
|
88
|
+
text: string;
|
|
89
|
+
/**
|
|
90
|
+
* `cleaned`: the full cleanup. `unwrapped`: only the citation links were removed (the preamble or
|
|
91
|
+
* title step was rejected by the guard). `raw`: the input as streamed (even link removal was
|
|
92
|
+
* rejected).
|
|
93
|
+
*/
|
|
94
|
+
stage: DraftCleanStage;
|
|
95
|
+
/** Length of the returned text over the length of the input without its citation markup. */
|
|
96
|
+
ratio: number;
|
|
97
|
+
/** Which steps changed the text before the guard (for logs). */
|
|
98
|
+
changedBy: ('citations' | 'preamble' | 'title')[];
|
|
99
|
+
/** The guard rejected a step because it would have lost content. */
|
|
100
|
+
guarded: boolean;
|
|
101
|
+
}
|
|
102
|
+
/** The three text steps of the cleanup; replaceable so the guard can be tested. */
|
|
103
|
+
interface DraftCleanSteps {
|
|
104
|
+
unwrap: (text: string) => string;
|
|
105
|
+
strip: (text: string) => string;
|
|
106
|
+
promote: (text: string) => string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* `cleanDraftMarkdown` with a safety net and a report, for storing a streamed draft. Each stage is
|
|
110
|
+
* accepted only if it provably cost nothing but narration and citation markup:
|
|
111
|
+
* - links removed: at least 70% of the text length remains and no heading or numbered item is lost
|
|
112
|
+
* (else `raw`, the input exactly as streamed);
|
|
113
|
+
* - narration removed: only a pure prefix of the text may go, and nothing structural;
|
|
114
|
+
* - title and heading tidy: at least 70% of the text remains and no heading or numbered item is lost.
|
|
115
|
+
* A rejected stage falls back to the previous one (`cleaned` -> `unwrapped` -> `raw`).
|
|
116
|
+
*/
|
|
117
|
+
declare function cleanDraftWithReport(raw: string, steps?: DraftCleanSteps): DraftCleanReport;
|
|
118
|
+
/**
|
|
119
|
+
* Everything a streamed draft needs before it is stored as the artifact's first version:
|
|
120
|
+
* `unwrapCitationLinks`, `stripAgentPreamble`, `promoteBoldTitle`, clean headings, collapsed blank
|
|
121
|
+
* runs, trimmed, under the guard of `cleanDraftWithReport` (use it to know which stage was kept).
|
|
122
|
+
*/
|
|
123
|
+
declare function cleanDraftMarkdown(raw: string): string;
|
|
124
|
+
|
|
125
|
+
export { type DraftCleanReport as D, type DraftCleanStage as a, cleanDraftWithReport as b, cleanDraftMarkdown as c, repairParsedTitle as d, unwrapCitationLinks as e, promoteBoldTitle as p, repairParsedStructure as r, stripAgentPreamble as s, unescapeMarkdown as u };
|