@vivix-labs/studio-chat-mcp 0.0.0-stage → 0.1.2

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.
@@ -0,0 +1,108 @@
1
+ import type { OperationTarget, InvokeOptions, ScopeRef } from 'vivix-studio/sdk/shared';
2
+ export type { OperationTarget } from 'vivix-studio/sdk/shared';
3
+
4
+ export interface ChatMessage {
5
+ intent: string;
6
+ data: Record<string, unknown>;
7
+ }
8
+
9
+ /** A plugin projection: The adapter supplies the source identity and registered UI asset. */
10
+ export interface ChatResult {
11
+ /** Server-only JSON authenticated by Host bindings; never accepted from browser props. */
12
+ bindingContext?: unknown;
13
+ text: string;
14
+ structuredContent: Record<string, unknown>;
15
+ view?: {
16
+ props: Record<string, unknown>;
17
+ /** Canonical HTTPS origins allowed for this component's images and media. */
18
+ mediaOrigins?: readonly string[];
19
+ };
20
+ }
21
+ export interface ChatView {
22
+ bindings: Readonly<Record<string, string>>;
23
+ protocolVersion: 1;
24
+ projectId: string;
25
+ scope?: ScopeRef;
26
+ target: OperationTarget;
27
+ component: string;
28
+ props: Record<string, unknown>;
29
+ mediaOrigins?: readonly string[];
30
+ ui: { format: 'iife'; javascript: string; sha256: string };
31
+ }
32
+ export interface HostChatResult extends Omit<ChatResult, 'view' | 'bindingContext'> {
33
+ /** Server-prepared message for the outer MCP App, never a browser-supplied prompt. */
34
+ message?: ChatMessage;
35
+ view?: ChatView;
36
+ }
37
+ export interface ChatRunRequest extends InvokeOptions {
38
+ target: OperationTarget;
39
+ input: unknown;
40
+ }
41
+ export interface ChatActionRequest extends InvokeOptions {
42
+ /** Host-issued operation binding for this declared action. */
43
+ binding: string;
44
+ /** Source operation that opened the card, never a caller-chosen destination. */
45
+ target: OperationTarget;
46
+ action: string;
47
+ input?: Record<string, unknown>;
48
+ }
49
+ export interface ChatProjectionContext {
50
+ /** Authenticated context of the original card when projecting an action response. */
51
+ bindingContext?: unknown;
52
+ projectId: string;
53
+ target: OperationTarget;
54
+ action?: string;
55
+ }
56
+ export interface ChatActionContext extends ChatProjectionContext {
57
+ action: string;
58
+ destination: OperationTarget;
59
+ }
60
+ export interface ChatActionBinding {
61
+ target: string | OperationTarget;
62
+ /** Resolve original objects and convert click parameters on the server. */
63
+ mapInput?: (request: ChatActionRequest, context: ChatActionContext) => unknown | Promise<unknown>;
64
+ /** Check object membership/ownership before the existing target handler runs. */
65
+ validate?: (input: unknown, context: ChatActionContext) => void | Promise<void>;
66
+ projectResult?: (
67
+ result: unknown,
68
+ context: ChatProjectionContext,
69
+ ) => ChatResult | Promise<ChatResult>;
70
+ }
71
+ export interface ChatMessageBinding {
72
+ /** Read-only preparation. The outer App owns actual message delivery. */
73
+ prepareMessage: (
74
+ request: ChatActionRequest,
75
+ context: ChatProjectionContext,
76
+ ) => ChatMessage | Promise<ChatMessage>;
77
+ target?: never;
78
+ }
79
+ export interface OperationChat<O = unknown> {
80
+ component: string;
81
+ projectResult: (result: O, context: ChatProjectionContext) => ChatResult | Promise<ChatResult>;
82
+ actions: Readonly<
83
+ Record<string, string | OperationTarget | ChatActionBinding | ChatMessageBinding>
84
+ >;
85
+ }
86
+
87
+ export interface ChatCardProps {
88
+ data: Record<string, unknown>;
89
+ projectId: string;
90
+ target: OperationTarget;
91
+ action(
92
+ name: string,
93
+ input?: Record<string, unknown>,
94
+ options?: InvokeOptions,
95
+ ): Promise<ChatCardResult>;
96
+ }
97
+
98
+ /** The sandbox receives projection data and errors, never executable bundle metadata. */
99
+ export interface ChatCardResult {
100
+ text: string;
101
+ structuredContent?: Record<string, unknown>;
102
+ view?: Omit<ChatView, 'ui'>;
103
+ isError: boolean;
104
+ }
105
+ export interface ChatCardMount {
106
+ update(props: ChatCardProps): void;
107
+ dispose(): void;
108
+ }
package/dist/shared.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,50 @@
1
1
  {
2
2
  "name": "@vivix-labs/studio-chat-mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.2",
4
+ "type": "module",
5
+ "engines": {
6
+ "node": ">=22.12.0"
7
+ },
8
+ "devDependencies": {
9
+ "@modelcontextprotocol/client": "2.4.0",
10
+ "@modelcontextprotocol/core": "2.4.0",
11
+ "@modelcontextprotocol/ext-apps": "2.0.3",
12
+ "@modelcontextprotocol/sdk": "^1.32.2",
13
+ "@playwright/test": "1.63.0",
14
+ "@types/node": "^22.19.0",
15
+ "esbuild": "^0.28.2",
16
+ "fflate": "^0.8.2",
17
+ "smol-toml": "1.9.1",
18
+ "tsx": "^4.21.0",
19
+ "typescript": "^5.9.3",
20
+ "zod": "^4.6.7"
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "studio-plugin.json",
25
+ "skills",
26
+ "LICENSE"
27
+ ],
28
+ "exports": {
29
+ "./server": "./dist/server.js",
30
+ "./shared": {
31
+ "types": "./dist/shared.d.ts",
32
+ "import": "./dist/shared.js"
33
+ }
34
+ },
35
+ "peerDependencies": {
36
+ "vivix-studio": ">=2.2.1"
37
+ },
38
+ "license": "MIT",
39
+ "publishConfig": {
40
+ "access": "public",
41
+ "registry": "https://registry.npmjs.org/",
42
+ "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
+ }
6
50
  }
@@ -0,0 +1,90 @@
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`, then
22
+ `describe_chat_capability` for the selected route and component ID. Reuse the
23
+ returned `scope`, `target`, schemas and examples. General conversation components
24
+ default to user scope and do not require creating a business project. The MCP
25
+ entry point reads the enabled provider's live catalog. Choose from that catalog.
26
+
27
+ Prepare props from the user's actual topic, draft or candidates. Open the
28
+ returned route with `run_studio_action`, using its actual scope and input.
29
+ Scope each prompt action to the clicked operation and use the latest interaction
30
+ data. Choose any subsequent presentation from the user's intent for that turn.
31
+ Local edits and sent prompts
32
+ do not prove a saved business change.
33
+
34
+ Read saved media through a discovered `query_studio_media` route after describing
35
+ its native input schema. Take the exact `ref` from a returned task, asset or user
36
+ selection. Call `resolve_chat_media` with that scope, ref and optional file ID to
37
+ get an HTTPS read URL. The file service owns origin lookup and ticket refresh.
38
+ Check the connection's returned `resourceDomains` before previewing media. A
39
+ readable URL does not prove the native host permits it. Report a URL-safety
40
+ rejection separately from expiry or decoding; do not proxy, rehost or disable
41
+ checks to evade that rejection. A changed UI resource must be tested in a
42
+ connection that actually loads the new resource version.
43
+ Use existing valid URLs directly. A local file without a registered source is a
44
+ reported preview gap; it does not authorize upload or generation.
45
+
46
+ If discovery returns no ready matching capability, report that status and retain
47
+ the draft. For an unmet general presentation need, follow the installed
48
+ `chat-components` custom-visualization route and `vivix-studio-ui` guidance when
49
+ the host supports it. Scope or transport failures are failures to report, not proof
50
+ that another CLI profile has no components. A specialized media workflow keeps
51
+ its generation steps and uses these interactions at confirmation and review.
52
+
53
+ Print a short readable receipt when reporting tool results. Preserve structured
54
+ results for the client; do not dump the entire MCP envelope, UI source or bindings
55
+ as conversation text. A ready receipt alone does not prove visible rendering.
56
+
57
+ ## Open a Studio project operation card
58
+
59
+ Use the `vivix-studio-chat` local MCP connection with an opened Studio project.
60
+ Use the same-connection discovery tools with the chosen project scope to read
61
+ the enabled operation, native schema and `chat` declaration. CLI `plugin describe`
62
+ is an alternative only when it addresses that same Host configuration.
63
+ Keep the user's chosen project explicit. A plugin being installed does not mean
64
+ its instance is enabled or that every operation supports a chat card.
65
+
66
+ Call `run_studio_action` with the discovered project `scope`, the declared source
67
+ `target: {instanceId, operationId}`, and `input`. For a mutation, choose one
68
+ `requestKey` before the first call and preserve it with the original parameters.
69
+ Host confirmation and permission rules apply to the operation. If the Host
70
+ requires human approval, present its approval instructions to the user.
71
+
72
+ The installed plugin supplies the card component; the MCP server supplies the
73
+ generic page at `ui://studio/chat/v1.html`. Card buttons call the app-only
74
+ `studio_card_action`; this installed adapter resolves the allowed destination from the source
75
+ operation. Use the card's original project, source target, and Host action binding throughout. Keep business fields inside `input`.
76
+ Business handlers are not individually exposed as MCP tools.
77
+
78
+ Report the text and business result even when the current chat cannot render the card.
79
+ Reopen an existing object using a declared read operation and its saved identity. A
80
+ transport error or `submission_unknown` leaves acceptance uncertain: retain the
81
+ original binding, key, and parameters, and recover or replay that same request only
82
+ when requested. A changed payload under one key is a conflict; a new key denotes
83
+ a new action. After a revision conflict, refresh and let the user review the new
84
+ state before another explicit write with a new key.
85
+
86
+ This adapter is a user-scoped Studio server plugin running in the Host process.
87
+ The MCP client connects to its authenticated HTTP route. If the Host is stopped,
88
+ open the project with the CLI. Use the package README for installation and client
89
+ connection configuration. Keep local credentials out of tool inputs and chat
90
+ messages. Host operation dispatch owns access, approval, receipts and leases.
@@ -0,0 +1,4 @@
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.'
@@ -0,0 +1,12 @@
1
+ {
2
+ "manifestVersion": "0.2",
3
+ "id": "studio.chat",
4
+ "requirements": {
5
+ "studioPluginApi": "^0.2.6"
6
+ },
7
+ "requestedAccess": ["host.operations"],
8
+ "resources": {
9
+ "skills": ["skills/vivix-studio-chat/SKILL.md"]
10
+ },
11
+ "operationExtensions": ["chat"]
12
+ }