zob-harness 0.1.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/.pi/adapters/registry.json +103 -0
- package/.pi/agents/architecture-cartographer.md +53 -0
- package/.pi/agents/chief-vision.md +39 -0
- package/.pi/agents/clarifier.md +58 -0
- package/.pi/agents/context-steward.md +52 -0
- package/.pi/agents/doc-steward.md +34 -0
- package/.pi/agents/explore.md +49 -0
- package/.pi/agents/factory.md +41 -0
- package/.pi/agents/implementer.md +44 -0
- package/.pi/agents/librarian.md +32 -0
- package/.pi/agents/oracle-merge.md +50 -0
- package/.pi/agents/oracle.md +55 -0
- package/.pi/agents/pattern-miner.md +53 -0
- package/.pi/agents/planner.md +39 -0
- package/.pi/agents/project-dna-golden-evaluator.md +32 -0
- package/.pi/agents/project-dna-ontology-steward.md +30 -0
- package/.pi/agents/project-dna-oracle.md +56 -0
- package/.pi/agents/project-dna-orchestrator.md +60 -0
- package/.pi/agents/project-dna-query-steward.md +38 -0
- package/.pi/agents/project-dna-safety-preflight.md +54 -0
- package/.pi/agents/project-dna-test-linker.md +27 -0
- package/.pi/agents/qa.md +38 -0
- package/.pi/agents/refactor-cartographer.md +28 -0
- package/.pi/agents/refactor-mover.md +31 -0
- package/.pi/agents/refactor-oracle.md +49 -0
- package/.pi/agents/repo-scout.md +60 -0
- package/.pi/agents/sample-architect.md +48 -0
- package/.pi/agents/specifier.md +57 -0
- package/.pi/agents/symbol-range-curator.md +41 -0
- package/.pi/agents/synthesis.md +52 -0
- package/.pi/agents/temp-agent-creator.md +35 -0
- package/.pi/autonomy-policy.json +67 -0
- package/.pi/budget-policy.json +54 -0
- package/.pi/capabilities/zob-public-runtime-capabilities.json +1700 -0
- package/.pi/chains/explore-plan-oracle.json +78 -0
- package/.pi/chains/explore-spec-clarify-plan-oracle.json +64 -0
- package/.pi/chains/explore-spec-plan-oracle.json +53 -0
- package/.pi/chains/spec-clarify-plan-oracle.json +53 -0
- package/.pi/chains/spec-factory-oracle.json +42 -0
- package/.pi/chains/spec-plan-oracle.json +42 -0
- package/.pi/compute-profiles/defaults.json +19 -0
- package/.pi/compute-profiles/overrides.json +13 -0
- package/.pi/compute-profiles/risk-rules.json +16 -0
- package/.pi/daemon-policy.json +80 -0
- package/.pi/damage-control-rules.json +45 -0
- package/.pi/extensions/zob-child-safety/index.ts +212 -0
- package/.pi/extensions/zob-harness/AGENTS.md +28 -0
- package/.pi/extensions/zob-harness/index.ts +391 -0
- package/.pi/extensions/zob-harness/src/AGENTS.md +25 -0
- package/.pi/extensions/zob-harness/src/agents.ts +82 -0
- package/.pi/extensions/zob-harness/src/autonomous-runtime.ts +2912 -0
- package/.pi/extensions/zob-harness/src/autonomy-readiness.ts +778 -0
- package/.pi/extensions/zob-harness/src/budget-policy.ts +308 -0
- package/.pi/extensions/zob-harness/src/capabilities.ts +249 -0
- package/.pi/extensions/zob-harness/src/child-runner.ts +249 -0
- package/.pi/extensions/zob-harness/src/chronicle.ts +262 -0
- package/.pi/extensions/zob-harness/src/compute-profile.ts +602 -0
- package/.pi/extensions/zob-harness/src/compute-workflow-shape.ts +168 -0
- package/.pi/extensions/zob-harness/src/coms-v2/AGENTS.md +16 -0
- package/.pi/extensions/zob-harness/src/coms-v2/envelope.ts +121 -0
- package/.pi/extensions/zob-harness/src/coms-v2/identity.ts +53 -0
- package/.pi/extensions/zob-harness/src/coms-v2/ledger-bridge.ts +67 -0
- package/.pi/extensions/zob-harness/src/coms-v2/local-transport.ts +147 -0
- package/.pi/extensions/zob-harness/src/coms-v2/pending-replies.ts +80 -0
- package/.pi/extensions/zob-harness/src/coms-v2/policy.ts +125 -0
- package/.pi/extensions/zob-harness/src/coms-v2/presence.ts +55 -0
- package/.pi/extensions/zob-harness/src/coms-v2/registry.ts +113 -0
- package/.pi/extensions/zob-harness/src/coms-v2/response-capture.ts +50 -0
- package/.pi/extensions/zob-harness/src/coms-v2/transcript-capture.ts +164 -0
- package/.pi/extensions/zob-harness/src/coms-v2/types.ts +149 -0
- package/.pi/extensions/zob-harness/src/coms-v2/zpeer-profile.ts +140 -0
- package/.pi/extensions/zob-harness/src/coms-v2/zpeer.ts +452 -0
- package/.pi/extensions/zob-harness/src/constants.ts +108 -0
- package/.pi/extensions/zob-harness/src/context-gbrain.ts +465 -0
- package/.pi/extensions/zob-harness/src/daemon-policy.ts +223 -0
- package/.pi/extensions/zob-harness/src/daemon-readiness.ts +134 -0
- package/.pi/extensions/zob-harness/src/daemon-runtime.ts +393 -0
- package/.pi/extensions/zob-harness/src/factory/AGENTS.md +24 -0
- package/.pi/extensions/zob-harness/src/factory/agentic-plan.ts +65 -0
- package/.pi/extensions/zob-harness/src/factory/quarantine.ts +319 -0
- package/.pi/extensions/zob-harness/src/factory/run.ts +520 -0
- package/.pi/extensions/zob-harness/src/factory/validation.ts +454 -0
- package/.pi/extensions/zob-harness/src/factory-selector.ts +318 -0
- package/.pi/extensions/zob-harness/src/full-autonomy-test.ts +226 -0
- package/.pi/extensions/zob-harness/src/git-ops.ts +868 -0
- package/.pi/extensions/zob-harness/src/goal-room.ts +178 -0
- package/.pi/extensions/zob-harness/src/goal-runtime.ts +1569 -0
- package/.pi/extensions/zob-harness/src/goal-todo-imports.ts +111 -0
- package/.pi/extensions/zob-harness/src/goal-todo-types.ts +231 -0
- package/.pi/extensions/zob-harness/src/goal-todos.ts +1410 -0
- package/.pi/extensions/zob-harness/src/goal.ts +152 -0
- package/.pi/extensions/zob-harness/src/governed-requests.ts +436 -0
- package/.pi/extensions/zob-harness/src/interactive-autonomy.ts +595 -0
- package/.pi/extensions/zob-harness/src/launch-apply.ts +313 -0
- package/.pi/extensions/zob-harness/src/merge-queue.ts +290 -0
- package/.pi/extensions/zob-harness/src/mission-control.ts +573 -0
- package/.pi/extensions/zob-harness/src/model-availability.ts +52 -0
- package/.pi/extensions/zob-harness/src/model-routing.ts +429 -0
- package/.pi/extensions/zob-harness/src/orchestration/AGENTS.md +23 -0
- package/.pi/extensions/zob-harness/src/orchestration/adaptive-delegation.ts +547 -0
- package/.pi/extensions/zob-harness/src/orchestration/adaptive-workflow.ts +585 -0
- package/.pi/extensions/zob-harness/src/orchestration/lead-plan.ts +192 -0
- package/.pi/extensions/zob-harness/src/orchestration/plan.ts +168 -0
- package/.pi/extensions/zob-harness/src/orchestration/room.ts +346 -0
- package/.pi/extensions/zob-harness/src/orchestration/run.ts +134 -0
- package/.pi/extensions/zob-harness/src/orchestration/supervised-readonly.ts +1147 -0
- package/.pi/extensions/zob-harness/src/orchestration/widget-readers.ts +132 -0
- package/.pi/extensions/zob-harness/src/output-contracts.ts +656 -0
- package/.pi/extensions/zob-harness/src/project-dna.ts +533 -0
- package/.pi/extensions/zob-harness/src/promotion/AGENTS.md +24 -0
- package/.pi/extensions/zob-harness/src/promotion/candidate.ts +336 -0
- package/.pi/extensions/zob-harness/src/promotion/coms.ts +127 -0
- package/.pi/extensions/zob-harness/src/promotion/documentation.ts +142 -0
- package/.pi/extensions/zob-harness/src/promotion/factory.ts +107 -0
- package/.pi/extensions/zob-harness/src/promotion/ledger.ts +2 -0
- package/.pi/extensions/zob-harness/src/promotion/temp-agent.ts +151 -0
- package/.pi/extensions/zob-harness/src/promotion/types.ts +149 -0
- package/.pi/extensions/zob-harness/src/promotion/validate.ts +6 -0
- package/.pi/extensions/zob-harness/src/promotion/write-lane.ts +162 -0
- package/.pi/extensions/zob-harness/src/prompt-packs.ts +239 -0
- package/.pi/extensions/zob-harness/src/queue.ts +386 -0
- package/.pi/extensions/zob-harness/src/rules.ts +225 -0
- package/.pi/extensions/zob-harness/src/runtime/AGENTS.md +26 -0
- package/.pi/extensions/zob-harness/src/runtime/adaptive-zmode.ts +116 -0
- package/.pi/extensions/zob-harness/src/runtime/auto-compaction.ts +715 -0
- package/.pi/extensions/zob-harness/src/runtime/commands.ts +1315 -0
- package/.pi/extensions/zob-harness/src/runtime/compaction-policy.ts +516 -0
- package/.pi/extensions/zob-harness/src/runtime/delegation-click-markers.ts +141 -0
- package/.pi/extensions/zob-harness/src/runtime/delegation-feed.ts +415 -0
- package/.pi/extensions/zob-harness/src/runtime/delegation-markdown.ts +97 -0
- package/.pi/extensions/zob-harness/src/runtime/delegation-monitor.ts +553 -0
- package/.pi/extensions/zob-harness/src/runtime/delegation-mouse.ts +205 -0
- package/.pi/extensions/zob-harness/src/runtime/delegation-overlay.ts +434 -0
- package/.pi/extensions/zob-harness/src/runtime/events.ts +736 -0
- package/.pi/extensions/zob-harness/src/runtime/goal-todo-overlay.ts +214 -0
- package/.pi/extensions/zob-harness/src/runtime/mode-intent.ts +144 -0
- package/.pi/extensions/zob-harness/src/runtime/plan-capture.ts +270 -0
- package/.pi/extensions/zob-harness/src/runtime/state.ts +403 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-autonomous.ts +117 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-compute.ts +136 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-coms.ts +365 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-context.ts +70 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-delegation.ts +1854 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-factory.ts +810 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-goal-room.ts +46 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-governed-requests.ts +38 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-merge-queue.ts +61 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-mission-control.ts +77 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-orchestration.ts +106 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-project-dna.ts +123 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-worker-pool.ts +93 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-workspace-claims.ts +62 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-zcommit.ts +147 -0
- package/.pi/extensions/zob-harness/src/runtime/widget.ts +353 -0
- package/.pi/extensions/zob-harness/src/runtime/zobHarness.ts +60 -0
- package/.pi/extensions/zob-harness/src/safety.ts +338 -0
- package/.pi/extensions/zob-harness/src/sandbox.ts +1508 -0
- package/.pi/extensions/zob-harness/src/schemas-project-dna.ts +47 -0
- package/.pi/extensions/zob-harness/src/schemas.ts +695 -0
- package/.pi/extensions/zob-harness/src/telemetry.ts +373 -0
- package/.pi/extensions/zob-harness/src/topology/AGENTS.md +22 -0
- package/.pi/extensions/zob-harness/src/topology/chains.ts +236 -0
- package/.pi/extensions/zob-harness/src/topology/coms.ts +211 -0
- package/.pi/extensions/zob-harness/src/topology/orchestration-profiles.ts +204 -0
- package/.pi/extensions/zob-harness/src/topology/teams.ts +113 -0
- package/.pi/extensions/zob-harness/src/types/core.ts +47 -0
- package/.pi/extensions/zob-harness/src/types.ts +939 -0
- package/.pi/extensions/zob-harness/src/utils/AGENTS.md +22 -0
- package/.pi/extensions/zob-harness/src/utils/formatting.ts +34 -0
- package/.pi/extensions/zob-harness/src/utils/hashing.ts +11 -0
- package/.pi/extensions/zob-harness/src/utils/json.ts +28 -0
- package/.pi/extensions/zob-harness/src/utils/paths.ts +54 -0
- package/.pi/extensions/zob-harness/src/utils/records.ts +25 -0
- package/.pi/extensions/zob-harness/src/utils/resources.ts +38 -0
- package/.pi/extensions/zob-harness/src/worker-pool.ts +672 -0
- package/.pi/extensions/zob-harness/src/workspace-claims.ts +297 -0
- package/.pi/extensions/zob-switch/index.ts +180 -0
- package/.pi/factories/budget-preflight-dry-run/batch-manifest.json +59 -0
- package/.pi/factories/budget-preflight-dry-run/factory.json +94 -0
- package/.pi/factories/budget-preflight-dry-run/pilot-manifest.json +50 -0
- package/.pi/factories/budget-preflight-dry-run/smoke-manifest.json +43 -0
- package/.pi/factories/code-review-matrix/batch-manifest.json +61 -0
- package/.pi/factories/code-review-matrix/factory.json +163 -0
- package/.pi/factories/code-review-matrix/pilot-manifest.json +41 -0
- package/.pi/factories/code-review-matrix/smoke-manifest.json +35 -0
- package/.pi/factories/factory-forge/batch-manifest.json +56 -0
- package/.pi/factories/factory-forge/factory.json +84 -0
- package/.pi/factories/factory-forge/pilot-manifest.json +32 -0
- package/.pi/factories/factory-forge/smoke-manifest.json +19 -0
- package/.pi/factories/opencode-pattern-canonizer/batch-manifest.json +54 -0
- package/.pi/factories/opencode-pattern-canonizer/factory.json +86 -0
- package/.pi/factories/opencode-pattern-canonizer/pilot-manifest.json +39 -0
- package/.pi/factories/opencode-pattern-canonizer/smoke-manifest.json +26 -0
- package/.pi/factories/project-dna/README.md +182 -0
- package/.pi/factories/project-dna/batch-manifest.json +37 -0
- package/.pi/factories/project-dna/example-project-dna-manifest-v2.json +80 -0
- package/.pi/factories/project-dna/example-project-dna-manifest.json +58 -0
- package/.pi/factories/project-dna/factory.json +131 -0
- package/.pi/factories/project-dna/golden-cases-smoke.json +62 -0
- package/.pi/factories/project-dna/pi-agentic-ontology.json +88 -0
- package/.pi/factories/project-dna/pilot-manifest.json +32 -0
- package/.pi/factories/project-dna/schemas/benchmark-suite.schema.json +27 -0
- package/.pi/factories/project-dna/schemas/code-knowledge-graph.schema.json +97 -0
- package/.pi/factories/project-dna/schemas/context-pack.schema.json +43 -0
- package/.pi/factories/project-dna/schemas/golden-case.schema.json +36 -0
- package/.pi/factories/project-dna/schemas/manifest-v2.schema.json +128 -0
- package/.pi/factories/project-dna/schemas/manifest.schema.json +77 -0
- package/.pi/factories/project-dna/schemas/ontology.schema.json +45 -0
- package/.pi/factories/project-dna/schemas/project-fingerprint.schema.json +28 -0
- package/.pi/factories/project-dna/schemas/query-steward-report.schema.json +52 -0
- package/.pi/factories/project-dna/smoke-manifest.json +27 -0
- package/.pi/factories/roadmap-smoke-lots/batch-manifest.json +49 -0
- package/.pi/factories/roadmap-smoke-lots/factory.json +89 -0
- package/.pi/factories/roadmap-smoke-lots/pilot-manifest.json +50 -0
- package/.pi/factories/roadmap-smoke-lots/smoke-manifest.json +35 -0
- package/.pi/git-policy.json +120 -0
- package/.pi/mission-control/zob_coms_transport.json +64 -0
- package/.pi/model-catalog.example.json +345 -0
- package/.pi/model-economy.example.json +196 -0
- package/.pi/model-routing.json +86 -0
- package/.pi/orchestrations/adaptive-chief-vision.json +193 -0
- package/.pi/orchestrations/ceo-feature-build.json +182 -0
- package/.pi/orchestrations/readonly-dynamic-smoke.json +75 -0
- package/.pi/output-contracts/agent-event.v1.json +19 -0
- package/.pi/output-contracts/base.v1.json +24 -0
- package/.pi/output-contracts/brain-lookup.v1.json +21 -0
- package/.pi/output-contracts/clarification.v1.json +21 -0
- package/.pi/output-contracts/context-pack.v1.json +20 -0
- package/.pi/output-contracts/context-request.v1.json +21 -0
- package/.pi/output-contracts/context-steward.v1.json +19 -0
- package/.pi/output-contracts/context-writeback-proposal.v1.json +18 -0
- package/.pi/output-contracts/delegation-request.v1.json +21 -0
- package/.pi/output-contracts/explore.v1.json +52 -0
- package/.pi/output-contracts/factory.v1.json +48 -0
- package/.pi/output-contracts/guidance-steward.v1.json +18 -0
- package/.pi/output-contracts/implement.v1.json +40 -0
- package/.pi/output-contracts/launch-authorization.v1.json +21 -0
- package/.pi/output-contracts/lead-plan.v1.json +22 -0
- package/.pi/output-contracts/mission-readiness.v1.json +20 -0
- package/.pi/output-contracts/oracle-merge.v1.json +44 -0
- package/.pi/output-contracts/oracle-request.v1.json +20 -0
- package/.pi/output-contracts/oracle.v1.json +44 -0
- package/.pi/output-contracts/orchestration-profile.v1.json +22 -0
- package/.pi/output-contracts/plan.v1.json +48 -0
- package/.pi/output-contracts/prompt-pack.v1.json +20 -0
- package/.pi/output-contracts/qa.v1.json +40 -0
- package/.pi/output-contracts/research.v1.json +36 -0
- package/.pi/output-contracts/spec.v1.json +22 -0
- package/.pi/output-contracts/synthesis.v1.json +44 -0
- package/.pi/output-contracts/temp-agent-card.v1.json +23 -0
- package/.pi/output-contracts/todo-child-result.v1.json +20 -0
- package/.pi/output-contracts/todo-child-result.v2.json +22 -0
- package/.pi/output-contracts/todo-claim-validation.v1.json +22 -0
- package/.pi/output-contracts/todo-split-request.v1.json +20 -0
- package/.pi/prompts/adaptive-workflow.md +63 -0
- package/.pi/prompts/autonomous-runtime.md +15 -0
- package/.pi/prompts/benchmark-contender.md +15 -0
- package/.pi/prompts/benchmark-judge.md +19 -0
- package/.pi/prompts/clarify-spec.md +20 -0
- package/.pi/prompts/compute-plan.md +36 -0
- package/.pi/prompts/compute-preview.md +42 -0
- package/.pi/prompts/contract.md +29 -0
- package/.pi/prompts/explore.md +13 -0
- package/.pi/prompts/factory-run.md +36 -0
- package/.pi/prompts/factory.md +20 -0
- package/.pi/prompts/implement.md +27 -0
- package/.pi/prompts/model-catalog.md +68 -0
- package/.pi/prompts/model-economy.md +64 -0
- package/.pi/prompts/oracle-merge.md +18 -0
- package/.pi/prompts/oracle.md +13 -0
- package/.pi/prompts/orchestrator.md +48 -0
- package/.pi/prompts/parallel-review.md +21 -0
- package/.pi/prompts/plan.md +21 -0
- package/.pi/prompts/project-dna.md +90 -0
- package/.pi/prompts/refactor-oracle.md +23 -0
- package/.pi/prompts/refactor-slice.md +24 -0
- package/.pi/prompts/research.md +20 -0
- package/.pi/prompts/spec.md +19 -0
- package/.pi/prompts/synthesis.md +18 -0
- package/.pi/rules/always.md +38 -0
- package/.pi/rules/docs.md +32 -0
- package/.pi/rules/factory.md +44 -0
- package/.pi/rules/oracle.md +34 -0
- package/.pi/rules/orchestration.md +44 -0
- package/.pi/rules/project.md +34 -0
- package/.pi/rules/prompts.md +43 -0
- package/.pi/rules/runtime.md +43 -0
- package/.pi/rules/sandbox.md +43 -0
- package/.pi/settings.json +28 -0
- package/.pi/skills/zob-agentic-access/SKILL.md +20 -0
- package/.pi/skills/zob-autonomous-runtime/SKILL.md +41 -0
- package/.pi/skills/zob-commit/SKILL.md +79 -0
- package/.pi/skills/zob-compaction-policy/SKILL.md +92 -0
- package/.pi/skills/zob-compute-profile/SKILL.md +108 -0
- package/.pi/skills/zob-coms-safety/SKILL.md +54 -0
- package/.pi/skills/zob-coms-v2-live/SKILL.md +47 -0
- package/.pi/skills/zob-delegation-routing/SKILL.md +82 -0
- package/.pi/skills/zob-factory/SKILL.md +28 -0
- package/.pi/skills/zob-goal-todo-tree/SKILL.md +279 -0
- package/.pi/skills/zob-harness/SKILL.md +68 -0
- package/.pi/skills/zob-mission-control-coms/SKILL.md +39 -0
- package/.pi/skills/zob-oracle/SKILL.md +21 -0
- package/.pi/skills/zob-owner-pool-drill-writer/SKILL.md +244 -0
- package/.pi/skills/zob-owner-pool-launcher/SKILL.md +261 -0
- package/.pi/skills/zob-project-dna/SKILL.md +275 -0
- package/.pi/skills/zob-sandbox/SKILL.md +29 -0
- package/.pi/skills/zob-spec/SKILL.md +25 -0
- package/.pi/skills/zob-split-refactor/SKILL.md +39 -0
- package/.pi/skills/zob-tool-router/SKILL.md +104 -0
- package/.pi/teams/zob-core.json +122 -0
- package/AGENTS.md +89 -0
- package/CONTRIBUTING.md +56 -0
- package/LICENSE +21 -0
- package/README.md +360 -0
- package/SECURITY.md +35 -0
- package/SOURCE_INDEX.md +46 -0
- package/package.json +135 -0
- package/scripts/README.md +57 -0
- package/scripts/autonomy/mission-readiness-secret-smoke.mjs +90 -0
- package/scripts/compute-profile/plan-workflow.mjs +85 -0
- package/scripts/compute-profile/preview.mjs +242 -0
- package/scripts/compute-profile/regression-smoke.mjs +38 -0
- package/scripts/compute-profile/summarize.mjs +72 -0
- package/scripts/compute-profile/validate-policy.mjs +50 -0
- package/scripts/compute-profile/validate-preview.mjs +95 -0
- package/scripts/compute-profile/validate-workflow.mjs +58 -0
- package/scripts/git-ops/commit-policy-smoke.mjs +221 -0
- package/scripts/goal-todo/child-goal-ref-smoke.mjs +252 -0
- package/scripts/harness-switch/static-smoke.mjs +43 -0
- package/scripts/model-catalog/validate-economy.mjs +223 -0
- package/scripts/model-catalog/validate.mjs +199 -0
- package/scripts/package-surface/validate-script-refs.mjs +190 -0
- package/scripts/path-policy/validate-smoke.mjs +103 -0
- package/scripts/project-dna/bench-smoke.mjs +217 -0
- package/scripts/project-dna/build-capsules.mjs +207 -0
- package/scripts/project-dna/build-sample-spec.mjs +140 -0
- package/scripts/project-dna/emit-golden-cases.mjs +75 -0
- package/scripts/project-dna/emit-ontology.mjs +75 -0
- package/scripts/project-dna/generate-sample.mjs +302 -0
- package/scripts/project-dna/oracle-review-smoke.mjs +157 -0
- package/scripts/project-dna/plan-workflow.mjs +289 -0
- package/scripts/project-dna/query-context.mjs +276 -0
- package/scripts/project-dna/query-steward.mjs +149 -0
- package/scripts/project-dna/scan.mjs +553 -0
- package/scripts/project-dna/validate-5of5.mjs +159 -0
- package/scripts/project-dna/validate-golden-cases.mjs +78 -0
- package/scripts/project-dna/validate-ontology.mjs +97 -0
- package/scripts/project-dna/validate-sample-project.mjs +105 -0
- package/scripts/project-dna/validate-scaffold.mjs +383 -0
- package/scripts/project-dna/validate-scan-artifacts.mjs +187 -0
- package/scripts/project-dna/validate-workflow.mjs +166 -0
- package/scripts/start-pi.sh +4 -0
- package/scripts/worker-pool/static-smoke.mjs +54 -0
- package/scripts/zpeer-local-e2e-smoke.mjs +395 -0
- package/scripts/zpeer-static-smoke.mjs +129 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { readZobComsV2Policy } from "../coms-v2/policy.js";
|
|
3
|
+
import { readZobLiveRegistrySnapshot } from "../coms-v2/registry.js";
|
|
4
|
+
import { peerAliasInRoom, refreshZpeerSelf, safeZpeerAlias, safeZpeerRoomId, sendZpeerPrompt, type ZpeerSendMode, type ZpeerSendResult } from "../coms-v2/zpeer.js";
|
|
5
|
+
import { buildZobLiveEnvelope } from "../coms-v2/envelope.js";
|
|
6
|
+
import { sendZobLocalEnvelope } from "../coms-v2/local-transport.js";
|
|
7
|
+
import { appendLiveDeliveredStatus, appendLiveErrorStatus, appendLiveSendRequestedRef } from "../coms-v2/ledger-bridge.js";
|
|
8
|
+
import { writeZobComsRedactedCapture } from "../coms-v2/transcript-capture.js";
|
|
9
|
+
import type { TeamDefinition } from "../types.js";
|
|
10
|
+
import { sha256 } from "../utils/hashing.js";
|
|
11
|
+
import {
|
|
12
|
+
ZobComsAckParams,
|
|
13
|
+
ZobComsAwaitParams,
|
|
14
|
+
ZobComsGetParams,
|
|
15
|
+
ZobComsListParams,
|
|
16
|
+
ZobComsReplyParams,
|
|
17
|
+
ZobComsSendParams,
|
|
18
|
+
ZobComsStatusParams,
|
|
19
|
+
ZpeerAskParams,
|
|
20
|
+
} from "../schemas.js";
|
|
21
|
+
import {
|
|
22
|
+
ackZobComsMessage,
|
|
23
|
+
appendZobComsMessage,
|
|
24
|
+
awaitZobComsMessage,
|
|
25
|
+
getZobComsMessage,
|
|
26
|
+
listZobComsMessages,
|
|
27
|
+
replyZobComsMessage,
|
|
28
|
+
transitionZobComsStatus,
|
|
29
|
+
} from "../topology/coms.js";
|
|
30
|
+
import { loadTeamDefinition, validateTeamDefinition } from "../topology/teams.js";
|
|
31
|
+
import type { HarnessRuntimeState } from "./state.js";
|
|
32
|
+
|
|
33
|
+
const SHA256_HEX = /^[a-f0-9]{64}$/i;
|
|
34
|
+
|
|
35
|
+
function breakGlassApprovalPresent(): boolean {
|
|
36
|
+
return SHA256_HEX.test(process.env.ZOB_COMS_BREAK_GLASS_APPROVAL_HASH ?? "");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function ledgerMutationPolicyBlock(repoRoot: string, toolName: string): { status: "blocked"; reason: string; text: string } | undefined {
|
|
40
|
+
const policy = readZobComsV2Policy(repoRoot);
|
|
41
|
+
if (policy.mode === "off") return { status: "blocked", reason: "transport_off", text: `${toolName} blocked: ZOB coms transport mode is off` };
|
|
42
|
+
if (policy.mode === "break_glass_ledger_only" && !breakGlassApprovalPresent()) return { status: "blocked", reason: "break_glass_approval_missing", text: `${toolName} blocked: break_glass_ledger_only requires ZOB_COMS_BREAK_GLASS_APPROVAL_HASH` };
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
type ZobComsSendToolParams = {
|
|
47
|
+
runId: string;
|
|
48
|
+
sender: string;
|
|
49
|
+
receiver: string;
|
|
50
|
+
kind?: string;
|
|
51
|
+
taskId?: string;
|
|
52
|
+
taskHash?: string;
|
|
53
|
+
transientBody?: string;
|
|
54
|
+
outputHash?: string;
|
|
55
|
+
status?: string;
|
|
56
|
+
team?: string;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
type ZpeerAskToolParams = {
|
|
60
|
+
targetAlias: string;
|
|
61
|
+
message: string;
|
|
62
|
+
roomId?: string;
|
|
63
|
+
mode?: ZpeerSendMode;
|
|
64
|
+
reason?: string;
|
|
65
|
+
timeoutMs?: number;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
function boundedZpeerAskTimeoutMs(mode: ZpeerSendMode, raw: number | undefined): number {
|
|
69
|
+
const fallback = mode === "long" ? 30 * 60 * 1000 : 10 * 60 * 1000;
|
|
70
|
+
const cap = mode === "long" ? 30 * 60 * 1000 : 10 * 60 * 1000;
|
|
71
|
+
return Math.max(1_000, Math.min(cap, Math.floor(raw ?? fallback)));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function zpeerAskGuardBlock(state: HarnessRuntimeState, params: ZpeerAskToolParams, selfAlias?: string, currentRoomId = "default"): string | undefined {
|
|
75
|
+
const targetAlias = safeZpeerAlias(params.targetAlias);
|
|
76
|
+
if (!targetAlias) return "invalid target alias";
|
|
77
|
+
if (selfAlias && targetAlias === selfAlias) return "cannot send to self";
|
|
78
|
+
const roomId = safeZpeerRoomId(params.roomId) ?? currentRoomId;
|
|
79
|
+
if (params.roomId && !safeZpeerRoomId(params.roomId)) return "invalid room id";
|
|
80
|
+
if (/\b(zpeer_ask|\/zpeer)\b/i.test(params.message)) return "loop guard blocked recursive ZPeer instruction";
|
|
81
|
+
const messageHash = sha256(params.message);
|
|
82
|
+
const now = Date.now();
|
|
83
|
+
const windowMs = 60_000;
|
|
84
|
+
const current = state.zobLive.zpeerAskGuard;
|
|
85
|
+
const guard = current && now - current.windowStartedMs < windowMs ? current : { windowStartedMs: now, count: 0 };
|
|
86
|
+
if (guard.count >= 3) return "rate guard blocked: max 3 agent-initiated ZPeer asks per 60s window";
|
|
87
|
+
if (guard.lastRoomId === roomId && guard.lastTargetAlias === targetAlias && guard.lastMessageHash === messageHash) return "loop guard blocked duplicate room/target/message in ask window";
|
|
88
|
+
state.zobLive.zpeerAskGuard = { windowStartedMs: guard.windowStartedMs, count: guard.count + 1, lastRoomId: roomId, lastTargetAlias: targetAlias, lastMessageHash: messageHash };
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function zpeerTerminalKind(status: ZpeerSendResult["status"]): "delivered" | "waiting" | "reply" | "blocked" | "error" | "timeout" | "expired" {
|
|
93
|
+
return status === "reply" || status === "completed" ? "reply" : status === "blocked" ? "blocked" : status === "timeout" ? "timeout" : status === "expired" ? "expired" : status === "error" ? "error" : status === "waiting" ? "waiting" : "delivered";
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function appendBlockedLiveSend(repoRoot: string, definition: TeamDefinition, params: ZobComsSendToolParams, status: string, reason: string): Record<string, unknown> {
|
|
97
|
+
return appendZobComsMessage(repoRoot, definition, {
|
|
98
|
+
runId: params.runId,
|
|
99
|
+
sender: params.sender,
|
|
100
|
+
receiver: params.receiver,
|
|
101
|
+
kind: params.kind ?? "handoff",
|
|
102
|
+
taskId: params.taskId,
|
|
103
|
+
taskHash: params.taskHash ?? (params.transientBody ? sha256(params.transientBody) : undefined),
|
|
104
|
+
outputHash: params.outputHash ?? null,
|
|
105
|
+
status,
|
|
106
|
+
ack: "not_sent",
|
|
107
|
+
metadata: { schema: "zob.coms-live-block.v1", reasonHash: sha256(reason), liveDelivery: "blocked", persistBodies: false },
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function executeRequiredLocalLiveSend(repoRoot: string, definition: TeamDefinition, params: ZobComsSendToolParams): Promise<Record<string, unknown>> {
|
|
112
|
+
const transientBody = typeof params.transientBody === "string" ? params.transientBody : "";
|
|
113
|
+
const taskHash = params.taskHash ?? (transientBody ? sha256(transientBody) : undefined);
|
|
114
|
+
if (!transientBody || !taskHash) {
|
|
115
|
+
return { status: "blocked", reason: "required_local live send requires transientBody or taskHash plus transientBody", message: appendBlockedLiveSend(repoRoot, definition, params, "blocked_live_body_missing", "missing transient live body") };
|
|
116
|
+
}
|
|
117
|
+
const registry = readZobLiveRegistrySnapshot(repoRoot, definition.name);
|
|
118
|
+
const receiver = registry.peers.find((peer) => peer.roleId === params.receiver && peer.status === "online" && peer.transport === "local_socket" && !peer.endpoint.startsWith("pending-"));
|
|
119
|
+
if (!receiver) {
|
|
120
|
+
return { status: "blocked", reason: "receiver unavailable in live registry", message: appendBlockedLiveSend(repoRoot, definition, params, "blocked_peer_unavailable", "receiver unavailable in live registry") };
|
|
121
|
+
}
|
|
122
|
+
const senderPeer = registry.peers.find((peer) => peer.roleId === params.sender && peer.status === "online" && peer.transport === "local_socket" && !peer.endpoint.startsWith("pending-"));
|
|
123
|
+
const policy = readZobComsV2Policy(repoRoot);
|
|
124
|
+
const msgId = params.taskId ?? `${params.runId}:${params.sender}:${params.receiver}:${Date.now()}`;
|
|
125
|
+
let promptCapture: ReturnType<typeof writeZobComsRedactedCapture>;
|
|
126
|
+
try {
|
|
127
|
+
promptCapture = writeZobComsRedactedCapture(repoRoot, policy.transcriptCapture, {
|
|
128
|
+
runId: params.runId,
|
|
129
|
+
msgId,
|
|
130
|
+
sender: params.sender,
|
|
131
|
+
receiver: params.receiver,
|
|
132
|
+
team: definition.name,
|
|
133
|
+
kind: "live_prompt",
|
|
134
|
+
taskHash,
|
|
135
|
+
transientPrompt: transientBody,
|
|
136
|
+
});
|
|
137
|
+
} catch {
|
|
138
|
+
promptCapture = undefined;
|
|
139
|
+
}
|
|
140
|
+
const envelope = buildZobLiveEnvelope({
|
|
141
|
+
type: "prompt",
|
|
142
|
+
msgId,
|
|
143
|
+
runId: params.runId,
|
|
144
|
+
sender: params.sender,
|
|
145
|
+
receiver: params.receiver,
|
|
146
|
+
team: definition.name,
|
|
147
|
+
taskHash,
|
|
148
|
+
replyEndpoint: senderPeer?.endpoint,
|
|
149
|
+
replyEndpointHash: senderPeer?.endpointHash,
|
|
150
|
+
artifactRefs: promptCapture ? [promptCapture.artifactRef] : undefined,
|
|
151
|
+
artifactHashes: promptCapture ? [promptCapture.artifactHash] : undefined,
|
|
152
|
+
transientPrompt: transientBody,
|
|
153
|
+
});
|
|
154
|
+
const liveRef = appendLiveSendRequestedRef(repoRoot, definition, envelope);
|
|
155
|
+
try {
|
|
156
|
+
const ack = await sendZobLocalEnvelope(receiver.endpoint, envelope, { timeoutMs: 5_000 });
|
|
157
|
+
if (ack.type !== "ack") {
|
|
158
|
+
appendLiveErrorStatus(repoRoot, String(liveRef.msgId), params.sender);
|
|
159
|
+
return { status: "error", reason: `expected ack, got ${ack.type}`, message: liveRef, ack };
|
|
160
|
+
}
|
|
161
|
+
const delivered = appendLiveDeliveredStatus(repoRoot, String(liveRef.msgId), params.sender);
|
|
162
|
+
return { status: "delivered", message: delivered, live: { schema: "zob.live-delivery.v1", msgId: envelope.msgId, receiverSessionHash: receiver.sessionHash, ackType: ack.type, bodyStored: false } };
|
|
163
|
+
} catch (error) {
|
|
164
|
+
appendLiveErrorStatus(repoRoot, String(liveRef.msgId), params.sender);
|
|
165
|
+
return { status: "error", reason: error instanceof Error ? error.message : String(error), message: liveRef };
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export function registerComsTools(pi: ExtensionAPI, state?: HarnessRuntimeState): void {
|
|
170
|
+
pi.registerTool({
|
|
171
|
+
name: "zpeer_ask",
|
|
172
|
+
label: "ZPeer Ask",
|
|
173
|
+
description: "Ask a visible local ZPeer via the governed room-scoped local_socket path. Defaults to mode=async; raw message/reply bodies are transient and durable metadata is hash-only.",
|
|
174
|
+
promptSnippet: "Use zpeer_ask with mode=\"async\" for useful non-trivial peer review/debug/planning coordination; avoid spam and loops.",
|
|
175
|
+
parameters: ZpeerAskParams,
|
|
176
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
177
|
+
if (!state?.zobLive.peerCard) return { content: [{ type: "text", text: "zpeer_ask blocked: current session has not registered a local peer endpoint" }], details: { schema: "zob.zpeer-ask-result.v1", status: "blocked", reason: "local_peer_unavailable", bodyStored: false } };
|
|
178
|
+
const mode = params.mode ?? "async";
|
|
179
|
+
const self = refreshZpeerSelf(ctx.cwd, state.zobLive.peerCard);
|
|
180
|
+
state.zobLive.peerCard = self;
|
|
181
|
+
const targetAlias = safeZpeerAlias(params.targetAlias) ?? params.targetAlias.replace(/^@+/, "");
|
|
182
|
+
const requestedRoomId = safeZpeerRoomId(params.roomId) ?? self.zpeerRoomId ?? "default";
|
|
183
|
+
const requestedFromAlias = peerAliasInRoom(self, requestedRoomId) ?? self.zpeerAlias;
|
|
184
|
+
const guardReason = zpeerAskGuardBlock(state, params, requestedFromAlias, requestedRoomId);
|
|
185
|
+
const emitZpeerAskEvent = (event: { kind: NonNullable<HarnessRuntimeState["zobLive"]["lastEvent"]>["kind"]; status: string; reason?: string; msgId?: string; roomId?: string; taskHash?: string; outputHash?: string }): void => {
|
|
186
|
+
const eventRoomId = event.roomId ?? requestedRoomId;
|
|
187
|
+
const fromAlias = peerAliasInRoom(self, eventRoomId) ?? requestedFromAlias;
|
|
188
|
+
state.zobLive.lastEvent = { kind: event.kind, roomId: eventRoomId, fromAlias, toAlias: targetAlias, status: event.status, reason: event.reason, msgId: event.msgId, taskHash: event.taskHash, outputHash: event.outputHash, at: new Date().toISOString(), localOnly: true, networkEnabled: false, bodyStored: false };
|
|
189
|
+
void pi.sendMessage({
|
|
190
|
+
customType: "zob-zpeer-event",
|
|
191
|
+
content: `ZPeer agent-request @${fromAlias ?? "?"} → @${targetAlias} ${event.status}`,
|
|
192
|
+
display: true,
|
|
193
|
+
details: { ...state.zobLive.lastEvent, source: "agent-request", mode, bodyStored: false, localOnly: true, networkEnabled: false },
|
|
194
|
+
}, { triggerTurn: false });
|
|
195
|
+
};
|
|
196
|
+
const taskHash = params.message.trim() ? sha256(params.message) : undefined;
|
|
197
|
+
if (guardReason) {
|
|
198
|
+
const result = { schema: "zob.zpeer-ask-result.v1", status: "blocked", reason: guardReason, targetAlias, taskHash, bodyStored: false };
|
|
199
|
+
emitZpeerAskEvent({ kind: "blocked", status: "blocked", reason: guardReason, taskHash });
|
|
200
|
+
pi.appendEntry("zob-zpeer", { schema: "zob.zpeer-ask.v1", action: "agent_request_blocked", mode, status: "blocked", reasonHash: sha256(guardReason), targetAliasHash: sha256(targetAlias), roomIdHash: sha256(requestedRoomId), taskHash, reasonInputHash: params.reason ? sha256(params.reason) : undefined, localOnly: true, networkEnabled: false, bodyStored: false, promptBodiesStored: false, outputBodiesStored: false, generatedAt: new Date().toISOString() });
|
|
201
|
+
return { content: [{ type: "text", text: `zpeer_ask blocked: ${guardReason}` }], details: result };
|
|
202
|
+
}
|
|
203
|
+
const timeoutMs = boundedZpeerAskTimeoutMs(mode, params.timeoutMs);
|
|
204
|
+
let feedbackEmittedTerminal = false;
|
|
205
|
+
const result = await sendZpeerPrompt(ctx.cwd, self, targetAlias, params.message, (msgId) => state.zobLive.pendingReplies.wait(msgId, timeoutMs), {
|
|
206
|
+
mode,
|
|
207
|
+
roomId: params.roomId,
|
|
208
|
+
onFeedback: (feedback) => {
|
|
209
|
+
feedbackEmittedTerminal = feedback.result.status === "waiting" || feedback.result.status === "reply" || feedback.result.status === "completed" || feedback.result.status === "blocked" || feedback.result.status === "error" || feedback.result.status === "timeout" || feedback.result.status === "expired";
|
|
210
|
+
emitZpeerAskEvent({ kind: feedback.kind, roomId: feedback.result.roomId, status: feedback.result.status, reason: feedback.result.reason, msgId: feedback.result.msgId, taskHash: feedback.result.taskHash, outputHash: feedback.result.outputHash });
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
if (!feedbackEmittedTerminal) emitZpeerAskEvent({ kind: zpeerTerminalKind(result.status), roomId: result.roomId, status: result.status, reason: result.reason, msgId: result.msgId, taskHash: result.taskHash, outputHash: result.outputHash });
|
|
214
|
+
pi.appendEntry("zob-zpeer", { schema: "zob.zpeer-ask.v1", action: "agent_request", mode, status: result.status, reasonHash: result.reason ? sha256(result.reason) : undefined, msgId: result.msgId, targetAliasHash: result.targetAlias ? sha256(result.targetAlias) : sha256(targetAlias), roomIdHash: sha256(result.roomId ?? requestedRoomId), taskHash: result.taskHash, outputHash: result.outputHash, reasonInputHash: params.reason ? sha256(params.reason) : undefined, localOnly: true, networkEnabled: false, bodyStored: false, promptBodiesStored: false, outputBodiesStored: false, generatedAt: new Date().toISOString() });
|
|
215
|
+
const ok = result.status === "reply" || result.status === "completed" || result.status === "waiting" || result.status === "delivered";
|
|
216
|
+
return { content: [{ type: "text", text: ok ? `zpeer_ask ${result.status}: @${result.targetAlias ?? targetAlias}${result.outputHash ? ` outputHash=${result.outputHash}` : ""}` : `zpeer_ask ${result.status}: ${result.reason ?? "see metadata"}` }], details: { schema: "zob.zpeer-ask-result.v1", mode, ...result } };
|
|
217
|
+
},
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
pi.registerTool({
|
|
221
|
+
name: "zob_coms_send",
|
|
222
|
+
label: "ZOB Coms Send",
|
|
223
|
+
description: "Send a ZOB coms message. In v2 required_local mode this delivers live first and mirrors hash-only to .pi/coms; outside required live mode it writes a plan_only hash-only reference, not delivery success. No network coms.",
|
|
224
|
+
promptSnippet: "Send a ZOB live/hash-only mailbox message",
|
|
225
|
+
parameters: ZobComsSendParams,
|
|
226
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
227
|
+
const team = loadTeamDefinition(ctx.cwd, params.team ?? "zob-core");
|
|
228
|
+
const errors = [...team.errors, ...validateTeamDefinition(ctx.cwd, team.definition)];
|
|
229
|
+
if (errors.length > 0 || !team.definition) return { content: [{ type: "text", text: `zob_coms_send failed_preflight:\n- ${errors.join("\n- ")}` }], details: { status: "failed_preflight", errors } };
|
|
230
|
+
try {
|
|
231
|
+
const policy = readZobComsV2Policy(ctx.cwd);
|
|
232
|
+
if (policy.mode === "off") return { content: [{ type: "text", text: "zob_coms_send blocked: ZOB coms transport mode is off" }], details: { status: "blocked", reason: "transport_off" } };
|
|
233
|
+
if (policy.mode === "required_network") return { content: [{ type: "text", text: "zob_coms_send blocked: required_network is not enabled in P1; network remains gated" }], details: { status: "blocked", reason: "network_gated", networkEnabled: policy.networkEnabled } };
|
|
234
|
+
if (policy.mode === "required_local") {
|
|
235
|
+
const live = await executeRequiredLocalLiveSend(ctx.cwd, team.definition as TeamDefinition, params);
|
|
236
|
+
const status = typeof live.status === "string" ? live.status : "unknown";
|
|
237
|
+
return { content: [{ type: "text", text: status === "delivered" ? `zob_coms_send delivered: ${(live.message as Record<string, unknown>).msgId}` : `zob_coms_send ${status}: ${live.reason ?? "live delivery failed"}` }], details: live };
|
|
238
|
+
}
|
|
239
|
+
if (policy.mode === "break_glass_ledger_only" && !breakGlassApprovalPresent()) return { content: [{ type: "text", text: "zob_coms_send blocked: break_glass_ledger_only requires ZOB_COMS_BREAK_GLASS_APPROVAL_HASH" }], details: { status: "blocked", reason: "break_glass_approval_missing" } };
|
|
240
|
+
const message = appendZobComsMessage(ctx.cwd, team.definition as TeamDefinition, {
|
|
241
|
+
runId: params.runId,
|
|
242
|
+
sender: params.sender,
|
|
243
|
+
receiver: params.receiver,
|
|
244
|
+
kind: params.kind ?? "plan_only_handoff_ref",
|
|
245
|
+
taskId: params.taskId,
|
|
246
|
+
taskHash: params.taskHash ?? (params.transientBody ? sha256(params.transientBody) : undefined),
|
|
247
|
+
outputHash: params.outputHash ?? null,
|
|
248
|
+
status: params.status ?? "planned",
|
|
249
|
+
metadata: { schema: "zob.coms-plan-only-ref.v1", noExecution: true, liveDelivery: "none", persistBodies: false },
|
|
250
|
+
});
|
|
251
|
+
return { content: [{ type: "text", text: `zob_coms_send planned_ref: ${message.msgId}` }], details: message };
|
|
252
|
+
} catch (error) {
|
|
253
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
254
|
+
return { content: [{ type: "text", text: `zob_coms_send blocked: ${message}` }], details: { status: "blocked", errors: [message] } };
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
pi.registerTool({
|
|
260
|
+
name: "zob_coms_ack",
|
|
261
|
+
label: "ZOB Coms ACK",
|
|
262
|
+
description: "ACK receipt of a local .pi/coms mailbox message. Appends metadata-only status event; no bodies stored.",
|
|
263
|
+
parameters: ZobComsAckParams,
|
|
264
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
265
|
+
try {
|
|
266
|
+
const policyBlock = ledgerMutationPolicyBlock(ctx.cwd, "zob_coms_ack");
|
|
267
|
+
if (policyBlock) return { content: [{ type: "text", text: policyBlock.text }], details: policyBlock };
|
|
268
|
+
const message = ackZobComsMessage(ctx.cwd, params.msgId, params.actor);
|
|
269
|
+
return { content: [{ type: "text", text: `zob_coms_ack: ${params.msgId}` }], details: message };
|
|
270
|
+
} catch (error) {
|
|
271
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
272
|
+
return { content: [{ type: "text", text: `zob_coms_ack blocked: ${message}` }], details: { status: "blocked", errors: [message] } };
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
pi.registerTool({
|
|
278
|
+
name: "zob_coms_status",
|
|
279
|
+
label: "ZOB Coms Status",
|
|
280
|
+
description: "Append a local metadata-only status transition for a .pi/coms message. No bodies stored.",
|
|
281
|
+
parameters: ZobComsStatusParams,
|
|
282
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
283
|
+
try {
|
|
284
|
+
const policyBlock = ledgerMutationPolicyBlock(ctx.cwd, "zob_coms_status");
|
|
285
|
+
if (policyBlock) return { content: [{ type: "text", text: policyBlock.text }], details: policyBlock };
|
|
286
|
+
const message = transitionZobComsStatus(ctx.cwd, params.msgId, params.actor, params.status);
|
|
287
|
+
return { content: [{ type: "text", text: `zob_coms_status ${params.status}: ${params.msgId}` }], details: message };
|
|
288
|
+
} catch (error) {
|
|
289
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
290
|
+
return { content: [{ type: "text", text: `zob_coms_status blocked: ${message}` }], details: { status: "blocked", errors: [message] } };
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
pi.registerTool({
|
|
296
|
+
name: "zob_coms_reply",
|
|
297
|
+
label: "ZOB Coms Reply",
|
|
298
|
+
description: "Append a topology-guarded hash-only local reply correlated to a parent .pi/coms message. No network coms.",
|
|
299
|
+
parameters: ZobComsReplyParams,
|
|
300
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
301
|
+
const team = loadTeamDefinition(ctx.cwd, params.team ?? "zob-core");
|
|
302
|
+
const errors = [...team.errors, ...validateTeamDefinition(ctx.cwd, team.definition)];
|
|
303
|
+
if (errors.length > 0 || !team.definition) return { content: [{ type: "text", text: `zob_coms_reply failed_preflight:\n- ${errors.join("\n- ")}` }], details: { status: "failed_preflight", errors } };
|
|
304
|
+
try {
|
|
305
|
+
const policy = readZobComsV2Policy(ctx.cwd);
|
|
306
|
+
if (policy.mode === "off") return { content: [{ type: "text", text: "zob_coms_reply blocked: ZOB coms transport mode is off" }], details: { status: "blocked", reason: "transport_off" } };
|
|
307
|
+
if (policy.mode === "break_glass_ledger_only" && !breakGlassApprovalPresent()) return { content: [{ type: "text", text: "zob_coms_reply blocked: break_glass_ledger_only requires ZOB_COMS_BREAK_GLASS_APPROVAL_HASH" }], details: { status: "blocked", reason: "break_glass_approval_missing" } };
|
|
308
|
+
const message = replyZobComsMessage(ctx.cwd, team.definition as TeamDefinition, params.msgId, {
|
|
309
|
+
sender: params.sender,
|
|
310
|
+
receiver: params.receiver,
|
|
311
|
+
kind: params.kind ?? "reply",
|
|
312
|
+
taskId: params.taskId,
|
|
313
|
+
taskHash: params.taskHash,
|
|
314
|
+
outputHash: params.outputHash ?? null,
|
|
315
|
+
status: params.status ?? "planned",
|
|
316
|
+
});
|
|
317
|
+
return { content: [{ type: "text", text: `zob_coms_reply planned_ref: ${message.msgId}` }], details: message };
|
|
318
|
+
} catch (error) {
|
|
319
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
320
|
+
return { content: [{ type: "text", text: `zob_coms_reply blocked: ${message}` }], details: { status: "blocked", errors: [message] } };
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
pi.registerTool({
|
|
326
|
+
name: "zob_coms_list",
|
|
327
|
+
label: "ZOB Coms List",
|
|
328
|
+
description: "List local .pi/coms mailbox messages with bounded filters. Bodies are never returned because they are not stored.",
|
|
329
|
+
parameters: ZobComsListParams,
|
|
330
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
331
|
+
const messages = listZobComsMessages(ctx.cwd, params);
|
|
332
|
+
return { content: [{ type: "text", text: `zob_coms_list: ${messages.length} message(s)` }], details: { schema: "zob.coms-list.v1", messages } };
|
|
333
|
+
},
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
pi.registerTool({
|
|
337
|
+
name: "zob_coms_get",
|
|
338
|
+
label: "ZOB Coms Get",
|
|
339
|
+
description: "Fetch one local .pi/coms mailbox message by id.",
|
|
340
|
+
parameters: ZobComsGetParams,
|
|
341
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
342
|
+
const message = getZobComsMessage(ctx.cwd, params.msgId);
|
|
343
|
+
return { content: [{ type: "text", text: message ? `zob_coms_get: ${params.msgId}` : `zob_coms_get: not found ${params.msgId}` }], details: { schema: "zob.coms-get.v1", message } };
|
|
344
|
+
},
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
pi.registerTool({
|
|
348
|
+
name: "zob_coms_await",
|
|
349
|
+
label: "ZOB Coms Await",
|
|
350
|
+
description: "Bounded wait for a local .pi/coms mailbox message. Timeout is capped at 5000ms.",
|
|
351
|
+
parameters: ZobComsAwaitParams,
|
|
352
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
353
|
+
const policy = readZobComsV2Policy(ctx.cwd);
|
|
354
|
+
if (policy.mode === "required_local" || policy.mode === "required_network") {
|
|
355
|
+
if (typeof params.msgId !== "string" || params.msgId.length === 0) return { content: [{ type: "text", text: "zob_coms_await blocked: required live mode requires msgId; ledger polling fallback is disabled" }], details: { schema: "zob.coms-await-live.v1", status: "blocked", reason: "msgId_required", timedOut: false } };
|
|
356
|
+
if (!state?.zobLive.pendingReplies) return { content: [{ type: "text", text: "zob_coms_await blocked: live pending reply registry unavailable" }], details: { schema: "zob.coms-await-live.v1", status: "blocked", reason: "pending_replies_unavailable", timedOut: false } };
|
|
357
|
+
const timeoutMs = Math.max(25, Math.min(30 * 60 * 1000, Math.floor(params.timeoutMs ?? 30_000)));
|
|
358
|
+
const result = await state.zobLive.pendingReplies.wait(params.msgId, timeoutMs);
|
|
359
|
+
return { content: [{ type: "text", text: result.status === "completed" ? `zob_coms_await live_response: ${params.msgId}` : `zob_coms_await ${result.status}: ${params.msgId}` }], details: { schema: "zob.coms-await-live.v1", timedOut: result.status === "timeout", result } };
|
|
360
|
+
}
|
|
361
|
+
const message = await awaitZobComsMessage(ctx.cwd, params);
|
|
362
|
+
return { content: [{ type: "text", text: message ? `zob_coms_await: ${message.msgId}` : "zob_coms_await: timeout" }], details: { schema: "zob.coms-await.v1", timedOut: !message, message } };
|
|
363
|
+
},
|
|
364
|
+
});
|
|
365
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ContextReadinessParams,
|
|
5
|
+
ContextScopeValidateParams,
|
|
6
|
+
ContextWritebackProposalParams,
|
|
7
|
+
} from "../schemas.js";
|
|
8
|
+
import {
|
|
9
|
+
buildContextGbrainReadinessAudit,
|
|
10
|
+
buildDefaultContextScope,
|
|
11
|
+
validateContextScope,
|
|
12
|
+
writeContextWritebackProposal,
|
|
13
|
+
} from "../context-gbrain.js";
|
|
14
|
+
|
|
15
|
+
export function registerContextTools(pi: ExtensionAPI): void {
|
|
16
|
+
pi.registerTool({
|
|
17
|
+
name: "zob_context_readiness",
|
|
18
|
+
label: "ZOB Context/GBrain Readiness",
|
|
19
|
+
description: "Audit Context/GBrain P0 readiness: context_scope, citations, bounded packs, forbidden sources, and local metadata-only writeback proposals. No GBrain import/embed/sync/write or corpus writes.",
|
|
20
|
+
parameters: ContextReadinessParams,
|
|
21
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
22
|
+
const audit = buildContextGbrainReadinessAudit(ctx.cwd, { runId: params.runId });
|
|
23
|
+
return { content: [{ type: "text", text: `zob_context_readiness: ${audit.verdict}` }], details: audit };
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
pi.registerTool({
|
|
28
|
+
name: "zob_context_validate_scope",
|
|
29
|
+
label: "ZOB Context Scope Validate",
|
|
30
|
+
description: "Build and validate a P0 context_scope. Requires citations, bounded tokens, explicit allowed brains/sources, forbidden sources, and proposal-only write policy.",
|
|
31
|
+
parameters: ContextScopeValidateParams,
|
|
32
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
33
|
+
const scope = buildDefaultContextScope(ctx.cwd, {
|
|
34
|
+
runId: params.runId,
|
|
35
|
+
scopeId: params.scopeId,
|
|
36
|
+
todoId: params.todoId,
|
|
37
|
+
allowedBrains: params.allowedBrains,
|
|
38
|
+
allowedSources: params.allowedSources,
|
|
39
|
+
forbiddenSources: params.forbiddenSources,
|
|
40
|
+
agentProfile: params.agentProfile,
|
|
41
|
+
maxContextTokens: params.maxContextTokens,
|
|
42
|
+
});
|
|
43
|
+
const errors = validateContextScope(ctx.cwd, scope);
|
|
44
|
+
return { content: [{ type: "text", text: errors.length === 0 ? `zob_context_validate_scope: valid ${scope.scopeId}` : `zob_context_validate_scope blocked:\n- ${errors.join("\n- ")}` }], details: { schema: "zob.context-scope-validation.v1", valid: errors.length === 0, errors, scope } };
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
pi.registerTool({
|
|
49
|
+
name: "zob_context_writeback_proposal",
|
|
50
|
+
label: "ZOB Context Writeback Proposal",
|
|
51
|
+
description: "Append a local metadata-only context learning/writeback proposal. No auto-promotion, no GBrain/corpus write, requires hash-only problem/pattern and evidence refs.",
|
|
52
|
+
parameters: ContextWritebackProposalParams,
|
|
53
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
54
|
+
try {
|
|
55
|
+
const proposal = writeContextWritebackProposal(ctx.cwd, {
|
|
56
|
+
proposalId: params.proposalId,
|
|
57
|
+
runId: params.runId,
|
|
58
|
+
observedProblemHash: params.observedProblemHash,
|
|
59
|
+
newPatternHash: params.newPatternHash,
|
|
60
|
+
evidenceRefs: params.evidenceRefs,
|
|
61
|
+
recommendedArtifact: params.recommendedArtifact,
|
|
62
|
+
});
|
|
63
|
+
return { content: [{ type: "text", text: `zob_context_writeback_proposal proposed: ${proposal.proposalId}` }], details: proposal };
|
|
64
|
+
} catch (error) {
|
|
65
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
66
|
+
return { content: [{ type: "text", text: `zob_context_writeback_proposal blocked: ${message}` }], details: { status: "blocked", errors: [message] } };
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|