mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
refactor(web): change old port (7003) and deploy port (80) to port 8082
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
"start": "pnpm run build && bun run dist/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@memoh/config": "workspace:*",
|
||||
"@ai-sdk/amazon-bedrock": "^4.0.56",
|
||||
"@ai-sdk/anthropic": "^3.0.9",
|
||||
"@ai-sdk/azure": "^3.0.28",
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
import { readFileSync } from 'fs'
|
||||
import { parse } from 'toml'
|
||||
|
||||
type AgentGatewayConfig = {
|
||||
'agent_gateway': {
|
||||
host?: string
|
||||
server_addr?: string
|
||||
port?: number
|
||||
},
|
||||
'server': {
|
||||
addr?: string
|
||||
},
|
||||
'brave'?: {
|
||||
api_key?: string
|
||||
base_url?: string
|
||||
}
|
||||
}
|
||||
|
||||
export const loadConfig = (path: string = './config.toml'): AgentGatewayConfig => {
|
||||
const config = parse(readFileSync(path, 'utf-8'))
|
||||
return config satisfies AgentGatewayConfig
|
||||
}
|
||||
+2
-21
@@ -2,7 +2,7 @@ import { Elysia } from 'elysia'
|
||||
import { chatModule } from './modules/chat'
|
||||
import { corsMiddleware } from './middlewares/cors'
|
||||
import { errorMiddleware } from './middlewares/error'
|
||||
import { loadConfig } from './config'
|
||||
import { loadConfig, getBaseUrl as getBaseUrlByConfig } from '@memoh/config'
|
||||
|
||||
const config = loadConfig('../config.toml')
|
||||
|
||||
@@ -19,26 +19,7 @@ export const getBraveConfig = () => {
|
||||
}
|
||||
|
||||
export const getBaseUrl = () => {
|
||||
const rawAddr =
|
||||
typeof config.agent_gateway.server_addr === 'string'
|
||||
? config.agent_gateway.server_addr.trim()
|
||||
: typeof config.server.addr === 'string'
|
||||
? config.server.addr.trim()
|
||||
: ''
|
||||
|
||||
if (!rawAddr) {
|
||||
return 'http://127.0.0.1'
|
||||
}
|
||||
|
||||
if (rawAddr.startsWith('http://') || rawAddr.startsWith('https://')) {
|
||||
return rawAddr.replace(/\/+$/, '')
|
||||
}
|
||||
|
||||
if (rawAddr.startsWith(':')) {
|
||||
return `http://127.0.0.1${rawAddr}`
|
||||
}
|
||||
|
||||
return `http://${rawAddr}`
|
||||
return getBaseUrlByConfig(config)
|
||||
}
|
||||
|
||||
export type AuthFetcher = (
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@
|
||||
/* Modules */
|
||||
"module": "ES2022", /* Specify what module code is generated. */
|
||||
// "rootDir": "./", /* Specify the root folder within your source files. */
|
||||
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
||||
"moduleResolution": "bundler", /* Specify how TypeScript looks up a file from a given module specifier. */
|
||||
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
||||
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
||||
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
||||
|
||||
+1
-1
@@ -118,7 +118,7 @@ services:
|
||||
- VITE_AGENT_URL=http://localhost:8081
|
||||
container_name: memoh-web
|
||||
ports:
|
||||
- "80:80"
|
||||
- "8082:8082"
|
||||
depends_on:
|
||||
- server
|
||||
- agent
|
||||
|
||||
@@ -27,9 +27,9 @@ COPY --from=builder /build/packages/web/dist /usr/share/nginx/html
|
||||
|
||||
COPY docker/config/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
EXPOSE 80
|
||||
EXPOSE 8082
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost/health || exit 1
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost:8082/health || exit 1
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
listen 8082;
|
||||
listen [::]:8082;
|
||||
server_name _;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# dependencies (bun install)
|
||||
node_modules
|
||||
|
||||
# output
|
||||
out
|
||||
dist
|
||||
*.tgz
|
||||
|
||||
# code coverage
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# logs
|
||||
logs
|
||||
_.log
|
||||
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
||||
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# caches
|
||||
.eslintcache
|
||||
.cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# IntelliJ based IDEs
|
||||
.idea
|
||||
|
||||
# Finder (MacOS) folder config
|
||||
.DS_Store
|
||||
@@ -0,0 +1,2 @@
|
||||
# @memoh/config
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "@memoh/config",
|
||||
"version": "1.0.0",
|
||||
"exports": {
|
||||
".": "./src/index.ts"
|
||||
},
|
||||
"packageManager": "pnpm@10.27.0",
|
||||
"module": "src/index.ts",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"peerDependencies": {
|
||||
"typescript": "^5"
|
||||
},
|
||||
"dependencies": {
|
||||
"toml": "^3.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { parse } from 'toml'
|
||||
import { readFileSync } from 'fs'
|
||||
import type { Config } from './types'
|
||||
|
||||
export const loadConfig = (path: string = './config.toml'): Config => {
|
||||
const config = parse(readFileSync(path, 'utf-8'))
|
||||
return config satisfies Config
|
||||
}
|
||||
|
||||
export const getBaseUrl = (config: Config) => {
|
||||
const rawAddr = typeof config.server.addr === 'string' ? config.server.addr.trim() : ''
|
||||
|
||||
if (!rawAddr) {
|
||||
return 'http://127.0.0.1'
|
||||
}
|
||||
|
||||
if (rawAddr.startsWith('http://') || rawAddr.startsWith('https://')) {
|
||||
return rawAddr.replace(/\/+$/, '')
|
||||
}
|
||||
|
||||
if (rawAddr.startsWith(':')) {
|
||||
return `http://127.0.0.1${rawAddr}`
|
||||
}
|
||||
|
||||
return `http://${rawAddr}`
|
||||
}
|
||||
|
||||
export * from './types'
|
||||
@@ -0,0 +1,76 @@
|
||||
export interface Config {
|
||||
log: LogConfig;
|
||||
server: ServerConfig;
|
||||
admin: AdminConfig;
|
||||
auth: AuthConfig;
|
||||
containerd: ContainerdConfig;
|
||||
mcp: McpConfig;
|
||||
postgres: PostgresConfig;
|
||||
qdrant: QdrantConfig;
|
||||
agent_gateway: AgentGatewayConfig;
|
||||
web: WebConfig;
|
||||
brave: BraveConfig;
|
||||
}
|
||||
|
||||
export interface LogConfig {
|
||||
level: string;
|
||||
format: string;
|
||||
}
|
||||
|
||||
export interface ServerConfig {
|
||||
addr: string;
|
||||
}
|
||||
|
||||
export interface AdminConfig {
|
||||
username: string;
|
||||
password: string;
|
||||
email: string;
|
||||
}
|
||||
|
||||
export interface AuthConfig {
|
||||
jwt_secret: string;
|
||||
jwt_expires_in: string;
|
||||
}
|
||||
|
||||
export interface ContainerdConfig {
|
||||
socket_path: string;
|
||||
namespace: string;
|
||||
}
|
||||
|
||||
export interface McpConfig {
|
||||
image: string;
|
||||
snapshotter: string;
|
||||
data_root: string;
|
||||
data_mount: string;
|
||||
}
|
||||
|
||||
export interface PostgresConfig {
|
||||
host: string;
|
||||
port: number;
|
||||
user: string;
|
||||
password: string;
|
||||
database: string;
|
||||
sslmode: string;
|
||||
}
|
||||
|
||||
export interface QdrantConfig {
|
||||
base_url: string;
|
||||
api_key: string;
|
||||
collection: string;
|
||||
timeout_seconds: number;
|
||||
}
|
||||
|
||||
export interface AgentGatewayConfig {
|
||||
host: string;
|
||||
port: number;
|
||||
}
|
||||
|
||||
export interface WebConfig {
|
||||
host: string;
|
||||
port: number;
|
||||
}
|
||||
|
||||
export interface BraveConfig {
|
||||
api_key: string;
|
||||
base_url: string;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"lib": ["ES2022"],
|
||||
"moduleResolution": "bundler",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"jsx": "react-jsx",
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
|
||||
@@ -503,6 +503,7 @@ export type HandlersMemorySearchPayload = {
|
||||
[key: string]: unknown;
|
||||
};
|
||||
limit?: number;
|
||||
no_stats?: boolean;
|
||||
query?: string;
|
||||
run_id?: string;
|
||||
sources?: Array<string>;
|
||||
@@ -597,6 +598,7 @@ export type MemoryDeleteResponse = {
|
||||
export type MemoryMemoryItem = {
|
||||
agent_id?: string;
|
||||
bot_id?: string;
|
||||
cdf_curve?: Array<MemoryCdfPoint>;
|
||||
created_at?: string;
|
||||
hash?: string;
|
||||
id?: string;
|
||||
@@ -606,6 +608,7 @@ export type MemoryMemoryItem = {
|
||||
};
|
||||
run_id?: string;
|
||||
score?: number;
|
||||
top_k_buckets?: Array<MemoryTopKBucket>;
|
||||
updated_at?: string;
|
||||
};
|
||||
|
||||
@@ -622,10 +625,8 @@ export type MemoryRebuildResult = {
|
||||
};
|
||||
|
||||
export type MemorySearchResponse = {
|
||||
cdf_curve?: Array<MemoryCdfPoint>;
|
||||
relations?: Array<unknown>;
|
||||
results?: Array<MemoryMemoryItem>;
|
||||
top_k_buckets?: Array<MemoryTopKBucket>;
|
||||
};
|
||||
|
||||
export type MemoryTopKBucket = {
|
||||
@@ -1791,7 +1792,12 @@ export type GetBotsByBotIdMemoryData = {
|
||||
*/
|
||||
bot_id: string;
|
||||
};
|
||||
query?: never;
|
||||
query?: {
|
||||
/**
|
||||
* Skip sparse vector stats (top_k_buckets, cdf_curve) to reduce overhead
|
||||
*/
|
||||
no_stats?: boolean;
|
||||
};
|
||||
url: '/bots/{bot_id}/memory';
|
||||
};
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
"@types/node": "^24.10.1",
|
||||
"@vitejs/plugin-vue": "^6.0.1",
|
||||
"@vue/tsconfig": "^0.8.1",
|
||||
"@memoh/config": "workspace:*",
|
||||
"typescript": "~5.9.3",
|
||||
"vite": "^7.2.4",
|
||||
"vue-tsc": "^3.1.4"
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import { config } from 'dotenv'
|
||||
import tailwindcss from '@tailwindcss/vite'
|
||||
import { fileURLToPath } from 'url'
|
||||
import { loadConfig, getBaseUrl } from '@memoh/config'
|
||||
|
||||
config({
|
||||
path: '../../.env',
|
||||
})
|
||||
|
||||
const port = Number(process.env.WEB_PORT || 7003)
|
||||
const config = loadConfig('../../config.toml')
|
||||
const { web: { port = 8082, host = '127.0.0.1' } } = config
|
||||
const baseUrl = getBaseUrl(config)
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [vue(), tailwindcss()],
|
||||
server: {
|
||||
port,
|
||||
host: '0.0.0.0',
|
||||
host,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:8080',
|
||||
target: baseUrl,
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/api/, '')
|
||||
}
|
||||
@@ -29,7 +27,7 @@ export default defineConfig({
|
||||
host: '0.0.0.0',
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:8080',
|
||||
target: baseUrl,
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/api/, '')
|
||||
}
|
||||
|
||||
Generated
+15
@@ -72,6 +72,9 @@ importers:
|
||||
'@elysiajs/cors':
|
||||
specifier: ^1.4.1
|
||||
version: 1.4.1(elysia@1.4.22(@sinclair/typebox@0.34.47)(@types/bun@1.3.8)(exact-mirror@0.2.6(@sinclair/typebox@0.34.47))(file-type@21.3.0)(openapi-types@12.1.3)(typescript@5.9.3))
|
||||
'@memoh/config':
|
||||
specifier: workspace:*
|
||||
version: link:../packages/config
|
||||
'@modelcontextprotocol/sdk':
|
||||
specifier: ^1.25.2
|
||||
version: 1.25.2(@cfworker/json-schema@4.1.1)(hono@4.11.4)(zod@4.3.5)
|
||||
@@ -156,6 +159,15 @@ importers:
|
||||
specifier: latest
|
||||
version: 1.3.8
|
||||
|
||||
packages/config:
|
||||
dependencies:
|
||||
toml:
|
||||
specifier: ^3.0.0
|
||||
version: 3.0.0
|
||||
typescript:
|
||||
specifier: ^5
|
||||
version: 5.9.3
|
||||
|
||||
packages/sdk:
|
||||
dependencies:
|
||||
'@pinia/colada':
|
||||
@@ -343,6 +355,9 @@ importers:
|
||||
specifier: ^4.3.5
|
||||
version: 4.3.5
|
||||
devDependencies:
|
||||
'@memoh/config':
|
||||
specifier: workspace:*
|
||||
version: link:../config
|
||||
'@types/node':
|
||||
specifier: ^24.10.1
|
||||
version: 24.10.4
|
||||
|
||||
+1
-1
@@ -145,7 +145,7 @@ echo "${GREEN}========================================${NC}"
|
||||
echo "${GREEN} Memoh is running!${NC}"
|
||||
echo "${GREEN}========================================${NC}"
|
||||
echo ""
|
||||
echo " Web UI: http://localhost"
|
||||
echo " Web UI: http://localhost:8082"
|
||||
echo " API: http://localhost:8080"
|
||||
echo " Agent Gateway: http://localhost:8081"
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user