@vivix-labs/studio-chat-mcp 0.1.21 → 0.1.22
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 +1 -1
- package/dist/chat-ui/index.html +1 -1
- package/dist/server.js +67 -12
- package/dist/shared.d.ts +14 -2
- package/docs/mcp-instructions.md +24 -18
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -29429,7 +29429,7 @@ data:
|
|
|
29429
29429
|
// package.json
|
|
29430
29430
|
var package_default = {
|
|
29431
29431
|
name: "@vivix-labs/studio-chat-mcp",
|
|
29432
|
-
version: "0.1.
|
|
29432
|
+
version: "0.1.22",
|
|
29433
29433
|
type: "module",
|
|
29434
29434
|
vivixStudio: {
|
|
29435
29435
|
mcpRegistration: "cli-v1"
|
|
@@ -38783,7 +38783,12 @@ var historicalChatResourceUris = [
|
|
|
38783
38783
|
"ui://studio/chat/v12.html"
|
|
38784
38784
|
];
|
|
38785
38785
|
var chatMimeType = "text/html;profile=mcp-app";
|
|
38786
|
-
var defaultResourceDomains = [
|
|
38786
|
+
var defaultResourceDomains = [
|
|
38787
|
+
"https://v.vivix.ai",
|
|
38788
|
+
"https://static.vivi-x.ai",
|
|
38789
|
+
"https://storage.googleapis.com",
|
|
38790
|
+
"https://media.framz.pro"
|
|
38791
|
+
];
|
|
38787
38792
|
var identifier = external_exports.string().min(1).max(512);
|
|
38788
38793
|
var target = external_exports.object({ instanceId: identifier, operationId: identifier }).strict();
|
|
38789
38794
|
var common = {
|
|
@@ -38828,6 +38833,19 @@ var cardTelemetryInput = external_exports.discriminatedUnion("event", [
|
|
|
38828
38833
|
status: external_exports.enum(["ok", "error"]),
|
|
38829
38834
|
durationMs: external_exports.number().int().nonnegative().optional(),
|
|
38830
38835
|
errorMessage: external_exports.string().max(1e3).optional()
|
|
38836
|
+
}).strict(),
|
|
38837
|
+
external_exports.object({
|
|
38838
|
+
event: external_exports.literal("prompt_clicked"),
|
|
38839
|
+
cardInteractionId: external_exports.string().min(1).max(200).optional(),
|
|
38840
|
+
cardInstanceId: external_exports.string().min(1).max(200),
|
|
38841
|
+
componentId: external_exports.string().min(1).max(200),
|
|
38842
|
+
projectId: external_exports.string().min(1).max(512).nullable().optional(),
|
|
38843
|
+
actionId: external_exports.string().min(1).max(200).optional(),
|
|
38844
|
+
placement: external_exports.string().min(1).max(64).optional(),
|
|
38845
|
+
emphasis: external_exports.string().min(1).max(64).optional(),
|
|
38846
|
+
status: external_exports.enum(["ok", "error"]),
|
|
38847
|
+
durationMs: external_exports.number().int().nonnegative().optional(),
|
|
38848
|
+
errorMessage: external_exports.string().max(1e3).optional()
|
|
38831
38849
|
}).strict()
|
|
38832
38850
|
]);
|
|
38833
38851
|
function mapChatResult(result) {
|
|
@@ -38848,9 +38866,26 @@ function mapChatResult(result) {
|
|
|
38848
38866
|
}
|
|
38849
38867
|
};
|
|
38850
38868
|
}
|
|
38869
|
+
function normalizeResourceOrigin(entry) {
|
|
38870
|
+
try {
|
|
38871
|
+
const parsed = new URL(entry);
|
|
38872
|
+
if (parsed.protocol !== "https:" || parsed.username || parsed.password || parsed.pathname !== "/" || parsed.search || parsed.hash || parsed.hostname.includes("*"))
|
|
38873
|
+
return null;
|
|
38874
|
+
return parsed.origin;
|
|
38875
|
+
} catch {
|
|
38876
|
+
return null;
|
|
38877
|
+
}
|
|
38878
|
+
}
|
|
38851
38879
|
function createChatServer(options2) {
|
|
38852
38880
|
const host = options2.host;
|
|
38853
38881
|
const mountedInstances = options2.mountedInstances ?? /* @__PURE__ */ new Set();
|
|
38882
|
+
const resourceDomains = options2.resourceDomains ?? defaultResourceDomains;
|
|
38883
|
+
const allowedResourceDomains = new Set(
|
|
38884
|
+
resourceDomains.flatMap((entry) => {
|
|
38885
|
+
const origin = normalizeResourceOrigin(entry);
|
|
38886
|
+
return origin ? [origin] : [];
|
|
38887
|
+
})
|
|
38888
|
+
);
|
|
38854
38889
|
const server = new McpServer(
|
|
38855
38890
|
{ name: "vivix-studio-chat", version: package_default.version },
|
|
38856
38891
|
{
|
|
@@ -38861,7 +38896,7 @@ function createChatServer(options2) {
|
|
|
38861
38896
|
"report_card_telemetry",
|
|
38862
38897
|
{
|
|
38863
38898
|
title: "Report card telemetry",
|
|
38864
|
-
description: "Record MCP App card mount exposure and built-in media download interactions. App-only telemetry callback; does not mutate business state.",
|
|
38899
|
+
description: "Record MCP App card mount exposure, prompt submissions, and built-in media download interactions. App-only telemetry callback; does not mutate business state.",
|
|
38865
38900
|
inputSchema: cardTelemetryInput,
|
|
38866
38901
|
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
38867
38902
|
_meta: { ui: { visibility: ["app"] } }
|
|
@@ -38883,21 +38918,29 @@ function createChatServer(options2) {
|
|
|
38883
38918
|
}
|
|
38884
38919
|
return { content: [{ type: "text", text: "Card mount recorded." }] };
|
|
38885
38920
|
}
|
|
38921
|
+
const isPrompt = input2.event === "prompt_clicked";
|
|
38886
38922
|
safeRecordChatTelemetry(host, {
|
|
38887
38923
|
event_name: "chat.card.action_clicked",
|
|
38888
38924
|
project_id: input2.projectId ?? null,
|
|
38889
38925
|
card_interaction_id: input2.cardInteractionId ?? uuidv72(),
|
|
38890
38926
|
card_instance_id: input2.cardInstanceId,
|
|
38891
38927
|
component_id: input2.componentId,
|
|
38892
|
-
action_id: input2.actionId ?? "download",
|
|
38893
|
-
placement: input2.placement ?? "inline",
|
|
38894
|
-
emphasis: input2.emphasis ?? "secondary",
|
|
38895
|
-
dispatch_mode: "download",
|
|
38928
|
+
action_id: input2.actionId ?? (isPrompt ? "prompt" : "download"),
|
|
38929
|
+
placement: input2.placement ?? (isPrompt ? "footer" : "inline"),
|
|
38930
|
+
emphasis: input2.emphasis ?? (isPrompt ? "primary" : "secondary"),
|
|
38931
|
+
dispatch_mode: isPrompt ? "prompt" : "download",
|
|
38896
38932
|
status: input2.status,
|
|
38897
38933
|
duration_ms: input2.durationMs,
|
|
38898
38934
|
...input2.errorMessage ? { error: new Error(input2.errorMessage) } : {}
|
|
38899
38935
|
});
|
|
38900
|
-
return {
|
|
38936
|
+
return {
|
|
38937
|
+
content: [
|
|
38938
|
+
{
|
|
38939
|
+
type: "text",
|
|
38940
|
+
text: isPrompt ? "Card prompt telemetry recorded." : "Card download telemetry recorded."
|
|
38941
|
+
}
|
|
38942
|
+
]
|
|
38943
|
+
};
|
|
38901
38944
|
}
|
|
38902
38945
|
);
|
|
38903
38946
|
server.registerTool(
|
|
@@ -39019,6 +39062,7 @@ function createChatServer(options2) {
|
|
|
39019
39062
|
if (cards.length)
|
|
39020
39063
|
return {
|
|
39021
39064
|
...discovered,
|
|
39065
|
+
resourceDomains: [...resourceDomains],
|
|
39022
39066
|
items: [...discovered.items, ...cards],
|
|
39023
39067
|
fallback: { scope: user.scope, itemCount: cards.length },
|
|
39024
39068
|
note: "Reusable cards were found in user scope. Use each card item's returned scope and target."
|
|
@@ -39026,7 +39070,7 @@ function createChatServer(options2) {
|
|
|
39026
39070
|
} catch {
|
|
39027
39071
|
}
|
|
39028
39072
|
}
|
|
39029
|
-
return discovered;
|
|
39073
|
+
return { ...discovered, resourceDomains: [...resourceDomains] };
|
|
39030
39074
|
}
|
|
39031
39075
|
)
|
|
39032
39076
|
);
|
|
@@ -39070,7 +39114,19 @@ function createChatServer(options2) {
|
|
|
39070
39114
|
fileId: external_exports.uuid().optional()
|
|
39071
39115
|
}).strict()
|
|
39072
39116
|
},
|
|
39073
|
-
({ scope, ref, fileId }) => readResult("Media read address ready.", () =>
|
|
39117
|
+
({ scope, ref, fileId }) => readResult("Media read address ready.", async () => {
|
|
39118
|
+
const resolved = await resolveChatMedia(host, scope, ref, fileId);
|
|
39119
|
+
const origin = new URL(resolved.url).origin;
|
|
39120
|
+
const embeddableInCard = allowedResourceDomains.has(origin);
|
|
39121
|
+
return {
|
|
39122
|
+
...resolved,
|
|
39123
|
+
origin,
|
|
39124
|
+
embeddableInCard,
|
|
39125
|
+
...!embeddableInCard && {
|
|
39126
|
+
note: `Origin ${origin} is outside the adapter resourceDomains (${resourceDomains.join(", ")}). Native cards will block this URL; fall back to a local path when supported or add the origin to resourceDomains.`
|
|
39127
|
+
}
|
|
39128
|
+
};
|
|
39129
|
+
})
|
|
39074
39130
|
);
|
|
39075
39131
|
server.registerTool(
|
|
39076
39132
|
"run_studio_action",
|
|
@@ -39092,7 +39148,7 @@ function createChatServer(options2) {
|
|
|
39092
39148
|
},
|
|
39093
39149
|
(args, extra) => invoke("studio_card_action", args, extra.signal)
|
|
39094
39150
|
);
|
|
39095
|
-
for (const scheme of ["
|
|
39151
|
+
for (const scheme of ["ui", "studio"]) {
|
|
39096
39152
|
server.registerResource(
|
|
39097
39153
|
"Registered Studio card script (" + scheme + ")",
|
|
39098
39154
|
new ResourceTemplate(
|
|
@@ -39182,7 +39238,6 @@ function createChatServer(options2) {
|
|
|
39182
39238
|
};
|
|
39183
39239
|
}
|
|
39184
39240
|
);
|
|
39185
|
-
const resourceDomains = options2.resourceDomains ?? defaultResourceDomains;
|
|
39186
39241
|
const replayMediaOrigins = encodeURIComponent(JSON.stringify(resourceDomains));
|
|
39187
39242
|
const metadata = {
|
|
39188
39243
|
// The component's CSP restricts HTTPS media to its declared media origins.
|
package/dist/shared.d.ts
CHANGED
|
@@ -97,14 +97,26 @@ export interface ChatCardProps {
|
|
|
97
97
|
data: Record<string, unknown>;
|
|
98
98
|
projectId: string;
|
|
99
99
|
target: OperationTarget;
|
|
100
|
-
/** Absent on older adapters, which support server tools. */
|
|
101
|
-
hostCapabilities?: { serverTools: boolean };
|
|
100
|
+
/** Absent on older adapters, which support server tools and follow-up messages. */
|
|
101
|
+
hostCapabilities?: { serverTools: boolean; message?: boolean };
|
|
102
102
|
/** Theme the host currently displays. Absent when the host declares none; it may change while mounted. */
|
|
103
103
|
theme?: 'light' | 'dark';
|
|
104
104
|
/** Download an original card media URL through the MCP Apps host, when supported. */
|
|
105
105
|
download?(media: { uri: string; name: string }): Promise<void>;
|
|
106
106
|
/** Read bytes of a local media path declared by this card, without a public URL. */
|
|
107
107
|
readMedia?(input: LocalMediaRead): Promise<LocalMediaChunk>;
|
|
108
|
+
/** Send a follow-up prompt message directly through the MCP Apps host (`ui/message`). */
|
|
109
|
+
sendMessage?(
|
|
110
|
+
message: ChatMessage,
|
|
111
|
+
options?: {
|
|
112
|
+
requestKey?: string;
|
|
113
|
+
telemetry?: {
|
|
114
|
+
actionId?: string;
|
|
115
|
+
placement?: string;
|
|
116
|
+
emphasis?: string;
|
|
117
|
+
};
|
|
118
|
+
},
|
|
119
|
+
): Promise<ChatCardResult>;
|
|
108
120
|
action(
|
|
109
121
|
name: string,
|
|
110
122
|
input?: Record<string, unknown>,
|
package/docs/mcp-instructions.md
CHANGED
|
@@ -16,30 +16,36 @@ This document only records the transport details owned by the MCP adapter.
|
|
|
16
16
|
`inputBindings`. They do not require a receiver card or a second business API.
|
|
17
17
|
|
|
18
18
|
The adapter projects the installed component through
|
|
19
|
-
`ui://studio/chat/
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
`ui://studio/chat/v13.html` (and historical `v1`–`v12` aliases). Prompt actions
|
|
20
|
+
send their structured follow-up directly through `ui/message` across all hosts
|
|
21
|
+
that advertise `message` support, while backend target actions return through
|
|
22
|
+
the app-only `studio_card_action` route when `serverTools` is available.
|
|
22
23
|
|
|
23
24
|
When a prompt button prepares a `chat-component-action` follow-up, the adapter
|
|
24
|
-
attaches
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
attaches an `interactionId` to the returned `data` object. On the immediate
|
|
26
|
+
continuation turn triggered by that callback, pass `data.interactionId` verbatim
|
|
27
|
+
via optional `fromInteractionId` on `run_studio_action` (or `--from-interaction`
|
|
28
|
+
/ `VIVIX_INTERACTION_ID` on Studio CLI invocations) so downstream operations
|
|
29
|
+
retain concurrent-safe attribution. Never fabricate an `interactionId` or carry
|
|
30
|
+
it across later turns.
|
|
30
31
|
|
|
31
32
|
## Media transport
|
|
32
33
|
|
|
33
34
|
Query saved media through the discovered `query_studio_media` route and resolve
|
|
34
|
-
the exact returned
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
the exact returned `VersionRef` with `resolve_chat_media` (in parallel when
|
|
36
|
+
resolving multiple shots or candidates). The file service owns origin lookup and
|
|
37
|
+
ticket refresh. Prefer the returned HTTPS `url` as `src` across all hosts
|
|
38
|
+
whenever `embeddableInCard` is `true` (its origin is within the active
|
|
39
|
+
`resourceDomains` returned by `list_chat_capabilities`).
|
|
40
|
+
|
|
41
|
+
Only fall back to an absolute local Host `path` for PNG, JPEG, WebP, audio or
|
|
42
|
+
video when no remote HTTPS preview exists (`MEDIA_ORIGIN_UNAVAILABLE` or
|
|
43
|
+
`MEDIA_READER_UNAVAILABLE`, such as bundled samples, user-imported local files,
|
|
44
|
+
user-scope library assets, or unsaved local files) or when `embeddableInCard` is
|
|
45
|
+
`false`. Supply exactly one of `src` or `path`; video `poster` values still
|
|
46
|
+
require HTTPS. Local reads require host `serverTools` (`read_local_media`) and
|
|
47
|
+
load the complete file before display. They do not upload, import or generate
|
|
48
|
+
content.
|
|
43
49
|
|
|
44
50
|
## Request recovery
|
|
45
51
|
|