@agent-spaces/server 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +21 -24
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/app.js
CHANGED
|
@@ -26,7 +26,6 @@ import { recoverRunningWorkOnStartup } from './services/issue-retry.js';
|
|
|
26
26
|
import { startPersistedNotificationServices } from './services/notification-hub/index.js';
|
|
27
27
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
28
28
|
const PORT = parseInt(process.env.PORT || '3100', 10);
|
|
29
|
-
const IS_PROD = process.env.NODE_ENV === 'production';
|
|
30
29
|
const resolveRuntimeDir = (name) => {
|
|
31
30
|
const currentDir = join(__dirname, name);
|
|
32
31
|
if (existsSync(currentDir))
|
|
@@ -77,31 +76,29 @@ app.use('/api/agents', agentRouter);
|
|
|
77
76
|
app.use('/api', llmRouter);
|
|
78
77
|
app.use('/api/folder', folderRouter);
|
|
79
78
|
// Serve static web frontend in production (after API routes, before catch-all)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
res.sendFile(workspaceHtml);
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
// Everything else -> root index.html
|
|
97
|
-
app.use((_req, res) => {
|
|
98
|
-
res.sendFile(indexHtml);
|
|
79
|
+
const webDir = resolveRuntimeDir('web');
|
|
80
|
+
if (existsSync(webDir)) {
|
|
81
|
+
// /static/* -> public/* (avatar URLs etc.)
|
|
82
|
+
app.use('/static', express.static(publicDir));
|
|
83
|
+
// web static assets (_next, monaco, etc.)
|
|
84
|
+
app.use(express.static(webDir));
|
|
85
|
+
// SPA fallback: serve correct HTML for each route
|
|
86
|
+
const indexHtml = join(webDir, 'index.html');
|
|
87
|
+
const workspaceHtml = join(webDir, 'workspace', '_.html');
|
|
88
|
+
// /workspace/* -> workspace SPA page
|
|
89
|
+
if (existsSync(workspaceHtml)) {
|
|
90
|
+
app.get('/workspace/:id', (_req, res) => {
|
|
91
|
+
res.sendFile(workspaceHtml);
|
|
99
92
|
});
|
|
100
|
-
console.log(`[server] serving web frontend from ${webDir}`);
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
console.warn('[server] web frontend not found at', webDir, '- run \`pnpm build\` first');
|
|
104
93
|
}
|
|
94
|
+
// Everything else -> root index.html
|
|
95
|
+
app.use((_req, res) => {
|
|
96
|
+
res.sendFile(indexHtml);
|
|
97
|
+
});
|
|
98
|
+
console.log(`[server] serving web frontend from ${webDir}`);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
console.warn('[server] web frontend not found at', webDir, '- run \`pnpm build\` first');
|
|
105
102
|
}
|
|
106
103
|
const server = createServer(app);
|
|
107
104
|
const wss = new WebSocketServer({ server, path: '/ws' });
|
package/dist/package.json
CHANGED