@athenaintel/react 0.21.1 → 0.22.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 +63 -0
- package/dist/chat/StatewireApprovalCard.cjs +70 -10
- package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
- package/dist/chat/StatewireApprovalCard.d.ts +12 -1
- package/dist/chat/StatewireApprovalCard.js +73 -13
- package/dist/chat/StatewireApprovalCard.js.map +1 -1
- package/dist/chat/tiptap-text.cjs +28 -23
- package/dist/chat/tiptap-text.cjs.map +1 -1
- package/dist/chat/tiptap-text.js +28 -23
- package/dist/chat/tiptap-text.js.map +1 -1
- package/dist/chat/use-statewire-approval-request.cjs +22 -1
- package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
- package/dist/chat/use-statewire-approval-request.d.ts +41 -0
- package/dist/chat/use-statewire-approval-request.js +24 -3
- package/dist/chat/use-statewire-approval-request.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.cjs +0 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.js +0 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.js.map +1 -1
- package/dist/collab/client.cjs +4 -9
- package/dist/collab/client.cjs.map +1 -1
- package/dist/collab/client.js +2 -7
- package/dist/collab/client.js.map +1 -1
- package/dist/collab/index.cjs +23 -0
- package/dist/collab/index.cjs.map +1 -1
- package/dist/collab/index.d.ts +17 -2
- package/dist/collab/index.js +24 -1
- package/dist/collab/index.js.map +1 -1
- package/dist/collab/mint.cjs +18 -13
- package/dist/collab/mint.cjs.map +1 -1
- package/dist/collab/mint.d.ts +10 -0
- package/dist/collab/mint.js +18 -13
- package/dist/collab/mint.js.map +1 -1
- package/dist/collab/presence-client.cjs +211 -0
- package/dist/collab/presence-client.cjs.map +1 -0
- package/dist/collab/presence-client.d.ts +60 -0
- package/dist/collab/presence-client.js +194 -0
- package/dist/collab/presence-client.js.map +1 -0
- package/dist/collab/presence-mint.cjs +68 -0
- package/dist/collab/presence-mint.cjs.map +1 -0
- package/dist/collab/presence-mint.d.ts +87 -0
- package/dist/collab/presence-mint.js +68 -0
- package/dist/collab/presence-mint.js.map +1 -0
- package/dist/collab/presence-react.cjs +114 -0
- package/dist/collab/presence-react.cjs.map +1 -0
- package/dist/collab/presence-react.d.ts +47 -0
- package/dist/collab/presence-react.js +114 -0
- package/dist/collab/presence-react.js.map +1 -0
- package/dist/collab/presence-slots.cjs +220 -0
- package/dist/collab/presence-slots.cjs.map +1 -0
- package/dist/collab/presence-slots.d.ts +119 -0
- package/dist/collab/presence-slots.js +220 -0
- package/dist/collab/presence-slots.js.map +1 -0
- package/dist/collab/token-refresh.cjs +13 -0
- package/dist/collab/token-refresh.cjs.map +1 -0
- package/dist/collab/token-refresh.d.ts +20 -0
- package/dist/collab/token-refresh.js +13 -0
- package/dist/collab/token-refresh.js.map +1 -0
- package/dist/packages/agent-runtime/src/interrupts.cjs +40 -1
- package/dist/packages/agent-runtime/src/interrupts.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/interrupts.js +40 -1
- package/dist/packages/agent-runtime/src/interrupts.js.map +1 -1
- package/dist/packages/react/package.json.cjs +1 -1
- package/dist/packages/react/package.json.js +1 -1
- package/package.json +7 -7
|
@@ -61,31 +61,36 @@ const TiptapText = ({ text }) => {
|
|
|
61
61
|
attributes: {
|
|
62
62
|
class: "prose prose-sm dark:prose-invert max-w-none focus:outline-none"
|
|
63
63
|
},
|
|
64
|
-
handleClick
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
64
|
+
// ProseMirror's `handleClick` fires on `mouseup`, where `preventDefault`
|
|
65
|
+
// cannot cancel the anchor's navigation; the native `click` event can.
|
|
66
|
+
handleDOMEvents: {
|
|
67
|
+
click: (_view, event) => {
|
|
68
|
+
var _a;
|
|
69
|
+
if (event.button !== 0 || event.defaultPrevented) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
const target = event.target;
|
|
73
|
+
const targetElement = target instanceof HTMLElement ? target : target instanceof Node ? target.parentElement : null;
|
|
74
|
+
if (!targetElement) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
const link = targetElement.closest("a[href]");
|
|
78
|
+
if (!(link instanceof HTMLAnchorElement)) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if (handleLinkClickRef.current({
|
|
82
|
+
href: link.getAttribute("href") ?? link.href,
|
|
83
|
+
linkText: link.textContent,
|
|
84
|
+
target: link.target,
|
|
85
|
+
nativeEvent: event
|
|
86
|
+
})) {
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
event.preventDefault();
|
|
91
|
+
(_a = window.open(link.href, link.target || "_blank")) == null ? void 0 : _a.focus();
|
|
84
92
|
return true;
|
|
85
93
|
}
|
|
86
|
-
event.preventDefault();
|
|
87
|
-
(_a = window.open(link.href, link.target || "_blank")) == null ? void 0 : _a.focus();
|
|
88
|
-
return true;
|
|
89
94
|
}
|
|
90
95
|
}
|
|
91
96
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiptap-text.cjs","sources":["../../src/chat/tiptap-text.tsx"],"sourcesContent":["import { useEditor, EditorContent } from \"@tiptap/react\";\nimport StarterKit from \"@tiptap/starter-kit\";\nimport Link from \"@tiptap/extension-link\";\nimport { Table } from \"@tiptap/extension-table\";\nimport { TableRow } from \"@tiptap/extension-table-row\";\nimport { TableCell } from \"@tiptap/extension-table-cell\";\nimport { TableHeader } from \"@tiptap/extension-table-header\";\nimport { Markdown } from \"tiptap-markdown\";\nimport type { FC } from \"react\";\nimport { useEffect, useRef } from \"react\";\nimport { MentionExtension } from \"../chat-ui/mentions/mention-extension\";\nimport { useAthenaLinkClickHandler } from \"./athena-citation-links\";\n\nconst extensions = [\n StarterKit.configure({\n codeBlock: {\n HTMLAttributes: {\n class: \"rounded-md bg-muted p-3 font-mono text-sm\",\n },\n },\n }),\n Link.configure({\n openOnClick: false,\n autolink: true,\n HTMLAttributes: {\n class: \"text-primary underline\",\n target: \"_blank\",\n rel: \"noopener noreferrer\",\n },\n }),\n Table.configure({\n resizable: false,\n HTMLAttributes: {\n class: \"aui-table\",\n },\n }),\n TableRow,\n TableCell,\n TableHeader,\n Markdown.configure({\n html: true,\n tightLists: true,\n linkify: true,\n breaks: true,\n transformPastedText: false,\n transformCopiedText: false,\n }),\n MentionExtension,\n];\n\nexport const TiptapText: FC<{ text: string }> = ({ text }) => {\n const handleLinkClick = useAthenaLinkClickHandler();\n const handleLinkClickRef = useRef(handleLinkClick);\n handleLinkClickRef.current = handleLinkClick;\n\n const editor = useEditor({\n immediatelyRender: true,\n extensions,\n content: text,\n editable: false,\n editorProps: {\n attributes: {\n class: \"prose prose-sm dark:prose-invert max-w-none focus:outline-none\",\n },\n handleClick: (_view,
|
|
1
|
+
{"version":3,"file":"tiptap-text.cjs","sources":["../../src/chat/tiptap-text.tsx"],"sourcesContent":["import { useEditor, EditorContent } from \"@tiptap/react\";\nimport StarterKit from \"@tiptap/starter-kit\";\nimport Link from \"@tiptap/extension-link\";\nimport { Table } from \"@tiptap/extension-table\";\nimport { TableRow } from \"@tiptap/extension-table-row\";\nimport { TableCell } from \"@tiptap/extension-table-cell\";\nimport { TableHeader } from \"@tiptap/extension-table-header\";\nimport { Markdown } from \"tiptap-markdown\";\nimport type { FC } from \"react\";\nimport { useEffect, useRef } from \"react\";\nimport { MentionExtension } from \"../chat-ui/mentions/mention-extension\";\nimport { useAthenaLinkClickHandler } from \"./athena-citation-links\";\n\nconst extensions = [\n StarterKit.configure({\n codeBlock: {\n HTMLAttributes: {\n class: \"rounded-md bg-muted p-3 font-mono text-sm\",\n },\n },\n }),\n Link.configure({\n openOnClick: false,\n autolink: true,\n HTMLAttributes: {\n class: \"text-primary underline\",\n target: \"_blank\",\n rel: \"noopener noreferrer\",\n },\n }),\n Table.configure({\n resizable: false,\n HTMLAttributes: {\n class: \"aui-table\",\n },\n }),\n TableRow,\n TableCell,\n TableHeader,\n Markdown.configure({\n html: true,\n tightLists: true,\n linkify: true,\n breaks: true,\n transformPastedText: false,\n transformCopiedText: false,\n }),\n MentionExtension,\n];\n\nexport const TiptapText: FC<{ text: string }> = ({ text }) => {\n const handleLinkClick = useAthenaLinkClickHandler();\n const handleLinkClickRef = useRef(handleLinkClick);\n handleLinkClickRef.current = handleLinkClick;\n\n const editor = useEditor({\n immediatelyRender: true,\n extensions,\n content: text,\n editable: false,\n editorProps: {\n attributes: {\n class: \"prose prose-sm dark:prose-invert max-w-none focus:outline-none\",\n },\n // ProseMirror's `handleClick` fires on `mouseup`, where `preventDefault`\n // cannot cancel the anchor's navigation; the native `click` event can.\n handleDOMEvents: {\n click: (_view, event) => {\n if (event.button !== 0 || event.defaultPrevented) {\n return false;\n }\n\n const target = event.target;\n const targetElement =\n target instanceof HTMLElement\n ? target\n : target instanceof Node\n ? target.parentElement\n : null;\n if (!targetElement) {\n return false;\n }\n\n const link = targetElement.closest(\"a[href]\");\n if (!(link instanceof HTMLAnchorElement)) {\n return false;\n }\n\n if (\n handleLinkClickRef.current({\n href: link.getAttribute(\"href\") ?? link.href,\n linkText: link.textContent,\n target: link.target,\n nativeEvent: event,\n })\n ) {\n event.preventDefault();\n return true;\n }\n\n event.preventDefault();\n window.open(link.href, link.target || \"_blank\")?.focus();\n return true;\n },\n },\n },\n });\n\n useEffect(() => {\n if (editor && text !== (editor.storage as any).markdown?.getMarkdown()) {\n editor.commands.setContent(text);\n }\n }, [text, editor]);\n\n return <EditorContent editor={editor} />;\n};\n"],"names":["Table","TableRow","TableCell","TableHeader","Markdown","MentionExtension","useAthenaLinkClickHandler","useRef","useEditor","useEffect","jsx","EditorContent"],"mappings":";;;;;;;;;;;;;;AAaA,MAAM,aAAa;AAAA,EACjB,WAAW,UAAU;AAAA,IACnB,WAAW;AAAA,MACT,gBAAgB;AAAA,QACd,OAAO;AAAA,MAAA;AAAA,IACT;AAAA,EACF,CACD;AAAA,EACD,KAAK,UAAU;AAAA,IACb,aAAa;AAAA,IACb,UAAU;AAAA,IACV,gBAAgB;AAAA,MACd,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,KAAK;AAAA,IAAA;AAAA,EACP,CACD;AAAA,EACDA,MAAAA,MAAM,UAAU;AAAA,IACd,WAAW;AAAA,IACX,gBAAgB;AAAA,MACd,OAAO;AAAA,IAAA;AAAA,EACT,CACD;AAAA,EACDC,SAAAA;AAAAA,EACAC,UAAAA;AAAAA,EACAC,YAAAA;AAAAA,EACAC,eAAAA,SAAS,UAAU;AAAA,IACjB,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,qBAAqB;AAAA,IACrB,qBAAqB;AAAA,EAAA,CACtB;AAAA,EACDC,iBAAAA;AACF;AAEO,MAAM,aAAmC,CAAC,EAAE,WAAW;AAC5D,QAAM,kBAAkBC,oBAAAA,0BAAA;AACxB,QAAM,qBAAqBC,MAAAA,OAAO,eAAe;AACjD,qBAAmB,UAAU;AAE7B,QAAM,SAASC,QAAAA,UAAU;AAAA,IACvB,mBAAmB;AAAA,IACnB;AAAA,IACA,SAAS;AAAA,IACT,UAAU;AAAA,IACV,aAAa;AAAA,MACX,YAAY;AAAA,QACV,OAAO;AAAA,MAAA;AAAA;AAAA;AAAA,MAIT,iBAAiB;AAAA,QACf,OAAO,CAAC,OAAO,UAAU;;AACvB,cAAI,MAAM,WAAW,KAAK,MAAM,kBAAkB;AAChD,mBAAO;AAAA,UACT;AAEA,gBAAM,SAAS,MAAM;AACrB,gBAAM,gBACJ,kBAAkB,cACd,SACA,kBAAkB,OAChB,OAAO,gBACP;AACR,cAAI,CAAC,eAAe;AAClB,mBAAO;AAAA,UACT;AAEA,gBAAM,OAAO,cAAc,QAAQ,SAAS;AAC5C,cAAI,EAAE,gBAAgB,oBAAoB;AACxC,mBAAO;AAAA,UACT;AAEA,cACE,mBAAmB,QAAQ;AAAA,YACzB,MAAM,KAAK,aAAa,MAAM,KAAK,KAAK;AAAA,YACxC,UAAU,KAAK;AAAA,YACf,QAAQ,KAAK;AAAA,YACb,aAAa;AAAA,UAAA,CACd,GACD;AACA,kBAAM,eAAA;AACN,mBAAO;AAAA,UACT;AAEA,gBAAM,eAAA;AACN,uBAAO,KAAK,KAAK,MAAM,KAAK,UAAU,QAAQ,MAA9C,mBAAiD;AACjD,iBAAO;AAAA,QACT;AAAA,MAAA;AAAA,IACF;AAAA,EACF,CACD;AAEDC,QAAAA,UAAU,MAAM;;AACd,QAAI,UAAU,WAAU,YAAO,QAAgB,aAAvB,mBAAiC,gBAAe;AACtE,aAAO,SAAS,WAAW,IAAI;AAAA,IACjC;AAAA,EACF,GAAG,CAAC,MAAM,MAAM,CAAC;AAEjB,SAAOC,+BAACC,QAAAA,iBAAc,QAAgB;AACxC;;"}
|
package/dist/chat/tiptap-text.js
CHANGED
|
@@ -59,31 +59,36 @@ const TiptapText = ({ text }) => {
|
|
|
59
59
|
attributes: {
|
|
60
60
|
class: "prose prose-sm dark:prose-invert max-w-none focus:outline-none"
|
|
61
61
|
},
|
|
62
|
-
handleClick
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
62
|
+
// ProseMirror's `handleClick` fires on `mouseup`, where `preventDefault`
|
|
63
|
+
// cannot cancel the anchor's navigation; the native `click` event can.
|
|
64
|
+
handleDOMEvents: {
|
|
65
|
+
click: (_view, event) => {
|
|
66
|
+
var _a;
|
|
67
|
+
if (event.button !== 0 || event.defaultPrevented) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
const target = event.target;
|
|
71
|
+
const targetElement = target instanceof HTMLElement ? target : target instanceof Node ? target.parentElement : null;
|
|
72
|
+
if (!targetElement) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
const link = targetElement.closest("a[href]");
|
|
76
|
+
if (!(link instanceof HTMLAnchorElement)) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
if (handleLinkClickRef.current({
|
|
80
|
+
href: link.getAttribute("href") ?? link.href,
|
|
81
|
+
linkText: link.textContent,
|
|
82
|
+
target: link.target,
|
|
83
|
+
nativeEvent: event
|
|
84
|
+
})) {
|
|
85
|
+
event.preventDefault();
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
(_a = window.open(link.href, link.target || "_blank")) == null ? void 0 : _a.focus();
|
|
82
90
|
return true;
|
|
83
91
|
}
|
|
84
|
-
event.preventDefault();
|
|
85
|
-
(_a = window.open(link.href, link.target || "_blank")) == null ? void 0 : _a.focus();
|
|
86
|
-
return true;
|
|
87
92
|
}
|
|
88
93
|
}
|
|
89
94
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiptap-text.js","sources":["../../src/chat/tiptap-text.tsx"],"sourcesContent":["import { useEditor, EditorContent } from \"@tiptap/react\";\nimport StarterKit from \"@tiptap/starter-kit\";\nimport Link from \"@tiptap/extension-link\";\nimport { Table } from \"@tiptap/extension-table\";\nimport { TableRow } from \"@tiptap/extension-table-row\";\nimport { TableCell } from \"@tiptap/extension-table-cell\";\nimport { TableHeader } from \"@tiptap/extension-table-header\";\nimport { Markdown } from \"tiptap-markdown\";\nimport type { FC } from \"react\";\nimport { useEffect, useRef } from \"react\";\nimport { MentionExtension } from \"../chat-ui/mentions/mention-extension\";\nimport { useAthenaLinkClickHandler } from \"./athena-citation-links\";\n\nconst extensions = [\n StarterKit.configure({\n codeBlock: {\n HTMLAttributes: {\n class: \"rounded-md bg-muted p-3 font-mono text-sm\",\n },\n },\n }),\n Link.configure({\n openOnClick: false,\n autolink: true,\n HTMLAttributes: {\n class: \"text-primary underline\",\n target: \"_blank\",\n rel: \"noopener noreferrer\",\n },\n }),\n Table.configure({\n resizable: false,\n HTMLAttributes: {\n class: \"aui-table\",\n },\n }),\n TableRow,\n TableCell,\n TableHeader,\n Markdown.configure({\n html: true,\n tightLists: true,\n linkify: true,\n breaks: true,\n transformPastedText: false,\n transformCopiedText: false,\n }),\n MentionExtension,\n];\n\nexport const TiptapText: FC<{ text: string }> = ({ text }) => {\n const handleLinkClick = useAthenaLinkClickHandler();\n const handleLinkClickRef = useRef(handleLinkClick);\n handleLinkClickRef.current = handleLinkClick;\n\n const editor = useEditor({\n immediatelyRender: true,\n extensions,\n content: text,\n editable: false,\n editorProps: {\n attributes: {\n class: \"prose prose-sm dark:prose-invert max-w-none focus:outline-none\",\n },\n handleClick: (_view,
|
|
1
|
+
{"version":3,"file":"tiptap-text.js","sources":["../../src/chat/tiptap-text.tsx"],"sourcesContent":["import { useEditor, EditorContent } from \"@tiptap/react\";\nimport StarterKit from \"@tiptap/starter-kit\";\nimport Link from \"@tiptap/extension-link\";\nimport { Table } from \"@tiptap/extension-table\";\nimport { TableRow } from \"@tiptap/extension-table-row\";\nimport { TableCell } from \"@tiptap/extension-table-cell\";\nimport { TableHeader } from \"@tiptap/extension-table-header\";\nimport { Markdown } from \"tiptap-markdown\";\nimport type { FC } from \"react\";\nimport { useEffect, useRef } from \"react\";\nimport { MentionExtension } from \"../chat-ui/mentions/mention-extension\";\nimport { useAthenaLinkClickHandler } from \"./athena-citation-links\";\n\nconst extensions = [\n StarterKit.configure({\n codeBlock: {\n HTMLAttributes: {\n class: \"rounded-md bg-muted p-3 font-mono text-sm\",\n },\n },\n }),\n Link.configure({\n openOnClick: false,\n autolink: true,\n HTMLAttributes: {\n class: \"text-primary underline\",\n target: \"_blank\",\n rel: \"noopener noreferrer\",\n },\n }),\n Table.configure({\n resizable: false,\n HTMLAttributes: {\n class: \"aui-table\",\n },\n }),\n TableRow,\n TableCell,\n TableHeader,\n Markdown.configure({\n html: true,\n tightLists: true,\n linkify: true,\n breaks: true,\n transformPastedText: false,\n transformCopiedText: false,\n }),\n MentionExtension,\n];\n\nexport const TiptapText: FC<{ text: string }> = ({ text }) => {\n const handleLinkClick = useAthenaLinkClickHandler();\n const handleLinkClickRef = useRef(handleLinkClick);\n handleLinkClickRef.current = handleLinkClick;\n\n const editor = useEditor({\n immediatelyRender: true,\n extensions,\n content: text,\n editable: false,\n editorProps: {\n attributes: {\n class: \"prose prose-sm dark:prose-invert max-w-none focus:outline-none\",\n },\n // ProseMirror's `handleClick` fires on `mouseup`, where `preventDefault`\n // cannot cancel the anchor's navigation; the native `click` event can.\n handleDOMEvents: {\n click: (_view, event) => {\n if (event.button !== 0 || event.defaultPrevented) {\n return false;\n }\n\n const target = event.target;\n const targetElement =\n target instanceof HTMLElement\n ? target\n : target instanceof Node\n ? target.parentElement\n : null;\n if (!targetElement) {\n return false;\n }\n\n const link = targetElement.closest(\"a[href]\");\n if (!(link instanceof HTMLAnchorElement)) {\n return false;\n }\n\n if (\n handleLinkClickRef.current({\n href: link.getAttribute(\"href\") ?? link.href,\n linkText: link.textContent,\n target: link.target,\n nativeEvent: event,\n })\n ) {\n event.preventDefault();\n return true;\n }\n\n event.preventDefault();\n window.open(link.href, link.target || \"_blank\")?.focus();\n return true;\n },\n },\n },\n });\n\n useEffect(() => {\n if (editor && text !== (editor.storage as any).markdown?.getMarkdown()) {\n editor.commands.setContent(text);\n }\n }, [text, editor]);\n\n return <EditorContent editor={editor} />;\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AAaA,MAAM,aAAa;AAAA,EACjB,WAAW,UAAU;AAAA,IACnB,WAAW;AAAA,MACT,gBAAgB;AAAA,QACd,OAAO;AAAA,MAAA;AAAA,IACT;AAAA,EACF,CACD;AAAA,EACD,KAAK,UAAU;AAAA,IACb,aAAa;AAAA,IACb,UAAU;AAAA,IACV,gBAAgB;AAAA,MACd,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,KAAK;AAAA,IAAA;AAAA,EACP,CACD;AAAA,EACD,MAAM,UAAU;AAAA,IACd,WAAW;AAAA,IACX,gBAAgB;AAAA,MACd,OAAO;AAAA,IAAA;AAAA,EACT,CACD;AAAA,EACD;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS,UAAU;AAAA,IACjB,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,qBAAqB;AAAA,IACrB,qBAAqB;AAAA,EAAA,CACtB;AAAA,EACD;AACF;AAEO,MAAM,aAAmC,CAAC,EAAE,WAAW;AAC5D,QAAM,kBAAkB,0BAAA;AACxB,QAAM,qBAAqB,OAAO,eAAe;AACjD,qBAAmB,UAAU;AAE7B,QAAM,SAAS,UAAU;AAAA,IACvB,mBAAmB;AAAA,IACnB;AAAA,IACA,SAAS;AAAA,IACT,UAAU;AAAA,IACV,aAAa;AAAA,MACX,YAAY;AAAA,QACV,OAAO;AAAA,MAAA;AAAA;AAAA;AAAA,MAIT,iBAAiB;AAAA,QACf,OAAO,CAAC,OAAO,UAAU;;AACvB,cAAI,MAAM,WAAW,KAAK,MAAM,kBAAkB;AAChD,mBAAO;AAAA,UACT;AAEA,gBAAM,SAAS,MAAM;AACrB,gBAAM,gBACJ,kBAAkB,cACd,SACA,kBAAkB,OAChB,OAAO,gBACP;AACR,cAAI,CAAC,eAAe;AAClB,mBAAO;AAAA,UACT;AAEA,gBAAM,OAAO,cAAc,QAAQ,SAAS;AAC5C,cAAI,EAAE,gBAAgB,oBAAoB;AACxC,mBAAO;AAAA,UACT;AAEA,cACE,mBAAmB,QAAQ;AAAA,YACzB,MAAM,KAAK,aAAa,MAAM,KAAK,KAAK;AAAA,YACxC,UAAU,KAAK;AAAA,YACf,QAAQ,KAAK;AAAA,YACb,aAAa;AAAA,UAAA,CACd,GACD;AACA,kBAAM,eAAA;AACN,mBAAO;AAAA,UACT;AAEA,gBAAM,eAAA;AACN,uBAAO,KAAK,KAAK,MAAM,KAAK,UAAU,QAAQ,MAA9C,mBAAiD;AACjD,iBAAO;AAAA,QACT;AAAA,MAAA;AAAA,IACF;AAAA,EACF,CACD;AAED,YAAU,MAAM;;AACd,QAAI,UAAU,WAAU,YAAO,QAAgB,aAAvB,mBAAiC,gBAAe;AACtE,aAAO,SAAS,WAAW,IAAI;AAAA,IACjC;AAAA,EACF,GAAG,CAAC,MAAM,MAAM,CAAC;AAEjB,SAAO,oBAAC,iBAAc,QAAgB;AACxC;"}
|
|
@@ -17,6 +17,7 @@ require("../packages/agent-runtime/src/thread-status.cjs");
|
|
|
17
17
|
require("@assistant-ui/core");
|
|
18
18
|
require("../packages/agent-runtime/src/thread-handoff.cjs");
|
|
19
19
|
const useAthenaRunLive = require("./use-athena-run-live.cjs");
|
|
20
|
+
const NO_QUEUED_LANE_DECISIONS = Object.freeze({});
|
|
20
21
|
function useStatewireApprovalRequest(options = {}) {
|
|
21
22
|
var _a;
|
|
22
23
|
const {
|
|
@@ -32,6 +33,10 @@ function useStatewireApprovalRequest(options = {}) {
|
|
|
32
33
|
const hitl = interrupts.asHitlApproval(request == null ? void 0 : request.payload);
|
|
33
34
|
const actionRequests = react.useMemo(() => interrupts.pendingActionRequests(hitl), [hitl]);
|
|
34
35
|
const isRunning = useAthenaRunLive.useAthenaRunLive();
|
|
36
|
+
const mirror = reactStatewire.useStatewireState(interrupts.readInterruptMirror);
|
|
37
|
+
const liveHitl = request === void 0 && isRunning ? interrupts.asHitlApproval(interrupts.interruptMirrorPayload(mirror)) : null;
|
|
38
|
+
const liveActionRequests = react.useMemo(() => interrupts.pendingActionRequests(liveHitl), [liveHitl]);
|
|
39
|
+
const queuedLaneDecisions = reactStatewire.useStatewireState(interrupts.readQueuedLaneDecisions) ?? NO_QUEUED_LANE_DECISIONS;
|
|
35
40
|
const { pending, resume } = interrupts.useApprovalResumeLock({
|
|
36
41
|
requestId,
|
|
37
42
|
isRunning,
|
|
@@ -45,7 +50,23 @@ function useStatewireApprovalRequest(options = {}) {
|
|
|
45
50
|
response: { type: "resume", value }
|
|
46
51
|
})
|
|
47
52
|
});
|
|
48
|
-
|
|
53
|
+
const sendLaneDecisions = react.useCallback(
|
|
54
|
+
(lanes) => requestId !== void 0 ? resume({ lane_decisions: lanes }) : sendCommand({ type: "run/lane-input", laneDecisions: lanes }),
|
|
55
|
+
[requestId, resume, sendCommand]
|
|
56
|
+
);
|
|
57
|
+
return {
|
|
58
|
+
request,
|
|
59
|
+
requestId,
|
|
60
|
+
hitl,
|
|
61
|
+
actionRequests,
|
|
62
|
+
liveHitl,
|
|
63
|
+
liveActionRequests,
|
|
64
|
+
queuedLaneDecisions,
|
|
65
|
+
abandonedInterrupt,
|
|
66
|
+
pending,
|
|
67
|
+
resume,
|
|
68
|
+
sendLaneDecisions
|
|
69
|
+
};
|
|
49
70
|
}
|
|
50
71
|
exports.useStatewireApprovalRequest = useStatewireApprovalRequest;
|
|
51
72
|
//# sourceMappingURL=use-statewire-approval-request.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-statewire-approval-request.cjs","sources":["../../src/chat/use-statewire-approval-request.ts"],"sourcesContent":["import type { StatewireThread } from '@assistant-ui/react-statewire';\nimport {\n useStatewireRuns,\n useStatewireSendCommand,\n useStatewireState,\n} from '@assistant-ui/react-statewire';\nimport {\n type AbandonedInputRequest,\n asHitlApproval,\n findAbandonedInterrupt,\n HITL_PENDING_RESUME_GRACE_MS,\n type HitlApprovalPayload,\n isApprovalCardInterrupt,\n type PendingActionRequest,\n pendingActionRequests,\n readAbandonedInputRequests,\n useApprovalResumeLock,\n} from '@athenaintel/agent-runtime';\nimport { useMemo } from 'react';\nimport { useAthenaRunLive } from './use-athena-run-live';\n\n/** Selects which pending interrupt an approval surface answers. */\nexport type StatewireInterruptPredicate = (\n request: StatewireThread.InputRequestState,\n) => request is StatewireThread.CustomInputRequest;\n\nexport interface UseStatewireApprovalRequestOptions {\n /**\n * Which pending interrupt to answer. Defaults to `isApprovalCardInterrupt`\n * (client-tool parks excluded — the client-tool bridge owns those, and a\n * generic resume would corrupt the parked tool call).\n */\n interruptPredicate?: StatewireInterruptPredicate;\n /**\n * How long a sent decision keeps the actions locked when no resume run ever\n * starts. Defaults to {@link HITL_PENDING_RESUME_GRACE_MS}.\n */\n pendingResumeGraceMs?: number;\n /**\n * The host refused the `run/input` (or the transport lost it): the\n * optimistic fold rolls back, the request is on screen again with its\n * actions re-enabled, and this is the surface's one chance to say why.\n */\n onResumeRejected?: (error: unknown, requestId: string) => void;\n}\n\nexport interface StatewireApprovalRequest<TValue> {\n /** The pending interrupt this surface answers, if any. */\n request: StatewireThread.CustomInputRequest | undefined;\n requestId: string | undefined;\n /** The payload narrowed to the Athena HITL approval shape, or `null`. */\n hitl: HitlApprovalPayload | null;\n /** Every gated call the approval covers, in decision order (empty for non-HITL parks). */\n actionRequests: PendingActionRequest[];\n /** An interrupt a non-resume dispatch dropped — the \"approval was cancelled\" notice. */\n abandonedInterrupt: AbandonedInputRequest | undefined;\n /** True after a resume until the request identity changes (or recovery fires). */\n pending: boolean;\n /**\n * Answer the request with `{ type: 'run/input', requestId, response: { type: 'resume', value } }`.\n * Returns the dispatch promise (settles when the host accepts, rejects when\n * it refuses), or `undefined` when the lock dropped the send.\n */\n resume: (value: TValue) => Promise<unknown> | undefined;\n}\n\n/**\n * The headless half of every statewire approval surface: selects the pending\n * interrupt from the runs projection, narrows its payload, reads the\n * host-published abandoned interrupts, and wires the shared optimistic resume\n * lock to the thread's `run/input` command. `StatewireApprovalCard` renders\n * over it; hosts with their own decision UI (per-lane subagent cards) build\n * on it directly so the selection and lock semantics cannot drift.\n *\n * Requires a statewire aui scope (throws outside one, like every\n * `useStatewire*` hook) — gate the mount with `hasStatewireThreadExtras`.\n */\nexport function useStatewireApprovalRequest<\n TValue extends StatewireThread.InputResponse = Record<string, string>,\n>(options: UseStatewireApprovalRequestOptions = {}): StatewireApprovalRequest<TValue> {\n const {\n interruptPredicate = isApprovalCardInterrupt,\n pendingResumeGraceMs = HITL_PENDING_RESUME_GRACE_MS,\n onResumeRejected,\n } = options;\n const sendCommand = useStatewireSendCommand();\n // The runs projection is memoized by the lib, so this derivation is\n // reference-stable between state updates.\n const request = useStatewireRuns().inputRequests?.find(interruptPredicate);\n const requestId = request?.id;\n\n // The host publishes the interrupts a non-resume dispatch dropped. Select\n // the raw array reference (pre-stream-safe) and derive inline; a `.find`\n // selector would return a fresh object every update.\n const abandoned = useStatewireState(readAbandonedInputRequests);\n const abandonedInterrupt = findAbandonedInterrupt(abandoned);\n\n const hitl = asHitlApproval(request?.payload);\n const actionRequests = useMemo(() => pendingActionRequests(hitl), [hitl]);\n\n const isRunning = useAthenaRunLive();\n const { pending, resume } = useApprovalResumeLock<TValue>({\n requestId,\n isRunning,\n pendingResumeGraceMs,\n onResumeRejected,\n // The dispatch promise is handed to the lock: a refusal releases it and\n // reaches `onResumeRejected`.\n sendResume: (id, value) =>\n sendCommand({\n type: 'run/input',\n requestId: id,\n response: { type: 'resume', value },\n }),\n });\n\n return { request, requestId, hitl, actionRequests, abandonedInterrupt, pending, resume };\n}\n"],"names":["isApprovalCardInterrupt","HITL_PENDING_RESUME_GRACE_MS","useStatewireSendCommand","useStatewireRuns","useStatewireState","readAbandonedInputRequests","findAbandonedInterrupt","asHitlApproval","useMemo","pendingActionRequests","useAthenaRunLive","useApprovalResumeLock"],"mappings":";;;;;;;;;;;;;;;;;;;AA6EO,SAAS,4BAEd,UAA8C,IAAsC;;AACpF,QAAM;AAAA,IACJ,qBAAqBA,WAAAA;AAAAA,IACrB,uBAAuBC,WAAAA;AAAAA,IACvB;AAAA,EAAA,IACE;AACJ,QAAM,cAAcC,eAAAA,wBAAA;AAGpB,QAAM,WAAUC,oBAAAA,iBAAA,EAAmB,kBAAnBA,mBAAkC,KAAK;AACvD,QAAM,YAAY,mCAAS;AAK3B,QAAM,YAAYC,eAAAA,kBAAkBC,qCAA0B;AAC9D,QAAM,qBAAqBC,WAAAA,uBAAuB,SAAS;AAE3D,QAAM,OAAOC,WAAAA,eAAe,mCAAS,OAAO;AAC5C,QAAM,iBAAiBC,MAAAA,QAAQ,MAAMC,WAAAA,sBAAsB,IAAI,GAAG,CAAC,IAAI,CAAC;AAExE,QAAM,YAAYC,iBAAAA,iBAAA;AAClB,QAAM,EAAE,SAAS,OAAA,IAAWC,iCAA8B;AAAA,IACxD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAAA,IAGA,YAAY,CAAC,IAAI,UACf,YAAY;AAAA,MACV,MAAM;AAAA,MACN,WAAW;AAAA,MACX,UAAU,EAAE,MAAM,UAAU,MAAA;AAAA,IAAM,CACnC;AAAA,EAAA,CACJ;AAED,SAAO,EAAE,SAAS,WAAW,MAAM,gBAAgB,oBAAoB,SAAS,OAAA;AAClF;;"}
|
|
1
|
+
{"version":3,"file":"use-statewire-approval-request.cjs","sources":["../../src/chat/use-statewire-approval-request.ts"],"sourcesContent":["import type { StatewireThread } from '@assistant-ui/react-statewire';\nimport {\n useStatewireRuns,\n useStatewireSendCommand,\n useStatewireState,\n} from '@assistant-ui/react-statewire';\nimport {\n type AbandonedInputRequest,\n asHitlApproval,\n findAbandonedInterrupt,\n HITL_PENDING_RESUME_GRACE_MS,\n type HitlApprovalPayload,\n interruptMirrorPayload,\n isApprovalCardInterrupt,\n type PendingActionRequest,\n pendingActionRequests,\n readAbandonedInputRequests,\n readInterruptMirror,\n readQueuedLaneDecisions,\n useApprovalResumeLock,\n} from '@athenaintel/agent-runtime';\nimport { useCallback, useMemo } from 'react';\nimport { useAthenaRunLive } from './use-athena-run-live';\n\ndeclare module '@assistant-ui/core' {\n namespace Assistant {\n interface Commands {\n /**\n * Decide per-dispatch subagent lanes while the parent run is still\n * streaming (`DeepAgentThread.run_lane_input`). Keys are the lanes'\n * langgraph interrupt ids; the host matches them against the lanes its\n * mirrored interrupt currently parks, answers at once when the run is\n * already parked, and otherwise holds them until it parks — stale or\n * unknown ids are ignored, never carried to a later interrupt.\n */\n runLaneInput: {\n readonly type: 'run/lane-input';\n readonly laneDecisions: Readonly<Record<string, StatewireThread.InputResponse>>;\n };\n }\n }\n}\n\nconst NO_QUEUED_LANE_DECISIONS: Readonly<Record<string, unknown>> = Object.freeze({});\n\n/** Selects which pending interrupt an approval surface answers. */\nexport type StatewireInterruptPredicate = (\n request: StatewireThread.InputRequestState,\n) => request is StatewireThread.CustomInputRequest;\n\nexport interface UseStatewireApprovalRequestOptions {\n /**\n * Which pending interrupt to answer. Defaults to `isApprovalCardInterrupt`\n * (client-tool parks excluded — the client-tool bridge owns those, and a\n * generic resume would corrupt the parked tool call).\n */\n interruptPredicate?: StatewireInterruptPredicate;\n /**\n * How long a sent decision keeps the actions locked when no resume run ever\n * starts. Defaults to {@link HITL_PENDING_RESUME_GRACE_MS}.\n */\n pendingResumeGraceMs?: number;\n /**\n * The host refused the `run/input` (or the transport lost it): the\n * optimistic fold rolls back, the request is on screen again with its\n * actions re-enabled, and this is the surface's one chance to say why.\n */\n onResumeRejected?: (error: unknown, requestId: string) => void;\n}\n\nexport interface StatewireApprovalRequest<TValue> {\n /** The pending interrupt this surface answers, if any. */\n request: StatewireThread.CustomInputRequest | undefined;\n requestId: string | undefined;\n /** The payload narrowed to the Athena HITL approval shape, or `null`. */\n hitl: HitlApprovalPayload | null;\n /** Every gated call the approval covers, in decision order (empty for non-HITL parks). */\n actionRequests: PendingActionRequest[];\n /** An interrupt a non-resume dispatch dropped — the \"approval was cancelled\" notice. */\n abandonedInterrupt: AbandonedInputRequest | undefined;\n /**\n * The mirrored interrupt's HITL payload while the run is still live and no\n * input request is answerable: per-dispatch `task` lanes parked on their\n * gates while sibling lanes stream. `null` once the run parks (the same\n * lanes are then `hitl` / `actionRequests`) and when nothing is parked.\n */\n liveHitl: HitlApprovalPayload | null;\n /** Every gated call `liveHitl` covers (empty when it is `null`). */\n liveActionRequests: PendingActionRequest[];\n /**\n * The decisions the host already holds from a `run/lane-input`, keyed by\n * langgraph interrupt id, to be answered when the run parks — a queued lane\n * reads as decided on every attached client, not just the one that sent it.\n */\n queuedLaneDecisions: Readonly<Record<string, unknown>>;\n /** True after a resume until the request identity changes (or recovery fires). */\n pending: boolean;\n /**\n * Answer the request with `{ type: 'run/input', requestId, response: { type: 'resume', value } }`.\n * Returns the dispatch promise (settles when the host accepts, rejects when\n * it refuses), or `undefined` when the lock dropped the send.\n */\n resume: (value: TValue) => Promise<unknown> | undefined;\n /**\n * Decide per-dispatch lanes by langgraph interrupt id. With a pending\n * request this is the native `lane_decisions` resume through the lock;\n * without one (the run is still streaming siblings) it is `run/lane-input`,\n * which the host queues and answers on the park. Returns the dispatch\n * promise, or `undefined` when the lock dropped a resume.\n */\n sendLaneDecisions: (\n lanes: Readonly<Record<string, StatewireThread.InputResponse>>,\n ) => Promise<unknown> | undefined;\n}\n\n/**\n * The headless half of every statewire approval surface: selects the pending\n * interrupt from the runs projection, narrows its payload, reads the\n * host-published abandoned interrupts, and wires the shared optimistic resume\n * lock to the thread's `run/input` command. `StatewireApprovalCard` renders\n * over it; hosts with their own decision UI (per-lane subagent cards) build\n * on it directly so the selection and lock semantics cannot drift.\n *\n * Requires a statewire aui scope (throws outside one, like every\n * `useStatewire*` hook) — gate the mount with `hasStatewireThreadExtras`.\n */\nexport function useStatewireApprovalRequest<\n TValue extends StatewireThread.InputResponse = Record<string, string>,\n>(options: UseStatewireApprovalRequestOptions = {}): StatewireApprovalRequest<TValue> {\n const {\n interruptPredicate = isApprovalCardInterrupt,\n pendingResumeGraceMs = HITL_PENDING_RESUME_GRACE_MS,\n onResumeRejected,\n } = options;\n const sendCommand = useStatewireSendCommand();\n // The runs projection is memoized by the lib, so this derivation is\n // reference-stable between state updates.\n const request = useStatewireRuns().inputRequests?.find(interruptPredicate);\n const requestId = request?.id;\n\n // The host publishes the interrupts a non-resume dispatch dropped. Select\n // the raw array reference (pre-stream-safe) and derive inline; a `.find`\n // selector would return a fresh object every update.\n const abandoned = useStatewireState(readAbandonedInputRequests);\n const abandonedInterrupt = findAbandonedInterrupt(abandoned);\n\n const hitl = asHitlApproval(request?.payload);\n const actionRequests = useMemo(() => pendingActionRequests(hitl), [hitl]);\n\n const isRunning = useAthenaRunLive();\n // The host mirrors the interrupt into state as soon as a lane parks — while\n // the run manager still reports `running` (siblings streaming) and has no\n // request to answer. Raw reference selectors; derive inline.\n const mirror = useStatewireState(readInterruptMirror);\n const liveHitl =\n request === undefined && isRunning ? asHitlApproval(interruptMirrorPayload(mirror)) : null;\n const liveActionRequests = useMemo(() => pendingActionRequests(liveHitl), [liveHitl]);\n const queuedLaneDecisions =\n useStatewireState(readQueuedLaneDecisions) ?? NO_QUEUED_LANE_DECISIONS;\n\n const { pending, resume } = useApprovalResumeLock<TValue>({\n requestId,\n isRunning,\n pendingResumeGraceMs,\n onResumeRejected,\n // The dispatch promise is handed to the lock: a refusal releases it and\n // reaches `onResumeRejected`.\n sendResume: (id, value) =>\n sendCommand({\n type: 'run/input',\n requestId: id,\n response: { type: 'resume', value },\n }),\n });\n\n const sendLaneDecisions = useCallback(\n (lanes: Readonly<Record<string, StatewireThread.InputResponse>>) =>\n requestId !== undefined\n ? resume({ lane_decisions: lanes } as unknown as TValue)\n : sendCommand({ type: 'run/lane-input', laneDecisions: lanes }),\n [requestId, resume, sendCommand],\n );\n\n return {\n request,\n requestId,\n hitl,\n actionRequests,\n liveHitl,\n liveActionRequests,\n queuedLaneDecisions,\n abandonedInterrupt,\n pending,\n resume,\n sendLaneDecisions,\n };\n}\n"],"names":["isApprovalCardInterrupt","HITL_PENDING_RESUME_GRACE_MS","useStatewireSendCommand","useStatewireRuns","useStatewireState","readAbandonedInputRequests","findAbandonedInterrupt","asHitlApproval","useMemo","pendingActionRequests","useAthenaRunLive","readInterruptMirror","interruptMirrorPayload","readQueuedLaneDecisions","useApprovalResumeLock","useCallback"],"mappings":";;;;;;;;;;;;;;;;;;;AA2CA,MAAM,2BAA8D,OAAO,OAAO,EAAE;AAmF7E,SAAS,4BAEd,UAA8C,IAAsC;;AACpF,QAAM;AAAA,IACJ,qBAAqBA,WAAAA;AAAAA,IACrB,uBAAuBC,WAAAA;AAAAA,IACvB;AAAA,EAAA,IACE;AACJ,QAAM,cAAcC,eAAAA,wBAAA;AAGpB,QAAM,WAAUC,oBAAAA,iBAAA,EAAmB,kBAAnBA,mBAAkC,KAAK;AACvD,QAAM,YAAY,mCAAS;AAK3B,QAAM,YAAYC,eAAAA,kBAAkBC,qCAA0B;AAC9D,QAAM,qBAAqBC,WAAAA,uBAAuB,SAAS;AAE3D,QAAM,OAAOC,WAAAA,eAAe,mCAAS,OAAO;AAC5C,QAAM,iBAAiBC,MAAAA,QAAQ,MAAMC,WAAAA,sBAAsB,IAAI,GAAG,CAAC,IAAI,CAAC;AAExE,QAAM,YAAYC,iBAAAA,iBAAA;AAIlB,QAAM,SAASN,eAAAA,kBAAkBO,8BAAmB;AACpD,QAAM,WACJ,YAAY,UAAa,YAAYJ,WAAAA,eAAeK,WAAAA,uBAAuB,MAAM,CAAC,IAAI;AACxF,QAAM,qBAAqBJ,MAAAA,QAAQ,MAAMC,WAAAA,sBAAsB,QAAQ,GAAG,CAAC,QAAQ,CAAC;AACpF,QAAM,sBACJL,eAAAA,kBAAkBS,WAAAA,uBAAuB,KAAK;AAEhD,QAAM,EAAE,SAAS,OAAA,IAAWC,iCAA8B;AAAA,IACxD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAAA,IAGA,YAAY,CAAC,IAAI,UACf,YAAY;AAAA,MACV,MAAM;AAAA,MACN,WAAW;AAAA,MACX,UAAU,EAAE,MAAM,UAAU,MAAA;AAAA,IAAM,CACnC;AAAA,EAAA,CACJ;AAED,QAAM,oBAAoBC,MAAAA;AAAAA,IACxB,CAAC,UACC,cAAc,SACV,OAAO,EAAE,gBAAgB,MAAA,CAA4B,IACrD,YAAY,EAAE,MAAM,kBAAkB,eAAe,OAAO;AAAA,IAClE,CAAC,WAAW,QAAQ,WAAW;AAAA,EAAA;AAGjC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;;"}
|
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
import type { StatewireThread } from '@assistant-ui/react-statewire';
|
|
2
2
|
import { type AbandonedInputRequest, type HitlApprovalPayload, type PendingActionRequest } from '@athenaintel/agent-runtime';
|
|
3
|
+
declare module '@assistant-ui/core' {
|
|
4
|
+
namespace Assistant {
|
|
5
|
+
interface Commands {
|
|
6
|
+
/**
|
|
7
|
+
* Decide per-dispatch subagent lanes while the parent run is still
|
|
8
|
+
* streaming (`DeepAgentThread.run_lane_input`). Keys are the lanes'
|
|
9
|
+
* langgraph interrupt ids; the host matches them against the lanes its
|
|
10
|
+
* mirrored interrupt currently parks, answers at once when the run is
|
|
11
|
+
* already parked, and otherwise holds them until it parks — stale or
|
|
12
|
+
* unknown ids are ignored, never carried to a later interrupt.
|
|
13
|
+
*/
|
|
14
|
+
runLaneInput: {
|
|
15
|
+
readonly type: 'run/lane-input';
|
|
16
|
+
readonly laneDecisions: Readonly<Record<string, StatewireThread.InputResponse>>;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
3
21
|
/** Selects which pending interrupt an approval surface answers. */
|
|
4
22
|
export type StatewireInterruptPredicate = (request: StatewireThread.InputRequestState) => request is StatewireThread.CustomInputRequest;
|
|
5
23
|
export interface UseStatewireApprovalRequestOptions {
|
|
@@ -31,6 +49,21 @@ export interface StatewireApprovalRequest<TValue> {
|
|
|
31
49
|
actionRequests: PendingActionRequest[];
|
|
32
50
|
/** An interrupt a non-resume dispatch dropped — the "approval was cancelled" notice. */
|
|
33
51
|
abandonedInterrupt: AbandonedInputRequest | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* The mirrored interrupt's HITL payload while the run is still live and no
|
|
54
|
+
* input request is answerable: per-dispatch `task` lanes parked on their
|
|
55
|
+
* gates while sibling lanes stream. `null` once the run parks (the same
|
|
56
|
+
* lanes are then `hitl` / `actionRequests`) and when nothing is parked.
|
|
57
|
+
*/
|
|
58
|
+
liveHitl: HitlApprovalPayload | null;
|
|
59
|
+
/** Every gated call `liveHitl` covers (empty when it is `null`). */
|
|
60
|
+
liveActionRequests: PendingActionRequest[];
|
|
61
|
+
/**
|
|
62
|
+
* The decisions the host already holds from a `run/lane-input`, keyed by
|
|
63
|
+
* langgraph interrupt id, to be answered when the run parks — a queued lane
|
|
64
|
+
* reads as decided on every attached client, not just the one that sent it.
|
|
65
|
+
*/
|
|
66
|
+
queuedLaneDecisions: Readonly<Record<string, unknown>>;
|
|
34
67
|
/** True after a resume until the request identity changes (or recovery fires). */
|
|
35
68
|
pending: boolean;
|
|
36
69
|
/**
|
|
@@ -39,6 +72,14 @@ export interface StatewireApprovalRequest<TValue> {
|
|
|
39
72
|
* it refuses), or `undefined` when the lock dropped the send.
|
|
40
73
|
*/
|
|
41
74
|
resume: (value: TValue) => Promise<unknown> | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Decide per-dispatch lanes by langgraph interrupt id. With a pending
|
|
77
|
+
* request this is the native `lane_decisions` resume through the lock;
|
|
78
|
+
* without one (the run is still streaming siblings) it is `run/lane-input`,
|
|
79
|
+
* which the host queues and answers on the park. Returns the dispatch
|
|
80
|
+
* promise, or `undefined` when the lock dropped a resume.
|
|
81
|
+
*/
|
|
82
|
+
sendLaneDecisions: (lanes: Readonly<Record<string, StatewireThread.InputResponse>>) => Promise<unknown> | undefined;
|
|
42
83
|
}
|
|
43
84
|
/**
|
|
44
85
|
* The headless half of every statewire approval surface: selects the pending
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useStatewireSendCommand, useStatewireRuns, useStatewireState } from "@assistant-ui/react-statewire";
|
|
2
2
|
import "../packages/agent-runtime/src/generated/runconfig-contract.js";
|
|
3
|
-
import { useMemo } from "react";
|
|
3
|
+
import { useMemo, useCallback } from "react";
|
|
4
4
|
import "@assistant-ui/tap";
|
|
5
5
|
import "statewire";
|
|
6
6
|
import "../packages/agent-runtime/src/statewire-suspended.js";
|
|
7
7
|
import "@tanstack/react-query";
|
|
8
|
-
import { isApprovalCardInterrupt, HITL_PENDING_RESUME_GRACE_MS, readAbandonedInputRequests, findAbandonedInterrupt, asHitlApproval, pendingActionRequests, useApprovalResumeLock } from "../packages/agent-runtime/src/interrupts.js";
|
|
8
|
+
import { isApprovalCardInterrupt, HITL_PENDING_RESUME_GRACE_MS, readAbandonedInputRequests, findAbandonedInterrupt, asHitlApproval, pendingActionRequests, readInterruptMirror, interruptMirrorPayload, readQueuedLaneDecisions, useApprovalResumeLock } from "../packages/agent-runtime/src/interrupts.js";
|
|
9
9
|
import "../packages/agent-runtime/src/messages.js";
|
|
10
10
|
import "../packages/agent-runtime/src/statewire-state.js";
|
|
11
11
|
import "@assistant-ui/store";
|
|
@@ -15,6 +15,7 @@ import "../packages/agent-runtime/src/thread-status.js";
|
|
|
15
15
|
import "@assistant-ui/core";
|
|
16
16
|
import "../packages/agent-runtime/src/thread-handoff.js";
|
|
17
17
|
import { useAthenaRunLive } from "./use-athena-run-live.js";
|
|
18
|
+
const NO_QUEUED_LANE_DECISIONS = Object.freeze({});
|
|
18
19
|
function useStatewireApprovalRequest(options = {}) {
|
|
19
20
|
var _a;
|
|
20
21
|
const {
|
|
@@ -30,6 +31,10 @@ function useStatewireApprovalRequest(options = {}) {
|
|
|
30
31
|
const hitl = asHitlApproval(request == null ? void 0 : request.payload);
|
|
31
32
|
const actionRequests = useMemo(() => pendingActionRequests(hitl), [hitl]);
|
|
32
33
|
const isRunning = useAthenaRunLive();
|
|
34
|
+
const mirror = useStatewireState(readInterruptMirror);
|
|
35
|
+
const liveHitl = request === void 0 && isRunning ? asHitlApproval(interruptMirrorPayload(mirror)) : null;
|
|
36
|
+
const liveActionRequests = useMemo(() => pendingActionRequests(liveHitl), [liveHitl]);
|
|
37
|
+
const queuedLaneDecisions = useStatewireState(readQueuedLaneDecisions) ?? NO_QUEUED_LANE_DECISIONS;
|
|
33
38
|
const { pending, resume } = useApprovalResumeLock({
|
|
34
39
|
requestId,
|
|
35
40
|
isRunning,
|
|
@@ -43,7 +48,23 @@ function useStatewireApprovalRequest(options = {}) {
|
|
|
43
48
|
response: { type: "resume", value }
|
|
44
49
|
})
|
|
45
50
|
});
|
|
46
|
-
|
|
51
|
+
const sendLaneDecisions = useCallback(
|
|
52
|
+
(lanes) => requestId !== void 0 ? resume({ lane_decisions: lanes }) : sendCommand({ type: "run/lane-input", laneDecisions: lanes }),
|
|
53
|
+
[requestId, resume, sendCommand]
|
|
54
|
+
);
|
|
55
|
+
return {
|
|
56
|
+
request,
|
|
57
|
+
requestId,
|
|
58
|
+
hitl,
|
|
59
|
+
actionRequests,
|
|
60
|
+
liveHitl,
|
|
61
|
+
liveActionRequests,
|
|
62
|
+
queuedLaneDecisions,
|
|
63
|
+
abandonedInterrupt,
|
|
64
|
+
pending,
|
|
65
|
+
resume,
|
|
66
|
+
sendLaneDecisions
|
|
67
|
+
};
|
|
47
68
|
}
|
|
48
69
|
export {
|
|
49
70
|
useStatewireApprovalRequest
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-statewire-approval-request.js","sources":["../../src/chat/use-statewire-approval-request.ts"],"sourcesContent":["import type { StatewireThread } from '@assistant-ui/react-statewire';\nimport {\n useStatewireRuns,\n useStatewireSendCommand,\n useStatewireState,\n} from '@assistant-ui/react-statewire';\nimport {\n type AbandonedInputRequest,\n asHitlApproval,\n findAbandonedInterrupt,\n HITL_PENDING_RESUME_GRACE_MS,\n type HitlApprovalPayload,\n isApprovalCardInterrupt,\n type PendingActionRequest,\n pendingActionRequests,\n readAbandonedInputRequests,\n useApprovalResumeLock,\n} from '@athenaintel/agent-runtime';\nimport { useMemo } from 'react';\nimport { useAthenaRunLive } from './use-athena-run-live';\n\n/** Selects which pending interrupt an approval surface answers. */\nexport type StatewireInterruptPredicate = (\n request: StatewireThread.InputRequestState,\n) => request is StatewireThread.CustomInputRequest;\n\nexport interface UseStatewireApprovalRequestOptions {\n /**\n * Which pending interrupt to answer. Defaults to `isApprovalCardInterrupt`\n * (client-tool parks excluded — the client-tool bridge owns those, and a\n * generic resume would corrupt the parked tool call).\n */\n interruptPredicate?: StatewireInterruptPredicate;\n /**\n * How long a sent decision keeps the actions locked when no resume run ever\n * starts. Defaults to {@link HITL_PENDING_RESUME_GRACE_MS}.\n */\n pendingResumeGraceMs?: number;\n /**\n * The host refused the `run/input` (or the transport lost it): the\n * optimistic fold rolls back, the request is on screen again with its\n * actions re-enabled, and this is the surface's one chance to say why.\n */\n onResumeRejected?: (error: unknown, requestId: string) => void;\n}\n\nexport interface StatewireApprovalRequest<TValue> {\n /** The pending interrupt this surface answers, if any. */\n request: StatewireThread.CustomInputRequest | undefined;\n requestId: string | undefined;\n /** The payload narrowed to the Athena HITL approval shape, or `null`. */\n hitl: HitlApprovalPayload | null;\n /** Every gated call the approval covers, in decision order (empty for non-HITL parks). */\n actionRequests: PendingActionRequest[];\n /** An interrupt a non-resume dispatch dropped — the \"approval was cancelled\" notice. */\n abandonedInterrupt: AbandonedInputRequest | undefined;\n /** True after a resume until the request identity changes (or recovery fires). */\n pending: boolean;\n /**\n * Answer the request with `{ type: 'run/input', requestId, response: { type: 'resume', value } }`.\n * Returns the dispatch promise (settles when the host accepts, rejects when\n * it refuses), or `undefined` when the lock dropped the send.\n */\n resume: (value: TValue) => Promise<unknown> | undefined;\n}\n\n/**\n * The headless half of every statewire approval surface: selects the pending\n * interrupt from the runs projection, narrows its payload, reads the\n * host-published abandoned interrupts, and wires the shared optimistic resume\n * lock to the thread's `run/input` command. `StatewireApprovalCard` renders\n * over it; hosts with their own decision UI (per-lane subagent cards) build\n * on it directly so the selection and lock semantics cannot drift.\n *\n * Requires a statewire aui scope (throws outside one, like every\n * `useStatewire*` hook) — gate the mount with `hasStatewireThreadExtras`.\n */\nexport function useStatewireApprovalRequest<\n TValue extends StatewireThread.InputResponse = Record<string, string>,\n>(options: UseStatewireApprovalRequestOptions = {}): StatewireApprovalRequest<TValue> {\n const {\n interruptPredicate = isApprovalCardInterrupt,\n pendingResumeGraceMs = HITL_PENDING_RESUME_GRACE_MS,\n onResumeRejected,\n } = options;\n const sendCommand = useStatewireSendCommand();\n // The runs projection is memoized by the lib, so this derivation is\n // reference-stable between state updates.\n const request = useStatewireRuns().inputRequests?.find(interruptPredicate);\n const requestId = request?.id;\n\n // The host publishes the interrupts a non-resume dispatch dropped. Select\n // the raw array reference (pre-stream-safe) and derive inline; a `.find`\n // selector would return a fresh object every update.\n const abandoned = useStatewireState(readAbandonedInputRequests);\n const abandonedInterrupt = findAbandonedInterrupt(abandoned);\n\n const hitl = asHitlApproval(request?.payload);\n const actionRequests = useMemo(() => pendingActionRequests(hitl), [hitl]);\n\n const isRunning = useAthenaRunLive();\n const { pending, resume } = useApprovalResumeLock<TValue>({\n requestId,\n isRunning,\n pendingResumeGraceMs,\n onResumeRejected,\n // The dispatch promise is handed to the lock: a refusal releases it and\n // reaches `onResumeRejected`.\n sendResume: (id, value) =>\n sendCommand({\n type: 'run/input',\n requestId: id,\n response: { type: 'resume', value },\n }),\n });\n\n
|
|
1
|
+
{"version":3,"file":"use-statewire-approval-request.js","sources":["../../src/chat/use-statewire-approval-request.ts"],"sourcesContent":["import type { StatewireThread } from '@assistant-ui/react-statewire';\nimport {\n useStatewireRuns,\n useStatewireSendCommand,\n useStatewireState,\n} from '@assistant-ui/react-statewire';\nimport {\n type AbandonedInputRequest,\n asHitlApproval,\n findAbandonedInterrupt,\n HITL_PENDING_RESUME_GRACE_MS,\n type HitlApprovalPayload,\n interruptMirrorPayload,\n isApprovalCardInterrupt,\n type PendingActionRequest,\n pendingActionRequests,\n readAbandonedInputRequests,\n readInterruptMirror,\n readQueuedLaneDecisions,\n useApprovalResumeLock,\n} from '@athenaintel/agent-runtime';\nimport { useCallback, useMemo } from 'react';\nimport { useAthenaRunLive } from './use-athena-run-live';\n\ndeclare module '@assistant-ui/core' {\n namespace Assistant {\n interface Commands {\n /**\n * Decide per-dispatch subagent lanes while the parent run is still\n * streaming (`DeepAgentThread.run_lane_input`). Keys are the lanes'\n * langgraph interrupt ids; the host matches them against the lanes its\n * mirrored interrupt currently parks, answers at once when the run is\n * already parked, and otherwise holds them until it parks — stale or\n * unknown ids are ignored, never carried to a later interrupt.\n */\n runLaneInput: {\n readonly type: 'run/lane-input';\n readonly laneDecisions: Readonly<Record<string, StatewireThread.InputResponse>>;\n };\n }\n }\n}\n\nconst NO_QUEUED_LANE_DECISIONS: Readonly<Record<string, unknown>> = Object.freeze({});\n\n/** Selects which pending interrupt an approval surface answers. */\nexport type StatewireInterruptPredicate = (\n request: StatewireThread.InputRequestState,\n) => request is StatewireThread.CustomInputRequest;\n\nexport interface UseStatewireApprovalRequestOptions {\n /**\n * Which pending interrupt to answer. Defaults to `isApprovalCardInterrupt`\n * (client-tool parks excluded — the client-tool bridge owns those, and a\n * generic resume would corrupt the parked tool call).\n */\n interruptPredicate?: StatewireInterruptPredicate;\n /**\n * How long a sent decision keeps the actions locked when no resume run ever\n * starts. Defaults to {@link HITL_PENDING_RESUME_GRACE_MS}.\n */\n pendingResumeGraceMs?: number;\n /**\n * The host refused the `run/input` (or the transport lost it): the\n * optimistic fold rolls back, the request is on screen again with its\n * actions re-enabled, and this is the surface's one chance to say why.\n */\n onResumeRejected?: (error: unknown, requestId: string) => void;\n}\n\nexport interface StatewireApprovalRequest<TValue> {\n /** The pending interrupt this surface answers, if any. */\n request: StatewireThread.CustomInputRequest | undefined;\n requestId: string | undefined;\n /** The payload narrowed to the Athena HITL approval shape, or `null`. */\n hitl: HitlApprovalPayload | null;\n /** Every gated call the approval covers, in decision order (empty for non-HITL parks). */\n actionRequests: PendingActionRequest[];\n /** An interrupt a non-resume dispatch dropped — the \"approval was cancelled\" notice. */\n abandonedInterrupt: AbandonedInputRequest | undefined;\n /**\n * The mirrored interrupt's HITL payload while the run is still live and no\n * input request is answerable: per-dispatch `task` lanes parked on their\n * gates while sibling lanes stream. `null` once the run parks (the same\n * lanes are then `hitl` / `actionRequests`) and when nothing is parked.\n */\n liveHitl: HitlApprovalPayload | null;\n /** Every gated call `liveHitl` covers (empty when it is `null`). */\n liveActionRequests: PendingActionRequest[];\n /**\n * The decisions the host already holds from a `run/lane-input`, keyed by\n * langgraph interrupt id, to be answered when the run parks — a queued lane\n * reads as decided on every attached client, not just the one that sent it.\n */\n queuedLaneDecisions: Readonly<Record<string, unknown>>;\n /** True after a resume until the request identity changes (or recovery fires). */\n pending: boolean;\n /**\n * Answer the request with `{ type: 'run/input', requestId, response: { type: 'resume', value } }`.\n * Returns the dispatch promise (settles when the host accepts, rejects when\n * it refuses), or `undefined` when the lock dropped the send.\n */\n resume: (value: TValue) => Promise<unknown> | undefined;\n /**\n * Decide per-dispatch lanes by langgraph interrupt id. With a pending\n * request this is the native `lane_decisions` resume through the lock;\n * without one (the run is still streaming siblings) it is `run/lane-input`,\n * which the host queues and answers on the park. Returns the dispatch\n * promise, or `undefined` when the lock dropped a resume.\n */\n sendLaneDecisions: (\n lanes: Readonly<Record<string, StatewireThread.InputResponse>>,\n ) => Promise<unknown> | undefined;\n}\n\n/**\n * The headless half of every statewire approval surface: selects the pending\n * interrupt from the runs projection, narrows its payload, reads the\n * host-published abandoned interrupts, and wires the shared optimistic resume\n * lock to the thread's `run/input` command. `StatewireApprovalCard` renders\n * over it; hosts with their own decision UI (per-lane subagent cards) build\n * on it directly so the selection and lock semantics cannot drift.\n *\n * Requires a statewire aui scope (throws outside one, like every\n * `useStatewire*` hook) — gate the mount with `hasStatewireThreadExtras`.\n */\nexport function useStatewireApprovalRequest<\n TValue extends StatewireThread.InputResponse = Record<string, string>,\n>(options: UseStatewireApprovalRequestOptions = {}): StatewireApprovalRequest<TValue> {\n const {\n interruptPredicate = isApprovalCardInterrupt,\n pendingResumeGraceMs = HITL_PENDING_RESUME_GRACE_MS,\n onResumeRejected,\n } = options;\n const sendCommand = useStatewireSendCommand();\n // The runs projection is memoized by the lib, so this derivation is\n // reference-stable between state updates.\n const request = useStatewireRuns().inputRequests?.find(interruptPredicate);\n const requestId = request?.id;\n\n // The host publishes the interrupts a non-resume dispatch dropped. Select\n // the raw array reference (pre-stream-safe) and derive inline; a `.find`\n // selector would return a fresh object every update.\n const abandoned = useStatewireState(readAbandonedInputRequests);\n const abandonedInterrupt = findAbandonedInterrupt(abandoned);\n\n const hitl = asHitlApproval(request?.payload);\n const actionRequests = useMemo(() => pendingActionRequests(hitl), [hitl]);\n\n const isRunning = useAthenaRunLive();\n // The host mirrors the interrupt into state as soon as a lane parks — while\n // the run manager still reports `running` (siblings streaming) and has no\n // request to answer. Raw reference selectors; derive inline.\n const mirror = useStatewireState(readInterruptMirror);\n const liveHitl =\n request === undefined && isRunning ? asHitlApproval(interruptMirrorPayload(mirror)) : null;\n const liveActionRequests = useMemo(() => pendingActionRequests(liveHitl), [liveHitl]);\n const queuedLaneDecisions =\n useStatewireState(readQueuedLaneDecisions) ?? NO_QUEUED_LANE_DECISIONS;\n\n const { pending, resume } = useApprovalResumeLock<TValue>({\n requestId,\n isRunning,\n pendingResumeGraceMs,\n onResumeRejected,\n // The dispatch promise is handed to the lock: a refusal releases it and\n // reaches `onResumeRejected`.\n sendResume: (id, value) =>\n sendCommand({\n type: 'run/input',\n requestId: id,\n response: { type: 'resume', value },\n }),\n });\n\n const sendLaneDecisions = useCallback(\n (lanes: Readonly<Record<string, StatewireThread.InputResponse>>) =>\n requestId !== undefined\n ? resume({ lane_decisions: lanes } as unknown as TValue)\n : sendCommand({ type: 'run/lane-input', laneDecisions: lanes }),\n [requestId, resume, sendCommand],\n );\n\n return {\n request,\n requestId,\n hitl,\n actionRequests,\n liveHitl,\n liveActionRequests,\n queuedLaneDecisions,\n abandonedInterrupt,\n pending,\n resume,\n sendLaneDecisions,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA2CA,MAAM,2BAA8D,OAAO,OAAO,EAAE;AAmF7E,SAAS,4BAEd,UAA8C,IAAsC;;AACpF,QAAM;AAAA,IACJ,qBAAqB;AAAA,IACrB,uBAAuB;AAAA,IACvB;AAAA,EAAA,IACE;AACJ,QAAM,cAAc,wBAAA;AAGpB,QAAM,WAAU,sBAAA,EAAmB,kBAAnB,mBAAkC,KAAK;AACvD,QAAM,YAAY,mCAAS;AAK3B,QAAM,YAAY,kBAAkB,0BAA0B;AAC9D,QAAM,qBAAqB,uBAAuB,SAAS;AAE3D,QAAM,OAAO,eAAe,mCAAS,OAAO;AAC5C,QAAM,iBAAiB,QAAQ,MAAM,sBAAsB,IAAI,GAAG,CAAC,IAAI,CAAC;AAExE,QAAM,YAAY,iBAAA;AAIlB,QAAM,SAAS,kBAAkB,mBAAmB;AACpD,QAAM,WACJ,YAAY,UAAa,YAAY,eAAe,uBAAuB,MAAM,CAAC,IAAI;AACxF,QAAM,qBAAqB,QAAQ,MAAM,sBAAsB,QAAQ,GAAG,CAAC,QAAQ,CAAC;AACpF,QAAM,sBACJ,kBAAkB,uBAAuB,KAAK;AAEhD,QAAM,EAAE,SAAS,OAAA,IAAW,sBAA8B;AAAA,IACxD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAAA,IAGA,YAAY,CAAC,IAAI,UACf,YAAY;AAAA,MACV,MAAM;AAAA,MACN,WAAW;AAAA,MACX,UAAU,EAAE,MAAM,UAAU,MAAA;AAAA,IAAM,CACnC;AAAA,EAAA,CACJ;AAED,QAAM,oBAAoB;AAAA,IACxB,CAAC,UACC,cAAc,SACV,OAAO,EAAE,gBAAgB,MAAA,CAA4B,IACrD,YAAY,EAAE,MAAM,kBAAkB,eAAe,OAAO;AAAA,IAClE,CAAC,WAAW,QAAQ,WAAW;AAAA,EAAA;AAGjC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-type-icons.cjs","sources":["../../../../../../src/chat-ui/mentions/suggestions/data/sources/asset-type-icons.ts"],"sourcesContent":["/**\n * Maps Athena asset types to SVG icon file names.\n *\n * The SVG files are bundled by the host app, which declares where they are\n * served from via `configureAssetIconBasePath`. Hosts that don't bundle them\n * fall back to the Lucide icons carried on every menu item.\n */\n\nlet iconBasePath: string | null = null;\n\n/**\n * Point the mention UI at the host's copy of the asset-type SVGs.\n * `basePath` is resolved against the host document; a trailing \"/\" is added\n * when the caller omits it.\n */\nexport function configureAssetIconBasePath({\n basePath,\n}: {\n basePath: string | null;\n}): void {\n iconBasePath = basePath ? basePath.replace(/\\/*$/, \"/\") : basePath;\n}\n\nconst ASSET_TYPE_ICON_FILE: Record<string, string> = {\n // Documents\n folder: \"ic-folder\",\n txt: \"ic-txt\",\n document: \"ic-word\",\n word_document: \"ic-word\",\n markdown: \"ic-md\",\n pdf: \"ic-pdf\",\n html: \"ic-html\",\n web_page: \"ic-html\",\n yaml: \"ic-yaml\",\n json: \"ic-json\",\n\n // Spreadsheets\n spreadsheet: \"ic-excel\",\n table: \"ic-table\",\n\n // Media\n image: \"ic-img\",\n audio: \"ic-audio\",\n video: \"ic-video\",\n voice_memo: \"ic-voice_memo\",\n\n // Presentations\n powerpoint_deck: \"ic-power_point\",\n presentation_pptx_studio: \"ic-power_point\",\n pptx: \"ic-power_point\",\n\n // Email & Calendar\n email: \"ic-mail\",\n email_message: \"ic-mail\",\n live_email_thread: \"ic-mail\",\n live_calendar_event: \"ic-mail\",\n\n // Code\n python: \"ic-py\",\n javascript: \"ic-js\",\n typescript: \"ic-code\",\n jsx: \"ic-code\",\n tsx: \"ic-code\",\n css: \"ic-code\",\n java: \"ic-code\",\n c: \"ic-code\",\n cpp: \"ic-code\",\n csharp: \"ic-code\",\n ruby: \"ic-code\",\n go: \"ic-code\",\n swift: \"ic-code\",\n php: \"ic-code\",\n rust: \"ic-code\",\n vue: \"ic-code\",\n wm_script: \"ic-code\",\n\n // Structured data\n database: \"ic-snippet\",\n schema: \"ic-schema\",\n catalog: \"ic-db\",\n drive: \"ic-db\",\n query_snippet: \"ic-snippet\",\n
|
|
1
|
+
{"version":3,"file":"asset-type-icons.cjs","sources":["../../../../../../src/chat-ui/mentions/suggestions/data/sources/asset-type-icons.ts"],"sourcesContent":["/**\n * Maps Athena asset types to SVG icon file names.\n *\n * The SVG files are bundled by the host app, which declares where they are\n * served from via `configureAssetIconBasePath`. Hosts that don't bundle them\n * fall back to the Lucide icons carried on every menu item.\n */\n\nlet iconBasePath: string | null = null;\n\n/**\n * Point the mention UI at the host's copy of the asset-type SVGs.\n * `basePath` is resolved against the host document; a trailing \"/\" is added\n * when the caller omits it.\n */\nexport function configureAssetIconBasePath({\n basePath,\n}: {\n basePath: string | null;\n}): void {\n iconBasePath = basePath ? basePath.replace(/\\/*$/, \"/\") : basePath;\n}\n\nconst ASSET_TYPE_ICON_FILE: Record<string, string> = {\n // Documents\n folder: \"ic-folder\",\n txt: \"ic-txt\",\n document: \"ic-word\",\n word_document: \"ic-word\",\n markdown: \"ic-md\",\n pdf: \"ic-pdf\",\n html: \"ic-html\",\n web_page: \"ic-html\",\n yaml: \"ic-yaml\",\n json: \"ic-json\",\n\n // Spreadsheets\n spreadsheet: \"ic-excel\",\n table: \"ic-table\",\n\n // Media\n image: \"ic-img\",\n audio: \"ic-audio\",\n video: \"ic-video\",\n voice_memo: \"ic-voice_memo\",\n\n // Presentations\n powerpoint_deck: \"ic-power_point\",\n presentation_pptx_studio: \"ic-power_point\",\n pptx: \"ic-power_point\",\n\n // Email & Calendar\n email: \"ic-mail\",\n email_message: \"ic-mail\",\n live_email_thread: \"ic-mail\",\n live_calendar_event: \"ic-mail\",\n\n // Code\n python: \"ic-py\",\n javascript: \"ic-js\",\n typescript: \"ic-code\",\n jsx: \"ic-code\",\n tsx: \"ic-code\",\n css: \"ic-code\",\n java: \"ic-code\",\n c: \"ic-code\",\n cpp: \"ic-code\",\n csharp: \"ic-code\",\n ruby: \"ic-code\",\n go: \"ic-code\",\n swift: \"ic-code\",\n php: \"ic-code\",\n rust: \"ic-code\",\n vue: \"ic-code\",\n wm_script: \"ic-code\",\n\n // Structured data\n database: \"ic-snippet\",\n schema: \"ic-schema\",\n catalog: \"ic-db\",\n drive: \"ic-db\",\n query_snippet: \"ic-snippet\",\n semantic_model: \"ic-db\",\n dataset: \"ic-db\",\n\n // Meetings & Calls\n meeting: \"ic-meeting\",\n video_session: \"ic-meeting\",\n phone_call: \"ic-phonecall\",\n\n // Sessions & Devices\n session: \"ic-session\",\n browse_session: \"ic-html\",\n virtual_machine: \"ic-html\",\n computer: \"ic-computer\",\n desktop_session: \"ic-desktop_session\",\n mobile_session: \"ic-mobile_session\",\n\n // Projects & Profiles\n project: \"ic-project\",\n browse_profile: \"ic-profile\",\n\n // Workflows & Automation\n aop: \"ic-flow\",\n playbook: \"ic-playbook\",\n policy: \"ic-policy\",\n flow: \"ic-flow\",\n transform_project: \"ic-transform_project\",\n\n // Collections & Notebooks\n collection: \"ic-collection\",\n notebook: \"ic-notebook\",\n\n // UI & Apps\n user_interface: \"ic-app\",\n application: \"ic-application\",\n canvas: \"ic-canvas\",\n dashboard: \"ic-dashboard\",\n figure: \"ic_figure\",\n\n // People & Companies\n person: \"ic-person\",\n company: \"ic-company\",\n\n // Misc\n prompt: \"ic-ai\",\n skill: \"ic-skill\",\n task_item: \"ic-task\",\n spaces: \"ic-spaces\",\n secret: \"ic-secret\",\n photoshop: \"ic-pts\",\n illustrator: \"ic-ai\",\n zip: \"ic-zip\",\n sevenzip: \"ic-zip\",\n\n // Google Drive / SharePoint / Salesforce\n gdrive_folder: \"ic-folder\",\n gdrive_file: \"ic-file\",\n salesforce_record: \"ic-db\",\n salesforce_file: \"ic-db\",\n};\n\nconst ASSET_TYPE_LUCIDE_FALLBACK: Record<string, string> = {\n folder: \"folder\",\n spreadsheet: \"sheet\",\n image: \"image\",\n video: \"video\",\n audio: \"headphones\",\n email: \"mail\",\n database: \"database\",\n project: \"folder-kanban\",\n meeting: \"video\",\n user_interface: \"layout\",\n};\n\n/**\n * Get the SVG thumbnail URL for an Athena asset type, or undefined when the\n * host app does not bundle the icon files.\n */\nexport function assetTypeToThumb(\n assetType: string | null | undefined,\n): string | undefined {\n if (!iconBasePath) return undefined;\n const name: string =\n (assetType ? ASSET_TYPE_ICON_FILE[assetType.toLowerCase()] : undefined) ??\n \"ic-file\";\n return `${iconBasePath}${name}.svg`;\n}\n\n/**\n * Get Lucide icon name fallback for an asset type.\n * Used when thumbnailUrl can't load.\n */\nexport function assetTypeToIcon(assetType: string | null | undefined): string {\n if (!assetType) return \"file\";\n return ASSET_TYPE_LUCIDE_FALLBACK[assetType.toLowerCase()] ?? \"file\";\n}\n"],"names":[],"mappings":";;AAQA,IAAI,eAA8B;AAO3B,SAAS,2BAA2B;AAAA,EACzC;AACF,GAES;AACP,iBAAe,WAAW,SAAS,QAAQ,QAAQ,GAAG,IAAI;AAC5D;AAEA,MAAM,uBAA+C;AAAA;AAAA,EAEnD,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,UAAU;AAAA,EACV,eAAe;AAAA,EACf,UAAU;AAAA,EACV,KAAK;AAAA,EACL,MAAM;AAAA,EACN,UAAU;AAAA,EACV,MAAM;AAAA,EACN,MAAM;AAAA;AAAA,EAGN,aAAa;AAAA,EACb,OAAO;AAAA;AAAA,EAGP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,YAAY;AAAA;AAAA,EAGZ,iBAAiB;AAAA,EACjB,0BAA0B;AAAA,EAC1B,MAAM;AAAA;AAAA,EAGN,OAAO;AAAA,EACP,eAAe;AAAA,EACf,mBAAmB;AAAA,EACnB,qBAAqB;AAAA;AAAA,EAGrB,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,GAAG;AAAA,EACH,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,WAAW;AAAA;AAAA,EAGX,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,OAAO;AAAA,EACP,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,SAAS;AAAA;AAAA,EAGT,SAAS;AAAA,EACT,eAAe;AAAA,EACf,YAAY;AAAA;AAAA,EAGZ,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,UAAU;AAAA,EACV,iBAAiB;AAAA,EACjB,gBAAgB;AAAA;AAAA,EAGhB,SAAS;AAAA,EACT,gBAAgB;AAAA;AAAA,EAGhB,KAAK;AAAA,EACL,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,mBAAmB;AAAA;AAAA,EAGnB,YAAY;AAAA,EACZ,UAAU;AAAA;AAAA,EAGV,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,QAAQ;AAAA;AAAA,EAGR,QAAQ;AAAA,EACR,SAAS;AAAA;AAAA,EAGT,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,aAAa;AAAA,EACb,KAAK;AAAA,EACL,UAAU;AAAA;AAAA,EAGV,eAAe;AAAA,EACf,aAAa;AAAA,EACb,mBAAmB;AAAA,EACnB,iBAAiB;AACnB;AAEA,MAAM,6BAAqD;AAAA,EACzD,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,UAAU;AAAA,EACV,SAAS;AAAA,EACT,SAAS;AAAA,EACT,gBAAgB;AAClB;AAMO,SAAS,iBACd,WACoB;AACpB,MAAI,CAAC,aAAc,QAAO;AAC1B,QAAM,QACH,YAAY,qBAAqB,UAAU,YAAA,CAAa,IAAI,WAC7D;AACF,SAAO,GAAG,YAAY,GAAG,IAAI;AAC/B;AAMO,SAAS,gBAAgB,WAA8C;AAC5E,MAAI,CAAC,UAAW,QAAO;AACvB,SAAO,2BAA2B,UAAU,YAAA,CAAa,KAAK;AAChE;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-type-icons.js","sources":["../../../../../../src/chat-ui/mentions/suggestions/data/sources/asset-type-icons.ts"],"sourcesContent":["/**\n * Maps Athena asset types to SVG icon file names.\n *\n * The SVG files are bundled by the host app, which declares where they are\n * served from via `configureAssetIconBasePath`. Hosts that don't bundle them\n * fall back to the Lucide icons carried on every menu item.\n */\n\nlet iconBasePath: string | null = null;\n\n/**\n * Point the mention UI at the host's copy of the asset-type SVGs.\n * `basePath` is resolved against the host document; a trailing \"/\" is added\n * when the caller omits it.\n */\nexport function configureAssetIconBasePath({\n basePath,\n}: {\n basePath: string | null;\n}): void {\n iconBasePath = basePath ? basePath.replace(/\\/*$/, \"/\") : basePath;\n}\n\nconst ASSET_TYPE_ICON_FILE: Record<string, string> = {\n // Documents\n folder: \"ic-folder\",\n txt: \"ic-txt\",\n document: \"ic-word\",\n word_document: \"ic-word\",\n markdown: \"ic-md\",\n pdf: \"ic-pdf\",\n html: \"ic-html\",\n web_page: \"ic-html\",\n yaml: \"ic-yaml\",\n json: \"ic-json\",\n\n // Spreadsheets\n spreadsheet: \"ic-excel\",\n table: \"ic-table\",\n\n // Media\n image: \"ic-img\",\n audio: \"ic-audio\",\n video: \"ic-video\",\n voice_memo: \"ic-voice_memo\",\n\n // Presentations\n powerpoint_deck: \"ic-power_point\",\n presentation_pptx_studio: \"ic-power_point\",\n pptx: \"ic-power_point\",\n\n // Email & Calendar\n email: \"ic-mail\",\n email_message: \"ic-mail\",\n live_email_thread: \"ic-mail\",\n live_calendar_event: \"ic-mail\",\n\n // Code\n python: \"ic-py\",\n javascript: \"ic-js\",\n typescript: \"ic-code\",\n jsx: \"ic-code\",\n tsx: \"ic-code\",\n css: \"ic-code\",\n java: \"ic-code\",\n c: \"ic-code\",\n cpp: \"ic-code\",\n csharp: \"ic-code\",\n ruby: \"ic-code\",\n go: \"ic-code\",\n swift: \"ic-code\",\n php: \"ic-code\",\n rust: \"ic-code\",\n vue: \"ic-code\",\n wm_script: \"ic-code\",\n\n // Structured data\n database: \"ic-snippet\",\n schema: \"ic-schema\",\n catalog: \"ic-db\",\n drive: \"ic-db\",\n query_snippet: \"ic-snippet\",\n
|
|
1
|
+
{"version":3,"file":"asset-type-icons.js","sources":["../../../../../../src/chat-ui/mentions/suggestions/data/sources/asset-type-icons.ts"],"sourcesContent":["/**\n * Maps Athena asset types to SVG icon file names.\n *\n * The SVG files are bundled by the host app, which declares where they are\n * served from via `configureAssetIconBasePath`. Hosts that don't bundle them\n * fall back to the Lucide icons carried on every menu item.\n */\n\nlet iconBasePath: string | null = null;\n\n/**\n * Point the mention UI at the host's copy of the asset-type SVGs.\n * `basePath` is resolved against the host document; a trailing \"/\" is added\n * when the caller omits it.\n */\nexport function configureAssetIconBasePath({\n basePath,\n}: {\n basePath: string | null;\n}): void {\n iconBasePath = basePath ? basePath.replace(/\\/*$/, \"/\") : basePath;\n}\n\nconst ASSET_TYPE_ICON_FILE: Record<string, string> = {\n // Documents\n folder: \"ic-folder\",\n txt: \"ic-txt\",\n document: \"ic-word\",\n word_document: \"ic-word\",\n markdown: \"ic-md\",\n pdf: \"ic-pdf\",\n html: \"ic-html\",\n web_page: \"ic-html\",\n yaml: \"ic-yaml\",\n json: \"ic-json\",\n\n // Spreadsheets\n spreadsheet: \"ic-excel\",\n table: \"ic-table\",\n\n // Media\n image: \"ic-img\",\n audio: \"ic-audio\",\n video: \"ic-video\",\n voice_memo: \"ic-voice_memo\",\n\n // Presentations\n powerpoint_deck: \"ic-power_point\",\n presentation_pptx_studio: \"ic-power_point\",\n pptx: \"ic-power_point\",\n\n // Email & Calendar\n email: \"ic-mail\",\n email_message: \"ic-mail\",\n live_email_thread: \"ic-mail\",\n live_calendar_event: \"ic-mail\",\n\n // Code\n python: \"ic-py\",\n javascript: \"ic-js\",\n typescript: \"ic-code\",\n jsx: \"ic-code\",\n tsx: \"ic-code\",\n css: \"ic-code\",\n java: \"ic-code\",\n c: \"ic-code\",\n cpp: \"ic-code\",\n csharp: \"ic-code\",\n ruby: \"ic-code\",\n go: \"ic-code\",\n swift: \"ic-code\",\n php: \"ic-code\",\n rust: \"ic-code\",\n vue: \"ic-code\",\n wm_script: \"ic-code\",\n\n // Structured data\n database: \"ic-snippet\",\n schema: \"ic-schema\",\n catalog: \"ic-db\",\n drive: \"ic-db\",\n query_snippet: \"ic-snippet\",\n semantic_model: \"ic-db\",\n dataset: \"ic-db\",\n\n // Meetings & Calls\n meeting: \"ic-meeting\",\n video_session: \"ic-meeting\",\n phone_call: \"ic-phonecall\",\n\n // Sessions & Devices\n session: \"ic-session\",\n browse_session: \"ic-html\",\n virtual_machine: \"ic-html\",\n computer: \"ic-computer\",\n desktop_session: \"ic-desktop_session\",\n mobile_session: \"ic-mobile_session\",\n\n // Projects & Profiles\n project: \"ic-project\",\n browse_profile: \"ic-profile\",\n\n // Workflows & Automation\n aop: \"ic-flow\",\n playbook: \"ic-playbook\",\n policy: \"ic-policy\",\n flow: \"ic-flow\",\n transform_project: \"ic-transform_project\",\n\n // Collections & Notebooks\n collection: \"ic-collection\",\n notebook: \"ic-notebook\",\n\n // UI & Apps\n user_interface: \"ic-app\",\n application: \"ic-application\",\n canvas: \"ic-canvas\",\n dashboard: \"ic-dashboard\",\n figure: \"ic_figure\",\n\n // People & Companies\n person: \"ic-person\",\n company: \"ic-company\",\n\n // Misc\n prompt: \"ic-ai\",\n skill: \"ic-skill\",\n task_item: \"ic-task\",\n spaces: \"ic-spaces\",\n secret: \"ic-secret\",\n photoshop: \"ic-pts\",\n illustrator: \"ic-ai\",\n zip: \"ic-zip\",\n sevenzip: \"ic-zip\",\n\n // Google Drive / SharePoint / Salesforce\n gdrive_folder: \"ic-folder\",\n gdrive_file: \"ic-file\",\n salesforce_record: \"ic-db\",\n salesforce_file: \"ic-db\",\n};\n\nconst ASSET_TYPE_LUCIDE_FALLBACK: Record<string, string> = {\n folder: \"folder\",\n spreadsheet: \"sheet\",\n image: \"image\",\n video: \"video\",\n audio: \"headphones\",\n email: \"mail\",\n database: \"database\",\n project: \"folder-kanban\",\n meeting: \"video\",\n user_interface: \"layout\",\n};\n\n/**\n * Get the SVG thumbnail URL for an Athena asset type, or undefined when the\n * host app does not bundle the icon files.\n */\nexport function assetTypeToThumb(\n assetType: string | null | undefined,\n): string | undefined {\n if (!iconBasePath) return undefined;\n const name: string =\n (assetType ? ASSET_TYPE_ICON_FILE[assetType.toLowerCase()] : undefined) ??\n \"ic-file\";\n return `${iconBasePath}${name}.svg`;\n}\n\n/**\n * Get Lucide icon name fallback for an asset type.\n * Used when thumbnailUrl can't load.\n */\nexport function assetTypeToIcon(assetType: string | null | undefined): string {\n if (!assetType) return \"file\";\n return ASSET_TYPE_LUCIDE_FALLBACK[assetType.toLowerCase()] ?? \"file\";\n}\n"],"names":[],"mappings":"AAQA,IAAI,eAA8B;AAO3B,SAAS,2BAA2B;AAAA,EACzC;AACF,GAES;AACP,iBAAe,WAAW,SAAS,QAAQ,QAAQ,GAAG,IAAI;AAC5D;AAEA,MAAM,uBAA+C;AAAA;AAAA,EAEnD,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,UAAU;AAAA,EACV,eAAe;AAAA,EACf,UAAU;AAAA,EACV,KAAK;AAAA,EACL,MAAM;AAAA,EACN,UAAU;AAAA,EACV,MAAM;AAAA,EACN,MAAM;AAAA;AAAA,EAGN,aAAa;AAAA,EACb,OAAO;AAAA;AAAA,EAGP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,YAAY;AAAA;AAAA,EAGZ,iBAAiB;AAAA,EACjB,0BAA0B;AAAA,EAC1B,MAAM;AAAA;AAAA,EAGN,OAAO;AAAA,EACP,eAAe;AAAA,EACf,mBAAmB;AAAA,EACnB,qBAAqB;AAAA;AAAA,EAGrB,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,GAAG;AAAA,EACH,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,WAAW;AAAA;AAAA,EAGX,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,OAAO;AAAA,EACP,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,SAAS;AAAA;AAAA,EAGT,SAAS;AAAA,EACT,eAAe;AAAA,EACf,YAAY;AAAA;AAAA,EAGZ,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,UAAU;AAAA,EACV,iBAAiB;AAAA,EACjB,gBAAgB;AAAA;AAAA,EAGhB,SAAS;AAAA,EACT,gBAAgB;AAAA;AAAA,EAGhB,KAAK;AAAA,EACL,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,mBAAmB;AAAA;AAAA,EAGnB,YAAY;AAAA,EACZ,UAAU;AAAA;AAAA,EAGV,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,QAAQ;AAAA;AAAA,EAGR,QAAQ;AAAA,EACR,SAAS;AAAA;AAAA,EAGT,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,aAAa;AAAA,EACb,KAAK;AAAA,EACL,UAAU;AAAA;AAAA,EAGV,eAAe;AAAA,EACf,aAAa;AAAA,EACb,mBAAmB;AAAA,EACnB,iBAAiB;AACnB;AAEA,MAAM,6BAAqD;AAAA,EACzD,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,UAAU;AAAA,EACV,SAAS;AAAA,EACT,SAAS;AAAA,EACT,gBAAgB;AAClB;AAMO,SAAS,iBACd,WACoB;AACpB,MAAI,CAAC,aAAc,QAAO;AAC1B,QAAM,QACH,YAAY,qBAAqB,UAAU,YAAA,CAAa,IAAI,WAC7D;AACF,SAAO,GAAG,YAAY,GAAG,IAAI;AAC/B;AAMO,SAAS,gBAAgB,WAA8C;AAC5E,MAAI,CAAC,UAAW,QAAO;AACvB,SAAO,2BAA2B,UAAU,YAAA,CAAa,KAAK;AAChE;"}
|
package/dist/collab/client.cjs
CHANGED
|
@@ -4,6 +4,7 @@ const websocket = require("@y/websocket");
|
|
|
4
4
|
const Y = require("@y/y");
|
|
5
5
|
const closePolicy = require("./close-policy.cjs");
|
|
6
6
|
const mint = require("./mint.cjs");
|
|
7
|
+
const tokenRefresh = require("./token-refresh.cjs");
|
|
7
8
|
function _interopNamespaceDefault(e) {
|
|
8
9
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
9
10
|
if (e) {
|
|
@@ -21,9 +22,6 @@ function _interopNamespaceDefault(e) {
|
|
|
21
22
|
return Object.freeze(n);
|
|
22
23
|
}
|
|
23
24
|
const Y__namespace = /* @__PURE__ */ _interopNamespaceDefault(Y);
|
|
24
|
-
const REFRESH_HEADROOM_MS = 5 * 60 * 1e3;
|
|
25
|
-
const MIN_REFRESH_DELAY_MS = 30 * 1e3;
|
|
26
|
-
const MAX_CONSECUTIVE_REMINTS = 2;
|
|
27
25
|
function connectGenericDoc(args) {
|
|
28
26
|
const access = args.access ?? "view";
|
|
29
27
|
const doc = new Y__namespace.Doc();
|
|
@@ -67,10 +65,7 @@ function connectGenericDoc(args) {
|
|
|
67
65
|
};
|
|
68
66
|
const scheduleRefresh = (grant) => {
|
|
69
67
|
clearRefreshTimer();
|
|
70
|
-
const delay =
|
|
71
|
-
grant.expires_at_ms - Date.now() - REFRESH_HEADROOM_MS,
|
|
72
|
-
MIN_REFRESH_DELAY_MS
|
|
73
|
-
);
|
|
68
|
+
const delay = tokenRefresh.refreshDelayMs({ expiresAtMs: grant.expires_at_ms, now: Date.now() });
|
|
74
69
|
refreshTimer = setTimeout(() => {
|
|
75
70
|
void connect({ scheduledRefresh: true });
|
|
76
71
|
}, delay);
|
|
@@ -90,7 +85,7 @@ function connectGenericDoc(args) {
|
|
|
90
85
|
if (scheduledRefresh && !destroyed) {
|
|
91
86
|
refreshTimer = setTimeout(() => {
|
|
92
87
|
void connect({ scheduledRefresh: true });
|
|
93
|
-
}, MIN_REFRESH_DELAY_MS);
|
|
88
|
+
}, tokenRefresh.MIN_REFRESH_DELAY_MS);
|
|
94
89
|
return;
|
|
95
90
|
}
|
|
96
91
|
setStatus("error", err instanceof Error ? err : new Error(String(err)));
|
|
@@ -136,7 +131,7 @@ function connectGenericDoc(args) {
|
|
|
136
131
|
if (action === "remint") {
|
|
137
132
|
consecutiveRemints += 1;
|
|
138
133
|
teardownProvider();
|
|
139
|
-
if (consecutiveRemints > MAX_CONSECUTIVE_REMINTS) {
|
|
134
|
+
if (consecutiveRemints > tokenRefresh.MAX_CONSECUTIVE_REMINTS) {
|
|
140
135
|
setStatus(
|
|
141
136
|
"closed",
|
|
142
137
|
new Error("Access repeatedly revoked mid-session (4401); giving up.")
|