@adonis-agora/agent-dashboard 0.1.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/LICENSE +21 -0
  3. package/README.md +57 -0
  4. package/dist/providers/agent_dashboard_provider.d.ts +33 -0
  5. package/dist/providers/agent_dashboard_provider.d.ts.map +1 -0
  6. package/dist/providers/agent_dashboard_provider.js +101 -0
  7. package/dist/providers/agent_dashboard_provider.js.map +1 -0
  8. package/dist/spa/assets/index-BYLm0nq8.css +1 -0
  9. package/dist/spa/assets/index-DR5D-Xzw.js +9 -0
  10. package/dist/spa/index.html +13 -0
  11. package/dist/src/client/agent-client.d.ts +55 -0
  12. package/dist/src/client/agent-client.d.ts.map +1 -0
  13. package/dist/src/client/agent-client.js +141 -0
  14. package/dist/src/client/agent-client.js.map +1 -0
  15. package/dist/src/client/api-base.d.ts +23 -0
  16. package/dist/src/client/api-base.d.ts.map +1 -0
  17. package/dist/src/client/api-base.js +32 -0
  18. package/dist/src/client/api-base.js.map +1 -0
  19. package/dist/src/client/default-range.d.ts +10 -0
  20. package/dist/src/client/default-range.d.ts.map +1 -0
  21. package/dist/src/client/default-range.js +26 -0
  22. package/dist/src/client/default-range.js.map +1 -0
  23. package/dist/src/client/format.d.ts +22 -0
  24. package/dist/src/client/format.d.ts.map +1 -0
  25. package/dist/src/client/format.js +76 -0
  26. package/dist/src/client/format.js.map +1 -0
  27. package/dist/src/client/index.d.ts +9 -0
  28. package/dist/src/client/index.d.ts.map +1 -0
  29. package/dist/src/client/index.js +8 -0
  30. package/dist/src/client/index.js.map +1 -0
  31. package/dist/src/client/spend-summary.d.ts +43 -0
  32. package/dist/src/client/spend-summary.d.ts.map +1 -0
  33. package/dist/src/client/spend-summary.js +59 -0
  34. package/dist/src/client/spend-summary.js.map +1 -0
  35. package/dist/src/client/trend-path.d.ts +27 -0
  36. package/dist/src/client/trend-path.d.ts.map +1 -0
  37. package/dist/src/client/trend-path.js +25 -0
  38. package/dist/src/client/trend-path.js.map +1 -0
  39. package/dist/src/client/types.d.ts +202 -0
  40. package/dist/src/client/types.d.ts.map +1 -0
  41. package/dist/src/client/types.js +8 -0
  42. package/dist/src/client/types.js.map +1 -0
  43. package/dist/src/server/define_config.d.ts +18 -0
  44. package/dist/src/server/define_config.d.ts.map +1 -0
  45. package/dist/src/server/define_config.js +6 -0
  46. package/dist/src/server/define_config.js.map +1 -0
  47. package/dist/src/server/paths.d.ts +27 -0
  48. package/dist/src/server/paths.d.ts.map +1 -0
  49. package/dist/src/server/paths.js +78 -0
  50. package/dist/src/server/paths.js.map +1 -0
  51. package/package.json +84 -0
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Project a daily trend series into SVG geometry. The x-axis spreads points evenly across `width`;
3
+ * the y-axis is normalized against the series max (inverted, since SVG y grows downward). A single
4
+ * point renders centered; an empty series yields empty paths and `max: 1`. Pure — no DOM.
5
+ */
6
+ export function buildTrendGeometry(points, metric, width, height) {
7
+ if (points.length === 0)
8
+ return { line: '', area: '', vertices: [], max: 1 };
9
+ const max = Math.max(1, ...points.map((point) => point[metric]));
10
+ const lastIndex = Math.max(1, points.length - 1);
11
+ const vertices = points.map((point, index) => {
12
+ const value = point[metric];
13
+ const x = points.length === 1 ? width / 2 : (index / lastIndex) * width;
14
+ const y = height - (value / max) * height;
15
+ return { day: point.day, value, x, y };
16
+ });
17
+ const line = vertices
18
+ .map((vertex, index) => `${index === 0 ? 'M' : 'L'}${vertex.x.toFixed(2)},${vertex.y.toFixed(2)}`)
19
+ .join(' ');
20
+ const firstX = vertices[0]?.x ?? 0;
21
+ const lastX = vertices[vertices.length - 1]?.x ?? width;
22
+ const area = `${line} L${lastX.toFixed(2)},${height} L${firstX.toFixed(2)},${height} Z`;
23
+ return { line, area, vertices, max };
24
+ }
25
+ //# sourceMappingURL=trend-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trend-path.js","sourceRoot":"","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MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAC7F;SACA,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC;IACxD,MAAM,IAAI,GAAG,GAAG,IAAI,KAAK,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,MAAM,KAAK,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,MAAM,IAAI,CAAC;IAExF,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;AACvC,CAAC"}
@@ -0,0 +1,202 @@
1
+ /**
2
+ * Wire shapes returned by the `@adonis-agora/agent` provider's read-only governance routes
3
+ * (`/agent/governance/*`) plus the per-actor `quota/today` route. These MIRROR the target's SPI
4
+ * (`AgentGovernanceQueries` in `src/spi/governance-queries.ts`) exactly — the SPA is a pure consumer,
5
+ * so any drift here is a bug against the server contract, not a local choice.
6
+ */
7
+ /** Inclusive UTC-day range, each `YYYY-MM-DD`. Sent as `?from=&to=`. */
8
+ export interface GovernanceRange {
9
+ fromDay: string;
10
+ toDay: string;
11
+ }
12
+ /** `GET /agent/governance/spend/model` — spend + token totals for one model over the range. */
13
+ export interface ModelSpendRow {
14
+ modelId: string;
15
+ requests: number;
16
+ inputTokens: number;
17
+ outputTokens: number;
18
+ costUsd: number;
19
+ }
20
+ /** `GET /agent/governance/spend/actor` — spend + token totals for one acting ref over the range. */
21
+ export interface ActorSpendRow {
22
+ actorRef: string;
23
+ requests: number;
24
+ totalTokens: number;
25
+ costUsd: number;
26
+ }
27
+ /** `GET /agent/governance/usage/trend` — one point on the daily usage/cost trend. */
28
+ export interface UsageTrendPoint {
29
+ day: string;
30
+ totalTokens: number;
31
+ costUsd: number;
32
+ }
33
+ /** `GET /agent/governance/tool-calls/recent` — a recent tool call for the activity feed. */
34
+ export interface ToolCallActivityRow {
35
+ toolCallId: string;
36
+ toolName: string;
37
+ toolType: string;
38
+ status: string;
39
+ threadId: string;
40
+ createdAt: string;
41
+ }
42
+ /** `GET /agent/governance/threads/recent` — a recent thread with rolled-up activity. */
43
+ export interface ThreadActivityRow {
44
+ threadId: string;
45
+ title: string;
46
+ actorRef: string;
47
+ messageCount: number;
48
+ totalTokens: number;
49
+ lastActivityAt: string;
50
+ }
51
+ /** `GET /agent/quota/today` — the caller's token spend so far today. */
52
+ export interface QuotaToday {
53
+ usedTokens: number;
54
+ }
55
+ /** A run's lifecycle status as the read-model surfaces it. */
56
+ export type RunStatus = 'running' | 'completed' | 'failed' | 'cancelled';
57
+ /** Filters + cursor for `GET /agent/governance/runs`. All optional; absent = no constraint. */
58
+ export interface ListRunsFilter {
59
+ /** Exact `actor_ref`. */
60
+ actor?: string;
61
+ /** Exact `agent_name`. */
62
+ agent?: string;
63
+ status?: RunStatus;
64
+ /** Inclusive UTC-day lower bound on `started_at`, `YYYY-MM-DD`. */
65
+ from?: string;
66
+ /** Inclusive UTC-day upper bound on `started_at`, `YYYY-MM-DD`. */
67
+ to?: string;
68
+ /** Opaque cursor from a prior page's {@link ListRunsResult.nextCursor}; omit for the first page. */
69
+ cursor?: string;
70
+ /** Page size; defaults to 50, clamped to 200 by the server. */
71
+ limit?: number;
72
+ }
73
+ /** A run row for the governance list + detail. Newest-first in {@link ListRunsResult}. */
74
+ export interface RunSummaryRow {
75
+ runId: string;
76
+ threadId: string;
77
+ actorRef: string;
78
+ tenantRef: string | null;
79
+ agentName: string | null;
80
+ status: string;
81
+ /** ISO timestamp. */
82
+ startedAt: string;
83
+ /** ISO timestamp, `null` while still running. */
84
+ finishedAt: string | null;
85
+ /** `finishedAt - startedAt` in ms, `null` while still running. */
86
+ durationMs: number | null;
87
+ stepCount: number;
88
+ inputTokens: number;
89
+ outputTokens: number;
90
+ costUsd: number | null;
91
+ error: string | null;
92
+ durable: boolean;
93
+ }
94
+ /** `GET /agent/governance/runs` — one page, newest-first, with an opaque forward cursor. */
95
+ export interface ListRunsResult {
96
+ runs: RunSummaryRow[];
97
+ /** Pass back as {@link ListRunsFilter.cursor} for the next page; `null` when the last page was returned. */
98
+ nextCursor: string | null;
99
+ }
100
+ /** A message belonging to a run, for {@link RunDetail}. */
101
+ export interface RunMessageRow {
102
+ id: string;
103
+ role: string;
104
+ content: string;
105
+ createdAt: string;
106
+ }
107
+ /** A tool call belonging to a run, for {@link RunDetail} (and the approvals subset). */
108
+ export interface RunToolCallRow {
109
+ toolCallId: string;
110
+ toolName: string;
111
+ toolType: string;
112
+ status: string;
113
+ input: unknown;
114
+ output: unknown;
115
+ error: string | null;
116
+ executionMs: number | null;
117
+ createdAt: string;
118
+ }
119
+ /** A usage ledger row belonging to a run, for {@link RunDetail}. */
120
+ export interface RunUsageRow {
121
+ modelId: string;
122
+ purpose: string;
123
+ inputTokens: number;
124
+ outputTokens: number;
125
+ costUsd: number | null;
126
+ createdAt: string;
127
+ }
128
+ /**
129
+ * `GET /agent/governance/runs/:id` — the full trace of one run (run + messages + tool calls +
130
+ * pending approvals + usage), or `null` if unknown.
131
+ */
132
+ export interface RunDetail {
133
+ run: RunSummaryRow;
134
+ messages: RunMessageRow[];
135
+ toolCalls: RunToolCallRow[];
136
+ /** The subset of `toolCalls` still `pending_approval`. */
137
+ approvals: RunToolCallRow[];
138
+ usage: RunUsageRow[];
139
+ }
140
+ /** Filters for `GET /agent/governance/approvals/pending`. */
141
+ export interface PendingApprovalsFilter {
142
+ /** Restrict to a single acting ref (the owning run's `actor_ref`). */
143
+ actor?: string;
144
+ /** Cap the inbox; defaults to 50, clamped to 200 by the server. */
145
+ limit?: number;
146
+ }
147
+ /**
148
+ * `GET /agent/governance/approvals/pending` — one tool call awaiting a HITL decision, for the
149
+ * cross-thread approvals inbox (oldest first).
150
+ */
151
+ export interface PendingApprovalRow {
152
+ toolCallId: string;
153
+ toolName: string;
154
+ input: unknown;
155
+ threadId: string;
156
+ /** The run this call belongs to, for a trace deep-link; `null` for a call recorded before run tracking. */
157
+ runId: string | null;
158
+ /** Who asked — the owning run's (or thread's) actor. */
159
+ actorRef: string;
160
+ /** ISO timestamp the call was recorded (requested). */
161
+ requestedAt: string;
162
+ }
163
+ /** Inclusive UTC-day range for the run/tool aggregates; each bound `YYYY-MM-DD`, both optional. */
164
+ export interface ToolStatsRange {
165
+ /** Lower bound on the row's `created_at`/`started_at`; omit for no lower bound. */
166
+ from?: string;
167
+ /** Upper bound; omit for no upper bound. */
168
+ to?: string;
169
+ }
170
+ /**
171
+ * `GET /agent/governance/tools/stats` — per-tool call/failure/rejection/latency rollup over a range,
172
+ * highest call count first.
173
+ */
174
+ export interface PerToolStatRow {
175
+ toolName: string;
176
+ toolType: string;
177
+ calls: number;
178
+ failed: number;
179
+ rejected: number;
180
+ /** Mean `executionMs` across calls that recorded one; `null` when none did. */
181
+ avgDurationMs: number | null;
182
+ }
183
+ /**
184
+ * `GET /agent/governance/reliability` — aggregated run reliability over a range (success / failure /
185
+ * cancel rates + mean settled duration).
186
+ */
187
+ export interface RunReliability {
188
+ runs: number;
189
+ completed: number;
190
+ failed: number;
191
+ cancelled: number;
192
+ running: number;
193
+ /** completed / runs, 0 when runs = 0. */
194
+ successRate: number;
195
+ /** failed / runs, 0 when runs = 0. */
196
+ failureRate: number;
197
+ /** cancelled / runs, 0 when runs = 0. */
198
+ cancelRate: number;
199
+ /** Mean duration of settled (completed/failed/cancelled) runs in ms; `null` when none settled. */
200
+ avgDurationMs: number | null;
201
+ }
202
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wEAAwE;AACxE,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rB,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,mGAAmG;AACnG,MAAM,WAAW,cAAc;IAC7B,mFAAmF;IACnF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,+EAA+E;IAC/E,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,kGAAkG;IAClG,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Wire shapes returned by the `@adonis-agora/agent` provider's read-only governance routes
3
+ * (`/agent/governance/*`) plus the per-actor `quota/today` route. These MIRROR the target's SPI
4
+ * (`AgentGovernanceQueries` in `src/spi/governance-queries.ts`) exactly — the SPA is a pure consumer,
5
+ * so any drift here is a bug against the server contract, not a local choice.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Optional `config('agent').dashboard` block. The dashboard reuses the agent config's `path` and
3
+ * `actorResolver` (so it sits behind the SAME actor gating as the governance routes); this block only
4
+ * toggles it on/off and optionally overrides the mount path.
5
+ */
6
+ export interface AgentDashboardConfig {
7
+ /** Mount the SPA. Default `true` — set `false` to keep the routes off entirely. */
8
+ enabled?: boolean;
9
+ /** Override the mount path. Default `<agentPath>/dashboard`. */
10
+ path?: string;
11
+ }
12
+ export interface ResolvedAgentDashboardConfig {
13
+ enabled: boolean;
14
+ path?: string;
15
+ }
16
+ /** Fill defaults for the optional dashboard config block. */
17
+ export declare function resolveDashboardConfig(config: AgentDashboardConfig | undefined): ResolvedAgentDashboardConfig;
18
+ //# sourceMappingURL=define_config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define_config.d.ts","sourceRoot":"","sources":["../../../src/server/define_config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,mFAAmF;IACnF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,6DAA6D;AAC7D,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,oBAAoB,GAAG,SAAS,GACvC,4BAA4B,CAG9B"}
@@ -0,0 +1,6 @@
1
+ /** Fill defaults for the optional dashboard config block. */
2
+ export function resolveDashboardConfig(config) {
3
+ const enabled = config?.enabled ?? true;
4
+ return config?.path !== undefined ? { enabled, path: config.path } : { enabled };
5
+ }
6
+ //# sourceMappingURL=define_config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define_config.js","sourceRoot":"","sources":["../../../src/server/define_config.ts"],"names":[],"mappings":"AAiBA,6DAA6D;AAC7D,MAAM,UAAU,sBAAsB,CACpC,MAAwC;IAExC,MAAM,OAAO,GAAG,MAAM,EAAE,OAAO,IAAI,IAAI,CAAC;IACxC,OAAO,MAAM,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;AACnF,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Pure path/asset helpers for the dashboard provider — extracted so they can be unit-tested without
3
+ * booting an AdonisJS app. The provider composes these; it holds only the router wiring + I/O.
4
+ */
5
+ /** Collapse duplicate slashes and strip leading/trailing ones: `/agent//` → `agent`. */
6
+ export declare function trimSlashes(path: string): string;
7
+ /** The agent API base as an absolute path with a single leading slash: `agent` → `/agent`. */
8
+ export declare function apiBaseFor(agentPath: string): string;
9
+ /**
10
+ * The canonical dashboard mount path (no trailing slash), default `<agentPath>/dashboard`. A caller
11
+ * may override with an explicit `dashboardPath`; both are normalized to a single leading slash.
12
+ */
13
+ export declare function mountPathFor(agentPath: string, dashboardPath?: string): string;
14
+ /** MIME type for a filename by extension; `application/octet-stream` for anything unknown. */
15
+ export declare function contentTypeFor(filename: string): string;
16
+ /**
17
+ * Reject a wildcard asset request that tries to escape the SPA root via `..` or an absolute path.
18
+ * Returns the safe, normalized relative segments (never starting with `..`), or `null` to deny.
19
+ */
20
+ export declare function safeAssetSegments(wildcard: string | string[] | undefined): string[] | null;
21
+ /**
22
+ * Inject the resolved agent API base into the served `index.html` as a global the SPA reads before
23
+ * boot, so the client calls the exact base the provider mounted (no build-time coupling). Idempotent
24
+ * per response — inserted right before `</head>`.
25
+ */
26
+ export declare function injectApiBase(html: string, apiBase: string): string;
27
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../src/server/paths.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wFAAwF;AACxF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,8FAA8F;AAC9F,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAGpD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAM9E;AAsBD,8FAA8F;AAC9F,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIvD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,GAAG,MAAM,EAAE,GAAG,IAAI,CAU1F;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAInE"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Pure path/asset helpers for the dashboard provider — extracted so they can be unit-tested without
3
+ * booting an AdonisJS app. The provider composes these; it holds only the router wiring + I/O.
4
+ */
5
+ /** Collapse duplicate slashes and strip leading/trailing ones: `/agent//` → `agent`. */
6
+ export function trimSlashes(path) {
7
+ return path.replace(/\/+/g, '/').replace(/^\/+|\/+$/g, '');
8
+ }
9
+ /** The agent API base as an absolute path with a single leading slash: `agent` → `/agent`. */
10
+ export function apiBaseFor(agentPath) {
11
+ const trimmed = trimSlashes(agentPath);
12
+ return trimmed === '' ? '/' : `/${trimmed}`;
13
+ }
14
+ /**
15
+ * The canonical dashboard mount path (no trailing slash), default `<agentPath>/dashboard`. A caller
16
+ * may override with an explicit `dashboardPath`; both are normalized to a single leading slash.
17
+ */
18
+ export function mountPathFor(agentPath, dashboardPath) {
19
+ if (dashboardPath !== undefined && trimSlashes(dashboardPath) !== '') {
20
+ return `/${trimSlashes(dashboardPath)}`;
21
+ }
22
+ const trimmed = trimSlashes(agentPath);
23
+ return trimmed === '' ? '/dashboard' : `/${trimmed}/dashboard`;
24
+ }
25
+ const CONTENT_TYPES = {
26
+ html: 'text/html; charset=utf-8',
27
+ js: 'text/javascript; charset=utf-8',
28
+ mjs: 'text/javascript; charset=utf-8',
29
+ css: 'text/css; charset=utf-8',
30
+ json: 'application/json; charset=utf-8',
31
+ svg: 'image/svg+xml',
32
+ png: 'image/png',
33
+ jpg: 'image/jpeg',
34
+ jpeg: 'image/jpeg',
35
+ gif: 'image/gif',
36
+ webp: 'image/webp',
37
+ ico: 'image/x-icon',
38
+ woff: 'font/woff',
39
+ woff2: 'font/woff2',
40
+ ttf: 'font/ttf',
41
+ map: 'application/json; charset=utf-8',
42
+ txt: 'text/plain; charset=utf-8',
43
+ };
44
+ /** MIME type for a filename by extension; `application/octet-stream` for anything unknown. */
45
+ export function contentTypeFor(filename) {
46
+ const dot = filename.lastIndexOf('.');
47
+ const ext = dot === -1 ? '' : filename.slice(dot + 1).toLowerCase();
48
+ return CONTENT_TYPES[ext] ?? 'application/octet-stream';
49
+ }
50
+ /**
51
+ * Reject a wildcard asset request that tries to escape the SPA root via `..` or an absolute path.
52
+ * Returns the safe, normalized relative segments (never starting with `..`), or `null` to deny.
53
+ */
54
+ export function safeAssetSegments(wildcard) {
55
+ const parts = Array.isArray(wildcard) ? wildcard : (wildcard ?? '').split('/');
56
+ const segments = [];
57
+ for (const raw of parts) {
58
+ const part = raw.trim();
59
+ if (part === '' || part === '.')
60
+ continue;
61
+ if (part === '..' || part.includes('\0') || part.includes('\\'))
62
+ return null;
63
+ segments.push(part);
64
+ }
65
+ return segments;
66
+ }
67
+ /**
68
+ * Inject the resolved agent API base into the served `index.html` as a global the SPA reads before
69
+ * boot, so the client calls the exact base the provider mounted (no build-time coupling). Idempotent
70
+ * per response — inserted right before `</head>`.
71
+ */
72
+ export function injectApiBase(html, apiBase) {
73
+ const tag = `<script>window.__AGENT_DASHBOARD_BASE__=${JSON.stringify(apiBase)}</script>`;
74
+ if (html.includes('</head>'))
75
+ return html.replace('</head>', `${tag}</head>`);
76
+ return `${tag}${html}`;
77
+ }
78
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../src/server/paths.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wFAAwF;AACxF,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAC7D,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,UAAU,CAAC,SAAiB;IAC1C,MAAM,OAAO,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;IACvC,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC;AAC9C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,SAAiB,EAAE,aAAsB;IACpE,IAAI,aAAa,KAAK,SAAS,IAAI,WAAW,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,CAAC;QACrE,OAAO,IAAI,WAAW,CAAC,aAAa,CAAC,EAAE,CAAC;IAC1C,CAAC;IACD,MAAM,OAAO,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;IACvC,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,OAAO,YAAY,CAAC;AACjE,CAAC;AAED,MAAM,aAAa,GAA2B;IAC5C,IAAI,EAAE,0BAA0B;IAChC,EAAE,EAAE,gCAAgC;IACpC,GAAG,EAAE,gCAAgC;IACrC,GAAG,EAAE,yBAAyB;IAC9B,IAAI,EAAE,iCAAiC;IACvC,GAAG,EAAE,eAAe;IACpB,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,YAAY;IACjB,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,WAAW;IAChB,IAAI,EAAE,YAAY;IAClB,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AAE,OAAe;IACzD,MAAM,GAAG,GAAG,2CAA2C,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC;IAC1F,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;QAAE,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,GAAG,SAAS,CAAC,CAAC;IAC9E,OAAO,GAAG,GAAG,GAAG,IAAI,EAAE,CAAC;AACzB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "@adonis-agora/agent-dashboard",
3
+ "version": "0.1.0",
4
+ "description": "Read-only governance console (spend by model/actor, usage trend, recent threads & tool calls, quota) for @adonis-agora/agent — a dependency-light React SPA served by a thin AdonisJS provider. Part of the Agora ecosystem.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/DavideCarvalho/adonis-agent.git",
9
+ "directory": "packages/dashboard"
10
+ },
11
+ "author": "Davi Carvalho <davi@goflip.ai>",
12
+ "type": "module",
13
+ "main": "./dist/providers/agent_dashboard_provider.js",
14
+ "types": "./dist/providers/agent_dashboard_provider.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/providers/agent_dashboard_provider.d.ts",
18
+ "import": "./dist/providers/agent_dashboard_provider.js",
19
+ "default": "./dist/providers/agent_dashboard_provider.js"
20
+ },
21
+ "./agent_dashboard_provider": {
22
+ "types": "./dist/providers/agent_dashboard_provider.d.ts",
23
+ "import": "./dist/providers/agent_dashboard_provider.js",
24
+ "default": "./dist/providers/agent_dashboard_provider.js"
25
+ },
26
+ "./client": {
27
+ "types": "./dist/src/client/index.d.ts",
28
+ "import": "./dist/src/client/index.js",
29
+ "default": "./dist/src/client/index.js"
30
+ }
31
+ },
32
+ "files": [
33
+ "dist/",
34
+ "README.md",
35
+ "CHANGELOG.md"
36
+ ],
37
+ "sideEffects": false,
38
+ "peerDependencies": {
39
+ "@adonisjs/core": "^7.3.0",
40
+ "@adonis-agora/agent": "^0.1.0"
41
+ },
42
+ "peerDependenciesMeta": {
43
+ "@adonisjs/core": {
44
+ "optional": true
45
+ }
46
+ },
47
+ "devDependencies": {
48
+ "@adonisjs/core": "^7.3.0",
49
+ "@testing-library/react": "^16.1.0",
50
+ "@types/node": "^22.0.0",
51
+ "@types/react": "^19.0.0",
52
+ "@types/react-dom": "^19.0.0",
53
+ "@vitejs/plugin-react": "^4.3.4",
54
+ "jsdom": "^25.0.1",
55
+ "react": "^19.0.0",
56
+ "react-dom": "^19.0.0",
57
+ "typescript": "^5.4.0",
58
+ "vite": "^7.0.0",
59
+ "vitest": "^3.0.0",
60
+ "@adonis-agora/agent": "0.1.0"
61
+ },
62
+ "engines": {
63
+ "node": ">=22.0.0"
64
+ },
65
+ "keywords": [
66
+ "adonisjs",
67
+ "adonis",
68
+ "ai",
69
+ "agent",
70
+ "governance",
71
+ "dashboard",
72
+ "spa",
73
+ "react",
74
+ "spend",
75
+ "usage",
76
+ "agora"
77
+ ],
78
+ "scripts": {
79
+ "build": "vite build && tsc -p tsconfig.json",
80
+ "test": "vitest run --passWithNoTests",
81
+ "test:watch": "vitest",
82
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.app.json --noEmit"
83
+ }
84
+ }