@kya-os/contracts 1.5.2-canary.4 → 1.5.2-canary.5
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/agentshield-api/endpoints.d.ts +50 -0
- package/dist/agentshield-api/endpoints.js +46 -0
- package/dist/agentshield-api/index.d.ts +13 -0
- package/dist/agentshield-api/index.js +37 -0
- package/dist/agentshield-api/schemas.d.ts +6032 -0
- package/dist/agentshield-api/schemas.js +240 -0
- package/dist/agentshield-api/types.d.ts +231 -0
- package/dist/agentshield-api/types.js +26 -0
- package/dist/cli.d.ts +388 -0
- package/dist/cli.js +121 -0
- package/dist/config/base.d.ts +96 -0
- package/dist/config/base.js +11 -0
- package/dist/config/builder.d.ts +33 -0
- package/dist/config/builder.js +74 -0
- package/dist/config/delegation.d.ts +194 -0
- package/dist/config/delegation.js +10 -0
- package/dist/config/identity.d.ts +116 -0
- package/dist/config/identity.js +10 -0
- package/dist/config/index.d.ts +34 -0
- package/dist/config/index.js +14 -0
- package/dist/config/proofing.d.ts +120 -0
- package/dist/config/proofing.js +10 -0
- package/dist/config/tool-protection.d.ts +139 -0
- package/dist/config/tool-protection.js +10 -0
- package/dist/consent/index.d.ts +6 -0
- package/dist/consent/index.js +22 -0
- package/dist/consent/schemas.d.ts +738 -0
- package/dist/consent/schemas.js +186 -0
- package/dist/consent/types.d.ts +155 -0
- package/dist/consent/types.js +10 -0
- package/dist/dashboard-config/default-config.d.ts +49 -0
- package/dist/dashboard-config/default-config.js +240 -0
- package/dist/dashboard-config/index.d.ts +10 -0
- package/dist/dashboard-config/index.js +35 -0
- package/dist/dashboard-config/schemas.d.ts +5904 -0
- package/dist/dashboard-config/schemas.js +254 -0
- package/dist/dashboard-config/types.d.ts +337 -0
- package/dist/dashboard-config/types.js +10 -0
- package/dist/delegation/constraints.d.ts +1021 -0
- package/dist/delegation/constraints.js +218 -0
- package/dist/delegation/index.d.ts +7 -0
- package/dist/delegation/index.js +23 -0
- package/dist/delegation/schemas.d.ts +8457 -0
- package/dist/delegation/schemas.js +475 -0
- package/dist/did/index.d.ts +8 -0
- package/dist/did/index.js +24 -0
- package/dist/did/resolve-contract.d.ts +219 -0
- package/dist/did/resolve-contract.js +31 -0
- package/dist/did/schemas.d.ts +112 -0
- package/dist/did/schemas.js +172 -0
- package/dist/did/types.d.ts +163 -0
- package/dist/did/types.js +70 -0
- package/dist/env/constants.d.ts +57 -0
- package/dist/env/constants.js +59 -0
- package/dist/env/index.d.ts +4 -0
- package/dist/env/index.js +20 -0
- package/dist/handshake.d.ts +172 -0
- package/dist/handshake.js +60 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +55 -0
- package/dist/proof/index.d.ts +9 -0
- package/dist/proof/index.js +38 -0
- package/dist/proof/proof-record.d.ts +837 -0
- package/dist/proof/proof-record.js +133 -0
- package/dist/proof/signing-spec.d.ts +146 -0
- package/dist/proof/signing-spec.js +122 -0
- package/dist/proof.d.ts +414 -0
- package/dist/proof.js +82 -0
- package/dist/registry.d.ts +342 -0
- package/dist/registry.js +118 -0
- package/dist/runtime/errors.d.ts +347 -0
- package/dist/runtime/errors.js +119 -0
- package/dist/runtime/headers.d.ts +83 -0
- package/dist/runtime/headers.js +81 -0
- package/dist/runtime/index.d.ts +5 -0
- package/dist/runtime/index.js +21 -0
- package/dist/test.d.ts +251 -0
- package/dist/test.js +119 -0
- package/dist/tlkrc/index.d.ts +4 -0
- package/dist/tlkrc/index.js +20 -0
- package/dist/tlkrc/rotation.d.ts +245 -0
- package/dist/tlkrc/rotation.js +126 -0
- package/dist/tool-protection/index.d.ts +227 -0
- package/dist/tool-protection/index.js +113 -0
- package/dist/utils/validation.d.ts +30 -0
- package/dist/utils/validation.js +69 -0
- package/dist/vc/index.d.ts +7 -0
- package/dist/vc/index.js +23 -0
- package/dist/vc/schemas.d.ts +2483 -0
- package/dist/vc/schemas.js +224 -0
- package/dist/vc/statuslist.d.ts +493 -0
- package/dist/vc/statuslist.js +132 -0
- package/dist/verifier.d.ts +205 -0
- package/dist/verifier.js +83 -0
- package/dist/well-known/index.d.ts +308 -0
- package/dist/well-known/index.js +134 -0
- package/package.json +1 -1
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AgentShield/Bouncer API Zod Validation Schemas
|
|
4
|
+
*
|
|
5
|
+
* Runtime validation schemas matching the API contract types.
|
|
6
|
+
* These schemas ensure request/response validation before sending/receiving.
|
|
7
|
+
*
|
|
8
|
+
* @package @kya-os/contracts/agentshield-api
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.revokeDelegationAPIResponseSchema = exports.revokeDelegationResponseSchema = exports.revokeDelegationRequestSchema = exports.createDelegationAPIResponseSchema = exports.createDelegationResponseSchema = exports.createDelegationRequestSchema = exports.toolProtectionConfigAPIResponseSchema = exports.toolProtectionConfigResponseSchema = exports.agentShieldToolProtectionSchema = exports.verifyDelegationAPIResponseSchema = exports.verifyDelegationResponseSchema = exports.verifyDelegationRequestSchema = exports.delegationCredentialSchema = exports.proofSubmissionResponseSchema = exports.proofSubmissionRequestSchema = exports.agentShieldAPIResponseSchema = exports.agentShieldAPIErrorSchema = void 0;
|
|
12
|
+
const zod_1 = require("zod");
|
|
13
|
+
const proof_js_1 = require("../proof.js");
|
|
14
|
+
const index_js_1 = require("../delegation/index.js");
|
|
15
|
+
/**
|
|
16
|
+
* Standard error schema
|
|
17
|
+
*/
|
|
18
|
+
exports.agentShieldAPIErrorSchema = zod_1.z.object({
|
|
19
|
+
code: zod_1.z.string(),
|
|
20
|
+
message: zod_1.z.string(),
|
|
21
|
+
details: zod_1.z.record(zod_1.z.unknown()).optional(),
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Standard API response wrapper schema
|
|
25
|
+
*/
|
|
26
|
+
const agentShieldAPIResponseSchema = (dataSchema) => zod_1.z.object({
|
|
27
|
+
success: zod_1.z.boolean(),
|
|
28
|
+
data: dataSchema,
|
|
29
|
+
metadata: zod_1.z
|
|
30
|
+
.object({
|
|
31
|
+
requestId: zod_1.z.string(),
|
|
32
|
+
timestamp: zod_1.z.string(),
|
|
33
|
+
})
|
|
34
|
+
.optional(),
|
|
35
|
+
});
|
|
36
|
+
exports.agentShieldAPIResponseSchema = agentShieldAPIResponseSchema;
|
|
37
|
+
// ============================================================================
|
|
38
|
+
// Proof Submission Schemas
|
|
39
|
+
// ============================================================================
|
|
40
|
+
/**
|
|
41
|
+
* Tool Call Context Schema (AgentShield Extension)
|
|
42
|
+
* Optional plaintext context for dashboard enrichment
|
|
43
|
+
*/
|
|
44
|
+
const toolCallContextSchema = zod_1.z.object({
|
|
45
|
+
tool: zod_1.z.string().min(1, "Tool name is required"),
|
|
46
|
+
args: zod_1.z.record(zod_1.z.unknown()),
|
|
47
|
+
result: zod_1.z.unknown().optional(),
|
|
48
|
+
scopeId: zod_1.z.string().min(1, "scopeId is required to link context to proof"),
|
|
49
|
+
userIdentifier: zod_1.z.string().optional(),
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Proof submission request schema
|
|
53
|
+
*/
|
|
54
|
+
exports.proofSubmissionRequestSchema = zod_1.z.object({
|
|
55
|
+
session_id: zod_1.z.string().max(100), // AgentShield session ID (may differ from MCP-I sessionId)
|
|
56
|
+
delegation_id: zod_1.z.string().uuid().nullish(),
|
|
57
|
+
proofs: zod_1.z.array(proof_js_1.DetachedProofSchema).min(1),
|
|
58
|
+
// AgentShield extension: Optional context for dashboard enrichment
|
|
59
|
+
context: zod_1.z
|
|
60
|
+
.object({
|
|
61
|
+
toolCalls: zod_1.z.array(toolCallContextSchema).optional(),
|
|
62
|
+
mcpServerUrl: zod_1.z.string().url().optional(), // MCP server URL for tool discovery
|
|
63
|
+
})
|
|
64
|
+
.optional(),
|
|
65
|
+
});
|
|
66
|
+
/**
|
|
67
|
+
* Proof submission response schema
|
|
68
|
+
*/
|
|
69
|
+
exports.proofSubmissionResponseSchema = zod_1.z.object({
|
|
70
|
+
success: zod_1.z.boolean(),
|
|
71
|
+
accepted: zod_1.z.number().int().min(0),
|
|
72
|
+
rejected: zod_1.z.number().int().min(0),
|
|
73
|
+
outcomes: zod_1.z.record(zod_1.z.string(), zod_1.z.number().int().min(0)), // Record<BouncerOutcome, number>
|
|
74
|
+
errors: zod_1.z
|
|
75
|
+
.array(zod_1.z.object({
|
|
76
|
+
proof_index: zod_1.z.number().int().min(0),
|
|
77
|
+
error: zod_1.z.object({
|
|
78
|
+
code: zod_1.z.string(),
|
|
79
|
+
message: zod_1.z.string(),
|
|
80
|
+
details: zod_1.z.record(zod_1.z.unknown()).optional(),
|
|
81
|
+
}),
|
|
82
|
+
}))
|
|
83
|
+
.optional(),
|
|
84
|
+
});
|
|
85
|
+
// ============================================================================
|
|
86
|
+
// Delegation Verification Schemas
|
|
87
|
+
// ============================================================================
|
|
88
|
+
/**
|
|
89
|
+
* Delegation credential schema
|
|
90
|
+
*/
|
|
91
|
+
exports.delegationCredentialSchema = zod_1.z.object({
|
|
92
|
+
agent_did: zod_1.z.string(),
|
|
93
|
+
user_id: zod_1.z.string().optional(),
|
|
94
|
+
user_identifier: zod_1.z.string().optional(),
|
|
95
|
+
scopes: zod_1.z.array(zod_1.z.string()),
|
|
96
|
+
constraints: zod_1.z.record(zod_1.z.unknown()).optional(),
|
|
97
|
+
issued_at: zod_1.z.number().int().positive(),
|
|
98
|
+
created_at: zod_1.z.number().int().positive(),
|
|
99
|
+
});
|
|
100
|
+
/**
|
|
101
|
+
* Delegation verification request schema
|
|
102
|
+
*/
|
|
103
|
+
exports.verifyDelegationRequestSchema = zod_1.z.object({
|
|
104
|
+
agent_did: zod_1.z.string(),
|
|
105
|
+
credential_jwt: zod_1.z.string().optional(), // Optional, omit (don't set to empty string) when not available for OAuth flow
|
|
106
|
+
delegation_token: zod_1.z.string().optional(), // Optional, for stateless MCP servers
|
|
107
|
+
scopes: zod_1.z.array(zod_1.z.string()).optional(), // Optional, can be empty array
|
|
108
|
+
timestamp: zod_1.z.number().int().positive().optional(),
|
|
109
|
+
client_info: zod_1.z
|
|
110
|
+
.object({
|
|
111
|
+
ip_address: zod_1.z.string().ip().optional(),
|
|
112
|
+
origin: zod_1.z.string().url().optional(),
|
|
113
|
+
user_agent: zod_1.z.string().optional(),
|
|
114
|
+
})
|
|
115
|
+
.optional(),
|
|
116
|
+
}).partial({ scopes: true }); // Make scopes truly optional by using partial
|
|
117
|
+
/**
|
|
118
|
+
* Delegation verification response schema
|
|
119
|
+
*/
|
|
120
|
+
exports.verifyDelegationResponseSchema = zod_1.z.object({
|
|
121
|
+
valid: zod_1.z.boolean(),
|
|
122
|
+
delegation: index_js_1.DelegationRecordSchema.optional(),
|
|
123
|
+
delegation_id: zod_1.z.string().uuid().optional(),
|
|
124
|
+
credential: exports.delegationCredentialSchema.optional(),
|
|
125
|
+
error: exports.agentShieldAPIErrorSchema.optional(),
|
|
126
|
+
reason: zod_1.z.string().optional(),
|
|
127
|
+
});
|
|
128
|
+
/**
|
|
129
|
+
* Wrapped verification response schema
|
|
130
|
+
*/
|
|
131
|
+
exports.verifyDelegationAPIResponseSchema = (0, exports.agentShieldAPIResponseSchema)(exports.verifyDelegationResponseSchema);
|
|
132
|
+
// ============================================================================
|
|
133
|
+
// Tool Protection Configuration Schemas
|
|
134
|
+
// ============================================================================
|
|
135
|
+
/**
|
|
136
|
+
* AgentShield tool protection schema (supports both snake_case and camelCase)
|
|
137
|
+
* This is the API-specific format, not the MCP-I spec schema
|
|
138
|
+
*/
|
|
139
|
+
exports.agentShieldToolProtectionSchema = zod_1.z
|
|
140
|
+
.object({
|
|
141
|
+
scopes: zod_1.z.array(zod_1.z.string()),
|
|
142
|
+
requires_delegation: zod_1.z.boolean().optional(),
|
|
143
|
+
requiresDelegation: zod_1.z.boolean().optional(),
|
|
144
|
+
required_scopes: zod_1.z.array(zod_1.z.string()).optional(),
|
|
145
|
+
})
|
|
146
|
+
.passthrough(); // Allow additional properties
|
|
147
|
+
/**
|
|
148
|
+
* Tool protection config response schema
|
|
149
|
+
*/
|
|
150
|
+
exports.toolProtectionConfigResponseSchema = zod_1.z.object({
|
|
151
|
+
agent_did: zod_1.z.string(),
|
|
152
|
+
tools: zod_1.z.record(zod_1.z.string(), exports.agentShieldToolProtectionSchema),
|
|
153
|
+
reputation_threshold: zod_1.z.number().min(0).max(1).optional(),
|
|
154
|
+
denied_agents: zod_1.z.array(zod_1.z.string()).optional(),
|
|
155
|
+
crisp_budget: zod_1.z
|
|
156
|
+
.object({
|
|
157
|
+
max_tokens: zod_1.z.number(),
|
|
158
|
+
max_cost: zod_1.z.number(),
|
|
159
|
+
currency: zod_1.z.string(),
|
|
160
|
+
time_window: zod_1.z.string(),
|
|
161
|
+
})
|
|
162
|
+
.optional(),
|
|
163
|
+
});
|
|
164
|
+
/**
|
|
165
|
+
* Wrapped config response schema
|
|
166
|
+
*/
|
|
167
|
+
exports.toolProtectionConfigAPIResponseSchema = (0, exports.agentShieldAPIResponseSchema)(exports.toolProtectionConfigResponseSchema);
|
|
168
|
+
// ============================================================================
|
|
169
|
+
// Delegation Management Schemas
|
|
170
|
+
// ============================================================================
|
|
171
|
+
/**
|
|
172
|
+
* Create delegation request schema
|
|
173
|
+
*
|
|
174
|
+
* Note: AgentShield API accepts a simplified format, not the full DelegationRecord.
|
|
175
|
+
* The API accepts: agent_did, scopes, expires_in_days, expires_at, session_id, project_id, custom_fields
|
|
176
|
+
*
|
|
177
|
+
* IMPORTANT: expires_in_days and expires_at are mutually exclusive - use one or the other, not both.
|
|
178
|
+
*/
|
|
179
|
+
exports.createDelegationRequestSchema = zod_1.z
|
|
180
|
+
.object({
|
|
181
|
+
agent_did: zod_1.z.string().min(1),
|
|
182
|
+
scopes: zod_1.z.array(zod_1.z.string()).min(1),
|
|
183
|
+
expires_in_days: zod_1.z.number().int().positive().optional(),
|
|
184
|
+
expires_at: zod_1.z.string().datetime().optional(),
|
|
185
|
+
session_id: zod_1.z.string().optional(),
|
|
186
|
+
project_id: zod_1.z.string().uuid().optional(),
|
|
187
|
+
custom_fields: zod_1.z.record(zod_1.z.unknown()).optional(),
|
|
188
|
+
})
|
|
189
|
+
.passthrough()
|
|
190
|
+
.refine((data) => {
|
|
191
|
+
// expires_in_days and expires_at are mutually exclusive
|
|
192
|
+
const hasExpiresInDays = data.expires_in_days !== undefined;
|
|
193
|
+
const hasExpiresAt = data.expires_at !== undefined;
|
|
194
|
+
return !(hasExpiresInDays && hasExpiresAt);
|
|
195
|
+
}, {
|
|
196
|
+
message: "expires_in_days and expires_at are mutually exclusive - use one or the other, not both",
|
|
197
|
+
path: ["expires_in_days", "expires_at"],
|
|
198
|
+
});
|
|
199
|
+
/**
|
|
200
|
+
* Create delegation response schema
|
|
201
|
+
*
|
|
202
|
+
* Canonical format returned by POST /api/v1/bouncer/delegations
|
|
203
|
+
*
|
|
204
|
+
* IMPORTANT: delegation_token is NOT returned by this endpoint.
|
|
205
|
+
* delegation_token is only available via OAuth callback flow (/api/v1/bouncer/oauth/callback)
|
|
206
|
+
* and is passed as a URL parameter, not in the API response body.
|
|
207
|
+
*/
|
|
208
|
+
exports.createDelegationResponseSchema = zod_1.z.object({
|
|
209
|
+
delegation_id: zod_1.z.string().uuid(),
|
|
210
|
+
agent_did: zod_1.z.string().min(1),
|
|
211
|
+
user_id: zod_1.z.string().optional(),
|
|
212
|
+
user_identifier: zod_1.z.string().optional(),
|
|
213
|
+
scopes: zod_1.z.array(zod_1.z.string()),
|
|
214
|
+
status: zod_1.z.literal("active"),
|
|
215
|
+
issued_at: zod_1.z.string().datetime(),
|
|
216
|
+
expires_at: zod_1.z.string().datetime().optional(),
|
|
217
|
+
created_at: zod_1.z.string().datetime(),
|
|
218
|
+
});
|
|
219
|
+
/**
|
|
220
|
+
* Wrapped creation response schema
|
|
221
|
+
*/
|
|
222
|
+
exports.createDelegationAPIResponseSchema = (0, exports.agentShieldAPIResponseSchema)(exports.createDelegationResponseSchema);
|
|
223
|
+
/**
|
|
224
|
+
* Revoke delegation request schema
|
|
225
|
+
*/
|
|
226
|
+
exports.revokeDelegationRequestSchema = zod_1.z.object({
|
|
227
|
+
reason: zod_1.z.string().optional(),
|
|
228
|
+
});
|
|
229
|
+
/**
|
|
230
|
+
* Revoke delegation response schema
|
|
231
|
+
*/
|
|
232
|
+
exports.revokeDelegationResponseSchema = zod_1.z.object({
|
|
233
|
+
delegation_id: zod_1.z.string().uuid(),
|
|
234
|
+
revoked: zod_1.z.boolean(),
|
|
235
|
+
revoked_at: zod_1.z.number().int().positive(),
|
|
236
|
+
});
|
|
237
|
+
/**
|
|
238
|
+
* Wrapped revocation response schema
|
|
239
|
+
*/
|
|
240
|
+
exports.revokeDelegationAPIResponseSchema = (0, exports.agentShieldAPIResponseSchema)(exports.revokeDelegationResponseSchema);
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentShield/Bouncer API Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* TypeScript interfaces matching the AgentShield dashboard API contract.
|
|
5
|
+
* These types ensure parity between xmcp-i clients and the AgentShield service.
|
|
6
|
+
*
|
|
7
|
+
* @package @kya-os/contracts/agentshield-api
|
|
8
|
+
*/
|
|
9
|
+
import type { DetachedProof } from "../proof.js";
|
|
10
|
+
import type { DelegationRecord } from "../delegation/index.js";
|
|
11
|
+
/**
|
|
12
|
+
* Standard AgentShield API response wrapper
|
|
13
|
+
*/
|
|
14
|
+
export interface AgentShieldAPIResponse<T> {
|
|
15
|
+
success: boolean;
|
|
16
|
+
data: T;
|
|
17
|
+
metadata?: {
|
|
18
|
+
requestId: string;
|
|
19
|
+
timestamp: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Standard AgentShield API error response structure
|
|
24
|
+
* (Use AgentShieldAPIError class for runtime errors)
|
|
25
|
+
*/
|
|
26
|
+
export interface AgentShieldAPIErrorResponse {
|
|
27
|
+
code: string;
|
|
28
|
+
message: string;
|
|
29
|
+
details?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Tool Call Context (AgentShield Extension to MCP-I)
|
|
33
|
+
*
|
|
34
|
+
* Optional plaintext context for dashboard enrichment.
|
|
35
|
+
* Links to MCP-I proof via scopeId.
|
|
36
|
+
*/
|
|
37
|
+
export interface ToolCallContext {
|
|
38
|
+
tool: string;
|
|
39
|
+
args: Record<string, unknown>;
|
|
40
|
+
result?: unknown;
|
|
41
|
+
scopeId: string;
|
|
42
|
+
userIdentifier?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Request body for proof submission endpoint
|
|
46
|
+
* POST /api/v1/bouncer/proofs
|
|
47
|
+
*/
|
|
48
|
+
export interface ProofSubmissionRequest {
|
|
49
|
+
/** Delegation ID (nullable, optional - null if no delegation context) */
|
|
50
|
+
delegation_id?: string | null;
|
|
51
|
+
/** Session ID for grouping proofs (AgentShield session ID, may differ from MCP-I sessionId) */
|
|
52
|
+
session_id: string;
|
|
53
|
+
/** Array of proofs to submit */
|
|
54
|
+
proofs: DetachedProof[];
|
|
55
|
+
/** AgentShield extension: Optional context for dashboard enrichment */
|
|
56
|
+
context?: {
|
|
57
|
+
toolCalls?: ToolCallContext[];
|
|
58
|
+
mcpServerUrl?: string;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Bouncer outcome types
|
|
63
|
+
*/
|
|
64
|
+
export type BouncerOutcome = "success" | "failed" | "blocked" | "error";
|
|
65
|
+
/**
|
|
66
|
+
* Response from proof submission endpoint
|
|
67
|
+
*/
|
|
68
|
+
export interface ProofSubmissionResponse {
|
|
69
|
+
success: boolean;
|
|
70
|
+
accepted: number;
|
|
71
|
+
rejected: number;
|
|
72
|
+
outcomes: Record<BouncerOutcome, number>;
|
|
73
|
+
errors?: Array<{
|
|
74
|
+
proof_index: number;
|
|
75
|
+
error: {
|
|
76
|
+
code: string;
|
|
77
|
+
message: string;
|
|
78
|
+
details?: Record<string, unknown>;
|
|
79
|
+
};
|
|
80
|
+
}>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Request body for delegation verification endpoint
|
|
84
|
+
* POST /api/v1/bouncer/delegations/verify
|
|
85
|
+
*/
|
|
86
|
+
export interface VerifyDelegationRequest {
|
|
87
|
+
/** Agent DID to verify */
|
|
88
|
+
agent_did: string;
|
|
89
|
+
/** Credential JWT (optional, defaults to empty string for OAuth flow) */
|
|
90
|
+
credential_jwt?: string;
|
|
91
|
+
/** Delegation token from OAuth flow (optional, for stateless MCP servers) */
|
|
92
|
+
delegation_token?: string;
|
|
93
|
+
/** Required scopes (optional, can be empty array) */
|
|
94
|
+
scopes?: string[];
|
|
95
|
+
/** Optional timestamp for verification */
|
|
96
|
+
timestamp?: number;
|
|
97
|
+
/** Optional client info for IP/origin checking */
|
|
98
|
+
client_info?: {
|
|
99
|
+
ip_address?: string;
|
|
100
|
+
origin?: string;
|
|
101
|
+
user_agent?: string;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Credential information returned in verification response
|
|
106
|
+
*/
|
|
107
|
+
export interface DelegationCredential {
|
|
108
|
+
agent_did: string;
|
|
109
|
+
user_id?: string;
|
|
110
|
+
user_identifier?: string;
|
|
111
|
+
scopes: string[];
|
|
112
|
+
constraints?: Record<string, unknown>;
|
|
113
|
+
issued_at: number;
|
|
114
|
+
created_at: number;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Response from delegation verification endpoint
|
|
118
|
+
*/
|
|
119
|
+
export interface VerifyDelegationResponse {
|
|
120
|
+
valid: boolean;
|
|
121
|
+
delegation?: DelegationRecord;
|
|
122
|
+
delegation_id?: string;
|
|
123
|
+
credential?: DelegationCredential;
|
|
124
|
+
error?: AgentShieldAPIErrorResponse;
|
|
125
|
+
reason?: string;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Wrapped verification response (AgentShield wraps in success/data)
|
|
129
|
+
*/
|
|
130
|
+
export type VerifyDelegationAPIResponse = AgentShieldAPIResponse<VerifyDelegationResponse>;
|
|
131
|
+
/**
|
|
132
|
+
* AgentShield API tool protection format for a single tool
|
|
133
|
+
* This is the API-specific format, not the MCP-I spec type
|
|
134
|
+
*/
|
|
135
|
+
export interface AgentShieldToolProtection {
|
|
136
|
+
scopes: string[];
|
|
137
|
+
requires_delegation?: boolean;
|
|
138
|
+
requiresDelegation?: boolean;
|
|
139
|
+
required_scopes?: string[];
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Response from tool protection config endpoint
|
|
143
|
+
* GET /api/v1/bouncer/projects/{projectId}/config
|
|
144
|
+
*/
|
|
145
|
+
export interface ToolProtectionConfigResponse {
|
|
146
|
+
agent_did: string;
|
|
147
|
+
tools: Record<string, AgentShieldToolProtection>;
|
|
148
|
+
reputation_threshold?: number;
|
|
149
|
+
denied_agents?: string[];
|
|
150
|
+
crisp_budget?: {
|
|
151
|
+
max_tokens: number;
|
|
152
|
+
max_cost: number;
|
|
153
|
+
currency: string;
|
|
154
|
+
time_window: string;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Wrapped config response
|
|
159
|
+
*/
|
|
160
|
+
export type ToolProtectionConfigAPIResponse = AgentShieldAPIResponse<ToolProtectionConfigResponse>;
|
|
161
|
+
/**
|
|
162
|
+
* Request body for creating a delegation
|
|
163
|
+
* POST /api/v1/bouncer/delegations
|
|
164
|
+
*
|
|
165
|
+
* Note: AgentShield API accepts a simplified format, not the full DelegationRecord.
|
|
166
|
+
* The API accepts: agent_did, scopes, expires_in_days, expires_at, session_id, project_id, custom_fields
|
|
167
|
+
*
|
|
168
|
+
* IMPORTANT: expires_in_days and expires_at are mutually exclusive - use one or the other, not both.
|
|
169
|
+
*/
|
|
170
|
+
export interface CreateDelegationRequest {
|
|
171
|
+
agent_did: string;
|
|
172
|
+
scopes: string[];
|
|
173
|
+
/** Number of days until expiration (1-365). Mutually exclusive with expires_at. */
|
|
174
|
+
expires_in_days?: number;
|
|
175
|
+
/** ISO 8601 datetime when delegation expires. Mutually exclusive with expires_in_days. */
|
|
176
|
+
expires_at?: string;
|
|
177
|
+
session_id?: string;
|
|
178
|
+
project_id?: string;
|
|
179
|
+
custom_fields?: Record<string, unknown>;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Response from delegation creation endpoint
|
|
183
|
+
*
|
|
184
|
+
* Canonical format returned by POST /api/v1/bouncer/delegations
|
|
185
|
+
*
|
|
186
|
+
* IMPORTANT: delegation_token is NOT returned by this endpoint.
|
|
187
|
+
* delegation_token is only available via OAuth callback flow (/api/v1/bouncer/oauth/callback)
|
|
188
|
+
* and is passed as a URL parameter, not in the API response body.
|
|
189
|
+
*/
|
|
190
|
+
export interface CreateDelegationResponse {
|
|
191
|
+
delegation_id: string;
|
|
192
|
+
agent_did: string;
|
|
193
|
+
user_id?: string;
|
|
194
|
+
user_identifier?: string;
|
|
195
|
+
scopes: string[];
|
|
196
|
+
status: "active";
|
|
197
|
+
issued_at: string;
|
|
198
|
+
expires_at?: string;
|
|
199
|
+
created_at: string;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Wrapped creation response
|
|
203
|
+
*/
|
|
204
|
+
export type CreateDelegationAPIResponse = AgentShieldAPIResponse<CreateDelegationResponse>;
|
|
205
|
+
/**
|
|
206
|
+
* Request body for revoking a delegation
|
|
207
|
+
* POST /api/v1/bouncer/delegations/{id}/revoke
|
|
208
|
+
*/
|
|
209
|
+
export interface RevokeDelegationRequest {
|
|
210
|
+
reason?: string;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Response from delegation revocation endpoint
|
|
214
|
+
*/
|
|
215
|
+
export interface RevokeDelegationResponse {
|
|
216
|
+
delegation_id: string;
|
|
217
|
+
revoked: boolean;
|
|
218
|
+
revoked_at: number;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Wrapped revocation response
|
|
222
|
+
*/
|
|
223
|
+
export type RevokeDelegationAPIResponse = AgentShieldAPIResponse<RevokeDelegationResponse>;
|
|
224
|
+
/**
|
|
225
|
+
* AgentShield API error class
|
|
226
|
+
*/
|
|
227
|
+
export declare class AgentShieldAPIError extends Error {
|
|
228
|
+
readonly code: string;
|
|
229
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
230
|
+
constructor(code: string, message: string, details?: Record<string, unknown> | undefined);
|
|
231
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AgentShield/Bouncer API Type Definitions
|
|
4
|
+
*
|
|
5
|
+
* TypeScript interfaces matching the AgentShield dashboard API contract.
|
|
6
|
+
* These types ensure parity between xmcp-i clients and the AgentShield service.
|
|
7
|
+
*
|
|
8
|
+
* @package @kya-os/contracts/agentshield-api
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.AgentShieldAPIError = void 0;
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Error Types
|
|
14
|
+
// ============================================================================
|
|
15
|
+
/**
|
|
16
|
+
* AgentShield API error class
|
|
17
|
+
*/
|
|
18
|
+
class AgentShieldAPIError extends Error {
|
|
19
|
+
constructor(code, message, details) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.code = code;
|
|
22
|
+
this.details = details;
|
|
23
|
+
this.name = "AgentShieldAPIError";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.AgentShieldAPIError = AgentShieldAPIError;
|