feat: add companion API and Android APK shell

This commit is contained in:
Hermes Agent
2026-07-09 04:43:00 +00:00
parent bd0cf34aa3
commit 7eb9648eb7
92 changed files with 7907 additions and 877 deletions
+25
View File
@@ -0,0 +1,25 @@
import type { FastifyInstance } from 'fastify';
import { terminalRunRequestSchema, terminalRunResponseSchema } from '@hermes-mobile/shared';
import type { CompanionConfig } from '../config/companionConfig.js';
import { toSafeAbsolutePath, toWorkspacePath } from '../config/paths.js';
import { runProcess } from '../system/processes.js';
export async function registerTerminalRoutes(app: FastifyInstance, config: CompanionConfig): Promise<void> {
app.post('/api/terminal/run', async (request) => {
const body = terminalRunRequestSchema.parse(request.body);
const cwd = toSafeAbsolutePath(config.workspaceRoot, body.cwd ?? '.');
const result = await runProcess('/bin/sh', ['-lc', body.command], {
cwd,
timeoutMs: body.timeoutMs ?? 10000,
});
return terminalRunResponseSchema.parse({
cwd: toWorkspacePath(config.workspaceRoot, cwd),
command: body.command,
stdout: result.stdout,
stderr: result.stderr,
exitCode: result.exitCode,
timedOut: result.timedOut,
});
});
}