@kya-os/contracts 1.8.1 → 1.9.1
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/schemas.d.ts +7 -0
- package/dist/compute.d.ts +31 -0
- package/dist/compute.js +23 -0
- package/dist/handshake.d.ts +4 -3
- package/dist/handshake.js +4 -3
- package/dist/proof/index.d.ts +3 -3
- package/dist/proof/index.js +2 -1
- package/dist/proof.d.ts +32 -0
- package/dist/proof.js +29 -1
- package/dist/reputation/index.d.ts +1 -0
- package/dist/reputation/index.js +2 -0
- package/dist/reputation/interactions.d.ts +146 -0
- package/dist/reputation/interactions.js +82 -0
- package/dist/runtime/headers.d.ts +16 -12
- package/dist/runtime/headers.js +16 -12
- package/dist/verifier.d.ts +20 -9
- package/dist/verifier.js +20 -9
- package/package.json +2 -1
- package/parity-vectors/delegation-conformance.json +265 -0
- package/parity-vectors/did-key.json +134 -0
- package/parity-vectors/index.ts +253 -0
- package/parity-vectors/scope-matching.json +330 -0
- package/parity-vectors/vc-jwt.json +210 -0
|
@@ -83,6 +83,7 @@ export declare const proofSubmissionRequestSchema: z.ZodObject<{
|
|
|
83
83
|
sessionId: z.ZodString;
|
|
84
84
|
requestHash: z.ZodString;
|
|
85
85
|
responseHash: z.ZodString;
|
|
86
|
+
outcome: z.ZodOptional<z.ZodEnum<["allowed", "denied", "step_up_required", "needs_authorization"]>>;
|
|
86
87
|
scopeId: z.ZodOptional<z.ZodString>;
|
|
87
88
|
delegationRef: z.ZodOptional<z.ZodString>;
|
|
88
89
|
clientDid: z.ZodOptional<z.ZodString>;
|
|
@@ -97,6 +98,7 @@ export declare const proofSubmissionRequestSchema: z.ZodObject<{
|
|
|
97
98
|
responseHash: string;
|
|
98
99
|
clientDid?: string | undefined;
|
|
99
100
|
delegationRef?: string | undefined;
|
|
101
|
+
outcome?: "allowed" | "denied" | "step_up_required" | "needs_authorization" | undefined;
|
|
100
102
|
scopeId?: string | undefined;
|
|
101
103
|
}, {
|
|
102
104
|
did: string;
|
|
@@ -109,6 +111,7 @@ export declare const proofSubmissionRequestSchema: z.ZodObject<{
|
|
|
109
111
|
responseHash: string;
|
|
110
112
|
clientDid?: string | undefined;
|
|
111
113
|
delegationRef?: string | undefined;
|
|
114
|
+
outcome?: "allowed" | "denied" | "step_up_required" | "needs_authorization" | undefined;
|
|
112
115
|
scopeId?: string | undefined;
|
|
113
116
|
}>;
|
|
114
117
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -124,6 +127,7 @@ export declare const proofSubmissionRequestSchema: z.ZodObject<{
|
|
|
124
127
|
responseHash: string;
|
|
125
128
|
clientDid?: string | undefined;
|
|
126
129
|
delegationRef?: string | undefined;
|
|
130
|
+
outcome?: "allowed" | "denied" | "step_up_required" | "needs_authorization" | undefined;
|
|
127
131
|
scopeId?: string | undefined;
|
|
128
132
|
};
|
|
129
133
|
}, {
|
|
@@ -139,6 +143,7 @@ export declare const proofSubmissionRequestSchema: z.ZodObject<{
|
|
|
139
143
|
responseHash: string;
|
|
140
144
|
clientDid?: string | undefined;
|
|
141
145
|
delegationRef?: string | undefined;
|
|
146
|
+
outcome?: "allowed" | "denied" | "step_up_required" | "needs_authorization" | undefined;
|
|
142
147
|
scopeId?: string | undefined;
|
|
143
148
|
};
|
|
144
149
|
}>, "many">;
|
|
@@ -286,6 +291,7 @@ export declare const proofSubmissionRequestSchema: z.ZodObject<{
|
|
|
286
291
|
responseHash: string;
|
|
287
292
|
clientDid?: string | undefined;
|
|
288
293
|
delegationRef?: string | undefined;
|
|
294
|
+
outcome?: "allowed" | "denied" | "step_up_required" | "needs_authorization" | undefined;
|
|
289
295
|
scopeId?: string | undefined;
|
|
290
296
|
};
|
|
291
297
|
}[];
|
|
@@ -332,6 +338,7 @@ export declare const proofSubmissionRequestSchema: z.ZodObject<{
|
|
|
332
338
|
responseHash: string;
|
|
333
339
|
clientDid?: string | undefined;
|
|
334
340
|
delegationRef?: string | undefined;
|
|
341
|
+
outcome?: "allowed" | "denied" | "step_up_required" | "needs_authorization" | undefined;
|
|
335
342
|
scopeId?: string | undefined;
|
|
336
343
|
};
|
|
337
344
|
}[];
|
package/dist/compute.d.ts
CHANGED
|
@@ -335,19 +335,45 @@ export declare const ConfigBundleSchema: z.ZodObject<{
|
|
|
335
335
|
aiProvider: z.ZodObject<{
|
|
336
336
|
type: z.ZodEnum<["anthropic", "openai"]>;
|
|
337
337
|
apiKey: z.ZodString;
|
|
338
|
+
/**
|
|
339
|
+
* Optional base URL override. When set, OpenClaw routes all provider
|
|
340
|
+
* traffic through this URL instead of the provider's default endpoint.
|
|
341
|
+
* Used by managed deployments where AgentShield issues a per-deployment
|
|
342
|
+
* gateway token and proxies to the upstream provider with budget tracking.
|
|
343
|
+
*/
|
|
344
|
+
baseUrl: z.ZodOptional<z.ZodString>;
|
|
338
345
|
}, "strip", z.ZodTypeAny, {
|
|
339
346
|
type: "anthropic" | "openai";
|
|
340
347
|
apiKey: string;
|
|
348
|
+
baseUrl?: string | undefined;
|
|
341
349
|
}, {
|
|
342
350
|
type: "anthropic" | "openai";
|
|
343
351
|
apiKey: string;
|
|
352
|
+
baseUrl?: string | undefined;
|
|
344
353
|
}>;
|
|
354
|
+
/**
|
|
355
|
+
* Optional OpenClaw heartbeat interval (`agents.defaults.heartbeat.every`).
|
|
356
|
+
* Drives how often OpenClaw wakes the agent for HEARTBEAT.md processing —
|
|
357
|
+
* the primary token-cost lever. Examples: "30m" (active), "6h" (idle),
|
|
358
|
+
* "off" (dormant — heartbeat disabled entirely). When absent, the patcher
|
|
359
|
+
* preserves whatever value already lives in openclaw.json (OpenClaw's
|
|
360
|
+
* built-in default of "30m").
|
|
361
|
+
*/
|
|
362
|
+
heartbeatEvery: z.ZodOptional<z.ZodString>;
|
|
363
|
+
/**
|
|
364
|
+
* Optional override for `agents.defaults.model.primary` (e.g.
|
|
365
|
+
* "anthropic/claude-haiku-4-5" for idle agents). When absent, the patcher
|
|
366
|
+
* derives the model from `aiProvider.type` as before. Format must be
|
|
367
|
+
* "<provider>/<model-id>".
|
|
368
|
+
*/
|
|
369
|
+
modelOverride: z.ZodOptional<z.ZodString>;
|
|
345
370
|
/** ISO timestamp of last config modification */
|
|
346
371
|
updatedAt: z.ZodString;
|
|
347
372
|
}, "strip", z.ZodTypeAny, {
|
|
348
373
|
aiProvider: {
|
|
349
374
|
type: "anthropic" | "openai";
|
|
350
375
|
apiKey: string;
|
|
376
|
+
baseUrl?: string | undefined;
|
|
351
377
|
};
|
|
352
378
|
version: number;
|
|
353
379
|
channels: {
|
|
@@ -373,10 +399,13 @@ export declare const ConfigBundleSchema: z.ZodObject<{
|
|
|
373
399
|
soulFile: string | null;
|
|
374
400
|
gatewayToken: string;
|
|
375
401
|
updatedAt: string;
|
|
402
|
+
heartbeatEvery?: string | undefined;
|
|
403
|
+
modelOverride?: string | undefined;
|
|
376
404
|
}, {
|
|
377
405
|
aiProvider: {
|
|
378
406
|
type: "anthropic" | "openai";
|
|
379
407
|
apiKey: string;
|
|
408
|
+
baseUrl?: string | undefined;
|
|
380
409
|
};
|
|
381
410
|
version: number;
|
|
382
411
|
channels: {
|
|
@@ -402,6 +431,8 @@ export declare const ConfigBundleSchema: z.ZodObject<{
|
|
|
402
431
|
soulFile: string | null;
|
|
403
432
|
gatewayToken: string;
|
|
404
433
|
updatedAt: string;
|
|
434
|
+
heartbeatEvery?: string | undefined;
|
|
435
|
+
modelOverride?: string | undefined;
|
|
405
436
|
}>;
|
|
406
437
|
export type ConfigBundle = z.infer<typeof ConfigBundleSchema>;
|
|
407
438
|
/**
|
package/dist/compute.js
CHANGED
|
@@ -161,7 +161,30 @@ exports.ConfigBundleSchema = zod_1.z.object({
|
|
|
161
161
|
aiProvider: zod_1.z.object({
|
|
162
162
|
type: zod_1.z.enum(["anthropic", "openai"]),
|
|
163
163
|
apiKey: zod_1.z.string().min(1).max(500),
|
|
164
|
+
/**
|
|
165
|
+
* Optional base URL override. When set, OpenClaw routes all provider
|
|
166
|
+
* traffic through this URL instead of the provider's default endpoint.
|
|
167
|
+
* Used by managed deployments where AgentShield issues a per-deployment
|
|
168
|
+
* gateway token and proxies to the upstream provider with budget tracking.
|
|
169
|
+
*/
|
|
170
|
+
baseUrl: zod_1.z.string().url().optional(),
|
|
164
171
|
}),
|
|
172
|
+
/**
|
|
173
|
+
* Optional OpenClaw heartbeat interval (`agents.defaults.heartbeat.every`).
|
|
174
|
+
* Drives how often OpenClaw wakes the agent for HEARTBEAT.md processing —
|
|
175
|
+
* the primary token-cost lever. Examples: "30m" (active), "6h" (idle),
|
|
176
|
+
* "off" (dormant — heartbeat disabled entirely). When absent, the patcher
|
|
177
|
+
* preserves whatever value already lives in openclaw.json (OpenClaw's
|
|
178
|
+
* built-in default of "30m").
|
|
179
|
+
*/
|
|
180
|
+
heartbeatEvery: zod_1.z.string().min(1).max(20).optional(),
|
|
181
|
+
/**
|
|
182
|
+
* Optional override for `agents.defaults.model.primary` (e.g.
|
|
183
|
+
* "anthropic/claude-haiku-4-5" for idle agents). When absent, the patcher
|
|
184
|
+
* derives the model from `aiProvider.type` as before. Format must be
|
|
185
|
+
* "<provider>/<model-id>".
|
|
186
|
+
*/
|
|
187
|
+
modelOverride: zod_1.z.string().min(1).max(100).optional(),
|
|
165
188
|
/** ISO timestamp of last config modification */
|
|
166
189
|
updatedAt: zod_1.z.string().datetime(),
|
|
167
190
|
});
|
package/dist/handshake.d.ts
CHANGED
|
@@ -206,18 +206,19 @@ export declare const SessionContextSchema: z.ZodObject<{
|
|
|
206
206
|
/**
|
|
207
207
|
* Delegation VC credential ID for the active delegation.
|
|
208
208
|
* Set after delegation verification succeeds for a protected tool call.
|
|
209
|
-
* Used by outbound fetch interceptors
|
|
209
|
+
* Used by outbound fetch interceptors as the delegation reference embedded
|
|
210
|
+
* in the KYA-OS-Delegation-Chain / KYA-OS-Delegation-Proof headers.
|
|
210
211
|
*/
|
|
211
212
|
delegationRef: z.ZodOptional<z.ZodString>;
|
|
212
213
|
/**
|
|
213
214
|
* Reference chain string for the delegation hierarchy.
|
|
214
215
|
* Format: "vc_id_1>del_id_1>vc_id_2>del_id_2"
|
|
215
|
-
* Used by outbound fetch interceptors to inject KYA-Delegation-Chain header.
|
|
216
|
+
* Used by outbound fetch interceptors to inject KYA-OS-Delegation-Chain header.
|
|
216
217
|
*/
|
|
217
218
|
delegationChain: z.ZodOptional<z.ZodString>;
|
|
218
219
|
/**
|
|
219
220
|
* Scopes granted by the active delegation.
|
|
220
|
-
* Used by outbound fetch interceptors to inject KYA-Granted-Scopes header.
|
|
221
|
+
* Used by outbound fetch interceptors to inject KYA-OS-Granted-Scopes header.
|
|
221
222
|
*/
|
|
222
223
|
delegationScopes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
223
224
|
}, "strip", z.ZodTypeAny, {
|
package/dist/handshake.js
CHANGED
|
@@ -78,18 +78,19 @@ exports.SessionContextSchema = zod_1.z.object({
|
|
|
78
78
|
/**
|
|
79
79
|
* Delegation VC credential ID for the active delegation.
|
|
80
80
|
* Set after delegation verification succeeds for a protected tool call.
|
|
81
|
-
* Used by outbound fetch interceptors
|
|
81
|
+
* Used by outbound fetch interceptors as the delegation reference embedded
|
|
82
|
+
* in the KYA-OS-Delegation-Chain / KYA-OS-Delegation-Proof headers.
|
|
82
83
|
*/
|
|
83
84
|
delegationRef: zod_1.z.string().optional(),
|
|
84
85
|
/**
|
|
85
86
|
* Reference chain string for the delegation hierarchy.
|
|
86
87
|
* Format: "vc_id_1>del_id_1>vc_id_2>del_id_2"
|
|
87
|
-
* Used by outbound fetch interceptors to inject KYA-Delegation-Chain header.
|
|
88
|
+
* Used by outbound fetch interceptors to inject KYA-OS-Delegation-Chain header.
|
|
88
89
|
*/
|
|
89
90
|
delegationChain: zod_1.z.string().optional(),
|
|
90
91
|
/**
|
|
91
92
|
* Scopes granted by the active delegation.
|
|
92
|
-
* Used by outbound fetch interceptors to inject KYA-Granted-Scopes header.
|
|
93
|
+
* Used by outbound fetch interceptors to inject KYA-OS-Granted-Scopes header.
|
|
93
94
|
*/
|
|
94
95
|
delegationScopes: zod_1.z.array(zod_1.z.string()).optional(),
|
|
95
96
|
});
|
package/dist/proof/index.d.ts
CHANGED
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* This module exports all proof-related types including DetachedProof,
|
|
5
5
|
* proof records, and signing specs.
|
|
6
6
|
*/
|
|
7
|
-
export { DetachedProofSchema, ProofMetaSchema, CanonicalHashesSchema, AuditRecordSchema, ToolCallContextSchema, ProofSubmissionContextSchema, ProofSubmissionRequestSchema, JWS_ALGORITHM, HASH_ALGORITHM, AUDIT_VERSION, type DetachedProof, type ProofMeta, type CanonicalHashes, type AuditRecord, type ToolCallContext, type ProofSubmissionContext, type ProofSubmissionRequest, } from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
7
|
+
export { DetachedProofSchema, ProofMetaSchema, ProofOutcomeSchema, CanonicalHashesSchema, AuditRecordSchema, ToolCallContextSchema, ProofSubmissionContextSchema, ProofSubmissionRequestSchema, JWS_ALGORITHM, HASH_ALGORITHM, AUDIT_VERSION, type DetachedProof, type ProofMeta, type ProofOutcome, type CanonicalHashes, type AuditRecord, type ToolCallContext, type ProofSubmissionContext, type ProofSubmissionRequest, } from "../proof.js";
|
|
8
|
+
export * from "./signing-spec.js";
|
|
9
|
+
export * from "./proof-record.js";
|
package/dist/proof/index.js
CHANGED
|
@@ -20,11 +20,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
20
20
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.AUDIT_VERSION = exports.HASH_ALGORITHM = exports.JWS_ALGORITHM = exports.ProofSubmissionRequestSchema = exports.ProofSubmissionContextSchema = exports.ToolCallContextSchema = exports.AuditRecordSchema = exports.CanonicalHashesSchema = exports.ProofMetaSchema = exports.DetachedProofSchema = void 0;
|
|
23
|
+
exports.AUDIT_VERSION = exports.HASH_ALGORITHM = exports.JWS_ALGORITHM = exports.ProofSubmissionRequestSchema = exports.ProofSubmissionContextSchema = exports.ToolCallContextSchema = exports.AuditRecordSchema = exports.CanonicalHashesSchema = exports.ProofOutcomeSchema = exports.ProofMetaSchema = exports.DetachedProofSchema = void 0;
|
|
24
24
|
// Export DetachedProof and related schemas from root proof.ts
|
|
25
25
|
var proof_js_1 = require("../proof.js");
|
|
26
26
|
Object.defineProperty(exports, "DetachedProofSchema", { enumerable: true, get: function () { return proof_js_1.DetachedProofSchema; } });
|
|
27
27
|
Object.defineProperty(exports, "ProofMetaSchema", { enumerable: true, get: function () { return proof_js_1.ProofMetaSchema; } });
|
|
28
|
+
Object.defineProperty(exports, "ProofOutcomeSchema", { enumerable: true, get: function () { return proof_js_1.ProofOutcomeSchema; } });
|
|
28
29
|
Object.defineProperty(exports, "CanonicalHashesSchema", { enumerable: true, get: function () { return proof_js_1.CanonicalHashesSchema; } });
|
|
29
30
|
Object.defineProperty(exports, "AuditRecordSchema", { enumerable: true, get: function () { return proof_js_1.AuditRecordSchema; } });
|
|
30
31
|
Object.defineProperty(exports, "ToolCallContextSchema", { enumerable: true, get: function () { return proof_js_1.ToolCallContextSchema; } });
|
package/dist/proof.d.ts
CHANGED
|
@@ -9,6 +9,23 @@ import { z } from "zod";
|
|
|
9
9
|
* The JWS payload contains JWT standard claims (aud, sub, iss) plus custom
|
|
10
10
|
* proof claims (requestHash, responseHash, nonce, etc.).
|
|
11
11
|
*/
|
|
12
|
+
/**
|
|
13
|
+
* Outcome of the policy decision a proof attests to (ratified DIF decision).
|
|
14
|
+
*
|
|
15
|
+
* - `allowed` — the call was authorized and produced a response; the
|
|
16
|
+
* proof carries a `responseHash` over that response.
|
|
17
|
+
* - `denied` — the call was refused; no response was produced.
|
|
18
|
+
* - `step_up_required` — a step-up (re-auth / higher assurance) is required
|
|
19
|
+
* before the call may proceed; no response yet.
|
|
20
|
+
* - `needs_authorization` — explicit user authorization is required first; no
|
|
21
|
+
* response yet.
|
|
22
|
+
*
|
|
23
|
+
* Denial and step-up outcomes authorize no response, so their proofs omit
|
|
24
|
+
* `responseHash`. The field is optional on {@link ProofMetaSchema}: proofs minted
|
|
25
|
+
* before it existed carry no `outcome` and are treated as `allowed`.
|
|
26
|
+
*/
|
|
27
|
+
export declare const ProofOutcomeSchema: z.ZodEnum<["allowed", "denied", "step_up_required", "needs_authorization"]>;
|
|
28
|
+
export type ProofOutcome = z.infer<typeof ProofOutcomeSchema>;
|
|
12
29
|
export declare const ProofMetaSchema: z.ZodObject<{
|
|
13
30
|
did: z.ZodString;
|
|
14
31
|
kid: z.ZodString;
|
|
@@ -18,6 +35,7 @@ export declare const ProofMetaSchema: z.ZodObject<{
|
|
|
18
35
|
sessionId: z.ZodString;
|
|
19
36
|
requestHash: z.ZodString;
|
|
20
37
|
responseHash: z.ZodString;
|
|
38
|
+
outcome: z.ZodOptional<z.ZodEnum<["allowed", "denied", "step_up_required", "needs_authorization"]>>;
|
|
21
39
|
scopeId: z.ZodOptional<z.ZodString>;
|
|
22
40
|
delegationRef: z.ZodOptional<z.ZodString>;
|
|
23
41
|
clientDid: z.ZodOptional<z.ZodString>;
|
|
@@ -32,6 +50,7 @@ export declare const ProofMetaSchema: z.ZodObject<{
|
|
|
32
50
|
responseHash: string;
|
|
33
51
|
clientDid?: string | undefined;
|
|
34
52
|
delegationRef?: string | undefined;
|
|
53
|
+
outcome?: "allowed" | "denied" | "step_up_required" | "needs_authorization" | undefined;
|
|
35
54
|
scopeId?: string | undefined;
|
|
36
55
|
}, {
|
|
37
56
|
did: string;
|
|
@@ -44,6 +63,7 @@ export declare const ProofMetaSchema: z.ZodObject<{
|
|
|
44
63
|
responseHash: string;
|
|
45
64
|
clientDid?: string | undefined;
|
|
46
65
|
delegationRef?: string | undefined;
|
|
66
|
+
outcome?: "allowed" | "denied" | "step_up_required" | "needs_authorization" | undefined;
|
|
47
67
|
scopeId?: string | undefined;
|
|
48
68
|
}>;
|
|
49
69
|
export declare const DetachedProofSchema: z.ZodObject<{
|
|
@@ -57,6 +77,7 @@ export declare const DetachedProofSchema: z.ZodObject<{
|
|
|
57
77
|
sessionId: z.ZodString;
|
|
58
78
|
requestHash: z.ZodString;
|
|
59
79
|
responseHash: z.ZodString;
|
|
80
|
+
outcome: z.ZodOptional<z.ZodEnum<["allowed", "denied", "step_up_required", "needs_authorization"]>>;
|
|
60
81
|
scopeId: z.ZodOptional<z.ZodString>;
|
|
61
82
|
delegationRef: z.ZodOptional<z.ZodString>;
|
|
62
83
|
clientDid: z.ZodOptional<z.ZodString>;
|
|
@@ -71,6 +92,7 @@ export declare const DetachedProofSchema: z.ZodObject<{
|
|
|
71
92
|
responseHash: string;
|
|
72
93
|
clientDid?: string | undefined;
|
|
73
94
|
delegationRef?: string | undefined;
|
|
95
|
+
outcome?: "allowed" | "denied" | "step_up_required" | "needs_authorization" | undefined;
|
|
74
96
|
scopeId?: string | undefined;
|
|
75
97
|
}, {
|
|
76
98
|
did: string;
|
|
@@ -83,6 +105,7 @@ export declare const DetachedProofSchema: z.ZodObject<{
|
|
|
83
105
|
responseHash: string;
|
|
84
106
|
clientDid?: string | undefined;
|
|
85
107
|
delegationRef?: string | undefined;
|
|
108
|
+
outcome?: "allowed" | "denied" | "step_up_required" | "needs_authorization" | undefined;
|
|
86
109
|
scopeId?: string | undefined;
|
|
87
110
|
}>;
|
|
88
111
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -98,6 +121,7 @@ export declare const DetachedProofSchema: z.ZodObject<{
|
|
|
98
121
|
responseHash: string;
|
|
99
122
|
clientDid?: string | undefined;
|
|
100
123
|
delegationRef?: string | undefined;
|
|
124
|
+
outcome?: "allowed" | "denied" | "step_up_required" | "needs_authorization" | undefined;
|
|
101
125
|
scopeId?: string | undefined;
|
|
102
126
|
};
|
|
103
127
|
}, {
|
|
@@ -113,6 +137,7 @@ export declare const DetachedProofSchema: z.ZodObject<{
|
|
|
113
137
|
responseHash: string;
|
|
114
138
|
clientDid?: string | undefined;
|
|
115
139
|
delegationRef?: string | undefined;
|
|
140
|
+
outcome?: "allowed" | "denied" | "step_up_required" | "needs_authorization" | undefined;
|
|
116
141
|
scopeId?: string | undefined;
|
|
117
142
|
};
|
|
118
143
|
}>;
|
|
@@ -251,6 +276,7 @@ export declare const ProofSubmissionRequestSchema: z.ZodObject<{
|
|
|
251
276
|
sessionId: z.ZodString;
|
|
252
277
|
requestHash: z.ZodString;
|
|
253
278
|
responseHash: z.ZodString;
|
|
279
|
+
outcome: z.ZodOptional<z.ZodEnum<["allowed", "denied", "step_up_required", "needs_authorization"]>>;
|
|
254
280
|
scopeId: z.ZodOptional<z.ZodString>;
|
|
255
281
|
delegationRef: z.ZodOptional<z.ZodString>;
|
|
256
282
|
clientDid: z.ZodOptional<z.ZodString>;
|
|
@@ -265,6 +291,7 @@ export declare const ProofSubmissionRequestSchema: z.ZodObject<{
|
|
|
265
291
|
responseHash: string;
|
|
266
292
|
clientDid?: string | undefined;
|
|
267
293
|
delegationRef?: string | undefined;
|
|
294
|
+
outcome?: "allowed" | "denied" | "step_up_required" | "needs_authorization" | undefined;
|
|
268
295
|
scopeId?: string | undefined;
|
|
269
296
|
}, {
|
|
270
297
|
did: string;
|
|
@@ -277,6 +304,7 @@ export declare const ProofSubmissionRequestSchema: z.ZodObject<{
|
|
|
277
304
|
responseHash: string;
|
|
278
305
|
clientDid?: string | undefined;
|
|
279
306
|
delegationRef?: string | undefined;
|
|
307
|
+
outcome?: "allowed" | "denied" | "step_up_required" | "needs_authorization" | undefined;
|
|
280
308
|
scopeId?: string | undefined;
|
|
281
309
|
}>;
|
|
282
310
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -292,6 +320,7 @@ export declare const ProofSubmissionRequestSchema: z.ZodObject<{
|
|
|
292
320
|
responseHash: string;
|
|
293
321
|
clientDid?: string | undefined;
|
|
294
322
|
delegationRef?: string | undefined;
|
|
323
|
+
outcome?: "allowed" | "denied" | "step_up_required" | "needs_authorization" | undefined;
|
|
295
324
|
scopeId?: string | undefined;
|
|
296
325
|
};
|
|
297
326
|
}, {
|
|
@@ -307,6 +336,7 @@ export declare const ProofSubmissionRequestSchema: z.ZodObject<{
|
|
|
307
336
|
responseHash: string;
|
|
308
337
|
clientDid?: string | undefined;
|
|
309
338
|
delegationRef?: string | undefined;
|
|
339
|
+
outcome?: "allowed" | "denied" | "step_up_required" | "needs_authorization" | undefined;
|
|
310
340
|
scopeId?: string | undefined;
|
|
311
341
|
};
|
|
312
342
|
}>, "many">;
|
|
@@ -365,6 +395,7 @@ export declare const ProofSubmissionRequestSchema: z.ZodObject<{
|
|
|
365
395
|
responseHash: string;
|
|
366
396
|
clientDid?: string | undefined;
|
|
367
397
|
delegationRef?: string | undefined;
|
|
398
|
+
outcome?: "allowed" | "denied" | "step_up_required" | "needs_authorization" | undefined;
|
|
368
399
|
scopeId?: string | undefined;
|
|
369
400
|
};
|
|
370
401
|
}[];
|
|
@@ -394,6 +425,7 @@ export declare const ProofSubmissionRequestSchema: z.ZodObject<{
|
|
|
394
425
|
responseHash: string;
|
|
395
426
|
clientDid?: string | undefined;
|
|
396
427
|
delegationRef?: string | undefined;
|
|
428
|
+
outcome?: "allowed" | "denied" | "step_up_required" | "needs_authorization" | undefined;
|
|
397
429
|
scopeId?: string | undefined;
|
|
398
430
|
};
|
|
399
431
|
}[];
|
package/dist/proof.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProofSubmissionRequestSchema = exports.ProofSubmissionContextSchema = exports.ToolCallContextSchema = exports.AUDIT_VERSION = exports.HASH_ALGORITHM = exports.JWS_ALGORITHM = exports.AuditRecordSchema = exports.CanonicalHashesSchema = exports.DetachedProofSchema = exports.ProofMetaSchema = void 0;
|
|
3
|
+
exports.ProofSubmissionRequestSchema = exports.ProofSubmissionContextSchema = exports.ToolCallContextSchema = exports.AUDIT_VERSION = exports.HASH_ALGORITHM = exports.JWS_ALGORITHM = exports.AuditRecordSchema = exports.CanonicalHashesSchema = exports.DetachedProofSchema = exports.ProofMetaSchema = exports.ProofOutcomeSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
/**
|
|
6
6
|
* Proof and signature schemas for MCP-I
|
|
@@ -12,6 +12,27 @@ const zod_1 = require("zod");
|
|
|
12
12
|
* The JWS payload contains JWT standard claims (aud, sub, iss) plus custom
|
|
13
13
|
* proof claims (requestHash, responseHash, nonce, etc.).
|
|
14
14
|
*/
|
|
15
|
+
/**
|
|
16
|
+
* Outcome of the policy decision a proof attests to (ratified DIF decision).
|
|
17
|
+
*
|
|
18
|
+
* - `allowed` — the call was authorized and produced a response; the
|
|
19
|
+
* proof carries a `responseHash` over that response.
|
|
20
|
+
* - `denied` — the call was refused; no response was produced.
|
|
21
|
+
* - `step_up_required` — a step-up (re-auth / higher assurance) is required
|
|
22
|
+
* before the call may proceed; no response yet.
|
|
23
|
+
* - `needs_authorization` — explicit user authorization is required first; no
|
|
24
|
+
* response yet.
|
|
25
|
+
*
|
|
26
|
+
* Denial and step-up outcomes authorize no response, so their proofs omit
|
|
27
|
+
* `responseHash`. The field is optional on {@link ProofMetaSchema}: proofs minted
|
|
28
|
+
* before it existed carry no `outcome` and are treated as `allowed`.
|
|
29
|
+
*/
|
|
30
|
+
exports.ProofOutcomeSchema = zod_1.z.enum([
|
|
31
|
+
"allowed",
|
|
32
|
+
"denied",
|
|
33
|
+
"step_up_required",
|
|
34
|
+
"needs_authorization",
|
|
35
|
+
]);
|
|
15
36
|
exports.ProofMetaSchema = zod_1.z.object({
|
|
16
37
|
did: zod_1.z.string().min(1),
|
|
17
38
|
kid: zod_1.z.string().min(1),
|
|
@@ -21,6 +42,13 @@ exports.ProofMetaSchema = zod_1.z.object({
|
|
|
21
42
|
sessionId: zod_1.z.string().min(1),
|
|
22
43
|
requestHash: zod_1.z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
23
44
|
responseHash: zod_1.z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
45
|
+
// Policy outcome this proof attests to (ratified DIF decision); absent on
|
|
46
|
+
// legacy proofs, which consumers treat as "allowed". Per the ratified schema
|
|
47
|
+
// `responseHash` is present only for the "allowed" outcome — the verifier
|
|
48
|
+
// enforces that outcome-conditionally. `responseHash` stays required-typed
|
|
49
|
+
// here to avoid a repo-wide `string | undefined` ripple; making it
|
|
50
|
+
// conditionally optional is a deferred schema refinement.
|
|
51
|
+
outcome: exports.ProofOutcomeSchema.optional(),
|
|
24
52
|
scopeId: zod_1.z.string().optional(),
|
|
25
53
|
delegationRef: zod_1.z.string().optional(),
|
|
26
54
|
clientDid: zod_1.z.string().optional(), // Optional for backward compatibility
|
package/dist/reputation/index.js
CHANGED
|
@@ -34,6 +34,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
34
34
|
__exportStar(require("./schemas.js"), exports);
|
|
35
35
|
// API schemas
|
|
36
36
|
__exportStar(require("./api.js"), exports);
|
|
37
|
+
// Per-tool-call interaction attestation request (xmcp-i#413)
|
|
38
|
+
__exportStar(require("./interactions.js"), exports);
|
|
37
39
|
// Credential schemas (W3C VC)
|
|
38
40
|
__exportStar(require("./credentials.js"), exports);
|
|
39
41
|
// Constants and configuration
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interaction Report Request Contract
|
|
3
|
+
*
|
|
4
|
+
* The per-tool-call attestation body that identity-aware runtimes POST to
|
|
5
|
+
* KTA's `POST /api/v1/agents/{did}/interactions` endpoint (xmcp-i#413). KTA
|
|
6
|
+
* verifies the embedded JWS against the agent's registered public key and
|
|
7
|
+
* folds the outcome into the Bayesian reputation engine.
|
|
8
|
+
*
|
|
9
|
+
* WHY this lives in @kya-os/contracts: per the repo's API-parity rule, the
|
|
10
|
+
* wire shape of any cross-service POST must be a shared, Zod-validated
|
|
11
|
+
* contract — never inlined at the call site. The producer here is
|
|
12
|
+
* `@kya-os/compute`'s attestation reporter; the consumer is the KTA route.
|
|
13
|
+
*
|
|
14
|
+
* PARITY CAVEAT: KTA's receiving schema lives in a different repository
|
|
15
|
+
* (Know-That-Ai/know-that-ai → `src/app/api/v1/agents/[did]/interactions/`)
|
|
16
|
+
* and cannot be imported or validated from here. This schema mirrors the body
|
|
17
|
+
* shape already accepted in production (the existing attestation flow), and
|
|
18
|
+
* MUST be kept in lock-step with that route when either side changes.
|
|
19
|
+
*
|
|
20
|
+
* Related Spec: MCP-I §5 (Reputation)
|
|
21
|
+
*/
|
|
22
|
+
import { z } from "zod";
|
|
23
|
+
/**
|
|
24
|
+
* Interaction classification. Open-ended on the wire (KTA may accept more
|
|
25
|
+
* types over time), but the per-tool-call attestation path emits exactly
|
|
26
|
+
* `"scope_executed"`. Modeled as a string with that documented default rather
|
|
27
|
+
* than a closed enum so adding a new KTA-side type does not require a
|
|
28
|
+
* contracts bump on the producer before the receiver is ready.
|
|
29
|
+
*/
|
|
30
|
+
export declare const INTERACTION_TYPE_SCOPE_EXECUTED: "scope_executed";
|
|
31
|
+
/**
|
|
32
|
+
* Coarse success/failure outcome KTA folds into the reputation score. The
|
|
33
|
+
* compute reporter collapses its finer 4-value status (success/error/denied/
|
|
34
|
+
* timeout) onto this two-value axis — anything that is not an unambiguous
|
|
35
|
+
* success counts as a failure for reputation purposes.
|
|
36
|
+
*/
|
|
37
|
+
export declare const InteractionOutcomeSchema: z.ZodEnum<["success", "failure"]>;
|
|
38
|
+
export type InteractionOutcome = z.infer<typeof InteractionOutcomeSchema>;
|
|
39
|
+
/**
|
|
40
|
+
* Evidentiary context carried alongside the signed attestation. `client_did`
|
|
41
|
+
* is optional because the agent may receive calls from un-attested clients
|
|
42
|
+
* during the rollout window; the attestation still has value without it.
|
|
43
|
+
*/
|
|
44
|
+
export declare const InteractionContextSchema: z.ZodObject<{
|
|
45
|
+
/** MCP session id from the originating tools/call. May be empty for headless flows. */
|
|
46
|
+
session_id: z.ZodString;
|
|
47
|
+
/** Calling client's DID, when known. Omitted (not null) when un-attested. */
|
|
48
|
+
client_did: z.ZodOptional<z.ZodString>;
|
|
49
|
+
/** Compact JWS attestation of the tool call, signed by the agent's key. */
|
|
50
|
+
attestation_jws: z.ZodString;
|
|
51
|
+
}, "strip", z.ZodTypeAny, {
|
|
52
|
+
session_id: string;
|
|
53
|
+
attestation_jws: string;
|
|
54
|
+
client_did?: string | undefined;
|
|
55
|
+
}, {
|
|
56
|
+
session_id: string;
|
|
57
|
+
attestation_jws: string;
|
|
58
|
+
client_did?: string | undefined;
|
|
59
|
+
}>;
|
|
60
|
+
export type InteractionContext = z.infer<typeof InteractionContextSchema>;
|
|
61
|
+
/**
|
|
62
|
+
* Interaction Report Request Schema
|
|
63
|
+
*
|
|
64
|
+
* Fire-and-forget body POSTed per tool call. Authenticated by the
|
|
65
|
+
* `x-api-key` header (not part of the body); idempotency is the caller's
|
|
66
|
+
* responsibility via `idempotency_key`.
|
|
67
|
+
*/
|
|
68
|
+
export declare const InteractionReportRequestSchema: z.ZodObject<{
|
|
69
|
+
/** Interaction classification — `"scope_executed"` for tool-call attestations. */
|
|
70
|
+
interaction_type: z.ZodString;
|
|
71
|
+
/** Reputation-facing outcome. */
|
|
72
|
+
outcome: z.ZodEnum<["success", "failure"]>;
|
|
73
|
+
/** Authorized scopes for the call, when a delegation context supplies them. */
|
|
74
|
+
scopes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
75
|
+
/** ISO 8601 timestamp of the call, set when the attestation is signed. */
|
|
76
|
+
timestamp: z.ZodString;
|
|
77
|
+
/** Evidentiary context including the signed attestation. */
|
|
78
|
+
context: z.ZodObject<{
|
|
79
|
+
/** MCP session id from the originating tools/call. May be empty for headless flows. */
|
|
80
|
+
session_id: z.ZodString;
|
|
81
|
+
/** Calling client's DID, when known. Omitted (not null) when un-attested. */
|
|
82
|
+
client_did: z.ZodOptional<z.ZodString>;
|
|
83
|
+
/** Compact JWS attestation of the tool call, signed by the agent's key. */
|
|
84
|
+
attestation_jws: z.ZodString;
|
|
85
|
+
}, "strip", z.ZodTypeAny, {
|
|
86
|
+
session_id: string;
|
|
87
|
+
attestation_jws: string;
|
|
88
|
+
client_did?: string | undefined;
|
|
89
|
+
}, {
|
|
90
|
+
session_id: string;
|
|
91
|
+
attestation_jws: string;
|
|
92
|
+
client_did?: string | undefined;
|
|
93
|
+
}>;
|
|
94
|
+
/** Per-call key so a retried POST of the same call is deduped by KTA. */
|
|
95
|
+
idempotency_key: z.ZodString;
|
|
96
|
+
}, "strip", z.ZodTypeAny, {
|
|
97
|
+
timestamp: string;
|
|
98
|
+
outcome: "success" | "failure";
|
|
99
|
+
context: {
|
|
100
|
+
session_id: string;
|
|
101
|
+
attestation_jws: string;
|
|
102
|
+
client_did?: string | undefined;
|
|
103
|
+
};
|
|
104
|
+
interaction_type: string;
|
|
105
|
+
idempotency_key: string;
|
|
106
|
+
scopes?: string[] | undefined;
|
|
107
|
+
}, {
|
|
108
|
+
timestamp: string;
|
|
109
|
+
outcome: "success" | "failure";
|
|
110
|
+
context: {
|
|
111
|
+
session_id: string;
|
|
112
|
+
attestation_jws: string;
|
|
113
|
+
client_did?: string | undefined;
|
|
114
|
+
};
|
|
115
|
+
interaction_type: string;
|
|
116
|
+
idempotency_key: string;
|
|
117
|
+
scopes?: string[] | undefined;
|
|
118
|
+
}>;
|
|
119
|
+
export type InteractionReportRequest = z.infer<typeof InteractionReportRequestSchema>;
|
|
120
|
+
/**
|
|
121
|
+
* Validate an interaction report request. Mirrors the `validate*` helpers in
|
|
122
|
+
* `./api.ts` so call sites can branch on `.success` without importing zod.
|
|
123
|
+
*/
|
|
124
|
+
export declare function validateInteractionReportRequest(data: unknown): z.SafeParseReturnType<{
|
|
125
|
+
timestamp: string;
|
|
126
|
+
outcome: "success" | "failure";
|
|
127
|
+
context: {
|
|
128
|
+
session_id: string;
|
|
129
|
+
attestation_jws: string;
|
|
130
|
+
client_did?: string | undefined;
|
|
131
|
+
};
|
|
132
|
+
interaction_type: string;
|
|
133
|
+
idempotency_key: string;
|
|
134
|
+
scopes?: string[] | undefined;
|
|
135
|
+
}, {
|
|
136
|
+
timestamp: string;
|
|
137
|
+
outcome: "success" | "failure";
|
|
138
|
+
context: {
|
|
139
|
+
session_id: string;
|
|
140
|
+
attestation_jws: string;
|
|
141
|
+
client_did?: string | undefined;
|
|
142
|
+
};
|
|
143
|
+
interaction_type: string;
|
|
144
|
+
idempotency_key: string;
|
|
145
|
+
scopes?: string[] | undefined;
|
|
146
|
+
}>;
|