nexakit 0.0.0-stage → 0.2.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/.claude-plugin/marketplace.json +28 -0
- package/LICENSE +26 -0
- package/README.md +79 -2
- package/agents/claude/docs-researcher.md +9 -0
- package/agents/claude/implementation-tutor.md +9 -0
- package/agents/claude/project-explorer.md +9 -0
- package/agents/claude/quality-reviewer.md +9 -0
- package/agents/claude/requirements-analyst.md +9 -0
- package/agents/claude/solution-architect.md +9 -0
- package/agents/codex/docs-researcher.toml +10 -0
- package/agents/codex/implementation-tutor.toml +10 -0
- package/agents/codex/project-explorer.toml +10 -0
- package/agents/codex/quality-reviewer.toml +10 -0
- package/agents/codex/requirements-analyst.toml +11 -0
- package/agents/codex/solution-architect.toml +10 -0
- package/assets/brand/README.md +38 -0
- package/assets/brand/agent-toolkit-mark.png +0 -0
- package/assets/brand/agent-toolkit-mark.svg +13 -0
- package/assets/brand/agent-toolkit-tui-hero.png +0 -0
- package/assets/brand/nexakit-readme-hero.png +0 -0
- package/assets/brand/nexakit-readme-hero.svg +21 -0
- package/assets/runtime/package-lock.json +1425 -0
- package/bin/agent-task.js +14 -0
- package/bin/agent-toolkit-gemini.js +13 -0
- package/bin/agent-toolkit-inbox.js +14 -0
- package/bin/agent-toolkit-mcp.js +17 -0
- package/bin/agent-toolkit.js +13 -0
- package/bin/nexakit.js +13 -0
- package/bin/project-memory-mcp.js +22 -0
- package/bin/project-memory.js +7 -0
- package/catalogs/skills/api-design-principles/LICENSE.txt +21 -0
- package/catalogs/skills/api-design-principles/SKILL.md +110 -0
- package/catalogs/skills/api-design-principles/assets/api-design-checklist.md +155 -0
- package/catalogs/skills/api-design-principles/assets/rest-api-template.py +185 -0
- package/catalogs/skills/api-design-principles/references/details.md +413 -0
- package/catalogs/skills/api-design-principles/references/graphql-schema-design.md +589 -0
- package/catalogs/skills/api-design-principles/references/rest-best-practices.md +408 -0
- package/catalogs/skills/nodejs-backend-patterns/LICENSE.txt +21 -0
- package/catalogs/skills/nodejs-backend-patterns/SKILL.md +45 -0
- package/catalogs/skills/nodejs-backend-patterns/references/advanced-patterns.md +430 -0
- package/catalogs/skills/nodejs-backend-patterns/references/details.md +599 -0
- package/catalogs/skills/supabase-postgres-best-practices/CHANGELOG.md +73 -0
- package/catalogs/skills/supabase-postgres-best-practices/LICENSE.txt +21 -0
- package/catalogs/skills/supabase-postgres-best-practices/SKILL.md +64 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/_contributing.md +170 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/_sections.md +39 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/_template.md +34 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/conn-limits.md +44 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/conn-pooling.md +41 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/data-pagination.md +50 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/data-upsert.md +50 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/lock-advisory.md +56 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/query-index-types.md +48 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/schema-constraints.md +80 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/schema-data-types.md +46 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/schema-partitioning.md +55 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/security-privileges.md +54 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/security-rls-basics.md +50 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/security-rls-performance.md +63 -0
- package/catalogs/skills/vercel-composition-patterns/AGENTS.md +946 -0
- package/catalogs/skills/vercel-composition-patterns/LICENSE.txt +27 -0
- package/catalogs/skills/vercel-composition-patterns/README.md +60 -0
- package/catalogs/skills/vercel-composition-patterns/SKILL.md +89 -0
- package/catalogs/skills/vercel-composition-patterns/metadata.json +11 -0
- package/catalogs/skills/vercel-composition-patterns/rules/_sections.md +29 -0
- package/catalogs/skills/vercel-composition-patterns/rules/_template.md +24 -0
- package/catalogs/skills/vercel-composition-patterns/rules/architecture-avoid-boolean-props.md +100 -0
- package/catalogs/skills/vercel-composition-patterns/rules/architecture-compound-components.md +112 -0
- package/catalogs/skills/vercel-composition-patterns/rules/patterns-children-over-render-props.md +87 -0
- package/catalogs/skills/vercel-composition-patterns/rules/patterns-explicit-variants.md +100 -0
- package/catalogs/skills/vercel-composition-patterns/rules/react19-no-forwardref.md +42 -0
- package/catalogs/skills/vercel-composition-patterns/rules/state-context-interface.md +191 -0
- package/catalogs/skills/vercel-composition-patterns/rules/state-decouple-implementation.md +113 -0
- package/catalogs/skills/vercel-composition-patterns/rules/state-lift-state.md +125 -0
- package/catalogs/skills/vercel-react-best-practices/AGENTS.md +3810 -0
- package/catalogs/skills/vercel-react-best-practices/LICENSE.txt +27 -0
- package/catalogs/skills/vercel-react-best-practices/README.md +123 -0
- package/catalogs/skills/vercel-react-best-practices/SKILL.md +149 -0
- package/catalogs/skills/vercel-react-best-practices/metadata.json +15 -0
- package/catalogs/skills/vercel-react-best-practices/rules/_sections.md +46 -0
- package/catalogs/skills/vercel-react-best-practices/rules/_template.md +28 -0
- package/catalogs/skills/vercel-react-best-practices/rules/advanced-effect-event-deps.md +56 -0
- package/catalogs/skills/vercel-react-best-practices/rules/advanced-event-handler-refs.md +55 -0
- package/catalogs/skills/vercel-react-best-practices/rules/advanced-init-once.md +42 -0
- package/catalogs/skills/vercel-react-best-practices/rules/advanced-use-latest.md +39 -0
- package/catalogs/skills/vercel-react-best-practices/rules/async-api-routes.md +38 -0
- package/catalogs/skills/vercel-react-best-practices/rules/async-cheap-condition-before-await.md +37 -0
- package/catalogs/skills/vercel-react-best-practices/rules/async-defer-await.md +82 -0
- package/catalogs/skills/vercel-react-best-practices/rules/async-dependencies.md +51 -0
- package/catalogs/skills/vercel-react-best-practices/rules/async-parallel.md +28 -0
- package/catalogs/skills/vercel-react-best-practices/rules/async-suspense-boundaries.md +99 -0
- package/catalogs/skills/vercel-react-best-practices/rules/bundle-analyzable-paths.md +63 -0
- package/catalogs/skills/vercel-react-best-practices/rules/bundle-barrel-imports.md +60 -0
- package/catalogs/skills/vercel-react-best-practices/rules/bundle-conditional.md +31 -0
- package/catalogs/skills/vercel-react-best-practices/rules/bundle-defer-third-party.md +49 -0
- package/catalogs/skills/vercel-react-best-practices/rules/bundle-dynamic-imports.md +35 -0
- package/catalogs/skills/vercel-react-best-practices/rules/bundle-preload.md +50 -0
- package/catalogs/skills/vercel-react-best-practices/rules/client-event-listeners.md +74 -0
- package/catalogs/skills/vercel-react-best-practices/rules/client-localstorage-schema.md +71 -0
- package/catalogs/skills/vercel-react-best-practices/rules/client-passive-event-listeners.md +48 -0
- package/catalogs/skills/vercel-react-best-practices/rules/client-swr-dedup.md +56 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-batch-dom-css.md +107 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-cache-function-results.md +80 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-cache-property-access.md +28 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-cache-storage.md +70 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-combine-iterations.md +32 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-early-exit.md +50 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-flatmap-filter.md +60 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-hoist-regexp.md +45 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-index-maps.md +37 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-length-check-first.md +49 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-min-max-loop.md +82 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-request-idle-callback.md +105 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-set-map-lookups.md +24 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-tosorted-immutable.md +57 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rendering-activity.md +26 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rendering-conditional-render.md +40 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rendering-content-visibility.md +38 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rendering-hoist-jsx.md +46 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rendering-resource-hints.md +85 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rendering-script-defer-async.md +68 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rendering-svg-precision.md +28 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rendering-usetransition-loading.md +75 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-defer-reads.md +39 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-dependencies.md +45 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-derived-state.md +29 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-functional-setstate.md +74 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-lazy-state-init.md +58 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-memo.md +44 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-no-inline-components.md +82 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-split-combined-hooks.md +64 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-transitions.md +40 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-use-deferred-value.md +59 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
- package/catalogs/skills/vercel-react-best-practices/rules/server-after-nonblocking.md +73 -0
- package/catalogs/skills/vercel-react-best-practices/rules/server-auth-actions.md +96 -0
- package/catalogs/skills/vercel-react-best-practices/rules/server-cache-lru.md +41 -0
- package/catalogs/skills/vercel-react-best-practices/rules/server-cache-react.md +76 -0
- package/catalogs/skills/vercel-react-best-practices/rules/server-dedup-props.md +65 -0
- package/catalogs/skills/vercel-react-best-practices/rules/server-hoist-static-io.md +149 -0
- package/catalogs/skills/vercel-react-best-practices/rules/server-no-shared-module-state.md +50 -0
- package/catalogs/skills/vercel-react-best-practices/rules/server-parallel-fetching.md +83 -0
- package/catalogs/skills/vercel-react-best-practices/rules/server-parallel-nested-fetching.md +34 -0
- package/catalogs/skills/vercel-react-best-practices/rules/server-serialization.md +38 -0
- package/catalogs/skills/webapp-testing/LICENSE.txt +202 -0
- package/catalogs/skills/webapp-testing/SKILL.md +96 -0
- package/catalogs/skills/webapp-testing/examples/console_logging.py +35 -0
- package/catalogs/skills/webapp-testing/examples/element_discovery.py +40 -0
- package/catalogs/skills/webapp-testing/examples/static_html_automation.py +33 -0
- package/catalogs/skills/webapp-testing/scripts/with_server.py +106 -0
- package/catalogs/skills.json +1115 -0
- package/docs/skills/evidencias/2026-10-28-evaluacion-inicial-mcp-seguridad.md +118 -0
- package/docs/skills/evidencias/2026-10-28-incorporacion-mcp-seguridad.json +152 -0
- package/docs/skills/evidencias/2026-10-28-recomendador-preparacion.md +50 -0
- package/package.json +73 -4
- package/plugins/nexakit-modelo/.claude-plugin/plugin.json +1 -0
- package/plugins/nexakit-modelo/hooks/hooks.json +1 -0
- package/plugins/nexakit-modelo/hooks/register.js +48 -0
- package/plugins/nexakit-modelo/hooks/status.js +8 -0
- package/plugins/nexakit-modelo/tests/register.test.ts +21 -0
- package/plugins/nexakit-panel/.claude-plugin/plugin.json +1 -0
- package/plugins/nexakit-panel/README.md +20 -0
- package/plugins/nexakit-panel/hooks/hooks.json +1 -0
- package/plugins/nexakit-panel/hooks/lienzo.js +382 -0
- package/plugins/nexakit-panel/hooks/panel.js +279 -0
- package/plugins/nexakit-panel/hooks/register.tsx +248 -0
- package/plugins/nexakit-panel/tests/lienzo.test.ts +142 -0
- package/plugins/nexakit-panel/tests/panel.test.ts +240 -0
- package/plugins/nexakit-panel/tests/register.test.ts +167 -0
- package/plugins/nexakit-panel/types/index.d.ts +41 -0
- package/plugins/nexakit-sesion/.claude-plugin/plugin.json +1 -0
- package/plugins/nexakit-sesion/README.md +12 -0
- package/plugins/nexakit-sesion/hooks/aviso.js +38 -0
- package/plugins/nexakit-sesion/hooks/hooks.json +1 -0
- package/plugins/nexakit-sesion/hooks/register.js +28 -0
- package/plugins/nexakit-sesion/tests/register.test.ts +96 -0
- package/plugins/niveles/.claude-plugin/plugin.json +5 -0
- package/plugins/niveles/agents/nivel-alto.md +13 -0
- package/plugins/niveles/agents/nivel-exigente.md +13 -0
- package/plugins/niveles/agents/nivel-ligero.md +13 -0
- package/plugins/niveles/agents/nivel-normal.md +13 -0
- package/schemas/agent-client-adapter.schema.json +786 -0
- package/schemas/agent-client-auth-diagnostic.schema.json +801 -0
- package/schemas/agent-client-isolated-variant.schema.json +105 -0
- package/schemas/agent-client-isolated-verification.schema.json +99 -0
- package/schemas/agent-client-managed-preferences-invocation.schema.json +67 -0
- package/schemas/agent-client-managed-preferences.schema.json +63 -0
- package/schemas/agent-client-native-diagnostics.schema.json +85 -0
- package/schemas/agent-client-native-evaluation.schema.json +171 -0
- package/schemas/agent-client-native-preflight.schema.json +90 -0
- package/schemas/agent-client-output.schema.json +551 -0
- package/schemas/agent-client-runtime-fixture.schema.json +90 -0
- package/schemas/agent-client-runtime-local.schema.json +95 -0
- package/schemas/agent-client-runtime.schema.json +1288 -0
- package/schemas/agent-client-selective-config.schema.json +77 -0
- package/schemas/agent-client-supervised-local.schema.json +135 -0
- package/schemas/agent-client-supervised.schema.json +186 -0
- package/schemas/agent-model-preference.schema.json +573 -0
- package/schemas/agent-model-selection.schema.json +311 -0
- package/schemas/agent-task-approvals.schema.json +362 -0
- package/schemas/agent-task-prepare.schema.json +1324 -0
- package/schemas/agent-task-verify.schema.json +198 -0
- package/schemas/project-memory-update.schema.json +33 -0
- package/schemas/project-memory.schema.json +298 -0
- package/schemas/skill-catalog.schema.json +246 -0
- package/schemas/task-workflow-plan-output.schema.json +35 -0
- package/scripts/prepare-package.js +6 -0
- package/scripts/validate-skill-catalog.js +41 -0
- package/skills/cerrar-avisens/SKILL.md +12 -0
- package/skills/cerrar-memoria/SKILL.md +96 -0
- package/skills/cerrar-memoria/references/cierre.md +76 -0
- package/skills/decision-records/SKILL.md +27 -0
- package/skills/decision-records/agents/openai.yaml +7 -0
- package/skills/decision-records/references/adr-template.md +35 -0
- package/skills/differential-review/LICENSE.txt +427 -0
- package/skills/differential-review/SKILL.md +225 -0
- package/skills/differential-review/adversarial.md +203 -0
- package/skills/differential-review/agents/openai.yaml +6 -0
- package/skills/differential-review/assets/trail-of-bits-mark.svg +1 -0
- package/skills/differential-review/methodology.md +234 -0
- package/skills/differential-review/patterns.md +300 -0
- package/skills/differential-review/reporting.md +369 -0
- package/skills/elegir-modelo/SKILL.md +68 -0
- package/skills/elegir-modelo/modelos.mjs +108 -0
- package/skills/frontend-design/LICENSE.txt +177 -0
- package/skills/frontend-design/SKILL.md +71 -0
- package/skills/gemini/SKILL.md +52 -0
- package/skills/imagen/SKILL.md +12 -0
- package/skills/investigar/SKILL.md +11 -0
- package/skills/mcp-builder/LICENSE.txt +202 -0
- package/skills/mcp-builder/SKILL.md +236 -0
- package/skills/mcp-builder/reference/evaluation.md +602 -0
- package/skills/mcp-builder/reference/mcp_best_practices.md +249 -0
- package/skills/mcp-builder/reference/node_mcp_server.md +970 -0
- package/skills/mcp-builder/reference/python_mcp_server.md +719 -0
- package/skills/mcp-builder/scripts/connections.py +151 -0
- package/skills/mcp-builder/scripts/evaluation.py +373 -0
- package/skills/mcp-builder/scripts/example_evaluation.xml +22 -0
- package/skills/mcp-builder/scripts/requirements.txt +2 -0
- package/skills/ordenar-proyecto/SKILL.md +56 -0
- package/skills/project-handoff/SKILL.md +53 -0
- package/skills/project-handoff/agents/openai.yaml +7 -0
- package/skills/project-handoff/references/handoff-template.md +35 -0
- package/skills/quality-gate/LICENSE.txt +26 -0
- package/skills/quality-gate/SKILL.md +44 -0
- package/skills/quality-gate/agents/openai.yaml +7 -0
- package/skills/quality-gate/references/review-checklist.md +42 -0
- package/skills/revisar/SKILL.md +11 -0
- package/skills/revisar-skill/LICENSE-find-skills.txt +26 -0
- package/skills/revisar-skill/SKILL.md +94 -0
- package/skills/revision-cruzada/SKILL.md +59 -0
- package/skills/web-design-guidelines/AGENTS.md +156 -0
- package/skills/web-design-guidelines/LICENSE.txt +21 -0
- package/skills/web-design-guidelines/SKILL.md +29 -0
- package/src/agent-models.js +131 -0
- package/src/brand.js +117 -0
- package/src/claude-code-runner.js +642 -0
- package/src/cli-executable.js +88 -0
- package/src/cli.js +778 -0
- package/src/client-adapter-plan.js +271 -0
- package/src/client-auth-diagnostic-parser.js +211 -0
- package/src/client-auth-diagnostic.js +257 -0
- package/src/client-isolated-variant.js +106 -0
- package/src/client-isolated-verification.js +130 -0
- package/src/client-local-platform.js +14 -0
- package/src/client-managed-preferences-invocation.js +209 -0
- package/src/client-managed-preferences.js +78 -0
- package/src/client-native-access.js +134 -0
- package/src/client-native-diagnostics.js +253 -0
- package/src/client-native-evaluation.js +106 -0
- package/src/client-native-preflight-files.js +68 -0
- package/src/client-native-preflight.js +95 -0
- package/src/client-output-json.js +118 -0
- package/src/client-output-parser.js +278 -0
- package/src/client-runtime-admission.js +80 -0
- package/src/client-runtime-coordinator.js +70 -0
- package/src/client-runtime-core.js +92 -0
- package/src/client-runtime-fixture-permit.js +20 -0
- package/src/client-runtime-fixture-protocol.js +39 -0
- package/src/client-runtime-state.js +67 -0
- package/src/client-runtime-store-files.js +91 -0
- package/src/client-runtime-store.js +239 -0
- package/src/client-runtime-supervisor.js +146 -0
- package/src/client-selective-config.js +195 -0
- package/src/client-selective-files.js +126 -0
- package/src/client-supervised-codes.js +32 -0
- package/src/client-supervised-contract.js +52 -0
- package/src/client-supervised-coordinator.js +36 -0
- package/src/client-supervised-permit.js +20 -0
- package/src/client-supervised-protocol.js +37 -0
- package/src/client-supervised-store.js +167 -0
- package/src/client-supervised-supervisor.js +167 -0
- package/src/client-supervised.js +160 -0
- package/src/codex-cli-runner.js +358 -0
- package/src/codex-delivery.js +101 -0
- package/src/connect.js +703 -0
- package/src/doctor.js +795 -0
- package/src/gemini-cli.js +76 -0
- package/src/gemini-files.js +45 -0
- package/src/gemini-tools.js +249 -0
- package/src/init.js +473 -0
- package/src/install-lock.js +127 -0
- package/src/install-registry.js +61 -0
- package/src/legacy-repair.js +71 -0
- package/src/level-agents.js +111 -0
- package/src/link-states.js +172 -0
- package/src/memory-connection-artifacts.js +192 -0
- package/src/memory-connection-descriptor.js +158 -0
- package/src/memory-connection-diagnostic.js +177 -0
- package/src/memory-connection-files.js +191 -0
- package/src/memory-connection-manifest.js +118 -0
- package/src/memory-connection-package.js +176 -0
- package/src/memory-connection-plan.js +211 -0
- package/src/memory-connection-skill.js +211 -0
- package/src/memory-connection-toml.js +153 -0
- package/src/memory-locator.js +118 -0
- package/src/memory-mcp-policy.js +181 -0
- package/src/memory-mcp-server.js +166 -0
- package/src/memory-mcp-transport.js +59 -0
- package/src/missing-dependencies.js +21 -0
- package/src/model-command.js +147 -0
- package/src/model-preference.js +235 -0
- package/src/model-selection.js +368 -0
- package/src/native/managed-preferences.c +100 -0
- package/src/native/managed-preferences.h +17 -0
- package/src/package-lock-path.js +13 -0
- package/src/panel-cli.js +182 -0
- package/src/peer-handoff.js +27 -0
- package/src/peer-inbox-cli.js +211 -0
- package/src/peer-review-mcp.js +210 -0
- package/src/peer-review-store.js +532 -0
- package/src/platform.js +24 -0
- package/src/project-root.js +41 -0
- package/src/project-signals.js +339 -0
- package/src/recommend-report.js +77 -0
- package/src/review-instructions.js +211 -0
- package/src/review-policy.js +35 -0
- package/src/revision-adapters.js +157 -0
- package/src/revision-context.js +86 -0
- package/src/revision-isolation.js +222 -0
- package/src/revision-process.js +103 -0
- package/src/revision-provenance.js +89 -0
- package/src/revision-snapshot.js +120 -0
- package/src/revision.js +242 -0
- package/src/runtime-fixtures/runtime-supervisor/child.cjs +3 -0
- package/src/runtime-fixtures/runtime-supervisor/fixture.cjs +49 -0
- package/src/runtime-fixtures/supervised/child.cjs +3 -0
- package/src/runtime-fixtures/supervised/fixture.cjs +47 -0
- package/src/sensitive-data.js +21 -0
- package/src/setup-apply.js +231 -0
- package/src/setup-plan.js +231 -0
- package/src/setup-state.js +277 -0
- package/src/setup-tui.js +555 -0
- package/src/skill-catalog-add.js +91 -0
- package/src/skill-catalog-audit.js +68 -0
- package/src/skill-catalog.js +170 -0
- package/src/skill-files.js +39 -0
- package/src/skill-recommendations.js +1673 -0
- package/src/skill-scan-report.js +14 -0
- package/src/skill-scan.js +178 -0
- package/src/stable-command.js +53 -0
- package/src/stable-install.js +222 -0
- package/src/status.js +200 -0
- package/src/superpowers.js +133 -0
- package/src/sync-apply.js +227 -0
- package/src/sync-files.js +109 -0
- package/src/sync-inspect.js +394 -0
- package/src/sync-ledger.js +94 -0
- package/src/sync-markdown.js +151 -0
- package/src/sync-proposal.js +84 -0
- package/src/sync-record.js +459 -0
- package/src/sync.js +360 -0
- package/src/task-approvals.js +367 -0
- package/src/task-cli.js +79 -0
- package/src/task-external-verifier.js +584 -0
- package/src/task-prepare-files.js +115 -0
- package/src/task-prepare.js +180 -0
- package/src/task-verify-cli.js +67 -0
- package/src/task-verify-files.js +188 -0
- package/src/task-verify.js +118 -0
- package/src/task-workflow-mcp.js +544 -0
- package/src/task-workflow-store.js +254 -0
- package/src/terminal-text.js +68 -0
- package/src/toolkit-cli.js +543 -0
- package/src/toolkit-commands-guide.js +107 -0
- package/src/toolkit-setup.js +614 -0
- package/src/usage-metrics.js +43 -0
- package/templates/agent-team/01-encargo.md +158 -0
- package/templates/agent-team/02-propuesta.md +132 -0
- package/templates/agent-team/03-revision.md +150 -0
- package/templates/agent-team/README.md +213 -0
- package/templates/model-inventory/01-inventario.md +154 -0
- package/templates/model-inventory/README.md +115 -0
- package/templates/project-memory/README.md +67 -0
- package/templates/project-memory/project-memory.example.json +53 -0
- package/templates/project-memory/skill/project-id/SKILL.md +37 -0
- package/templates/project-memory/skill/project-id/references/project-profile.md +44 -0
- package/templates/project-memory/vault/00-INICIO/Estado actual.md +44 -0
- package/templates/project-memory/vault/00-INICIO/Fuentes de verdad.md +30 -0
- package/templates/project-memory/vault/00-INICIO/Inicio del proyecto.md +44 -0
- package/templates/project-memory/vault/00-INICIO/Mantenimiento de la memoria.md +26 -0
- package/templates/project-memory/vault/00-INICIO/Mapa de la memoria.md +33 -0
- package/templates/project-memory/vault/00-INICIO/Registro de sincronizaci/303/263n.md" +28 -0
- package/templates/project-memory/vault/01-PRODUCTO/Producto.md +16 -0
- package/templates/project-memory/vault/02-ARQUITECTURA/Arquitectura.md +16 -0
- package/templates/project-memory/vault/03-IMPLEMENTACION/Implementaci/303/263n.md +15 -0
- package/templates/project-memory/vault/04-DECISIONES/Decisiones.md +19 -0
- package/templates/project-memory/vault/05-ENTREGAS/Entregas.md +12 -0
- package/templates/project-memory/vault/06-OPERACION/Operaci/303/263n.md +15 -0
- package/templates/project-memory/vault/07-AGENTES/Protocolo de agentes.md +33 -0
- package/templates/project-memory/vault/08-RECURSOS/Recursos.md +12 -0
- package/templates/project-memory/vault/09-ARCHIVO/README.md +5 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { types } from "node:util";
|
|
3
|
+
|
|
4
|
+
import Ajv2020 from "ajv/dist/2020.js";
|
|
5
|
+
|
|
6
|
+
import { createModelSelector } from "./model-selection.js";
|
|
7
|
+
|
|
8
|
+
const SCHEMA_ID = "https://agent-toolkit.local/schemas/agent-client-adapter.schema.json";
|
|
9
|
+
const ROUTES = {
|
|
10
|
+
"codex-cli": ["openai", "codex-native"],
|
|
11
|
+
"claude-code": ["anthropic", "claude-native"]
|
|
12
|
+
};
|
|
13
|
+
const CONTROLS = [
|
|
14
|
+
"no-tools", "no-subagents", "no-mcp", "no-hooks",
|
|
15
|
+
"no-personalizations", "no-updates", "stdin-text"
|
|
16
|
+
];
|
|
17
|
+
const GATES = [
|
|
18
|
+
"human-authorization", "client-preflight", "billing-policy",
|
|
19
|
+
"preventive-controls", "atomic-history-and-reservation",
|
|
20
|
+
"private-context-resolution", "process-cancellation"
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Supply trusted packaged schemas as JSON. Registry/context/access claims are
|
|
25
|
+
* declarations only: this factory and its planner do no IO or authentication.
|
|
26
|
+
* A prepared intent is NOT a runnable command or permission to launch a client.
|
|
27
|
+
*/
|
|
28
|
+
export function createClientAdapterPlanner(baseSchema, preferenceSchema, adapterSchema) {
|
|
29
|
+
const schemas = [baseSchema, preferenceSchema, adapterSchema].map(copyJson);
|
|
30
|
+
if (schemas[2].$id !== SCHEMA_ID) throw new Error("Unsupported adapter schema");
|
|
31
|
+
const select = createModelSelector(schemas[0], schemas[1]);
|
|
32
|
+
const ajv = new Ajv2020({ strict: true, allErrors: true });
|
|
33
|
+
ajv.addFormat("date-time", { type: "string", validate: isUtcTimestamp });
|
|
34
|
+
schemas.forEach((schema) => ajv.addSchema(schema));
|
|
35
|
+
const validateInput = ajv.compile({ $ref: `${SCHEMA_ID}#/$defs/input` });
|
|
36
|
+
const validateReport = ajv.compile({ $ref: `${SCHEMA_ID}#/$defs/report` });
|
|
37
|
+
const adapterSchemaSha256 = hashJson(schemas[2]);
|
|
38
|
+
|
|
39
|
+
function finish(report, state, reasons = []) {
|
|
40
|
+
report.state = state;
|
|
41
|
+
report.reasons = [...new Set([...report.reasons, ...reasons])].sort();
|
|
42
|
+
report.missing = [...new Set(report.missing)].sort();
|
|
43
|
+
if (!validateReport(report)) throw new Error("Adapter planner invariant failed");
|
|
44
|
+
return report;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return function planClientAdapter(input) {
|
|
48
|
+
const report = {
|
|
49
|
+
schemaVersion: "1.0.0", plannerVersion: "1.0.0", state: "invalid",
|
|
50
|
+
executed: false, runtimeReady: false, identity: null, intent: null,
|
|
51
|
+
observedModels: [], modelVerification: "unknown", observedEffort: null,
|
|
52
|
+
effortVerification: "unknown", reasons: [], missing: [], selectorState: null,
|
|
53
|
+
externalGates: [...GATES],
|
|
54
|
+
audit: { adapterSchemaSha256, inputSha256: null, registrySha256: null, decisionSha256: null }
|
|
55
|
+
};
|
|
56
|
+
let data;
|
|
57
|
+
try { data = copyJson(input); }
|
|
58
|
+
catch { return finish(report, "invalid", ["non-json-or-input-limit"]); }
|
|
59
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
60
|
+
return finish(report, "invalid", ["invalid-envelope"]);
|
|
61
|
+
}
|
|
62
|
+
if (data.selection && ["request", "catalog", "policy"].some((name) =>
|
|
63
|
+
data.selection[name]?.schemaVersion !== "2.0.0")) {
|
|
64
|
+
return finish(report, "invalid", ["unsupported-selection-version"]);
|
|
65
|
+
}
|
|
66
|
+
if (!validateInput(data)) return finish(report, "invalid", ["invalid-structure"]);
|
|
67
|
+
report.audit.inputSha256 = hashJson(data);
|
|
68
|
+
report.audit.registrySha256 = hashJson(data.registry);
|
|
69
|
+
report.audit.decisionSha256 = hashJson(data.decision);
|
|
70
|
+
|
|
71
|
+
const selected = select(data.selection);
|
|
72
|
+
report.selectorState = selected.state;
|
|
73
|
+
report.identity = selected.identity;
|
|
74
|
+
// Compare the WHOLE recomputed report, including constraints and audit.
|
|
75
|
+
if (canonicalJson(selected.identity) !== canonicalJson(data.decision.identity ?? null)) {
|
|
76
|
+
return finish(report, "blocked", ["decision-identity-mismatch"]);
|
|
77
|
+
}
|
|
78
|
+
if (canonicalJson(selected) !== canonicalJson(data.decision)) {
|
|
79
|
+
return finish(report, "invalid", ["decision-mismatch"]);
|
|
80
|
+
}
|
|
81
|
+
if (selected.state !== "recommended") {
|
|
82
|
+
report.missing = selected.missing.map((key) => `selection.${key}`);
|
|
83
|
+
return finish(report, selected.state, ["selection-not-recommended", ...selected.reasons]);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const { request, catalog, policy } = data.selection;
|
|
87
|
+
const { recommendation } = selected;
|
|
88
|
+
const blocks = [];
|
|
89
|
+
const block = (code) => blocks.push(code);
|
|
90
|
+
const profile = catalog.profiles.find((p) => p.profileId === recommendation.profileId);
|
|
91
|
+
if (!["tutor", "proposer", "reviewer"].includes(request.role) ||
|
|
92
|
+
request.category === "application" || data.context?.scope === "application") {
|
|
93
|
+
block("textual-scope-only");
|
|
94
|
+
}
|
|
95
|
+
if (request.mode === "tutor" && (request.authorizationContext.activeWriter !== "user" ||
|
|
96
|
+
request.authorizationContext.allowedActions.includes("apply"))) {
|
|
97
|
+
block("tutor-authorship-conflict");
|
|
98
|
+
}
|
|
99
|
+
if (profile.versionPolicy !== "pinned" ||
|
|
100
|
+
/(?:^|[-.:])(?:latest|default|auto)(?:$|[-.:])/i.test(recommendation.requestedModel)) {
|
|
101
|
+
block("model-not-pinned");
|
|
102
|
+
}
|
|
103
|
+
if (recommendation.effort === null) block("explicit-effort-required");
|
|
104
|
+
if (request.requirements.tools.length ||
|
|
105
|
+
request.requirements.inputModalities.some((value) => value !== "text") ||
|
|
106
|
+
request.requirements.outputFormats.some((value) => !["text", "markdown"].includes(value))) {
|
|
107
|
+
block("unsupported-textual-requirements");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const required = [
|
|
111
|
+
"adapter", "context.scope", "context.promptRef", "context.provenance",
|
|
112
|
+
"context.authorization", "environment.access", "environment.externalBilling",
|
|
113
|
+
"environment.controls", "environment.checkedAt", "environment.evidenceRef", "limits", "historyEvidence"
|
|
114
|
+
];
|
|
115
|
+
report.missing = required.filter((field) => getField(data, field) === undefined);
|
|
116
|
+
if (data.adapter && !sameRoute(data.adapter, recommendation)) block("adapter-route-mismatch");
|
|
117
|
+
|
|
118
|
+
// Duplicates are contradictory even if they belong to another route.
|
|
119
|
+
const records = data.registry.records;
|
|
120
|
+
if (hasDuplicates(records.map((r) => r.recordId)) ||
|
|
121
|
+
hasDuplicates(records.map((r) => JSON.stringify([
|
|
122
|
+
r.provider, r.client, r.variant, r.clientVersion
|
|
123
|
+
])))) {
|
|
124
|
+
return finish(report, "invalid", ["ambiguous-compatibility-registry"]);
|
|
125
|
+
}
|
|
126
|
+
if (records.some((r) => !sameRoute(r, r))) {
|
|
127
|
+
return finish(report, "invalid", ["invalid-registry-route"]);
|
|
128
|
+
}
|
|
129
|
+
const now = Date.parse(request.evaluationTime);
|
|
130
|
+
if (records.some((r) => Date.parse(r.evaluatedAt) > now)) {
|
|
131
|
+
return finish(report, "invalid", ["registry-evaluated-in-future"]);
|
|
132
|
+
}
|
|
133
|
+
let record;
|
|
134
|
+
if (data.adapter) {
|
|
135
|
+
record = records.find((r) => ["provider", "client", "variant", "clientVersion"]
|
|
136
|
+
.every((key) => r[key] === data.adapter[key]));
|
|
137
|
+
if (!record) block("client-version-not-admitted");
|
|
138
|
+
else {
|
|
139
|
+
if (record.status !== "evaluated") block("client-controls-not-evaluated");
|
|
140
|
+
if (!record.supportedModels.includes(recommendation.requestedModel)) block("client-model-not-admitted");
|
|
141
|
+
if (!record.efforts.includes(recommendation.effort)) block("client-effort-not-admitted");
|
|
142
|
+
if (!record.roles.includes(request.role)) block("client-role-not-admitted");
|
|
143
|
+
if (CONTROLS.some((control) => !record.controls.includes(control))) block("client-controls-incomplete");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const context = data.context;
|
|
148
|
+
if (context?.authorization) {
|
|
149
|
+
if (context.authorization.status !== "approved") block("authorization-not-declared-approved");
|
|
150
|
+
if (context.authorization.referenceId !== request.authorizationContext.referenceId) {
|
|
151
|
+
block("authorization-reference-mismatch");
|
|
152
|
+
}
|
|
153
|
+
if (!fresh(context.authorization.checkedAt, now, policy.availabilityMaxAgeSeconds)) {
|
|
154
|
+
block("authorization-evidence-not-current");
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (context?.provenance && !fresh(context.provenance.checkedAt, now, policy.availabilityMaxAgeSeconds)) {
|
|
158
|
+
block("context-evidence-not-current");
|
|
159
|
+
}
|
|
160
|
+
const environment = data.environment;
|
|
161
|
+
if (environment?.access !== undefined && environment.access !== "subscription-session") {
|
|
162
|
+
block("subscription-access-not-declared");
|
|
163
|
+
}
|
|
164
|
+
if (environment?.externalBilling !== undefined && environment.externalBilling !== "disabled") {
|
|
165
|
+
block("external-billing-not-declared-disabled");
|
|
166
|
+
}
|
|
167
|
+
if (environment?.controls && CONTROLS.some((c) => !environment.controls.includes(c))) {
|
|
168
|
+
block("preventive-controls-not-declared");
|
|
169
|
+
}
|
|
170
|
+
if (environment?.checkedAt && !fresh(environment.checkedAt, now, policy.availabilityMaxAgeSeconds)) {
|
|
171
|
+
block("environment-evidence-not-current");
|
|
172
|
+
}
|
|
173
|
+
const remainingTime = policy.maxFutureDurationSeconds - request.history.durationUsedSeconds;
|
|
174
|
+
const remainingExecutions = policy.maxFutureExecutions - request.history.executionsUsed;
|
|
175
|
+
if (data.historyEvidence) {
|
|
176
|
+
if (canonicalJson(data.historyEvidence.history) !== canonicalJson(request.history)) {
|
|
177
|
+
return finish(report, "invalid", ["history-evidence-mismatch"]);
|
|
178
|
+
}
|
|
179
|
+
if (data.historyEvidence.status !== "reconciled") block("history-not-declared-reconciled");
|
|
180
|
+
if (!fresh(data.historyEvidence.checkedAt, now, policy.availabilityMaxAgeSeconds)) {
|
|
181
|
+
block("history-evidence-not-current");
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (data.limits) {
|
|
185
|
+
if (data.limits.timeoutSeconds > remainingTime) block("timeout-exceeds-remaining-budget");
|
|
186
|
+
if (data.limits.maxLineBytes > data.limits.maxOutputBytes) block("line-limit-exceeds-output-limit");
|
|
187
|
+
}
|
|
188
|
+
if (blocks.length) return finish(report, "blocked", blocks);
|
|
189
|
+
if (report.missing.length) return finish(report, "needs-info", ["missing-adapter-information"]);
|
|
190
|
+
|
|
191
|
+
report.intent = {
|
|
192
|
+
operation: "text-response", client: data.adapter,
|
|
193
|
+
profileId: recommendation.profileId, requestedModel: recommendation.requestedModel,
|
|
194
|
+
requestedEffort: recommendation.effort,
|
|
195
|
+
arguments: [
|
|
196
|
+
{ name: "model", value: recommendation.requestedModel },
|
|
197
|
+
{ name: "effort", value: recommendation.effort }
|
|
198
|
+
],
|
|
199
|
+
input: { transport: "stdin-text", promptRef: context.promptRef, provenance: context.provenance },
|
|
200
|
+
authorizationRef: context.authorization.referenceId, compatibilityRecordId: record.recordId,
|
|
201
|
+
scope: "text-only", requiredControls: [...CONTROLS], limits: data.limits,
|
|
202
|
+
budget: {
|
|
203
|
+
executionsRemaining: remainingExecutions, durationRemainingSeconds: remainingTime,
|
|
204
|
+
history: request.history
|
|
205
|
+
},
|
|
206
|
+
automaticRetry: false, allowProviderSwitch: false, allowImplicitFallback: false
|
|
207
|
+
};
|
|
208
|
+
return finish(report, "prepared", ["declared-plan-only"]);
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function sameRoute(adapter, recommendation) {
|
|
213
|
+
const expected = ROUTES[adapter.client];
|
|
214
|
+
return !!expected && expected[0] === adapter.provider && expected[1] === adapter.variant &&
|
|
215
|
+
adapter.provider === recommendation.provider && adapter.client === recommendation.client;
|
|
216
|
+
}
|
|
217
|
+
function getField(data, field) { return field.split(".").reduce((v, key) => v?.[key], data); }
|
|
218
|
+
function hasDuplicates(values) { return new Set(values).size !== values.length; }
|
|
219
|
+
function fresh(timestamp, now, maxAge) {
|
|
220
|
+
const age = (now - Date.parse(timestamp)) / 1000;
|
|
221
|
+
return age >= 0 && age <= maxAge;
|
|
222
|
+
}
|
|
223
|
+
function isUtcTimestamp(value) {
|
|
224
|
+
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(value)) return false;
|
|
225
|
+
const time = Date.parse(value);
|
|
226
|
+
return Number.isFinite(time) && new Date(time).toISOString() === value.replace(/Z$/, ".000Z");
|
|
227
|
+
}
|
|
228
|
+
function hashJson(value) { return createHash("sha256").update(canonicalJson(value)).digest("hex"); }
|
|
229
|
+
function canonicalJson(value) {
|
|
230
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
231
|
+
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
232
|
+
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonicalJson(value[key])}`).join(",")}}`;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// This boundary accepts inert, bounded JSON, without invoking accessors/toJSON.
|
|
236
|
+
// JavaScript proxies are not JSON and are rejected before inspecting properties.
|
|
237
|
+
function copyJson(value) {
|
|
238
|
+
const ancestors = new Set();
|
|
239
|
+
let nodes = 0;
|
|
240
|
+
let bytes = 0;
|
|
241
|
+
function text(value) {
|
|
242
|
+
bytes += Buffer.byteLength(value, "utf8");
|
|
243
|
+
if (bytes > 2_000_000) throw new Error("JSON limit");
|
|
244
|
+
}
|
|
245
|
+
function visit(item, depth) {
|
|
246
|
+
if (++nodes > 30_000 || depth > 64) throw new Error("JSON limit");
|
|
247
|
+
if (typeof item === "string") { text(item); return item; }
|
|
248
|
+
if (item === null || typeof item === "boolean") return item;
|
|
249
|
+
if (typeof item === "number" && Number.isFinite(item)) return item;
|
|
250
|
+
if (typeof item !== "object" || types.isProxy(item) || ancestors.has(item)) throw new Error("Non-JSON data");
|
|
251
|
+
const array = Array.isArray(item);
|
|
252
|
+
if (array && item.length > 256) throw new Error("JSON limit");
|
|
253
|
+
if (!array && ![Object.prototype, null].includes(Object.getPrototypeOf(item))) throw new Error("Non-JSON object");
|
|
254
|
+
if (Object.getOwnPropertySymbols(item).length) throw new Error("Non-JSON keys");
|
|
255
|
+
const keys = Object.getOwnPropertyNames(item).filter((key) => !array || key !== "length");
|
|
256
|
+
if (array && (keys.length !== item.length || keys.some((key, i) => key !== String(i)))) throw new Error("Non-JSON array");
|
|
257
|
+
if (keys.length > 30_000) throw new Error("JSON limit");
|
|
258
|
+
ancestors.add(item);
|
|
259
|
+
const result = array ? [] : {};
|
|
260
|
+
for (const key of keys) {
|
|
261
|
+
if (["__proto__", "prototype", "constructor"].includes(key)) throw new Error("Unsafe JSON key");
|
|
262
|
+
const descriptor = Object.getOwnPropertyDescriptor(item, key);
|
|
263
|
+
if (!descriptor.enumerable || !("value" in descriptor)) throw new Error("Non-JSON property");
|
|
264
|
+
text(key);
|
|
265
|
+
result[key] = visit(descriptor.value, depth + 1);
|
|
266
|
+
}
|
|
267
|
+
ancestors.delete(item);
|
|
268
|
+
return result;
|
|
269
|
+
}
|
|
270
|
+
return visit(value, 0);
|
|
271
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import Ajv2020 from "ajv/dist/2020.js";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { types } from "node:util";
|
|
4
|
+
import { copyInertJson, copyBytes } from "./client-output-json.js";
|
|
5
|
+
|
|
6
|
+
export const AUTH_DIAGNOSTIC_ID = "https://agent-toolkit.local/schemas/agent-client-auth-diagnostic.schema.json";
|
|
7
|
+
const ENUMS = Object.freeze({ authMethod: Object.freeze(["none","claude.ai","oauth_token","api_key","api_key_helper","third_party"]), subscriptionType: Object.freeze(["pro","max","team","enterprise","free"]) });
|
|
8
|
+
class ScanFailure extends Error { constructor(code) { super(code); this.code = code; } }
|
|
9
|
+
const fail = code => { throw new ScanFailure(code); };
|
|
10
|
+
const white = cp => cp === 32 || cp === 9 || cp === 10 || cp === 13;
|
|
11
|
+
const digit = cp => cp >= 48 && cp <= 57;
|
|
12
|
+
const utf8Width = cp => cp < 128 ? 1 : cp < 2048 ? 2 : cp < 65536 ? 3 : 4;
|
|
13
|
+
|
|
14
|
+
/** Incremental byte grammar. Discarded values never become strings/objects. */
|
|
15
|
+
export function createAuthDiagnosticParser(schema, limits = { maxBytes: 32768, blockBytes: 32768, maxDepth: 32, maxNodes: 20000, maxKeyBytes: 256, maxKeys: 4096 }) {
|
|
16
|
+
const s = copyInertJson(schema), l = copyInertJson(limits);
|
|
17
|
+
if (s.$id !== AUTH_DIAGNOSTIC_ID) throw Error("Unsupported auth diagnostic contract");
|
|
18
|
+
const ajv = new Ajv2020({ strict: true }); ajv.addSchema(s);
|
|
19
|
+
const validLimits = ajv.compile({ $ref: AUTH_DIAGNOSTIC_ID + "#/$defs/parserLimits" });
|
|
20
|
+
const validReport = ajv.compile({ $ref: AUTH_DIAGNOSTIC_ID + "#/$defs/parserReport" });
|
|
21
|
+
if (!validLimits(l) || l.blockBytes > l.maxBytes) throw Error("Invalid auth diagnostic limits");
|
|
22
|
+
const names = ["loggedIn", "authMethod", "subscriptionType"];
|
|
23
|
+
const fields = names.map(name => ({ name, present: false, value: null }));
|
|
24
|
+
let stack = [], root = "start", token = null, bytes = 0, nodes = 0, keys = 0, peakDepth = 0, peakKeyDigests = 0, digests = 0;
|
|
25
|
+
let utfLeft = 0, utfValue = 0, utfMin = 0, error = null, closed = false;
|
|
26
|
+
|
|
27
|
+
function item() { if (++nodes > l.maxNodes) fail("auth-node-limit"); }
|
|
28
|
+
function completeValue() {
|
|
29
|
+
if (!stack.length) { root = "end"; return; }
|
|
30
|
+
const f = stack.at(-1); f.items++; f.phase = "comma-or-end"; f.selector = null;
|
|
31
|
+
}
|
|
32
|
+
function beginValue(cp, tag) {
|
|
33
|
+
item();
|
|
34
|
+
const type = cp === 123 ? "object" : cp === 91 ? "array" : cp === 34 ? "string" : cp === 116 || cp === 102 ? "boolean" : cp === 110 ? "null" : cp === 45 || digit(cp) ? "number" : null;
|
|
35
|
+
if (!type) fail("auth-invalid-json");
|
|
36
|
+
if (tag) {
|
|
37
|
+
if (tag.name === "loggedIn" ? type !== "boolean" : tag.name === "authMethod" ? type !== "string" : !["string", "null"].includes(type)) fail("auth-invalid-type");
|
|
38
|
+
tag.present = true;
|
|
39
|
+
}
|
|
40
|
+
if (type === "object" || type === "array") {
|
|
41
|
+
const f = { type, phase: type === "object" ? "key-or-end" : "value-or-end", items: 0, selector: null, tag, keys: new Set() };
|
|
42
|
+
stack.push(f); peakDepth = Math.max(peakDepth, stack.length);
|
|
43
|
+
if (stack.length > l.maxDepth) fail("auth-depth-limit");
|
|
44
|
+
} else if (type === "string") beginString(false, tag);
|
|
45
|
+
else if (type === "number") token = { kind: "number", phase: cp === 45 ? "minus" : cp === 48 ? "zero" : "integer", tag };
|
|
46
|
+
else token = { kind: "literal", word: cp === 116 ? "true" : cp === 102 ? "false" : "null", index: 1, tag };
|
|
47
|
+
}
|
|
48
|
+
function beginString(key, tag) {
|
|
49
|
+
token = { kind: "string", key, tag, escape: false, hexLeft: 0, hex: 0, high: null, needSlash: false, needU: false,
|
|
50
|
+
count: 0, keyBytes: 0, candidates: key ? (stack.length === 1 ? [...names] : []) : tag ? [...ENUMS[tag.name]] : [], digest: key ? createHash("sha256") : null };
|
|
51
|
+
}
|
|
52
|
+
function emitStringCodepoint(t, cp) {
|
|
53
|
+
if (t.key) {
|
|
54
|
+
t.keyBytes += utf8Width(cp); if (t.keyBytes > l.maxKeyBytes) fail("auth-key-bytes-limit");
|
|
55
|
+
// Only names are hashed transiently. No hash or textual decoding of values.
|
|
56
|
+
t.digest.update(Buffer.from(String.fromCodePoint(cp), "utf8"));
|
|
57
|
+
t.candidates = t.candidates.filter(n => t.count < n.length && n.charCodeAt(t.count) === cp);
|
|
58
|
+
}
|
|
59
|
+
if (!t.key && t.tag) t.candidates = t.candidates.filter(n => t.count < n.length && n.charCodeAt(t.count) === cp);
|
|
60
|
+
t.count++; // Unknown values are counted, never concatenated or decoded to text.
|
|
61
|
+
}
|
|
62
|
+
function endString(t) {
|
|
63
|
+
if (t.high !== null) fail("auth-invalid-unicode");
|
|
64
|
+
if (t.key) {
|
|
65
|
+
const f = stack.at(-1), fingerprint = t.digest.digest("hex");
|
|
66
|
+
if (f.keys.has(fingerprint)) fail("auth-duplicate-key");
|
|
67
|
+
if (++keys > l.maxKeys) fail("auth-key-limit");
|
|
68
|
+
f.keys.add(fingerprint); digests++; peakKeyDigests = Math.max(peakKeyDigests, digests);
|
|
69
|
+
const selected = t.candidates.find(n => n.length === t.count);
|
|
70
|
+
f.selector = selected ? fields.find(v => v.name === selected) : null; f.phase = "colon";
|
|
71
|
+
} else {
|
|
72
|
+
if (t.tag) {
|
|
73
|
+
const selected = t.candidates.find(n => n.length === t.count);
|
|
74
|
+
if (!selected) fail("auth-invalid-enum");
|
|
75
|
+
t.tag.value = selected; // A fixed enum label, never an arbitrary input string.
|
|
76
|
+
}
|
|
77
|
+
completeValue();
|
|
78
|
+
}
|
|
79
|
+
token = null;
|
|
80
|
+
}
|
|
81
|
+
function stringChar(cp) {
|
|
82
|
+
const t = token;
|
|
83
|
+
if (t.needSlash) { if (cp !== 92) fail("auth-invalid-unicode"); t.needSlash = false; t.needU = true; return; }
|
|
84
|
+
if (t.needU) { if (cp !== 117) fail("auth-invalid-unicode"); t.needU = false; t.hexLeft = 4; t.hex = 0; return; }
|
|
85
|
+
if (t.hexLeft) {
|
|
86
|
+
const n = cp >= 48 && cp <= 57 ? cp - 48 : cp >= 65 && cp <= 70 ? cp - 55 : cp >= 97 && cp <= 102 ? cp - 87 : -1;
|
|
87
|
+
if (n < 0) fail("auth-invalid-json"); t.hex = t.hex * 16 + n;
|
|
88
|
+
if (--t.hexLeft === 0) {
|
|
89
|
+
const u = t.hex;
|
|
90
|
+
if (t.high !== null) {
|
|
91
|
+
if (u < 0xdc00 || u > 0xdfff) fail("auth-invalid-unicode");
|
|
92
|
+
const value = 0x10000 + (t.high - 0xd800) * 1024 + u - 0xdc00; t.high = null; emitStringCodepoint(t, value);
|
|
93
|
+
} else if (u >= 0xd800 && u <= 0xdbff) { t.high = u; t.needSlash = true; }
|
|
94
|
+
else if (u >= 0xdc00 && u <= 0xdfff) fail("auth-invalid-unicode");
|
|
95
|
+
else emitStringCodepoint(t, u);
|
|
96
|
+
} return;
|
|
97
|
+
}
|
|
98
|
+
if (t.escape) {
|
|
99
|
+
t.escape = false;
|
|
100
|
+
if (cp === 117) { t.hexLeft = 4; t.hex = 0; return; }
|
|
101
|
+
const escaped = { 34: 34, 92: 92, 47: 47, 98: 8, 102: 12, 110: 10, 114: 13, 116: 9 };
|
|
102
|
+
if (!Object.hasOwn(escaped, cp)) fail("auth-invalid-json"); emitStringCodepoint(t, escaped[cp]); return;
|
|
103
|
+
}
|
|
104
|
+
if (cp === 34) endString(t);
|
|
105
|
+
else if (cp === 92) t.escape = true;
|
|
106
|
+
else { if (cp < 32) fail("auth-invalid-json"); emitStringCodepoint(t, cp); }
|
|
107
|
+
}
|
|
108
|
+
function numberChar(cp) {
|
|
109
|
+
const t = token, p = t.phase;
|
|
110
|
+
if (p === "minus") { if (!digit(cp)) fail("auth-invalid-json"); t.phase = cp === 48 ? "zero" : "integer"; return true; }
|
|
111
|
+
if (p === "zero" || p === "integer" || p === "fraction") {
|
|
112
|
+
if (digit(cp)) { if (p === "zero") fail("auth-invalid-json"); return true; }
|
|
113
|
+
if (cp === 46 && p !== "fraction") { t.phase = "dot"; return true; }
|
|
114
|
+
if (cp === 101 || cp === 69) { t.phase = "exponent"; return true; }
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
if (p === "dot") { if (!digit(cp)) fail("auth-invalid-json"); t.phase = "fraction"; return true; }
|
|
118
|
+
if (p === "exponent") { if (cp === 43 || cp === 45) { t.phase = "exponent-sign"; return true; } if (!digit(cp)) fail("auth-invalid-json"); t.phase = "exponent-digits"; return true; }
|
|
119
|
+
if (p === "exponent-sign") { if (!digit(cp)) fail("auth-invalid-json"); t.phase = "exponent-digits"; return true; }
|
|
120
|
+
if (p === "exponent-digits") return digit(cp);
|
|
121
|
+
fail("auth-invalid-json");
|
|
122
|
+
}
|
|
123
|
+
function closeContainer(cp) {
|
|
124
|
+
const f = stack.at(-1);
|
|
125
|
+
if (cp !== (f.type === "object" ? 125 : 93)) fail("auth-invalid-json");
|
|
126
|
+
digests -= f.keys.size; stack.pop(); completeValue();
|
|
127
|
+
}
|
|
128
|
+
function grammar(cp) {
|
|
129
|
+
if (token) {
|
|
130
|
+
if (token.kind === "string") { stringChar(cp); return; }
|
|
131
|
+
if (token.kind === "literal") {
|
|
132
|
+
const t = token;
|
|
133
|
+
if (cp !== t.word.charCodeAt(t.index++)) fail("auth-invalid-json");
|
|
134
|
+
if (t.index === t.word.length) {
|
|
135
|
+
if (t.tag) t.tag.value = t.word === "null" ? null : t.word === "true";
|
|
136
|
+
token = null; completeValue();
|
|
137
|
+
} return;
|
|
138
|
+
}
|
|
139
|
+
if (numberChar(cp)) return;
|
|
140
|
+
token = null; completeValue(); // Re-process the number's delimiter below.
|
|
141
|
+
}
|
|
142
|
+
if (white(cp)) return;
|
|
143
|
+
if (root === "end") fail("auth-invalid-json");
|
|
144
|
+
if (!stack.length) { if (cp !== 123) fail("auth-root-object-required"); root = "running"; beginValue(cp, null); return; }
|
|
145
|
+
const f = stack.at(-1);
|
|
146
|
+
if (f.phase === "key-or-end" || f.phase === "key-only") {
|
|
147
|
+
if (cp === 125 && f.phase === "key-or-end") { closeContainer(cp); return; }
|
|
148
|
+
if (cp !== 34) fail("auth-invalid-json"); item(); beginString(true, null); return;
|
|
149
|
+
}
|
|
150
|
+
if (f.phase === "colon") { if (cp !== 58) fail("auth-invalid-json"); f.phase = "value"; return; }
|
|
151
|
+
if (f.phase === "value-or-end" && cp === 93) { closeContainer(cp); return; }
|
|
152
|
+
if (f.phase === "value" || f.phase === "value-or-end" || f.phase === "value-only") { beginValue(cp, f.selector); return; }
|
|
153
|
+
if (f.phase === "comma-or-end") {
|
|
154
|
+
if (cp === 44) f.phase = f.type === "object" ? "key-only" : "value-only";
|
|
155
|
+
else closeContainer(cp);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
fail("auth-invalid-json");
|
|
159
|
+
}
|
|
160
|
+
function byte(b) {
|
|
161
|
+
if (utfLeft) {
|
|
162
|
+
if ((b & 0xc0) !== 0x80) fail("auth-invalid-utf8"); utfValue = utfValue * 64 + (b & 63);
|
|
163
|
+
if (--utfLeft === 0) {
|
|
164
|
+
if (utfValue < utfMin || utfValue > 0x10ffff || utfValue >= 0xd800 && utfValue <= 0xdfff) fail("auth-invalid-utf8");
|
|
165
|
+
grammar(utfValue);
|
|
166
|
+
} return;
|
|
167
|
+
}
|
|
168
|
+
if (b < 128) grammar(b);
|
|
169
|
+
else if (b >= 0xc2 && b <= 0xdf) { utfLeft = 1; utfValue = b & 31; utfMin = 128; }
|
|
170
|
+
else if (b >= 0xe0 && b <= 0xef) { utfLeft = 2; utfValue = b & 15; utfMin = 2048; }
|
|
171
|
+
else if (b >= 0xf0 && b <= 0xf4) { utfLeft = 3; utfValue = b & 7; utfMin = 65536; }
|
|
172
|
+
else fail("auth-invalid-utf8");
|
|
173
|
+
}
|
|
174
|
+
function abandon(e) { error = e instanceof ScanFailure ? e.code : "auth-block-invalid"; stack = []; token = null; digests = 0; }
|
|
175
|
+
function report(final = false) {
|
|
176
|
+
const ok = final && error === null && root === "end";
|
|
177
|
+
const loggedIn = fields[0].value, authMethod = fields[1].value, subscriptionType = fields[2].value;
|
|
178
|
+
const classification = !loggedIn ? "signed-out" : ["api_key", "api_key_helper", "oauth_token", "third_party"].includes(authMethod) || subscriptionType === "free" ? "incompatible" :
|
|
179
|
+
authMethod === "claude.ai" && ["pro", "max", "team", "enterprise"].includes(subscriptionType) ? "compatible-declared" : "unresolved";
|
|
180
|
+
const output = { scope: "auth-diagnostic-provided-bytes", state: ok ? "observed" : error ? "invalid" : "incomplete",
|
|
181
|
+
projection: ok ? { loggedIn, authMethod, subscriptionType, classification } : null,
|
|
182
|
+
nativeExecuted: false, inferenceRequested: false, runtimeReady: false, verifiedAdmission: false, externalBillingVerified: false,
|
|
183
|
+
stats: { bytes, nodes, keys, peakDepth, peakKeyDigests, retainedRawBytes: 0, retainedUnselectedValueTextBytes: 0,
|
|
184
|
+
retainedApprovedScalarCount: fields.filter(f => f.present && f.value !== null).length },
|
|
185
|
+
reason: ok ? "auth-observed" : error ?? "auth-incomplete" };
|
|
186
|
+
if (!validReport(output)) throw Error("Auth parser report invariant failed");
|
|
187
|
+
return output;
|
|
188
|
+
}
|
|
189
|
+
return Object.freeze({
|
|
190
|
+
push(input) {
|
|
191
|
+
if (closed) { abandon(new ScanFailure("auth-closed")); return report(false); }
|
|
192
|
+
if (error) return report(false);
|
|
193
|
+
try {
|
|
194
|
+
if (types.isProxy(input) || !types.isUint8Array(input)) fail("auth-block-invalid");
|
|
195
|
+
const b = copyBytes(input, l.blockBytes); bytes += b.length;
|
|
196
|
+
if (bytes > l.maxBytes) fail("auth-byte-limit");
|
|
197
|
+
for (let i = 0; i < b.length; i++) byte(b[i]);
|
|
198
|
+
} catch (e) { abandon(e); }
|
|
199
|
+
return report(false);
|
|
200
|
+
},
|
|
201
|
+
abort() { if (!closed) abandon(new ScanFailure("auth-aborted")); return report(false); },
|
|
202
|
+
finish(exitCode) {
|
|
203
|
+
if (closed) { abandon(new ScanFailure("auth-closed")); return report(false); }
|
|
204
|
+
closed = true;
|
|
205
|
+
if (!error && (utfLeft || token || stack.length || root !== "end")) abandon(new ScanFailure("auth-truncated"));
|
|
206
|
+
if (!error && (!fields[0].present || !fields[1].present)) abandon(new ScanFailure("auth-required-field"));
|
|
207
|
+
if (!error && exitCode !== (fields[0].value ? 0 : 1)) abandon(new ScanFailure("auth-exit-mismatch"));
|
|
208
|
+
return report(true);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|