@ai-matrx/chat 0.7.3 → 0.7.4
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/CHANGELOG.md +10 -0
- package/dist/agents/addressing/agentAddress.d.ts +8 -0
- package/dist/agents/addressing/agentAddress.js +1 -0
- package/dist/agents/addressing/useAgentHref.js +8 -1
- package/dist/agents/components/conversation-history/ConversationHistorySidebar.d.ts +7 -0
- package/dist/agents/components/conversation-history/ConversationHistorySidebar.js +13 -7
- package/dist/agents/components/shared/assistant-message-layout.d.ts +21 -0
- package/dist/agents/components/shared/assistant-message-layout.js +6 -0
- package/dist/agents/hooks/useCreatorOwnershipSync.js +3 -1
- package/dist/agents/redux/conversation-history/thunks.js +2 -1
- package/dist/agents/redux/execution-system/instance-resources/rendered-artifact-draft.d.ts +23 -0
- package/dist/agents/redux/execution-system/instance-resources/rendered-artifact-draft.js +100 -0
- package/dist/agents/redux/execution-system/instance-user-input/composer-draft.middleware.js +9 -0
- package/dist/agents/redux/execution-system/instance-user-input/useComposerDraftRestore.js +3 -1
- package/dist/agents/redux/execution-system/thunks/execute-instance.thunk.js +1 -1
- package/dist/agents/redux/execution-system/thunks/execute-manual-instance.thunk.js +1 -1
- package/dist/agents/redux/execution-system/thunks/frozen-submission.d.ts +5 -0
- package/dist/agents/redux/execution-system/thunks/frozen-submission.js +2 -1
- package/dist/agents/redux/execution-system/utils/content-prefilter.d.ts +50 -0
- package/dist/agents/redux/execution-system/utils/content-prefilter.js +243 -0
- package/dist/agents/redux/execution-system/utils/stream-block-accumulator.d.ts +335 -65
- package/dist/agents/redux/execution-system/utils/stream-block-accumulator.js +1909 -224
- package/dist/conversation/hooks/useDomCapturePrint.js +13 -2
- package/dist/conversation/utils/frame-print.js +20 -2
- package/dist/conversation/utils/isolate-for-capture.d.ts +19 -0
- package/dist/conversation/utils/isolate-for-capture.js +55 -0
- package/dist/host/admin-seat.d.ts +19 -0
- package/dist/host/admin-seat.js +8 -0
- package/dist/ui/markdown-stream/EnhancedChatMarkdown.js +5 -1
- package/package.json +9 -9
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useRef, useState, useCallback } from "react";
|
|
3
|
+
import { toast } from "../../host/notify.js";
|
|
3
4
|
function useDomCapturePrint() {
|
|
4
5
|
const captureRef = useRef(null);
|
|
5
6
|
const [isCapturing, setIsCapturing] = useState(false);
|
|
@@ -16,29 +17,39 @@ function useDomCapturePrint() {
|
|
|
16
17
|
setError(null);
|
|
17
18
|
let releaseRenderAll = null;
|
|
18
19
|
let restoreFrames = null;
|
|
20
|
+
let disposeCopy = null;
|
|
21
|
+
const { filename = "ai-response", ...captureOptions } = options;
|
|
22
|
+
const toastId = toast.loading("Building the PDF\u2026");
|
|
19
23
|
try {
|
|
20
24
|
const { renderAllDiagrams } = await import("@ai-matrx/rich-content/mermaid/lazy-draw");
|
|
21
25
|
releaseRenderAll = (await renderAllDiagrams()).release;
|
|
22
26
|
const { framesToPictures } = await import("../utils/frame-print.js");
|
|
23
27
|
restoreFrames = (await framesToPictures(el)).restore;
|
|
28
|
+
const { isolateForCapture } = await import("../utils/isolate-for-capture.js");
|
|
29
|
+
const isolated = await isolateForCapture(el);
|
|
30
|
+
disposeCopy = isolated.dispose;
|
|
24
31
|
const [{ captureDocumentPdf }, { downloadFile }] = await Promise.all([
|
|
25
32
|
import("@ai-matrx/alchemy/operate/capture"),
|
|
26
33
|
import("@ai-matrx/kit/download")
|
|
27
34
|
]);
|
|
28
|
-
const
|
|
29
|
-
const pdf = await captureDocumentPdf(el, {
|
|
35
|
+
const pdf = await captureDocumentPdf(isolated.element, {
|
|
30
36
|
scale: 2,
|
|
37
|
+
imageFormat: "jpeg",
|
|
31
38
|
...captureOptions,
|
|
32
39
|
onProgress: (page, total) => {
|
|
33
40
|
setProgress(Math.round(page / Math.max(total, 1) * 100));
|
|
41
|
+
if (total > 0) toast.loading(`Building the PDF \u2014 page ${Math.min(page + 1, total)} of ${total}`, { id: toastId });
|
|
34
42
|
options.onProgress?.(page, total);
|
|
35
43
|
}
|
|
36
44
|
});
|
|
37
45
|
downloadFile(`${filename}.pdf`, pdf, "application/pdf");
|
|
46
|
+
toast.success(`Downloaded ${filename}.pdf`, { id: toastId });
|
|
38
47
|
} catch (err) {
|
|
39
48
|
const msg = err instanceof Error ? err.message : "PDF export failed";
|
|
40
49
|
setError(msg);
|
|
50
|
+
toast.error(`The PDF could not be made: ${msg}`, { id: toastId });
|
|
41
51
|
} finally {
|
|
52
|
+
disposeCopy?.();
|
|
42
53
|
restoreFrames?.();
|
|
43
54
|
releaseRenderAll?.();
|
|
44
55
|
setIsCapturing(false);
|
|
@@ -6,9 +6,20 @@ function standInFor(text, width, height) {
|
|
|
6
6
|
stand.style.cssText = `display:flex;align-items:center;justify-content:center;box-sizing:border-box;width:${width ? `${width}px` : "100%"};max-width:100%;min-height:${Math.min(Math.max(height, 96), 240)}px;padding:16px;border:1px dashed #94a3b8;border-radius:8px;color:#475569;font:italic 13px/1.4 system-ui,sans-serif;text-align:center;background:#f8fafc`;
|
|
7
7
|
return stand;
|
|
8
8
|
}
|
|
9
|
+
const objectUrls = /* @__PURE__ */ new Set();
|
|
10
|
+
async function compactSrc(src) {
|
|
11
|
+
if (!src.startsWith("data:") || src.length < 64e3) return src;
|
|
12
|
+
try {
|
|
13
|
+
const url = URL.createObjectURL(await (await fetch(src)).blob());
|
|
14
|
+
objectUrls.add(url);
|
|
15
|
+
return url;
|
|
16
|
+
} catch {
|
|
17
|
+
return src;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
9
20
|
async function pictureOf(src, alt, width, height) {
|
|
10
21
|
const img = document.createElement("img");
|
|
11
|
-
img.src = src;
|
|
22
|
+
img.src = await compactSrc(src);
|
|
12
23
|
img.alt = alt;
|
|
13
24
|
img.style.cssText = `display:block;width:${width ? `${width}px` : "100%"};max-width:100%;height:${height ? `${height}px` : "auto"}`;
|
|
14
25
|
await img.decode().catch(() => void 0);
|
|
@@ -76,7 +87,14 @@ async function framesToPictures(root) {
|
|
|
76
87
|
undo.push(swap(element, await pictureOf(src, element.getAttribute("aria-label") || "Picture", width, height || null)));
|
|
77
88
|
})
|
|
78
89
|
]);
|
|
79
|
-
return {
|
|
90
|
+
return {
|
|
91
|
+
restore: () => {
|
|
92
|
+
undo.forEach((fn) => fn());
|
|
93
|
+
objectUrls.forEach((url) => URL.revokeObjectURL(url));
|
|
94
|
+
objectUrls.clear();
|
|
95
|
+
},
|
|
96
|
+
frames: total
|
|
97
|
+
};
|
|
80
98
|
}
|
|
81
99
|
export {
|
|
82
100
|
CANVAS_PRINT_STAND_IN,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A message, alone, for a DOM capture.
|
|
3
|
+
*
|
|
4
|
+
* html2canvas clones the element's WHOLE document before it draws — for a
|
|
5
|
+
* message inside the app that is the entire app page (every conversation turn,
|
|
6
|
+
* every panel, every inline picture as base64): a 91.8 MB clone on 2026-10-08,
|
|
7
|
+
* and Full Print never finished. This puts a copy of just the message into a
|
|
8
|
+
* hidden same-origin frame that carries only the page's stylesheets and theme,
|
|
9
|
+
* so the capture clones a document that holds one message.
|
|
10
|
+
*
|
|
11
|
+
* Run it AFTER the live-surface pre-pass (`framesToPictures`): a copy keeps
|
|
12
|
+
* pictures but not a canvas's pixels or a frame's page.
|
|
13
|
+
*/
|
|
14
|
+
export interface IsolatedCapture {
|
|
15
|
+
/** The copy to capture — the same width the message has on screen. */
|
|
16
|
+
element: HTMLElement;
|
|
17
|
+
dispose: () => void;
|
|
18
|
+
}
|
|
19
|
+
export declare function isolateForCapture(source: HTMLElement): Promise<IsolatedCapture>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const STYLESHEET_WAIT_MS = 5e3;
|
|
2
|
+
function loaded(link) {
|
|
3
|
+
if (link.sheet) return Promise.resolve();
|
|
4
|
+
return new Promise((resolve) => {
|
|
5
|
+
const done = () => resolve();
|
|
6
|
+
link.addEventListener("load", done, { once: true });
|
|
7
|
+
link.addEventListener("error", done, { once: true });
|
|
8
|
+
setTimeout(done, STYLESHEET_WAIT_MS);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
async function isolateForCapture(source) {
|
|
12
|
+
const width = Math.ceil(source.getBoundingClientRect().width) || source.offsetWidth || 768;
|
|
13
|
+
const frame = document.createElement("iframe");
|
|
14
|
+
frame.setAttribute("aria-hidden", "true");
|
|
15
|
+
frame.tabIndex = -1;
|
|
16
|
+
frame.setAttribute("data-matrx-capture-host", "");
|
|
17
|
+
frame.style.cssText = `position:fixed;left:-100000px;top:0;width:${width}px;height:100px;border:0;pointer-events:none`;
|
|
18
|
+
document.body.appendChild(frame);
|
|
19
|
+
const doc = frame.contentDocument;
|
|
20
|
+
if (!doc) {
|
|
21
|
+
frame.remove();
|
|
22
|
+
throw new Error("The PDF could not be prepared (no capture frame).");
|
|
23
|
+
}
|
|
24
|
+
doc.open();
|
|
25
|
+
doc.write("<!DOCTYPE html><html><head></head><body></body></html>");
|
|
26
|
+
doc.close();
|
|
27
|
+
const html = document.documentElement;
|
|
28
|
+
doc.documentElement.className = html.className;
|
|
29
|
+
const htmlStyle = html.getAttribute("style");
|
|
30
|
+
if (htmlStyle) doc.documentElement.setAttribute("style", htmlStyle);
|
|
31
|
+
for (const attr of [...html.attributes]) {
|
|
32
|
+
if (attr.name.startsWith("data-")) doc.documentElement.setAttribute(attr.name, attr.value);
|
|
33
|
+
}
|
|
34
|
+
doc.body.className = document.body.className;
|
|
35
|
+
doc.body.style.margin = "0";
|
|
36
|
+
doc.body.style.width = `${width}px`;
|
|
37
|
+
const links = [];
|
|
38
|
+
for (const node of document.querySelectorAll('link[rel="stylesheet"], style')) {
|
|
39
|
+
const copy = doc.importNode(node, true);
|
|
40
|
+
doc.head.appendChild(copy);
|
|
41
|
+
if (copy.tagName === "LINK") links.push(copy);
|
|
42
|
+
}
|
|
43
|
+
await Promise.all(links.map(loaded));
|
|
44
|
+
const element = doc.importNode(source, true);
|
|
45
|
+
element.style.width = `${width}px`;
|
|
46
|
+
doc.body.appendChild(element);
|
|
47
|
+
await Promise.all(
|
|
48
|
+
[...element.querySelectorAll("img")].map((img) => img.decode().catch(() => void 0))
|
|
49
|
+
);
|
|
50
|
+
await doc.fonts?.ready.catch(() => void 0);
|
|
51
|
+
return { element, dispose: () => frame.remove() };
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
isolateForCapture
|
|
55
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE ADMIN SEAT (Arman: platform admins keep FULL access inside the admin
|
|
3
|
+
* system, and only there; on ordinary user pages an admin is an ordinary
|
|
4
|
+
* person).
|
|
5
|
+
*
|
|
6
|
+
* Open only when BOTH hold:
|
|
7
|
+
* - the request rides the admin lane (`adminLaneOrganizationId()` is non-null
|
|
8
|
+
* only on an admin page — the host decides from the page at call time), and
|
|
9
|
+
* - the host grants admin power (`selectIsAdmin` — matrx-frontend grants it
|
|
10
|
+
* only inside the admin section).
|
|
11
|
+
*
|
|
12
|
+
* The database mirrors the same gate: `is_platform_admin()` is true only when
|
|
13
|
+
* the admin lane is open, and the "may I?" doors (`agx_get_access_level`,
|
|
14
|
+
* `get_resource_access`, `version_list`, `version_restore`) ask
|
|
15
|
+
* `platform.platform_admin_may`, which answers exactly what the admin RLS
|
|
16
|
+
* policies admit. Client surfaces that decide without a DB round-trip (the
|
|
17
|
+
* creator flag, agent addresses, the history creator filter) ask THIS.
|
|
18
|
+
*/
|
|
19
|
+
export declare function adminSeatOpen(state: unknown): boolean;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState, useEffect, useLayoutEffect, useMemo, useCallback, useRef } from "react";
|
|
4
4
|
import { cn } from "@ai-matrx/design-system";
|
|
5
|
+
import { WIDE_FIGURE_HOST_CLASS, WIDE_FIGURE_PROSE_CLIP_CLASS } from "../../agents/components/shared/assistant-message-layout.js";
|
|
5
6
|
import { splitContentIntoBlocksV2 } from "@ai-matrx/rich-content/display/markdown-classification/processors/utils/content-splitter-v2";
|
|
6
7
|
import { renderSettledFromRecord, settledOneShotBlocks } from "@ai-matrx/rich-content/display/chat-markdown/settle-stream-blocks";
|
|
7
8
|
import { expandTextBlocksInList } from "@ai-matrx/rich-content/display/markdown-classification/processors/utils/expand-text-blocks";
|
|
@@ -733,6 +734,9 @@ const EnhancedChatMarkdownInternal = ({
|
|
|
733
734
|
"pt-1 pb-0 px-0 space-y-4 font-sans text-md antialiased leading-relaxed tracking-wide overflow-x-clip min-w-0 break-words",
|
|
734
735
|
// The first block starts flush (no top margin) — app/globals.css.
|
|
735
736
|
"block w-full bg-inherit markdown-flush-start",
|
|
737
|
+
// A wide figure (a rendered web page) inside: the clip edge moves out to its band, prose keeps the column's.
|
|
738
|
+
WIDE_FIGURE_HOST_CLASS,
|
|
739
|
+
WIDE_FIGURE_PROSE_CLIP_CLASS,
|
|
736
740
|
className
|
|
737
741
|
);
|
|
738
742
|
if (hasError) {
|
|
@@ -1001,7 +1005,7 @@ const EnhancedChatMarkdownInternal = ({
|
|
|
1001
1005
|
/* @__PURE__ */ jsx(MarkdownStreamingProvider, { value: !!isStreamActive, children: /* @__PURE__ */ jsx(DocumentNumberingProvider, { source: currentContent, children: /* @__PURE__ */ jsx(MaybeSourceEdit, { source: currentContent, save: isStreamActive ? void 0 : onContentChange ? handleSaveEdit : void 0, children: /* @__PURE__ */ jsxs(
|
|
1002
1006
|
"div",
|
|
1003
1007
|
{
|
|
1004
|
-
className: "mb-1 w-full min-w-0 text-left overflow-x-clip",
|
|
1008
|
+
className: cn("mb-1 w-full min-w-0 text-left overflow-x-clip", WIDE_FIGURE_HOST_CLASS),
|
|
1005
1009
|
"data-matrx-doc-root": "",
|
|
1006
1010
|
"data-block-count": hasUnifiedSpecial ? void 0 : hasDbInterleavedSpecial ? interleavedTextBlockTotal : stableBlocks.length,
|
|
1007
1011
|
"data-blocks-mounted": hasUnifiedSpecial ? void 0 : hasDbInterleavedSpecial ? Math.min(interleavedShown, interleavedTextBlockTotal) : mountedBlockCount,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-matrx/chat",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "THE one AI Matrx person-to-agent chat system: the full chat (running agents, conversations, tool calls, streaming, context, surfaces, voice) as explicit per-module subpaths @ai-matrx/chat/<domain>/<module> (no wildcards: scripts/public-modules.json) over a host contract (/host, /host/react) whose only required value is a db. One chat, one renderer: the old kernel entries (., /external-store, /matrx, /react, /tools, styles.css, tokens.css) are retired.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -4666,16 +4666,14 @@
|
|
|
4666
4666
|
"server-only": "^0.0.1",
|
|
4667
4667
|
"uuid": "^14.0.2",
|
|
4668
4668
|
"zod": "^4.6.5",
|
|
4669
|
-
"@ai-matrx/browser-audio": "latest",
|
|
4670
|
-
"@ai-matrx/canvas": "latest",
|
|
4671
|
-
"@ai-matrx/content-ir": "latest",
|
|
4672
4669
|
"@ai-matrx/alchemy": "latest",
|
|
4673
4670
|
"@ai-matrx/associations": "latest",
|
|
4671
|
+
"@ai-matrx/agents": "latest",
|
|
4672
|
+
"@ai-matrx/browser-audio": "latest",
|
|
4673
|
+
"@ai-matrx/content-ir": "latest",
|
|
4674
|
+
"@ai-matrx/canvas": "latest",
|
|
4674
4675
|
"@ai-matrx/content-ir-react": "latest",
|
|
4675
4676
|
"@ai-matrx/data": "latest",
|
|
4676
|
-
"@ai-matrx/agents": "latest",
|
|
4677
|
-
"@ai-matrx/diff": "latest",
|
|
4678
|
-
"@ai-matrx/design-system": "latest",
|
|
4679
4677
|
"@ai-matrx/icons": "latest",
|
|
4680
4678
|
"@ai-matrx/kit": "latest",
|
|
4681
4679
|
"@ai-matrx/media": "latest",
|
|
@@ -4684,7 +4682,9 @@
|
|
|
4684
4682
|
"@ai-matrx/records": "latest",
|
|
4685
4683
|
"@ai-matrx/records-ui": "latest",
|
|
4686
4684
|
"@ai-matrx/rich-content": "latest",
|
|
4687
|
-
"@ai-matrx/rich-editor": "latest"
|
|
4685
|
+
"@ai-matrx/rich-editor": "latest",
|
|
4686
|
+
"@ai-matrx/diff": "latest",
|
|
4687
|
+
"@ai-matrx/design-system": "latest"
|
|
4688
4688
|
},
|
|
4689
4689
|
"devDependencies": {
|
|
4690
4690
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
@@ -4802,5 +4802,5 @@
|
|
|
4802
4802
|
"check:side-effects": "node ../scripts/check-side-effects-listed.mjs . && node ../scripts/check-side-effects-listed.mjs --self-test",
|
|
4803
4803
|
"check:public-surface": "node ./scripts/sync-public-surface.mjs --check && node ./scripts/sync-public-surface.mjs --self-test"
|
|
4804
4804
|
},
|
|
4805
|
-
"gitHead": "
|
|
4805
|
+
"gitHead": "7383483116d7588203992904f838129d54b59463"
|
|
4806
4806
|
}
|