@dudousxd/nestjs-agent-dashboard 0.11.0 → 0.13.0
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/client/agent-client.d.ts +1 -0
- package/dist/client/agent-client.d.ts.map +1 -1
- package/dist/client/agent-client.js +4 -0
- package/dist/client/agent-client.js.map +1 -1
- package/dist/client/console-session.d.ts +63 -0
- package/dist/client/console-session.d.ts.map +1 -0
- package/dist/client/console-session.js +107 -0
- package/dist/client/console-session.js.map +1 -0
- package/dist/react/index.d.ts +4 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +14 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/open-console-button.d.ts +26 -0
- package/dist/react/open-console-button.d.ts.map +1 -0
- package/dist/react/open-console-button.js +29 -0
- package/dist/react/open-console-button.js.map +1 -0
- package/dist/react/use-open-console.d.ts +34 -0
- package/dist/react/use-open-console.d.ts.map +1 -0
- package/dist/react/use-open-console.js +46 -0
- package/dist/react/use-open-console.js.map +1 -0
- package/package.json +21 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** Inclusive UTC day range, each `YYYY-MM-DD`. */
|
|
2
|
+
export { ConsoleSessionError, agentConsoleSessionUrl, agentConsoleUrl, mintAgentConsoleSession, openAgentConsole, type OpenConsoleOptions, } from './console-session.js';
|
|
2
3
|
export interface GovernanceRange {
|
|
3
4
|
fromDay: string;
|
|
4
5
|
toDay: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-client.d.ts","sourceRoot":"","sources":["../../src/client/agent-client.ts"],"names":[],"mappings":"AAIA,kDAAkD;
|
|
1
|
+
{"version":3,"file":"agent-client.d.ts","sourceRoot":"","sources":["../../src/client/agent-client.ts"],"names":[],"mappings":"AAIA,kDAAkD;AAGlD,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAChB,KAAK,kBAAkB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WAAW,EAAE,CAAC;IAIzD,wCAAwC;6BACnB,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAGjD,+EAA+E;uBAC5D,mBAAmB,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;IAGhG,+EAA+E;oBAC/D,mBAAmB,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;IAGrF,gFAAgF;eACrE,OAAO,CAAC,UAAU,EAAE,CAAC;IAGhC,gFAAgF;uBACvD,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ9D;;;OAGG;0BACmB,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,GAAG,MAAM,IAAI;CAWnE,CAAC"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// Typed API client for the AI-gateway console. Self-contained: the row shapes are re-declared here
|
|
2
2
|
// (identical to core's `AgentGovernanceQueries` contract) so `@dudousxd/nestjs-agent-dashboard/client`
|
|
3
3
|
// is dependency-free for an external front-end that only wants to call the API.
|
|
4
|
+
/** Inclusive UTC day range, each `YYYY-MM-DD`. */
|
|
5
|
+
// Headless console-launcher primitives (path derivation + mint-then-navigate). Re-exported here
|
|
6
|
+
// because `./client` resolves to this file — see the package's `exports` map.
|
|
7
|
+
export { ConsoleSessionError, agentConsoleSessionUrl, agentConsoleUrl, mintAgentConsoleSession, openAgentConsole, } from './console-session.js';
|
|
4
8
|
function apiBase() {
|
|
5
9
|
if (typeof window !== 'undefined' && window.__AGENT_API__)
|
|
6
10
|
return window.__AGENT_API__;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-client.js","sourceRoot":"","sources":["../../src/client/agent-client.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,uGAAuG;AACvG,gFAAgF;
|
|
1
|
+
{"version":3,"file":"agent-client.js","sourceRoot":"","sources":["../../src/client/agent-client.ts"],"names":[],"mappings":"AAAA,mGAAm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AA+E;IAC/E,QAAQ,CAAC,KAAoC;QAC3C,OAAO,IAAI,CAA+B,cAAc,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACpF,CAAC;IACD,gFAAgF;IAChF,OAAO;QACL,OAAO,IAAI,CAAe,UAAU,CAAC,CAAC;IACxC,CAAC;IACD,gFAAgF;IAChF,KAAK,CAAC,WAAW,CAAC,KAA4B;QAC5C,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,OAAO,EAAE,UAAU,EAAE;YAC9C,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;SAC5B,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;IAClE,CAAC;IACD;;;OAGG;IACH,YAAY,CAAC,OAAwC;QACnD,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,GAAG,OAAO,EAAE,SAAS,CAAC,CAAC;QACtD,MAAM,CAAC,SAAS,GAAG,CAAC,GAAG,EAAE,EAAE;YACzB,IAAI,CAAC;gBACH,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAmB,CAAC,CAAC;YAClD,CAAC;YAAC,MAAM,CAAC;gBACP,4BAA4B;YAC9B,CAAC;QACH,CAAC,CAAC;QACF,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless client for opening the console from YOUR app.
|
|
3
|
+
*
|
|
4
|
+
* The console SPA is served at a literal path and knows nothing about your app's auth, so a plain
|
|
5
|
+
* browser navigation to it carries no identity. Mode A closes that gap: an XHR from inside your app
|
|
6
|
+
* — which DOES carry your auth — posts to the console's session endpoint, the `session` hook
|
|
7
|
+
* decides, and the library answers with its own signed cookie. The navigation that follows rides it.
|
|
8
|
+
*
|
|
9
|
+
* No UI here on purpose: you own the button, the page and the copy. This module owns the two things
|
|
10
|
+
* a host would otherwise have to rediscover — where the session endpoint actually lives, and how to
|
|
11
|
+
* call it without the failure mode below.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Where `POST` mints the console session cookie.
|
|
15
|
+
*
|
|
16
|
+
* Derived from `basePath` rather than hardcoded by the caller: this package owns the route (the
|
|
17
|
+
* auth controller is mounted relative to `basePath` by `RouterModule`), so a host that hardcodes it
|
|
18
|
+
* is guessing at something that can change under a version bump — with no compile error when it
|
|
19
|
+
* does, because the break only shows up as a 404 at runtime.
|
|
20
|
+
*/
|
|
21
|
+
export declare function agentConsoleSessionUrl(basePath?: string): string;
|
|
22
|
+
/** Where the console SPA itself is served. */
|
|
23
|
+
export declare function agentConsoleUrl(basePath?: string): string;
|
|
24
|
+
export interface OpenConsoleOptions {
|
|
25
|
+
/** Where the console is mounted. MUST match `AgentDashboardModule.forRoot({ basePath })`. */
|
|
26
|
+
basePath?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Headers for the mint request — in practice your app's `Authorization` header. A function (sync
|
|
29
|
+
* or async) is accepted so a token can be read at call time rather than captured at wiring time,
|
|
30
|
+
* which is what a refreshing token needs.
|
|
31
|
+
*/
|
|
32
|
+
headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
|
|
33
|
+
/** Injected for tests and non-browser callers. Defaults to the global `fetch`. */
|
|
34
|
+
fetch?: typeof globalThis.fetch;
|
|
35
|
+
signal?: AbortSignal;
|
|
36
|
+
/**
|
|
37
|
+
* Performs the navigation after a successful mint. Defaults to `location.assign`. Override to
|
|
38
|
+
* route through your own router, or to open in a new tab.
|
|
39
|
+
*/
|
|
40
|
+
navigate?: (url: string) => void;
|
|
41
|
+
}
|
|
42
|
+
/** Thrown when the session could not be minted. Never thrown after a successful mint. */
|
|
43
|
+
export declare class ConsoleSessionError extends Error {
|
|
44
|
+
readonly url: string;
|
|
45
|
+
/** The HTTP status, or `undefined` when the request never produced one (network error). */
|
|
46
|
+
readonly status?: number | undefined;
|
|
47
|
+
constructor(message: string, url: string,
|
|
48
|
+
/** The HTTP status, or `undefined` when the request never produced one (network error). */
|
|
49
|
+
status?: number | undefined);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Mint the console session cookie. Resolves on success; throws {@link ConsoleSessionError} on
|
|
53
|
+
* refusal. Use this directly when you want to mint without navigating (a pre-flight check, or a
|
|
54
|
+
* link the user opens later).
|
|
55
|
+
*/
|
|
56
|
+
export declare function mintAgentConsoleSession(options?: OpenConsoleOptions): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Mint the session, then navigate to the console. Throws without navigating when the mint is
|
|
59
|
+
* refused, so a denied user gets a real error instead of landing on the console's
|
|
60
|
+
* "no session" page — which reads as a bug rather than a permission decision.
|
|
61
|
+
*/
|
|
62
|
+
export declare function openAgentConsole(options?: OpenConsoleOptions): Promise<void>;
|
|
63
|
+
//# sourceMappingURL=console-session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console-session.d.ts","sourceRoot":"","sources":["../../src/client/console-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAWH;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,GAAE,MAA0B,GAAG,MAAM,CAEnF;AAED,8CAA8C;AAC9C,wBAAgB,eAAe,CAAC,QAAQ,GAAE,MAA0B,GAAG,MAAM,CAE5E;AAED,MAAM,WAAW,kBAAkB;IACjC,6FAA6F;IAC7F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,WAAW,GAAG,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IACnE,kFAAkF;IAClF,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAED,yFAAyF;AACzF,qBAAa,mBAAoB,SAAQ,KAAK;IAG1C,QAAQ,CAAC,GAAG,EAAE,MAAM;IACpB,2FAA2F;IAC3F,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM;gBAHxB,OAAO,EAAE,MAAM,EACN,GAAG,EAAE,MAAM;IACpB,2FAA2F;IAClF,MAAM,CAAC,EAAE,MAAM,YAAA;CAK3B;AAOD;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkD7F;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAKtF"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless client for opening the console from YOUR app.
|
|
3
|
+
*
|
|
4
|
+
* The console SPA is served at a literal path and knows nothing about your app's auth, so a plain
|
|
5
|
+
* browser navigation to it carries no identity. Mode A closes that gap: an XHR from inside your app
|
|
6
|
+
* — which DOES carry your auth — posts to the console's session endpoint, the `session` hook
|
|
7
|
+
* decides, and the library answers with its own signed cookie. The navigation that follows rides it.
|
|
8
|
+
*
|
|
9
|
+
* No UI here on purpose: you own the button, the page and the copy. This module owns the two things
|
|
10
|
+
* a host would otherwise have to rediscover — where the session endpoint actually lives, and how to
|
|
11
|
+
* call it without the failure mode below.
|
|
12
|
+
*/
|
|
13
|
+
/** The mount default; matches `AgentDashboardModule.forRoot()`'s own default. */
|
|
14
|
+
const DEFAULT_BASE_PATH = '/ai-gateway';
|
|
15
|
+
function normalizeBasePath(basePath) {
|
|
16
|
+
const trimmed = basePath.trim().replace(/\/+$/, '');
|
|
17
|
+
if (trimmed === '')
|
|
18
|
+
return '';
|
|
19
|
+
return trimmed.startsWith('/') ? trimmed : `/${trimmed}`;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Where `POST` mints the console session cookie.
|
|
23
|
+
*
|
|
24
|
+
* Derived from `basePath` rather than hardcoded by the caller: this package owns the route (the
|
|
25
|
+
* auth controller is mounted relative to `basePath` by `RouterModule`), so a host that hardcodes it
|
|
26
|
+
* is guessing at something that can change under a version bump — with no compile error when it
|
|
27
|
+
* does, because the break only shows up as a 404 at runtime.
|
|
28
|
+
*/
|
|
29
|
+
export function agentConsoleSessionUrl(basePath = DEFAULT_BASE_PATH) {
|
|
30
|
+
return `${normalizeBasePath(basePath)}/auth/session`;
|
|
31
|
+
}
|
|
32
|
+
/** Where the console SPA itself is served. */
|
|
33
|
+
export function agentConsoleUrl(basePath = DEFAULT_BASE_PATH) {
|
|
34
|
+
return normalizeBasePath(basePath) || '/';
|
|
35
|
+
}
|
|
36
|
+
/** Thrown when the session could not be minted. Never thrown after a successful mint. */
|
|
37
|
+
export class ConsoleSessionError extends Error {
|
|
38
|
+
url;
|
|
39
|
+
status;
|
|
40
|
+
constructor(message, url,
|
|
41
|
+
/** The HTTP status, or `undefined` when the request never produced one (network error). */
|
|
42
|
+
status) {
|
|
43
|
+
super(message);
|
|
44
|
+
this.url = url;
|
|
45
|
+
this.status = status;
|
|
46
|
+
this.name = 'ConsoleSessionError';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async function resolveHeaders(headers) {
|
|
50
|
+
if (headers === undefined)
|
|
51
|
+
return {};
|
|
52
|
+
return typeof headers === 'function' ? await headers() : headers;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Mint the console session cookie. Resolves on success; throws {@link ConsoleSessionError} on
|
|
56
|
+
* refusal. Use this directly when you want to mint without navigating (a pre-flight check, or a
|
|
57
|
+
* link the user opens later).
|
|
58
|
+
*/
|
|
59
|
+
export async function mintAgentConsoleSession(options = {}) {
|
|
60
|
+
const url = agentConsoleSessionUrl(options.basePath);
|
|
61
|
+
const doFetch = options.fetch ?? globalThis.fetch;
|
|
62
|
+
if (typeof doFetch !== 'function') {
|
|
63
|
+
throw new ConsoleSessionError('No `fetch` available; pass one via `options.fetch`.', url);
|
|
64
|
+
}
|
|
65
|
+
let response;
|
|
66
|
+
try {
|
|
67
|
+
response = await doFetch(url, {
|
|
68
|
+
method: 'POST',
|
|
69
|
+
// The whole point: the response's Set-Cookie must stick, and the cookie must ride the
|
|
70
|
+
// navigation that follows.
|
|
71
|
+
credentials: 'include',
|
|
72
|
+
headers: await resolveHeaders(options.headers),
|
|
73
|
+
// Load-bearing, and the reason this helper exists rather than three lines at the call site.
|
|
74
|
+
// `fetch` FOLLOWS redirects by default, so an app whose auth layer rewrites a 401 into a
|
|
75
|
+
// "go to /signin" redirect makes this request resolve 200 against the sign-in HTML —
|
|
76
|
+
// `response.ok` reads true, the caller navigates, and the user lands in a console with no
|
|
77
|
+
// session, which looks exactly like a permissions bug. Handling the redirect explicitly turns
|
|
78
|
+
// that into a clear error instead of a silent false success.
|
|
79
|
+
redirect: 'manual',
|
|
80
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
catch (cause) {
|
|
84
|
+
throw new ConsoleSessionError(`Could not reach the console session endpoint at ${url}: ${String(cause)}`, url);
|
|
85
|
+
}
|
|
86
|
+
// `redirect: 'manual'` surfaces differently per runtime: browsers give an opaque response
|
|
87
|
+
// (`type: 'opaqueredirect'`, status 0), Node/undici gives the real 3xx. Both mean the same thing.
|
|
88
|
+
const redirected = response.type === 'opaqueredirect' || (response.status >= 300 && response.status < 400);
|
|
89
|
+
if (redirected) {
|
|
90
|
+
throw new ConsoleSessionError(`The console session endpoint at ${url} answered with a redirect instead of minting a session. Something in front of it — usually an auth middleware or exception filter that rewrites 401s into a sign-in redirect — is intercepting the response. Exempt this path from that rewrite so the real status reaches this caller.`, url, response.status || undefined);
|
|
91
|
+
}
|
|
92
|
+
if (!response.ok) {
|
|
93
|
+
throw new ConsoleSessionError(`The console refused to open (HTTP ${response.status}).`, url, response.status);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Mint the session, then navigate to the console. Throws without navigating when the mint is
|
|
98
|
+
* refused, so a denied user gets a real error instead of landing on the console's
|
|
99
|
+
* "no session" page — which reads as a bug rather than a permission decision.
|
|
100
|
+
*/
|
|
101
|
+
export async function openAgentConsole(options = {}) {
|
|
102
|
+
await mintAgentConsoleSession(options);
|
|
103
|
+
const target = agentConsoleUrl(options.basePath);
|
|
104
|
+
const navigate = options.navigate ?? ((url) => globalThis.location?.assign(url));
|
|
105
|
+
navigate(target);
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=console-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console-session.js","sourceRoot":"","sources":["../../src/client/console-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,iFAAiF;AACjF,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAExC,SAAS,iBAAiB,CAAC,QAAgB;IACzC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACpD,IAAI,OAAO,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IAC9B,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC;AAC3D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,WAAmB,iBAAiB;IACzE,OAAO,GAAG,iBAAiB,CAAC,QAAQ,CAAC,eAAe,CAAC;AACvD,CAAC;AAED,8CAA8C;AAC9C,MAAM,UAAU,eAAe,CAAC,WAAmB,iBA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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AASA,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AAEzC,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// The React tier of `@dudousxd/nestjs-agent-dashboard`, published at the `./react` subpath so a
|
|
2
|
+
// host that only mounts the NestJS module never pulls React in. Three levels, pick one:
|
|
3
|
+
//
|
|
4
|
+
// openAgentConsole(...) — no React at all (`./client`), you own everything
|
|
5
|
+
// useOpenAgentConsole(...) — state for a launcher UI, you own the markup
|
|
6
|
+
// <OpenAgentConsoleButton /> — drop-in, unstyled, forwards every button prop
|
|
7
|
+
//
|
|
8
|
+
// `openAgentConsoleMutationOptions` wires the same call into TanStack Query without this package
|
|
9
|
+
// depending on TanStack.
|
|
10
|
+
export * from './use-open-console.js';
|
|
11
|
+
export * from './open-console-button.js';
|
|
12
|
+
// Re-exported so a React consumer needs one import path, not two.
|
|
13
|
+
export * from '../client/console-session.js';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,wFAAwF;AACxF,EAAE;AACF,oFAAoF;AACpF,+EAA+E;AAC/E,iFAAiF;AACjF,EAAE;AACF,iGAAiG;AACjG,yBAAyB;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,kEAAkE;AAClE,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import type { OpenConsoleOptions } from '../client/console-session.js';
|
|
3
|
+
export interface OpenAgentConsoleButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick' | 'children'>, OpenConsoleOptions {
|
|
4
|
+
/** Button label. Defaults to "Open AI gateway". */
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
/** Shown while the session is being minted. Defaults to "Opening…". */
|
|
7
|
+
pendingLabel?: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Render the refusal yourself. Omit and the button renders a plain `<p role="alert">` under
|
|
10
|
+
* itself; pass `null` to render nothing and read the error from {@link useOpenAgentConsole}.
|
|
11
|
+
*/
|
|
12
|
+
renderError?: ((error: Error) => ReactNode) | null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Drop-in launcher: the top tier, for a host that just wants a working button.
|
|
16
|
+
*
|
|
17
|
+
* Deliberately unstyled — it emits a bare `<button>` and forwards `className`/`style`/every other
|
|
18
|
+
* button prop, so it inherits whatever design system the host already has instead of importing CSS
|
|
19
|
+
* that would fight it. When it doesn't fit, drop to {@link useOpenAgentConsole} (same behaviour,
|
|
20
|
+
* your markup) or to `openAgentConsole` (no React at all).
|
|
21
|
+
*
|
|
22
|
+
* The error is rendered by default rather than swallowed: a refused mint is the case a launcher most
|
|
23
|
+
* needs to surface, and a button that silently does nothing reads as broken rather than forbidden.
|
|
24
|
+
*/
|
|
25
|
+
export declare function OpenAgentConsoleButton({ children, pendingLabel, renderError, basePath, headers, fetch: fetchImpl, signal, navigate, disabled, ...buttonProps }: OpenAgentConsoleButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
//# sourceMappingURL=open-console-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-console-button.d.ts","sourceRoot":"","sources":["../../src/react/open-console-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAGvE,MAAM,WAAW,2BACf,SAAQ,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC,EAC3E,kBAAkB;IACpB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,uEAAuE;IACvE,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,GAAG,IAAI,CAAC;CACpD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,OAAO,EACP,KAAK,EAAE,SAAS,EAChB,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,GAAG,WAAW,EACf,EAAE,2BAA2B,2CA4B7B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useOpenAgentConsole } from './use-open-console.js';
|
|
3
|
+
/**
|
|
4
|
+
* Drop-in launcher: the top tier, for a host that just wants a working button.
|
|
5
|
+
*
|
|
6
|
+
* Deliberately unstyled — it emits a bare `<button>` and forwards `className`/`style`/every other
|
|
7
|
+
* button prop, so it inherits whatever design system the host already has instead of importing CSS
|
|
8
|
+
* that would fight it. When it doesn't fit, drop to {@link useOpenAgentConsole} (same behaviour,
|
|
9
|
+
* your markup) or to `openAgentConsole` (no React at all).
|
|
10
|
+
*
|
|
11
|
+
* The error is rendered by default rather than swallowed: a refused mint is the case a launcher most
|
|
12
|
+
* needs to surface, and a button that silently does nothing reads as broken rather than forbidden.
|
|
13
|
+
*/
|
|
14
|
+
export function OpenAgentConsoleButton({ children, pendingLabel, renderError, basePath, headers, fetch: fetchImpl, signal, navigate, disabled, ...buttonProps }) {
|
|
15
|
+
const { open, isPending, error } = useOpenAgentConsole({
|
|
16
|
+
// Spread-if-defined rather than passing the keys through: the package compiles with
|
|
17
|
+
// `exactOptionalPropertyTypes`, under which an explicit `basePath: undefined` is not assignable
|
|
18
|
+
// to `basePath?: string`.
|
|
19
|
+
...(basePath !== undefined ? { basePath } : {}),
|
|
20
|
+
...(headers !== undefined ? { headers } : {}),
|
|
21
|
+
...(fetchImpl !== undefined ? { fetch: fetchImpl } : {}),
|
|
22
|
+
...(signal !== undefined ? { signal } : {}),
|
|
23
|
+
...(navigate !== undefined ? { navigate } : {}),
|
|
24
|
+
});
|
|
25
|
+
return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", ...buttonProps, onClick: open, disabled: disabled || isPending, "aria-busy": isPending || undefined, children: isPending ? (pendingLabel ?? 'Opening…') : (children ?? 'Open AI gateway') }), error &&
|
|
26
|
+
renderError !== null &&
|
|
27
|
+
(renderError?.(error) ?? _jsx("p", { role: "alert", children: error.message }))] }));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=open-console-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-console-button.js","sourceRoot":"","sources":["../../src/react/open-console-button.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAgB5D;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CAAC,EACrC,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,OAAO,EACP,KAAK,EAAE,SAAS,EAChB,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,GAAG,WAAW,EACc;IAC5B,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,mBAAmB,CAAC;QACrD,oFAAoF;QACpF,gGAAgG;QAChG,0BAA0B;QAC1B,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/C,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7C,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACxD,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3C,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAChD,CAAC,CAAC;IAEH,OAAO,CACL,8BACE,iBACE,IAAI,EAAC,QAAQ,KACT,WAAW,EACf,OAAO,EAAE,IAAI,EACb,QAAQ,EAAE,QAAQ,IAAI,SAAS,eACpB,SAAS,IAAI,SAAS,YAEhC,SAAS,CAAC,CAAC,CAAC,CAAC,YAAY,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,IAAI,iBAAiB,CAAC,GACpE,EACR,KAAK;gBACJ,WAAW,KAAK,IAAI;gBACpB,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,IAAI,YAAG,IAAI,EAAC,OAAO,YAAE,KAAK,CAAC,OAAO,GAAK,CAAC,IAC9D,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ConsoleSessionError, type OpenConsoleOptions } from '../client/console-session.js';
|
|
2
|
+
/**
|
|
3
|
+
* React layer over `openAgentConsole` — the middle tier between the bare function
|
|
4
|
+
* (`../client/console-session.ts`) and the drop-in `<OpenAgentConsoleButton>`.
|
|
5
|
+
*
|
|
6
|
+
* You get the state a launcher UI actually needs (in-flight, error) and keep full control of the
|
|
7
|
+
* markup. Nothing here is AI-gateway-specific beyond the endpoint: it is a mint-then-navigate call
|
|
8
|
+
* with the two states that call can be in.
|
|
9
|
+
*/
|
|
10
|
+
export interface UseOpenConsoleResult {
|
|
11
|
+
/** Start the mint-then-navigate. Never rejects — read `error` instead. */
|
|
12
|
+
open: () => void;
|
|
13
|
+
/** True from the click until the navigation starts, or until it fails. */
|
|
14
|
+
isPending: boolean;
|
|
15
|
+
/** The last refusal, or `null`. Cleared when `open()` is called again. */
|
|
16
|
+
error: ConsoleSessionError | null;
|
|
17
|
+
/** Drop a stale error without retrying — e.g. when a dialog closes. */
|
|
18
|
+
reset: () => void;
|
|
19
|
+
}
|
|
20
|
+
export declare function useOpenAgentConsole(options?: OpenConsoleOptions): UseOpenConsoleResult;
|
|
21
|
+
/**
|
|
22
|
+
* TanStack Query integration WITHOUT a TanStack dependency: the returned object is the shape
|
|
23
|
+
* `useMutation` takes, so a host that already uses Query wires the launcher into its own cache,
|
|
24
|
+
* devtools and error handling with no extra adapter — and a host that doesn't never pays for it.
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* const { mutate, isPending } = useMutation(openAgentConsoleMutationOptions({ headers }));
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function openAgentConsoleMutationOptions(options?: OpenConsoleOptions): {
|
|
31
|
+
mutationKey: readonly unknown[];
|
|
32
|
+
mutationFn: () => Promise<void>;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=use-open-console.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-open-console.d.ts","sourceRoot":"","sources":["../../src/react/use-open-console.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,KAAK,kBAAkB,EAGxB,MAAM,8BAA8B,CAAC;AAEtC;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC,0EAA0E;IAC1E,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,0EAA0E;IAC1E,SAAS,EAAE,OAAO,CAAC;IACnB,0EAA0E;IAC1E,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAClC,uEAAuE;IACvE,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,kBAAuB,GAAG,oBAAoB,CAoC1F;AAED;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,GAAE,kBAAuB,GAAG;IACjF,WAAW,EAAE,SAAS,OAAO,EAAE,CAAC;IAChC,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC,CAKA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from 'react';
|
|
2
|
+
import { ConsoleSessionError, agentConsoleSessionUrl, openAgentConsole, } from '../client/console-session.js';
|
|
3
|
+
export function useOpenAgentConsole(options = {}) {
|
|
4
|
+
const [isPending, setIsPending] = useState(false);
|
|
5
|
+
const [error, setError] = useState(null);
|
|
6
|
+
// Kept in a ref so a caller passing an inline object literal (the common case) doesn't change the
|
|
7
|
+
// identity of `open` on every render, which would defeat memoizing anything downstream.
|
|
8
|
+
const optionsRef = useRef(options);
|
|
9
|
+
optionsRef.current = options;
|
|
10
|
+
const open = useCallback(() => {
|
|
11
|
+
setIsPending(true);
|
|
12
|
+
setError(null);
|
|
13
|
+
void openAgentConsole(optionsRef.current)
|
|
14
|
+
.then(() => {
|
|
15
|
+
// Deliberately NOT clearing `isPending` on success: the navigation is already underway and
|
|
16
|
+
// this component is about to be torn down. Flipping the button back to idle first produces
|
|
17
|
+
// a visible flicker of "ready to click again" on a page that is leaving.
|
|
18
|
+
})
|
|
19
|
+
.catch((cause) => {
|
|
20
|
+
setError(cause instanceof ConsoleSessionError
|
|
21
|
+
? cause
|
|
22
|
+
: // Anything else got thrown before the client could classify it, so the endpoint is
|
|
23
|
+
// the only context worth carrying — `ConsoleSessionError` takes the url, not a kind.
|
|
24
|
+
new ConsoleSessionError(String(cause), agentConsoleSessionUrl(optionsRef.current.basePath)));
|
|
25
|
+
setIsPending(false);
|
|
26
|
+
});
|
|
27
|
+
}, []);
|
|
28
|
+
const reset = useCallback(() => setError(null), []);
|
|
29
|
+
return { open, isPending, error, reset };
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* TanStack Query integration WITHOUT a TanStack dependency: the returned object is the shape
|
|
33
|
+
* `useMutation` takes, so a host that already uses Query wires the launcher into its own cache,
|
|
34
|
+
* devtools and error handling with no extra adapter — and a host that doesn't never pays for it.
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* const { mutate, isPending } = useMutation(openAgentConsoleMutationOptions({ headers }));
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export function openAgentConsoleMutationOptions(options = {}) {
|
|
41
|
+
return {
|
|
42
|
+
mutationKey: ['agent', 'console', 'open', options.basePath ?? null],
|
|
43
|
+
mutationFn: () => openAgentConsole(options),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=use-open-console.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-open-console.js","sourceRoot":"","sources":["../../src/react/use-open-console.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EACL,mBAAmB,EAEnB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,8BAA8B,CAAC;AAqBtC,MAAM,UAAU,mBAAmB,CAAC,UAA8B,EAAE;IAClE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAA6B,IAAI,CAAC,CAAC;IAErE,kGAAkG;IAClG,wFAAwF;IACxF,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IACnC,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC;IAE7B,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,EAAE;QAC5B,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,QAAQ,CAAC,IAAI,CAAC,CAAC;QACf,KAAK,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC;aACtC,IAAI,CAAC,GAAG,EAAE;YACT,2FAA2F;YAC3F,2FAA2F;YAC3F,yEAAyE;QAC3E,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YACxB,QAAQ,CACN,KAAK,YAAY,mBAAmB;gBAClC,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,mFAAmF;oBACnF,qFAAqF;oBACrF,IAAI,mBAAmB,CACrB,MAAM,CAAC,KAAK,CAAC,EACb,sBAAsB,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CACpD,CACN,CAAC;YACF,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;IACP,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IAEpD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC3C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,+BAA+B,CAAC,UAA8B,EAAE;IAI9E,OAAO;QACL,WAAW,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAU;QAC5E,UAAU,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC;KAC5C,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dudousxd/nestjs-agent-dashboard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/DavideCarvalho/nestjs-agent.git",
|
|
@@ -28,6 +28,11 @@
|
|
|
28
28
|
"types": "./dist/client/agent-client.d.ts",
|
|
29
29
|
"import": "./dist/client/agent-client.js",
|
|
30
30
|
"default": "./dist/client/agent-client.js"
|
|
31
|
+
},
|
|
32
|
+
"./react": {
|
|
33
|
+
"types": "./dist/react/index.d.ts",
|
|
34
|
+
"import": "./dist/react/index.js",
|
|
35
|
+
"default": "./dist/react/index.js"
|
|
31
36
|
}
|
|
32
37
|
},
|
|
33
38
|
"files": [
|
|
@@ -37,9 +42,19 @@
|
|
|
37
42
|
"@dudousxd/nestjs-agent-core": ">=0.1.0 <1.0.0",
|
|
38
43
|
"@nestjs/common": "^10.0.0 || ^11.0.0",
|
|
39
44
|
"@nestjs/core": "^10.0.0 || ^11.0.0",
|
|
45
|
+
"react": ">=18.0.0",
|
|
46
|
+
"react-dom": ">=18.0.0",
|
|
40
47
|
"reflect-metadata": "^0.2.0",
|
|
41
48
|
"rxjs": "^7.0.0"
|
|
42
49
|
},
|
|
50
|
+
"peerDependenciesMeta": {
|
|
51
|
+
"react": {
|
|
52
|
+
"optional": true
|
|
53
|
+
},
|
|
54
|
+
"react-dom": {
|
|
55
|
+
"optional": true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
43
58
|
"dependencies": {
|
|
44
59
|
"@dudousxd/nestjs-diagnostics": "0.7.0"
|
|
45
60
|
},
|
|
@@ -50,11 +65,14 @@
|
|
|
50
65
|
"@nestjs/testing": "11.1.6",
|
|
51
66
|
"@swc/core": "1.15.41",
|
|
52
67
|
"@tanstack/react-query": "5.62.7",
|
|
68
|
+
"@testing-library/dom": "10.4.0",
|
|
69
|
+
"@testing-library/react": "16.3.0",
|
|
53
70
|
"@types/react": "19.2.5",
|
|
54
71
|
"@types/react-dom": "19.2.3",
|
|
55
72
|
"@types/supertest": "6.0.2",
|
|
56
73
|
"@vitejs/plugin-react": "4.3.4",
|
|
57
74
|
"autoprefixer": "10.4.20",
|
|
75
|
+
"jsdom": "26.1.0",
|
|
58
76
|
"postcss": "8.5.16",
|
|
59
77
|
"react": "19.2.5",
|
|
60
78
|
"react-dom": "19.2.5",
|
|
@@ -69,7 +87,7 @@
|
|
|
69
87
|
"@dudousxd/nestjs-agent-core": "0.10.0"
|
|
70
88
|
},
|
|
71
89
|
"scripts": {
|
|
72
|
-
"build": "vite build && tsup && tsc -p tsconfig.client.json",
|
|
73
|
-
"typecheck": "tsc -p tsconfig.server.json --noEmit && tsc -p tsconfig.server.spec.json --noEmit && tsc -p tsconfig.app.json --noEmit"
|
|
90
|
+
"build": "vite build && tsup && tsc -p tsconfig.client.json && tsc -p tsconfig.react.json",
|
|
91
|
+
"typecheck": "tsc -p tsconfig.server.json --noEmit && tsc -p tsconfig.server.spec.json --noEmit && tsc -p tsconfig.app.json --noEmit && tsc -p tsconfig.react.spec.json --noEmit"
|
|
74
92
|
}
|
|
75
93
|
}
|