@lqc123qwe/car-runtime 1.8.0 → 1.10.0

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 (178) hide show
  1. package/README.md +29 -1
  2. package/dist/SHA256SUMS +1 -0
  3. package/dist/authz/authz.d.ts +44 -0
  4. package/dist/authz/authz.js +65 -0
  5. package/dist/car-runtime-1.10.0.tgz +0 -0
  6. package/dist/car-runtime-1.10.0.tgz.sig.bundle +1 -0
  7. package/dist/cli.d.ts +1 -0
  8. package/dist/cli.js +825 -0
  9. package/dist/dx/doctor.d.ts +62 -0
  10. package/dist/dx/doctor.js +127 -0
  11. package/dist/governance/dump.d.ts +47 -0
  12. package/dist/governance/dump.js +17 -0
  13. package/dist/host/facade.d.ts +13 -0
  14. package/dist/host/facade.js +154 -0
  15. package/dist/host/hostGateway.d.ts +117 -0
  16. package/dist/host/hostGateway.js +65 -0
  17. package/dist/host/mappings.d.ts +27 -0
  18. package/dist/host/mappings.js +52 -0
  19. package/dist/host/stdio.d.ts +14 -0
  20. package/dist/host/stdio.js +83 -0
  21. package/dist/kernel/context.d.ts +76 -0
  22. package/dist/kernel/context.js +203 -0
  23. package/dist/kernel/events.d.ts +37 -0
  24. package/dist/kernel/events.js +82 -0
  25. package/dist/load/config.d.ts +79 -0
  26. package/dist/load/config.js +285 -0
  27. package/dist/load/loader.d.ts +72 -0
  28. package/dist/load/loader.js +162 -0
  29. package/dist/load/registry.d.ts +44 -0
  30. package/dist/load/registry.js +58 -0
  31. package/dist/load/report.d.ts +98 -0
  32. package/dist/load/report.js +301 -0
  33. package/dist/load/sigGate.d.ts +22 -0
  34. package/dist/load/sigGate.js +68 -0
  35. package/dist/load/sign.d.ts +25 -0
  36. package/dist/load/sign.js +47 -0
  37. package/dist/load/verifier.d.ts +35 -0
  38. package/dist/load/verifier.js +56 -0
  39. package/dist/loop/goal.d.ts +31 -0
  40. package/dist/loop/goal.js +34 -0
  41. package/dist/loop/recover.d.ts +17 -0
  42. package/dist/loop/recover.js +39 -0
  43. package/dist/loop/stop.d.ts +79 -0
  44. package/dist/loop/stop.js +151 -0
  45. package/dist/mcp/gateway.d.ts +96 -0
  46. package/dist/mcp/gateway.js +69 -0
  47. package/dist/mcp/httpClient.d.ts +27 -0
  48. package/dist/mcp/httpClient.js +196 -0
  49. package/dist/mcp/stdioClient.d.ts +8 -0
  50. package/dist/mcp/stdioClient.js +73 -0
  51. package/dist/ptc/budget.d.ts +21 -0
  52. package/dist/ptc/budget.js +36 -0
  53. package/dist/ptc/erasable.d.ts +14 -0
  54. package/dist/ptc/erasable.js +27 -0
  55. package/dist/ptc/runCode.d.ts +65 -0
  56. package/dist/ptc/runCode.js +140 -0
  57. package/dist/ptc/schemaRender.d.ts +15 -0
  58. package/dist/ptc/schemaRender.js +90 -0
  59. package/dist/ptc/sdk.d.ts +27 -0
  60. package/dist/ptc/sdk.js +23 -0
  61. package/dist/ptc/worker-entry.d.ts +1 -0
  62. package/dist/ptc/worker-entry.js +71 -0
  63. package/dist/release-audit.jsonl +4 -0
  64. package/dist/runtime-core/chatStep.d.ts +40 -0
  65. package/dist/runtime-core/chatStep.js +104 -0
  66. package/dist/runtime-core/credentials.d.ts +49 -0
  67. package/dist/runtime-core/credentials.js +118 -0
  68. package/dist/runtime-core/errors.d.ts +30 -0
  69. package/dist/runtime-core/errors.js +36 -0
  70. package/dist/runtime-core/llm.d.ts +76 -0
  71. package/dist/runtime-core/llm.js +553 -0
  72. package/dist/runtime-core/redaction.d.ts +39 -0
  73. package/dist/runtime-core/redaction.js +79 -0
  74. package/dist/runtime-core/telemetry.d.ts +88 -0
  75. package/dist/runtime-core/telemetry.js +332 -0
  76. package/dist/runtime-core/tools.d.ts +15 -0
  77. package/dist/runtime-core/tools.js +12 -0
  78. package/dist/runtime-core/trace.d.ts +55 -0
  79. package/dist/runtime-core/trace.js +137 -0
  80. package/dist/runtime-core/types.d.ts +84 -0
  81. package/dist/runtime-core/types.js +13 -0
  82. package/dist/sandbox/sandbox.d.ts +68 -0
  83. package/dist/sandbox/sandbox.js +153 -0
  84. package/dist/sbom.json +263 -0
  85. package/dist/seam.d.ts +21 -0
  86. package/dist/seam.js +20 -0
  87. package/dist/security/secrets-baseline.d.ts +43 -0
  88. package/dist/security/secrets-baseline.js +176 -0
  89. package/dist/security/secrets.d.ts +45 -0
  90. package/dist/security/secrets.js +138 -0
  91. package/dist/session/export.d.ts +55 -0
  92. package/dist/session/export.js +81 -0
  93. package/dist/session/fork.d.ts +51 -0
  94. package/dist/session/fork.js +63 -0
  95. package/dist/session/format.d.ts +21 -0
  96. package/dist/session/format.js +49 -0
  97. package/dist/session/indexStore.d.ts +44 -0
  98. package/dist/session/indexStore.js +265 -0
  99. package/dist/session/log.d.ts +79 -0
  100. package/dist/session/log.js +157 -0
  101. package/dist/session/store.d.ts +9 -0
  102. package/dist/session/store.js +37 -0
  103. package/dist/telemetry/metrics.d.ts +25 -0
  104. package/dist/telemetry/metrics.js +26 -0
  105. package/package.json +17 -1
  106. package/src/mcp/gateway.ts +10 -2
  107. package/src/mcp/httpClient.ts +23 -5
  108. package/src/runtime-core/trace.ts +5 -0
  109. package/src/seam.ts +21 -0
  110. package/.gitattributes +0 -11
  111. package/.github/workflows/ci.yml +0 -293
  112. package/.github/workflows/release.yml +0 -54
  113. package/adr/ADR-001.md +0 -4
  114. package/adr/ADR-002.md +0 -5
  115. package/adr/ADR-003.md +0 -35
  116. package/adr/host-onboarding.md +0 -68
  117. package/adr/mlps-audit-checklist.md +0 -41
  118. package/adr/win32-spike.md +0 -45
  119. package/docs/plugin-authoring.md +0 -82
  120. package/native/landlock-run/Makefile +0 -19
  121. package/native/landlock-run/landlock-run.c +0 -162
  122. package/scripts/contract-check.ts +0 -56
  123. package/scripts/invariant-n1.ts +0 -96
  124. package/scripts/package-check.ts +0 -29
  125. package/scripts/ptc-baseline/run-baseline.ts +0 -118
  126. package/scripts/release-artifacts.ts +0 -111
  127. package/scripts/release-pipeline.ts +0 -245
  128. package/scripts/secrets-baseline.ts +0 -33
  129. package/scripts/secrets-scan.ts +0 -56
  130. package/scripts/win32-ffi-debug.ts +0 -143
  131. package/scripts/win32-koffi-spike.ts +0 -537
  132. package/test/contract/eventmap.golden.json +0 -7
  133. package/test/fixtures/hello-plugin.ts +0 -5
  134. package/test/kernel.spec.ts +0 -136
  135. package/test/registry-e2e/run-e2e.ts +0 -213
  136. package/test/s11.spec.ts +0 -129
  137. package/test/s12.spec.ts +0 -135
  138. package/test/s13.spec.ts +0 -117
  139. package/test/s14.spec.ts +0 -117
  140. package/test/s15.spec.ts +0 -80
  141. package/test/s16.spec.ts +0 -133
  142. package/test/s17.spec.ts +0 -102
  143. package/test/s18.spec.ts +0 -81
  144. package/test/s19.spec.ts +0 -138
  145. package/test/s2.spec.ts +0 -245
  146. package/test/s20.spec.ts +0 -241
  147. package/test/s21.spec.ts +0 -231
  148. package/test/s22-m7-store-format.spec.ts +0 -135
  149. package/test/s23-m7-export-index.spec.ts +0 -189
  150. package/test/s24-signature-gate.spec.ts +0 -185
  151. package/test/s25-m8-runtime-core.spec.ts +0 -600
  152. package/test/s26-signature-closeout.spec.ts +0 -349
  153. package/test/s27-host-load-wiring.spec.ts +0 -134
  154. package/test/s28-session-index-followup.spec.ts +0 -236
  155. package/test/s29-otel-producer.spec.ts +0 -252
  156. package/test/s3.spec.ts +0 -179
  157. package/test/s30-release-artifacts.spec.ts +0 -127
  158. package/test/s31-real-model-wiring.spec.ts +0 -329
  159. package/test/s32-telemetry-mcp-ptc.spec.ts +0 -218
  160. package/test/s33-anthropic-adapter.spec.ts +0 -354
  161. package/test/s34-mcp-remote-transport.spec.ts +0 -250
  162. package/test/s35-config-ts-zod.spec.ts +0 -145
  163. package/test/s36-host-tool-surface.spec.ts +0 -250
  164. package/test/s37-projection-dedupe.spec.ts +0 -161
  165. package/test/s38-config-jiti.spec.ts +0 -116
  166. package/test/s39-otlp-span-semantics.spec.ts +0 -100
  167. package/test/s4.spec.ts +0 -169
  168. package/test/s40-metrics-cumulative.spec.ts +0 -67
  169. package/test/s41-mcp-serve-turn-span.spec.ts +0 -148
  170. package/test/s42-traceparent-propagation.spec.ts +0 -415
  171. package/test/s5.spec.ts +0 -95
  172. package/test/s6.spec.ts +0 -169
  173. package/test/s7.spec.ts +0 -136
  174. package/test/s7b-baseline.spec.ts +0 -20
  175. package/test/s9.spec.ts +0 -89
  176. package/test/sandbox-escape/j17-orchestrate.sh +0 -30
  177. package/test/sandbox-escape/run-matrix.sh +0 -98
  178. package/tsconfig.json +0 -18
package/dist/sbom.json ADDED
@@ -0,0 +1,263 @@
1
+ {
2
+ "bomFormat": "CAR-SBOM",
3
+ "specVersion": "0.1",
4
+ "version": "1.10.0",
5
+ "components": [
6
+ {
7
+ "type": "file",
8
+ "path": "src/authz/authz.ts",
9
+ "sha256": "3988f18886c1f0e77f3f1536cea93445189a9fd112fd42ecd8ba90525ba908c0"
10
+ },
11
+ {
12
+ "type": "file",
13
+ "path": "src/cli.ts",
14
+ "sha256": "fc52749c25ac8534bed687e33ae4c32ecbaf221d11b38af3477191779b6b5b36"
15
+ },
16
+ {
17
+ "type": "file",
18
+ "path": "src/dx/doctor.ts",
19
+ "sha256": "bf0e39f62edbafe12f91100c009879cbc73ff1cd7628a7851b264dbef1fd5a4c"
20
+ },
21
+ {
22
+ "type": "file",
23
+ "path": "src/governance/dump.ts",
24
+ "sha256": "7cfbf8eda03d5fd10ab80f7a06e62c6722a584ecc94a833112922bb9b095d2f1"
25
+ },
26
+ {
27
+ "type": "file",
28
+ "path": "src/host/facade.ts",
29
+ "sha256": "564ad91b40afcbffbc84a9e0974e77e5f3da1f15d97d15ec62d42b22044c7a7d"
30
+ },
31
+ {
32
+ "type": "file",
33
+ "path": "src/host/hostGateway.ts",
34
+ "sha256": "3cd027297ca0f2f16984a5f2e91f98cf0f127a97bfa1bb787d8414ca255d9d8b"
35
+ },
36
+ {
37
+ "type": "file",
38
+ "path": "src/host/mappings.ts",
39
+ "sha256": "01e57ad2a89c828a5e0d43d3d98d1c4a9db4601fffe32f4c9678b268057b006c"
40
+ },
41
+ {
42
+ "type": "file",
43
+ "path": "src/host/stdio.ts",
44
+ "sha256": "03d80ac988b79c2db05d443a9cc8e87c62b3da03ce01f3445276d23ca6543955"
45
+ },
46
+ {
47
+ "type": "file",
48
+ "path": "src/kernel/context.ts",
49
+ "sha256": "a2d0afb72c96c880a28ba806f2248ea8b42c3d59c1d26ec901f3de823651de3e"
50
+ },
51
+ {
52
+ "type": "file",
53
+ "path": "src/kernel/events.ts",
54
+ "sha256": "eff9fc018c5f87ff6f090df35702c0ac9b5821150c8d0640245aad3ca7527a13"
55
+ },
56
+ {
57
+ "type": "file",
58
+ "path": "src/load/config.ts",
59
+ "sha256": "60b0b2c4bd97a75f3c31e59fe4d1a44acbc0d2ca6167bd0394c2744d63a4d8e2"
60
+ },
61
+ {
62
+ "type": "file",
63
+ "path": "src/load/loader.ts",
64
+ "sha256": "61302590522da92501e3927b2dc6551e86e8a8ef9e79db8b10865ba73e978246"
65
+ },
66
+ {
67
+ "type": "file",
68
+ "path": "src/load/registry.ts",
69
+ "sha256": "37503eff9bccc8ea7ce52f68d510c5cbcd216aabe9833c8060a68e56b47bb30c"
70
+ },
71
+ {
72
+ "type": "file",
73
+ "path": "src/load/report.ts",
74
+ "sha256": "a7e176c353d9b639b969f5af46681cf56eedbbc725c5af8ab1663422360f4d83"
75
+ },
76
+ {
77
+ "type": "file",
78
+ "path": "src/load/sigGate.ts",
79
+ "sha256": "1bfb6a82a003d4bfef31e4d9aad82081bb57913e35b09ee603466baa32b93216"
80
+ },
81
+ {
82
+ "type": "file",
83
+ "path": "src/load/sign.ts",
84
+ "sha256": "f757d2fd277c97921b30571cb4997a49746a4a2827c615943d39c9b59d2e7217"
85
+ },
86
+ {
87
+ "type": "file",
88
+ "path": "src/load/verifier.ts",
89
+ "sha256": "e4b65e4bc97d81e10ecb2d1efb5d1f2647105d4ad5d4c0d67aeab8c0ed9f8ad0"
90
+ },
91
+ {
92
+ "type": "file",
93
+ "path": "src/loop/goal.ts",
94
+ "sha256": "69cd3f41cac19435b514426962ea81f4f5518c5d34c39fea21b94d7f46e653c6"
95
+ },
96
+ {
97
+ "type": "file",
98
+ "path": "src/loop/recover.ts",
99
+ "sha256": "095d68827ae129f80f84cf485d7d2c41549dec99574311b8fe0f65fae9498ec5"
100
+ },
101
+ {
102
+ "type": "file",
103
+ "path": "src/loop/stop.ts",
104
+ "sha256": "435be5f60aae6b0d5b87642960d5daf9ee73e06530993dc194c60e804fbc7075"
105
+ },
106
+ {
107
+ "type": "file",
108
+ "path": "src/mcp/gateway.ts",
109
+ "sha256": "a7da0cfd913a5a5b85b9c69401070f4a39ecf47337ab7969ea96dee318675df0"
110
+ },
111
+ {
112
+ "type": "file",
113
+ "path": "src/mcp/httpClient.ts",
114
+ "sha256": "d2db77099633dc89c34330fab04c4a05bc6dc87f9f457898f5b29d2e8c25b436"
115
+ },
116
+ {
117
+ "type": "file",
118
+ "path": "src/mcp/stdioClient.ts",
119
+ "sha256": "5c5c576e906eeef1c68397fde90e468183e3f4eabd93a72e23b5bbf0154fb6c6"
120
+ },
121
+ {
122
+ "type": "file",
123
+ "path": "src/ptc/budget.ts",
124
+ "sha256": "61d9419b6e6a9fb722f81a86731108e0f0078f0211dbb87b4de6cf3396c5231a"
125
+ },
126
+ {
127
+ "type": "file",
128
+ "path": "src/ptc/erasable.ts",
129
+ "sha256": "8579ce6e6d501cc534a119dde0ae55e539cd79ce4397be6a6ba8f7a0b8eaa975"
130
+ },
131
+ {
132
+ "type": "file",
133
+ "path": "src/ptc/runCode.ts",
134
+ "sha256": "eac0bd34fe8419ea85b5f7728c5a3291eb14925effaf5d21c29216bc02424f2d"
135
+ },
136
+ {
137
+ "type": "file",
138
+ "path": "src/ptc/schemaRender.ts",
139
+ "sha256": "d5426253a575910ae642bd8ce9e73faaa6b49fbd565da0efb15765abd3b84374"
140
+ },
141
+ {
142
+ "type": "file",
143
+ "path": "src/ptc/sdk.ts",
144
+ "sha256": "332c567377fe135ada141629eb5c07fd8aeef7184e17ba58e3935161660b5456"
145
+ },
146
+ {
147
+ "type": "file",
148
+ "path": "src/ptc/worker-entry.ts",
149
+ "sha256": "d6fd30b9c92435eb09869f77328ee39eca4fc401cea090bc36ab769f2ebc8115"
150
+ },
151
+ {
152
+ "type": "file",
153
+ "path": "src/runtime-core/chatStep.ts",
154
+ "sha256": "c1720b041905d4b24e3c8eae5dc20817f12172ecf8b260fdee5e69eb7710905a"
155
+ },
156
+ {
157
+ "type": "file",
158
+ "path": "src/runtime-core/credentials.ts",
159
+ "sha256": "f59d8420e5066d915f688f594b447026b992fa70980600a500773e3a0de2d1b1"
160
+ },
161
+ {
162
+ "type": "file",
163
+ "path": "src/runtime-core/errors.ts",
164
+ "sha256": "e94d3ce47aba5ed85fffcc468bc785e8d083b689385c91321f397a5cbb3a445b"
165
+ },
166
+ {
167
+ "type": "file",
168
+ "path": "src/runtime-core/llm.ts",
169
+ "sha256": "fe308a55b6c2e3e089a27b70479a36d9f081af3a5862bc376dc5c0fd46d39bee"
170
+ },
171
+ {
172
+ "type": "file",
173
+ "path": "src/runtime-core/redaction.ts",
174
+ "sha256": "9e0f40b1151ea6c57d13552d4ba04ac5189caef69baa4dcf39fd6bf68d718ae4"
175
+ },
176
+ {
177
+ "type": "file",
178
+ "path": "src/runtime-core/telemetry.ts",
179
+ "sha256": "6f7839fe84668124d5ecfc4d216739b8a025e5a01e7201bcdcd26e3098c08ac1"
180
+ },
181
+ {
182
+ "type": "file",
183
+ "path": "src/runtime-core/tools.ts",
184
+ "sha256": "7298906174ddfaae0f6a88110e0a48fea0d7bbf690ee47dcec7bd6ddb734e3b6"
185
+ },
186
+ {
187
+ "type": "file",
188
+ "path": "src/runtime-core/trace.ts",
189
+ "sha256": "7ee54e2dcd408851b82d7bbd0b55473726b60a1875a220b5a5dc827f3a07420d"
190
+ },
191
+ {
192
+ "type": "file",
193
+ "path": "src/runtime-core/types.ts",
194
+ "sha256": "b532ae18ff4a24ee24c2181e3ab6cf1e14996b9f8a2e30a17e8cfce684505d82"
195
+ },
196
+ {
197
+ "type": "file",
198
+ "path": "src/sandbox/sandbox.ts",
199
+ "sha256": "2ef4e259fb00284df36c21ef171e0680e72d6e3daa524b2697d4f38c3edc0215"
200
+ },
201
+ {
202
+ "type": "file",
203
+ "path": "src/seam.ts",
204
+ "sha256": "c3ed5dbefe745e97e89fff6ebccc44fc1bbdd05dafa1e1b934dd5d29717b7e27"
205
+ },
206
+ {
207
+ "type": "file",
208
+ "path": "src/security/secrets-baseline.ts",
209
+ "sha256": "e2eccbad24cf881ce5535f58d5016975ffe02ccef2fd113aae38c5f93bbdf0de"
210
+ },
211
+ {
212
+ "type": "file",
213
+ "path": "src/security/secrets.ts",
214
+ "sha256": "9c9c95c9c9d5cc7b9c31b5aada49e556417882ade56df40d90967c900a209a06"
215
+ },
216
+ {
217
+ "type": "file",
218
+ "path": "src/session/export.ts",
219
+ "sha256": "6b40fbb1266f9441e589edb9b769cd9f6fe430fe5517c3c72f2d4aa4e1f7448b"
220
+ },
221
+ {
222
+ "type": "file",
223
+ "path": "src/session/fork.ts",
224
+ "sha256": "4a58e18e8d1410f69659dded561f91add3f3801abaf254a58c9dbc20c83f4cf6"
225
+ },
226
+ {
227
+ "type": "file",
228
+ "path": "src/session/format.ts",
229
+ "sha256": "2a9f1dd071610010ac3f1e32984125f0f80daa59cb11af3b2cf82304faf1911e"
230
+ },
231
+ {
232
+ "type": "file",
233
+ "path": "src/session/indexStore.ts",
234
+ "sha256": "9ddf06a35158f3af1e401932850a0dc4a79ccb90d79b2c7c4649e7272167c253"
235
+ },
236
+ {
237
+ "type": "file",
238
+ "path": "src/session/log.ts",
239
+ "sha256": "054922dad476e51c822508dee97558791306e9c3359893b230a4b4e1536613f8"
240
+ },
241
+ {
242
+ "type": "file",
243
+ "path": "src/session/store.ts",
244
+ "sha256": "c46261cbc8dbfd0e151748fc66318f73677db23449bf8558d3d0dbdf70cc051e"
245
+ },
246
+ {
247
+ "type": "file",
248
+ "path": "src/telemetry/metrics.ts",
249
+ "sha256": "119ef9094781b8d3e16226daa4a7895407e8a4fc1a54dcf4df7c27de350f0dab"
250
+ },
251
+ {
252
+ "type": "file",
253
+ "path": "package.json",
254
+ "sha256": "35103775f8eff29b1c3226da5c19bd47bc3ad9db068e767defd01c0af5bcfa66"
255
+ },
256
+ {
257
+ "type": "file",
258
+ "path": "README.md",
259
+ "sha256": "c0f3b806a2b2639a95ab4ac1f28bb85e13426f24de462a65e806455667e171f2"
260
+ }
261
+ ],
262
+ "runtimeDependencies": []
263
+ }
package/dist/seam.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * KernelSeam 公开导出面(1.10.0 加法——D16 T-6 冻结面口径:本文件即内核库形态的 semver 承诺面)
3
+ *
4
+ * 消费方:CAR 平台层(KernelSeam 适配器);约定:
5
+ * - 仅暴露进程内挂接所需的最窄面(装配/会话/turn/遥测),禁止透出内核内部模块路径语义;
6
+ * - 破坏性变更须内核 major;加法演进走 minor 并在本文件头登记;
7
+ * - 语义不变:runTurn/chatStep/SessionLog 即 CLI 与测试承载的同一实现(非转发壳)。
8
+ */
9
+ export { SessionLog, type SessionEvent, type EventKind, type Actor } from './session/log.ts';
10
+ export { SessionFileStore } from './session/store.ts';
11
+ export { runTurn, type TurnEndReason, type TurnPreset, type TurnResult } from './loop/stop.ts';
12
+ export { chatStep } from './runtime-core/chatStep.ts';
13
+ export { RuntimeCore, createOpenAICompatAdapter, createAnthropicAdapter } from './runtime-core/llm.ts';
14
+ export { CredentialService } from './runtime-core/credentials.ts';
15
+ export type { LlmAdapter, LlmRequest, LlmChunk } from './runtime-core/types.ts';
16
+ export { mountPlugin } from './load/loader.ts';
17
+ export { Context } from './kernel/context.ts';
18
+ export { loadCarConfig, mergeLlmConfig, mergeSignatureGate, warmCarConfig, type CarConfig, type LlmConfig } from './load/config.ts';
19
+ export { probeCapabilities, SandboxExecutor } from './sandbox/sandbox.ts';
20
+ export { createTelemetryFacade, telemetryConfigFromEnv } from './runtime-core/telemetry.ts';
21
+ export { TurnTracer, type TurnSpanHandle } from './runtime-core/trace.ts';
package/dist/seam.js ADDED
@@ -0,0 +1,20 @@
1
+ /**
2
+ * KernelSeam 公开导出面(1.10.0 加法——D16 T-6 冻结面口径:本文件即内核库形态的 semver 承诺面)
3
+ *
4
+ * 消费方:CAR 平台层(KernelSeam 适配器);约定:
5
+ * - 仅暴露进程内挂接所需的最窄面(装配/会话/turn/遥测),禁止透出内核内部模块路径语义;
6
+ * - 破坏性变更须内核 major;加法演进走 minor 并在本文件头登记;
7
+ * - 语义不变:runTurn/chatStep/SessionLog 即 CLI 与测试承载的同一实现(非转发壳)。
8
+ */
9
+ export { SessionLog } from './session/log.js';
10
+ export { SessionFileStore } from './session/store.js';
11
+ export { runTurn } from './loop/stop.js';
12
+ export { chatStep } from './runtime-core/chatStep.js';
13
+ export { RuntimeCore, createOpenAICompatAdapter, createAnthropicAdapter } from './runtime-core/llm.js';
14
+ export { CredentialService } from './runtime-core/credentials.js';
15
+ export { mountPlugin } from './load/loader.js';
16
+ export { Context } from './kernel/context.js';
17
+ export { loadCarConfig, mergeLlmConfig, mergeSignatureGate, warmCarConfig } from './load/config.js';
18
+ export { probeCapabilities, SandboxExecutor } from './sandbox/sandbox.js';
19
+ export { createTelemetryFacade, telemetryConfigFromEnv } from './runtime-core/telemetry.js';
20
+ export { TurnTracer } from './runtime-core/trace.js';
@@ -0,0 +1,43 @@
1
+ /**
2
+ * E-5 · 万级 secrets 基准集(M2 退出标准 #4 落地;D-3 可验证交付)
3
+ *
4
+ * 口径(M2 安全设计增补 D-3):基准集 1:9 正负比 = 1000 正 + 9000 负;
5
+ * 判据:漏报率 <1.5%、FPR ≤5%、precision ≥80%。
6
+ * 生成确定性(mulberry32 固定种子)——同版本代码跑出的结果可复现、可 diff。
7
+ *
8
+ * 负样本四类对抗面(逐类映射三层检测的一个防误报机制):
9
+ * N1 泛良性(无 L1 前缀交叠,纯稀释面)
10
+ * N2 低熵/占位前缀近似(测 L2 熵过滤:sk-/ghp_/AKIA/AWS/AccountKey 等后接低熵或占位串)
11
+ * N3 注释行无键名真形(测 L3 注释降级;「注释+键名」按 D-3 设计语义 2+1-1=2 应命中,不属负样本)
12
+ * N4 文档风连接串占位值(结构化模式无熵过滤——已知 FP 高危族,如实计量)
13
+ * N5 低熵 kv(password/api_key 后接弱值)
14
+ *
15
+ * 红线:不输出任何样本原文;报告只含计数与聚合指标。
16
+ */
17
+ export interface BaselineSample {
18
+ label: 'pos' | 'neg';
19
+ cls: string;
20
+ text: string;
21
+ }
22
+ export declare function genPositives(n: number, seed?: number): BaselineSample[];
23
+ export declare function genNegatives(n: number, seed?: number): BaselineSample[];
24
+ export interface BaselineResult {
25
+ posTotal: number;
26
+ negTotal: number;
27
+ tp: number;
28
+ fn: number;
29
+ fp: number;
30
+ tn: number;
31
+ missRate: number;
32
+ fpr: number;
33
+ precision: number;
34
+ fpByClass: Record<string, number>;
35
+ missByClass: Record<string, number>;
36
+ criteria: {
37
+ missRateLt: number;
38
+ fprLe: number;
39
+ precisionGe: number;
40
+ };
41
+ pass: boolean;
42
+ }
43
+ export declare function runBaseline(posN?: number, negN?: number): BaselineResult;
@@ -0,0 +1,176 @@
1
+ /**
2
+ * E-5 · 万级 secrets 基准集(M2 退出标准 #4 落地;D-3 可验证交付)
3
+ *
4
+ * 口径(M2 安全设计增补 D-3):基准集 1:9 正负比 = 1000 正 + 9000 负;
5
+ * 判据:漏报率 <1.5%、FPR ≤5%、precision ≥80%。
6
+ * 生成确定性(mulberry32 固定种子)——同版本代码跑出的结果可复现、可 diff。
7
+ *
8
+ * 负样本四类对抗面(逐类映射三层检测的一个防误报机制):
9
+ * N1 泛良性(无 L1 前缀交叠,纯稀释面)
10
+ * N2 低熵/占位前缀近似(测 L2 熵过滤:sk-/ghp_/AKIA/AWS/AccountKey 等后接低熵或占位串)
11
+ * N3 注释行无键名真形(测 L3 注释降级;「注释+键名」按 D-3 设计语义 2+1-1=2 应命中,不属负样本)
12
+ * N4 文档风连接串占位值(结构化模式无熵过滤——已知 FP 高危族,如实计量)
13
+ * N5 低熵 kv(password/api_key 后接弱值)
14
+ *
15
+ * 红线:不输出任何样本原文;报告只含计数与聚合指标。
16
+ */
17
+ import { scanSecrets } from './secrets.js';
18
+ // ── 确定性 RNG(mulberry32) ──
19
+ function mulberry32(seed) {
20
+ let a = seed >>> 0;
21
+ return function () {
22
+ a |= 0;
23
+ a = (a + 0x6d2b79f5) | 0;
24
+ let t = Math.imul(a ^ (a >>> 15), 1 | a);
25
+ t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
26
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
27
+ };
28
+ }
29
+ const ALNUM = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
30
+ const UPPER36 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
31
+ const B64CH = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
32
+ function randFrom(rnd, alphabet, n) {
33
+ let s = '';
34
+ for (let i = 0; i < n; i++)
35
+ s += alphabet[Math.floor(rnd() * alphabet.length)];
36
+ return s;
37
+ }
38
+ const randAlnum = (rnd, n) => randFrom(rnd, ALNUM, n);
39
+ const randB64 = (rnd, n) => randFrom(rnd, B64CH, n);
40
+ /** 不放回采样(n ≤ |alphabet|):全异字符 → 经验熵 = log2(n),稳定越过 L2 硬门槛 */
41
+ function sampleDistinct(rnd, alphabet, n) {
42
+ const pool = alphabet.split('');
43
+ let s = '';
44
+ for (let i = 0; i < n; i++)
45
+ s += pool.splice(Math.floor(rnd() * pool.length), 1)[0];
46
+ return s;
47
+ }
48
+ const POS_MAKERS = [
49
+ ['openai', r => `const OPENAI_API_KEY = "sk-${randAlnum(r, 45)}"`],
50
+ ['anthropic', r => `anthropic_key: "sk-ant-${randAlnum(r, 45)}"`],
51
+ ['github-pat', r => `GITHUB_TOKEN=ghp_${randAlnum(r, 36)}`],
52
+ ['slack', r => `SLACK_BOT_TOKEN=xoxb-${randAlnum(r, 12)}-${randAlnum(r, 12)}`],
53
+ ['aws-akia', r => `aws_access_key_id = AKIA${sampleDistinct(r, UPPER36, 16)}`],
54
+ ['stripe', r => `stripe.secret_key = "sk_live_${randAlnum(r, 24)}"`],
55
+ ['npm', r => `npm_token: npm_${randAlnum(r, 32)}`],
56
+ ['pem-rsa', r => `-----BEGIN RSA PRIVATE KEY-----\n${randB64(r, 64)}\n${randB64(r, 64)}\n-----END RSA PRIVATE KEY-----`],
57
+ ['pem-ec', r => `-----BEGIN EC PRIVATE KEY-----\n${randB64(r, 64)}\n-----END EC PRIVATE KEY-----`],
58
+ ['pem-openssh', r => `-----BEGIN OPENSSH PRIVATE KEY-----\n${randB64(r, 64)}\n-----END OPENSSH PRIVATE KEY-----`],
59
+ ['pem-pkcs8', r => `-----BEGIN PRIVATE KEY-----\n${randB64(r, 64)}\n-----END PRIVATE KEY-----`],
60
+ ['putty-ppk', r => `PuTTY-User-Key-File-2: ssh-rsa\nEncryption: aes256-cbc\nComment: ${randAlnum(r, 8)}-key`],
61
+ ['conn-postgres', r => `DATABASE_URL=postgresql://app_svc:${randAlnum(r, 20)}@db.internal:5432/prod`],
62
+ ['conn-mysql', r => `mysql://root:${randAlnum(r, 18)}@127.0.0.1:3306/app`],
63
+ ['conn-mongo', r => `MONGO_URI=mongodb+srv://svc:${randAlnum(r, 22)}@cluster0.mongodb.net/db`],
64
+ ['conn-redis', r => `REDIS_URL=redis://:${randAlnum(r, 24)}@cache.internal:6379`],
65
+ ['conn-jdbc', r => `jdbc:mysql://svc:${randAlnum(r, 20)}@db.internal:3306/core`],
66
+ ['aws-secret', r => `aws_secret_access_key = ${randB64(r, 40)}`],
67
+ ['gcp-sa', r => `{"type": "service_account", "project_id": "proj-${randAlnum(r, 6)}", "private_key": "-----BEGIN PRIVATE KEY-----"}`],
68
+ ['azure-conn', r => `DefaultEndpointsProtocol=https;AccountName=st01;AccountKey=${randB64(r, 88)}`],
69
+ ['jwt', r => `token=${'eyJ' + randAlnum(r, 30)}.${'eyJ' + randAlnum(r, 30)}.${randAlnum(r, 43)}`],
70
+ ['bearer', r => `fetch(url, { headers: { Authorization: 'Bearer ${randAlnum(r, 32)}' } })`],
71
+ ['api-key-kv', r => `api_key: "${sampleDistinct(r, ALNUM, 20)}"`],
72
+ ['client-secret-kv', r => `"client_secret": "${sampleDistinct(r, ALNUM, 16)}"`],
73
+ ['password-kv', r => `password = "${sampleDistinct(r, ALNUM, 24)}"`],
74
+ ];
75
+ export function genPositives(n, seed = 20260918) {
76
+ const rnd = mulberry32(seed);
77
+ const out = [];
78
+ const per = Math.floor(n / POS_MAKERS.length);
79
+ for (const [cls, maker] of POS_MAKERS) {
80
+ for (let i = 0; i < per; i++)
81
+ out.push({ label: 'pos', cls, text: maker(rnd) });
82
+ }
83
+ for (let i = 0; out.length < n; i++)
84
+ out.push({ label: 'pos', cls: POS_MAKERS[0][0], text: POS_MAKERS[0][1](rnd) });
85
+ return out;
86
+ }
87
+ const NEG_MAKERS = [
88
+ // N1 泛良性(无 L1 交叠)
89
+ { cls: 'N1-generic', make: r => `const id = "${randAlnum(r, 8)}-${randAlnum(r, 4)}"; // internal ref` },
90
+ { cls: 'N1-uuid', make: r => `${randAlnum(r, 8)}-${randAlnum(r, 4)}-4${randAlnum(r, 3)}-a${randAlnum(r, 3)}-${randAlnum(r, 12)}` },
91
+ { cls: 'N1-sha', make: r => `commit ${randFrom(r, '0123456789abcdef', 40)}` },
92
+ { cls: 'N1-b64img', make: r => `data:image/png;base64,${randB64(r, 60)}` },
93
+ { cls: 'N1-url', make: r => `https://registry.example.com/@scope/pkg/-/pkg-1.${Math.floor(r() * 9)}.${Math.floor(r() * 9)}.tgz` },
94
+ { cls: 'N1-config', make: r => `max_retries=${Math.floor(r() * 9)}\ntimeout_ms=${Math.floor(r() * 9000)}\nregion=cn-north-1` },
95
+ // N2 低熵/占位前缀近似(L2 应过滤)
96
+ { cls: 'N2-lowent-openai', make: () => `const K = "sk-aaaaaaaaaaaaaaaaaaaaaaaaaaaa"` },
97
+ { cls: 'N2-lowent-ghp', make: () => `GITHUB_TOKEN=ghp_1234123412341234123412341234123412` },
98
+ { cls: 'N2-lowent-npm', make: () => `npm_token: npm_bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb` },
99
+ { cls: 'N2-lowent-slack', make: () => `SLACK_TOKEN=xoxb-0000000000-0000000000` },
100
+ { cls: 'N2-lowent-akia', make: () => `aws_access_key_id = AKIA0123012301230123` },
101
+ { cls: 'N2-lowent-awssecret', make: () => `aws_secret_access_key = ${'1234567890'.repeat(4)}` },
102
+ { cls: 'N2-lowent-azure', make: () => `AccountKey=${'A'.repeat(80)}` },
103
+ { cls: 'N2-lowent-stripe', make: () => `stripe_key = "sk_live_test0000000000000000000"` },
104
+ { cls: 'N2-placeholder', make: () => `openai.api_key = "sk-your-key-here-xxxxxxxxxxxx"` },
105
+ // N3 注释行无键名真形(L3 注释降级应压到 1 → 仅候选)
106
+ { cls: 'N3-comment-token1', make: r => `// sk-${randAlnum(r, 45)}` },
107
+ { cls: 'N3-comment-token2', make: r => `# ghp_${randAlnum(r, 36)}` },
108
+ { cls: 'N3-comment-token3', make: r => `* xoxb-${randAlnum(r, 12)}-${randAlnum(r, 12)}` },
109
+ { cls: 'N3-comment-token4', make: r => `// redis://:${randAlnum(r, 16)}@cache.internal:6379` },
110
+ // N4 文档风连接串占位值(结构化模式无熵过滤——FP 高危族,如实计量)
111
+ { cls: 'N4-docs-pg', make: () => `postgres://user:password@localhost:5432/mydb` },
112
+ { cls: 'N4-docs-pg2', make: () => `postgresql://demo:demo@db.example.com/demo` },
113
+ { cls: 'N4-docs-mysql', make: () => `mysql://root:changeme@127.0.0.1:3306/app` },
114
+ { cls: 'N4-docs-mongo', make: () => `mongodb://admin:example@cluster0.sample.mongodb.net/test` },
115
+ { cls: 'N4-docs-redis', make: () => `redis://:default@localhost:6379/0` },
116
+ { cls: 'N4-docs-jdbc', make: () => `jdbc:mysql://dev:pass@db.local:3306/sample` },
117
+ // N5 低熵 kv(L2 应过滤)
118
+ { cls: 'N5-lowent-password', make: () => `password = "12345678"` },
119
+ { cls: 'N5-lowent-password2', make: () => `password: "abcd1234"` },
120
+ { cls: 'N5-lowent-apikey', make: () => `api_key: "aaaaaaaaaaaaaaaa"` },
121
+ { cls: 'N5-empty-secret', make: () => `client_secret: ""` },
122
+ { cls: 'N5-short-token', make: () => `access_token: "tok_123"` },
123
+ ];
124
+ export function genNegatives(n, seed = 20260919) {
125
+ const rnd = mulberry32(seed);
126
+ const out = [];
127
+ // 权重:N1 30% / N2 20% / N3 7% / N4 13% / N5 30%(N4≈1170 条如实暴露占位连接串 FP 面)
128
+ const weights = { N1: 0.30, N2: 0.20, N3: 0.07, N4: 0.13, N5: 0.30 };
129
+ const bucketTarget = Object.fromEntries(Object.entries(weights).map(([k, w]) => [k, Math.round(w * n)]));
130
+ let i = 0;
131
+ while (out.length < n) {
132
+ const m = NEG_MAKERS[i % NEG_MAKERS.length];
133
+ const bucket = m.cls.split('-')[0];
134
+ if ((bucketTarget[bucket] ?? 0) > 0 || out.length + NEG_MAKERS.length >= n) {
135
+ out.push({ label: 'neg', cls: m.cls, text: m.make(rnd) });
136
+ if (bucketTarget[bucket] !== undefined)
137
+ bucketTarget[bucket]--;
138
+ }
139
+ i++;
140
+ }
141
+ return out;
142
+ }
143
+ export function runBaseline(posN = 1000, negN = 9000) {
144
+ const pos = genPositives(posN);
145
+ const neg = genNegatives(negN);
146
+ let tp = 0, fn = 0, fp = 0, tn = 0;
147
+ const fpByClass = {};
148
+ const missByClass = {};
149
+ for (const s of pos) {
150
+ const { hits } = scanSecrets(s.text);
151
+ if (hits.length > 0)
152
+ tp++;
153
+ else {
154
+ fn++;
155
+ missByClass[s.cls] = (missByClass[s.cls] ?? 0) + 1;
156
+ }
157
+ }
158
+ for (const s of neg) {
159
+ const { hits } = scanSecrets(s.text);
160
+ if (hits.length > 0) {
161
+ fp++;
162
+ fpByClass[s.cls] = (fpByClass[s.cls] ?? 0) + 1;
163
+ }
164
+ else
165
+ tn++;
166
+ }
167
+ const missRate = fn / pos.length;
168
+ const fpr = fp / neg.length;
169
+ const precision = tp / Math.max(1, tp + fp);
170
+ const pass = missRate < 0.015 && fpr <= 0.05 && precision >= 0.80;
171
+ return {
172
+ posTotal: pos.length, negTotal: neg.length, tp, fn, fp, tn,
173
+ missRate, fpr, precision, fpByClass, missByClass,
174
+ criteria: { missRateLt: 0.015, fprLe: 0.05, precisionGe: 0.80 }, pass,
175
+ };
176
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * F12 · secrets 检测(完整版,M2-S7 实装加载期;运行期输出期挂点预留)
3
+ *
4
+ * 口径(M2 安全设计增补 T-6 + D-3 裁决):
5
+ * - 模式库 6 类(api-key 前缀族 / 私钥块 / 连接串 / 云凭据 / token-Bearer / 自定义正则);
6
+ * - 三层检测降误报:L1 精确前缀(Aho-Corasick 等价的朴素扫描,规模小不构成瓶颈)
7
+ * → L2 Shannon 熵(≥3.5 才升级候选,排除 'aaaa' 类低熵误报)
8
+ * → L3 上下文打分(键名共现 +1、代码引号内 +0、注释 -1;总分 ≥2 判命中);
9
+ * - 可验证交付(D-3):漏报率 <1.5%、FPR ≤5%、precision ≥80%——基准集 1:9 正负比、CI 标定;
10
+ * - 检测不可静默关闭:disable 仅允许显式配置且留痕(本层不提供总开关,红线 §6.3)。
11
+ */
12
+ export type SecretCategory = 'api-key' | 'private-key' | 'connection-string' | 'cloud-credential' | 'bearer-token' | 'custom';
13
+ export interface SecretPattern {
14
+ category: SecretCategory;
15
+ name: string;
16
+ re: RegExp; /** 键名共现提示 */
17
+ keyHints?: string[];
18
+ }
19
+ /** 6 类模式库(v1:30 条精选;自定义正则经 manifest 注入需过安全评审,M3) */
20
+ export declare const PATTERN_LIBRARY: SecretPattern[];
21
+ /** Shannon 熵(bit/char) */
22
+ export declare function shannonEntropy(s: string): number;
23
+ export interface ScanHit {
24
+ category: SecretCategory;
25
+ name: string;
26
+ start: number;
27
+ end: number; /** 命中摘要(全遮蔽,保留首尾 ≤4) */
28
+ masked: string;
29
+ score: number;
30
+ }
31
+ /**
32
+ * 三层检测:前缀命中 → 熵过滤 → 上下文打分。
33
+ * 返回确认命中(score ≥2);低分候选不返回但可通过 returnCandidates 观察(标定用)。
34
+ */
35
+ export declare function scanSecrets(text: string, opts?: {
36
+ returnCandidates?: boolean;
37
+ }): {
38
+ hits: ScanHit[];
39
+ candidates: ScanHit[];
40
+ };
41
+ /** 脱敏钩子:确认命中全遮蔽后返回新文本(M8 redact 的 F12 升级实现) */
42
+ export declare function redactSecrets(text: string): {
43
+ text: string;
44
+ redacted: number;
45
+ };