@7h3/protocol 0.5.0 → 0.5.2

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 (294) hide show
  1. package/README.md +6 -1317
  2. package/agentAdapter.d.ts +26 -0
  3. package/auditLog.d.ts +54 -0
  4. package/capability.d.ts +67 -0
  5. package/cborCodec.d.ts +34 -0
  6. package/conformanceVectors.d.ts +20 -0
  7. package/encryption.d.ts +85 -0
  8. package/envelopeCbor.d.ts +33 -0
  9. package/frameworkAdapters.d.ts +72 -0
  10. package/gateway.d.ts +53 -0
  11. package/grpcBinding.d.ts +29 -0
  12. package/httpBinding.d.ts +50 -0
  13. package/index.d.ts +39 -0
  14. package/index.js +3670 -0
  15. package/keyInfra.d.ts +64 -0
  16. package/keyRegistry.d.ts +9 -0
  17. package/keyRotation.d.ts +20 -0
  18. package/mcpGateway.d.ts +37 -0
  19. package/mcpTransports.d.ts +62 -0
  20. package/mcpWrapper.d.ts +83 -0
  21. package/otel.d.ts +65 -0
  22. package/package.json +13 -121
  23. package/policyEnforcer.d.ts +50 -0
  24. package/policyTelemetryFeedback.d.ts +11 -0
  25. package/{src/protocol.d.ts → protocol.d.ts} +6 -2
  26. package/protocolAgent.d.ts +58 -0
  27. package/protocolBinary.d.ts +8 -0
  28. package/protocolCapabilities.d.ts +24 -0
  29. package/protocolReplay.d.ts +35 -0
  30. package/protocolTransport.d.ts +73 -0
  31. package/queueBinding.d.ts +43 -0
  32. package/rateLimiter.d.ts +18 -0
  33. package/{src/redisClient.ts → redisClient.d.ts} +25 -75
  34. package/replayStores.d.ts +98 -0
  35. package/revocation.d.ts +71 -0
  36. package/routePolicy.d.ts +30 -0
  37. package/runtimePolicy.d.ts +24 -0
  38. package/runtimePolicyManager.d.ts +15 -0
  39. package/runtimePolicyPresets.d.ts +11 -0
  40. package/signedResponse.d.ts +21 -0
  41. package/stream.d.ts +59 -0
  42. package/telemetry.d.ts +79 -0
  43. package/webhookBinding.d.ts +30 -0
  44. package/wsBinding.d.ts +52 -0
  45. package/.dockerignore +0 -19
  46. package/.github/dependabot.yml +0 -32
  47. package/.github/workflows/ci.yml +0 -31
  48. package/.github/workflows/publish.yml +0 -59
  49. package/.github/workflows/scorecard.yml +0 -37
  50. package/7h3.example.yaml +0 -125
  51. package/CHANGELOG.md +0 -152
  52. package/CONTRIBUTING.md +0 -82
  53. package/Dockerfile +0 -73
  54. package/GOVERNANCE.md +0 -62
  55. package/SECURITY.md +0 -70
  56. package/bench-results/replay-cache-full-1777891033256.json +0 -10
  57. package/bench-results/replay-cache-full-1777896317488.json +0 -10
  58. package/bench-results/replay-cache-full-1777900993184.json +0 -10
  59. package/bench-results/replay-cache-full-1777901019285.json +0 -10
  60. package/bench-results/replay-cache-quick-1777870170126.json +0 -10
  61. package/bench-results/signature-profiles-quick-1775875160079.json +0 -85
  62. package/bench-results/signature-profiles-quick-1775983539716.json +0 -85
  63. package/bench-results/signature-profiles-quick-1776237913190.json +0 -85
  64. package/bench-results/wire-codecs-full-1777891019803.json +0 -93
  65. package/bench-results/wire-codecs-full-1777896260964.json +0 -93
  66. package/bench-results/wire-codecs-full-1777901004247.json +0 -93
  67. package/bench-results/wire-codecs-quick-1775972879056.json +0 -93
  68. package/bench-results/wire-codecs-quick-1775983541111.json +0 -93
  69. package/bench-results/wire-codecs-quick-1776237914299.json +0 -93
  70. package/bench-results/wire-codecs-quick-1777841285236.json +0 -93
  71. package/bench-results/wire-codecs-quick-1777841321772.json +0 -93
  72. package/bench-results/wire-codecs-quick-1777841330408.json +0 -93
  73. package/bench-results/wire-codecs-quick-1777852886082.json +0 -93
  74. package/bench-results/wire-codecs-quick-1777852988773.json +0 -93
  75. package/bench-results/wire-codecs-quick-1777870188095.json +0 -93
  76. package/bench-results/wire-codecs-quick-1777870263918.json +0 -93
  77. package/bench-results/wire-codecs-quick-1777870455034.json +0 -93
  78. package/bench-results/wire-codecs-quick-1778816163081.json +0 -93
  79. package/bench-results/wire-codecs-quick-1778843936130.json +0 -93
  80. package/bin/7h3.ts +0 -406
  81. package/conformance/7h3_v0_1.json +0 -77
  82. package/conformance/7h3_v0_1_binary.json +0 -20
  83. package/conformance/aip_v0_1_binary.json +0 -20
  84. package/docker-compose.yaml +0 -77
  85. package/docs/ADOPTION_PLAN.md +0 -120
  86. package/docs/AGENTS.md +0 -77
  87. package/docs/AIP_RFC_v0.1.md +0 -97
  88. package/docs/AI_DECISION_CARD.md +0 -122
  89. package/docs/AI_RUNTIME_POLICY.json +0 -126
  90. package/docs/AI_RUNTIME_POLICY.yaml +0 -110
  91. package/docs/BACKPRESSURE_TUNING.md +0 -65
  92. package/docs/BENCHMARK_CLAIM_MATRIX.md +0 -42
  93. package/docs/BENCHMARK_REPORT_TEMPLATE.md +0 -169
  94. package/docs/BINARY_CODEC_BENCH.md +0 -23
  95. package/docs/CLEAN_CLONE_RUNBOOK.md +0 -36
  96. package/docs/CLOCK_SKEW_POLICY.md +0 -30
  97. package/docs/DISTRIBUTED_REPLAY.md +0 -142
  98. package/docs/FUZZ_CAMPAIGN.md +0 -121
  99. package/docs/GATEWAY.md +0 -195
  100. package/docs/KEY_MANAGEMENT_POLICY.md +0 -53
  101. package/docs/KEY_REVOCATION.md +0 -69
  102. package/docs/MCP_WRAPPER.md +0 -159
  103. package/docs/MIGRATION_GUIDE.md +0 -40
  104. package/docs/OPERATORS.md +0 -184
  105. package/docs/PERF_REGRESSION_POLICY.md +0 -34
  106. package/docs/PROJECT_EXAMINATION_2026-05-31.md +0 -219
  107. package/docs/RELEASE_BENCHMARK_REPORT_2026-05-15.md +0 -135
  108. package/docs/RELEASE_GATE.md +0 -25
  109. package/docs/RELEASE_NOTES_v0.1.0.md +0 -54
  110. package/docs/SECURITY_REVIEW_2026-06-05.md +0 -165
  111. package/docs/TELEMETRY.md +0 -41
  112. package/docs/THREAT_MODEL.md +0 -89
  113. package/docs/VERSIONING_POLICY.md +0 -30
  114. package/docs/assets/banner-github.png +0 -0
  115. package/docs/assets/banner.png +0 -0
  116. package/docs/assets/banner.svg +0 -123
  117. package/eslint.config.js +0 -15
  118. package/fuzz/ts/harness-decode.ts +0 -136
  119. package/fuzz/ts/harness-verify.ts +0 -121
  120. package/fuzz/ts/run.ts +0 -35
  121. package/mcp-server/README.md +0 -38
  122. package/mcp-server/package-lock.json +0 -1187
  123. package/mcp-server/package.json +0 -35
  124. package/mcp-server/src/index.ts +0 -236
  125. package/mcp-server/tsconfig.json +0 -14
  126. package/scripts/aip-framework-quickstart.ts +0 -110
  127. package/scripts/aip-mcp-gateway.ts +0 -38
  128. package/scripts/aip-mcp-wrap-demo.ts +0 -72
  129. package/scripts/aip-quickstart.ts +0 -60
  130. package/scripts/bench-diff.ts +0 -118
  131. package/scripts/bench-protocol-e2e.ts +0 -937
  132. package/scripts/bench-protocol-openloop.ts +0 -1397
  133. package/scripts/bench-replay-cache.ts +0 -76
  134. package/scripts/bench-signature-profiles.ts +0 -180
  135. package/scripts/bench-wire-codecs.ts +0 -161
  136. package/scripts/build-binary-conformance.ts +0 -36
  137. package/scripts/build-release-dashboard.ts +0 -175
  138. package/scripts/canary-rollout.ts +0 -38
  139. package/scripts/mcpGatewayCli.test.ts +0 -116
  140. package/scripts/prepare-aip-package.ts +0 -88
  141. package/scripts/regen-conformance-sigs.ts +0 -18
  142. package/scripts/release-gate.ts +0 -19
  143. package/scripts/validate-runtime-policy.ts +0 -18
  144. package/sdk/browser/index.test.ts +0 -162
  145. package/sdk/browser/index.ts +0 -257
  146. package/sdk/browser/package.json +0 -13
  147. package/sdk/go/cbor.go +0 -551
  148. package/sdk/go/cbor_test.go +0 -232
  149. package/sdk/go/encryption.go +0 -280
  150. package/sdk/go/encryption_test.go +0 -318
  151. package/sdk/go/go.mod +0 -7
  152. package/sdk/go/go.sum +0 -4
  153. package/sdk/go/http.go +0 -135
  154. package/sdk/go/protocol.go +0 -324
  155. package/sdk/go/protocol_test.go +0 -334
  156. package/sdk/go/replay.go +0 -121
  157. package/sdk/go/replay_test.go +0 -149
  158. package/sdk/go/webhook.go +0 -136
  159. package/sdk/pq/package-lock.json +0 -1358
  160. package/sdk/pq/package.json +0 -42
  161. package/sdk/pq/src/index.test.ts +0 -143
  162. package/sdk/pq/src/index.ts +0 -166
  163. package/sdk/pq/tsconfig.json +0 -14
  164. package/sdk/pq/vitest.config.ts +0 -7
  165. package/sdk/python/README.md +0 -18
  166. package/sdk/python/protocol_7h3/__init__.py +0 -46
  167. package/sdk/python/protocol_7h3/encryption.py +0 -252
  168. package/sdk/python/protocol_7h3/http.py +0 -212
  169. package/sdk/python/protocol_7h3/keys.py +0 -149
  170. package/sdk/python/protocol_7h3/pq.py +0 -244
  171. package/sdk/python/protocol_7h3/protocol.py +0 -525
  172. package/sdk/python/protocol_7h3/queue.py +0 -118
  173. package/sdk/python/protocol_7h3/replay.py +0 -98
  174. package/sdk/python/protocol_7h3/webhook.py +0 -116
  175. package/sdk/python/pyproject.toml +0 -40
  176. package/sdk/python/tests/test_conformance.py +0 -110
  177. package/sdk/python/tests/test_encryption.py +0 -206
  178. package/sdk/python/tests/test_http.py +0 -305
  179. package/sdk/python/tests/test_keys.py +0 -417
  180. package/sdk/python/tests/test_queue.py +0 -120
  181. package/sdk/python/tests/test_webhook.py +0 -345
  182. package/sdk/rust/Cargo.lock +0 -371
  183. package/sdk/rust/Cargo.toml +0 -25
  184. package/sdk/rust/README.md +0 -31
  185. package/sdk/rust/fuzz/Cargo.toml +0 -29
  186. package/sdk/rust/fuzz/fuzz_targets/fuzz_canonicalize.rs +0 -46
  187. package/sdk/rust/fuzz/fuzz_targets/fuzz_decode.rs +0 -11
  188. package/sdk/rust/src/bin/aip_mcp_gateway.rs +0 -59
  189. package/sdk/rust/src/http.rs +0 -145
  190. package/sdk/rust/src/keys.rs +0 -161
  191. package/sdk/rust/src/lib.rs +0 -688
  192. package/sdk/rust/src/queue.rs +0 -79
  193. package/sdk/rust/src/webhook.rs +0 -86
  194. package/sdk/rust/tests/conformance.rs +0 -148
  195. package/sdk/rust/tests/gateway.rs +0 -130
  196. package/sdk/rust/tests/http_webhook_queue.rs +0 -201
  197. package/sdk/rust/tests/keys.rs +0 -189
  198. package/sdk/threshold/index.d.ts +0 -68
  199. package/sdk/threshold/index.d.ts.map +0 -1
  200. package/sdk/threshold/index.js +0 -254
  201. package/sdk/threshold/package-lock.json +0 -1361
  202. package/sdk/threshold/package.json +0 -39
  203. package/sdk/threshold/src/index.d.ts +0 -68
  204. package/sdk/threshold/src/index.d.ts.map +0 -1
  205. package/sdk/threshold/src/index.js +0 -254
  206. package/sdk/threshold/src/index.test.ts +0 -238
  207. package/sdk/threshold/src/index.ts +0 -355
  208. package/sdk/threshold/tsconfig.json +0 -19
  209. package/sdk/threshold/vitest.config.ts +0 -12
  210. package/src/agentAdapter.test.ts +0 -48
  211. package/src/agentAdapter.ts +0 -56
  212. package/src/auditLog.test.ts +0 -145
  213. package/src/auditLog.ts +0 -147
  214. package/src/capability.test.ts +0 -504
  215. package/src/capability.ts +0 -380
  216. package/src/cborCodec.test.ts +0 -263
  217. package/src/cborCodec.ts +0 -339
  218. package/src/conformance.test.ts +0 -136
  219. package/src/conformanceVectors.ts +0 -99
  220. package/src/encryption.test.ts +0 -206
  221. package/src/encryption.ts +0 -245
  222. package/src/envelopeCbor.ts +0 -140
  223. package/src/frameworkAdapters.test.ts +0 -290
  224. package/src/frameworkAdapters.ts +0 -261
  225. package/src/gateway.test.ts +0 -343
  226. package/src/gateway.ts +0 -246
  227. package/src/grpcBinding.test.ts +0 -211
  228. package/src/grpcBinding.ts +0 -103
  229. package/src/httpBinding.test.ts +0 -376
  230. package/src/httpBinding.ts +0 -189
  231. package/src/index.ts +0 -39
  232. package/src/keyInfra.test.ts +0 -278
  233. package/src/keyInfra.ts +0 -228
  234. package/src/keyRegistry.ts +0 -59
  235. package/src/keyRotation.test.ts +0 -78
  236. package/src/keyRotation.ts +0 -72
  237. package/src/mcpGateway.test.ts +0 -129
  238. package/src/mcpGateway.ts +0 -250
  239. package/src/mcpTransports.test.ts +0 -92
  240. package/src/mcpTransports.ts +0 -169
  241. package/src/mcpWrapper.test.ts +0 -179
  242. package/src/mcpWrapper.ts +0 -206
  243. package/src/otel.ts +0 -136
  244. package/src/policyEnforcer.test.ts +0 -99
  245. package/src/policyEnforcer.ts +0 -169
  246. package/src/policyTelemetryFeedback.test.ts +0 -25
  247. package/src/policyTelemetryFeedback.ts +0 -38
  248. package/src/protocol.bench.ts +0 -37
  249. package/src/protocol.d.ts.map +0 -1
  250. package/src/protocol.js +0 -294
  251. package/src/protocol.test.ts +0 -155
  252. package/src/protocol.ts +0 -414
  253. package/src/protocolAgent.test.ts +0 -105
  254. package/src/protocolAgent.ts +0 -169
  255. package/src/protocolBinary.test.ts +0 -165
  256. package/src/protocolBinary.ts +0 -312
  257. package/src/protocolCapabilities.ts +0 -70
  258. package/src/protocolFuzz.advanced.test.ts +0 -235
  259. package/src/protocolFuzz.test.ts +0 -111
  260. package/src/protocolNegative.test.ts +0 -97
  261. package/src/protocolReplay.test.ts +0 -71
  262. package/src/protocolReplay.ts +0 -194
  263. package/src/protocolTransport.test.ts +0 -556
  264. package/src/protocolTransport.ts +0 -483
  265. package/src/queueBinding.test.ts +0 -130
  266. package/src/queueBinding.ts +0 -102
  267. package/src/rateLimiter.test.ts +0 -96
  268. package/src/rateLimiter.ts +0 -46
  269. package/src/redisIntegration.test.ts +0 -134
  270. package/src/replayStores.test.ts +0 -273
  271. package/src/replayStores.ts +0 -215
  272. package/src/revocation.test.ts +0 -98
  273. package/src/revocation.ts +0 -0
  274. package/src/routePolicy.test.ts +0 -87
  275. package/src/routePolicy.ts +0 -72
  276. package/src/runtimePolicy.test.ts +0 -49
  277. package/src/runtimePolicy.ts +0 -81
  278. package/src/runtimePolicyManager.test.ts +0 -29
  279. package/src/runtimePolicyManager.ts +0 -50
  280. package/src/runtimePolicyPresets.ts +0 -43
  281. package/src/signedResponse.test.ts +0 -111
  282. package/src/signedResponse.ts +0 -83
  283. package/src/stream.test.ts +0 -254
  284. package/src/stream.ts +0 -417
  285. package/src/telemetry.test.ts +0 -251
  286. package/src/telemetry.ts +0 -299
  287. package/src/webhookBinding.test.ts +0 -144
  288. package/src/webhookBinding.ts +0 -115
  289. package/src/wsBinding.test.ts +0 -221
  290. package/src/wsBinding.ts +0 -200
  291. package/tsconfig.json +0 -15
  292. package/tsconfig.lib.json +0 -23
  293. package/vite.lib.config.ts +0 -16
  294. package/vitest.config.ts +0 -11
package/keyInfra.d.ts ADDED
@@ -0,0 +1,64 @@
1
+ import type { KeyRegistry } from './keyRegistry';
2
+ export interface KeyEntry {
3
+ id: string;
4
+ algorithm: 'Ed25519';
5
+ publicKey: string;
6
+ created: number;
7
+ expires?: number;
8
+ revoked?: boolean;
9
+ revokedAt?: number;
10
+ }
11
+ export interface WellKnownKeysDocument {
12
+ version: '7h3/0.1';
13
+ updated: number;
14
+ keys: KeyEntry[];
15
+ }
16
+ export declare function serveWellKnownKeys(doc: WellKnownKeysDocument): string;
17
+ export declare function parseWellKnownKeys(json: string): WellKnownKeysDocument;
18
+ export declare function fetchWellKnownKeys(baseUrl: string, opts?: {
19
+ timeout?: number;
20
+ }): Promise<WellKnownKeysDocument>;
21
+ export declare function createHttpKeyRegistry(opts?: {
22
+ timeout?: number;
23
+ cacheMs?: number;
24
+ }): KeyRegistry;
25
+ export interface ManagedKeyPair {
26
+ id: string;
27
+ publicKey: string;
28
+ privateKey: string;
29
+ createdAt: number;
30
+ expiresAt?: number;
31
+ }
32
+ export interface KeyRotationOptions {
33
+ maxAgeMs: number;
34
+ overlapMs?: number;
35
+ }
36
+ export declare class KeyRotationManager {
37
+ private readonly maxAgeMs;
38
+ private readonly overlapMs;
39
+ private keys;
40
+ constructor(opts: KeyRotationOptions);
41
+ addKey(pair: ManagedKeyPair): void;
42
+ getCurrentKey(): ManagedKeyPair | null;
43
+ rotateIfNeeded(): Promise<ManagedKeyPair | null>;
44
+ getWellKnownDocument(): WellKnownKeysDocument;
45
+ toKeyRegistry(): KeyRegistry;
46
+ }
47
+ export interface RevocationEntry {
48
+ id: string;
49
+ revokedAt: number;
50
+ reason?: string;
51
+ }
52
+ export interface RevocationList {
53
+ version: '7h3/0.1';
54
+ updated: number;
55
+ revokedKeys: RevocationEntry[];
56
+ }
57
+ export declare class RevocationRegistry {
58
+ private revoked;
59
+ revoke(keyId: string, reason?: string): void;
60
+ isRevoked(keyId: string): boolean;
61
+ getList(): RevocationList;
62
+ importList(list: RevocationList): void;
63
+ wrapRegistry(inner: KeyRegistry): KeyRegistry;
64
+ }
@@ -0,0 +1,9 @@
1
+ export interface KeyRegistry {
2
+ getPublicKey(senderId: string): Promise<string | null>;
3
+ getSharedSecret?(keyId: string): Promise<string | null>;
4
+ }
5
+ export declare function createStaticKeyRegistry(keys: Record<string, string>): KeyRegistry;
6
+ export declare function createCompositeKeyRegistry(...registries: KeyRegistry[]): KeyRegistry;
7
+ export declare function createCachingKeyRegistry(inner: KeyRegistry, opts?: {
8
+ ttlMs?: number;
9
+ }): KeyRegistry;
@@ -0,0 +1,20 @@
1
+ import type { ProtocolEnvelope, SignatureVerificationMaterial } from './protocol';
2
+ export type KeyStatus = 'active' | 'verify-only' | 'revoked';
3
+ export interface KeyRecord {
4
+ sender: string;
5
+ keyId: string;
6
+ alg: SignatureVerificationMaterial['alg'];
7
+ status: KeyStatus;
8
+ notBeforeMs: number;
9
+ notAfterMs: number;
10
+ material: SignatureVerificationMaterial;
11
+ }
12
+ export declare class RollingKeyring {
13
+ private readonly records;
14
+ constructor(records?: KeyRecord[]);
15
+ add(record: KeyRecord): void;
16
+ revoke(sender: string, keyId: string, revokedAtMs?: number): boolean;
17
+ selectSigningKey(sender: string, alg: SignatureVerificationMaterial['alg'], nowMs?: number): KeyRecord | null;
18
+ resolveVerificationMaterial(signature: NonNullable<ProtocolEnvelope['signature']>, sender: string, nowMs?: number): SignatureVerificationMaterial | undefined;
19
+ }
20
+ export declare function createKeyringSignatureResolver(keyring: RollingKeyring, nowMsProvider?: () => number): (signature: NonNullable<ProtocolEnvelope["signature"]>, sender: string) => Promise<SignatureVerificationMaterial | undefined>;
@@ -0,0 +1,37 @@
1
+ import { type BootstrapRuntimePolicyEnforcerOptions } from './policyEnforcer';
2
+ import { type JsonRpcPolicyEvent, type JsonRpcBridgeOptions } from './frameworkAdapters';
3
+ export interface AipMcpGatewayOptions {
4
+ sharedSecret: string;
5
+ gatewayAgentId?: string;
6
+ workerAgentId?: string;
7
+ allowedMethods?: readonly string[];
8
+ workerCapabilityPrefix?: string;
9
+ methodToCapability?: JsonRpcBridgeOptions['methodToCapability'];
10
+ authorizeMethod?: JsonRpcBridgeOptions['authorizeMethod'];
11
+ rateLimitKey?: JsonRpcBridgeOptions['rateLimitKey'];
12
+ rateLimiter?: JsonRpcBridgeOptions['rateLimiter'];
13
+ onAuditEvent?: (event: AipMcpGatewayAuditEvent) => void | Promise<void>;
14
+ gatewayWireFormat?: 'json' | 'compact' | 'binary';
15
+ workerWireFormat?: 'json' | 'compact' | 'binary';
16
+ runtimePolicy?: {
17
+ enabled?: boolean;
18
+ options?: BootstrapRuntimePolicyEnforcerOptions;
19
+ concurrencyHint?: number;
20
+ latencySensitive?: boolean;
21
+ compatibilityFirst?: boolean;
22
+ };
23
+ }
24
+ export interface AipMcpGatewayRuntime {
25
+ handleLine: (line: string) => Promise<string | null>;
26
+ }
27
+ export interface AipMcpGatewayAuditEvent {
28
+ phase: 'request_received' | 'policy' | 'verification_failed' | 'request_success' | 'request_error';
29
+ id?: string | number | null;
30
+ method?: string;
31
+ code?: number;
32
+ message?: string;
33
+ policy?: JsonRpcPolicyEvent;
34
+ timestampMs: number;
35
+ }
36
+ export declare function createAipMcpGatewayRuntime(options: AipMcpGatewayOptions): AipMcpGatewayRuntime;
37
+ export declare function createAipMcpGatewayRuntimeWithPolicy(options: AipMcpGatewayOptions): Promise<AipMcpGatewayRuntime>;
@@ -0,0 +1,62 @@
1
+ import type { IncomingMessage, ServerResponse } from 'node:http';
2
+ import type { Readable, Writable } from 'node:stream';
3
+ import type { WireEnvelope } from './protocolTransport';
4
+ /**
5
+ * Transport adapters for the MCP hardening wrapper.
6
+ *
7
+ * The wrapper (`wrapMcpServer` / `wrapMcpClient`) is transport-agnostic: it
8
+ * operates on `WireEnvelope`s. These adapters connect it to real transports —
9
+ * newline-delimited stdio and HTTP — so a secured server is deployable as-is.
10
+ *
11
+ * Note: the stdio adapter frames one envelope per line and therefore supports
12
+ * the string wire formats (`json`, `compact`). For `binary`, use HTTP.
13
+ */
14
+ type WireHandler = (raw: WireEnvelope) => Promise<WireEnvelope>;
15
+ export interface StdioServerHandle {
16
+ close(): void;
17
+ }
18
+ /**
19
+ * Serves a wrapped MCP handler over newline-delimited streams (default
20
+ * `process.stdin` / `process.stdout`). Lines are processed sequentially so
21
+ * responses are emitted in request order.
22
+ */
23
+ export declare function serveMcpOverStdio(handle: WireHandler, options?: {
24
+ input?: Readable;
25
+ output?: Writable;
26
+ onError?: (error: unknown) => void;
27
+ }): StdioServerHandle;
28
+ export interface StdioClientHandle {
29
+ send: WireHandler;
30
+ close(): void;
31
+ }
32
+ /**
33
+ * Creates a stdio client `send` function for `wrapMcpClient`. Requests and
34
+ * responses are correlated by order over the single pipe (one envelope per line).
35
+ */
36
+ export declare function createStdioMcpClient(options: {
37
+ input: Readable;
38
+ output: Writable;
39
+ }): StdioClientHandle;
40
+ /**
41
+ * Creates a `node:http`-compatible request handler that runs the wrapped MCP
42
+ * handler. The request body is the wire envelope; the response body is the
43
+ * signed reply envelope.
44
+ */
45
+ export declare function createHttpMcpHandler(handle: WireHandler, options?: {
46
+ binary?: boolean;
47
+ }): (req: IncomingMessage, res: ServerResponse) => void;
48
+ export interface HttpClientHandle {
49
+ send: WireHandler;
50
+ }
51
+ /**
52
+ * Creates an HTTP client `send` function for `wrapMcpClient`. POSTs the request
53
+ * envelope to `url` and returns the response envelope. Uses the global `fetch`
54
+ * by default; inject `fetchImpl` for tests or custom agents.
55
+ */
56
+ export declare function createHttpMcpClient(options: {
57
+ url: string;
58
+ fetchImpl?: typeof fetch;
59
+ binary?: boolean;
60
+ headers?: Record<string, string>;
61
+ }): HttpClientHandle;
62
+ export {};
@@ -0,0 +1,83 @@
1
+ import { type ProtocolEnvelope } from './protocol';
2
+ import { type ReceiveEnvelopeOptions, type WireEnvelope, type WireFormat } from './protocolTransport';
3
+ /**
4
+ * MCP hardening middleware.
5
+ *
6
+ * MCP messages are plain JSON-RPC 2.0 and, as shipped, carry no signature or
7
+ * replay protection. These wrappers put an AIP envelope around each message on
8
+ * the wire — signing, TTL-bounding, and replay-checking every request and
9
+ * response — while the underlying MCP handler still receives plain JSON-RPC.
10
+ * "Zero app changes": your handler signature does not change.
11
+ *
12
+ * The wrappers enforce four bindings beyond signature verification:
13
+ * - recipient binding: the server only runs the handler when the envelope is
14
+ * addressed to it (`recipient === selfAgentId`) — defeats cross-server relay.
15
+ * - sender binding: the client only accepts responses from its expected peer
16
+ * (`sender === peerAgentId`) — defeats response spoofing.
17
+ * - correlation binding: the client only accepts a response whose
18
+ * `correlationId` matches the request it sent — defeats response substitution.
19
+ * - replay protection on by default (an `InMemoryReplayCache` if none supplied).
20
+ *
21
+ * Verification reuses the transport pipeline (`receiveEnvelope`), so it composes
22
+ * directly with a Redis-backed replay cache (`createRedisReplayStore`) and
23
+ * fleet-wide revocation (`withRevocationCheck`) via the `receive` options.
24
+ */
25
+ export type JsonRpcId = string | number | null;
26
+ export interface JsonRpcRequest {
27
+ jsonrpc: '2.0';
28
+ id: JsonRpcId;
29
+ method: string;
30
+ params?: unknown;
31
+ }
32
+ export interface JsonRpcResponse {
33
+ jsonrpc: '2.0';
34
+ id: JsonRpcId;
35
+ result?: unknown;
36
+ error?: {
37
+ code: number;
38
+ message: string;
39
+ data?: unknown;
40
+ };
41
+ }
42
+ export type McpJsonRpcHandler = (request: JsonRpcRequest) => JsonRpcResponse | Promise<JsonRpcResponse>;
43
+ export interface McpSecurityOptions {
44
+ /** This peer's agent id, used as the envelope `sender` and enforced as the inbound `recipient`. */
45
+ selfAgentId: string;
46
+ /** The peer's agent id: set as the envelope `recipient` (client) and enforced as the response `sender`. */
47
+ peerAgentId?: string;
48
+ /** Signs an unsigned envelope, e.g. `(e) => signEnvelopeHmac(e, secret, keyId)`. */
49
+ sign: (envelope: Omit<ProtocolEnvelope, 'signature'>) => Promise<ProtocolEnvelope>;
50
+ /** Inbound verification options: signature material resolver, replay cache, clock skew, etc. */
51
+ receive?: ReceiveEnvelopeOptions;
52
+ /** Wire format for the envelope on the wire. Default `compact`. */
53
+ wireFormat?: WireFormat;
54
+ /** Envelope TTL in ms. Default 60_000. */
55
+ ttlMs?: number;
56
+ }
57
+ export interface EncodedRequest {
58
+ raw: WireEnvelope;
59
+ /** The envelope `messageId` generated for this request; bind the response's `correlationId` to it. */
60
+ messageId: string;
61
+ }
62
+ export interface DecodeResponseOptions {
63
+ /** When set, require the response `correlationId` to equal this value (the request's messageId). */
64
+ expectCorrelationId?: string;
65
+ }
66
+ /**
67
+ * Wraps an existing MCP JSON-RPC handler so every inbound message is verified
68
+ * (signature + replay + TTL + recipient binding) before the handler runs, and
69
+ * every response is signed. Returns a function over the AIP wire envelope.
70
+ */
71
+ export declare function wrapMcpServer(handler: McpJsonRpcHandler, options: McpSecurityOptions): (raw: WireEnvelope) => Promise<WireEnvelope>;
72
+ export interface McpClientCodec {
73
+ encodeRequest(request: JsonRpcRequest): Promise<EncodedRequest>;
74
+ decodeResponse(raw: WireEnvelope, options?: DecodeResponseOptions): Promise<JsonRpcResponse>;
75
+ }
76
+ /** Signs outbound requests and verifies inbound responses (with sender + correlation binding). */
77
+ export declare function createMcpClientCodec(options: McpSecurityOptions): McpClientCodec;
78
+ /**
79
+ * Wraps a transport send function (`stdio`, HTTP, ...) so callers issue and
80
+ * receive plain JSON-RPC while AIP signing, verification, and request/response
81
+ * correlation happen on the wire.
82
+ */
83
+ export declare function wrapMcpClient(send: (raw: WireEnvelope) => Promise<WireEnvelope>, options: McpSecurityOptions): (request: JsonRpcRequest) => Promise<JsonRpcResponse>;
package/otel.d.ts ADDED
@@ -0,0 +1,65 @@
1
+ /**
2
+ * otel.ts — Optional OpenTelemetry integration for 7h3 Protocol
3
+ *
4
+ * Pass your @opentelemetry/api Tracer provider via setOtelProvider.
5
+ * No hard dependency — works with any OTel-compatible SDK or without any OTel at all.
6
+ *
7
+ * Duck-typed interfaces: any object matching the shape will work, including
8
+ * the real @opentelemetry/api TracerProvider.
9
+ *
10
+ * Usage:
11
+ * import { setOtelProvider } from '@7h3/protocol/otel'
12
+ * import { trace } from '@opentelemetry/api'
13
+ *
14
+ * setOtelProvider(trace.getTracerProvider())
15
+ *
16
+ * Without OTel configured, withVerificationSpan and withAuditSpan call fn(null)
17
+ * with zero overhead.
18
+ */
19
+ /**
20
+ * A minimal OTel-compatible span interface.
21
+ * Compatible with @opentelemetry/api Span.
22
+ */
23
+ export interface OtelSpan {
24
+ setAttribute(key: string, value: string | number | boolean): void;
25
+ end(): void;
26
+ recordException(error: Error): void;
27
+ }
28
+ /**
29
+ * A minimal OTel-compatible tracer interface.
30
+ * Compatible with @opentelemetry/api Tracer.
31
+ */
32
+ export interface OtelTracer {
33
+ startSpan(name: string, attrs?: Record<string, string | number>): OtelSpan;
34
+ }
35
+ /**
36
+ * A minimal OTel-compatible provider interface.
37
+ * Compatible with @opentelemetry/api TracerProvider.
38
+ */
39
+ export interface OtelProvider {
40
+ getTracer(name: string): OtelTracer;
41
+ }
42
+ /**
43
+ * Register an OTel provider. Call once at application startup.
44
+ * Subsequent calls replace the previous provider.
45
+ */
46
+ export declare function setOtelProvider(provider: OtelProvider): void;
47
+ /**
48
+ * Returns the active OTel tracer for '7h3/protocol', or null if no provider
49
+ * has been registered.
50
+ */
51
+ export declare function getOtelTracer(): OtelTracer | null;
52
+ /**
53
+ * Creates a span named '7h3.verify' if OTel is configured, calls fn(span),
54
+ * records any exception, and ends the span on completion.
55
+ *
56
+ * If no OTel provider is registered, calls fn(null) directly with zero overhead.
57
+ */
58
+ export declare function withVerificationSpan<T>(fn: (span: OtelSpan | null) => Promise<T>, attrs?: Record<string, string | number>): Promise<T>;
59
+ /**
60
+ * Creates a span named '7h3.audit.write' if OTel is configured, calls fn(span),
61
+ * records any exception, and ends the span on completion.
62
+ *
63
+ * If no OTel provider is registered, calls fn(null) directly with zero overhead.
64
+ */
65
+ export declare function withAuditSpan<T>(fn: (span: OtelSpan | null) => Promise<T>): Promise<T>;
package/package.json CHANGED
@@ -1,132 +1,24 @@
1
1
  {
2
2
  "name": "@7h3/protocol",
3
- "version": "0.5.0",
4
- "description": "7h3 Protocol: deterministic, signed, replay-safe AI-to-AI messaging with TypeScript/Python/Rust parity. Wire version 7h3/0.1.",
3
+ "version": "0.5.2",
4
+ "description": "7h3 Protocol: deterministic, signed, replay-safe AI-to-AI message envelopes (wire 7h3/0.1).",
5
5
  "type": "module",
6
- "license": "MIT",
7
- "main": "./dist/protocol/index.js",
8
- "types": "./dist/protocol/index.d.ts",
6
+ "main": "./index.js",
7
+ "types": "./index.d.ts",
9
8
  "exports": {
10
9
  ".": {
11
- "types": "./dist/protocol/index.d.ts",
12
- "import": "./dist/protocol/index.js"
13
- },
14
- "./protocol": {
15
- "types": "./dist/protocol/index.d.ts",
16
- "import": "./dist/protocol/index.js"
17
- },
18
- "./http": {
19
- "types": "./dist/protocol/httpBinding.d.ts",
20
- "import": "./dist/protocol/httpBinding.js"
21
- },
22
- "./webhook": {
23
- "types": "./dist/protocol/webhookBinding.d.ts",
24
- "import": "./dist/protocol/webhookBinding.js"
25
- },
26
- "./queue": {
27
- "types": "./dist/protocol/queueBinding.d.ts",
28
- "import": "./dist/protocol/queueBinding.js"
29
- },
30
- "./ws": {
31
- "types": "./dist/protocol/wsBinding.d.ts",
32
- "import": "./dist/protocol/wsBinding.js"
33
- },
34
- "./grpc": {
35
- "types": "./dist/protocol/grpcBinding.d.ts",
36
- "import": "./dist/protocol/grpcBinding.js"
37
- },
38
- "./keys": {
39
- "types": "./dist/protocol/keyInfra.d.ts",
40
- "import": "./dist/protocol/keyInfra.js"
41
- },
42
- "./key-registry": {
43
- "types": "./dist/protocol/keyRegistry.d.ts",
44
- "import": "./dist/protocol/keyRegistry.js"
45
- },
46
- "./gateway": {
47
- "types": "./dist/protocol/gateway.d.ts",
48
- "import": "./dist/protocol/gateway.js"
49
- },
50
- "./audit-log": {
51
- "types": "./dist/protocol/auditLog.d.ts",
52
- "import": "./dist/protocol/auditLog.js"
53
- },
54
- "./signed-response": {
55
- "types": "./dist/protocol/signedResponse.d.ts",
56
- "import": "./dist/protocol/signedResponse.js"
57
- },
58
- "./rate-limiter": {
59
- "types": "./dist/protocol/rateLimiter.d.ts",
60
- "import": "./dist/protocol/rateLimiter.js"
61
- },
62
- "./route-policy": {
63
- "types": "./dist/protocol/routePolicy.d.ts",
64
- "import": "./dist/protocol/routePolicy.js"
65
- },
66
- "./encryption": { "types": "./dist/protocol/encryption.d.ts", "import": "./dist/protocol/encryption.js" },
67
- "./capability": { "types": "./dist/protocol/capability.d.ts", "import": "./dist/protocol/capability.js" },
68
- "./stream": { "types": "./dist/protocol/stream.d.ts", "import": "./dist/protocol/stream.js" },
69
- "./telemetry": { "types": "./dist/protocol/telemetry.d.ts", "import": "./dist/protocol/telemetry.js" },
70
- "./cbor": { "types": "./dist/protocol/envelopeCbor.d.ts", "import": "./dist/protocol/envelopeCbor.js" },
71
- "./replay": { "types": "./dist/protocol/replayStores.d.ts", "import": "./dist/protocol/replayStores.js" }
10
+ "import": "./index.js",
11
+ "types": "./index.d.ts"
12
+ }
72
13
  },
14
+ "files": [
15
+ "index.js",
16
+ "*.d.ts",
17
+ "README.md"
18
+ ],
19
+ "license": "MIT",
73
20
  "repository": {
74
21
  "type": "git",
75
22
  "url": "https://github.com/IceMasterT/7h3-protocol-aip.git"
76
- },
77
- "bin": {
78
- "7h3": "./bin/7h3.js"
79
- },
80
- "scripts": {
81
- "cli:help": "tsx bin/7h3.ts help",
82
- "cli:keygen": "tsx bin/7h3.ts keygen",
83
- "lint": "eslint .",
84
- "test": "vitest run",
85
- "build:protocol": "tsc -p tsconfig.lib.json && vite build --config vite.lib.config.ts",
86
- "package:protocol": "npm run build:protocol && tsx scripts/prepare-aip-package.ts",
87
- "bench:protocol": "vitest bench src/protocol.bench.ts",
88
- "bench:e2e:quick": "tsx scripts/bench-protocol-e2e.ts --profile quick",
89
- "bench:e2e:full": "tsx scripts/bench-protocol-e2e.ts --profile full",
90
- "aip:quickstart": "tsx scripts/aip-quickstart.ts",
91
- "aip:framework:quickstart": "tsx scripts/aip-framework-quickstart.ts",
92
- "aip:mcp:gateway": "tsx scripts/aip-mcp-gateway.ts",
93
- "aip:mcp:wrap": "tsx scripts/aip-mcp-wrap-demo.ts",
94
- "bench:openloop:quick": "tsx scripts/bench-protocol-openloop.ts --profile quick --adaptive --p99-threshold 200 --drop-threshold-pct 2",
95
- "bench:openloop:full": "tsx scripts/bench-protocol-openloop.ts --profile full --adaptive --p99-threshold 200 --drop-threshold-pct 2 --adaptive-max-doublings 6 --adaptive-binary-steps 8",
96
- "bench:openloop:stress:quick": "tsx scripts/bench-protocol-openloop.ts --profile quick",
97
- "bench:openloop:stress:full": "tsx scripts/bench-protocol-openloop.ts --profile full",
98
- "bench:signatures:quick": "tsx scripts/bench-signature-profiles.ts --profile quick",
99
- "bench:signatures:full": "tsx scripts/bench-signature-profiles.ts --profile full",
100
- "bench:wire:quick": "tsx scripts/bench-wire-codecs.ts --profile quick",
101
- "bench:wire:full": "tsx scripts/bench-wire-codecs.ts --profile full",
102
- "bench:replay:quick": "tsx scripts/bench-replay-cache.ts --profile quick",
103
- "bench:replay:full": "tsx scripts/bench-replay-cache.ts --profile full",
104
- "conformance:binary": "tsx scripts/build-binary-conformance.ts",
105
- "release:gate": "tsx scripts/release-gate.ts",
106
- "policy:validate": "tsx scripts/validate-runtime-policy.ts",
107
- "canary:plan": "tsx scripts/canary-rollout.ts",
108
- "release:dashboard": "tsx scripts/build-release-dashboard.ts",
109
- "bench:diff": "tsx scripts/bench-diff.ts",
110
- "conformance:python": "PYTHONPATH=sdk/python python3 -m unittest discover -s sdk/python/tests -v",
111
- "conformance:rust": "cargo test --manifest-path sdk/rust/Cargo.toml",
112
- "fuzz:ts": "tsx fuzz/ts/run.ts",
113
- "fuzz:ts:decode": "tsx fuzz/ts/harness-decode.ts",
114
- "fuzz:ts:verify": "tsx fuzz/ts/harness-verify.ts",
115
- "fuzz:rust:setup": "cargo install cargo-fuzz 2>/dev/null || true",
116
- "fuzz:rust:decode": "cargo +nightly fuzz run fuzz_decode --manifest-path sdk/rust/fuzz/Cargo.toml -- -max_total_time=60",
117
- "fuzz:rust:canonicalize": "cargo +nightly fuzz run fuzz_canonicalize --manifest-path sdk/rust/fuzz/Cargo.toml -- -max_total_time=60"
118
- },
119
- "devDependencies": {
120
- "@eslint/js": "^10.0.1",
121
- "@types/node": "^25.9.3",
122
- "eslint": "^10.5.0",
123
- "fast-check": "^4.8.0",
124
- "globals": "^17.6.0",
125
- "tsx": "^4.20.6",
126
- "typescript": "~6.0.3",
127
- "typescript-eslint": "^8.61.0",
128
- "vite": "^8.0.16",
129
- "vitest": "^4.1.8",
130
- "ws": "^8.18.3"
131
23
  }
132
24
  }
@@ -0,0 +1,50 @@
1
+ import { type LoadRuntimePolicyOptions, type RuntimePolicy } from './runtimePolicy';
2
+ export type RuntimeMode = 'http' | 'ws' | 'http-binary' | 'http-batch' | 'http-binary-batch' | 'ws-batch' | 'ws-binary' | 'ws-binary-batch';
3
+ export interface ModeSelectionInput {
4
+ concurrency: number;
5
+ latencySensitive?: boolean;
6
+ compatibilityFirst?: boolean;
7
+ }
8
+ export interface TuningInput {
9
+ trafficClass: 'low' | 'medium' | 'high';
10
+ p99Ms?: number;
11
+ dropPct?: number;
12
+ }
13
+ export interface TuningDecision {
14
+ batchSizeRange: [number, number];
15
+ inflightCapRange: [number, number];
16
+ retryBackoffMsRange: [number, number];
17
+ actions: string[];
18
+ }
19
+ export interface RetryInput {
20
+ error: unknown;
21
+ attempt: number;
22
+ }
23
+ export interface InvariantConfig {
24
+ signatureVerification: boolean;
25
+ canonicalization: boolean;
26
+ replayDefense: boolean;
27
+ ttlClockSkewEnforcement: boolean;
28
+ }
29
+ export declare function createPolicyEnforcer(policy: RuntimePolicy): {
30
+ selectMode: (input: ModeSelectionInput) => RuntimeMode;
31
+ tune: (input: TuningInput) => TuningDecision;
32
+ shouldRetry: (input: RetryInput) => boolean;
33
+ assertInvariant: (config: InvariantConfig) => void;
34
+ metadata: {
35
+ policyName: string;
36
+ policyVersion: string;
37
+ policyStatus: string;
38
+ enforcedSlo: {
39
+ dropPctMax: number;
40
+ p99MsMax: number;
41
+ };
42
+ };
43
+ };
44
+ export type PolicyEnforcer = ReturnType<typeof createPolicyEnforcer>;
45
+ export type BootstrapRuntimePolicyEnforcerOptions = LoadRuntimePolicyOptions;
46
+ export declare function bootstrapRuntimePolicyEnforcer(options?: BootstrapRuntimePolicyEnforcerOptions): Promise<{
47
+ policy: RuntimePolicy;
48
+ enforcer: PolicyEnforcer;
49
+ }>;
50
+ export declare function isRuntimeMode(value: string): value is RuntimeMode;
@@ -0,0 +1,11 @@
1
+ export interface TelemetryFeedbackInput {
2
+ mode: string;
3
+ p99Ms: number;
4
+ dropPct: number;
5
+ concurrency: number;
6
+ }
7
+ export interface TelemetryFeedbackRecommendation {
8
+ severity: 'normal' | 'warn' | 'critical';
9
+ actions: string[];
10
+ }
11
+ export declare function recommendPolicyAdjustments(input: TelemetryFeedbackInput): TelemetryFeedbackRecommendation;
@@ -1,5 +1,5 @@
1
1
  export type ProtocolVersion = '7h3/0.1';
2
- export type IntentKind = 'PING' | 'PONG' | 'CAPS' | 'TASK' | 'RESULT' | 'ERROR';
2
+ export type IntentKind = 'PING' | 'PONG' | 'CAPS' | 'TASK' | 'RESULT' | 'ERROR' | 'ENCRYPTED';
3
3
  export interface ProtocolHeader {
4
4
  version: ProtocolVersion;
5
5
  messageId: string;
@@ -37,6 +37,11 @@ export type SignatureVerificationMaterial = {
37
37
  publicKey: string;
38
38
  };
39
39
  export declare function canonicalizeEnvelope(envelope: Omit<ProtocolEnvelope, 'signature'>): string;
40
+ /**
41
+ * Cryptographically secure random hex string. Nonces are the replay-protection
42
+ * primitive, so they must come from a CSPRNG — never Math.random().
43
+ */
44
+ export declare function randomHex(bytes?: number): string;
40
45
  export declare function signCanonicalPayloadHmac(payload: string, secret: string): Promise<string>;
41
46
  export declare function verifyCanonicalPayloadHmac(payload: string, signature: string, secret: string): Promise<boolean>;
42
47
  export declare function generateEd25519KeypairBase64Url(): Promise<{
@@ -64,4 +69,3 @@ export declare function createEnvelope(input: {
64
69
  nonce?: string;
65
70
  nowMs?: number;
66
71
  }): Omit<ProtocolEnvelope, 'signature'>;
67
- //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1,58 @@
1
+ import { type IntentKind, type ProtocolDiagnostic, type ProtocolEnvelope } from './protocol';
2
+ import { type AckMode } from './protocolCapabilities';
3
+ import { InMemoryReplayCache } from './protocolReplay';
4
+ import { type WireEnvelope, type WireFormat } from './protocolTransport';
5
+ export interface TaskHandlerResult {
6
+ intent?: 'RESULT' | 'ERROR';
7
+ content: string;
8
+ capability?: string;
9
+ }
10
+ export interface AgentSessionConfig {
11
+ agentId: string;
12
+ outboundSecret: string;
13
+ keyId?: string;
14
+ capabilities?: string[];
15
+ supportedWireFormats?: WireFormat[];
16
+ maxBatchSize?: number;
17
+ ackModes?: AckMode[];
18
+ requireSignature?: boolean;
19
+ replayCache?: InMemoryReplayCache;
20
+ sharedSecrets?: Record<string, string>;
21
+ resolveInboundSecret?: (keyId: string, sender: string) => string | undefined | Promise<string | undefined>;
22
+ onTask?: (envelope: ProtocolEnvelope) => TaskHandlerResult | Promise<TaskHandlerResult>;
23
+ }
24
+ export interface AgentReceiveResult {
25
+ ok: boolean;
26
+ diagnostics: ProtocolDiagnostic[];
27
+ received: ProtocolEnvelope | null;
28
+ response: ProtocolEnvelope | null;
29
+ }
30
+ export declare class AgentSession {
31
+ private readonly agentId;
32
+ private readonly outboundSecret;
33
+ private readonly keyId;
34
+ private readonly capabilities;
35
+ private readonly supportedWireFormats;
36
+ private readonly maxBatchSize;
37
+ private readonly ackModes;
38
+ private readonly requireSignature;
39
+ private readonly replayCache;
40
+ private readonly sharedSecrets;
41
+ private readonly resolveInboundSecret?;
42
+ private readonly onTask?;
43
+ constructor(config: AgentSessionConfig);
44
+ private inboundSecretResolver;
45
+ createSignedIntent(input: {
46
+ recipient?: string;
47
+ intent: IntentKind;
48
+ content: string;
49
+ capability?: string;
50
+ correlationId?: string;
51
+ ttlMs?: number;
52
+ messageId?: string;
53
+ nonce?: string;
54
+ nowMs?: number;
55
+ }): Promise<ProtocolEnvelope>;
56
+ receiveAndRespond(input: WireEnvelope | ProtocolEnvelope, nowMs?: number): Promise<AgentReceiveResult>;
57
+ private buildAutoResponse;
58
+ }
@@ -0,0 +1,8 @@
1
+ import type { ProtocolEnvelope } from './protocol';
2
+ import type { ReceiveEnvelopeResult } from './protocolTransport';
3
+ export declare const DEFAULT_MAX_BINARY_ENVELOPE_BYTES: number;
4
+ export interface BinaryDecodeOptions {
5
+ maxFrameBytes?: number;
6
+ }
7
+ export declare function encodeEnvelopeBinary(envelope: ProtocolEnvelope): Uint8Array;
8
+ export declare function decodeEnvelopeBinary(payload: Uint8Array, options?: BinaryDecodeOptions): ReceiveEnvelopeResult;