@agent-plan/server 0.2.10 → 0.2.16
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/serve.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAiHpC,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,GAAG,KAAK,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED,MAAM,WAAW,QAAQ;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,EAAE,kBAAkB,CAAC,CAAC,CAAC;IACzF,MAAM,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;CACrC;AAgoBD,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,GAAG,SAAS,CAAC;CACtC;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,IAAI,EAAE,OAAO,GAAG,KAAK,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,KAAK,CAAC;IACX,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED,wBAAsB,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CA6EvE"}
|
package/dist/serve.js
CHANGED
|
@@ -2,6 +2,7 @@ import { watch, existsSync, readFileSync } from "node:fs";
|
|
|
2
2
|
import { writeFile } from "node:fs/promises";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import { networkInterfaces } from "node:os";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
5
6
|
import { createAdaptorServer } from "@hono/node-server";
|
|
6
7
|
import { Hono } from "hono";
|
|
7
8
|
import { cors } from "hono/cors";
|
|
@@ -688,6 +689,19 @@ function createSpaApp(store, hubRef, staticDir, uiConfig, isBusy) {
|
|
|
688
689
|
});
|
|
689
690
|
return app;
|
|
690
691
|
}
|
|
692
|
+
// ─── Serve ──────────────────────────────────────────────────────────────
|
|
693
|
+
/** Resolve the web UI bundle shipped alongside this package (../web-ui-dist
|
|
694
|
+
* relative to dist/serve.js). Returns undefined when not bundled (dev/API-only).
|
|
695
|
+
* Callers can pass staticDir: "" to force API-only even when the bundle exists. */
|
|
696
|
+
function resolveBundledStaticDir() {
|
|
697
|
+
try {
|
|
698
|
+
const dir = join(dirname(fileURLToPath(import.meta.url)), "..", "web-ui-dist");
|
|
699
|
+
return existsSync(join(dir, "index.html")) ? dir : undefined;
|
|
700
|
+
}
|
|
701
|
+
catch {
|
|
702
|
+
return undefined;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
691
705
|
export async function serve(options) {
|
|
692
706
|
const { port = 3030, planRoot, host = "127.0.0.1" } = options;
|
|
693
707
|
const store = new PlanStore(planRoot);
|
|
@@ -699,7 +713,10 @@ export async function serve(options) {
|
|
|
699
713
|
await store.syncStatuses();
|
|
700
714
|
// Shared mutable reference — routes see the hub after it's created
|
|
701
715
|
const hubRef = { current: null };
|
|
702
|
-
|
|
716
|
+
// Default to the bundled web UI when the caller doesn't pass staticDir. Pass
|
|
717
|
+
// an empty string ("") to force API-only even when the bundle is present.
|
|
718
|
+
const staticDir = options.staticDir ?? resolveBundledStaticDir();
|
|
719
|
+
const app = createSpaApp(store, hubRef, staticDir, runtimeUiConfig, options.isBusy);
|
|
703
720
|
return new Promise((resolve, reject) => {
|
|
704
721
|
// Create the Node HTTP server without listening yet
|
|
705
722
|
const server = createAdaptorServer({ fetch: app.fetch, hostname: host });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-plan/server",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Local HTTP/WebSocket server for Agent Plan dashboards and planner APIs.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"dist/**/*.js",
|
|
16
16
|
"dist/**/*.d.ts",
|
|
17
17
|
"dist/**/*.d.ts.map",
|
|
18
|
+
"web-ui-dist/**",
|
|
18
19
|
"README.md",
|
|
19
20
|
"LICENSE"
|
|
20
21
|
],
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
"@hono/node-server": "^1.14.0",
|
|
41
42
|
"hono": "^4.7.0",
|
|
42
43
|
"ws": "^8.18.0",
|
|
43
|
-
"@agent-plan/core": "0.2.
|
|
44
|
+
"@agent-plan/core": "0.2.16"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@types/ws": "^8.18.0"
|