agentcheck-sdk 0.2.0 → 0.3.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/dashboard.d.ts +36 -0
- package/dist/dashboard.js +101 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AgentCheckClient } from "./client";
|
|
2
|
+
export interface DashboardConfig {
|
|
3
|
+
/** Title shown at the top */
|
|
4
|
+
title?: string;
|
|
5
|
+
/** Auto-refresh interval in seconds (0 = off) */
|
|
6
|
+
refreshInterval?: number;
|
|
7
|
+
/** Max records to show */
|
|
8
|
+
limit?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* DelegationDashboard - Embeddable HTML widget for agent delegation status.
|
|
12
|
+
*
|
|
13
|
+
* Generates a self-contained HTML snippet that shows:
|
|
14
|
+
* - Active delegations with status badges
|
|
15
|
+
* - Recent execution logs
|
|
16
|
+
* - Quick actions (revoke)
|
|
17
|
+
*
|
|
18
|
+
* Usage (Express):
|
|
19
|
+
* app.get('/admin/delegations', async (req, res) => {
|
|
20
|
+
* const html = await dashboard.render();
|
|
21
|
+
* res.send(html);
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* Usage (embed in existing page):
|
|
25
|
+
* const html = await dashboard.renderWidget();
|
|
26
|
+
* // Insert into your page's <div id="delegation-widget">
|
|
27
|
+
*/
|
|
28
|
+
export declare class DelegationDashboard {
|
|
29
|
+
private client;
|
|
30
|
+
private config;
|
|
31
|
+
constructor(client: AgentCheckClient, config?: DashboardConfig);
|
|
32
|
+
/** Render full HTML page with dashboard. */
|
|
33
|
+
render(): Promise<string>;
|
|
34
|
+
/** Render widget HTML (for embedding in existing pages). */
|
|
35
|
+
renderWidget(): Promise<string>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DelegationDashboard = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* DelegationDashboard - Embeddable HTML widget for agent delegation status.
|
|
6
|
+
*
|
|
7
|
+
* Generates a self-contained HTML snippet that shows:
|
|
8
|
+
* - Active delegations with status badges
|
|
9
|
+
* - Recent execution logs
|
|
10
|
+
* - Quick actions (revoke)
|
|
11
|
+
*
|
|
12
|
+
* Usage (Express):
|
|
13
|
+
* app.get('/admin/delegations', async (req, res) => {
|
|
14
|
+
* const html = await dashboard.render();
|
|
15
|
+
* res.send(html);
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* Usage (embed in existing page):
|
|
19
|
+
* const html = await dashboard.renderWidget();
|
|
20
|
+
* // Insert into your page's <div id="delegation-widget">
|
|
21
|
+
*/
|
|
22
|
+
class DelegationDashboard {
|
|
23
|
+
constructor(client, config = {}) {
|
|
24
|
+
this.client = client;
|
|
25
|
+
this.config = {
|
|
26
|
+
title: config.title ?? "Agent Delegations",
|
|
27
|
+
refreshInterval: config.refreshInterval ?? 30,
|
|
28
|
+
limit: config.limit ?? 20,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** Render full HTML page with dashboard. */
|
|
32
|
+
async render() {
|
|
33
|
+
const widget = await this.renderWidget();
|
|
34
|
+
const refresh = this.config.refreshInterval > 0
|
|
35
|
+
? `<meta http-equiv="refresh" content="${this.config.refreshInterval}">`
|
|
36
|
+
: "";
|
|
37
|
+
return `<!DOCTYPE html>
|
|
38
|
+
<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
39
|
+
${refresh}
|
|
40
|
+
<title>${this.config.title}</title>
|
|
41
|
+
<style>${DASHBOARD_CSS}</style>
|
|
42
|
+
</head><body>${widget}</body></html>`;
|
|
43
|
+
}
|
|
44
|
+
/** Render widget HTML (for embedding in existing pages). */
|
|
45
|
+
async renderWidget() {
|
|
46
|
+
const list = await this.client.list({ limit: this.config.limit });
|
|
47
|
+
const records = list.records;
|
|
48
|
+
const statusCounts = {};
|
|
49
|
+
for (const r of records) {
|
|
50
|
+
statusCounts[r.status] = (statusCounts[r.status] || 0) + 1;
|
|
51
|
+
}
|
|
52
|
+
const summaryCards = Object.entries(statusCounts)
|
|
53
|
+
.map(([status, count]) => `<div class="ac-card"><div class="ac-card-num">${count}</div><div class="ac-card-label">${status}</div></div>`).join("\n");
|
|
54
|
+
const rows = records
|
|
55
|
+
.map((r) => {
|
|
56
|
+
const statusClass = r.status === "approved" ? "ac-approved"
|
|
57
|
+
: r.status === "revoked" ? "ac-revoked"
|
|
58
|
+
: r.status === "expired" ? "ac-expired"
|
|
59
|
+
: "ac-pending";
|
|
60
|
+
return `<tr>
|
|
61
|
+
<td><span class="ac-badge ${statusClass}">${r.status}</span></td>
|
|
62
|
+
<td>${r.agent}</td>
|
|
63
|
+
<td title="${r.scope}">${r.scope.length > 60 ? r.scope.slice(0, 60) + "..." : r.scope}</td>
|
|
64
|
+
<td>${r.authorized_by}</td>
|
|
65
|
+
<td>${new Date(r.created_at).toLocaleDateString()}</td>
|
|
66
|
+
<td><a href="${r.verify_url}" target="_blank">Verify</a></td>
|
|
67
|
+
</tr>`;
|
|
68
|
+
}).join("\n");
|
|
69
|
+
return `<div class="ac-dashboard">
|
|
70
|
+
<h2 class="ac-title">${this.config.title}</h2>
|
|
71
|
+
<div class="ac-cards">${summaryCards}</div>
|
|
72
|
+
<table class="ac-table">
|
|
73
|
+
<thead><tr>
|
|
74
|
+
<th>Status</th><th>Agent</th><th>Scope</th><th>Authorized by</th><th>Created</th><th>Verify</th>
|
|
75
|
+
</tr></thead>
|
|
76
|
+
<tbody>${rows}</tbody>
|
|
77
|
+
</table>
|
|
78
|
+
<div class="ac-footer">${records.length} delegation(s) | ${this.config.refreshInterval > 0 ? `Auto-refresh: ${this.config.refreshInterval}s` : "Manual refresh"}</div>
|
|
79
|
+
</div>
|
|
80
|
+
<style>${DASHBOARD_CSS}</style>`;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.DelegationDashboard = DelegationDashboard;
|
|
84
|
+
const DASHBOARD_CSS = `
|
|
85
|
+
.ac-dashboard{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;max-width:960px;margin:0 auto;padding:24px;}
|
|
86
|
+
.ac-title{font-size:20px;font-weight:700;margin:0 0 20px;color:#1e293b;}
|
|
87
|
+
.ac-cards{display:flex;gap:12px;margin-bottom:20px;flex-wrap:wrap;}
|
|
88
|
+
.ac-card{background:#fff;border:1px solid #e5e7eb;border-radius:10px;padding:16px 20px;min-width:100px;text-align:center;}
|
|
89
|
+
.ac-card-num{font-size:28px;font-weight:800;color:#1e293b;}
|
|
90
|
+
.ac-card-label{font-size:12px;color:#64748b;text-transform:uppercase;letter-spacing:.5px;margin-top:4px;}
|
|
91
|
+
.ac-table{width:100%;border-collapse:collapse;background:#fff;border-radius:10px;overflow:hidden;border:1px solid #e5e7eb;}
|
|
92
|
+
.ac-table th{padding:10px 14px;text-align:left;font-size:12px;font-weight:700;color:#475569;background:#f8fafc;border-bottom:2px solid #e5e7eb;}
|
|
93
|
+
.ac-table td{padding:10px 14px;font-size:13px;color:#555;border-bottom:1px solid #f0f0f0;}
|
|
94
|
+
.ac-table a{color:#2563eb;font-size:12px;}
|
|
95
|
+
.ac-badge{display:inline-block;padding:2px 10px;border-radius:9999px;font-size:11px;font-weight:700;color:#fff;}
|
|
96
|
+
.ac-approved{background:#16a34a;}
|
|
97
|
+
.ac-pending{background:#ca8a04;}
|
|
98
|
+
.ac-revoked{background:#dc2626;}
|
|
99
|
+
.ac-expired{background:#6b7280;}
|
|
100
|
+
.ac-footer{text-align:center;color:#94a3b8;font-size:12px;margin-top:16px;}
|
|
101
|
+
`;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { WebhookHandler } from "./webhook";
|
|
|
3
3
|
export { DelegationProvider } from "./provider";
|
|
4
4
|
export { delegationGuard } from "./guard";
|
|
5
5
|
export { AgentToolChecker } from "./langchain";
|
|
6
|
+
export { DelegationDashboard } from "./dashboard";
|
|
6
7
|
export type { WebhookEvent } from "./webhook";
|
|
7
8
|
export type { ScopeVerifier, DelegationProviderConfig } from "./provider";
|
|
8
9
|
export type { GuardConfig } from "./guard";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RateLimitError = exports.ValidationError = exports.NotFoundError = exports.AuthenticationError = exports.AgentCheckError = exports.AgentToolChecker = exports.delegationGuard = exports.DelegationProvider = exports.WebhookHandler = exports.AgentCheckClient = void 0;
|
|
3
|
+
exports.RateLimitError = exports.ValidationError = exports.NotFoundError = exports.AuthenticationError = exports.AgentCheckError = exports.DelegationDashboard = exports.AgentToolChecker = exports.delegationGuard = exports.DelegationProvider = exports.WebhookHandler = exports.AgentCheckClient = void 0;
|
|
4
4
|
// Individual commands (basic menu)
|
|
5
5
|
var client_1 = require("./client");
|
|
6
6
|
Object.defineProperty(exports, "AgentCheckClient", { enumerable: true, get: function () { return client_1.AgentCheckClient; } });
|
|
@@ -13,6 +13,8 @@ var guard_1 = require("./guard");
|
|
|
13
13
|
Object.defineProperty(exports, "delegationGuard", { enumerable: true, get: function () { return guard_1.delegationGuard; } });
|
|
14
14
|
var langchain_1 = require("./langchain");
|
|
15
15
|
Object.defineProperty(exports, "AgentToolChecker", { enumerable: true, get: function () { return langchain_1.AgentToolChecker; } });
|
|
16
|
+
var dashboard_1 = require("./dashboard");
|
|
17
|
+
Object.defineProperty(exports, "DelegationDashboard", { enumerable: true, get: function () { return dashboard_1.DelegationDashboard; } });
|
|
16
18
|
var errors_1 = require("./errors");
|
|
17
19
|
Object.defineProperty(exports, "AgentCheckError", { enumerable: true, get: function () { return errors_1.AgentCheckError; } });
|
|
18
20
|
Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function () { return errors_1.AuthenticationError; } });
|