@apifuse/provider-sdk 2.2.0-beta.5 → 2.2.0-beta.50

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 (365) hide show
  1. package/AUTHORING.md +537 -33
  2. package/CHANGELOG.md +201 -1
  3. package/README.md +83 -22
  4. package/SUBMISSION.md +2 -2
  5. package/bin/apifuse-check.ts +165 -11
  6. package/bin/apifuse-dev.ts +57 -13
  7. package/bin/apifuse-migrate-operation-declaration.ts +55 -0
  8. package/bin/apifuse-migrate-shape.ts +202 -0
  9. package/bin/apifuse-pack-check.ts +22 -2
  10. package/bin/apifuse-pack-smoke.ts +57 -2
  11. package/bin/apifuse-pack-types.ts +357 -38
  12. package/bin/apifuse-perf.ts +14 -13
  13. package/bin/apifuse-record.ts +709 -72
  14. package/bin/apifuse-submit-check.ts +2344 -324
  15. package/bin/apifuse-sync-assets.ts +117 -0
  16. package/bin/submit-check-delimited-text.ts +50 -0
  17. package/dist/auth-turn/index.d.ts +3 -3
  18. package/dist/auth-turn/index.js +1 -1
  19. package/dist/auth.d.ts +14 -0
  20. package/dist/auth.js +67 -0
  21. package/dist/ceremonies/index.d.ts +16 -0
  22. package/dist/ceremonies/index.js +141 -36
  23. package/dist/cli/commands.d.ts +1 -1
  24. package/dist/cli/commands.js +27 -0
  25. package/dist/cli/create.d.ts +4 -1
  26. package/dist/cli/create.js +42 -37
  27. package/dist/cli/migrate-operation-declaration.d.ts +59 -0
  28. package/dist/cli/migrate-operation-declaration.js +1178 -0
  29. package/dist/cli/migrate-operation-shape.d.ts +44 -0
  30. package/dist/cli/migrate-operation-shape.js +113 -0
  31. package/dist/cli/migrate-provider-shape.d.ts +52 -0
  32. package/dist/cli/migrate-provider-shape.js +578 -0
  33. package/dist/cli/prompt-assets.d.ts +80 -0
  34. package/dist/cli/prompt-assets.js +743 -0
  35. package/dist/cli/templates/provider/AGENTS.md.tpl +17 -8
  36. package/dist/cli/templates/provider/Dockerfile.tpl +1 -1
  37. package/dist/cli/templates/provider/README.md.tpl +5 -5
  38. package/dist/cli/templates/provider/index.ts.tpl +6 -3
  39. package/dist/cli/templates/provider/operations/ping.ts.tpl +4 -1
  40. package/dist/cli/templates/provider/provider.json.tpl +6 -0
  41. package/dist/config/loader.d.ts +179 -16
  42. package/dist/config/loader.js +435 -127
  43. package/dist/contract-serialization.js +4 -8
  44. package/dist/contract-types.d.ts +12 -5
  45. package/dist/contract.js +24 -10
  46. package/dist/declaration-validation.d.ts +33 -0
  47. package/dist/declaration-validation.js +266 -0
  48. package/dist/define.d.ts +66 -29
  49. package/dist/define.js +778 -69
  50. package/dist/dev.d.ts +3 -0
  51. package/dist/dev.js +1 -1
  52. package/dist/engine.d.ts +78 -0
  53. package/dist/engine.js +133 -0
  54. package/dist/error-observability.d.ts +7 -0
  55. package/dist/error-observability.js +61 -0
  56. package/dist/error-resolution.d.ts +4 -0
  57. package/dist/error-resolution.js +122 -0
  58. package/dist/errors.d.ts +33 -0
  59. package/dist/errors.js +40 -0
  60. package/dist/fixture-sanitization.d.ts +28 -0
  61. package/dist/fixture-sanitization.js +227 -0
  62. package/dist/health-scenario.d.ts +1842 -0
  63. package/dist/health-scenario.js +624 -0
  64. package/dist/index.d.ts +21 -10
  65. package/dist/index.js +12 -7
  66. package/dist/lint.d.ts +23 -11
  67. package/dist/lint.js +572 -69
  68. package/dist/native-address.d.ts +43 -0
  69. package/dist/native-address.js +281 -0
  70. package/dist/native-egress-policy.d.ts +31 -0
  71. package/dist/native-egress-policy.js +288 -0
  72. package/dist/observability.d.ts +5 -2
  73. package/dist/observability.js +48 -1
  74. package/dist/provider.d.ts +10 -2
  75. package/dist/provider.js +4 -1
  76. package/dist/runtime/auth-flow.d.ts +5 -1
  77. package/dist/runtime/auth-flow.js +6 -0
  78. package/dist/runtime/browser.d.ts +1 -0
  79. package/dist/runtime/browser.js +492 -49
  80. package/dist/runtime/cache.d.ts +1 -0
  81. package/dist/runtime/cache.js +169 -15
  82. package/dist/runtime/choice-wordlist.d.ts +9 -0
  83. package/dist/runtime/choice-wordlist.js +138 -0
  84. package/dist/runtime/choice.d.ts +13 -1
  85. package/dist/runtime/choice.js +490 -102
  86. package/dist/runtime/chrome149-header-order.d.ts +58 -0
  87. package/dist/runtime/chrome149-header-order.js +289 -0
  88. package/dist/runtime/env.js +12 -0
  89. package/dist/runtime/executor.d.ts +3 -2
  90. package/dist/runtime/executor.js +26 -25
  91. package/dist/runtime/http.d.ts +1 -0
  92. package/dist/runtime/http.js +515 -53
  93. package/dist/runtime/insights.js +2 -2
  94. package/dist/runtime/instrumentation.d.ts +2 -2
  95. package/dist/runtime/instrumentation.js +366 -8
  96. package/dist/runtime/native-network-errors.d.ts +33 -0
  97. package/dist/runtime/native-network-errors.js +69 -0
  98. package/dist/runtime/native-network.d.ts +96 -0
  99. package/dist/runtime/native-network.js +1232 -0
  100. package/dist/runtime/ocr.d.ts +29 -0
  101. package/dist/runtime/ocr.js +440 -0
  102. package/dist/runtime/otlp.d.ts +71 -2
  103. package/dist/runtime/otlp.js +397 -16
  104. package/dist/runtime/proxy-errors.js +6 -2
  105. package/dist/runtime/proxy-nodemaven.d.ts +56 -0
  106. package/dist/runtime/proxy-nodemaven.js +146 -0
  107. package/dist/runtime/proxy-telemetry.d.ts +80 -1
  108. package/dist/runtime/proxy-telemetry.js +154 -47
  109. package/dist/runtime/redirects.d.ts +29 -0
  110. package/dist/runtime/redirects.js +36 -0
  111. package/dist/runtime/redis.d.ts +1 -1
  112. package/dist/runtime/redis.js +4 -2
  113. package/dist/runtime/request-options.d.ts +68 -1
  114. package/dist/runtime/request-options.js +548 -0
  115. package/dist/runtime/resolver-config.d.ts +6 -0
  116. package/dist/runtime/resolver-config.js +6 -0
  117. package/dist/runtime/resolver-public.d.ts +1 -0
  118. package/dist/runtime/resolver-public.js +1 -0
  119. package/dist/runtime/resolver-shared.d.ts +14 -0
  120. package/dist/runtime/resolver-shared.js +12 -0
  121. package/dist/runtime/resolver-vendors/bindings.d.ts +48 -0
  122. package/dist/runtime/resolver-vendors/bindings.js +40 -0
  123. package/dist/runtime/resolver-vendors/browser.d.ts +22 -0
  124. package/dist/runtime/resolver-vendors/browser.js +377 -0
  125. package/dist/runtime/resolver-vendors/capsolver.d.ts +22 -0
  126. package/dist/runtime/resolver-vendors/capsolver.js +531 -0
  127. package/dist/runtime/resolver-vendors/hosts.d.ts +2 -0
  128. package/dist/runtime/resolver-vendors/hosts.js +33 -0
  129. package/dist/runtime/resolver-vendors/twocaptcha.d.ts +24 -0
  130. package/dist/runtime/resolver-vendors/twocaptcha.js +408 -0
  131. package/dist/runtime/resolver-vendors/types.d.ts +94 -0
  132. package/dist/runtime/resolver-vendors/types.js +96 -0
  133. package/dist/runtime/resolver.d.ts +72 -0
  134. package/dist/runtime/resolver.js +771 -0
  135. package/dist/runtime/secrets.d.ts +27 -0
  136. package/dist/runtime/secrets.js +51 -0
  137. package/dist/runtime/state.d.ts +3 -0
  138. package/dist/runtime/state.js +277 -71
  139. package/dist/runtime/stealth-cookies.d.ts +20 -0
  140. package/dist/runtime/stealth-cookies.js +111 -0
  141. package/dist/runtime/stealth.d.ts +41 -5
  142. package/dist/runtime/stealth.js +997 -291
  143. package/dist/runtime/stt.js +1 -12
  144. package/dist/runtime/timeout.d.ts +5 -0
  145. package/dist/runtime/timeout.js +12 -0
  146. package/dist/runtime/trace-config.d.ts +12 -0
  147. package/dist/runtime/trace-config.js +62 -0
  148. package/dist/runtime/trace.d.ts +5 -0
  149. package/dist/runtime/trace.js +43 -10
  150. package/dist/serve.d.ts +1 -1
  151. package/dist/serve.js +1 -1
  152. package/dist/server/error-observability.d.ts +1 -0
  153. package/dist/server/error-observability.js +1 -0
  154. package/dist/server/index.d.ts +5 -2
  155. package/dist/server/index.js +2 -2
  156. package/dist/server/self-test-input-tokens.d.ts +2 -1
  157. package/dist/server/self-test-input-tokens.js +18 -14
  158. package/dist/server/self-test.d.ts +14 -3
  159. package/dist/server/self-test.js +129 -58
  160. package/dist/server/serve-implementation.d.ts +230 -0
  161. package/dist/server/serve-implementation.js +2265 -0
  162. package/dist/server/serve.d.ts +1 -70
  163. package/dist/server/serve.js +1 -1131
  164. package/dist/server/trace-output.d.ts +6 -0
  165. package/dist/server/trace-output.js +79 -0
  166. package/dist/server/types.d.ts +30 -5
  167. package/dist/server/types.js +13 -1
  168. package/dist/stateful/errors.d.ts +19 -0
  169. package/dist/stateful/errors.js +24 -0
  170. package/dist/stateful/http-provider-event-emitter.d.ts +40 -0
  171. package/dist/stateful/http-provider-event-emitter.js +237 -0
  172. package/dist/stateful/http-session-owner-registry.d.ts +44 -0
  173. package/dist/stateful/http-session-owner-registry.js +210 -0
  174. package/dist/stateful/index.d.ts +18 -0
  175. package/dist/stateful/index.js +18 -0
  176. package/dist/stateful/provider-event-delivery-failures.d.ts +32 -0
  177. package/dist/stateful/provider-event-delivery-failures.js +43 -0
  178. package/dist/stateful/provider-event-pipeline-metrics.d.ts +46 -0
  179. package/dist/stateful/provider-event-pipeline-metrics.js +48 -0
  180. package/dist/stateful/provider-event-pipeline.d.ts +50 -0
  181. package/dist/stateful/provider-event-pipeline.js +1 -0
  182. package/dist/stateful/provider-events.d.ts +101 -0
  183. package/dist/stateful/provider-events.js +289 -0
  184. package/dist/stateful/session-key.d.ts +15 -0
  185. package/dist/stateful/session-key.js +86 -0
  186. package/dist/stateful/stateful-provider-adapter-context.d.ts +5 -0
  187. package/dist/stateful/stateful-provider-adapter-context.js +42 -0
  188. package/dist/stateful/stateful-provider-adapter-metrics.d.ts +15 -0
  189. package/dist/stateful/stateful-provider-adapter-metrics.js +21 -0
  190. package/dist/stateful/stateful-provider-adapter.d.ts +98 -0
  191. package/dist/stateful/stateful-provider-adapter.js +287 -0
  192. package/dist/stateful/stateful-provider-observability.d.ts +62 -0
  193. package/dist/stateful/stateful-provider-observability.js +161 -0
  194. package/dist/stateful/stateful-provider-owner-forwarder.d.ts +41 -0
  195. package/dist/stateful/stateful-provider-owner-forwarder.js +215 -0
  196. package/dist/stateful/stateful-provider-runtime-context.d.ts +32 -0
  197. package/dist/stateful/stateful-provider-runtime-context.js +60 -0
  198. package/dist/stateful/stateful-provider-runtime-executor.d.ts +34 -0
  199. package/dist/stateful/stateful-provider-runtime-executor.js +52 -0
  200. package/dist/stateful/stateful-provider-session-routing.d.ts +67 -0
  201. package/dist/stateful/stateful-provider-session-routing.js +345 -0
  202. package/dist/stateful/stateful-provider-session-runtime.d.ts +98 -0
  203. package/dist/stateful/stateful-provider-session-runtime.js +245 -0
  204. package/dist/stateful-signing.d.ts +18 -0
  205. package/dist/stateful-signing.js +27 -0
  206. package/dist/stealth/profiles.d.ts +9 -4
  207. package/dist/stealth/profiles.js +160 -211
  208. package/dist/stream-evidence.d.ts +74 -0
  209. package/dist/stream-evidence.js +785 -0
  210. package/dist/stream.js +7 -1
  211. package/dist/testing/index.d.ts +2 -1
  212. package/dist/testing/index.js +2 -1
  213. package/dist/testing/run.d.ts +32 -2
  214. package/dist/testing/run.js +489 -21
  215. package/dist/trace-sanitization.d.ts +5 -0
  216. package/dist/trace-sanitization.js +45 -0
  217. package/dist/types.d.ts +673 -131
  218. package/dist/types.js +1 -0
  219. package/package.json +45 -5
  220. package/src/auth-turn/index.ts +1 -1
  221. package/src/auth.ts +118 -0
  222. package/src/ceremonies/index.ts +189 -46
  223. package/src/cli/__tests__/fixtures/migrate-operation-declaration/approval-override.ts.txt +6 -0
  224. package/src/cli/__tests__/fixtures/migrate-operation-declaration/codemod-syntax.ts.txt +3 -0
  225. package/src/cli/__tests__/fixtures/migrate-operation-declaration/connection-precedence.ts.txt +10 -0
  226. package/src/cli/__tests__/fixtures/migrate-operation-declaration/docs-conflict.ts.txt +8 -0
  227. package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-map.ts.txt +5 -0
  228. package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-operation.ts.txt +16 -0
  229. package/src/cli/__tests__/fixtures/migrate-operation-declaration/factory-map.ts.txt +3 -0
  230. package/src/cli/__tests__/fixtures/migrate-operation-declaration/hoist-all.ts.txt +31 -0
  231. package/src/cli/__tests__/fixtures/migrate-operation-declaration/hoisted-const.ts.txt +11 -0
  232. package/src/cli/__tests__/fixtures/migrate-operation-declaration/imported-spread.ts.txt +11 -0
  233. package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-map.ts.txt +11 -0
  234. package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-spread-cast-tail.ts.txt +21 -0
  235. package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-spread-ekitan.ts.txt +11 -0
  236. package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-spread-override.ts.txt +14 -0
  237. package/src/cli/__tests__/fixtures/migrate-operation-declaration/missing-english-locale.ts.txt +7 -0
  238. package/src/cli/__tests__/fixtures/migrate-operation-declaration/no-safety.ts.txt +6 -0
  239. package/src/cli/__tests__/fixtures/migrate-operation-declaration/non-literal.ts.txt +7 -0
  240. package/src/cli/__tests__/fixtures/migrate-operation-declaration/redundant-approval.ts.txt +6 -0
  241. package/src/cli/__tests__/fixtures/migrate-operation-declaration/safety-conflict.ts.txt +7 -0
  242. package/src/cli/__tests__/fixtures/migrate-operation-declaration/stream.ts.txt +7 -0
  243. package/src/cli/__tests__/fixtures/migrate-operation-declaration/tool-router-spread.ts.txt +15 -0
  244. package/src/cli/__tests__/fixtures/migrate-operation-declaration/unparseable.ts.txt +4 -0
  245. package/src/cli/__tests__/fixtures/migrate-operation-declaration/verbatim-template.ts.txt +12 -0
  246. package/src/cli/commands.ts +33 -0
  247. package/src/cli/create.ts +50 -37
  248. package/src/cli/migrate-operation-declaration.ts +1654 -0
  249. package/src/cli/migrate-operation-shape.ts +184 -0
  250. package/src/cli/migrate-provider-shape.ts +772 -0
  251. package/src/cli/prompt-assets.ts +865 -0
  252. package/src/cli/templates/provider/AGENTS.md.tpl +17 -8
  253. package/src/cli/templates/provider/Dockerfile.tpl +1 -1
  254. package/src/cli/templates/provider/README.md.tpl +5 -5
  255. package/src/cli/templates/provider/index.ts.tpl +6 -3
  256. package/src/cli/templates/provider/operations/ping.ts.tpl +4 -1
  257. package/src/cli/templates/provider/provider.json.tpl +6 -0
  258. package/src/config/loader.ts +690 -163
  259. package/src/contract-serialization.ts +5 -7
  260. package/src/contract-types.ts +12 -5
  261. package/src/contract.ts +24 -10
  262. package/src/declaration-validation.ts +330 -0
  263. package/src/define.ts +1048 -131
  264. package/src/dev.ts +4 -1
  265. package/src/engine.ts +279 -0
  266. package/src/error-observability.ts +64 -0
  267. package/src/error-resolution.ts +127 -0
  268. package/src/errors.ts +68 -0
  269. package/src/fixture-sanitization.ts +264 -0
  270. package/src/health-scenario.ts +875 -0
  271. package/src/index.ts +220 -13
  272. package/src/lint.ts +698 -90
  273. package/src/native-address.ts +340 -0
  274. package/src/native-egress-policy.ts +358 -0
  275. package/src/observability.ts +51 -1
  276. package/src/provider.ts +161 -3
  277. package/src/runtime/auth-flow.ts +12 -0
  278. package/src/runtime/browser.ts +661 -63
  279. package/src/runtime/cache.ts +189 -14
  280. package/src/runtime/choice-wordlist.ts +145 -0
  281. package/src/runtime/choice.ts +631 -120
  282. package/src/runtime/chrome149-header-order.ts +330 -0
  283. package/src/runtime/env.ts +13 -0
  284. package/src/runtime/executor.ts +43 -31
  285. package/src/runtime/http.ts +641 -61
  286. package/src/runtime/insights.ts +2 -2
  287. package/src/runtime/instrumentation.ts +520 -15
  288. package/src/runtime/native-network-errors.ts +99 -0
  289. package/src/runtime/native-network.ts +1605 -0
  290. package/src/runtime/ocr.ts +523 -0
  291. package/src/runtime/otlp.ts +467 -21
  292. package/src/runtime/proxy-errors.ts +12 -4
  293. package/src/runtime/proxy-nodemaven.ts +221 -0
  294. package/src/runtime/proxy-telemetry.ts +244 -75
  295. package/src/runtime/redirects.ts +66 -0
  296. package/src/runtime/redis.ts +7 -2
  297. package/src/runtime/request-options.ts +680 -1
  298. package/src/runtime/resolver-config.ts +6 -0
  299. package/src/runtime/resolver-public.ts +23 -0
  300. package/src/runtime/resolver-shared.ts +33 -0
  301. package/src/runtime/resolver-vendors/bindings.ts +56 -0
  302. package/src/runtime/resolver-vendors/browser.ts +533 -0
  303. package/src/runtime/resolver-vendors/capsolver.ts +707 -0
  304. package/src/runtime/resolver-vendors/hosts.ts +38 -0
  305. package/src/runtime/resolver-vendors/twocaptcha.ts +540 -0
  306. package/src/runtime/resolver-vendors/types.ts +212 -0
  307. package/src/runtime/resolver.ts +1157 -0
  308. package/src/runtime/secrets.ts +64 -0
  309. package/src/runtime/state.ts +394 -77
  310. package/src/runtime/stealth-cookies.ts +132 -0
  311. package/src/runtime/stealth.ts +1280 -336
  312. package/src/runtime/stt.ts +1 -19
  313. package/src/runtime/timeout.ts +18 -0
  314. package/src/runtime/trace-config.ts +78 -0
  315. package/src/runtime/trace.ts +57 -17
  316. package/src/serve.ts +6 -1
  317. package/src/server/error-observability.ts +1 -0
  318. package/src/server/index.ts +34 -2
  319. package/src/server/self-test-input-tokens.ts +29 -14
  320. package/src/server/self-test.ts +191 -68
  321. package/src/server/serve-implementation.ts +3378 -0
  322. package/src/server/serve.ts +1 -1632
  323. package/src/server/trace-output.ts +129 -0
  324. package/src/server/types.ts +13 -1
  325. package/src/stateful/README.md +146 -0
  326. package/src/stateful/errors.ts +35 -0
  327. package/src/stateful/http-provider-event-emitter.ts +314 -0
  328. package/src/stateful/http-session-owner-registry.ts +306 -0
  329. package/src/stateful/index.ts +18 -0
  330. package/src/stateful/provider-event-delivery-failures.ts +80 -0
  331. package/src/stateful/provider-event-pipeline-metrics.ts +95 -0
  332. package/src/stateful/provider-event-pipeline.ts +61 -0
  333. package/src/stateful/provider-events.ts +462 -0
  334. package/src/stateful/session-key.ts +111 -0
  335. package/src/stateful/stateful-provider-adapter-context.ts +59 -0
  336. package/src/stateful/stateful-provider-adapter-metrics.ts +48 -0
  337. package/src/stateful/stateful-provider-adapter.ts +562 -0
  338. package/src/stateful/stateful-provider-observability.ts +261 -0
  339. package/src/stateful/stateful-provider-owner-forwarder.ts +287 -0
  340. package/src/stateful/stateful-provider-runtime-context.ts +92 -0
  341. package/src/stateful/stateful-provider-runtime-executor.ts +96 -0
  342. package/src/stateful/stateful-provider-session-routing.ts +546 -0
  343. package/src/stateful/stateful-provider-session-runtime.ts +403 -0
  344. package/src/stateful-signing.ts +46 -0
  345. package/src/stealth/profiles.ts +202 -231
  346. package/src/stream-evidence.ts +988 -0
  347. package/src/stream.ts +8 -1
  348. package/src/testing/index.ts +10 -1
  349. package/src/testing/run.ts +658 -15
  350. package/src/trace-sanitization.ts +63 -0
  351. package/src/types.ts +788 -174
  352. package/dist/cli/templates/provider/CLAUDE.md.tpl +0 -1
  353. package/src/cli/templates/provider/CLAUDE.md.tpl +0 -1
  354. /package/dist/cli/templates/provider/{skills → .agents/skills}/fixtures-and-recording/SKILL.md.tpl +0 -0
  355. /package/dist/cli/templates/provider/{skills → .agents/skills}/health-checks-and-fail-closed/SKILL.md.tpl +0 -0
  356. /package/dist/cli/templates/provider/{skills → .agents/skills}/normalization-standards/SKILL.md.tpl +0 -0
  357. /package/dist/cli/templates/provider/{skills → .agents/skills}/pagination-and-counts/SKILL.md.tpl +0 -0
  358. /package/dist/cli/templates/provider/{skills → .agents/skills}/upstream-contract-verification/SKILL.md.tpl +0 -0
  359. /package/dist/cli/templates/provider/{skills → .agents/skills}/upstream-notes/README.md.tpl +0 -0
  360. /package/src/cli/templates/provider/{skills → .agents/skills}/fixtures-and-recording/SKILL.md.tpl +0 -0
  361. /package/src/cli/templates/provider/{skills → .agents/skills}/health-checks-and-fail-closed/SKILL.md.tpl +0 -0
  362. /package/src/cli/templates/provider/{skills → .agents/skills}/normalization-standards/SKILL.md.tpl +0 -0
  363. /package/src/cli/templates/provider/{skills → .agents/skills}/pagination-and-counts/SKILL.md.tpl +0 -0
  364. /package/src/cli/templates/provider/{skills → .agents/skills}/upstream-contract-verification/SKILL.md.tpl +0 -0
  365. /package/src/cli/templates/provider/{skills → .agents/skills}/upstream-notes/README.md.tpl +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,191 @@
1
1
  # @apifuse/provider-sdk Changelog
2
2
 
3
+ ## 2.2.0-beta.50
4
+
5
+ - Release candidate for main commit 341c2f0e55a4159cac423fec0bf4f84625191731.
6
+
7
+ ## 2.2.0-beta.49
8
+
9
+ - Release candidate for main commit 694b145f65c2c81e298c2516dde221ce19cb52da.
10
+
11
+ ## 2.2.0-beta.48
12
+
13
+ - Release candidate for main commit ba6636fa8dd53a35af3091ae6efd797f5ef3d836.
14
+
15
+ ## 2.2.0-beta.47
16
+
17
+ - Release candidate for main commit 0ff0c6c90153af3aab75978eb73040c9adaa2609.
18
+
19
+ ## 2.2.0-beta.46
20
+
21
+ - Release candidate for main commit 0340fbc51b4ad71689bb1ec61b9b818dedda4587.
22
+
23
+ ## 2.2.0-beta.45
24
+
25
+ - Release candidate for main commit 5d337d9fc1c77cd814ec7a4e1aa44ba0f8b2a5a9.
26
+
27
+ ## 2.2.0-beta.44
28
+
29
+ - Release candidate for main commit a3091c0b4931c5ae48fe01b9776e4dc213db2716.
30
+
31
+ ## 2.2.0-beta.43
32
+
33
+ - Release candidate for main commit 5b8b6048514fb500ead400495bd5e1ed8695ed6d.
34
+
35
+ ## 2.2.0-beta.42
36
+
37
+ - Release candidate for main commit efbdbb409c9400e6211b061705b634e659f298bd.
38
+
39
+ ## 2.2.0-beta.41
40
+
41
+ - Release candidate for main commit e1bde60e6a9e0424074a357afd9e8af56549080d.
42
+
43
+ ## 2.2.0-beta.40
44
+
45
+ - Release candidate for main commit 7e2f05a954c23593a77e89e463a9bcbc2cdc7695.
46
+
47
+ ## 2.2.0-beta.39
48
+
49
+ - Release candidate for main commit ecbe349c44e15c873b7c58b42e14610db029eb5f.
50
+
51
+ ## 2.2.0-beta.38
52
+
53
+ - Release candidate for main commit 448775077dbc9ab907209f1feee4e6e4e5ef4283.
54
+
55
+ ## 2.2.0-beta.37
56
+
57
+ - Release candidate for main commit aa14b268dffe1196f25c2b6b314598fe0896edec.
58
+
59
+ ## 2.2.0-beta.36
60
+
61
+ - Release candidate for main commit c6858f8b87d78b3b755adeb28982e875434be406.
62
+
63
+ ## 2.2.0-beta.35
64
+
65
+ - Release candidate for main commit 027fa0087b883a6281bc6d8bdaaf6d0be382000f.
66
+
67
+ ## 2.2.0-beta.34
68
+
69
+ - Release candidate for main commit 383a97e7d0ce995d098d5f95c9ffdcbeed13de31.
70
+
71
+ ## 2.2.0-beta.33
72
+
73
+ - Release candidate for main commit e7d854ec3e859702b22e2b37eaa2ae6bd4545c80.
74
+
75
+ ## 2.2.0-beta.32
76
+
77
+ - Release candidate for main commit 82f1c0c1de916a40c8c74b1d6470a493b134c0ed.
78
+
79
+ ## 2.2.0-beta.31
80
+
81
+ - Release candidate for main commit 94006be0852918867d254dc23d0fa8420a07be9c.
82
+
83
+ ## 2.2.0-beta.30
84
+
85
+ - Release candidate for main commit ccf3d56bfcbe9683c6e7ad45dde8e6703467f9e7.
86
+
87
+ ## 2.2.0-beta.29
88
+
89
+ - Release candidate for main commit b7243459ab12403e11d7b5b93292f09b734b0a96.
90
+
91
+ ## 2.2.0-beta.28
92
+
93
+ - Release candidate for main commit 2936f1891d4e2326502f0585081f8a58060d6dd7.
94
+
95
+ ## 2.2.0-beta.27
96
+
97
+ - Release candidate for main commit 579d9e7fd22d8414b151be2b71a43a0990456911.
98
+
99
+ ## 2.2.0-beta.26
100
+
101
+ - Release candidate for main commit 924fe13d1101e7840d799a562a7a70174355185d.
102
+
103
+ ## 2.2.0-beta.25
104
+
105
+ - Release candidate for main commit e6df658b95c0728b671fd221919ec2f85f82b0b7.
106
+
107
+ ## 2.2.0-beta.24
108
+
109
+ - Release candidate for main commit 0f21a2959dcbb9b96fe426259259d0870cfc537f.
110
+
111
+ ## 2.2.0-beta.23
112
+
113
+ - Release candidate for main commit 36b3bedc9c14913c4152c4631cc87de71062f21f.
114
+
115
+ ## 2.2.0-beta.22
116
+
117
+ - Release candidate for main commit b8bf920b5ca053d1bf43018167fd4eedff01700d.
118
+
119
+ ## Unreleased
120
+
121
+ - Server-stored provider choices now issue word-format tokens unconditionally. The runtime issuance setting and legacy issuance path were removed.
122
+ - **Breaking:** Legacy encrypted server-handle choice tokens are no longer parsed. They are rejected with the uniform choice-not-found error; server-stored choices are now word-only. Encrypted inline choice tokens remain supported.
123
+ - Added the `thrown-error-code-undeclared` authoring lint (warning level): `apifuse check` now statically flags literal `ProviderError`/`ValidationError` codes that are neither SDK-registered nor declared in any operation's `docs.errorCodes`, surfacing the runtime `unregistered_provider_error_code` signal at check time. The canonical SDK code→status mapping moved to `SDK_STATUS_MAPPED_PROVIDER_ERROR_CODES` in `error-resolution.ts`, shared by the runtime status resolver and the lint.
124
+
125
+ ## 2.2.0-beta.21
126
+
127
+ - Release candidate for main commit 00f61024fb18db39711dc5076c4621508baa49f5.
128
+
129
+ ## 2.2.0-beta.20
130
+
131
+ - Release candidate for main commit 8043d2ef0047e431aace750d8abca2e1149ec1d6.
132
+
133
+ ## 2.2.0-beta.19
134
+
135
+ - Release candidate for main commit fd93ae68d0472fae68d908312249163373ec5d22.
136
+
137
+ ## 2.2.0-beta.18
138
+
139
+ - Release candidate for main commit cebaf4b994918d2641c0fe6681fbffd3a3284c5d.
140
+
141
+ ## 2.2.0-beta.17
142
+
143
+ - Release candidate for main commit 5a0f9127a5861992d5c144b07ad379a085756544.
144
+
145
+ ## 2.2.0-beta.16
146
+
147
+ - Release candidate for main commit c5deb2bc31a4a4a236d27a2ce3d214b533ed358f.
148
+
149
+ ## 2.2.0-beta.15
150
+
151
+ - Release candidate for main commit b5ebd25e48f6502e4ddb775d4e0a25f5c8276712.
152
+
153
+ ## 2.2.0-beta.14
154
+
155
+ - Release candidate for main commit 3491acd253ca17b517985e8a618f1c2904a664a9.
156
+
157
+ ## 2.2.0-beta.13
158
+
159
+ - Release candidate for main commit 75e840d0614aea3b99a1e5cef4f93f8cdccf0507.
160
+
161
+ ## 2.2.0-beta.12
162
+
163
+ - Release candidate for main commit c66789c4745c72fc94ad3c10b3e0d7e5ed83fd25.
164
+
165
+ ## 2.2.0-beta.11
166
+
167
+ - Release candidate for main commit f6f739bd5265afe714bbace9900edc2695fcf826.
168
+
169
+ ## 2.2.0-beta.10
170
+
171
+ - Release candidate for main commit c41bd919739e0293ae8fa4d72a8a32f034cef4b8.
172
+
173
+ ## 2.2.0-beta.9
174
+
175
+ - Release candidate for main commit 5c78c8b (bundles #67 nodemaven required-secret + #68 transport vendor-advance).
176
+
177
+ ## 2.2.0-beta.8
178
+
179
+ - Release candidate for main commit 9e8a3f028ee78b9cab29d4aa3f5494ac9cffa65f.
180
+
181
+ ## 2.2.0-beta.7
182
+
183
+ - Release candidate for main commit 2ce4ea4bd36ce333eba8b3b474bf6e82b5e9216c.
184
+
185
+ ## 2.2.0-beta.6
186
+
187
+ - Release candidate for main commit 17f4e41d44efe7c148ef875b950be4f2c7df1294.
188
+
3
189
  ## 2.2.0-beta.5
4
190
 
5
191
  - Release candidate for main commit 82fa14e99a9af7edd44e3196aa3f4e87b4699edf.
@@ -50,8 +236,22 @@
50
236
 
51
237
  ## Unreleased
52
238
 
239
+ - Upstream the platform monorepo's beta.16 dist patch: OAuth2-proxied auth ceremony (`createOAuth2ProxiedStart`, `OAUTH2_PROXIED_PKCE_VERIFIER_KEY`, `APIFUSE__AUTH_PROXY__URL` origin key, proxied redirect/callback turns) and the provider runtime state upgrades it depends on (in-memory compareAndSet with quota-aware write policy, Redis CAS/set Lua scripts with entry quotas and legacy index migration). The monorepo drops `patchedDependencies` once it pins this release.
240
+ - **honest-provider-error-contract (phase 2):** `UPSTREAM_REJECTED` is a registered code family serving HTTP 409 with `retryable: false` — deterministic upstream business refusals are no longer 502s. Operation-declared `docs.errorCodes` may now use 409/410/422. Public error envelopes carry a `source` field (`client` | `upstream_rule` | `upstream_failure` | `apifuse`) derived from the observability category. Taxonomy version bumps to `2026-08-07` with the `upstream_rejected`, `dependency_unavailable`, `unsupported_transport`, and `client_cancelled` categories (409/410/422 map to `upstream_rejected`), matching the platform monorepo SoT. The `unregistered_provider_error_code` signal now carries a `signalFix` pointing at `docs.errorCodes` declaration.
241
+ - **Breaking for custom native gateway adapters:** `NativeGatewayProxySynthesisInput` now includes an injected `credentials` resolver and selected `protocol`; synthesizers may return promises and structured skip reasons, and `resolveNativeGatewayProxy` is async. Default callers retain env-backed behavior. Native transport now supports both HTTP CONNECT and SOCKS5, defaults per vendor with an explicit runtime override, registers smartproxy allocation ahead of nodemaven when declared in that order, and reports every exhausted vendor reason without exposing proxy credentials.
242
+ - Honor operation `docs.errorCodes` at runtime: declared provider-owned statuses and retryability now drive the HTTP envelope, observability header, and structured log; invalid statuses fail `defineProvider`, declared codes no longer emit the unregistered-code signal, and `TransportError` status-preservation workarounds are obsolete.
243
+ - Add an opt-in same-origin redirect hop policy to `ctx.http`, with bounded manual following and typed failures before a refused target is requested.
244
+ - Enforce provider-declared native TCP/TLS egress before proxy or socket setup, with revocable and expiring dynamic grants plus typed authorization failures; providers without a native egress declaration retain legacy behavior.
245
+ - **Breaking:** Provider error `details` is now passed through verbatim; SDK observability fields (`category`, `taxonomyVersion`, `upstreamStatus`, and derived `retryable`) are no longer merged into the public body. Emitted error envelopes now require top-level `retryable`, while inbound stateful forwarding tolerates an older owner response that omits it and defaults it to `false`. The removed observability metadata is available in the new `X-ApiFuse-Error-Observability` response header.
246
+ - Unregistered `ProviderError` codes now default to HTTP 500 instead of 400 and emit an `unregistered_provider_error_code` structured-log signal; registered mappings remain unchanged and take precedence over the HTTP 400 fallback for unregistered input `ValidationError` codes.
247
+ - Add an opt-in native connection idle read timeout with a typed error, independently from TCP/SOCKS/TLS establishment deadlines.
248
+ - Add opt-in `maxBodyBytes` enforcement to stealth fetches and redirect hops, aborting oversized decoded response streams with `response_too_large`.
249
+ - Resolve relative date tokens in fixture requests before input-schema validation, add KST capture-date `fixtures.recordedAt` metadata, and support explicit KST/UTC calendars in the shared health-input resolver.
250
+ - Add opt-in `runStandardTests(provider, { upstreamStub })` real-handler E2E coverage with strict offline transport stubs, output-schema validation, and per-operation warnings when handler E2E is not enabled.
251
+ - Export native-network and request-file TypeScript contracts from the package root and `./provider`, including typed native provider declarations and optional runtime capabilities on provider/auth contexts.
53
252
  - Add `arrayBuffer()` and `bytes()` to `HttpResponse` so `ctx.http` consumers can read binary-safe upstream bodies; internal response handling is now byte-first.
54
253
  - Preserve identity-only operation `connectionId` values in `ProviderContext` without requiring credential material.
254
+ - Accept and validate `proxy.session.drainLeadSeconds` in `defineProvider`, so providers can actually declare the native sticky-expiry drain lead time the type surface already exposed; a non-positive value, or one that meets or exceeds the sticky lifetime, is rejected at define time.
55
255
 
56
256
  ## 2.1.0-beta.15
57
257
 
@@ -107,7 +307,7 @@
107
307
 
108
308
  ## 2.1.0-beta.3
109
309
 
110
- - Replace the legacy TypeScript request transport with `ctx.stealth`, backed by `impit` browser-grade TLS/HTTP2 impersonation without Python runtime dependencies.
310
+ - Replace the legacy TypeScript request transport with `ctx.stealth`, backed by browser-grade TLS/HTTP2 impersonation without Python runtime dependencies.
111
311
  - Add the public `apifuse submit-check` / `apifuse bounty-check` CLI for score-based pre-submission provider quality checks.
112
312
  - Ship `SUBMISSION.md` in the npm package so bounty contributors can follow the checklist without access to the private monorepo.
113
313
  - Include submit-check in generated provider validation scripts and packed-artifact smoke coverage.
package/README.md CHANGED
@@ -119,7 +119,11 @@ the bad request path; provider/runtime failures include `code`, `message`, and
119
119
  local-only values through `connection.secrets`. Read them in handlers with
120
120
  `ctx.credential.get("key")` or `ctx.credential.getAccessToken()`.
121
121
  - **Provider env secrets**: declare `secrets[]`, set values in your shell or
122
- `.env`, and read only those names through `ctx.env.get("NAME")`.
122
+ `.env`, and read only those names through `ctx.env.get("NAME")`. The SDK
123
+ enforces presence of `required: true` declarations before handlers and auth
124
+ flows run, failing the invocation with a structured `MISSING_SECRET` error
125
+ (HTTP 400, category `credential_unavailable`) — do not re-check presence in
126
+ handlers.
123
127
  - **Credentials auth flows**: prefer `defineCredentialsAuth()` over hand-written
124
128
  `auth.flow`. Declare the form fields and credential keys once, then put the
125
129
  upstream login/session creation in `login(ctx, input)`. Return
@@ -133,15 +137,59 @@ the bad request path; provider/runtime failures include `code`, `message`, and
133
137
  `context` object.
134
138
  - **Stealth-sensitive providers**: use `ctx.http` for normal JSON/REST calls and
135
139
  `ctx.stealth.fetch()` when you need browser-like session or cookie control.
136
- `ctx.stealth.fetch()` uses the impit-backed browser stealth transport and
137
- accepts request controls for `params`, `proxy`, `timeout`, `profile`,
138
- `redirect`, `throwOnHttpError`, and `stealth.insecureSkipVerify`. For login
140
+ `ctx.stealth.fetch()` uses the `wreq-js`-backed browser stealth transport and
141
+ accepts request controls for `params`, `sensitiveParams`, `proxy`, `timeout`,
142
+ `maxBodyBytes`, `redirect`, `throwOnHttpError`, and
143
+ `stealth.insecureSkipVerify`. For login
139
144
  flows that must inspect intermediate `Location`/`Set-Cookie` headers, create
140
145
  a session with `ctx.stealth.createSession()` and use `session.redirects.run()`;
141
146
  inspect accumulated cookies through `session.cookies`. Select an SDK stealth
142
- `profile` such as `chrome-146`; do not tune JA3, HTTP/2 SETTINGS, or
143
- pseudo-header order in provider code. Chrome/Firefox-style profiles are
144
- supported; use `ctx.browser` when Safari-specific behavior is required.
147
+ identity with structured `stealth: { browser, os }` options; omitted `os`
148
+ explicitly defaults to `macos`. Do not pin a browser version
149
+ or tune JA3, HTTP/2 SETTINGS, or
150
+ pseudo-header order in provider code. Chrome, Firefox, and Safari profiles
151
+ are supported; use `ctx.browser` when the provider needs browser execution.
152
+ - **Query-parameter credentials**: when an upstream requires a credential in
153
+ its URL query, pass it through `sensitiveParams`, not `params` and never a
154
+ hand-built URL. It is sent as a normal query parameter while the SDK redacts
155
+ its value from transport errors, traces, and recorded fixtures:
156
+
157
+ ```ts
158
+ const response = await ctx.http.get("/openapi/service", {
159
+ params: { page: 1 },
160
+ sensitiveParams: { serviceKey: ctx.env.get("APIFUSE__PROVIDER__EXAMPLE__API_KEY")! },
161
+ });
162
+ ```
163
+
164
+ Use this only when the upstream offers no header or body credential channel.
165
+ Declared query-key positions and exact scalar diagnostics are always redacted.
166
+ Free-text values of four or more characters are redacted as substrings; shorter
167
+ values require token boundaries so low-entropy values do not corrupt unrelated
168
+ words or timestamps. Consequently, a sub-four-character secret embedded in a
169
+ larger alphanumeric token can remain in free text; prefer higher-entropy or
170
+ non-query credentials when possible. `sensitiveParams: {}` is equivalent to
171
+ omitting the option. Redirect results structurally redact declared keys and
172
+ common response-only credential keys from hop URLs; use
173
+ `redirects.run({ stopWhen })` to inspect a real intermediate `Location` during
174
+ the run when a login flow needs a rotated value.
175
+ - **Proxy URLs for non-stealth consumers**: use `resolveProxy()` when a
176
+ provider-owned client outside `ctx.stealth` needs the provider's proxy, such
177
+ as a CAPTCHA solver that must use matching egress. Pass the provider proxy
178
+ policy used by the provider and consume the returned `url`; the SDK owns
179
+ vendor selection, allocation, failover, and URL formats. Never call proxy
180
+ allocator APIs or hardcode proxy vendor hostnames in provider code.
181
+
182
+ ```ts
183
+ import { resolveProxy } from "@apifuse/provider-sdk"
184
+
185
+ const resolvedProxy = await resolveProxy({
186
+ proxyPolicy,
187
+ affinityKey: connectionId,
188
+ })
189
+
190
+ if (!resolvedProxy.url) throw new Error("This login requires proxy egress")
191
+ const captchaTask = { proxy: resolvedProxy.url }
192
+ ```
145
193
  - **Browser providers**: for TypeScript Providers use `runtime: "browser"` plus
146
194
  `browser.engine: "playwright-stealth"`; `nodriver` is a Python-runtime path.
147
195
  Install local browser assets with `bunx playwright install chromium` when
@@ -150,12 +198,29 @@ the bad request path; provider/runtime failures include `code`, `message`, and
150
198
 
151
199
  ## Authoring ergonomics
152
200
 
153
- `defineProvider()` infers each operation handler input from the operation `input` schema. For larger providers, factor operations with `defineOperation()` and compose them later:
201
+ `defineProvider()` establishes the capability declaration before its returned
202
+ builder contextually types operations. For larger providers, export the derived
203
+ context once and use it with `defineOperation()` in separate files:
154
204
 
155
205
  ```ts
156
- import { defineOperation, defineProvider, z } from "@apifuse/provider-sdk/provider"
206
+ import {
207
+ defineOperation,
208
+ defineProvider,
209
+ type ProviderContextOf,
210
+ z,
211
+ } from "@apifuse/provider-sdk/provider"
212
+
213
+ const buildProvider = defineProvider({
214
+ id: "factored-provider",
215
+ version: "1.0.0",
216
+ runtime: "standard",
217
+ meta: { displayName: "Factored", category: "demo" },
218
+ })
157
219
 
158
- const search = defineOperation({
220
+ export type ProviderContext = ProviderContextOf<typeof buildProvider>
221
+
222
+ const search = defineOperation<ProviderContext>()({
223
+ riskClass: "read",
159
224
  input: z.object({ q: z.string().describe("Search query") }),
160
225
  output: z.object({ count: z.number().describe("Result count") }),
161
226
  async handler(ctx, input) {
@@ -166,11 +231,7 @@ const search = defineOperation({
166
231
  },
167
232
  })
168
233
 
169
- export default defineProvider({
170
- id: "factored-provider",
171
- version: "1.0.0",
172
- runtime: "standard",
173
- meta: { displayName: "Factored", category: "demo" },
234
+ export default buildProvider({
174
235
  operations: { search },
175
236
  })
176
237
  ```
@@ -207,17 +268,17 @@ healthCheck: {
207
268
  }
208
269
  ```
209
270
 
210
- ### Operation annotations
271
+ ### Flat operation metadata
211
272
 
212
- Operations declare non-functional metadata via `annotations`:
273
+ Operations declare access, safety, and execution metadata directly on the
274
+ operation. `riskClass` is required and is the safety source of truth:
213
275
 
214
276
  | Field | Type | Notes |
215
277
  |---|---|---|
216
- | `readOnly` | `boolean` | Operation has no side effects (safe to test in production). |
217
- | `destructive` | `boolean` | Operation modifies/deletes state. |
218
- | `idempotent` | `boolean` | Safe to retry without duplicate side effects. |
219
- | `openWorld` | `boolean` | Callable without authentication. |
220
- | `rateLimit` | `{ calls, window }` | Per-operation rate hint. `window` is `"minute"\|"hour"\|"day"`. |
278
+ | `riskClass` | `"read" \| "write" \| "destructive" \| "external-send"` | Required safety classification. |
279
+ | `approval` | `"never" \| "risk-based" \| "always"` | Optional override; omit when it matches the risk-class default. |
280
+ | `connectionMode` | `"none" \| "optional" \| "required"` | Access requirement. Required by lint for credential-bearing providers. |
281
+ | `connectionExternalRefParam` | `string` | Public argument used to resolve a Connection. |
221
282
  | `timeoutMs` | `number` | Per-operation upstream timeout (1–60000 ms). Omit to inherit the gateway global default. |
222
283
 
223
284
  `defineProvider()` validates `timeoutMs` is an integer in `[1, 60000]` and throws `ValidationError` otherwise. The gateway applies the value via `context.WithTimeout` on every proxied call and clamps defensively to the same bound.
package/SUBMISSION.md CHANGED
@@ -28,7 +28,7 @@ The score is a triage aid, not a payout guarantee. Maintainers still review corr
28
28
  | Category | Points | Examples |
29
29
  |---|---:|---|
30
30
  | Definition & metadata | 15 | `defineProvider`, package, Dockerfile, SDK structural checks |
31
- | Operations & schemas | 15 | strong descriptions, annotations, input/output schemas |
31
+ | Operations & schemas | 15 | locale-keyed descriptions, explicit risk classes, input/output schemas |
32
32
  | Fixtures & tests | 15 | bidirectional fixtures that parse against schemas |
33
33
  | Health coverage | 15 | real `healthCheck` or specific `healthCheckUnsupported.reason` |
34
34
  | Runtime/local smoke | 10 | `/health` and at least one `POST /v1/{operation}` note |
@@ -50,7 +50,7 @@ Fix all blockers before submitting:
50
50
  - High-confidence secret or token material in source, README, package metadata, or fixtures.
51
51
  - SDK-native source blockers: prefixed Provider ids, `vendor/` SDK shims or imports, raw `.describe()` prose instead of `describeKey`, raw global `fetch()` calls, and excessive `as Type` assertions.
52
52
 
53
- Warnings do not fail the command, but they should be addressed when practical. For example, the generated starter `ping` operation warns because it is not a real upstream-backed bounty Operation. SDK-native warnings also flag moderate `as Type` assertion counts and credentialed Providers that never reference `ctx.credential`.
53
+ Warnings do not fail the command, but they should be addressed when practical. For example, the generated starter `ping` operation warns because it is not a real upstream-backed bounty Operation. SDK-native warnings also flag moderate `as Type` assertion counts, credentialed Providers that never reference `ctx.credential`, and provider-local re-validation of declared env secrets (`sdk-owned-secret-presence`, 0 points): the SDK already rejects invocations with a structured `MISSING_SECRET` error when a declared `required: true` secret is unset, so `requireServiceKey`-style presence guards are deprecated dead weight — delete the guard and read the value directly with `ctx.env.get()`, or acknowledge a deliberate exception with `// @apifuse-allow sdk-owned-secret-presence: <reason>`.
54
54
 
55
55
  ## Measured local smoke
56
56
 
@@ -6,8 +6,18 @@ import { pathToFileURL } from "node:url";
6
6
 
7
7
  import { z } from "zod";
8
8
 
9
+ import {
10
+ formatPromptAssetIssues,
11
+ PROMPT_ASSET_SYNC_REMEDIATION,
12
+ verifyPromptAssets,
13
+ } from "../src/cli/prompt-assets.js";
14
+ import {
15
+ DECLARATION_INVALID_CODE,
16
+ validateFailClosedDeclaration,
17
+ } from "../src/declaration-validation.js";
18
+ import { isProviderError } from "../src/errors.js";
9
19
  import type { ProviderDefinition } from "../src/index.js";
10
- import { lintProvider, type ProviderLintMode } from "../src/lint.js";
20
+ import { lintProviderWithInformation, type ProviderLintMode } from "../src/lint.js";
11
21
  import { safeParseSchemaSync } from "../src/schema.js";
12
22
 
13
23
  const HELP_TEXT = `Usage: apifuse check [path]
@@ -61,7 +71,7 @@ function normalizeArgs(argv: string[]): string[] {
61
71
  return argv[0] === "check" ? argv.slice(1) : argv;
62
72
  }
63
73
 
64
- function resolveProviderRoot(inputPath: string): string {
74
+ export function resolveProviderRoot(inputPath: string): string {
65
75
  const resolvedInput = resolveFromParents(inputPath);
66
76
 
67
77
  if (!existsSync(resolvedInput)) {
@@ -113,15 +123,27 @@ export async function runChecks(
113
123
  const indexPath = resolve(providerRoot, "index.ts");
114
124
  const dockerfilePath = resolve(providerRoot, "Dockerfile");
115
125
  const packageJsonPath = resolve(providerRoot, "package.json");
116
-
117
- const providerModule = existsSync(indexPath)
118
- ? await import(pathToFileURL(indexPath).href)
119
- : undefined;
126
+ const providerJsonPath = resolve(providerRoot, "provider.json");
127
+
128
+ let providerModule: Record<string, unknown> | undefined;
129
+ let providerImportError: unknown;
130
+ if (existsSync(indexPath)) {
131
+ try {
132
+ providerModule = (await import(pathToFileURL(indexPath).href)) as Record<string, unknown>;
133
+ } catch (error) {
134
+ if (isProviderError(error) && error.code === DECLARATION_INVALID_CODE) {
135
+ providerImportError = error;
136
+ } else {
137
+ throw error;
138
+ }
139
+ }
140
+ }
120
141
  const provider = assertProviderDefinition(providerModule?.default);
121
142
  const providerSourceFiles = collectProviderSourceFiles(providerRoot);
122
143
 
123
144
  return [
124
145
  checkIndex(indexPath, provider),
146
+ checkDeclaration(provider, providerImportError),
125
147
  checkOperations(provider),
126
148
  checkFixtures(provider),
127
149
  checkSchemas(provider),
@@ -129,9 +151,70 @@ export async function runChecks(
129
151
  checkProviderMetadata(provider),
130
152
  checkDockerfile(dockerfilePath),
131
153
  checkPackageJson(packageJsonPath),
154
+ checkProviderJson(providerJsonPath, packageJsonPath),
155
+ checkPromptAssets(providerRoot),
132
156
  ];
133
157
  }
134
158
 
159
+ const DECLARATION_CHECK_MESSAGE = "Provider declaration passes fail-closed validation";
160
+
161
+ function checkDeclaration(
162
+ provider: ProviderDefinition | undefined,
163
+ importError: unknown,
164
+ ): CheckResult {
165
+ if (importError !== undefined) {
166
+ return {
167
+ message: DECLARATION_CHECK_MESSAGE,
168
+ passed: false,
169
+ details: formatDeclarationError(importError),
170
+ };
171
+ }
172
+ if (!provider) return { message: DECLARATION_CHECK_MESSAGE, passed: false };
173
+ try {
174
+ validateFailClosedDeclaration(provider);
175
+ return { message: DECLARATION_CHECK_MESSAGE, passed: true };
176
+ } catch (error) {
177
+ return {
178
+ message: DECLARATION_CHECK_MESSAGE,
179
+ passed: false,
180
+ details: formatDeclarationError(error),
181
+ };
182
+ }
183
+ }
184
+
185
+ function formatDeclarationError(error: unknown): string[] {
186
+ if (isProviderError(error) && error.code === DECLARATION_INVALID_CODE) {
187
+ const details = error.details;
188
+ if (isRecord(details) && Array.isArray(details.violations)) {
189
+ return details.violations.map((violation) => {
190
+ if (!isRecord(violation)) return String(violation);
191
+ const ruleId = typeof violation.ruleId === "string" ? violation.ruleId : "unknown-rule";
192
+ const path = typeof violation.path === "string" ? violation.path : "unknown-path";
193
+ const message = typeof violation.message === "string" ? `: ${violation.message}` : "";
194
+ const fix = typeof violation.fix === "string" ? ` Fix: ${violation.fix}` : "";
195
+ return `${path} [${ruleId}]${message}${fix}`;
196
+ });
197
+ }
198
+ }
199
+ return [error instanceof Error ? error.message : String(error)];
200
+ }
201
+
202
+ export const PROMPT_ASSETS_CHECK_MESSAGE =
203
+ "Agent prompt assets match the installed SDK version";
204
+
205
+ function checkPromptAssets(providerRoot: string): CheckResult {
206
+ const verification = verifyPromptAssets(providerRoot);
207
+ if (verification.ok) {
208
+ return { message: PROMPT_ASSETS_CHECK_MESSAGE, passed: true };
209
+ }
210
+
211
+ return {
212
+ message: PROMPT_ASSETS_CHECK_MESSAGE,
213
+ passed: false,
214
+ details: [...formatPromptAssetIssues(verification), PROMPT_ASSET_SYNC_REMEDIATION],
215
+ };
216
+ }
217
+
135
218
  function isScannableProviderSourceFile(relativePath: string): boolean {
136
219
  return (
137
220
  /\.(?:ts|tsx|js|jsx|mjs|cjs|sh|bash)$/.test(relativePath) ||
@@ -142,6 +225,9 @@ function isScannableProviderSourceFile(relativePath: string): boolean {
142
225
 
143
226
  function collectProviderSourceFiles(providerRoot: string): Record<string, string> {
144
227
  const sources: Record<string, string> = {};
228
+ // `.agents`/`.apifuse` are deliberately not skipped: managed content there
229
+ // is markdown/JSON (never matched by isScannableProviderSourceFile), and a
230
+ // planted `.ts`/`.sh` under those directories must stay in scanner scope.
145
231
  const skipDirectories = new Set([".git", "node_modules", "dist", "build", ".next"]);
146
232
  const visit = (directory: string) => {
147
233
  for (const entry of readdirSync(directory, { withFileTypes: true })) {
@@ -293,12 +379,21 @@ function checkAuthoringLint(
293
379
  };
294
380
  }
295
381
 
296
- const diagnostics = lintProvider({ ...provider, providerSourceFiles }, { mode: lintMode });
382
+ const { diagnostics, information } = lintProviderWithInformation(
383
+ { ...provider, providerSourceFiles },
384
+ { mode: lintMode },
385
+ );
297
386
  const errors = diagnostics.filter((diagnostic) => diagnostic.level === "error");
298
- const details = diagnostics.map((diagnostic) => {
299
- const field = diagnostic.field ? `${diagnostic.field}: ` : "";
300
- return `${diagnostic.level.toUpperCase()} ${diagnostic.rule} ${field}${diagnostic.message}`;
387
+ const details = information.map((entry) => {
388
+ const field = entry.field ? `${entry.field}: ` : "";
389
+ return `INFO ${entry.rule} ${field}${entry.message}`;
301
390
  });
391
+ details.push(
392
+ ...diagnostics.map((diagnostic) => {
393
+ const field = diagnostic.field ? `${diagnostic.field}: ` : "";
394
+ return `${diagnostic.level.toUpperCase()} ${diagnostic.rule} ${field}${diagnostic.message}`;
395
+ }),
396
+ );
302
397
 
303
398
  return {
304
399
  message: "Provider authoring lint has no error-level diagnostics",
@@ -394,6 +489,65 @@ function checkPackageJson(packageJsonPath: string): CheckResult {
394
489
  }
395
490
  }
396
491
 
492
+ export const PROVIDER_JSON_CHECK_MESSAGE = "provider.json exists with a valid declaration";
493
+
494
+ const providerDeclarationSchema = z
495
+ .object({
496
+ schemaVersion: z.literal(1),
497
+ providerId: z.string(),
498
+ owner: z.string(),
499
+ lifecycle: z.enum(["draft", "ready", "live", "retired"]),
500
+ })
501
+ .strict();
502
+
503
+ function checkProviderJson(providerJsonPath: string, packageJsonPath: string): CheckResult {
504
+ if (!existsSync(providerJsonPath)) {
505
+ return {
506
+ message: PROVIDER_JSON_CHECK_MESSAGE,
507
+ passed: false,
508
+ details: ["Missing provider.json at the provider root"],
509
+ };
510
+ }
511
+
512
+ try {
513
+ const declaration = providerDeclarationSchema.parse(
514
+ JSON.parse(readFileSync(providerJsonPath, "utf-8")) as unknown,
515
+ );
516
+ const expectedProviderId = readProviderIdFromPackageName(packageJsonPath);
517
+ if (expectedProviderId !== undefined && declaration.providerId !== expectedProviderId) {
518
+ return {
519
+ message: PROVIDER_JSON_CHECK_MESSAGE,
520
+ passed: false,
521
+ details: [
522
+ `provider.json providerId "${declaration.providerId}" does not match package.json name (expected "${expectedProviderId}")`,
523
+ ],
524
+ };
525
+ }
526
+
527
+ return {
528
+ message: PROVIDER_JSON_CHECK_MESSAGE,
529
+ passed: true,
530
+ details: [`providerId: ${declaration.providerId}`, `lifecycle: ${declaration.lifecycle}`],
531
+ };
532
+ } catch (error) {
533
+ return {
534
+ message: PROVIDER_JSON_CHECK_MESSAGE,
535
+ passed: false,
536
+ details: [error instanceof Error ? error.message : String(error)],
537
+ };
538
+ }
539
+ }
540
+
541
+ function readProviderIdFromPackageName(packageJsonPath: string): string | undefined {
542
+ try {
543
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8")) as unknown;
544
+ if (!isRecord(packageJson) || typeof packageJson.name !== "string") return undefined;
545
+ return /^(?:apifuse-provider-|@apifuse\/provider-)(.+)$/.exec(packageJson.name)?.[1];
546
+ } catch {
547
+ return undefined;
548
+ }
549
+ }
550
+
397
551
  function assertProviderDefinition(value: unknown): ProviderDefinition | undefined {
398
552
  return isProviderDefinition(value) ? value : undefined;
399
553
  }
@@ -406,7 +560,7 @@ function isProviderDefinition(value: unknown): value is ProviderDefinition {
406
560
  return (
407
561
  typeof value.id === "string" &&
408
562
  typeof value.version === "string" &&
409
- (value.runtime === "standard" || value.runtime === "browser") &&
563
+ (value.runtime === "standard" || value.runtime === "shared" || value.runtime === "browser") &&
410
564
  typeof value.meta.displayName === "string" &&
411
565
  typeof value.meta.category === "string"
412
566
  );