Skip to content

Commit aef1ce4

Browse files
committed
Prettier
1 parent 12d47d9 commit aef1ce4

File tree

5 files changed

+5518
-4712
lines changed

5 files changed

+5518
-4712
lines changed
Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
import { describe, expect, it } from "vitest";
2-
import { get_file_name_from_path } from "./fileUtils";
1+
import { describe, expect, it } from 'vitest'
32

4-
describe ("get_file_name_from_path", () => {
5-
it("strips files/contents", async () => {
6-
const path = await get_file_name_from_path('/files/contents/cats');
7-
expect(path).toBe("/cats");
8-
}),
9-
it("works if files/contents is not present", async () => {
10-
const path = await get_file_name_from_path('/dogs');
11-
expect(path).toBe("/dogs");
12-
}),
13-
it("strips a trailing slash", async () => {
14-
const path = await get_file_name_from_path('/files/contents/birds/');
15-
expect(path).toBe("/birds");
16-
})
17-
})
3+
import { get_file_name_from_path } from './fileUtils'
4+
5+
describe('get_file_name_from_path', () => {
6+
it('strips files/contents', async () => {
7+
const path = await get_file_name_from_path('/files/contents/cats')
8+
expect(path).toBe('/cats')
9+
}),
10+
it('works if files/contents is not present', async () => {
11+
const path = await get_file_name_from_path('/dogs')
12+
expect(path).toBe('/dogs')
13+
}),
14+
it('strips a trailing slash', async () => {
15+
const path = await get_file_name_from_path('/files/contents/birds/')
16+
expect(path).toBe('/birds')
17+
})
18+
})
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export async function get_file_name_from_path(path: string): Promise<string> {
2-
path = path.replace('/files/contents', '')
2+
path = path.replace('/files/contents', '')
33
path = path.endsWith('/') ? path.substring(0, path.length - 1) : path
44

5-
return path
6-
}
5+
return path
6+
}

apps/sandbox-container/container/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
import { exec } from 'node:child_process'
2+
import * as fs from 'node:fs/promises'
3+
import path from 'node:path'
14
import { serve } from '@hono/node-server'
25
import { zValidator } from '@hono/zod-validator'
36
import { Hono } from 'hono'
47
import { streamText } from 'hono/streaming'
58
import mime from 'mime'
6-
import { exec } from 'node:child_process'
7-
import * as fs from 'node:fs/promises'
8-
import path from 'node:path'
99

10-
import type { FileList } from '../shared/schema.ts'
1110
import { ExecParams, FilesWrite } from '../shared/schema.ts'
1211
import { get_file_name_from_path } from './fileUtils.ts'
1312

13+
import type { FileList } from '../shared/schema.ts'
14+
1415
process.chdir('workdir')
1516

1617
const app = new Hono()
@@ -125,7 +126,7 @@ app.delete('/files/contents/*', async (c) => {
125126
const reqPath = await get_file_name_from_path(c.req.path)
126127

127128
try {
128-
await fs.rm(path.join(process.cwd(), reqPath), {recursive: true})
129+
await fs.rm(path.join(process.cwd(), reqPath), { recursive: true })
129130
return c.newResponse('ok', 200)
130131
} catch (e: any) {
131132
if (e.code) {

apps/sandbox-container/server/containerMcp.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
22
import { McpAgent } from 'agents/mcp'
33
import { z } from 'zod'
44

5-
import type { Env, Props } from '.'
65
import { OPEN_CONTAINER_PORT } from '../shared/consts'
7-
import type { FileList } from '../shared/schema'
86
import { ExecParams, FilePathParam, FilesWrite } from '../shared/schema'
97
import { MAX_CONTAINERS, proxyFetch, startAndWaitForPort } from './containerHelpers'
108
import { getContainerManager } from './containerManager'
119
import { BASE_INSTRUCTIONS } from './prompts'
1210
import { fileToBase64 } from './utils'
1311

12+
import type { FileList } from '../shared/schema'
13+
import type { Env, Props } from '.'
14+
1415
export class ContainerMcpAgent extends McpAgent<Env, Props> {
1516
server = new McpServer(
1617
{
@@ -74,14 +75,13 @@ export class ContainerMcpAgent extends McpAgent<Env, Props> {
7475
this.server.tool(
7576
'container_file_delete',
7677
'Delete file and its contents',
77-
{ args: FilePathParam},
78+
{ args: FilePathParam },
7879
async ({ args }) => {
7980
const deleted = await this.container_file_delete(args)
8081
return {
81-
content: [{ type: 'text', text: `File deleted: ${deleted}.`}]
82+
content: [{ type: 'text', text: `File deleted: ${deleted}.` }],
8283
}
8384
}
84-
8585
)
8686
this.server.tool(
8787
'container_files_write',
@@ -242,12 +242,12 @@ export class ContainerMcpAgent extends McpAgent<Env, Props> {
242242
return json
243243
}
244244

245-
async container_file_delete(filePath: string): Promise<boolean>{
245+
async container_file_delete(filePath: string): Promise<boolean> {
246246
const res = await proxyFetch(
247247
this.env.ENVIRONMENT,
248248
this.ctx.container,
249249
new Request(`http://host:${OPEN_CONTAINER_PORT}/files/contents/${filePath}`, {
250-
method: 'DELETE'
250+
method: 'DELETE',
251251
}),
252252
OPEN_CONTAINER_PORT
253253
)

0 commit comments

Comments
 (0)