@aumos/agent-gov 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.
- package/dist/client.d.ts +84 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +120 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +240 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +14 -0
- package/dist/types.js.map +1 -0
- package/package.json +38 -0
- package/src/client.ts +252 -0
- package/src/index.ts +33 -0
- package/src/types.ts +280 -0
- package/tsconfig.json +25 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for the agent-gov governance API.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Fetch API (available natively in Node 18+, browsers, and Deno).
|
|
5
|
+
* No external dependencies required.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createAgentGovClient } from "@aumos/agent-gov";
|
|
10
|
+
*
|
|
11
|
+
* const client = createAgentGovClient({ baseUrl: "http://localhost:8070" });
|
|
12
|
+
*
|
|
13
|
+
* const result = await client.checkCompliance({
|
|
14
|
+
* agent_id: "my-agent",
|
|
15
|
+
* policy_name: "default",
|
|
16
|
+
* action: { type: "search", query: "user emails" },
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* if (result.ok && result.data.passed) {
|
|
20
|
+
* console.log("Action approved by governance policy");
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
import type { ApiResult, AuditEntry, AuditLogQuery, CheckComplianceRequest, ComplianceCostReport, ComplianceReport, GenerateReportRequest, ValidatePolicyRequest, ValidatePolicyResponse } from "./types.js";
|
|
25
|
+
/** Configuration options for the AgentGovClient. */
|
|
26
|
+
export interface AgentGovClientConfig {
|
|
27
|
+
/** Base URL of the agent-gov server (e.g. "http://localhost:8070"). */
|
|
28
|
+
readonly baseUrl: string;
|
|
29
|
+
/** Optional request timeout in milliseconds (default: 30000). */
|
|
30
|
+
readonly timeoutMs?: number;
|
|
31
|
+
/** Optional extra HTTP headers sent with every request. */
|
|
32
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
33
|
+
}
|
|
34
|
+
/** Typed HTTP client for the agent-gov governance server. */
|
|
35
|
+
export interface AgentGovClient {
|
|
36
|
+
/**
|
|
37
|
+
* Evaluate an agent action against a named policy.
|
|
38
|
+
*
|
|
39
|
+
* Sends the action payload to the governance engine and returns a full
|
|
40
|
+
* ComplianceReport with per-rule verdicts, pass/fail status, and severity.
|
|
41
|
+
*
|
|
42
|
+
* @param request - The agent ID, action payload, and target policy name.
|
|
43
|
+
* @returns A ComplianceReport with all rule verdicts and an overall verdict.
|
|
44
|
+
*/
|
|
45
|
+
checkCompliance(request: CheckComplianceRequest): Promise<ApiResult<ComplianceReport>>;
|
|
46
|
+
/**
|
|
47
|
+
* Retrieve the audit log with optional filtering.
|
|
48
|
+
*
|
|
49
|
+
* Returns entries in reverse chronological order (most recent first).
|
|
50
|
+
*
|
|
51
|
+
* @param query - Optional filter parameters (agentId, policyName, verdict, limit).
|
|
52
|
+
* @returns Array of AuditEntry records matching the filter criteria.
|
|
53
|
+
*/
|
|
54
|
+
getAuditLog(query?: AuditLogQuery): Promise<ApiResult<readonly AuditEntry[]>>;
|
|
55
|
+
/**
|
|
56
|
+
* Generate a cost-of-compliance report for a regulatory framework.
|
|
57
|
+
*
|
|
58
|
+
* Computes per-requirement cost estimates under the given automation
|
|
59
|
+
* scenario and returns aggregated totals with savings percentages.
|
|
60
|
+
*
|
|
61
|
+
* @param request - Framework name, automation coverage overrides, and hourly rate.
|
|
62
|
+
* @returns A ComplianceCostReport with full cost breakdown.
|
|
63
|
+
*/
|
|
64
|
+
generateReport(request: GenerateReportRequest): Promise<ApiResult<ComplianceCostReport>>;
|
|
65
|
+
/**
|
|
66
|
+
* Validate a policy configuration without persisting it.
|
|
67
|
+
*
|
|
68
|
+
* Checks rule type references, parameter schemas, and structural
|
|
69
|
+
* correctness. Returns a list of validation errors when the policy
|
|
70
|
+
* is invalid.
|
|
71
|
+
*
|
|
72
|
+
* @param request - The full policy configuration to validate.
|
|
73
|
+
* @returns Validation result with error messages and enabled rule count.
|
|
74
|
+
*/
|
|
75
|
+
validatePolicy(request: ValidatePolicyRequest): Promise<ApiResult<ValidatePolicyResponse>>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Create a typed HTTP client for the agent-gov governance server.
|
|
79
|
+
*
|
|
80
|
+
* @param config - Client configuration including base URL.
|
|
81
|
+
* @returns An AgentGovClient instance.
|
|
82
|
+
*/
|
|
83
|
+
export declare function createAgentGovClient(config: AgentGovClientConfig): AgentGovClient;
|
|
84
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAEV,SAAS,EACT,UAAU,EACV,aAAa,EACb,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAMpB,oDAAoD;AACpD,MAAM,WAAW,oBAAoB;IACnC,uEAAuE;IACvE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,iEAAiE;IACjE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACrD;AA0DD,6DAA6D;AAC7D,MAAM,WAAW,cAAc;IAC7B;;;;;;;;OAQG;IACH,eAAe,CACb,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAExC;;;;;;;OAOG;IACH,WAAW,CACT,KAAK,CAAC,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,CAAC,SAAS,UAAU,EAAE,CAAC,CAAC,CAAC;IAE7C;;;;;;;;OAQG;IACH,cAAc,CACZ,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAE5C;;;;;;;;;OASG;IACH,cAAc,CACZ,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAC,CAAC;CAC/C;AAMD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,oBAAoB,GAC3B,cAAc,CA4EhB"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for the agent-gov governance API.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Fetch API (available natively in Node 18+, browsers, and Deno).
|
|
5
|
+
* No external dependencies required.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createAgentGovClient } from "@aumos/agent-gov";
|
|
10
|
+
*
|
|
11
|
+
* const client = createAgentGovClient({ baseUrl: "http://localhost:8070" });
|
|
12
|
+
*
|
|
13
|
+
* const result = await client.checkCompliance({
|
|
14
|
+
* agent_id: "my-agent",
|
|
15
|
+
* policy_name: "default",
|
|
16
|
+
* action: { type: "search", query: "user emails" },
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* if (result.ok && result.data.passed) {
|
|
20
|
+
* console.log("Action approved by governance policy");
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
// Internal helpers
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
async function fetchJson(url, init, timeoutMs) {
|
|
28
|
+
const controller = new AbortController();
|
|
29
|
+
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
30
|
+
try {
|
|
31
|
+
const response = await fetch(url, { ...init, signal: controller.signal });
|
|
32
|
+
clearTimeout(timeoutId);
|
|
33
|
+
const body = await response.json();
|
|
34
|
+
if (!response.ok) {
|
|
35
|
+
const errorBody = body;
|
|
36
|
+
return {
|
|
37
|
+
ok: false,
|
|
38
|
+
error: {
|
|
39
|
+
error: errorBody.error ?? "Unknown error",
|
|
40
|
+
detail: errorBody.detail ?? "",
|
|
41
|
+
},
|
|
42
|
+
status: response.status,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return { ok: true, data: body };
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
clearTimeout(timeoutId);
|
|
49
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
50
|
+
return {
|
|
51
|
+
ok: false,
|
|
52
|
+
error: { error: "Network error", detail: message },
|
|
53
|
+
status: 0,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function buildHeaders(extraHeaders) {
|
|
58
|
+
return {
|
|
59
|
+
"Content-Type": "application/json",
|
|
60
|
+
Accept: "application/json",
|
|
61
|
+
...extraHeaders,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
// Client factory
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
/**
|
|
68
|
+
* Create a typed HTTP client for the agent-gov governance server.
|
|
69
|
+
*
|
|
70
|
+
* @param config - Client configuration including base URL.
|
|
71
|
+
* @returns An AgentGovClient instance.
|
|
72
|
+
*/
|
|
73
|
+
export function createAgentGovClient(config) {
|
|
74
|
+
const { baseUrl, timeoutMs = 30_000, headers: extraHeaders } = config;
|
|
75
|
+
const baseHeaders = buildHeaders(extraHeaders);
|
|
76
|
+
return {
|
|
77
|
+
async checkCompliance(request) {
|
|
78
|
+
return fetchJson(`${baseUrl}/compliance/check`, {
|
|
79
|
+
method: "POST",
|
|
80
|
+
headers: baseHeaders,
|
|
81
|
+
body: JSON.stringify(request),
|
|
82
|
+
}, timeoutMs);
|
|
83
|
+
},
|
|
84
|
+
async getAuditLog(query = {}) {
|
|
85
|
+
const params = new URLSearchParams();
|
|
86
|
+
if (query.agentId !== undefined) {
|
|
87
|
+
params.set("agent_id", query.agentId);
|
|
88
|
+
}
|
|
89
|
+
if (query.policyName !== undefined) {
|
|
90
|
+
params.set("policy_name", query.policyName);
|
|
91
|
+
}
|
|
92
|
+
if (query.verdict !== undefined) {
|
|
93
|
+
params.set("verdict", query.verdict);
|
|
94
|
+
}
|
|
95
|
+
if (query.limit !== undefined) {
|
|
96
|
+
params.set("limit", String(query.limit));
|
|
97
|
+
}
|
|
98
|
+
const queryString = params.toString();
|
|
99
|
+
const url = queryString
|
|
100
|
+
? `${baseUrl}/audit/log?${queryString}`
|
|
101
|
+
: `${baseUrl}/audit/log`;
|
|
102
|
+
return fetchJson(url, { method: "GET", headers: baseHeaders }, timeoutMs);
|
|
103
|
+
},
|
|
104
|
+
async generateReport(request) {
|
|
105
|
+
return fetchJson(`${baseUrl}/compliance/report`, {
|
|
106
|
+
method: "POST",
|
|
107
|
+
headers: baseHeaders,
|
|
108
|
+
body: JSON.stringify(request),
|
|
109
|
+
}, timeoutMs);
|
|
110
|
+
},
|
|
111
|
+
async validatePolicy(request) {
|
|
112
|
+
return fetchJson(`${baseUrl}/policies/validate`, {
|
|
113
|
+
method: "POST",
|
|
114
|
+
headers: baseHeaders,
|
|
115
|
+
body: JSON.stringify(request),
|
|
116
|
+
}, timeoutMs);
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"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,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;gBAC9B,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;YAC3C,CAAC;YAED,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;YACtC,MAAM,GAAG,GAAG,WAAW;gBACrB,CAAC,CAAC,GAAG,OAAO,cAAc,WAAW,EAAE;gBACvC,CAAC,CAAC,GAAG,OAAO,YAAY,CAAC;YAE3B,OAAO,SAAS,CACd,GAAG,EACH,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,EACvC,SAAS,CACV,CAAC;QACJ,CAAC;QAED,KAAK,CAAC,cAAc,CAClB,OAA8B;YAE9B,OAAO,SAAS,CACd,GAAG,OAAO,oBAAoB,EAC9B;gBACE,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,WAAW;gBACpB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;aAC9B,EACD,SAAS,CACV,CAAC;QACJ,CAAC;QAED,KAAK,CAAC,cAAc,CAClB,OAA8B;YAE9B,OAAO,SAAS,CACd,GAAG,OAAO,oBAAoB,EAC9B;gBACE,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,WAAW;gBACpB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;aAC9B,EACD,SAAS,CACV,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @aumos/agent-gov
|
|
3
|
+
*
|
|
4
|
+
* TypeScript client for the AumOS agent-gov governance framework.
|
|
5
|
+
* Provides policy evaluation, compliance checking, audit logging,
|
|
6
|
+
* and cost-of-compliance reporting.
|
|
7
|
+
*/
|
|
8
|
+
export type { AgentGovClient, AgentGovClientConfig } from "./client.js";
|
|
9
|
+
export { createAgentGovClient } from "./client.js";
|
|
10
|
+
export type { Severity, ComplianceFramework, AutomationLevel, AuditVerdict, PolicyRule, GovernanceConfig, RuleVerdict, ComplianceReport, AuditEntry, RequirementCostDetail, ComplianceCostReport, CheckComplianceRequest, ValidatePolicyRequest, ValidatePolicyResponse, GenerateReportRequest, AuditLogQuery, ApiError, ApiResult, } from "./types.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGnD,YAAY,EACV,QAAQ,EACR,mBAAmB,EACnB,eAAe,EACf,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,aAAa,EACb,QAAQ,EACR,SAAS,GACV,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @aumos/agent-gov
|
|
3
|
+
*
|
|
4
|
+
* TypeScript client for the AumOS agent-gov governance framework.
|
|
5
|
+
* Provides policy evaluation, compliance checking, audit logging,
|
|
6
|
+
* and cost-of-compliance reporting.
|
|
7
|
+
*/
|
|
8
|
+
export { createAgentGovClient } from "./client.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript interfaces for the agent-gov governance framework.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the Pydantic/dataclass models defined in:
|
|
5
|
+
* agent_gov.policy.schema — PolicyRule, PolicyConfig, RuleConfig
|
|
6
|
+
* agent_gov.policy.rule — RuleVerdict
|
|
7
|
+
* agent_gov.policy.result — EvaluationReport
|
|
8
|
+
* agent_gov.audit.entry — AuditEntry
|
|
9
|
+
* agent_gov.compliance_cost.calculator — CostReport
|
|
10
|
+
*
|
|
11
|
+
* All interfaces use readonly fields to match Python frozen models.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Severity levels for policy rule violations.
|
|
15
|
+
* Maps to the Python Severity enum in agent_gov.policy.schema.
|
|
16
|
+
*/
|
|
17
|
+
export type Severity = "low" | "medium" | "high" | "critical";
|
|
18
|
+
/**
|
|
19
|
+
* Compliance frameworks supported by the governance engine.
|
|
20
|
+
* Each identifier maps to a built-in requirement catalogue.
|
|
21
|
+
*/
|
|
22
|
+
export type ComplianceFramework = "eu_ai_act" | "gdpr" | "hipaa" | "soc2";
|
|
23
|
+
/**
|
|
24
|
+
* Automation level for a compliance requirement.
|
|
25
|
+
* Controls how labour hours are estimated in cost calculations.
|
|
26
|
+
*/
|
|
27
|
+
export type AutomationLevel = "fully_automated" | "semi_automated" | "manual";
|
|
28
|
+
/**
|
|
29
|
+
* Audit verdict — the outcome of a policy evaluation.
|
|
30
|
+
*/
|
|
31
|
+
export type AuditVerdict = "pass" | "fail";
|
|
32
|
+
/**
|
|
33
|
+
* Configuration for a single rule within a policy.
|
|
34
|
+
* Maps to RuleConfig in agent_gov.policy.schema.
|
|
35
|
+
*/
|
|
36
|
+
export interface PolicyRule {
|
|
37
|
+
/** Human-readable label for this rule within the policy. */
|
|
38
|
+
readonly name: string;
|
|
39
|
+
/**
|
|
40
|
+
* Rule type identifier — matches the rule class `name` attribute used
|
|
41
|
+
* for rule registry lookup.
|
|
42
|
+
*/
|
|
43
|
+
readonly type: string;
|
|
44
|
+
/** When false the rule is skipped during evaluation. Default true. */
|
|
45
|
+
readonly enabled: boolean;
|
|
46
|
+
/** Default severity applied to verdicts produced by this rule. */
|
|
47
|
+
readonly severity: Severity;
|
|
48
|
+
/** Arbitrary key/value parameters forwarded to the rule evaluate call. */
|
|
49
|
+
readonly params: Readonly<Record<string, unknown>>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Top-level policy configuration.
|
|
53
|
+
* Maps to PolicyConfig in agent_gov.policy.schema.
|
|
54
|
+
*/
|
|
55
|
+
export interface GovernanceConfig {
|
|
56
|
+
/** Unique identifier for this policy. */
|
|
57
|
+
readonly name: string;
|
|
58
|
+
/** Semantic version string for tracking policy changes. */
|
|
59
|
+
readonly version: string;
|
|
60
|
+
/** Free-text description of what this policy governs. */
|
|
61
|
+
readonly description: string;
|
|
62
|
+
/** Ordered list of rule configurations to evaluate. */
|
|
63
|
+
readonly rules: readonly PolicyRule[];
|
|
64
|
+
/** Arbitrary string key/value metadata (author, team, ticket, etc.). */
|
|
65
|
+
readonly metadata: Readonly<Record<string, string>>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Result produced by a single rule evaluation.
|
|
69
|
+
* Maps to RuleVerdict in agent_gov.policy.rule.
|
|
70
|
+
*/
|
|
71
|
+
export interface RuleVerdict {
|
|
72
|
+
/** The name of the rule that produced this verdict. */
|
|
73
|
+
readonly rule_name: string;
|
|
74
|
+
/** True when the action satisfies the rule; false when it violates it. */
|
|
75
|
+
readonly passed: boolean;
|
|
76
|
+
/** Severity level of this verdict. */
|
|
77
|
+
readonly severity: Severity;
|
|
78
|
+
/** Human-readable explanation, typically set when passed is false. */
|
|
79
|
+
readonly message: string;
|
|
80
|
+
/** Arbitrary structured data providing additional context. */
|
|
81
|
+
readonly details: Readonly<Record<string, unknown>>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Complete result of evaluating one action against a policy.
|
|
85
|
+
* Maps to EvaluationReport in agent_gov.policy.result.
|
|
86
|
+
*/
|
|
87
|
+
export interface ComplianceReport {
|
|
88
|
+
/** Name of the policy that generated this report. */
|
|
89
|
+
readonly policy_name: string;
|
|
90
|
+
/** The original action dictionary that was evaluated. */
|
|
91
|
+
readonly action: Readonly<Record<string, unknown>>;
|
|
92
|
+
/** One RuleVerdict per enabled rule that was evaluated. */
|
|
93
|
+
readonly verdicts: readonly RuleVerdict[];
|
|
94
|
+
/** True only when all verdicts report passed=true. */
|
|
95
|
+
readonly passed: boolean;
|
|
96
|
+
/** ISO-8601 UTC timestamp at which the evaluation completed. */
|
|
97
|
+
readonly timestamp: string;
|
|
98
|
+
/** Number of rules that flagged a violation. */
|
|
99
|
+
readonly violation_count: number;
|
|
100
|
+
/** Highest severity among all failed verdicts; "none" when no failures. */
|
|
101
|
+
readonly highest_severity: Severity | "none";
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* A single immutable audit log record.
|
|
105
|
+
* Maps to AuditEntry in agent_gov.audit.entry.
|
|
106
|
+
*/
|
|
107
|
+
export interface AuditEntry {
|
|
108
|
+
/** Unique identifier for the agent that performed the action. */
|
|
109
|
+
readonly agent_id: string;
|
|
110
|
+
/** Short category/type string for the action (e.g. "search", "write"). */
|
|
111
|
+
readonly action_type: string;
|
|
112
|
+
/** Full action payload as passed to the policy evaluator. */
|
|
113
|
+
readonly action_data: Readonly<Record<string, unknown>>;
|
|
114
|
+
/** Overall verdict: "pass" or "fail". */
|
|
115
|
+
readonly verdict: AuditVerdict;
|
|
116
|
+
/** Name of the policy that produced the verdict. */
|
|
117
|
+
readonly policy_name: string;
|
|
118
|
+
/** ISO-8601 UTC timestamp of the evaluation. */
|
|
119
|
+
readonly timestamp: string;
|
|
120
|
+
/** Arbitrary additional context (run ID, environment, etc.). */
|
|
121
|
+
readonly metadata: Readonly<Record<string, string>>;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Per-requirement cost detail line within a CostReport.
|
|
125
|
+
*/
|
|
126
|
+
export interface RequirementCostDetail {
|
|
127
|
+
/** Short unique identifier within the framework. */
|
|
128
|
+
readonly requirement_id: string;
|
|
129
|
+
/** Plain-language description of the requirement. */
|
|
130
|
+
readonly description: string;
|
|
131
|
+
/** Current automation level for this requirement. */
|
|
132
|
+
readonly automation_level: AutomationLevel;
|
|
133
|
+
/** Hours estimate when handled manually. */
|
|
134
|
+
readonly hours_manual: number;
|
|
135
|
+
/** Hours estimate under the current automation scenario. */
|
|
136
|
+
readonly hours_automated: number;
|
|
137
|
+
/** Cost in currency units under full manual mode. */
|
|
138
|
+
readonly cost_manual: number;
|
|
139
|
+
/** Cost in currency units under the current automation scenario. */
|
|
140
|
+
readonly cost_automated: number;
|
|
141
|
+
/** Cost saving from automation (cost_manual - cost_automated). */
|
|
142
|
+
readonly savings: number;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Cost-of-compliance report for a single framework and automation scenario.
|
|
146
|
+
* Maps to CostReport in agent_gov.compliance_cost.calculator.
|
|
147
|
+
*/
|
|
148
|
+
export interface ComplianceCostReport {
|
|
149
|
+
/** The regulatory framework being reported on. */
|
|
150
|
+
readonly framework: ComplianceFramework | string;
|
|
151
|
+
/** Total number of requirements in the framework. */
|
|
152
|
+
readonly total_requirements: number;
|
|
153
|
+
/** Count of requirements classified as fully_automated. */
|
|
154
|
+
readonly automated_count: number;
|
|
155
|
+
/** Count of semi_automated requirements. */
|
|
156
|
+
readonly semi_automated_count: number;
|
|
157
|
+
/** Count of manual requirements. */
|
|
158
|
+
readonly manual_count: number;
|
|
159
|
+
/** Sum of manual-mode hours across all requirements. */
|
|
160
|
+
readonly total_hours_manual: number;
|
|
161
|
+
/** Sum of automated-mode hours across all requirements. */
|
|
162
|
+
readonly total_hours_automated: number;
|
|
163
|
+
/** Total cost in currency units under fully manual mode. */
|
|
164
|
+
readonly total_cost_manual: number;
|
|
165
|
+
/** Total cost in currency units under the current automation scenario. */
|
|
166
|
+
readonly total_cost_with_automation: number;
|
|
167
|
+
/** Percentage cost reduction from automation. */
|
|
168
|
+
readonly savings_percentage: number;
|
|
169
|
+
/** Hourly rate used in the calculation. */
|
|
170
|
+
readonly hourly_rate: number;
|
|
171
|
+
/** Per-requirement cost detail lines. */
|
|
172
|
+
readonly requirement_details: readonly RequirementCostDetail[];
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Request body for the checkCompliance endpoint.
|
|
176
|
+
*/
|
|
177
|
+
export interface CheckComplianceRequest {
|
|
178
|
+
/** Identifier of the agent performing the action. */
|
|
179
|
+
readonly agent_id: string;
|
|
180
|
+
/** The action payload to evaluate. */
|
|
181
|
+
readonly action: Readonly<Record<string, unknown>>;
|
|
182
|
+
/** Name of the policy to evaluate against. */
|
|
183
|
+
readonly policy_name: string;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Request body for the validatePolicy endpoint.
|
|
187
|
+
*/
|
|
188
|
+
export interface ValidatePolicyRequest {
|
|
189
|
+
/** The full policy configuration to validate. */
|
|
190
|
+
readonly policy: GovernanceConfig;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Response from the validatePolicy endpoint. */
|
|
194
|
+
export interface ValidatePolicyResponse {
|
|
195
|
+
/** Whether the policy configuration is valid. */
|
|
196
|
+
readonly valid: boolean;
|
|
197
|
+
/** Validation error messages; empty when valid. */
|
|
198
|
+
readonly errors: readonly string[];
|
|
199
|
+
/** Number of enabled rules in the policy. */
|
|
200
|
+
readonly enabled_rule_count: number;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Request body for the generateReport endpoint.
|
|
204
|
+
*/
|
|
205
|
+
export interface GenerateReportRequest {
|
|
206
|
+
/** The regulatory framework to generate a cost report for. */
|
|
207
|
+
readonly framework: ComplianceFramework | string;
|
|
208
|
+
/** Automation level overrides per requirement_id. */
|
|
209
|
+
readonly automation_coverage?: Readonly<Record<string, AutomationLevel>>;
|
|
210
|
+
/** Hourly labour rate in currency units (default 150.0). */
|
|
211
|
+
readonly hourly_rate?: number;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Query parameters for the getAuditLog endpoint.
|
|
215
|
+
*/
|
|
216
|
+
export interface AuditLogQuery {
|
|
217
|
+
/** Filter by agent ID. */
|
|
218
|
+
readonly agentId?: string;
|
|
219
|
+
/** Filter by policy name. */
|
|
220
|
+
readonly policyName?: string;
|
|
221
|
+
/** Filter by verdict. */
|
|
222
|
+
readonly verdict?: AuditVerdict;
|
|
223
|
+
/** Maximum number of entries to return (default 100). */
|
|
224
|
+
readonly limit?: number;
|
|
225
|
+
}
|
|
226
|
+
/** Standard error payload returned by the agent-gov API. */
|
|
227
|
+
export interface ApiError {
|
|
228
|
+
readonly error: string;
|
|
229
|
+
readonly detail: string;
|
|
230
|
+
}
|
|
231
|
+
/** Result type for all client operations. */
|
|
232
|
+
export type ApiResult<T> = {
|
|
233
|
+
readonly ok: true;
|
|
234
|
+
readonly data: T;
|
|
235
|
+
} | {
|
|
236
|
+
readonly ok: false;
|
|
237
|
+
readonly error: ApiError;
|
|
238
|
+
readonly status: number;
|
|
239
|
+
};
|
|
240
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;AAE9D;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAE1E;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,QAAQ,CAAC;AAE9E;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MA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C;CACzB;AAED,6CAA6C;AAC7C,MAAM,MAAM,SAAS,CAAC,CAAC,IACnB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GACvC;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript interfaces for the agent-gov governance framework.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the Pydantic/dataclass models defined in:
|
|
5
|
+
* agent_gov.policy.schema — PolicyRule, PolicyConfig, RuleConfig
|
|
6
|
+
* agent_gov.policy.rule — RuleVerdict
|
|
7
|
+
* agent_gov.policy.result — EvaluationReport
|
|
8
|
+
* agent_gov.audit.entry — AuditEntry
|
|
9
|
+
* agent_gov.compliance_cost.calculator — CostReport
|
|
10
|
+
*
|
|
11
|
+
* All interfaces use readonly fields to match Python frozen models.
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aumos/agent-gov",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript client for the AumOS agent-gov governance framework — policy evaluation, compliance checking, and audit logging",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"typecheck": "tsc --noEmit"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"typescript": "^5.3.0"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"aumos",
|
|
24
|
+
"agent-gov",
|
|
25
|
+
"governance",
|
|
26
|
+
"compliance",
|
|
27
|
+
"policy",
|
|
28
|
+
"audit",
|
|
29
|
+
"eu-ai-act",
|
|
30
|
+
"gdpr",
|
|
31
|
+
"hipaa",
|
|
32
|
+
"typescript"
|
|
33
|
+
],
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/aumos-ai/agent-gov"
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for the agent-gov governance API.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Fetch API (available natively in Node 18+, browsers, and Deno).
|
|
5
|
+
* No external dependencies required.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createAgentGovClient } from "@aumos/agent-gov";
|
|
10
|
+
*
|
|
11
|
+
* const client = createAgentGovClient({ baseUrl: "http://localhost:8070" });
|
|
12
|
+
*
|
|
13
|
+
* const result = await client.checkCompliance({
|
|
14
|
+
* agent_id: "my-agent",
|
|
15
|
+
* policy_name: "default",
|
|
16
|
+
* action: { type: "search", query: "user emails" },
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* if (result.ok && result.data.passed) {
|
|
20
|
+
* console.log("Action approved by governance policy");
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import type {
|
|
26
|
+
ApiError,
|
|
27
|
+
ApiResult,
|
|
28
|
+
AuditEntry,
|
|
29
|
+
AuditLogQuery,
|
|
30
|
+
CheckComplianceRequest,
|
|
31
|
+
ComplianceCostReport,
|
|
32
|
+
ComplianceReport,
|
|
33
|
+
GenerateReportRequest,
|
|
34
|
+
ValidatePolicyRequest,
|
|
35
|
+
ValidatePolicyResponse,
|
|
36
|
+
} from "./types.js";
|
|
37
|
+
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
// Client configuration
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
|
|
42
|
+
/** Configuration options for the AgentGovClient. */
|
|
43
|
+
export interface AgentGovClientConfig {
|
|
44
|
+
/** Base URL of the agent-gov server (e.g. "http://localhost:8070"). */
|
|
45
|
+
readonly baseUrl: string;
|
|
46
|
+
/** Optional request timeout in milliseconds (default: 30000). */
|
|
47
|
+
readonly timeoutMs?: number;
|
|
48
|
+
/** Optional extra HTTP headers sent with every request. */
|
|
49
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
// Internal helpers
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
|
|
56
|
+
async function fetchJson<T>(
|
|
57
|
+
url: string,
|
|
58
|
+
init: RequestInit,
|
|
59
|
+
timeoutMs: number,
|
|
60
|
+
): Promise<ApiResult<T>> {
|
|
61
|
+
const controller = new AbortController();
|
|
62
|
+
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
const response = await fetch(url, { ...init, signal: controller.signal });
|
|
66
|
+
clearTimeout(timeoutId);
|
|
67
|
+
|
|
68
|
+
const body = await response.json() as unknown;
|
|
69
|
+
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
const errorBody = body as Partial<ApiError>;
|
|
72
|
+
return {
|
|
73
|
+
ok: false,
|
|
74
|
+
error: {
|
|
75
|
+
error: errorBody.error ?? "Unknown error",
|
|
76
|
+
detail: errorBody.detail ?? "",
|
|
77
|
+
},
|
|
78
|
+
status: response.status,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return { ok: true, data: body as T };
|
|
83
|
+
} catch (err: unknown) {
|
|
84
|
+
clearTimeout(timeoutId);
|
|
85
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
86
|
+
return {
|
|
87
|
+
ok: false,
|
|
88
|
+
error: { error: "Network error", detail: message },
|
|
89
|
+
status: 0,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function buildHeaders(
|
|
95
|
+
extraHeaders: Readonly<Record<string, string>> | undefined,
|
|
96
|
+
): Record<string, string> {
|
|
97
|
+
return {
|
|
98
|
+
"Content-Type": "application/json",
|
|
99
|
+
Accept: "application/json",
|
|
100
|
+
...extraHeaders,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// ---------------------------------------------------------------------------
|
|
105
|
+
// Client interface
|
|
106
|
+
// ---------------------------------------------------------------------------
|
|
107
|
+
|
|
108
|
+
/** Typed HTTP client for the agent-gov governance server. */
|
|
109
|
+
export interface AgentGovClient {
|
|
110
|
+
/**
|
|
111
|
+
* Evaluate an agent action against a named policy.
|
|
112
|
+
*
|
|
113
|
+
* Sends the action payload to the governance engine and returns a full
|
|
114
|
+
* ComplianceReport with per-rule verdicts, pass/fail status, and severity.
|
|
115
|
+
*
|
|
116
|
+
* @param request - The agent ID, action payload, and target policy name.
|
|
117
|
+
* @returns A ComplianceReport with all rule verdicts and an overall verdict.
|
|
118
|
+
*/
|
|
119
|
+
checkCompliance(
|
|
120
|
+
request: CheckComplianceRequest,
|
|
121
|
+
): Promise<ApiResult<ComplianceReport>>;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Retrieve the audit log with optional filtering.
|
|
125
|
+
*
|
|
126
|
+
* Returns entries in reverse chronological order (most recent first).
|
|
127
|
+
*
|
|
128
|
+
* @param query - Optional filter parameters (agentId, policyName, verdict, limit).
|
|
129
|
+
* @returns Array of AuditEntry records matching the filter criteria.
|
|
130
|
+
*/
|
|
131
|
+
getAuditLog(
|
|
132
|
+
query?: AuditLogQuery,
|
|
133
|
+
): Promise<ApiResult<readonly AuditEntry[]>>;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Generate a cost-of-compliance report for a regulatory framework.
|
|
137
|
+
*
|
|
138
|
+
* Computes per-requirement cost estimates under the given automation
|
|
139
|
+
* scenario and returns aggregated totals with savings percentages.
|
|
140
|
+
*
|
|
141
|
+
* @param request - Framework name, automation coverage overrides, and hourly rate.
|
|
142
|
+
* @returns A ComplianceCostReport with full cost breakdown.
|
|
143
|
+
*/
|
|
144
|
+
generateReport(
|
|
145
|
+
request: GenerateReportRequest,
|
|
146
|
+
): Promise<ApiResult<ComplianceCostReport>>;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Validate a policy configuration without persisting it.
|
|
150
|
+
*
|
|
151
|
+
* Checks rule type references, parameter schemas, and structural
|
|
152
|
+
* correctness. Returns a list of validation errors when the policy
|
|
153
|
+
* is invalid.
|
|
154
|
+
*
|
|
155
|
+
* @param request - The full policy configuration to validate.
|
|
156
|
+
* @returns Validation result with error messages and enabled rule count.
|
|
157
|
+
*/
|
|
158
|
+
validatePolicy(
|
|
159
|
+
request: ValidatePolicyRequest,
|
|
160
|
+
): Promise<ApiResult<ValidatePolicyResponse>>;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// ---------------------------------------------------------------------------
|
|
164
|
+
// Client factory
|
|
165
|
+
// ---------------------------------------------------------------------------
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Create a typed HTTP client for the agent-gov governance server.
|
|
169
|
+
*
|
|
170
|
+
* @param config - Client configuration including base URL.
|
|
171
|
+
* @returns An AgentGovClient instance.
|
|
172
|
+
*/
|
|
173
|
+
export function createAgentGovClient(
|
|
174
|
+
config: AgentGovClientConfig,
|
|
175
|
+
): AgentGovClient {
|
|
176
|
+
const { baseUrl, timeoutMs = 30_000, headers: extraHeaders } = config;
|
|
177
|
+
const baseHeaders = buildHeaders(extraHeaders);
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
async checkCompliance(
|
|
181
|
+
request: CheckComplianceRequest,
|
|
182
|
+
): Promise<ApiResult<ComplianceReport>> {
|
|
183
|
+
return fetchJson<ComplianceReport>(
|
|
184
|
+
`${baseUrl}/compliance/check`,
|
|
185
|
+
{
|
|
186
|
+
method: "POST",
|
|
187
|
+
headers: baseHeaders,
|
|
188
|
+
body: JSON.stringify(request),
|
|
189
|
+
},
|
|
190
|
+
timeoutMs,
|
|
191
|
+
);
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
async getAuditLog(
|
|
195
|
+
query: AuditLogQuery = {},
|
|
196
|
+
): Promise<ApiResult<readonly AuditEntry[]>> {
|
|
197
|
+
const params = new URLSearchParams();
|
|
198
|
+
if (query.agentId !== undefined) {
|
|
199
|
+
params.set("agent_id", query.agentId);
|
|
200
|
+
}
|
|
201
|
+
if (query.policyName !== undefined) {
|
|
202
|
+
params.set("policy_name", query.policyName);
|
|
203
|
+
}
|
|
204
|
+
if (query.verdict !== undefined) {
|
|
205
|
+
params.set("verdict", query.verdict);
|
|
206
|
+
}
|
|
207
|
+
if (query.limit !== undefined) {
|
|
208
|
+
params.set("limit", String(query.limit));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const queryString = params.toString();
|
|
212
|
+
const url = queryString
|
|
213
|
+
? `${baseUrl}/audit/log?${queryString}`
|
|
214
|
+
: `${baseUrl}/audit/log`;
|
|
215
|
+
|
|
216
|
+
return fetchJson<readonly AuditEntry[]>(
|
|
217
|
+
url,
|
|
218
|
+
{ method: "GET", headers: baseHeaders },
|
|
219
|
+
timeoutMs,
|
|
220
|
+
);
|
|
221
|
+
},
|
|
222
|
+
|
|
223
|
+
async generateReport(
|
|
224
|
+
request: GenerateReportRequest,
|
|
225
|
+
): Promise<ApiResult<ComplianceCostReport>> {
|
|
226
|
+
return fetchJson<ComplianceCostReport>(
|
|
227
|
+
`${baseUrl}/compliance/report`,
|
|
228
|
+
{
|
|
229
|
+
method: "POST",
|
|
230
|
+
headers: baseHeaders,
|
|
231
|
+
body: JSON.stringify(request),
|
|
232
|
+
},
|
|
233
|
+
timeoutMs,
|
|
234
|
+
);
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
async validatePolicy(
|
|
238
|
+
request: ValidatePolicyRequest,
|
|
239
|
+
): Promise<ApiResult<ValidatePolicyResponse>> {
|
|
240
|
+
return fetchJson<ValidatePolicyResponse>(
|
|
241
|
+
`${baseUrl}/policies/validate`,
|
|
242
|
+
{
|
|
243
|
+
method: "POST",
|
|
244
|
+
headers: baseHeaders,
|
|
245
|
+
body: JSON.stringify(request),
|
|
246
|
+
},
|
|
247
|
+
timeoutMs,
|
|
248
|
+
);
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @aumos/agent-gov
|
|
3
|
+
*
|
|
4
|
+
* TypeScript client for the AumOS agent-gov governance framework.
|
|
5
|
+
* Provides policy evaluation, compliance checking, audit logging,
|
|
6
|
+
* and cost-of-compliance reporting.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Client and configuration
|
|
10
|
+
export type { AgentGovClient, AgentGovClientConfig } from "./client.js";
|
|
11
|
+
export { createAgentGovClient } from "./client.js";
|
|
12
|
+
|
|
13
|
+
// Core governance types
|
|
14
|
+
export type {
|
|
15
|
+
Severity,
|
|
16
|
+
ComplianceFramework,
|
|
17
|
+
AutomationLevel,
|
|
18
|
+
AuditVerdict,
|
|
19
|
+
PolicyRule,
|
|
20
|
+
GovernanceConfig,
|
|
21
|
+
RuleVerdict,
|
|
22
|
+
ComplianceReport,
|
|
23
|
+
AuditEntry,
|
|
24
|
+
RequirementCostDetail,
|
|
25
|
+
ComplianceCostReport,
|
|
26
|
+
CheckComplianceRequest,
|
|
27
|
+
ValidatePolicyRequest,
|
|
28
|
+
ValidatePolicyResponse,
|
|
29
|
+
GenerateReportRequest,
|
|
30
|
+
AuditLogQuery,
|
|
31
|
+
ApiError,
|
|
32
|
+
ApiResult,
|
|
33
|
+
} from "./types.js";
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript interfaces for the agent-gov governance framework.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the Pydantic/dataclass models defined in:
|
|
5
|
+
* agent_gov.policy.schema — PolicyRule, PolicyConfig, RuleConfig
|
|
6
|
+
* agent_gov.policy.rule — RuleVerdict
|
|
7
|
+
* agent_gov.policy.result — EvaluationReport
|
|
8
|
+
* agent_gov.audit.entry — AuditEntry
|
|
9
|
+
* agent_gov.compliance_cost.calculator — CostReport
|
|
10
|
+
*
|
|
11
|
+
* All interfaces use readonly fields to match Python frozen models.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
// Enumerations
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Severity levels for policy rule violations.
|
|
20
|
+
* Maps to the Python Severity enum in agent_gov.policy.schema.
|
|
21
|
+
*/
|
|
22
|
+
export type Severity = "low" | "medium" | "high" | "critical";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Compliance frameworks supported by the governance engine.
|
|
26
|
+
* Each identifier maps to a built-in requirement catalogue.
|
|
27
|
+
*/
|
|
28
|
+
export type ComplianceFramework = "eu_ai_act" | "gdpr" | "hipaa" | "soc2";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Automation level for a compliance requirement.
|
|
32
|
+
* Controls how labour hours are estimated in cost calculations.
|
|
33
|
+
*/
|
|
34
|
+
export type AutomationLevel = "fully_automated" | "semi_automated" | "manual";
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Audit verdict — the outcome of a policy evaluation.
|
|
38
|
+
*/
|
|
39
|
+
export type AuditVerdict = "pass" | "fail";
|
|
40
|
+
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
// Policy rule types
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Configuration for a single rule within a policy.
|
|
47
|
+
* Maps to RuleConfig in agent_gov.policy.schema.
|
|
48
|
+
*/
|
|
49
|
+
export interface PolicyRule {
|
|
50
|
+
/** Human-readable label for this rule within the policy. */
|
|
51
|
+
readonly name: string;
|
|
52
|
+
/**
|
|
53
|
+
* Rule type identifier — matches the rule class `name` attribute used
|
|
54
|
+
* for rule registry lookup.
|
|
55
|
+
*/
|
|
56
|
+
readonly type: string;
|
|
57
|
+
/** When false the rule is skipped during evaluation. Default true. */
|
|
58
|
+
readonly enabled: boolean;
|
|
59
|
+
/** Default severity applied to verdicts produced by this rule. */
|
|
60
|
+
readonly severity: Severity;
|
|
61
|
+
/** Arbitrary key/value parameters forwarded to the rule evaluate call. */
|
|
62
|
+
readonly params: Readonly<Record<string, unknown>>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Top-level policy configuration.
|
|
67
|
+
* Maps to PolicyConfig in agent_gov.policy.schema.
|
|
68
|
+
*/
|
|
69
|
+
export interface GovernanceConfig {
|
|
70
|
+
/** Unique identifier for this policy. */
|
|
71
|
+
readonly name: string;
|
|
72
|
+
/** Semantic version string for tracking policy changes. */
|
|
73
|
+
readonly version: string;
|
|
74
|
+
/** Free-text description of what this policy governs. */
|
|
75
|
+
readonly description: string;
|
|
76
|
+
/** Ordered list of rule configurations to evaluate. */
|
|
77
|
+
readonly rules: readonly PolicyRule[];
|
|
78
|
+
/** Arbitrary string key/value metadata (author, team, ticket, etc.). */
|
|
79
|
+
readonly metadata: Readonly<Record<string, string>>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
// Rule verdict and evaluation report
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Result produced by a single rule evaluation.
|
|
88
|
+
* Maps to RuleVerdict in agent_gov.policy.rule.
|
|
89
|
+
*/
|
|
90
|
+
export interface RuleVerdict {
|
|
91
|
+
/** The name of the rule that produced this verdict. */
|
|
92
|
+
readonly rule_name: string;
|
|
93
|
+
/** True when the action satisfies the rule; false when it violates it. */
|
|
94
|
+
readonly passed: boolean;
|
|
95
|
+
/** Severity level of this verdict. */
|
|
96
|
+
readonly severity: Severity;
|
|
97
|
+
/** Human-readable explanation, typically set when passed is false. */
|
|
98
|
+
readonly message: string;
|
|
99
|
+
/** Arbitrary structured data providing additional context. */
|
|
100
|
+
readonly details: Readonly<Record<string, unknown>>;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Complete result of evaluating one action against a policy.
|
|
105
|
+
* Maps to EvaluationReport in agent_gov.policy.result.
|
|
106
|
+
*/
|
|
107
|
+
export interface ComplianceReport {
|
|
108
|
+
/** Name of the policy that generated this report. */
|
|
109
|
+
readonly policy_name: string;
|
|
110
|
+
/** The original action dictionary that was evaluated. */
|
|
111
|
+
readonly action: Readonly<Record<string, unknown>>;
|
|
112
|
+
/** One RuleVerdict per enabled rule that was evaluated. */
|
|
113
|
+
readonly verdicts: readonly RuleVerdict[];
|
|
114
|
+
/** True only when all verdicts report passed=true. */
|
|
115
|
+
readonly passed: boolean;
|
|
116
|
+
/** ISO-8601 UTC timestamp at which the evaluation completed. */
|
|
117
|
+
readonly timestamp: string;
|
|
118
|
+
/** Number of rules that flagged a violation. */
|
|
119
|
+
readonly violation_count: number;
|
|
120
|
+
/** Highest severity among all failed verdicts; "none" when no failures. */
|
|
121
|
+
readonly highest_severity: Severity | "none";
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// ---------------------------------------------------------------------------
|
|
125
|
+
// Audit log
|
|
126
|
+
// ---------------------------------------------------------------------------
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* A single immutable audit log record.
|
|
130
|
+
* Maps to AuditEntry in agent_gov.audit.entry.
|
|
131
|
+
*/
|
|
132
|
+
export interface AuditEntry {
|
|
133
|
+
/** Unique identifier for the agent that performed the action. */
|
|
134
|
+
readonly agent_id: string;
|
|
135
|
+
/** Short category/type string for the action (e.g. "search", "write"). */
|
|
136
|
+
readonly action_type: string;
|
|
137
|
+
/** Full action payload as passed to the policy evaluator. */
|
|
138
|
+
readonly action_data: Readonly<Record<string, unknown>>;
|
|
139
|
+
/** Overall verdict: "pass" or "fail". */
|
|
140
|
+
readonly verdict: AuditVerdict;
|
|
141
|
+
/** Name of the policy that produced the verdict. */
|
|
142
|
+
readonly policy_name: string;
|
|
143
|
+
/** ISO-8601 UTC timestamp of the evaluation. */
|
|
144
|
+
readonly timestamp: string;
|
|
145
|
+
/** Arbitrary additional context (run ID, environment, etc.). */
|
|
146
|
+
readonly metadata: Readonly<Record<string, string>>;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// ---------------------------------------------------------------------------
|
|
150
|
+
// Compliance cost types
|
|
151
|
+
// ---------------------------------------------------------------------------
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Per-requirement cost detail line within a CostReport.
|
|
155
|
+
*/
|
|
156
|
+
export interface RequirementCostDetail {
|
|
157
|
+
/** Short unique identifier within the framework. */
|
|
158
|
+
readonly requirement_id: string;
|
|
159
|
+
/** Plain-language description of the requirement. */
|
|
160
|
+
readonly description: string;
|
|
161
|
+
/** Current automation level for this requirement. */
|
|
162
|
+
readonly automation_level: AutomationLevel;
|
|
163
|
+
/** Hours estimate when handled manually. */
|
|
164
|
+
readonly hours_manual: number;
|
|
165
|
+
/** Hours estimate under the current automation scenario. */
|
|
166
|
+
readonly hours_automated: number;
|
|
167
|
+
/** Cost in currency units under full manual mode. */
|
|
168
|
+
readonly cost_manual: number;
|
|
169
|
+
/** Cost in currency units under the current automation scenario. */
|
|
170
|
+
readonly cost_automated: number;
|
|
171
|
+
/** Cost saving from automation (cost_manual - cost_automated). */
|
|
172
|
+
readonly savings: number;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Cost-of-compliance report for a single framework and automation scenario.
|
|
177
|
+
* Maps to CostReport in agent_gov.compliance_cost.calculator.
|
|
178
|
+
*/
|
|
179
|
+
export interface ComplianceCostReport {
|
|
180
|
+
/** The regulatory framework being reported on. */
|
|
181
|
+
readonly framework: ComplianceFramework | string;
|
|
182
|
+
/** Total number of requirements in the framework. */
|
|
183
|
+
readonly total_requirements: number;
|
|
184
|
+
/** Count of requirements classified as fully_automated. */
|
|
185
|
+
readonly automated_count: number;
|
|
186
|
+
/** Count of semi_automated requirements. */
|
|
187
|
+
readonly semi_automated_count: number;
|
|
188
|
+
/** Count of manual requirements. */
|
|
189
|
+
readonly manual_count: number;
|
|
190
|
+
/** Sum of manual-mode hours across all requirements. */
|
|
191
|
+
readonly total_hours_manual: number;
|
|
192
|
+
/** Sum of automated-mode hours across all requirements. */
|
|
193
|
+
readonly total_hours_automated: number;
|
|
194
|
+
/** Total cost in currency units under fully manual mode. */
|
|
195
|
+
readonly total_cost_manual: number;
|
|
196
|
+
/** Total cost in currency units under the current automation scenario. */
|
|
197
|
+
readonly total_cost_with_automation: number;
|
|
198
|
+
/** Percentage cost reduction from automation. */
|
|
199
|
+
readonly savings_percentage: number;
|
|
200
|
+
/** Hourly rate used in the calculation. */
|
|
201
|
+
readonly hourly_rate: number;
|
|
202
|
+
/** Per-requirement cost detail lines. */
|
|
203
|
+
readonly requirement_details: readonly RequirementCostDetail[];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// ---------------------------------------------------------------------------
|
|
207
|
+
// Request payload types
|
|
208
|
+
// ---------------------------------------------------------------------------
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Request body for the checkCompliance endpoint.
|
|
212
|
+
*/
|
|
213
|
+
export interface CheckComplianceRequest {
|
|
214
|
+
/** Identifier of the agent performing the action. */
|
|
215
|
+
readonly agent_id: string;
|
|
216
|
+
/** The action payload to evaluate. */
|
|
217
|
+
readonly action: Readonly<Record<string, unknown>>;
|
|
218
|
+
/** Name of the policy to evaluate against. */
|
|
219
|
+
readonly policy_name: string;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Request body for the validatePolicy endpoint.
|
|
224
|
+
*/
|
|
225
|
+
export interface ValidatePolicyRequest {
|
|
226
|
+
/** The full policy configuration to validate. */
|
|
227
|
+
readonly policy: GovernanceConfig;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Response from the validatePolicy endpoint. */
|
|
232
|
+
export interface ValidatePolicyResponse {
|
|
233
|
+
/** Whether the policy configuration is valid. */
|
|
234
|
+
readonly valid: boolean;
|
|
235
|
+
/** Validation error messages; empty when valid. */
|
|
236
|
+
readonly errors: readonly string[];
|
|
237
|
+
/** Number of enabled rules in the policy. */
|
|
238
|
+
readonly enabled_rule_count: number;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Request body for the generateReport endpoint.
|
|
243
|
+
*/
|
|
244
|
+
export interface GenerateReportRequest {
|
|
245
|
+
/** The regulatory framework to generate a cost report for. */
|
|
246
|
+
readonly framework: ComplianceFramework | string;
|
|
247
|
+
/** Automation level overrides per requirement_id. */
|
|
248
|
+
readonly automation_coverage?: Readonly<Record<string, AutomationLevel>>;
|
|
249
|
+
/** Hourly labour rate in currency units (default 150.0). */
|
|
250
|
+
readonly hourly_rate?: number;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Query parameters for the getAuditLog endpoint.
|
|
255
|
+
*/
|
|
256
|
+
export interface AuditLogQuery {
|
|
257
|
+
/** Filter by agent ID. */
|
|
258
|
+
readonly agentId?: string;
|
|
259
|
+
/** Filter by policy name. */
|
|
260
|
+
readonly policyName?: string;
|
|
261
|
+
/** Filter by verdict. */
|
|
262
|
+
readonly verdict?: AuditVerdict;
|
|
263
|
+
/** Maximum number of entries to return (default 100). */
|
|
264
|
+
readonly limit?: number;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// ---------------------------------------------------------------------------
|
|
268
|
+
// API result wrapper (shared pattern)
|
|
269
|
+
// ---------------------------------------------------------------------------
|
|
270
|
+
|
|
271
|
+
/** Standard error payload returned by the agent-gov API. */
|
|
272
|
+
export interface ApiError {
|
|
273
|
+
readonly error: string;
|
|
274
|
+
readonly detail: string;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** Result type for all client operations. */
|
|
278
|
+
export type ApiResult<T> =
|
|
279
|
+
| { readonly ok: true; readonly data: T }
|
|
280
|
+
| { readonly ok: false; readonly error: ApiError; readonly status: number };
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["ES2022", "DOM"],
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"rootDir": "./src",
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"declarationMap": true,
|
|
11
|
+
"sourceMap": true,
|
|
12
|
+
"strict": true,
|
|
13
|
+
"noImplicitAny": true,
|
|
14
|
+
"strictNullChecks": true,
|
|
15
|
+
"noUnusedLocals": true,
|
|
16
|
+
"noUnusedParameters": true,
|
|
17
|
+
"noImplicitReturns": true,
|
|
18
|
+
"exactOptionalPropertyTypes": true,
|
|
19
|
+
"forceConsistentCasingInFileNames": true,
|
|
20
|
+
"esModuleInterop": true,
|
|
21
|
+
"skipLibCheck": true
|
|
22
|
+
},
|
|
23
|
+
"include": ["src/**/*"],
|
|
24
|
+
"exclude": ["node_modules", "dist"]
|
|
25
|
+
}
|