@7h3/protocol 0.5.0 → 0.5.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.
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 +3662 -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} +1 -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
@@ -1,93 +0,0 @@
1
- {
2
- "generatedAt": "2026-05-15T03:36:03.081Z",
3
- "profile": "quick",
4
- "iterations": 10000,
5
- "payloadSizes": [
6
- 256,
7
- 1024,
8
- 4096,
9
- 16384
10
- ],
11
- "results": [
12
- {
13
- "profile": "quick",
14
- "payloadBytes": 256,
15
- "format": "compact-json",
16
- "encodedBytes": 498,
17
- "encodeUsPerOp": 0.793,
18
- "decodeUsPerOp": 1.03,
19
- "encodeOpsPerSecond": 1261085.096,
20
- "decodeOpsPerSecond": 971138.351
21
- },
22
- {
23
- "profile": "quick",
24
- "payloadBytes": 256,
25
- "format": "binary",
26
- "encodedBytes": 426,
27
- "encodeUsPerOp": 5.529,
28
- "decodeUsPerOp": 2.827,
29
- "encodeOpsPerSecond": 180848.871,
30
- "decodeOpsPerSecond": 353762.342
31
- },
32
- {
33
- "profile": "quick",
34
- "payloadBytes": 1024,
35
- "format": "compact-json",
36
- "encodedBytes": 1269,
37
- "encodeUsPerOp": 1.07,
38
- "decodeUsPerOp": 1.066,
39
- "encodeOpsPerSecond": 934445.822,
40
- "decodeOpsPerSecond": 937718.078
41
- },
42
- {
43
- "profile": "quick",
44
- "payloadBytes": 1024,
45
- "format": "binary",
46
- "encodedBytes": 1197,
47
- "encodeUsPerOp": 7.638,
48
- "decodeUsPerOp": 2.989,
49
- "encodeOpsPerSecond": 130926.791,
50
- "decodeOpsPerSecond": 334577.225
51
- },
52
- {
53
- "profile": "quick",
54
- "payloadBytes": 4096,
55
- "format": "compact-json",
56
- "encodedBytes": 4341,
57
- "encodeUsPerOp": 3.104,
58
- "decodeUsPerOp": 1.807,
59
- "encodeOpsPerSecond": 322159.811,
60
- "decodeOpsPerSecond": 553432.68
61
- },
62
- {
63
- "profile": "quick",
64
- "payloadBytes": 4096,
65
- "format": "binary",
66
- "encodedBytes": 4269,
67
- "encodeUsPerOp": 8.986,
68
- "decodeUsPerOp": 3.036,
69
- "encodeOpsPerSecond": 111280.79,
70
- "decodeOpsPerSecond": 329346.831
71
- },
72
- {
73
- "profile": "quick",
74
- "payloadBytes": 16384,
75
- "format": "compact-json",
76
- "encodedBytes": 16632,
77
- "encodeUsPerOp": 8.292,
78
- "decodeUsPerOp": 4.561,
79
- "encodeOpsPerSecond": 120595.796,
80
- "decodeOpsPerSecond": 219271.207
81
- },
82
- {
83
- "profile": "quick",
84
- "payloadBytes": 16384,
85
- "format": "binary",
86
- "encodedBytes": 16560,
87
- "encodeUsPerOp": 15.204,
88
- "decodeUsPerOp": 4.587,
89
- "encodeOpsPerSecond": 65772.192,
90
- "decodeOpsPerSecond": 217984.825
91
- }
92
- ]
93
- }
@@ -1,93 +0,0 @@
1
- {
2
- "generatedAt": "2026-05-15T11:18:56.130Z",
3
- "profile": "quick",
4
- "iterations": 10000,
5
- "payloadSizes": [
6
- 256,
7
- 1024,
8
- 4096,
9
- 16384
10
- ],
11
- "results": [
12
- {
13
- "profile": "quick",
14
- "payloadBytes": 256,
15
- "format": "compact-json",
16
- "encodedBytes": 498,
17
- "encodeUsPerOp": 0.861,
18
- "decodeUsPerOp": 0.93,
19
- "encodeOpsPerSecond": 1161370.719,
20
- "decodeOpsPerSecond": 1075066.173
21
- },
22
- {
23
- "profile": "quick",
24
- "payloadBytes": 256,
25
- "format": "binary",
26
- "encodedBytes": 426,
27
- "encodeUsPerOp": 6.016,
28
- "decodeUsPerOp": 2.499,
29
- "encodeOpsPerSecond": 166209.883,
30
- "decodeOpsPerSecond": 400117.683
31
- },
32
- {
33
- "profile": "quick",
34
- "payloadBytes": 1024,
35
- "format": "compact-json",
36
- "encodedBytes": 1269,
37
- "encodeUsPerOp": 0.963,
38
- "decodeUsPerOp": 0.904,
39
- "encodeOpsPerSecond": 1038530.737,
40
- "decodeOpsPerSecond": 1105743.219
41
- },
42
- {
43
- "profile": "quick",
44
- "payloadBytes": 1024,
45
- "format": "binary",
46
- "encodedBytes": 1197,
47
- "encodeUsPerOp": 6.58,
48
- "decodeUsPerOp": 2.551,
49
- "encodeOpsPerSecond": 151983.004,
50
- "decodeOpsPerSecond": 391961.804
51
- },
52
- {
53
- "profile": "quick",
54
- "payloadBytes": 4096,
55
- "format": "compact-json",
56
- "encodedBytes": 4341,
57
- "encodeUsPerOp": 2.29,
58
- "decodeUsPerOp": 1.706,
59
- "encodeOpsPerSecond": 436690.681,
60
- "decodeOpsPerSecond": 586132.045
61
- },
62
- {
63
- "profile": "quick",
64
- "payloadBytes": 4096,
65
- "format": "binary",
66
- "encodedBytes": 4269,
67
- "encodeUsPerOp": 8.274,
68
- "decodeUsPerOp": 2.81,
69
- "encodeOpsPerSecond": 120859.221,
70
- "decodeOpsPerSecond": 355922.792
71
- },
72
- {
73
- "profile": "quick",
74
- "payloadBytes": 16384,
75
- "format": "compact-json",
76
- "encodedBytes": 16632,
77
- "encodeUsPerOp": 6.953,
78
- "decodeUsPerOp": 3.802,
79
- "encodeOpsPerSecond": 143830.843,
80
- "decodeOpsPerSecond": 263020.978
81
- },
82
- {
83
- "profile": "quick",
84
- "payloadBytes": 16384,
85
- "format": "binary",
86
- "encodedBytes": 16560,
87
- "encodeUsPerOp": 13.34,
88
- "decodeUsPerOp": 3.786,
89
- "encodeOpsPerSecond": 74962.159,
90
- "decodeOpsPerSecond": 264160.181
91
- }
92
- ]
93
- }
package/bin/7h3.ts DELETED
@@ -1,406 +0,0 @@
1
- #!/usr/bin/env node
2
- import { parseArgs } from 'node:util'
3
- import { createServer } from 'node:http'
4
- import { writeFileSync } from 'node:fs'
5
-
6
- const USAGE = `
7
- 7h3 — Aurelion Interaction Protocol CLI (wire version 7h3/0.1)
8
-
9
- Usage:
10
- 7h3 keygen [--output <file>]
11
- 7h3 sign --private-key <key> --sender <id> [--recipient <id>] [--payload <str>] [--ttl <ms>]
12
- 7h3 verify --public-key <key> --envelope <json>
13
- 7h3 inspect --envelope <json>
14
- 7h3 gateway --upstream <url> [--port <n>] [--public-key <key>] [--require ed25519|none]
15
- [--sign-responses] [--private-key <key>] [--sender <id>] [--metrics-port <n>]
16
- 7h3 keys serve [--public-key <key>] [--key-id <id>] [--port <n>]
17
- 7h3 help
18
-
19
- Commands:
20
- keygen Generate an Ed25519 keypair (PKCS8/SPKI, base64url-encoded)
21
- sign Create and sign an AIP envelope
22
- verify Verify an AIP envelope signature
23
- inspect Pretty-print an AIP envelope fields
24
- gateway Run a verifying HTTP proxy gateway
25
- keys serve Serve a /.well-known/7h3-keys endpoint
26
- help Show this usage table
27
- `
28
-
29
- function die(msg: string): never {
30
- process.stderr.write(`Error: ${msg}\n`)
31
- process.exit(1)
32
- }
33
-
34
- async function cmdKeygen(argv: string[]): Promise<void> {
35
- const { values } = parseArgs({
36
- args: argv,
37
- options: {
38
- output: { type: 'string', short: 'o' },
39
- },
40
- strict: false,
41
- })
42
-
43
- const { generateEd25519KeypairBase64Url } = await import('../src/protocol.js')
44
- const { publicKey, privateKey } = await generateEd25519KeypairBase64Url()
45
-
46
- const result = {
47
- algorithm: 'Ed25519',
48
- wireVersion: '7h3/0.1',
49
- publicKey,
50
- privateKey,
51
- createdAt: new Date().toISOString(),
52
- warning: 'Keep privateKey secret — it grants signing authority over your agent identity.',
53
- }
54
-
55
- const json = JSON.stringify(result, null, 2)
56
-
57
- if (values.output) {
58
- writeFileSync(values.output as string, json, 'utf8')
59
- process.stdout.write(`Keypair written to ${values.output}\n`)
60
- process.stdout.write(` algorithm : Ed25519\n`)
61
- process.stdout.write(` publicKey : ${publicKey}\n`)
62
- process.stdout.write(` createdAt : ${result.createdAt}\n`)
63
- } else {
64
- process.stdout.write(json + '\n')
65
- }
66
- }
67
-
68
- async function cmdSign(argv: string[]): Promise<void> {
69
- const { values } = parseArgs({
70
- args: argv,
71
- options: {
72
- 'private-key': { type: 'string' },
73
- sender: { type: 'string' },
74
- recipient: { type: 'string' },
75
- payload: { type: 'string' },
76
- ttl: { type: 'string' },
77
- },
78
- strict: false,
79
- })
80
-
81
- const privateKey = values['private-key'] as string | undefined
82
- const sender = values['sender'] as string | undefined
83
-
84
- if (!privateKey) die('--private-key is required')
85
- if (!sender) die('--sender is required')
86
-
87
- const { createEnvelope, signEnvelopeEd25519 } = await import('../src/protocol.js')
88
-
89
- const envelope = createEnvelope({
90
- sender: sender!,
91
- recipient: values['recipient'] as string | undefined,
92
- intent: 'PING',
93
- content: (values['payload'] as string | undefined) ?? '',
94
- ttlMs: values['ttl'] ? parseInt(values['ttl'] as string, 10) : 60_000,
95
- })
96
-
97
- const signed = await signEnvelopeEd25519(envelope, privateKey!)
98
- process.stdout.write(JSON.stringify(signed) + '\n')
99
- }
100
-
101
- async function cmdVerify(argv: string[]): Promise<void> {
102
- const { values } = parseArgs({
103
- args: argv,
104
- options: {
105
- 'public-key': { type: 'string' },
106
- envelope: { type: 'string' },
107
- },
108
- strict: false,
109
- })
110
-
111
- const publicKey = values['public-key'] as string | undefined
112
- const envelopeJson = values['envelope'] as string | undefined
113
-
114
- if (!publicKey) die('--public-key is required')
115
- if (!envelopeJson) die('--envelope is required')
116
-
117
- const { validateEnvelope, verifyEnvelopeEd25519 } = await import('../src/protocol.js')
118
-
119
- let envelope: ReturnType<typeof JSON.parse>
120
- try {
121
- envelope = JSON.parse(envelopeJson!)
122
- } catch {
123
- die('--envelope is not valid JSON')
124
- }
125
-
126
- const diagnostics = validateEnvelope(envelope)
127
- const errors = diagnostics.filter(d => d.level === 'error')
128
- const warnings = diagnostics.filter(d => d.level === 'warning')
129
-
130
- if (errors.length > 0) {
131
- process.stdout.write('INVALID — envelope validation errors:\n')
132
- for (const e of errors) process.stdout.write(` [error] ${e.message}\n`)
133
- for (const w of warnings) process.stdout.write(` [warning] ${w.message}\n`)
134
- process.exit(1)
135
- }
136
-
137
- const valid = await verifyEnvelopeEd25519(envelope, publicKey!)
138
-
139
- if (valid) {
140
- process.stdout.write('Signature valid\n')
141
- if (warnings.length > 0) {
142
- for (const w of warnings) process.stdout.write(` [warning] ${w.message}\n`)
143
- }
144
- } else {
145
- process.stdout.write('INVALID — signature verification failed\n')
146
- process.stdout.write(` alg : ${envelope.signature?.alg ?? 'none'}\n`)
147
- process.stdout.write(` keyId : ${envelope.signature?.keyId ?? 'none'}\n`)
148
- process.exit(1)
149
- }
150
- }
151
-
152
- async function cmdInspect(argv: string[]): Promise<void> {
153
- const { values } = parseArgs({
154
- args: argv,
155
- options: {
156
- envelope: { type: 'string' },
157
- },
158
- strict: false,
159
- })
160
-
161
- const envelopeJson = values['envelope'] as string | undefined
162
- if (!envelopeJson) die('--envelope is required')
163
-
164
- let envelope: ReturnType<typeof JSON.parse>
165
- try {
166
- envelope = JSON.parse(envelopeJson!)
167
- } catch {
168
- die('--envelope is not valid JSON')
169
- }
170
-
171
- const h = envelope.header ?? {}
172
- const b = envelope.body ?? {}
173
- const s = envelope.signature
174
-
175
- const nowMs = Date.now()
176
- const expiresMs = (h.timestampMs ?? 0) + (h.ttlMs ?? 0)
177
- const expired = expiresMs < nowMs
178
- const expiresStatus = expired
179
- ? `EXPIRED (${new Date(expiresMs).toISOString()})`
180
- : `OK — expires ${new Date(expiresMs).toISOString()}`
181
-
182
- const content: string = typeof b.content === 'string' ? b.content : ''
183
- const contentPreview = content.length > 80 ? content.slice(0, 77) + '...' : content
184
-
185
- process.stdout.write(`Wire Version : ${h.version ?? '(none)'}\n`)
186
- process.stdout.write(`Message ID : ${h.messageId ?? '(none)'}\n`)
187
- process.stdout.write(`Sender : ${h.sender ?? '(none)'}\n`)
188
- process.stdout.write(`Recipient : ${h.recipient ?? '(none)'}\n`)
189
- process.stdout.write(`Timestamp : ${h.timestampMs ? new Date(h.timestampMs).toISOString() : '(none)'}\n`)
190
- process.stdout.write(`TTL : ${h.ttlMs ?? '(none)'} ms\n`)
191
- process.stdout.write(`Expires : ${expiresStatus}\n`)
192
- process.stdout.write(`Intent : ${b.intent ?? '(none)'}\n`)
193
- process.stdout.write(`Content : ${contentPreview || '(empty)'}\n`)
194
- if (s) {
195
- process.stdout.write(`Sig alg : ${s.alg}\n`)
196
- process.stdout.write(`Sig keyId : ${s.keyId}\n`)
197
- } else {
198
- process.stdout.write(`Signature : (none)\n`)
199
- }
200
- }
201
-
202
- async function cmdGateway(argv: string[]): Promise<void> {
203
- const { values } = parseArgs({
204
- args: argv,
205
- options: {
206
- upstream: { type: 'string' },
207
- port: { type: 'string' },
208
- 'public-key': { type: 'string' },
209
- require: { type: 'string' },
210
- 'sign-responses': { type: 'boolean' },
211
- 'private-key': { type: 'string' },
212
- sender: { type: 'string' },
213
- 'metrics-port': { type: 'string' },
214
- },
215
- strict: false,
216
- })
217
-
218
- const upstream = values['upstream'] as string | undefined
219
- if (!upstream) die('--upstream is required')
220
-
221
- const port = parseInt((values['port'] as string | undefined) ?? '8080', 10)
222
- const publicKey = values['public-key'] as string | undefined
223
- const requireMode = (values['require'] as string | undefined) ?? (publicKey ? 'ed25519' : 'none')
224
- const signResponses = !!(values['sign-responses'])
225
- const privateKey = values['private-key'] as string | undefined
226
- const sender = values['sender'] as string | undefined
227
- const metricsPortRaw = values['metrics-port'] as string | undefined
228
- const metricsPort = metricsPortRaw ? parseInt(metricsPortRaw, 10) : undefined
229
-
230
- const { createGateway } = await import('../src/gateway.js')
231
- const { createStaticKeyRegistry } = await import('../src/keyRegistry.js')
232
-
233
- const keys: Record<string, string> = {}
234
- if (publicKey && sender) keys[sender] = publicKey
235
- const keyRegistry = createStaticKeyRegistry(keys)
236
-
237
- const gateway = createGateway({
238
- upstream: upstream!,
239
- keyRegistry,
240
- signResponses: signResponses && !!privateKey,
241
- privateKey,
242
- sender,
243
- defaultPolicy: requireMode === 'none' ? 'allow' : 'deny',
244
- })
245
-
246
- const server = createServer(async (req, res) => {
247
- const chunks: Buffer[] = []
248
- req.on('data', (chunk: Buffer) => chunks.push(chunk))
249
- req.on('end', async () => {
250
- const body = Buffer.concat(chunks)
251
-
252
- // Flatten headers: string | string[] => string
253
- const headers: Record<string, string> = {}
254
- for (const [k, v] of Object.entries(req.headers)) {
255
- if (v === undefined) continue
256
- headers[k] = Array.isArray(v) ? v.join(', ') : v
257
- }
258
-
259
- try {
260
- const result = await gateway.handle({
261
- method: req.method ?? 'GET',
262
- path: req.url ?? '/',
263
- headers,
264
- body: body.length > 0 ? body.toString('utf8') : undefined,
265
- })
266
- res.writeHead(result.status, result.headers)
267
- res.end(result.body)
268
- } catch (err) {
269
- res.writeHead(502, { 'content-type': 'text/plain' })
270
- res.end(`Gateway error: ${String(err)}`)
271
- }
272
- })
273
- })
274
-
275
- server.listen(port, () => {
276
- process.stderr.write(`7h3 gateway listening on port ${port}\n`)
277
- process.stderr.write(` upstream : ${upstream}\n`)
278
- process.stderr.write(` verify mode : ${requireMode}\n`)
279
- process.stderr.write(` sign-responses: ${signResponses && !!privateKey}\n`)
280
- if (sender) process.stderr.write(` sender : ${sender}\n`)
281
- })
282
-
283
- // Optional: dedicated metrics server
284
- if (metricsPort !== undefined) {
285
- const { metrics: globalMetrics, renderPrometheusText } = await import('../src/telemetry.js')
286
- const metricsServer = createServer((req, res) => {
287
- if (req.url === '/metrics' && req.method === 'GET') {
288
- const body = renderPrometheusText(globalMetrics)
289
- res.writeHead(200, { 'content-type': 'text/plain; version=0.0.4; charset=utf-8' })
290
- res.end(body)
291
- } else {
292
- res.writeHead(404, { 'content-type': 'text/plain' })
293
- res.end('Not Found')
294
- }
295
- })
296
- metricsServer.listen(metricsPort, () => {
297
- process.stderr.write(`7h3 metrics listening on :${metricsPort}/metrics\n`)
298
- })
299
- }
300
- }
301
-
302
- async function cmdKeysServe(argv: string[]): Promise<void> {
303
- const { values } = parseArgs({
304
- args: argv,
305
- options: {
306
- 'public-key': { type: 'string' },
307
- 'key-id': { type: 'string' },
308
- port: { type: 'string' },
309
- },
310
- strict: false,
311
- })
312
-
313
- const publicKey = values['public-key'] as string | undefined
314
- const keyId = (values['key-id'] as string | undefined) ?? 'default'
315
- const port = parseInt((values['port'] as string | undefined) ?? '8081', 10)
316
-
317
- const { serveWellKnownKeys } = await import('../src/keyInfra.js')
318
-
319
- const doc = {
320
- version: '7h3/0.1' as const,
321
- updated: Date.now(),
322
- keys: publicKey
323
- ? [
324
- {
325
- id: keyId,
326
- algorithm: 'Ed25519' as const,
327
- publicKey,
328
- created: Date.now(),
329
- },
330
- ]
331
- : [],
332
- }
333
-
334
- const body = serveWellKnownKeys(doc)
335
-
336
- const server = createServer((req, res) => {
337
- if (req.url === '/.well-known/7h3-keys') {
338
- res.writeHead(200, { 'content-type': 'application/json' })
339
- res.end(body)
340
- } else {
341
- res.writeHead(404, { 'content-type': 'text/plain' })
342
- res.end('Not Found')
343
- }
344
- })
345
-
346
- server.listen(port, () => {
347
- process.stderr.write(`7h3 key server listening on port ${port}\n`)
348
- process.stderr.write(` GET /.well-known/7h3-keys\n`)
349
- if (publicKey) process.stderr.write(` key-id: ${keyId}\n`)
350
- else process.stderr.write(` (no keys configured — empty document)\n`)
351
- })
352
- }
353
-
354
- async function main(): Promise<void> {
355
- const args = process.argv.slice(2)
356
- const command = args[0] ?? 'help'
357
- const rest = args.slice(1)
358
-
359
- switch (command) {
360
- case 'keygen':
361
- await cmdKeygen(rest)
362
- break
363
-
364
- case 'sign':
365
- await cmdSign(rest)
366
- break
367
-
368
- case 'verify':
369
- await cmdVerify(rest)
370
- break
371
-
372
- case 'inspect':
373
- await cmdInspect(rest)
374
- break
375
-
376
- case 'gateway':
377
- await cmdGateway(rest)
378
- break
379
-
380
- case 'keys': {
381
- const sub = rest[0]
382
- if (sub === 'serve') {
383
- await cmdKeysServe(rest.slice(1))
384
- } else {
385
- die(`Unknown subcommand 'keys ${sub ?? ''}'. Did you mean 'keys serve'?`)
386
- }
387
- break
388
- }
389
-
390
- case 'help':
391
- case '--help':
392
- case '-h':
393
- process.stdout.write(USAGE)
394
- break
395
-
396
- default:
397
- process.stderr.write(`Unknown command: ${command}\n`)
398
- process.stdout.write(USAGE)
399
- process.exit(1)
400
- }
401
- }
402
-
403
- main().catch(err => {
404
- process.stderr.write(`Fatal: ${String(err)}\n`)
405
- process.exit(1)
406
- })
@@ -1,77 +0,0 @@
1
- {
2
- "version": "7h3/0.1",
3
- "vectors": [
4
- {
5
- "id": "task-with-capability-and-recipient",
6
- "secret": "vector-secret-1",
7
- "keyId": "vector-key-1",
8
- "envelope": {
9
- "header": {
10
- "version": "7h3/0.1",
11
- "messageId": "vec-1",
12
- "timestampMs": 1712500000000,
13
- "ttlMs": 60000,
14
- "sender": "agent.alpha",
15
- "recipient": "agent.beta",
16
- "nonce": "nonce-vec-1"
17
- },
18
- "body": {
19
- "intent": "TASK",
20
- "content": "route:alpha->beta",
21
- "capability": "task.plan",
22
- "correlationId": "corr-1"
23
- }
24
- },
25
- "canonical": "{\"body\":{\"capability\":\"task.plan\",\"content\":\"route:alpha->beta\",\"correlationId\":\"corr-1\",\"intent\":\"TASK\"},\"header\":{\"messageId\":\"vec-1\",\"nonce\":\"nonce-vec-1\",\"recipient\":\"agent.beta\",\"sender\":\"agent.alpha\",\"timestampMs\":1712500000000,\"ttlMs\":60000,\"version\":\"7h3/0.1\"}}",
26
- "signature": "bZP1N1f4w4RGSKw6pfdcA6dQjvpv9nIHAQCttjNCZyI"
27
- },
28
- {
29
- "id": "result-with-minimal-fields",
30
- "secret": "vector-secret-2",
31
- "keyId": "vector-key-2",
32
- "envelope": {
33
- "header": {
34
- "version": "7h3/0.1",
35
- "messageId": "vec-2",
36
- "timestampMs": 1712500005000,
37
- "ttlMs": 30000,
38
- "sender": "memory.agent",
39
- "nonce": "nonce-vec-2"
40
- },
41
- "body": {
42
- "intent": "RESULT",
43
- "content": "memory:ok"
44
- }
45
- },
46
- "canonical": "{\"body\":{\"content\":\"memory:ok\",\"intent\":\"RESULT\"},\"header\":{\"messageId\":\"vec-2\",\"nonce\":\"nonce-vec-2\",\"sender\":\"memory.agent\",\"timestampMs\":1712500005000,\"ttlMs\":30000,\"version\":\"7h3/0.1\"}}",
47
- "signature": "_soWM4GZS8qWZDWyXEeXPaQp7Diyp2SQua9mKy2q0BQ"
48
- }
49
- ],
50
- "ed25519Vectors": [
51
- {
52
- "id": "task-ed25519-with-recipient",
53
- "keyId": "ed-vector-key-1",
54
- "publicKey": "MCowBQYDK2VwAyEA-mUFiTQtcKN4nnD19V_-Wyy4q19OivnAutRUPhOcC78",
55
- "privateKey": "MC4CAQAwBQYDK2VwBCIEICheZbQGuDVb6hezIlcs0QnCHGxz6IhiLkC9M0qr8OOZ",
56
- "envelope": {
57
- "header": {
58
- "version": "7h3/0.1",
59
- "messageId": "vec-ed-1",
60
- "timestampMs": 1712500010000,
61
- "ttlMs": 45000,
62
- "sender": "agent.ed",
63
- "recipient": "agent.verify",
64
- "nonce": "nonce-ed-1"
65
- },
66
- "body": {
67
- "intent": "TASK",
68
- "content": "route:ed25519",
69
- "capability": "task.sign",
70
- "correlationId": "corr-ed-1"
71
- }
72
- },
73
- "canonical": "{\"body\":{\"capability\":\"task.sign\",\"content\":\"route:ed25519\",\"correlationId\":\"corr-ed-1\",\"intent\":\"TASK\"},\"header\":{\"messageId\":\"vec-ed-1\",\"nonce\":\"nonce-ed-1\",\"recipient\":\"agent.verify\",\"sender\":\"agent.ed\",\"timestampMs\":1712500010000,\"ttlMs\":45000,\"version\":\"7h3/0.1\"}}",
74
- "signature": "AAWu-6pp7NQZ-NtWKrgREWlMBx-kMZZzZ5dIiBqOdT-zdr-u4HtS6upE79yX7UUNPYUfyKs7lfssi0EeOvIxAA"
75
- }
76
- ]
77
- }
@@ -1,20 +0,0 @@
1
- {
2
- "generatedAt": "2026-06-28T00:56:52.383Z",
3
- "vectors": [
4
- {
5
- "id": "task-with-capability-and-recipient",
6
- "alg": "HS256",
7
- "binaryHex": "41495042010f0000018eb8f445000000ea60000000073768332f302e31000000057665632d310000000b6167656e742e616c7068610000000b6e6f6e63652d7665632d31000000045441534b00000011726f7574653a616c7068612d3e626574610000000a6167656e742e62657461000000097461736b2e706c616e00000006636f72722d31010000000c766563746f722d6b65792d310000002b625a50314e31663477345247534b773670666463413664516a767076396e494841514374746a4e435a7949"
8
- },
9
- {
10
- "id": "result-with-minimal-fields",
11
- "alg": "HS256",
12
- "binaryHex": "4149504201080000018eb8f4588800007530000000073768332f302e31000000057665632d320000000c6d656d6f72792e6167656e740000000b6e6f6e63652d7665632d3200000006524553554c54000000096d656d6f72793a6f6b010000000c766563746f722d6b65792d320000002b5f736f574d34475a533871575a445779584565585061517037446979703253517561396d4b793271304251"
13
- },
14
- {
15
- "id": "task-ed25519-with-recipient",
16
- "alg": "ED25519",
17
- "binaryHex": "41495042010f0000018eb8f46c100000afc8000000073768332f302e31000000087665632d65642d31000000086167656e742e65640000000a6e6f6e63652d65642d31000000045441534b0000000d726f7574653a656432353531390000000c6167656e742e766572696679000000097461736b2e7369676e00000009636f72722d65642d31020000000f65642d766563746f722d6b65792d3100000056414157752d367070374e515a2d4e74574b72675245576c4d42782d6b4d5a5a7a5a3564496942714f64542d7a64722d753448745336757045373979583755554e50595566794b73376c667373693045654f7649784141"
18
- }
19
- ]
20
- }