@namzu/sandbox 23.0.1 → 25.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +290 -0
- package/dist/backends/http-worker-client.d.ts +3 -1
- package/dist/backends/http-worker-client.d.ts.map +1 -1
- package/dist/backends/http-worker-client.js +15 -4
- package/dist/backends/http-worker-client.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/local-virtual-computer/client.d.ts +21 -0
- package/dist/local-virtual-computer/client.d.ts.map +1 -0
- package/dist/local-virtual-computer/client.js +503 -0
- package/dist/local-virtual-computer/client.js.map +1 -0
- package/dist/local-virtual-computer/detached-process.d.ts +15 -0
- package/dist/local-virtual-computer/detached-process.d.ts.map +1 -0
- package/dist/local-virtual-computer/detached-process.js +111 -0
- package/dist/local-virtual-computer/detached-process.js.map +1 -0
- package/dist/local-virtual-computer/detached-worker.d.ts +11 -0
- package/dist/local-virtual-computer/detached-worker.d.ts.map +1 -0
- package/dist/local-virtual-computer/detached-worker.js +97 -0
- package/dist/local-virtual-computer/detached-worker.js.map +1 -0
- package/dist/local-virtual-computer/dialect.d.ts +26 -0
- package/dist/local-virtual-computer/dialect.d.ts.map +1 -0
- package/dist/local-virtual-computer/dialect.js +61 -0
- package/dist/local-virtual-computer/dialect.js.map +1 -0
- package/dist/local-virtual-computer/engine.d.ts +63 -0
- package/dist/local-virtual-computer/engine.d.ts.map +1 -0
- package/dist/local-virtual-computer/engine.js +125 -0
- package/dist/local-virtual-computer/engine.js.map +1 -0
- package/dist/local-virtual-computer/guest-stdio.d.ts +15 -0
- package/dist/local-virtual-computer/guest-stdio.d.ts.map +1 -0
- package/dist/local-virtual-computer/guest-stdio.js +330 -0
- package/dist/local-virtual-computer/guest-stdio.js.map +1 -0
- package/dist/local-virtual-computer/index.d.ts +36 -0
- package/dist/local-virtual-computer/index.d.ts.map +1 -0
- package/dist/local-virtual-computer/index.js +341 -0
- package/dist/local-virtual-computer/index.js.map +1 -0
- package/dist/local-virtual-computer/podman-machine.d.ts +17 -0
- package/dist/local-virtual-computer/podman-machine.d.ts.map +1 -0
- package/dist/local-virtual-computer/podman-machine.js +181 -0
- package/dist/local-virtual-computer/podman-machine.js.map +1 -0
- package/dist/local-virtual-computer/setup/contract.d.ts +360 -0
- package/dist/local-virtual-computer/setup/contract.d.ts.map +1 -0
- package/dist/local-virtual-computer/setup/contract.js +3 -0
- package/dist/local-virtual-computer/setup/contract.js.map +1 -0
- package/dist/local-virtual-computer/setup/elevated.d.ts +78 -0
- package/dist/local-virtual-computer/setup/elevated.d.ts.map +1 -0
- package/dist/local-virtual-computer/setup/elevated.js +548 -0
- package/dist/local-virtual-computer/setup/elevated.js.map +1 -0
- package/dist/local-virtual-computer/setup/host.d.ts +12 -0
- package/dist/local-virtual-computer/setup/host.d.ts.map +1 -0
- package/dist/local-virtual-computer/setup/host.js +93 -0
- package/dist/local-virtual-computer/setup/host.js.map +1 -0
- package/dist/local-virtual-computer/setup/idle.d.ts +18 -0
- package/dist/local-virtual-computer/setup/idle.d.ts.map +1 -0
- package/dist/local-virtual-computer/setup/idle.js +38 -0
- package/dist/local-virtual-computer/setup/idle.js.map +1 -0
- package/dist/local-virtual-computer/setup/image.d.ts +7 -0
- package/dist/local-virtual-computer/setup/image.d.ts.map +1 -0
- package/dist/local-virtual-computer/setup/image.js +124 -0
- package/dist/local-virtual-computer/setup/image.js.map +1 -0
- package/dist/local-virtual-computer/setup/index.d.ts +17 -0
- package/dist/local-virtual-computer/setup/index.d.ts.map +1 -0
- package/dist/local-virtual-computer/setup/index.js +17 -0
- package/dist/local-virtual-computer/setup/index.js.map +1 -0
- package/dist/local-virtual-computer/setup/limits.d.ts +30 -0
- package/dist/local-virtual-computer/setup/limits.d.ts.map +1 -0
- package/dist/local-virtual-computer/setup/limits.js +58 -0
- package/dist/local-virtual-computer/setup/limits.js.map +1 -0
- package/dist/local-virtual-computer/setup/plan.d.ts +8 -0
- package/dist/local-virtual-computer/setup/plan.d.ts.map +1 -0
- package/dist/local-virtual-computer/setup/plan.js +131 -0
- package/dist/local-virtual-computer/setup/plan.js.map +1 -0
- package/dist/local-virtual-computer/setup/readiness.d.ts +11 -0
- package/dist/local-virtual-computer/setup/readiness.d.ts.map +1 -0
- package/dist/local-virtual-computer/setup/readiness.js +320 -0
- package/dist/local-virtual-computer/setup/readiness.js.map +1 -0
- package/dist/local-virtual-computer/setup/registry.d.ts +18 -0
- package/dist/local-virtual-computer/setup/registry.d.ts.map +1 -0
- package/dist/local-virtual-computer/setup/registry.js +50 -0
- package/dist/local-virtual-computer/setup/registry.js.map +1 -0
- package/dist/local-virtual-computer/setup/restart.d.ts +8 -0
- package/dist/local-virtual-computer/setup/restart.d.ts.map +1 -0
- package/dist/local-virtual-computer/setup/restart.js +60 -0
- package/dist/local-virtual-computer/setup/restart.js.map +1 -0
- package/dist/local-virtual-computer/setup/resume.d.ts +14 -0
- package/dist/local-virtual-computer/setup/resume.d.ts.map +1 -0
- package/dist/local-virtual-computer/setup/resume.js +58 -0
- package/dist/local-virtual-computer/setup/resume.js.map +1 -0
- package/dist/local-virtual-computer/setup/run.d.ts +8 -0
- package/dist/local-virtual-computer/setup/run.d.ts.map +1 -0
- package/dist/local-virtual-computer/setup/run.js +200 -0
- package/dist/local-virtual-computer/setup/run.js.map +1 -0
- package/dist/local-virtual-computer/setup/windows-folder.d.ts +11 -0
- package/dist/local-virtual-computer/setup/windows-folder.d.ts.map +1 -0
- package/dist/local-virtual-computer/setup/windows-folder.js +14 -0
- package/dist/local-virtual-computer/setup/windows-folder.js.map +1 -0
- package/dist/local-virtual-computer/setup/wsl-package.d.ts +19 -0
- package/dist/local-virtual-computer/setup/wsl-package.d.ts.map +1 -0
- package/dist/local-virtual-computer/setup/wsl-package.js +242 -0
- package/dist/local-virtual-computer/setup/wsl-package.js.map +1 -0
- package/dist/local-virtual-computer/setup/wslc-shared.d.ts +27 -0
- package/dist/local-virtual-computer/setup/wslc-shared.d.ts.map +1 -0
- package/dist/local-virtual-computer/setup/wslc-shared.js +137 -0
- package/dist/local-virtual-computer/setup/wslc-shared.js.map +1 -0
- package/dist/local-virtual-computer/ssh-forward.d.ts +19 -0
- package/dist/local-virtual-computer/ssh-forward.d.ts.map +1 -0
- package/dist/local-virtual-computer/ssh-forward.js +179 -0
- package/dist/local-virtual-computer/ssh-forward.js.map +1 -0
- package/dist/local-virtual-computer/wslc-engine.d.ts +27 -0
- package/dist/local-virtual-computer/wslc-engine.d.ts.map +1 -0
- package/dist/local-virtual-computer/wslc-engine.js +98 -0
- package/dist/local-virtual-computer/wslc-engine.js.map +1 -0
- package/local-computer/Dockerfile +99 -0
- package/local-computer/app-catalog.cjs +240 -0
- package/local-computer/app-native-host.cjs +144 -0
- package/local-computer/browser-home.cjs +249 -0
- package/local-computer/build-image.mjs +310 -0
- package/local-computer/desktop-worker.cjs +477 -0
- package/local-computer/entrypoint.sh +161 -0
- package/local-computer/home.html +28 -0
- package/local-computer/new-tab/home.css +255 -0
- package/local-computer/new-tab/home.js +65 -0
- package/local-computer/new-tab/manifest.json +12 -0
- package/local-computer/new-tab/wordmark.svg +33 -0
- package/local-computer/openbox-rc.xml +41 -0
- package/local-computer/prepare-home.cjs +121 -0
- package/local-computer/tint2rc +44 -0
- package/package.json +13 -4
- package/src/backends/http-worker-client.ts +31 -3
- package/src/index.ts +13 -0
- package/src/local-virtual-computer/client.ts +573 -0
- package/src/local-virtual-computer/detached-process.ts +133 -0
- package/src/local-virtual-computer/detached-worker.ts +124 -0
- package/src/local-virtual-computer/dialect.ts +83 -0
- package/src/local-virtual-computer/engine.ts +197 -0
- package/src/local-virtual-computer/guest-stdio.ts +332 -0
- package/src/local-virtual-computer/index.ts +447 -0
- package/src/local-virtual-computer/podman-machine.ts +264 -0
- package/src/local-virtual-computer/setup/contract.ts +395 -0
- package/src/local-virtual-computer/setup/elevated.ts +655 -0
- package/src/local-virtual-computer/setup/host.ts +100 -0
- package/src/local-virtual-computer/setup/idle.ts +39 -0
- package/src/local-virtual-computer/setup/image.ts +159 -0
- package/src/local-virtual-computer/setup/index.ts +16 -0
- package/src/local-virtual-computer/setup/limits.ts +68 -0
- package/src/local-virtual-computer/setup/plan.ts +144 -0
- package/src/local-virtual-computer/setup/readiness.ts +386 -0
- package/src/local-virtual-computer/setup/registry.ts +50 -0
- package/src/local-virtual-computer/setup/restart.ts +64 -0
- package/src/local-virtual-computer/setup/resume.ts +65 -0
- package/src/local-virtual-computer/setup/run.ts +225 -0
- package/src/local-virtual-computer/setup/windows-folder.ts +13 -0
- package/src/local-virtual-computer/setup/wsl-package.ts +242 -0
- package/src/local-virtual-computer/setup/wslc-shared.ts +147 -0
- package/src/local-virtual-computer/ssh-forward.ts +195 -0
- package/src/local-virtual-computer/wslc-engine.ts +124 -0
- package/worker/server.js +1499 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { workerAuthorization } from '../backends/http-worker-client.js';
|
|
2
|
+
const MAX_FRAME_BYTES = 2 * 1024 * 1024;
|
|
3
|
+
const MAX_QUEUED_BYTES = 4 * 1024 * 1024;
|
|
4
|
+
/** Private allocation token stays inside this host channel, never in guest argv/env. */
|
|
5
|
+
export async function openGuestStdio(host, command, args, options) {
|
|
6
|
+
if (!command || typeof command !== 'string' || args.some((arg) => typeof arg !== 'string'))
|
|
7
|
+
throw new Error('Guest stdio requires a command and literal argv');
|
|
8
|
+
const headers = { 'content-type': 'application/json', ...workerAuthorization(host.token) };
|
|
9
|
+
const post = async (route, body, signal) => {
|
|
10
|
+
const response = await fetch(`${host.executionUrl}${route}`, {
|
|
11
|
+
method: 'POST',
|
|
12
|
+
headers,
|
|
13
|
+
body: JSON.stringify(body),
|
|
14
|
+
signal: signal
|
|
15
|
+
? AbortSignal.any([signal, AbortSignal.timeout(30_000)])
|
|
16
|
+
: AbortSignal.timeout(30_000),
|
|
17
|
+
});
|
|
18
|
+
if (!response.ok)
|
|
19
|
+
throw new Error(`Guest stdio request refused (${response.status})`);
|
|
20
|
+
return (await response.json());
|
|
21
|
+
};
|
|
22
|
+
const reservation = await post('/executions/reserve', {}, options?.signal);
|
|
23
|
+
const executionId = reservation.executionId;
|
|
24
|
+
if (typeof executionId !== 'string' || !/^exec_[0-9a-f-]{36}$/.test(executionId))
|
|
25
|
+
throw new Error('Guest did not return an execution reservation');
|
|
26
|
+
const cancel = async () => {
|
|
27
|
+
const result = await post('/cancel', { executionId });
|
|
28
|
+
if (result.ok !== true || !['completed', 'cancelled', 'failed'].includes(String(result.state)))
|
|
29
|
+
throw new Error('Guest stdio process-group termination was not confirmed');
|
|
30
|
+
};
|
|
31
|
+
const capability = reservation.stdio;
|
|
32
|
+
if (capability?.version !== 1 ||
|
|
33
|
+
!Number.isSafeInteger(capability.maxLifetimeMs) ||
|
|
34
|
+
typeof capability.maxLifetimeMs !== 'number' ||
|
|
35
|
+
capability.maxLifetimeMs < 1 ||
|
|
36
|
+
capability.maxLifetimeMs > 2_147_000_000) {
|
|
37
|
+
await cancel();
|
|
38
|
+
throw new Error('This guest worker does not support owned interactive stdio; rebuild the Pal image');
|
|
39
|
+
}
|
|
40
|
+
const controller = new AbortController();
|
|
41
|
+
let confirmed = false;
|
|
42
|
+
let closing;
|
|
43
|
+
let terminal = false;
|
|
44
|
+
let failure;
|
|
45
|
+
let resolveClosed;
|
|
46
|
+
let rejectClosed;
|
|
47
|
+
const closed = new Promise((resolve, reject) => {
|
|
48
|
+
resolveClosed = resolve;
|
|
49
|
+
rejectClosed = reject;
|
|
50
|
+
});
|
|
51
|
+
// An embedding transport may attach only after connect resolves.
|
|
52
|
+
void closed.catch(() => { });
|
|
53
|
+
const operations = new Set();
|
|
54
|
+
const unknown = () => {
|
|
55
|
+
host.uncertain();
|
|
56
|
+
for (const operation of operations)
|
|
57
|
+
operation.unknown();
|
|
58
|
+
};
|
|
59
|
+
const queue = [];
|
|
60
|
+
let queuedBytes = 0;
|
|
61
|
+
let consumerWake;
|
|
62
|
+
let producerWake;
|
|
63
|
+
let claimed = false;
|
|
64
|
+
const finish = (error) => {
|
|
65
|
+
if (terminal)
|
|
66
|
+
return;
|
|
67
|
+
terminal = true;
|
|
68
|
+
failure = error;
|
|
69
|
+
options?.signal?.removeEventListener('abort', onAbort);
|
|
70
|
+
consumerWake?.();
|
|
71
|
+
producerWake?.();
|
|
72
|
+
if (error)
|
|
73
|
+
rejectClosed(error);
|
|
74
|
+
else
|
|
75
|
+
resolveClosed();
|
|
76
|
+
};
|
|
77
|
+
const close = () => {
|
|
78
|
+
if (confirmed)
|
|
79
|
+
return Promise.resolve();
|
|
80
|
+
if (closing)
|
|
81
|
+
return closing;
|
|
82
|
+
// Closing MCP does not prove an external editor command stopped.
|
|
83
|
+
if (operations.size)
|
|
84
|
+
unknown();
|
|
85
|
+
closing = cancel()
|
|
86
|
+
.then(() => {
|
|
87
|
+
confirmed = true;
|
|
88
|
+
controller.abort();
|
|
89
|
+
finish();
|
|
90
|
+
})
|
|
91
|
+
.catch((error) => {
|
|
92
|
+
unknown();
|
|
93
|
+
closing = undefined;
|
|
94
|
+
throw error;
|
|
95
|
+
});
|
|
96
|
+
return closing;
|
|
97
|
+
};
|
|
98
|
+
const onAbort = () => {
|
|
99
|
+
void close().catch(() => { });
|
|
100
|
+
};
|
|
101
|
+
let response;
|
|
102
|
+
const handshakeTimeout = setTimeout(() => controller.abort(new Error('Guest stdio startup timed out')), 30_000);
|
|
103
|
+
try {
|
|
104
|
+
options?.signal?.throwIfAborted();
|
|
105
|
+
await options?.assertExecutionAllowed?.();
|
|
106
|
+
options?.signal?.throwIfAborted();
|
|
107
|
+
response = await fetch(`${host.executionUrl}/execute`, {
|
|
108
|
+
method: 'POST',
|
|
109
|
+
headers,
|
|
110
|
+
body: JSON.stringify({
|
|
111
|
+
executionId,
|
|
112
|
+
command,
|
|
113
|
+
args,
|
|
114
|
+
cwd: options?.cwd,
|
|
115
|
+
env: options?.env,
|
|
116
|
+
stdio: true,
|
|
117
|
+
timeoutMs: capability.maxLifetimeMs,
|
|
118
|
+
normalExitPolicy: 'strict',
|
|
119
|
+
}),
|
|
120
|
+
signal: AbortSignal.any([controller.signal, ...(options?.signal ? [options.signal] : [])]),
|
|
121
|
+
});
|
|
122
|
+
if (!response.ok || !response.body)
|
|
123
|
+
throw new Error('Guest stdio admission was not confirmed');
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
clearTimeout(handshakeTimeout);
|
|
127
|
+
try {
|
|
128
|
+
await close();
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
host.uncertain();
|
|
132
|
+
}
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
const frames = readFrames(response.body);
|
|
136
|
+
try {
|
|
137
|
+
const first = await frames.next();
|
|
138
|
+
if (first.done || first.value.type !== 'stdio_started' || first.value.version !== 1)
|
|
139
|
+
throw new Error('Guest stdio startup acknowledgement is missing');
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
try {
|
|
143
|
+
await close();
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
host.uncertain();
|
|
147
|
+
}
|
|
148
|
+
throw error;
|
|
149
|
+
}
|
|
150
|
+
finally {
|
|
151
|
+
clearTimeout(handshakeTimeout);
|
|
152
|
+
}
|
|
153
|
+
options?.signal?.addEventListener('abort', onAbort, { once: true });
|
|
154
|
+
if (options?.signal?.aborted)
|
|
155
|
+
onAbort();
|
|
156
|
+
void (async () => {
|
|
157
|
+
try {
|
|
158
|
+
for await (const frame of frames) {
|
|
159
|
+
if (frame.type === 'stdio_heartbeat') {
|
|
160
|
+
if (frame.version !== 1 || Object.keys(frame).length !== 2)
|
|
161
|
+
throw new Error('Invalid guest stdio heartbeat');
|
|
162
|
+
// Transport liveness is not stdout, an RPC reply or device admission.
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
if (frame.type === 'result') {
|
|
166
|
+
confirmed = true;
|
|
167
|
+
// The consumer may still have an exact reply in its queue. Its RPC
|
|
168
|
+
// adapter settles that reply before classifying remaining EOF calls.
|
|
169
|
+
finish();
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (frame.type !== 'stdio_data' ||
|
|
173
|
+
!['stdout', 'stderr'].includes(String(frame.stream)) ||
|
|
174
|
+
typeof frame.data !== 'string')
|
|
175
|
+
throw new Error('Invalid guest stdio stream frame');
|
|
176
|
+
const bytes = Buffer.from(frame.data, 'base64');
|
|
177
|
+
if (bytes.toString('base64') !== frame.data)
|
|
178
|
+
throw new Error('Invalid guest stdio stream bytes');
|
|
179
|
+
while (!terminal && queuedBytes >= MAX_QUEUED_BYTES)
|
|
180
|
+
await new Promise((resolve) => {
|
|
181
|
+
producerWake = resolve;
|
|
182
|
+
});
|
|
183
|
+
if (terminal)
|
|
184
|
+
return;
|
|
185
|
+
queue.push({ stream: frame.stream, data: bytes });
|
|
186
|
+
queuedBytes += bytes.length;
|
|
187
|
+
consumerWake?.();
|
|
188
|
+
}
|
|
189
|
+
if (!confirmed)
|
|
190
|
+
throw new Error('Guest stdio stream ended without process-group confirmation');
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
if (confirmed)
|
|
194
|
+
return;
|
|
195
|
+
if (operations.size)
|
|
196
|
+
unknown();
|
|
197
|
+
try {
|
|
198
|
+
await cancel();
|
|
199
|
+
confirmed = true;
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
unknown();
|
|
203
|
+
}
|
|
204
|
+
finish(error instanceof Error ? error : new Error('Guest stdio stream failed'));
|
|
205
|
+
}
|
|
206
|
+
})();
|
|
207
|
+
return {
|
|
208
|
+
closed,
|
|
209
|
+
close,
|
|
210
|
+
allocationEnded() {
|
|
211
|
+
confirmed = true;
|
|
212
|
+
controller.abort();
|
|
213
|
+
finish();
|
|
214
|
+
},
|
|
215
|
+
events: {
|
|
216
|
+
async *[Symbol.asyncIterator]() {
|
|
217
|
+
if (claimed)
|
|
218
|
+
throw new Error('Guest stdio supports one stream consumer');
|
|
219
|
+
claimed = true;
|
|
220
|
+
while (true) {
|
|
221
|
+
if (queue.length) {
|
|
222
|
+
const event = queue.shift();
|
|
223
|
+
if (!event)
|
|
224
|
+
continue;
|
|
225
|
+
queuedBytes -= event.data.length;
|
|
226
|
+
producerWake?.();
|
|
227
|
+
yield event;
|
|
228
|
+
}
|
|
229
|
+
else if (terminal) {
|
|
230
|
+
if (failure)
|
|
231
|
+
throw failure;
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
else
|
|
235
|
+
await new Promise((resolve) => {
|
|
236
|
+
consumerWake = resolve;
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
async beginOperation(signal) {
|
|
242
|
+
if (terminal || closing)
|
|
243
|
+
throw new Error('Guest stdio channel has ended');
|
|
244
|
+
const release = await host.acquire(signal);
|
|
245
|
+
if (terminal || closing) {
|
|
246
|
+
release();
|
|
247
|
+
throw new Error('Guest stdio channel has ended');
|
|
248
|
+
}
|
|
249
|
+
let ended = false;
|
|
250
|
+
const operation = {
|
|
251
|
+
unknown: () => {
|
|
252
|
+
if (!ended) {
|
|
253
|
+
ended = true;
|
|
254
|
+
host.uncertain();
|
|
255
|
+
operations.delete(operation);
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
operations.add(operation);
|
|
260
|
+
return {
|
|
261
|
+
complete() {
|
|
262
|
+
if (!ended) {
|
|
263
|
+
ended = true;
|
|
264
|
+
operations.delete(operation);
|
|
265
|
+
release();
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
outcomeUnknown: operation.unknown,
|
|
269
|
+
};
|
|
270
|
+
},
|
|
271
|
+
async write(data, signal) {
|
|
272
|
+
if (terminal || closing)
|
|
273
|
+
throw new Error('Guest stdio channel has ended');
|
|
274
|
+
const bytes = Buffer.from(data);
|
|
275
|
+
if (bytes.length > 1024 * 1024)
|
|
276
|
+
throw new Error('Guest stdio write exceeds 1 MiB; split the byte stream');
|
|
277
|
+
const release = await host.acquire(signal);
|
|
278
|
+
let issued = false;
|
|
279
|
+
try {
|
|
280
|
+
if (terminal || closing)
|
|
281
|
+
throw new Error('Guest stdio channel has ended');
|
|
282
|
+
signal?.throwIfAborted();
|
|
283
|
+
issued = true;
|
|
284
|
+
const result = await post('/executions/write', { executionId, data: bytes.toString('base64') }, signal);
|
|
285
|
+
if (result.ok !== true || result.bytesWritten !== bytes.length)
|
|
286
|
+
throw new Error('Guest stdin delivery was not confirmed');
|
|
287
|
+
}
|
|
288
|
+
catch (error) {
|
|
289
|
+
if (issued)
|
|
290
|
+
unknown();
|
|
291
|
+
throw error;
|
|
292
|
+
}
|
|
293
|
+
finally {
|
|
294
|
+
release();
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
async function* readFrames(body) {
|
|
300
|
+
const reader = body.getReader();
|
|
301
|
+
let pending = '';
|
|
302
|
+
const decoder = new TextDecoder();
|
|
303
|
+
try {
|
|
304
|
+
while (true) {
|
|
305
|
+
const next = await reader.read();
|
|
306
|
+
if (next.done)
|
|
307
|
+
break;
|
|
308
|
+
pending += decoder.decode(next.value, { stream: true });
|
|
309
|
+
let newline = pending.indexOf('\n');
|
|
310
|
+
while (newline >= 0) {
|
|
311
|
+
if (newline > MAX_FRAME_BYTES)
|
|
312
|
+
throw new Error('Guest stdio frame exceeds its bound');
|
|
313
|
+
const frame = JSON.parse(pending.slice(0, newline));
|
|
314
|
+
pending = pending.slice(newline + 1);
|
|
315
|
+
newline = pending.indexOf('\n');
|
|
316
|
+
if (!frame || typeof frame !== 'object')
|
|
317
|
+
throw new Error('Invalid guest stdio frame');
|
|
318
|
+
yield frame;
|
|
319
|
+
}
|
|
320
|
+
if (pending.length > MAX_FRAME_BYTES)
|
|
321
|
+
throw new Error('Guest stdio frame exceeds its bound');
|
|
322
|
+
}
|
|
323
|
+
if (pending.trim())
|
|
324
|
+
throw new Error('Truncated guest stdio frame');
|
|
325
|
+
}
|
|
326
|
+
finally {
|
|
327
|
+
reader.releaseLock();
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
//# sourceMappingURL=guest-stdio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guest-stdio.js","sourceRoot":"","sources":["../../src/local-virtual-computer/guest-stdio.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AASvE,MAAM,eAAe,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA;AACvC,MAAM,gBAAgB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA;AAOxC,wFAAwF;AACxF,MAAM,CAAC,KAAK,UAAU,cAAc,CACnC,IAAoB,EACpB,OAAe,EACf,IAAuB,EACvB,OAA6B;IAE7B,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC;QACzF,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAA;IACnE,MAAM,OAAO,GAAG,EAAE,cAAc,EAAE,kBAAkB,EAAE,GAAG,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAA;IAC1F,MAAM,IAAI,GAAG,KAAK,EAAE,KAAa,EAAE,IAAa,EAAE,MAAoB,EAAE,EAAE;QACzE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,YAAY,GAAG,KAAK,EAAE,EAAE;YAC5D,MAAM,EAAE,MAAM;YACd,OAAO;YACP,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;YAC1B,MAAM,EAAE,MAAM;gBACb,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CA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,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QAC7F,CAAC;QACD,IAAI,OAAO,CAAC,IAAI,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;IACnE,CAAC;YAAS,CAAC;QACV,MAAM,CAAC,WAAW,EAAE,CAAA;IACrB,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { PalEnvironmentProvider } from '@namzu/sdk';
|
|
2
|
+
import { type EngineDialect, type LocalComputerCommandRunner } from './engine.js';
|
|
3
|
+
export type { LocalComputerCommandRunner } from './engine.js';
|
|
4
|
+
export { type EngineDialect, LocalComputerSetupError, type LocalComputerSetupCode, } from './engine.js';
|
|
5
|
+
export declare const LOCAL_COMPUTER_IMAGE = "namzu-local-computer:1";
|
|
6
|
+
export declare const LOCAL_COMPUTER_PROTOCOL_LABEL = "org.namzu.local-computer.protocol";
|
|
7
|
+
/** Uses an already installed local engine and an already built guest image. */
|
|
8
|
+
export interface LocalVirtualComputerOptions {
|
|
9
|
+
readonly image?: string;
|
|
10
|
+
/** Foreground applications normally belong to the computer after a successful launcher. */
|
|
11
|
+
readonly normalExitPolicy?: 'strict' | 'computer-lifetime';
|
|
12
|
+
/**
|
|
13
|
+
* Docker remains the default. Podman requires an explicitly selected local
|
|
14
|
+
* Windows WSL machine. wslc is Windows' own container CLI for WSL and must be
|
|
15
|
+
* selected explicitly; it is never chosen automatically.
|
|
16
|
+
*/
|
|
17
|
+
readonly engine?: EngineDialect;
|
|
18
|
+
readonly dockerBinary?: string;
|
|
19
|
+
/** Path to wslc.exe; defaults to the WSL install directory, then PATH. */
|
|
20
|
+
readonly wslcBinary?: string;
|
|
21
|
+
readonly podmanBinary?: string;
|
|
22
|
+
readonly podmanMachine?: string;
|
|
23
|
+
readonly podmanConnection?: string;
|
|
24
|
+
readonly engineEndpoint?: string;
|
|
25
|
+
readonly readyTimeoutMs?: number;
|
|
26
|
+
readonly width?: number;
|
|
27
|
+
readonly height?: number;
|
|
28
|
+
/** Host transport injection for embedders/tests; contains authority, never model input. */
|
|
29
|
+
readonly runner?: LocalComputerCommandRunner;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A separate guest desktop in a local Linux container. It does not provision
|
|
33
|
+
* a dedicated-kernel VM and never falls back to the operator's desktop.
|
|
34
|
+
*/
|
|
35
|
+
export declare function createLocalVirtualComputerProvider(options?: LocalVirtualComputerOptions): PalEnvironmentProvider;
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/local-virtual-computer/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAuB,sBAAsB,EAAyB,MAAM,YAAY,CAAA;AAWpG,OAAO,EACN,KAAK,aAAa,EAElB,KAAK,0BAA0B,EAK/B,MAAM,aAAa,CAAA;AAKpB,YAAY,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA;AAC7D,OAAO,EACN,KAAK,aAAa,EAClB,uBAAuB,EACvB,KAAK,sBAAsB,GAC3B,MAAM,aAAa,CAAA;AAEpB,eAAO,MAAM,oBAAoB,2BAA2B,CAAA;AAC5D,eAAO,MAAM,6BAA6B,sCAAsC,CAAA;AAGhF,+EAA+E;AAC/E,MAAM,WAAW,2BAA2B;IAC3C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,2FAA2F;IAC3F,QAAQ,CAAC,gBAAgB,CAAC,EAAE,QAAQ,GAAG,mBAAmB,CAAA;IAC1D;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAA;IAC/B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,0EAA0E;IAC1E,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,C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