@adonis-agora/agent-dashboard 0.3.0 → 0.3.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/CHANGELOG.md +38 -0
- package/dist/providers/agent_dashboard_provider.d.ts +4 -1
- package/dist/providers/agent_dashboard_provider.d.ts.map +1 -1
- package/dist/providers/agent_dashboard_provider.js +22 -14
- package/dist/providers/agent_dashboard_provider.js.map +1 -1
- package/dist/src/server/paths.d.ts +8 -0
- package/dist/src/server/paths.d.ts.map +1 -1
- package/dist/src/server/paths.js +16 -0
- package/dist/src/server/paths.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# @adonis-agora/agent-dashboard
|
|
2
2
|
|
|
3
|
+
## 0.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#16](https://github.com/DavideCarvalho/adonis-agent/pull/16) [`07a46bd`](https://github.com/DavideCarvalho/adonis-agent/commit/07a46bd3d7efcc6861dee6c977ab0b19b6d4575b) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Widen the `@adonis-agora/agent` peer range to `>=0.4.0 <1.0.0`
|
|
8
|
+
|
|
9
|
+
The dashboard only consumes the agent's stable HTTP routes and public types, which are
|
|
10
|
+
compatible across the agent's pre-1.0 minor releases — so pinning the peer to `^0.4.0`
|
|
11
|
+
(i.e. `>=0.4.0 <0.5.0`) was too tight: every agent minor pushed the installed agent out
|
|
12
|
+
of range, producing a spurious peer warning in consumers and forcing an unwarranted major
|
|
13
|
+
bump of the dashboard. The range now tolerates any `0.x` agent from `0.4.0` up, and will
|
|
14
|
+
intentionally require a re-check at the agent's eventual `1.0.0`.
|
|
15
|
+
|
|
16
|
+
## 0.3.1
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [#12](https://github.com/DavideCarvalho/adonis-agent/pull/12) [`4021b6b`](https://github.com/DavideCarvalho/adonis-agent/commit/4021b6b5355ec7679f44f035a2c1dfafeb3c5e61) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Fix the dashboard provider crashing every app boot (and a duplicate-route crash)
|
|
21
|
+
|
|
22
|
+
Two bugs that made the provider unbootable in a real app — surfaced the first time
|
|
23
|
+
it was registered in one (entre-textos):
|
|
24
|
+
|
|
25
|
+
- **`router` was `undefined` at boot.** The provider imported `router` from
|
|
26
|
+
`@adonisjs/core/services/router` and called `router.get(...)` in `boot()`. That
|
|
27
|
+
service's default export is only assigned inside an `app.booted()` hook, which
|
|
28
|
+
runs AFTER every provider's `boot()`, so it was still `undefined` — `router.get`
|
|
29
|
+
threw `Cannot read properties of undefined (reading 'get')` and crashed the whole
|
|
30
|
+
app. It now resolves the router from the container (`app.container.make('router')`),
|
|
31
|
+
available during boot, mirroring how the agent provider registers its routes.
|
|
32
|
+
|
|
33
|
+
- **Duplicate `GET <mount>` route.** The provider registered a bare-mount redirect
|
|
34
|
+
(`<mount>` → `<mount>/`) plus the shell at `<mount>/`. The AdonisJS router
|
|
35
|
+
normalizes trailing slashes, so both are the SAME pattern — the second
|
|
36
|
+
registration threw `Duplicate route found`. The shell now serves at the bare
|
|
37
|
+
`<mount>` (one route), and `sendIndex` injects a `<base href="<mount>/">` so the
|
|
38
|
+
SPA's relative `./assets/*` URLs (Vite `base: './'`) still resolve against the
|
|
39
|
+
mount directory regardless of the URL's trailing slash.
|
|
40
|
+
|
|
3
41
|
## 0.3.0
|
|
4
42
|
|
|
5
43
|
### Minor Changes
|
|
@@ -27,7 +27,10 @@ export default class AgentDashboardProvider {
|
|
|
27
27
|
* router-free {@link evaluateDashboardGate} so it can be unit tested; this only writes the response.
|
|
28
28
|
*/
|
|
29
29
|
private gate;
|
|
30
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Read `dist/spa/index.html`, inject the `<base href>` (so relative `./assets/*` resolve against
|
|
32
|
+
* the mount dir) and the API base, and send it.
|
|
33
|
+
*/
|
|
31
34
|
private sendIndex;
|
|
32
35
|
/** Send the requested built asset, or fall back to the SPA shell when it does not exist. */
|
|
33
36
|
private sendAsset;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent_dashboard_provider.d.ts","sourceRoot":"","sources":["../../providers/agent_dashboard_provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agent_dashboard_provider.d.ts","sourceRoot":"","sources":["../../providers/agent_dashboard_provider.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAgB/D;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,OAAO,sBAAsB;IAC7B,SAAS,CAAC,GAAG,EAAE,kBAAkB;gBAAvB,GAAG,EAAE,kBAAkB;IAE7C,+FAA+F;IAC/F,OAAO,CAAC,SAAS,CAAuC;IAElD,IAAI;IA0CV;;;;;OAKG;YACW,IAAI;IAalB;;;OAGG;YACW,SAAS;IAOvB,4FAA4F;YAC9E,SAAS;CAmBxB"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import router from '@adonisjs/core/services/router';
|
|
3
2
|
import { resolveDashboardConfig, } from '../src/server/define_config.js';
|
|
4
3
|
import { evaluateDashboardGate } from '../src/server/gate.js';
|
|
5
|
-
import { apiBaseFor, contentTypeFor, injectApiBase, mountPathFor, safeAssetSegments, } from '../src/server/paths.js';
|
|
4
|
+
import { apiBaseFor, contentTypeFor, injectApiBase, injectBaseHref, mountPathFor, safeAssetSegments, } from '../src/server/paths.js';
|
|
6
5
|
/**
|
|
7
6
|
* Serves the `@adonis-agora/agent-dashboard` governance SPA (a Vite build in `dist/spa`) as static
|
|
8
7
|
* assets under `<agentPath>/dashboard`, behind the SAME actor gating as the agent's governance
|
|
@@ -30,19 +29,25 @@ export default class AgentDashboardProvider {
|
|
|
30
29
|
const dashboardConfig = resolveDashboardConfig(this.app.config.get('agent.dashboard', {}));
|
|
31
30
|
if (!dashboardConfig.enabled)
|
|
32
31
|
return;
|
|
32
|
+
// Resolve the router from the container, NOT from `@adonisjs/core/services/router`: that service's
|
|
33
|
+
// default export is assigned inside an `app.booted()` hook, which runs AFTER every provider's
|
|
34
|
+
// `boot()` — so at this point the module default is still `undefined` and `router.get(...)` throws.
|
|
35
|
+
// The container binding is available now (mirrors how the agent provider registers its routes).
|
|
36
|
+
const router = await this.app.container.make('router');
|
|
33
37
|
const agentPath = agentConfig.path ?? 'agent';
|
|
34
38
|
const apiBase = apiBaseFor(agentPath);
|
|
35
39
|
const mount = mountPathFor(agentPath, dashboardConfig.path);
|
|
36
40
|
const actorResolver = agentConfig.actorResolver;
|
|
37
|
-
// Bare mount → canonical trailing slash so the SPA's relative `./assets/*` URLs resolve against
|
|
38
|
-
// the mount directory rather than its parent.
|
|
39
|
-
router.get(mount, (ctx) => ctx.response.redirect().toPath(`${mount}/`));
|
|
40
41
|
const authorize = dashboardConfig.authorize;
|
|
41
|
-
// The SPA shell.
|
|
42
|
-
router
|
|
42
|
+
// The SPA shell, served at the bare mount. We do NOT redirect to a trailing-slash variant: the
|
|
43
|
+
// AdonisJS router normalizes trailing slashes, so `mount` and `${mount}/` are the SAME route
|
|
44
|
+
// pattern — registering both throws "Duplicate route". Instead `sendIndex` injects a
|
|
45
|
+
// `<base href="${mount}/">`, so the SPA's relative `./assets/*` URLs resolve against the mount
|
|
46
|
+
// directory regardless of whether the browser's URL carries a trailing slash.
|
|
47
|
+
router.get(mount, async (ctx) => {
|
|
43
48
|
if (!(await this.gate(ctx, actorResolver, authorize)))
|
|
44
49
|
return;
|
|
45
|
-
await this.sendIndex(ctx, apiBase);
|
|
50
|
+
await this.sendIndex(ctx, apiBase, mount);
|
|
46
51
|
});
|
|
47
52
|
// Built assets (JS/CSS/fonts/...), with an index fallback for any unmatched path so the
|
|
48
53
|
// client-rendered console still boots on a deep link.
|
|
@@ -53,7 +58,7 @@ export default class AgentDashboardProvider {
|
|
|
53
58
|
if (segments === null) {
|
|
54
59
|
return ctx.response.status(400).json({ error: 'bad asset path' });
|
|
55
60
|
}
|
|
56
|
-
await this.sendAsset(ctx, segments, apiBase);
|
|
61
|
+
await this.sendAsset(ctx, segments, apiBase, mount);
|
|
57
62
|
});
|
|
58
63
|
}
|
|
59
64
|
/**
|
|
@@ -70,15 +75,18 @@ export default class AgentDashboardProvider {
|
|
|
70
75
|
}
|
|
71
76
|
return true;
|
|
72
77
|
}
|
|
73
|
-
/**
|
|
74
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Read `dist/spa/index.html`, inject the `<base href>` (so relative `./assets/*` resolve against
|
|
80
|
+
* the mount dir) and the API base, and send it.
|
|
81
|
+
*/
|
|
82
|
+
async sendIndex(ctx, apiBase, mount) {
|
|
75
83
|
const html = await readFile(new URL('index.html', this.spaDirUrl), 'utf8');
|
|
76
84
|
ctx.response.header('content-type', 'text/html; charset=utf-8');
|
|
77
85
|
ctx.response.header('cache-control', 'no-store, must-revalidate');
|
|
78
|
-
ctx.response.send(injectApiBase(html, apiBase));
|
|
86
|
+
ctx.response.send(injectApiBase(injectBaseHref(html, mount), apiBase));
|
|
79
87
|
}
|
|
80
88
|
/** Send the requested built asset, or fall back to the SPA shell when it does not exist. */
|
|
81
|
-
async sendAsset(ctx, segments, apiBase) {
|
|
89
|
+
async sendAsset(ctx, segments, apiBase, mount) {
|
|
82
90
|
const filename = segments[segments.length - 1] ?? 'index.html';
|
|
83
91
|
try {
|
|
84
92
|
const buffer = await readFile(new URL(segments.join('/'), this.spaDirUrl));
|
|
@@ -87,7 +95,7 @@ export default class AgentDashboardProvider {
|
|
|
87
95
|
}
|
|
88
96
|
catch (error) {
|
|
89
97
|
if (error.code === 'ENOENT') {
|
|
90
|
-
await this.sendIndex(ctx, apiBase);
|
|
98
|
+
await this.sendIndex(ctx, apiBase, mount);
|
|
91
99
|
return;
|
|
92
100
|
}
|
|
93
101
|
throw error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent_dashboard_provider.js","sourceRoot":"","sources":["../../providers/agent_dashboard_provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"agent_dashboard_provider.js","sourceRoot":"","sources":["../../providers/agent_dashboard_provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI5C,OAAO,EAGL,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EACL,UAAU,EACV,cAAc,EACd,aAAa,EACb,cAAc,EACd,YAAY,EACZ,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,OAAO,sBAAsB;IACnB;IAAtB,YAAsB,GAAuB;QAAvB,QAAG,GAAH,GAAG,CAAoB;IAAG,CAAC;IAEjD,+FAA+F;IACvF,SAAS,GAAG,IAAI,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAExD,KAAK,CAAC,IAAI;QACR,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAc,OAAO,EAAE,EAAiB,CAAC,CAAC;QACjF,MAAM,eAAe,GAAG,sBAAsB,CAC5C,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAuB,iBAAiB,EAAE,EAAE,CAAC,CACjE,CAAC;QACF,IAAI,CAAC,eAAe,CAAC,OAAO;YAAE,OAAO;QAErC,mGAAmG;QACnG,8FAA8F;QAC9F,oGAAoG;QACpG,gGAAgG;QAChG,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEvD,MAA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AC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;YAC3E,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC9D,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACvD,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;gBAC1C,OAAO;YACT,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -24,4 +24,12 @@ export declare function safeAssetSegments(wildcard: string | string[] | undefine
|
|
|
24
24
|
* per response — inserted right before `</head>`.
|
|
25
25
|
*/
|
|
26
26
|
export declare function injectApiBase(html: string, apiBase: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Inject a `<base href="${mount}/">` as the FIRST thing inside `<head>`, so the SPA's relative
|
|
29
|
+
* `./assets/*` URLs (Vite `base: './'`) resolve against the mount directory no matter whether the
|
|
30
|
+
* browser's URL carries a trailing slash. This replaces the old trailing-slash redirect, which the
|
|
31
|
+
* AdonisJS router (it normalizes trailing slashes) turned into a duplicate-route crash. `mount` is a
|
|
32
|
+
* leading-slash, no-trailing-slash path (e.g. `/agent/dashboard`).
|
|
33
|
+
*/
|
|
34
|
+
export declare function injectBaseHref(html: string, mount: string): string;
|
|
27
35
|
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../src/server/paths.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wFAAwF;AACxF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,8FAA8F;AAC9F,wBAAgB,UAAU,C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
package/dist/src/server/paths.js
CHANGED
|
@@ -75,4 +75,20 @@ export function injectApiBase(html, apiBase) {
|
|
|
75
75
|
return html.replace('</head>', `${tag}</head>`);
|
|
76
76
|
return `${tag}${html}`;
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Inject a `<base href="${mount}/">` as the FIRST thing inside `<head>`, so the SPA's relative
|
|
80
|
+
* `./assets/*` URLs (Vite `base: './'`) resolve against the mount directory no matter whether the
|
|
81
|
+
* browser's URL carries a trailing slash. This replaces the old trailing-slash redirect, which the
|
|
82
|
+
* AdonisJS router (it normalizes trailing slashes) turned into a duplicate-route crash. `mount` is a
|
|
83
|
+
* leading-slash, no-trailing-slash path (e.g. `/agent/dashboard`).
|
|
84
|
+
*/
|
|
85
|
+
export function injectBaseHref(html, mount) {
|
|
86
|
+
const tag = `<base href="${mount}/">`;
|
|
87
|
+
const headOpen = html.match(/<head[^>]*>/i);
|
|
88
|
+
if (headOpen?.index !== undefined) {
|
|
89
|
+
const at = headOpen.index + headOpen[0].length;
|
|
90
|
+
return html.slice(0, at) + tag + html.slice(at);
|
|
91
|
+
}
|
|
92
|
+
return `${tag}${html}`;
|
|
93
|
+
}
|
|
78
94
|
//# sourceMappingURL=paths.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../src/server/paths.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wFAAwF;AACxF,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAC7D,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,UAAU,CAAC,SAAiB;IAC1C,MAAM,OAAO,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;IACvC,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,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MG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,KAAa;IACxD,MAAM,GAAG,GAAG,eAAe,KAAK,KAAK,CAAC;IACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAC5C,IAAI,QAAQ,EAAE,KAAK,KAAK,SAAS,EAAE,CAAC;QAClC,MAAM,EAAE,GAAG,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,GAAG,GAAG,GAAG,IAAI,EAAE,CAAC;AACzB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonis-agora/agent-dashboard",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Read-only governance console (spend by model/actor, usage trend, recent threads & tool calls, quota) for @adonis-agora/agent — a dependency-light React SPA served by a thin AdonisJS provider. Part of the Agora ecosystem.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"sideEffects": false,
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@adonisjs/core": "^7.3.0",
|
|
40
|
-
"@adonis-agora/agent": "
|
|
40
|
+
"@adonis-agora/agent": ">=0.4.0 <1.0.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependenciesMeta": {
|
|
43
43
|
"@adonisjs/core": {
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"typescript": "^5.4.0",
|
|
58
58
|
"vite": "^7.0.0",
|
|
59
59
|
"vitest": "^3.0.0",
|
|
60
|
-
"@adonis-agora/agent": "0.
|
|
60
|
+
"@adonis-agora/agent": "0.5.0"
|
|
61
61
|
},
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=22.0.0"
|