@vivix-labs/studio-chat-mcp 0.1.15 → 0.1.17

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/setup.js CHANGED
@@ -945,8 +945,9 @@ async function enable(id, scope, options = [], additions) {
945
945
  try {
946
946
  activate();
947
947
  } catch (error) {
948
- if (error.code !== "USER_SCOPE_IN_USE" || scope !== user || restarted) throw error;
949
- restarted = true;
948
+ const canRestart = error.code === "USER_SCOPE_IN_USE" && scope === user && !restarted || error.code === "INSTANCE_UNAVAILABLE" && scope !== user;
949
+ if (!canRestart) throw error;
950
+ if (scope === user) restarted = true;
950
951
  cliCall("host", "stop");
951
952
  for (let i = 0; cliCall("host", "status").pid; i++) {
952
953
  if (i === 60) throw Error("Studio Host is still stopping. Rerun setup after it exits.");
@@ -961,13 +962,12 @@ async function enable(id, scope, options = [], additions) {
961
962
  await enable("studio-chat", user, ["--allow-access", "host.operations"]);
962
963
  await enable("chat-components", user);
963
964
  await enable("ui-system", user);
964
- var examples = await present(join(profile, "home-initialization.json")) ? await read(join(profile, "home-initialization.json")) : {};
965
- var drama = examples.projects?.["out-of-steps"]?.projectId;
966
- if (drama && cliCall("project", "list").projects.some((p) => p.id === drama && p.available)) {
967
- const scope = ["--project", drama];
965
+ for (const project of cliCall("project", "list").projects) {
966
+ if (!project.available) continue;
967
+ const scope = ["--project", project.id];
968
968
  const author = cliCall("plugin", "list", ...scope).instances.find((i) => i.id === "authoring");
969
969
  if (author?.package === packages.authoring) {
970
- await enable("authoring", scope);
970
+ await enable("authoring", scope, ["--allow-access", "events.publish"]);
971
971
  await enable("chat-components", scope, [], {
972
972
  character: { instanceId: "authoring", operationId: "characters.receiveCard" }
973
973
  });
package/dist/shared.d.ts CHANGED
@@ -25,6 +25,8 @@ export interface ChatView {
25
25
  scope?: ScopeRef;
26
26
  target: OperationTarget;
27
27
  component: string;
28
+ cardInstanceId?: string;
29
+ componentId?: string;
28
30
  props: Record<string, unknown>;
29
31
  mediaOrigins?: readonly string[];
30
32
  ui: { format: 'iife'; javascript: string; sha256: string };
@@ -37,6 +39,7 @@ export interface HostChatResult extends Omit<ChatResult, 'view' | 'bindingContex
37
39
  export interface ChatRunRequest extends InvokeOptions {
38
40
  target: OperationTarget;
39
41
  input: unknown;
42
+ fromInteractionId?: string;
40
43
  }
41
44
  export interface ChatActionRequest extends InvokeOptions {
42
45
  /** Host-issued operation binding for this declared action. */
@@ -45,6 +48,8 @@ export interface ChatActionRequest extends InvokeOptions {
45
48
  target: OperationTarget;
46
49
  action: string;
47
50
  input?: Record<string, unknown>;
51
+ cardInstanceId?: string;
52
+ fromInteractionId?: string;
48
53
  }
49
54
  export interface ChatProjectionContext {
50
55
  /** Authenticated context of the original card when projecting an action response. */
@@ -52,6 +57,7 @@ export interface ChatProjectionContext {
52
57
  projectId: string;
53
58
  target: OperationTarget;
54
59
  action?: string;
60
+ interactionId?: string;
55
61
  }
56
62
  export interface ChatActionContext extends ChatProjectionContext {
57
63
  action: string;
@@ -0,0 +1,54 @@
1
+ # Studio Chat MCP contract
2
+
3
+ Use the unified `vivix-studio` Skill's `chat-interactions.md` for capability
4
+ discovery, presentation choice, defaults, session handling and continuation.
5
+ This document only records the transport details owned by the MCP adapter.
6
+
7
+ ## Discovery and routing
8
+
9
+ - Call `list_chat_capabilities` on this connection before selecting a card.
10
+ - Call `describe_chat_capability` with the returned component or native-operation
11
+ target before constructing input.
12
+ - Call `run_studio_action` with the returned `scope`, `target`, schemas and input.
13
+ - General components use user scope. Project media queries and declared project
14
+ cards use the explicit project scope returned by discovery.
15
+ - Native-operation actions use `target.mode: "native"` and the declared
16
+ `inputBindings`. They do not require a receiver card or a second business API.
17
+
18
+ The adapter projects the installed component through
19
+ `ui://studio/chat/v1.html`. Card buttons return through the app-only
20
+ `studio_card_action` route. The adapter authenticates the original source,
21
+ component, action and target before dispatching a Host operation.
22
+
23
+ When a prompt button prepares a `chat-component-action` follow-up, the adapter
24
+ attaches a server-minted `interactionId` to the returned `data` object. On the
25
+ immediate continuation turn triggered by that callback, pass `data.interactionId`
26
+ verbatim via optional `fromInteractionId` on `run_studio_action` (or
27
+ `--from-interaction` / `VIVIX_INTERACTION_ID` on Studio CLI invocations) so
28
+ downstream operations retain concurrent-safe attribution. Never fabricate an
29
+ `interactionId` or carry it across later turns.
30
+
31
+ ## Media transport
32
+
33
+ Query saved media through the discovered `query_studio_media` route and resolve
34
+ the exact returned reference with `resolve_chat_media`. The file service owns
35
+ origin lookup and ticket refresh. Check the returned `resourceDomains` before
36
+ using an HTTPS preview URL.
37
+
38
+ When the component schema supports local media, pass an absolute local Host
39
+ `path` for PNG, JPEG, WebP, audio or video instead of `src`, and pass exactly
40
+ one of them. Video `poster` values still require HTTPS. Local reads use the
41
+ app-only `read_local_media` channel and load the complete file before display.
42
+ They do not upload, import or generate content.
43
+
44
+ ## Request recovery
45
+
46
+ Choose one `requestKey` before a mutation and preserve the original input,
47
+ scope, source target and action binding through retries. An uncertain or
48
+ `submission_unknown` result must be recovered through the original operation and
49
+ key before any new submission. A changed payload under the same key is a
50
+ conflict. A new key represents a new action.
51
+
52
+ The Host owns access, approval, receipts and leases. A successful adapter result
53
+ means the Host accepted the request. It does not prove that the client rendered
54
+ the card or that a business write, export or generation completed.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vivix-labs/studio-chat-mcp",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=22.12.0"
@@ -28,7 +28,8 @@
28
28
  "files": [
29
29
  "dist",
30
30
  "studio-plugin.json",
31
- "skills",
31
+ "README.md",
32
+ "docs",
32
33
  "LICENSE"
33
34
  ],
34
35
  "exports": {
@@ -5,8 +5,5 @@
5
5
  "studioPluginApi": "^0.2.6"
6
6
  },
7
7
  "requestedAccess": ["host.operations"],
8
- "resources": {
9
- "skills": ["skills/vivix-studio-chat/SKILL.md"]
10
- },
11
8
  "operationExtensions": ["chat"]
12
9
  }
@@ -1,117 +0,0 @@
1
- ---
2
- name: vivix-studio-chat
3
- description: Discover and open a native chat card when it helps with the current inspection, comparison, choice or edit. General interactions need no business project. Saved Studio operations use the chosen project scope. Remote creation uses vivix-studio-mcp.
4
- ---
5
-
6
- # Chat interactions and local Studio cards
7
-
8
- ## Discover a general interaction
9
-
10
- Use the installed `chat-components` Skill's “Choose the presentation for this
11
- turn” rule for native cards and custom UI. Discover a card when it helps with the
12
- user's current task, including a preview that needs no follow-up question.
13
-
14
- Default card headings, field labels, group headings, buttons, placeholders, and
15
- instructions to English, even when the conversation is Chinese. Follow an explicit
16
- request for another interface language. Preserve story names and text, character
17
- names, saved object names, and user input in their original language. A story
18
- choice's `label` is content; its group `label` is interface text. For example, use
19
- `Choose a story` with `《我们先约会》` and its original Chinese synopsis.
20
-
21
- Use this connection's `list_chat_capabilities` (check active session
22
- capabilities when starting or continuing a Studio project), then
23
- `describe_chat_capability` for the selected route and component ID. Reuse the
24
- returned `scope`, `target`, schemas and examples. General conversation components
25
- default to user scope and do not require creating a business project. The MCP
26
- entry point reads the enabled provider's live catalog. Choose from that catalog.
27
-
28
- For a reusable card button calling one native operation, explicitly search this
29
- connection with `kind:"nativeOperation"` and describe the returned target with the
30
- same kind. Read its input schema, effects and confirm. Configure target.mode=native
31
- and inputBindings as described in the installed chat-components interaction guide.
32
- The native operation needs no chat view or receiver envelope. Keep the original
33
- scope and let the Host handle execution, approvals and request-key recovery.
34
-
35
- Prepare props from the user's actual topic, draft or candidates. Open the
36
- returned route with `run_studio_action`, using its actual scope and input.
37
- Scope each prompt action to the clicked operation and use the latest interaction
38
- data. Choose any subsequent presentation from the user's intent for that turn.
39
- Local edits and sent prompts
40
- do not prove a saved business change.
41
-
42
- Read saved media through a discovered `query_studio_media` route after describing
43
- its native input schema. Take the exact `ref` from a returned task, asset or user
44
- selection. Call `resolve_chat_media` with that scope, ref and optional file ID to
45
- get an HTTPS read URL. The file service owns origin lookup and ticket refresh.
46
- Check the connection's returned `resourceDomains` before previewing media. A
47
- readable URL does not prove the native host permits it. Report a URL-safety
48
- rejection separately from expiry or decoding; do not proxy, rehost or disable
49
- checks to evade that rejection. A changed UI resource must be tested in a
50
- connection that actually loads the new resource version.
51
- Use existing valid URLs directly. For PNG/JPEG/WebP images, audio, or video
52
- already available on the local MCP Host, supply its absolute `path` instead of
53
- `src` when the component's schema supports it; use exactly one of the two.
54
- Video `poster` strings still require HTTPS. The card reads `path + offset`
55
- through the App-only `read_local_media` channel and loads the complete file
56
- before display or playback. It needs no preview ID,
57
- import or public URL. A remote MCP Host cannot read a path on the user's computer.
58
- This whole-file preview does not provide progressive long-video playback.
59
-
60
- If the interactive card tools are not active after this conversation has just
61
- installed Studio or changed the MCP configuration, proactively tell the user
62
- in natural language (without mentioning internal protocol/server names or
63
- hardcoding a client name) that interactive cards require starting a new
64
- conversation, while continuing via the CLI and Studio Workbench. On a later
65
- conversation, if the tools are still absent, report that the current host has
66
- not exposed interactive cards and continue via the CLI and Studio Workbench
67
- without asking for another conversation.
68
-
69
- When `list_chat_capabilities`, `describe_chat_capability`, or
70
- `run_studio_action` has succeeded in the current conversation, treat cards as
71
- active and do not suggest starting a new conversation for this task.
72
-
73
- If discovery returns no ready matching capability, report that status and retain
74
- the draft. For an unmet general presentation need, follow the installed
75
- `chat-components` custom-visualization route and `vivix-studio-ui` guidance when
76
- the host supports it. Scope or transport failures are failures to report, not proof
77
- that another CLI profile has no components. A specialized media workflow keeps
78
- its generation steps and uses these interactions at confirmation and review.
79
-
80
- Print a short readable receipt when reporting tool results. Preserve structured
81
- results for the client; do not dump the entire MCP envelope, UI source or bindings
82
- as conversation text. A ready receipt alone does not prove visible rendering.
83
-
84
- ## Open a Studio project operation card
85
-
86
- Use the `vivix-studio-chat` local MCP connection with an opened Studio project.
87
- Use the same-connection discovery tools with the chosen project scope to read
88
- the enabled operation, native schema and `chat` declaration. CLI `plugin describe`
89
- is an alternative only when it addresses that same Host configuration.
90
- Keep the user's chosen project explicit. A plugin being installed does not mean
91
- its instance is enabled or that every operation supports a chat card.
92
-
93
- Call `run_studio_action` with the discovered project `scope`, the declared source
94
- `target: {instanceId, operationId}`, and `input`. For a mutation, choose one
95
- `requestKey` before the first call and preserve it with the original parameters.
96
- Host confirmation and permission rules apply to the operation. If the Host
97
- requires human approval, present its approval instructions to the user.
98
-
99
- The installed plugin supplies the card component; the MCP server supplies the
100
- generic page at `ui://studio/chat/v1.html`. Card buttons call the app-only
101
- `studio_card_action`; this installed adapter resolves the allowed destination from the source
102
- operation. Use the card's original project, source target, and Host action binding throughout. Keep business fields inside `input`.
103
- Business handlers are not individually exposed as MCP tools.
104
-
105
- Report the text and business result even when the current chat cannot render the card.
106
- Reopen an existing object using a declared read operation and its saved identity. A
107
- transport error or `submission_unknown` leaves acceptance uncertain: retain the
108
- original binding, key, and parameters, and recover or replay that same request only
109
- when requested. A changed payload under one key is a conflict; a new key denotes
110
- a new action. After a revision conflict, refresh and let the user review the new
111
- state before another explicit write with a new key.
112
-
113
- This adapter is a user-scoped Studio server plugin running in the Host process.
114
- The MCP client connects to its authenticated HTTP route. If the Host is stopped,
115
- open the project with the CLI. Use the package README for installation and client
116
- connection configuration. Keep local credentials out of tool inputs and chat
117
- messages. Host operation dispatch owns access, approval, receipts and leases.
@@ -1,4 +0,0 @@
1
- interface:
2
- display_name: 'Vivix Studio Chat'
3
- short_description: 'Use local Studio plugin cards in chat'
4
- default_prompt: 'Use $vivix-studio-chat to open the declared card for my local Studio project.'