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
|
@@ -1,195 +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
|
-
import { hash } from "./client-runtime-core.js";
|
|
6
|
-
|
|
7
|
-
export const SELECTIVE_ID = "https://agent-toolkit.local/schemas/agent-client-selective-config.schema.json";
|
|
8
|
-
export const SELECTORS = Object.freeze({ "personal-settings": Object.freeze(["hooks", "apiKeyHelper", "disableAllHooks"]), "global-state": Object.freeze(["mcpServers"]) });
|
|
9
|
-
class ScanFailure extends Error { constructor(code) { super(code); this.code = code; } }
|
|
10
|
-
const fail = code => { throw new ScanFailure(code); };
|
|
11
|
-
const white = cp => cp === 32 || cp === 9 || cp === 10 || cp === 13;
|
|
12
|
-
const digit = cp => cp >= 48 && cp <= 57;
|
|
13
|
-
const utf8Width = cp => cp < 128 ? 1 : cp < 2048 ? 2 : cp < 65536 ? 3 : 4;
|
|
14
|
-
|
|
15
|
-
/** Incremental byte grammar. Discarded values never become strings/objects. */
|
|
16
|
-
export function createSelectiveConfigParser(schema, sourceId, limits) {
|
|
17
|
-
const s = copyInertJson(schema), l = copyInertJson(limits);
|
|
18
|
-
if (s.$id !== SELECTIVE_ID || typeof sourceId !== "string" || !Object.hasOwn(SELECTORS, sourceId)) throw Error("Unsupported selective contract");
|
|
19
|
-
const ajv = new Ajv2020({ strict: true }); ajv.addSchema(s);
|
|
20
|
-
const validLimits = ajv.compile({ $ref: SELECTIVE_ID + "#/$defs/limits" });
|
|
21
|
-
const validReport = ajv.compile({ $ref: SELECTIVE_ID + "#/$defs/report" });
|
|
22
|
-
if (!validLimits(l) || l.blockBytes > l.maxBytes) throw Error("Invalid selective limits");
|
|
23
|
-
const names = SELECTORS[sourceId];
|
|
24
|
-
const fields = names.map(name => ({ name, present: false, type: null, empty: null, booleanValue: null }));
|
|
25
|
-
let stack = [], root = "start", token = null, bytes = 0, nodes = 0, keys = 0, peakDepth = 0, peakKeyDigests = 0, digests = 0;
|
|
26
|
-
let utfLeft = 0, utfValue = 0, utfMin = 0, error = null, closed = false;
|
|
27
|
-
|
|
28
|
-
function item() { if (++nodes > l.maxNodes) fail("selective-node-limit"); }
|
|
29
|
-
function completeValue() {
|
|
30
|
-
if (!stack.length) { root = "end"; return; }
|
|
31
|
-
const f = stack.at(-1); f.items++; f.phase = "comma-or-end"; f.selector = null;
|
|
32
|
-
}
|
|
33
|
-
function beginValue(cp, tag) {
|
|
34
|
-
item();
|
|
35
|
-
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;
|
|
36
|
-
if (!type) fail("selective-invalid-json");
|
|
37
|
-
if (tag) { tag.present = true; tag.type = type; }
|
|
38
|
-
if (type === "object" || type === "array") {
|
|
39
|
-
const f = { type, phase: type === "object" ? "key-or-end" : "value-or-end", items: 0, selector: null, tag, keys: new Set() };
|
|
40
|
-
stack.push(f); peakDepth = Math.max(peakDepth, stack.length);
|
|
41
|
-
if (stack.length > l.maxDepth) fail("selective-depth-limit");
|
|
42
|
-
} else if (type === "string") beginString(false, tag);
|
|
43
|
-
else if (type === "number") token = { kind: "number", phase: cp === 45 ? "minus" : cp === 48 ? "zero" : "integer", tag };
|
|
44
|
-
else token = { kind: "literal", word: cp === 116 ? "true" : cp === 102 ? "false" : "null", index: 1, tag };
|
|
45
|
-
}
|
|
46
|
-
function beginString(key, tag) {
|
|
47
|
-
token = { kind: "string", key, tag, escape: false, hexLeft: 0, hex: 0, high: null, needSlash: false, needU: false,
|
|
48
|
-
count: 0, keyBytes: 0, candidates: key && stack.length === 1 ? [...names] : [], digest: key ? createHash("sha256") : null };
|
|
49
|
-
}
|
|
50
|
-
function emitStringCodepoint(t, cp) {
|
|
51
|
-
if (t.key) {
|
|
52
|
-
t.keyBytes += utf8Width(cp); if (t.keyBytes > l.maxKeyBytes) fail("selective-key-bytes-limit");
|
|
53
|
-
// Only names are hashed transiently. No hash or textual decoding of values.
|
|
54
|
-
t.digest.update(Buffer.from(String.fromCodePoint(cp), "utf8"));
|
|
55
|
-
t.candidates = t.candidates.filter(n => t.count < n.length && n.charCodeAt(t.count) === cp);
|
|
56
|
-
}
|
|
57
|
-
t.count++; // String values are counted, never concatenated or decoded to text.
|
|
58
|
-
}
|
|
59
|
-
function endString(t) {
|
|
60
|
-
if (t.high !== null) fail("selective-invalid-unicode");
|
|
61
|
-
if (t.key) {
|
|
62
|
-
const f = stack.at(-1), fingerprint = t.digest.digest("hex");
|
|
63
|
-
if (f.keys.has(fingerprint)) fail("selective-duplicate-key");
|
|
64
|
-
if (++keys > l.maxKeys) fail("selective-key-limit");
|
|
65
|
-
f.keys.add(fingerprint); digests++; peakKeyDigests = Math.max(peakKeyDigests, digests);
|
|
66
|
-
const selected = t.candidates.find(n => n.length === t.count);
|
|
67
|
-
f.selector = selected ? fields.find(v => v.name === selected) : null; f.phase = "colon";
|
|
68
|
-
} else { if (t.tag) t.tag.empty = t.count === 0; completeValue(); }
|
|
69
|
-
token = null;
|
|
70
|
-
}
|
|
71
|
-
function stringChar(cp) {
|
|
72
|
-
const t = token;
|
|
73
|
-
if (t.needSlash) { if (cp !== 92) fail("selective-invalid-unicode"); t.needSlash = false; t.needU = true; return; }
|
|
74
|
-
if (t.needU) { if (cp !== 117) fail("selective-invalid-unicode"); t.needU = false; t.hexLeft = 4; t.hex = 0; return; }
|
|
75
|
-
if (t.hexLeft) {
|
|
76
|
-
const n = cp >= 48 && cp <= 57 ? cp - 48 : cp >= 65 && cp <= 70 ? cp - 55 : cp >= 97 && cp <= 102 ? cp - 87 : -1;
|
|
77
|
-
if (n < 0) fail("selective-invalid-json"); t.hex = t.hex * 16 + n;
|
|
78
|
-
if (--t.hexLeft === 0) {
|
|
79
|
-
const u = t.hex;
|
|
80
|
-
if (t.high !== null) {
|
|
81
|
-
if (u < 0xdc00 || u > 0xdfff) fail("selective-invalid-unicode");
|
|
82
|
-
const value = 0x10000 + (t.high - 0xd800) * 1024 + u - 0xdc00; t.high = null; emitStringCodepoint(t, value);
|
|
83
|
-
} else if (u >= 0xd800 && u <= 0xdbff) { t.high = u; t.needSlash = true; }
|
|
84
|
-
else if (u >= 0xdc00 && u <= 0xdfff) fail("selective-invalid-unicode");
|
|
85
|
-
else emitStringCodepoint(t, u);
|
|
86
|
-
} return;
|
|
87
|
-
}
|
|
88
|
-
if (t.escape) {
|
|
89
|
-
t.escape = false;
|
|
90
|
-
if (cp === 117) { t.hexLeft = 4; t.hex = 0; return; }
|
|
91
|
-
const escaped = { 34: 34, 92: 92, 47: 47, 98: 8, 102: 12, 110: 10, 114: 13, 116: 9 };
|
|
92
|
-
if (!Object.hasOwn(escaped, cp)) fail("selective-invalid-json"); emitStringCodepoint(t, escaped[cp]); return;
|
|
93
|
-
}
|
|
94
|
-
if (cp === 34) endString(t);
|
|
95
|
-
else if (cp === 92) t.escape = true;
|
|
96
|
-
else { if (cp < 32) fail("selective-invalid-json"); emitStringCodepoint(t, cp); }
|
|
97
|
-
}
|
|
98
|
-
function numberChar(cp) {
|
|
99
|
-
const t = token, p = t.phase;
|
|
100
|
-
if (p === "minus") { if (!digit(cp)) fail("selective-invalid-json"); t.phase = cp === 48 ? "zero" : "integer"; return true; }
|
|
101
|
-
if (p === "zero" || p === "integer" || p === "fraction") {
|
|
102
|
-
if (digit(cp)) { if (p === "zero") fail("selective-invalid-json"); return true; }
|
|
103
|
-
if (cp === 46 && p !== "fraction") { t.phase = "dot"; return true; }
|
|
104
|
-
if (cp === 101 || cp === 69) { t.phase = "exponent"; return true; }
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
if (p === "dot") { if (!digit(cp)) fail("selective-invalid-json"); t.phase = "fraction"; return true; }
|
|
108
|
-
if (p === "exponent") { if (cp === 43 || cp === 45) { t.phase = "exponent-sign"; return true; } if (!digit(cp)) fail("selective-invalid-json"); t.phase = "exponent-digits"; return true; }
|
|
109
|
-
if (p === "exponent-sign") { if (!digit(cp)) fail("selective-invalid-json"); t.phase = "exponent-digits"; return true; }
|
|
110
|
-
if (p === "exponent-digits") return digit(cp);
|
|
111
|
-
fail("selective-invalid-json");
|
|
112
|
-
}
|
|
113
|
-
function closeContainer(cp) {
|
|
114
|
-
const f = stack.at(-1);
|
|
115
|
-
if (cp !== (f.type === "object" ? 125 : 93)) fail("selective-invalid-json");
|
|
116
|
-
if (f.tag) f.tag.empty = f.items === 0;
|
|
117
|
-
digests -= f.keys.size; stack.pop(); completeValue();
|
|
118
|
-
}
|
|
119
|
-
function grammar(cp) {
|
|
120
|
-
if (token) {
|
|
121
|
-
if (token.kind === "string") { stringChar(cp); return; }
|
|
122
|
-
if (token.kind === "literal") {
|
|
123
|
-
const t = token;
|
|
124
|
-
if (cp !== t.word.charCodeAt(t.index++)) fail("selective-invalid-json");
|
|
125
|
-
if (t.index === t.word.length) {
|
|
126
|
-
if (t.tag?.name === "disableAllHooks" && t.word !== "null") t.tag.booleanValue = t.word === "true";
|
|
127
|
-
token = null; completeValue();
|
|
128
|
-
} return;
|
|
129
|
-
}
|
|
130
|
-
if (numberChar(cp)) return;
|
|
131
|
-
token = null; completeValue(); // Re-process the number's delimiter below.
|
|
132
|
-
}
|
|
133
|
-
if (white(cp)) return;
|
|
134
|
-
if (root === "end") fail("selective-invalid-json");
|
|
135
|
-
if (!stack.length) { if (cp !== 123) fail("selective-root-object-required"); root = "running"; beginValue(cp, null); return; }
|
|
136
|
-
const f = stack.at(-1);
|
|
137
|
-
if (f.phase === "key-or-end" || f.phase === "key-only") {
|
|
138
|
-
if (cp === 125 && f.phase === "key-or-end") { closeContainer(cp); return; }
|
|
139
|
-
if (cp !== 34) fail("selective-invalid-json"); item(); beginString(true, null); return;
|
|
140
|
-
}
|
|
141
|
-
if (f.phase === "colon") { if (cp !== 58) fail("selective-invalid-json"); f.phase = "value"; return; }
|
|
142
|
-
if (f.phase === "value-or-end" && cp === 93) { closeContainer(cp); return; }
|
|
143
|
-
if (f.phase === "value" || f.phase === "value-or-end" || f.phase === "value-only") { beginValue(cp, f.selector); return; }
|
|
144
|
-
if (f.phase === "comma-or-end") {
|
|
145
|
-
if (cp === 44) f.phase = f.type === "object" ? "key-only" : "value-only";
|
|
146
|
-
else closeContainer(cp);
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
fail("selective-invalid-json");
|
|
150
|
-
}
|
|
151
|
-
function byte(b) {
|
|
152
|
-
if (utfLeft) {
|
|
153
|
-
if ((b & 0xc0) !== 0x80) fail("selective-invalid-utf8"); utfValue = utfValue * 64 + (b & 63);
|
|
154
|
-
if (--utfLeft === 0) {
|
|
155
|
-
if (utfValue < utfMin || utfValue > 0x10ffff || utfValue >= 0xd800 && utfValue <= 0xdfff) fail("selective-invalid-utf8");
|
|
156
|
-
grammar(utfValue);
|
|
157
|
-
} return;
|
|
158
|
-
}
|
|
159
|
-
if (b < 128) grammar(b);
|
|
160
|
-
else if (b >= 0xc2 && b <= 0xdf) { utfLeft = 1; utfValue = b & 31; utfMin = 128; }
|
|
161
|
-
else if (b >= 0xe0 && b <= 0xef) { utfLeft = 2; utfValue = b & 15; utfMin = 2048; }
|
|
162
|
-
else if (b >= 0xf0 && b <= 0xf4) { utfLeft = 3; utfValue = b & 7; utfMin = 65536; }
|
|
163
|
-
else fail("selective-invalid-utf8");
|
|
164
|
-
}
|
|
165
|
-
function abandon(e) { error = e instanceof ScanFailure ? e.code : "selective-block-invalid"; stack = []; token = null; digests = 0; }
|
|
166
|
-
function report(final = false) {
|
|
167
|
-
const ok = final && error === null && root === "end";
|
|
168
|
-
const output = { scope: "selective-local-structure-only", sourceId, state: ok ? "observed" : error ? "invalid" : "incomplete",
|
|
169
|
-
provenance: "provided-bytes-structure", fields: ok ? copyInertJson(fields) : [], projectionSha256: ok ? hash({ sourceId, fields }) : null,
|
|
170
|
-
inferenceRequested: false, nativeExecuted: false, runtimeReady: false, verifiedAdmission: false,
|
|
171
|
-
externalBillingVerified: false, effectiveControlsVerified: false,
|
|
172
|
-
stats: { bytes, nodes, keys, peakDepth, peakKeyDigests, retainedRawBytes: 0, retainedValueTextBytes: 0 },
|
|
173
|
-
reasons: [ok ? "selective-observed" : error ?? "selective-incomplete"] };
|
|
174
|
-
if (!validReport(output)) throw Error("Selective report invariant failed");
|
|
175
|
-
return output;
|
|
176
|
-
}
|
|
177
|
-
return Object.freeze({
|
|
178
|
-
push(input) {
|
|
179
|
-
if (closed || error) return report(false);
|
|
180
|
-
try {
|
|
181
|
-
if (types.isProxy(input) || !types.isUint8Array(input)) fail("selective-block-invalid");
|
|
182
|
-
const b = copyBytes(input, l.blockBytes); bytes += b.length;
|
|
183
|
-
if (bytes > l.maxBytes) fail("selective-byte-limit");
|
|
184
|
-
for (let i = 0; i < b.length; i++) byte(b[i]);
|
|
185
|
-
} catch (e) { abandon(e); }
|
|
186
|
-
return report(false);
|
|
187
|
-
},
|
|
188
|
-
finish() {
|
|
189
|
-
if (closed) { abandon(new ScanFailure("selective-closed")); return report(false); }
|
|
190
|
-
closed = true;
|
|
191
|
-
if (!error && (utfLeft || token || stack.length || root !== "end")) abandon(new ScanFailure("selective-truncated"));
|
|
192
|
-
return report(true);
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { IS_WINDOWS, warnPlatformPermissions } from './platform.js';
|
|
2
|
-
import fs from "node:fs/promises";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { constants } from "node:fs";
|
|
5
|
-
import { types } from "node:util";
|
|
6
|
-
import Ajv2020 from "ajv/dist/2020.js";
|
|
7
|
-
import { copyInertJson } from "./client-output-json.js";
|
|
8
|
-
import { hash } from "./client-runtime-core.js";
|
|
9
|
-
import { createSelectiveConfigParser, SELECTIVE_ID } from "./client-selective-config.js";
|
|
10
|
-
|
|
11
|
-
const permits = new WeakMap();
|
|
12
|
-
class ReadFailure extends Error { constructor(code) { super(code); this.code = code; } }
|
|
13
|
-
const fail = code => { throw new ReadFailure(code); };
|
|
14
|
-
const monoMs = () => Number(process.hrtime.bigint() / 1000000n);
|
|
15
|
-
const statIdentity = s => [s.dev, s.ino, s.uid, s.gid, s.mode, s.nlink, s.size, s.mtimeMs, s.ctimeMs];
|
|
16
|
-
const equal = (a, b) => JSON.stringify(statIdentity(a)) === JSON.stringify(statIdentity(b));
|
|
17
|
-
const safePath = p => typeof p === "string" && path.isAbsolute(p) && path.normalize(p) === p && !/[\x00-\x1f\x7f]/.test(p);
|
|
18
|
-
|
|
19
|
-
// Only trusted orchestration can turn the human's exact-path approval into a handle.
|
|
20
|
-
export function createSelectiveReadPermit(configuration) {
|
|
21
|
-
const h = Object.freeze(Object.create(null)); permits.set(h, { binding: hash(copyInertJson(configuration)), used: false, live: true }); return h;
|
|
22
|
-
}
|
|
23
|
-
export function revokeSelectiveReadPermit(h) { const p = permits.get(h); if (p) p.live = false; }
|
|
24
|
-
|
|
25
|
-
/** Reads exactly two approved sources. No settings edits, clients or account queries. */
|
|
26
|
-
export function createSelectiveFileReader(schema, configuration, authorization, dependencies = {}) {
|
|
27
|
-
const s = copyInertJson(schema), cfg = copyInertJson(configuration);
|
|
28
|
-
if (s.$id !== SELECTIVE_ID) throw Error("Unsupported selective schema");
|
|
29
|
-
const ajv = new Ajv2020({ strict: true }); ajv.addSchema(s); const limitsValid = ajv.compile({ $ref: SELECTIVE_ID + "#/$defs/limits" });
|
|
30
|
-
const reportValid = ajv.compile({ $ref: SELECTIVE_ID + "#/$defs/fileReport" });
|
|
31
|
-
if (Object.keys(cfg).sort().join() !== "aggregateBytes,limits,sources,timeoutMs" || !limitsValid(cfg.limits) || cfg.limits.blockBytes > cfg.limits.maxBytes ||
|
|
32
|
-
!Number.isSafeInteger(cfg.timeoutMs) || cfg.timeoutMs < 1 || cfg.timeoutMs > 30000 || !Number.isSafeInteger(cfg.aggregateBytes) || cfg.aggregateBytes < 1 || cfg.aggregateBytes > 2097152 ||
|
|
33
|
-
!Array.isArray(cfg.sources) || cfg.sources.length !== 2 || cfg.sources[0].sourceId !== "personal-settings" || cfg.sources[1].sourceId !== "global-state" ||
|
|
34
|
-
cfg.sources.some(e => Object.keys(e).sort().join() !== "path,sourceId" || !safePath(e.path)) || cfg.sources[0].path === cfg.sources[1].path) throw Error("Invalid selective file configuration");
|
|
35
|
-
const io = { ...fs, ...dependencies.io }, mono = dependencies.monotonic ?? monoMs, checkpoint = dependencies.checkpoint ?? (async () => {});
|
|
36
|
-
const uid = process.getuid?.(); let invoked = false;
|
|
37
|
-
const clock = () => { const n = mono(); if (!Number.isFinite(n) || n < 0) fail("selective-clock-unavailable"); return n; };
|
|
38
|
-
const errorCode = e => e instanceof ReadFailure ? e.code : "selective-file-unconfirmed";
|
|
39
|
-
async function physical(name) {
|
|
40
|
-
let curr = path.parse(name).root; const identities = [];
|
|
41
|
-
const parts = name.slice(curr.length).split(path.sep).filter(Boolean);
|
|
42
|
-
if (parts.length > 64) fail("selective-path-unsafe");
|
|
43
|
-
for (const [i, part] of parts.entries()) {
|
|
44
|
-
curr = path.join(curr, part); const st = await io.lstat(curr);
|
|
45
|
-
if (st.isSymbolicLink() || i < parts.length - 1 && !st.isDirectory()) fail("selective-path-unsafe");
|
|
46
|
-
if (i < parts.length - 1) identities.push([st.dev, st.ino, st.uid, st.mode]);
|
|
47
|
-
}
|
|
48
|
-
return identities;
|
|
49
|
-
}
|
|
50
|
-
function allowed(st) {
|
|
51
|
-
if (!st.isFile() || st.isSymbolicLink() || (!IS_WINDOWS && st.uid !== uid) || st.nlink !== 1 || (!IS_WINDOWS && st.mode & 0o022)) fail("selective-file-unsafe");
|
|
52
|
-
if (st.size > cfg.limits.maxBytes) fail("selective-file-limit");
|
|
53
|
-
}
|
|
54
|
-
return Object.freeze({ async run(...args) {
|
|
55
|
-
const r = { scope: "selective-local-structure-only", state: "blocked", sources: [],
|
|
56
|
-
inferenceRequested: false, nativeExecuted: false, runtimeReady: false, verifiedAdmission: false,
|
|
57
|
-
externalBillingVerified: false, effectiveControlsVerified: false, bytesRead: 0, elapsedMs: 0, reasons: [] };
|
|
58
|
-
const observations = []; let began, claimed = false, activeSource = null;
|
|
59
|
-
try {
|
|
60
|
-
began = clock();
|
|
61
|
-
if (invoked) fail("selective-permit-unavailable"); invoked = true;
|
|
62
|
-
const p = !types.isProxy(authorization) && permits.get(authorization);
|
|
63
|
-
if (!p || !p.live || p.used || p.binding !== hash(cfg)) fail("selective-permit-unavailable");
|
|
64
|
-
p.used = true; claimed = true;
|
|
65
|
-
if (args.length) fail("selective-input-forbidden");
|
|
66
|
-
if (!IS_WINDOWS && !Number.isInteger(uid)) fail("selective-owner-unavailable");
|
|
67
|
-
warnPlatformPermissions();
|
|
68
|
-
const budget = () => { if (!p.live || dependencies.signal?.aborted) fail("selective-canceled"); if (clock() - began >= cfg.timeoutMs) fail("selective-deadline"); };
|
|
69
|
-
for (const source of cfg.sources) {
|
|
70
|
-
activeSource = source.sourceId; budget();
|
|
71
|
-
let before;
|
|
72
|
-
try { before = await io.lstat(source.path); } catch (e) { if (e.code === "ENOENT") fail("selective-source-missing"); throw e; }
|
|
73
|
-
const parents = await physical(source.path); allowed(before);
|
|
74
|
-
const parser = createSelectiveConfigParser(s, source.sourceId, cfg.limits);
|
|
75
|
-
const h = await io.open(source.path, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
76
|
-
const buffer = Buffer.alloc(cfg.limits.blockBytes); let read = 0, projection;
|
|
77
|
-
try {
|
|
78
|
-
if (!equal(before, await h.stat())) fail("selective-file-changed");
|
|
79
|
-
await checkpoint("opened", source.sourceId);
|
|
80
|
-
for (;;) {
|
|
81
|
-
budget();
|
|
82
|
-
const remaining = Math.min(cfg.limits.maxBytes - read, cfg.aggregateBytes - r.bytesRead);
|
|
83
|
-
if (remaining <= 0) {
|
|
84
|
-
if (read !== before.size) fail("selective-read-limit"); break;
|
|
85
|
-
}
|
|
86
|
-
const { bytesRead } = await h.read(buffer, 0, Math.min(buffer.length, remaining), read);
|
|
87
|
-
if (!bytesRead) break;
|
|
88
|
-
read += bytesRead; r.bytesRead += bytesRead;
|
|
89
|
-
const partial = parser.push(buffer.subarray(0, bytesRead)); buffer.fill(0);
|
|
90
|
-
if (partial.state === "invalid") fail(partial.reasons[0]);
|
|
91
|
-
await checkpoint("block-read", source.sourceId);
|
|
92
|
-
}
|
|
93
|
-
projection = parser.finish();
|
|
94
|
-
if (projection.state !== "observed") fail(projection.reasons[0]);
|
|
95
|
-
budget(); await checkpoint("before-revalidate", source.sourceId);
|
|
96
|
-
const after = await h.stat(), named = await io.lstat(source.path); allowed(after); allowed(named);
|
|
97
|
-
if (read !== before.size || !equal(before, after) || !equal(after, named) || JSON.stringify(parents) !== JSON.stringify(await physical(source.path))) fail("selective-file-changed");
|
|
98
|
-
budget();
|
|
99
|
-
} finally { buffer.fill(0); await h.close(); }
|
|
100
|
-
budget(); // A delayed close cannot turn an over-deadline source into evidence.
|
|
101
|
-
// Bytes scanner cannot claim an installation observation. Only this IO
|
|
102
|
-
// wrapper attaches local provenance after full descriptor revalidation.
|
|
103
|
-
r.sources.push({ sourceId: source.sourceId, state: "observed", provenance: "local-structure-observation", fields: projection.fields,
|
|
104
|
-
projectionSha256: projection.projectionSha256, stats: projection.stats });
|
|
105
|
-
observations.push({ sourceId: source.sourceId, dev: before.dev, ino: before.ino, uid: before.uid, mode: before.mode & 4095,
|
|
106
|
-
size: before.size, mtimeMs: before.mtimeMs, ctimeMs: before.ctimeMs });
|
|
107
|
-
activeSource = null;
|
|
108
|
-
}
|
|
109
|
-
r.state = "observed"; r.reasons = ["selective-local-observed"];
|
|
110
|
-
} catch (e) {
|
|
111
|
-
const code = errorCode(e); r.state = code === "selective-source-missing" ? "incomplete" : "blocked"; r.reasons = [code];
|
|
112
|
-
if (activeSource) r.sources.push({ sourceId: activeSource, state: r.state, provenance: "pending", fields: [], projectionSha256: null, stats: null });
|
|
113
|
-
} finally {
|
|
114
|
-
if (claimed) revokeSelectiveReadPermit(authorization);
|
|
115
|
-
if (began !== undefined) {
|
|
116
|
-
try {
|
|
117
|
-
r.elapsedMs = Math.max(0, Math.ceil(clock() - began));
|
|
118
|
-
if (r.elapsedMs > cfg.timeoutMs) { r.state = "blocked"; r.reasons = ["selective-deadline"]; }
|
|
119
|
-
}
|
|
120
|
-
catch { r.state = "blocked"; r.reasons = ["selective-clock-unavailable"]; }
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
if (!reportValid(r)) throw Error("Selective file report invariant failed");
|
|
124
|
-
return { report: r, privateObservations: observations };
|
|
125
|
-
} });
|
|
126
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// Closed non-sensitive diagnostics shared with the independent S2 schema.
|
|
2
|
-
export const REASON_CODES = Object.freeze([
|
|
3
|
-
"byte-limit", "duplicate-json-key", "event-json-limit",
|
|
4
|
-
"invalid-byte-input", "invalid-event-object", "invalid-json",
|
|
5
|
-
"invalid-unicode", "invalid-utf8", "json-number-precision-loss",
|
|
6
|
-
"metadata-limit", "non-finite-json-number", "non-json-metadata",
|
|
7
|
-
"store-created-resource-unusable", "store-directory-replaced", "store-file-limit",
|
|
8
|
-
"store-invalid-parent", "store-io-failed", "store-residual-resource",
|
|
9
|
-
"store-resource-changed", "store-resource-exists", "store-resource-replaced",
|
|
10
|
-
"store-short-write", "store-symlink-path", "store-unsafe-resource",
|
|
11
|
-
"supervised-after-terminal", "supervised-budget-consumed", "supervised-budget-reserved",
|
|
12
|
-
"supervised-canceled", "supervised-canceled-before-reservation", "supervised-canceled-before-start",
|
|
13
|
-
"supervised-clock-unavailable", "supervised-consumer-required", "supervised-deadline",
|
|
14
|
-
"supervised-deadline-before-start", "supervised-descendants-live", "supervised-empty-reservation",
|
|
15
|
-
"supervised-event-binding-mismatch", "supervised-event-chain-mismatch", "supervised-event-gap",
|
|
16
|
-
"supervised-event-limit", "supervised-exit-failed", "supervised-fixture-completed",
|
|
17
|
-
"supervised-fixture-directory-unsafe", "supervised-fixture-source-unsafe", "supervised-forbidden-event",
|
|
18
|
-
"supervised-group-unconfirmed", "supervised-incompatible-limits", "supervised-incomplete-protocol",
|
|
19
|
-
"supervised-invalid-claim", "supervised-invalid-completion", "supervised-invalid-deadline",
|
|
20
|
-
"supervised-invalid-event", "supervised-invalid-identity", "supervised-invalid-observation",
|
|
21
|
-
"supervised-invalid-processReport", "supervised-invalid-receipt", "supervised-invalid-report",
|
|
22
|
-
"supervised-invalid-request", "supervised-invalid-reservation", "supervised-invalid-start",
|
|
23
|
-
"supervised-invalid-transition", "supervised-line-limit", "supervised-local-error",
|
|
24
|
-
"supervised-local-result", "supervised-output-limit", "supervised-platform-not-admitted",
|
|
25
|
-
"supervised-process-error", "supervised-receipt-mismatch", "supervised-reconciliation-required",
|
|
26
|
-
"supervised-reservation-changed", "supervised-result-recorded", "supervised-root-not-temporary",
|
|
27
|
-
"supervised-signal-unconfirmed", "supervised-spawn-failed", "supervised-start-record-unconfirmed",
|
|
28
|
-
"supervised-stderr-error", "supervised-stderr-invalid-utf8", "supervised-stderr-limit",
|
|
29
|
-
"supervised-stdin-error", "supervised-stdout-error", "supervised-unconfirmed-terminal",
|
|
30
|
-
"supervised-unterminated-line", "supervised-workspace-cleanup-required", "supervised-workspace-parent-unsafe",
|
|
31
|
-
"supervised-write-not-confirmed", "synthetic-result", "unsafe-json-key",
|
|
32
|
-
]);
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import Ajv2020 from "ajv/dist/2020.js";
|
|
2
|
-
import { types } from "node:util";
|
|
3
|
-
import { copyBytes, decode, parseEventJson, copyInertJson, fail, ParseFailure } from "./client-output-json.js";
|
|
4
|
-
import { hash, same } from "./client-runtime-core.js";
|
|
5
|
-
import { REASON_CODES } from "./client-supervised-codes.js";
|
|
6
|
-
|
|
7
|
-
export { hash, same, fail, ParseFailure, copyInertJson };
|
|
8
|
-
export const LOCAL_ID = "https://agent-toolkit.local/schemas/agent-client-supervised-local.schema.json";
|
|
9
|
-
export const FIXTURE_IDS = Object.freeze(["success", "split-utf8", "environment", "silent", "blocked-stdin", "closed-stdin", "failure", "stdout-overflow", "stderr-overflow", "stderr-invalid", "long-line", "event-overflow", "invalid-utf8", "forbidden-event", "duplicate-json", "after-terminal", "unterminated", "incomplete", "ignore-term", "parent-child", "child-after-parent"]);
|
|
10
|
-
export const terminalStates = new Set(["completed-for-review", "failed", "canceled", "timed-out", "indeterminate"]);
|
|
11
|
-
export const zeroMetrics = () => ({ spawnAttempts: 0, mainStartsObserved: 0, stdoutBytes: 0, stderrBytes: 0, events: 0, elapsedMs: 0, terminationConfirmed: false });
|
|
12
|
-
export const taskKey = i => hash({ projectId: i.projectId, taskId: i.taskId });
|
|
13
|
-
export const monotonicMs = () => Number(process.hrtime.bigint() / 1_000_000n);
|
|
14
|
-
export const errorCode = e => e instanceof ParseFailure && REASON_CODES.includes(e.code) ? e.code : "supervised-local-error";
|
|
15
|
-
|
|
16
|
-
export function createSupervisedContract(schema) {
|
|
17
|
-
const s = copyInertJson(schema);
|
|
18
|
-
if (s.$id !== LOCAL_ID || !same(s.$defs.fixtureId.enum, FIXTURE_IDS) || !same(s.$defs.reasons.items.enum, REASON_CODES)) throw Error("Unsupported supervised local schema");
|
|
19
|
-
const ajv = new Ajv2020({ strict: true, allErrors: true });
|
|
20
|
-
ajv.addFormat("date-time", { type: "string", validate: v => /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(v) && Number.isFinite(Date.parse(v)) && new Date(v).toISOString() === v.replace(/Z$/, ".000Z") });
|
|
21
|
-
ajv.addSchema(s);
|
|
22
|
-
const v = Object.fromEntries(["identity", "request", "event", "receipt", "processReport", "report", "observation"].map(k => [k, ajv.compile({ $ref: `${LOCAL_ID}#/$defs/${k}` })]));
|
|
23
|
-
function json(value) {
|
|
24
|
-
if (types.isProxy(value)) fail("non-json-metadata");
|
|
25
|
-
const obj = typeof value === "string" || types.isUint8Array(value)
|
|
26
|
-
? parseEventJson(decode(copyBytes(value, 131072))) : copyInertJson(value);
|
|
27
|
-
const bytes = copyBytes(JSON.stringify(obj), 131072);
|
|
28
|
-
// Strict string and Unicode validation for nested metadata too.
|
|
29
|
-
return copyInertJson(parseEventJson(decode(bytes)));
|
|
30
|
-
}
|
|
31
|
-
const validate = (name, input) => { const obj = json(input); if (!v[name](obj)) fail("supervised-invalid-" + name); return obj; };
|
|
32
|
-
return Object.freeze({
|
|
33
|
-
request(input) {
|
|
34
|
-
const d = validate("request", input), l = d.limits;
|
|
35
|
-
if (l.graceMs + l.confirmationMs >= l.timeoutMs || l.maxLineBytes > l.maxOutputBytes) fail("supervised-incompatible-limits");
|
|
36
|
-
copyBytes(d.inputText, l.maxInputBytes);
|
|
37
|
-
return d;
|
|
38
|
-
},
|
|
39
|
-
identity: input => validate("identity", input),
|
|
40
|
-
event: input => validate("event", input),
|
|
41
|
-
receipt: input => validate("receipt", input),
|
|
42
|
-
processReport(input) {
|
|
43
|
-
const r = validate("processReport", input);
|
|
44
|
-
if (r.fixtureExecuted !== (r.metrics.mainStartsObserved === 1) || r.metrics.mainStartsObserved > r.metrics.spawnAttempts ||
|
|
45
|
-
r.state === "completed-for-review" && (!r.fixtureExecuted || !r.exitObserved || !r.pipesClosed ||
|
|
46
|
-
r.groupObservation !== "absent" || !r.metrics.terminationConfirmed)) fail("supervised-invalid-processReport");
|
|
47
|
-
return r;
|
|
48
|
-
},
|
|
49
|
-
report: input => validate("report", input),
|
|
50
|
-
observation: input => validate("observation", input)
|
|
51
|
-
});
|
|
52
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { supportsLocalPosix } from "./client-local-platform.js";
|
|
2
|
-
import { createSupervisedStore } from "./client-supervised-store.js";
|
|
3
|
-
import { createSupervisedSupervisor } from "./client-supervised-supervisor.js";
|
|
4
|
-
import { createSupervisedContract, monotonicMs, errorCode, fail } from "./client-supervised-contract.js";
|
|
5
|
-
|
|
6
|
-
/** Only trusted local harnesses invoke this; no CLI or native-client adapter. */
|
|
7
|
-
export function createSupervisedCoordinator(schema, configuration, dependencies = {}) {
|
|
8
|
-
const contract = createSupervisedContract(schema), store = createSupervisedStore(schema, configuration, dependencies.store);
|
|
9
|
-
const supervise = createSupervisedSupervisor(schema, dependencies.supervisor);
|
|
10
|
-
return async function coordinate(input, { signal } = {}) {
|
|
11
|
-
const mono = dependencies.supervisor?.monotonic ?? monotonicMs;
|
|
12
|
-
const beganAt = mono();
|
|
13
|
-
const r = { scope: "fixture-only", state: "not-started", fixtureExecuted: false, nativeExecuted: false,
|
|
14
|
-
runtimeReady: false, verifiedAdmission: false, actualModelCalls: null, fixtureModelCalls: 0,
|
|
15
|
-
internalCallCeiling: null, remoteCancellationVerified: false, process: null, storage: null, elapsedMs: 0, reasons: [] };
|
|
16
|
-
try {
|
|
17
|
-
const d = contract.request(input);
|
|
18
|
-
if (!supportsLocalPosix(process.platform)) fail("supervised-platform-not-admitted");
|
|
19
|
-
if (signal?.aborted) fail("supervised-canceled-before-reservation");
|
|
20
|
-
const storage = await store.withReservation(d, async handle => {
|
|
21
|
-
const p = await supervise(handle, d, { signal, beganAt });
|
|
22
|
-
r.process = p; r.fixtureExecuted = p.fixtureExecuted; r.state = p.state;
|
|
23
|
-
return p;
|
|
24
|
-
});
|
|
25
|
-
r.storage = { state: storage.state, durability: storage.durability, reasons: storage.reasons };
|
|
26
|
-
r.reasons = [...new Set([...(r.process?.reasons ?? []), ...storage.reasons])].sort();
|
|
27
|
-
if (storage.state === "reconciliation-required") r.state = "indeterminate";
|
|
28
|
-
r.elapsedMs = Math.max(0, Math.ceil(mono() - beganAt));
|
|
29
|
-
if (r.elapsedMs > d.limits.timeoutMs) {
|
|
30
|
-
r.state = "indeterminate"; r.reasons = [...new Set([...r.reasons, "supervised-deadline"])].sort();
|
|
31
|
-
}
|
|
32
|
-
} catch (e) { r.reasons = [errorCode(e)]; }
|
|
33
|
-
r.elapsedMs = Math.max(r.elapsedMs, Math.max(0, Math.ceil(mono() - beganAt)));
|
|
34
|
-
return contract.report(r);
|
|
35
|
-
};
|
|
36
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// Independent S2 capabilities: trusted code only, never JSON or a C2 handle.
|
|
2
|
-
const permits = new WeakMap();
|
|
3
|
-
export function createSupervisedPermit(binding, claim, started) {
|
|
4
|
-
const h = Object.freeze(Object.create(null));
|
|
5
|
-
permits.set(h, { binding, claim, started, live: true, used: false });
|
|
6
|
-
return h;
|
|
7
|
-
}
|
|
8
|
-
export function revokeSupervisedPermit(h) { const p = permits.get(h); if (p) p.live = false; }
|
|
9
|
-
export async function claimSupervisedPermit(h, binding) {
|
|
10
|
-
const p = permits.get(h);
|
|
11
|
-
if (!p || !p.live || p.used) throw Error("Supervised permit unavailable");
|
|
12
|
-
p.used = true;
|
|
13
|
-
if (p.binding !== binding) throw Error("Supervised permit binding mismatch");
|
|
14
|
-
await p.claim();
|
|
15
|
-
if (!p.live) throw Error("Supervised permit unavailable");
|
|
16
|
-
return Object.freeze({ started: async () => {
|
|
17
|
-
if (!p.live || p.startedUsed) throw Error("Supervised observation unavailable");
|
|
18
|
-
p.startedUsed = true; return p.started();
|
|
19
|
-
} });
|
|
20
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { decode, parseEventJson, fail } from "./client-output-json.js";
|
|
2
|
-
|
|
3
|
-
/** S2 protocol is synthetic and versioned separately; raw data is discarded. */
|
|
4
|
-
export function createSupervisedProtocol(limits) {
|
|
5
|
-
let bytes = 0, events = 0, pending = Buffer.alloc(0), state = "initial";
|
|
6
|
-
function line(input) {
|
|
7
|
-
if (state === "terminal") fail("supervised-after-terminal");
|
|
8
|
-
if (++events > limits.maxEvents) fail("supervised-event-limit");
|
|
9
|
-
const e = parseEventJson(decode(input.at(-1) === 13 ? input.subarray(0, -1) : input));
|
|
10
|
-
if (e.s !== 2) fail("supervised-invalid-event");
|
|
11
|
-
const keys = Object.keys(e).sort().join(",");
|
|
12
|
-
if (e.type === "start" && state === "initial" && keys === "s,type") state = "running";
|
|
13
|
-
else if (e.type === "data" && state === "running" && keys === "s,text,type" && typeof e.text === "string") { /* No capture retained. */ }
|
|
14
|
-
else if (e.type === "end" && state === "running" && keys === "ok,s,type" && e.ok === true) state = "terminal";
|
|
15
|
-
else fail("supervised-forbidden-event");
|
|
16
|
-
}
|
|
17
|
-
return Object.freeze({
|
|
18
|
-
push(chunk) {
|
|
19
|
-
bytes += chunk.length;
|
|
20
|
-
if (bytes > limits.maxOutputBytes) fail("supervised-output-limit");
|
|
21
|
-
let start = 0;
|
|
22
|
-
for (let i = 0; i < chunk.length; i++) if (chunk[i] === 10) {
|
|
23
|
-
const size = pending.length + i - start;
|
|
24
|
-
if (size > limits.maxLineBytes) fail("supervised-line-limit");
|
|
25
|
-
line(Buffer.concat([pending, chunk.subarray(start, i)], size));
|
|
26
|
-
pending = Buffer.alloc(0); start = i + 1;
|
|
27
|
-
}
|
|
28
|
-
if (pending.length + chunk.length - start > limits.maxLineBytes) fail("supervised-line-limit");
|
|
29
|
-
pending = Buffer.concat([pending, chunk.subarray(start)]);
|
|
30
|
-
},
|
|
31
|
-
finish() {
|
|
32
|
-
if (pending.length) fail("supervised-unterminated-line");
|
|
33
|
-
if (state !== "terminal") fail("supervised-incomplete-protocol");
|
|
34
|
-
},
|
|
35
|
-
counts: () => ({ stdoutBytes: bytes, events, retainedLineBytes: pending.length })
|
|
36
|
-
});
|
|
37
|
-
}
|