@kya-os/contracts 1.7.25 → 1.7.31
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/agent-deployment-utils.d.ts +62 -0
- package/dist/agent-deployment-utils.js +92 -0
- package/dist/agent-deployment.d.ts +723 -0
- package/dist/agent-deployment.js +270 -0
- package/dist/agentshield-api/admin-schemas.d.ts +2 -2
- package/dist/agentshield-api/schemas.d.ts +413 -413
- package/dist/audit/index.d.ts +4 -4
- package/dist/cli.d.ts +42 -42
- package/dist/compute-binding.d.ts +48 -0
- package/dist/compute-binding.js +42 -0
- package/dist/compute.d.ts +443 -0
- package/dist/compute.js +190 -0
- package/dist/config/identity.d.ts +98 -98
- package/dist/consent/schemas.d.ts +118 -118
- package/dist/dashboard-config/schemas.d.ts +1241 -1241
- package/dist/delegation/constraints.d.ts +32 -32
- package/dist/delegation/schemas.d.ts +588 -588
- package/dist/deploy/schemas.d.ts +127 -127
- package/dist/deploy/schemas.js +1 -0
- package/dist/deploy/types.d.ts +1 -1
- package/dist/gateway/agents.d.ts +21 -0
- package/dist/gateway/agents.js +12 -0
- package/dist/gateway/cron.d.ts +33 -0
- package/dist/gateway/cron.js +16 -0
- package/dist/gateway/index.d.ts +20 -0
- package/dist/gateway/index.js +37 -0
- package/dist/gateway/sessions.d.ts +30 -0
- package/dist/gateway/sessions.js +15 -0
- package/dist/gateway/skills.d.ts +445 -0
- package/dist/gateway/skills.js +47 -0
- package/dist/gateway/usage.d.ts +43 -0
- package/dist/gateway/usage.js +18 -0
- package/dist/handshake.d.ts +56 -56
- package/dist/identity/schemas.d.ts +8 -8
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/molti/admin-ws.d.ts +60 -60
- package/dist/molti/schemas.d.ts +30 -30
- package/dist/pairing/index.d.ts +44 -0
- package/dist/pairing/index.js +11 -0
- package/dist/policy/schemas.d.ts +671 -671
- package/dist/proof/proof-record.d.ts +36 -36
- package/dist/proof/signing-spec.d.ts +8 -8
- package/dist/proof.d.ts +68 -68
- package/dist/registry.d.ts +42 -42
- package/dist/reputation/api.d.ts +150 -150
- package/dist/reputation/credentials.d.ts +12 -12
- package/dist/reputation/schemas.d.ts +48 -48
- package/dist/test.d.ts +22 -22
- package/dist/tlkrc/rotation.d.ts +12 -12
- package/dist/tool-protection/index.d.ts +20 -20
- package/dist/verifier.d.ts +21 -21
- package/dist/well-known/index.d.ts +68 -68
- package/package.json +25 -5
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Managed Agent Deployment Utilities
|
|
3
|
+
*
|
|
4
|
+
* Crypto-dependent functions (didToSlug, didToFlyApp) isolated here
|
|
5
|
+
* to keep the main schema module (agent-deployment.ts) free of Node.js
|
|
6
|
+
* dependencies. This ensures pure Zod schemas like DidStringSchema and
|
|
7
|
+
* FlyRegionSchema remain portable across all runtimes.
|
|
8
|
+
*
|
|
9
|
+
* **Node.js only** — uses `crypto.createHash`. See JSDoc on each function.
|
|
10
|
+
*
|
|
11
|
+
* @package @kya-os/contracts/agent-deployment
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Derive a short, deterministic, DNS-safe slug from an agent DID.
|
|
15
|
+
*
|
|
16
|
+
* Format: "kya-{first 16 chars of SHA-256 hex}"
|
|
17
|
+
* Example: did:key:z6MkhaXg... -> "kya-a3f2b1c9d4e5f6a7"
|
|
18
|
+
*
|
|
19
|
+
* Collision probability: ~1 in 4.3 billion (16 hex chars = 64 bits, birthday bound).
|
|
20
|
+
* Safe for millions of agents.
|
|
21
|
+
*
|
|
22
|
+
* **Note**: Uses Node.js `crypto.createHash` intentionally. This function runs
|
|
23
|
+
* server-side only (AgentShield + deploy services), never in browser or edge runtimes.
|
|
24
|
+
* If edge support is needed in the future, swap to Web Crypto `subtle.digest`.
|
|
25
|
+
*
|
|
26
|
+
* @param did - The agent DID string (must start with "did:")
|
|
27
|
+
* @returns DNS-safe slug matching /^kya-[a-f0-9]{16}$/ (20 chars total)
|
|
28
|
+
* @throws {Error} If `did` is empty or does not start with "did:"
|
|
29
|
+
*/
|
|
30
|
+
export declare function didToSlug(did: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Derive Fly app name from agent DID.
|
|
33
|
+
* Fly app names must be: lowercase, alphanumeric + hyphens, 1-30 chars.
|
|
34
|
+
* Our slugs are 20 chars — well within the limit.
|
|
35
|
+
*
|
|
36
|
+
* **Note**: Uses Node.js `crypto.createHash` via `didToSlug`. See `didToSlug` JSDoc
|
|
37
|
+
* for portability notes.
|
|
38
|
+
*
|
|
39
|
+
* @param did - The agent DID string (must start with "did:")
|
|
40
|
+
* @throws {Error} If `did` is empty or does not start with "did:"
|
|
41
|
+
*/
|
|
42
|
+
export declare function didToFlyApp(did: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* Derive a readable, DNS-safe Fly app name from an agent name + DID.
|
|
45
|
+
*
|
|
46
|
+
* Format: "kya-{name[:19]}-{first 6 hex chars of SHA-256 of DID}"
|
|
47
|
+
* Example: ("researcher", "did:key:z6Mk...") → "kya-researcher-a3f2b1"
|
|
48
|
+
*
|
|
49
|
+
* Constraints:
|
|
50
|
+
* "kya-" (4) + name[:19] (≤19) + "-" (1) + hash[:6] (6) = ≤30 chars
|
|
51
|
+
* Fly app name hard limit: 30 chars ✓
|
|
52
|
+
*
|
|
53
|
+
* Uniqueness: 6 hex chars = 24 bits → birthday collision at ~4,096 agents
|
|
54
|
+
* sharing the exact same human name. Safe for production scale.
|
|
55
|
+
*
|
|
56
|
+
* Node.js only — same crypto constraint as didToSlug.
|
|
57
|
+
*
|
|
58
|
+
* @param name - Human-readable agent name from the deploy request
|
|
59
|
+
* @param did - The agent DID string (must start with "did:")
|
|
60
|
+
* @throws {Error} If DID is invalid or name sanitizes to empty string
|
|
61
|
+
*/
|
|
62
|
+
export declare function nameToFlySlug(name: string, did: string): string;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Managed Agent Deployment Utilities
|
|
4
|
+
*
|
|
5
|
+
* Crypto-dependent functions (didToSlug, didToFlyApp) isolated here
|
|
6
|
+
* to keep the main schema module (agent-deployment.ts) free of Node.js
|
|
7
|
+
* dependencies. This ensures pure Zod schemas like DidStringSchema and
|
|
8
|
+
* FlyRegionSchema remain portable across all runtimes.
|
|
9
|
+
*
|
|
10
|
+
* **Node.js only** — uses `crypto.createHash`. See JSDoc on each function.
|
|
11
|
+
*
|
|
12
|
+
* @package @kya-os/contracts/agent-deployment
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.didToSlug = didToSlug;
|
|
16
|
+
exports.didToFlyApp = didToFlyApp;
|
|
17
|
+
exports.nameToFlySlug = nameToFlySlug;
|
|
18
|
+
const crypto_1 = require("crypto");
|
|
19
|
+
/**
|
|
20
|
+
* Derive a short, deterministic, DNS-safe slug from an agent DID.
|
|
21
|
+
*
|
|
22
|
+
* Format: "kya-{first 16 chars of SHA-256 hex}"
|
|
23
|
+
* Example: did:key:z6MkhaXg... -> "kya-a3f2b1c9d4e5f6a7"
|
|
24
|
+
*
|
|
25
|
+
* Collision probability: ~1 in 4.3 billion (16 hex chars = 64 bits, birthday bound).
|
|
26
|
+
* Safe for millions of agents.
|
|
27
|
+
*
|
|
28
|
+
* **Note**: Uses Node.js `crypto.createHash` intentionally. This function runs
|
|
29
|
+
* server-side only (AgentShield + deploy services), never in browser or edge runtimes.
|
|
30
|
+
* If edge support is needed in the future, swap to Web Crypto `subtle.digest`.
|
|
31
|
+
*
|
|
32
|
+
* @param did - The agent DID string (must start with "did:")
|
|
33
|
+
* @returns DNS-safe slug matching /^kya-[a-f0-9]{16}$/ (20 chars total)
|
|
34
|
+
* @throws {Error} If `did` is empty or does not start with "did:"
|
|
35
|
+
*/
|
|
36
|
+
function didToSlug(did) {
|
|
37
|
+
if (!did || typeof did !== "string" || !did.startsWith("did:")) {
|
|
38
|
+
throw new Error('didToSlug: expected a valid DID string starting with "did:"');
|
|
39
|
+
}
|
|
40
|
+
const hash = (0, crypto_1.createHash)("sha256").update(did).digest("hex");
|
|
41
|
+
return `kya-${hash.substring(0, 16)}`;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Derive Fly app name from agent DID.
|
|
45
|
+
* Fly app names must be: lowercase, alphanumeric + hyphens, 1-30 chars.
|
|
46
|
+
* Our slugs are 20 chars — well within the limit.
|
|
47
|
+
*
|
|
48
|
+
* **Note**: Uses Node.js `crypto.createHash` via `didToSlug`. See `didToSlug` JSDoc
|
|
49
|
+
* for portability notes.
|
|
50
|
+
*
|
|
51
|
+
* @param did - The agent DID string (must start with "did:")
|
|
52
|
+
* @throws {Error} If `did` is empty or does not start with "did:"
|
|
53
|
+
*/
|
|
54
|
+
function didToFlyApp(did) {
|
|
55
|
+
return didToSlug(did);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Derive a readable, DNS-safe Fly app name from an agent name + DID.
|
|
59
|
+
*
|
|
60
|
+
* Format: "kya-{name[:19]}-{first 6 hex chars of SHA-256 of DID}"
|
|
61
|
+
* Example: ("researcher", "did:key:z6Mk...") → "kya-researcher-a3f2b1"
|
|
62
|
+
*
|
|
63
|
+
* Constraints:
|
|
64
|
+
* "kya-" (4) + name[:19] (≤19) + "-" (1) + hash[:6] (6) = ≤30 chars
|
|
65
|
+
* Fly app name hard limit: 30 chars ✓
|
|
66
|
+
*
|
|
67
|
+
* Uniqueness: 6 hex chars = 24 bits → birthday collision at ~4,096 agents
|
|
68
|
+
* sharing the exact same human name. Safe for production scale.
|
|
69
|
+
*
|
|
70
|
+
* Node.js only — same crypto constraint as didToSlug.
|
|
71
|
+
*
|
|
72
|
+
* @param name - Human-readable agent name from the deploy request
|
|
73
|
+
* @param did - The agent DID string (must start with "did:")
|
|
74
|
+
* @throws {Error} If DID is invalid or name sanitizes to empty string
|
|
75
|
+
*/
|
|
76
|
+
function nameToFlySlug(name, did) {
|
|
77
|
+
if (!did || typeof did !== "string" || !did.startsWith("did:")) {
|
|
78
|
+
throw new Error('nameToFlySlug: expected a valid DID string starting with "did:"');
|
|
79
|
+
}
|
|
80
|
+
const hash = (0, crypto_1.createHash)("sha256").update(did).digest("hex").substring(0, 6);
|
|
81
|
+
const slug = name
|
|
82
|
+
.toLowerCase()
|
|
83
|
+
.replace(/[^a-z0-9-]/g, "-") // non-alphanumeric → hyphen
|
|
84
|
+
.replace(/-{2,}/g, "-") // collapse consecutive hyphens
|
|
85
|
+
.replace(/^-+|-+$/g, "") // strip leading/trailing hyphens
|
|
86
|
+
.substring(0, 19)
|
|
87
|
+
.replace(/-+$/, ""); // strip trailing hyphens after truncation
|
|
88
|
+
if (!slug) {
|
|
89
|
+
throw new Error("nameToFlySlug: name sanitized to empty string");
|
|
90
|
+
}
|
|
91
|
+
return `kya-${slug}-${hash}`;
|
|
92
|
+
}
|