nexakit 0.10.0 → 0.13.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 (479) hide show
  1. package/README.md +13 -6
  2. package/assets/runtime/package-lock.json +415 -6
  3. package/bench/casos/arquitectura/alta-usuarios/base/controladores/usuarios.js +16 -0
  4. package/bench/casos/arquitectura/alta-usuarios/base/db.js +14 -0
  5. package/bench/casos/arquitectura/alta-usuarios/base/docs/adr/0003-capas.md +15 -0
  6. package/bench/casos/arquitectura/alta-usuarios/base/errores.js +3 -0
  7. package/bench/casos/arquitectura/alta-usuarios/base/repositorios/usuarios.js +14 -0
  8. package/bench/casos/arquitectura/alta-usuarios/base/servicios/usuarios.js +20 -0
  9. package/bench/casos/arquitectura/alta-usuarios/cambio/controladores/usuarios.js +47 -0
  10. package/bench/casos/arquitectura/alta-usuarios/cambio/repositorios/usuarios.js +21 -0
  11. package/bench/casos/arquitectura/alta-usuarios/cambio/servicios/perfil.js +14 -0
  12. package/bench/casos/arquitectura/alta-usuarios/esperado.json +53 -0
  13. package/bench/casos/arquitectura/pedidos-facturacion/base/docs/adr/0001-capas.md +18 -0
  14. package/bench/casos/arquitectura/pedidos-facturacion/base/src/aplicacion/confirmar.ts +8 -0
  15. package/bench/casos/arquitectura/pedidos-facturacion/base/src/dominio/pedido.ts +15 -0
  16. package/bench/casos/arquitectura/pedidos-facturacion/base/src/dominio/puertos.ts +6 -0
  17. package/bench/casos/arquitectura/pedidos-facturacion/base/src/infra/db.ts +14 -0
  18. package/bench/casos/arquitectura/pedidos-facturacion/base/src/main.ts +9 -0
  19. package/bench/casos/arquitectura/pedidos-facturacion/cambio/src/aplicacion/facturar.ts +19 -0
  20. package/bench/casos/arquitectura/pedidos-facturacion/cambio/src/dominio/informe.ts +7 -0
  21. package/bench/casos/arquitectura/pedidos-facturacion/cambio/src/dominio/pedido.ts +21 -0
  22. package/bench/casos/arquitectura/pedidos-facturacion/cambio/src/infra/db.ts +22 -0
  23. package/bench/casos/arquitectura/pedidos-facturacion/esperado.json +53 -0
  24. package/bench/casos/arquitectura/resumen-cliente/base/docs/adr/0001-capas.md +18 -0
  25. package/bench/casos/arquitectura/resumen-cliente/base/src/aplicacion/confirmar.ts +8 -0
  26. package/bench/casos/arquitectura/resumen-cliente/base/src/dominio/pedido.ts +15 -0
  27. package/bench/casos/arquitectura/resumen-cliente/base/src/dominio/puertos.ts +6 -0
  28. package/bench/casos/arquitectura/resumen-cliente/base/src/infra/db.ts +14 -0
  29. package/bench/casos/arquitectura/resumen-cliente/base/src/main.ts +9 -0
  30. package/bench/casos/arquitectura/resumen-cliente/cambio/src/aplicacion/resumen.ts +6 -0
  31. package/bench/casos/arquitectura/resumen-cliente/cambio/src/dominio/pedido.ts +33 -0
  32. package/bench/casos/arquitectura/resumen-cliente/cambio/src/dominio/puertos.ts +7 -0
  33. package/bench/casos/arquitectura/resumen-cliente/cambio/src/infra/db.ts +18 -0
  34. package/bench/casos/arquitectura/resumen-cliente/cambio/src/main.ts +14 -0
  35. package/bench/casos/arquitectura/resumen-cliente/esperado.json +23 -0
  36. package/bench/casos/documentacion/comentario-obsoleto/base/README.md +18 -0
  37. package/bench/casos/documentacion/comentario-obsoleto/base/src/usuarios.ts +35 -0
  38. package/bench/casos/documentacion/comentario-obsoleto/cambio/src/copia.ts +8 -0
  39. package/bench/casos/documentacion/comentario-obsoleto/cambio/src/usuarios.ts +43 -0
  40. package/bench/casos/documentacion/comentario-obsoleto/esperado.json +42 -0
  41. package/bench/casos/documentacion/reportes-config/base/README.md +23 -0
  42. package/bench/casos/documentacion/reportes-config/base/src/cli.js +33 -0
  43. package/bench/casos/documentacion/reportes-config/base/src/config.js +15 -0
  44. package/bench/casos/documentacion/reportes-config/base/src/envio.js +23 -0
  45. package/bench/casos/documentacion/reportes-config/cambio/src/cli.js +35 -0
  46. package/bench/casos/documentacion/reportes-config/cambio/src/config.js +15 -0
  47. package/bench/casos/documentacion/reportes-config/esperado.json +42 -0
  48. package/bench/casos/documentacion/tiempo-espera/base/README.md +10 -0
  49. package/bench/casos/documentacion/tiempo-espera/base/src/config.js +8 -0
  50. package/bench/casos/documentacion/tiempo-espera/cambio/README.md +10 -0
  51. package/bench/casos/documentacion/tiempo-espera/cambio/src/config.js +8 -0
  52. package/bench/casos/documentacion/tiempo-espera/esperado.json +16 -0
  53. package/bench/casos/pruebas/calendario-laboral/base/src/fechas.js +3 -0
  54. package/bench/casos/pruebas/calendario-laboral/base/test/fechas.test.js +7 -0
  55. package/bench/casos/pruebas/calendario-laboral/cambio/src/fechas.js +37 -0
  56. package/bench/casos/pruebas/calendario-laboral/cambio/test/calendario.test.js +31 -0
  57. package/bench/casos/pruebas/calendario-laboral/esperado.json +49 -0
  58. package/bench/casos/pruebas/fin-de-semana/base/src/fechas.js +3 -0
  59. package/bench/casos/pruebas/fin-de-semana/base/test/fechas.test.js +7 -0
  60. package/bench/casos/pruebas/fin-de-semana/cambio/src/fechas.js +8 -0
  61. package/bench/casos/pruebas/fin-de-semana/cambio/test/fines-de-semana.test.js +13 -0
  62. package/bench/casos/pruebas/fin-de-semana/esperado.json +16 -0
  63. package/bench/casos/pruebas/precios-carrito/base/src/precio.ts +3 -0
  64. package/bench/casos/pruebas/precios-carrito/base/test/precio.test.js +11 -0
  65. package/bench/casos/pruebas/precios-carrito/cambio/src/precio.ts +34 -0
  66. package/bench/casos/pruebas/precios-carrito/cambio/test/precio.test.js +42 -0
  67. package/bench/casos/pruebas/precios-carrito/esperado.json +42 -0
  68. package/bench/casos/rendimiento/boletin-correo/base/src/correo.html +1 -0
  69. package/bench/casos/rendimiento/boletin-correo/base/src/plantilla.ts +11 -0
  70. package/bench/casos/rendimiento/boletin-correo/cambio/src/envios.ts +44 -0
  71. package/bench/casos/rendimiento/boletin-correo/cambio/src/plantilla.ts +10 -0
  72. package/bench/casos/rendimiento/boletin-correo/esperado.json +42 -0
  73. package/bench/casos/rendimiento/clientes-por-lote/base/src/informe.js +8 -0
  74. package/bench/casos/rendimiento/clientes-por-lote/cambio/src/informe.js +6 -0
  75. package/bench/casos/rendimiento/clientes-por-lote/esperado.json +14 -0
  76. package/bench/casos/rendimiento/informe-ventas/base/src/informe.js +6 -0
  77. package/bench/casos/rendimiento/informe-ventas/base/src/tasas.json +1 -0
  78. package/bench/casos/rendimiento/informe-ventas/cambio/src/informe.js +33 -0
  79. package/bench/casos/rendimiento/informe-ventas/cambio/src/tasas.js +7 -0
  80. package/bench/casos/rendimiento/informe-ventas/esperado.json +42 -0
  81. package/bench/casos/seguridad/inyeccion-orden/base/src/respaldo.ts +13 -0
  82. package/bench/casos/seguridad/inyeccion-orden/cambio/src/respaldo.ts +69 -0
  83. package/bench/casos/seguridad/inyeccion-orden/esperado.json +42 -0
  84. package/bench/casos/seguridad/limpio-validacion/base/servidor.js +11 -0
  85. package/bench/casos/seguridad/limpio-validacion/cambio/servidor.js +39 -0
  86. package/bench/casos/seguridad/limpio-validacion/esperado.json +14 -0
  87. package/bench/casos/seguridad/servidor-archivos/base/servidor.js +21 -0
  88. package/bench/casos/seguridad/servidor-archivos/cambio/servidor.js +79 -0
  89. package/bench/casos/seguridad/servidor-archivos/esperado.json +42 -0
  90. package/bin/nexakit-fabrica-mcp.js +12 -0
  91. package/dist/fabrica/banco/casos.js +304 -0
  92. package/dist/fabrica/banco/ejecutar.js +483 -0
  93. package/dist/fabrica/banco/medir.js +120 -0
  94. package/dist/fabrica/cli.js +737 -0
  95. package/dist/fabrica/conectores/antigravity.js +1040 -0
  96. package/dist/fabrica/conectores/codex.js +967 -0
  97. package/dist/fabrica/conectores/tipos.js +8 -0
  98. package/dist/fabrica/config.js +44 -0
  99. package/dist/fabrica/consolidar.js +218 -0
  100. package/dist/fabrica/decision.js +210 -0
  101. package/dist/fabrica/diff.js +247 -0
  102. package/dist/fabrica/disco.js +356 -0
  103. package/dist/fabrica/ejecutor.js +597 -0
  104. package/dist/fabrica/encargo/candado.js +274 -0
  105. package/dist/fabrica/encargo/ejecutar.js +827 -0
  106. package/dist/fabrica/encargo/evidencia.js +308 -0
  107. package/dist/fabrica/encargo/parche.js +146 -0
  108. package/dist/fabrica/encargo/worktree.js +394 -0
  109. package/dist/fabrica/enrutador.js +425 -0
  110. package/dist/fabrica/errores.js +14 -0
  111. package/dist/fabrica/esquemas.js +57 -0
  112. package/dist/fabrica/estaciones.js +75 -0
  113. package/dist/fabrica/evidencia.js +406 -0
  114. package/dist/fabrica/indice.js +1 -0
  115. package/dist/fabrica/jsonrpc.js +274 -0
  116. package/dist/fabrica/lecciones.js +363 -0
  117. package/dist/fabrica/mcp.js +376 -0
  118. package/dist/fabrica/preferencias.js +56 -0
  119. package/dist/fabrica/protocolos/codex/AbsolutePathBuf.js +2 -0
  120. package/dist/fabrica/protocolos/codex/ApplyPatchApprovalResponse.js +2 -0
  121. package/dist/fabrica/protocolos/codex/ClientInfo.js +2 -0
  122. package/dist/fabrica/protocolos/codex/ExecCommandApprovalParams.js +2 -0
  123. package/dist/fabrica/protocolos/codex/ExecCommandApprovalResponse.js +2 -0
  124. package/dist/fabrica/protocolos/codex/ExecPolicyAmendment.js +2 -0
  125. package/dist/fabrica/protocolos/codex/FunctionCallOutputBody.js +2 -0
  126. package/dist/fabrica/protocolos/codex/FunctionCallOutputContentItem.js +2 -0
  127. package/dist/fabrica/protocolos/codex/ImageDetail.js +2 -0
  128. package/dist/fabrica/protocolos/codex/InitializeCapabilities.js +2 -0
  129. package/dist/fabrica/protocolos/codex/InitializeParams.js +2 -0
  130. package/dist/fabrica/protocolos/codex/InitializeResponse.js +2 -0
  131. package/dist/fabrica/protocolos/codex/InputModality.js +2 -0
  132. package/dist/fabrica/protocolos/codex/LegacyAppPathString.js +2 -0
  133. package/dist/fabrica/protocolos/codex/NetworkPolicyAmendment.js +2 -0
  134. package/dist/fabrica/protocolos/codex/NetworkPolicyRuleAction.js +2 -0
  135. package/dist/fabrica/protocolos/codex/ParsedCommand.js +2 -0
  136. package/dist/fabrica/protocolos/codex/Personality.js +2 -0
  137. package/dist/fabrica/protocolos/codex/ReasoningEffort.js +2 -0
  138. package/dist/fabrica/protocolos/codex/ReasoningSummary.js +2 -0
  139. package/dist/fabrica/protocolos/codex/ReviewDecision.js +2 -0
  140. package/dist/fabrica/protocolos/codex/ThreadId.js +2 -0
  141. package/dist/fabrica/protocolos/codex/serde_json/JsonValue.js +2 -0
  142. package/dist/fabrica/protocolos/codex/v2/AdditionalFileSystemPermissions.js +2 -0
  143. package/dist/fabrica/protocolos/codex/v2/AdditionalNetworkPermissions.js +2 -0
  144. package/dist/fabrica/protocolos/codex/v2/ApprovalsReviewer.js +2 -0
  145. package/dist/fabrica/protocolos/codex/v2/AskForApproval.js +2 -0
  146. package/dist/fabrica/protocolos/codex/v2/ByteRange.js +2 -0
  147. package/dist/fabrica/protocolos/codex/v2/CommandAction.js +2 -0
  148. package/dist/fabrica/protocolos/codex/v2/CommandExecutionApprovalDecision.js +2 -0
  149. package/dist/fabrica/protocolos/codex/v2/CommandExecutionApprovalKind.js +2 -0
  150. package/dist/fabrica/protocolos/codex/v2/CommandExecutionRequestApprovalParams.js +2 -0
  151. package/dist/fabrica/protocolos/codex/v2/CommandExecutionRequestApprovalResponse.js +2 -0
  152. package/dist/fabrica/protocolos/codex/v2/ConfigReadParams.js +2 -0
  153. package/dist/fabrica/protocolos/codex/v2/CyberAccessProgram.js +2 -0
  154. package/dist/fabrica/protocolos/codex/v2/ExecPolicyAmendment.js +2 -0
  155. package/dist/fabrica/protocolos/codex/v2/FileChangeApprovalDecision.js +2 -0
  156. package/dist/fabrica/protocolos/codex/v2/FileChangeRequestApprovalResponse.js +2 -0
  157. package/dist/fabrica/protocolos/codex/v2/FileSystemAccessMode.js +2 -0
  158. package/dist/fabrica/protocolos/codex/v2/FileSystemPath.js +2 -0
  159. package/dist/fabrica/protocolos/codex/v2/FileSystemSandboxEntry.js +2 -0
  160. package/dist/fabrica/protocolos/codex/v2/FileSystemSpecialPath.js +2 -0
  161. package/dist/fabrica/protocolos/codex/v2/GrantedPermissionProfile.js +2 -0
  162. package/dist/fabrica/protocolos/codex/v2/ListMcpServerStatusParams.js +2 -0
  163. package/dist/fabrica/protocolos/codex/v2/McpServerElicitationAction.js +2 -0
  164. package/dist/fabrica/protocolos/codex/v2/McpServerElicitationRequestResponse.js +2 -0
  165. package/dist/fabrica/protocolos/codex/v2/McpServerStatusDetail.js +2 -0
  166. package/dist/fabrica/protocolos/codex/v2/Model.js +2 -0
  167. package/dist/fabrica/protocolos/codex/v2/ModelAccessPrograms.js +2 -0
  168. package/dist/fabrica/protocolos/codex/v2/ModelAvailabilityNux.js +2 -0
  169. package/dist/fabrica/protocolos/codex/v2/ModelListParams.js +2 -0
  170. package/dist/fabrica/protocolos/codex/v2/ModelListResponse.js +2 -0
  171. package/dist/fabrica/protocolos/codex/v2/ModelServiceTier.js +2 -0
  172. package/dist/fabrica/protocolos/codex/v2/ModelUpgradeInfo.js +2 -0
  173. package/dist/fabrica/protocolos/codex/v2/MultiAgentVersion.js +2 -0
  174. package/dist/fabrica/protocolos/codex/v2/NetworkAccess.js +2 -0
  175. package/dist/fabrica/protocolos/codex/v2/NetworkApprovalContext.js +2 -0
  176. package/dist/fabrica/protocolos/codex/v2/NetworkApprovalProtocol.js +2 -0
  177. package/dist/fabrica/protocolos/codex/v2/NetworkPolicyAmendment.js +2 -0
  178. package/dist/fabrica/protocolos/codex/v2/NetworkPolicyRuleAction.js +2 -0
  179. package/dist/fabrica/protocolos/codex/v2/PermissionGrantScope.js +2 -0
  180. package/dist/fabrica/protocolos/codex/v2/PermissionsRequestApprovalResponse.js +2 -0
  181. package/dist/fabrica/protocolos/codex/v2/ReasoningEffortOption.js +2 -0
  182. package/dist/fabrica/protocolos/codex/v2/SandboxMode.js +2 -0
  183. package/dist/fabrica/protocolos/codex/v2/SandboxPolicy.js +2 -0
  184. package/dist/fabrica/protocolos/codex/v2/TextElement.js +2 -0
  185. package/dist/fabrica/protocolos/codex/v2/ThreadSource.js +2 -0
  186. package/dist/fabrica/protocolos/codex/v2/ThreadStartParams.js +2 -0
  187. package/dist/fabrica/protocolos/codex/v2/ThreadStartSource.js +2 -0
  188. package/dist/fabrica/protocolos/codex/v2/ThreadTokenUsage.js +2 -0
  189. package/dist/fabrica/protocolos/codex/v2/ThreadTokenUsageUpdatedNotification.js +2 -0
  190. package/dist/fabrica/protocolos/codex/v2/TokenUsageBreakdown.js +2 -0
  191. package/dist/fabrica/protocolos/codex/v2/ToolRequestUserInputAnswer.js +2 -0
  192. package/dist/fabrica/protocolos/codex/v2/ToolRequestUserInputResponse.js +2 -0
  193. package/dist/fabrica/protocolos/codex/v2/TurnInterruptParams.js +2 -0
  194. package/dist/fabrica/protocolos/codex/v2/TurnStartParams.js +2 -0
  195. package/dist/fabrica/protocolos/codex/v2/TurnToolOutput.js +2 -0
  196. package/dist/fabrica/protocolos/codex/v2/UserInput.js +2 -0
  197. package/dist/fabrica/rastro.js +487 -0
  198. package/dist/fabrica/sesion.js +230 -0
  199. package/dist/fabrica/tabla-modelos.json +29 -0
  200. package/dist/fabrica/veredictos.js +327 -0
  201. package/package.json +16 -8
  202. package/plugins/huellas.json +6 -6
  203. package/plugins/nexakit-lecciones/.claude-plugin/plugin.json +1 -1
  204. package/plugins/nexakit-lecciones/README.md +6 -5
  205. package/plugins/nexakit-lecciones/hooks/lecciones.js +29 -5
  206. package/plugins/nexakit-lecciones/hooks/register.js +7 -3
  207. package/plugins/nexakit-modelo/.claude-plugin/plugin.json +1 -1
  208. package/plugins/nexakit-modelo/hooks/barra.js +100 -4
  209. package/plugins/nexakit-modelo/hooks/decidir.js +2 -2
  210. package/plugins/nexakit-modelo/hooks/recomendar.js +1 -1
  211. package/plugins/nexakit-modelo/hooks/register.js +122 -7
  212. package/plugins/nexakit-modelo/tests/register.test.ts +301 -0
  213. package/plugins/niveles/.claude-plugin/plugin.json +1 -1
  214. package/plugins/niveles/agents/cazador-de-flakes.md +1 -0
  215. package/plugins/niveles/agents/cierre-de-memoria.md +1 -0
  216. package/plugins/niveles/agents/investigador.md +1 -0
  217. package/plugins/niveles/agents/nivel-alto.md +1 -0
  218. package/plugins/niveles/agents/nivel-exigente.md +1 -0
  219. package/plugins/niveles/agents/nivel-ligero.md +1 -0
  220. package/plugins/niveles/agents/nivel-normal.md +1 -0
  221. package/plugins/niveles/agents/revisor-de-calidad.md +1 -0
  222. package/plugins/niveles/agents/sincronizador-docs.md +1 -0
  223. package/plugins/niveles/agents/subir-al-repo.md +1 -0
  224. package/skills/elegir-modelo/SKILL.md +4 -3
  225. package/skills/elegir-modelo/modelos.mjs +100 -1
  226. package/skills/fabrica/SKILL.md +55 -0
  227. package/skills/gemini/SKILL.md +2 -3
  228. package/skills/quality-gate/SKILL.md +2 -2
  229. package/src/agent-models.js +6 -4
  230. package/src/antigravity-barra.js +64 -12
  231. package/src/antigravity-command.js +4 -2
  232. package/src/antigravity-models.js +61 -0
  233. package/src/antigravity-pre-tool.js +11 -3
  234. package/src/antigravity-recommendation.js +15 -9
  235. package/src/antigravity-setup.js +4 -31
  236. package/src/cli-executable.d.ts +11 -0
  237. package/src/codex-pre-tool.js +3 -3
  238. package/src/codex-recommendation.js +1 -2
  239. package/src/codex-setup.js +3 -20
  240. package/src/codex-team.js +31 -4
  241. package/src/fabrica/banco/casos.ts +315 -0
  242. package/src/fabrica/banco/ejecutar.ts +587 -0
  243. package/src/fabrica/banco/medir.ts +160 -0
  244. package/src/fabrica/cli.ts +781 -0
  245. package/src/fabrica/conectores/antigravity.ts +1090 -0
  246. package/src/fabrica/conectores/codex.ts +1013 -0
  247. package/src/fabrica/conectores/tipos.ts +54 -0
  248. package/src/fabrica/config.ts +43 -0
  249. package/src/fabrica/consolidar.ts +277 -0
  250. package/src/fabrica/decision.ts +285 -0
  251. package/src/fabrica/diff.ts +294 -0
  252. package/src/fabrica/disco.ts +380 -0
  253. package/src/fabrica/ejecutor.ts +716 -0
  254. package/src/fabrica/encargo/candado.ts +287 -0
  255. package/src/fabrica/encargo/ejecutar.ts +953 -0
  256. package/src/fabrica/encargo/evidencia.ts +301 -0
  257. package/src/fabrica/encargo/parche.ts +151 -0
  258. package/src/fabrica/encargo/worktree.ts +427 -0
  259. package/src/fabrica/enrutador.ts +494 -0
  260. package/src/fabrica/errores.ts +15 -0
  261. package/src/fabrica/esquemas.ts +92 -0
  262. package/src/fabrica/estaciones.ts +83 -0
  263. package/src/fabrica/evidencia.ts +445 -0
  264. package/src/fabrica/indice.ts +1 -0
  265. package/src/fabrica/jsonrpc.ts +314 -0
  266. package/src/fabrica/lecciones.ts +411 -0
  267. package/src/fabrica/mcp.ts +450 -0
  268. package/src/fabrica/preferencias.ts +66 -0
  269. package/src/fabrica/protocolos/codex/AbsolutePathBuf.ts +14 -0
  270. package/src/fabrica/protocolos/codex/ApplyPatchApprovalResponse.ts +6 -0
  271. package/src/fabrica/protocolos/codex/ClientInfo.ts +5 -0
  272. package/src/fabrica/protocolos/codex/ExecCommandApprovalParams.ts +16 -0
  273. package/src/fabrica/protocolos/codex/ExecCommandApprovalResponse.ts +6 -0
  274. package/src/fabrica/protocolos/codex/ExecPolicyAmendment.ts +12 -0
  275. package/src/fabrica/protocolos/codex/FunctionCallOutputBody.ts +6 -0
  276. package/src/fabrica/protocolos/codex/FunctionCallOutputContentItem.ts +10 -0
  277. package/src/fabrica/protocolos/codex/ImageDetail.ts +5 -0
  278. package/src/fabrica/protocolos/codex/InitializeCapabilities.ts +42 -0
  279. package/src/fabrica/protocolos/codex/InitializeParams.ts +7 -0
  280. package/src/fabrica/protocolos/codex/InitializeResponse.ts +20 -0
  281. package/src/fabrica/protocolos/codex/InputModality.ts +8 -0
  282. package/src/fabrica/protocolos/codex/LegacyAppPathString.ts +27 -0
  283. package/src/fabrica/protocolos/codex/NetworkPolicyAmendment.ts +6 -0
  284. package/src/fabrica/protocolos/codex/NetworkPolicyRuleAction.ts +5 -0
  285. package/src/fabrica/protocolos/codex/ParsedCommand.ts +12 -0
  286. package/src/fabrica/protocolos/codex/Personality.ts +8 -0
  287. package/src/fabrica/protocolos/codex/ReasoningEffort.ts +8 -0
  288. package/src/fabrica/protocolos/codex/ReasoningSummary.ts +10 -0
  289. package/src/fabrica/protocolos/codex/ReviewDecision.ts +10 -0
  290. package/src/fabrica/protocolos/codex/ThreadId.ts +10 -0
  291. package/src/fabrica/protocolos/codex/VERSION +1 -0
  292. package/src/fabrica/protocolos/codex/serde_json/JsonValue.ts +5 -0
  293. package/src/fabrica/protocolos/codex/v2/AdditionalFileSystemPermissions.ts +15 -0
  294. package/src/fabrica/protocolos/codex/v2/AdditionalNetworkPermissions.ts +5 -0
  295. package/src/fabrica/protocolos/codex/v2/ApprovalsReviewer.ts +12 -0
  296. package/src/fabrica/protocolos/codex/v2/AskForApproval.ts +5 -0
  297. package/src/fabrica/protocolos/codex/v2/ByteRange.ts +5 -0
  298. package/src/fabrica/protocolos/codex/v2/CommandAction.ts +6 -0
  299. package/src/fabrica/protocolos/codex/v2/CommandExecutionApprovalDecision.ts +7 -0
  300. package/src/fabrica/protocolos/codex/v2/CommandExecutionApprovalKind.ts +8 -0
  301. package/src/fabrica/protocolos/codex/v2/CommandExecutionRequestApprovalParams.ts +51 -0
  302. package/src/fabrica/protocolos/codex/v2/CommandExecutionRequestApprovalResponse.ts +6 -0
  303. package/src/fabrica/protocolos/codex/v2/ConfigReadParams.ts +11 -0
  304. package/src/fabrica/protocolos/codex/v2/CyberAccessProgram.ts +9 -0
  305. package/src/fabrica/protocolos/codex/v2/ExecPolicyAmendment.ts +5 -0
  306. package/src/fabrica/protocolos/codex/v2/FileChangeApprovalDecision.ts +5 -0
  307. package/src/fabrica/protocolos/codex/v2/FileChangeRequestApprovalResponse.ts +6 -0
  308. package/src/fabrica/protocolos/codex/v2/FileSystemAccessMode.ts +5 -0
  309. package/src/fabrica/protocolos/codex/v2/FileSystemPath.ts +7 -0
  310. package/src/fabrica/protocolos/codex/v2/FileSystemSandboxEntry.ts +7 -0
  311. package/src/fabrica/protocolos/codex/v2/FileSystemSpecialPath.ts +6 -0
  312. package/src/fabrica/protocolos/codex/v2/GrantedPermissionProfile.ts +7 -0
  313. package/src/fabrica/protocolos/codex/v2/ListMcpServerStatusParams.ts +23 -0
  314. package/src/fabrica/protocolos/codex/v2/McpServerElicitationAction.ts +5 -0
  315. package/src/fabrica/protocolos/codex/v2/McpServerElicitationRequestResponse.ts +17 -0
  316. package/src/fabrica/protocolos/codex/v2/McpServerStatusDetail.ts +5 -0
  317. package/src/fabrica/protocolos/codex/v2/Model.ts +33 -0
  318. package/src/fabrica/protocolos/codex/v2/ModelAccessPrograms.ts +13 -0
  319. package/src/fabrica/protocolos/codex/v2/ModelAvailabilityNux.ts +5 -0
  320. package/src/fabrica/protocolos/codex/v2/ModelListParams.ts +17 -0
  321. package/src/fabrica/protocolos/codex/v2/ModelListResponse.ts +11 -0
  322. package/src/fabrica/protocolos/codex/v2/ModelServiceTier.ts +5 -0
  323. package/src/fabrica/protocolos/codex/v2/ModelUpgradeInfo.ts +9 -0
  324. package/src/fabrica/protocolos/codex/v2/MultiAgentVersion.ts +8 -0
  325. package/src/fabrica/protocolos/codex/v2/NetworkAccess.ts +5 -0
  326. package/src/fabrica/protocolos/codex/v2/NetworkApprovalContext.ts +6 -0
  327. package/src/fabrica/protocolos/codex/v2/NetworkApprovalProtocol.ts +5 -0
  328. package/src/fabrica/protocolos/codex/v2/NetworkPolicyAmendment.ts +6 -0
  329. package/src/fabrica/protocolos/codex/v2/NetworkPolicyRuleAction.ts +5 -0
  330. package/src/fabrica/protocolos/codex/v2/PermissionGrantScope.ts +5 -0
  331. package/src/fabrica/protocolos/codex/v2/PermissionsRequestApprovalResponse.ts +11 -0
  332. package/src/fabrica/protocolos/codex/v2/ReasoningEffortOption.ts +6 -0
  333. package/src/fabrica/protocolos/codex/v2/SandboxMode.ts +5 -0
  334. package/src/fabrica/protocolos/codex/v2/SandboxPolicy.ts +7 -0
  335. package/src/fabrica/protocolos/codex/v2/TextElement.ts +14 -0
  336. package/src/fabrica/protocolos/codex/v2/ThreadSource.ts +5 -0
  337. package/src/fabrica/protocolos/codex/v2/ThreadStartParams.ts +22 -0
  338. package/src/fabrica/protocolos/codex/v2/ThreadStartSource.ts +5 -0
  339. package/src/fabrica/protocolos/codex/v2/ThreadTokenUsage.ts +6 -0
  340. package/src/fabrica/protocolos/codex/v2/ThreadTokenUsageUpdatedNotification.ts +6 -0
  341. package/src/fabrica/protocolos/codex/v2/TokenUsageBreakdown.ts +5 -0
  342. package/src/fabrica/protocolos/codex/v2/ToolRequestUserInputAnswer.ts +8 -0
  343. package/src/fabrica/protocolos/codex/v2/ToolRequestUserInputResponse.ts +9 -0
  344. package/src/fabrica/protocolos/codex/v2/TurnInterruptParams.ts +5 -0
  345. package/src/fabrica/protocolos/codex/v2/TurnStartParams.ts +75 -0
  346. package/src/fabrica/protocolos/codex/v2/TurnToolOutput.ts +10 -0
  347. package/src/fabrica/protocolos/codex/v2/UserInput.ts +11 -0
  348. package/src/fabrica/rastro.ts +508 -0
  349. package/src/fabrica/sesion.ts +280 -0
  350. package/src/fabrica/tabla-modelos.json +29 -0
  351. package/src/fabrica/veredictos.ts +365 -0
  352. package/src/gemini-cli.js +15 -12
  353. package/src/gemini-tools.js +1 -1
  354. package/src/gemini-usage-store.js +32 -0
  355. package/src/instructions-block.js +69 -0
  356. package/src/lecciones-command.js +105 -4
  357. package/src/lecciones-instructions.js +178 -0
  358. package/src/legacy-repair.js +1 -1
  359. package/src/level-agents.js +5 -3
  360. package/src/memory-mcp-policy.js +1 -1
  361. package/src/missing-dependencies.js +5 -0
  362. package/src/model-command.d.ts +29 -0
  363. package/src/model-command.js +4 -27
  364. package/src/regla-ordenes-simples.d.ts +2 -0
  365. package/src/regla-ordenes-simples.js +4 -0
  366. package/src/review-instructions.js +69 -81
  367. package/src/safe-paths.js +38 -0
  368. package/src/setup-apply.js +24 -2
  369. package/src/setup-plan.js +57 -1
  370. package/src/setup-state.js +14 -0
  371. package/src/shell-quote.js +2 -0
  372. package/src/skill-recommendations.js +101 -28
  373. package/src/stable-command.js +2 -2
  374. package/src/stable-install.js +4 -2
  375. package/src/superpowers.js +0 -7
  376. package/src/task-document.js +59 -0
  377. package/src/terminal-text.js +2 -19
  378. package/src/toolkit-cli.js +63 -8
  379. package/src/toolkit-setup.js +192 -37
  380. package/templates/agent-team/README.md +7 -19
  381. package/bin/agent-task.js +0 -14
  382. package/bin/agent-toolkit-inbox.js +0 -14
  383. package/bin/agent-toolkit-mcp.js +0 -17
  384. package/schemas/agent-client-adapter.schema.json +0 -786
  385. package/schemas/agent-client-auth-diagnostic.schema.json +0 -801
  386. package/schemas/agent-client-isolated-variant.schema.json +0 -105
  387. package/schemas/agent-client-isolated-verification.schema.json +0 -99
  388. package/schemas/agent-client-managed-preferences-invocation.schema.json +0 -67
  389. package/schemas/agent-client-managed-preferences.schema.json +0 -63
  390. package/schemas/agent-client-native-diagnostics.schema.json +0 -85
  391. package/schemas/agent-client-native-evaluation.schema.json +0 -171
  392. package/schemas/agent-client-native-preflight.schema.json +0 -90
  393. package/schemas/agent-client-output.schema.json +0 -551
  394. package/schemas/agent-client-runtime-fixture.schema.json +0 -90
  395. package/schemas/agent-client-runtime-local.schema.json +0 -95
  396. package/schemas/agent-client-runtime.schema.json +0 -1288
  397. package/schemas/agent-client-selective-config.schema.json +0 -77
  398. package/schemas/agent-client-supervised-local.schema.json +0 -135
  399. package/schemas/agent-client-supervised.schema.json +0 -186
  400. package/schemas/agent-task-approvals.schema.json +0 -362
  401. package/schemas/agent-task-prepare.schema.json +0 -1324
  402. package/schemas/agent-task-verify.schema.json +0 -198
  403. package/schemas/task-workflow-plan-output.schema.json +0 -35
  404. package/skills/revisar/SKILL.md +0 -51
  405. package/src/claude-code-runner.js +0 -642
  406. package/src/client-adapter-plan.js +0 -271
  407. package/src/client-auth-diagnostic-parser.js +0 -211
  408. package/src/client-auth-diagnostic.js +0 -257
  409. package/src/client-isolated-variant.js +0 -106
  410. package/src/client-isolated-verification.js +0 -130
  411. package/src/client-local-platform.js +0 -14
  412. package/src/client-managed-preferences-invocation.js +0 -209
  413. package/src/client-managed-preferences.js +0 -78
  414. package/src/client-native-access.js +0 -134
  415. package/src/client-native-diagnostics.js +0 -253
  416. package/src/client-native-evaluation.js +0 -106
  417. package/src/client-native-preflight-files.js +0 -68
  418. package/src/client-native-preflight.js +0 -95
  419. package/src/client-output-parser.js +0 -278
  420. package/src/client-runtime-admission.js +0 -80
  421. package/src/client-runtime-coordinator.js +0 -70
  422. package/src/client-runtime-core.js +0 -92
  423. package/src/client-runtime-fixture-permit.js +0 -20
  424. package/src/client-runtime-fixture-protocol.js +0 -39
  425. package/src/client-runtime-state.js +0 -67
  426. package/src/client-runtime-store-files.js +0 -91
  427. package/src/client-runtime-store.js +0 -239
  428. package/src/client-runtime-supervisor.js +0 -146
  429. package/src/client-selective-config.js +0 -195
  430. package/src/client-selective-files.js +0 -126
  431. package/src/client-supervised-codes.js +0 -32
  432. package/src/client-supervised-contract.js +0 -52
  433. package/src/client-supervised-coordinator.js +0 -36
  434. package/src/client-supervised-permit.js +0 -20
  435. package/src/client-supervised-protocol.js +0 -37
  436. package/src/client-supervised-store.js +0 -167
  437. package/src/client-supervised-supervisor.js +0 -167
  438. package/src/client-supervised.js +0 -160
  439. package/src/codex-cli-runner.js +0 -358
  440. package/src/codex-delivery.js +0 -101
  441. package/src/memory-connection-artifacts.js +0 -192
  442. package/src/memory-connection-descriptor.js +0 -158
  443. package/src/memory-connection-diagnostic.js +0 -177
  444. package/src/memory-connection-files.js +0 -191
  445. package/src/memory-connection-manifest.js +0 -118
  446. package/src/memory-connection-package.js +0 -176
  447. package/src/memory-connection-plan.js +0 -217
  448. package/src/memory-connection-skill.js +0 -211
  449. package/src/memory-connection-toml.js +0 -153
  450. package/src/native/managed-preferences.c +0 -100
  451. package/src/native/managed-preferences.h +0 -17
  452. package/src/package-lock-path.js +0 -13
  453. package/src/peer-handoff.js +0 -27
  454. package/src/peer-inbox-cli.js +0 -211
  455. package/src/peer-review-mcp.js +0 -210
  456. package/src/peer-review-store.js +0 -532
  457. package/src/review-policy.js +0 -35
  458. package/src/revision-adapters.js +0 -158
  459. package/src/revision-context.js +0 -86
  460. package/src/revision-isolation.js +0 -222
  461. package/src/revision-process.js +0 -103
  462. package/src/revision-provenance.js +0 -89
  463. package/src/revision-snapshot.js +0 -120
  464. package/src/revision.js +0 -242
  465. package/src/runtime-fixtures/runtime-supervisor/child.cjs +0 -3
  466. package/src/runtime-fixtures/runtime-supervisor/fixture.cjs +0 -49
  467. package/src/runtime-fixtures/supervised/child.cjs +0 -3
  468. package/src/runtime-fixtures/supervised/fixture.cjs +0 -47
  469. package/src/task-approvals.js +0 -367
  470. package/src/task-cli.js +0 -79
  471. package/src/task-external-verifier.js +0 -584
  472. package/src/task-prepare-files.js +0 -115
  473. package/src/task-prepare.js +0 -180
  474. package/src/task-verify-cli.js +0 -67
  475. package/src/task-verify-files.js +0 -188
  476. package/src/task-verify.js +0 -118
  477. package/src/task-workflow-mcp.js +0 -544
  478. package/src/task-workflow-store.js +0 -254
  479. package/src/toolkit-commands-guide.js +0 -115
@@ -1,271 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { types } from "node:util";
3
-
4
- import Ajv2020 from "ajv/dist/2020.js";
5
-
6
- import { createModelSelector } from "./model-selection.js";
7
-
8
- const SCHEMA_ID = "https://agent-toolkit.local/schemas/agent-client-adapter.schema.json";
9
- const ROUTES = {
10
- "codex-cli": ["openai", "codex-native"],
11
- "claude-code": ["anthropic", "claude-native"]
12
- };
13
- const CONTROLS = [
14
- "no-tools", "no-subagents", "no-mcp", "no-hooks",
15
- "no-personalizations", "no-updates", "stdin-text"
16
- ];
17
- const GATES = [
18
- "human-authorization", "client-preflight", "billing-policy",
19
- "preventive-controls", "atomic-history-and-reservation",
20
- "private-context-resolution", "process-cancellation"
21
- ];
22
-
23
- /**
24
- * Supply trusted packaged schemas as JSON. Registry/context/access claims are
25
- * declarations only: this factory and its planner do no IO or authentication.
26
- * A prepared intent is NOT a runnable command or permission to launch a client.
27
- */
28
- export function createClientAdapterPlanner(baseSchema, preferenceSchema, adapterSchema) {
29
- const schemas = [baseSchema, preferenceSchema, adapterSchema].map(copyJson);
30
- if (schemas[2].$id !== SCHEMA_ID) throw new Error("Unsupported adapter schema");
31
- const select = createModelSelector(schemas[0], schemas[1]);
32
- const ajv = new Ajv2020({ strict: true, allErrors: true });
33
- ajv.addFormat("date-time", { type: "string", validate: isUtcTimestamp });
34
- schemas.forEach((schema) => ajv.addSchema(schema));
35
- const validateInput = ajv.compile({ $ref: `${SCHEMA_ID}#/$defs/input` });
36
- const validateReport = ajv.compile({ $ref: `${SCHEMA_ID}#/$defs/report` });
37
- const adapterSchemaSha256 = hashJson(schemas[2]);
38
-
39
- function finish(report, state, reasons = []) {
40
- report.state = state;
41
- report.reasons = [...new Set([...report.reasons, ...reasons])].sort();
42
- report.missing = [...new Set(report.missing)].sort();
43
- if (!validateReport(report)) throw new Error("Adapter planner invariant failed");
44
- return report;
45
- }
46
-
47
- return function planClientAdapter(input) {
48
- const report = {
49
- schemaVersion: "1.0.0", plannerVersion: "1.0.0", state: "invalid",
50
- executed: false, runtimeReady: false, identity: null, intent: null,
51
- observedModels: [], modelVerification: "unknown", observedEffort: null,
52
- effortVerification: "unknown", reasons: [], missing: [], selectorState: null,
53
- externalGates: [...GATES],
54
- audit: { adapterSchemaSha256, inputSha256: null, registrySha256: null, decisionSha256: null }
55
- };
56
- let data;
57
- try { data = copyJson(input); }
58
- catch { return finish(report, "invalid", ["non-json-or-input-limit"]); }
59
- if (!data || typeof data !== "object" || Array.isArray(data)) {
60
- return finish(report, "invalid", ["invalid-envelope"]);
61
- }
62
- if (data.selection && ["request", "catalog", "policy"].some((name) =>
63
- data.selection[name]?.schemaVersion !== "2.0.0")) {
64
- return finish(report, "invalid", ["unsupported-selection-version"]);
65
- }
66
- if (!validateInput(data)) return finish(report, "invalid", ["invalid-structure"]);
67
- report.audit.inputSha256 = hashJson(data);
68
- report.audit.registrySha256 = hashJson(data.registry);
69
- report.audit.decisionSha256 = hashJson(data.decision);
70
-
71
- const selected = select(data.selection);
72
- report.selectorState = selected.state;
73
- report.identity = selected.identity;
74
- // Compare the WHOLE recomputed report, including constraints and audit.
75
- if (canonicalJson(selected.identity) !== canonicalJson(data.decision.identity ?? null)) {
76
- return finish(report, "blocked", ["decision-identity-mismatch"]);
77
- }
78
- if (canonicalJson(selected) !== canonicalJson(data.decision)) {
79
- return finish(report, "invalid", ["decision-mismatch"]);
80
- }
81
- if (selected.state !== "recommended") {
82
- report.missing = selected.missing.map((key) => `selection.${key}`);
83
- return finish(report, selected.state, ["selection-not-recommended", ...selected.reasons]);
84
- }
85
-
86
- const { request, catalog, policy } = data.selection;
87
- const { recommendation } = selected;
88
- const blocks = [];
89
- const block = (code) => blocks.push(code);
90
- const profile = catalog.profiles.find((p) => p.profileId === recommendation.profileId);
91
- if (!["tutor", "proposer", "reviewer"].includes(request.role) ||
92
- request.category === "application" || data.context?.scope === "application") {
93
- block("textual-scope-only");
94
- }
95
- if (request.mode === "tutor" && (request.authorizationContext.activeWriter !== "user" ||
96
- request.authorizationContext.allowedActions.includes("apply"))) {
97
- block("tutor-authorship-conflict");
98
- }
99
- if (profile.versionPolicy !== "pinned" ||
100
- /(?:^|[-.:])(?:latest|default|auto)(?:$|[-.:])/i.test(recommendation.requestedModel)) {
101
- block("model-not-pinned");
102
- }
103
- if (recommendation.effort === null) block("explicit-effort-required");
104
- if (request.requirements.tools.length ||
105
- request.requirements.inputModalities.some((value) => value !== "text") ||
106
- request.requirements.outputFormats.some((value) => !["text", "markdown"].includes(value))) {
107
- block("unsupported-textual-requirements");
108
- }
109
-
110
- const required = [
111
- "adapter", "context.scope", "context.promptRef", "context.provenance",
112
- "context.authorization", "environment.access", "environment.externalBilling",
113
- "environment.controls", "environment.checkedAt", "environment.evidenceRef", "limits", "historyEvidence"
114
- ];
115
- report.missing = required.filter((field) => getField(data, field) === undefined);
116
- if (data.adapter && !sameRoute(data.adapter, recommendation)) block("adapter-route-mismatch");
117
-
118
- // Duplicates are contradictory even if they belong to another route.
119
- const records = data.registry.records;
120
- if (hasDuplicates(records.map((r) => r.recordId)) ||
121
- hasDuplicates(records.map((r) => JSON.stringify([
122
- r.provider, r.client, r.variant, r.clientVersion
123
- ])))) {
124
- return finish(report, "invalid", ["ambiguous-compatibility-registry"]);
125
- }
126
- if (records.some((r) => !sameRoute(r, r))) {
127
- return finish(report, "invalid", ["invalid-registry-route"]);
128
- }
129
- const now = Date.parse(request.evaluationTime);
130
- if (records.some((r) => Date.parse(r.evaluatedAt) > now)) {
131
- return finish(report, "invalid", ["registry-evaluated-in-future"]);
132
- }
133
- let record;
134
- if (data.adapter) {
135
- record = records.find((r) => ["provider", "client", "variant", "clientVersion"]
136
- .every((key) => r[key] === data.adapter[key]));
137
- if (!record) block("client-version-not-admitted");
138
- else {
139
- if (record.status !== "evaluated") block("client-controls-not-evaluated");
140
- if (!record.supportedModels.includes(recommendation.requestedModel)) block("client-model-not-admitted");
141
- if (!record.efforts.includes(recommendation.effort)) block("client-effort-not-admitted");
142
- if (!record.roles.includes(request.role)) block("client-role-not-admitted");
143
- if (CONTROLS.some((control) => !record.controls.includes(control))) block("client-controls-incomplete");
144
- }
145
- }
146
-
147
- const context = data.context;
148
- if (context?.authorization) {
149
- if (context.authorization.status !== "approved") block("authorization-not-declared-approved");
150
- if (context.authorization.referenceId !== request.authorizationContext.referenceId) {
151
- block("authorization-reference-mismatch");
152
- }
153
- if (!fresh(context.authorization.checkedAt, now, policy.availabilityMaxAgeSeconds)) {
154
- block("authorization-evidence-not-current");
155
- }
156
- }
157
- if (context?.provenance && !fresh(context.provenance.checkedAt, now, policy.availabilityMaxAgeSeconds)) {
158
- block("context-evidence-not-current");
159
- }
160
- const environment = data.environment;
161
- if (environment?.access !== undefined && environment.access !== "subscription-session") {
162
- block("subscription-access-not-declared");
163
- }
164
- if (environment?.externalBilling !== undefined && environment.externalBilling !== "disabled") {
165
- block("external-billing-not-declared-disabled");
166
- }
167
- if (environment?.controls && CONTROLS.some((c) => !environment.controls.includes(c))) {
168
- block("preventive-controls-not-declared");
169
- }
170
- if (environment?.checkedAt && !fresh(environment.checkedAt, now, policy.availabilityMaxAgeSeconds)) {
171
- block("environment-evidence-not-current");
172
- }
173
- const remainingTime = policy.maxFutureDurationSeconds - request.history.durationUsedSeconds;
174
- const remainingExecutions = policy.maxFutureExecutions - request.history.executionsUsed;
175
- if (data.historyEvidence) {
176
- if (canonicalJson(data.historyEvidence.history) !== canonicalJson(request.history)) {
177
- return finish(report, "invalid", ["history-evidence-mismatch"]);
178
- }
179
- if (data.historyEvidence.status !== "reconciled") block("history-not-declared-reconciled");
180
- if (!fresh(data.historyEvidence.checkedAt, now, policy.availabilityMaxAgeSeconds)) {
181
- block("history-evidence-not-current");
182
- }
183
- }
184
- if (data.limits) {
185
- if (data.limits.timeoutSeconds > remainingTime) block("timeout-exceeds-remaining-budget");
186
- if (data.limits.maxLineBytes > data.limits.maxOutputBytes) block("line-limit-exceeds-output-limit");
187
- }
188
- if (blocks.length) return finish(report, "blocked", blocks);
189
- if (report.missing.length) return finish(report, "needs-info", ["missing-adapter-information"]);
190
-
191
- report.intent = {
192
- operation: "text-response", client: data.adapter,
193
- profileId: recommendation.profileId, requestedModel: recommendation.requestedModel,
194
- requestedEffort: recommendation.effort,
195
- arguments: [
196
- { name: "model", value: recommendation.requestedModel },
197
- { name: "effort", value: recommendation.effort }
198
- ],
199
- input: { transport: "stdin-text", promptRef: context.promptRef, provenance: context.provenance },
200
- authorizationRef: context.authorization.referenceId, compatibilityRecordId: record.recordId,
201
- scope: "text-only", requiredControls: [...CONTROLS], limits: data.limits,
202
- budget: {
203
- executionsRemaining: remainingExecutions, durationRemainingSeconds: remainingTime,
204
- history: request.history
205
- },
206
- automaticRetry: false, allowProviderSwitch: false, allowImplicitFallback: false
207
- };
208
- return finish(report, "prepared", ["declared-plan-only"]);
209
- };
210
- }
211
-
212
- function sameRoute(adapter, recommendation) {
213
- const expected = ROUTES[adapter.client];
214
- return !!expected && expected[0] === adapter.provider && expected[1] === adapter.variant &&
215
- adapter.provider === recommendation.provider && adapter.client === recommendation.client;
216
- }
217
- function getField(data, field) { return field.split(".").reduce((v, key) => v?.[key], data); }
218
- function hasDuplicates(values) { return new Set(values).size !== values.length; }
219
- function fresh(timestamp, now, maxAge) {
220
- const age = (now - Date.parse(timestamp)) / 1000;
221
- return age >= 0 && age <= maxAge;
222
- }
223
- function isUtcTimestamp(value) {
224
- if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(value)) return false;
225
- const time = Date.parse(value);
226
- return Number.isFinite(time) && new Date(time).toISOString() === value.replace(/Z$/, ".000Z");
227
- }
228
- function hashJson(value) { return createHash("sha256").update(canonicalJson(value)).digest("hex"); }
229
- function canonicalJson(value) {
230
- if (value === null || typeof value !== "object") return JSON.stringify(value);
231
- if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
232
- return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonicalJson(value[key])}`).join(",")}}`;
233
- }
234
-
235
- // This boundary accepts inert, bounded JSON, without invoking accessors/toJSON.
236
- // JavaScript proxies are not JSON and are rejected before inspecting properties.
237
- function copyJson(value) {
238
- const ancestors = new Set();
239
- let nodes = 0;
240
- let bytes = 0;
241
- function text(value) {
242
- bytes += Buffer.byteLength(value, "utf8");
243
- if (bytes > 2_000_000) throw new Error("JSON limit");
244
- }
245
- function visit(item, depth) {
246
- if (++nodes > 30_000 || depth > 64) throw new Error("JSON limit");
247
- if (typeof item === "string") { text(item); return item; }
248
- if (item === null || typeof item === "boolean") return item;
249
- if (typeof item === "number" && Number.isFinite(item)) return item;
250
- if (typeof item !== "object" || types.isProxy(item) || ancestors.has(item)) throw new Error("Non-JSON data");
251
- const array = Array.isArray(item);
252
- if (array && item.length > 256) throw new Error("JSON limit");
253
- if (!array && ![Object.prototype, null].includes(Object.getPrototypeOf(item))) throw new Error("Non-JSON object");
254
- if (Object.getOwnPropertySymbols(item).length) throw new Error("Non-JSON keys");
255
- const keys = Object.getOwnPropertyNames(item).filter((key) => !array || key !== "length");
256
- if (array && (keys.length !== item.length || keys.some((key, i) => key !== String(i)))) throw new Error("Non-JSON array");
257
- if (keys.length > 30_000) throw new Error("JSON limit");
258
- ancestors.add(item);
259
- const result = array ? [] : {};
260
- for (const key of keys) {
261
- if (["__proto__", "prototype", "constructor"].includes(key)) throw new Error("Unsafe JSON key");
262
- const descriptor = Object.getOwnPropertyDescriptor(item, key);
263
- if (!descriptor.enumerable || !("value" in descriptor)) throw new Error("Non-JSON property");
264
- text(key);
265
- result[key] = visit(descriptor.value, depth + 1);
266
- }
267
- ancestors.delete(item);
268
- return result;
269
- }
270
- return visit(value, 0);
271
- }
@@ -1,211 +0,0 @@
1
- import Ajv2020 from "ajv/dist/2020.js";
2
- import { createHash } from "node:crypto";
3
- import { types } from "node:util";
4
- import { copyInertJson, copyBytes } from "./client-output-json.js";
5
-
6
- export const AUTH_DIAGNOSTIC_ID = "https://agent-toolkit.local/schemas/agent-client-auth-diagnostic.schema.json";
7
- const ENUMS = Object.freeze({ authMethod: Object.freeze(["none","claude.ai","oauth_token","api_key","api_key_helper","third_party"]), subscriptionType: Object.freeze(["pro","max","team","enterprise","free"]) });
8
- class ScanFailure extends Error { constructor(code) { super(code); this.code = code; } }
9
- const fail = code => { throw new ScanFailure(code); };
10
- const white = cp => cp === 32 || cp === 9 || cp === 10 || cp === 13;
11
- const digit = cp => cp >= 48 && cp <= 57;
12
- const utf8Width = cp => cp < 128 ? 1 : cp < 2048 ? 2 : cp < 65536 ? 3 : 4;
13
-
14
- /** Incremental byte grammar. Discarded values never become strings/objects. */
15
- export function createAuthDiagnosticParser(schema, limits = { maxBytes: 32768, blockBytes: 32768, maxDepth: 32, maxNodes: 20000, maxKeyBytes: 256, maxKeys: 4096 }) {
16
- const s = copyInertJson(schema), l = copyInertJson(limits);
17
- if (s.$id !== AUTH_DIAGNOSTIC_ID) throw Error("Unsupported auth diagnostic contract");
18
- const ajv = new Ajv2020({ strict: true }); ajv.addSchema(s);
19
- const validLimits = ajv.compile({ $ref: AUTH_DIAGNOSTIC_ID + "#/$defs/parserLimits" });
20
- const validReport = ajv.compile({ $ref: AUTH_DIAGNOSTIC_ID + "#/$defs/parserReport" });
21
- if (!validLimits(l) || l.blockBytes > l.maxBytes) throw Error("Invalid auth diagnostic limits");
22
- const names = ["loggedIn", "authMethod", "subscriptionType"];
23
- const fields = names.map(name => ({ name, present: false, value: null }));
24
- let stack = [], root = "start", token = null, bytes = 0, nodes = 0, keys = 0, peakDepth = 0, peakKeyDigests = 0, digests = 0;
25
- let utfLeft = 0, utfValue = 0, utfMin = 0, error = null, closed = false;
26
-
27
- function item() { if (++nodes > l.maxNodes) fail("auth-node-limit"); }
28
- function completeValue() {
29
- if (!stack.length) { root = "end"; return; }
30
- const f = stack.at(-1); f.items++; f.phase = "comma-or-end"; f.selector = null;
31
- }
32
- function beginValue(cp, tag) {
33
- item();
34
- const type = cp === 123 ? "object" : cp === 91 ? "array" : cp === 34 ? "string" : cp === 116 || cp === 102 ? "boolean" : cp === 110 ? "null" : cp === 45 || digit(cp) ? "number" : null;
35
- if (!type) fail("auth-invalid-json");
36
- if (tag) {
37
- if (tag.name === "loggedIn" ? type !== "boolean" : tag.name === "authMethod" ? type !== "string" : !["string", "null"].includes(type)) fail("auth-invalid-type");
38
- tag.present = true;
39
- }
40
- if (type === "object" || type === "array") {
41
- const f = { type, phase: type === "object" ? "key-or-end" : "value-or-end", items: 0, selector: null, tag, keys: new Set() };
42
- stack.push(f); peakDepth = Math.max(peakDepth, stack.length);
43
- if (stack.length > l.maxDepth) fail("auth-depth-limit");
44
- } else if (type === "string") beginString(false, tag);
45
- else if (type === "number") token = { kind: "number", phase: cp === 45 ? "minus" : cp === 48 ? "zero" : "integer", tag };
46
- else token = { kind: "literal", word: cp === 116 ? "true" : cp === 102 ? "false" : "null", index: 1, tag };
47
- }
48
- function beginString(key, tag) {
49
- token = { kind: "string", key, tag, escape: false, hexLeft: 0, hex: 0, high: null, needSlash: false, needU: false,
50
- count: 0, keyBytes: 0, candidates: key ? (stack.length === 1 ? [...names] : []) : tag ? [...ENUMS[tag.name]] : [], digest: key ? createHash("sha256") : null };
51
- }
52
- function emitStringCodepoint(t, cp) {
53
- if (t.key) {
54
- t.keyBytes += utf8Width(cp); if (t.keyBytes > l.maxKeyBytes) fail("auth-key-bytes-limit");
55
- // Only names are hashed transiently. No hash or textual decoding of values.
56
- t.digest.update(Buffer.from(String.fromCodePoint(cp), "utf8"));
57
- t.candidates = t.candidates.filter(n => t.count < n.length && n.charCodeAt(t.count) === cp);
58
- }
59
- if (!t.key && t.tag) t.candidates = t.candidates.filter(n => t.count < n.length && n.charCodeAt(t.count) === cp);
60
- t.count++; // Unknown values are counted, never concatenated or decoded to text.
61
- }
62
- function endString(t) {
63
- if (t.high !== null) fail("auth-invalid-unicode");
64
- if (t.key) {
65
- const f = stack.at(-1), fingerprint = t.digest.digest("hex");
66
- if (f.keys.has(fingerprint)) fail("auth-duplicate-key");
67
- if (++keys > l.maxKeys) fail("auth-key-limit");
68
- f.keys.add(fingerprint); digests++; peakKeyDigests = Math.max(peakKeyDigests, digests);
69
- const selected = t.candidates.find(n => n.length === t.count);
70
- f.selector = selected ? fields.find(v => v.name === selected) : null; f.phase = "colon";
71
- } else {
72
- if (t.tag) {
73
- const selected = t.candidates.find(n => n.length === t.count);
74
- if (!selected) fail("auth-invalid-enum");
75
- t.tag.value = selected; // A fixed enum label, never an arbitrary input string.
76
- }
77
- completeValue();
78
- }
79
- token = null;
80
- }
81
- function stringChar(cp) {
82
- const t = token;
83
- if (t.needSlash) { if (cp !== 92) fail("auth-invalid-unicode"); t.needSlash = false; t.needU = true; return; }
84
- if (t.needU) { if (cp !== 117) fail("auth-invalid-unicode"); t.needU = false; t.hexLeft = 4; t.hex = 0; return; }
85
- if (t.hexLeft) {
86
- const n = cp >= 48 && cp <= 57 ? cp - 48 : cp >= 65 && cp <= 70 ? cp - 55 : cp >= 97 && cp <= 102 ? cp - 87 : -1;
87
- if (n < 0) fail("auth-invalid-json"); t.hex = t.hex * 16 + n;
88
- if (--t.hexLeft === 0) {
89
- const u = t.hex;
90
- if (t.high !== null) {
91
- if (u < 0xdc00 || u > 0xdfff) fail("auth-invalid-unicode");
92
- const value = 0x10000 + (t.high - 0xd800) * 1024 + u - 0xdc00; t.high = null; emitStringCodepoint(t, value);
93
- } else if (u >= 0xd800 && u <= 0xdbff) { t.high = u; t.needSlash = true; }
94
- else if (u >= 0xdc00 && u <= 0xdfff) fail("auth-invalid-unicode");
95
- else emitStringCodepoint(t, u);
96
- } return;
97
- }
98
- if (t.escape) {
99
- t.escape = false;
100
- if (cp === 117) { t.hexLeft = 4; t.hex = 0; return; }
101
- const escaped = { 34: 34, 92: 92, 47: 47, 98: 8, 102: 12, 110: 10, 114: 13, 116: 9 };
102
- if (!Object.hasOwn(escaped, cp)) fail("auth-invalid-json"); emitStringCodepoint(t, escaped[cp]); return;
103
- }
104
- if (cp === 34) endString(t);
105
- else if (cp === 92) t.escape = true;
106
- else { if (cp < 32) fail("auth-invalid-json"); emitStringCodepoint(t, cp); }
107
- }
108
- function numberChar(cp) {
109
- const t = token, p = t.phase;
110
- if (p === "minus") { if (!digit(cp)) fail("auth-invalid-json"); t.phase = cp === 48 ? "zero" : "integer"; return true; }
111
- if (p === "zero" || p === "integer" || p === "fraction") {
112
- if (digit(cp)) { if (p === "zero") fail("auth-invalid-json"); return true; }
113
- if (cp === 46 && p !== "fraction") { t.phase = "dot"; return true; }
114
- if (cp === 101 || cp === 69) { t.phase = "exponent"; return true; }
115
- return false;
116
- }
117
- if (p === "dot") { if (!digit(cp)) fail("auth-invalid-json"); t.phase = "fraction"; return true; }
118
- if (p === "exponent") { if (cp === 43 || cp === 45) { t.phase = "exponent-sign"; return true; } if (!digit(cp)) fail("auth-invalid-json"); t.phase = "exponent-digits"; return true; }
119
- if (p === "exponent-sign") { if (!digit(cp)) fail("auth-invalid-json"); t.phase = "exponent-digits"; return true; }
120
- if (p === "exponent-digits") return digit(cp);
121
- fail("auth-invalid-json");
122
- }
123
- function closeContainer(cp) {
124
- const f = stack.at(-1);
125
- if (cp !== (f.type === "object" ? 125 : 93)) fail("auth-invalid-json");
126
- digests -= f.keys.size; stack.pop(); completeValue();
127
- }
128
- function grammar(cp) {
129
- if (token) {
130
- if (token.kind === "string") { stringChar(cp); return; }
131
- if (token.kind === "literal") {
132
- const t = token;
133
- if (cp !== t.word.charCodeAt(t.index++)) fail("auth-invalid-json");
134
- if (t.index === t.word.length) {
135
- if (t.tag) t.tag.value = t.word === "null" ? null : t.word === "true";
136
- token = null; completeValue();
137
- } return;
138
- }
139
- if (numberChar(cp)) return;
140
- token = null; completeValue(); // Re-process the number's delimiter below.
141
- }
142
- if (white(cp)) return;
143
- if (root === "end") fail("auth-invalid-json");
144
- if (!stack.length) { if (cp !== 123) fail("auth-root-object-required"); root = "running"; beginValue(cp, null); return; }
145
- const f = stack.at(-1);
146
- if (f.phase === "key-or-end" || f.phase === "key-only") {
147
- if (cp === 125 && f.phase === "key-or-end") { closeContainer(cp); return; }
148
- if (cp !== 34) fail("auth-invalid-json"); item(); beginString(true, null); return;
149
- }
150
- if (f.phase === "colon") { if (cp !== 58) fail("auth-invalid-json"); f.phase = "value"; return; }
151
- if (f.phase === "value-or-end" && cp === 93) { closeContainer(cp); return; }
152
- if (f.phase === "value" || f.phase === "value-or-end" || f.phase === "value-only") { beginValue(cp, f.selector); return; }
153
- if (f.phase === "comma-or-end") {
154
- if (cp === 44) f.phase = f.type === "object" ? "key-only" : "value-only";
155
- else closeContainer(cp);
156
- return;
157
- }
158
- fail("auth-invalid-json");
159
- }
160
- function byte(b) {
161
- if (utfLeft) {
162
- if ((b & 0xc0) !== 0x80) fail("auth-invalid-utf8"); utfValue = utfValue * 64 + (b & 63);
163
- if (--utfLeft === 0) {
164
- if (utfValue < utfMin || utfValue > 0x10ffff || utfValue >= 0xd800 && utfValue <= 0xdfff) fail("auth-invalid-utf8");
165
- grammar(utfValue);
166
- } return;
167
- }
168
- if (b < 128) grammar(b);
169
- else if (b >= 0xc2 && b <= 0xdf) { utfLeft = 1; utfValue = b & 31; utfMin = 128; }
170
- else if (b >= 0xe0 && b <= 0xef) { utfLeft = 2; utfValue = b & 15; utfMin = 2048; }
171
- else if (b >= 0xf0 && b <= 0xf4) { utfLeft = 3; utfValue = b & 7; utfMin = 65536; }
172
- else fail("auth-invalid-utf8");
173
- }
174
- function abandon(e) { error = e instanceof ScanFailure ? e.code : "auth-block-invalid"; stack = []; token = null; digests = 0; }
175
- function report(final = false) {
176
- const ok = final && error === null && root === "end";
177
- const loggedIn = fields[0].value, authMethod = fields[1].value, subscriptionType = fields[2].value;
178
- const classification = !loggedIn ? "signed-out" : ["api_key", "api_key_helper", "oauth_token", "third_party"].includes(authMethod) || subscriptionType === "free" ? "incompatible" :
179
- authMethod === "claude.ai" && ["pro", "max", "team", "enterprise"].includes(subscriptionType) ? "compatible-declared" : "unresolved";
180
- const output = { scope: "auth-diagnostic-provided-bytes", state: ok ? "observed" : error ? "invalid" : "incomplete",
181
- projection: ok ? { loggedIn, authMethod, subscriptionType, classification } : null,
182
- nativeExecuted: false, inferenceRequested: false, runtimeReady: false, verifiedAdmission: false, externalBillingVerified: false,
183
- stats: { bytes, nodes, keys, peakDepth, peakKeyDigests, retainedRawBytes: 0, retainedUnselectedValueTextBytes: 0,
184
- retainedApprovedScalarCount: fields.filter(f => f.present && f.value !== null).length },
185
- reason: ok ? "auth-observed" : error ?? "auth-incomplete" };
186
- if (!validReport(output)) throw Error("Auth parser report invariant failed");
187
- return output;
188
- }
189
- return Object.freeze({
190
- push(input) {
191
- if (closed) { abandon(new ScanFailure("auth-closed")); return report(false); }
192
- if (error) return report(false);
193
- try {
194
- if (types.isProxy(input) || !types.isUint8Array(input)) fail("auth-block-invalid");
195
- const b = copyBytes(input, l.blockBytes); bytes += b.length;
196
- if (bytes > l.maxBytes) fail("auth-byte-limit");
197
- for (let i = 0; i < b.length; i++) byte(b[i]);
198
- } catch (e) { abandon(e); }
199
- return report(false);
200
- },
201
- abort() { if (!closed) abandon(new ScanFailure("auth-aborted")); return report(false); },
202
- finish(exitCode) {
203
- if (closed) { abandon(new ScanFailure("auth-closed")); return report(false); }
204
- closed = true;
205
- if (!error && (utfLeft || token || stack.length || root !== "end")) abandon(new ScanFailure("auth-truncated"));
206
- if (!error && (!fields[0].present || !fields[1].present)) abandon(new ScanFailure("auth-required-field"));
207
- if (!error && exitCode !== (fields[0].value ? 0 : 1)) abandon(new ScanFailure("auth-exit-mismatch"));
208
- return report(true);
209
- }
210
- });
211
- }