@openspecui/server 1.2.0 → 1.4.1
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/index.mjs +41 -15
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { createServer as createServer$1 } from "node:net";
|
|
1
2
|
import { serve } from "@hono/node-server";
|
|
2
|
-
import { CliExecutor, ConfigManager, OpenSpecAdapter, OpenSpecWatcher, OpsxKernel, PtyClientMessageSchema, ReactiveContext, getAllTools, getAvailableTools, getConfiguredTools, getDefaultCliCommandString, initWatcherPool, isWatcherPoolInitialized, sniffGlobalCli } from "@openspecui/core";
|
|
3
|
+
import { CliExecutor, ConfigManager, OpenSpecAdapter, OpenSpecWatcher, OpsxKernel, PtyClientMessageSchema, ReactiveContext, TerminalConfigSchema, TerminalRendererEngineSchema, getAllTools, getAvailableTools, getConfiguredTools, getDefaultCliCommandString, getWatcherRuntimeStatus, initWatcherPool, isWatcherPoolInitialized, sniffGlobalCli } from "@openspecui/core";
|
|
3
4
|
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
|
|
4
5
|
import { applyWSSHandler } from "@trpc/server/adapters/ws";
|
|
5
6
|
import { Hono } from "hono";
|
|
6
7
|
import { cors } from "hono/cors";
|
|
7
8
|
import { WebSocketServer } from "ws";
|
|
8
|
-
import { createServer as createServer$1 } from "node:net";
|
|
9
9
|
import * as pty from "@lydell/node-pty";
|
|
10
10
|
import { EventEmitter } from "events";
|
|
11
11
|
import { SearchQuerySchema } from "@openspecui/search";
|
|
@@ -668,6 +668,16 @@ async function fetchOpsxTemplateContents(ctx, schema) {
|
|
|
668
668
|
await ctx.kernel.ensureTemplateContents(schema);
|
|
669
669
|
return ctx.kernel.getTemplateContents(schema);
|
|
670
670
|
}
|
|
671
|
+
function buildSystemStatus(ctx) {
|
|
672
|
+
const runtime = getWatcherRuntimeStatus();
|
|
673
|
+
return {
|
|
674
|
+
projectDir: ctx.projectDir,
|
|
675
|
+
watcherEnabled: runtime?.initialized ?? false,
|
|
676
|
+
watcherGeneration: runtime?.generation ?? 0,
|
|
677
|
+
watcherReinitializeCount: runtime?.reinitializeCount ?? 0,
|
|
678
|
+
watcherLastReinitializeReason: runtime?.lastReinitializeReason ?? null
|
|
679
|
+
};
|
|
680
|
+
}
|
|
671
681
|
/**
|
|
672
682
|
* Spec router - spec CRUD operations
|
|
673
683
|
*/
|
|
@@ -875,17 +885,7 @@ const configRouter = router({
|
|
|
875
885
|
"dark",
|
|
876
886
|
"system"
|
|
877
887
|
]).optional(),
|
|
878
|
-
terminal:
|
|
879
|
-
fontSize: z.number().min(8).max(32).optional(),
|
|
880
|
-
fontFamily: z.string().optional(),
|
|
881
|
-
cursorBlink: z.boolean().optional(),
|
|
882
|
-
cursorStyle: z.enum([
|
|
883
|
-
"block",
|
|
884
|
-
"underline",
|
|
885
|
-
"bar"
|
|
886
|
-
]).optional(),
|
|
887
|
-
scrollback: z.number().min(0).max(1e5).optional()
|
|
888
|
-
}).optional()
|
|
888
|
+
terminal: TerminalConfigSchema.omit({ rendererEngine: true }).partial().extend({ rendererEngine: TerminalRendererEngineSchema.optional() }).optional()
|
|
889
889
|
})).mutation(async ({ ctx, input }) => {
|
|
890
890
|
const hasCliCommand = input.cli !== void 0 && Object.prototype.hasOwnProperty.call(input.cli, "command");
|
|
891
891
|
const hasCliArgs = input.cli !== void 0 && Object.prototype.hasOwnProperty.call(input.cli, "args");
|
|
@@ -1330,6 +1330,26 @@ const searchRouter = router({
|
|
|
1330
1330
|
})
|
|
1331
1331
|
});
|
|
1332
1332
|
/**
|
|
1333
|
+
* System router - runtime status and heartbeat-friendly subscription
|
|
1334
|
+
*/
|
|
1335
|
+
const systemRouter = router({
|
|
1336
|
+
status: publicProcedure.query(({ ctx }) => {
|
|
1337
|
+
return buildSystemStatus(ctx);
|
|
1338
|
+
}),
|
|
1339
|
+
subscribe: publicProcedure.subscription(({ ctx }) => {
|
|
1340
|
+
return observable((emit) => {
|
|
1341
|
+
emit.next(buildSystemStatus(ctx));
|
|
1342
|
+
const timer = setInterval(() => {
|
|
1343
|
+
emit.next(buildSystemStatus(ctx));
|
|
1344
|
+
}, 3e3);
|
|
1345
|
+
timer.unref();
|
|
1346
|
+
return () => {
|
|
1347
|
+
clearInterval(timer);
|
|
1348
|
+
};
|
|
1349
|
+
});
|
|
1350
|
+
})
|
|
1351
|
+
});
|
|
1352
|
+
/**
|
|
1333
1353
|
* Main app router
|
|
1334
1354
|
*/
|
|
1335
1355
|
const appRouter = router({
|
|
@@ -1342,7 +1362,8 @@ const appRouter = router({
|
|
|
1342
1362
|
cli: cliRouter,
|
|
1343
1363
|
opsx: opsxRouter,
|
|
1344
1364
|
kv: kvRouter,
|
|
1345
|
-
search: searchRouter
|
|
1365
|
+
search: searchRouter,
|
|
1366
|
+
system: systemRouter
|
|
1346
1367
|
});
|
|
1347
1368
|
|
|
1348
1369
|
//#endregion
|
|
@@ -1561,7 +1582,12 @@ async function createWebSocketServer(server, httpServer, config) {
|
|
|
1561
1582
|
const handler = applyWSSHandler({
|
|
1562
1583
|
wss,
|
|
1563
1584
|
router: appRouter,
|
|
1564
|
-
createContext: server.createContext
|
|
1585
|
+
createContext: server.createContext,
|
|
1586
|
+
keepAlive: {
|
|
1587
|
+
enabled: true,
|
|
1588
|
+
pingMs: 3e4,
|
|
1589
|
+
pongWaitMs: 5e3
|
|
1590
|
+
}
|
|
1565
1591
|
});
|
|
1566
1592
|
const ptyManager = new PtyManager(config.projectDir);
|
|
1567
1593
|
const ptyWss = new WebSocketServer({ noServer: true });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openspecui/server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
6
|
"exports": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "tsdown src/index.ts --format esm --no-dts",
|
|
37
|
-
"typecheck": "tsc --noEmit",
|
|
37
|
+
"typecheck": "tsc -p tsconfig.check.json --noEmit",
|
|
38
38
|
"dev": "tsx watch --include '../core/dist/**' --include '../search/dist/**' src/standalone.ts",
|
|
39
39
|
"test": "vitest run",
|
|
40
40
|
"test:watch": "vitest"
|