dev3000 0.0.189 → 0.0.192

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 (183) hide show
  1. package/README.md +101 -12
  2. package/dist/cdp-monitor.d.ts +10 -0
  3. package/dist/cdp-monitor.d.ts.map +1 -1
  4. package/dist/cdp-monitor.js +28 -4
  5. package/dist/cdp-monitor.js.map +1 -1
  6. package/dist/runtime/bridge.d.ts +2 -0
  7. package/dist/runtime/bridge.d.ts.map +1 -1
  8. package/dist/runtime/bridge.js +74 -0
  9. package/dist/runtime/bridge.js.map +1 -1
  10. package/dist/runtime/browser-capture.d.ts +117 -0
  11. package/dist/runtime/browser-capture.d.ts.map +1 -0
  12. package/dist/runtime/browser-capture.js +274 -0
  13. package/dist/runtime/browser-capture.js.map +1 -0
  14. package/dist/runtime/browser-compare.d.ts +91 -0
  15. package/dist/runtime/browser-compare.d.ts.map +1 -0
  16. package/dist/runtime/browser-compare.js +129 -0
  17. package/dist/runtime/browser-compare.js.map +1 -0
  18. package/dist/runtime/browser-events.d.ts +3 -2
  19. package/dist/runtime/browser-events.d.ts.map +1 -1
  20. package/dist/runtime/browser-events.js +11 -53
  21. package/dist/runtime/browser-events.js.map +1 -1
  22. package/dist/runtime/browser-metrics.d.ts +148 -0
  23. package/dist/runtime/browser-metrics.d.ts.map +1 -0
  24. package/dist/runtime/browser-metrics.js +243 -0
  25. package/dist/runtime/browser-metrics.js.map +1 -0
  26. package/dist/runtime/chrome-isolation.d.ts +4 -2
  27. package/dist/runtime/chrome-isolation.d.ts.map +1 -1
  28. package/dist/runtime/chrome-isolation.js +24 -35
  29. package/dist/runtime/chrome-isolation.js.map +1 -1
  30. package/dist/runtime/cli.js +67 -2
  31. package/dist/runtime/cli.js.map +1 -1
  32. package/dist/runtime/desktop-mcp.d.ts +216 -0
  33. package/dist/runtime/desktop-mcp.d.ts.map +1 -0
  34. package/dist/runtime/desktop-mcp.js +258 -0
  35. package/dist/runtime/desktop-mcp.js.map +1 -0
  36. package/dist/runtime/git-identity.d.ts +17 -0
  37. package/dist/runtime/git-identity.d.ts.map +1 -0
  38. package/dist/runtime/git-identity.js +41 -0
  39. package/dist/runtime/git-identity.js.map +1 -0
  40. package/dist/runtime/github-publish.d.ts +31 -0
  41. package/dist/runtime/github-publish.d.ts.map +1 -0
  42. package/dist/runtime/github-publish.js +237 -0
  43. package/dist/runtime/github-publish.js.map +1 -0
  44. package/dist/runtime/harness.d.ts +14 -3
  45. package/dist/runtime/harness.d.ts.map +1 -1
  46. package/dist/runtime/harness.js +55 -7
  47. package/dist/runtime/harness.js.map +1 -1
  48. package/dist/runtime/managed-cdp.d.ts +10 -0
  49. package/dist/runtime/managed-cdp.d.ts.map +1 -0
  50. package/dist/runtime/managed-cdp.js +80 -0
  51. package/dist/runtime/managed-cdp.js.map +1 -0
  52. package/dist/runtime/mcp-stdio.d.ts +17 -0
  53. package/dist/runtime/mcp-stdio.d.ts.map +1 -0
  54. package/dist/runtime/mcp-stdio.js +99 -0
  55. package/dist/runtime/mcp-stdio.js.map +1 -0
  56. package/dist/runtime/network-evidence.d.ts +28 -0
  57. package/dist/runtime/network-evidence.d.ts.map +1 -0
  58. package/dist/runtime/network-evidence.js +291 -0
  59. package/dist/runtime/network-evidence.js.map +1 -0
  60. package/dist/runtime/package-manager.d.ts +13 -0
  61. package/dist/runtime/package-manager.d.ts.map +1 -0
  62. package/dist/runtime/package-manager.js +69 -0
  63. package/dist/runtime/package-manager.js.map +1 -0
  64. package/dist/runtime/runtime.d.ts +7 -0
  65. package/dist/runtime/runtime.d.ts.map +1 -1
  66. package/dist/runtime/runtime.js +54 -30
  67. package/dist/runtime/runtime.js.map +1 -1
  68. package/dist/runtime/sandbox-agent.d.ts +5 -0
  69. package/dist/runtime/sandbox-agent.d.ts.map +1 -1
  70. package/dist/runtime/sandbox-agent.js +32 -0
  71. package/dist/runtime/sandbox-agent.js.map +1 -1
  72. package/dist/runtime/sandbox-cleanup.d.ts +14 -0
  73. package/dist/runtime/sandbox-cleanup.d.ts.map +1 -0
  74. package/dist/runtime/sandbox-cleanup.js +77 -0
  75. package/dist/runtime/sandbox-cleanup.js.map +1 -0
  76. package/dist/runtime/sandbox-command.d.ts +1 -0
  77. package/dist/runtime/sandbox-command.d.ts.map +1 -1
  78. package/dist/runtime/sandbox-command.js +39 -9
  79. package/dist/runtime/sandbox-command.js.map +1 -1
  80. package/dist/runtime/sandbox-context.d.ts +5 -0
  81. package/dist/runtime/sandbox-context.d.ts.map +1 -0
  82. package/dist/runtime/sandbox-context.js +42 -0
  83. package/dist/runtime/sandbox-context.js.map +1 -0
  84. package/dist/runtime/sandbox-fx-resume.d.ts +11 -0
  85. package/dist/runtime/sandbox-fx-resume.d.ts.map +1 -0
  86. package/dist/runtime/sandbox-fx-resume.js +45 -0
  87. package/dist/runtime/sandbox-fx-resume.js.map +1 -0
  88. package/dist/runtime/sandbox-gateway.d.ts +17 -0
  89. package/dist/runtime/sandbox-gateway.d.ts.map +1 -0
  90. package/dist/runtime/sandbox-gateway.js +34 -0
  91. package/dist/runtime/sandbox-gateway.js.map +1 -0
  92. package/dist/runtime/sandbox-git.d.ts +19 -0
  93. package/dist/runtime/sandbox-git.d.ts.map +1 -0
  94. package/dist/runtime/sandbox-git.js +42 -0
  95. package/dist/runtime/sandbox-git.js.map +1 -0
  96. package/dist/runtime/sandbox-github.d.ts +10 -0
  97. package/dist/runtime/sandbox-github.d.ts.map +1 -0
  98. package/dist/runtime/sandbox-github.js +35 -0
  99. package/dist/runtime/sandbox-github.js.map +1 -0
  100. package/dist/runtime/sandbox-local-harness.d.ts +34 -0
  101. package/dist/runtime/sandbox-local-harness.d.ts.map +1 -0
  102. package/dist/runtime/sandbox-local-harness.js +151 -0
  103. package/dist/runtime/sandbox-local-harness.js.map +1 -0
  104. package/dist/runtime/sandbox-ports.d.ts +6 -0
  105. package/dist/runtime/sandbox-ports.d.ts.map +1 -0
  106. package/dist/runtime/sandbox-ports.js +11 -0
  107. package/dist/runtime/sandbox-ports.js.map +1 -0
  108. package/dist/runtime/sandbox-preview.d.ts +14 -0
  109. package/dist/runtime/sandbox-preview.d.ts.map +1 -0
  110. package/dist/runtime/sandbox-preview.js +96 -0
  111. package/dist/runtime/sandbox-preview.js.map +1 -0
  112. package/dist/runtime/sandbox-process.d.ts +11 -0
  113. package/dist/runtime/sandbox-process.d.ts.map +1 -0
  114. package/dist/runtime/sandbox-process.js +77 -0
  115. package/dist/runtime/sandbox-process.js.map +1 -0
  116. package/dist/runtime/sandbox-proxy.d.ts +2 -0
  117. package/dist/runtime/sandbox-proxy.d.ts.map +1 -1
  118. package/dist/runtime/sandbox-proxy.js +75 -20
  119. package/dist/runtime/sandbox-proxy.js.map +1 -1
  120. package/dist/runtime/sandbox-recovery.d.ts +4 -0
  121. package/dist/runtime/sandbox-recovery.d.ts.map +1 -0
  122. package/dist/runtime/sandbox-recovery.js +36 -0
  123. package/dist/runtime/sandbox-recovery.js.map +1 -0
  124. package/dist/runtime/sandbox-sessions.d.ts +8 -1
  125. package/dist/runtime/sandbox-sessions.d.ts.map +1 -1
  126. package/dist/runtime/sandbox-sessions.js +20 -2
  127. package/dist/runtime/sandbox-sessions.js.map +1 -1
  128. package/dist/runtime/sandbox-setup.d.ts +5 -0
  129. package/dist/runtime/sandbox-setup.d.ts.map +1 -0
  130. package/dist/runtime/sandbox-setup.js +62 -0
  131. package/dist/runtime/sandbox-setup.js.map +1 -0
  132. package/dist/runtime/sandbox-shell.d.ts +27 -0
  133. package/dist/runtime/sandbox-shell.d.ts.map +1 -0
  134. package/dist/runtime/sandbox-shell.js +169 -0
  135. package/dist/runtime/sandbox-shell.js.map +1 -0
  136. package/dist/runtime/sandbox-watch.d.ts +11 -0
  137. package/dist/runtime/sandbox-watch.d.ts.map +1 -0
  138. package/dist/runtime/sandbox-watch.js +30 -0
  139. package/dist/runtime/sandbox-watch.js.map +1 -0
  140. package/dist/runtime/sandbox-workspace.d.ts +125 -0
  141. package/dist/runtime/sandbox-workspace.d.ts.map +1 -0
  142. package/dist/runtime/sandbox-workspace.js +205 -0
  143. package/dist/runtime/sandbox-workspace.js.map +1 -0
  144. package/dist/runtime/sandbox.d.ts +21 -2
  145. package/dist/runtime/sandbox.d.ts.map +1 -1
  146. package/dist/runtime/sandbox.js +473 -207
  147. package/dist/runtime/sandbox.js.map +1 -1
  148. package/dist/runtime/session.d.ts +1 -1
  149. package/dist/runtime/session.d.ts.map +1 -1
  150. package/dist/runtime/session.js +3 -3
  151. package/dist/runtime/session.js.map +1 -1
  152. package/dist/runtime/terminal.d.ts +19 -0
  153. package/dist/runtime/terminal.d.ts.map +1 -0
  154. package/dist/runtime/terminal.js +60 -0
  155. package/dist/runtime/terminal.js.map +1 -0
  156. package/dist/runtime/workspace-client.d.ts +2 -0
  157. package/dist/runtime/workspace-client.d.ts.map +1 -0
  158. package/dist/runtime/workspace-client.js +46 -0
  159. package/dist/runtime/workspace-client.js.map +1 -0
  160. package/package.json +2 -1
  161. package/scripts/eve/README.md +341 -0
  162. package/scripts/eve/agent/agent.ts +12 -0
  163. package/scripts/eve/agent/channels/eve.ts +23 -0
  164. package/scripts/eve/agent/instructions.md +53 -0
  165. package/scripts/eve/agent/sandbox.ts +34 -0
  166. package/scripts/eve/build-cache.mjs +18 -0
  167. package/scripts/eve/build-cache.test.mjs +32 -0
  168. package/scripts/eve/client.mjs +229 -0
  169. package/scripts/eve/connection.mjs +89 -0
  170. package/scripts/eve/conversation.mjs +91 -0
  171. package/scripts/eve/conversation.test.mjs +113 -0
  172. package/scripts/eve/fixture-agent.ts +101 -0
  173. package/scripts/eve/images.mjs +84 -0
  174. package/scripts/eve/launch.mjs +277 -0
  175. package/scripts/eve/model-command.mjs +21 -0
  176. package/scripts/eve/reconnect.mjs +22 -0
  177. package/scripts/eve/reconnect.test.mjs +41 -0
  178. package/scripts/eve/settings.mjs +33 -0
  179. package/scripts/eve/supervisor.mjs +41 -0
  180. package/scripts/eve/tui-client.mjs +234 -0
  181. package/scripts/eve/tui-input.mjs +114 -0
  182. package/scripts/eve/verify.mjs +575 -0
  183. package/skills/d3k/SKILL.md +60 -5
@@ -0,0 +1,234 @@
1
+ import { join } from "node:path"
2
+ import { pathToFileURL } from "node:url"
3
+ import { clipboardImage, eveClient, imageAttachment, pendingInteractions } from "./client.mjs"
4
+ import { Images } from "./images.mjs"
5
+ import { ModelSelection } from "./model-command.mjs"
6
+ import { EVE_MODELS } from "./settings.mjs"
7
+ import { ImageInput } from "./tui-input.mjs"
8
+
9
+ // These are pinned Eve internals. Use Eve's actual renderer, not a recreation of
10
+ // its look. Keep the fixed-session transport adapter small and verify on upgrades.
11
+ export async function nativeTui() {
12
+ const root = process.env.D3K_EVE_PACKAGE_ROOT
13
+ if (!root) throw new Error("The Eve launcher must provide its pinned package directory")
14
+ const load = (file) => import(pathToFileURL(join(root, "dist/src/cli/dev/tui", file)).href)
15
+ const [{ TerminalRenderer }, views, { PROMPT_COMMANDS }] = await Promise.all([
16
+ load("terminal-renderer.js"),
17
+ load("conversation-view.js"),
18
+ load("prompt-commands.js")
19
+ ])
20
+ return { TerminalRenderer, ...views, PROMPT_COMMANDS }
21
+ }
22
+
23
+ export async function runTuiClient({
24
+ baseUrl,
25
+ token,
26
+ sessionId,
27
+ signal,
28
+ readClipboard = clipboardImage,
29
+ rendererFactory,
30
+ models = new ModelSelection()
31
+ }) {
32
+ if (signal?.aborted) return
33
+ const { Client, SessionStore } = await eveClient()
34
+ const { TerminalRenderer, conversationView, tuiSessionData, PROMPT_COMMANDS } = await nativeTui()
35
+ const client = new Client({ baseUrl, auth: { bearer: token }, headers: () => models.headers() })
36
+ const session = sessionId ? client.sessions.attach(sessionId) : (await client.sessions.create()).session
37
+ const store = new SessionStore({ client, session, followAgents: true })
38
+ const images = new Images(imageAttachment)
39
+ let renderer
40
+ let closed = false
41
+ let reading
42
+ let failure
43
+ const answered = new Set()
44
+ const pending = () => pendingInteractions(store.snapshot).filter((entry) => !answered.has(entry.interactionId))
45
+ const input = new ImageInput(process.stdin, images, readClipboard, (error) =>
46
+ renderer?.renderError("Image paste", error.message)
47
+ )
48
+ const close = () => {
49
+ closed = true
50
+ reading?.abort()
51
+ renderer?.requestInterrupt()
52
+ }
53
+ const commands = PROMPT_COMMANDS.filter((command) =>
54
+ ["cancel", "compact", "help", "exit", "model"].includes(command.name)
55
+ )
56
+ commands.push({
57
+ name: "detach",
58
+ aliases: [],
59
+ description: "Leave the agent running and return to reconnect",
60
+ takesArgument: false,
61
+ history: "omit",
62
+ build: () => ({ type: "exit" })
63
+ })
64
+ renderer = rendererFactory
65
+ ? rendererFactory({ input, close })
66
+ : new TerminalRenderer({
67
+ input,
68
+ output: process.stdout,
69
+ captureForeignOutput: false,
70
+ tools: "auto-collapsed",
71
+ reasoning: "auto-collapsed",
72
+ availablePromptCommands: commands,
73
+ onExitRequest: close
74
+ })
75
+ renderer.setSessionId(session.id)
76
+ const render = () => {
77
+ if (closed) return
78
+ const snapshot = store.snapshot
79
+ renderer.renderConversation(conversationView(snapshot, tuiSessionData(snapshot)))
80
+ if (snapshot.error && snapshot.error !== failure) {
81
+ failure = snapshot.error
82
+ renderer.renderError("Connection", `${failure.message}. No message was automatically retried.`)
83
+ }
84
+ if (input.mode === "composer" && pending().length) reading?.abort()
85
+ }
86
+ const unsubscribe = store.subscribe(render)
87
+ const release = store.observe()
88
+ const stop = () => {
89
+ close()
90
+ release()
91
+ }
92
+ process.on("SIGTERM", close)
93
+ signal?.addEventListener("abort", stop, { once: true })
94
+ if (signal?.aborted) stop()
95
+ try {
96
+ if (closed) return
97
+ const info = await client
98
+ .info({ signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(5000)]) : AbortSignal.timeout(5000) })
99
+ .catch(() => undefined)
100
+ if (closed) return
101
+ renderer.renderAgentHeader({ name: "eve · d3k", serverUrl: baseUrl, ...(info ? { info } : {}) })
102
+ renderer.renderNotice(`${models.current.label} · /model to change`)
103
+ renderer.renderNotice(
104
+ "Paste an image or image path into the composer. Ctrl+V reads the clipboard. /detach reconnects later in this launch."
105
+ )
106
+ await store.resume()
107
+ render()
108
+ while (!closed && !renderer.exitRequested()) {
109
+ const interaction = pending()[0]
110
+ reading = new AbortController()
111
+ try {
112
+ if (interaction) {
113
+ input.mode = "approval"
114
+ let answer
115
+ if (interaction.request.kind === "approval") {
116
+ const response = await renderer.readToolApproval(
117
+ {
118
+ approvalId: interaction.interactionId,
119
+ toolCallId: interaction.call?.callId || interaction.interactionId,
120
+ toolName: interaction.call?.name || "tool",
121
+ prompt: interaction.request.prompt,
122
+ input: interaction.call?.input
123
+ },
124
+ { signal: reading.signal }
125
+ )
126
+ answer = { interactionId: interaction.interactionId, optionId: response.approved ? "approve" : "deny" }
127
+ } else {
128
+ const response = await renderer.readInputQuestion(
129
+ {
130
+ requestId: interaction.interactionId,
131
+ prompt: interaction.request.prompt,
132
+ display: interaction.request.display === "text" ? "text" : "select",
133
+ options: interaction.request.options,
134
+ allowFreeform: interaction.request.allowFreeform
135
+ },
136
+ { signal: reading.signal }
137
+ )
138
+ if (response) answer = { interactionId: interaction.interactionId, ...response }
139
+ }
140
+ if (answer && !closed) {
141
+ answered.add(interaction.interactionId)
142
+ try {
143
+ await store.send({ answers: [answer], signal })
144
+ } catch (error) {
145
+ answered.delete(interaction.interactionId)
146
+ throw error
147
+ }
148
+ } else if (!closed) answered.add(interaction.interactionId)
149
+ continue
150
+ }
151
+ input.mode = "composer"
152
+ const action = await renderer.readInput({ title: "eve · d3k", signal: reading.signal })
153
+ if (!action || closed) continue
154
+ if (action.type === "cancel") {
155
+ await store.cancel()
156
+ continue
157
+ }
158
+ if (action.type === "interrupt") break
159
+ const text = action.text.trim()
160
+ if (["/detach", "/exit", "/quit"].includes(text)) break
161
+ if (text === "/cancel") {
162
+ await store.cancel()
163
+ continue
164
+ }
165
+ if (text === "/compact") {
166
+ await store.compact()
167
+ continue
168
+ }
169
+ if (text === "/model" || text.startsWith("/model ")) {
170
+ const argument = text.slice(6).trim()
171
+ if (!argument) {
172
+ input.mode = "approval"
173
+ const response = await renderer.readInputQuestion(
174
+ {
175
+ requestId: "d3k-model",
176
+ prompt: `Choose model (current: ${models.current.label})`,
177
+ display: "select",
178
+ options: EVE_MODELS.map((model) => ({ id: model.id, label: model.label })),
179
+ allowFreeform: false
180
+ },
181
+ { signal: reading.signal }
182
+ )
183
+ if (response?.optionId && !closed) renderer.renderNotice(models.select(response.optionId))
184
+ } else
185
+ renderer.renderNotice(
186
+ argument === "current" ? models.describe() : argument === "list" ? models.list() : models.select(argument)
187
+ )
188
+ continue
189
+ }
190
+ if (text === "/help") {
191
+ renderer.renderNotice(
192
+ "Paste image paths normally or press Ctrl+V for a clipboard image. /model, /detach, /cancel, /compact. Approve tools with the keyboard panel."
193
+ )
194
+ continue
195
+ }
196
+ if (text === "/paste") {
197
+ renderer.restoreDraft(images.add(await readClipboard()))
198
+ continue
199
+ }
200
+ if (text.startsWith("/attach ")) {
201
+ renderer.restoreDraft(images.add(await imageAttachment(text.slice(8).trim())))
202
+ continue
203
+ }
204
+ if (!text) continue
205
+ // Fallback for terminals that split an unframed file-path paste across reads.
206
+ const prompt = await images.replacePaths(text)
207
+ if (closed) break
208
+ try {
209
+ await store.send({ message: images.message(prompt), signal })
210
+ images.clear()
211
+ } catch (error) {
212
+ renderer.restoreDraft(prompt)
213
+ throw error
214
+ }
215
+ } catch (error) {
216
+ if (error.name === "InterruptedError") break
217
+ if (!closed && error.name !== "AbortError" && !reading.signal.aborted)
218
+ renderer.renderError("Eve", error.message)
219
+ } finally {
220
+ reading = undefined
221
+ }
222
+ }
223
+ } catch (error) {
224
+ if (!signal?.aborted) throw error
225
+ } finally {
226
+ closed = true
227
+ input.close()
228
+ release()
229
+ unsubscribe()
230
+ process.off("SIGTERM", close)
231
+ signal?.removeEventListener("abort", stop)
232
+ renderer.shutdown()
233
+ }
234
+ }
@@ -0,0 +1,114 @@
1
+ import { EventEmitter } from "node:events"
2
+ import { StringDecoder } from "node:string_decoder"
3
+
4
+ const START = "\x1b[200~"
5
+ const END = "\x1b[201~"
6
+
7
+ /** Preserve terminal editing; intercept only explicit clipboard/paste input. */
8
+ export class ImageInput extends EventEmitter {
9
+ constructor(input, images, readClipboard, onError) {
10
+ super()
11
+ this.input = input
12
+ this.isTTY = input.isTTY
13
+ this.images = images
14
+ this.readClipboard = readClipboard
15
+ this.onError = onError
16
+ this.decoder = new StringDecoder("utf8")
17
+ this.buffer = ""
18
+ this.commands = Promise.resolve()
19
+ this.active = true
20
+ this.mode = "composer"
21
+ this.receive = (chunk) => {
22
+ const text = this.decoder.write(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk))
23
+ this.commands = this.commands.then(() => this.consume(text)).catch((error) => this.onError(error))
24
+ }
25
+ input.on("data", this.receive)
26
+ }
27
+ resume() {
28
+ this.input.resume()
29
+ return this
30
+ }
31
+ pause() {
32
+ this.input.pause()
33
+ return this
34
+ }
35
+ setRawMode(mode) {
36
+ this.input.setRawMode?.(mode)
37
+ return this
38
+ }
39
+ output(text) {
40
+ if (this.active && text) this.emit("data", Buffer.from(text))
41
+ }
42
+ inject(text) {
43
+ this.output(START + text + END)
44
+ }
45
+ async consume(text) {
46
+ if (!this.active) return
47
+ if (this.mode !== "composer") {
48
+ this.output(text)
49
+ return
50
+ }
51
+ clearTimeout(this.prefixTimer)
52
+ this.buffer += text
53
+ while (this.buffer) {
54
+ if (this.buffer.startsWith(START)) {
55
+ const end = this.buffer.indexOf(END, START.length)
56
+ if (end < 0) {
57
+ if (this.buffer.length > 1024 * 1024) {
58
+ this.buffer = ""
59
+ throw new Error("Paste is too large")
60
+ }
61
+ return
62
+ }
63
+ const paste = this.buffer.slice(START.length, end)
64
+ this.buffer = this.buffer.slice(end + END.length)
65
+ this.inject(await this.images.replacePaths(paste))
66
+ continue
67
+ }
68
+ // Hold a split framing prefix briefly, while keeping a lone Escape usable.
69
+ let suffix = 0
70
+ for (let length = 1; length < START.length; length++) {
71
+ if (this.buffer.endsWith(START.slice(0, length))) suffix = length
72
+ }
73
+ if (suffix === this.buffer.length) {
74
+ this.prefixTimer = setTimeout(() => {
75
+ this.commands = this.commands
76
+ .then(() => {
77
+ const remaining = this.buffer
78
+ this.buffer = ""
79
+ this.output(remaining)
80
+ })
81
+ .catch(this.onError)
82
+ }, 50)
83
+ return
84
+ }
85
+ const paste = this.buffer.indexOf(START)
86
+ const clipboard = this.buffer.indexOf("\x16")
87
+ const boundary = Math.min(...[paste, clipboard].filter((index) => index >= 0), this.buffer.length - suffix)
88
+ if (boundary > 0) {
89
+ const raw = this.buffer.slice(0, boundary)
90
+ this.buffer = this.buffer.slice(boundary)
91
+ // Cmd+V and file drags can arrive as an unframed escaped file path.
92
+ const replaced = await this.images.replacePaths(raw)
93
+ if (replaced !== raw) this.output(replaced)
94
+ else this.output(raw)
95
+ continue
96
+ }
97
+ if (clipboard === 0) {
98
+ this.buffer = this.buffer.slice(1)
99
+ try {
100
+ this.inject(this.images.add(await this.readClipboard()))
101
+ } catch (error) {
102
+ this.onError(error)
103
+ }
104
+ continue
105
+ }
106
+ break
107
+ }
108
+ }
109
+ close() {
110
+ clearTimeout(this.prefixTimer)
111
+ this.active = false
112
+ this.input.off("data", this.receive)
113
+ }
114
+ }