MCPcopy Create free account
hub / github.com/TanStack/ai / handleSpawning

Function handleSpawning

packages/ai-sandbox/tests/runner.test.ts:20–55  ·  view source on GitHub ↗

Minimal handle whose process.spawn replays scripted stdout chunks.

(chunks: Array<string>)

Source from the content-addressed store, hash-verified

18
19/** Minimal handle whose process.spawn replays scripted stdout chunks. */
20function handleSpawning(chunks: Array<string>): SandboxHandle {
21 const spawnHandle: SpawnHandle = {
22 pid: 1,
23 stdout: fromChunks(chunks),
24 stderr: fromChunks([]),
25 stdin: { write: () => Promise.resolve(), end: () => Promise.resolve() },
26 wait: () => Promise.resolve(0),
27 kill: () => Promise.resolve(),
28 }
29 return {
30 id: 'fake',
31 provider: 'fake',
32 capabilities: {
33 fs: true,
34 exec: true,
35 env: true,
36 ports: false,
37 backgroundProcesses: true,
38 writableStdin: true,
39 snapshots: false,
40 networkPolicy: false,
41 durableFilesystem: false,
42 fork: false,
43 },
44 // Only process.spawn is exercised here.
45 fs: {} as SandboxHandle['fs'],
46 git: {} as SandboxHandle['git'],
47 process: {
48 exec: () => Promise.reject(new Error('unused')),
49 spawn: () => Promise.resolve(spawnHandle),
50 },
51 ports: { connect: () => Promise.reject(new Error('unused')) },
52 env: { set: () => Promise.resolve() },
53 destroy: () => Promise.resolve(),
54 }
55}
56
57describe('toLines', () => {
58 it('reassembles lines split across chunk boundaries', async () => {

Callers 1

runner.test.tsFile · 0.85

Calls 2

resolveMethod · 0.80
fromChunksFunction · 0.70

Tested by

no test coverage detected