pty-auto 0.3.6

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 (143) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +515 -0
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +3 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/src/plugin/constants.d.ts +5 -0
  8. package/dist/src/plugin/constants.d.ts.map +1 -0
  9. package/dist/src/plugin/constants.js +7 -0
  10. package/dist/src/plugin/constants.js.map +1 -0
  11. package/dist/src/plugin/pty/buffer.d.ts +19 -0
  12. package/dist/src/plugin/pty/buffer.d.ts.map +1 -0
  13. package/dist/src/plugin/pty/buffer.js +61 -0
  14. package/dist/src/plugin/pty/buffer.js.map +1 -0
  15. package/dist/src/plugin/pty/formatters.d.ts +4 -0
  16. package/dist/src/plugin/pty/formatters.d.ts.map +1 -0
  17. package/dist/src/plugin/pty/formatters.js +22 -0
  18. package/dist/src/plugin/pty/formatters.js.map +1 -0
  19. package/dist/src/plugin/pty/manager.d.ts +33 -0
  20. package/dist/src/plugin/pty/manager.d.ts.map +1 -0
  21. package/dist/src/plugin/pty/manager.js +108 -0
  22. package/dist/src/plugin/pty/manager.js.map +1 -0
  23. package/dist/src/plugin/pty/notification-manager.d.ts +9 -0
  24. package/dist/src/plugin/pty/notification-manager.d.ts.map +1 -0
  25. package/dist/src/plugin/pty/notification-manager.js +69 -0
  26. package/dist/src/plugin/pty/notification-manager.js.map +1 -0
  27. package/dist/src/plugin/pty/output-manager.d.ts +7 -0
  28. package/dist/src/plugin/pty/output-manager.d.ts.map +1 -0
  29. package/dist/src/plugin/pty/output-manager.js +26 -0
  30. package/dist/src/plugin/pty/output-manager.js.map +1 -0
  31. package/dist/src/plugin/pty/permissions.d.ts +27 -0
  32. package/dist/src/plugin/pty/permissions.d.ts.map +1 -0
  33. package/dist/src/plugin/pty/permissions.js +54 -0
  34. package/dist/src/plugin/pty/permissions.js.map +1 -0
  35. package/dist/src/plugin/pty/session-lifecycle.d.ts +20 -0
  36. package/dist/src/plugin/pty/session-lifecycle.d.ts.map +1 -0
  37. package/dist/src/plugin/pty/session-lifecycle.js +177 -0
  38. package/dist/src/plugin/pty/session-lifecycle.js.map +1 -0
  39. package/dist/src/plugin/pty/tools/kill.d.ts +12 -0
  40. package/dist/src/plugin/pty/tools/kill.d.ts.map +1 -0
  41. package/dist/src/plugin/pty/tools/kill.js +37 -0
  42. package/dist/src/plugin/pty/tools/kill.js.map +1 -0
  43. package/dist/src/plugin/pty/tools/kill.txt +25 -0
  44. package/dist/src/plugin/pty/tools/list.d.ts +6 -0
  45. package/dist/src/plugin/pty/tools/list.d.ts.map +1 -0
  46. package/dist/src/plugin/pty/tools/list.js +22 -0
  47. package/dist/src/plugin/pty/tools/list.js.map +1 -0
  48. package/dist/src/plugin/pty/tools/list.txt +22 -0
  49. package/dist/src/plugin/pty/tools/read.d.ts +18 -0
  50. package/dist/src/plugin/pty/tools/read.d.ts.map +1 -0
  51. package/dist/src/plugin/pty/tools/read.js +165 -0
  52. package/dist/src/plugin/pty/tools/read.js.map +1 -0
  53. package/dist/src/plugin/pty/tools/read.txt +39 -0
  54. package/dist/src/plugin/pty/tools/spawn.d.ts +24 -0
  55. package/dist/src/plugin/pty/tools/spawn.d.ts.map +1 -0
  56. package/dist/src/plugin/pty/tools/spawn.js +75 -0
  57. package/dist/src/plugin/pty/tools/spawn.js.map +1 -0
  58. package/dist/src/plugin/pty/tools/spawn.txt +52 -0
  59. package/dist/src/plugin/pty/tools/write.d.ts +12 -0
  60. package/dist/src/plugin/pty/tools/write.d.ts.map +1 -0
  61. package/dist/src/plugin/pty/tools/write.js +62 -0
  62. package/dist/src/plugin/pty/tools/write.js.map +1 -0
  63. package/dist/src/plugin/pty/tools/write.txt +28 -0
  64. package/dist/src/plugin/pty/types.d.ts +70 -0
  65. package/dist/src/plugin/pty/types.d.ts.map +1 -0
  66. package/dist/src/plugin/pty/types.js +1 -0
  67. package/dist/src/plugin/pty/types.js.map +1 -0
  68. package/dist/src/plugin/pty/utils.d.ts +12 -0
  69. package/dist/src/plugin/pty/utils.d.ts.map +1 -0
  70. package/dist/src/plugin/pty/utils.js +17 -0
  71. package/dist/src/plugin/pty/utils.js.map +1 -0
  72. package/dist/src/plugin/pty/wildcard.d.ts +7 -0
  73. package/dist/src/plugin/pty/wildcard.d.ts.map +1 -0
  74. package/dist/src/plugin/pty/wildcard.js +51 -0
  75. package/dist/src/plugin/pty/wildcard.js.map +1 -0
  76. package/dist/src/plugin/types.d.ts +5 -0
  77. package/dist/src/plugin/types.d.ts.map +1 -0
  78. package/dist/src/plugin/types.js +1 -0
  79. package/dist/src/plugin/types.js.map +1 -0
  80. package/dist/src/plugin.d.ts +3 -0
  81. package/dist/src/plugin.d.ts.map +1 -0
  82. package/dist/src/plugin.js +71 -0
  83. package/dist/src/plugin.js.map +1 -0
  84. package/dist/src/shared/constants.d.ts +5 -0
  85. package/dist/src/shared/constants.d.ts.map +1 -0
  86. package/dist/src/shared/constants.js +7 -0
  87. package/dist/src/shared/constants.js.map +1 -0
  88. package/dist/src/web/server/callback-manager.d.ts +8 -0
  89. package/dist/src/web/server/callback-manager.d.ts.map +1 -0
  90. package/dist/src/web/server/callback-manager.js +23 -0
  91. package/dist/src/web/server/callback-manager.js.map +1 -0
  92. package/dist/src/web/server/handlers/health.d.ts +3 -0
  93. package/dist/src/web/server/handlers/health.d.ts.map +1 -0
  94. package/dist/src/web/server/handlers/health.js +33 -0
  95. package/dist/src/web/server/handlers/health.js.map +1 -0
  96. package/dist/src/web/server/handlers/responses.d.ts +10 -0
  97. package/dist/src/web/server/handlers/responses.d.ts.map +1 -0
  98. package/dist/src/web/server/handlers/responses.js +26 -0
  99. package/dist/src/web/server/handlers/responses.js.map +1 -0
  100. package/dist/src/web/server/handlers/sessions.d.ts +13 -0
  101. package/dist/src/web/server/handlers/sessions.d.ts.map +1 -0
  102. package/dist/src/web/server/handlers/sessions.js +96 -0
  103. package/dist/src/web/server/handlers/sessions.js.map +1 -0
  104. package/dist/src/web/server/handlers/static.d.ts +2 -0
  105. package/dist/src/web/server/handlers/static.d.ts.map +1 -0
  106. package/dist/src/web/server/handlers/static.js +38 -0
  107. package/dist/src/web/server/handlers/static.js.map +1 -0
  108. package/dist/src/web/server/handlers/upgrade.d.ts +2 -0
  109. package/dist/src/web/server/handlers/upgrade.d.ts.map +1 -0
  110. package/dist/src/web/server/handlers/upgrade.js +11 -0
  111. package/dist/src/web/server/handlers/upgrade.js.map +1 -0
  112. package/dist/src/web/server/handlers/websocket.d.ts +3 -0
  113. package/dist/src/web/server/handlers/websocket.d.ts.map +1 -0
  114. package/dist/src/web/server/handlers/websocket.js +119 -0
  115. package/dist/src/web/server/handlers/websocket.js.map +1 -0
  116. package/dist/src/web/server/server.d.ts +12 -0
  117. package/dist/src/web/server/server.d.ts.map +1 -0
  118. package/dist/src/web/server/server.js +73 -0
  119. package/dist/src/web/server/server.js.map +1 -0
  120. package/dist/src/web/shared/api-client.d.ts +132 -0
  121. package/dist/src/web/shared/api-client.d.ts.map +1 -0
  122. package/dist/src/web/shared/api-client.js +79 -0
  123. package/dist/src/web/shared/api-client.js.map +1 -0
  124. package/dist/src/web/shared/constants.d.ts +11 -0
  125. package/dist/src/web/shared/constants.d.ts.map +1 -0
  126. package/dist/src/web/shared/constants.js +23 -0
  127. package/dist/src/web/shared/constants.js.map +1 -0
  128. package/dist/src/web/shared/route-builder.d.ts +30 -0
  129. package/dist/src/web/shared/route-builder.d.ts.map +1 -0
  130. package/dist/src/web/shared/route-builder.js +42 -0
  131. package/dist/src/web/shared/route-builder.js.map +1 -0
  132. package/dist/src/web/shared/routes.d.ts +37 -0
  133. package/dist/src/web/shared/routes.d.ts.map +1 -0
  134. package/dist/src/web/shared/routes.js +39 -0
  135. package/dist/src/web/shared/routes.js.map +1 -0
  136. package/dist/src/web/shared/types.d.ts +87 -0
  137. package/dist/src/web/shared/types.d.ts.map +1 -0
  138. package/dist/src/web/shared/types.js +15 -0
  139. package/dist/src/web/shared/types.js.map +1 -0
  140. package/dist/web/assets/index-CYWtqpTG.js +24 -0
  141. package/dist/web/assets/index-DDGTF8rc.css +1 -0
  142. package/dist/web/index.html +204 -0
  143. package/package.json +107 -0
@@ -0,0 +1,28 @@
1
+ Sends input data to an active PTY session.
2
+
3
+ Use this tool to:
4
+ - Type commands or text into an interactive terminal
5
+ - Send special key sequences (Ctrl+C, Enter, arrow keys, etc.)
6
+ - Respond to prompts in interactive programs
7
+
8
+ Usage:
9
+ - `id`: The PTY session ID (from pty_spawn or pty_list)
10
+ - `data`: The input to send (text, commands, or escape sequences)
11
+
12
+ Common escape sequences:
13
+ - Enter/newline: "\n" or "\r"
14
+ - Ctrl+C (interrupt): "\x03"
15
+ - Ctrl+D (EOF): "\x04"
16
+ - Ctrl+Z (suspend): "\x1a"
17
+ - Tab: "\t"
18
+ - Arrow Up: "\x1b[A"
19
+ - Arrow Down: "\x1b[B"
20
+ - Arrow Right: "\x1b[C"
21
+ - Arrow Left: "\x1b[D"
22
+
23
+ Returns success or error message.
24
+
25
+ Examples:
26
+ - Send a command: data="ls -la\n"
27
+ - Interrupt a process: data="\x03"
28
+ - Answer a prompt: data="yes\n"
@@ -0,0 +1,70 @@
1
+ import type { IPty } from 'bun-pty';
2
+ import type { RingBuffer } from './buffer.ts';
3
+ export type PTYStatus = 'running' | 'exited' | 'killing' | 'killed';
4
+ export interface PTYSession {
5
+ id: string;
6
+ title: string;
7
+ description?: string;
8
+ command: string;
9
+ args: string[];
10
+ workdir: string;
11
+ env?: Record<string, string>;
12
+ status: PTYStatus;
13
+ exitCode?: number;
14
+ exitSignal?: number | string;
15
+ pid: number;
16
+ createdAt: Date;
17
+ parentSessionId: string;
18
+ parentAgent?: string;
19
+ notifyOnExit: boolean;
20
+ timeoutSeconds: number;
21
+ timedOut: boolean;
22
+ buffer: RingBuffer;
23
+ process: IPty | null;
24
+ }
25
+ export interface PTYSessionInfo {
26
+ id: string;
27
+ title: string;
28
+ description?: string;
29
+ command: string;
30
+ args: string[];
31
+ workdir: string;
32
+ status: PTYStatus;
33
+ notifyOnExit: boolean;
34
+ timeoutSeconds: number;
35
+ timedOut: boolean;
36
+ exitCode?: number;
37
+ exitSignal?: number | string;
38
+ pid: number;
39
+ createdAt: string;
40
+ lineCount: number;
41
+ }
42
+ export interface SpawnOptions {
43
+ command: string;
44
+ args?: string[];
45
+ workdir?: string;
46
+ env?: Record<string, string>;
47
+ title?: string;
48
+ description?: string;
49
+ parentSessionId: string;
50
+ parentAgent?: string;
51
+ notifyOnExit?: boolean;
52
+ timeoutSeconds: number;
53
+ }
54
+ export interface ReadResult {
55
+ lines: string[];
56
+ totalLines: number;
57
+ offset: number;
58
+ hasMore: boolean;
59
+ }
60
+ export interface SearchResult {
61
+ matches: Array<{
62
+ lineNumber: number;
63
+ text: string;
64
+ }>;
65
+ totalMatches: number;
66
+ totalLines: number;
67
+ offset: number;
68
+ hasMore: boolean;
69
+ }
70
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/plugin/pty/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAA;AAEnE,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5B,MAAM,E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,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACpD,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;CACjB"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/plugin/pty/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ export declare function buildSessionNotFoundError(id: string): Error;
2
+ /**
3
+ * Helper to DRY up session-get/null-check logic
4
+ * - manager: object with a getSession(id) or similar method
5
+ * - id: session id
6
+ * - fn: function called with session if found
7
+ * - defaultValue: what to return if not found (default null)
8
+ */
9
+ export declare function withSession<TSession, TResult>(manager: {
10
+ getSession(id: string): TSession | null;
11
+ }, id: string, fn: (session: TSession) => TResult, defaultValue: TResult): TResult;
12
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/plugin/pty/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,yBAAyB,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK,CAE3D;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,OAAO,EAC3C,OAAO,EAAE;IAAE,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAAA;CAAE,EACpD,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,OAAO,EAClC,YAAY,EAAE,OAAO,GACpB,OAAO,CAIT"}
@@ -0,0 +1,17 @@
1
+ export function buildSessionNotFoundError(id) {
2
+ return new Error(`PTY session '${id}' not found. Use pty_list to see active sessions.`);
3
+ }
4
+ /**
5
+ * Helper to DRY up session-get/null-check logic
6
+ * - manager: object with a getSession(id) or similar method
7
+ * - id: session id
8
+ * - fn: function called with session if found
9
+ * - defaultValue: what to return if not found (default null)
10
+ */
11
+ export function withSession(manager, id, fn, defaultValue) {
12
+ const session = manager.getSession(id);
13
+ if (!session)
14
+ return defaultValue;
15
+ return fn(session);
16
+ }
17
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/plugin/pty/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,yBAAyB,CAAC,EAAU;IAClD,OAAO,IAAI,KAAK,CAAC,gBAAgB,EAAE,mDAAmD,CAAC,CAAA;AACzF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CACzB,OAAoD,EACpD,EAAU,EACV,EAAkC,EAClC,YAAqB;IAErB,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;IACtC,IAAI,CAAC,OAAO;QAAE,OAAO,YAAY,CAAA;IACjC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAA;AACpB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare function match(str: string, pattern: string): boolean;
2
+ export declare function all(input: string, patterns: Record<string, string>): string | undefined;
3
+ export declare function allStructured(input: {
4
+ head: string;
5
+ tail: string[];
6
+ }, patterns: Record<string, string>): string | undefined;
7
+ //# sourceMappingURL=wildcard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wildcard.d.ts","sourceRoot":"","sources":["../../../../src/plugin/pty/wildcard.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAW3D;AAED,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,CAWvF;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,EACvC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,MAAM,GAAG,SAAS,CAcpB"}
@@ -0,0 +1,51 @@
1
+ export function match(str, pattern) {
2
+ const regex = new RegExp('^' +
3
+ pattern
4
+ .replace(/[.+^${}()|[\]\\]/g, '\\$&')
5
+ .replace(/\*/g, '.*')
6
+ .replace(/\?/g, '.') +
7
+ '$', 's');
8
+ return regex.test(str);
9
+ }
10
+ export function all(input, patterns) {
11
+ const sorted = Object.entries(patterns).sort((a, b) => a[0].length - b[0].length || a[0].localeCompare(b[0]));
12
+ let result;
13
+ for (const [pattern, value] of sorted) {
14
+ if (match(input, pattern)) {
15
+ result = value;
16
+ }
17
+ }
18
+ return result;
19
+ }
20
+ export function allStructured(input, patterns) {
21
+ const sorted = Object.entries(patterns).sort((a, b) => a[0].length - b[0].length || a[0].localeCompare(b[0]));
22
+ let result;
23
+ for (const [pattern, value] of sorted) {
24
+ const parts = pattern.split(/\s+/);
25
+ const firstPart = parts[0];
26
+ if (!firstPart || !match(input.head, firstPart))
27
+ continue;
28
+ if (parts.length === 1 || matchSequence(input.tail, parts.slice(1))) {
29
+ result = value;
30
+ }
31
+ }
32
+ return result;
33
+ }
34
+ function matchSequence(items, patterns) {
35
+ if (patterns.length === 0)
36
+ return true;
37
+ const [pattern, ...rest] = patterns;
38
+ if (pattern === '*')
39
+ return matchSequence(items, rest);
40
+ for (let i = 0; i < items.length; i++) {
41
+ const item = items[i];
42
+ if (item !== undefined &&
43
+ pattern !== undefined &&
44
+ match(item, pattern) &&
45
+ matchSequence(items.slice(i + 1), rest)) {
46
+ return true;
47
+ }
48
+ }
49
+ return false;
50
+ }
51
+ //# sourceMappingURL=wildcard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wildcard.js","sourceRoot":"","sources":["../../../../src/plugin/pty/wildcard.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,KAAK,CAAC,GAAW,EAAE,OAAe;IAChD,MAAM,KAAK,GAAG,IAAI,MAAM,CACtB,GAAG;QACD,OAAO;aACJ,OAAO,CAAC,mBAAmB,EAAE,MAAM,CAAC;aACpC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC;aACpB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;QACtB,GAAG,EACL,GAAG,CACJ,CAAA;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACxB,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,QAAgC;IACjE,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAC1C,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAChE,CAAA;IACD,IAAI,MAA0B,CAAA;IAC9B,KAAK,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,MAAM,EAAE,CAAC;QACtC,IAAI,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC;YAC1B,MAAM,GAAG,KAAK,CAAA;QAChB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;A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E,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QACrB,IACE,IAAI,KAAK,SAAS;YAClB,OAAO,KAAK,SAAS;YACrB,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC;YACpB,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,EACvC,CAAC;YACD,OAAO,IAAI,CAAA;QACb,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { Plugin } from '@opencode-ai/plugin';
2
+ export type PluginClient = Parameters<Plugin>[0]['client'];
3
+ export type PluginContext = Parameters<Plugin>[0];
4
+ export type PluginResult = Awaited<ReturnType<Plugin>>;
5
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugin/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAEjD,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;AAE1D,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AAEjD,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plugin/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import type { PluginContext, PluginResult } from './plugin/types.ts';
2
+ export declare const PTYPlugin: ({ client, directory }: PluginContext) => Promise<PluginResult>;
3
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAcpE,eAAO,MAAM,SAAS,GAAU,uBAAuB,aAAa,KAAG,OAAO,CAAC,YAAY,CA0D1F,CAAA"}
@@ -0,0 +1,71 @@
1
+ import { initManager, manager } from "./plugin/pty/manager.js";
2
+ import { initPermissions } from "./plugin/pty/permissions.js";
3
+ import { ptySpawn } from "./plugin/pty/tools/spawn.js";
4
+ import { ptyWrite } from "./plugin/pty/tools/write.js";
5
+ import { ptyRead } from "./plugin/pty/tools/read.js";
6
+ import { ptyList } from "./plugin/pty/tools/list.js";
7
+ import { ptyKill } from "./plugin/pty/tools/kill.js";
8
+ import { PTYServer } from "./web/server/server.js";
9
+ import open from 'open';
10
+ const ptyOpenClientCommand = 'pty-open-background-spy';
11
+ const ptyShowServerUrlCommand = 'pty-show-server-url';
12
+ export const PTYPlugin = async ({ client, directory }) => {
13
+ initPermissions(client, directory);
14
+ initManager(client);
15
+ let ptyServer;
16
+ return {
17
+ 'command.execute.before': async (input) => {
18
+ if (input.command !== ptyOpenClientCommand && input.command !== ptyShowServerUrlCommand) {
19
+ return;
20
+ }
21
+ if (ptyServer === undefined) {
22
+ ptyServer = await PTYServer.createServer();
23
+ }
24
+ if (input.command === ptyOpenClientCommand) {
25
+ open(ptyServer.server.url.origin);
26
+ }
27
+ else if (input.command === ptyShowServerUrlCommand) {
28
+ const message = `PTY Sessions Web Interface URL: ${ptyServer.server.url.origin}`;
29
+ await client.session.prompt({
30
+ path: { id: input.sessionID },
31
+ body: {
32
+ noReply: true,
33
+ parts: [
34
+ {
35
+ type: 'text',
36
+ text: message,
37
+ },
38
+ ],
39
+ },
40
+ });
41
+ }
42
+ throw new Error('Command handled by PTY plugin');
43
+ },
44
+ tool: {
45
+ pty_spawn: ptySpawn,
46
+ pty_write: ptyWrite,
47
+ pty_read: ptyRead,
48
+ pty_list: ptyList,
49
+ pty_kill: ptyKill,
50
+ },
51
+ config: async (input) => {
52
+ if (!input.command) {
53
+ input.command = {};
54
+ }
55
+ input.command[ptyOpenClientCommand] = {
56
+ template: `This command will start the PTY Sessions Web Interface in your default browser.`,
57
+ description: 'Open PTY Sessions Web Interface',
58
+ };
59
+ input.command[ptyShowServerUrlCommand] = {
60
+ template: `This command will show the PTY Sessions Web Interface URL.`,
61
+ description: 'Show PTY Sessions Web Interface URL',
62
+ };
63
+ },
64
+ event: async ({ event }) => {
65
+ if (event.type === 'session.deleted') {
66
+ manager.cleanupBySession(event.properties.info.id);
67
+ }
68
+ },
69
+ };
70
+ };
71
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,MAAM,oBAAoB,GAAG,yBAAyB,CAAA;AACtD,MAAM,uBAAuB,GAAG,qBAAqB,CAAA;AAErD,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,EAAE,MAAM,EAAE,SAAS,EAAiB,EAAyB,EAAE;IAC7F,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAClC,WAAW,CAAC,MAAM,CA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AAE,CAAA;YACpB,CAAC;YACD,KAAK,CAAC,OAAO,CAAC,oBAAoB,CAAC,GAAG;gBACpC,QAAQ,EAAE,iFAAiF;gBAC3F,WAAW,EAAE,iCAAiC;aAC/C,CAAA;YACD,KAAK,CAAC,OAAO,CAAC,uBAAuB,CAAC,GAAG;gBACvC,QAAQ,EAAE,4DAA4D;gBACtE,WAAW,EAAE,qCAAqC;aACnD,CAAA;QACH,CAAC;QACD,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;YACzB,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;gBACrC,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACpD,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ export declare const DEFAULT_READ_LIMIT = 500;
2
+ export declare const MAX_LINE_LENGTH = 2000;
3
+ export declare const DEFAULT_MAX_BUFFER_LINES = 50000;
4
+ export declare const PERFORMANCE_MEASURE_LIMIT = 100;
5
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/shared/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,kBAAkB,MAAM,CAAA;AACrC,eAAO,MAAM,eAAe,OAAO,CAAA;AACnC,eAAO,MAAM,wBAAwB,QAAQ,CAAA;AAG7C,eAAO,MAAM,yBAAyB,MAAM,CAAA"}
@@ -0,0 +1,7 @@
1
+ // Shared constants used across the entire application
2
+ export const DEFAULT_READ_LIMIT = 500;
3
+ export const MAX_LINE_LENGTH = 2000;
4
+ export const DEFAULT_MAX_BUFFER_LINES = 50000;
5
+ // Performance monitoring constants
6
+ export const PERFORMANCE_MEASURE_LIMIT = 100;
7
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/shared/constants.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAA;AACrC,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAA;AACnC,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAA;AAE7C,mCAAmC;AACnC,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,CAAA"}
@@ -0,0 +1,8 @@
1
+ export declare class CallbackManager implements Disposable {
2
+ private server;
3
+ constructor(server: Bun.Server<undefined>);
4
+ private sessionUpdateCallback;
5
+ private rawOutputCallback;
6
+ [Symbol.dispose](): void;
7
+ }
8
+ //# sourceMappingURL=callback-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callback-manager.d.ts","sourceRoot":"","sources":["../../../../src/web/server/callback-manager.ts"],"names":[],"mappings":"AASA,qBAAa,eAAgB,YAAW,UAAU;IACpC,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC;IAMjD,OAAO,CAAC,qBAAqB,CAG5B;IAED,OAAO,CAAC,iBAAiB,CAGvB;IAEF,CAAC,MAAM,CAAC,OAAO,CAAC;CAIjB"}
@@ -0,0 +1,23 @@
1
+ import { registerRawOutputCallback, registerSessionUpdateCallback, removeRawOutputCallback, removeSessionUpdateCallback, } from '../../plugin/pty/manager';
2
+ export class CallbackManager {
3
+ server;
4
+ constructor(server) {
5
+ this.server = server;
6
+ this.server = server;
7
+ registerSessionUpdateCallback(this.sessionUpdateCallback);
8
+ registerRawOutputCallback(this.rawOutputCallback);
9
+ }
10
+ sessionUpdateCallback = (session) => {
11
+ const message = { type: 'session_update', session };
12
+ this.server.publish('sessions:update', JSON.stringify(message));
13
+ };
14
+ rawOutputCallback = (session, rawData) => {
15
+ const message = { type: 'raw_data', session, rawData };
16
+ this.server.publish(`session:${session.id}`, JSON.stringify(message));
17
+ };
18
+ [Symbol.dispose]() {
19
+ removeSessionUpdateCallback(this.sessionUpdateCallback);
20
+ removeRawOutputCallback(this.rawOutputCallback);
21
+ }
22
+ }
23
+ //# sourceMappingURL=callback-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callback-manager.js","sourceRoot":"","sources":["../../../../src/web/server/callback-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,6BAA6B,EAC7B,uBAAuB,EACvB,2BAA2B,GAC5B,MAAM,0BAA0B,CAAA;AAIjC,MAAM,OAAO,eAAe;IACN;IAApB,YAAoB,MAA6B;QAA7B,WAAM,GAAN,MAAM,CAAuB;QAC/C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,6BAA6B,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;QACzD,yBAAyB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;IACnD,CAAC;IAEO,qBAAqB,GAAG,CAAC,OAAuB,EAAQ,EAAE;QAChE,MAAM,OAAO,GAAiC,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAA;QACjF,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IACjE,CAAC,CAAA;IAEO,iBAAiB,GAAG,CAAC,OAAuB,EAAE,OAAe,EAAQ,EAAE;QAC7E,MAAM,OAAO,GAA2B,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,CAAA;QAC9E,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,OAAO,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IACvE,CAAC,CAAC;IAEF,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,2BAA2B,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;QACvD,uBAAuB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;IACjD,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ import { JsonResponse } from './responses.ts';
2
+ export declare function handleHealth(server: Bun.Server<undefined>): JsonResponse;
3
+ //# sourceMappingURL=health.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../../../../src/web/server/handlers/health.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAG7C,wBAAgB,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,gBAiCzD"}
@@ -0,0 +1,33 @@
1
+ import { manager } from "../../../plugin/pty/manager.js";
2
+ import { JsonResponse } from "./responses.js";
3
+ export function handleHealth(server) {
4
+ const sessions = manager.list();
5
+ const activeSessions = sessions.filter((s) => s.status === 'running').length;
6
+ const totalSessions = sessions.length;
7
+ // Calculate response time (rough approximation)
8
+ const startTime = Date.now();
9
+ const healthResponse = {
10
+ status: 'healthy',
11
+ timestamp: new Date().toISOString(),
12
+ uptime: process.uptime(),
13
+ sessions: {
14
+ total: totalSessions,
15
+ active: activeSessions,
16
+ },
17
+ websocket: {
18
+ connections: server.pendingWebSockets,
19
+ },
20
+ memory: process.memoryUsage
21
+ ? {
22
+ rss: process.memoryUsage().rss,
23
+ heapUsed: process.memoryUsage().heapUsed,
24
+ heapTotal: process.memoryUsage().heapTotal,
25
+ }
26
+ : undefined,
27
+ };
28
+ // Add response time
29
+ const responseTime = Date.now() - startTime;
30
+ healthResponse.responseTime = responseTime;
31
+ return new JsonResponse(healthResponse);
32
+ }
33
+ //# sourceMappingURL=health.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.js","sourceRoot":"","sources":["../../../../../src/web/server/handlers/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAG7C,MAAM,UAAU,YAAY,CAAC,MAA6B;IACxD,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,EAAE,CAAA;IAC/B,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,MAAM,CAAA;IAC5E,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAA;IAErC,gDAAgD;IAChD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;IAE5B,MAAM,cAAc,GAAmB;QACrC,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE;QACxB,QAAQ,EAAE;YACR,KAAK,EAAE,aAAa;YACpB,MAAM,EAAE,cAAc;SACvB;QACD,SAAS,EAAE;YACT,WAAW,EAAE,MAAM,CAAC,iBAAiB;SACtC;QACD,MAAM,EAAE,OAAO,CAAC,WAAW;YACzB,CAAC,CAAC;gBACE,GAAG,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,GAAG;gBAC9B,QAAQ,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ;gBACxC,SAAS,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,SAAS;aAC3C;YACH,CAAC,CAAC,SAAS;KACd,CAAA;IAED,oBAAoB;IACpB,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAA;IAC3C,cAAc,CAAC,YAAY,GAAG,YAAY,CAAA;IAE1C,OAAO,IAAI,YAAY,CAAC,cAAc,CAAC,CAAA;AACzC,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Response helper classes for consistent JSON responses
3
+ */
4
+ export declare class JsonResponse extends Response {
5
+ constructor(data: unknown, status?: number, headers?: Record<string, string>);
6
+ }
7
+ export declare class ErrorResponse extends Response {
8
+ constructor(message: string, status?: number, headers?: Record<string, string>);
9
+ }
10
+ //# sourceMappingURL=responses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../../../../src/web/server/handlers/responses.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAa,YAAa,SAAQ,QAAQ;gBAC5B,IAAI,EAAE,OAAO,EAAE,MAAM,SAAM,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;CAS9E;AAED,qBAAa,aAAc,SAAQ,QAAQ;gBAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAM,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;CAShF"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Response helper classes for consistent JSON responses
3
+ */
4
+ export class JsonResponse extends Response {
5
+ constructor(data, status = 200, headers = {}) {
6
+ super(JSON.stringify(data), {
7
+ status,
8
+ headers: {
9
+ 'Content-Type': 'application/json',
10
+ ...headers,
11
+ },
12
+ });
13
+ }
14
+ }
15
+ export class ErrorResponse extends Response {
16
+ constructor(message, status = 500, headers = {}) {
17
+ super(JSON.stringify({ error: message }), {
18
+ status,
19
+ headers: {
20
+ 'Content-Type': 'application/json',
21
+ ...headers,
22
+ },
23
+ });
24
+ }
25
+ }
26
+ //# sourceMappingURL=responses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responses.js","sourceRoot":"","sources":["../../../../../src/web/server/handlers/responses.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,OAAO,YAAa,SAAQ,QAAQ;IACxC,YAAY,IAAa,EAAE,MAAM,GAAG,GAAG,EAAE,UAAkC,EAAE;QAC3E,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;YAC1B,MAAM;YACN,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,GAAG,OAAO;aACX;SACF,CAAC,CAAA;IACJ,CAAC;CACF;AAED,MAAM,OAAO,aAAc,SAAQ,QAAQ;IACzC,YAAY,OAAe,EAAE,MAAM,GAAG,GAAG,EAAE,UAAkC,EAAE;QAC7E,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE;YACxC,MAAM;YACN,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,GAAG,OAAO;aACX;SACF,CAAC,CAAA;IACJ,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ import type { BunRequest } from 'bun';
2
+ import { JsonResponse, ErrorResponse } from './responses.ts';
3
+ import type { routes } from '../../shared/routes.ts';
4
+ export declare function getSessions(): JsonResponse;
5
+ export declare function createSession(req: Request): Promise<JsonResponse | ErrorResponse>;
6
+ export declare function clearSessions(): JsonResponse;
7
+ export declare function getSession(req: BunRequest<typeof routes.session.path>): JsonResponse | ErrorResponse;
8
+ export declare function sendInput(req: BunRequest<typeof routes.session.input.path>): Promise<Response>;
9
+ export declare function cleanupSession(req: BunRequest<typeof routes.session.cleanup.path>): JsonResponse | ErrorResponse;
10
+ export declare function killSession(req: BunRequest<typeof routes.session.path>): JsonResponse | ErrorResponse;
11
+ export declare function getRawBuffer(req: BunRequest<typeof routes.session.buffer.raw.path>): JsonResponse | ErrorResponse;
12
+ export declare function getPlainBuffer(req: BunRequest<typeof routes.session.buffer.plain.path>): JsonResponse | ErrorResponse;
13
+ //# sourceMappingURL=sessions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../../../../src/web/server/handlers/sessions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AACrC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD,wBAAgB,WAAW,iBAG1B;AAED,wBAAsB,aAAa,CAAC,GAAG,EAAE,OAAO,yCAwC/C;AAED,wBAAgB,aAAa,iBAG5B;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,gCAMrE;AAED,wBAAsB,SAAS,CAC7B,GAAG,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,GAChD,OAAO,CAAC,QAAQ,CAAC,CAcnB;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,gCAMjF;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,gCAMtE;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,gCAOlF;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,gCAWtF"}
@@ -0,0 +1,96 @@
1
+ import { manager } from "../../../plugin/pty/manager.js";
2
+ import { JsonResponse, ErrorResponse } from "./responses.js";
3
+ export function getSessions() {
4
+ const sessions = manager.list();
5
+ return new JsonResponse(sessions);
6
+ }
7
+ export async function createSession(req) {
8
+ let body;
9
+ try {
10
+ body = (await req.json());
11
+ }
12
+ catch {
13
+ return new ErrorResponse('Invalid JSON in request body', 400);
14
+ }
15
+ if (!body.command || typeof body.command !== 'string' || body.command.trim() === '') {
16
+ return new ErrorResponse('Command is required', 400);
17
+ }
18
+ if (!Number.isInteger(body.timeoutSeconds) || body.timeoutSeconds <= 0) {
19
+ return new ErrorResponse('timeoutSeconds must be a positive integer in seconds', 400);
20
+ }
21
+ try {
22
+ const session = manager.spawn({
23
+ command: body.command,
24
+ args: body.args || [],
25
+ title: body.description,
26
+ description: body.description,
27
+ workdir: body.workdir,
28
+ timeoutSeconds: body.timeoutSeconds,
29
+ parentSessionId: 'web-api',
30
+ });
31
+ return new JsonResponse(session);
32
+ }
33
+ catch (error) {
34
+ return new ErrorResponse(error instanceof Error ? error.message : 'Failed to create session', 400);
35
+ }
36
+ }
37
+ export function clearSessions() {
38
+ manager.clearAllSessions();
39
+ return new JsonResponse({ success: true });
40
+ }
41
+ export function getSession(req) {
42
+ const session = manager.get(req.params.id);
43
+ if (!session) {
44
+ return new ErrorResponse('Session not found', 404);
45
+ }
46
+ return new JsonResponse(session);
47
+ }
48
+ export async function sendInput(req) {
49
+ try {
50
+ const body = (await req.json());
51
+ if (!body.data || typeof body.data !== 'string') {
52
+ return new ErrorResponse('Data field is required and must be a string', 400);
53
+ }
54
+ const success = manager.write(req.params.id, body.data);
55
+ if (!success) {
56
+ return new ErrorResponse('Failed to write to session', 400);
57
+ }
58
+ return new JsonResponse({ success: true });
59
+ }
60
+ catch {
61
+ return new ErrorResponse('Invalid JSON in request body', 400);
62
+ }
63
+ }
64
+ export function cleanupSession(req) {
65
+ const success = manager.kill(req.params.id, true);
66
+ if (!success) {
67
+ return new ErrorResponse('Failed to kill session', 400);
68
+ }
69
+ return new JsonResponse({ success: true });
70
+ }
71
+ export function killSession(req) {
72
+ const success = manager.kill(req.params.id);
73
+ if (!success) {
74
+ return new ErrorResponse('Failed to kill session', 400);
75
+ }
76
+ return new JsonResponse({ success: true });
77
+ }
78
+ export function getRawBuffer(req) {
79
+ const bufferData = manager.getRawBuffer(req.params.id);
80
+ if (!bufferData) {
81
+ return new ErrorResponse('Session not found', 404);
82
+ }
83
+ return new JsonResponse(bufferData);
84
+ }
85
+ export function getPlainBuffer(req) {
86
+ const bufferData = manager.getRawBuffer(req.params.id);
87
+ if (!bufferData) {
88
+ return new ErrorResponse('Session not found', 404);
89
+ }
90
+ const plainText = Bun.stripANSI(bufferData.raw);
91
+ return new JsonResponse({
92
+ plain: plainText,
93
+ byteLength: new TextEncoder().encode(plainText).length,
94
+ });
95
+ }
96
+ //# sourceMappingURL=sessions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../../../../src/web/server/handlers/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AAExD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAG5D,MAAM,UAAU,WAAW;IACzB,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,EAAE,CAAA;IAC/B,OAAO,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAA;AACnC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,GAAY;IAC9C,IAAI,IAMH,CAAA;IAED,IAAI,CAAC;QACH,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAgB,CAAA;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,aAAa,CAAC,8BAA8B,EAAE,GAAG,CAAC,CAAA;IAC/D,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACpF,OAAO,IAAI,aAAa,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAA;IACtD,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,cAAc,IAAI,CAAC,EAAE,CAAC;QACvE,OAAO,IAAI,aAAa,CAAC,sDAAsD,EAAE,GAAG,CAAC,CAAA;IACvF,CAAC;IAED,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC;YAC5B,OAAO,EAAE,IAAI,CAAC,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AC;QAChB,OAAO,IAAI,aAAa,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAA;IACpD,CAAC;IAED,OAAO,IAAI,YAAY,CAAC,UAAU,CAAC,CAAA;AACrC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAwD;IACrF,MAAM,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IACtD,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,IAAI,aAAa,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAA;IACpD,CAAC;IAED,MAAM,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IAC/C,OAAO,IAAI,YAAY,CAAC;QACtB,KAAK,EAAE,SAAS;QAChB,UAAU,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM;KACvD,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function buildStaticRoutes(): Promise<Record<string, Response>>;
2
+ //# sourceMappingURL=static.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../../../../../src/web/server/handlers/static.ts"],"names":[],"mappings":"AAkBA,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAsB3E"}