@vivix-labs/studio-chat-mcp 0.1.9 → 0.1.11

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/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.9",
29432
+ version: "0.1.11",
29433
29433
  type: "module",
29434
29434
  engines: {
29435
29435
  node: ">=22.12.0"
@@ -38464,7 +38464,7 @@ async function resolveChatMedia(host, scope, ref, fileId) {
38464
38464
  }
38465
38465
 
38466
38466
  // src/chat-server.ts
38467
- var chatResourceUri = "ui://studio/chat/v8.html";
38467
+ var chatResourceUri = "ui://studio/chat/v12.html";
38468
38468
  var historicalChatResourceUris = [
38469
38469
  "ui://studio/chat/v1.html",
38470
38470
  "ui://studio/chat/v2.html",
@@ -38472,7 +38472,11 @@ var historicalChatResourceUris = [
38472
38472
  "ui://studio/chat/v4.html",
38473
38473
  "ui://studio/chat/v5.html",
38474
38474
  "ui://studio/chat/v6.html",
38475
- "ui://studio/chat/v7.html"
38475
+ "ui://studio/chat/v7.html",
38476
+ "ui://studio/chat/v8.html",
38477
+ "ui://studio/chat/v9.html",
38478
+ "ui://studio/chat/v10.html",
38479
+ "ui://studio/chat/v11.html"
38476
38480
  ];
38477
38481
  var chatMimeType = "text/html;profile=mcp-app";
38478
38482
  var defaultResourceDomains = ["https://static.vivi-x.ai"];
package/dist/setup.js CHANGED
@@ -1,8 +1,8 @@
1
1
  // scripts/setup.mjs
2
2
  import { execFileSync } from "node:child_process";
3
- import { createHash, randomUUID } from "node:crypto";
3
+ import { randomUUID } from "node:crypto";
4
4
  import { homedir } from "node:os";
5
- import { join, resolve } from "node:path";
5
+ import { join, resolve as resolve2 } from "node:path";
6
6
  import {
7
7
  lstat,
8
8
  mkdir,
@@ -16,6 +16,9 @@ import {
16
16
  } from "node:fs/promises";
17
17
  import { setTimeout as delay } from "node:timers/promises";
18
18
 
19
+ // scripts/codex-config.mjs
20
+ import { resolve } from "node:path";
21
+
19
22
  // ../../node_modules/.pnpm/smol-toml@1.9.1/node_modules/smol-toml/dist/error.js
20
23
  function getLineColFromPtr(string, ptr) {
21
24
  let lines = string.slice(0, ptr).split(/\r?\n/);
@@ -774,6 +777,102 @@ function parse(toml, options = {}) {
774
777
  // ../../node_modules/.pnpm/smol-toml@1.9.1/node_modules/smol-toml/dist/stringify.js
775
778
  var HAS_WELLFORMED = !!"".isWellFormed;
776
779
 
780
+ // scripts/codex-config.mjs
781
+ var LEGACY_KEY_PATTERN = /^vivix-studio-chat-[0-9a-f]{10}$/;
782
+ var TABLE_HEADER_PATTERN = /^\s*(\[\[?)\s*([^\[\]]+?)\s*\]\]?\s*(?:#.*)?$/;
783
+ function resolveBridgeLaunch(cli2) {
784
+ if (/\.[cm]?js$/i.test(cli2)) {
785
+ return { command: process.execPath, args: [resolve(cli2), "agent", "mcp"] };
786
+ }
787
+ const command = cli2.includes("/") || cli2.includes("\\") ? resolve(cli2) : cli2;
788
+ return { command, args: ["agent", "mcp"] };
789
+ }
790
+ function parseTableSegments(header) {
791
+ const segments = [];
792
+ let index = 0;
793
+ while (index < header.length) {
794
+ while (index < header.length && /[\s.]/.test(header[index])) index++;
795
+ if (index >= header.length) break;
796
+ const quote = header[index];
797
+ if (quote === '"' || quote === "'") {
798
+ let value = "";
799
+ index++;
800
+ while (index < header.length && header[index] !== quote) {
801
+ if (quote === '"' && header[index] === "\\" && index + 1 < header.length) {
802
+ index++;
803
+ }
804
+ value += header[index++];
805
+ }
806
+ index++;
807
+ segments.push(value);
808
+ } else {
809
+ let value = "";
810
+ while (index < header.length && header[index] !== ".") {
811
+ value += header[index++];
812
+ }
813
+ segments.push(value.trim());
814
+ }
815
+ }
816
+ return segments;
817
+ }
818
+ function isManagedServerEntry(key, value) {
819
+ if (key === "vivix-studio-chat") return true;
820
+ return LEGACY_KEY_PATTERN.test(key) && typeof value?.url === "string" && value.url.endsWith("/v1/user/http/studio-chat/mcp");
821
+ }
822
+ function matchesStdioEntry(entry, launch2, xdgConfigHome) {
823
+ if (!entry || entry.enabled === false) return false;
824
+ if (entry.url !== void 0 || entry.http_headers !== void 0) return false;
825
+ if (entry.command !== launch2.command) return false;
826
+ if (JSON.stringify(entry.args ?? []) !== JSON.stringify(launch2.args)) return false;
827
+ const expectedEnv = xdgConfigHome ? { XDG_CONFIG_HOME: xdgConfigHome } : void 0;
828
+ return JSON.stringify(entry.env ?? void 0) === JSON.stringify(expectedEnv);
829
+ }
830
+ function stripManagedTables(existingToml, managedKeys) {
831
+ if (!existingToml) return "";
832
+ const kept = [];
833
+ let skipping = false;
834
+ for (const line of existingToml.split(/\r?\n/)) {
835
+ const match = TABLE_HEADER_PATTERN.exec(line);
836
+ if (match) {
837
+ const isArrayTable = match[1] === "[[";
838
+ const segments = parseTableSegments(match[2]);
839
+ skipping = !isArrayTable && segments[0] === "mcp_servers" && managedKeys.has(segments[1]);
840
+ }
841
+ if (!skipping) kept.push(line);
842
+ }
843
+ while (kept.length && kept[kept.length - 1].trim() === "") kept.pop();
844
+ return kept.join("\n");
845
+ }
846
+ function upsertCodexStdioConfig(existingToml, launch2, xdgConfigHome) {
847
+ const parsed = parse(existingToml || "");
848
+ const servers = parsed.mcp_servers || {};
849
+ const managedKeys = new Set(
850
+ Object.entries(servers).filter(([key, value]) => isManagedServerEntry(key, value)).map(([key]) => key)
851
+ );
852
+ const legacyExtras = [...managedKeys].some((key) => key !== "vivix-studio-chat");
853
+ if (!legacyExtras && matchesStdioEntry(servers["vivix-studio-chat"], launch2, xdgConfigHome)) {
854
+ return { changed: false, content: existingToml };
855
+ }
856
+ const base = stripManagedTables(existingToml, managedKeys);
857
+ const lines = [
858
+ "[mcp_servers.vivix-studio-chat]",
859
+ `command = ${JSON.stringify(launch2.command)}`,
860
+ `args = ${JSON.stringify(launch2.args)}`
861
+ ];
862
+ if (xdgConfigHome) {
863
+ lines.push(
864
+ "[mcp_servers.vivix-studio-chat.env]",
865
+ `XDG_CONFIG_HOME = ${JSON.stringify(xdgConfigHome)}`
866
+ );
867
+ }
868
+ const section = lines.join("\n") + "\n";
869
+ const next2 = base ? `${base}
870
+
871
+ ${section}` : section;
872
+ parse(next2);
873
+ return { changed: true, content: next2 };
874
+ }
875
+
777
876
  // scripts/setup.mjs
778
877
  var [cli, scratch] = process.argv.slice(2);
779
878
  var profile = process.env.XDG_CONFIG_HOME ? join(process.env.XDG_CONFIG_HOME, "vivix-studio") : join(homedir(), ".vivix-studio");
@@ -900,7 +999,7 @@ for (const [id, skill] of [
900
999
  await mkdir(parent, { recursive: true });
901
1000
  const link = await present(dest);
902
1001
  if (link) {
903
- const old2 = link.isSymbolicLink() && resolve(parent, await readlink(dest));
1002
+ const old2 = link.isSymbolicLink() && resolve2(parent, await readlink(dest));
904
1003
  if (old2 === source) continue;
905
1004
  if (!old2 || !old2.startsWith(packageStore + "/") || !old2.endsWith("/skills/" + skill)) {
906
1005
  console.log("Retained personal Skill: " + dest);
@@ -930,21 +1029,9 @@ var old = await readFile(path, "utf8").catch((e) => {
930
1029
  if (e.code !== "ENOENT") throw e;
931
1030
  return "";
932
1031
  });
933
- var servers = parse(old).mcp_servers || {};
934
- var expected = Object.entries(servers).find(
935
- ([, value]) => value.enabled !== false && value.url === conn.url && value.http_headers?.Authorization === conn.headers.Authorization
936
- );
937
- if (!expected) {
938
- let key = "vivix-studio-chat";
939
- if (Object.hasOwn(servers, key)) {
940
- const suffix = createHash("sha256").update(conn.url).digest("hex").slice(0, 10);
941
- key += "-" + suffix;
942
- if (Object.hasOwn(servers, key))
943
- throw Error("Existing Codex MCP configuration conflicts with this connection.");
944
- }
945
- const section = "\n[mcp_servers." + key + "]\nurl = " + JSON.stringify(conn.url) + "\n[mcp_servers." + key + ".http_headers]\nAuthorization = " + JSON.stringify(conn.headers.Authorization) + "\n";
946
- const next = old + section;
947
- parse(next);
1032
+ var launch = resolveBridgeLaunch(cli);
1033
+ var { changed, content: next } = upsertCodexStdioConfig(old, launch, process.env.XDG_CONFIG_HOME);
1034
+ if (changed) {
948
1035
  const tmp = path + "." + randomUUID() + ".tmp";
949
1036
  try {
950
1037
  await writeFile(tmp, next, { mode: 384, flag: "wx" });
@@ -952,13 +1039,15 @@ if (!expected) {
952
1039
  if (e.code !== "ENOENT") throw e;
953
1040
  return "";
954
1041
  }) !== old)
955
- throw Error("Codex configuration changed during setup. Rerun the installer.");
1042
+ throw Error("Agent configuration changed during setup. Rerun the installer.");
956
1043
  await rename(tmp, path);
957
1044
  } finally {
958
1045
  await rm(tmp, { force: true });
959
1046
  }
960
1047
  }
961
- console.log("Studio Chat is connected to the local Host. Open a new Codex chat to load its cards.");
1048
+ console.log(
1049
+ "Studio Chat is configured for new conversations (CLI and Workbench are ready immediately)."
1050
+ );
962
1051
  /*! Bundled license information:
963
1052
 
964
1053
  smol-toml/dist/error.js:
package/package.json CHANGED
@@ -1,10 +1,16 @@
1
1
  {
2
2
  "name": "@vivix-labs/studio-chat-mcp",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=22.12.0"
7
7
  },
8
+ "scripts": {
9
+ "build": "tsx scripts/build-chat-mcp.ts build",
10
+ "package": "tsx scripts/build-chat-mcp.ts package",
11
+ "check": "tsc --noEmit",
12
+ "test": "tsx --test tests/*.test.ts chat-ui/*.test.ts"
13
+ },
8
14
  "devDependencies": {
9
15
  "@modelcontextprotocol/client": "2.4.0",
10
16
  "@modelcontextprotocol/core": "2.4.0",
@@ -40,11 +46,5 @@
40
46
  "access": "public",
41
47
  "registry": "https://registry.npmjs.org/",
42
48
  "tag": "beta"
43
- },
44
- "scripts": {
45
- "build": "tsx scripts/build-chat-mcp.ts build",
46
- "package": "tsx scripts/build-chat-mcp.ts package",
47
- "check": "tsc --noEmit",
48
- "test": "tsx --test tests/*.test.ts chat-ui/*.test.ts"
49
49
  }
50
- }
50
+ }
@@ -56,6 +56,13 @@ before display or playback. It needs no preview ID,
56
56
  import or public URL. A remote MCP Host cannot read a path on the user's computer.
57
57
  This whole-file preview does not provide progressive long-video playback.
58
58
 
59
+ If the interactive card tools are not active in the current conversation,
60
+ proactively tell the user in natural language (without mentioning internal
61
+ protocol/server names or hardcoding a client name) that interactive cards are
62
+ not active in this session yet and suggest starting a new conversation to
63
+ experience the full interactive features, while continuing via the CLI and
64
+ Studio Workbench.
65
+
59
66
  If discovery returns no ready matching capability, report that status and retain
60
67
  the draft. For an unmet general presentation need, follow the installed
61
68
  `chat-components` custom-visualization route and `vivix-studio-ui` guidance when
package/README.md DELETED
@@ -1,121 +0,0 @@
1
- # Studio Chat MCP adapter
2
-
3
- Studio loads this user-scoped server plugin into its Host process. The plugin owns MCP tools, chat declarations, card action routing, projection and the bundled MCP Apps page. Codex connects to the plugin's authenticated Streamable HTTP route.
4
-
5
- ## Install and enable
6
-
7
- The public Studio suite installer installs this Host plugin and its card provider, enables them in user scope, and adds their authenticated HTTP connection to the private Codex configuration. Restart the Codex chat to discover the new connection. Existing MCP entries and personal Skills are preserved.
8
-
9
- Use the paired Studio CLI with SDK API 0.2.6, Node.js 22.12+ and pnpm 10.33.0. Build a standard Studio plugin directory from this repository.
10
-
11
- ```sh
12
- pnpm --filter @vivix-labs/studio-chat-mcp package "$PWD/artifacts/studio-chat-host"
13
- vivix-studio plugin install "$PWD/artifacts/studio-chat-host/studio-chat-mcp"
14
- vivix-studio plugin enable @vivix-labs/studio-chat-mcp --scope user --instance studio-chat --trust --allow-access host.operations
15
- ```
16
-
17
- Open a project and enable its business plugins normally. Discover their ready operations with `vivix-studio plugin describe`. Use ordinary `plugin call <adapter-instance> run --scope user --input <file> --json` or the MCP tools to open a card. The adapter also registers an `action` operation for subsequent clicks.
18
-
19
- The package exports its chat protocol types from `@vivix-labs/studio-chat-mcp/shared`. Chat components import these types from the adapter package. The CLI SDK does not export chat types.
20
-
21
- ## Connect an MCP client
22
-
23
- Read the installed adapter's connection with an empty input JSON file.
24
-
25
- ```sh
26
- printf '{}\n' > connection-input.json
27
- vivix-studio plugin call studio-chat connection --scope user --input connection-input.json --json
28
- ```
29
-
30
- The private result contains `url`, `headers.Authorization` and the adapter's `pid`. Configure the MCP client with that URL and header. For Codex, the corresponding configuration has this shape.
31
-
32
- ```toml
33
- [mcp_servers.vivix-studio-chat]
34
- url = "http://127.0.0.1:<host-port>/v1/user/http/studio-chat/mcp"
35
-
36
- [mcp_servers.vivix-studio-chat.http_headers]
37
- Authorization = "Bearer <route-credential>"
38
- ```
39
-
40
- Keep the credential in the client's private configuration. It authorizes this exact plugin route. The Host derives it from the profile's existing persistent browser key. The saved Host port and route credential survive Host restarts. CLI bearer credentials continue rotating at startup. Start the Host through the Studio CLI before reconnecting a stopped Host.
41
-
42
- The plugin requires Studio plugin API 0.2.6. It exposes discovery and media reads on the same connection as `run_studio_action`, the app-only `studio_card_action`, and `ui://studio/chat/v8.html`. Its connection PID equals the Studio Host PID. Disabling the plugin removes the route through the normal plugin lifecycle. The current bundled MCP dependency requires an explicit Host restart for code upgrades when the generic reloader reports `restart_required`.
43
-
44
- ## Discover and read through one connection
45
-
46
- `list_chat_capabilities({})` defaults to `{kind:"user",id:"user"}` and returns ready reusable components, declared chat operations and read-only media queries with their actual `scope` and `target`. Component entries come from the enabled provider's existing `components.list`; the adapter does not keep a second component registry. Generic interactions need a user-scoped component provider and do not create a business project.
47
-
48
- Pass the returned route to `describe_chat_capability({scope,target,componentId?})`. A component description contains its props, result, selected render input and examples, with local schema references intact. For saved project operations, use the selected project's explicit scope. The Host still enforces grants, readiness, bindings and receipts. Legacy `projectId` input remains supported; supplying both it and `scope` is rejected.
49
-
50
- `query_studio_media({scope,target,input})` invokes only a discovered media query with read effects and no confirmation. Read its input schema first. Returned records, task output refs and file selections provide the immutable `ref: {storeId,objectId,versionId}` for `resolve_chat_media({scope,ref,fileId?})`.
51
-
52
- The resolver delegates `{ref,fileId?,access:"https"}` to the existing backend file-access operation. The file service checks the selected bytes, follows a matching saved origin, reuses a usable stored HTTPS URL, or asks the original API provider for a fresh read ticket by its persisted remote ID and original task identity. Ordinary local reads keep their existing behavior. An unmatched local file is an explicit error; resolving never uploads, generates or substitutes another version. The MCP response contains the fixed ref, file ID, MIME type, HTTPS URL and optional expiry, without the Host path.
53
-
54
- Tool `content` is a short readable receipt. `structuredContent` contains model-readable creative data and routing. Signed action bindings, the script digest and prepared messages travel in `_meta` for the App. The page reads the current registered renderer for the original versioned component ID through a read-only MCP resource, then verifies the response's component ID and script digest before mounting. Historical props use the current compatible appearance. The saved digest remains available for legacy clients. The page also accepts legacy replies whose public data contains bindings. A tool return proves neither that a client displayed the card nor that a click delivered a continuation; those require separate UI evidence.
55
-
56
- The adapter's `resourceDomains` configuration declares canonical HTTPS origins for media and other resources. Its default is the Official media CDN, `https://static.vivi-x.ai`. Declare any additional verified source origins explicitly in this adapter's configuration. Discovery returns the active `resourceDomains`; a readable URL alone does not establish that a native host permits the iframe to load it. The component's own `mediaOrigins` further restricts each card. Do not use URL proxies, rehosting or disabled checks to evade a host URL-safety rejection.
57
-
58
- - [Installation-to-card acceptance](acceptance/README.md)
59
- - [Card page and sandbox](chat-ui/README.md)
60
-
61
- ## Discover native action targets
62
-
63
- Search `list_chat_capabilities({scope,kind:"nativeOperation",query,offset,limit})`.
64
- The default limit is 20, the maximum is 100, and nextOffset identifies the next page.
65
- Describe the returned target with kind=nativeOperation to read input/output schemas,
66
- effects, confirm and contract. This includes operations without a chat declaration.
67
- Discovery reads metadata without invoking business operations; default component
68
- discovery does not expand into the whole native catalog.
69
-
70
- An installed source may provide `dynamicActions(context)`. It resolves native
71
- bindings from initial input or authenticated binding context. The adapter admits
72
- those exact same-scope targets through host.operations, signs them with the source
73
- and retains invokeBound recovery. The resolver is installed server code; browser
74
- input never supplies a destination or callback. Static dependency rules are unchanged.
75
-
76
- ## Declare a chat operation
77
-
78
- The App-only `read_local_media` tool reads a supplied absolute image, audio or video `path`
79
- and byte `offset` directly on the local Host. Each response contains at most
80
- 256 KiB in `_meta["studio/media"]`; binary data does not enter public tool output.
81
- Local images support PNG, JPEG and WebP through the same chunk and Blob transport.
82
- The component receives an optional `readMedia` callback through the sandbox bridge,
83
- which accepts only paths declared by the original card projection. Later reads
84
- carry the initial file identity/size/mtime and reject changes. No preview registry,
85
- public media endpoint, import or CLI SDK change is involved. Existing HTTPS media
86
- and action dispatch keep their current routes. Use a matching component package
87
- and adapter; local paths require the Host to share the caller's filesystem.
88
-
89
- A business plugin publishes `extensions: { chat: { component, projectResult, actions } }`
90
- on its operation and registers the component in the manifest's `components` field.
91
- The adapter routes `(action, input)` to the declared destination. Business plugins
92
- own object identity, validation, input mapping, and writes. See the
93
- [component contract](chat-ui/README.md) for Props and Host receipt recovery.
94
-
95
- Card projectors may return optional server-only `bindingContext` JSON. The adapter
96
- puts it inside the existing signed Host operation bindings, strips the top-level
97
- field from the public projection, and supplies the authenticated snapshot as
98
- `ChatActionContext.bindingContext` and `ChatProjectionContext.bindingContext`.
99
- Browser action input never supplies that context. Updated projections can replace
100
- it; unchanged legacy cards omit it and keep context-free bindings. The Host keeps
101
- its existing size limit, scope/caller authentication, generation validation and
102
- receipt-before-preparation replay. Context is signed for integrity, not encrypted;
103
- do not put secrets in it.
104
-
105
- ## Send a follow-up message
106
-
107
- A declared action can provide `prepareMessage(request, context)` instead of a
108
- target. The adapter authenticates the original source binding and passes its
109
- server-owned context to this callback. The callback returns `{intent, data}` with
110
- a nonempty intent and JSON object data. This read-only path invokes no business
111
- operation and creates no business receipt.
112
-
113
- The outer MCP App sends the prepared content through the current client's
114
- `sendMessage` API. The sandbox receives the result status, never the prepared
115
- message metadata. Client confirmation means the message was sent, while business
116
- changes require the subsequent conversation turn and persisted readback.
117
-
118
- Unsupported or rejected sends retain the draft. Unknown sends retain their
119
- original request identity and are not automatically resent. The component's
120
- prompt and target actions remain exclusive per button. No context-update API or
121
- widget-state write substitutes for message delivery.