@kya-os/contracts 1.0.0-alpha

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.
@@ -0,0 +1,63 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Verifier middleware schemas and headers
4
+ */
5
+ export const AgentContextSchema = z.object({
6
+ did: z.string().min(1),
7
+ keyId: z.string().min(1),
8
+ subject: z.string().optional(),
9
+ scopes: z.array(z.string()).default([]),
10
+ session: z.string().min(1),
11
+ confidence: z.literal("verified"),
12
+ delegationRef: z.string().optional(),
13
+ registry: z.string().url(),
14
+ verifiedAt: z.number().int().positive(),
15
+ });
16
+ export const VerifierResultSchema = z.object({
17
+ success: z.boolean(),
18
+ headers: z.record(z.string()).optional(),
19
+ error: z
20
+ .object({
21
+ code: z.string(),
22
+ message: z.string(),
23
+ details: z.any().optional(),
24
+ httpStatus: z.number().int().min(400).max(599),
25
+ })
26
+ .optional(),
27
+ });
28
+ export const StructuredErrorSchema = z.object({
29
+ code: z.string(),
30
+ message: z.string(),
31
+ details: z
32
+ .object({
33
+ reason: z.string().optional(),
34
+ expected: z.any().optional(),
35
+ received: z.any().optional(),
36
+ remediation: z.string().optional(),
37
+ })
38
+ .optional(),
39
+ });
40
+ // Header constants (frozen names)
41
+ export const AGENT_HEADERS = {
42
+ DID: "X-Agent-DID",
43
+ KEY_ID: "X-Agent-KeyId",
44
+ SUBJECT: "X-Agent-Subject",
45
+ SCOPES: "X-Agent-Scopes",
46
+ SESSION: "X-Agent-Session",
47
+ CONFIDENCE: "X-Agent-Confidence",
48
+ DELEGATION_REF: "X-Agent-Delegation-Ref",
49
+ REGISTRY: "X-Agent-Registry",
50
+ VERIFIED_AT: "X-Agent-Verified-At",
51
+ };
52
+ // HTTP status mappings
53
+ export const ERROR_HTTP_STATUS = {
54
+ XMCP_I_EBADPROOF: 403,
55
+ XMCP_I_ENOIDENTITY: 500,
56
+ XMCP_I_EMIRRORPENDING: 200,
57
+ XMCP_I_EHAN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AG;IACvB,qBAAqB,EAAE,GAAG;IAC1B,iBAAiB,EAAE,GAAG;IACtB,eAAe,EAAE,GAAG;IACpB,aAAa,EAAE,GAAG;IAClB,cAAc,EAAE,GAAG;IACnB,eAAe,EAAE,GAAG;CACZ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@kya-os/contracts",
3
+ "version": "1.0.0-alpha",
4
+ "description": "Shared types and schemas for XMCP-I ecosystem",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./handshake": {
15
+ "types": "./dist/handshake.d.ts",
16
+ "import": "./dist/handshake.js"
17
+ },
18
+ "./proof": {
19
+ "types": "./dist/proof.d.ts",
20
+ "import": "./dist/proof.js"
21
+ },
22
+ "./verifier": {
23
+ "types": "./dist/verifier.d.ts",
24
+ "import": "./dist/verifier.js"
25
+ },
26
+ "./registry": {
27
+ "types": "./dist/registry.d.ts",
28
+ "import": "./dist/registry.js"
29
+ },
30
+ "./cli": {
31
+ "types": "./dist/cli.d.ts",
32
+ "import": "./dist/cli.js"
33
+ },
34
+ "./test": {
35
+ "types": "./dist/test.d.ts",
36
+ "import": "./dist/test.js"
37
+ },
38
+ "./schemas/*": "./schemas/*"
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "schemas",
43
+ "README.md"
44
+ ],
45
+ "scripts": {
46
+ "build": "tsc -p tsconfig.build.json",
47
+ "clean": "rm -rf dist",
48
+ "dev": "tsc -p tsconfig.build.json --watch",
49
+ "type-check": "tsc --noEmit"
50
+ },
51
+ "devDependencies": {
52
+ "@types/node": "^20.0.0",
53
+ "typescript": "^5.0.0"
54
+ },
55
+ "dependencies": {
56
+ "zod": "^3.22.0"
57
+ },
58
+ "keywords": [
59
+ "xmcp",
60
+ "mcp",
61
+ "identity",
62
+ "types",
63
+ "contracts"
64
+ ],
65
+ "author": "KYA OS",
66
+ "license": "MIT",
67
+ "repository": {
68
+ "type": "git",
69
+ "url": "https://github.com/kya-os/xmcp-i.git",
70
+ "directory": "packages/contracts"
71
+ }
72
+ }
@@ -0,0 +1,69 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://schemas.kya-os.com/xmcp-i/cli/register-output/v1.0.0",
4
+ "title": "XMCP-I CLI Register Output",
5
+ "description": "Schema for xmcpi register command JSON output",
6
+ "type": "object",
7
+ "properties": {
8
+ "agentDID": {
9
+ "type": "string",
10
+ "description": "Agent DID",
11
+ "minLength": 1
12
+ },
13
+ "agentURL": {
14
+ "type": "string",
15
+ "format": "uri",
16
+ "description": "Agent URL"
17
+ },
18
+ "agentId": {
19
+ "type": "string",
20
+ "description": "Agent identifier",
21
+ "minLength": 1
22
+ },
23
+ "agentSlug": {
24
+ "type": "string",
25
+ "description": "Agent slug",
26
+ "minLength": 1
27
+ },
28
+ "claimURL": {
29
+ "type": "string",
30
+ "format": "uri",
31
+ "description": "Claim URL (when draft)"
32
+ },
33
+ "verificationEndpoint": {
34
+ "type": "string",
35
+ "format": "uri",
36
+ "description": "Verification endpoint URL"
37
+ },
38
+ "conformanceCapabilities": {
39
+ "type": "array",
40
+ "items": {
41
+ "type": "string",
42
+ "enum": ["handshake", "signing", "verification"]
43
+ },
44
+ "minItems": 3,
45
+ "maxItems": 3,
46
+ "description": "Exactly the three MCP-I capabilities"
47
+ },
48
+ "mirrorStatus": {
49
+ "type": "string",
50
+ "enum": ["pending", "success", "error"],
51
+ "description": "MCP Registry mirror status"
52
+ },
53
+ "mirrorLink": {
54
+ "type": "string",
55
+ "format": "uri",
56
+ "description": "MCP Registry mirror link"
57
+ }
58
+ },
59
+ "required": [
60
+ "agentDID",
61
+ "agentURL",
62
+ "agentId",
63
+ "agentSlug",
64
+ "verificationEndpoint",
65
+ "conformanceCapabilities",
66
+ "mirrorStatus"
67
+ ],
68
+ "additionalProperties": false
69
+ }
@@ -0,0 +1,80 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://schemas.kya-os.com/xmcp-i/proof/v1.0.0",
4
+ "title": "XMCP-I Detached Proof",
5
+ "description": "Schema for detached proofs in XMCP-I protocol",
6
+ "type": "object",
7
+ "properties": {
8
+ "jws": {
9
+ "type": "string",
10
+ "description": "Compact JWS format detached signature",
11
+ "minLength": 1
12
+ },
13
+ "meta": {
14
+ "type": "object",
15
+ "properties": {
16
+ "did": {
17
+ "type": "string",
18
+ "description": "Agent DID",
19
+ "minLength": 1
20
+ },
21
+ "kid": {
22
+ "type": "string",
23
+ "description": "Key identifier",
24
+ "minLength": 1
25
+ },
26
+ "ts": {
27
+ "type": "integer",
28
+ "description": "Unix timestamp",
29
+ "minimum": 1
30
+ },
31
+ "nonce": {
32
+ "type": "string",
33
+ "description": "Session nonce",
34
+ "minLength": 1
35
+ },
36
+ "audience": {
37
+ "type": "string",
38
+ "description": "Intended audience",
39
+ "minLength": 1
40
+ },
41
+ "sessionId": {
42
+ "type": "string",
43
+ "description": "Session identifier",
44
+ "minLength": 1
45
+ },
46
+ "requestHash": {
47
+ "type": "string",
48
+ "pattern": "^sha256:[a-f0-9]{64}$",
49
+ "description": "SHA-256 hash of canonical request"
50
+ },
51
+ "responseHash": {
52
+ "type": "string",
53
+ "pattern": "^sha256:[a-f0-9]{64}$",
54
+ "description": "SHA-256 hash of canonical response"
55
+ },
56
+ "scopeId": {
57
+ "type": "string",
58
+ "description": "Optional scope identifier"
59
+ },
60
+ "delegationRef": {
61
+ "type": "string",
62
+ "description": "Optional delegation reference"
63
+ }
64
+ },
65
+ "required": [
66
+ "did",
67
+ "kid",
68
+ "ts",
69
+ "nonce",
70
+ "audience",
71
+ "sessionId",
72
+ "requestHash",
73
+ "responseHash"
74
+ ],
75
+ "additionalProperties": false
76
+ }
77
+ },
78
+ "required": ["jws", "meta"],
79
+ "additionalProperties": false
80
+ }
@@ -0,0 +1,60 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://schemas.kya.dev/xmcpi/receipt/v1.0.0.json",
4
+ "title": "XMCP-I Receipt",
5
+ "description": "Receipt object returned by KTA for verifiable operations",
6
+ "type": "object",
7
+ "properties": {
8
+ "$schema": {
9
+ "type": "string",
10
+ "const": "https://schemas.kya.dev/xmcpi/receipt/v1.0.0.json"
11
+ },
12
+ "ref": {
13
+ "type": "string",
14
+ "minLength": 1,
15
+ "description": "Unique reference identifier for the receipt"
16
+ },
17
+ "contentHash": {
18
+ "type": "string",
19
+ "pattern": "^sha256:[a-f0-9]{64}$",
20
+ "description": "SHA-256 hash of the content with sha256: prefix"
21
+ },
22
+ "action": {
23
+ "type": "string",
24
+ "enum": ["issue", "revoke"],
25
+ "description": "The action performed (issue or revoke)"
26
+ },
27
+ "ts": {
28
+ "type": "integer",
29
+ "minimum": 1,
30
+ "description": "Unix timestamp when the action was performed"
31
+ },
32
+ "logIndex": {
33
+ "type": "integer",
34
+ "minimum": 0,
35
+ "description": "Index in the KTA log for this receipt"
36
+ },
37
+ "logRoot": {
38
+ "type": "string",
39
+ "minLength": 1,
40
+ "description": "Merkle log root hash for verification"
41
+ },
42
+ "inclusionProof": {
43
+ "type": "array",
44
+ "items": {
45
+ "type": "string"
46
+ },
47
+ "description": "Merkle inclusion proof for verifying the receipt against the log root"
48
+ }
49
+ },
50
+ "required": [
51
+ "ref",
52
+ "contentHash",
53
+ "action",
54
+ "ts",
55
+ "logIndex",
56
+ "logRoot",
57
+ "inclusionProof"
58
+ ],
59
+ "additionalProperties": false
60
+ }
@@ -0,0 +1,94 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://schemas.kya-os.com/xmcp-i/verifier/verify-page/v1.0.0",
4
+ "title": "XMCP-I Verify Page Payload",
5
+ "description": "Schema for /verify debug page payload",
6
+ "type": "object",
7
+ "properties": {
8
+ "canonicalHashes": {
9
+ "type": "object",
10
+ "properties": {
11
+ "requestHash": {
12
+ "type": "string",
13
+ "pattern": "^sha256:[a-f0-9]{64}$",
14
+ "description": "SHA-256 hash of canonical request"
15
+ },
16
+ "responseHash": {
17
+ "type": "string",
18
+ "pattern": "^sha256:[a-f0-9]{64}$",
19
+ "description": "SHA-256 hash of canonical response"
20
+ }
21
+ },
22
+ "required": ["requestHash", "responseHash"],
23
+ "additionalProperties": false
24
+ },
25
+ "proof": {
26
+ "type": "object",
27
+ "properties": {
28
+ "jws": {
29
+ "type": "string",
30
+ "description": "Compact JWS format detached signature",
31
+ "minLength": 1
32
+ },
33
+ "meta": {
34
+ "$ref": "https://schemas.kya-os.com/xmcp-i/proof/v1.0.0#/properties/meta"
35
+ }
36
+ },
37
+ "required": ["jws", "meta"],
38
+ "additionalProperties": false
39
+ },
40
+ "didDocumentLink": {
41
+ "type": "string",
42
+ "format": "uri",
43
+ "description": "Link to DID document"
44
+ },
45
+ "ktaURL": {
46
+ "type": "string",
47
+ "format": "uri",
48
+ "description": "Know-That-AI URL"
49
+ },
50
+ "mcpMirrorStatus": {
51
+ "type": "string",
52
+ "enum": ["pending", "success", "error"],
53
+ "description": "MCP Registry mirror status"
54
+ },
55
+ "protocolCapabilities": {
56
+ "type": "array",
57
+ "items": {
58
+ "type": "string",
59
+ "enum": ["handshake", "signing", "verification"]
60
+ },
61
+ "minItems": 3,
62
+ "maxItems": 3,
63
+ "description": "Advertised protocol capabilities"
64
+ },
65
+ "localVerificationResult": {
66
+ "type": "object",
67
+ "properties": {
68
+ "valid": {
69
+ "type": "boolean",
70
+ "description": "Local verification result"
71
+ },
72
+ "errors": {
73
+ "type": "array",
74
+ "items": {
75
+ "type": "string"
76
+ },
77
+ "description": "Validation errors if any"
78
+ }
79
+ },
80
+ "required": ["valid"],
81
+ "additionalProperties": false
82
+ }
83
+ },
84
+ "required": [
85
+ "canonicalHashes",
86
+ "proof",
87
+ "didDocumentLink",
88
+ "ktaURL",
89
+ "mcpMirrorStatus",
90
+ "protocolCapabilities",
91
+ "localVerificationResult"
92
+ ],
93
+ "additionalProperties": false
94
+ }
@@ -0,0 +1,49 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://schemas.kya-os.com/xmcp-i/well-known/agent/v1.0.0",
4
+ "title": "XMCP-I Agent Well-Known Document",
5
+ "description": "Schema for /.well-known/agent.json endpoint",
6
+ "type": "object",
7
+ "properties": {
8
+ "id": {
9
+ "type": "string",
10
+ "description": "Agent DID",
11
+ "minLength": 1
12
+ },
13
+ "capabilities": {
14
+ "type": "object",
15
+ "properties": {
16
+ "mcp-i": {
17
+ "type": "array",
18
+ "items": {
19
+ "type": "string",
20
+ "enum": ["handshake", "signing", "verification"]
21
+ },
22
+ "minItems": 3,
23
+ "maxItems": 3,
24
+ "description": "Exactly the three MCP-I capabilities"
25
+ }
26
+ },
27
+ "required": ["mcp-i"],
28
+ "additionalProperties": true
29
+ },
30
+ "registry": {
31
+ "type": "object",
32
+ "properties": {
33
+ "kta": {
34
+ "type": "string",
35
+ "format": "uri",
36
+ "description": "Know-That-AI registry URL"
37
+ },
38
+ "mcp": {
39
+ "type": "string",
40
+ "format": "uri",
41
+ "description": "MCP Registry URL"
42
+ }
43
+ },
44
+ "additionalProperties": true
45
+ }
46
+ },
47
+ "required": ["id", "capabilities"],
48
+ "additionalProperties": true
49
+ }