@maintainer-pro/ai-server 0.1.9 → 0.1.11
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/package.json +2 -2
- package/src/server.mjs +19 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maintainer-pro/ai-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "Node HTTP server for Maintainer Pro chat. Uses @maintainer-pro/ai-cli to talk to coding agents.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"maintainer-pro",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@maintainer-pro/ai-cli": "^0.1.
|
|
33
|
+
"@maintainer-pro/ai-cli": "^0.1.18",
|
|
34
34
|
"@maintainer-pro/ai-ui": "^0.2.12",
|
|
35
35
|
"ws": "^8.21.3"
|
|
36
36
|
},
|
package/src/server.mjs
CHANGED
|
@@ -225,6 +225,7 @@ Logging (env):
|
|
|
225
225
|
* @param {string} [options.dataDir]
|
|
226
226
|
* @param {string} [options.sandboxId]
|
|
227
227
|
* @param {string} [options.label]
|
|
228
|
+
* @param {(info: { conversationId: string, userMessage: string, assistantText: string, workspaceDir: string }) => unknown} [options.onTurnComplete]
|
|
228
229
|
*/
|
|
229
230
|
export async function startAiServer(options = {}) {
|
|
230
231
|
const env = options.env && typeof options.env === "object" ? options.env : {};
|
|
@@ -296,6 +297,10 @@ export async function startAiServer(options = {}) {
|
|
|
296
297
|
sandboxId: sandboxId || undefined,
|
|
297
298
|
db,
|
|
298
299
|
logger,
|
|
300
|
+
onTurnComplete:
|
|
301
|
+
typeof options.onTurnComplete === "function"
|
|
302
|
+
? options.onTurnComplete
|
|
303
|
+
: undefined,
|
|
299
304
|
});
|
|
300
305
|
|
|
301
306
|
function applyCors(req, res) {
|
|
@@ -420,8 +425,8 @@ export async function startAiServer(options = {}) {
|
|
|
420
425
|
pickEnv(env, "NEXT_PUBLIC_MAINTAINER_PRO_CLIENT_API_KEY"),
|
|
421
426
|
versions,
|
|
422
427
|
};
|
|
423
|
-
logger.debug({ aiServerUrl }, "embed-config");
|
|
424
428
|
outHeaders["content-type"] = "text/javascript; charset=utf-8";
|
|
429
|
+
outHeaders["cache-control"] = "private, max-age=60";
|
|
425
430
|
return {
|
|
426
431
|
status: 200,
|
|
427
432
|
headers: outHeaders,
|
|
@@ -477,6 +482,10 @@ export async function startAiServer(options = {}) {
|
|
|
477
482
|
});
|
|
478
483
|
return { status: response.status, headers: outHeaders, body: buf };
|
|
479
484
|
}
|
|
485
|
+
if (pathname.endsWith(".map")) {
|
|
486
|
+
outHeaders["content-type"] = "text/plain; charset=utf-8";
|
|
487
|
+
return { status: 404, headers: outHeaders, body: Buffer.from("Not found") };
|
|
488
|
+
}
|
|
480
489
|
const file = resolveUiFile(uiDir, pathname);
|
|
481
490
|
if (!file) {
|
|
482
491
|
if (pathname === "/ai-ui.iife.js") {
|
|
@@ -488,7 +497,15 @@ export async function startAiServer(options = {}) {
|
|
|
488
497
|
return { status: 404, headers: outHeaders, body: Buffer.from("Not found") };
|
|
489
498
|
}
|
|
490
499
|
outHeaders["content-type"] = contentType(file);
|
|
491
|
-
|
|
500
|
+
let fileBody = fs.readFileSync(file);
|
|
501
|
+
if (pathname === "/ai-ui.iife.js") {
|
|
502
|
+
fileBody = Buffer.from(
|
|
503
|
+
fileBody
|
|
504
|
+
.toString("utf8")
|
|
505
|
+
.replace(/\r?\n\/\/[#@] sourceMappingURL=.*$/g, "")
|
|
506
|
+
);
|
|
507
|
+
}
|
|
508
|
+
return { status: 200, headers: outHeaders, body: fileBody };
|
|
492
509
|
}
|
|
493
510
|
|
|
494
511
|
async function historyForTurn(conversationId, userMessage, userMessageId) {
|