@adonis-agora/agent-dashboard 0.7.3 → 0.7.4
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 +15 -0
- package/dist/spa/assets/index-Cfi3g3b2.js +9 -0
- package/dist/spa/index.html +1 -1
- package/dist/src/client/api-base.d.ts +17 -6
- package/dist/src/client/api-base.d.ts.map +1 -1
- package/dist/src/client/api-base.js +36 -6
- package/dist/src/client/api-base.js.map +1 -1
- package/package.json +2 -2
- package/dist/spa/assets/index-C1YrXiT7.js +0 -9
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Resolve the base URL of the agent routes the SPA calls. The provider
|
|
3
|
-
* mounted the agent under
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* Resolve the base URL of the agent routes the SPA calls. The provider hands the exact base it
|
|
3
|
+
* mounted the agent under to the page as a JSON data block
|
|
4
|
+
* (`<script type="application/json" id="agent-dashboard-config">{"apiBase":…}</script>`) when it
|
|
5
|
+
* serves `index.html`; a `window.__AGENT_DASHBOARD_BASE__` global is honoured after it (tests,
|
|
6
|
+
* hand-embedding); and when both are absent (e.g. the standalone `vite dev` preview) we derive it
|
|
7
|
+
* from the page's own location by stripping the trailing `/dashboard` mount segment. Either way the
|
|
8
|
+
* SPA never hard-codes `/agent`.
|
|
9
|
+
*
|
|
10
|
+
* The data block, and not an inline script setting the global, because a host
|
|
11
|
+
* Content-Security-Policy of `script-src 'self' 'nonce-…'` (shield's `@nonce`) refuses an un-nonced
|
|
12
|
+
* inline script without a word: the global was never set, the location-derived base took over, and
|
|
13
|
+
* a console mounted anywhere but the default answered 404 to all of its own requests while rendering
|
|
14
|
+
* perfectly. A data block is never executed, so no policy can refuse it.
|
|
6
15
|
*/
|
|
7
16
|
declare global {
|
|
8
17
|
interface Window {
|
|
9
18
|
__AGENT_DASHBOARD_BASE__?: string;
|
|
10
19
|
}
|
|
11
20
|
}
|
|
21
|
+
/** `id` of the data block the provider injects (`@adonis-agora/agent`'s `CONFIG_ELEMENT_ID`). */
|
|
22
|
+
export declare const CONFIG_ELEMENT_ID = "agent-dashboard-config";
|
|
12
23
|
/**
|
|
13
24
|
* Derive the agent API base from the dashboard's own `pathname`. The dashboard is mounted at
|
|
14
25
|
* `<agentBase>/dashboard`, so we drop that last segment: `/agent/dashboard` → `/agent`,
|
|
@@ -16,8 +27,8 @@ declare global {
|
|
|
16
27
|
* cleaned (trailing slash removed) as a best-effort base.
|
|
17
28
|
*/
|
|
18
29
|
export declare function deriveApiBase(pathname: string): string;
|
|
19
|
-
/** The resolved agent API base for this page
|
|
30
|
+
/** The resolved agent API base for this page: the data block, else the global, else location-derived. */
|
|
20
31
|
export declare function resolveApiBase(win?: Pick<Window, 'location'> & {
|
|
21
32
|
__AGENT_DASHBOARD_BASE__?: string;
|
|
22
|
-
}): string;
|
|
33
|
+
}, doc?: Pick<Document, 'getElementById'> | undefined): string;
|
|
23
34
|
//# sourceMappingURL=api-base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-base.d.ts","sourceRoot":"","sources":["../../../src/client/api-base.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"api-base.d.ts","sourceRoot":"","sources":["../../../src/client/api-base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,wBAAwB,CAAC,EAAE,MAAM,CAAC;KACnC;CACF;AAED,iGAAiG;AACjG,eAAO,MAAM,iBAAiB,2BAA2B,CAAC;AAsB1D;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOtD;AAED,yGAAyG;AACzG,wBAAgB,cAAc,CAC5B,GAAG,GAAE,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG;IAAE,wBAAwB,CAAC,EAAE,MAAM,CAAA;CAAW,EAC9E,GAAG,GAAE,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC,GAAG,SAE5B,GACX,MAAM,CAMR"}
|
|
@@ -1,9 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Resolve the base URL of the agent routes the SPA calls. The provider
|
|
3
|
-
* mounted the agent under
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* Resolve the base URL of the agent routes the SPA calls. The provider hands the exact base it
|
|
3
|
+
* mounted the agent under to the page as a JSON data block
|
|
4
|
+
* (`<script type="application/json" id="agent-dashboard-config">{"apiBase":…}</script>`) when it
|
|
5
|
+
* serves `index.html`; a `window.__AGENT_DASHBOARD_BASE__` global is honoured after it (tests,
|
|
6
|
+
* hand-embedding); and when both are absent (e.g. the standalone `vite dev` preview) we derive it
|
|
7
|
+
* from the page's own location by stripping the trailing `/dashboard` mount segment. Either way the
|
|
8
|
+
* SPA never hard-codes `/agent`.
|
|
9
|
+
*
|
|
10
|
+
* The data block, and not an inline script setting the global, because a host
|
|
11
|
+
* Content-Security-Policy of `script-src 'self' 'nonce-…'` (shield's `@nonce`) refuses an un-nonced
|
|
12
|
+
* inline script without a word: the global was never set, the location-derived base took over, and
|
|
13
|
+
* a console mounted anywhere but the default answered 404 to all of its own requests while rendering
|
|
14
|
+
* perfectly. A data block is never executed, so no policy can refuse it.
|
|
6
15
|
*/
|
|
16
|
+
/** `id` of the data block the provider injects (`@adonis-agora/agent`'s `CONFIG_ELEMENT_ID`). */
|
|
17
|
+
export const CONFIG_ELEMENT_ID = 'agent-dashboard-config';
|
|
18
|
+
/** The `apiBase` carried by the injected data block, or `undefined` when there is none. */
|
|
19
|
+
function readInjectedApiBase(doc) {
|
|
20
|
+
const element = doc?.getElementById(CONFIG_ELEMENT_ID) ?? null;
|
|
21
|
+
if (element === null)
|
|
22
|
+
return undefined;
|
|
23
|
+
try {
|
|
24
|
+
const parsed = JSON.parse(element.textContent ?? '');
|
|
25
|
+
const apiBase = parsed?.apiBase;
|
|
26
|
+
return typeof apiBase === 'string' && apiBase !== '' ? apiBase : undefined;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
7
32
|
/** Strip a trailing `/` (but never reduce `/` itself to `''`). */
|
|
8
33
|
function stripTrailingSlash(path) {
|
|
9
34
|
return path.length > 1 ? path.replace(/\/+$/, '') : path;
|
|
@@ -22,8 +47,13 @@ export function deriveApiBase(pathname) {
|
|
|
22
47
|
}
|
|
23
48
|
return clean === '' ? '/' : clean;
|
|
24
49
|
}
|
|
25
|
-
/** The resolved agent API base for this page
|
|
26
|
-
export function resolveApiBase(win = window
|
|
50
|
+
/** The resolved agent API base for this page: the data block, else the global, else location-derived. */
|
|
51
|
+
export function resolveApiBase(win = window, doc = typeof document === 'undefined'
|
|
52
|
+
? undefined
|
|
53
|
+
: document) {
|
|
54
|
+
const fromBlock = readInjectedApiBase(doc);
|
|
55
|
+
if (fromBlock !== undefined)
|
|
56
|
+
return stripTrailingSlash(fromBlock);
|
|
27
57
|
const injected = win.__AGENT_DASHBOARD_BASE__;
|
|
28
58
|
if (typeof injected === 'string' && injected !== '')
|
|
29
59
|
return stripTrailingSlash(injected);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-base.js","sourceRoot":"","sources":["../../../src/client/api-base.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"api-base.js","sourceRoot":"","sources":["../../../src/client/api-base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAQH,iGAAiG;AACjG,MAAM,CAAC,MAAM,iBAAiB,GAAG,wBAAwB,CAAC;AAE1D,2FAA2F;AAC3F,SAAS,mBAAmB,CAC1B,GAAiD;IAEjD,MAAM,OAAO,GAAG,GAAG,EAAE,cAAc,CAAC,iBAAiB,CAAC,IAAI,IAAI,CAAC;IAC/D,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IACvC,I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AS,KAAK,SAAS;QAAE,OAAO,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAClE,MAAM,QAAQ,GAAG,GAAG,CAAC,wBAAwB,CAAC;IAC9C,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,EAAE;QAAE,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACzF,OAAO,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC9C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonis-agora/agent-dashboard",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
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": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@adonis-agora/agent": "0.25.
|
|
49
|
+
"@adonis-agora/agent": "0.25.5",
|
|
50
50
|
"@adonisjs/core": "7.5.0",
|
|
51
51
|
"@tanstack/intent": "^0.3.7",
|
|
52
52
|
"@testing-library/react": "16.3.3",
|