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,176 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { types } from "node:util";
|
|
3
|
-
import { copyBytes, copyInertJson, decode, parseEventJson } from "./client-output-json.js";
|
|
4
|
-
import {
|
|
5
|
-
createMemoryConnectionDescriptor, copyMemoryConnectionData, freezeMemoryConnectionData,
|
|
6
|
-
memoryConnectionHash, MEMORY_CONNECTION_FACTS, MEMORY_CONNECTION_VERSION
|
|
7
|
-
} from "./memory-connection-descriptor.js";
|
|
8
|
-
import { containsSensitiveData } from "./sensitive-data.js";
|
|
9
|
-
|
|
10
|
-
export const MEMORY_CONNECTION_PACKAGE_LIMITS = Object.freeze({
|
|
11
|
-
packageJsonBytes: 512 * 1024, packageLockBytes: 2 * 1024 * 1024,
|
|
12
|
-
totalBytes: 2560 * 1024, reportBytes: 128 * 1024,
|
|
13
|
-
depth: 64, nodes: 30000, arrayItems: 256, metadataBytes: 2000000,
|
|
14
|
-
dependencies: 256, nameChars: 256, specifierChars: 1024
|
|
15
|
-
});
|
|
16
|
-
const KEYS = ["descriptor", "packageJsonBytes", "packageLockBytes", "expectedPackageJsonSha256", "expectedPackageLockSha256"];
|
|
17
|
-
const HASH = /^[a-f0-9]{64}$/;
|
|
18
|
-
const CONTROL = /[\x00-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/u;
|
|
19
|
-
const object = value => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
20
|
-
const within = (root, full) => full === root || full.startsWith(root + "/");
|
|
21
|
-
const sha256 = bytes => createHash("sha256").update(bytes).digest("hex");
|
|
22
|
-
class Rejected extends Error {
|
|
23
|
-
constructor(code, state = "blocked") { super(code); this.code = code; this.state = state; }
|
|
24
|
-
}
|
|
25
|
-
const reject = (code, state) => { throw new Rejected(code, state); };
|
|
26
|
-
|
|
27
|
-
function inputs(input) {
|
|
28
|
-
try {
|
|
29
|
-
if (!object(input) || types.isProxy(input) ||
|
|
30
|
-
![Object.prototype, null].includes(Object.getPrototypeOf(input)) || Object.getOwnPropertySymbols(input).length) {
|
|
31
|
-
reject("MC_PACKAGE_INPUT", "invalid");
|
|
32
|
-
}
|
|
33
|
-
const fields = Object.getOwnPropertyDescriptors(input);
|
|
34
|
-
if (Object.keys(fields).length !== KEYS.length || !KEYS.every(key =>
|
|
35
|
-
Object.hasOwn(fields, key) && fields[key].enumerable && Object.hasOwn(fields[key], "value"))) reject("MC_PACKAGE_INPUT", "invalid");
|
|
36
|
-
// Copy only small metadata here: file bytes have their own larger budgets.
|
|
37
|
-
const data = copyMemoryConnectionData({
|
|
38
|
-
descriptor: fields.descriptor.value,
|
|
39
|
-
packagePin: fields.expectedPackageJsonSha256.value,
|
|
40
|
-
lockPin: fields.expectedPackageLockSha256.value
|
|
41
|
-
});
|
|
42
|
-
if (typeof data.packagePin !== "string" || !HASH.test(data.packagePin) ||
|
|
43
|
-
typeof data.lockPin !== "string" || !HASH.test(data.lockPin)) reject("MC_PACKAGE_INPUT", "invalid");
|
|
44
|
-
const descriptor = createMemoryConnectionDescriptor(data.descriptor?.identity);
|
|
45
|
-
if (memoryConnectionHash(descriptor) !== memoryConnectionHash(data.descriptor)) reject("MC_PACKAGE_INPUT", "invalid");
|
|
46
|
-
const { toolkitRoot, vaultPath, manifestPath } = descriptor.identity;
|
|
47
|
-
if (within(toolkitRoot, vaultPath) || within(vaultPath, toolkitRoot) || !manifestPath.startsWith(vaultPath + "/")) {
|
|
48
|
-
reject("MC_PACKAGE_INPUT", "invalid");
|
|
49
|
-
}
|
|
50
|
-
return { descriptor, packagePin: data.packagePin, lockPin: data.lockPin,
|
|
51
|
-
packageValue: fields.packageJsonBytes.value, lockValue: fields.packageLockBytes.value };
|
|
52
|
-
} catch { reject("MC_PACKAGE_INPUT", "invalid"); }
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function capture(value, limit) {
|
|
56
|
-
try {
|
|
57
|
-
if (value && typeof value === "object" && !types.isProxy(value) && types.isUint8Array(value)) {
|
|
58
|
-
const typed = Object.getPrototypeOf(Uint8Array.prototype);
|
|
59
|
-
const backing = Object.getOwnPropertyDescriptor(typed, "buffer").get.call(value);
|
|
60
|
-
if (types.isSharedArrayBuffer(backing)) reject("MC_PACKAGE_INPUT", "invalid");
|
|
61
|
-
}
|
|
62
|
-
return copyBytes(value, limit);
|
|
63
|
-
} catch (error) {
|
|
64
|
-
if (error instanceof Rejected) throw error;
|
|
65
|
-
if (error?.code === "byte-limit") reject("MC_PACKAGE_LIMIT");
|
|
66
|
-
if (["invalid-unicode", "invalid-utf8"].includes(error?.code)) reject("MC_PACKAGE_FORMAT");
|
|
67
|
-
reject("MC_PACKAGE_INPUT", "invalid");
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function parse(bytes) {
|
|
72
|
-
try { return copyInertJson(parseEventJson(decode(bytes))); }
|
|
73
|
-
catch (error) { reject(["event-json-limit", "metadata-limit"].includes(error?.code) ? "MC_PACKAGE_LIMIT" : "MC_PACKAGE_FORMAT"); }
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function profile(pkg, lock) {
|
|
77
|
-
if (lock.lockfileVersion !== 3 || !object(lock.packages) || !Object.hasOwn(lock.packages, "") || !object(lock.packages[""])) {
|
|
78
|
-
reject("MC_PACKAGE_PROFILE");
|
|
79
|
-
}
|
|
80
|
-
const root = lock.packages[""];
|
|
81
|
-
for (const item of [pkg, root]) {
|
|
82
|
-
for (const field of ["devDependencies", "optionalDependencies", "peerDependencies"]) {
|
|
83
|
-
if (Object.hasOwn(item, field) && (!object(item[field]) || Object.keys(item[field]).length)) reject("MC_PACKAGE_PROFILE");
|
|
84
|
-
}
|
|
85
|
-
for (const field of ["workspaces", "overrides", "bundleDependencies", "bundledDependencies"]) {
|
|
86
|
-
if (Object.hasOwn(item, field)) reject("MC_PACKAGE_PROFILE");
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return root;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function literal(value, limit, reason) {
|
|
93
|
-
if (typeof value === "string" && value.length > limit) reject("MC_PACKAGE_LIMIT");
|
|
94
|
-
if (typeof value !== "string" || !value || value !== value.trim() || CONTROL.test(value)) reject(reason);
|
|
95
|
-
return value;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function identity(pkg, lock, root) {
|
|
99
|
-
for (const field of ["name", "version"]) {
|
|
100
|
-
const values = [pkg, lock, root].map(item => literal(item[field], MEMORY_CONNECTION_PACKAGE_LIMITS.nameChars, "MC_PACKAGE_IDENTITY"));
|
|
101
|
-
if (values.some(value => value !== values[0])) reject("MC_PACKAGE_IDENTITY");
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function dependencies(item) {
|
|
106
|
-
if (!Object.hasOwn(item, "dependencies")) return {};
|
|
107
|
-
const value = item.dependencies;
|
|
108
|
-
if (!object(value)) reject("MC_PACKAGE_DEPENDENCIES");
|
|
109
|
-
const keys = Object.keys(value);
|
|
110
|
-
if (keys.length > MEMORY_CONNECTION_PACKAGE_LIMITS.dependencies) reject("MC_PACKAGE_LIMIT");
|
|
111
|
-
for (const key of keys) {
|
|
112
|
-
literal(key, MEMORY_CONNECTION_PACKAGE_LIMITS.nameChars, "MC_PACKAGE_DEPENDENCIES");
|
|
113
|
-
literal(value[key], MEMORY_CONNECTION_PACKAGE_LIMITS.specifierChars, "MC_PACKAGE_DEPENDENCIES");
|
|
114
|
-
}
|
|
115
|
-
return value;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function engines(pkg, root) {
|
|
119
|
-
for (const item of [pkg, root]) {
|
|
120
|
-
if (Object.hasOwn(item, "engines") && !object(item.engines)) reject("MC_PACKAGE_ENGINES");
|
|
121
|
-
}
|
|
122
|
-
const has = item => Object.hasOwn(item, "engines") && Object.hasOwn(item.engines, "node");
|
|
123
|
-
const a = has(pkg), b = has(root);
|
|
124
|
-
if (!a && !b) return false;
|
|
125
|
-
if (!a || !b) reject("MC_PACKAGE_ENGINES");
|
|
126
|
-
const left = literal(pkg.engines.node, MEMORY_CONNECTION_PACKAGE_LIMITS.specifierChars, "MC_PACKAGE_ENGINES");
|
|
127
|
-
const right = literal(root.engines.node, MEMORY_CONNECTION_PACKAGE_LIMITS.specifierChars, "MC_PACKAGE_ENGINES");
|
|
128
|
-
if (left !== right) reject("MC_PACKAGE_ENGINES");
|
|
129
|
-
return true;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function report(state, reason, hashes = {}, engineMatched = false) {
|
|
133
|
-
const matched = state === "consistent";
|
|
134
|
-
const result = {
|
|
135
|
-
schemaVersion: MEMORY_CONNECTION_VERSION, state, reasons: [reason],
|
|
136
|
-
descriptorSha256: null, packageJsonSha256: null, packageLockSha256: null, ...hashes,
|
|
137
|
-
facts: {
|
|
138
|
-
...MEMORY_CONNECTION_FACTS, evidence: "provided-bytes", verificationScope: "package-root-declarations-only",
|
|
139
|
-
packageIdentityMatched: matched, directDependencyDeclarationsMatched: matched,
|
|
140
|
-
engineDeclarationMatched: matched && engineMatched,
|
|
141
|
-
rangeSatisfactionVerified: false, dependencyGraphVerified: false, installedDependenciesVerified: false,
|
|
142
|
-
runtimeVersionVerified: false, runtimeCompatibilityVerified: false
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
if (Buffer.byteLength(JSON.stringify(result)) > MEMORY_CONNECTION_PACKAGE_LIMITS.reportBytes) reject("MC_PACKAGE_LIMIT");
|
|
146
|
-
return freezeMemoryConnectionData(result);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Compare two reviewed byte captures and root declarations only. No candidate IO,
|
|
151
|
-
* npm/Node execution, range solving, installed-tree inspection or plan integration.
|
|
152
|
-
*/
|
|
153
|
-
export function validateMemoryConnectionPackage(input) {
|
|
154
|
-
try {
|
|
155
|
-
const data = inputs(input);
|
|
156
|
-
const packageBytes = capture(data.packageValue, MEMORY_CONNECTION_PACKAGE_LIMITS.packageJsonBytes);
|
|
157
|
-
const lockBytes = capture(data.lockValue, MEMORY_CONNECTION_PACKAGE_LIMITS.packageLockBytes);
|
|
158
|
-
if (packageBytes.length + lockBytes.length > MEMORY_CONNECTION_PACKAGE_LIMITS.totalBytes) reject("MC_PACKAGE_LIMIT");
|
|
159
|
-
const packageHash = sha256(packageBytes), lockHash = sha256(lockBytes);
|
|
160
|
-
if (packageHash !== data.packagePin || lockHash !== data.lockPin) reject("MC_PACKAGE_PIN_MISMATCH");
|
|
161
|
-
const pkg = parse(packageBytes), lock = parse(lockBytes);
|
|
162
|
-
if (containsSensitiveData(JSON.stringify(pkg)) || containsSensitiveData(JSON.stringify(lock))) reject("MC_PACKAGE_SENSITIVE");
|
|
163
|
-
const root = profile(pkg, lock);
|
|
164
|
-
identity(pkg, lock, root);
|
|
165
|
-
const left = dependencies(pkg), right = dependencies(root), keys = Object.keys(left);
|
|
166
|
-
if (keys.length !== Object.keys(right).length || keys.some(key => !Object.hasOwn(right, key) || left[key] !== right[key])) {
|
|
167
|
-
reject("MC_PACKAGE_DEPENDENCIES");
|
|
168
|
-
}
|
|
169
|
-
const engineMatched = engines(pkg, root);
|
|
170
|
-
return report("consistent", "MC_PACKAGE_CONSISTENT", {
|
|
171
|
-
descriptorSha256: memoryConnectionHash(data.descriptor), packageJsonSha256: data.packagePin, packageLockSha256: data.lockPin
|
|
172
|
-
}, engineMatched);
|
|
173
|
-
} catch (error) {
|
|
174
|
-
return report(error instanceof Rejected ? error.state : "blocked", error instanceof Rejected ? error.code : "MC_PACKAGE_VALIDATION");
|
|
175
|
-
}
|
|
176
|
-
}
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createMemoryConnectionDescriptor,
|
|
3
|
-
copyMemoryConnectionData,
|
|
4
|
-
freezeMemoryConnectionData,
|
|
5
|
-
hasMemoryConnectionKeys,
|
|
6
|
-
memoryConnectionHash,
|
|
7
|
-
MEMORY_CONNECTION_FACTS,
|
|
8
|
-
MEMORY_CONNECTION_LIMITS,
|
|
9
|
-
MEMORY_CONNECTION_VERSION,
|
|
10
|
-
MemoryConnectionInputError
|
|
11
|
-
} from "./memory-connection-descriptor.js";
|
|
12
|
-
import { containsSensitiveData } from "./sensitive-data.js";
|
|
13
|
-
|
|
14
|
-
const PIN_KEYS = [
|
|
15
|
-
"manifestSha256", "binSha256", "nodeSha256", "dependenciesSha256",
|
|
16
|
-
"pathMetadataSha256", "skillMetadataSha256"
|
|
17
|
-
];
|
|
18
|
-
const SERVER_KEYS = ["command", "args", "enabled"];
|
|
19
|
-
const SERVER_OPTIONAL = ["cwd", "enabled_tools"];
|
|
20
|
-
const HASH = /^[a-f0-9]{64}$/;
|
|
21
|
-
const states = (value, allowed) => typeof value === "string" && allowed.includes(value);
|
|
22
|
-
const component = (id, action, code) => ({ id, action, code });
|
|
23
|
-
const reject = (code) => { throw new MemoryConnectionInputError(code); };
|
|
24
|
-
const equal = (a, b) => memoryConnectionHash(a) === memoryConnectionHash(b);
|
|
25
|
-
|
|
26
|
-
function blank() {
|
|
27
|
-
return {
|
|
28
|
-
command: "project-memory connect plan",
|
|
29
|
-
schemaVersion: MEMORY_CONNECTION_VERSION,
|
|
30
|
-
state: "invalid",
|
|
31
|
-
connectionClass: "unknown",
|
|
32
|
-
identity: null,
|
|
33
|
-
candidateServer: null,
|
|
34
|
-
components: [],
|
|
35
|
-
summary: { create: 0, update: 0, migrate: 0, unchanged: 0, conflicts: 0, blocked: 0 },
|
|
36
|
-
reasons: [],
|
|
37
|
-
planHash: null,
|
|
38
|
-
facts: { ...MEMORY_CONNECTION_FACTS }
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function finish(report, state, reasons) {
|
|
43
|
-
report.state = state;
|
|
44
|
-
report.reasons = [...new Set(reasons)].sort();
|
|
45
|
-
report.summary = {
|
|
46
|
-
create: report.components.filter((item) => item.action === "create").length,
|
|
47
|
-
update: report.components.filter((item) => item.action === "update").length,
|
|
48
|
-
migrate: report.components.filter((item) => item.action === "migrate").length,
|
|
49
|
-
unchanged: report.components.filter((item) => item.action === "unchanged").length,
|
|
50
|
-
conflicts: report.components.filter((item) => item.action === "conflict").length,
|
|
51
|
-
blocked: report.components.filter((item) => item.action === "blocked").length
|
|
52
|
-
};
|
|
53
|
-
if (!["preview", "unchanged"].includes(state)) {
|
|
54
|
-
report.candidateServer = null;
|
|
55
|
-
report.planHash = null;
|
|
56
|
-
}
|
|
57
|
-
if (Buffer.byteLength(JSON.stringify(report)) > MEMORY_CONNECTION_LIMITS.reportBytes) {
|
|
58
|
-
const limited = blank();
|
|
59
|
-
limited.reasons = ["MC_REPORT_LIMIT"];
|
|
60
|
-
return freezeMemoryConnectionData(limited);
|
|
61
|
-
}
|
|
62
|
-
return freezeMemoryConnectionData(report);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function checkObservations(observations) {
|
|
66
|
-
if (!hasMemoryConnectionKeys(observations, ["configuration", "skill"])) {
|
|
67
|
-
reject("MC_OBSERVATIONS_INVALID");
|
|
68
|
-
}
|
|
69
|
-
const config = observations.configuration;
|
|
70
|
-
if (!hasMemoryConnectionKeys(config, ["state", "sha256", "server"]) ||
|
|
71
|
-
!states(config.state, ["absent", "present", "unsafe"])) {
|
|
72
|
-
reject("MC_OBSERVATIONS_INVALID");
|
|
73
|
-
}
|
|
74
|
-
if (config.state === "present") {
|
|
75
|
-
if (typeof config.sha256 !== "string" || !HASH.test(config.sha256) ||
|
|
76
|
-
config.server !== null && (typeof config.server !== "object" || Array.isArray(config.server))) {
|
|
77
|
-
reject("MC_OBSERVATIONS_INVALID");
|
|
78
|
-
}
|
|
79
|
-
} else if (config.sha256 !== null || config.server !== null) {
|
|
80
|
-
reject("MC_OBSERVATIONS_INVALID");
|
|
81
|
-
}
|
|
82
|
-
const skill = observations.skill;
|
|
83
|
-
if (!hasMemoryConnectionKeys(skill, ["state", "resolvedSource"]) ||
|
|
84
|
-
!states(skill.state, ["absent", "matched", "conflict", "unsafe"]) ||
|
|
85
|
-
["absent", "unsafe"].includes(skill.state) && skill.resolvedSource !== null ||
|
|
86
|
-
skill.state === "matched" && typeof skill.resolvedSource !== "string" ||
|
|
87
|
-
skill.state === "conflict" && skill.resolvedSource !== null && typeof skill.resolvedSource !== "string") {
|
|
88
|
-
reject("MC_OBSERVATIONS_INVALID");
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function sensitive(value) {
|
|
93
|
-
if (typeof value === "string") return containsSensitiveData(value);
|
|
94
|
-
return value !== null && typeof value === "object" &&
|
|
95
|
-
Object.values(value).some(sensitive);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function serverShape(server) {
|
|
99
|
-
return hasMemoryConnectionKeys(server, SERVER_KEYS, SERVER_OPTIONAL) &&
|
|
100
|
-
typeof server.command === "string" && Array.isArray(server.args) &&
|
|
101
|
-
server.args.length <= 16 && server.args.every((arg) => typeof arg === "string") &&
|
|
102
|
-
typeof server.enabled === "boolean" &&
|
|
103
|
-
(server.cwd === undefined || typeof server.cwd === "string") &&
|
|
104
|
-
(server.enabled_tools === undefined || Array.isArray(server.enabled_tools) &&
|
|
105
|
-
server.enabled_tools.every((tool) => typeof tool === "string"));
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function policyMatches(tools, expected) {
|
|
109
|
-
return Array.isArray(tools) && tools.length === expected.length &&
|
|
110
|
-
new Set(tools).size === tools.length && expected.every((tool) => tools.includes(tool));
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Classifies explicit declarations and creates an intent pin, never a permission.
|
|
115
|
-
* Only these two modules and their tests are part of RG3-A1a: no TOML collector,
|
|
116
|
-
* writer, public CLI dispatch, native MCP test or actual client configuration.
|
|
117
|
-
*/
|
|
118
|
-
// The exact direct launches `connect` has registered: the first reviewed one and, since nexakit 0.6.0, the
|
|
119
|
-
// read-only one. Anything else with the same name stays an identity mismatch.
|
|
120
|
-
const LEGACY_DIRECT_LAUNCHES = Object.freeze([
|
|
121
|
-
["-y", "@modelcontextprotocol/server-filesystem@2026.8.31"],
|
|
122
|
-
["-y", "@modelcontextprotocol/server-filesystem@2.3.0", "--read-only", "--confine-roots"]
|
|
123
|
-
]);
|
|
124
|
-
|
|
125
|
-
export function createMemoryConnectionPlan(input) {
|
|
126
|
-
const report = blank();
|
|
127
|
-
let data, descriptor;
|
|
128
|
-
try {
|
|
129
|
-
data = copyMemoryConnectionData(input);
|
|
130
|
-
if (!hasMemoryConnectionKeys(data, ["schemaVersion", "descriptor", "observations", "pins", "migrateLegacy"]) ||
|
|
131
|
-
data.schemaVersion !== MEMORY_CONNECTION_VERSION || typeof data.migrateLegacy !== "boolean") {
|
|
132
|
-
reject("MC_PLAN_INVALID");
|
|
133
|
-
}
|
|
134
|
-
if (sensitive(data)) reject("MC_SENSITIVE_INPUT");
|
|
135
|
-
descriptor = createMemoryConnectionDescriptor(data.descriptor?.identity);
|
|
136
|
-
if (!equal(descriptor, data.descriptor)) reject("MC_DESCRIPTOR_MISMATCH");
|
|
137
|
-
if (!hasMemoryConnectionKeys(data.pins, PIN_KEYS) ||
|
|
138
|
-
Object.values(data.pins).some((hash) => typeof hash !== "string" || !HASH.test(hash))) {
|
|
139
|
-
reject("MC_PINS_INVALID");
|
|
140
|
-
}
|
|
141
|
-
checkObservations(data.observations);
|
|
142
|
-
if (data.observations.skill.state === "matched" &&
|
|
143
|
-
data.observations.skill.resolvedSource !== descriptor.skill.source) {
|
|
144
|
-
reject("MC_SKILL_DECLARATION_MISMATCH");
|
|
145
|
-
}
|
|
146
|
-
} catch (error) {
|
|
147
|
-
return finish(report, "invalid", [error instanceof MemoryConnectionInputError ? error.code : "MC_PLAN_INVALID"]);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
report.identity = { ...descriptor.identity };
|
|
151
|
-
const { configuration, skill } = data.observations;
|
|
152
|
-
report.components.push(component("skill", {
|
|
153
|
-
absent: "create", matched: "unchanged", conflict: "conflict", unsafe: "blocked"
|
|
154
|
-
}[skill.state], {
|
|
155
|
-
absent: "MC_SKILL_MISSING", matched: "MC_SKILL_MATCH_DECLARED",
|
|
156
|
-
conflict: "MC_SKILL_CONFLICT", unsafe: "MC_SKILL_UNSAFE"
|
|
157
|
-
}[skill.state]));
|
|
158
|
-
|
|
159
|
-
if (configuration.state === "unsafe") {
|
|
160
|
-
report.connectionClass = "unsafe";
|
|
161
|
-
report.components.push(component("mcp", "blocked", "MC_CONFIG_UNSAFE"));
|
|
162
|
-
} else if (configuration.server === null) {
|
|
163
|
-
report.connectionClass = "absent";
|
|
164
|
-
report.components.push(component("mcp", "create", "MC_SERVER_MISSING"),
|
|
165
|
-
component("policy", "create", "MC_POLICY_PROPOSED"));
|
|
166
|
-
report.candidateServer = structuredClone(descriptor.server);
|
|
167
|
-
} else {
|
|
168
|
-
const current = configuration.server;
|
|
169
|
-
if (!serverShape(current)) {
|
|
170
|
-
report.components.push(component("mcp", "conflict", "MC_SERVER_UNKNOWN"));
|
|
171
|
-
} else if (current.command === descriptor.server.command &&
|
|
172
|
-
equal(current.args, descriptor.server.args) && current.cwd === descriptor.server.cwd) {
|
|
173
|
-
report.connectionClass = "protected";
|
|
174
|
-
report.components.push(component("mcp", "unchanged", "MC_SERVER_MATCH_DECLARED"));
|
|
175
|
-
if (policyMatches(current.enabled_tools, descriptor.server.enabled_tools)) {
|
|
176
|
-
report.components.push(component("policy", "unchanged", "MC_POLICY_MATCH_DECLARED"));
|
|
177
|
-
report.candidateServer = { ...structuredClone(descriptor.server), enabled: current.enabled };
|
|
178
|
-
} else {
|
|
179
|
-
report.components.push(component("policy", "conflict", "MC_POLICY_MISMATCH"));
|
|
180
|
-
}
|
|
181
|
-
} else if (current.command === "npx" && LEGACY_DIRECT_LAUNCHES.some(launch =>
|
|
182
|
-
equal(current.args, [...launch, descriptor.identity.vaultPath])) && (current.cwd === undefined || current.cwd === descriptor.server.cwd)) {
|
|
183
|
-
report.connectionClass = "legacy-direct";
|
|
184
|
-
if (data.migrateLegacy) {
|
|
185
|
-
report.components.push(component("mcp", "migrate", "MC_LEGACY_MIGRATION_PROPOSED"),
|
|
186
|
-
component("policy", "migrate", "MC_POLICY_PROPOSED"));
|
|
187
|
-
report.candidateServer = structuredClone(descriptor.server);
|
|
188
|
-
} else {
|
|
189
|
-
report.components.push(component("mcp", "conflict", "MC_LEGACY_OPT_IN_REQUIRED"));
|
|
190
|
-
}
|
|
191
|
-
} else {
|
|
192
|
-
report.components.push(component("mcp", "conflict", "MC_SERVER_IDENTITY_MISMATCH"));
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
const reasons = report.components.filter((item) => ["conflict", "blocked"].includes(item.action))
|
|
197
|
-
.map((item) => item.code);
|
|
198
|
-
if (report.components.some((item) => item.action === "blocked")) return finish(report, "blocked", reasons);
|
|
199
|
-
if (report.components.some((item) => item.action === "conflict")) return finish(report, "conflict", reasons);
|
|
200
|
-
try {
|
|
201
|
-
report.planHash = memoryConnectionHash({
|
|
202
|
-
schemaVersion: MEMORY_CONNECTION_VERSION,
|
|
203
|
-
descriptor,
|
|
204
|
-
observations: data.observations,
|
|
205
|
-
pins: data.pins,
|
|
206
|
-
migrateLegacy: data.migrateLegacy,
|
|
207
|
-
components: report.components,
|
|
208
|
-
candidateServer: report.candidateServer
|
|
209
|
-
});
|
|
210
|
-
} catch {
|
|
211
|
-
return finish(report, "invalid", ["MC_PLAN_LIMIT"]);
|
|
212
|
-
}
|
|
213
|
-
const unchanged = report.components.every((item) => item.action === "unchanged");
|
|
214
|
-
const notes = [unchanged ? "MC_MATCH_DECLARED" : "MC_PREVIEW_ONLY"];
|
|
215
|
-
if (report.candidateServer.enabled === false) notes.push("MC_SERVER_DISABLED");
|
|
216
|
-
return finish(report, unchanged ? "unchanged" : "preview", notes);
|
|
217
|
-
}
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
import { constants } from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { createHash } from "node:crypto";
|
|
5
|
-
import { copyBytes, decode } from "./client-output-json.js";
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
createMemoryConnectionDescriptor, copyMemoryConnectionData,
|
|
9
|
-
freezeMemoryConnectionData, memoryConnectionHash,
|
|
10
|
-
MEMORY_CONNECTION_FACTS, MEMORY_CONNECTION_VERSION
|
|
11
|
-
} from "./memory-connection-descriptor.js";
|
|
12
|
-
|
|
13
|
-
export const MEMORY_CONNECTION_SKILL_LIMITS = Object.freeze({
|
|
14
|
-
fileBytes: 131072, chunkBytes: 65536, pathChars: 4096,
|
|
15
|
-
components: 64, reportBytes: 131072
|
|
16
|
-
});
|
|
17
|
-
export const MEMORY_CONNECTION_SKILL_OPEN_FLAGS = constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK;
|
|
18
|
-
class Rejected extends Error {
|
|
19
|
-
constructor(code, state = "blocked") { super(code); this.code = code; this.state = state; }
|
|
20
|
-
}
|
|
21
|
-
const reject = (code, state) => { throw new Rejected(code, state); };
|
|
22
|
-
const errno = (e) => e instanceof Error && typeof e.code === "string" ? e.code : "";
|
|
23
|
-
const digest = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
24
|
-
const dirSignature = (s) => JSON.stringify([s.dev, s.ino, s.uid, s.gid, s.mode]);
|
|
25
|
-
const fileSignature = (s) => JSON.stringify([s.dev, s.ino, s.uid, s.gid, s.mode, s.nlink, s.size, s.mtimeMs, s.ctimeMs]);
|
|
26
|
-
|
|
27
|
-
function inputs(input) {
|
|
28
|
-
try {
|
|
29
|
-
const data = copyMemoryConnectionData(input);
|
|
30
|
-
if (!data || Array.isArray(data) || Object.keys(data).length !== 2 ||
|
|
31
|
-
!Object.hasOwn(data, "descriptor") || !Object.hasOwn(data, "expectedSkillSha256") ||
|
|
32
|
-
typeof data.expectedSkillSha256 !== "string" || !/^[a-f0-9]{64}$/.test(data.expectedSkillSha256)) {
|
|
33
|
-
reject("MC_SKILL_INPUT", "invalid");
|
|
34
|
-
}
|
|
35
|
-
const descriptor = createMemoryConnectionDescriptor(data.descriptor?.identity);
|
|
36
|
-
if (memoryConnectionHash(descriptor) !== memoryConnectionHash(data.descriptor)) reject("MC_SKILL_INPUT", "invalid");
|
|
37
|
-
const sourceFile = descriptor.skill.source + "/SKILL.md";
|
|
38
|
-
for (const full of [descriptor.skill.target, sourceFile]) {
|
|
39
|
-
if (full.length > MEMORY_CONNECTION_SKILL_LIMITS.pathChars ||
|
|
40
|
-
full.split("/").length - 1 > MEMORY_CONNECTION_SKILL_LIMITS.components) reject("MC_SKILL_INPUT", "invalid");
|
|
41
|
-
}
|
|
42
|
-
return { descriptor, expected: data.expectedSkillSha256, sourceFile };
|
|
43
|
-
} catch { reject("MC_SKILL_INPUT", "invalid"); }
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function safeDir(s, uid, owned) {
|
|
47
|
-
if (!s.isDirectory() || s.isSymbolicLink() || !(s.mode & 0o100)) reject("MC_SKILL_PARENT_UNSAFE");
|
|
48
|
-
if (owned) {
|
|
49
|
-
if (s.uid !== uid || s.mode & 0o7022) reject("MC_SKILL_PARENT_UNSAFE");
|
|
50
|
-
} else {
|
|
51
|
-
const sharedSticky = s.uid === 0 && (s.mode & 0o7777) === 0o1777;
|
|
52
|
-
if (![0, uid].includes(s.uid) || !sharedSticky && s.mode & 0o7022) reject("MC_SKILL_PARENT_UNSAFE");
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function safeSourceFile(s, uid) {
|
|
56
|
-
if (!s.isFile() || s.isSymbolicLink() || s.uid !== uid || s.nlink !== 1 || (s.mode & 0o7777) !== 0o600) {
|
|
57
|
-
reject("MC_SKILL_FILE_UNSAFE");
|
|
58
|
-
}
|
|
59
|
-
if (!Number.isSafeInteger(s.size) || s.size < 0 || s.size > MEMORY_CONNECTION_SKILL_LIMITS.fileBytes) reject("MC_SKILL_FILE_LIMIT");
|
|
60
|
-
}
|
|
61
|
-
async function parents(io, full, ownedRoot, uid, missingAllowed = []) {
|
|
62
|
-
const chain = []; let current = "/";
|
|
63
|
-
const root = await io.lstat(current); safeDir(root, uid, false);
|
|
64
|
-
chain.push({ path: current, signature: dirSignature(root) });
|
|
65
|
-
const parts = full.slice(1).split("/");
|
|
66
|
-
for (const part of parts.slice(0, -1)) {
|
|
67
|
-
current = path.posix.join(current, part); let s;
|
|
68
|
-
try { s = await io.lstat(current); }
|
|
69
|
-
catch (e) {
|
|
70
|
-
if (errno(e) === "ENOENT" && missingAllowed.includes(current)) return { chain, missing: current };
|
|
71
|
-
reject(errno(e) === "ENOENT" ? "MC_SKILL_PATH_MISSING" : "MC_SKILL_UNREADABLE");
|
|
72
|
-
}
|
|
73
|
-
safeDir(s, uid, current === ownedRoot || current.startsWith(ownedRoot + "/"));
|
|
74
|
-
chain.push({ path: current, signature: dirSignature(s) });
|
|
75
|
-
}
|
|
76
|
-
return { chain, missing: null };
|
|
77
|
-
}
|
|
78
|
-
async function recheckParents(io, snapshot, ownedRoot, uid) {
|
|
79
|
-
for (const parent of snapshot.chain) {
|
|
80
|
-
let s; try { s = await io.lstat(parent.path); } catch { reject("MC_SKILL_CHANGED"); }
|
|
81
|
-
safeDir(s, uid, parent.path === ownedRoot || parent.path.startsWith(ownedRoot + "/"));
|
|
82
|
-
if (dirSignature(s) !== parent.signature) reject("MC_SKILL_CHANGED");
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
async function targetSnapshot(io, descriptor, uid) {
|
|
86
|
-
const home = descriptor.identity.homeDirectory, target = descriptor.skill.target;
|
|
87
|
-
const snapshot = await parents(io, target, home, uid, [home + "/.agents", home + "/.agents/skills"]);
|
|
88
|
-
snapshot.stat = null; snapshot.link = null;
|
|
89
|
-
if (snapshot.missing) return snapshot;
|
|
90
|
-
let s;
|
|
91
|
-
try { s = await io.lstat(target); }
|
|
92
|
-
catch (e) { if (errno(e) === "ENOENT") { snapshot.missing = target; return snapshot; } reject("MC_SKILL_UNREADABLE"); }
|
|
93
|
-
if (s.uid !== uid) reject("MC_SKILL_TARGET_UNSAFE");
|
|
94
|
-
snapshot.stat = s;
|
|
95
|
-
if (s.isSymbolicLink()) {
|
|
96
|
-
if (s.nlink !== 1 || s.mode & 0o7000) reject("MC_SKILL_TARGET_UNSAFE");
|
|
97
|
-
snapshot.link = await linkText(io, target);
|
|
98
|
-
} else if (!s.isFile() && !s.isDirectory()) reject("MC_SKILL_TARGET_UNSAFE");
|
|
99
|
-
return snapshot;
|
|
100
|
-
}
|
|
101
|
-
async function linkText(io, target) {
|
|
102
|
-
// Native readlink must not silently replace invalid path bytes with U+FFFD.
|
|
103
|
-
const raw = await io.readlink(target, { encoding: "buffer" });
|
|
104
|
-
try {
|
|
105
|
-
const text = decode(copyBytes(raw, MEMORY_CONNECTION_SKILL_LIMITS.pathChars * 4));
|
|
106
|
-
if (text.length > MEMORY_CONNECTION_SKILL_LIMITS.pathChars) reject("MC_SKILL_TARGET_UNSAFE");
|
|
107
|
-
return text;
|
|
108
|
-
} catch { reject("MC_SKILL_TARGET_UNSAFE"); }
|
|
109
|
-
}
|
|
110
|
-
async function recheckTarget(io, descriptor, snapshot, uid) {
|
|
111
|
-
await recheckParents(io, snapshot, descriptor.identity.homeDirectory, uid);
|
|
112
|
-
if (snapshot.missing) {
|
|
113
|
-
try { await io.lstat(snapshot.missing); }
|
|
114
|
-
catch (e) { if (errno(e) === "ENOENT") return; reject("MC_SKILL_CHANGED"); }
|
|
115
|
-
reject("MC_SKILL_CHANGED");
|
|
116
|
-
}
|
|
117
|
-
let s;
|
|
118
|
-
try { s = await io.lstat(descriptor.skill.target); } catch { reject("MC_SKILL_CHANGED"); }
|
|
119
|
-
if (fileSignature(s) !== fileSignature(snapshot.stat)) reject("MC_SKILL_CHANGED");
|
|
120
|
-
if (snapshot.link !== null && await linkText(io, descriptor.skill.target) !== snapshot.link) reject("MC_SKILL_CHANGED");
|
|
121
|
-
}
|
|
122
|
-
async function sourceSnapshot(io, data, uid) {
|
|
123
|
-
const snapshot = await parents(io, data.sourceFile, data.descriptor.identity.vaultPath, uid);
|
|
124
|
-
let s;
|
|
125
|
-
try { s = await io.lstat(data.sourceFile); }
|
|
126
|
-
catch (e) { reject(errno(e) === "ENOENT" ? "MC_SKILL_SOURCE_MISSING" : "MC_SKILL_UNREADABLE"); }
|
|
127
|
-
safeSourceFile(s, uid); snapshot.stat = s; return snapshot;
|
|
128
|
-
}
|
|
129
|
-
async function recheckSource(io, data, snapshot, uid) {
|
|
130
|
-
await recheckParents(io, snapshot, data.descriptor.identity.vaultPath, uid);
|
|
131
|
-
let s;
|
|
132
|
-
try { s = await io.lstat(data.sourceFile); } catch { reject("MC_SKILL_CHANGED"); }
|
|
133
|
-
safeSourceFile(s, uid);
|
|
134
|
-
if (fileSignature(s) !== fileSignature(snapshot.stat)) reject("MC_SKILL_CHANGED");
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Check only the exact own link and reviewed SKILL.md bytes. Never enumerate,
|
|
139
|
-
* interpret Skill text, follow foreign destinations, install, repair or execute.
|
|
140
|
-
* IO overrides are trusted simulations, not a sandbox or native-read evidence.
|
|
141
|
-
* Rechecks detect observable races; they are not atomic openat/ABA protection.
|
|
142
|
-
*/
|
|
143
|
-
export async function inspectMemoryConnectionSkill(input, dependencies = {}) {
|
|
144
|
-
let data = null, nativeIO = false;
|
|
145
|
-
const report = (state, details = {}) => {
|
|
146
|
-
const read = ["matched", "absent"].includes(state), observed = read || state === "conflict";
|
|
147
|
-
const result = {
|
|
148
|
-
schemaVersion: MEMORY_CONNECTION_VERSION, state, skillName: data?.descriptor.identity.skillName ?? null,
|
|
149
|
-
sourceSha256: null, metadataSha256: null, resolvedSource: null, reasons: [], ...details,
|
|
150
|
-
facts: {
|
|
151
|
-
...MEMORY_CONNECTION_FACTS, verificationScope: "skill-installation-only",
|
|
152
|
-
evidence: observed ? nativeIO ? read ? "local-skill-file" : "local-skill-metadata" : "simulated-local-skill" : "none",
|
|
153
|
-
targetObservationVerified: observed && nativeIO, skillSourceVerified: read && nativeIO,
|
|
154
|
-
localReadVerified: read && nativeIO, bytePinMatched: read,
|
|
155
|
-
skillFormatVerified: false, skillLoadedVerified: false
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
if (Buffer.byteLength(JSON.stringify(result)) > MEMORY_CONNECTION_SKILL_LIMITS.reportBytes) reject("MC_SKILL_REPORT_LIMIT");
|
|
159
|
-
return freezeMemoryConnectionData(result);
|
|
160
|
-
};
|
|
161
|
-
try {
|
|
162
|
-
data = inputs(input);
|
|
163
|
-
nativeIO = dependencies.io === undefined;
|
|
164
|
-
const io = dependencies.io ?? fs, uid = process.getuid?.();
|
|
165
|
-
if (!["darwin", "linux"].includes(process.platform) || !Number.isSafeInteger(uid) || constants.O_NOFOLLOW === undefined) reject("MC_SKILL_PLATFORM");
|
|
166
|
-
const descriptor = data.descriptor, target = await targetSnapshot(io, descriptor, uid);
|
|
167
|
-
await recheckTarget(io, descriptor, target, uid);
|
|
168
|
-
if (target.stat && target.link !== descriptor.skill.source) {
|
|
169
|
-
return report("conflict", { reasons: ["MC_SKILL_TARGET_CONFLICT"] });
|
|
170
|
-
}
|
|
171
|
-
const source = await sourceSnapshot(io, data, uid);
|
|
172
|
-
await recheckSource(io, data, source, uid); await recheckTarget(io, descriptor, target, uid);
|
|
173
|
-
let handle;
|
|
174
|
-
try { handle = await io.open(data.sourceFile, MEMORY_CONNECTION_SKILL_OPEN_FLAGS); }
|
|
175
|
-
catch (e) { reject(errno(e) === "ELOOP" ? "MC_SKILL_FILE_UNSAFE" : "MC_SKILL_UNREADABLE"); }
|
|
176
|
-
let bytes;
|
|
177
|
-
try {
|
|
178
|
-
const start = await handle.stat(); safeSourceFile(start, uid);
|
|
179
|
-
if (fileSignature(start) !== fileSignature(source.stat)) reject("MC_SKILL_CHANGED");
|
|
180
|
-
await recheckSource(io, data, source, uid); await recheckTarget(io, descriptor, target, uid);
|
|
181
|
-
bytes = Buffer.alloc(source.stat.size); let offset = 0;
|
|
182
|
-
while (offset < bytes.length) {
|
|
183
|
-
const request = Math.min(MEMORY_CONNECTION_SKILL_LIMITS.chunkBytes, bytes.length - offset);
|
|
184
|
-
const { bytesRead } = await handle.read(bytes, offset, request, offset);
|
|
185
|
-
if (!Number.isSafeInteger(bytesRead) || bytesRead < 0 || bytesRead > request) reject("MC_SKILL_READ");
|
|
186
|
-
if (!bytesRead) reject("MC_SKILL_CHANGED");
|
|
187
|
-
offset += bytesRead;
|
|
188
|
-
}
|
|
189
|
-
const after = await handle.stat(); safeSourceFile(after, uid);
|
|
190
|
-
if (fileSignature(after) !== fileSignature(source.stat)) reject("MC_SKILL_CHANGED");
|
|
191
|
-
await recheckSource(io, data, source, uid); await recheckTarget(io, descriptor, target, uid);
|
|
192
|
-
} finally {
|
|
193
|
-
try { await handle.close(); } catch { reject("MC_SKILL_CLOSE"); }
|
|
194
|
-
}
|
|
195
|
-
await recheckSource(io, data, source, uid); await recheckTarget(io, descriptor, target, uid);
|
|
196
|
-
const sha256 = digest(bytes);
|
|
197
|
-
if (sha256 !== data.expected) reject("MC_SKILL_PIN_MISMATCH");
|
|
198
|
-
const metadataSha256 = digest(JSON.stringify({
|
|
199
|
-
source: { path: data.sourceFile, parents: source.chain, signature: fileSignature(source.stat) },
|
|
200
|
-
target: { path: descriptor.skill.target, parents: target.chain, missing: target.missing,
|
|
201
|
-
signature: target.stat ? fileSignature(target.stat) : null, link: target.link }
|
|
202
|
-
}));
|
|
203
|
-
return report(target.missing ? "absent" : "matched", {
|
|
204
|
-
sourceSha256: sha256, metadataSha256,
|
|
205
|
-
resolvedSource: target.missing ? null : descriptor.skill.source,
|
|
206
|
-
reasons: [target.missing ? "MC_SKILL_TARGET_MISSING" : "MC_SKILL_MATCH"]
|
|
207
|
-
});
|
|
208
|
-
} catch (e) {
|
|
209
|
-
return report(e instanceof Rejected ? e.state : "blocked", { reasons: [e instanceof Rejected ? e.code : "MC_SKILL_IO"] });
|
|
210
|
-
}
|
|
211
|
-
}
|