@bolloon/bolloon-agent 0.1.0 → 0.1.1
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/package.json +1 -1
- package/dist/constraint-runtime/tests/agent.test.js +0 -16
- package/dist/constraint-runtime/tests/constraint.test.js +0 -41
- package/dist/constraint-runtime/tests/skill.test.js +0 -19
- package/dist/constraint-runtime/tests/thinking.test.js +0 -22
- package/dist/electron-preload.js +0 -15
- package/dist/electron-preload.js.map +0 -1
- package/dist/electron.js +0 -206
- package/dist/electron.js.map +0 -1
- package/dist/test/constraint-layer.test.js +0 -164
- package/dist/test/global-shared-context.test.js +0 -315
- package/dist/test/pi-sdk.test.js +0 -47
- package/dist/test/set-persona.test.js +0 -38
- package/dist/test/subagent-manager.test.js +0 -276
- package/dist/test/workflow-engine.test.js +0 -87
- package/dist/workflows/collaboration.js +0 -374
- package/dist/workflows/index.js +0 -54
- package/docs/agent-communication.md +0 -333
- package/docs/plans/2026-05-15-document-agent-design.md +0 -479
- package/docs/plans/2026-05-15-document-agent-implementation-plan.md +0 -792
- package/docs/plans/2026-05-16-chat-ui-design.md +0 -86
- package/docs/plans/2026-05-16-constraint-runtime-design.md +0 -106
- package/docs/plans/2026-05-16-constraint-runtime-implementation.md +0 -441
- package/docs//346/225/260/345/255/246/350/276/205/345/212/251/346/231/272/350/203/275/344/275/223-/346/240/270/345/277/203/346/225/210/346/236/234/345/256/232/344/271/211.md +0 -287
- package/src/bollharness/.boll/CLAUDE.md.template +0 -34
- package/src/bollharness/.boll/MANIFEST.yaml +0 -213
- package/src/bollharness/.boll/active-review-agents/.gitkeep +0 -0
- package/src/bollharness/.boll/agents/review-base.yaml +0 -108
- package/src/bollharness/.boll/deploy-allowlist.yaml +0 -38
- package/src/bollharness/.boll/inbox/schema/message-v1.json +0 -99
- package/src/bollharness/.boll/install-staging/.gitkeep +0 -0
- package/src/bollharness/.boll/issue-adapter.yaml +0 -31
- package/src/bollharness/.boll/plugins/boll-mode-toolkit/contracts/mode-contract.md +0 -85
- package/src/bollharness/.boll/plugins/boll-review-toolkit/contracts/evidence-packet-schema.json +0 -102
- package/src/bollharness/.boll/plugins/boll-review-toolkit/contracts/review-contract.yaml +0 -247
- package/src/bollharness/.boll/rules/backend-routes.md +0 -31
- package/src/bollharness/.boll/rules/closure-semantics.md +0 -30
- package/src/bollharness/.boll/rules/env-vars.md +0 -32
- package/src/bollharness/.boll/rules/hanis-protocol.md +0 -145
- package/src/bollharness/.boll/rules/repo-structure.md +0 -42
- package/src/bollharness/.boll/rules/review-agent-isolation.md +0 -73
- package/src/bollharness/.boll/rules/source-of-truth.md +0 -33
- package/src/bollharness/.boll/settings.json +0 -180
- package/src/bollharness/.boll/settings.json.template +0 -31
- package/src/bollharness/.boll/skills/arch/SKILL.md +0 -372
- package/src/bollharness/.boll/skills/bug-pipeline/SKILL.md +0 -168
- package/src/bollharness/.boll/skills/bug-triage/SKILL.md +0 -161
- package/src/bollharness/.boll/skills/context-chains/SKILL.md +0 -250
- package/src/bollharness/.boll/skills/context-chains/context-chain-index.md +0 -48
- package/src/bollharness/.boll/skills/context-chains/work-type-extractors/code_change_extractor.ts +0 -142
- package/src/bollharness/.boll/skills/context-chains/work-type-extractors/debugging_extractor.ts +0 -126
- package/src/bollharness/.boll/skills/context-chains/work-type-extractors/design_extractor.ts +0 -148
- package/src/bollharness/.boll/skills/context-chains/work-type-extractors/planning_extractor.ts +0 -162
- package/src/bollharness/.boll/skills/context-chains/work-type-extractors/question_extractor.ts +0 -116
- package/src/bollharness/.boll/skills/context-chains/work-type-extractors/review_extractor.ts +0 -136
- package/src/bollharness/.boll/skills/crystal-learn/SKILL.md +0 -93
- package/src/bollharness/.boll/skills/crystal-learn/invariants/INV-0.md +0 -34
- package/src/bollharness/.boll/skills/crystal-learn/invariants/INV-1.md +0 -34
- package/src/bollharness/.boll/skills/crystal-learn/invariants/INV-2.md +0 -35
- package/src/bollharness/.boll/skills/crystal-learn/invariants/INV-3.md +0 -34
- package/src/bollharness/.boll/skills/crystal-learn/invariants/INV-4.md +0 -43
- package/src/bollharness/.boll/skills/crystal-learn/invariants/INV-5.md +0 -34
- package/src/bollharness/.boll/skills/crystal-learn/invariants/INV-6.md +0 -37
- package/src/bollharness/.boll/skills/crystal-learn/invariants/INV-7.md +0 -46
- package/src/bollharness/.boll/skills/guardian-fixer/PROMPT.md +0 -415
- package/src/bollharness/.boll/skills/guardian-fixer/SKILL.md +0 -320
- package/src/bollharness/.boll/skills/harness-dev/SKILL.md +0 -93
- package/src/bollharness/.boll/skills/harness-dev/examples/README.md +0 -227
- package/src/bollharness/.boll/skills/harness-dev-handoff/SKILL.md +0 -165
- package/src/bollharness/.boll/skills/harness-eng/SKILL.md +0 -110
- package/src/bollharness/.boll/skills/harness-eng-test/SKILL.md +0 -79
- package/src/bollharness/.boll/skills/harness-lab/SKILL.md +0 -170
- package/src/bollharness/.boll/skills/harness-ops/SKILL.md +0 -57
- package/src/bollharness/.boll/skills/harness-voice/SKILL.md +0 -183
- package/src/bollharness/.boll/skills/judgment/SKILL.md +0 -115
- package/src/bollharness/.boll/skills/lead/SKILL.md +0 -245
- package/src/bollharness/.boll/skills/lead/install-wow-harness.md +0 -77
- package/src/bollharness/.boll/skills/lead/ref-review-sop.md +0 -91
- package/src/bollharness/.boll/skills/lead/ref-stages.md +0 -129
- package/src/bollharness/.boll/skills/skill-discovery/SKILL.md +0 -169
- package/src/bollharness/.boll/skills/task-arch/SKILL.md +0 -106
- package/src/bollharness/.boll/skills/toolkit/SKILL.md +0 -57
- package/src/bollharness/.boll/tasks/.gitkeep +0 -0
- package/src/bollharness/.boll/toolkit-index.yaml +0 -112
- package/src/bollharness/.claude/agents/review-base.yaml +0 -108
- package/src/bollharness/.claude/plugins/boll-mode-toolkit/.claude-plugin/plugin.json +0 -44
- package/src/bollharness/.claude/plugins/boll-review-toolkit/.claude-plugin/plugin.json +0 -24
- package/src/bollharness/.claude/plugins/boll-review-toolkit/contracts/evidence-packet-schema.json +0 -102
- package/src/bollharness/.claude/plugins/boll-review-toolkit/contracts/review-contract.yaml +0 -247
- package/src/bollharness/.claude/settings.json +0 -157
- package/src/bollharness/.claude/skills/arch/SKILL.md +0 -64
- package/src/bollharness/.claude/skills/crystal-learn/SKILL.md +0 -93
- package/src/bollharness/.claude/skills/guardian-fixer/PROMPT.md +0 -44
- package/src/bollharness/.claude/skills/guardian-fixer/SKILL.md +0 -324
- package/src/bollharness/.claude/skills/harness-dev/SKILL.md +0 -93
- package/src/bollharness/.claude/skills/harness-dev/examples/README.md +0 -17
- package/src/bollharness/.claude/skills/harness-dev-handoff/SKILL.md +0 -165
- package/src/bollharness/.claude/skills/harness-eng/SKILL.md +0 -183
- package/src/bollharness/.claude/skills/harness-eng-test/SKILL.md +0 -57
- package/src/bollharness/.claude/skills/harness-ops/SKILL.md +0 -57
- package/src/bollharness/.claude/skills/harness-voice/SKILL.md +0 -84
- package/src/bollharness/.claude/skills/lead/INDEX.md +0 -28
- package/src/bollharness/.claude/skills/lead/SKILL.md +0 -24
- package/src/bollharness/.claude/skills/lead/install-wow-harness.md +0 -77
- package/src/bollharness/.claude/skills/lead/ref-review-sop.md +0 -48
- package/src/bollharness/.claude/skills/lead/ref-stages.md +0 -58
- package/src/bollharness/.claude/skills/plan-lock/SKILL.md +0 -74
- package/src/bollharness/.claude/skills/skill-discovery/SKILL.md +0 -120
- package/src/bollharness/.claude/skills/task-arch/SKILL.md +0 -106
- package/src/bollharness/.claude/skills/toolkit/SKILL.md +0 -57
- package/src/bollharness/.claude/skills/toolkit/list.sh +0 -92
- package/src/bollharness/.githooks/pre-commit +0 -21
- package/src/bollharness/.github/workflows/ci.yml +0 -88
- package/src/bollharness/CLAUDE.md +0 -73
- package/src/bollharness/README.md +0 -143
- package/src/bollharness/README.zh-CN.md +0 -131
- package/src/bollharness/docs/decisions/ADR-030-guard-signal-protocol-and-governance-reload.md +0 -1076
- package/src/bollharness/docs/decisions/ADR-038-harness-optimization-strategy.md +0 -2039
- package/src/bollharness/docs/decisions/ADR-041-codex-claude-code-division-of-labor.md +0 -128
- package/src/bollharness/docs/decisions/ADR-H1-crystal-learn-revival.md +0 -188
- package/src/bollharness/docs/decisions/ADR-H2-identity-isolation.md +0 -183
- package/src/bollharness/docs/decisions/ADR-H3-memory-scope.md +0 -133
- package/src/bollharness/docs/decisions/ADR-H4-prompt-governance.md +0 -146
- package/src/bollharness/docs/decisions/ADR-H5-gate-quantization.md +0 -212
- package/src/bollharness/docs/decisions/ADR-H6-state-file-health.md +0 -211
- package/src/bollharness/docs/decisions/ADR-H8-issue-and-doc-compliance.md +0 -202
- package/src/bollharness/docs/decisions/ADR-H9-mailbox.md +0 -231
- package/src/bollharness/docs/decisions/PLAN-H1-crystal-learn-revival.md +0 -270
- package/src/bollharness/docs/decisions/PLAN-H2-identity-isolation.md +0 -291
- package/src/bollharness/docs/decisions/PLAN-H3-memory-scope.md +0 -228
- package/src/bollharness/docs/decisions/PLAN-H4-prompt-governance.md +0 -227
- package/src/bollharness/docs/decisions/PLAN-H5-gate-quantization.md +0 -239
- package/src/bollharness/docs/decisions/PLAN-H6-state-file-health.md +0 -325
- package/src/bollharness/docs/decisions/PLAN-H8-issue-and-doc-compliance.md +0 -242
- package/src/bollharness/docs/decisions/PLAN-H9-mailbox.md +0 -378
- package/src/bollharness/docs/launch-article-en.md +0 -276
- package/src/bollharness/docs/launch-article-zh.md +0 -305
- package/src/bollharness/docs/practice.html +0 -356
- package/src/bollharness/docs/practice.md +0 -82
- package/src/bollharness/docs/research/round-1/README.md +0 -11
- package/src/bollharness/docs/research/round-2/README.md +0 -11
- package/src/bollharness/docs/research/round-3/README.md +0 -11
- package/src/bollharness/docs/research/round-4/README.md +0 -11
- package/src/bollharness/docs/research/round-5/README.md +0 -11
- package/src/bollharness/docs/research/round-6/README.md +0 -11
- package/src/bollharness/package-lock.json +0 -48
- package/src/bollharness/reference/boll-reference/.claude/rules/backend-routes.md +0 -268
- package/src/bollharness/reference/boll-reference/.claude/rules/bridge.md +0 -20
- package/src/bollharness/reference/boll-reference/.claude/rules/closure-semantics.md +0 -30
- package/src/bollharness/reference/boll-reference/.claude/rules/coaching.md +0 -13
- package/src/bollharness/reference/boll-reference/.claude/rules/env-vars.md +0 -50
- package/src/bollharness/reference/boll-reference/.claude/rules/hackathon.md +0 -12
- package/src/bollharness/reference/boll-reference/.claude/rules/repo-structure.md +0 -184
- package/src/bollharness/reference/boll-reference/.claude/rules/review-agent-isolation.md +0 -112
- package/src/bollharness/reference/boll-reference/.claude/rules/scenes.md +0 -12
- package/src/bollharness/reference/boll-reference/.claude/skills/arch/SKILL.md +0 -551
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-animation/SKILL.md +0 -26
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-bridge/SKILL.md +0 -227
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-bridge/agents/openai.yaml +0 -4
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-bridge/references/bridge-failure-taxonomy.md +0 -142
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-bridge/references/bridge-validation-ladder.md +0 -107
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-crystal/SKILL.md +0 -893
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-crystal-learn/SKILL.md +0 -89
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-dev/SKILL.md +0 -93
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-dev/examples/README.md +0 -209
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-dev-handoff/SKILL.md +0 -165
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-eng/SKILL.md +0 -110
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-eng-frontend/SKILL.md +0 -203
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-eng-hdc/SKILL.md +0 -27
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-eng-orchestrator/SKILL.md +0 -28
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-eng-prompt/SKILL.md +0 -27
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-eng-test/SKILL.md +0 -79
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-lab/SKILL.md +0 -372
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-run/SKILL.md +0 -437
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-ux-appstore/SKILL.md +0 -27
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-voice/SKILL.md +0 -442
- package/src/bollharness/reference/boll-reference/.claude/skills/guardian-fixer/PROMPT.md +0 -421
- package/src/bollharness/reference/boll-reference/.claude/skills/guardian-fixer/SKILL.md +0 -326
- package/src/bollharness/reference/boll-reference/.claude/skills/lead/SKILL.md +0 -155
- package/src/bollharness/reference/boll-reference/.claude/skills/lead/ref-review-sop.md +0 -91
- package/src/bollharness/reference/boll-reference/.claude/skills/lead/ref-stages.md +0 -129
- package/src/bollharness/reference/boll-reference/.claude/skills/nature-designer/output/skill-map-preview.png +0 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/nature-designer/output/skill-map-v2.png +0 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/nature-designer/output/skill-map-v3.png +0 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/nature-designer/output/skill-map-v4.png +0 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/plan-lock/SKILL.md +0 -425
- package/src/bollharness/reference/boll-reference/.claude/skills/plan-lock/ref-three-checks.md +0 -62
- package/src/bollharness/reference/boll-reference/.claude/skills/plan-lock/ref-wp-templates.md +0 -78
- package/src/bollharness/reference/boll-reference/.claude/skills/task-arch/SKILL.md +0 -76
- package/src/bollharness/reference/boll-reference/.claude/skills/vibedevteam-graph/SKILL.md +0 -57
- package/src/bollharness/reference/boll-reference/.claude/skills/vibedevteam-graph/beads-graph.sh +0 -153
- package/src/bollharness/reference/boll-reference/.claude/skills/vibedevteam-init/SKILL.md +0 -52
- package/src/bollharness/reference/boll-reference/.claude/skills/vibedevteam-init/beads-auto-link.sh +0 -76
- package/src/bollharness/reference/boll-reference/.claude/skills/vibedevteam-sync/SKILL.md +0 -50
- package/src/bollharness/reference/boll-reference/.claude/skills/vibedevteam-sync/beads-sync-proj.sh +0 -108
- package/src/bollharness/reference/boll-reference/docs/architecture/AGENT-PROFILE.md +0 -151
- package/src/bollharness/reference/boll-reference/docs/architecture/COST-STRUCTURE.md +0 -56
- package/src/bollharness/reference/boll-reference/docs/architecture/INDEX.md +0 -76
- package/src/bollharness/reference/boll-reference/docs/architecture/MODULE1-INTENT-FIELD.md +0 -116
- package/src/bollharness/reference/boll-reference/docs/architecture/MODULE2-CRYSTALLIZATION.md +0 -200
- package/src/bollharness/reference/boll-reference/docs/architecture/PRINCIPLES.md +0 -84
- package/src/bollharness/reference/boll-reference/docs/architecture/PROTOCOL-CORE.md +0 -209
- package/src/bollharness/reference/boll-reference/docs/architecture/VISION.md +0 -181
- package/src/bollharness/reference/boll-reference/docs/architecture/discussions/D-01-MARKET-SCENE-PROTOCOL.md +0 -754
- package/src/bollharness/reference/boll-reference/scripts/hooks/stop-evaluator.md +0 -57
- package/src/bollharness/scripts/context-fragments/artifact-linkage.md +0 -14
- package/src/bollharness/scripts/context-fragments/auth-consumers.md +0 -17
- package/src/bollharness/scripts/context-fragments/bridge-constitution.md +0 -13
- package/src/bollharness/scripts/context-fragments/catalyst-distributed.md +0 -18
- package/src/bollharness/scripts/context-fragments/closure-checklist.md +0 -13
- package/src/bollharness/scripts/context-fragments/contract-consumers.md +0 -15
- package/src/bollharness/scripts/context-fragments/db-shared-structures.md +0 -15
- package/src/bollharness/scripts/context-fragments/fixed-three-layers.md +0 -19
- package/src/bollharness/scripts/context-fragments/general-dev-principles.md +0 -11
- package/src/bollharness/scripts/context-fragments/issue-first.md +0 -8
- package/src/bollharness/scripts/context-fragments/mcp-parity.md +0 -16
- package/src/bollharness/scripts/context-fragments/pi-agent-operations.md +0 -74
- package/src/bollharness/scripts/context-fragments/protocol-consumers.md +0 -15
- package/src/bollharness/scripts/context-fragments/run-events-consumers.md +0 -15
- package/src/bollharness/scripts/context-fragments/scene-fidelity.md +0 -13
- package/src/bollharness/scripts/context-fragments/truth-source-hierarchy.md +0 -15
- package/src/bollharness/scripts/context-fragments/two-language.md +0 -15
- package/src/bollharness/scripts/context-fragments/version-sources.md +0 -14
- package/src/bollharness/scripts/hooks/stop-evaluator.md +0 -83
- package/src/bollharness/templates/scaffold/.boll/guard/.gitkeep +0 -0
- package/src/bollharness/templates/scaffold/.boll/metrics/.gitkeep +0 -0
- package/src/bollharness/templates/scaffold/.boll/state/.gitkeep +0 -0
- package/src/bollharness/templates/scaffold/CLAUDE.md +0 -89
- package/src/bollharness/templates/scaffold/docs/INDEX.md +0 -3
- package/src/bollharness/templates/scaffold/docs/decisions/ADR_TEMPLATE.md +0 -38
- package/src/bollharness/templates/scaffold/docs/decisions/PLAN_TEMPLATE.md +0 -45
- package/src/bollharness/templates/scaffold/docs/decisions/tasks/.gitkeep +0 -2
- package/src/bollharness/templates/scaffold/docs/issues/.gitkeep +0 -0
- package/src/bollharness/templates/scaffold/docs/issues/GUARD_ISSUE_TEMPLATE.md +0 -35
- package/src/bollharness/templates/scaffold/docs/issues/ISSUE_TEMPLATE.md +0 -51
- package/src/bollharness/tsconfig.json +0 -26
- package/src/constraint-runtime/package-lock.json +0 -48
- package/src/constraint-runtime/package.json +0 -34
- package/src/constraint-runtime/src/_archive_helper.ts +0 -16
- package/src/constraint-runtime/src/agent/coordinator.ts +0 -71
- package/src/constraint-runtime/src/agent/index.ts +0 -1
- package/src/constraint-runtime/src/assistant/index.ts +0 -15
- package/src/constraint-runtime/src/bootstrap/index.ts +0 -15
- package/src/constraint-runtime/src/bootstrap_graph.ts +0 -17
- package/src/constraint-runtime/src/bridge/index.ts +0 -15
- package/src/constraint-runtime/src/buddy/index.ts +0 -15
- package/src/constraint-runtime/src/cli/index.ts +0 -15
- package/src/constraint-runtime/src/command_graph.ts +0 -20
- package/src/constraint-runtime/src/commands.ts +0 -83
- package/src/constraint-runtime/src/components/index.ts +0 -15
- package/src/constraint-runtime/src/constants/index.ts +0 -15
- package/src/constraint-runtime/src/constraint/budget.ts +0 -25
- package/src/constraint-runtime/src/constraint/index.ts +0 -3
- package/src/constraint-runtime/src/constraint/permission.ts +0 -28
- package/src/constraint-runtime/src/context.ts +0 -45
- package/src/constraint-runtime/src/coordinator/index.ts +0 -15
- package/src/constraint-runtime/src/cost_hook.ts +0 -6
- package/src/constraint-runtime/src/cost_tracker.ts +0 -9
- package/src/constraint-runtime/src/deferred_init.ts +0 -18
- package/src/constraint-runtime/src/direct_modes.ts +0 -13
- package/src/constraint-runtime/src/dynamic-tool-loader.ts +0 -115
- package/src/constraint-runtime/src/entrypoints/index.ts +0 -15
- package/src/constraint-runtime/src/execution_registry.ts +0 -41
- package/src/constraint-runtime/src/history.ts +0 -16
- package/src/constraint-runtime/src/hooks/index.ts +0 -15
- package/src/constraint-runtime/src/index.ts +0 -28
- package/src/constraint-runtime/src/ink.ts +0 -4
- package/src/constraint-runtime/src/keybindings/index.ts +0 -15
- package/src/constraint-runtime/src/memdir/index.ts +0 -15
- package/src/constraint-runtime/src/migrations/index.ts +0 -15
- package/src/constraint-runtime/src/models.ts +0 -49
- package/src/constraint-runtime/src/moreright/index.ts +0 -15
- package/src/constraint-runtime/src/native_ts/index.ts +0 -15
- package/src/constraint-runtime/src/output_styles/index.ts +0 -15
- package/src/constraint-runtime/src/parity_audit.ts +0 -23
- package/src/constraint-runtime/src/plugins/index.ts +0 -15
- package/src/constraint-runtime/src/port_manifest.ts +0 -20
- package/src/constraint-runtime/src/prefetch.ts +0 -17
- package/src/constraint-runtime/src/query.ts +0 -7
- package/src/constraint-runtime/src/reference_data/archive_surface_snapshot.json +0 -63
- package/src/constraint-runtime/src/reference_data/commands_snapshot.json +0 -1037
- package/src/constraint-runtime/src/reference_data/subsystems/OpenCLI.json +0 -10
- package/src/constraint-runtime/src/reference_data/subsystems/PolymarketSDK.json +0 -12
- package/src/constraint-runtime/src/reference_data/subsystems/SafeSDK.json +0 -14
- package/src/constraint-runtime/src/reference_data/subsystems/assistant.json +0 -8
- package/src/constraint-runtime/src/reference_data/subsystems/bootstrap.json +0 -8
- package/src/constraint-runtime/src/reference_data/subsystems/bridge.json +0 -32
- package/src/constraint-runtime/src/reference_data/subsystems/buddy.json +0 -13
- package/src/constraint-runtime/src/reference_data/subsystems/cli.json +0 -26
- package/src/constraint-runtime/src/reference_data/subsystems/components.json +0 -32
- package/src/constraint-runtime/src/reference_data/subsystems/constants.json +0 -28
- package/src/constraint-runtime/src/reference_data/subsystems/coordinator.json +0 -8
- package/src/constraint-runtime/src/reference_data/subsystems/entrypoints.json +0 -15
- package/src/constraint-runtime/src/reference_data/subsystems/hooks.json +0 -32
- package/src/constraint-runtime/src/reference_data/subsystems/keybindings.json +0 -21
- package/src/constraint-runtime/src/reference_data/subsystems/memdir.json +0 -15
- package/src/constraint-runtime/src/reference_data/subsystems/migrations.json +0 -18
- package/src/constraint-runtime/src/reference_data/subsystems/moreright.json +0 -8
- package/src/constraint-runtime/src/reference_data/subsystems/native_ts.json +0 -11
- package/src/constraint-runtime/src/reference_data/subsystems/outputStyles.json +0 -8
- package/src/constraint-runtime/src/reference_data/subsystems/plugins.json +0 -9
- package/src/constraint-runtime/src/reference_data/subsystems/remote.json +0 -11
- package/src/constraint-runtime/src/reference_data/subsystems/schemas.json +0 -8
- package/src/constraint-runtime/src/reference_data/subsystems/screens.json +0 -10
- package/src/constraint-runtime/src/reference_data/subsystems/server.json +0 -10
- package/src/constraint-runtime/src/reference_data/subsystems/services.json +0 -32
- package/src/constraint-runtime/src/reference_data/subsystems/skills.json +0 -27
- package/src/constraint-runtime/src/reference_data/subsystems/state.json +0 -13
- package/src/constraint-runtime/src/reference_data/subsystems/types.json +0 -18
- package/src/constraint-runtime/src/reference_data/subsystems/upstreamproxy.json +0 -9
- package/src/constraint-runtime/src/reference_data/subsystems/utils.json +0 -32
- package/src/constraint-runtime/src/reference_data/subsystems/vim.json +0 -12
- package/src/constraint-runtime/src/reference_data/subsystems/voice.json +0 -8
- package/src/constraint-runtime/src/reference_data/tools_snapshot.json +0 -1042
- package/src/constraint-runtime/src/remote/index.ts +0 -15
- package/src/constraint-runtime/src/remote_runtime.ts +0 -17
- package/src/constraint-runtime/src/runtime/index.ts +0 -1
- package/src/constraint-runtime/src/runtime/session.ts +0 -42
- package/src/constraint-runtime/src/schemas/index.ts +0 -15
- package/src/constraint-runtime/src/screens/index.ts +0 -15
- package/src/constraint-runtime/src/server/index.ts +0 -15
- package/src/constraint-runtime/src/services/index.ts +0 -15
- package/src/constraint-runtime/src/session_store.ts +0 -32
- package/src/constraint-runtime/src/setup.ts +0 -50
- package/src/constraint-runtime/src/skills/index.ts +0 -1
- package/src/constraint-runtime/src/skills/skill-registry.ts +0 -40
- package/src/constraint-runtime/src/state/index.ts +0 -15
- package/src/constraint-runtime/src/system_init.ts +0 -21
- package/src/constraint-runtime/src/thinking/engine.ts +0 -61
- package/src/constraint-runtime/src/thinking/index.ts +0 -1
- package/src/constraint-runtime/src/tool_pool.ts +0 -20
- package/src/constraint-runtime/src/tools/OpenCLI/execAdapter.ts +0 -12
- package/src/constraint-runtime/src/tools/OpenCLI/listAdapters.ts +0 -12
- package/src/constraint-runtime/src/tools/OpenCLI/runCommand.ts +0 -13
- package/src/constraint-runtime/src/tools/PolymarketSDK/cancelOrder.ts +0 -10
- package/src/constraint-runtime/src/tools/PolymarketSDK/createOrder.ts +0 -13
- package/src/constraint-runtime/src/tools/PolymarketSDK/getMarket.ts +0 -14
- package/src/constraint-runtime/src/tools/PolymarketSDK/getOrders.ts +0 -10
- package/src/constraint-runtime/src/tools/PolymarketSDK/listMarkets.ts +0 -24
- package/src/constraint-runtime/src/tools/SafeSDK/confirmTransaction.ts +0 -13
- package/src/constraint-runtime/src/tools/SafeSDK/createTransaction.ts +0 -23
- package/src/constraint-runtime/src/tools/SafeSDK/deploySafe.ts +0 -12
- package/src/constraint-runtime/src/tools/SafeSDK/executeTransaction.ts +0 -12
- package/src/constraint-runtime/src/tools/SafeSDK/getBalance.ts +0 -10
- package/src/constraint-runtime/src/tools/SafeSDK/getPendingTransactions.ts +0 -10
- package/src/constraint-runtime/src/tools/SafeSDK/proposeTransaction.ts +0 -14
- package/src/constraint-runtime/src/tools/WalletTools/autoPay.ts +0 -58
- package/src/constraint-runtime/src/tools/WalletTools/createWallet.ts +0 -19
- package/src/constraint-runtime/src/tools/WalletTools/getBalance.ts +0 -28
- package/src/constraint-runtime/src/tools/WalletTools/importWallet.ts +0 -34
- package/src/constraint-runtime/src/tools/WalletTools/sendTransaction.ts +0 -50
- package/src/constraint-runtime/src/tools/WalletTools/signMessage.ts +0 -23
- package/src/constraint-runtime/src/tools/WalletTools/transferToken.ts +0 -49
- package/src/constraint-runtime/src/tools.ts +0 -100
- package/src/constraint-runtime/src/transcript.ts +0 -23
- package/src/constraint-runtime/src/types/index.ts +0 -15
- package/src/constraint-runtime/src/upstream_proxy/index.ts +0 -15
- package/src/constraint-runtime/src/utils/index.ts +0 -15
- package/src/constraint-runtime/src/vim/index.ts +0 -15
- package/src/constraint-runtime/src/voice/index.ts +0 -15
- package/src/constraint-runtime/tests/agent.test.ts +0 -20
- package/src/constraint-runtime/tests/constraint.test.ts +0 -47
- package/src/constraint-runtime/tests/skill.test.ts +0 -23
- package/src/constraint-runtime/tests/thinking.test.ts +0 -28
- package/src/constraint-runtime/tsconfig.json +0 -13
- package/src/pi-ecosystem/index.ts +0 -453
- package/src/pi-ecosystem-colony/index.ts +0 -482
- package/src/pi-ecosystem-goals/index.ts +0 -585
- package/src/pi-ecosystem-judgment/decision.ts +0 -431
- package/src/pi-ecosystem-judgment/distillation.ts +0 -398
- package/src/pi-ecosystem-judgment/human-value-store.ts +0 -580
- package/src/pi-ecosystem-judgment/index.ts +0 -678
- package/src/pi-ecosystem-judgment/value-injection.ts +0 -744
- package/src/pi-ecosystem-mcp/index.ts +0 -427
- package/src/pi-ecosystem-subagents/index.ts +0 -408
- package/src/test/ai-judgment-test.ts +0 -92
- package/src/test/bollharness-integration.test.ts +0 -398
- package/src/test/channel-agent-multi-dialogue.ts +0 -265
- package/src/test/channel-heartbeat-agent-test.ts +0 -244
- package/src/test/constraint-layer.test.ts +0 -191
- package/src/test/diap-identity-test.ts +0 -222
- package/src/test/diap-quick-test.ts +0 -73
- package/src/test/global-shared-context.test.ts +0 -393
- package/src/test/harness-judgment-injection.test.ts +0 -353
- package/src/test/harness-workflow-integrator-test.ts +0 -285
- package/src/test/human-value-store.test.ts +0 -316
- package/src/test/hybrid-integration-test.ts +0 -126
- package/src/test/hybrid-messenger-verify.ts +0 -68
- package/src/test/iroh-bistream-debug.ts +0 -50
- package/src/test/iroh-communication.test.ts +0 -81
- package/src/test/iroh-debug-test.ts +0 -69
- package/src/test/iroh-diap-test.ts +0 -90
- package/src/test/iroh-direct-connect.ts +0 -65
- package/src/test/iroh-e2e-fixed.ts +0 -106
- package/src/test/iroh-e2e-same-process.ts +0 -83
- package/src/test/iroh-e2e.ts +0 -83
- package/src/test/iroh-final-e2e.ts +0 -84
- package/src/test/iroh-relay-test.ts +0 -46
- package/src/test/iroh-simple-test.ts +0 -49
- package/src/test/iroh-transport-verify.ts +0 -60
- package/src/test/iroh-transport.test.ts +0 -47
- package/src/test/iroh-two-nodes.ts +0 -87
- package/src/test/iroh-verify.ts +0 -55
- package/src/test/judgment-decision.test.ts +0 -373
- package/src/test/llm-judgment-integration.test.ts +0 -257
- package/src/test/p2p-agent-complex-dialogue.ts +0 -490
- package/src/test/p2p-agent-dialogue.ts +0 -423
- package/src/test/p2p-agent-full-bidirectional.ts +0 -686
- package/src/test/p2p-agent-harness-flow.ts +0 -562
- package/src/test/p2p-agent-harness-single.ts +0 -175
- package/src/test/p2p-ai-dialogue-test.ts +0 -374
- package/src/test/p2p-cid-connect-test.ts +0 -245
- package/src/test/p2p-connect-receiver.ts +0 -85
- package/src/test/p2p-iroh-test.ts +0 -214
- package/src/test/p2p-minimal-test.ts +0 -264
- package/src/test/p2p-node-1.ts +0 -172
- package/src/test/p2p-node-2.ts +0 -172
- package/src/test/p2p-server.ts +0 -335
- package/src/test/p2p-two-nodes-test.ts +0 -542
- package/src/test/pi-sdk.test.ts +0 -47
- package/src/test/set-persona.ts +0 -56
- package/src/test/simple.test.ts +0 -11
- package/src/test/storage-integration.test.ts +0 -191
- package/src/test/subagent-manager.test.ts +0 -392
- package/src/test/test-gate-flow.test.ts +0 -92
- package/src/test/workflow-engine.test.ts +0 -101
- package/src/web/design.md +0 -99
- package/src/workflows/collaboration.ts +0 -455
- package/src/workflows/index.ts +0 -64
- package/vitest.config.ts +0 -12
- package//346/203/263/346/263/225.md +0 -79
|
@@ -1,686 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* P2P Agent Full Bidirectional HTTP Response Test
|
|
3
|
-
* 测试完整双向对话流:HTTP 请求-响应模式
|
|
4
|
-
*
|
|
5
|
-
* 运行: npx tsx src/test/p2p-agent-full-bidirectional.ts
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { config } from 'dotenv';
|
|
9
|
-
import express from 'express';
|
|
10
|
-
import { createServer } from 'http';
|
|
11
|
-
import crypto from 'crypto';
|
|
12
|
-
|
|
13
|
-
config();
|
|
14
|
-
|
|
15
|
-
const PORT_ALICE = 8401;
|
|
16
|
-
const PORT_BOB = 8402;
|
|
17
|
-
const REQUEST_TIMEOUT_MS = 10000;
|
|
18
|
-
|
|
19
|
-
// ============================================================================
|
|
20
|
-
// HTTP 响应类型定义
|
|
21
|
-
// ============================================================================
|
|
22
|
-
|
|
23
|
-
interface HTTPResponse {
|
|
24
|
-
requestId: string;
|
|
25
|
-
type: string;
|
|
26
|
-
payload: string;
|
|
27
|
-
from: string;
|
|
28
|
-
timestamp: number;
|
|
29
|
-
requiresHarness: boolean;
|
|
30
|
-
harnessResult?: {
|
|
31
|
-
gate: number;
|
|
32
|
-
skills: string[];
|
|
33
|
-
result: string;
|
|
34
|
-
};
|
|
35
|
-
followUpRequired: boolean;
|
|
36
|
-
followUpContext?: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// ============================================================================
|
|
40
|
-
// Harness 模块
|
|
41
|
-
// ============================================================================
|
|
42
|
-
|
|
43
|
-
interface HarnessDecision {
|
|
44
|
-
shouldCall: boolean;
|
|
45
|
-
gate: number;
|
|
46
|
-
reason: string;
|
|
47
|
-
skills: string[];
|
|
48
|
-
result: string;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
interface HarnessResult {
|
|
52
|
-
success: boolean;
|
|
53
|
-
gate: number;
|
|
54
|
-
skills: string[];
|
|
55
|
-
result: string;
|
|
56
|
-
message: string;
|
|
57
|
-
followUpRequired: boolean;
|
|
58
|
-
followUpSuggestion?: string;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
class HarnessCore {
|
|
62
|
-
private executionLog: Array<{ gate: number; timestamp: number; input: string }> = [];
|
|
63
|
-
|
|
64
|
-
decide(content: string): HarnessDecision {
|
|
65
|
-
const lower = content.toLowerCase();
|
|
66
|
-
|
|
67
|
-
// Gate 1: 架构设计
|
|
68
|
-
if (lower.includes('架构') || lower.includes('设计') || lower.includes('方案')) {
|
|
69
|
-
return {
|
|
70
|
-
shouldCall: true,
|
|
71
|
-
gate: 1,
|
|
72
|
-
reason: '检测到架构设计相关请求',
|
|
73
|
-
skills: ['arch', 'lead'],
|
|
74
|
-
result: '[Gate 1] 建议采用分层架构:表现层、业务层、数据层分离'
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Gate 2: 代码审查
|
|
79
|
-
if (lower.includes('review') || lower.includes('检查') || lower.includes('审核') || lower.includes('代码')) {
|
|
80
|
-
return {
|
|
81
|
-
shouldCall: true,
|
|
82
|
-
gate: 2,
|
|
83
|
-
reason: '检测到代码审查请求',
|
|
84
|
-
skills: ['arch', 'guardian-fixer'],
|
|
85
|
-
result: '[Gate 2] 建议添加输入验证和错误处理机制'
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Gate 4: 安全检查
|
|
90
|
-
if (lower.includes('安全') || lower.includes('权限') || lower.includes('认证')) {
|
|
91
|
-
return {
|
|
92
|
-
shouldCall: true,
|
|
93
|
-
gate: 4,
|
|
94
|
-
reason: '检测到安全相关请求',
|
|
95
|
-
skills: ['arch', 'guardian-fixer'],
|
|
96
|
-
result: '[Gate 4] 建议实现 JWT token 过期和刷新机制'
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Gate 5: 任务分解
|
|
101
|
-
if (lower.includes('任务') || lower.includes('分解') || lower.includes('计划')) {
|
|
102
|
-
return {
|
|
103
|
-
shouldCall: true,
|
|
104
|
-
gate: 5,
|
|
105
|
-
reason: '检测到任务规划请求',
|
|
106
|
-
skills: ['task-arch', 'crystal-learn'],
|
|
107
|
-
result: '[Gate 5] 已分解为 4 个子任务,按优先级排序'
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Gate 7: 代码实现
|
|
112
|
-
if (lower.includes('实现') || lower.includes('写代码') || lower.includes('开发')) {
|
|
113
|
-
return {
|
|
114
|
-
shouldCall: true,
|
|
115
|
-
gate: 7,
|
|
116
|
-
reason: '检测到代码实现请求',
|
|
117
|
-
skills: ['harness-eng', 'crystal-learn'],
|
|
118
|
-
result: '[Gate 7] 建议使用策略模式重构业务逻辑'
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Gate 8: 测试验证
|
|
123
|
-
if (lower.includes('测试') || lower.includes('验证')) {
|
|
124
|
-
return {
|
|
125
|
-
shouldCall: true,
|
|
126
|
-
gate: 8,
|
|
127
|
-
reason: '检测到测试验证请求',
|
|
128
|
-
skills: ['harness-eng', 'harness-eng-test'],
|
|
129
|
-
result: '[Gate 8] 建议优先测试核心业务逻辑'
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return {
|
|
134
|
-
shouldCall: false,
|
|
135
|
-
gate: 0,
|
|
136
|
-
reason: '普通对话,无需 Harness',
|
|
137
|
-
skills: [],
|
|
138
|
-
result: ''
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
execute(gate: number, content: string): HarnessResult {
|
|
143
|
-
const decision = this.decide(content);
|
|
144
|
-
|
|
145
|
-
if (!decision.shouldCall) {
|
|
146
|
-
return {
|
|
147
|
-
success: true,
|
|
148
|
-
gate: 0,
|
|
149
|
-
skills: [],
|
|
150
|
-
result: '',
|
|
151
|
-
message: '无需 Harness 处理',
|
|
152
|
-
followUpRequired: false
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
this.executionLog.push({ gate: decision.gate, timestamp: Date.now(), input: content });
|
|
157
|
-
|
|
158
|
-
// 根据 Gate 生成更详细的响应
|
|
159
|
-
let detailedResult = '';
|
|
160
|
-
let followUpRequired = false;
|
|
161
|
-
let followUpSuggestion: string | undefined;
|
|
162
|
-
|
|
163
|
-
switch (gate) {
|
|
164
|
-
case 1:
|
|
165
|
-
detailedResult = `${decision.result}\n\n详细建议:\n1. 使用依赖注入降低耦合\n2. 引入接口隔离原则\n3. 考虑使用策略模式处理变化点`;
|
|
166
|
-
followUpRequired = true;
|
|
167
|
-
followUpSuggestion = '需要我进一步分析具体的模块设计吗?';
|
|
168
|
-
break;
|
|
169
|
-
case 2:
|
|
170
|
-
detailedResult = `${decision.result}\n\n审查要点:\n1. 检查边界条件处理\n2. 验证错误处理路径\n3. 确保资源正确释放`;
|
|
171
|
-
followUpRequired = true;
|
|
172
|
-
followUpSuggestion = '需要我帮你 review 具体的代码段吗?';
|
|
173
|
-
break;
|
|
174
|
-
case 4:
|
|
175
|
-
detailedResult = `${decision.result}\n\n安全建议:\n1. 使用 HTTPS 加密传输\n2. 实现 token 过期机制\n3. 添加二次验证层`;
|
|
176
|
-
followUpRequired = true;
|
|
177
|
-
followUpSuggestion = '需要我生成安全检查清单吗?';
|
|
178
|
-
break;
|
|
179
|
-
case 5:
|
|
180
|
-
detailedResult = `${decision.result}\n\n任务分解:\n1. 登录模块 (高优先级)\n2. 注册模块 (高优先级)\n3. 权限管理 (中优先级)\n4. 测试集成 (中优先级)`;
|
|
181
|
-
followUpRequired = false;
|
|
182
|
-
break;
|
|
183
|
-
case 7:
|
|
184
|
-
detailedResult = `${decision.result}\n\n实现计划:\n1. 定义接口契约\n2. 实现核心逻辑\n3. 添加单元测试`;
|
|
185
|
-
followUpRequired = true;
|
|
186
|
-
followUpSuggestion = '需要我帮你实现哪个部分?';
|
|
187
|
-
break;
|
|
188
|
-
case 8:
|
|
189
|
-
detailedResult = `${decision.result}\n\n测试策略:\n1. 单元测试 (覆盖率 80%)\n2. 集成测试\n3. E2E 测试`;
|
|
190
|
-
followUpRequired = true;
|
|
191
|
-
followUpSuggestion = '需要我生成测试用例吗?';
|
|
192
|
-
break;
|
|
193
|
-
default:
|
|
194
|
-
detailedResult = decision.result;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return {
|
|
198
|
-
success: true,
|
|
199
|
-
gate: decision.gate,
|
|
200
|
-
skills: decision.skills,
|
|
201
|
-
result: detailedResult,
|
|
202
|
-
message: `Gate ${decision.gate} 处理完成`,
|
|
203
|
-
followUpRequired,
|
|
204
|
-
followUpSuggestion
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
getExecutionLog() {
|
|
209
|
-
return [...this.executionLog];
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// ============================================================================
|
|
214
|
-
// HTTP 会话管理器
|
|
215
|
-
// ============================================================================
|
|
216
|
-
|
|
217
|
-
interface PendingRequest {
|
|
218
|
-
requestId: string;
|
|
219
|
-
type: string;
|
|
220
|
-
payload: string;
|
|
221
|
-
fromPort: number;
|
|
222
|
-
timestamp: number;
|
|
223
|
-
timeout: ReturnType<typeof setTimeout>;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
class HTTPSessionManager {
|
|
227
|
-
private pendingRequests: Map<string, PendingRequest> = new Map();
|
|
228
|
-
private responseHandlers: Map<string, (response: HTTPResponse) => void> = new Map();
|
|
229
|
-
private agentPort: number;
|
|
230
|
-
|
|
231
|
-
constructor(agentPort: number) {
|
|
232
|
-
this.agentPort = agentPort;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
createRequest(type: string, payload: string, fromPort: number): string {
|
|
236
|
-
const requestId = crypto.randomUUID();
|
|
237
|
-
const timeout = setTimeout(() => {
|
|
238
|
-
this.failRequest(requestId, new Error('Request timeout'));
|
|
239
|
-
}, REQUEST_TIMEOUT_MS);
|
|
240
|
-
|
|
241
|
-
this.pendingRequests.set(requestId, {
|
|
242
|
-
requestId,
|
|
243
|
-
type,
|
|
244
|
-
payload,
|
|
245
|
-
fromPort,
|
|
246
|
-
timestamp: Date.now(),
|
|
247
|
-
timeout
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
return requestId;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
completeRequest(requestId: string, response: HTTPResponse): void {
|
|
254
|
-
const pending = this.pendingRequests.get(requestId);
|
|
255
|
-
if (pending) {
|
|
256
|
-
clearTimeout(pending.timeout);
|
|
257
|
-
this.pendingRequests.delete(requestId);
|
|
258
|
-
|
|
259
|
-
const handler = this.responseHandlers.get(requestId);
|
|
260
|
-
if (handler) {
|
|
261
|
-
handler(response);
|
|
262
|
-
this.responseHandlers.delete(requestId);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
failRequest(requestId: string, error: Error): void {
|
|
268
|
-
const pending = this.pendingRequests.get(requestId);
|
|
269
|
-
if (pending) {
|
|
270
|
-
clearTimeout(pending.timeout);
|
|
271
|
-
this.pendingRequests.delete(requestId);
|
|
272
|
-
|
|
273
|
-
const handler = this.responseHandlers.get(requestId);
|
|
274
|
-
if (handler) {
|
|
275
|
-
handler({
|
|
276
|
-
requestId,
|
|
277
|
-
type: 'error',
|
|
278
|
-
payload: error.message,
|
|
279
|
-
from: '',
|
|
280
|
-
timestamp: Date.now(),
|
|
281
|
-
requiresHarness: false,
|
|
282
|
-
followUpRequired: false
|
|
283
|
-
});
|
|
284
|
-
this.responseHandlers.delete(requestId);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
onResponse(requestId: string, handler: (response: HTTPResponse) => void): void {
|
|
290
|
-
this.responseHandlers.set(requestId, handler);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
getPendingRequests(): PendingRequest[] {
|
|
294
|
-
return Array.from(this.pendingRequests.values());
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
clear(): void {
|
|
298
|
-
for (const req of this.pendingRequests.values()) {
|
|
299
|
-
clearTimeout(req.timeout);
|
|
300
|
-
}
|
|
301
|
-
this.pendingRequests.clear();
|
|
302
|
-
this.responseHandlers.clear();
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// ============================================================================
|
|
307
|
-
// 智能体
|
|
308
|
-
// ============================================================================
|
|
309
|
-
|
|
310
|
-
interface AgentMessage {
|
|
311
|
-
id: string;
|
|
312
|
-
requestId?: string;
|
|
313
|
-
from: string;
|
|
314
|
-
to: string;
|
|
315
|
-
content: string;
|
|
316
|
-
timestamp: number;
|
|
317
|
-
response?: HTTPResponse;
|
|
318
|
-
processed: boolean;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
class Agent {
|
|
322
|
-
id = crypto.randomUUID();
|
|
323
|
-
name: string;
|
|
324
|
-
port: number;
|
|
325
|
-
harness = new HarnessCore();
|
|
326
|
-
sessionManager: HTTPSessionManager;
|
|
327
|
-
messages: AgentMessage[] = [];
|
|
328
|
-
peerPort: number | null = null;
|
|
329
|
-
|
|
330
|
-
constructor(name: string, port: number) {
|
|
331
|
-
this.name = name;
|
|
332
|
-
this.port = port;
|
|
333
|
-
this.sessionManager = new HTTPSessionManager(port);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
async start(): Promise<void> {
|
|
337
|
-
const app = express();
|
|
338
|
-
app.use(express.json());
|
|
339
|
-
|
|
340
|
-
// 健康检查
|
|
341
|
-
app.get('/health', (req, res) => {
|
|
342
|
-
res.json({
|
|
343
|
-
id: this.id,
|
|
344
|
-
name: this.name,
|
|
345
|
-
port: this.port,
|
|
346
|
-
messageCount: this.messages.length,
|
|
347
|
-
pendingRequests: this.sessionManager.getPendingRequests().length
|
|
348
|
-
});
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
// 发现端点
|
|
352
|
-
app.get('/discovery', (req, res) => {
|
|
353
|
-
res.json({
|
|
354
|
-
id: this.id,
|
|
355
|
-
name: this.name,
|
|
356
|
-
port: this.port,
|
|
357
|
-
capabilities: ['http-response', 'harness']
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
// 接收请求并发送响应
|
|
362
|
-
app.post('/request', async (req, res) => {
|
|
363
|
-
const { requestId, fromName, type, content, context } = req.body;
|
|
364
|
-
|
|
365
|
-
console.log(`\n📨 [${this.name}] 收到请求 from ${fromName}:`);
|
|
366
|
-
console.log(` Type: ${type}`);
|
|
367
|
-
console.log(` Content: "${content.substring(0, 50)}..."`);
|
|
368
|
-
|
|
369
|
-
// 处理请求
|
|
370
|
-
const decision = this.harness.decide(content);
|
|
371
|
-
|
|
372
|
-
let response: HTTPResponse;
|
|
373
|
-
if (decision.shouldCall) {
|
|
374
|
-
console.log(`🧠 [${this.name}] 调用 Harness: Gate ${decision.gate}`);
|
|
375
|
-
|
|
376
|
-
const harnessResult = this.harness.execute(decision.gate, content);
|
|
377
|
-
|
|
378
|
-
response = {
|
|
379
|
-
requestId: requestId || crypto.randomUUID(),
|
|
380
|
-
type: 'harness-response',
|
|
381
|
-
payload: harnessResult.result,
|
|
382
|
-
from: this.name,
|
|
383
|
-
timestamp: Date.now(),
|
|
384
|
-
requiresHarness: true,
|
|
385
|
-
harnessResult: {
|
|
386
|
-
gate: harnessResult.gate,
|
|
387
|
-
skills: harnessResult.skills,
|
|
388
|
-
result: harnessResult.result
|
|
389
|
-
},
|
|
390
|
-
followUpRequired: harnessResult.followUpRequired,
|
|
391
|
-
followUpContext: harnessResult.followUpSuggestion
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
console.log(` 📋 Skills: ${harnessResult.skills.join(', ')}`);
|
|
395
|
-
console.log(` 📤 响应: ${harnessResult.result.substring(0, 50)}...`);
|
|
396
|
-
} else {
|
|
397
|
-
console.log(`🧠 [${this.name}] 普通响应 (无需 Harness)`);
|
|
398
|
-
|
|
399
|
-
const naturalResponse = this.generateNaturalResponse(content);
|
|
400
|
-
|
|
401
|
-
response = {
|
|
402
|
-
requestId: requestId || crypto.randomUUID(),
|
|
403
|
-
type: 'natural-response',
|
|
404
|
-
payload: naturalResponse,
|
|
405
|
-
from: this.name,
|
|
406
|
-
timestamp: Date.now(),
|
|
407
|
-
requiresHarness: false,
|
|
408
|
-
followUpRequired: false
|
|
409
|
-
};
|
|
410
|
-
|
|
411
|
-
console.log(` 📤 响应: ${naturalResponse.substring(0, 50)}...`);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
// 记录消息
|
|
415
|
-
this.messages.push({
|
|
416
|
-
id: crypto.randomUUID(),
|
|
417
|
-
requestId,
|
|
418
|
-
from: fromName,
|
|
419
|
-
to: this.name,
|
|
420
|
-
content,
|
|
421
|
-
timestamp: Date.now(),
|
|
422
|
-
response,
|
|
423
|
-
processed: true
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
// 发送响应
|
|
427
|
-
res.json(response);
|
|
428
|
-
});
|
|
429
|
-
|
|
430
|
-
// 接收响应 (处理来自其他智能体的响应)
|
|
431
|
-
app.post('/response', async (req, res) => {
|
|
432
|
-
const response: HTTPResponse = req.body;
|
|
433
|
-
|
|
434
|
-
console.log(`\n📥 [${this.name}] 收到响应 from ${response.from}:`);
|
|
435
|
-
console.log(` Type: ${response.type}`);
|
|
436
|
-
console.log(` Payload: "${response.payload.substring(0, 50)}..."`);
|
|
437
|
-
|
|
438
|
-
if (response.requiresHarness && response.harnessResult) {
|
|
439
|
-
console.log(`🧠 [${this.name}] 响应包含 Harness 结果: Gate ${response.harnessResult.gate}`);
|
|
440
|
-
console.log(` Skills: ${response.harnessResult.skills.join(', ')}`);
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
// 完成挂起的请求
|
|
444
|
-
if (response.requestId) {
|
|
445
|
-
this.sessionManager.completeRequest(response.requestId, response);
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
res.json({ ok: true });
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
const server = createServer(app);
|
|
452
|
-
return new Promise(resolve => {
|
|
453
|
-
server.listen(this.port, () => {
|
|
454
|
-
console.log(`✓ [${this.name}] 启动 on port ${this.port}`);
|
|
455
|
-
resolve();
|
|
456
|
-
});
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
private generateNaturalResponse(content: string): string {
|
|
461
|
-
const lower = content.toLowerCase();
|
|
462
|
-
|
|
463
|
-
if (lower.includes('你好') || lower.includes('hi') || lower.includes('hello')) {
|
|
464
|
-
return `你好!我是 ${this.name},有什么可以帮你的吗?`;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
if (lower.includes('谢谢') || lower.includes('感谢')) {
|
|
468
|
-
return `不客气!还有其他需要帮助的吗?`;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
if (lower.includes('?') || lower.includes('?')) {
|
|
472
|
-
return `这是个有趣的问题。让我想想...`;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
const responses = [
|
|
476
|
-
'明白了!',
|
|
477
|
-
'好的,我理解。',
|
|
478
|
-
'收到,让我处理一下。',
|
|
479
|
-
'没问题!',
|
|
480
|
-
'好的,继续。'
|
|
481
|
-
];
|
|
482
|
-
|
|
483
|
-
return responses[Math.floor(Math.random() * responses.length)];
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
setPeer(port: number): void {
|
|
487
|
-
this.peerPort = port;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
async sendRequest(targetPort: number, type: string, content: string, relatedRequestId?: string): Promise<HTTPResponse | null> {
|
|
491
|
-
const requestId = crypto.randomUUID();
|
|
492
|
-
|
|
493
|
-
console.log(`\n📤 [${this.name}] 发送请求 to port ${targetPort}:`);
|
|
494
|
-
console.log(` RequestId: ${requestId}`);
|
|
495
|
-
console.log(` Type: ${type}`);
|
|
496
|
-
console.log(` Content: "${content.substring(0, 50)}..."`);
|
|
497
|
-
|
|
498
|
-
try {
|
|
499
|
-
const res = await fetch(`http://localhost:${targetPort}/request`, {
|
|
500
|
-
method: 'POST',
|
|
501
|
-
headers: { 'Content-Type': 'application/json' },
|
|
502
|
-
body: JSON.stringify({
|
|
503
|
-
requestId,
|
|
504
|
-
fromName: this.name,
|
|
505
|
-
type,
|
|
506
|
-
content,
|
|
507
|
-
context: relatedRequestId
|
|
508
|
-
})
|
|
509
|
-
});
|
|
510
|
-
|
|
511
|
-
const response: HTTPResponse = await res.json();
|
|
512
|
-
|
|
513
|
-
console.log(`\n✅ [${this.name}] 收到响应`);
|
|
514
|
-
|
|
515
|
-
// 记录消息
|
|
516
|
-
this.messages.push({
|
|
517
|
-
id: crypto.randomUUID(),
|
|
518
|
-
requestId,
|
|
519
|
-
from: this.name,
|
|
520
|
-
to: `port:${targetPort}`,
|
|
521
|
-
content,
|
|
522
|
-
timestamp: Date.now(),
|
|
523
|
-
response,
|
|
524
|
-
processed: true
|
|
525
|
-
});
|
|
526
|
-
|
|
527
|
-
return response;
|
|
528
|
-
} catch (err) {
|
|
529
|
-
console.error(`❌ [${this.name}] 请求失败:`, err);
|
|
530
|
-
return null;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
getMessages(): AgentMessage[] {
|
|
535
|
-
return [...this.messages];
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
async stop(): Promise<void> {
|
|
539
|
-
this.sessionManager.clear();
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
// ============================================================================
|
|
544
|
-
// 测试场景
|
|
545
|
-
// ============================================================================
|
|
546
|
-
|
|
547
|
-
async function runFullBidirectionalTest() {
|
|
548
|
-
console.log('\n========================================');
|
|
549
|
-
console.log(' P2P Agent Full Bidirectional HTTP Test');
|
|
550
|
-
console.log(' 场景: 完整双向对话流 + Harness 调用');
|
|
551
|
-
console.log('========================================\n');
|
|
552
|
-
|
|
553
|
-
const alice = new Agent('Alice', PORT_ALICE);
|
|
554
|
-
const bob = new Agent('Bob', PORT_BOB);
|
|
555
|
-
|
|
556
|
-
// 设置邻居关系
|
|
557
|
-
alice.setPeer(PORT_BOB);
|
|
558
|
-
bob.setPeer(PORT_ALICE);
|
|
559
|
-
|
|
560
|
-
console.log('━━━ 启动智能体 ━━━\n');
|
|
561
|
-
await alice.start();
|
|
562
|
-
await bob.start();
|
|
563
|
-
|
|
564
|
-
console.log('\n━━━ 对话 1: 架构分析 (需要 Harness + 跟进) ━━━\n');
|
|
565
|
-
|
|
566
|
-
const response1 = await alice.sendRequest(PORT_BOB, 'analysis', 'Bob,我们需要设计一个用户认证系统,请帮我分析一下架构。');
|
|
567
|
-
|
|
568
|
-
if (response1) {
|
|
569
|
-
console.log(`\n✅ [Alice] 收到 Bob 的响应:`);
|
|
570
|
-
console.log(` 类型: ${response1.type}`);
|
|
571
|
-
console.log(` 需要 Harness: ${response1.requiresHarness}`);
|
|
572
|
-
if (response1.harnessResult) {
|
|
573
|
-
console.log(` Gate: ${response1.harnessResult.gate}`);
|
|
574
|
-
console.log(` Skills: ${response1.harnessResult.skills.join(', ')}`);
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
await new Promise(r => setTimeout(r, 1000));
|
|
579
|
-
|
|
580
|
-
console.log('\n━━━ 对话 2: 代码审查 (需要 Harness + 跟进) ━━━\n');
|
|
581
|
-
|
|
582
|
-
const response2 = await bob.sendRequest(PORT_ALICE, 'review', 'Alice,帮我 review 一下登录模块的代码实现。');
|
|
583
|
-
|
|
584
|
-
if (response2) {
|
|
585
|
-
console.log(`\n✅ [Bob] 收到 Alice 的响应:`);
|
|
586
|
-
console.log(` 类型: ${response2.type}`);
|
|
587
|
-
console.log(` 需要 Harness: ${response2.requiresHarness}`);
|
|
588
|
-
if (response2.harnessResult) {
|
|
589
|
-
console.log(` Gate: ${response2.harnessResult.gate}`);
|
|
590
|
-
console.log(` Skills: ${response2.harnessResult.skills.join(', ')}`);
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
await new Promise(r => setTimeout(r, 1000));
|
|
595
|
-
|
|
596
|
-
console.log('\n━━━ 对话 3: 简单问候 (无需 Harness) ━━━\n');
|
|
597
|
-
|
|
598
|
-
const response3 = await alice.sendRequest(PORT_BOB, 'greeting', 'Bob,你好吗?最近项目进展如何?');
|
|
599
|
-
|
|
600
|
-
if (response3) {
|
|
601
|
-
console.log(`\n✅ [Alice] 收到 Bob 的响应:`);
|
|
602
|
-
console.log(` 类型: ${response3.type}`);
|
|
603
|
-
console.log(` 需要 Harness: ${response3.requiresHarness}`);
|
|
604
|
-
console.log(` 内容: ${response3.payload}`);
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
await new Promise(r => setTimeout(r, 1000));
|
|
608
|
-
|
|
609
|
-
console.log('\n━━━ 对话 4: 任务分解 (需要 Harness) ━━━\n');
|
|
610
|
-
|
|
611
|
-
const response4 = await bob.sendRequest(PORT_ALICE, 'planning', 'Alice,我们需要完成用户管理功能,请帮我分解一下任务。');
|
|
612
|
-
|
|
613
|
-
if (response4) {
|
|
614
|
-
console.log(`\n✅ [Bob] 收到 Alice 的响应:`);
|
|
615
|
-
console.log(` 类型: ${response4.type}`);
|
|
616
|
-
console.log(` 需要 Harness: ${response4.requiresHarness}`);
|
|
617
|
-
if (response4.harnessResult) {
|
|
618
|
-
console.log(` Gate: ${response4.harnessResult.gate}`);
|
|
619
|
-
console.log(` 内容: ${response4.harnessResult.result.substring(0, 80)}...`);
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
await new Promise(r => setTimeout(r, 1000));
|
|
624
|
-
|
|
625
|
-
console.log('\n━━━ 结果汇总 ━━━\n');
|
|
626
|
-
|
|
627
|
-
const aliceMessages = alice.getMessages();
|
|
628
|
-
const bobMessages = bob.getMessages();
|
|
629
|
-
|
|
630
|
-
console.log(`[Alice] 消息数: ${aliceMessages.length}`);
|
|
631
|
-
console.log(`[Bob] 消息数: ${bobMessages.length}`);
|
|
632
|
-
|
|
633
|
-
// 统计 Harness 调用
|
|
634
|
-
const harnessCalls = [...aliceMessages, ...bobMessages].filter(m =>
|
|
635
|
-
m.response?.requiresHarness
|
|
636
|
-
);
|
|
637
|
-
|
|
638
|
-
console.log(`\nHarness 调用次数: ${harnessCalls.length}`);
|
|
639
|
-
|
|
640
|
-
console.log('\nHarness 调用详情:');
|
|
641
|
-
harnessCalls.forEach((call, i) => {
|
|
642
|
-
console.log(` ${i + 1}. [${call.from}] -> [${call.to}]`);
|
|
643
|
-
if (call.response?.harnessResult) {
|
|
644
|
-
console.log(` Gate: ${call.response.harnessResult.gate}`);
|
|
645
|
-
console.log(` Skills: ${call.response.harnessResult.skills.join(', ')}`);
|
|
646
|
-
}
|
|
647
|
-
});
|
|
648
|
-
|
|
649
|
-
// 展示完整对话流
|
|
650
|
-
console.log('\n━━━ 完整对话流 ━━━\n');
|
|
651
|
-
|
|
652
|
-
const allMessages = [...aliceMessages, ...bobMessages]
|
|
653
|
-
.sort((a, b) => a.timestamp - b.timestamp)
|
|
654
|
-
.slice(0, 20);
|
|
655
|
-
|
|
656
|
-
for (const msg of allMessages) {
|
|
657
|
-
const harnessIcon = msg.response?.requiresHarness ? '🧠' : ' ';
|
|
658
|
-
const gateInfo = msg.response?.harnessResult ? ` [Gate ${msg.response.harnessResult.gate}]` : '';
|
|
659
|
-
console.log(`${harnessIcon} [${msg.from}]${gateInfo}: ${msg.content.substring(0, 40)}...`);
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
// 健康检查
|
|
663
|
-
console.log('\n━━━ 最终状态 ━━━\n');
|
|
664
|
-
const aliceHealth = await fetch(`http://localhost:${PORT_ALICE}/health`).then(r => r.json());
|
|
665
|
-
const bobHealth = await fetch(`http://localhost:${PORT_BOB}/health`).then(r => r.json());
|
|
666
|
-
|
|
667
|
-
console.log(`[Alice] ID: ${aliceHealth.id.substring(0, 16)}...`);
|
|
668
|
-
console.log(`[Bob] ID: ${bobHealth.id.substring(0, 16)}...`);
|
|
669
|
-
console.log(`\n总消息数: ${aliceMessages.length + bobMessages.length}`);
|
|
670
|
-
console.log(`Harness 调用: ${harnessCalls.length} 次`);
|
|
671
|
-
|
|
672
|
-
// 判断测试成功
|
|
673
|
-
const success = harnessCalls.length >= 3;
|
|
674
|
-
console.log(`\n${success ? '✅' : '⚠️'} ${success ? '测试成功' : '测试部分成功'}`);
|
|
675
|
-
|
|
676
|
-
console.log('\n========================================\n');
|
|
677
|
-
|
|
678
|
-
// 清理
|
|
679
|
-
await alice.stop();
|
|
680
|
-
await bob.stop();
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
runFullBidirectionalTest().catch(err => {
|
|
684
|
-
console.error('测试失败:', err);
|
|
685
|
-
process.exit(1);
|
|
686
|
-
});
|