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.
- package/README.md +13 -6
- package/assets/runtime/package-lock.json +415 -6
- package/bench/casos/arquitectura/alta-usuarios/base/controladores/usuarios.js +16 -0
- package/bench/casos/arquitectura/alta-usuarios/base/db.js +14 -0
- package/bench/casos/arquitectura/alta-usuarios/base/docs/adr/0003-capas.md +15 -0
- package/bench/casos/arquitectura/alta-usuarios/base/errores.js +3 -0
- package/bench/casos/arquitectura/alta-usuarios/base/repositorios/usuarios.js +14 -0
- package/bench/casos/arquitectura/alta-usuarios/base/servicios/usuarios.js +20 -0
- package/bench/casos/arquitectura/alta-usuarios/cambio/controladores/usuarios.js +47 -0
- package/bench/casos/arquitectura/alta-usuarios/cambio/repositorios/usuarios.js +21 -0
- package/bench/casos/arquitectura/alta-usuarios/cambio/servicios/perfil.js +14 -0
- package/bench/casos/arquitectura/alta-usuarios/esperado.json +53 -0
- package/bench/casos/arquitectura/pedidos-facturacion/base/docs/adr/0001-capas.md +18 -0
- package/bench/casos/arquitectura/pedidos-facturacion/base/src/aplicacion/confirmar.ts +8 -0
- package/bench/casos/arquitectura/pedidos-facturacion/base/src/dominio/pedido.ts +15 -0
- package/bench/casos/arquitectura/pedidos-facturacion/base/src/dominio/puertos.ts +6 -0
- package/bench/casos/arquitectura/pedidos-facturacion/base/src/infra/db.ts +14 -0
- package/bench/casos/arquitectura/pedidos-facturacion/base/src/main.ts +9 -0
- package/bench/casos/arquitectura/pedidos-facturacion/cambio/src/aplicacion/facturar.ts +19 -0
- package/bench/casos/arquitectura/pedidos-facturacion/cambio/src/dominio/informe.ts +7 -0
- package/bench/casos/arquitectura/pedidos-facturacion/cambio/src/dominio/pedido.ts +21 -0
- package/bench/casos/arquitectura/pedidos-facturacion/cambio/src/infra/db.ts +22 -0
- package/bench/casos/arquitectura/pedidos-facturacion/esperado.json +53 -0
- package/bench/casos/arquitectura/resumen-cliente/base/docs/adr/0001-capas.md +18 -0
- package/bench/casos/arquitectura/resumen-cliente/base/src/aplicacion/confirmar.ts +8 -0
- package/bench/casos/arquitectura/resumen-cliente/base/src/dominio/pedido.ts +15 -0
- package/bench/casos/arquitectura/resumen-cliente/base/src/dominio/puertos.ts +6 -0
- package/bench/casos/arquitectura/resumen-cliente/base/src/infra/db.ts +14 -0
- package/bench/casos/arquitectura/resumen-cliente/base/src/main.ts +9 -0
- package/bench/casos/arquitectura/resumen-cliente/cambio/src/aplicacion/resumen.ts +6 -0
- package/bench/casos/arquitectura/resumen-cliente/cambio/src/dominio/pedido.ts +33 -0
- package/bench/casos/arquitectura/resumen-cliente/cambio/src/dominio/puertos.ts +7 -0
- package/bench/casos/arquitectura/resumen-cliente/cambio/src/infra/db.ts +18 -0
- package/bench/casos/arquitectura/resumen-cliente/cambio/src/main.ts +14 -0
- package/bench/casos/arquitectura/resumen-cliente/esperado.json +23 -0
- package/bench/casos/documentacion/comentario-obsoleto/base/README.md +18 -0
- package/bench/casos/documentacion/comentario-obsoleto/base/src/usuarios.ts +35 -0
- package/bench/casos/documentacion/comentario-obsoleto/cambio/src/copia.ts +8 -0
- package/bench/casos/documentacion/comentario-obsoleto/cambio/src/usuarios.ts +43 -0
- package/bench/casos/documentacion/comentario-obsoleto/esperado.json +42 -0
- package/bench/casos/documentacion/reportes-config/base/README.md +23 -0
- package/bench/casos/documentacion/reportes-config/base/src/cli.js +33 -0
- package/bench/casos/documentacion/reportes-config/base/src/config.js +15 -0
- package/bench/casos/documentacion/reportes-config/base/src/envio.js +23 -0
- package/bench/casos/documentacion/reportes-config/cambio/src/cli.js +35 -0
- package/bench/casos/documentacion/reportes-config/cambio/src/config.js +15 -0
- package/bench/casos/documentacion/reportes-config/esperado.json +42 -0
- package/bench/casos/documentacion/tiempo-espera/base/README.md +10 -0
- package/bench/casos/documentacion/tiempo-espera/base/src/config.js +8 -0
- package/bench/casos/documentacion/tiempo-espera/cambio/README.md +10 -0
- package/bench/casos/documentacion/tiempo-espera/cambio/src/config.js +8 -0
- package/bench/casos/documentacion/tiempo-espera/esperado.json +16 -0
- package/bench/casos/pruebas/calendario-laboral/base/src/fechas.js +3 -0
- package/bench/casos/pruebas/calendario-laboral/base/test/fechas.test.js +7 -0
- package/bench/casos/pruebas/calendario-laboral/cambio/src/fechas.js +37 -0
- package/bench/casos/pruebas/calendario-laboral/cambio/test/calendario.test.js +31 -0
- package/bench/casos/pruebas/calendario-laboral/esperado.json +49 -0
- package/bench/casos/pruebas/fin-de-semana/base/src/fechas.js +3 -0
- package/bench/casos/pruebas/fin-de-semana/base/test/fechas.test.js +7 -0
- package/bench/casos/pruebas/fin-de-semana/cambio/src/fechas.js +8 -0
- package/bench/casos/pruebas/fin-de-semana/cambio/test/fines-de-semana.test.js +13 -0
- package/bench/casos/pruebas/fin-de-semana/esperado.json +16 -0
- package/bench/casos/pruebas/precios-carrito/base/src/precio.ts +3 -0
- package/bench/casos/pruebas/precios-carrito/base/test/precio.test.js +11 -0
- package/bench/casos/pruebas/precios-carrito/cambio/src/precio.ts +34 -0
- package/bench/casos/pruebas/precios-carrito/cambio/test/precio.test.js +42 -0
- package/bench/casos/pruebas/precios-carrito/esperado.json +42 -0
- package/bench/casos/rendimiento/boletin-correo/base/src/correo.html +1 -0
- package/bench/casos/rendimiento/boletin-correo/base/src/plantilla.ts +11 -0
- package/bench/casos/rendimiento/boletin-correo/cambio/src/envios.ts +44 -0
- package/bench/casos/rendimiento/boletin-correo/cambio/src/plantilla.ts +10 -0
- package/bench/casos/rendimiento/boletin-correo/esperado.json +42 -0
- package/bench/casos/rendimiento/clientes-por-lote/base/src/informe.js +8 -0
- package/bench/casos/rendimiento/clientes-por-lote/cambio/src/informe.js +6 -0
- package/bench/casos/rendimiento/clientes-por-lote/esperado.json +14 -0
- package/bench/casos/rendimiento/informe-ventas/base/src/informe.js +6 -0
- package/bench/casos/rendimiento/informe-ventas/base/src/tasas.json +1 -0
- package/bench/casos/rendimiento/informe-ventas/cambio/src/informe.js +33 -0
- package/bench/casos/rendimiento/informe-ventas/cambio/src/tasas.js +7 -0
- package/bench/casos/rendimiento/informe-ventas/esperado.json +42 -0
- package/bench/casos/seguridad/inyeccion-orden/base/src/respaldo.ts +13 -0
- package/bench/casos/seguridad/inyeccion-orden/cambio/src/respaldo.ts +69 -0
- package/bench/casos/seguridad/inyeccion-orden/esperado.json +42 -0
- package/bench/casos/seguridad/limpio-validacion/base/servidor.js +11 -0
- package/bench/casos/seguridad/limpio-validacion/cambio/servidor.js +39 -0
- package/bench/casos/seguridad/limpio-validacion/esperado.json +14 -0
- package/bench/casos/seguridad/servidor-archivos/base/servidor.js +21 -0
- package/bench/casos/seguridad/servidor-archivos/cambio/servidor.js +79 -0
- package/bench/casos/seguridad/servidor-archivos/esperado.json +42 -0
- package/bin/nexakit-fabrica-mcp.js +12 -0
- package/dist/fabrica/banco/casos.js +304 -0
- package/dist/fabrica/banco/ejecutar.js +483 -0
- package/dist/fabrica/banco/medir.js +120 -0
- package/dist/fabrica/cli.js +737 -0
- package/dist/fabrica/conectores/antigravity.js +1040 -0
- package/dist/fabrica/conectores/codex.js +967 -0
- package/dist/fabrica/conectores/tipos.js +8 -0
- package/dist/fabrica/config.js +44 -0
- package/dist/fabrica/consolidar.js +218 -0
- package/dist/fabrica/decision.js +210 -0
- package/dist/fabrica/diff.js +247 -0
- package/dist/fabrica/disco.js +356 -0
- package/dist/fabrica/ejecutor.js +597 -0
- package/dist/fabrica/encargo/candado.js +274 -0
- package/dist/fabrica/encargo/ejecutar.js +827 -0
- package/dist/fabrica/encargo/evidencia.js +308 -0
- package/dist/fabrica/encargo/parche.js +146 -0
- package/dist/fabrica/encargo/worktree.js +394 -0
- package/dist/fabrica/enrutador.js +425 -0
- package/dist/fabrica/errores.js +14 -0
- package/dist/fabrica/esquemas.js +57 -0
- package/dist/fabrica/estaciones.js +75 -0
- package/dist/fabrica/evidencia.js +406 -0
- package/dist/fabrica/indice.js +1 -0
- package/dist/fabrica/jsonrpc.js +274 -0
- package/dist/fabrica/lecciones.js +363 -0
- package/dist/fabrica/mcp.js +376 -0
- package/dist/fabrica/preferencias.js +56 -0
- package/dist/fabrica/protocolos/codex/AbsolutePathBuf.js +2 -0
- package/dist/fabrica/protocolos/codex/ApplyPatchApprovalResponse.js +2 -0
- package/dist/fabrica/protocolos/codex/ClientInfo.js +2 -0
- package/dist/fabrica/protocolos/codex/ExecCommandApprovalParams.js +2 -0
- package/dist/fabrica/protocolos/codex/ExecCommandApprovalResponse.js +2 -0
- package/dist/fabrica/protocolos/codex/ExecPolicyAmendment.js +2 -0
- package/dist/fabrica/protocolos/codex/FunctionCallOutputBody.js +2 -0
- package/dist/fabrica/protocolos/codex/FunctionCallOutputContentItem.js +2 -0
- package/dist/fabrica/protocolos/codex/ImageDetail.js +2 -0
- package/dist/fabrica/protocolos/codex/InitializeCapabilities.js +2 -0
- package/dist/fabrica/protocolos/codex/InitializeParams.js +2 -0
- package/dist/fabrica/protocolos/codex/InitializeResponse.js +2 -0
- package/dist/fabrica/protocolos/codex/InputModality.js +2 -0
- package/dist/fabrica/protocolos/codex/LegacyAppPathString.js +2 -0
- package/dist/fabrica/protocolos/codex/NetworkPolicyAmendment.js +2 -0
- package/dist/fabrica/protocolos/codex/NetworkPolicyRuleAction.js +2 -0
- package/dist/fabrica/protocolos/codex/ParsedCommand.js +2 -0
- package/dist/fabrica/protocolos/codex/Personality.js +2 -0
- package/dist/fabrica/protocolos/codex/ReasoningEffort.js +2 -0
- package/dist/fabrica/protocolos/codex/ReasoningSummary.js +2 -0
- package/dist/fabrica/protocolos/codex/ReviewDecision.js +2 -0
- package/dist/fabrica/protocolos/codex/ThreadId.js +2 -0
- package/dist/fabrica/protocolos/codex/serde_json/JsonValue.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/AdditionalFileSystemPermissions.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/AdditionalNetworkPermissions.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/ApprovalsReviewer.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/AskForApproval.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/ByteRange.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/CommandAction.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/CommandExecutionApprovalDecision.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/CommandExecutionApprovalKind.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/CommandExecutionRequestApprovalParams.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/CommandExecutionRequestApprovalResponse.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/ConfigReadParams.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/CyberAccessProgram.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/ExecPolicyAmendment.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/FileChangeApprovalDecision.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/FileChangeRequestApprovalResponse.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/FileSystemAccessMode.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/FileSystemPath.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/FileSystemSandboxEntry.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/FileSystemSpecialPath.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/GrantedPermissionProfile.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/ListMcpServerStatusParams.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/McpServerElicitationAction.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/McpServerElicitationRequestResponse.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/McpServerStatusDetail.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/Model.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/ModelAccessPrograms.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/ModelAvailabilityNux.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/ModelListParams.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/ModelListResponse.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/ModelServiceTier.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/ModelUpgradeInfo.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/MultiAgentVersion.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/NetworkAccess.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/NetworkApprovalContext.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/NetworkApprovalProtocol.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/NetworkPolicyAmendment.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/NetworkPolicyRuleAction.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/PermissionGrantScope.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/PermissionsRequestApprovalResponse.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/ReasoningEffortOption.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/SandboxMode.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/SandboxPolicy.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/TextElement.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/ThreadSource.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/ThreadStartParams.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/ThreadStartSource.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/ThreadTokenUsage.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/ThreadTokenUsageUpdatedNotification.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/TokenUsageBreakdown.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/ToolRequestUserInputAnswer.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/ToolRequestUserInputResponse.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/TurnInterruptParams.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/TurnStartParams.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/TurnToolOutput.js +2 -0
- package/dist/fabrica/protocolos/codex/v2/UserInput.js +2 -0
- package/dist/fabrica/rastro.js +487 -0
- package/dist/fabrica/sesion.js +230 -0
- package/dist/fabrica/tabla-modelos.json +29 -0
- package/dist/fabrica/veredictos.js +327 -0
- package/package.json +16 -8
- package/plugins/huellas.json +6 -6
- package/plugins/nexakit-lecciones/.claude-plugin/plugin.json +1 -1
- package/plugins/nexakit-lecciones/README.md +6 -5
- package/plugins/nexakit-lecciones/hooks/lecciones.js +29 -5
- package/plugins/nexakit-lecciones/hooks/register.js +7 -3
- package/plugins/nexakit-modelo/.claude-plugin/plugin.json +1 -1
- package/plugins/nexakit-modelo/hooks/barra.js +100 -4
- package/plugins/nexakit-modelo/hooks/decidir.js +2 -2
- package/plugins/nexakit-modelo/hooks/recomendar.js +1 -1
- package/plugins/nexakit-modelo/hooks/register.js +122 -7
- package/plugins/nexakit-modelo/tests/register.test.ts +301 -0
- package/plugins/niveles/.claude-plugin/plugin.json +1 -1
- package/plugins/niveles/agents/cazador-de-flakes.md +1 -0
- package/plugins/niveles/agents/cierre-de-memoria.md +1 -0
- package/plugins/niveles/agents/investigador.md +1 -0
- package/plugins/niveles/agents/nivel-alto.md +1 -0
- package/plugins/niveles/agents/nivel-exigente.md +1 -0
- package/plugins/niveles/agents/nivel-ligero.md +1 -0
- package/plugins/niveles/agents/nivel-normal.md +1 -0
- package/plugins/niveles/agents/revisor-de-calidad.md +1 -0
- package/plugins/niveles/agents/sincronizador-docs.md +1 -0
- package/plugins/niveles/agents/subir-al-repo.md +1 -0
- package/skills/elegir-modelo/SKILL.md +4 -3
- package/skills/elegir-modelo/modelos.mjs +100 -1
- package/skills/fabrica/SKILL.md +55 -0
- package/skills/gemini/SKILL.md +2 -3
- package/skills/quality-gate/SKILL.md +2 -2
- package/src/agent-models.js +6 -4
- package/src/antigravity-barra.js +64 -12
- package/src/antigravity-command.js +4 -2
- package/src/antigravity-models.js +61 -0
- package/src/antigravity-pre-tool.js +11 -3
- package/src/antigravity-recommendation.js +15 -9
- package/src/antigravity-setup.js +4 -31
- package/src/cli-executable.d.ts +11 -0
- package/src/codex-pre-tool.js +3 -3
- package/src/codex-recommendation.js +1 -2
- package/src/codex-setup.js +3 -20
- package/src/codex-team.js +31 -4
- package/src/fabrica/banco/casos.ts +315 -0
- package/src/fabrica/banco/ejecutar.ts +587 -0
- package/src/fabrica/banco/medir.ts +160 -0
- package/src/fabrica/cli.ts +781 -0
- package/src/fabrica/conectores/antigravity.ts +1090 -0
- package/src/fabrica/conectores/codex.ts +1013 -0
- package/src/fabrica/conectores/tipos.ts +54 -0
- package/src/fabrica/config.ts +43 -0
- package/src/fabrica/consolidar.ts +277 -0
- package/src/fabrica/decision.ts +285 -0
- package/src/fabrica/diff.ts +294 -0
- package/src/fabrica/disco.ts +380 -0
- package/src/fabrica/ejecutor.ts +716 -0
- package/src/fabrica/encargo/candado.ts +287 -0
- package/src/fabrica/encargo/ejecutar.ts +953 -0
- package/src/fabrica/encargo/evidencia.ts +301 -0
- package/src/fabrica/encargo/parche.ts +151 -0
- package/src/fabrica/encargo/worktree.ts +427 -0
- package/src/fabrica/enrutador.ts +494 -0
- package/src/fabrica/errores.ts +15 -0
- package/src/fabrica/esquemas.ts +92 -0
- package/src/fabrica/estaciones.ts +83 -0
- package/src/fabrica/evidencia.ts +445 -0
- package/src/fabrica/indice.ts +1 -0
- package/src/fabrica/jsonrpc.ts +314 -0
- package/src/fabrica/lecciones.ts +411 -0
- package/src/fabrica/mcp.ts +450 -0
- package/src/fabrica/preferencias.ts +66 -0
- package/src/fabrica/protocolos/codex/AbsolutePathBuf.ts +14 -0
- package/src/fabrica/protocolos/codex/ApplyPatchApprovalResponse.ts +6 -0
- package/src/fabrica/protocolos/codex/ClientInfo.ts +5 -0
- package/src/fabrica/protocolos/codex/ExecCommandApprovalParams.ts +16 -0
- package/src/fabrica/protocolos/codex/ExecCommandApprovalResponse.ts +6 -0
- package/src/fabrica/protocolos/codex/ExecPolicyAmendment.ts +12 -0
- package/src/fabrica/protocolos/codex/FunctionCallOutputBody.ts +6 -0
- package/src/fabrica/protocolos/codex/FunctionCallOutputContentItem.ts +10 -0
- package/src/fabrica/protocolos/codex/ImageDetail.ts +5 -0
- package/src/fabrica/protocolos/codex/InitializeCapabilities.ts +42 -0
- package/src/fabrica/protocolos/codex/InitializeParams.ts +7 -0
- package/src/fabrica/protocolos/codex/InitializeResponse.ts +20 -0
- package/src/fabrica/protocolos/codex/InputModality.ts +8 -0
- package/src/fabrica/protocolos/codex/LegacyAppPathString.ts +27 -0
- package/src/fabrica/protocolos/codex/NetworkPolicyAmendment.ts +6 -0
- package/src/fabrica/protocolos/codex/NetworkPolicyRuleAction.ts +5 -0
- package/src/fabrica/protocolos/codex/ParsedCommand.ts +12 -0
- package/src/fabrica/protocolos/codex/Personality.ts +8 -0
- package/src/fabrica/protocolos/codex/ReasoningEffort.ts +8 -0
- package/src/fabrica/protocolos/codex/ReasoningSummary.ts +10 -0
- package/src/fabrica/protocolos/codex/ReviewDecision.ts +10 -0
- package/src/fabrica/protocolos/codex/ThreadId.ts +10 -0
- package/src/fabrica/protocolos/codex/VERSION +1 -0
- package/src/fabrica/protocolos/codex/serde_json/JsonValue.ts +5 -0
- package/src/fabrica/protocolos/codex/v2/AdditionalFileSystemPermissions.ts +15 -0
- package/src/fabrica/protocolos/codex/v2/AdditionalNetworkPermissions.ts +5 -0
- package/src/fabrica/protocolos/codex/v2/ApprovalsReviewer.ts +12 -0
- package/src/fabrica/protocolos/codex/v2/AskForApproval.ts +5 -0
- package/src/fabrica/protocolos/codex/v2/ByteRange.ts +5 -0
- package/src/fabrica/protocolos/codex/v2/CommandAction.ts +6 -0
- package/src/fabrica/protocolos/codex/v2/CommandExecutionApprovalDecision.ts +7 -0
- package/src/fabrica/protocolos/codex/v2/CommandExecutionApprovalKind.ts +8 -0
- package/src/fabrica/protocolos/codex/v2/CommandExecutionRequestApprovalParams.ts +51 -0
- package/src/fabrica/protocolos/codex/v2/CommandExecutionRequestApprovalResponse.ts +6 -0
- package/src/fabrica/protocolos/codex/v2/ConfigReadParams.ts +11 -0
- package/src/fabrica/protocolos/codex/v2/CyberAccessProgram.ts +9 -0
- package/src/fabrica/protocolos/codex/v2/ExecPolicyAmendment.ts +5 -0
- package/src/fabrica/protocolos/codex/v2/FileChangeApprovalDecision.ts +5 -0
- package/src/fabrica/protocolos/codex/v2/FileChangeRequestApprovalResponse.ts +6 -0
- package/src/fabrica/protocolos/codex/v2/FileSystemAccessMode.ts +5 -0
- package/src/fabrica/protocolos/codex/v2/FileSystemPath.ts +7 -0
- package/src/fabrica/protocolos/codex/v2/FileSystemSandboxEntry.ts +7 -0
- package/src/fabrica/protocolos/codex/v2/FileSystemSpecialPath.ts +6 -0
- package/src/fabrica/protocolos/codex/v2/GrantedPermissionProfile.ts +7 -0
- package/src/fabrica/protocolos/codex/v2/ListMcpServerStatusParams.ts +23 -0
- package/src/fabrica/protocolos/codex/v2/McpServerElicitationAction.ts +5 -0
- package/src/fabrica/protocolos/codex/v2/McpServerElicitationRequestResponse.ts +17 -0
- package/src/fabrica/protocolos/codex/v2/McpServerStatusDetail.ts +5 -0
- package/src/fabrica/protocolos/codex/v2/Model.ts +33 -0
- package/src/fabrica/protocolos/codex/v2/ModelAccessPrograms.ts +13 -0
- package/src/fabrica/protocolos/codex/v2/ModelAvailabilityNux.ts +5 -0
- package/src/fabrica/protocolos/codex/v2/ModelListParams.ts +17 -0
- package/src/fabrica/protocolos/codex/v2/ModelListResponse.ts +11 -0
- package/src/fabrica/protocolos/codex/v2/ModelServiceTier.ts +5 -0
- package/src/fabrica/protocolos/codex/v2/ModelUpgradeInfo.ts +9 -0
- package/src/fabrica/protocolos/codex/v2/MultiAgentVersion.ts +8 -0
- package/src/fabrica/protocolos/codex/v2/NetworkAccess.ts +5 -0
- package/src/fabrica/protocolos/codex/v2/NetworkApprovalContext.ts +6 -0
- package/src/fabrica/protocolos/codex/v2/NetworkApprovalProtocol.ts +5 -0
- package/src/fabrica/protocolos/codex/v2/NetworkPolicyAmendment.ts +6 -0
- package/src/fabrica/protocolos/codex/v2/NetworkPolicyRuleAction.ts +5 -0
- package/src/fabrica/protocolos/codex/v2/PermissionGrantScope.ts +5 -0
- package/src/fabrica/protocolos/codex/v2/PermissionsRequestApprovalResponse.ts +11 -0
- package/src/fabrica/protocolos/codex/v2/ReasoningEffortOption.ts +6 -0
- package/src/fabrica/protocolos/codex/v2/SandboxMode.ts +5 -0
- package/src/fabrica/protocolos/codex/v2/SandboxPolicy.ts +7 -0
- package/src/fabrica/protocolos/codex/v2/TextElement.ts +14 -0
- package/src/fabrica/protocolos/codex/v2/ThreadSource.ts +5 -0
- package/src/fabrica/protocolos/codex/v2/ThreadStartParams.ts +22 -0
- package/src/fabrica/protocolos/codex/v2/ThreadStartSource.ts +5 -0
- package/src/fabrica/protocolos/codex/v2/ThreadTokenUsage.ts +6 -0
- package/src/fabrica/protocolos/codex/v2/ThreadTokenUsageUpdatedNotification.ts +6 -0
- package/src/fabrica/protocolos/codex/v2/TokenUsageBreakdown.ts +5 -0
- package/src/fabrica/protocolos/codex/v2/ToolRequestUserInputAnswer.ts +8 -0
- package/src/fabrica/protocolos/codex/v2/ToolRequestUserInputResponse.ts +9 -0
- package/src/fabrica/protocolos/codex/v2/TurnInterruptParams.ts +5 -0
- package/src/fabrica/protocolos/codex/v2/TurnStartParams.ts +75 -0
- package/src/fabrica/protocolos/codex/v2/TurnToolOutput.ts +10 -0
- package/src/fabrica/protocolos/codex/v2/UserInput.ts +11 -0
- package/src/fabrica/rastro.ts +508 -0
- package/src/fabrica/sesion.ts +280 -0
- package/src/fabrica/tabla-modelos.json +29 -0
- package/src/fabrica/veredictos.ts +365 -0
- package/src/gemini-cli.js +15 -12
- package/src/gemini-tools.js +1 -1
- package/src/gemini-usage-store.js +32 -0
- package/src/instructions-block.js +69 -0
- package/src/lecciones-command.js +105 -4
- package/src/lecciones-instructions.js +178 -0
- package/src/legacy-repair.js +1 -1
- package/src/level-agents.js +5 -3
- package/src/memory-mcp-policy.js +1 -1
- package/src/missing-dependencies.js +5 -0
- package/src/model-command.d.ts +29 -0
- package/src/model-command.js +4 -27
- package/src/regla-ordenes-simples.d.ts +2 -0
- package/src/regla-ordenes-simples.js +4 -0
- package/src/review-instructions.js +69 -81
- package/src/safe-paths.js +38 -0
- package/src/setup-apply.js +24 -2
- package/src/setup-plan.js +57 -1
- package/src/setup-state.js +14 -0
- package/src/shell-quote.js +2 -0
- package/src/skill-recommendations.js +101 -28
- package/src/stable-command.js +2 -2
- package/src/stable-install.js +4 -2
- package/src/superpowers.js +0 -7
- package/src/task-document.js +59 -0
- package/src/terminal-text.js +2 -19
- package/src/toolkit-cli.js +63 -8
- package/src/toolkit-setup.js +192 -37
- package/templates/agent-team/README.md +7 -19
- package/bin/agent-task.js +0 -14
- package/bin/agent-toolkit-inbox.js +0 -14
- package/bin/agent-toolkit-mcp.js +0 -17
- package/schemas/agent-client-adapter.schema.json +0 -786
- package/schemas/agent-client-auth-diagnostic.schema.json +0 -801
- package/schemas/agent-client-isolated-variant.schema.json +0 -105
- package/schemas/agent-client-isolated-verification.schema.json +0 -99
- package/schemas/agent-client-managed-preferences-invocation.schema.json +0 -67
- package/schemas/agent-client-managed-preferences.schema.json +0 -63
- package/schemas/agent-client-native-diagnostics.schema.json +0 -85
- package/schemas/agent-client-native-evaluation.schema.json +0 -171
- package/schemas/agent-client-native-preflight.schema.json +0 -90
- package/schemas/agent-client-output.schema.json +0 -551
- package/schemas/agent-client-runtime-fixture.schema.json +0 -90
- package/schemas/agent-client-runtime-local.schema.json +0 -95
- package/schemas/agent-client-runtime.schema.json +0 -1288
- package/schemas/agent-client-selective-config.schema.json +0 -77
- package/schemas/agent-client-supervised-local.schema.json +0 -135
- package/schemas/agent-client-supervised.schema.json +0 -186
- package/schemas/agent-task-approvals.schema.json +0 -362
- package/schemas/agent-task-prepare.schema.json +0 -1324
- package/schemas/agent-task-verify.schema.json +0 -198
- package/schemas/task-workflow-plan-output.schema.json +0 -35
- package/skills/revisar/SKILL.md +0 -51
- package/src/claude-code-runner.js +0 -642
- package/src/client-adapter-plan.js +0 -271
- package/src/client-auth-diagnostic-parser.js +0 -211
- package/src/client-auth-diagnostic.js +0 -257
- package/src/client-isolated-variant.js +0 -106
- package/src/client-isolated-verification.js +0 -130
- package/src/client-local-platform.js +0 -14
- package/src/client-managed-preferences-invocation.js +0 -209
- package/src/client-managed-preferences.js +0 -78
- package/src/client-native-access.js +0 -134
- package/src/client-native-diagnostics.js +0 -253
- package/src/client-native-evaluation.js +0 -106
- package/src/client-native-preflight-files.js +0 -68
- package/src/client-native-preflight.js +0 -95
- package/src/client-output-parser.js +0 -278
- package/src/client-runtime-admission.js +0 -80
- package/src/client-runtime-coordinator.js +0 -70
- package/src/client-runtime-core.js +0 -92
- package/src/client-runtime-fixture-permit.js +0 -20
- package/src/client-runtime-fixture-protocol.js +0 -39
- package/src/client-runtime-state.js +0 -67
- package/src/client-runtime-store-files.js +0 -91
- package/src/client-runtime-store.js +0 -239
- package/src/client-runtime-supervisor.js +0 -146
- package/src/client-selective-config.js +0 -195
- package/src/client-selective-files.js +0 -126
- package/src/client-supervised-codes.js +0 -32
- package/src/client-supervised-contract.js +0 -52
- package/src/client-supervised-coordinator.js +0 -36
- package/src/client-supervised-permit.js +0 -20
- package/src/client-supervised-protocol.js +0 -37
- package/src/client-supervised-store.js +0 -167
- package/src/client-supervised-supervisor.js +0 -167
- package/src/client-supervised.js +0 -160
- package/src/codex-cli-runner.js +0 -358
- package/src/codex-delivery.js +0 -101
- package/src/memory-connection-artifacts.js +0 -192
- package/src/memory-connection-descriptor.js +0 -158
- package/src/memory-connection-diagnostic.js +0 -177
- package/src/memory-connection-files.js +0 -191
- package/src/memory-connection-manifest.js +0 -118
- package/src/memory-connection-package.js +0 -176
- package/src/memory-connection-plan.js +0 -217
- package/src/memory-connection-skill.js +0 -211
- package/src/memory-connection-toml.js +0 -153
- package/src/native/managed-preferences.c +0 -100
- package/src/native/managed-preferences.h +0 -17
- package/src/package-lock-path.js +0 -13
- package/src/peer-handoff.js +0 -27
- package/src/peer-inbox-cli.js +0 -211
- package/src/peer-review-mcp.js +0 -210
- package/src/peer-review-store.js +0 -532
- package/src/review-policy.js +0 -35
- package/src/revision-adapters.js +0 -158
- package/src/revision-context.js +0 -86
- package/src/revision-isolation.js +0 -222
- package/src/revision-process.js +0 -103
- package/src/revision-provenance.js +0 -89
- package/src/revision-snapshot.js +0 -120
- package/src/revision.js +0 -242
- package/src/runtime-fixtures/runtime-supervisor/child.cjs +0 -3
- package/src/runtime-fixtures/runtime-supervisor/fixture.cjs +0 -49
- package/src/runtime-fixtures/supervised/child.cjs +0 -3
- package/src/runtime-fixtures/supervised/fixture.cjs +0 -47
- package/src/task-approvals.js +0 -367
- package/src/task-cli.js +0 -79
- package/src/task-external-verifier.js +0 -584
- package/src/task-prepare-files.js +0 -115
- package/src/task-prepare.js +0 -180
- package/src/task-verify-cli.js +0 -67
- package/src/task-verify-files.js +0 -188
- package/src/task-verify.js +0 -118
- package/src/task-workflow-mcp.js +0 -544
- package/src/task-workflow-store.js +0 -254
- package/src/toolkit-commands-guide.js +0 -115
package/src/task-approvals.js
DELETED
|
@@ -1,367 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import Ajv2020 from "ajv/dist/2020.js";
|
|
3
|
-
import { copyBytes, copyInertJson, decode, fail, parseEventJson, ParseFailure } from "./client-output-json.js";
|
|
4
|
-
|
|
5
|
-
export const APPROVALS_ID = "https://agent-toolkit.local/schemas/agent-task-approvals.schema.json";
|
|
6
|
-
export const LIMITS = Object.freeze({ maxBytes: 1_000_000, maxEvents: 256 });
|
|
7
|
-
const OPEN = ["reserved", "started", "indeterminate"];
|
|
8
|
-
const BAD_PATH = /[\p{Cc}\p{Cf}\p{Zl}\p{Zp}\\*?[\]{}]/u;
|
|
9
|
-
|
|
10
|
-
// Declared data only: nothing here proves who approved, what ran or what time it is.
|
|
11
|
-
class Refusal extends Error {
|
|
12
|
-
constructor(state, code) { super(code); this.state = state; this.code = code; }
|
|
13
|
-
}
|
|
14
|
-
const block = code => { throw new Refusal("blocked", code); };
|
|
15
|
-
|
|
16
|
-
function canonical(v) {
|
|
17
|
-
if (v === null || typeof v !== "object") return JSON.stringify(v);
|
|
18
|
-
if (Array.isArray(v)) return `[${v.map(canonical).join(",")}]`;
|
|
19
|
-
return `{${Object.keys(v).sort().map(k => `${JSON.stringify(k)}:${canonical(v[k])}`).join(",")}}`;
|
|
20
|
-
}
|
|
21
|
-
// Internal: input is already inert JSON (validated or copied), so no further checks.
|
|
22
|
-
const digest = v => createHash("sha256").update(canonical(v)).digest("hex");
|
|
23
|
-
/**
|
|
24
|
-
* Canonical SHA-256 of JSON data. It identifies content; it does not authenticate anyone.
|
|
25
|
-
* Only bounded inert JSON is accepted: getters, proxies, cycles, functions (toJSON) and
|
|
26
|
-
* non-plain objects are rejected by copyInertJson without invoking any callback.
|
|
27
|
-
*/
|
|
28
|
-
export function approvalHash(value) { return digest(copyInertJson(value)); }
|
|
29
|
-
const same = (a, b) => canonical(a) === canonical(b);
|
|
30
|
-
function freeze(v) {
|
|
31
|
-
if (v && typeof v === "object") { Object.values(v).forEach(freeze); Object.freeze(v); }
|
|
32
|
-
return v;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function validTime(v) {
|
|
36
|
-
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(v)) return false;
|
|
37
|
-
const t = Date.parse(v);
|
|
38
|
-
return Number.isFinite(t) && new Date(t).toISOString() === v.replace(/Z$/, ".000Z");
|
|
39
|
-
}
|
|
40
|
-
function validPath(p) {
|
|
41
|
-
if (typeof p !== "string" || p.length === 0 || p.length > 256 || p !== p.normalize("NFC") || BAD_PATH.test(p)) return false;
|
|
42
|
-
if (/^[A-Za-z]:/.test(p)) return false;
|
|
43
|
-
return p.split("/").every(s => s !== "" && s !== "." && s !== "..");
|
|
44
|
-
}
|
|
45
|
-
// Logical comparison only. Symlinks and physical aliases are out of scope for this core.
|
|
46
|
-
function pathFacts(items) {
|
|
47
|
-
const pairs = new Set(); const folded = new Map();
|
|
48
|
-
for (const { path, action } of items) {
|
|
49
|
-
if (!validPath(path)) fail("invalid-approval-path");
|
|
50
|
-
const pair = JSON.stringify([path, action]);
|
|
51
|
-
if (pairs.has(pair)) fail("duplicate-approval-path");
|
|
52
|
-
pairs.add(pair);
|
|
53
|
-
const key = path.normalize("NFKC").toLowerCase();
|
|
54
|
-
if (folded.has(key) && folded.get(key) !== path) fail("path-collision");
|
|
55
|
-
folded.set(key, path);
|
|
56
|
-
}
|
|
57
|
-
const keys = [...folded.keys()];
|
|
58
|
-
if (keys.some(k => keys.some(o => o.startsWith(`${k}/`)))) fail("path-file-directory-conflict");
|
|
59
|
-
}
|
|
60
|
-
// Effects must match what the actions and checks imply, in both directions. Never auto-added.
|
|
61
|
-
function effectFacts(items, checks, effects) {
|
|
62
|
-
if (items.some(i => i.action !== "read") !== effects.includes("workspace-write")) fail("effect-path-mismatch");
|
|
63
|
-
if ((checks.length > 0) !== effects.includes("test-execution")) fail("effect-check-mismatch");
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const itemKey = i => JSON.stringify([i.path, i.action]);
|
|
67
|
-
// Identity of the work, not of its bookkeeping: ids, array order and the base do not matter,
|
|
68
|
-
// the concrete artifact does. A reviewed correction therefore is new work, not a repeat.
|
|
69
|
-
const workKey = (items, checks, effects, artifactSha256) =>
|
|
70
|
-
canonical([items.map(itemKey).sort(), [...checks].sort(), [...effects].sort(), artifactSha256]);
|
|
71
|
-
const within = (items, allowed, key = x => x) => {
|
|
72
|
-
const set = new Set(allowed.map(key));
|
|
73
|
-
return items.every(i => set.has(key(i)));
|
|
74
|
-
};
|
|
75
|
-
const live = r => r.ops.filter(o => o.state !== "released-declared");
|
|
76
|
-
const remaining = r => ({
|
|
77
|
-
operations: Math.max(0, r.scope.limits.maxOperations - live(r).length),
|
|
78
|
-
corrections: Math.max(0, r.scope.limits.maxCorrections - r.corrections),
|
|
79
|
-
retries: Math.max(0, r.scope.limits.maxRetries - r.retries)
|
|
80
|
-
});
|
|
81
|
-
// A new request may follow only requests that consumed nothing. Renewals after consumption,
|
|
82
|
-
// overlapping requests and other recipients need an accounting context RA-A does not have.
|
|
83
|
-
const pristine = r => r.status === "denied"
|
|
84
|
-
|| ((r.status === "revoked" || r.status === "closed") && r.ops.length === 0 && r.corrections === 0);
|
|
85
|
-
|
|
86
|
-
function requestFacts(e, history) {
|
|
87
|
-
const { scope } = e;
|
|
88
|
-
if (scope.projectId !== history.projectId || scope.taskId !== history.taskId) fail("foreign-request-identity");
|
|
89
|
-
if (digest(scope) !== e.scopeSha256) fail("scope-hash-mismatch");
|
|
90
|
-
if (!validTime(scope.validFrom) || !validTime(scope.expiresAt) || Date.parse(scope.validFrom) >= Date.parse(scope.expiresAt)) fail("invalid-validity");
|
|
91
|
-
if (scope.limits.maxRetries >= scope.limits.maxOperations) fail("invalid-limits");
|
|
92
|
-
pathFacts(scope.paths);
|
|
93
|
-
effectFacts(scope.paths, scope.checks, scope.effects);
|
|
94
|
-
const seen = new Set();
|
|
95
|
-
for (const t of e.baseBinding.transitions) {
|
|
96
|
-
const key = `${t.fromSha256}>${t.toSha256}`;
|
|
97
|
-
if (t.fromSha256 === t.toSha256 || seen.has(key)) fail("invalid-base-transition");
|
|
98
|
-
seen.add(key);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function newRequest(e) {
|
|
103
|
-
return {
|
|
104
|
-
requestId: e.requestId, scope: e.scope, scopeSha256: e.scopeSha256, requestSha256: digest(e), status: "pending",
|
|
105
|
-
artifact: e.artifact, revisions: new Set([e.artifact.revision]), shas: new Set([e.artifact.sha256]),
|
|
106
|
-
corrections: 0, retries: 0, base: e.baseBinding.initialSha256, transitions: e.baseBinding.transitions,
|
|
107
|
-
divergedBase: null, ops: []
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Shared by reserve events and prospective coverage. Returns null or [state, reason].
|
|
112
|
-
function admission(r, s, now) {
|
|
113
|
-
if (r.status === "pending") return ["approval-needed", "decision-pending"];
|
|
114
|
-
if (r.status !== "approved") return ["blocked", r.status];
|
|
115
|
-
if (!within(s.items, r.scope.paths, itemKey) || !within(s.checks, r.scope.checks) || !within(s.effects, r.scope.effects)) return ["approval-needed", "outside-scope"];
|
|
116
|
-
if (r.divergedBase !== null) return ["blocked", "unexpected-base-change"];
|
|
117
|
-
if (s.base !== r.base) return ["blocked", "base-diverged"];
|
|
118
|
-
if (s.revision !== r.artifact.revision || (s.sha !== null && s.sha !== r.artifact.sha256)) return ["blocked", "artifact-mismatch"];
|
|
119
|
-
if (r.ops.some(o => o.state === "indeterminate")) return ["reconciliation-required", "reconciliation-required"];
|
|
120
|
-
if (r.ops.some(o => OPEN.includes(o.state))) return ["blocked", "operation-in-progress"];
|
|
121
|
-
if (now < Date.parse(r.scope.validFrom)) return ["blocked", "not-yet-valid"];
|
|
122
|
-
if (now >= Date.parse(r.scope.expiresAt)) return ["approval-needed", "expired"];
|
|
123
|
-
if (live(r).length >= r.scope.limits.maxOperations) return ["approval-needed", "budget-exhausted"];
|
|
124
|
-
const key = workKey(s.items, s.checks, s.effects, r.artifact.sha256);
|
|
125
|
-
const twins = live(r).filter(o => o.key === key);
|
|
126
|
-
if (twins.some(o => o.state === "succeeded")) return ["blocked", "operation-already-finished"];
|
|
127
|
-
if (s.retryOf === null) return twins.length ? ["blocked", "undeclared-retry"] : null;
|
|
128
|
-
const origin = r.ops.find(o => o.operationId === s.retryOf);
|
|
129
|
-
if (!origin || origin.state !== "failed" || origin.key !== key) return ["blocked", "invalid-retry"];
|
|
130
|
-
if (r.retries >= r.scope.limits.maxRetries) return ["approval-needed", "retry-not-allowed"];
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// Per-file queries inside an already reserved operation: read-only, they never consume a use.
|
|
135
|
-
function inFlight(r, q, now) {
|
|
136
|
-
if (r.status !== "approved") return ["blocked", r.status];
|
|
137
|
-
const o = r.ops.find(x => x.operationId === q.operationId);
|
|
138
|
-
if (!o) return ["blocked", "unknown-operation"];
|
|
139
|
-
if (o.state === "indeterminate") return ["reconciliation-required", "reconciliation-required"];
|
|
140
|
-
if (o.state !== "reserved" && o.state !== "started") return ["blocked", "operation-finished"];
|
|
141
|
-
if (now >= Date.parse(r.scope.expiresAt)) return ["blocked", "expired-in-flight"];
|
|
142
|
-
if (!within(q.items, o.items, itemKey) || !within(q.checks, o.checks) || !within(q.effects, o.effects)) return ["blocked", "outside-operation"];
|
|
143
|
-
if (q.observedBaseSha256 !== o.expectedBase) return ["blocked", "base-diverged"];
|
|
144
|
-
if (q.artifact.revision !== o.artifactRevision || q.artifact.sha256 !== o.artifactSha256) return ["blocked", "artifact-mismatch"];
|
|
145
|
-
return null;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// An unexpected base is recorded, not hidden: the approval stays, new coverage is blocked.
|
|
149
|
-
function settle(r, o, outcome, resulting) {
|
|
150
|
-
if (outcome === "succeeded" && resulting === null) fail("missing-result-base");
|
|
151
|
-
o.state = outcome;
|
|
152
|
-
if (resulting === null || resulting === o.expectedBase) return;
|
|
153
|
-
if (r.transitions.some(t => t.fromSha256 === o.expectedBase && t.toSha256 === resulting)) r.base = resulting;
|
|
154
|
-
else r.divergedBase = resulting;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function operationEvent(r, e, at, claim) {
|
|
158
|
-
const o = r.ops.find(x => x.operationId === e.operationId);
|
|
159
|
-
if (!o) block("unknown-operation");
|
|
160
|
-
if (e.type === "start") {
|
|
161
|
-
if (o.state !== "reserved") block("invalid-operation-transition");
|
|
162
|
-
if (r.status !== "approved") block(r.status);
|
|
163
|
-
if (at >= Date.parse(r.scope.expiresAt)) block("expired");
|
|
164
|
-
o.state = "started"; o.sawStart = true; o.lastEventId = e.eventId;
|
|
165
|
-
} else if (e.type === "interrupt") {
|
|
166
|
-
if (o.state !== "reserved" && o.state !== "started") block("invalid-operation-transition");
|
|
167
|
-
o.state = "indeterminate"; o.lastEventId = e.eventId;
|
|
168
|
-
} else if (e.type === "result") {
|
|
169
|
-
if (o.state !== "started") block("invalid-operation-transition");
|
|
170
|
-
settle(r, o, e.outcome, e.resultingBaseSha256);
|
|
171
|
-
} else {
|
|
172
|
-
// Reconciliation is declared data. Missing start/result or a timeout has no evidence shape
|
|
173
|
-
// here, so it can only leave the operation indeterminate; it never releases a use.
|
|
174
|
-
const ev = e.evidence;
|
|
175
|
-
if (!OPEN.includes(o.state)) block("invalid-operation-transition");
|
|
176
|
-
if (ev.reservationEventId !== o.reserveEventId || ev.priorEventId !== o.lastEventId || ev.previousState !== o.state) block("reconcile-evidence-mismatch");
|
|
177
|
-
claim(ev.decisionRef);
|
|
178
|
-
if (e.resolution === "not-started-confirmed") {
|
|
179
|
-
if (ev.observation !== "non-start-confirmed" || o.sawStart) block("reconcile-contradiction");
|
|
180
|
-
if (ev.inspectedBaseSha256 !== o.expectedBase) block("non-start-base-mismatch");
|
|
181
|
-
if (e.resultingBaseSha256 !== null) fail("unexpected-result-base");
|
|
182
|
-
o.state = "released-declared";
|
|
183
|
-
} else {
|
|
184
|
-
if (ev.observation !== "termination-observed") block("reconcile-contradiction");
|
|
185
|
-
settle(r, o, e.resolution === "finished-succeeded" ? "succeeded" : "failed", e.resultingBaseSha256);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function reduceHistory(history, checkpoint) {
|
|
191
|
-
const { events } = history;
|
|
192
|
-
if (events.length !== checkpoint.revision || digest(history) !== checkpoint.historySha256) block("checkpoint-divergent");
|
|
193
|
-
const seen = new Map(); const responses = new Set(); const operations = new Set(); const requests = new Map();
|
|
194
|
-
let clock = -Infinity; let duplicates = 0;
|
|
195
|
-
const claim = ref => { if (responses.has(ref)) block("response-ref-reused"); responses.add(ref); };
|
|
196
|
-
for (const e of events) {
|
|
197
|
-
if (!validTime(e.at)) fail("invalid-event-time");
|
|
198
|
-
const previous = seen.get(e.eventId);
|
|
199
|
-
if (previous) {
|
|
200
|
-
if (!same(previous, e)) block("event-id-conflict");
|
|
201
|
-
duplicates++; continue;
|
|
202
|
-
}
|
|
203
|
-
seen.set(e.eventId, e);
|
|
204
|
-
const at = Date.parse(e.at);
|
|
205
|
-
if (at < clock) block("clock-regression");
|
|
206
|
-
clock = at;
|
|
207
|
-
if (e.type === "request") {
|
|
208
|
-
if (requests.has(e.requestId)) block("request-id-conflict");
|
|
209
|
-
if (![...requests.values()].every(pristine)) block("accounting-context-required");
|
|
210
|
-
requestFacts(e, history); requests.set(e.requestId, newRequest(e));
|
|
211
|
-
continue;
|
|
212
|
-
}
|
|
213
|
-
const r = requests.get(e.requestId);
|
|
214
|
-
if (!r) block("unknown-request");
|
|
215
|
-
switch (e.type) {
|
|
216
|
-
case "decision":
|
|
217
|
-
claim(e.responseRef);
|
|
218
|
-
if (r.status !== "pending") block("decision-conflict");
|
|
219
|
-
if (e.requestSha256 !== r.requestSha256) block("decision-request-mismatch");
|
|
220
|
-
r.status = e.decision === "approve" ? "approved" : "denied";
|
|
221
|
-
break;
|
|
222
|
-
case "revoke":
|
|
223
|
-
claim(e.responseRef);
|
|
224
|
-
if (r.status !== "pending" && r.status !== "approved") block("terminal-conflict");
|
|
225
|
-
r.status = "revoked";
|
|
226
|
-
break;
|
|
227
|
-
case "close":
|
|
228
|
-
if (r.status !== "pending" && r.status !== "approved") block("terminal-conflict");
|
|
229
|
-
r.status = "closed";
|
|
230
|
-
break;
|
|
231
|
-
case "correction":
|
|
232
|
-
if (r.status !== "approved") block("correction-not-allowed");
|
|
233
|
-
if (e.scopeSha256 !== r.scopeSha256) block("scope-change-requires-new-request");
|
|
234
|
-
if (r.corrections >= r.scope.limits.maxCorrections) block("correction-limit");
|
|
235
|
-
if (e.previousRevision !== r.artifact.revision) block("correction-chain-conflict");
|
|
236
|
-
if (r.revisions.has(e.artifact.revision)) block("revision-reused");
|
|
237
|
-
if (r.shas.has(e.artifact.sha256)) block("artifact-reused");
|
|
238
|
-
if (r.ops.some(o => OPEN.includes(o.state))) block("operation-in-progress");
|
|
239
|
-
r.artifact = e.artifact; r.revisions.add(e.artifact.revision); r.shas.add(e.artifact.sha256); r.corrections++;
|
|
240
|
-
break;
|
|
241
|
-
case "reserve": {
|
|
242
|
-
pathFacts(e.items); effectFacts(e.items, e.checks, e.effects);
|
|
243
|
-
if (operations.has(e.operationId)) block("operation-id-conflict");
|
|
244
|
-
const refusal = admission(r, {
|
|
245
|
-
items: e.items, checks: e.checks, effects: e.effects, base: e.expectedBaseSha256,
|
|
246
|
-
revision: e.artifactRevision, sha: null, retryOf: e.retryOf
|
|
247
|
-
}, at);
|
|
248
|
-
if (refusal) block(refusal[1]);
|
|
249
|
-
operations.add(e.operationId);
|
|
250
|
-
if (e.retryOf !== null) r.retries++;
|
|
251
|
-
r.ops.push({
|
|
252
|
-
operationId: e.operationId, state: "reserved", reserveEventId: e.eventId, lastEventId: e.eventId,
|
|
253
|
-
items: e.items, checks: e.checks, effects: e.effects, key: workKey(e.items, e.checks, e.effects, r.artifact.sha256),
|
|
254
|
-
expectedBase: e.expectedBaseSha256, artifactRevision: r.artifact.revision, artifactSha256: r.artifact.sha256,
|
|
255
|
-
retryOf: e.retryOf, sawStart: false
|
|
256
|
-
});
|
|
257
|
-
break;
|
|
258
|
-
}
|
|
259
|
-
default:
|
|
260
|
-
operationEvent(r, e, at, claim);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
return { requests, clock, duplicates };
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function summarize(reduced, history) {
|
|
267
|
-
const { requests, clock, duplicates } = reduced;
|
|
268
|
-
return {
|
|
269
|
-
revision: history.events.length, historySha256: digest(history), duplicatesIgnored: duplicates,
|
|
270
|
-
lastEventAt: Number.isFinite(clock) ? new Date(clock).toISOString().replace(".000Z", "Z") : null,
|
|
271
|
-
requests: [...requests.values()].map(r => ({
|
|
272
|
-
requestId: r.requestId, status: r.status, scopeSha256: r.scopeSha256, requestSha256: r.requestSha256,
|
|
273
|
-
artifact: { ...r.artifact }, baseSha256: r.base, divergedBaseSha256: r.divergedBase,
|
|
274
|
-
corrections: r.corrections, retries: r.retries, usedOperations: live(r).length, remaining: remaining(r),
|
|
275
|
-
operations: r.ops.map(o => ({ operationId: o.operationId, state: o.state, reserveEventId: o.reserveEventId, retryOf: o.retryOf }))
|
|
276
|
-
}))
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/** Strict text/bytes entry point: bounded size, valid UTF-8, no duplicate or unsafe keys. */
|
|
281
|
-
export function parseApprovalInput(value) {
|
|
282
|
-
return copyInertJson(parseEventJson(decode(copyBytes(value, LIMITS.maxBytes))));
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Pure calculators over explicit inputs. No IO, clock, processes, store or runtime.
|
|
287
|
-
* Every report keeps authorityVerified/executionAuthorized/persisted/nativeExecuted false.
|
|
288
|
-
*/
|
|
289
|
-
export function createTaskApprovals(schema) {
|
|
290
|
-
const root = copyInertJson(schema);
|
|
291
|
-
if (root.$id !== APPROVALS_ID) throw Error("Unsupported approvals schema");
|
|
292
|
-
const ajv = new Ajv2020({ strict: true, allErrors: false });
|
|
293
|
-
ajv.addSchema(root);
|
|
294
|
-
const check = Object.fromEntries(["replayInput", "proposeInput", "coverInput", "report"]
|
|
295
|
-
.map(name => [name, ajv.compile({ $ref: `${APPROVALS_ID}#/$defs/${name}` })]));
|
|
296
|
-
|
|
297
|
-
function run(operation, input, body) {
|
|
298
|
-
const r = {
|
|
299
|
-
schemaVersion: "1.0.0", engineVersion: "1.0.0", operation, state: "invalid", reasons: [],
|
|
300
|
-
authorityVerified: false, executionAuthorized: false, persisted: false, nativeExecuted: false,
|
|
301
|
-
requestId: null, revision: null, historySha256: null, view: null, remaining: null, proposal: null
|
|
302
|
-
};
|
|
303
|
-
try {
|
|
304
|
-
const d = copyInertJson(input);
|
|
305
|
-
if (!check[`${operation}Input`](d)) fail("invalid-approval-input");
|
|
306
|
-
body(d, r);
|
|
307
|
-
} catch (error) {
|
|
308
|
-
if (!(error instanceof Refusal || error instanceof ParseFailure)) throw error;
|
|
309
|
-
r.state = error instanceof Refusal ? error.state : "invalid"; r.reasons = [error.code];
|
|
310
|
-
r.view = null; r.remaining = null; r.proposal = null;
|
|
311
|
-
}
|
|
312
|
-
if (!check.report(r)) throw Error("Approval report invariant failed");
|
|
313
|
-
return freeze(r);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
return {
|
|
317
|
-
replay: input => run("replay", input, (d, r) => {
|
|
318
|
-
const reduced = reduceHistory(d.history, d.checkpoint);
|
|
319
|
-
r.state = "reduced"; r.reasons = ["history-replayed"];
|
|
320
|
-
r.revision = d.history.events.length; r.historySha256 = d.checkpoint.historySha256;
|
|
321
|
-
r.view = summarize(reduced, d.history);
|
|
322
|
-
}),
|
|
323
|
-
|
|
324
|
-
propose: input => run("propose", input, (d, r) => {
|
|
325
|
-
reduceHistory(d.history, d.checkpoint);
|
|
326
|
-
r.revision = d.history.events.length; r.historySha256 = d.checkpoint.historySha256; r.requestId = d.event.requestId;
|
|
327
|
-
const known = d.history.events.find(e => e.eventId === d.event.eventId);
|
|
328
|
-
if (known) {
|
|
329
|
-
if (!same(known, d.event)) block("event-id-conflict");
|
|
330
|
-
r.state = "noop"; r.reasons = ["event-already-recorded"];
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
if (d.history.events.length >= LIMITS.maxEvents) block("event-limit");
|
|
334
|
-
const history = { ...d.history, events: [...d.history.events, d.event] };
|
|
335
|
-
const next = { revision: history.events.length, historySha256: digest(history) };
|
|
336
|
-
reduceHistory(history, next); // the reducer is the single source of validity
|
|
337
|
-
r.state = "proposed"; r.reasons = ["event-proposed"];
|
|
338
|
-
r.proposal = { event: d.event, nextRevision: next.revision, nextHistorySha256: next.historySha256 };
|
|
339
|
-
}),
|
|
340
|
-
|
|
341
|
-
cover: input => run("cover", input, (d, r) => {
|
|
342
|
-
const reduced = reduceHistory(d.history, d.checkpoint);
|
|
343
|
-
const q = d.query;
|
|
344
|
-
r.revision = d.history.events.length; r.historySha256 = d.checkpoint.historySha256; r.requestId = q.requestId;
|
|
345
|
-
if (!validTime(d.now)) fail("invalid-now");
|
|
346
|
-
const now = Date.parse(d.now);
|
|
347
|
-
if (now < reduced.clock) block("clock-regression");
|
|
348
|
-
pathFacts(q.items); effectFacts(q.items, q.checks, q.effects);
|
|
349
|
-
const request = reduced.requests.get(q.requestId);
|
|
350
|
-
let verdict;
|
|
351
|
-
if (!request) verdict = ["approval-needed", "request-missing"];
|
|
352
|
-
else {
|
|
353
|
-
r.remaining = remaining(request);
|
|
354
|
-
if (!same(q.recipient, request.scope.recipient)) verdict = ["approval-needed", "recipient-not-covered"];
|
|
355
|
-
else if (q.operationId !== null) verdict = inFlight(request, q, now);
|
|
356
|
-
else {
|
|
357
|
-
verdict = admission(request, {
|
|
358
|
-
items: q.items, checks: q.checks, effects: q.effects, base: q.observedBaseSha256,
|
|
359
|
-
revision: q.artifact.revision, sha: q.artifact.sha256, retryOf: q.retryOf
|
|
360
|
-
}, now);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
r.state = verdict ? verdict[0] : "declared-covered";
|
|
364
|
-
r.reasons = [verdict ? verdict[1] : "declared-data-match"];
|
|
365
|
-
})
|
|
366
|
-
};
|
|
367
|
-
}
|
package/src/task-cli.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { createTaskPreparer, TASK_LIMITS } from "./task-prepare.js";
|
|
4
|
-
import { readTaskInputs, parseTaskDocument, TaskInputError } from "./task-prepare-files.js";
|
|
5
|
-
import { runVerifyCli } from "./task-verify-cli.js";
|
|
6
|
-
import { runExternalVerifierCli } from "./task-external-verifier.js";
|
|
7
|
-
|
|
8
|
-
const HELP = `agent-task — borradores manuales y verificación local
|
|
9
|
-
|
|
10
|
-
Uso local:
|
|
11
|
-
node bin/agent-task.js prepare --task <archivo> --request <archivo> --catalog <archivo> --policy <archivo> [--json | --show-brief]
|
|
12
|
-
node bin/agent-task.js verify --contract <json> --expect <sha256> --source <raíz> --handoff <raíz> --phase <before|after> [--json]
|
|
13
|
-
node bin/agent-task.js external-verifier --help
|
|
14
|
-
node bin/agent-task.js external-verifier preview --task <json> --request <json> --catalog <json> --policy <json> --source <raíz> --handoff <raíz-0700> --delivery <ruta>
|
|
15
|
-
node bin/agent-task.js --help
|
|
16
|
-
|
|
17
|
-
Sin flags de salida: resumen sin cuerpo del encargo ni rutas privadas.
|
|
18
|
-
--json: ese mismo resumen estructurado.
|
|
19
|
-
--show-brief: muestra el borrador privado completo en el terminal; no lo guarda ni envía.
|
|
20
|
-
prepare solo interpreta documentos locales; no usa IA ni consulta cuentas.
|
|
21
|
-
Preparar no autoriza, verifica la base ni cambia el modelo del cliente.
|
|
22
|
-
No comprueba actualidad frente al reloj; acceso/disponibilidad son datos declarados.
|
|
23
|
-
El usuario revisa el borrador y elige manualmente el modelo antes de entregarlo.
|
|
24
|
-
Exit: 0 borrador/ayuda; 1 faltan datos/bloqueo; 2 entrada/lectura/salida inválida.
|
|
25
|
-
verify compara huellas de archivos listados; «verify --help» detalla estados y salida. matched no aprueba nada.
|
|
26
|
-
Modo sin ejecución de IA por omisión: external-verifier preview no llama al modelo y run exige confirmación aparte.
|
|
27
|
-
`;
|
|
28
|
-
const NAMES = ["task", "request", "catalog", "policy"];
|
|
29
|
-
const schemaPaths = ["agent-task-prepare", "agent-model-selection", "agent-model-preference"].map(n => fileURLToPath(new URL(`../schemas/${n}.schema.json`, import.meta.url)));
|
|
30
|
-
function options(argv) {
|
|
31
|
-
if (!Array.isArray(argv) || argv.some(v => typeof v !== "string")) throw Error();
|
|
32
|
-
if (!argv.length || argv.length === 1 && ["--help", "-h"].includes(argv[0]) || argv.length === 2 && argv[0] === "prepare" && ["--help", "-h"].includes(argv[1])) return { help: true };
|
|
33
|
-
if (argv[0] !== "prepare") throw Error();
|
|
34
|
-
const values = {}, flags = new Set();
|
|
35
|
-
for (let i = 1; i < argv.length; i++) {
|
|
36
|
-
const a = argv[i];
|
|
37
|
-
if (["--json", "--show-brief"].includes(a)) { if (flags.has(a)) throw Error(); flags.add(a); continue; }
|
|
38
|
-
const key = a.startsWith("--") ? a.slice(2) : "";
|
|
39
|
-
if (!NAMES.includes(key) || Object.hasOwn(values, key) || !argv[i + 1] || argv[i + 1].startsWith("-")) throw Error();
|
|
40
|
-
values[key] = argv[++i];
|
|
41
|
-
}
|
|
42
|
-
if (Object.keys(values).length !== 4 || flags.size > 1) throw Error();
|
|
43
|
-
return { values, json: flags.has("--json"), show: flags.has("--show-brief") };
|
|
44
|
-
}
|
|
45
|
-
function outputSummary(s, json) {
|
|
46
|
-
if (json) return JSON.stringify(s, null, 2) + "\n";
|
|
47
|
-
return `agent-task prepare: ${s.state}\n` + (s.identity?.purpose === "external-verifier" ? "Propósito: verificador externo (solo lectura declarada).\n" : "") + (s.recommended ?
|
|
48
|
-
`Modelo solicitado: ${s.recommended.requestedModel}; esfuerzo: ${s.recommended.effort ?? "null (sin ajuste explícito)"}\n` : "Sin recomendación utilizable.\n") +
|
|
49
|
-
`Motivos: ${s.reasons.join(", ")}\n` + (s.missing.length ? `Datos pendientes: ${s.missing.join(", ")}\n` : "") +
|
|
50
|
-
"No ejecutado, enviado ni escrito. Permiso, base y modelo real no verificados.\n" +
|
|
51
|
-
"Disponibilidad declarada; actualidad frente al reloj no verificada.\n";
|
|
52
|
-
}
|
|
53
|
-
/** IO callbacks/dependencies are trusted hosts, not fields in input JSON. */
|
|
54
|
-
export async function runTaskCli(argv, io, dependencies = {}) {
|
|
55
|
-
if (Array.isArray(argv) && argv[0] === "verify") return runVerifyCli(argv.slice(1), io, dependencies);
|
|
56
|
-
if (Array.isArray(argv) && argv[0] === "external-verifier") return runExternalVerifierCli(argv.slice(1), io, dependencies);
|
|
57
|
-
let opts;
|
|
58
|
-
const fail = async code => { try { await io.err(`agent-task: ${code}\n`); } catch {} return 2; };
|
|
59
|
-
try { opts = options(argv); } catch { return fail("task-invalid-option"); }
|
|
60
|
-
if (opts.help) {
|
|
61
|
-
try { await io.out(HELP); return 0; } catch { return fail("task-output-failed"); }
|
|
62
|
-
}
|
|
63
|
-
let core, report;
|
|
64
|
-
try {
|
|
65
|
-
const readSchema = dependencies.readPackagedSchema ?? (p => fs.readFile(p));
|
|
66
|
-
const schemas = []; for (const p of schemaPaths) schemas.push(parseTaskDocument(await readSchema(p)));
|
|
67
|
-
core = createTaskPreparer(...schemas);
|
|
68
|
-
const { data, byteHashes } = await readTaskInputs(opts.values, dependencies.cwd ?? process.cwd(), { io: dependencies.fileIo });
|
|
69
|
-
report = core.prepareTask(data); report.audit.sourceByteHashes = byteHashes;
|
|
70
|
-
} catch (e) { return fail(e instanceof TaskInputError ? e.code : "task-preparation-failed"); }
|
|
71
|
-
try {
|
|
72
|
-
const summary = core.summarize(report);
|
|
73
|
-
const output = opts.show && report.state === "prepared-draft" ? report.brief : outputSummary(summary, opts.json);
|
|
74
|
-
const cap = opts.show && report.state === "prepared-draft" ? TASK_LIMITS.briefBytes : TASK_LIMITS.summaryBytes;
|
|
75
|
-
if (Buffer.byteLength(output) > cap) throw Error();
|
|
76
|
-
await io.out(output);
|
|
77
|
-
return report.state === "prepared-draft" ? 0 : report.state === "invalid" ? 2 : 1;
|
|
78
|
-
} catch { return fail("task-output-failed"); }
|
|
79
|
-
}
|