@ai-matrx/chat 0.5.18 → 0.6.1
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 +32 -0
- package/dist/agents/components/identity-refs/AiIdentityRef.d.ts +33 -0
- package/dist/agents/components/identity-refs/AiIdentityRef.js +138 -0
- package/dist/agents/components/inputs/resources/RenderedArtifactChip.d.ts +8 -0
- package/dist/agents/components/inputs/resources/RenderedArtifactChip.js +109 -0
- package/dist/agents/components/inputs/resources/SmartAgentResourceChips.js +20 -0
- package/dist/agents/components/inputs/resources/useAttachRenderedArtifact.js +31 -6
- package/dist/agents/components/inputs/smart-input/QuicksetPanel.js +5 -9
- package/dist/agents/components/inputs/smart-input/RunSkillPicker.js +1 -1
- package/dist/agents/components/inputs/smart-input/RunToolPicker.js +6 -11
- package/dist/agents/components/inputs/smart-input/ShapeChipsRow.js +1 -1
- package/dist/agents/components/inputs/smart-input/composer/ComposerEffortPill.js +1 -1
- package/dist/agents/components/inputs/smart-input/composer/ComposerOutput.js +1 -1
- package/dist/agents/components/inputs/smart-input/composer/ComposerPlusMenu.js +1 -1
- package/dist/agents/components/inputs/smart-input/composer/useComposerAgent.js +1 -1
- package/dist/agents/components/inputs/smart-input/composer/useRunControlCounts.d.ts +3 -0
- package/dist/agents/components/inputs/smart-input/composer/useRunControlCounts.js +54 -0
- package/dist/agents/components/model-tiers/ModelTierIdentityList.js +1 -1
- package/dist/agents/components/run-controls/RunConfigOverrides.js +1 -1
- package/dist/agents/components/run-controls/RunInputCapabilities.js +1 -1
- package/dist/agents/components/run-controls/panels/shared.d.ts +0 -2
- package/dist/agents/hooks/useDiffEnrichment.js +3 -6
- package/dist/agents/identity/agent-catalog-lists.js +2 -1
- package/dist/agents/identity/agent-identity.js +2 -1
- package/dist/agents/identity/model-catalog.d.ts +9 -0
- package/dist/agents/identity/model-catalog.js +25 -0
- package/dist/agents/identity/preferred-chat-model.d.ts +9 -0
- package/dist/agents/identity/preferred-chat-model.js +33 -0
- package/dist/agents/identity/settings-store.d.ts +10 -0
- package/dist/agents/identity/settings-store.js +49 -0
- package/dist/agents/identity/skill-catalog.d.ts +27 -0
- package/dist/agents/identity/skill-catalog.js +100 -0
- package/dist/agents/identity/tool-catalog.d.ts +15 -0
- package/dist/agents/identity/tool-catalog.js +67 -0
- package/dist/agents/redux/agent-definition/cache-bust-middleware.d.ts +0 -1
- package/dist/agents/redux/agent-definition/cache-bust-middleware.js +1 -13
- package/dist/agents/redux/agent-definition/selectors.d.ts +12 -546
- package/dist/agents/redux/agent-settings/internal-utils.d.ts +2 -123
- package/dist/agents/redux/agent-settings/internal-utils.js +1 -315
- package/dist/agents/redux/agent-settings/settings-catalogue.d.ts +2 -78
- package/dist/agents/redux/agent-settings/settings-catalogue.js +1 -176
- package/dist/agents/redux/agent-settings/types.d.ts +2 -148
- package/dist/agents/redux/agent-settings/types.js +1 -0
- package/dist/agents/redux/agent-settings/ui-gates.d.ts +2 -54
- package/dist/agents/redux/agent-settings/ui-gates.js +1 -38
- package/dist/agents/redux/agent-shortcut-categories/selectors.d.ts +0 -100
- package/dist/agents/redux/agent-shortcuts/selectors.d.ts +0 -294
- package/dist/agents/redux/conversation-history/selectors.d.ts +0 -32
- package/dist/agents/redux/conversation-list/conversation-list.selectors.d.ts +0 -4
- package/dist/agents/redux/execution-system/active-requests/active-requests.selectors.d.ts +0 -108
- package/dist/agents/redux/execution-system/context-state/context-state.selectors.d.ts +0 -28
- package/dist/agents/redux/execution-system/conversations/conversations.selectors.d.ts +0 -10
- package/dist/agents/redux/execution-system/instance-context/instance-context.selectors.d.ts +0 -6
- package/dist/agents/redux/execution-system/instance-model-overrides/launch-model-overrides.js +1 -1
- package/dist/agents/redux/execution-system/instance-resources/instance-resources.selectors.d.ts +0 -16
- package/dist/agents/redux/execution-system/instance-ui-state/instance-ui-state.selectors.d.ts +0 -10
- package/dist/agents/redux/execution-system/instance-variable-values/instance-variable-values.selectors.d.ts +0 -14
- package/dist/agents/redux/execution-system/messages/messages.selectors.d.ts +0 -2
- package/dist/agents/redux/execution-system/observability/observability.selectors.d.ts +0 -14
- package/dist/agents/redux/execution-system/observational-memory/observational-memory.selectors.d.ts +0 -2
- package/dist/agents/redux/execution-system/selectors/aggregate.selectors.d.ts +0 -28
- package/dist/agents/redux/execution-system/thunks/process-stream.js +2 -5
- package/dist/agents/redux/execution-system/utils/loaded-skill-sources.d.ts +1 -1
- package/dist/agents/redux/execution-system/utils/loaded-skill-sources.js +3 -3
- package/dist/agents/redux/proposed-directives/proposedDirectivesSlice.d.ts +0 -2
- package/dist/agents/ui-first-tools/redux/agent-lists.selectors.d.ts +0 -4
- package/dist/agents/utils/renderedArtifactContext.d.ts +55 -17
- package/dist/agents/utils/renderedArtifactContext.js +83 -2
- package/dist/conversation/utils/frame-print.d.ts +10 -5
- package/dist/conversation/utils/frame-print.js +65 -27
- package/dist/host/frame-print.d.ts +10 -0
- package/dist/host/frame-print.js +9 -0
- package/dist/host/ui-slots.d.ts +0 -46
- package/dist/host/ui-slots.js +0 -33
- package/dist/store/create-chat-store.d.ts +0 -4
- package/dist/store/middlewares.d.ts +0 -10
- package/dist/store/slices.d.ts +0 -2
- package/dist/store/slices.js +0 -4
- package/dist/surfaces/redux/selectors.d.ts +0 -4
- package/dist/tool-call-visualization/redux/selectors.d.ts +0 -2
- package/dist/ui/chat-default-model-knob.d.ts +1 -1
- package/dist/ui/chat-default-model-knob.js +1 -1
- package/package.json +5 -5
- package/dist/agents/components/model/AgentModelPanel.d.ts +0 -4
- package/dist/agents/components/model/AgentModelPanel.js +0 -9
- package/dist/agents/redux/agent-settings/agentSettingsSlice.d.ts +0 -1015
- package/dist/agents/redux/agent-settings/agentSettingsSlice.js +0 -659
- package/dist/agents/redux/agent-settings/selectors.d.ts +0 -10057
- package/dist/agents/redux/agent-settings/selectors.js +0 -234
- package/dist/agents/redux/agent-settings/useNormalizedControls.d.ts +0 -8
- package/dist/agents/redux/agent-settings/useNormalizedControls.js +0 -24
- package/dist/agents/redux/tools/tools.selectors.d.ts +0 -529
- package/dist/agents/redux/tools/tools.selectors.js +0 -24
- package/dist/agents/redux/tools/tools.slice.d.ts +0 -12
- package/dist/agents/redux/tools/tools.slice.js +0 -37
- package/dist/agents/redux/tools/tools.thunks.d.ts +0 -125
- package/dist/agents/redux/tools/tools.thunks.js +0 -45
- package/dist/host/defaults/setting-control-input.d.ts +0 -11
- package/dist/host/defaults/setting-control-input.js +0 -91
|
@@ -1,41 +1,79 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Rendered-artifact context items (rendered-output standard, guarantee 3).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* Any artifact the person sees — an HTML page, a canvas item, a table / code /
|
|
5
|
+
* diagram / quiz block inside a message — is attachable to a chat turn in the
|
|
6
|
+
* representations ITS TYPE offers (the host declares them per artifact type on
|
|
7
|
+
* the source's `options`; HTML's are the default list below):
|
|
8
|
+
* - `code` — the artifact's content: the HTML document, the code, the
|
|
9
|
+
* diagram source, the markdown, or the kind's data as JSON
|
|
10
|
+
* (labelled per type: "Code", "Source", "Data", …),
|
|
11
|
+
* - `text` — a readable plain-text form, where one exists,
|
|
12
|
+
* - `screenshot` — the artifact as rendered, captured at ATTACH time by the
|
|
13
|
+
* host's capture port and attached as an explicit image part
|
|
9
14
|
* (`input_image`, the paste-image path). Never captured at send.
|
|
10
15
|
*
|
|
11
|
-
* `
|
|
12
|
-
*
|
|
16
|
+
* A SAVED artifact (`canvas_item` / `html_page`) rides `request.context` as a
|
|
17
|
+
* resource reference with the chosen representation; the server resolver reads
|
|
18
|
+
* it. An UNSAVED one (a block in a message that was never materialised) is an
|
|
19
|
+
* `inline` source: its content/text ride `request.context` as a named entry.
|
|
20
|
+
* Neither ever becomes `user_input` (THE USER-INPUT LAW).
|
|
13
21
|
*/
|
|
14
|
-
import { createResourceReference } from "../agent-context/resource-reference.js";
|
|
15
22
|
import type { RenderedArtifactRepresentation, ResourceRepresentation } from "../types/instance.types.js";
|
|
16
23
|
export declare const RENDERED_ARTIFACT_BLOCK_TYPE = "rendered_artifact";
|
|
17
|
-
export type RenderedArtifactRecordType = "canvas_item" | "html_page";
|
|
24
|
+
export type RenderedArtifactRecordType = "canvas_item" | "html_page" | "inline";
|
|
25
|
+
export interface RenderedArtifactRepresentationOption {
|
|
26
|
+
value: RenderedArtifactRepresentation;
|
|
27
|
+
label: string;
|
|
28
|
+
hint: string;
|
|
29
|
+
/** Present when this type cannot offer it yet — shown, with the reason, never hidden. */
|
|
30
|
+
unavailable?: string;
|
|
31
|
+
}
|
|
32
|
+
/** The body of an `inline` (unsaved) artifact — what its context entries carry. */
|
|
33
|
+
export interface RenderedArtifactInlineBody {
|
|
34
|
+
/** The content representation: code, source, markdown, or the data as JSON. */
|
|
35
|
+
code: string;
|
|
36
|
+
/** The readable plain-text form, when the type has one. */
|
|
37
|
+
text?: string | null;
|
|
38
|
+
}
|
|
18
39
|
/** The `source` of a `rendered_artifact` resource. */
|
|
19
40
|
export interface RenderedArtifactSource {
|
|
20
41
|
kind: "rendered_artifact";
|
|
21
42
|
record_type: RenderedArtifactRecordType;
|
|
43
|
+
/** The record id; for `inline`, a stable key of the block. */
|
|
22
44
|
record_id: string;
|
|
23
45
|
title: string;
|
|
46
|
+
/** The artifact type (canvas content type / `__kind`) — names it to the model. */
|
|
47
|
+
artifact_type?: string;
|
|
48
|
+
/** What this artifact offers, in menu order, first = default. Absent → HTML's list. */
|
|
49
|
+
options?: RenderedArtifactRepresentationOption[];
|
|
50
|
+
/** Only for `inline`. */
|
|
51
|
+
body?: RenderedArtifactInlineBody;
|
|
24
52
|
}
|
|
25
|
-
|
|
26
|
-
value: RenderedArtifactRepresentation;
|
|
27
|
-
label: string;
|
|
28
|
-
hint: string;
|
|
29
|
-
}
|
|
30
|
-
/** The options a rendered artifact offers, data-driven so a new one is one entry. */
|
|
53
|
+
/** HTML's options — the default when a source declares none. */
|
|
31
54
|
export declare function availableRenderedArtifactRepresentations(): RenderedArtifactRepresentationOption[];
|
|
55
|
+
/** The options a source offers (its own, else HTML's). */
|
|
56
|
+
export declare function renderedArtifactOptionsOf(source: RenderedArtifactSource): RenderedArtifactRepresentationOption[];
|
|
57
|
+
/** The chip's short name for a representation of this source. */
|
|
58
|
+
export declare function renderedArtifactRepresentationLabel(source: RenderedArtifactSource, representation: RenderedArtifactRepresentation): string;
|
|
32
59
|
export declare function isRenderedArtifactSource(source: unknown): source is RenderedArtifactSource;
|
|
33
60
|
export declare function isRenderedArtifactRepresentation(value: unknown): value is RenderedArtifactRepresentation;
|
|
34
61
|
/**
|
|
35
|
-
* The `request.context` entry for a
|
|
62
|
+
* The `request.context` entry for a content/text attachment, or null when the
|
|
36
63
|
* source is malformed or the choice is `screenshot` (an image part, not context).
|
|
37
64
|
*/
|
|
38
65
|
export declare function renderedArtifactContextEntry(source: unknown, representation: ResourceRepresentation | undefined): {
|
|
39
66
|
key: string;
|
|
40
|
-
reference:
|
|
67
|
+
reference: unknown;
|
|
41
68
|
} | null;
|
|
69
|
+
/**
|
|
70
|
+
* A readable plain-text form of structured data (a kind value, a table, a
|
|
71
|
+
* quiz): one `label: value` line per leaf, nested objects indented, arrays as
|
|
72
|
+
* numbered items, `__kind` named once at the top. Server twin:
|
|
73
|
+
* `canvas_sources.readable_text` (same rules, same corpus in both tests).
|
|
74
|
+
*/
|
|
75
|
+
export declare function readableText(value: unknown): string;
|
|
76
|
+
type CaptureFn = () => Promise<unknown>;
|
|
77
|
+
export declare function registerRenderedArtifactCapture(source: Pick<RenderedArtifactSource, "record_type" | "record_id">, capture: CaptureFn): void;
|
|
78
|
+
export declare function renderedArtifactCaptureFor<T = unknown>(source: Pick<RenderedArtifactSource, "record_type" | "record_id">): (() => Promise<T>) | null;
|
|
79
|
+
export {};
|
|
@@ -7,10 +7,23 @@ function availableRenderedArtifactRepresentations() {
|
|
|
7
7
|
{ value: "text", label: "Text", hint: "The words on the page" }
|
|
8
8
|
];
|
|
9
9
|
}
|
|
10
|
+
function renderedArtifactOptionsOf(source) {
|
|
11
|
+
return source.options && source.options.length > 0 ? source.options : availableRenderedArtifactRepresentations();
|
|
12
|
+
}
|
|
13
|
+
function renderedArtifactRepresentationLabel(source, representation) {
|
|
14
|
+
const option = renderedArtifactOptionsOf(source).find((o) => o.value === representation);
|
|
15
|
+
if (option) return option.label;
|
|
16
|
+
return representation === "code" ? "Code" : representation === "text" ? "Text" : "Screenshot";
|
|
17
|
+
}
|
|
10
18
|
function isRenderedArtifactSource(source) {
|
|
11
19
|
if (!source || typeof source !== "object") return false;
|
|
12
20
|
const s = source;
|
|
13
|
-
|
|
21
|
+
if (s.kind !== "rendered_artifact") return false;
|
|
22
|
+
if (typeof s.record_id !== "string" || s.record_id.length === 0) return false;
|
|
23
|
+
if (s.record_type === "canvas_item" || s.record_type === "html_page") return true;
|
|
24
|
+
if (s.record_type !== "inline") return false;
|
|
25
|
+
const body = s.body;
|
|
26
|
+
return !!body && typeof body.code === "string";
|
|
14
27
|
}
|
|
15
28
|
function isRenderedArtifactRepresentation(value) {
|
|
16
29
|
return value === "code" || value === "screenshot" || value === "text";
|
|
@@ -19,12 +32,28 @@ function serverRepresentation(recordType, representation) {
|
|
|
19
32
|
if (representation === "text") return "text";
|
|
20
33
|
return recordType === "html_page" ? "html" : "content";
|
|
21
34
|
}
|
|
35
|
+
function inlineEntryValue(source, representation) {
|
|
36
|
+
const body = source.body;
|
|
37
|
+
const text = representation === "text" ? body.text ?? body.code : body.code;
|
|
38
|
+
const label = renderedArtifactRepresentationLabel(source, representation);
|
|
39
|
+
const type = source.artifact_type ? ` ${source.artifact_type}` : "";
|
|
40
|
+
return `Attached${type} "${source.title || "artifact"}" (${label.toLowerCase()}):
|
|
41
|
+
|
|
42
|
+
${text}`;
|
|
43
|
+
}
|
|
22
44
|
function renderedArtifactContextEntry(source, representation) {
|
|
23
45
|
if (!isRenderedArtifactSource(source)) return null;
|
|
24
46
|
const rep = isRenderedArtifactRepresentation(
|
|
25
47
|
representation
|
|
26
48
|
) ? representation : "code";
|
|
27
49
|
if (rep === "screenshot") return null;
|
|
50
|
+
if (source.record_type === "inline") {
|
|
51
|
+
const safeId = source.record_id.replace(/[^\w-]+/g, "_").slice(0, 64);
|
|
52
|
+
return {
|
|
53
|
+
key: `artifact_${safeId}_${rep === "code" ? "content" : "text"}`,
|
|
54
|
+
reference: inlineEntryValue(source, rep)
|
|
55
|
+
};
|
|
56
|
+
}
|
|
28
57
|
return {
|
|
29
58
|
key: `resource_${source.record_type}_${source.record_id}_${rep}`,
|
|
30
59
|
reference: createResourceReference(source.record_type, source.record_id, {
|
|
@@ -32,10 +61,62 @@ function renderedArtifactContextEntry(source, representation) {
|
|
|
32
61
|
})
|
|
33
62
|
};
|
|
34
63
|
}
|
|
64
|
+
function readableText(value) {
|
|
65
|
+
const lines = [];
|
|
66
|
+
const humanize = (key) => key.replace(/[_-]+/g, " ").replace(/\s+/g, " ").trim();
|
|
67
|
+
const walk = (node, depth, label) => {
|
|
68
|
+
const pad = " ".repeat(depth);
|
|
69
|
+
const prefix = label ? `${label}: ` : "";
|
|
70
|
+
if (node === null || node === void 0 || node === "") return;
|
|
71
|
+
if (typeof node !== "object") {
|
|
72
|
+
lines.push(`${pad}${prefix}${String(node)}`);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (Array.isArray(node)) {
|
|
76
|
+
if (node.length === 0) return;
|
|
77
|
+
if (label) lines.push(`${pad}${label}:`);
|
|
78
|
+
node.forEach((item, index) => {
|
|
79
|
+
if (item !== null && typeof item === "object") {
|
|
80
|
+
lines.push(`${pad}${label ? " " : ""}${index + 1}.`);
|
|
81
|
+
walk(item, depth + (label ? 2 : 1), null);
|
|
82
|
+
} else {
|
|
83
|
+
walk(item, depth + (label ? 1 : 0), `${index + 1}`);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const record = node;
|
|
89
|
+
if (label) lines.push(`${pad}${label}:`);
|
|
90
|
+
for (const [key, child] of Object.entries(record)) {
|
|
91
|
+
if (key === "__kind") {
|
|
92
|
+
if (depth === 0 && !label && typeof child === "string") lines.push(`(${child})`);
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
walk(child, depth + (label ? 1 : 0), humanize(key));
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
walk(value, 0, null);
|
|
99
|
+
return lines.join("\n");
|
|
100
|
+
}
|
|
101
|
+
const captures = /* @__PURE__ */ new Map();
|
|
102
|
+
function sourceKey(source) {
|
|
103
|
+
return `${source.record_type}:${source.record_id}`;
|
|
104
|
+
}
|
|
105
|
+
function registerRenderedArtifactCapture(source, capture) {
|
|
106
|
+
captures.set(sourceKey(source), capture);
|
|
107
|
+
}
|
|
108
|
+
function renderedArtifactCaptureFor(source) {
|
|
109
|
+
return captures.get(sourceKey(source)) ?? null;
|
|
110
|
+
}
|
|
35
111
|
export {
|
|
36
112
|
RENDERED_ARTIFACT_BLOCK_TYPE,
|
|
37
113
|
availableRenderedArtifactRepresentations,
|
|
38
114
|
isRenderedArtifactRepresentation,
|
|
39
115
|
isRenderedArtifactSource,
|
|
40
|
-
|
|
116
|
+
readableText,
|
|
117
|
+
registerRenderedArtifactCapture,
|
|
118
|
+
renderedArtifactCaptureFor,
|
|
119
|
+
renderedArtifactContextEntry,
|
|
120
|
+
renderedArtifactOptionsOf,
|
|
121
|
+
renderedArtifactRepresentationLabel
|
|
41
122
|
};
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Full Print's
|
|
3
|
-
* `<iframe>` inside the captured message is shown as its picture — from
|
|
4
|
-
* host's frame capture port — or as an honest stand-in
|
|
5
|
-
*
|
|
6
|
-
*
|
|
2
|
+
* Full Print's live-surface pre-pass (the `renderAllDiagrams` of live pages):
|
|
3
|
+
* every `<iframe>` inside the captured message is shown as its picture — from
|
|
4
|
+
* the host's frame capture port — or as an honest stand-in; every `<canvas>`
|
|
5
|
+
* (a chart, a document editor's page) as the picture it holds right now; every
|
|
6
|
+
* `[data-matrx-print-picture]` element (a map) as the host's picture of it.
|
|
7
|
+
* Each lasts exactly as long as the capture runs. The originals are hidden,
|
|
8
|
+
* never removed (removing a frame reloads its page), and come back untouched
|
|
9
|
+
* when `restore` runs.
|
|
7
10
|
*/
|
|
11
|
+
/** What prints in a canvas's place when its pixels cannot be read (another origin drew into it). */
|
|
12
|
+
export declare const CANVAS_PRINT_STAND_IN = "Drawing unavailable \u2014 print it from its card.";
|
|
8
13
|
export declare function framesToPictures(root: HTMLElement): Promise<{
|
|
9
14
|
restore: () => void;
|
|
10
15
|
frames: number;
|
|
@@ -1,11 +1,41 @@
|
|
|
1
|
-
import { FRAME_PRINT_STAND_IN, getFramePrintCapture } from "../../host/frame-print.js";
|
|
1
|
+
import { FRAME_PRINT_STAND_IN, getElementPrintCapture, getFramePrintCapture } from "../../host/frame-print.js";
|
|
2
|
+
const CANVAS_PRINT_STAND_IN = "Drawing unavailable \u2014 print it from its card.";
|
|
3
|
+
function standInFor(text, width, height) {
|
|
4
|
+
const stand = document.createElement("div");
|
|
5
|
+
stand.textContent = text;
|
|
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
|
+
return stand;
|
|
8
|
+
}
|
|
9
|
+
async function pictureOf(src, alt, width, height) {
|
|
10
|
+
const img = document.createElement("img");
|
|
11
|
+
img.src = src;
|
|
12
|
+
img.alt = alt;
|
|
13
|
+
img.style.cssText = `display:block;width:${width ? `${width}px` : "100%"};max-width:100%;height:${height ? `${height}px` : "auto"}`;
|
|
14
|
+
await img.decode().catch(() => void 0);
|
|
15
|
+
return img;
|
|
16
|
+
}
|
|
17
|
+
function swap(original, stand) {
|
|
18
|
+
stand.setAttribute("data-matrx-frame-print", "");
|
|
19
|
+
const display = original.style.display;
|
|
20
|
+
original.style.display = "none";
|
|
21
|
+
original.after(stand);
|
|
22
|
+
return () => {
|
|
23
|
+
stand.remove();
|
|
24
|
+
original.style.display = display;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
2
27
|
async function framesToPictures(root) {
|
|
3
|
-
const
|
|
4
|
-
|
|
28
|
+
const marked = [...root.querySelectorAll("[data-matrx-print-picture]")];
|
|
29
|
+
const insideMarked = (node) => marked.some((element) => element !== node && element.contains(node));
|
|
30
|
+
const frames = [...root.querySelectorAll("iframe")].filter((frame) => !insideMarked(frame));
|
|
31
|
+
const canvases = [...root.querySelectorAll("canvas")].filter((canvas) => !insideMarked(canvas));
|
|
32
|
+
const total = frames.length + canvases.length + marked.length;
|
|
33
|
+
if (total === 0) return { restore: () => void 0, frames: 0 };
|
|
5
34
|
const capture = getFramePrintCapture();
|
|
35
|
+
const elementCapture = getElementPrintCapture();
|
|
6
36
|
const undo = [];
|
|
7
|
-
await Promise.all(
|
|
8
|
-
frames.map(async (frame) => {
|
|
37
|
+
await Promise.all([
|
|
38
|
+
...frames.map(async (frame) => {
|
|
9
39
|
let src = null;
|
|
10
40
|
if (capture) {
|
|
11
41
|
try {
|
|
@@ -16,31 +46,39 @@ async function framesToPictures(root) {
|
|
|
16
46
|
}
|
|
17
47
|
const width = frame.clientWidth || frame.offsetWidth;
|
|
18
48
|
const height = frame.clientHeight || frame.offsetHeight;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
49
|
+
const stand = src ? await pictureOf(src, frame.title || "Web page", width, null) : standInFor(FRAME_PRINT_STAND_IN, width, height);
|
|
50
|
+
undo.push(swap(frame, stand));
|
|
51
|
+
}),
|
|
52
|
+
...canvases.map(async (canvas) => {
|
|
53
|
+
const width = canvas.clientWidth || canvas.offsetWidth;
|
|
54
|
+
const height = canvas.clientHeight || canvas.offsetHeight;
|
|
55
|
+
if (!width || !height) return;
|
|
56
|
+
let src = null;
|
|
57
|
+
try {
|
|
58
|
+
src = canvas.toDataURL("image/png");
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error("[print] a drawing could not be read for print", error);
|
|
61
|
+
}
|
|
62
|
+
const stand = src ? await pictureOf(src, canvas.getAttribute("aria-label") || "Drawing", width, height) : standInFor(CANVAS_PRINT_STAND_IN, width, height);
|
|
63
|
+
undo.push(swap(canvas, stand));
|
|
64
|
+
}),
|
|
65
|
+
...marked.map(async (element) => {
|
|
66
|
+
if (!elementCapture) return;
|
|
67
|
+
let src = null;
|
|
68
|
+
try {
|
|
69
|
+
src = await elementCapture(element);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error("[print] a live surface could not be captured for print", error);
|
|
31
72
|
}
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
undo.push(() => {
|
|
37
|
-
stand.remove();
|
|
38
|
-
frame.style.display = display;
|
|
39
|
-
});
|
|
73
|
+
if (!src) return;
|
|
74
|
+
const width = element.clientWidth || element.offsetWidth;
|
|
75
|
+
const height = element.clientHeight || element.offsetHeight;
|
|
76
|
+
undo.push(swap(element, await pictureOf(src, element.getAttribute("aria-label") || "Picture", width, height || null)));
|
|
40
77
|
})
|
|
41
|
-
);
|
|
42
|
-
return { restore: () => undo.forEach((fn) => fn()), frames:
|
|
78
|
+
]);
|
|
79
|
+
return { restore: () => undo.forEach((fn) => fn()), frames: total };
|
|
43
80
|
}
|
|
44
81
|
export {
|
|
82
|
+
CANVAS_PRINT_STAND_IN,
|
|
45
83
|
framesToPictures
|
|
46
84
|
};
|
|
@@ -15,3 +15,13 @@ export declare const FRAME_PRINT_STAND_IN = "Page image unavailable \u2014 print
|
|
|
15
15
|
/** Plugs (or, with null, removes) the host's frame capture engine. */
|
|
16
16
|
export declare function setFramePrintCapture(capture: FramePrintCapture | null): void;
|
|
17
17
|
export declare function getFramePrintCapture(): FramePrintCapture | null;
|
|
18
|
+
/**
|
|
19
|
+
* A picture of one marked element (`data-matrx-print-picture`) — a surface a
|
|
20
|
+
* DOM capture draws wrong or blank (a map whose tiles come from another
|
|
21
|
+
* origin). The host plugs the drawing in; without it the element is captured
|
|
22
|
+
* as it is.
|
|
23
|
+
*/
|
|
24
|
+
export type ElementPrintCapture = (element: HTMLElement) => Promise<string | null>;
|
|
25
|
+
/** Plugs (or, with null, removes) the host's capture for `[data-matrx-print-picture]` elements. */
|
|
26
|
+
export declare function setElementPrintCapture(capture: ElementPrintCapture | null): void;
|
|
27
|
+
export declare function getElementPrintCapture(): ElementPrintCapture | null;
|
package/dist/host/frame-print.js
CHANGED
|
@@ -6,8 +6,17 @@ function setFramePrintCapture(capture) {
|
|
|
6
6
|
function getFramePrintCapture() {
|
|
7
7
|
return globalThis[PORT] ?? null;
|
|
8
8
|
}
|
|
9
|
+
const ELEMENT_PORT = /* @__PURE__ */ Symbol.for("ai-matrx.chat.element-print-capture");
|
|
10
|
+
function setElementPrintCapture(capture) {
|
|
11
|
+
globalThis[ELEMENT_PORT] = capture;
|
|
12
|
+
}
|
|
13
|
+
function getElementPrintCapture() {
|
|
14
|
+
return globalThis[ELEMENT_PORT] ?? null;
|
|
15
|
+
}
|
|
9
16
|
export {
|
|
10
17
|
FRAME_PRINT_STAND_IN,
|
|
18
|
+
getElementPrintCapture,
|
|
11
19
|
getFramePrintCapture,
|
|
20
|
+
setElementPrintCapture,
|
|
12
21
|
setFramePrintCapture
|
|
13
22
|
};
|
package/dist/host/ui-slots.d.ts
CHANGED
|
@@ -2,8 +2,6 @@ import { Component, type ComponentType, type ChangeEvent, type ReactNode } from
|
|
|
2
2
|
import type { EditableContextMenuProps, NonEditableContextMenuProps } from "../context-menu/types.js";
|
|
3
3
|
/** The host context menu's props (its registration is typed against them). */
|
|
4
4
|
export type { EditableContextMenuProps, NonEditableContextMenuProps };
|
|
5
|
-
import type { SkillRow } from "../ui/skills-types.js";
|
|
6
|
-
import type { AgentCatalog } from "@ai-matrx/agents/catalog";
|
|
7
5
|
import type { DecodedDirective } from "@ai-matrx/content-ir";
|
|
8
6
|
import type { AudioSessionControls, AudioSessionSource, PlaybackSessionHandle } from "../ui/audio-session-types.js";
|
|
9
7
|
import type { ItemRowProps } from "../ui/item-types.js";
|
|
@@ -160,8 +158,6 @@ export interface ChatUiSlots {
|
|
|
160
158
|
readProjectScopeOrganizationId: AnyFn;
|
|
161
159
|
summarizeContextCell: AnyFn;
|
|
162
160
|
useEntityTitles: AnyFn;
|
|
163
|
-
/** The skills the host has loaded: `{ status, skills }` (a host with none answers nothing loaded). */
|
|
164
|
-
loadedSkills: AnyFn;
|
|
165
161
|
/** Dev-only render-path tracing for the war-room tile; a host without it traces nothing. */
|
|
166
162
|
traceWarRoomRenderPath: AnyFn;
|
|
167
163
|
isWarRoomThreadAgentSurface: AnyFn;
|
|
@@ -181,7 +177,6 @@ export interface ChatUiSlots {
|
|
|
181
177
|
icon: any;
|
|
182
178
|
[field: string]: any;
|
|
183
179
|
}>;
|
|
184
|
-
useRunControlCounts: AnyFn;
|
|
185
180
|
useAttachResourcePicker: AnyFn;
|
|
186
181
|
usePopoutContainer: AnyFn;
|
|
187
182
|
useUrlSync: AnyFn;
|
|
@@ -236,14 +231,6 @@ export interface ChatUiSlots {
|
|
|
236
231
|
humanLines: AnyFn;
|
|
237
232
|
useCanvasOpenGuard: AnyFn;
|
|
238
233
|
useRegisterChatAttachTarget: AnyFn;
|
|
239
|
-
useSkills: () => {
|
|
240
|
-
skills: SkillRow[];
|
|
241
|
-
grouped: Record<string, SkillRow[]>;
|
|
242
|
-
count: number;
|
|
243
|
-
loading: boolean;
|
|
244
|
-
error: string | null;
|
|
245
|
-
reload: () => Promise<void>;
|
|
246
|
-
};
|
|
247
234
|
useAutoLabel: AnyFn;
|
|
248
235
|
generateLabelFromContent: AnyFn;
|
|
249
236
|
usePickListForSelection: (listId: string | null | undefined, groupName?: string) => {
|
|
@@ -266,8 +253,6 @@ export interface ChatUiSlots {
|
|
|
266
253
|
selectEditorMode: AnyFn;
|
|
267
254
|
receivedFsChange: AnyFn;
|
|
268
255
|
loadCodeEditHistoryThunk: AnyFn;
|
|
269
|
-
applySkillStreamEvent: AnyFn;
|
|
270
|
-
isSkillStreamEvent: AnyFn;
|
|
271
256
|
materializeMessageArtifacts: (args: {
|
|
272
257
|
messageId: string;
|
|
273
258
|
conversationId: string;
|
|
@@ -339,8 +324,6 @@ export interface ChatUiSlots {
|
|
|
339
324
|
ConfigurationTable: AnyComponent;
|
|
340
325
|
ConfigurationTableRow: AnyComponent;
|
|
341
326
|
FieldHelp: AnyComponent;
|
|
342
|
-
useModelFull: AnyFn;
|
|
343
|
-
useModelOptions: AnyFn;
|
|
344
327
|
useOrganizationRequired: AnyFn;
|
|
345
328
|
useAuthGuardedAction: AnyFn;
|
|
346
329
|
readOf: AnyFn;
|
|
@@ -371,8 +354,6 @@ export interface ChatUiSlots {
|
|
|
371
354
|
reason: string;
|
|
372
355
|
cause: "no-selection" | "unreadable";
|
|
373
356
|
}>;
|
|
374
|
-
getAgentCatalog: () => AgentCatalog;
|
|
375
|
-
resolvePreferredChatModel: AnyFn;
|
|
376
357
|
publishedToWebPatch: AnyFn;
|
|
377
358
|
isUuidValue: AnyFn;
|
|
378
359
|
/**
|
|
@@ -403,13 +384,8 @@ export interface ChatUiSlots {
|
|
|
403
384
|
surfaceKey: string;
|
|
404
385
|
tabs?: string[];
|
|
405
386
|
}>;
|
|
406
|
-
AgentSettingsCore: AnyComponent;
|
|
407
|
-
SettingControlInput: AnyComponent;
|
|
408
|
-
InputCapabilitiesEditor: AnyComponent;
|
|
409
387
|
CustomDataBindingSummary: AnyComponent;
|
|
410
388
|
CustomDataBindingPreview: AnyComponent;
|
|
411
|
-
AiModelRef: AnyComponent;
|
|
412
|
-
AiToolRef: AnyComponent;
|
|
413
389
|
TextInputDialog: SlotComponent<TextInputDialogProps>;
|
|
414
390
|
ProInput: SlotComponent<InputSlotProps>;
|
|
415
391
|
MatrxDynamicPanelHost: AnyComponent;
|
|
@@ -517,7 +493,6 @@ export declare const readProjectScopeOrganizationId: AnyFn;
|
|
|
517
493
|
export declare const summarizeContextCell: AnyFn;
|
|
518
494
|
/** A host with no entity directory titles nothing; callers fall back to the raw reference. */
|
|
519
495
|
export declare const useEntityTitles: AnyFn;
|
|
520
|
-
export declare const loadedSkills: AnyFn;
|
|
521
496
|
/** A host with no war-room tile has nothing to trace; the call is a reported no-op. */
|
|
522
497
|
export declare const traceWarRoomRenderPath: AnyFn;
|
|
523
498
|
export declare const isWarRoomThreadAgentSurface: AnyFn;
|
|
@@ -544,7 +519,6 @@ export declare const flattenResourcePickerItems: () => Array<{
|
|
|
544
519
|
icon: any;
|
|
545
520
|
[field: string]: any;
|
|
546
521
|
}>;
|
|
547
|
-
export declare const useRunControlCounts: AnyFn;
|
|
548
522
|
/** Same shape as the host door (`features/connectors/useAttachResourcePicker`): the hook returns the open function. A host with no picker opens nothing. */
|
|
549
523
|
export declare const useAttachResourcePicker: AnyFn;
|
|
550
524
|
/** A host with no popout windows portals into the page body (Radix default). */
|
|
@@ -647,14 +621,6 @@ export declare const loadProjectsWithTasks: AnyFn;
|
|
|
647
621
|
export declare const humanLines: AnyFn;
|
|
648
622
|
export declare const useCanvasOpenGuard: AnyFn;
|
|
649
623
|
export declare const useRegisterChatAttachTarget: AnyFn;
|
|
650
|
-
export declare const useSkills: () => {
|
|
651
|
-
skills: SkillRow[];
|
|
652
|
-
grouped: Record<string, SkillRow[]>;
|
|
653
|
-
count: number;
|
|
654
|
-
loading: boolean;
|
|
655
|
-
error: string | null;
|
|
656
|
-
reload: () => Promise<void>;
|
|
657
|
-
};
|
|
658
624
|
export declare const useAutoLabel: AnyFn;
|
|
659
625
|
export declare const generateLabelFromContent: AnyFn;
|
|
660
626
|
export declare const usePickListForSelection: (listId: string | null | undefined, groupName?: string) => {
|
|
@@ -677,8 +643,6 @@ export declare const selectActiveSandboxProxyUrl: AnyFn;
|
|
|
677
643
|
export declare const selectEditorMode: AnyFn;
|
|
678
644
|
export declare const receivedFsChange: AnyFn;
|
|
679
645
|
export declare const loadCodeEditHistoryThunk: AnyFn;
|
|
680
|
-
export declare const applySkillStreamEvent: AnyFn;
|
|
681
|
-
export declare const isSkillStreamEvent: AnyFn;
|
|
682
646
|
export declare const materializeMessageArtifacts: (args: {
|
|
683
647
|
messageId: string;
|
|
684
648
|
conversationId: string;
|
|
@@ -711,8 +675,6 @@ export declare const selectContentBlocksByScopeRef: AnyFn;
|
|
|
711
675
|
export declare const selectActiveContentBlocks: AnyFn;
|
|
712
676
|
export declare const LibraryPreviewPage: AnyComponent;
|
|
713
677
|
export declare const NoteVersionHistoryPanel: AnyComponent;
|
|
714
|
-
export declare const useModelFull: AnyFn;
|
|
715
|
-
export declare const useModelOptions: AnyFn;
|
|
716
678
|
export declare const useOrganizationRequired: AnyFn;
|
|
717
679
|
export declare const useAuthGuardedAction: AnyFn;
|
|
718
680
|
export declare const readOf: AnyFn;
|
|
@@ -743,8 +705,6 @@ export declare const awaitEffectiveOrganizationId: () => Promise<{
|
|
|
743
705
|
reason: string;
|
|
744
706
|
cause: "no-selection" | "unreadable";
|
|
745
707
|
}>;
|
|
746
|
-
export declare const getAgentCatalog: () => AgentCatalog;
|
|
747
|
-
export declare const resolvePreferredChatModel: AnyFn;
|
|
748
708
|
export declare const publishedToWebPatch: AnyFn;
|
|
749
709
|
export declare const isUuidValue: AnyFn;
|
|
750
710
|
export declare const AgentOptionsMenu: SlotComponent<{
|
|
@@ -770,14 +730,8 @@ export declare const CreatorRunPanel: SlotComponent<{
|
|
|
770
730
|
surfaceKey: string;
|
|
771
731
|
tabs?: string[];
|
|
772
732
|
}>;
|
|
773
|
-
export declare const AgentSettingsCore: AnyComponent;
|
|
774
|
-
/** A bare host gets the package's own per-type setting control (`defaults/setting-control-input`). */
|
|
775
|
-
export declare const SettingControlInput: AnyComponent;
|
|
776
|
-
export declare const InputCapabilitiesEditor: AnyComponent;
|
|
777
733
|
export declare const CustomDataBindingSummary: AnyComponent;
|
|
778
734
|
export declare const CustomDataBindingPreview: AnyComponent;
|
|
779
|
-
export declare const AiModelRef: AnyComponent;
|
|
780
|
-
export declare const AiToolRef: AnyComponent;
|
|
781
735
|
export declare const TextInputDialog: SlotComponent<TextInputDialogProps>;
|
|
782
736
|
export declare const ProInput: SlotComponent<InputSlotProps>;
|
|
783
737
|
export declare const MatrxDynamicPanelHost: AnyComponent;
|