diff --git a/.github/workflows/deploy-device-gateway.yml b/.github/workflows/deploy-device-gateway.yml index 8b1e1f29f5..33853463d1 100644 --- a/.github/workflows/deploy-device-gateway.yml +++ b/.github/workflows/deploy-device-gateway.yml @@ -8,7 +8,7 @@ on: branches: [canary] paths: - 'apps/device-gateway/**' - workflow_dispatch: + workflow_dispatch: {} concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/apps/device-gateway/package.json b/apps/device-gateway/package.json index d8dfad632e..9423498443 100644 --- a/apps/device-gateway/package.json +++ b/apps/device-gateway/package.json @@ -3,8 +3,8 @@ "version": "0.1.0", "private": true, "scripts": { - "dev": "wrangler dev", "deploy": "wrangler deploy", + "dev": "wrangler dev", "type-check": "tsc --noEmit" }, "dependencies": { diff --git a/apps/device-gateway/src/DeviceGatewayDO.ts b/apps/device-gateway/src/DeviceGatewayDO.ts index 3e909366f6..c30518c0e8 100644 --- a/apps/device-gateway/src/DeviceGatewayDO.ts +++ b/apps/device-gateway/src/DeviceGatewayDO.ts @@ -1,6 +1,6 @@ import { DurableObject } from 'cloudflare:workers'; -import { DeviceAttachment, Env } from './types'; +import type { DeviceAttachment, Env } from './types'; export class DeviceGatewayDO extends DurableObject { private pendingRequests = new Map< @@ -95,7 +95,11 @@ export class DeviceGatewayDO extends DurableObject { ); } - const { deviceId, timeout = 30_000, toolCall } = (await request.json()) as { + const { + deviceId, + timeout = 30_000, + toolCall, + } = (await request.json()) as { deviceId?: string; timeout?: number; toolCall: unknown; diff --git a/apps/device-gateway/src/auth.ts b/apps/device-gateway/src/auth.ts index 61752ee1e0..f1d9af940c 100644 --- a/apps/device-gateway/src/auth.ts +++ b/apps/device-gateway/src/auth.ts @@ -1,6 +1,6 @@ import { importJWK, jwtVerify } from 'jose'; -import { Env } from './types'; +import type { Env } from './types'; let cachedKey: CryptoKey | null = null; diff --git a/apps/device-gateway/src/index.ts b/apps/device-gateway/src/index.ts index c766c0a871..6def5c28c5 100644 --- a/apps/device-gateway/src/index.ts +++ b/apps/device-gateway/src/index.ts @@ -1,6 +1,6 @@ import { verifyDesktopToken } from './auth'; import { DeviceGatewayDO } from './DeviceGatewayDO'; -import { Env } from './types'; +import type { Env } from './types'; export { DeviceGatewayDO }; diff --git a/package.json b/package.json index 4036e09511..3871a1a252 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "build:docker": "pnpm run build:spa && pnpm run build:spa:mobile && pnpm run build:spa:copy && cross-env NODE_OPTIONS=--max-old-space-size=8192 DOCKER=true next build && pnpm run build-sitemap", "build:next": "cross-env NODE_OPTIONS=--max-old-space-size=6144 next build", "build:spa": "rm -rf public/spa && cross-env NODE_OPTIONS=--max-old-space-size=6144 vite build", - "build:spa:copy": "mkdir -p public/spa && for dir in assets i18n vendor; do ([ -d dist/desktop/$dir ] && cp -r dist/desktop/$dir public/spa/ || true) && ([ -d dist/mobile/$dir ] && cp -r dist/mobile/$dir public/spa/ || true); done && tsx scripts/generateSpaTemplates.mts", + "build:spa:copy": "tsx scripts/copySpaBuild.mts && tsx scripts/generateSpaTemplates.mts", "build:spa:mobile": "cross-env NODE_OPTIONS=--max-old-space-size=8192 MOBILE=true vite build", "build:vercel": "bun run build && bun run db:migrate", "build-migrate-db": "bun run db:migrate", diff --git a/packages/agent-tracing/tsconfig.json b/packages/agent-tracing/tsconfig.json index 6ddc33fbfb..1b9d693dc9 100644 --- a/packages/agent-tracing/tsconfig.json +++ b/packages/agent-tracing/tsconfig.json @@ -1,7 +1,7 @@ { - "extends": "../../tsconfig.json", "compilerOptions": { "outDir": "./dist" }, + "extends": "../../tsconfig.json", "include": ["src/**/*.ts"] } diff --git a/packages/context-engine/src/providers/UserMemoryInjector.ts b/packages/context-engine/src/providers/UserMemoryInjector.ts index f070f40b75..ae6dcd7a59 100644 --- a/packages/context-engine/src/providers/UserMemoryInjector.ts +++ b/packages/context-engine/src/providers/UserMemoryInjector.ts @@ -1,9 +1,9 @@ -import { type UserMemoryData } from '@lobechat/prompts'; +import { type UserMemoryData } from '@lobechat/prompts'; import { promptUserMemory } from '@lobechat/prompts'; import debug from 'debug'; import { BaseFirstUserContentProvider } from '../base/BaseFirstUserContentProvider'; -import { type PipelineContext, type ProcessorOptions } from '../types'; +import { type PipelineContext, type ProcessorOptions } from '../types'; const log = debug('context-engine:provider:UserMemoryInjector'); diff --git a/scripts/copySpaBuild.mts b/scripts/copySpaBuild.mts new file mode 100644 index 0000000000..a883c256b4 --- /dev/null +++ b/scripts/copySpaBuild.mts @@ -0,0 +1,21 @@ +import { cpSync, existsSync, mkdirSync } from 'node:fs'; +import path from 'node:path'; + +const root = path.resolve(import.meta.dirname, '..'); +const spaDir = path.resolve(root, 'public/spa'); +const distDirs = ['desktop', 'mobile'] as const; +const copyDirs = ['assets', 'i18n', 'vendor'] as const; + +mkdirSync(spaDir, { recursive: true }); + +for (const distDir of distDirs) { + for (const dir of copyDirs) { + const sourceDir = path.resolve(root, `dist/${distDir}/${dir}`); + const targetDir = path.resolve(spaDir, dir); + + if (!existsSync(sourceDir)) continue; + + cpSync(sourceDir, targetDir, { recursive: true }); + console.log(`Copied dist/${distDir}/${dir} -> public/spa/${dir}`); + } +} diff --git a/scripts/devStartupSequence.mts b/scripts/devStartupSequence.mts index 62d56bc383..099e7d3d92 100644 --- a/scripts/devStartupSequence.mts +++ b/scripts/devStartupSequence.mts @@ -1,7 +1,7 @@ import { type ChildProcess, spawn } from 'node:child_process'; import { readFileSync } from 'node:fs'; -import { resolve } from 'node:path'; import net from 'node:net'; +import { resolve } from 'node:path'; const NEXT_HOST = 'localhost'; @@ -17,7 +17,9 @@ const resolveNextPort = (): number => { const match = devNext.match(/(?:--port|-p)\s+(\d+)/); if (match) return Number(match[1]); } - } catch { /* fallback */ } + } catch { + /* fallback */ + } return 3010; }; @@ -36,6 +38,7 @@ const runNpmScript = (scriptName: string) => spawn(npmCommand, ['run', scriptName], { env: process.env, stdio: 'inherit', + shell: process.platform === 'win32', }); const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));