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.
- package/README.md +101 -12
- package/dist/cdp-monitor.d.ts +10 -0
- package/dist/cdp-monitor.d.ts.map +1 -1
- package/dist/cdp-monitor.js +28 -4
- package/dist/cdp-monitor.js.map +1 -1
- package/dist/runtime/bridge.d.ts +2 -0
- package/dist/runtime/bridge.d.ts.map +1 -1
- package/dist/runtime/bridge.js +74 -0
- package/dist/runtime/bridge.js.map +1 -1
- package/dist/runtime/browser-capture.d.ts +117 -0
- package/dist/runtime/browser-capture.d.ts.map +1 -0
- package/dist/runtime/browser-capture.js +274 -0
- package/dist/runtime/browser-capture.js.map +1 -0
- package/dist/runtime/browser-compare.d.ts +91 -0
- package/dist/runtime/browser-compare.d.ts.map +1 -0
- package/dist/runtime/browser-compare.js +129 -0
- package/dist/runtime/browser-compare.js.map +1 -0
- package/dist/runtime/browser-events.d.ts +3 -2
- package/dist/runtime/browser-events.d.ts.map +1 -1
- package/dist/runtime/browser-events.js +11 -53
- package/dist/runtime/browser-events.js.map +1 -1
- package/dist/runtime/browser-metrics.d.ts +148 -0
- package/dist/runtime/browser-metrics.d.ts.map +1 -0
- package/dist/runtime/browser-metrics.js +243 -0
- package/dist/runtime/browser-metrics.js.map +1 -0
- package/dist/runtime/chrome-isolation.d.ts +4 -2
- package/dist/runtime/chrome-isolation.d.ts.map +1 -1
- package/dist/runtime/chrome-isolation.js +24 -35
- package/dist/runtime/chrome-isolation.js.map +1 -1
- package/dist/runtime/cli.js +67 -2
- package/dist/runtime/cli.js.map +1 -1
- package/dist/runtime/desktop-mcp.d.ts +216 -0
- package/dist/runtime/desktop-mcp.d.ts.map +1 -0
- package/dist/runtime/desktop-mcp.js +258 -0
- package/dist/runtime/desktop-mcp.js.map +1 -0
- package/dist/runtime/git-identity.d.ts +17 -0
- package/dist/runtime/git-identity.d.ts.map +1 -0
- package/dist/runtime/git-identity.js +41 -0
- package/dist/runtime/git-identity.js.map +1 -0
- package/dist/runtime/github-publish.d.ts +31 -0
- package/dist/runtime/github-publish.d.ts.map +1 -0
- package/dist/runtime/github-publish.js +237 -0
- package/dist/runtime/github-publish.js.map +1 -0
- package/dist/runtime/harness.d.ts +14 -3
- package/dist/runtime/harness.d.ts.map +1 -1
- package/dist/runtime/harness.js +55 -7
- package/dist/runtime/harness.js.map +1 -1
- package/dist/runtime/managed-cdp.d.ts +10 -0
- package/dist/runtime/managed-cdp.d.ts.map +1 -0
- package/dist/runtime/managed-cdp.js +80 -0
- package/dist/runtime/managed-cdp.js.map +1 -0
- package/dist/runtime/mcp-stdio.d.ts +17 -0
- package/dist/runtime/mcp-stdio.d.ts.map +1 -0
- package/dist/runtime/mcp-stdio.js +99 -0
- package/dist/runtime/mcp-stdio.js.map +1 -0
- package/dist/runtime/network-evidence.d.ts +28 -0
- package/dist/runtime/network-evidence.d.ts.map +1 -0
- package/dist/runtime/network-evidence.js +291 -0
- package/dist/runtime/network-evidence.js.map +1 -0
- package/dist/runtime/package-manager.d.ts +13 -0
- package/dist/runtime/package-manager.d.ts.map +1 -0
- package/dist/runtime/package-manager.js +69 -0
- package/dist/runtime/package-manager.js.map +1 -0
- package/dist/runtime/runtime.d.ts +7 -0
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +54 -30
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/sandbox-agent.d.ts +5 -0
- package/dist/runtime/sandbox-agent.d.ts.map +1 -1
- package/dist/runtime/sandbox-agent.js +32 -0
- package/dist/runtime/sandbox-agent.js.map +1 -1
- package/dist/runtime/sandbox-cleanup.d.ts +14 -0
- package/dist/runtime/sandbox-cleanup.d.ts.map +1 -0
- package/dist/runtime/sandbox-cleanup.js +77 -0
- package/dist/runtime/sandbox-cleanup.js.map +1 -0
- package/dist/runtime/sandbox-command.d.ts +1 -0
- package/dist/runtime/sandbox-command.d.ts.map +1 -1
- package/dist/runtime/sandbox-command.js +39 -9
- package/dist/runtime/sandbox-command.js.map +1 -1
- package/dist/runtime/sandbox-context.d.ts +5 -0
- package/dist/runtime/sandbox-context.d.ts.map +1 -0
- package/dist/runtime/sandbox-context.js +42 -0
- package/dist/runtime/sandbox-context.js.map +1 -0
- package/dist/runtime/sandbox-fx-resume.d.ts +11 -0
- package/dist/runtime/sandbox-fx-resume.d.ts.map +1 -0
- package/dist/runtime/sandbox-fx-resume.js +45 -0
- package/dist/runtime/sandbox-fx-resume.js.map +1 -0
- package/dist/runtime/sandbox-gateway.d.ts +17 -0
- package/dist/runtime/sandbox-gateway.d.ts.map +1 -0
- package/dist/runtime/sandbox-gateway.js +34 -0
- package/dist/runtime/sandbox-gateway.js.map +1 -0
- package/dist/runtime/sandbox-git.d.ts +19 -0
- package/dist/runtime/sandbox-git.d.ts.map +1 -0
- package/dist/runtime/sandbox-git.js +42 -0
- package/dist/runtime/sandbox-git.js.map +1 -0
- package/dist/runtime/sandbox-github.d.ts +10 -0
- package/dist/runtime/sandbox-github.d.ts.map +1 -0
- package/dist/runtime/sandbox-github.js +35 -0
- package/dist/runtime/sandbox-github.js.map +1 -0
- package/dist/runtime/sandbox-local-harness.d.ts +34 -0
- package/dist/runtime/sandbox-local-harness.d.ts.map +1 -0
- package/dist/runtime/sandbox-local-harness.js +151 -0
- package/dist/runtime/sandbox-local-harness.js.map +1 -0
- package/dist/runtime/sandbox-ports.d.ts +6 -0
- package/dist/runtime/sandbox-ports.d.ts.map +1 -0
- package/dist/runtime/sandbox-ports.js +11 -0
- package/dist/runtime/sandbox-ports.js.map +1 -0
- package/dist/runtime/sandbox-preview.d.ts +14 -0
- package/dist/runtime/sandbox-preview.d.ts.map +1 -0
- package/dist/runtime/sandbox-preview.js +96 -0
- package/dist/runtime/sandbox-preview.js.map +1 -0
- package/dist/runtime/sandbox-process.d.ts +11 -0
- package/dist/runtime/sandbox-process.d.ts.map +1 -0
- package/dist/runtime/sandbox-process.js +77 -0
- package/dist/runtime/sandbox-process.js.map +1 -0
- package/dist/runtime/sandbox-proxy.d.ts +2 -0
- package/dist/runtime/sandbox-proxy.d.ts.map +1 -1
- package/dist/runtime/sandbox-proxy.js +75 -20
- package/dist/runtime/sandbox-proxy.js.map +1 -1
- package/dist/runtime/sandbox-recovery.d.ts +4 -0
- package/dist/runtime/sandbox-recovery.d.ts.map +1 -0
- package/dist/runtime/sandbox-recovery.js +36 -0
- package/dist/runtime/sandbox-recovery.js.map +1 -0
- package/dist/runtime/sandbox-sessions.d.ts +8 -1
- package/dist/runtime/sandbox-sessions.d.ts.map +1 -1
- package/dist/runtime/sandbox-sessions.js +20 -2
- package/dist/runtime/sandbox-sessions.js.map +1 -1
- package/dist/runtime/sandbox-setup.d.ts +5 -0
- package/dist/runtime/sandbox-setup.d.ts.map +1 -0
- package/dist/runtime/sandbox-setup.js +62 -0
- package/dist/runtime/sandbox-setup.js.map +1 -0
- package/dist/runtime/sandbox-shell.d.ts +27 -0
- package/dist/runtime/sandbox-shell.d.ts.map +1 -0
- package/dist/runtime/sandbox-shell.js +169 -0
- package/dist/runtime/sandbox-shell.js.map +1 -0
- package/dist/runtime/sandbox-watch.d.ts +11 -0
- package/dist/runtime/sandbox-watch.d.ts.map +1 -0
- package/dist/runtime/sandbox-watch.js +30 -0
- package/dist/runtime/sandbox-watch.js.map +1 -0
- package/dist/runtime/sandbox-workspace.d.ts +125 -0
- package/dist/runtime/sandbox-workspace.d.ts.map +1 -0
- package/dist/runtime/sandbox-workspace.js +205 -0
- package/dist/runtime/sandbox-workspace.js.map +1 -0
- package/dist/runtime/sandbox.d.ts +21 -2
- package/dist/runtime/sandbox.d.ts.map +1 -1
- package/dist/runtime/sandbox.js +473 -207
- package/dist/runtime/sandbox.js.map +1 -1
- package/dist/runtime/session.d.ts +1 -1
- package/dist/runtime/session.d.ts.map +1 -1
- package/dist/runtime/session.js +3 -3
- package/dist/runtime/session.js.map +1 -1
- package/dist/runtime/terminal.d.ts +19 -0
- package/dist/runtime/terminal.d.ts.map +1 -0
- package/dist/runtime/terminal.js +60 -0
- package/dist/runtime/terminal.js.map +1 -0
- package/dist/runtime/workspace-client.d.ts +2 -0
- package/dist/runtime/workspace-client.d.ts.map +1 -0
- package/dist/runtime/workspace-client.js +46 -0
- package/dist/runtime/workspace-client.js.map +1 -0
- package/package.json +2 -1
- package/scripts/eve/README.md +341 -0
- package/scripts/eve/agent/agent.ts +12 -0
- package/scripts/eve/agent/channels/eve.ts +23 -0
- package/scripts/eve/agent/instructions.md +53 -0
- package/scripts/eve/agent/sandbox.ts +34 -0
- package/scripts/eve/build-cache.mjs +18 -0
- package/scripts/eve/build-cache.test.mjs +32 -0
- package/scripts/eve/client.mjs +229 -0
- package/scripts/eve/connection.mjs +89 -0
- package/scripts/eve/conversation.mjs +91 -0
- package/scripts/eve/conversation.test.mjs +113 -0
- package/scripts/eve/fixture-agent.ts +101 -0
- package/scripts/eve/images.mjs +84 -0
- package/scripts/eve/launch.mjs +277 -0
- package/scripts/eve/model-command.mjs +21 -0
- package/scripts/eve/reconnect.mjs +22 -0
- package/scripts/eve/reconnect.test.mjs +41 -0
- package/scripts/eve/settings.mjs +33 -0
- package/scripts/eve/supervisor.mjs +41 -0
- package/scripts/eve/tui-client.mjs +234 -0
- package/scripts/eve/tui-input.mjs +114 -0
- package/scripts/eve/verify.mjs +575 -0
- package/skills/d3k/SKILL.md +60 -5
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { execFile } from "node:child_process"
|
|
2
|
+
import { readFile, stat } from "node:fs/promises"
|
|
3
|
+
import { basename, extname, join } from "node:path"
|
|
4
|
+
import { createInterface } from "node:readline"
|
|
5
|
+
import { pathToFileURL } from "node:url"
|
|
6
|
+
import { parseArgs, promisify, stripVTControlCharacters } from "node:util"
|
|
7
|
+
import { ModelSelection } from "./model-command.mjs"
|
|
8
|
+
|
|
9
|
+
export async function eveClient() {
|
|
10
|
+
const root = process.env.D3K_EVE_PACKAGE_ROOT
|
|
11
|
+
return import(root ? pathToFileURL(join(root, "dist/src/client/index.js")).href : "eve/client")
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function pendingInteractions(snapshot) {
|
|
15
|
+
const result = new Map()
|
|
16
|
+
for (const message of snapshot.messages) {
|
|
17
|
+
for (const part of message.parts) {
|
|
18
|
+
const interaction = part.type === "interaction" ? part : part.interaction
|
|
19
|
+
if (interaction?.status === "open" && !interaction.answer) result.set(interaction.interactionId, interaction)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return [...result.values()]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function imageAttachment(path) {
|
|
26
|
+
const types = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp" }
|
|
27
|
+
const mediaType = types[extname(path).toLowerCase()]
|
|
28
|
+
if (!mediaType) throw new Error("Attach a PNG, JPEG, or WebP image")
|
|
29
|
+
if ((await stat(path)).size > 3 * 1024 * 1024) throw new Error("Image must be at most 3 MiB")
|
|
30
|
+
return { type: "file", mediaType, filename: basename(path), data: await readFile(path) }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function clipboardImage() {
|
|
34
|
+
if (process.platform !== "darwin") throw new Error("Use /attach <path> on this platform")
|
|
35
|
+
// Read only on an explicit image paste (Ctrl+V or /paste). Never take a screenshot.
|
|
36
|
+
const { stdout } = await promisify(execFile)("osascript", ["-e", "get the clipboard as «class PNGf»"], {
|
|
37
|
+
maxBuffer: 7 * 1024 * 1024,
|
|
38
|
+
timeout: 5000
|
|
39
|
+
})
|
|
40
|
+
const hex = /^«data PNGf([a-f\d]+)»\s*$/i.exec(stdout)?.[1]
|
|
41
|
+
if (!hex || hex.length % 2 || hex.length > 6 * 1024 * 1024)
|
|
42
|
+
throw new Error("Clipboard must contain a PNG image of at most 3 MiB")
|
|
43
|
+
return { type: "file", mediaType: "image/png", filename: "clipboard.png", data: Buffer.from(hex, "hex") }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function runClient({
|
|
47
|
+
baseUrl,
|
|
48
|
+
token,
|
|
49
|
+
sessionId,
|
|
50
|
+
signal,
|
|
51
|
+
readClipboard = clipboardImage,
|
|
52
|
+
models = new ModelSelection()
|
|
53
|
+
}) {
|
|
54
|
+
if (signal?.aborted) return
|
|
55
|
+
const url = new URL(baseUrl)
|
|
56
|
+
if (url.protocol !== "https:" && !(url.protocol === "http:" && url.hostname === "127.0.0.1"))
|
|
57
|
+
throw new Error("Use HTTPS, or loopback HTTP for the local fixture")
|
|
58
|
+
if (!token) throw new Error("Set D3K_EVE_TOKEN; do not put credentials in command arguments")
|
|
59
|
+
if (process.stdin.isTTY && process.stdout.isTTY && process.env.D3K_EVE_PLAIN_CLIENT !== "1") {
|
|
60
|
+
const { runTuiClient } = await import("./tui-client.mjs")
|
|
61
|
+
return runTuiClient({ baseUrl, token, sessionId, readClipboard, models, signal })
|
|
62
|
+
}
|
|
63
|
+
const { Client, SessionStore } = await eveClient()
|
|
64
|
+
const client = new Client({ baseUrl, auth: { bearer: token }, headers: () => models.headers() })
|
|
65
|
+
// Get a fixed identity before accepting input. Reconnection never resends a prompt.
|
|
66
|
+
const session = sessionId ? client.sessions.attach(sessionId) : (await client.sessions.create()).session
|
|
67
|
+
const store = new SessionStore({ client, session })
|
|
68
|
+
const input = createInterface({ input: process.stdin, output: process.stdout })
|
|
69
|
+
input.pause()
|
|
70
|
+
const seen = new Set()
|
|
71
|
+
let attachments = []
|
|
72
|
+
let lastError
|
|
73
|
+
let onKeypress
|
|
74
|
+
let acceptingInput = true
|
|
75
|
+
const clean = (text) =>
|
|
76
|
+
[...stripVTControlCharacters(text)]
|
|
77
|
+
.filter((character) => {
|
|
78
|
+
const code = character.codePointAt(0)
|
|
79
|
+
return (code >= 32 && code !== 127) || character === "\n" || character === "\t"
|
|
80
|
+
})
|
|
81
|
+
.join("")
|
|
82
|
+
const print = (text) => {
|
|
83
|
+
process.stdout.write(`\n${clean(text)}\n`)
|
|
84
|
+
input.prompt(true)
|
|
85
|
+
}
|
|
86
|
+
const render = () => {
|
|
87
|
+
const snapshot = store.snapshot
|
|
88
|
+
if (snapshot.error && snapshot.error !== lastError) {
|
|
89
|
+
lastError = snapshot.error
|
|
90
|
+
print(`Connection/session error: ${snapshot.error.message}. No prompt was automatically retried.`)
|
|
91
|
+
}
|
|
92
|
+
for (const message of snapshot.messages) {
|
|
93
|
+
for (const [index, part] of message.parts.entries()) {
|
|
94
|
+
const key = `${message.id}:${index}`
|
|
95
|
+
if (part.type === "text" && part.state !== "streaming" && !seen.has(key)) {
|
|
96
|
+
seen.add(key)
|
|
97
|
+
print(`${message.role}: ${part.text}`)
|
|
98
|
+
}
|
|
99
|
+
if (part.type === "tool" && !seen.has(`${key}:${part.state}`)) {
|
|
100
|
+
seen.add(`${key}:${part.state}`)
|
|
101
|
+
print(`${part.label || part.name} (${part.state})`)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
for (const interaction of pendingInteractions(snapshot)) {
|
|
106
|
+
const key = `interaction:${interaction.interactionId}`
|
|
107
|
+
if (seen.has(key)) continue
|
|
108
|
+
seen.add(key)
|
|
109
|
+
print(
|
|
110
|
+
`${interaction.request.prompt}\nID: ${interaction.interactionId}\n` +
|
|
111
|
+
(interaction.call ? `${interaction.call.name}: ${JSON.stringify(interaction.call.input)}\n` : "") +
|
|
112
|
+
(interaction.request.options || []).map((option) => `${option.id}: ${option.label}`).join("\n") +
|
|
113
|
+
`\nReply: /answer ${interaction.interactionId} <option ID or text>`
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const unsubscribe = store.subscribe(render)
|
|
118
|
+
const release = store.observe()
|
|
119
|
+
const stop = () => {
|
|
120
|
+
acceptingInput = false
|
|
121
|
+
release()
|
|
122
|
+
input.close()
|
|
123
|
+
}
|
|
124
|
+
const closed = new Promise((resolve) => input.once("close", resolve))
|
|
125
|
+
process.on("SIGTERM", stop)
|
|
126
|
+
input.on("SIGINT", stop)
|
|
127
|
+
signal?.addEventListener("abort", stop, { once: true })
|
|
128
|
+
if (signal?.aborted) stop()
|
|
129
|
+
try {
|
|
130
|
+
if (!acceptingInput) return
|
|
131
|
+
print(
|
|
132
|
+
`Eve session: ${session.id}\nReconnect: --session ${session.id}\n/detach leaves the agent running; /cancel stops its turn.\nCtrl+V attaches a clipboard image; /attach <path> also works. Send a message to upload it.`
|
|
133
|
+
)
|
|
134
|
+
await store.resume()
|
|
135
|
+
if (!acceptingInput) return
|
|
136
|
+
input.setPrompt("eve> ")
|
|
137
|
+
print(`${models.current.label} · /model to change`)
|
|
138
|
+
input.prompt()
|
|
139
|
+
const queueImage = (image) => {
|
|
140
|
+
if (!acceptingInput) return
|
|
141
|
+
if (attachments.length >= 4) throw new Error("Send the queued images before attaching more")
|
|
142
|
+
attachments.push(image)
|
|
143
|
+
print(`Attached ${image.filename}; send a message to upload it.`)
|
|
144
|
+
}
|
|
145
|
+
// readline owns local editing. HTTP traffic starts only on submitted input.
|
|
146
|
+
const handleLine = async (line) => {
|
|
147
|
+
if (signal?.aborted) return
|
|
148
|
+
try {
|
|
149
|
+
if (line === "/detach" || line === "/exit") return stop()
|
|
150
|
+
if (line === "/model" || line.startsWith("/model ")) {
|
|
151
|
+
const argument = line.slice(6).trim()
|
|
152
|
+
print(
|
|
153
|
+
!argument || argument === "list"
|
|
154
|
+
? models.list()
|
|
155
|
+
: argument === "current"
|
|
156
|
+
? models.describe()
|
|
157
|
+
: models.select(argument)
|
|
158
|
+
)
|
|
159
|
+
} else if (line === "/cancel") await store.cancel()
|
|
160
|
+
else if (line.startsWith("/attach ") || line === "/paste") {
|
|
161
|
+
queueImage(line === "/paste" ? await readClipboard() : await imageAttachment(line.slice(8).trim()))
|
|
162
|
+
} else if (line.startsWith("/answer ")) {
|
|
163
|
+
const [, id, value] = /^\/answer\s+(\S+)\s+([\s\S]+)$/.exec(line) || []
|
|
164
|
+
const interaction = pendingInteractions(store.snapshot).find((entry) => entry.interactionId === id)
|
|
165
|
+
if (!interaction) throw new Error("That request is no longer pending")
|
|
166
|
+
const option = interaction.request.options?.find((entry) => entry.id === value)
|
|
167
|
+
if (!option && !interaction.request.allowFreeform && interaction.request.display !== "text")
|
|
168
|
+
throw new Error("Choose one of the displayed option IDs")
|
|
169
|
+
await store.send({
|
|
170
|
+
signal,
|
|
171
|
+
answers: [{ interactionId: id, ...(option ? { optionId: option.id } : { text: value }) }]
|
|
172
|
+
})
|
|
173
|
+
} else if (line.trim()) {
|
|
174
|
+
const message = attachments.length ? [{ type: "text", text: line }, ...attachments] : line
|
|
175
|
+
// Do not replay an uncertain POST. Preserve attachments so the user can inspect/retry deliberately.
|
|
176
|
+
await store.send({ message, signal })
|
|
177
|
+
attachments = []
|
|
178
|
+
}
|
|
179
|
+
} catch (error) {
|
|
180
|
+
if (acceptingInput) print(error.message)
|
|
181
|
+
}
|
|
182
|
+
input.prompt()
|
|
183
|
+
}
|
|
184
|
+
let commands = Promise.resolve()
|
|
185
|
+
input.on("line", (line) => {
|
|
186
|
+
commands = commands.then(() => acceptingInput && handleLine(line))
|
|
187
|
+
})
|
|
188
|
+
// readline emits keypresses locally in a terminal. Queue clipboard reads with
|
|
189
|
+
// submitted lines so pressing Enter immediately after Ctrl+V includes the image.
|
|
190
|
+
// Preserve the draft/cursor; no extra Enter or slash command is needed.
|
|
191
|
+
onKeypress = (_text, key) => {
|
|
192
|
+
if (!key?.ctrl || key.name !== "v" || key.meta || key.shift || !acceptingInput) return
|
|
193
|
+
// readline's default handler may insert the control byte before emitting
|
|
194
|
+
// to this listener. Remove only that byte, preserving the surrounding draft.
|
|
195
|
+
if (input.line[input.cursor - 1] === "\u0016") {
|
|
196
|
+
input.line = input.line.slice(0, input.cursor - 1) + input.line.slice(input.cursor)
|
|
197
|
+
input.cursor--
|
|
198
|
+
input.prompt(true)
|
|
199
|
+
}
|
|
200
|
+
commands = commands.then(async () => {
|
|
201
|
+
if (!acceptingInput) return
|
|
202
|
+
try {
|
|
203
|
+
queueImage(await readClipboard())
|
|
204
|
+
} catch (error) {
|
|
205
|
+
if (acceptingInput) print(error.message)
|
|
206
|
+
}
|
|
207
|
+
})
|
|
208
|
+
}
|
|
209
|
+
if (process.stdin.isTTY) process.stdin.on("keypress", onKeypress)
|
|
210
|
+
input.resume()
|
|
211
|
+
await closed
|
|
212
|
+
} catch (error) {
|
|
213
|
+
if (!signal?.aborted) throw error
|
|
214
|
+
} finally {
|
|
215
|
+
acceptingInput = false
|
|
216
|
+
if (onKeypress) process.stdin.off("keypress", onKeypress)
|
|
217
|
+
release()
|
|
218
|
+
unsubscribe()
|
|
219
|
+
process.off("SIGTERM", stop)
|
|
220
|
+
signal?.removeEventListener("abort", stop)
|
|
221
|
+
input.close()
|
|
222
|
+
if (!signal?.aborted) console.log(`Detached from ${session.id}. Remote execution was not cancelled.`)
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
227
|
+
const { values } = parseArgs({ options: { session: { type: "string" } } })
|
|
228
|
+
await runClient({ baseUrl: process.env.D3K_EVE_URL, token: process.env.D3K_EVE_TOKEN, sessionId: values.session })
|
|
229
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { spawn } from "node:child_process"
|
|
2
|
+
import { mkdir, readFile, rm, writeFile } from "node:fs/promises"
|
|
3
|
+
import { dirname, isAbsolute } from "node:path"
|
|
4
|
+
import { Readable, Writable } from "node:stream"
|
|
5
|
+
|
|
6
|
+
/** The host must already be an isolated VM. This adapter adds no isolation. */
|
|
7
|
+
export function connect(workspaceRoot) {
|
|
8
|
+
if (!isAbsolute(workspaceRoot)) throw new Error("Eve requires an absolute existing checkout")
|
|
9
|
+
return {
|
|
10
|
+
workspaceRoot,
|
|
11
|
+
async spawn({ signal, stdin, command, env, workingDirectory }) {
|
|
12
|
+
signal?.throwIfAborted()
|
|
13
|
+
const commandEnv = { ...process.env, ...env }
|
|
14
|
+
for (const key of [
|
|
15
|
+
"D3K_EVE_TOKEN",
|
|
16
|
+
"AI_GATEWAY_API_KEY",
|
|
17
|
+
"VERCEL_TOKEN",
|
|
18
|
+
"VERCEL_AUTH_TOKEN",
|
|
19
|
+
"VERCEL_OIDC_TOKEN"
|
|
20
|
+
])
|
|
21
|
+
delete commandEnv[key]
|
|
22
|
+
const child = spawn("bash", ["-lc", command], {
|
|
23
|
+
cwd: workingDirectory,
|
|
24
|
+
env: commandEnv,
|
|
25
|
+
detached: true,
|
|
26
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
27
|
+
})
|
|
28
|
+
const killGroup = (signalName) => {
|
|
29
|
+
if (!child.pid) return
|
|
30
|
+
try {
|
|
31
|
+
process.kill(-child.pid, signalName)
|
|
32
|
+
} catch (error) {
|
|
33
|
+
if (error.code !== "ESRCH") throw error
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
let timer
|
|
37
|
+
const kill = async () => {
|
|
38
|
+
killGroup("SIGTERM")
|
|
39
|
+
timer ??= setTimeout(() => killGroup("SIGKILL"), 1000)
|
|
40
|
+
timer.unref()
|
|
41
|
+
}
|
|
42
|
+
const abort = () => void kill()
|
|
43
|
+
const result = new Promise((resolve, reject) => {
|
|
44
|
+
child.once("error", reject)
|
|
45
|
+
child.once("close", (code, termination) => {
|
|
46
|
+
clearTimeout(timer)
|
|
47
|
+
signal?.removeEventListener("abort", abort)
|
|
48
|
+
if (termination) reject(new Error(`Command terminated: ${termination}`))
|
|
49
|
+
else resolve({ exitCode: code ?? 1 })
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
// A process may fail before Eve starts waiting for it.
|
|
53
|
+
void result.catch(() => {})
|
|
54
|
+
signal?.addEventListener("abort", abort, { once: true })
|
|
55
|
+
if (signal?.aborted) abort()
|
|
56
|
+
if (!stdin) child.stdin.end()
|
|
57
|
+
return {
|
|
58
|
+
pid: child.pid,
|
|
59
|
+
stdin: stdin ? Writable.toWeb(child.stdin) : undefined,
|
|
60
|
+
stdout: Readable.toWeb(child.stdout),
|
|
61
|
+
stderr: Readable.toWeb(child.stderr),
|
|
62
|
+
wait: () => result,
|
|
63
|
+
kill
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
async readFile({ path, signal }) {
|
|
67
|
+
try {
|
|
68
|
+
return await readFile(path, { signal })
|
|
69
|
+
} catch (error) {
|
|
70
|
+
if (error.code === "ENOENT") return null
|
|
71
|
+
throw error
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
async writeFiles({ files, signal }) {
|
|
75
|
+
for (const { path, content } of files) {
|
|
76
|
+
signal?.throwIfAborted()
|
|
77
|
+
await mkdir(dirname(path), { recursive: true })
|
|
78
|
+
await writeFile(path, content, { signal })
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
async removePath({ path, force, recursive, signal }) {
|
|
82
|
+
signal?.throwIfAborted()
|
|
83
|
+
await rm(path, { force, recursive })
|
|
84
|
+
},
|
|
85
|
+
// d3k owns the shared VM; ending an Eve session must not stop its dev server.
|
|
86
|
+
async stop() {},
|
|
87
|
+
async close() {}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/** Keep discovery and history on the remote disk, independently of build hashes. */
|
|
2
|
+
export const prepareEveWorkspaceScript = `
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const [directory, owner, workdir, appUrl, legacyRoot = "/tmp"] = process.argv.slice(1);
|
|
6
|
+
const stateName = '.d3k-conversation.json';
|
|
7
|
+
let migrated = false;
|
|
8
|
+
if (!fs.existsSync(directory)) {
|
|
9
|
+
const candidates = [];
|
|
10
|
+
for (const name of fs.readdirSync(legacyRoot)) {
|
|
11
|
+
if (!/^d3k-eve-([a-f0-9]{12}|[a-f0-9]{64})$/.test(name)) continue;
|
|
12
|
+
const legacy = path.join(legacyRoot, name);
|
|
13
|
+
if (fs.existsSync(path.join(legacy, stateName))) continue;
|
|
14
|
+
const instructions = path.join(legacy, 'agent/instructions.md');
|
|
15
|
+
if (!fs.existsSync(instructions)) continue;
|
|
16
|
+
const context = fs.readFileSync(instructions, 'utf8');
|
|
17
|
+
if (!context.includes(workdir) || !context.includes(appUrl)) continue;
|
|
18
|
+
const runs = path.join(legacy, '.eve/.workflow-data/runs');
|
|
19
|
+
if (!fs.existsSync(runs)) continue;
|
|
20
|
+
for (const file of fs.readdirSync(runs)) {
|
|
21
|
+
if (!file.endsWith('.json')) continue;
|
|
22
|
+
const run = JSON.parse(fs.readFileSync(path.join(runs, file), 'utf8'));
|
|
23
|
+
if (run.workflowName === 'workflow//eve//workflowEntry')
|
|
24
|
+
candidates.push({directory:legacy, id:run.runId, createdAt:run.createdAt});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
candidates.sort((a,b) => String(b.createdAt).localeCompare(String(a.createdAt)));
|
|
28
|
+
fs.mkdirSync(path.dirname(directory), {recursive:true});
|
|
29
|
+
if (candidates.length) {
|
|
30
|
+
const latest = candidates[0];
|
|
31
|
+
// Keep the original path valid: compiled builds contain absolute paths.
|
|
32
|
+
fs.symlinkSync(latest.directory, directory, 'dir');
|
|
33
|
+
const state = {version:1, owner, workdir, conversationId:latest.id};
|
|
34
|
+
fs.writeFileSync(path.join(directory, stateName), JSON.stringify(state), {flag:'wx', mode:0o600});
|
|
35
|
+
migrated = true;
|
|
36
|
+
} else fs.mkdirSync(directory);
|
|
37
|
+
}
|
|
38
|
+
const statePath = path.join(directory, stateName);
|
|
39
|
+
// Recover after an uncertain create/save, never silently create over durable history.
|
|
40
|
+
if (!fs.existsSync(statePath)) {
|
|
41
|
+
const runs = path.join(directory, '.eve/.workflow-data/runs');
|
|
42
|
+
const roots = fs.existsSync(runs) ? fs.readdirSync(runs).filter(file => file.endsWith('.json')).map(file => JSON.parse(fs.readFileSync(path.join(runs,file),'utf8'))).filter(run => run.workflowName === 'workflow//eve//workflowEntry').sort((a,b) => String(b.createdAt).localeCompare(String(a.createdAt))) : [];
|
|
43
|
+
if (roots.length) {
|
|
44
|
+
fs.writeFileSync(statePath, JSON.stringify({version:1,owner,workdir,conversationId:roots[0].runId}), {flag:'wx',mode:0o600});
|
|
45
|
+
migrated = true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const state = fs.existsSync(statePath) ? JSON.parse(fs.readFileSync(statePath, 'utf8')) : null;
|
|
49
|
+
console.log(JSON.stringify({state, migrated}));
|
|
50
|
+
`
|
|
51
|
+
|
|
52
|
+
export const saveEveConversationScript = `
|
|
53
|
+
const fs = require('node:fs');
|
|
54
|
+
const path = require('node:path');
|
|
55
|
+
const [directory, serialized] = process.argv.slice(1);
|
|
56
|
+
const file = path.join(directory, '.d3k-conversation.json');
|
|
57
|
+
const temporary = file + '.' + process.pid + '.tmp';
|
|
58
|
+
fs.writeFileSync(temporary, serialized, {mode:0o600});
|
|
59
|
+
fs.renameSync(temporary, file);
|
|
60
|
+
`
|
|
61
|
+
|
|
62
|
+
export function validateConversation(state, { owner, workdir }) {
|
|
63
|
+
if (
|
|
64
|
+
state?.version !== 1 ||
|
|
65
|
+
state.owner !== owner ||
|
|
66
|
+
state.workdir !== workdir ||
|
|
67
|
+
typeof state.conversationId !== "string" ||
|
|
68
|
+
!/^wrun_[A-Z0-9]{26}$/.test(state.conversationId)
|
|
69
|
+
)
|
|
70
|
+
throw new Error("Saved Eve conversation does not match this sandbox session; refusing to replace it.")
|
|
71
|
+
return state
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export async function openEveConversation({ client, state, owner, workdir, save, signal }) {
|
|
75
|
+
if (state) {
|
|
76
|
+
validateConversation(state, { owner, workdir })
|
|
77
|
+
const session = client.sessions.attach(state.conversationId)
|
|
78
|
+
try {
|
|
79
|
+
await session.snapshot({ signal })
|
|
80
|
+
} catch (error) {
|
|
81
|
+
throw new Error(`Could not recover Eve conversation ${state.conversationId}. No new conversation was created.`, {
|
|
82
|
+
cause: error
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
return session
|
|
86
|
+
}
|
|
87
|
+
const { session } = await client.sessions.create()
|
|
88
|
+
// Persist before accepting input. An uncertain create/save is never retried here.
|
|
89
|
+
await save({ version: 1, owner, workdir, conversationId: session.id })
|
|
90
|
+
return session
|
|
91
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process"
|
|
2
|
+
import { mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs"
|
|
3
|
+
import { tmpdir } from "node:os"
|
|
4
|
+
import { join } from "node:path"
|
|
5
|
+
import { afterEach, expect, it, vi } from "vitest"
|
|
6
|
+
import { openEveConversation, prepareEveWorkspaceScript, saveEveConversationScript } from "./conversation.mjs"
|
|
7
|
+
|
|
8
|
+
const roots = []
|
|
9
|
+
afterEach(() => {
|
|
10
|
+
for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true })
|
|
11
|
+
})
|
|
12
|
+
const owner = "saved-sandbox"
|
|
13
|
+
const workdir = "/vercel/project"
|
|
14
|
+
const id = "wrun_01M6QHTXRYRKNVQKPGTG3FHC6E"
|
|
15
|
+
const state = { version: 1, owner, workdir, conversationId: id }
|
|
16
|
+
|
|
17
|
+
it("persists a new conversation identity before returning it to the UI", async () => {
|
|
18
|
+
const session = { id }
|
|
19
|
+
const client = { sessions: { create: vi.fn(async () => ({ session })) } }
|
|
20
|
+
let persisted
|
|
21
|
+
const returned = await openEveConversation({
|
|
22
|
+
client,
|
|
23
|
+
owner,
|
|
24
|
+
workdir,
|
|
25
|
+
save: async (value) => {
|
|
26
|
+
persisted = value
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
expect(returned).toBe(session)
|
|
30
|
+
expect(persisted).toEqual(state)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it("attaches the saved conversation and verifies history without creating or resending a prompt", async () => {
|
|
34
|
+
const session = { id, snapshot: vi.fn(async () => ({ events: [] })) }
|
|
35
|
+
const client = { sessions: { attach: vi.fn(() => session), create: vi.fn() } }
|
|
36
|
+
expect(await openEveConversation({ client, state, owner, workdir })).toBe(session)
|
|
37
|
+
expect(client.sessions.attach).toHaveBeenCalledWith(id)
|
|
38
|
+
expect(session.snapshot).toHaveBeenCalledOnce()
|
|
39
|
+
expect(client.sessions.create).not.toHaveBeenCalled()
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it("does not fall back to a new conversation when saved history is unavailable", async () => {
|
|
43
|
+
const client = {
|
|
44
|
+
sessions: {
|
|
45
|
+
attach: () => ({
|
|
46
|
+
snapshot: async () => {
|
|
47
|
+
throw new Error("history missing")
|
|
48
|
+
}
|
|
49
|
+
}),
|
|
50
|
+
create: vi.fn()
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
await expect(openEveConversation({ client, state, owner, workdir })).rejects.toThrow(
|
|
54
|
+
"No new conversation was created"
|
|
55
|
+
)
|
|
56
|
+
expect(client.sessions.create).not.toHaveBeenCalled()
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it.each([{ owner: "another-sandbox" }, { workdir: "/vercel/other" }, { conversationId: "invalid" }])(
|
|
60
|
+
"rejects mismatched or corrupt discovery state %j",
|
|
61
|
+
async (changed) => {
|
|
62
|
+
const client = { sessions: { attach: vi.fn(), create: vi.fn() } }
|
|
63
|
+
await expect(openEveConversation({ client, state: { ...state, ...changed }, owner, workdir })).rejects.toThrow(
|
|
64
|
+
"does not match"
|
|
65
|
+
)
|
|
66
|
+
expect(client.sessions.attach).not.toHaveBeenCalled()
|
|
67
|
+
expect(client.sessions.create).not.toHaveBeenCalled()
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
it("adopts legacy history into a stable session path and retains it across builds and subsequent resumes", () => {
|
|
72
|
+
const root = mkdtempSync(join(tmpdir(), "d3k-conversation-"))
|
|
73
|
+
roots.push(root)
|
|
74
|
+
const legacy = join(root, "d3k-eve-0123456789ab")
|
|
75
|
+
mkdirSync(join(legacy, "agent"), { recursive: true })
|
|
76
|
+
writeFileSync(join(legacy, "agent/instructions.md"), `${workdir} https://project.d3k.localhost`)
|
|
77
|
+
const runs = join(legacy, ".eve/.workflow-data/runs")
|
|
78
|
+
mkdirSync(runs, { recursive: true })
|
|
79
|
+
writeFileSync(
|
|
80
|
+
join(runs, `${id}.json`),
|
|
81
|
+
JSON.stringify({ runId: id, workflowName: "workflow//eve//workflowEntry", createdAt: "2026-11-05T00:00:00Z" })
|
|
82
|
+
)
|
|
83
|
+
// Timeout workflows must never be mistaken for conversations.
|
|
84
|
+
writeFileSync(
|
|
85
|
+
join(runs, "timeout.json"),
|
|
86
|
+
JSON.stringify({
|
|
87
|
+
runId: "timeout",
|
|
88
|
+
workflowName: "workflow//eve//sessionTimeoutWorkflow",
|
|
89
|
+
createdAt: "2026-11-06T00:00:00Z"
|
|
90
|
+
})
|
|
91
|
+
)
|
|
92
|
+
const directory = join(root, "sessions", owner)
|
|
93
|
+
const prepare = () => {
|
|
94
|
+
const result = spawnSync(
|
|
95
|
+
process.execPath,
|
|
96
|
+
["-e", prepareEveWorkspaceScript, directory, owner, workdir, "https://project.d3k.localhost", root],
|
|
97
|
+
{ encoding: "utf8" }
|
|
98
|
+
)
|
|
99
|
+
expect(result.status, result.stderr).toBe(0)
|
|
100
|
+
return JSON.parse(result.stdout)
|
|
101
|
+
}
|
|
102
|
+
expect(prepare()).toEqual({ state, migrated: true })
|
|
103
|
+
expect(realpathSync(directory)).toBe(realpathSync(legacy))
|
|
104
|
+
writeFileSync(join(directory, "agent/agent.ts"), "updated service source")
|
|
105
|
+
expect(prepare()).toEqual({ state, migrated: false })
|
|
106
|
+
// A lost pointer is recovered from history instead of starting over.
|
|
107
|
+
rmSync(join(directory, ".d3k-conversation.json"))
|
|
108
|
+
expect(prepare()).toEqual({ state, migrated: true })
|
|
109
|
+
const updated = { ...state, model: "selected-model" }
|
|
110
|
+
const saved = spawnSync(process.execPath, ["-e", saveEveConversationScript, directory, JSON.stringify(updated)])
|
|
111
|
+
expect(saved.status).toBe(0)
|
|
112
|
+
expect(JSON.parse(readFileSync(join(directory, ".d3k-conversation.json"), "utf8"))).toEqual(updated)
|
|
113
|
+
})
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// Deterministic model for transport verification. Never used by the real scaffold.
|
|
2
|
+
import { MockLanguageModelV4, simulateReadableStream } from "ai/test"
|
|
3
|
+
import { defineAgent } from "eve"
|
|
4
|
+
import { defineDynamic } from "eve/models"
|
|
5
|
+
import { resolveModel } from "../settings.mjs"
|
|
6
|
+
|
|
7
|
+
export default defineAgent({
|
|
8
|
+
approval: ({ toolInput }) => (String(toolInput?.command).includes("approval.txt") ? "user-approval" : undefined),
|
|
9
|
+
model: defineDynamic((ctx) => {
|
|
10
|
+
const requested = ctx.session.auth.current?.attributes.d3kModel
|
|
11
|
+
const selected = resolveModel(typeof requested === "string" ? requested : undefined)
|
|
12
|
+
return {
|
|
13
|
+
model: new MockLanguageModelV4({
|
|
14
|
+
// Eve needs known context-window metadata even for a test model.
|
|
15
|
+
provider: "openai",
|
|
16
|
+
modelId: "gpt-5.4",
|
|
17
|
+
doStream: async ({ prompt, tools }) => {
|
|
18
|
+
const image = prompt.some(
|
|
19
|
+
(message) =>
|
|
20
|
+
Array.isArray(message.content) &&
|
|
21
|
+
message.content.some(
|
|
22
|
+
(part) => part.type === "file" && part.mediaType === "image/png" && part.data.type === "data"
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
const historyCase = /remember-case|recall-case/.test(JSON.stringify(prompt))
|
|
26
|
+
const remembered = JSON.stringify(prompt).includes("remember-case")
|
|
27
|
+
const modelCase = JSON.stringify(prompt).includes("model-case")
|
|
28
|
+
const contextCase = JSON.stringify(prompt).includes("context-case")
|
|
29
|
+
if (contextCase) {
|
|
30
|
+
const system = prompt
|
|
31
|
+
.filter((message) => message.role === "system")
|
|
32
|
+
.map((message) => message.content)
|
|
33
|
+
.join("\n")
|
|
34
|
+
for (const required of [
|
|
35
|
+
process.env.D3K_EVE_WORKDIR,
|
|
36
|
+
"https://fixture.d3k.localhost",
|
|
37
|
+
"/tmp/d3k-tools/node_modules/.bin/d3k-runtime browser snapshot -i",
|
|
38
|
+
"After a user-visible UI change",
|
|
39
|
+
"## Pull requests",
|
|
40
|
+
"without another confirmation",
|
|
41
|
+
"untracked artifacts",
|
|
42
|
+
"already running"
|
|
43
|
+
])
|
|
44
|
+
if (!system.includes(required)) throw new Error(`Connected-session context missing: ${required}`)
|
|
45
|
+
}
|
|
46
|
+
const finished = prompt.some((message) => message.role === "tool")
|
|
47
|
+
const approval = JSON.stringify(prompt).includes("approval-case")
|
|
48
|
+
const bash = tools?.find((tool) => tool.name === "bash")
|
|
49
|
+
const reply = contextCase
|
|
50
|
+
? "CONTEXT_READY"
|
|
51
|
+
: historyCase
|
|
52
|
+
? remembered
|
|
53
|
+
? "HISTORY_PRESENT"
|
|
54
|
+
: "HISTORY_MISSING"
|
|
55
|
+
: modelCase
|
|
56
|
+
? `MODEL_USED:${selected.id}`
|
|
57
|
+
: image
|
|
58
|
+
? "IMAGE_RECEIVED"
|
|
59
|
+
: "The remote task finished."
|
|
60
|
+
const command = approval ? "printf approved >> approval.txt" : "sleep 2; printf completed >> proof.txt"
|
|
61
|
+
const chunks =
|
|
62
|
+
finished || image || modelCase || contextCase || historyCase || !bash
|
|
63
|
+
? [
|
|
64
|
+
{ type: "text-start", id: "reply" },
|
|
65
|
+
{ type: "text-delta", id: "reply", delta: reply },
|
|
66
|
+
{ type: "text-end", id: "reply" }
|
|
67
|
+
]
|
|
68
|
+
: [
|
|
69
|
+
{
|
|
70
|
+
type: "tool-call",
|
|
71
|
+
toolCallId: "fixture-command",
|
|
72
|
+
toolName: bash.name,
|
|
73
|
+
input: JSON.stringify({ command })
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
return {
|
|
77
|
+
stream: simulateReadableStream({
|
|
78
|
+
chunks: [
|
|
79
|
+
...chunks,
|
|
80
|
+
{
|
|
81
|
+
type: "finish",
|
|
82
|
+
finishReason: {
|
|
83
|
+
unified: finished || image || modelCase || contextCase || historyCase ? "stop" : "tool-calls",
|
|
84
|
+
raw: finished || image || modelCase || contextCase || historyCase ? "stop" : "tool_calls"
|
|
85
|
+
},
|
|
86
|
+
usage: {
|
|
87
|
+
inputTokens: { total: 1, noCache: 1, cacheRead: 0, cacheWrite: 0 },
|
|
88
|
+
outputTokens: { total: 1, text: 1, reasoning: 0 }
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
chunkDelayInMs: 10
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}),
|
|
97
|
+
modelContextWindowTokens: selected.context,
|
|
98
|
+
reasoning: selected.reasoning
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
})
|