MCPcopy Index your code
hub / github.com/simstudioai/sim / createSession

Function createSession

apps/sim/executor/handlers/pi/ssh-tools.test.ts:26–45  ·  view source on GitHub ↗
(files: Record<string, string>)

Source from the content-addressed store, hash-verified

24import { buildSshToolSpecs } from '@/executor/handlers/pi/ssh-tools'
25
26function createSession(files: Record<string, string>): PiSshSession {
27 const sftp = {
28 readFile: (path: string, cb: (err: Error | undefined, data: Buffer) => void) => {
29 if (!(path in files)) {
30 cb(new Error(`no such file: ${path}`), Buffer.from(''))
31 return
32 }
33 cb(undefined, Buffer.from(files[path]))
34 },
35 writeFile: (path: string, data: string, cb: (err?: Error) => void) => {
36 files[path] = data
37 cb(undefined)
38 },
39 }
40 return {
41 client: {} as PiSshSession['client'],
42 sftp: sftp as unknown as PiSshSession['sftp'],
43 close: vi.fn(),
44 }
45}
46
47function getTool(repoPath: string, files: Record<string, string>, name: string) {
48 const tools = buildSshToolSpecs(createSession(files), repoPath)

Callers 1

getToolFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected