@vivix-labs/studio-chat-mcp 0.1.8 → 0.1.9
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 +15 -15
- package/dist/server.js +37 -6
- package/dist/setup.js +9 -1
- 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.9",
|
|
29433
29433
|
type: "module",
|
|
29434
29434
|
engines: {
|
|
29435
29435
|
node: ">=22.12.0"
|
|
@@ -37978,16 +37978,18 @@ function chatTargets(catalog, source, context) {
|
|
|
37978
37978
|
)
|
|
37979
37979
|
];
|
|
37980
37980
|
}
|
|
37981
|
-
function readChatBundle(host, scope, target2,
|
|
37981
|
+
function readChatBundle(host, scope, target2, expected) {
|
|
37982
37982
|
return host.withOperations(
|
|
37983
37983
|
scope,
|
|
37984
37984
|
() => [target2],
|
|
37985
37985
|
async (runtime) => {
|
|
37986
37986
|
const source = sourceOperation(runtime, target2);
|
|
37987
|
+
if ("component" in expected && source.chat.component !== expected.component)
|
|
37988
|
+
throw new Error("A compatible Studio card renderer is unavailable.");
|
|
37987
37989
|
const bundle = await runtime.component(target2, source.chat.component);
|
|
37988
|
-
if (bundle.sha256 !==
|
|
37990
|
+
if ("sha256" in expected && bundle.sha256 !== expected.sha256)
|
|
37989
37991
|
throw new Error("The original Studio card script is unavailable.");
|
|
37990
|
-
return bundle
|
|
37992
|
+
return bundle;
|
|
37991
37993
|
}
|
|
37992
37994
|
);
|
|
37993
37995
|
}
|
|
@@ -38698,8 +38700,37 @@ function createChatServer(options2) {
|
|
|
38698
38700
|
const scope = scopeSchema.parse({ kind: part("kind"), id: part("scopeId") });
|
|
38699
38701
|
const source = target.parse({ instanceId: part("instance"), operationId: part("operation") });
|
|
38700
38702
|
const digest = external_exports.string().regex(/^[a-f0-9]{64}$/).parse(variables.digest);
|
|
38701
|
-
const
|
|
38702
|
-
return {
|
|
38703
|
+
const bundle = await readChatBundle(host, scope, source, { sha256: digest });
|
|
38704
|
+
return {
|
|
38705
|
+
contents: [{ uri: uri.href, mimeType: "text/javascript", text: bundle.javascript }]
|
|
38706
|
+
};
|
|
38707
|
+
}
|
|
38708
|
+
);
|
|
38709
|
+
server.registerResource(
|
|
38710
|
+
"Compatible Studio card renderer",
|
|
38711
|
+
new ResourceTemplate(
|
|
38712
|
+
"studio://chat-bundles/{kind}/{scopeId}/{instance}/{operation}/components/{component}",
|
|
38713
|
+
{ list: void 0 }
|
|
38714
|
+
),
|
|
38715
|
+
{ mimeType: "text/javascript" },
|
|
38716
|
+
async (uri, variables) => {
|
|
38717
|
+
const part = (key) => decodeURIComponent(external_exports.string().parse(variables[key]));
|
|
38718
|
+
const scope = scopeSchema.parse({ kind: part("kind"), id: part("scopeId") });
|
|
38719
|
+
const source = target.parse({ instanceId: part("instance"), operationId: part("operation") });
|
|
38720
|
+
const component = identifier.regex(/^[a-zA-Z0-9._/-]+@[1-9]\d*$/).parse(part("component"));
|
|
38721
|
+
const bundle = await readChatBundle(host, scope, source, { component });
|
|
38722
|
+
return {
|
|
38723
|
+
contents: [
|
|
38724
|
+
{
|
|
38725
|
+
uri: uri.href,
|
|
38726
|
+
mimeType: "text/javascript",
|
|
38727
|
+
text: bundle.javascript,
|
|
38728
|
+
_meta: {
|
|
38729
|
+
"studio/component": { id: component, format: bundle.format, sha256: bundle.sha256 }
|
|
38730
|
+
}
|
|
38731
|
+
}
|
|
38732
|
+
]
|
|
38733
|
+
};
|
|
38703
38734
|
}
|
|
38704
38735
|
);
|
|
38705
38736
|
const metadata = {
|
package/dist/setup.js
CHANGED
|
@@ -815,6 +815,14 @@ async function enable(id, scope, options = [], additions) {
|
|
|
815
815
|
const current = before.find((item) => item.id === id);
|
|
816
816
|
if (current && current.package !== name) throw Error("Another plugin owns the instance " + id);
|
|
817
817
|
const config = { ...current?.config || {} };
|
|
818
|
+
if (id === "chat-components" && !config.libraryInstance) {
|
|
819
|
+
const libraries = cliCall("plugin", "list", ...user).instances.filter(
|
|
820
|
+
(item) => item.package === "@vivix-labs/material-library" && item.state === "ready" && item.config.role === "service"
|
|
821
|
+
);
|
|
822
|
+
if (libraries.length !== 1)
|
|
823
|
+
throw Error("Configure one ready user material library before enabling chat file uploads.");
|
|
824
|
+
config.libraryInstance = scope === user ? libraries[0].id : `user:${libraries[0].id}`;
|
|
825
|
+
}
|
|
818
826
|
if (additions) {
|
|
819
827
|
config.targets = { ...config.targets };
|
|
820
828
|
for (const [key, target] of Object.entries(additions)) {
|
|
@@ -829,7 +837,7 @@ async function enable(id, scope, options = [], additions) {
|
|
|
829
837
|
}
|
|
830
838
|
if (current?.state === "ready" && current.version === version && JSON.stringify(config) === JSON.stringify(current.config))
|
|
831
839
|
return;
|
|
832
|
-
if (additions) {
|
|
840
|
+
if (additions || id === "chat-components") {
|
|
833
841
|
const file = join(scratch, "component-config.json");
|
|
834
842
|
await writeFile(file, JSON.stringify(config), { mode: 384 });
|
|
835
843
|
options = [...options, "--config", file];
|