@dudousxd/nestjs-agent-dashboard 0.3.1 → 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 +27 -0
- package/dist/client/agent-client.d.ts.map +1 -1
- package/dist/client/agent-client.js +14 -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 +216 -45
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +119 -10
- package/dist/server/index.d.ts +119 -10
- package/dist/server/index.js +178 -11
- 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-DAwWrHBV.css +0 -1
- package/dist/spa/assets/index-iAxp-O4a.js +0 -49
- package/dist/spa/assets/index-qU4prctf.js +0 -1
- package/dist/spa/assets/preview-DsgQ_Xk_.js +0 -1
|
@@ -17,6 +17,8 @@ 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;
|
|
20
22
|
}
|
|
21
23
|
/** Spend + token totals for one thread over a range. */
|
|
22
24
|
export interface ThreadSpendRow {
|
|
@@ -26,6 +28,8 @@ export interface ThreadSpendRow {
|
|
|
26
28
|
requests: number;
|
|
27
29
|
totalTokens: number;
|
|
28
30
|
costUsd: number;
|
|
31
|
+
/** Human-readable label resolved from `actorRef` (an `ActorDirectory`), when one is bound server-side. */
|
|
32
|
+
actorLabel: string | null;
|
|
29
33
|
}
|
|
30
34
|
/** One point on the daily usage/cost trend. */
|
|
31
35
|
export interface UsageTrendPoint {
|
|
@@ -50,6 +54,25 @@ export interface ThreadActivityRow {
|
|
|
50
54
|
messageCount: number;
|
|
51
55
|
totalTokens: number;
|
|
52
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;
|
|
53
76
|
}
|
|
54
77
|
/** The `GET <api>/spend` response. */
|
|
55
78
|
export interface SpendOverview {
|
|
@@ -80,6 +103,10 @@ export declare const agentClient: {
|
|
|
80
103
|
toolCalls(limit?: number): Promise<ToolCallActivityRow[]>;
|
|
81
104
|
/** Most recent threads (default 50). */
|
|
82
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>;
|
|
83
110
|
/**
|
|
84
111
|
* Live-tail `aviary:agent:*` events over SSE. Calls `onEvent` per event; returns a function that
|
|
85
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,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,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;CAWnE,CAAC"}
|
|
@@ -32,6 +32,20 @@ export const agentClient = {
|
|
|
32
32
|
threads(limit = 50) {
|
|
33
33
|
return http(`/threads?limit=${limit}`);
|
|
34
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
|
+
},
|
|
35
49
|
/**
|
|
36
50
|
* Live-tail `aviary:agent:*` events over SSE. Calls `onEvent` per event; returns a function that
|
|
37
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,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,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"}
|
|
@@ -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,KAA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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,16 +129,21 @@ 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,
|
|
@@ -99,16 +151,60 @@ var DashboardService = class {
|
|
|
99
151
|
};
|
|
100
152
|
}
|
|
101
153
|
/** Top threads by cost for a day range (default 10, highest cost first). */
|
|
102
|
-
topThreads(range, limit = 10) {
|
|
103
|
-
|
|
154
|
+
async topThreads(range, limit = 10) {
|
|
155
|
+
const rows = await this.queries.spendByThread(range, limit);
|
|
156
|
+
return this.withActorLabels(rows);
|
|
104
157
|
}
|
|
105
158
|
/** Most recent tool calls (status/type/thread) for the Runs & tools activity feed. */
|
|
106
159
|
recentToolCalls(limit) {
|
|
107
160
|
return this.queries.recentToolCalls(limit);
|
|
108
161
|
}
|
|
109
162
|
/** Most recent threads with rolled-up message/token counts. */
|
|
110
|
-
recentThreads(limit) {
|
|
111
|
-
|
|
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));
|
|
112
208
|
}
|
|
113
209
|
/**
|
|
114
210
|
* Live SSE stream of `aviary:agent:*` diagnostics events. One subscription per SSE client:
|
|
@@ -142,11 +238,17 @@ var DashboardService = class {
|
|
|
142
238
|
}
|
|
143
239
|
};
|
|
144
240
|
DashboardService = _ts_decorate([
|
|
145
|
-
(0,
|
|
146
|
-
_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)),
|
|
147
247
|
_ts_metadata("design:type", Function),
|
|
148
248
|
_ts_metadata("design:paramtypes", [
|
|
149
|
-
typeof AgentGovernanceQueries === "undefined" ? Object : AgentGovernanceQueries
|
|
249
|
+
typeof AgentGovernanceQueries === "undefined" ? Object : AgentGovernanceQueries,
|
|
250
|
+
typeof ActorDirectory === "undefined" ? Object : ActorDirectory,
|
|
251
|
+
typeof AgentPricingStore === "undefined" ? Object : AgentPricingStore
|
|
150
252
|
])
|
|
151
253
|
], DashboardService);
|
|
152
254
|
|
|
@@ -215,15 +317,30 @@ var AgentApiController = class {
|
|
|
215
317
|
threads(limit) {
|
|
216
318
|
return this.dashboard.recentThreads(parseLimit(limit, 50));
|
|
217
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
|
+
}
|
|
218
335
|
/** Server-Sent Events stream of live `aviary:agent:*` events — the Live feed tails it. */
|
|
219
336
|
stream() {
|
|
220
337
|
return this.dashboard.streamEvents();
|
|
221
338
|
}
|
|
222
339
|
};
|
|
223
340
|
_ts_decorate2([
|
|
224
|
-
(0,
|
|
225
|
-
_ts_param2(0, (0,
|
|
226
|
-
_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")),
|
|
227
344
|
_ts_metadata2("design:type", Function),
|
|
228
345
|
_ts_metadata2("design:paramtypes", [
|
|
229
346
|
String,
|
|
@@ -232,10 +349,10 @@ _ts_decorate2([
|
|
|
232
349
|
_ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
233
350
|
], AgentApiController.prototype, "spend", null);
|
|
234
351
|
_ts_decorate2([
|
|
235
|
-
(0,
|
|
236
|
-
_ts_param2(0, (0,
|
|
237
|
-
_ts_param2(1, (0,
|
|
238
|
-
_ts_param2(2, (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")),
|
|
239
356
|
_ts_metadata2("design:type", Function),
|
|
240
357
|
_ts_metadata2("design:paramtypes", [
|
|
241
358
|
String,
|
|
@@ -245,8 +362,8 @@ _ts_decorate2([
|
|
|
245
362
|
_ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
246
363
|
], AgentApiController.prototype, "topThreads", null);
|
|
247
364
|
_ts_decorate2([
|
|
248
|
-
(0,
|
|
249
|
-
_ts_param2(0, (0,
|
|
365
|
+
(0, import_common3.Get)("tool-calls"),
|
|
366
|
+
_ts_param2(0, (0, import_common3.Query)("limit")),
|
|
250
367
|
_ts_metadata2("design:type", Function),
|
|
251
368
|
_ts_metadata2("design:paramtypes", [
|
|
252
369
|
String
|
|
@@ -254,8 +371,8 @@ _ts_decorate2([
|
|
|
254
371
|
_ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
255
372
|
], AgentApiController.prototype, "toolCalls", null);
|
|
256
373
|
_ts_decorate2([
|
|
257
|
-
(0,
|
|
258
|
-
_ts_param2(0, (0,
|
|
374
|
+
(0, import_common3.Get)("threads"),
|
|
375
|
+
_ts_param2(0, (0, import_common3.Query)("limit")),
|
|
259
376
|
_ts_metadata2("design:type", Function),
|
|
260
377
|
_ts_metadata2("design:paramtypes", [
|
|
261
378
|
String
|
|
@@ -263,28 +380,69 @@ _ts_decorate2([
|
|
|
263
380
|
_ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
264
381
|
], AgentApiController.prototype, "threads", null);
|
|
265
382
|
_ts_decorate2([
|
|
266
|
-
(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"),
|
|
267
399
|
_ts_metadata2("design:type", Function),
|
|
268
400
|
_ts_metadata2("design:paramtypes", []),
|
|
269
401
|
_ts_metadata2("design:returntype", typeof Observable === "undefined" ? Object : Observable)
|
|
270
402
|
], AgentApiController.prototype, "stream", null);
|
|
271
403
|
AgentApiController = _ts_decorate2([
|
|
272
|
-
(0,
|
|
404
|
+
(0, import_common3.Controller)(),
|
|
273
405
|
_ts_metadata2("design:type", Function),
|
|
274
406
|
_ts_metadata2("design:paramtypes", [
|
|
275
407
|
typeof DashboardService === "undefined" ? Object : DashboardService
|
|
276
408
|
])
|
|
277
409
|
], AgentApiController);
|
|
278
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
|
+
|
|
279
436
|
// src/server/agent-dashboard.module.ts
|
|
280
|
-
var
|
|
437
|
+
var import_reflect_metadata = require("reflect-metadata");
|
|
438
|
+
var import_common5 = require("@nestjs/common");
|
|
281
439
|
var import_core = require("@nestjs/core");
|
|
282
440
|
|
|
283
441
|
// src/server/agent-ui.controller.ts
|
|
284
442
|
var import_node_fs = require("fs");
|
|
285
443
|
var import_node_path = require("path");
|
|
286
444
|
var import_node_url = require("url");
|
|
287
|
-
var
|
|
445
|
+
var import_common4 = require("@nestjs/common");
|
|
288
446
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
289
447
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
290
448
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -332,7 +490,7 @@ var AgentUiController = class {
|
|
|
332
490
|
index() {
|
|
333
491
|
const indexPath = (0, import_node_path.join)(this.dir, "index.html");
|
|
334
492
|
if (!(0, import_node_fs.existsSync)(indexPath)) {
|
|
335
|
-
throw new
|
|
493
|
+
throw new import_common4.NotFoundException("Dashboard is not built. Run the package build.");
|
|
336
494
|
}
|
|
337
495
|
const html = (0, import_node_fs.readFileSync)(indexPath, "utf8").replaceAll(`="${BUILD_BASE}/`, `="${this.basePath}/`);
|
|
338
496
|
const inject = `<script>window.__AGENT_BASE__='${this.basePath}';window.__AGENT_API__='${this.apiBasePath}';</script>`;
|
|
@@ -340,40 +498,40 @@ var AgentUiController = class {
|
|
|
340
498
|
}
|
|
341
499
|
asset(file) {
|
|
342
500
|
const safe = (0, import_node_path.basename)(file);
|
|
343
|
-
if (safe !== file) throw new
|
|
501
|
+
if (safe !== file) throw new import_common4.NotFoundException();
|
|
344
502
|
const root = (0, import_node_path.resolve)(this.dir, "assets");
|
|
345
503
|
const assetPath = (0, import_node_path.resolve)(root, safe);
|
|
346
504
|
if (!assetPath.startsWith(root + import_node_path.sep) || !(0, import_node_fs.existsSync)(assetPath)) {
|
|
347
|
-
throw new
|
|
505
|
+
throw new import_common4.NotFoundException();
|
|
348
506
|
}
|
|
349
507
|
const type = CONTENT_TYPES[(0, import_node_path.extname)(safe)] ?? "application/octet-stream";
|
|
350
|
-
return new
|
|
508
|
+
return new import_common4.StreamableFile((0, import_node_fs.readFileSync)(assetPath), {
|
|
351
509
|
type
|
|
352
510
|
});
|
|
353
511
|
}
|
|
354
512
|
};
|
|
355
513
|
_ts_decorate3([
|
|
356
|
-
(0,
|
|
357
|
-
(0,
|
|
358
|
-
(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"),
|
|
359
517
|
_ts_metadata3("design:type", Function),
|
|
360
518
|
_ts_metadata3("design:paramtypes", []),
|
|
361
519
|
_ts_metadata3("design:returntype", String)
|
|
362
520
|
], AgentUiController.prototype, "index", null);
|
|
363
521
|
_ts_decorate3([
|
|
364
|
-
(0,
|
|
365
|
-
(0,
|
|
366
|
-
_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")),
|
|
367
525
|
_ts_metadata3("design:type", Function),
|
|
368
526
|
_ts_metadata3("design:paramtypes", [
|
|
369
527
|
String
|
|
370
528
|
]),
|
|
371
|
-
_ts_metadata3("design:returntype", typeof
|
|
529
|
+
_ts_metadata3("design:returntype", typeof import_common4.StreamableFile === "undefined" ? Object : import_common4.StreamableFile)
|
|
372
530
|
], AgentUiController.prototype, "asset", null);
|
|
373
531
|
AgentUiController = _ts_decorate3([
|
|
374
|
-
(0,
|
|
375
|
-
_ts_param3(0, (0,
|
|
376
|
-
_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)),
|
|
377
535
|
_ts_metadata3("design:type", Function),
|
|
378
536
|
_ts_metadata3("design:paramtypes", [
|
|
379
537
|
String,
|
|
@@ -389,17 +547,24 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
389
547
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
390
548
|
}
|
|
391
549
|
__name(_ts_decorate4, "_ts_decorate");
|
|
550
|
+
var GUARDS_METADATA = "__guards__";
|
|
392
551
|
function normalize(path) {
|
|
393
|
-
return
|
|
552
|
+
return normalizeDashboardPath(path);
|
|
394
553
|
}
|
|
395
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");
|
|
396
561
|
var AgentApiModule = class {
|
|
397
562
|
static {
|
|
398
563
|
__name(this, "AgentApiModule");
|
|
399
564
|
}
|
|
400
565
|
};
|
|
401
566
|
AgentApiModule = _ts_decorate4([
|
|
402
|
-
(0,
|
|
567
|
+
(0, import_common5.Module)({
|
|
403
568
|
controllers: [
|
|
404
569
|
AgentApiController
|
|
405
570
|
],
|
|
@@ -418,9 +583,11 @@ var AgentDashboardModule = class _AgentDashboardModule {
|
|
|
418
583
|
static forRoot(options = {}) {
|
|
419
584
|
const basePath = normalize(options.basePath ?? "/ai-gateway");
|
|
420
585
|
const apiBasePath = normalize(options.apiBasePath ?? `${basePath}/api`);
|
|
586
|
+
stampGuards(options.guards, AgentApiController, AgentUiController);
|
|
421
587
|
return {
|
|
422
588
|
module: _AgentDashboardModule,
|
|
423
589
|
imports: [
|
|
590
|
+
...options.imports ?? [],
|
|
424
591
|
AgentApiModule,
|
|
425
592
|
import_core.RouterModule.register([
|
|
426
593
|
{
|
|
@@ -454,17 +621,21 @@ var AgentDashboardModule = class _AgentDashboardModule {
|
|
|
454
621
|
}
|
|
455
622
|
};
|
|
456
623
|
AgentDashboardModule = _ts_decorate4([
|
|
457
|
-
(0,
|
|
624
|
+
(0, import_common5.Module)({})
|
|
458
625
|
], AgentDashboardModule);
|
|
459
626
|
// Annotate the CommonJS export names for ESM import in node:
|
|
460
627
|
0 && (module.exports = {
|
|
628
|
+
AGENT_ACTOR_DIRECTORY,
|
|
461
629
|
AGENT_GOVERNANCE_QUERIES,
|
|
630
|
+
AGENT_PRICING_STORE,
|
|
462
631
|
AgentApiController,
|
|
463
632
|
AgentApiModule,
|
|
464
633
|
AgentDashboardModule,
|
|
465
634
|
AgentUiController,
|
|
466
635
|
DASHBOARD_API_PATH,
|
|
467
636
|
DASHBOARD_BASE_PATH,
|
|
468
|
-
DashboardService
|
|
637
|
+
DashboardService,
|
|
638
|
+
agentDashboardMountPaths,
|
|
639
|
+
parsePriceInput
|
|
469
640
|
});
|
|
470
641
|
//# sourceMappingURL=index.cjs.map
|