sidecar network host

This commit is contained in:
2026-02-26 03:32:04 +00:00
parent 42abb97d7b
commit 466dc3adda
8 changed files with 310 additions and 420 deletions
+291 -399
View File
File diff suppressed because it is too large Load Diff
+2 -4
View File
@@ -1,12 +1,10 @@
import { mkdir } from 'node:fs/promises';
import { dirname, join } from 'node:path';
import { homedir } from 'node:os';
import { createRouter } from '../../create-router';
import { DATA_PATH } from '@@/data-path';
import { DATA_PATH, SERVER_CONFIG_DIR } from '@@/data-path';
import { CustomError } from '../../custom-errors';
const configDir = `${homedir()}/.config/officer.dev`;
const googleConfigPath = join(configDir, 'google-oauth.json');
const googleConfigPath = join(SERVER_CONFIG_DIR, 'google-oauth.json');
const GOOGLE_SCOPES = [
'https://www.googleapis.com/auth/gmail.readonly',
@@ -1,6 +1,6 @@
import { createRouter } from '../../create-router';
import { homedir } from 'node:os';
import { mkdir } from 'node:fs/promises';
import { SERVER_CONFIG_DIR } from '@@/data-path';
import { readdirSync, existsSync } from 'node:fs';
import { join } from 'node:path';
import { claudeCodeRouter } from './claude-code';
@@ -14,12 +14,11 @@ import { sttRouter } from './stt';
import { ocrRouter } from './ocr';
import { searxngRouter } from './searxng';
const configDir = `${homedir()}/.config/officer.dev`;
export const settingsPath = `${configDir}/server-settings.json`;
export const settingsPath = `${SERVER_CONFIG_DIR}/server-settings.json`;
const settingsFile = Bun.file(settingsPath);
if (!(await settingsFile.exists())) {
await mkdir(configDir, { recursive: true });
await mkdir(SERVER_CONFIG_DIR, { recursive: true });
await Bun.write(settingsPath, '{}');
}
+5 -6
View File
@@ -1,9 +1,9 @@
import type { ServerWebSocket } from 'bun';
import { existsSync, mkdirSync, statSync, writeFileSync } from 'node:fs';
import { homedir } from 'node:os';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { getHomeDir, getGlobalSkillsDir, getGlobalToolsDir, getGlobalExtensionsDir, getUserSkillsDir, getUserToolsDir, DATA_PATH } from '@@/data-path';
import { getHomeDir, getGlobalSkillsDir, getGlobalToolsDir, getGlobalExtensionsDir, getUserSkillsDir, getUserToolsDir, DATA_PATH, SERVER_CONFIG_DIR } from '@@/data-path';
import { syncUserPiConfig } from '@@/api/server-settings/sync-user-pi-config';
import { getUsers } from 'officerdb';
@@ -138,7 +138,7 @@ const startDockerSidecar = (port: number, homeDir: string, userId: number, usern
}
const containerHome = `/home/${username}`;
const googleConfigHost = join(homedir(), '.config', 'officer.dev', 'google-oauth.json');
const googleConfigHost = join(SERVER_CONFIG_DIR, 'google-oauth.json');
const googleMounts: string[] = existsSync(googleConfigHost)
? ['-v', `${googleConfigHost}:/officer/google-oauth.json:ro`]
: [];
@@ -152,12 +152,11 @@ const startDockerSidecar = (port: number, homeDir: string, userId: number, usern
dockerId,
'--restart',
'unless-stopped',
'-p',
`127.0.0.1:${port}:${port}`,
'--network', 'host',
'-e',
`TERMINAL_PTY_PORT=${port}`,
'-e',
'TERMINAL_PTY_HOST=0.0.0.0',
'TERMINAL_PTY_HOST=127.0.0.1',
'-e',
`TERMINAL_USER=${username}`,
'-e',
+2
View File
@@ -2,6 +2,8 @@ import { join, resolve } from 'node:path';
export const DATA_PATH = process.env.DATA_PATH ?? join(process.cwd(), 'data');
export const SERVER_CONFIG_DIR = join(DATA_PATH, 'server-settings');
export const PI_CONFIG_DIR = join(DATA_PATH, 'pi-config');
export const SEED_PATH = resolve(import.meta.dir, '../../seed');
+1 -1
View File
@@ -31,5 +31,5 @@ export async function sign(payload: any, expiration = '30d') {
}
export async function verify(token: string): Promise<any> {
return jwtVerify(token, JWT_SECRET!);
return jwtVerify(token, JWT_SECRET!, 'HS256');
}
+2 -3
View File
@@ -1,9 +1,8 @@
import { join } from 'node:path';
import { homedir } from 'node:os';
import type { Database } from 'bun:sqlite';
import type { JobHandler } from '../types';
import { registerHandler } from '../handler-registry';
import { DATA_PATH } from '../../data-path';
import { DATA_PATH, SERVER_CONFIG_DIR } from '../../data-path';
import { openEmailDb, upsertFromRawEml, getSyncMeta, setSyncMeta, updateEmailLabels } from '../../api/email/email-db';
type GoogleCredentials = {
@@ -14,7 +13,7 @@ type GoogleCredentials = {
clientSecret: string;
};
const googleConfigPath = join(homedir(), '.config', 'officer.dev', 'google-oauth.json');
const googleConfigPath = join(SERVER_CONFIG_DIR, 'google-oauth.json');
async function loadCredentials(userId: string): Promise<GoogleCredentials> {
const config = await Bun.file(googleConfigPath).json().catch(() => null);
+4 -3
View File
@@ -1,7 +1,8 @@
import { createTransport, type Transporter } from 'nodemailer';
import { homedir } from 'node:os';
import { join } from 'node:path';
const { MAIL_TRANSPORT } = process.env;
const { MAIL_TRANSPORT, DATA_PATH } = process.env;
const dataPath = DATA_PATH ?? join(process.cwd(), 'data');
type SmtpConfig = {
provider: 'resend' | 'smtp' | 'mailhog';
@@ -15,7 +16,7 @@ type SmtpConfig = {
fromEmail: string;
};
const settingsPath = `${homedir()}/.config/officer.dev/server-settings.json`;
const settingsPath = join(dataPath, 'server-settings', 'server-settings.json');
let cachedTransport: Transporter | null = null;
let cachedConfigHash: string | null = null;