@ellery/terminal-mcp 0.2.1 → 0.3.0

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.
Files changed (115) hide show
  1. package/README.md +301 -9
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +2 -61
  4. package/dist/client.js.map +1 -1
  5. package/dist/index.js +286 -14
  6. package/dist/index.js.map +1 -1
  7. package/dist/prompts/index.d.ts.map +1 -1
  8. package/dist/prompts/index.js +8 -0
  9. package/dist/prompts/index.js.map +1 -1
  10. package/dist/recording/index.d.ts +4 -0
  11. package/dist/recording/index.d.ts.map +1 -0
  12. package/dist/recording/index.js +3 -0
  13. package/dist/recording/index.js.map +1 -0
  14. package/dist/recording/manager.d.ts +62 -0
  15. package/dist/recording/manager.d.ts.map +1 -0
  16. package/dist/recording/manager.js +123 -0
  17. package/dist/recording/manager.js.map +1 -0
  18. package/dist/recording/recorder.d.ts +95 -0
  19. package/dist/recording/recorder.d.ts.map +1 -0
  20. package/dist/recording/recorder.js +296 -0
  21. package/dist/recording/recorder.js.map +1 -0
  22. package/dist/recording/types.d.ts +65 -0
  23. package/dist/recording/types.d.ts.map +1 -0
  24. package/dist/recording/types.js +2 -0
  25. package/dist/recording/types.js.map +1 -0
  26. package/dist/sandbox/config.d.ts +46 -0
  27. package/dist/sandbox/config.d.ts.map +1 -0
  28. package/dist/sandbox/config.js +144 -0
  29. package/dist/sandbox/config.js.map +1 -0
  30. package/dist/sandbox/controller.d.ts +72 -0
  31. package/dist/sandbox/controller.d.ts.map +1 -0
  32. package/dist/sandbox/controller.js +208 -0
  33. package/dist/sandbox/controller.js.map +1 -0
  34. package/dist/sandbox/index.d.ts +6 -0
  35. package/dist/sandbox/index.d.ts.map +1 -0
  36. package/dist/sandbox/index.js +4 -0
  37. package/dist/sandbox/index.js.map +1 -0
  38. package/dist/sandbox/prompt.d.ts +10 -0
  39. package/dist/sandbox/prompt.d.ts.map +1 -0
  40. package/dist/sandbox/prompt.js +434 -0
  41. package/dist/sandbox/prompt.js.map +1 -0
  42. package/dist/server.d.ts +2 -3
  43. package/dist/server.d.ts.map +1 -1
  44. package/dist/server.js +21 -0
  45. package/dist/server.js.map +1 -1
  46. package/dist/terminal/index.d.ts +1 -0
  47. package/dist/terminal/index.d.ts.map +1 -1
  48. package/dist/terminal/manager.d.ts +89 -31
  49. package/dist/terminal/manager.d.ts.map +1 -1
  50. package/dist/terminal/manager.js +313 -44
  51. package/dist/terminal/manager.js.map +1 -1
  52. package/dist/terminal/session.d.ts +34 -1
  53. package/dist/terminal/session.d.ts.map +1 -1
  54. package/dist/terminal/session.js +160 -3
  55. package/dist/terminal/session.js.map +1 -1
  56. package/dist/tools/createSession.d.ts +44 -0
  57. package/dist/tools/createSession.d.ts.map +1 -0
  58. package/dist/tools/createSession.js +41 -0
  59. package/dist/tools/createSession.js.map +1 -0
  60. package/dist/tools/definitions.d.ts +18 -0
  61. package/dist/tools/definitions.d.ts.map +1 -0
  62. package/dist/tools/definitions.js +116 -0
  63. package/dist/tools/definitions.js.map +1 -0
  64. package/dist/tools/destroySession.d.ts +31 -0
  65. package/dist/tools/destroySession.d.ts.map +1 -0
  66. package/dist/tools/destroySession.js +32 -0
  67. package/dist/tools/destroySession.js.map +1 -0
  68. package/dist/tools/getContent.d.ts +7 -0
  69. package/dist/tools/getContent.d.ts.map +1 -1
  70. package/dist/tools/getContent.js +8 -3
  71. package/dist/tools/getContent.js.map +1 -1
  72. package/dist/tools/index.d.ts.map +1 -1
  73. package/dist/tools/index.js +26 -1
  74. package/dist/tools/index.js.map +1 -1
  75. package/dist/tools/listSessions.d.ts +19 -0
  76. package/dist/tools/listSessions.d.ts.map +1 -0
  77. package/dist/tools/listSessions.js +23 -0
  78. package/dist/tools/listSessions.js.map +1 -0
  79. package/dist/tools/screenshot.d.ts +26 -3
  80. package/dist/tools/screenshot.d.ts.map +1 -1
  81. package/dist/tools/screenshot.js +55 -5
  82. package/dist/tools/screenshot.js.map +1 -1
  83. package/dist/tools/sendKey.d.ts +7 -0
  84. package/dist/tools/sendKey.d.ts.map +1 -1
  85. package/dist/tools/sendKey.js +7 -2
  86. package/dist/tools/sendKey.js.map +1 -1
  87. package/dist/tools/startRecording.d.ts +68 -0
  88. package/dist/tools/startRecording.d.ts.map +1 -0
  89. package/dist/tools/startRecording.js +111 -0
  90. package/dist/tools/startRecording.js.map +1 -0
  91. package/dist/tools/stopRecording.d.ts +31 -0
  92. package/dist/tools/stopRecording.d.ts.map +1 -0
  93. package/dist/tools/stopRecording.js +76 -0
  94. package/dist/tools/stopRecording.js.map +1 -0
  95. package/dist/tools/type.d.ts +7 -0
  96. package/dist/tools/type.d.ts.map +1 -1
  97. package/dist/tools/type.js +7 -2
  98. package/dist/tools/type.js.map +1 -1
  99. package/dist/transport/socket.d.ts.map +1 -1
  100. package/dist/transport/socket.js +10 -0
  101. package/dist/transport/socket.js.map +1 -1
  102. package/dist/ui/index.d.ts +1 -0
  103. package/dist/ui/index.d.ts.map +1 -1
  104. package/dist/ui/index.js +17 -1
  105. package/dist/ui/index.js.map +1 -1
  106. package/dist/utils/platform.d.ts +6 -0
  107. package/dist/utils/platform.d.ts.map +1 -1
  108. package/dist/utils/platform.js +15 -0
  109. package/dist/utils/platform.js.map +1 -1
  110. package/dist/utils/render.d.ts +21 -0
  111. package/dist/utils/render.d.ts.map +1 -0
  112. package/dist/utils/render.js +162 -0
  113. package/dist/utils/render.js.map +1 -0
  114. package/package.json +6 -2
  115. package/sandbox-permissions.png +0 -0
@@ -3,7 +3,22 @@ import { typeTool, handleType } from "./type.js";
3
3
  import { sendKeyTool, handleSendKey } from "./sendKey.js";
4
4
  import { getContentTool, handleGetContent } from "./getContent.js";
5
5
  import { screenshotTool, handleScreenshot } from "./screenshot.js";
6
- const tools = [typeTool, sendKeyTool, getContentTool, screenshotTool];
6
+ import { startRecordingTool, handleStartRecording } from "./startRecording.js";
7
+ import { stopRecordingTool, handleStopRecording } from "./stopRecording.js";
8
+ import { createSessionTool, handleCreateSession } from "./createSession.js";
9
+ import { listSessionsTool, handleListSessions } from "./listSessions.js";
10
+ import { destroySessionTool, handleDestroySession } from "./destroySession.js";
11
+ const tools = [
12
+ typeTool,
13
+ sendKeyTool,
14
+ getContentTool,
15
+ screenshotTool,
16
+ startRecordingTool,
17
+ stopRecordingTool,
18
+ createSessionTool,
19
+ listSessionsTool,
20
+ destroySessionTool,
21
+ ];
7
22
  export function registerTools(server, manager) {
8
23
  // Register list tools handler
9
24
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
@@ -22,6 +37,16 @@ export function registerTools(server, manager) {
22
37
  return handleGetContent(manager, args);
23
38
  case "takeScreenshot":
24
39
  return handleScreenshot(manager, args);
40
+ case "startRecording":
41
+ return handleStartRecording(manager, args);
42
+ case "stopRecording":
43
+ return await handleStopRecording(manager, args);
44
+ case "createSession":
45
+ return await handleCreateSession(manager, args);
46
+ case "listSessions":
47
+ return handleListSessions(manager, args);
48
+ case "destroySession":
49
+ return handleDestroySession(manager, args);
25
50
  default:
26
51
  throw new Error(`Unknown tool: ${name}`);
27
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAG5C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnE,MAAM,KAAK,GAAG,CAAC,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;AAEtE,MAAM,UAAU,aAAa,CAAC,MAAc,EAAE,OAAwB;IACpE,8BAA8B;IAC9B,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BACZ,OAAO,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBAEtC,KAAK,YAAY;oBACf,OAAO,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBAEzC,KAAK,gBAAgB;oBACnB,OAAO,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBAEzC,KAAK,gBAAgB;oBACnB,OAAO,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBAE7C,KAAK,eAAe;oBAClB,OAAO,MAAM,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBAElD,KAAK,eAAe;oBAClB,OAAO,MAAM,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBAElD,KAAK,cAAc;oBACjB,OAAO,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBAE3C,KAAK,gBAAgB;oBACnB,OAAO,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBAE7C;oBACE,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,UAAU,OAAO,EAAE;qBAC1B;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { z } from "zod";
2
+ import { TerminalManager } from "../terminal/index.js";
3
+ export declare const listSessionsSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
4
+ export declare const listSessionsTool: {
5
+ name: string;
6
+ description: string;
7
+ inputSchema: {
8
+ type: "object";
9
+ properties: {};
10
+ required: never[];
11
+ };
12
+ };
13
+ export declare function handleListSessions(manager: TerminalManager, _args: unknown): {
14
+ content: Array<{
15
+ type: "text";
16
+ text: string;
17
+ }>;
18
+ };
19
+ //# sourceMappingURL=listSessions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listSessions.d.ts","sourceRoot":"","sources":["../../src/tools/listSessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,eAAO,MAAM,kBAAkB,gDAAe,CAAC;AAE/C,eAAO,MAAM,gBAAgB;;;;;;;;CAQ5B,CAAC;AAEF,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,OAAO,GACb;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAUpD"}
@@ -0,0 +1,23 @@
1
+ import { z } from "zod";
2
+ export const listSessionsSchema = z.object({});
3
+ export const listSessionsTool = {
4
+ name: "listSessions",
5
+ description: "List all active terminal sessions, including the default session. Returns session metadata and the configured limits.",
6
+ inputSchema: {
7
+ type: "object",
8
+ properties: {},
9
+ required: [],
10
+ },
11
+ };
12
+ export function handleListSessions(manager, _args) {
13
+ const result = manager.listSessions();
14
+ return {
15
+ content: [
16
+ {
17
+ type: "text",
18
+ text: JSON.stringify(result, null, 2),
19
+ },
20
+ ],
21
+ };
22
+ }
23
+ //# sourceMappingURL=listSessions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listSessions.js","sourceRoot":"","sources":["../../src/tools/listSessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAE/C,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,uHAAuH;IACpI,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,EAAE;KACb;CACF,CAAC;AAEF,MAAM,UAAU,kBAAkB,CAChC,OAAwB,EACxB,KAAc;IAEd,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IACtC,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;aACtC;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -1,20 +1,43 @@
1
1
  import { z } from "zod";
2
2
  import { TerminalManager } from "../terminal/index.js";
3
- export declare const screenshotSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
3
+ export declare const screenshotSchema: z.ZodObject<{
4
+ format: z.ZodOptional<z.ZodEnum<["text", "ansi", "png"]>>;
5
+ sessionId: z.ZodOptional<z.ZodString>;
6
+ }, "strip", z.ZodTypeAny, {
7
+ format?: "text" | "ansi" | "png" | undefined;
8
+ sessionId?: string | undefined;
9
+ }, {
10
+ format?: "text" | "ansi" | "png" | undefined;
11
+ sessionId?: string | undefined;
12
+ }>;
4
13
  export type ScreenshotArgs = z.infer<typeof screenshotSchema>;
5
14
  export declare const screenshotTool: {
6
15
  name: string;
7
16
  description: string;
8
17
  inputSchema: {
9
18
  type: "object";
10
- properties: {};
19
+ properties: {
20
+ format: {
21
+ type: string;
22
+ enum: string[];
23
+ description: string;
24
+ };
25
+ sessionId: {
26
+ type: string;
27
+ description: string;
28
+ };
29
+ };
11
30
  required: never[];
12
31
  };
13
32
  };
14
- export declare function handleScreenshot(manager: TerminalManager, _args: unknown): {
33
+ export declare function handleScreenshot(manager: TerminalManager, args: unknown): {
15
34
  content: Array<{
16
35
  type: "text";
17
36
  text: string;
37
+ } | {
38
+ type: "image";
39
+ data: string;
40
+ mimeType: string;
18
41
  }>;
19
42
  };
20
43
  //# sourceMappingURL=screenshot.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/tools/screenshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,eAAO,MAAM,gBAAgB,gDAAe,CAAC;AAE7C,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE9D,eAAO,MAAM,cAAc;;;;;;;;CAQ1B,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAiB7H"}
1
+ {"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/tools/screenshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,eAAO,MAAM,gBAAgB;;;;;;;;;EAK3B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE9D,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;CAoB1B,CAAC;AAEF,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,OAAO,GACZ;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAwDxG"}
@@ -1,16 +1,66 @@
1
1
  import { z } from "zod";
2
- export const screenshotSchema = z.object({});
2
+ import { renderTerminalToPng } from "../utils/render.js";
3
+ export const screenshotSchema = z.object({
4
+ format: z.enum(["text", "ansi", "png"]).optional().describe("Output format: 'text' (default) returns plain JSON, 'ansi' returns text with ANSI color codes, 'png' returns a color screenshot image"),
5
+ sessionId: z.string().optional().describe("Target session ID. Omit to target the default session."),
6
+ });
3
7
  export const screenshotTool = {
4
8
  name: "takeScreenshot",
5
- description: "Capture terminal state as structured JSON with: content (visible text), cursor {x, y} position, and dimensions {cols, rows}. Use when you need cursor position (e.g., for interactive apps, vim) or terminal dimensions. For simple command output, prefer getContent().",
9
+ description: "Capture terminal state. Format 'text' (default) returns plain JSON with content, cursor, dimensions. Format 'ansi' returns JSON with ANSI color escape codes preserved in the content field. Format 'png' returns a color screenshot image.",
6
10
  inputSchema: {
7
11
  type: "object",
8
- properties: {},
12
+ properties: {
13
+ format: {
14
+ type: "string",
15
+ enum: ["text", "ansi", "png"],
16
+ description: "Output format: 'text' (default) plain JSON, 'ansi' for colored text with ANSI codes, 'png' for color screenshot image",
17
+ },
18
+ sessionId: {
19
+ type: "string",
20
+ description: "Target session ID. Omit to target the default session.",
21
+ },
22
+ },
9
23
  required: [],
10
24
  },
11
25
  };
12
- export function handleScreenshot(manager, _args) {
13
- const screenshot = manager.takeScreenshot();
26
+ export function handleScreenshot(manager, args) {
27
+ const parsed = screenshotSchema.parse(args);
28
+ const format = parsed.format || "text";
29
+ if (format === "ansi") {
30
+ const content = manager.getAnsiContent(true, parsed.sessionId);
31
+ const buffer = manager.getTerminal(parsed.sessionId).buffer.active;
32
+ const result = {
33
+ content,
34
+ cursor: { x: buffer.cursorX, y: buffer.cursorY },
35
+ dimensions: {
36
+ cols: manager.getDimensions(parsed.sessionId).cols,
37
+ rows: manager.getDimensions(parsed.sessionId).rows,
38
+ },
39
+ };
40
+ return {
41
+ content: [
42
+ {
43
+ type: "text",
44
+ text: JSON.stringify(result, null, 2),
45
+ },
46
+ ],
47
+ };
48
+ }
49
+ if (format === "png") {
50
+ const terminal = manager.getTerminal(parsed.sessionId);
51
+ const pngBuffer = renderTerminalToPng(terminal);
52
+ return {
53
+ content: [
54
+ {
55
+ type: "image",
56
+ data: pngBuffer.toString("base64"),
57
+ mimeType: "image/png",
58
+ },
59
+ ],
60
+ };
61
+ }
62
+ // Default text format
63
+ const screenshot = manager.takeScreenshot(parsed.sessionId);
14
64
  const result = {
15
65
  content: screenshot.content,
16
66
  cursor: screenshot.cursor,
@@ -1 +1 @@
1
- {"version":3,"file":"screenshot.js","sourceRoot":"","sources":["../../src/tools/screenshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAI7C,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,0QAA0Q;IACvR,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,EAAE;KACb;CACF,CAAC;AAEF,MAAM,UAAU,gBAAgB,CAAC,OAAwB,EAAE,KAAc;IACvE,MAAM,UAAU,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAE5C,MAAM,MAAM,GAAG;QACb,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,UAAU,EAAE,UAAU,CAAC,UAAU;KAClC,CAAC;IAEF,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,I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M;QACzB,UAAU,EAAE,UAAU,CAAC,UAAU;KAClC,CAAC;IAEF,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;aACtC;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -2,10 +2,13 @@ import { z } from "zod";
2
2
  import { TerminalManager } from "../terminal/index.js";
3
3
  export declare const sendKeySchema: z.ZodObject<{
4
4
  key: z.ZodString;
5
+ sessionId: z.ZodOptional<z.ZodString>;
5
6
  }, "strip", z.ZodTypeAny, {
6
7
  key: string;
8
+ sessionId?: string | undefined;
7
9
  }, {
8
10
  key: string;
11
+ sessionId?: string | undefined;
9
12
  }>;
10
13
  export type SendKeyArgs = z.infer<typeof sendKeySchema>;
11
14
  export declare const sendKeyTool: {
@@ -18,6 +21,10 @@ export declare const sendKeyTool: {
18
21
  type: string;
19
22
  description: string;
20
23
  };
24
+ sessionId: {
25
+ type: string;
26
+ description: string;
27
+ };
21
28
  };
22
29
  required: string[];
23
30
  };
@@ -1 +1 @@
1
- {"version":3,"file":"sendKey.d.ts","sourceRoot":"","sources":["../../src/tools/sendKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,eAAO,MAAM,aAAa;;;;;;EAExB,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAIxD,eAAO,MAAM,WAAW;;;;;;;;;;;;;CAavB,CAAC;AAEF,wBAAgB,aAAa,CAAC,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAqBzH"}
1
+ {"version":3,"file":"sendKey.d.ts","sourceRoot":"","sources":["../../src/tools/sendKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,eAAO,MAAM,aAAa;;;;;;;;;EAGxB,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAIxD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;CAiBvB,CAAC;AAEF,wBAAgB,aAAa,CAAC,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAqBzH"}
@@ -2,11 +2,12 @@ import { z } from "zod";
2
2
  import { getKeySequence, getAvailableKeys } from "../utils/keys.js";
3
3
  export const sendKeySchema = z.object({
4
4
  key: z.string().describe("The key to send (e.g., 'Enter', 'Tab', 'Ctrl+C', 'ArrowUp')"),
5
+ sessionId: z.string().optional().describe("Target session ID. Omit to target the default session."),
5
6
  });
6
7
  const availableKeys = getAvailableKeys();
7
8
  export const sendKeyTool = {
8
9
  name: "sendKey",
9
- description: "Send a special key or key combination to the terminal. Common keys: Enter, Tab, Escape, Backspace, Delete, ArrowUp/Down/Left/Right, Home, End, PageUp, PageDown. Control sequences: Ctrl+C (interrupt), Ctrl+D (EOF), Ctrl+Z (suspend), Ctrl+L (clear screen), Ctrl+A (line start), Ctrl+E (line end), Ctrl+U (clear line). Function keys: F1-F12.",
10
+ description: "Send a special key or key combination to the terminal. Common keys: Enter, Tab, Escape, Backspace, Delete, ArrowUp/Down/Left/Right, Home, End, PageUp, PageDown. Control sequences: Ctrl+C (interrupt), Ctrl+D (EOF), Ctrl+Z (suspend), Ctrl+L (clear screen), Ctrl+A (line start), Ctrl+E (line end), Ctrl+U (clear line). Function keys: F1-F12. Pass sessionId to target a specific session.",
10
11
  inputSchema: {
11
12
  type: "object",
12
13
  properties: {
@@ -14,6 +15,10 @@ export const sendKeyTool = {
14
15
  type: "string",
15
16
  description: "The key to send (e.g., 'Enter', 'Tab', 'Ctrl+C', 'ArrowUp', 'Escape')",
16
17
  },
18
+ sessionId: {
19
+ type: "string",
20
+ description: "Target session ID. Omit to target the default session.",
21
+ },
17
22
  },
18
23
  required: ["key"],
19
24
  },
@@ -25,7 +30,7 @@ export function handleSendKey(manager, args) {
25
30
  const available = getAvailableKeys();
26
31
  throw new Error(`Unknown key: "${parsed.key}". Available keys include: ${available.slice(0, 15).join(", ")}...`);
27
32
  }
28
- manager.write(sequence);
33
+ manager.write(sequence, parsed.sessionId);
29
34
  return {
30
35
  content: [
31
36
  {
@@ -1 +1 @@
1
- {"version":3,"file":"sendKey.js","sourceRoot":"","sources":["../../src/tools/sendKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6DAA6D,CAAC;CACxF,CAAC,CAAC;AAIH,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;AAEzC,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,oVAAoV;IACjW,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,GAAG,EAAE;gBACH,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,uEAAuE;aACrF;SACF;QACD,QAAQ,EAAE,CAAC,KAAK,CAAC;KAClB;CACF,CAAC;AAE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AAE,QAAiB;QACvB,UAAU,EAAE;YACV,GAAG,EAAE;gBACH,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,uEAAuE;aACrF;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,wDAAwD;aACtE;SACF;QACD,QAAQ,EAAE,CAAC,KAAK,CAAC;KAClB;CACF,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,OAAwB,EAAE,IAAa;IACnE,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAE5C,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,MAAM,SAAS,GAAG,gBAAgB,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CACb,iBAAiB,MAAM,CAAC,GAAG,8BAA8B,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAChG,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;IAE1C,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,aAAa,MAAM,CAAC,GAAG,EAAE;aAChC;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,68 @@
1
+ import { z } from "zod";
2
+ import { TerminalManager } from "../terminal/index.js";
3
+ export declare const startRecordingSchema: z.ZodObject<{
4
+ format: z.ZodDefault<z.ZodOptional<z.ZodEnum<["v2"]>>>;
5
+ mode: z.ZodDefault<z.ZodOptional<z.ZodEnum<["always", "on-failure"]>>>;
6
+ outputDir: z.ZodOptional<z.ZodString>;
7
+ idleTimeLimit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
8
+ maxDuration: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
9
+ inactivityTimeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
10
+ }, "strip", z.ZodTypeAny, {
11
+ format: "v2";
12
+ mode: "always" | "on-failure";
13
+ idleTimeLimit: number;
14
+ maxDuration: number;
15
+ inactivityTimeout: number;
16
+ outputDir?: string | undefined;
17
+ }, {
18
+ format?: "v2" | undefined;
19
+ mode?: "always" | "on-failure" | undefined;
20
+ outputDir?: string | undefined;
21
+ idleTimeLimit?: number | undefined;
22
+ maxDuration?: number | undefined;
23
+ inactivityTimeout?: number | undefined;
24
+ }>;
25
+ export declare const startRecordingTool: {
26
+ name: string;
27
+ description: string;
28
+ inputSchema: {
29
+ type: "object";
30
+ properties: {
31
+ format: {
32
+ type: string;
33
+ enum: string[];
34
+ description: string;
35
+ };
36
+ mode: {
37
+ type: string;
38
+ enum: string[];
39
+ description: string;
40
+ };
41
+ outputDir: {
42
+ type: string;
43
+ description: string;
44
+ };
45
+ idleTimeLimit: {
46
+ type: string;
47
+ description: string;
48
+ };
49
+ maxDuration: {
50
+ type: string;
51
+ description: string;
52
+ };
53
+ inactivityTimeout: {
54
+ type: string;
55
+ description: string;
56
+ };
57
+ };
58
+ required: never[];
59
+ };
60
+ };
61
+ export declare function handleStartRecording(manager: TerminalManager, args: unknown): {
62
+ content: Array<{
63
+ type: "text";
64
+ text: string;
65
+ }>;
66
+ isError?: boolean;
67
+ };
68
+ //# sourceMappingURL=startRecording.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startRecording.d.ts","sourceRoot":"","sources":["../../src/tools/startRecording.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;EAO/B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmC9B,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,OAAO,GACZ;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAuEvE"}
@@ -0,0 +1,111 @@
1
+ import { z } from "zod";
2
+ export const startRecordingSchema = z.object({
3
+ format: z.enum(['v2']).optional().default('v2'),
4
+ mode: z.enum(['always', 'on-failure']).optional().default('always'),
5
+ outputDir: z.string().optional(),
6
+ idleTimeLimit: z.number().optional().default(2),
7
+ maxDuration: z.number().optional().default(3600),
8
+ inactivityTimeout: z.number().optional().default(600),
9
+ });
10
+ export const startRecordingTool = {
11
+ name: "startRecording",
12
+ description: "Start recording terminal output to an asciicast v2 file. Returns the recording ID and path where the file will be saved. Only one recording can be active at a time. Recording captures output from all active sessions in the process.",
13
+ inputSchema: {
14
+ type: "object",
15
+ properties: {
16
+ format: {
17
+ type: "string",
18
+ enum: ["v2"],
19
+ description: "Recording format (default: v2, asciicast v2 format)",
20
+ },
21
+ mode: {
22
+ type: "string",
23
+ enum: ["always", "on-failure"],
24
+ description: "Recording mode: always saves the recording, on-failure only saves if session exits with non-zero code (default: always)",
25
+ },
26
+ outputDir: {
27
+ type: "string",
28
+ description: "Directory to save the recording (default: ~/.local/state/terminal-mcp/recordings, or TERMINAL_MCP_RECORD_DIR env var)",
29
+ },
30
+ idleTimeLimit: {
31
+ type: "number",
32
+ description: "Max seconds between events in the recording (default: 2). Caps idle time to prevent long pauses during playback.",
33
+ },
34
+ maxDuration: {
35
+ type: "number",
36
+ description: "Max recording duration in seconds (default: 3600 = 60 minutes). Recording will auto-stop when this limit is reached.",
37
+ },
38
+ inactivityTimeout: {
39
+ type: "number",
40
+ description: "Stop recording after N seconds of no terminal output (default: 600 = 10 minutes). Resets on each output event.",
41
+ },
42
+ },
43
+ required: [],
44
+ },
45
+ };
46
+ export function handleStartRecording(manager, args) {
47
+ const parsed = startRecordingSchema.parse(args ?? {});
48
+ const recordingManager = manager.getRecordingManager();
49
+ // Check if there's already an active recording
50
+ const activeRecordings = recordingManager.getActiveRecordings();
51
+ if (activeRecordings.length > 0) {
52
+ const existing = activeRecordings[0];
53
+ return {
54
+ content: [
55
+ {
56
+ type: "text",
57
+ text: JSON.stringify({
58
+ error: "A recording is already in progress",
59
+ activeRecordingId: existing.id,
60
+ activePath: existing.getFinalPath(),
61
+ }, null, 2),
62
+ },
63
+ ],
64
+ isError: true,
65
+ };
66
+ }
67
+ const recorder = recordingManager.createRecording({
68
+ format: parsed.format,
69
+ mode: parsed.mode,
70
+ outputDir: parsed.outputDir ?? recordingManager.getDefaultOutputDir(),
71
+ idleTimeLimit: parsed.idleTimeLimit,
72
+ maxDuration: parsed.maxDuration,
73
+ inactivityTimeout: parsed.inactivityTimeout,
74
+ });
75
+ // Get current dimensions and start recording
76
+ const dimensions = manager.getDimensions();
77
+ recorder.start(dimensions.cols, dimensions.rows, {
78
+ TERM: 'xterm-256color',
79
+ });
80
+ // Build timeout message
81
+ const timeoutParts = [];
82
+ if (parsed.maxDuration > 0) {
83
+ const mins = Math.floor(parsed.maxDuration / 60);
84
+ timeoutParts.push(`${mins} minute${mins !== 1 ? 's' : ''}`);
85
+ }
86
+ if (parsed.inactivityTimeout > 0) {
87
+ const mins = Math.floor(parsed.inactivityTimeout / 60);
88
+ timeoutParts.push(`${mins} minute${mins !== 1 ? 's' : ''} of inactivity`);
89
+ }
90
+ const timeoutMessage = timeoutParts.length > 0
91
+ ? `Recording will auto-stop after ${timeoutParts.join(' or ')}`
92
+ : undefined;
93
+ const result = {
94
+ recordingId: recorder.id,
95
+ path: recorder.getFinalPath(),
96
+ format: parsed.format,
97
+ mode: parsed.mode,
98
+ maxDuration: parsed.maxDuration,
99
+ inactivityTimeout: parsed.inactivityTimeout,
100
+ message: timeoutMessage,
101
+ };
102
+ return {
103
+ content: [
104
+ {
105
+ type: "text",
106
+ text: JSON.stringify(result, null, 2),
107
+ },
108
+ ],
109
+ };
110
+ }
111
+ //# sourceMappingURL=startRecording.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startRecording.js","sourceRoot":"","sources":["../../src/tools/startRecording.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAC/C,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC;IACnE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAChD,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;CACtD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,yOAAyO;IACtP,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,IAAI,CAAC;gBACZ,WAAW,EAAE,qDAAqD;aACnE;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;g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AG;QACb,WAAW,EAAE,QAAQ,CAAC,EAAE;QACxB,IAAI,EAAE,QAAQ,CAAC,YAAY,EAAE;QAC7B,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,OAAO,EAAE,cAAc;KACxB,CAAC;IAEF,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAe;gBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;aACtC;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { z } from "zod";
2
+ import { TerminalManager } from "../terminal/index.js";
3
+ export declare const stopRecordingSchema: z.ZodObject<{
4
+ recordingId: z.ZodString;
5
+ }, "strip", z.ZodTypeAny, {
6
+ recordingId: string;
7
+ }, {
8
+ recordingId: string;
9
+ }>;
10
+ export declare const stopRecordingTool: {
11
+ name: string;
12
+ description: string;
13
+ inputSchema: {
14
+ type: "object";
15
+ properties: {
16
+ recordingId: {
17
+ type: string;
18
+ description: string;
19
+ };
20
+ };
21
+ required: string[];
22
+ };
23
+ };
24
+ export declare function handleStopRecording(manager: TerminalManager, args: unknown): Promise<{
25
+ content: Array<{
26
+ type: "text";
27
+ text: string;
28
+ }>;
29
+ isError?: boolean;
30
+ }>;
31
+ //# sourceMappingURL=stopRecording.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stopRecording.d.ts","sourceRoot":"","sources":["../../src/tools/stopRecording.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,eAAO,MAAM,mBAAmB;;;;;;EAE9B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;CAa7B,CAAC;AAEF,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CA+DhF"}
@@ -0,0 +1,76 @@
1
+ import { z } from "zod";
2
+ export const stopRecordingSchema = z.object({
3
+ recordingId: z.string(),
4
+ });
5
+ export const stopRecordingTool = {
6
+ name: "stopRecording",
7
+ description: "Stop a recording and finalize the asciicast file. Returns metadata about the saved recording including the file path and duration.",
8
+ inputSchema: {
9
+ type: "object",
10
+ properties: {
11
+ recordingId: {
12
+ type: "string",
13
+ description: "The recording ID returned by startRecording",
14
+ },
15
+ },
16
+ required: ["recordingId"],
17
+ },
18
+ };
19
+ export async function handleStopRecording(manager, args) {
20
+ const parsed = stopRecordingSchema.parse(args);
21
+ const recordingManager = manager.getRecordingManager();
22
+ const recorder = recordingManager.getRecording(parsed.recordingId);
23
+ if (!recorder) {
24
+ return {
25
+ content: [
26
+ {
27
+ type: "text",
28
+ text: `Error: Recording not found: ${parsed.recordingId}`,
29
+ },
30
+ ],
31
+ isError: true,
32
+ };
33
+ }
34
+ if (!recorder.isActive()) {
35
+ return {
36
+ content: [
37
+ {
38
+ type: "text",
39
+ text: `Error: Recording already finalized: ${parsed.recordingId}`,
40
+ },
41
+ ],
42
+ isError: true,
43
+ };
44
+ }
45
+ // Finalize with exit code 0 (explicit stop means success)
46
+ const metadata = await recordingManager.finalizeRecording(parsed.recordingId, 0, 'explicit');
47
+ if (!metadata) {
48
+ return {
49
+ content: [
50
+ {
51
+ type: "text",
52
+ text: `Error: Failed to finalize recording: ${parsed.recordingId}`,
53
+ },
54
+ ],
55
+ isError: true,
56
+ };
57
+ }
58
+ const result = {
59
+ recordingId: metadata.id,
60
+ path: metadata.path,
61
+ durationMs: metadata.durationMs,
62
+ bytesWritten: metadata.bytesWritten,
63
+ saved: metadata.saved,
64
+ mode: metadata.mode,
65
+ stopReason: metadata.stopReason,
66
+ };
67
+ return {
68
+ content: [
69
+ {
70
+ type: "text",
71
+ text: JSON.stringify(result, null, 2),
72
+ },
73
+ ],
74
+ };
75
+ }
76
+ //# sourceMappingURL=stopRecording.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stopRecording.js","sourceRoot":"","sources":["../../src/tools/stopRecording.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;CACxB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,oIAAoI;IACjJ,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,6CAA6C;aAC3D;SACF;QACD,QAAQ,EAAE,CAAC,aAAa,CAAC;KAC1B;CACF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,OAAwB,EACxB,IAAa;IAEb,MAAM,MAAM,GAAG,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE/C,MAAM,gBAAgB,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IACvD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,YAAY,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAEnE,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,+BAA+B,MAAM,CAAC,WAAW,EAAE;iBAC1D;a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