@dudousxd/nestjs-agent-dashboard 0.3.0 → 0.4.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 +38 -0
- package/dist/client/agent-client.d.ts.map +1 -1
- package/dist/client/agent-client.js +19 -0
- package/dist/client/agent-client.js.map +1 -1
- package/dist/client/budget-usage.d.ts +2 -0
- package/dist/client/budget-usage.d.ts.map +1 -1
- package/dist/client/budget-usage.js +1 -0
- package/dist/client/budget-usage.js.map +1 -1
- package/dist/client/format-model.d.ts +10 -0
- package/dist/client/format-model.d.ts.map +1 -0
- package/dist/client/format-model.js +18 -0
- package/dist/client/format-model.js.map +1 -0
- package/dist/server/index.cjs +231 -39
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +121 -8
- package/dist/server/index.d.ts +121 -8
- package/dist/server/index.js +197 -9
- package/dist/server/index.js.map +1 -1
- package/dist/spa/assets/index-BHFHKR8b.css +1 -0
- package/dist/spa/assets/index-DPCmjbDB.js +1 -0
- package/dist/spa/assets/index-DXmRzl_c.js +49 -0
- package/dist/spa/assets/preview-BQeQWTP5.js +1 -0
- package/dist/spa/index.html +3 -3
- package/dist/spa/preview.html +3 -3
- package/package.json +8 -2
- package/dist/spa/assets/index-CVpU-HIB.js +0 -49
- package/dist/spa/assets/index-DAwWrHBV.css +0 -1
- package/dist/spa/assets/index-IlHveh9s.js +0 -1
- package/dist/spa/assets/preview-BsbVArrR.js +0 -1
|
@@ -17,6 +17,19 @@ export interface ActorSpendRow {
|
|
|
17
17
|
requests: number;
|
|
18
18
|
totalTokens: number;
|
|
19
19
|
costUsd: number;
|
|
20
|
+
/** Human-readable label resolved from `actorRef` (an `ActorDirectory`), when one is bound server-side. */
|
|
21
|
+
actorLabel: string | null;
|
|
22
|
+
}
|
|
23
|
+
/** Spend + token totals for one thread over a range. */
|
|
24
|
+
export interface ThreadSpendRow {
|
|
25
|
+
threadId: string;
|
|
26
|
+
title: string;
|
|
27
|
+
actorRef: string;
|
|
28
|
+
requests: number;
|
|
29
|
+
totalTokens: number;
|
|
30
|
+
costUsd: number;
|
|
31
|
+
/** Human-readable label resolved from `actorRef` (an `ActorDirectory`), when one is bound server-side. */
|
|
32
|
+
actorLabel: string | null;
|
|
20
33
|
}
|
|
21
34
|
/** One point on the daily usage/cost trend. */
|
|
22
35
|
export interface UsageTrendPoint {
|
|
@@ -41,6 +54,25 @@ export interface ThreadActivityRow {
|
|
|
41
54
|
messageCount: number;
|
|
42
55
|
totalTokens: number;
|
|
43
56
|
lastActivityAt: string;
|
|
57
|
+
/** Human-readable label resolved from `actorRef` (an `ActorDirectory`), when one is bound server-side. */
|
|
58
|
+
actorLabel: string | null;
|
|
59
|
+
}
|
|
60
|
+
/** A model's current per-1M-token price (the pricing tab's row shape). */
|
|
61
|
+
export interface ModelPrice {
|
|
62
|
+
modelId: string;
|
|
63
|
+
inputPricePer1m: number;
|
|
64
|
+
outputPricePer1m: number;
|
|
65
|
+
cacheWritePricePer1m?: number;
|
|
66
|
+
cacheReadPricePer1m?: number;
|
|
67
|
+
effectiveFrom: string;
|
|
68
|
+
}
|
|
69
|
+
/** Body for `POST <api>/pricing` — sets a model's current price. */
|
|
70
|
+
export interface UpsertModelPriceInput {
|
|
71
|
+
modelId: string;
|
|
72
|
+
inputPricePer1m: number;
|
|
73
|
+
outputPricePer1m: number;
|
|
74
|
+
cacheWritePricePer1m?: number;
|
|
75
|
+
cacheReadPricePer1m?: number;
|
|
44
76
|
}
|
|
45
77
|
/** The `GET <api>/spend` response. */
|
|
46
78
|
export interface SpendOverview {
|
|
@@ -65,10 +97,16 @@ declare global {
|
|
|
65
97
|
export declare const agentClient: {
|
|
66
98
|
/** Spend/usage overview for a day range: `{ byModel, byActor, trend }`. */
|
|
67
99
|
spend(range: GovernanceRange): Promise<SpendOverview>;
|
|
100
|
+
/** Top threads by cost for a day range (default 10). */
|
|
101
|
+
topThreads(range: GovernanceRange, limit?: number): Promise<ThreadSpendRow[]>;
|
|
68
102
|
/** Most recent tool calls (default 50). */
|
|
69
103
|
toolCalls(limit?: number): Promise<ToolCallActivityRow[]>;
|
|
70
104
|
/** Most recent threads (default 50). */
|
|
71
105
|
threads(limit?: number): Promise<ThreadActivityRow[]>;
|
|
106
|
+
/** Current price row per model. 501s if the host has no pricing store bound. */
|
|
107
|
+
pricing(): Promise<ModelPrice[]>;
|
|
108
|
+
/** Set a model's current price. 501s if the host has no pricing store bound. */
|
|
109
|
+
upsertPrice(input: UpsertModelPriceInput): Promise<void>;
|
|
72
110
|
/**
|
|
73
111
|
* Live-tail `aviary:agent:*` events over SSE. Calls `onEvent` per event; returns a function that
|
|
74
112
|
* closes the stream.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-client.d.ts","sourceRoot":"","sources":["../../src/client/agent-client.ts"],"names":[],"mappings":"AAIA,kDAAkD;AAClD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,0EAA0E;AAC1E,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-client.d.ts","sourceRoot":"","sources":["../../src/client/agent-client.ts"],"names":[],"mappings":"AAIA,kDAAkD;AAClD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,uDAAuD;AACvD,MAAM,WAAW,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AE,CAAC;IAGrD,wCAAwC;6BACnB,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAGjD,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"}
|
|
@@ -19,6 +19,11 @@ export const agentClient = {
|
|
|
19
19
|
const q = new URLSearchParams({ from: range.fromDay, to: range.toDay });
|
|
20
20
|
return http(`/spend?${q.toString()}`);
|
|
21
21
|
},
|
|
22
|
+
/** Top threads by cost for a day range (default 10). */
|
|
23
|
+
topThreads(range, limit = 10) {
|
|
24
|
+
const q = new URLSearchParams({ from: range.fromDay, to: range.toDay, limit: `${limit}` });
|
|
25
|
+
return http(`/top-threads?${q.toString()}`);
|
|
26
|
+
},
|
|
22
27
|
/** Most recent tool calls (default 50). */
|
|
23
28
|
toolCalls(limit = 50) {
|
|
24
29
|
return http(`/tool-calls?limit=${limit}`);
|
|
@@ -27,6 +32,20 @@ export const agentClient = {
|
|
|
27
32
|
threads(limit = 50) {
|
|
28
33
|
return http(`/threads?limit=${limit}`);
|
|
29
34
|
},
|
|
35
|
+
/** Current price row per model. 501s if the host has no pricing store bound. */
|
|
36
|
+
pricing() {
|
|
37
|
+
return http('/pricing');
|
|
38
|
+
},
|
|
39
|
+
/** Set a model's current price. 501s if the host has no pricing store bound. */
|
|
40
|
+
async upsertPrice(input) {
|
|
41
|
+
const res = await fetch(`${apiBase()}/pricing`, {
|
|
42
|
+
method: 'POST',
|
|
43
|
+
headers: { 'Content-Type': 'application/json' },
|
|
44
|
+
body: JSON.stringify(input),
|
|
45
|
+
});
|
|
46
|
+
if (!res.ok)
|
|
47
|
+
throw new Error(`${res.status} ${res.statusText}`);
|
|
48
|
+
},
|
|
30
49
|
/**
|
|
31
50
|
* Live-tail `aviary:agent:*` events over SSE. Calls `onEvent` per event; returns a function that
|
|
32
51
|
* closes the stream.
|
|
@@ -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,mGAAmG;AACnG,uGAAuG;AACvG,gFAAgF;AA8GhF,SAAS,OAAO;IACd,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,aAAa;QAAE,OAAO,MAAM,CAAC,aAAa,CAAC;IACvF,MAAM,IAAI,GAAG,CAAC,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,cAAc,CAAC,IAAI,aAAa,CAAC;IACvF,OAAO,GAAG,IAAI,MAAM,CAAC;AACvB,CAAC;AAED,KAAK,UAAU,IAAI,CAAI,IAAY,EAAE,IAAkB;IACrD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,CAAC,CAAC;IAChD,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;IAChE,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAM,CAAC;AACjC,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,2EAA2E;IAC3E,KAAK,CAAC,KAAsB;QAC1B,MAAM,CAAC,GAAG,IAAI,eAAe,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QACxE,OAAO,IAAI,CAAgB,UAAU,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACvD,CAAC;IACD,wDAAw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C;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"}
|
|
@@ -7,6 +7,8 @@ export interface ActorBudget {
|
|
|
7
7
|
requests: number;
|
|
8
8
|
totalTokens: number;
|
|
9
9
|
costUsd: number;
|
|
10
|
+
/** Human-readable label resolved from `actorRef`, when an `ActorDirectory` is bound server-side. */
|
|
11
|
+
actorLabel: string | null;
|
|
10
12
|
/** Configured daily token limit, when known. */
|
|
11
13
|
limitTokens?: number;
|
|
12
14
|
/** `totalTokens / limitTokens` (0..N; can exceed 1). Present only when a limit is known. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"budget-usage.d.ts","sourceRoot":"","sources":["../../src/client/budget-usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,uGAAuG;AACvG,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE/C,wEAAwE;AACxE,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4FAA4F;IAC5F,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,aAAa,EAAE,EAAE,OAAO,GAAE,SAAc,GAAG,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"budget-usage.d.ts","sourceRoot":"","sources":["../../src/client/budget-usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,uGAAuG;AACvG,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE/C,wEAAwE;AACxE,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,oGAAoG;IACpG,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,gDAAgD;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4FAA4F;IAC5F,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,aAAa,EAAE,EAAE,OAAO,GAAE,SAAc,GAAG,WAAW,EAAE,CAkBzF"}
|
|
@@ -14,6 +14,7 @@ export function joinBudgets(rows, budgets = {}) {
|
|
|
14
14
|
requests: row.requests,
|
|
15
15
|
totalTokens: row.totalTokens,
|
|
16
16
|
costUsd: row.costUsd,
|
|
17
|
+
actorLabel: row.actorLabel,
|
|
17
18
|
overBudget: usageRatio !== undefined && usageRatio >= 1,
|
|
18
19
|
...(hasLimit ? { limitTokens: limit } : {}),
|
|
19
20
|
...(usageRatio !== undefined ? { usageRatio } : {}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"budget-usage.js","sourceRoot":"","sources":["../../src/client/budget-usage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"budget-usage.js","sourceRoot":"","sources":["../../src/client/budget-usage.ts"],"names":[],"mappings":"AAqBA;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,IAAqB,EAAE,UAAqB,EAAE;IACxE,OAAO,IAAI;SACR,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QACX,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACpC,MAAM,QAAQ,GAAG,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,GAAG,CAAC,CAAC;QACxD,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;QAClE,OAAO;YACL,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,UAAU,EAAE,GAAG,CAAC,UAAU;YAC1B,UAAU,EAAE,UAAU,KAAK,SAAS,IAAI,UAAU,IAAI,CAAC;YACvD,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3C,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACpD,CAAC;IACJ,CAAC,CAAC;SACD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC;AAC5E,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn a raw model id — often a full Bedrock inference-profile ARN — into a short, readable label
|
|
3
|
+
* for the governance UI. Bedrock ids arrive as
|
|
4
|
+
* `arn:aws:bedrock:<region>:<acct>:inference-profile/<region>.<provider>.<model>`, which overflows
|
|
5
|
+
* cards and shoves table columns sideways. We keep the distinguishing `<model>` and drop the ARN
|
|
6
|
+
* prefix plus the cross-region/provider qualifiers. Non-ARN ids (e.g. `gpt-4o`) pass through
|
|
7
|
+
* unchanged. The full id is still surfaced via a `title` tooltip at the call sites.
|
|
8
|
+
*/
|
|
9
|
+
export declare function formatModelLabel(modelId: string): string;
|
|
10
|
+
//# sourceMappingURL=format-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-model.d.ts","sourceRoot":"","sources":["../../src/client/format-model.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAQxD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn a raw model id — often a full Bedrock inference-profile ARN — into a short, readable label
|
|
3
|
+
* for the governance UI. Bedrock ids arrive as
|
|
4
|
+
* `arn:aws:bedrock:<region>:<acct>:inference-profile/<region>.<provider>.<model>`, which overflows
|
|
5
|
+
* cards and shoves table columns sideways. We keep the distinguishing `<model>` and drop the ARN
|
|
6
|
+
* prefix plus the cross-region/provider qualifiers. Non-ARN ids (e.g. `gpt-4o`) pass through
|
|
7
|
+
* unchanged. The full id is still surfaced via a `title` tooltip at the call sites.
|
|
8
|
+
*/
|
|
9
|
+
export function formatModelLabel(modelId) {
|
|
10
|
+
if (!modelId.includes('/')) {
|
|
11
|
+
return modelId;
|
|
12
|
+
}
|
|
13
|
+
const profile = modelId.slice(modelId.lastIndexOf('/') + 1);
|
|
14
|
+
// Inference-profile ids are "<region>.<provider>.<model>" (e.g. "us-gov.anthropic.claude-…").
|
|
15
|
+
// Drop the leading region + provider so only the model name remains.
|
|
16
|
+
return profile.replace(/^[a-z]{2}[a-z-]*\.[a-z0-9]+\./, '');
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=format-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-model.js","sourceRoot":"","sources":["../../src/client/format-model.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5D,8FAA8F;IAC9F,qEAAqE;IACrE,OAAO,OAAO,CAAC,OAAO,CAAC,+BAA+B,EAAE,EAAE,CAAC,CAAC;AAC9D,CAAC"}
|
package/dist/server/index.cjs
CHANGED
|
@@ -22,28 +22,74 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
22
22
|
// src/server/index.ts
|
|
23
23
|
var index_exports = {};
|
|
24
24
|
__export(index_exports, {
|
|
25
|
+
AGENT_ACTOR_DIRECTORY: () => AGENT_ACTOR_DIRECTORY,
|
|
25
26
|
AGENT_GOVERNANCE_QUERIES: () => AGENT_GOVERNANCE_QUERIES,
|
|
27
|
+
AGENT_PRICING_STORE: () => AGENT_PRICING_STORE,
|
|
26
28
|
AgentApiController: () => AgentApiController,
|
|
27
29
|
AgentApiModule: () => AgentApiModule,
|
|
28
30
|
AgentDashboardModule: () => AgentDashboardModule,
|
|
29
31
|
AgentUiController: () => AgentUiController,
|
|
30
32
|
DASHBOARD_API_PATH: () => DASHBOARD_API_PATH,
|
|
31
33
|
DASHBOARD_BASE_PATH: () => DASHBOARD_BASE_PATH,
|
|
32
|
-
DashboardService: () => DashboardService
|
|
34
|
+
DashboardService: () => DashboardService,
|
|
35
|
+
agentDashboardMountPaths: () => agentDashboardMountPaths,
|
|
36
|
+
parsePriceInput: () => parsePriceInput
|
|
33
37
|
});
|
|
34
38
|
module.exports = __toCommonJS(index_exports);
|
|
35
39
|
|
|
36
40
|
// src/server/agent-api.controller.ts
|
|
37
|
-
var
|
|
41
|
+
var import_common3 = require("@nestjs/common");
|
|
38
42
|
|
|
39
43
|
// src/server/dashboard.service.ts
|
|
40
44
|
var import_node_diagnostics_channel = require("diagnostics_channel");
|
|
41
45
|
var import_nestjs_diagnostics = require("@dudousxd/nestjs-diagnostics");
|
|
42
|
-
var
|
|
46
|
+
var import_common2 = require("@nestjs/common");
|
|
43
47
|
var import_rxjs = require("rxjs");
|
|
44
48
|
|
|
49
|
+
// src/server/parse-price-input.ts
|
|
50
|
+
var import_common = require("@nestjs/common");
|
|
51
|
+
function parsePriceInput(body) {
|
|
52
|
+
if (typeof body !== "object" || body === null) {
|
|
53
|
+
throw new import_common.BadRequestException("Expected a JSON object body.");
|
|
54
|
+
}
|
|
55
|
+
const { modelId, inputPricePer1m, outputPricePer1m, cacheWritePricePer1m, cacheReadPricePer1m } = body;
|
|
56
|
+
if (typeof modelId !== "string" || modelId.trim().length === 0) {
|
|
57
|
+
throw new import_common.BadRequestException('"modelId" must be a non-empty string.');
|
|
58
|
+
}
|
|
59
|
+
if (!isFiniteNonNegative(inputPricePer1m)) {
|
|
60
|
+
throw new import_common.BadRequestException('"inputPricePer1m" must be a non-negative number.');
|
|
61
|
+
}
|
|
62
|
+
if (!isFiniteNonNegative(outputPricePer1m)) {
|
|
63
|
+
throw new import_common.BadRequestException('"outputPricePer1m" must be a non-negative number.');
|
|
64
|
+
}
|
|
65
|
+
if (cacheWritePricePer1m !== void 0 && !isFiniteNonNegative(cacheWritePricePer1m)) {
|
|
66
|
+
throw new import_common.BadRequestException('"cacheWritePricePer1m" must be a non-negative number when present.');
|
|
67
|
+
}
|
|
68
|
+
if (cacheReadPricePer1m !== void 0 && !isFiniteNonNegative(cacheReadPricePer1m)) {
|
|
69
|
+
throw new import_common.BadRequestException('"cacheReadPricePer1m" must be a non-negative number when present.');
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
modelId,
|
|
73
|
+
inputPricePer1m,
|
|
74
|
+
outputPricePer1m,
|
|
75
|
+
...cacheWritePricePer1m !== void 0 ? {
|
|
76
|
+
cacheWritePricePer1m
|
|
77
|
+
} : {},
|
|
78
|
+
...cacheReadPricePer1m !== void 0 ? {
|
|
79
|
+
cacheReadPricePer1m
|
|
80
|
+
} : {}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
__name(parsePriceInput, "parsePriceInput");
|
|
84
|
+
function isFiniteNonNegative(value) {
|
|
85
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
86
|
+
}
|
|
87
|
+
__name(isFiniteNonNegative, "isFiniteNonNegative");
|
|
88
|
+
|
|
45
89
|
// src/server/tokens.ts
|
|
46
90
|
var AGENT_GOVERNANCE_QUERIES = Symbol.for("@dudousxd/nestjs-agent:governance-queries");
|
|
91
|
+
var AGENT_ACTOR_DIRECTORY = Symbol.for("@dudousxd/nestjs-agent:actor-directory");
|
|
92
|
+
var AGENT_PRICING_STORE = Symbol.for("@dudousxd/nestjs-agent:pricing-store");
|
|
47
93
|
var DASHBOARD_BASE_PATH = Symbol.for("@dudousxd/nestjs-agent-dashboard:base-path");
|
|
48
94
|
var DASHBOARD_API_PATH = Symbol.for("@dudousxd/nestjs-agent-dashboard:api-path");
|
|
49
95
|
|
|
@@ -65,6 +111,7 @@ function _ts_param(paramIndex, decorator) {
|
|
|
65
111
|
};
|
|
66
112
|
}
|
|
67
113
|
__name(_ts_param, "_ts_param");
|
|
114
|
+
var PRICING_STORE_UNBOUND_MESSAGE = "Pricing CRUD is unavailable: no AGENT_PRICING_STORE is bound. Bind a pricing store (e.g. MikroOrmPricingStore from @dudousxd/nestjs-agent-store-mikro-orm) to enable it.";
|
|
68
115
|
var AGENT_EVENTS = [
|
|
69
116
|
"run.started",
|
|
70
117
|
"message",
|
|
@@ -82,29 +129,82 @@ var DashboardService = class {
|
|
|
82
129
|
__name(this, "DashboardService");
|
|
83
130
|
}
|
|
84
131
|
queries;
|
|
85
|
-
|
|
132
|
+
actorDirectory;
|
|
133
|
+
pricingStore;
|
|
134
|
+
constructor(queries, actorDirectory, pricingStore) {
|
|
86
135
|
this.queries = queries;
|
|
136
|
+
this.actorDirectory = actorDirectory;
|
|
137
|
+
this.pricingStore = pricingStore;
|
|
87
138
|
}
|
|
88
139
|
/** Spend/usage overview for a day range: by-model + by-actor spend and the daily trend, in parallel. */
|
|
89
140
|
async spend(range) {
|
|
90
|
-
const [byModel,
|
|
141
|
+
const [byModel, byActorRaw, trend] = await Promise.all([
|
|
91
142
|
this.queries.spendByModel(range),
|
|
92
143
|
this.queries.spendByActor(range),
|
|
93
144
|
this.queries.usageTrend(range)
|
|
94
145
|
]);
|
|
146
|
+
const byActor = await this.withActorLabels(byActorRaw);
|
|
95
147
|
return {
|
|
96
148
|
byModel,
|
|
97
149
|
byActor,
|
|
98
150
|
trend
|
|
99
151
|
};
|
|
100
152
|
}
|
|
153
|
+
/** Top threads by cost for a day range (default 10, highest cost first). */
|
|
154
|
+
async topThreads(range, limit = 10) {
|
|
155
|
+
const rows = await this.queries.spendByThread(range, limit);
|
|
156
|
+
return this.withActorLabels(rows);
|
|
157
|
+
}
|
|
101
158
|
/** Most recent tool calls (status/type/thread) for the Runs & tools activity feed. */
|
|
102
159
|
recentToolCalls(limit) {
|
|
103
160
|
return this.queries.recentToolCalls(limit);
|
|
104
161
|
}
|
|
105
162
|
/** Most recent threads with rolled-up message/token counts. */
|
|
106
|
-
recentThreads(limit) {
|
|
107
|
-
|
|
163
|
+
async recentThreads(limit) {
|
|
164
|
+
const rows = await this.queries.recentThreads(limit);
|
|
165
|
+
return this.withActorLabels(rows);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Decorate actor-scoped rows with `actorLabel`, batching the distinct `actorRef`s into ONE
|
|
169
|
+
* {@link ActorDirectory.resolveDisplay} call per response. `null` for every row when no directory
|
|
170
|
+
* is bound, or for a ref the directory didn't resolve.
|
|
171
|
+
*/
|
|
172
|
+
async withActorLabels(rows) {
|
|
173
|
+
if (rows.length === 0) {
|
|
174
|
+
return [];
|
|
175
|
+
}
|
|
176
|
+
if (this.actorDirectory === void 0) {
|
|
177
|
+
return rows.map((row) => ({
|
|
178
|
+
...row,
|
|
179
|
+
actorLabel: null
|
|
180
|
+
}));
|
|
181
|
+
}
|
|
182
|
+
const refs = [
|
|
183
|
+
...new Set(rows.map((row) => row.actorRef))
|
|
184
|
+
];
|
|
185
|
+
const resolved = await this.actorDirectory.resolveDisplay(refs);
|
|
186
|
+
return rows.map((row) => ({
|
|
187
|
+
...row,
|
|
188
|
+
actorLabel: resolved[row.actorRef] ?? null
|
|
189
|
+
}));
|
|
190
|
+
}
|
|
191
|
+
/** Current price row per model, for the pricing tab. 501s when no `AGENT_PRICING_STORE` is bound. */
|
|
192
|
+
async listPrices() {
|
|
193
|
+
if (this.pricingStore === void 0) {
|
|
194
|
+
throw new import_common2.NotImplementedException(PRICING_STORE_UNBOUND_MESSAGE);
|
|
195
|
+
}
|
|
196
|
+
return this.pricingStore.listCurrentPrices();
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Set a model's current price (`POST <api>/pricing` body). 501s when no `AGENT_PRICING_STORE` is
|
|
200
|
+
* bound (checked BEFORE body validation, so an unbound store always reports as unimplemented rather
|
|
201
|
+
* than as a validation error); otherwise the body is minimally validated via {@link parsePriceInput}.
|
|
202
|
+
*/
|
|
203
|
+
async upsertPrice(body) {
|
|
204
|
+
if (this.pricingStore === void 0) {
|
|
205
|
+
throw new import_common2.NotImplementedException(PRICING_STORE_UNBOUND_MESSAGE);
|
|
206
|
+
}
|
|
207
|
+
await this.pricingStore.upsertModelPrice(parsePriceInput(body));
|
|
108
208
|
}
|
|
109
209
|
/**
|
|
110
210
|
* Live SSE stream of `aviary:agent:*` diagnostics events. One subscription per SSE client:
|
|
@@ -138,11 +238,17 @@ var DashboardService = class {
|
|
|
138
238
|
}
|
|
139
239
|
};
|
|
140
240
|
DashboardService = _ts_decorate([
|
|
141
|
-
(0,
|
|
142
|
-
_ts_param(0, (0,
|
|
241
|
+
(0, import_common2.Injectable)(),
|
|
242
|
+
_ts_param(0, (0, import_common2.Inject)(AGENT_GOVERNANCE_QUERIES)),
|
|
243
|
+
_ts_param(1, (0, import_common2.Optional)()),
|
|
244
|
+
_ts_param(1, (0, import_common2.Inject)(AGENT_ACTOR_DIRECTORY)),
|
|
245
|
+
_ts_param(2, (0, import_common2.Optional)()),
|
|
246
|
+
_ts_param(2, (0, import_common2.Inject)(AGENT_PRICING_STORE)),
|
|
143
247
|
_ts_metadata("design:type", Function),
|
|
144
248
|
_ts_metadata("design:paramtypes", [
|
|
145
|
-
typeof AgentGovernanceQueries === "undefined" ? Object : AgentGovernanceQueries
|
|
249
|
+
typeof AgentGovernanceQueries === "undefined" ? Object : AgentGovernanceQueries,
|
|
250
|
+
typeof ActorDirectory === "undefined" ? Object : ActorDirectory,
|
|
251
|
+
typeof AgentPricingStore === "undefined" ? Object : AgentPricingStore
|
|
146
252
|
])
|
|
147
253
|
], DashboardService);
|
|
148
254
|
|
|
@@ -199,6 +305,10 @@ var AgentApiController = class {
|
|
|
199
305
|
spend(from, to) {
|
|
200
306
|
return this.dashboard.spend(resolveRange(from, to));
|
|
201
307
|
}
|
|
308
|
+
/** Top threads by cost (default 10, max 200) for a day range (defaults to the last 30 days). */
|
|
309
|
+
topThreads(from, to, limit) {
|
|
310
|
+
return this.dashboard.topThreads(resolveRange(from, to), parseLimit(limit, 10));
|
|
311
|
+
}
|
|
202
312
|
/** Most recent tool calls (default 50, max 200) for the activity feed. */
|
|
203
313
|
toolCalls(limit) {
|
|
204
314
|
return this.dashboard.recentToolCalls(parseLimit(limit, 50));
|
|
@@ -207,15 +317,30 @@ var AgentApiController = class {
|
|
|
207
317
|
threads(limit) {
|
|
208
318
|
return this.dashboard.recentThreads(parseLimit(limit, 50));
|
|
209
319
|
}
|
|
320
|
+
/**
|
|
321
|
+
* Current price row per model, for the pricing tab. 501s (via `DashboardService.listPrices`) when
|
|
322
|
+
* no `AGENT_PRICING_STORE` is bound.
|
|
323
|
+
*/
|
|
324
|
+
listPrices() {
|
|
325
|
+
return this.dashboard.listPrices();
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Set a model's current price. Body shape mirrors core's `ModelPriceInput`
|
|
329
|
+
* (`{ modelId, inputPricePer1m, outputPricePer1m, cacheWritePricePer1m?, cacheReadPricePer1m? }`).
|
|
330
|
+
* 501s when no `AGENT_PRICING_STORE` is bound; 400s on a malformed body.
|
|
331
|
+
*/
|
|
332
|
+
upsertPrice(body) {
|
|
333
|
+
return this.dashboard.upsertPrice(body);
|
|
334
|
+
}
|
|
210
335
|
/** Server-Sent Events stream of live `aviary:agent:*` events — the Live feed tails it. */
|
|
211
336
|
stream() {
|
|
212
337
|
return this.dashboard.streamEvents();
|
|
213
338
|
}
|
|
214
339
|
};
|
|
215
340
|
_ts_decorate2([
|
|
216
|
-
(0,
|
|
217
|
-
_ts_param2(0, (0,
|
|
218
|
-
_ts_param2(1, (0,
|
|
341
|
+
(0, import_common3.Get)("spend"),
|
|
342
|
+
_ts_param2(0, (0, import_common3.Query)("from")),
|
|
343
|
+
_ts_param2(1, (0, import_common3.Query)("to")),
|
|
219
344
|
_ts_metadata2("design:type", Function),
|
|
220
345
|
_ts_metadata2("design:paramtypes", [
|
|
221
346
|
String,
|
|
@@ -224,8 +349,21 @@ _ts_decorate2([
|
|
|
224
349
|
_ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
225
350
|
], AgentApiController.prototype, "spend", null);
|
|
226
351
|
_ts_decorate2([
|
|
227
|
-
(0,
|
|
228
|
-
_ts_param2(0, (0,
|
|
352
|
+
(0, import_common3.Get)("top-threads"),
|
|
353
|
+
_ts_param2(0, (0, import_common3.Query)("from")),
|
|
354
|
+
_ts_param2(1, (0, import_common3.Query)("to")),
|
|
355
|
+
_ts_param2(2, (0, import_common3.Query)("limit")),
|
|
356
|
+
_ts_metadata2("design:type", Function),
|
|
357
|
+
_ts_metadata2("design:paramtypes", [
|
|
358
|
+
String,
|
|
359
|
+
String,
|
|
360
|
+
String
|
|
361
|
+
]),
|
|
362
|
+
_ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
363
|
+
], AgentApiController.prototype, "topThreads", null);
|
|
364
|
+
_ts_decorate2([
|
|
365
|
+
(0, import_common3.Get)("tool-calls"),
|
|
366
|
+
_ts_param2(0, (0, import_common3.Query)("limit")),
|
|
229
367
|
_ts_metadata2("design:type", Function),
|
|
230
368
|
_ts_metadata2("design:paramtypes", [
|
|
231
369
|
String
|
|
@@ -233,8 +371,8 @@ _ts_decorate2([
|
|
|
233
371
|
_ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
234
372
|
], AgentApiController.prototype, "toolCalls", null);
|
|
235
373
|
_ts_decorate2([
|
|
236
|
-
(0,
|
|
237
|
-
_ts_param2(0, (0,
|
|
374
|
+
(0, import_common3.Get)("threads"),
|
|
375
|
+
_ts_param2(0, (0, import_common3.Query)("limit")),
|
|
238
376
|
_ts_metadata2("design:type", Function),
|
|
239
377
|
_ts_metadata2("design:paramtypes", [
|
|
240
378
|
String
|
|
@@ -242,28 +380,69 @@ _ts_decorate2([
|
|
|
242
380
|
_ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
243
381
|
], AgentApiController.prototype, "threads", null);
|
|
244
382
|
_ts_decorate2([
|
|
245
|
-
(0,
|
|
383
|
+
(0, import_common3.Get)("pricing"),
|
|
384
|
+
_ts_metadata2("design:type", Function),
|
|
385
|
+
_ts_metadata2("design:paramtypes", []),
|
|
386
|
+
_ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
387
|
+
], AgentApiController.prototype, "listPrices", null);
|
|
388
|
+
_ts_decorate2([
|
|
389
|
+
(0, import_common3.Post)("pricing"),
|
|
390
|
+
_ts_param2(0, (0, import_common3.Body)()),
|
|
391
|
+
_ts_metadata2("design:type", Function),
|
|
392
|
+
_ts_metadata2("design:paramtypes", [
|
|
393
|
+
Object
|
|
394
|
+
]),
|
|
395
|
+
_ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
396
|
+
], AgentApiController.prototype, "upsertPrice", null);
|
|
397
|
+
_ts_decorate2([
|
|
398
|
+
(0, import_common3.Sse)("stream"),
|
|
246
399
|
_ts_metadata2("design:type", Function),
|
|
247
400
|
_ts_metadata2("design:paramtypes", []),
|
|
248
401
|
_ts_metadata2("design:returntype", typeof Observable === "undefined" ? Object : Observable)
|
|
249
402
|
], AgentApiController.prototype, "stream", null);
|
|
250
403
|
AgentApiController = _ts_decorate2([
|
|
251
|
-
(0,
|
|
404
|
+
(0, import_common3.Controller)(),
|
|
252
405
|
_ts_metadata2("design:type", Function),
|
|
253
406
|
_ts_metadata2("design:paramtypes", [
|
|
254
407
|
typeof DashboardService === "undefined" ? Object : DashboardService
|
|
255
408
|
])
|
|
256
409
|
], AgentApiController);
|
|
257
410
|
|
|
411
|
+
// src/server/normalize-path.ts
|
|
412
|
+
function normalizeDashboardPath(path) {
|
|
413
|
+
return `/${path.replace(/^\/+|\/+$/g, "")}`;
|
|
414
|
+
}
|
|
415
|
+
__name(normalizeDashboardPath, "normalizeDashboardPath");
|
|
416
|
+
|
|
417
|
+
// src/server/agent-dashboard-mount-paths.ts
|
|
418
|
+
function unprefixed(path) {
|
|
419
|
+
return path.replace(/^\/+/, "");
|
|
420
|
+
}
|
|
421
|
+
__name(unprefixed, "unprefixed");
|
|
422
|
+
function agentDashboardMountPaths(options) {
|
|
423
|
+
const basePath = normalizeDashboardPath(options?.basePath ?? "/ai-gateway");
|
|
424
|
+
const apiBasePath = normalizeDashboardPath(options?.apiBasePath ?? `${basePath}/api`);
|
|
425
|
+
const base = unprefixed(basePath);
|
|
426
|
+
const api = unprefixed(apiBasePath);
|
|
427
|
+
return [
|
|
428
|
+
base,
|
|
429
|
+
`${base}/{*splat}`,
|
|
430
|
+
api,
|
|
431
|
+
`${api}/{*splat}`
|
|
432
|
+
];
|
|
433
|
+
}
|
|
434
|
+
__name(agentDashboardMountPaths, "agentDashboardMountPaths");
|
|
435
|
+
|
|
258
436
|
// src/server/agent-dashboard.module.ts
|
|
259
|
-
var
|
|
437
|
+
var import_reflect_metadata = require("reflect-metadata");
|
|
438
|
+
var import_common5 = require("@nestjs/common");
|
|
260
439
|
var import_core = require("@nestjs/core");
|
|
261
440
|
|
|
262
441
|
// src/server/agent-ui.controller.ts
|
|
263
442
|
var import_node_fs = require("fs");
|
|
264
443
|
var import_node_path = require("path");
|
|
265
444
|
var import_node_url = require("url");
|
|
266
|
-
var
|
|
445
|
+
var import_common4 = require("@nestjs/common");
|
|
267
446
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
268
447
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
269
448
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -311,7 +490,7 @@ var AgentUiController = class {
|
|
|
311
490
|
index() {
|
|
312
491
|
const indexPath = (0, import_node_path.join)(this.dir, "index.html");
|
|
313
492
|
if (!(0, import_node_fs.existsSync)(indexPath)) {
|
|
314
|
-
throw new
|
|
493
|
+
throw new import_common4.NotFoundException("Dashboard is not built. Run the package build.");
|
|
315
494
|
}
|
|
316
495
|
const html = (0, import_node_fs.readFileSync)(indexPath, "utf8").replaceAll(`="${BUILD_BASE}/`, `="${this.basePath}/`);
|
|
317
496
|
const inject = `<script>window.__AGENT_BASE__='${this.basePath}';window.__AGENT_API__='${this.apiBasePath}';</script>`;
|
|
@@ -319,40 +498,40 @@ var AgentUiController = class {
|
|
|
319
498
|
}
|
|
320
499
|
asset(file) {
|
|
321
500
|
const safe = (0, import_node_path.basename)(file);
|
|
322
|
-
if (safe !== file) throw new
|
|
501
|
+
if (safe !== file) throw new import_common4.NotFoundException();
|
|
323
502
|
const root = (0, import_node_path.resolve)(this.dir, "assets");
|
|
324
503
|
const assetPath = (0, import_node_path.resolve)(root, safe);
|
|
325
504
|
if (!assetPath.startsWith(root + import_node_path.sep) || !(0, import_node_fs.existsSync)(assetPath)) {
|
|
326
|
-
throw new
|
|
505
|
+
throw new import_common4.NotFoundException();
|
|
327
506
|
}
|
|
328
507
|
const type = CONTENT_TYPES[(0, import_node_path.extname)(safe)] ?? "application/octet-stream";
|
|
329
|
-
return new
|
|
508
|
+
return new import_common4.StreamableFile((0, import_node_fs.readFileSync)(assetPath), {
|
|
330
509
|
type
|
|
331
510
|
});
|
|
332
511
|
}
|
|
333
512
|
};
|
|
334
513
|
_ts_decorate3([
|
|
335
|
-
(0,
|
|
336
|
-
(0,
|
|
337
|
-
(0,
|
|
514
|
+
(0, import_common4.Get)(),
|
|
515
|
+
(0, import_common4.Header)("Content-Type", "text/html; charset=utf-8"),
|
|
516
|
+
(0, import_common4.Header)("Cache-Control", "no-store, must-revalidate"),
|
|
338
517
|
_ts_metadata3("design:type", Function),
|
|
339
518
|
_ts_metadata3("design:paramtypes", []),
|
|
340
519
|
_ts_metadata3("design:returntype", String)
|
|
341
520
|
], AgentUiController.prototype, "index", null);
|
|
342
521
|
_ts_decorate3([
|
|
343
|
-
(0,
|
|
344
|
-
(0,
|
|
345
|
-
_ts_param3(0, (0,
|
|
522
|
+
(0, import_common4.Get)("assets/:file"),
|
|
523
|
+
(0, import_common4.Header)("Cache-Control", "public, max-age=31536000, immutable"),
|
|
524
|
+
_ts_param3(0, (0, import_common4.Param)("file")),
|
|
346
525
|
_ts_metadata3("design:type", Function),
|
|
347
526
|
_ts_metadata3("design:paramtypes", [
|
|
348
527
|
String
|
|
349
528
|
]),
|
|
350
|
-
_ts_metadata3("design:returntype", typeof
|
|
529
|
+
_ts_metadata3("design:returntype", typeof import_common4.StreamableFile === "undefined" ? Object : import_common4.StreamableFile)
|
|
351
530
|
], AgentUiController.prototype, "asset", null);
|
|
352
531
|
AgentUiController = _ts_decorate3([
|
|
353
|
-
(0,
|
|
354
|
-
_ts_param3(0, (0,
|
|
355
|
-
_ts_param3(1, (0,
|
|
532
|
+
(0, import_common4.Controller)(),
|
|
533
|
+
_ts_param3(0, (0, import_common4.Inject)(DASHBOARD_BASE_PATH)),
|
|
534
|
+
_ts_param3(1, (0, import_common4.Inject)(DASHBOARD_API_PATH)),
|
|
356
535
|
_ts_metadata3("design:type", Function),
|
|
357
536
|
_ts_metadata3("design:paramtypes", [
|
|
358
537
|
String,
|
|
@@ -368,17 +547,24 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
368
547
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
369
548
|
}
|
|
370
549
|
__name(_ts_decorate4, "_ts_decorate");
|
|
550
|
+
var GUARDS_METADATA = "__guards__";
|
|
371
551
|
function normalize(path) {
|
|
372
|
-
return
|
|
552
|
+
return normalizeDashboardPath(path);
|
|
373
553
|
}
|
|
374
554
|
__name(normalize, "normalize");
|
|
555
|
+
function stampGuards(guards, ...controllers) {
|
|
556
|
+
for (const controller of controllers) {
|
|
557
|
+
Reflect.defineMetadata(GUARDS_METADATA, guards ?? [], controller);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
__name(stampGuards, "stampGuards");
|
|
375
561
|
var AgentApiModule = class {
|
|
376
562
|
static {
|
|
377
563
|
__name(this, "AgentApiModule");
|
|
378
564
|
}
|
|
379
565
|
};
|
|
380
566
|
AgentApiModule = _ts_decorate4([
|
|
381
|
-
(0,
|
|
567
|
+
(0, import_common5.Module)({
|
|
382
568
|
controllers: [
|
|
383
569
|
AgentApiController
|
|
384
570
|
],
|
|
@@ -397,9 +583,11 @@ var AgentDashboardModule = class _AgentDashboardModule {
|
|
|
397
583
|
static forRoot(options = {}) {
|
|
398
584
|
const basePath = normalize(options.basePath ?? "/ai-gateway");
|
|
399
585
|
const apiBasePath = normalize(options.apiBasePath ?? `${basePath}/api`);
|
|
586
|
+
stampGuards(options.guards, AgentApiController, AgentUiController);
|
|
400
587
|
return {
|
|
401
588
|
module: _AgentDashboardModule,
|
|
402
589
|
imports: [
|
|
590
|
+
...options.imports ?? [],
|
|
403
591
|
AgentApiModule,
|
|
404
592
|
import_core.RouterModule.register([
|
|
405
593
|
{
|
|
@@ -433,17 +621,21 @@ var AgentDashboardModule = class _AgentDashboardModule {
|
|
|
433
621
|
}
|
|
434
622
|
};
|
|
435
623
|
AgentDashboardModule = _ts_decorate4([
|
|
436
|
-
(0,
|
|
624
|
+
(0, import_common5.Module)({})
|
|
437
625
|
], AgentDashboardModule);
|
|
438
626
|
// Annotate the CommonJS export names for ESM import in node:
|
|
439
627
|
0 && (module.exports = {
|
|
628
|
+
AGENT_ACTOR_DIRECTORY,
|
|
440
629
|
AGENT_GOVERNANCE_QUERIES,
|
|
630
|
+
AGENT_PRICING_STORE,
|
|
441
631
|
AgentApiController,
|
|
442
632
|
AgentApiModule,
|
|
443
633
|
AgentDashboardModule,
|
|
444
634
|
AgentUiController,
|
|
445
635
|
DASHBOARD_API_PATH,
|
|
446
636
|
DASHBOARD_BASE_PATH,
|
|
447
|
-
DashboardService
|
|
637
|
+
DashboardService,
|
|
638
|
+
agentDashboardMountPaths,
|
|
639
|
+
parsePriceInput
|
|
448
640
|
});
|
|
449
641
|
//# sourceMappingURL=index.cjs.map
|