@kya-os/contracts 1.3.4 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/agentshield-api/endpoints.d.ts +50 -0
  2. package/dist/agentshield-api/endpoints.js +46 -0
  3. package/dist/agentshield-api/index.d.ts +13 -0
  4. package/dist/agentshield-api/index.js +38 -0
  5. package/dist/agentshield-api/schemas.d.ts +9914 -0
  6. package/dist/agentshield-api/schemas.js +165 -0
  7. package/dist/agentshield-api/types.d.ts +168 -0
  8. package/dist/agentshield-api/types.js +27 -0
  9. package/dist/cli.d.ts +388 -0
  10. package/dist/cli.js +121 -0
  11. package/dist/config/base.d.ts +96 -0
  12. package/dist/config/base.js +11 -0
  13. package/dist/config/delegation.d.ts +194 -0
  14. package/dist/config/delegation.js +10 -0
  15. package/dist/config/identity.d.ts +117 -0
  16. package/dist/config/identity.js +11 -0
  17. package/dist/config/index.d.ts +33 -0
  18. package/dist/config/index.js +11 -0
  19. package/dist/config/proofing.d.ts +120 -0
  20. package/dist/config/proofing.js +10 -0
  21. package/dist/config/tool-protection.d.ts +139 -0
  22. package/dist/config/tool-protection.js +10 -0
  23. package/dist/dashboard-config/index.d.ts +10 -0
  24. package/dist/dashboard-config/index.js +31 -0
  25. package/dist/dashboard-config/schemas.d.ts +5847 -0
  26. package/dist/dashboard-config/schemas.js +251 -0
  27. package/dist/dashboard-config/types.d.ts +331 -0
  28. package/dist/dashboard-config/types.js +11 -0
  29. package/dist/delegation/constraints.d.ts +991 -0
  30. package/dist/delegation/constraints.js +209 -0
  31. package/dist/delegation/index.d.ts +7 -0
  32. package/dist/delegation/index.js +23 -0
  33. package/dist/delegation/schemas.d.ts +8381 -0
  34. package/dist/delegation/schemas.js +475 -0
  35. package/dist/did/index.d.ts +8 -0
  36. package/dist/did/index.js +24 -0
  37. package/dist/did/resolve-contract.d.ts +219 -0
  38. package/dist/did/resolve-contract.js +31 -0
  39. package/dist/did/schemas.d.ts +112 -0
  40. package/dist/did/schemas.js +172 -0
  41. package/dist/did/types.d.ts +163 -0
  42. package/dist/did/types.js +70 -0
  43. package/dist/env/constants.d.ts +57 -0
  44. package/dist/env/constants.js +59 -0
  45. package/dist/env/index.d.ts +4 -0
  46. package/dist/env/index.js +20 -0
  47. package/dist/handshake.d.ts +158 -0
  48. package/dist/handshake.js +57 -0
  49. package/dist/index.d.ts +25 -0
  50. package/dist/index.js +56 -0
  51. package/dist/proof/index.d.ts +8 -0
  52. package/dist/proof/index.js +24 -0
  53. package/dist/proof/proof-record.d.ts +837 -0
  54. package/dist/proof/proof-record.js +133 -0
  55. package/dist/proof/signing-spec.d.ts +146 -0
  56. package/dist/proof/signing-spec.js +122 -0
  57. package/dist/proof.d.ts +415 -0
  58. package/dist/proof.js +83 -0
  59. package/dist/registry.d.ts +342 -0
  60. package/dist/registry.js +118 -0
  61. package/dist/runtime/errors.d.ts +347 -0
  62. package/dist/runtime/errors.js +119 -0
  63. package/dist/runtime/headers.d.ts +83 -0
  64. package/dist/runtime/headers.js +81 -0
  65. package/dist/runtime/index.d.ts +5 -0
  66. package/dist/runtime/index.js +21 -0
  67. package/dist/test.d.ts +251 -0
  68. package/dist/test.js +119 -0
  69. package/dist/tlkrc/index.d.ts +4 -0
  70. package/dist/tlkrc/index.js +20 -0
  71. package/dist/tlkrc/rotation.d.ts +245 -0
  72. package/dist/tlkrc/rotation.js +126 -0
  73. package/dist/tool-protection/index.d.ts +227 -0
  74. package/dist/tool-protection/index.js +113 -0
  75. package/dist/utils/validation.d.ts +30 -0
  76. package/dist/utils/validation.js +69 -0
  77. package/dist/vc/index.d.ts +7 -0
  78. package/dist/vc/index.js +23 -0
  79. package/dist/vc/schemas.d.ts +2483 -0
  80. package/dist/vc/schemas.js +224 -0
  81. package/dist/vc/statuslist.d.ts +493 -0
  82. package/dist/vc/statuslist.js +132 -0
  83. package/dist/verifier.d.ts +205 -0
  84. package/dist/verifier.js +83 -0
  85. package/dist/well-known/index.d.ts +308 -0
  86. package/dist/well-known/index.js +134 -0
  87. package/package.json +6 -1
@@ -0,0 +1,165 @@
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.object({
30
+ requestId: zod_1.z.string(),
31
+ timestamp: zod_1.z.string(),
32
+ }).optional(),
33
+ });
34
+ exports.agentShieldAPIResponseSchema = agentShieldAPIResponseSchema;
35
+ // ============================================================================
36
+ // Proof Submission Schemas
37
+ // ============================================================================
38
+ /**
39
+ * Proof submission request schema
40
+ */
41
+ exports.proofSubmissionRequestSchema = zod_1.z.object({
42
+ delegation_id: zod_1.z.string().uuid().nullable(),
43
+ session_id: zod_1.z.string().uuid(),
44
+ proofs: zod_1.z.array(proof_js_1.DetachedProofSchema).min(1),
45
+ });
46
+ /**
47
+ * Proof submission response schema
48
+ */
49
+ exports.proofSubmissionResponseSchema = zod_1.z.object({
50
+ success: zod_1.z.boolean(),
51
+ received: zod_1.z.number().int().min(0),
52
+ processed: zod_1.z.number().int().min(0),
53
+ errors: zod_1.z.array(zod_1.z.object({
54
+ proofId: zod_1.z.string(),
55
+ error: zod_1.z.string(),
56
+ })).optional(),
57
+ });
58
+ // ============================================================================
59
+ // Delegation Verification Schemas
60
+ // ============================================================================
61
+ /**
62
+ * Delegation credential schema
63
+ */
64
+ exports.delegationCredentialSchema = zod_1.z.object({
65
+ agent_did: zod_1.z.string(),
66
+ user_id: zod_1.z.string().optional(),
67
+ user_identifier: zod_1.z.string().optional(),
68
+ scopes: zod_1.z.array(zod_1.z.string()),
69
+ constraints: zod_1.z.record(zod_1.z.unknown()).optional(),
70
+ issued_at: zod_1.z.number().int().positive(),
71
+ created_at: zod_1.z.number().int().positive(),
72
+ });
73
+ /**
74
+ * Delegation verification request schema
75
+ */
76
+ exports.verifyDelegationRequestSchema = zod_1.z.object({
77
+ agent_did: zod_1.z.string(),
78
+ scopes: zod_1.z.array(zod_1.z.string()).min(1),
79
+ timestamp: zod_1.z.number().int().positive().optional(),
80
+ client_info: zod_1.z.object({
81
+ ip_address: zod_1.z.string().ip().optional(),
82
+ origin: zod_1.z.string().url().optional(),
83
+ user_agent: zod_1.z.string().optional(),
84
+ }).optional(),
85
+ });
86
+ /**
87
+ * Delegation verification response schema
88
+ */
89
+ exports.verifyDelegationResponseSchema = zod_1.z.object({
90
+ valid: zod_1.z.boolean(),
91
+ delegation: index_js_1.DelegationRecordSchema.optional(),
92
+ delegation_id: zod_1.z.string().uuid().optional(),
93
+ credential: exports.delegationCredentialSchema.optional(),
94
+ error: exports.agentShieldAPIErrorSchema.optional(),
95
+ reason: zod_1.z.string().optional(),
96
+ });
97
+ /**
98
+ * Wrapped verification response schema
99
+ */
100
+ exports.verifyDelegationAPIResponseSchema = (0, exports.agentShieldAPIResponseSchema)(exports.verifyDelegationResponseSchema);
101
+ // ============================================================================
102
+ // Tool Protection Configuration Schemas
103
+ // ============================================================================
104
+ /**
105
+ * AgentShield tool protection schema (supports both snake_case and camelCase)
106
+ * This is the API-specific format, not the MCP-I spec schema
107
+ */
108
+ exports.agentShieldToolProtectionSchema = zod_1.z.object({
109
+ scopes: zod_1.z.array(zod_1.z.string()),
110
+ requires_delegation: zod_1.z.boolean().optional(),
111
+ requiresDelegation: zod_1.z.boolean().optional(),
112
+ required_scopes: zod_1.z.array(zod_1.z.string()).optional(),
113
+ }).passthrough(); // Allow additional properties
114
+ /**
115
+ * Tool protection config response schema
116
+ */
117
+ exports.toolProtectionConfigResponseSchema = zod_1.z.object({
118
+ agent_did: zod_1.z.string(),
119
+ tools: zod_1.z.record(zod_1.z.string(), exports.agentShieldToolProtectionSchema),
120
+ reputation_threshold: zod_1.z.number().min(0).max(1).optional(),
121
+ denied_agents: zod_1.z.array(zod_1.z.string()).optional(),
122
+ });
123
+ /**
124
+ * Wrapped config response schema
125
+ */
126
+ exports.toolProtectionConfigAPIResponseSchema = (0, exports.agentShieldAPIResponseSchema)(exports.toolProtectionConfigResponseSchema);
127
+ // ============================================================================
128
+ // Delegation Management Schemas
129
+ // ============================================================================
130
+ /**
131
+ * Create delegation request schema
132
+ */
133
+ exports.createDelegationRequestSchema = zod_1.z.object({
134
+ delegation: index_js_1.DelegationRecordSchema,
135
+ });
136
+ /**
137
+ * Create delegation response schema
138
+ */
139
+ exports.createDelegationResponseSchema = zod_1.z.object({
140
+ delegation_id: zod_1.z.string().uuid(),
141
+ delegation: index_js_1.DelegationRecordSchema,
142
+ });
143
+ /**
144
+ * Wrapped creation response schema
145
+ */
146
+ exports.createDelegationAPIResponseSchema = (0, exports.agentShieldAPIResponseSchema)(exports.createDelegationResponseSchema);
147
+ /**
148
+ * Revoke delegation request schema
149
+ */
150
+ exports.revokeDelegationRequestSchema = zod_1.z.object({
151
+ reason: zod_1.z.string().optional(),
152
+ });
153
+ /**
154
+ * Revoke delegation response schema
155
+ */
156
+ exports.revokeDelegationResponseSchema = zod_1.z.object({
157
+ delegation_id: zod_1.z.string().uuid(),
158
+ revoked: zod_1.z.boolean(),
159
+ revoked_at: zod_1.z.number().int().positive(),
160
+ });
161
+ /**
162
+ * Wrapped revocation response schema
163
+ */
164
+ exports.revokeDelegationAPIResponseSchema = (0, exports.agentShieldAPIResponseSchema)(exports.revokeDelegationResponseSchema);
165
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1,168 @@
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
+ * Request body for proof submission endpoint
33
+ * POST /api/v1/bouncer/proofs
34
+ */
35
+ export interface ProofSubmissionRequest {
36
+ /** Delegation ID (null if no delegation context) */
37
+ delegation_id: string | null;
38
+ /** Session ID for grouping proofs */
39
+ session_id: string;
40
+ /** Array of proofs to submit */
41
+ proofs: DetachedProof[];
42
+ }
43
+ /**
44
+ * Response from proof submission endpoint
45
+ */
46
+ export interface ProofSubmissionResponse {
47
+ success: boolean;
48
+ received: number;
49
+ processed: number;
50
+ errors?: Array<{
51
+ proofId: string;
52
+ error: string;
53
+ }>;
54
+ }
55
+ /**
56
+ * Request body for delegation verification endpoint
57
+ * POST /api/v1/bouncer/delegations/verify
58
+ */
59
+ export interface VerifyDelegationRequest {
60
+ /** Agent DID to verify */
61
+ agent_did: string;
62
+ /** Required scopes */
63
+ scopes: string[];
64
+ /** Optional timestamp for verification */
65
+ timestamp?: number;
66
+ /** Optional client info for IP/origin checking */
67
+ client_info?: {
68
+ ip_address?: string;
69
+ origin?: string;
70
+ user_agent?: string;
71
+ };
72
+ }
73
+ /**
74
+ * Credential information returned in verification response
75
+ */
76
+ export interface DelegationCredential {
77
+ agent_did: string;
78
+ user_id?: string;
79
+ user_identifier?: string;
80
+ scopes: string[];
81
+ constraints?: Record<string, unknown>;
82
+ issued_at: number;
83
+ created_at: number;
84
+ }
85
+ /**
86
+ * Response from delegation verification endpoint
87
+ */
88
+ export interface VerifyDelegationResponse {
89
+ valid: boolean;
90
+ delegation?: DelegationRecord;
91
+ delegation_id?: string;
92
+ credential?: DelegationCredential;
93
+ error?: AgentShieldAPIErrorResponse;
94
+ reason?: string;
95
+ }
96
+ /**
97
+ * Wrapped verification response (AgentShield wraps in success/data)
98
+ */
99
+ export type VerifyDelegationAPIResponse = AgentShieldAPIResponse<VerifyDelegationResponse>;
100
+ /**
101
+ * AgentShield API tool protection format for a single tool
102
+ * This is the API-specific format, not the MCP-I spec type
103
+ */
104
+ export interface AgentShieldToolProtection {
105
+ scopes: string[];
106
+ requires_delegation?: boolean;
107
+ requiresDelegation?: boolean;
108
+ required_scopes?: string[];
109
+ }
110
+ /**
111
+ * Response from tool protection config endpoint
112
+ * GET /api/v1/bouncer/config/{projectId}
113
+ */
114
+ export interface ToolProtectionConfigResponse {
115
+ agent_did: string;
116
+ tools: Record<string, AgentShieldToolProtection>;
117
+ reputation_threshold?: number;
118
+ denied_agents?: string[];
119
+ }
120
+ /**
121
+ * Wrapped config response
122
+ */
123
+ export type ToolProtectionConfigAPIResponse = AgentShieldAPIResponse<ToolProtectionConfigResponse>;
124
+ /**
125
+ * Request body for creating a delegation
126
+ * POST /api/v1/bouncer/delegations
127
+ */
128
+ export interface CreateDelegationRequest {
129
+ delegation: DelegationRecord;
130
+ }
131
+ /**
132
+ * Response from delegation creation endpoint
133
+ */
134
+ export interface CreateDelegationResponse {
135
+ delegation_id: string;
136
+ delegation: DelegationRecord;
137
+ }
138
+ /**
139
+ * Wrapped creation response
140
+ */
141
+ export type CreateDelegationAPIResponse = AgentShieldAPIResponse<CreateDelegationResponse>;
142
+ /**
143
+ * Request body for revoking a delegation
144
+ * POST /api/v1/bouncer/delegations/{id}/revoke
145
+ */
146
+ export interface RevokeDelegationRequest {
147
+ reason?: string;
148
+ }
149
+ /**
150
+ * Response from delegation revocation endpoint
151
+ */
152
+ export interface RevokeDelegationResponse {
153
+ delegation_id: string;
154
+ revoked: boolean;
155
+ revoked_at: number;
156
+ }
157
+ /**
158
+ * Wrapped revocation response
159
+ */
160
+ export type RevokeDelegationAPIResponse = AgentShieldAPIResponse<RevokeDelegationResponse>;
161
+ /**
162
+ * AgentShield API error class
163
+ */
164
+ export declare class AgentShieldAPIError extends Error {
165
+ readonly code: string;
166
+ readonly details?: Record<string, unknown> | undefined;
167
+ constructor(code: string, message: string, details?: Record<string, unknown> | undefined);
168
+ }
@@ -0,0 +1,27 @@
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;
27
+ //# sourceMappingURL=types.js.map