Skip to content

The VS Code of video editing, built for agents.

TypeScript

Update README and refactor MCP server configuration

konstantin-paulus7f0e7d9d122b
diff --git a/README.md b/README.md
index 92170998..783a5253 100644
--- a/README.md
+++ b/README.md
@@ -61,7 +61,7 @@ Download the desktop app, it walks you through setting everything up:
<a href="https://www.diffusion.studio/download"><img src="https://img.shields.io/badge/Download-Diffusion%20Studio-161616?style=for-the-badge&logo=apple&logoColor=F8F8F8&labelColor=000000" alt="Download Diffusion Studio" /></a>
-Use with Claude Code, Codex, Cursor, Copilot, or Gemini CLI. `/editor` is the main skill you'll use. Ask for what you want in plain language. Behind it is the app's MCP server, which the app registers with your agent; `dapi` is the same set of tools as a CLI.
+Use with Claude Code, Codex, Cursor, Copilot, or Gemini CLI. The app registers its MCP server with your agent, so just ask for what you want in plain language. Agents that list a server's prompts also offer `/diffusion:editor` and `/diffusion:watch`, which pull in the editing and watching guidance up front. `dapi` is the same set of tools as a CLI.
## Prompt examples
@@ -69,11 +69,11 @@ Use with Claude Code, Codex, Cursor, Copilot, or Gemini CLI. `/editor` is the ma
<summary><b>Motion graphics</b></summary>
```text
-/editor Create a ~20-second promo for vercel-labs/native in Vercel's presentation style. Research its official website, GitHub, and brand guidelines; use authentic assets and verified product features, with crisp typography, polished motion, and a strong final CTA.
+Create a ~20-second promo for vercel-labs/native in Vercel's presentation style. Research its official website, GitHub, and brand guidelines; use authentic assets and verified product features, with crisp typography, polished motion, and a strong final CTA.
```
```text
-/editor Recreate the 3blue1brown animation from https://youtu.be/HEfHFsfGXjs, closely matching its visual style, pacing, framing, colors, labels, and transitions. Use the exact collision mathematics from Gregory Galperin's original paper, do not approximate the physics.
+Recreate the 3blue1brown animation from https://youtu.be/HEfHFsfGXjs, closely matching its visual style, pacing, framing, colors, labels, and transitions. Use the exact collision mathematics from Gregory Galperin's original paper, do not approximate the physics.
```
</details>
@@ -82,11 +82,11 @@ Use with Claude Code, Codex, Cursor, Copilot, or Gemini CLI. `/editor` is the ma
<summary><b>Video editing</b></summary>
```text
-/editor edit the footage in /path/to/folder
+Edit the footage in /path/to/folder
```
```text
-/editor turn this footage into a polished YouTube video. Add readable captions and an attention-grabbing graphic in the opening to give viewers a strong visual hook.
+Turn this footage into a polished YouTube video. Add readable captions and an attention-grabbing graphic in the opening to give viewers a strong visual hook.
```
</details>
@@ -95,11 +95,11 @@ Use with Claude Code, Codex, Cursor, Copilot, or Gemini CLI. `/editor` is the ma
<summary><b>Clipping</b></summary>
```text
-/editor Can you pull the best 30-second moment from https://youtu.be/MtQ0qxyf-Ds and make a vertical version for social?
+Can you pull the best 30-second moment from https://youtu.be/MtQ0qxyf-Ds and make a vertical version for social?
```
```text
-/editor Make a 15-second version of this launch video. https://x.com/claudeai/status/2045156267690213649
+Make a 15-second version of this launch video. https://x.com/claudeai/status/2045156267690213649
```
</details>
@@ -108,11 +108,11 @@ Use with Claude Code, Codex, Cursor, Copilot, or Gemini CLI. `/editor` is the ma
<summary><b>Video understanding and reasoning</b></summary>
```text
-/watch In three bullets, explain what starts the conflict. Include timestamps. https://youtu.be/aqz-KE-bpKQ
+In three bullets, explain what starts the conflict. Include timestamps. https://youtu.be/aqz-KE-bpKQ
```
```text
-/watch Name three recurring locations and give one visual cue that distinguishes each. https://youtu.be/dQw4w9WgXcQ
+Name three recurring locations and give one visual cue that distinguishes each. https://youtu.be/dQw4w9WgXcQ
```
</details>
diff --git a/apps/desktop/src/dapi/knowledge.test.ts b/apps/desktop/src/dapi/knowledge.test.ts
index 93f8ed33..6a4a0b67 100644
--- a/apps/desktop/src/dapi/knowledge.test.ts
+++ b/apps/desktop/src/dapi/knowledge.test.ts
@@ -9,7 +9,7 @@ import { afterAll, beforeAll, describe, expect, it } from "vitest";
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
-import { instructions, registerResources } from "./knowledge";
+import { instructions, registerPrompts, registerResources, SKILLS } from "./knowledge";
import type { KnowledgeDeps } from "./knowledge";
@@ -23,10 +23,11 @@ beforeAll(() => {
mkdirSync(join(knowledgeDir, "examples", "node_modules"), { recursive: true });
mkdirSync(join(knowledgeDir, "skills"), { recursive: true });
mkdirSync(join(knowledgeDir, "brand", "assets", "logos"), { recursive: true });
- writeFileSync(join(knowledgeDir, "INSTRUCTIONS.md"), "Diffusion Studio is running.\n\n---\nname: editor\npath: dapi://skills/editor.md\n---\n");
+ writeFileSync(join(knowledgeDir, "INSTRUCTIONS.md"), "Diffusion Studio is running.\n");
writeFileSync(join(knowledgeDir, "reference", "jsx", "text.md"), "# text\n\nThe `<text>` element draws a run of text. It wraps at `width`.\n\n## Props\n");
writeFileSync(join(knowledgeDir, "reference", "README.md"), "---\ntitle: x\n---\n# Reference\n\n| a | b |\n\nEvery page, one per tool.\n");
writeFileSync(join(knowledgeDir, "skills", "editor.md"), "# Editing\n\nHow to edit.\n");
+ writeFileSync(join(knowledgeDir, "skills", "watch.md"), "# Watching\n\nHow to watch.\n");
writeFileSync(join(knowledgeDir, "examples", "01-hello.tsx"), "export default <scene />;\n");
writeFileSync(join(knowledgeDir, "examples", "tsconfig.json"), "{}\n");
writeFileSync(join(knowledgeDir, "examples", "node_modules", "ignored.md"), "no\n");
@@ -46,6 +47,7 @@ const deps = (projectOpen: boolean, dir: string | null = knowledgeDir): Knowledg
async function connect(d: KnowledgeDeps): Promise<Client> {
const server = new McpServer({ name: "test", version: "0" }, { instructions: instructions(d) });
registerResources(server, d);
+ registerPrompts(server, d);
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
await server.connect(serverTransport);
const client = new Client({ name: "test-client", version: "0" });
@@ -57,10 +59,17 @@ describe("instructions", () => {
it("is INSTRUCTIONS.md followed by where the tree sits on disk", () => {
const text = instructions(deps(true));
expect(text.startsWith("Diffusion Studio is running.")).toBe(true);
- expect(text).toContain("path: dapi://skills/editor.md");
expect(text).toContain(knowledgeDir);
});
+ it("lists the skills, marking the default, with both ways to pull one in", () => {
+ const text = instructions(deps(true));
+ expect(text).toContain("`editor` (the default) —");
+ expect(text).toContain("Pull it in with the `editor` prompt, or read `dapi://skills/editor.md`.");
+ expect(text).toContain("`watch` —");
+ expect(text).not.toContain("`watch` (the default)");
+ });
+
it("falls back to a one-liner when nothing is staged", () => {
const text = instructions(deps(true, null));
expect(text).toContain("The tools are the whole API");
@@ -80,6 +89,7 @@ describe("resources", () => {
"dapi://reference/README.md",
"dapi://reference/jsx/text.md",
"dapi://skills/editor.md",
+ "dapi://skills/watch.md",
]);
await client.close();
});
@@ -112,3 +122,49 @@ describe("resources", () => {
expect(text).not.toContain("\\`");
});
});
+
+describe("prompts", () => {
+ it("offers one prompt per skill, described the way the instructions describe it", async () => {
+ const client = await connect(deps(true));
+ const prompts = (await client.listPrompts()).prompts;
+ expect(prompts.map((p) => p.name).sort()).toEqual(["editor", "watch"]);
+ for (const skill of SKILLS) {
+ expect(prompts.find((p) => p.name === skill.name)?.description).toBe(skill.description);
+ }
+ await client.close();
+ });
+
+ it("returns the page as the prompt, with the coda that says what to do with it", async () => {
+ const client = await connect(deps(true));
+ const result = await client.getPrompt({ name: "editor" });
+ expect(result.messages).toHaveLength(1);
+ expect(result.messages[0].role).toBe("user");
+ const text = (result.messages[0].content as { text: string }).text;
+ expect(text.startsWith("# Editing")).toBe(true);
+ expect(text).toContain("ask them what they want to make");
+ await client.close();
+ });
+
+ it("has no prompts when nothing is staged", async () => {
+ const client = await connect(deps(true, null));
+ await expect(client.listPrompts()).rejects.toThrow();
+ await client.close();
+ });
+
+ it("skips a skill whose page the staged tree does not carry", async () => {
+ const bare = join(root, "bare");
+ mkdirSync(join(bare, "skills"), { recursive: true });
+ writeFileSync(join(bare, "skills", "editor.md"), "# Editing\n");
+ const client = await connect(deps(true, bare));
+ expect((await client.listPrompts()).prompts.map((p) => p.name)).toEqual(["editor"]);
+ await client.close();
+ });
+
+ it("has a page in the repo's own knowledge base for every skill in the table", () => {
+ const repoKnowledge = join(__dirname, "..", "..", "..", "..", "knowledge");
+ if (!existsSync(repoKnowledge)) return;
+ expect(SKILLS.map((s) => s.name)).toEqual(["editor", "watch"]);
+ expect(SKILLS.filter((s) => s.default)).toHaveLength(1);
+ for (const skill of SKILLS) expect(existsSync(join(repoKnowledge, skill.page))).toBe(true);
+ });
+});
diff --git a/apps/desktop/src/dapi/knowledge.ts b/apps/desktop/src/dapi/knowledge.ts
index afaa7309..b7ff9aa8 100644
--- a/apps/desktop/src/dapi/knowledge.ts
+++ b/apps/desktop/src/dapi/knowledge.ts
@@ -2,14 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-// What an agent needs to know besides the tools, served from the knowledge
-// base staged into the app bundle (the repo's `knowledge/`): INSTRUCTIONS.md
-// is the server's instructions, which every client receives on connect, and
-// every other page is a resource under `dapi://<path>`, so what an agent
-// reads is exactly what the installed version documents. Two live
-// resources sit beside them for the state agents poll.
-
-import { readdirSync, readFileSync, statSync } from "node:fs";
+import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
import { readFile } from "node:fs/promises";
import { join, relative, sep } from "node:path";
@@ -25,6 +18,39 @@ export type KnowledgeDeps = {
export const INSTRUCTIONS_FILE = "INSTRUCTIONS.md";
+const RESOURCE_PREFIX = "dapi://";
+
+export type Skill = {
+ name: string;
+ /** The page carrying the guidance, relative to the knowledge base. */
+ page: string;
+ description: string;
+ /** The skill to reach for when the user has not pointed at one. Exactly one. */
+ default?: boolean;
+};
+
+/**
+ * What the server offers besides the tools. Each entry is both a line in the
+ * instructions every session receives and a prompt (`/diffusion:editor`), so
+ * adding a skill is adding a row here and its page under `knowledge/skills/`.
+ * Editing is the default; watching is the one you ask for.
+ */
+export const SKILLS: readonly Skill[] = [
+ {
+ name: "editor",
+ page: "skills/editor.md",
+ default: true,
+ description:
+ "Understand, generate, and edit footage with Diffusion Studio: analyze video/audio/images, generate them with AI, and compose video compositions. Use for any media analysis, media generation, or video editing task.",
+ },
+ {
+ name: "watch",
+ page: "skills/watch.md",
+ description:
+ "Watch and understand footage with Diffusion Studio: answer questions about a video or audio file, summarize it, find scenes and moments, pull quotes, and describe what happens and when. Use whenever the user asks what's in a piece of footage, wants a summary or recap, wants to locate a moment, or needs a claim about a video or audio file checked.",
+ },
+];
+
const MIME_TYPES: Record<string, string> = {
".md": "text/markdown",
".ts": "text/plain",
@@ -44,6 +70,7 @@ export function instructions(deps: KnowledgeDeps): string {
const text = deps.knowledgeDir ? readText(join(deps.knowledgeDir, INSTRUCTIONS_FILE)) : null;
const parts = [text?.trim() || FALLBACK_INSTRUCTIONS];
if (deps.knowledgeDir) {
+ parts.push(skillList());
parts.push(
`The resources under \`dapi://\` are the files at \`${deps.knowledgeDir}\`, for anything a resource cannot carry (fonts, imagery, components to copy). They belong to the app; read them, never edit them.`,
);
@@ -77,6 +104,41 @@ export function registerResources(session: McpServer, deps: KnowledgeDeps): void
);
}
+/**
+ * The skills as the instructions present them: what each is for, which to
+ * reach for by default, and both ways to pull one in — the prompt, for agents
+ * that list them, and the resource, for the ones that do not.
+ */
+function skillList(): string {
+ const lines = SKILLS.map(
+ (skill) =>
+ `- \`${skill.name}\`${skill.default ? " (the default)" : ""} — ${skill.description} Pull it in with the \`${skill.name}\` prompt, or read \`${RESOURCE_PREFIX}${skill.page}\`.`,
+ );
+ return ["Before starting on the work itself, pull in the skill that covers it:", ...lines].join("\n");
+}
+
+/**
+ * One prompt per skill, named as the table names it, so an agent that lists a
+ * server's prompts offers `/diffusion:editor` and `/diffusion:watch` beside
+ * its own commands. The page is read at call time, like a resource.
+ */
+export function registerPrompts(session: McpServer, deps: KnowledgeDeps): void {
+ const dir = deps.knowledgeDir;
+ if (!dir) return;
+ for (const skill of SKILLS) {
+ const path = join(dir, ...skill.page.split("/"));
+ if (!existsSync(path)) continue; // a page the staged tree does not carry
+ session.registerPrompt(skill.name, { title: skill.name, description: skill.description }, async () => ({
+ messages: [{ role: "user", content: { type: "text", text: `${await readFile(path, "utf8")}\n${PROMPT_CODA}` } }],
+ }));
+ }
+}
+
+// A prompt arrives as a user turn, so the page needs a closing line saying
+// what to do with guidance that turned up without a request attached to it.
+const PROMPT_CODA =
+ "\nThe guidance above is in effect for the rest of this conversation. Apply it to what the user asked for; if they have not asked for anything yet, ask them what they want to make.";
+
type Page = { name: string; uri: string; path: string; mimeType: string; description?: string };
// The listing is the same for every session; walk the staged tree once.
@@ -115,7 +177,7 @@ function collect(root: string, dir: string, out: Page[]): void {
if (!mimeType) continue;
const name = relative(root, path).split(sep).join("/");
if (name === INSTRUCTIONS_FILE) continue; // already in every session's instructions
- out.push({ name, uri: `dapi://${name}`, path, mimeType, description: mimeType === "text/markdown" ? summary(path) : undefined });
+ out.push({ name, uri: `${RESOURCE_PREFIX}${name}`, path, mimeType, description: mimeType === "text/markdown" ? summary(path) : undefined });
}
}
diff --git a/apps/desktop/src/dapi/server.ts b/apps/desktop/src/dapi/server.ts
index 0536b7b3..99b3357d 100644
--- a/apps/desktop/src/dapi/server.ts
+++ b/apps/desktop/src/dapi/server.ts
@@ -9,7 +9,8 @@ import { tools } from "@diffusionstudio/dapi";
import { MCP_HOST, MCP_PATH, MCP_PORT, SOCKET_PATH, SocketTransport } from "@diffusionstudio/dapi/socket";
import { mainHandlers } from "./handlers";
import { DapiHttpServer } from "./http";
-import { instructions, registerResources } from "./knowledge";
+import { instructions, registerPrompts, registerResources } from "./knowledge";
+import { SERVER_NAME } from "../mcp-config";
import { present, toCallToolResult, toErrorResult } from "./present";
import { RendererCalls } from "./renderer-calls";
@@ -108,7 +109,7 @@ export class DapiServer {
}
}
- /** One MCP server over the whole catalog, plus the docs and live state as resources. */
+ /** One MCP server over the whole catalog, plus the docs and live state as resources and the skills as prompts. */
private createSession(): McpServer {
const knowledge = {
knowledgeDir: this.deps.knowledgeDir,
@@ -116,9 +117,12 @@ export class DapiServer {
context: (signal: AbortSignal) => this.renderer.call("context", {}, signal) as Promise<ToolOutput<"context">>,
};
this.instructionsText ??= instructions(knowledge);
- const session = new McpServer({ name: "diffusion-studio", version: this.deps.version }, { instructions: this.instructionsText });
+ // `name` is the machine identity, and matches the key we write into agent
+ // configs; `title` is what a client shows a person.
+ const session = new McpServer({ name: SERVER_NAME, title: "Diffusion Studio", version: this.deps.version }, { instructions: this.instructionsText });
for (const tool of tools) this.register(session, tool);
registerResources(session, knowledge);
+ registerPrompts(session, knowledge);
return session;
}
diff --git a/apps/desktop/src/mcp-config.test.ts b/apps/desktop/src/mcp-config.test.ts
index 470dc2f6..a294410c 100644
--- a/apps/desktop/src/mcp-config.test.ts
+++ b/apps/desktop/src/mcp-config.test.ts
@@ -34,7 +34,7 @@ describe("per-agent entries", () => {
describe("json configs", () => {
it("creates the file from nothing", () => {
const text = upsertServer(null, "json", { type: "http", url: spec.url });
- expect(JSON.parse(text)).toEqual({ mcpServers: { dapi: { type: "http", url: spec.url } } });
+ expect(JSON.parse(text)).toEqual({ mcpServers: { diffusion: { type: "http", url: spec.url } } });
expect(text.endsWith("\n")).toBe(true);
});
@@ -48,7 +48,7 @@ describe("json configs", () => {
expect(after.numStartups).toBe(12);
expect(after.projects).toEqual({ "/a": { allowedTools: [] } });
expect(after.mcpServers.other).toEqual({ command: "x", args: [] });
- expect(after.mcpServers.dapi).toEqual({ url: spec.url });
+ expect(after.mcpServers.diffusion).toEqual({ url: spec.url });
});
it("replaces a stdio entry with a URL entry, and reads either", () => {
@@ -56,7 +56,7 @@ describe("json configs", () => {
expect(readServer(before, "json")).toEqual({ command: "/old/dapi" });
const after = upsertServer(before, "json", { type: "http", url: spec.url });
expect(readServer(after, "json")).toEqual({ url: spec.url });
- expect(JSON.parse(after).mcpServers.dapi.command).toBeUndefined();
+ expect(JSON.parse(after).mcpServers.diffusion.command).toBeUndefined();
});
it("reads the URL under each agent's key", () => {
@@ -73,7 +73,7 @@ describe("json configs", () => {
it("treats an empty file as no config", () => {
expect(readServer("", "json")).toBeNull();
- expect(JSON.parse(upsertServer(" \n", "json", { url: spec.url }))).toEqual({ mcpServers: { dapi: { url: spec.url } } });
+ expect(JSON.parse(upsertServer(" \n", "json", { url: spec.url }))).toEqual({ mcpServers: { diffusion: { url: spec.url } } });
});
});
@@ -81,21 +81,21 @@ describe("toml configs (codex)", () => {
it("appends a table to an existing config", () => {
const before = 'model = "o3"\n\n[mcp_servers.other]\ncommand = "x"\n';
const after = upsertServer(before, "toml", { url: spec.url });
- expect(after).toBe('model = "o3"\n\n[mcp_servers.other]\ncommand = "x"\n\n[mcp_servers.dapi]\nurl = "http://127.0.0.1:3274/mcp"\n');
+ expect(after).toBe('model = "o3"\n\n[mcp_servers.other]\ncommand = "x"\n\n[mcp_servers.diffusion]\nurl = "http://127.0.0.1:3274/mcp"\n');
expect(readServer(after, "toml")).toEqual({ url: spec.url });
});
it("replaces our table in place and leaves the next one alone", () => {
- const before = '[mcp_servers.dapi]\ncommand = "/old/dapi"\nargs = ["mcp"]\n\n[mcp_servers.other]\ncommand = "x"\n';
+ const before = '[mcp_servers.diffusion]\ncommand = "/old/dapi"\nargs = ["mcp"]\n\n[mcp_servers.other]\ncommand = "x"\n';
expect(readServer(before, "toml")).toEqual({ command: "/old/dapi" });
const after = upsertServer(before, "toml", { url: spec.url });
- expect(after).toBe('[mcp_servers.dapi]\nurl = "http://127.0.0.1:3274/mcp"\n[mcp_servers.other]\ncommand = "x"\n');
+ expect(after).toBe('[mcp_servers.diffusion]\nurl = "http://127.0.0.1:3274/mcp"\n[mcp_servers.other]\ncommand = "x"\n');
expect(readServer(after, "toml")).toEqual({ url: spec.url });
});
it("starts a file from nothing", () => {
const text = upsertServer(null, "toml", { url: spec.url });
- expect(text).toBe('[mcp_servers.dapi]\nurl = "http://127.0.0.1:3274/mcp"\n');
+ expect(text).toBe('[mcp_servers.diffusion]\nurl = "http://127.0.0.1:3274/mcp"\n');
});
it("escapes quotes and backslashes in stdio paths", () => {
diff --git a/apps/desktop/src/mcp-config.ts b/apps/desktop/src/mcp-config.ts
index b910c5e3..fab14673 100644
--- a/apps/desktop/src/mcp-config.ts
+++ b/apps/desktop/src/mcp-config.ts
@@ -13,8 +13,13 @@
*/
export type McpServerSpec = { url: string; command: string; args: string[] };
-/** The key our entry lives under in every agent's server map. */
-export const SERVER_NAME = "dapi";
+/**
+ * The key our entry lives under in every agent's server map, and so the
+ * namespace an agent shows us under: `mcp__diffusion__<tool>` and
+ * `/diffusion:<prompt>`. The same word as our URL scheme, and not `dapi`,
+ * which is the CLI.
+ */
+export const SERVER_NAME = "diffusion";
/** One agent's config entry: what its file format spells a server as. */
export type ServerEntry = Record<string, string | string[]>;
diff --git a/knowledge/INSTRUCTIONS.md b/knowledge/INSTRUCTIONS.md
index 742ac41e..6143e6d0 100644
--- a/knowledge/INSTRUCTIONS.md
+++ b/knowledge/INSTRUCTIONS.md
@@ -3,22 +3,3 @@ Diffusion Studio, a video editor, is running on this machine and you are connect
Projects are folders of JSX; `open` a folder once, then write its files and save — the app recompiles and re-renders.
The tools are the whole API, and their descriptions are authoritative. The same tools exist as `dapi` commands for shells and scripts: `media_grab` is `dapi media grab`, a field like `perSheet` is `--per-sheet`, and the result is the same JSON either way. Each tool is documented once for both under `dapi://reference/tools/`.
-
----
-name: editor
-description: >-
- Understand, generate, and edit footage with Diffusion Studio: analyze
- video/audio/images, generate them with AI, and compose video compositions.
- Use for any media analysis, media generation, or video editing task.
-path: dapi://skills/editor.md
----
-name: watch
-description: >-
- Watch and understand footage with Diffusion Studio: answer questions about a
- video or audio file, summarize it, find scenes and moments, pull quotes, and
- describe what happens and when. Use whenever the user asks what's in a piece
- of footage, wants a summary or recap, wants to locate a moment ("where does X
- happen", "find the scene where..."), or needs a claim about a video or audio
- file checked.
-path: dapi://skills/watch.md
----
diff --git a/packages/dapi/src/socket.ts b/packages/dapi/src/socket.ts
index 08573b0d..62c1b9db 100644
--- a/packages/dapi/src/socket.ts
+++ b/packages/dapi/src/socket.ts
@@ -87,7 +87,7 @@ export class SocketTransport implements Transport {
if (this.draining) return;
this.draining = true;
try {
- for (;;) {
+ while (true) {
let message: JSONRPCMessage | null;
try {
message = this.buffer.readMessage();