@bolloon/bolloon-agent 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/README.md +462 -0
- package/dist/agents/constraint-layer.js +211 -0
- package/dist/agents/constraint-layer.js.map +1 -0
- package/dist/agents/pi-sdk.js +1199 -0
- package/dist/agents/pi-sdk.js.map +1 -0
- package/dist/agents/protocol.js +229 -0
- package/dist/agents/subagent-manager.js +361 -0
- package/dist/agents/workflow-engine.js +222 -0
- package/dist/agents/workflow-engine.js.map +1 -0
- package/dist/bollharness-integration/bollharness-integration/context-router-judgment.d.ts +48 -0
- package/dist/bollharness-integration/bollharness-integration/context-router-judgment.js +261 -0
- package/dist/bollharness-integration/bollharness-integration/context-router.d.ts +110 -0
- package/dist/bollharness-integration/bollharness-integration/context-router.js +542 -0
- package/dist/bollharness-integration/bollharness-integration/gate-state-machine.d.ts +87 -0
- package/dist/bollharness-integration/bollharness-integration/gate-state-machine.js +231 -0
- package/dist/bollharness-integration/bollharness-integration/gate-transition-hooks.d.ts +30 -0
- package/dist/bollharness-integration/bollharness-integration/gate-transition-hooks.js +91 -0
- package/dist/bollharness-integration/bollharness-integration/guard-checker.d.ts +105 -0
- package/dist/bollharness-integration/bollharness-integration/guard-checker.js +353 -0
- package/dist/bollharness-integration/bollharness-integration/index.d.ts +66 -0
- package/dist/bollharness-integration/bollharness-integration/index.js +32 -0
- package/dist/bollharness-integration/bollharness-integration/integration.d.ts +219 -0
- package/dist/bollharness-integration/bollharness-integration/integration.js +420 -0
- package/dist/bollharness-integration/bollharness-integration/skill-adapter.d.ts +151 -0
- package/dist/bollharness-integration/bollharness-integration/skill-adapter.js +518 -0
- package/dist/bollharness-integration/context-router-judgment.js +269 -0
- package/dist/bollharness-integration/context-router-judgment.js.map +1 -0
- package/dist/bollharness-integration/context-router.js +584 -0
- package/dist/bollharness-integration/context-router.js.map +1 -0
- package/dist/bollharness-integration/gate-state-machine.js +349 -0
- package/dist/bollharness-integration/gate-state-machine.js.map +1 -0
- package/dist/bollharness-integration/gate-transition-hooks.js +136 -0
- package/dist/bollharness-integration/gate-transition-hooks.js.map +1 -0
- package/dist/bollharness-integration/guard-checker.js +400 -0
- package/dist/bollharness-integration/guard-checker.js.map +1 -0
- package/dist/bollharness-integration/index.js +142 -0
- package/dist/bollharness-integration/index.js.map +1 -0
- package/dist/bollharness-integration/integration.js +427 -0
- package/dist/bollharness-integration/integration.js.map +1 -0
- package/dist/bollharness-integration/llm/pi-ai.d.ts +60 -0
- package/dist/bollharness-integration/llm/pi-ai.js +397 -0
- package/dist/bollharness-integration/pi-ecosystem-colony/index.d.ts +153 -0
- package/dist/bollharness-integration/pi-ecosystem-colony/index.js +365 -0
- package/dist/bollharness-integration/pi-ecosystem-goals/index.d.ts +136 -0
- package/dist/bollharness-integration/pi-ecosystem-goals/index.js +458 -0
- package/dist/bollharness-integration/pi-ecosystem-judgment/decision.d.ts +117 -0
- package/dist/bollharness-integration/pi-ecosystem-judgment/decision.js +300 -0
- package/dist/bollharness-integration/pi-ecosystem-judgment/distillation.d.ts +78 -0
- package/dist/bollharness-integration/pi-ecosystem-judgment/distillation.js +291 -0
- package/dist/bollharness-integration/pi-ecosystem-judgment/index.d.ts +139 -0
- package/dist/bollharness-integration/pi-ecosystem-judgment/index.js +445 -0
- package/dist/bollharness-integration/pi-ecosystem-mcp/index.d.ts +127 -0
- package/dist/bollharness-integration/pi-ecosystem-mcp/index.js +331 -0
- package/dist/bollharness-integration/pi-ecosystem-subagents/index.d.ts +95 -0
- package/dist/bollharness-integration/pi-ecosystem-subagents/index.js +303 -0
- package/dist/bollharness-integration/skill-adapter.js +564 -0
- package/dist/bollharness-integration/skill-adapter.js.map +1 -0
- package/dist/cli/interface.js +181 -0
- package/dist/constraint-runtime/src/_archive_helper.js +9 -0
- package/dist/constraint-runtime/src/agent/coordinator.js +48 -0
- package/dist/constraint-runtime/src/agent/index.js +1 -0
- package/dist/constraint-runtime/src/assistant/index.js +12 -0
- package/dist/constraint-runtime/src/bootstrap/index.js +12 -0
- package/dist/constraint-runtime/src/bootstrap_graph.js +13 -0
- package/dist/constraint-runtime/src/bridge/index.js +12 -0
- package/dist/constraint-runtime/src/buddy/index.js +12 -0
- package/dist/constraint-runtime/src/cli/index.js +12 -0
- package/dist/constraint-runtime/src/command_graph.js +10 -0
- package/dist/constraint-runtime/src/commands.js +50 -0
- package/dist/constraint-runtime/src/components/index.js +12 -0
- package/dist/constraint-runtime/src/constants/index.js +12 -0
- package/dist/constraint-runtime/src/constraint/budget.js +27 -0
- package/dist/constraint-runtime/src/constraint/budget.js.map +1 -0
- package/dist/constraint-runtime/src/constraint/index.js +2 -0
- package/dist/constraint-runtime/src/constraint/permission.js +25 -0
- package/dist/constraint-runtime/src/constraint/permission.js.map +1 -0
- package/dist/constraint-runtime/src/context.js +30 -0
- package/dist/constraint-runtime/src/coordinator/index.js +12 -0
- package/dist/constraint-runtime/src/cost_hook.js +4 -0
- package/dist/constraint-runtime/src/cost_tracker.js +8 -0
- package/dist/constraint-runtime/src/deferred_init.js +10 -0
- package/dist/constraint-runtime/src/direct_modes.js +6 -0
- package/dist/constraint-runtime/src/dynamic-tool-loader.js +85 -0
- package/dist/constraint-runtime/src/entrypoints/index.js +12 -0
- package/dist/constraint-runtime/src/execution_registry.js +44 -0
- package/dist/constraint-runtime/src/history.js +9 -0
- package/dist/constraint-runtime/src/hooks/index.js +12 -0
- package/dist/constraint-runtime/src/index.js +26 -0
- package/dist/constraint-runtime/src/ink.js +4 -0
- package/dist/constraint-runtime/src/keybindings/index.js +12 -0
- package/dist/constraint-runtime/src/memdir/index.js +12 -0
- package/dist/constraint-runtime/src/migrations/index.js +12 -0
- package/dist/constraint-runtime/src/models.js +3 -0
- package/dist/constraint-runtime/src/models.js.map +1 -0
- package/dist/constraint-runtime/src/moreright/index.js +12 -0
- package/dist/constraint-runtime/src/native_ts/index.js +12 -0
- package/dist/constraint-runtime/src/output_styles/index.js +12 -0
- package/dist/constraint-runtime/src/parity_audit.js +12 -0
- package/dist/constraint-runtime/src/plugins/index.js +12 -0
- package/dist/constraint-runtime/src/port_manifest.js +11 -0
- package/dist/constraint-runtime/src/prefetch.js +9 -0
- package/dist/constraint-runtime/src/query.js +1 -0
- package/dist/constraint-runtime/src/remote/index.js +12 -0
- package/dist/constraint-runtime/src/remote_runtime.js +9 -0
- package/dist/constraint-runtime/src/runtime/index.js +1 -0
- package/dist/constraint-runtime/src/runtime/session.js +35 -0
- package/dist/constraint-runtime/src/schemas/index.js +12 -0
- package/dist/constraint-runtime/src/screens/index.js +12 -0
- package/dist/constraint-runtime/src/server/index.js +12 -0
- package/dist/constraint-runtime/src/services/index.js +12 -0
- package/dist/constraint-runtime/src/session_store.js +22 -0
- package/dist/constraint-runtime/src/setup.js +30 -0
- package/dist/constraint-runtime/src/skills/index.js +1 -0
- package/dist/constraint-runtime/src/skills/skill-registry.js +28 -0
- package/dist/constraint-runtime/src/state/index.js +12 -0
- package/dist/constraint-runtime/src/system_init.js +20 -0
- package/dist/constraint-runtime/src/thinking/engine.js +42 -0
- package/dist/constraint-runtime/src/thinking/index.js +1 -0
- package/dist/constraint-runtime/src/tool_pool.js +8 -0
- package/dist/constraint-runtime/src/tools/OpenCLI/execAdapter.js +7 -0
- package/dist/constraint-runtime/src/tools/OpenCLI/listAdapters.js +7 -0
- package/dist/constraint-runtime/src/tools/OpenCLI/runCommand.js +7 -0
- package/dist/constraint-runtime/src/tools/PolymarketSDK/cancelOrder.js +6 -0
- package/dist/constraint-runtime/src/tools/PolymarketSDK/createOrder.js +6 -0
- package/dist/constraint-runtime/src/tools/PolymarketSDK/getMarket.js +5 -0
- package/dist/constraint-runtime/src/tools/PolymarketSDK/getOrders.js +6 -0
- package/dist/constraint-runtime/src/tools/PolymarketSDK/listMarkets.js +4 -0
- package/dist/constraint-runtime/src/tools/SafeSDK/confirmTransaction.js +6 -0
- package/dist/constraint-runtime/src/tools/SafeSDK/createTransaction.js +8 -0
- package/dist/constraint-runtime/src/tools/SafeSDK/deploySafe.js +6 -0
- package/dist/constraint-runtime/src/tools/SafeSDK/executeTransaction.js +6 -0
- package/dist/constraint-runtime/src/tools/SafeSDK/getBalance.js +6 -0
- package/dist/constraint-runtime/src/tools/SafeSDK/getPendingTransactions.js +6 -0
- package/dist/constraint-runtime/src/tools/SafeSDK/proposeTransaction.js +6 -0
- package/dist/constraint-runtime/src/tools/WalletTools/autoPay.js +29 -0
- package/dist/constraint-runtime/src/tools/WalletTools/createWallet.js +10 -0
- package/dist/constraint-runtime/src/tools/WalletTools/getBalance.js +13 -0
- package/dist/constraint-runtime/src/tools/WalletTools/importWallet.js +22 -0
- package/dist/constraint-runtime/src/tools/WalletTools/sendTransaction.js +25 -0
- package/dist/constraint-runtime/src/tools/WalletTools/signMessage.js +10 -0
- package/dist/constraint-runtime/src/tools/WalletTools/transferToken.js +25 -0
- package/dist/constraint-runtime/src/tools.js +70 -0
- package/dist/constraint-runtime/src/transcript.js +19 -0
- package/dist/constraint-runtime/src/types/index.js +12 -0
- package/dist/constraint-runtime/src/upstream_proxy/index.js +12 -0
- package/dist/constraint-runtime/src/utils/index.js +12 -0
- package/dist/constraint-runtime/src/vim/index.js +12 -0
- package/dist/constraint-runtime/src/voice/index.js +12 -0
- package/dist/constraint-runtime/tests/agent.test.js +16 -0
- package/dist/constraint-runtime/tests/constraint.test.js +41 -0
- package/dist/constraint-runtime/tests/skill.test.js +19 -0
- package/dist/constraint-runtime/tests/thinking.test.js +22 -0
- package/dist/constraints/commands.js +100 -0
- package/dist/constraints/index.js +11 -0
- package/dist/constraints/index.js.map +1 -0
- package/dist/constraints/permissions.js +37 -0
- package/dist/constraints/runtime.js +135 -0
- package/dist/constraints/session.js +48 -0
- package/dist/constraints/system-init.js +51 -0
- package/dist/constraints/tools.js +104 -0
- package/dist/documents/reader.js +104 -0
- package/dist/documents/reader.js.map +1 -0
- package/dist/electron-preload.js +15 -0
- package/dist/electron-preload.js.map +1 -0
- package/dist/electron.js +206 -0
- package/dist/electron.js.map +1 -0
- package/dist/index.js +1053 -0
- package/dist/llm/config-store.js +301 -0
- package/dist/llm/config-store.js.map +1 -0
- package/dist/llm/minimax-provider.js +46 -0
- package/dist/llm/minimax.js +45 -0
- package/dist/llm/pi-ai.js +471 -0
- package/dist/llm/pi-ai.js.map +1 -0
- package/dist/network/agent-network.js +692 -0
- package/dist/network/agent-network.js.map +1 -0
- package/dist/network/iroh-integration.js +117 -0
- package/dist/network/iroh-integration.js.map +1 -0
- package/dist/network/iroh-transport.js +506 -0
- package/dist/network/iroh-transport.js.map +1 -0
- package/dist/network/p2p.js +864 -0
- package/dist/network/p2p.js.map +1 -0
- package/dist/network/storage/adapters/json-adapter.js +401 -0
- package/dist/network/storage/adapters/json-adapter.js.map +1 -0
- package/dist/pi-ecosystem-colony/index.js +426 -0
- package/dist/pi-ecosystem-colony/index.js.map +1 -0
- package/dist/pi-ecosystem-goals/index.js +512 -0
- package/dist/pi-ecosystem-goals/index.js.map +1 -0
- package/dist/pi-ecosystem-judgment/decision.js +318 -0
- package/dist/pi-ecosystem-judgment/decision.js.map +1 -0
- package/dist/pi-ecosystem-judgment/distillation.js +304 -0
- package/dist/pi-ecosystem-judgment/distillation.js.map +1 -0
- package/dist/pi-ecosystem-judgment/human-value-store.js +463 -0
- package/dist/pi-ecosystem-judgment/human-value-store.js.map +1 -0
- package/dist/pi-ecosystem-judgment/index.js +581 -0
- package/dist/pi-ecosystem-judgment/index.js.map +1 -0
- package/dist/pi-ecosystem-judgment/value-injection.js +592 -0
- package/dist/pi-ecosystem-judgment/value-injection.js.map +1 -0
- package/dist/pi-ecosystem-mcp/index.js +385 -0
- package/dist/pi-ecosystem-mcp/index.js.map +1 -0
- package/dist/pi-ecosystem-subagents/index.js +352 -0
- package/dist/pi-ecosystem-subagents/index.js.map +1 -0
- package/dist/runtime/context/minimax-prompt.js +178 -0
- package/dist/runtime/context/sys-prompt.js +1 -0
- package/dist/social/ant-colony/AdaptiveHeartbeat.js +106 -0
- package/dist/social/ant-colony/AdaptiveHeartbeat.js.map +1 -0
- package/dist/social/ant-colony/PheromoneEngine.js +265 -0
- package/dist/social/ant-colony/PheromoneEngine.js.map +1 -0
- package/dist/social/ant-colony/types.js +28 -0
- package/dist/social/ant-colony/types.js.map +1 -0
- package/dist/social/channels/ChannelManager.js +444 -0
- package/dist/social/channels/ChannelManager.js.map +1 -0
- package/dist/social/channels/DiapChannelBridge.js +451 -0
- package/dist/social/channels/DiapChannelBridge.js.map +1 -0
- package/dist/social/channels/InterestMatcher.js +135 -0
- package/dist/social/channels/InterestMatcher.js.map +1 -0
- package/dist/social/channels/types.js +21 -0
- package/dist/social/channels/types.js.map +1 -0
- package/dist/social/global-shared-context.js +368 -0
- package/dist/social/global-shared-context.js.map +1 -0
- package/dist/social/heartbeat.js +865 -0
- package/dist/social/heartbeat.js.map +1 -0
- package/dist/test/constraint-layer.test.js +164 -0
- package/dist/test/global-shared-context.test.js +315 -0
- package/dist/test/pi-sdk.test.js +47 -0
- package/dist/test/set-persona.test.js +38 -0
- package/dist/test/subagent-manager.test.js +276 -0
- package/dist/test/workflow-engine.test.js +87 -0
- package/dist/web/api-config.html +265 -0
- package/dist/web/client.js +1401 -0
- package/dist/web/components/p2p/index.js +357 -0
- package/dist/web/components/p2p/p2p-connection.js +161 -0
- package/dist/web/components/p2p/p2p-identity.js +78 -0
- package/dist/web/components/p2p/p2p-manager.js +82 -0
- package/dist/web/components/p2p/p2p-messages.js +186 -0
- package/dist/web/components/p2p/p2p-store-memory.js +129 -0
- package/dist/web/components/p2p/types.js +23 -0
- package/dist/web/index.html +192 -0
- package/dist/web/server.js +1647 -0
- package/dist/web/server.js.map +1 -0
- package/dist/web/style.css +3260 -0
- package/dist/workflows/collaboration.js +374 -0
- package/dist/workflows/index.js +54 -0
- package/docs/agent-communication.md +333 -0
- package/docs/plans/2026-05-15-document-agent-design.md +479 -0
- package/docs/plans/2026-05-15-document-agent-implementation-plan.md +792 -0
- package/docs/plans/2026-05-16-chat-ui-design.md +86 -0
- package/docs/plans/2026-05-16-constraint-runtime-design.md +106 -0
- package/docs/plans/2026-05-16-constraint-runtime-implementation.md +441 -0
- 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 +287 -0
- package/package.json +121 -0
- package/scripts/build-web.ts +61 -0
- package/src/agents/constraint-layer.ts +309 -0
- package/src/agents/pi-sdk.ts +1591 -0
- package/src/agents/protocol.ts +304 -0
- package/src/agents/subagent-manager.ts +553 -0
- package/src/agents/workflow-engine.ts +332 -0
- package/src/bollharness/.boll/CLAUDE.md.template +34 -0
- package/src/bollharness/.boll/MANIFEST.yaml +213 -0
- package/src/bollharness/.boll/active-review-agents/.gitkeep +0 -0
- package/src/bollharness/.boll/agents/review-base.yaml +108 -0
- package/src/bollharness/.boll/deploy-allowlist.yaml +38 -0
- package/src/bollharness/.boll/inbox/schema/message-v1.json +99 -0
- package/src/bollharness/.boll/install-staging/.gitkeep +0 -0
- package/src/bollharness/.boll/issue-adapter.yaml +31 -0
- package/src/bollharness/.boll/plugins/boll-mode-toolkit/contracts/mode-contract.md +85 -0
- package/src/bollharness/.boll/plugins/boll-review-toolkit/contracts/evidence-packet-schema.json +102 -0
- package/src/bollharness/.boll/plugins/boll-review-toolkit/contracts/review-contract.yaml +247 -0
- package/src/bollharness/.boll/rules/backend-routes.md +31 -0
- package/src/bollharness/.boll/rules/closure-semantics.md +30 -0
- package/src/bollharness/.boll/rules/env-vars.md +32 -0
- package/src/bollharness/.boll/rules/hanis-protocol.md +145 -0
- package/src/bollharness/.boll/rules/repo-structure.md +42 -0
- package/src/bollharness/.boll/rules/review-agent-isolation.md +73 -0
- package/src/bollharness/.boll/rules/source-of-truth.md +33 -0
- package/src/bollharness/.boll/settings.json +180 -0
- package/src/bollharness/.boll/settings.json.template +31 -0
- package/src/bollharness/.boll/skills/arch/SKILL.md +372 -0
- package/src/bollharness/.boll/skills/bug-pipeline/SKILL.md +168 -0
- package/src/bollharness/.boll/skills/bug-triage/SKILL.md +161 -0
- package/src/bollharness/.boll/skills/context-chains/SKILL.md +250 -0
- package/src/bollharness/.boll/skills/context-chains/context-chain-index.md +48 -0
- package/src/bollharness/.boll/skills/context-chains/work-type-extractors/code_change_extractor.ts +142 -0
- package/src/bollharness/.boll/skills/context-chains/work-type-extractors/debugging_extractor.ts +126 -0
- package/src/bollharness/.boll/skills/context-chains/work-type-extractors/design_extractor.ts +148 -0
- package/src/bollharness/.boll/skills/context-chains/work-type-extractors/planning_extractor.ts +162 -0
- package/src/bollharness/.boll/skills/context-chains/work-type-extractors/question_extractor.ts +116 -0
- package/src/bollharness/.boll/skills/context-chains/work-type-extractors/review_extractor.ts +136 -0
- package/src/bollharness/.boll/skills/crystal-learn/SKILL.md +93 -0
- package/src/bollharness/.boll/skills/crystal-learn/invariants/INV-0.md +34 -0
- package/src/bollharness/.boll/skills/crystal-learn/invariants/INV-1.md +34 -0
- package/src/bollharness/.boll/skills/crystal-learn/invariants/INV-2.md +35 -0
- package/src/bollharness/.boll/skills/crystal-learn/invariants/INV-3.md +34 -0
- package/src/bollharness/.boll/skills/crystal-learn/invariants/INV-4.md +43 -0
- package/src/bollharness/.boll/skills/crystal-learn/invariants/INV-5.md +34 -0
- package/src/bollharness/.boll/skills/crystal-learn/invariants/INV-6.md +37 -0
- package/src/bollharness/.boll/skills/crystal-learn/invariants/INV-7.md +46 -0
- package/src/bollharness/.boll/skills/guardian-fixer/PROMPT.md +415 -0
- package/src/bollharness/.boll/skills/guardian-fixer/SKILL.md +320 -0
- package/src/bollharness/.boll/skills/harness-dev/SKILL.md +93 -0
- package/src/bollharness/.boll/skills/harness-dev/examples/README.md +227 -0
- package/src/bollharness/.boll/skills/harness-dev-handoff/SKILL.md +165 -0
- package/src/bollharness/.boll/skills/harness-eng/SKILL.md +110 -0
- package/src/bollharness/.boll/skills/harness-eng-test/SKILL.md +79 -0
- package/src/bollharness/.boll/skills/harness-lab/SKILL.md +170 -0
- package/src/bollharness/.boll/skills/harness-ops/SKILL.md +57 -0
- package/src/bollharness/.boll/skills/harness-voice/SKILL.md +183 -0
- package/src/bollharness/.boll/skills/judgment/SKILL.md +115 -0
- package/src/bollharness/.boll/skills/lead/SKILL.md +245 -0
- package/src/bollharness/.boll/skills/lead/install-wow-harness.md +77 -0
- package/src/bollharness/.boll/skills/lead/ref-review-sop.md +91 -0
- package/src/bollharness/.boll/skills/lead/ref-stages.md +129 -0
- package/src/bollharness/.boll/skills/skill-discovery/SKILL.md +169 -0
- package/src/bollharness/.boll/skills/task-arch/SKILL.md +106 -0
- package/src/bollharness/.boll/skills/toolkit/SKILL.md +57 -0
- package/src/bollharness/.boll/tasks/.gitkeep +0 -0
- package/src/bollharness/.boll/toolkit-index.yaml +112 -0
- package/src/bollharness/.claude/agents/review-base.yaml +108 -0
- package/src/bollharness/.claude/plugins/boll-mode-toolkit/.claude-plugin/plugin.json +44 -0
- package/src/bollharness/.claude/plugins/boll-review-toolkit/.claude-plugin/plugin.json +24 -0
- package/src/bollharness/.claude/plugins/boll-review-toolkit/contracts/evidence-packet-schema.json +102 -0
- package/src/bollharness/.claude/plugins/boll-review-toolkit/contracts/review-contract.yaml +247 -0
- package/src/bollharness/.claude/settings.json +157 -0
- package/src/bollharness/.claude/skills/arch/SKILL.md +64 -0
- package/src/bollharness/.claude/skills/crystal-learn/SKILL.md +93 -0
- package/src/bollharness/.claude/skills/guardian-fixer/PROMPT.md +44 -0
- package/src/bollharness/.claude/skills/guardian-fixer/SKILL.md +324 -0
- package/src/bollharness/.claude/skills/harness-dev/SKILL.md +93 -0
- package/src/bollharness/.claude/skills/harness-dev/examples/README.md +17 -0
- package/src/bollharness/.claude/skills/harness-dev-handoff/SKILL.md +165 -0
- package/src/bollharness/.claude/skills/harness-eng/SKILL.md +183 -0
- package/src/bollharness/.claude/skills/harness-eng-test/SKILL.md +57 -0
- package/src/bollharness/.claude/skills/harness-ops/SKILL.md +57 -0
- package/src/bollharness/.claude/skills/harness-voice/SKILL.md +84 -0
- package/src/bollharness/.claude/skills/lead/INDEX.md +28 -0
- package/src/bollharness/.claude/skills/lead/SKILL.md +24 -0
- package/src/bollharness/.claude/skills/lead/install-wow-harness.md +77 -0
- package/src/bollharness/.claude/skills/lead/ref-review-sop.md +48 -0
- package/src/bollharness/.claude/skills/lead/ref-stages.md +58 -0
- package/src/bollharness/.claude/skills/plan-lock/SKILL.md +74 -0
- package/src/bollharness/.claude/skills/skill-discovery/SKILL.md +120 -0
- package/src/bollharness/.claude/skills/task-arch/SKILL.md +106 -0
- package/src/bollharness/.claude/skills/toolkit/SKILL.md +57 -0
- package/src/bollharness/.claude/skills/toolkit/list.sh +92 -0
- package/src/bollharness/.githooks/pre-commit +21 -0
- package/src/bollharness/.github/workflows/ci.yml +88 -0
- package/src/bollharness/.sanitize-report.json +13 -0
- package/src/bollharness/CLAUDE.md +73 -0
- package/src/bollharness/LICENSE +21 -0
- package/src/bollharness/README.md +143 -0
- package/src/bollharness/README.zh-CN.md +131 -0
- package/src/bollharness/docs/decisions/ADR-030-guard-signal-protocol-and-governance-reload.md +1076 -0
- package/src/bollharness/docs/decisions/ADR-038-harness-optimization-strategy.md +2039 -0
- package/src/bollharness/docs/decisions/ADR-041-codex-claude-code-division-of-labor.md +128 -0
- package/src/bollharness/docs/decisions/ADR-H1-crystal-learn-revival.md +188 -0
- package/src/bollharness/docs/decisions/ADR-H2-identity-isolation.md +183 -0
- package/src/bollharness/docs/decisions/ADR-H3-memory-scope.md +133 -0
- package/src/bollharness/docs/decisions/ADR-H4-prompt-governance.md +146 -0
- package/src/bollharness/docs/decisions/ADR-H5-gate-quantization.md +212 -0
- package/src/bollharness/docs/decisions/ADR-H6-state-file-health.md +211 -0
- package/src/bollharness/docs/decisions/ADR-H8-issue-and-doc-compliance.md +202 -0
- package/src/bollharness/docs/decisions/ADR-H9-mailbox.md +231 -0
- package/src/bollharness/docs/decisions/PLAN-H1-crystal-learn-revival.md +270 -0
- package/src/bollharness/docs/decisions/PLAN-H2-identity-isolation.md +291 -0
- package/src/bollharness/docs/decisions/PLAN-H3-memory-scope.md +228 -0
- package/src/bollharness/docs/decisions/PLAN-H4-prompt-governance.md +227 -0
- package/src/bollharness/docs/decisions/PLAN-H5-gate-quantization.md +239 -0
- package/src/bollharness/docs/decisions/PLAN-H6-state-file-health.md +325 -0
- package/src/bollharness/docs/decisions/PLAN-H8-issue-and-doc-compliance.md +242 -0
- package/src/bollharness/docs/decisions/PLAN-H9-mailbox.md +378 -0
- package/src/bollharness/docs/launch-article-en.md +276 -0
- package/src/bollharness/docs/launch-article-zh.md +305 -0
- package/src/bollharness/docs/practice.html +356 -0
- package/src/bollharness/docs/practice.md +82 -0
- package/src/bollharness/docs/research/round-1/README.md +11 -0
- package/src/bollharness/docs/research/round-2/README.md +11 -0
- package/src/bollharness/docs/research/round-3/README.md +11 -0
- package/src/bollharness/docs/research/round-4/README.md +11 -0
- package/src/bollharness/docs/research/round-5/README.md +11 -0
- package/src/bollharness/docs/research/round-6/README.md +11 -0
- package/src/bollharness/package-lock.json +48 -0
- package/src/bollharness/package.json +20 -0
- package/src/bollharness/reference/SOURCE-COMMIT.txt +3 -0
- package/src/bollharness/reference/boll-reference/.claude/rules/backend-routes.md +268 -0
- package/src/bollharness/reference/boll-reference/.claude/rules/bridge.md +20 -0
- package/src/bollharness/reference/boll-reference/.claude/rules/closure-semantics.md +30 -0
- package/src/bollharness/reference/boll-reference/.claude/rules/coaching.md +13 -0
- package/src/bollharness/reference/boll-reference/.claude/rules/env-vars.md +50 -0
- package/src/bollharness/reference/boll-reference/.claude/rules/hackathon.md +12 -0
- package/src/bollharness/reference/boll-reference/.claude/rules/repo-structure.md +184 -0
- package/src/bollharness/reference/boll-reference/.claude/rules/review-agent-isolation.md +112 -0
- package/src/bollharness/reference/boll-reference/.claude/rules/scenes.md +12 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/arch/SKILL.md +551 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-animation/SKILL.md +26 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-bridge/SKILL.md +227 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-bridge/agents/openai.yaml +4 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-bridge/references/bridge-failure-taxonomy.md +142 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-bridge/references/bridge-validation-ladder.md +107 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-crystal/SKILL.md +893 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-crystal-learn/SKILL.md +89 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-dev/SKILL.md +93 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-dev/examples/README.md +209 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-dev-handoff/SKILL.md +165 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-eng/SKILL.md +110 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-eng-frontend/SKILL.md +203 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-eng-hdc/SKILL.md +27 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-eng-orchestrator/SKILL.md +28 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-eng-prompt/SKILL.md +27 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-eng-test/SKILL.md +79 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-lab/SKILL.md +372 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-run/SKILL.md +437 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-ux-appstore/SKILL.md +27 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/boll-voice/SKILL.md +442 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/guardian-fixer/PROMPT.md +421 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/guardian-fixer/SKILL.md +326 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/lead/SKILL.md +155 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/lead/ref-review-sop.md +91 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/lead/ref-stages.md +129 -0
- 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 +425 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/plan-lock/ref-three-checks.md +62 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/plan-lock/ref-wp-templates.md +78 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/task-arch/SKILL.md +76 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/vibedevteam-graph/SKILL.md +57 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/vibedevteam-graph/beads-graph.sh +153 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/vibedevteam-init/SKILL.md +52 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/vibedevteam-init/beads-auto-link.sh +76 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/vibedevteam-sync/SKILL.md +50 -0
- package/src/bollharness/reference/boll-reference/.claude/skills/vibedevteam-sync/beads-sync-proj.sh +108 -0
- package/src/bollharness/reference/boll-reference/docs/architecture/AGENT-PROFILE.md +151 -0
- package/src/bollharness/reference/boll-reference/docs/architecture/COST-STRUCTURE.md +56 -0
- package/src/bollharness/reference/boll-reference/docs/architecture/INDEX.md +76 -0
- package/src/bollharness/reference/boll-reference/docs/architecture/MODULE1-INTENT-FIELD.md +116 -0
- package/src/bollharness/reference/boll-reference/docs/architecture/MODULE2-CRYSTALLIZATION.md +200 -0
- package/src/bollharness/reference/boll-reference/docs/architecture/PRINCIPLES.md +84 -0
- package/src/bollharness/reference/boll-reference/docs/architecture/PROTOCOL-CORE.md +209 -0
- package/src/bollharness/reference/boll-reference/docs/architecture/VISION.md +181 -0
- package/src/bollharness/reference/boll-reference/docs/architecture/discussions/D-01-MARKET-SCENE-PROTOCOL.md +754 -0
- package/src/bollharness/reference/boll-reference/scripts/hooks/.sanitize-report.json +12 -0
- package/src/bollharness/reference/boll-reference/scripts/hooks/find-boll-root.sh +27 -0
- package/src/bollharness/reference/boll-reference/scripts/hooks/precompact.sh +57 -0
- package/src/bollharness/reference/boll-reference/scripts/hooks/stop-evaluator.md +57 -0
- package/src/bollharness/schemas/metrics-jsonl-allowlist.json +67 -0
- package/src/bollharness/scripts/checks/next_decision_number.sh +48 -0
- package/src/bollharness/scripts/ci/count-components.sh +65 -0
- package/src/bollharness/scripts/context-fragments/artifact-linkage.md +14 -0
- package/src/bollharness/scripts/context-fragments/auth-consumers.md +17 -0
- package/src/bollharness/scripts/context-fragments/bridge-constitution.md +13 -0
- package/src/bollharness/scripts/context-fragments/catalyst-distributed.md +18 -0
- package/src/bollharness/scripts/context-fragments/closure-checklist.md +13 -0
- package/src/bollharness/scripts/context-fragments/contract-consumers.md +15 -0
- package/src/bollharness/scripts/context-fragments/db-shared-structures.md +15 -0
- package/src/bollharness/scripts/context-fragments/fixed-three-layers.md +19 -0
- package/src/bollharness/scripts/context-fragments/general-dev-principles.md +11 -0
- package/src/bollharness/scripts/context-fragments/issue-first.md +8 -0
- package/src/bollharness/scripts/context-fragments/mcp-parity.md +16 -0
- package/src/bollharness/scripts/context-fragments/pi-agent-operations.md +74 -0
- package/src/bollharness/scripts/context-fragments/protocol-consumers.md +15 -0
- package/src/bollharness/scripts/context-fragments/run-events-consumers.md +15 -0
- package/src/bollharness/scripts/context-fragments/scene-fidelity.md +13 -0
- package/src/bollharness/scripts/context-fragments/truth-source-hierarchy.md +15 -0
- package/src/bollharness/scripts/context-fragments/two-language.md +15 -0
- package/src/bollharness/scripts/context-fragments/version-sources.md +14 -0
- package/src/bollharness/scripts/hooks/find-project-root.sh +47 -0
- package/src/bollharness/scripts/hooks/inbox-poll.sh +78 -0
- package/src/bollharness/scripts/hooks/precompact.sh +56 -0
- package/src/bollharness/scripts/hooks/stop-evaluator.md +83 -0
- package/src/bollharness/scripts/sync-from-upstream.sh +281 -0
- package/src/bollharness/src/index.ts +5 -0
- package/src/bollharness/src/scripts/checks/check_adr_plan_numbering.ts +11 -0
- package/src/bollharness/src/scripts/checks/check_api_types.ts +52 -0
- package/src/bollharness/src/scripts/checks/check_artifact_link.ts +156 -0
- package/src/bollharness/src/scripts/checks/check_bridge_deps.ts +11 -0
- package/src/bollharness/src/scripts/checks/check_bugfix_binding.ts +11 -0
- package/src/bollharness/src/scripts/checks/check_bugfix_binding_ci.ts +11 -0
- package/src/bollharness/src/scripts/checks/check_doc_file_references.ts +11 -0
- package/src/bollharness/src/scripts/checks/check_doc_freshness.ts +141 -0
- package/src/bollharness/src/scripts/checks/check_doc_links.ts +36 -0
- package/src/bollharness/src/scripts/checks/check_file_existence_claims.ts +11 -0
- package/src/bollharness/src/scripts/checks/check_fragment_integrity.ts +40 -0
- package/src/bollharness/src/scripts/checks/check_hook_installed.ts +70 -0
- package/src/bollharness/src/scripts/checks/check_issue_closure.ts +51 -0
- package/src/bollharness/src/scripts/checks/check_mcp_parity.ts +11 -0
- package/src/bollharness/src/scripts/checks/check_security.ts +54 -0
- package/src/bollharness/src/scripts/checks/check_skill_parity.ts +11 -0
- package/src/bollharness/src/scripts/checks/check_versions.ts +11 -0
- package/src/bollharness/src/scripts/checks/finding.ts +35 -0
- package/src/bollharness/src/scripts/checks/next_decision_number.ts +24 -0
- package/src/bollharness/src/scripts/checks/regenerate_magic_docs.ts +11 -0
- package/src/bollharness/src/scripts/ci/detect_rebaseline_triggers.ts +14 -0
- package/src/bollharness/src/scripts/ci/scan_subprocess_cfg.ts +14 -0
- package/src/bollharness/src/scripts/ci/scan_verify_artifacts.ts +14 -0
- package/src/bollharness/src/scripts/ci/scan_yaml_schema.ts +14 -0
- package/src/bollharness/src/scripts/context_router.ts +76 -0
- package/src/bollharness/src/scripts/deploy-guard.ts +182 -0
- package/src/bollharness/src/scripts/guard-feedback.ts +215 -0
- package/src/bollharness/src/scripts/guard_router.ts +194 -0
- package/src/bollharness/src/scripts/hooks/_hook_output.js +3 -0
- package/src/bollharness/src/scripts/hooks/_hook_output.ts +11 -0
- package/src/bollharness/src/scripts/hooks/auto-python3.ts +10 -0
- package/src/bollharness/src/scripts/hooks/deploy-progress-on-session-end.ts +10 -0
- package/src/bollharness/src/scripts/hooks/failure-analyzer.ts +10 -0
- package/src/bollharness/src/scripts/hooks/gate-judgment-inject.ts +111 -0
- package/src/bollharness/src/scripts/hooks/gate-transition-judgment.ts +74 -0
- package/src/bollharness/src/scripts/hooks/inbox-ack.ts +10 -0
- package/src/bollharness/src/scripts/hooks/inbox-inject-on-start.ts +10 -0
- package/src/bollharness/src/scripts/hooks/inbox-validate.ts +10 -0
- package/src/bollharness/src/scripts/hooks/inbox-write-ledger.ts +10 -0
- package/src/bollharness/src/scripts/hooks/initializer-agent.ts +10 -0
- package/src/bollharness/src/scripts/hooks/loop-detection.ts +83 -0
- package/src/bollharness/src/scripts/hooks/owner-guard.ts +10 -0
- package/src/bollharness/src/scripts/hooks/precompact.ts +10 -0
- package/src/bollharness/src/scripts/hooks/review-agent-gatekeeper.ts +10 -0
- package/src/bollharness/src/scripts/hooks/risk-tracker.ts +121 -0
- package/src/bollharness/src/scripts/hooks/sanitize-on-read.ts +10 -0
- package/src/bollharness/src/scripts/hooks/session-reflection.ts +12 -0
- package/src/bollharness/src/scripts/hooks/session-start-magic-docs.ts +12 -0
- package/src/bollharness/src/scripts/hooks/session-start-reset-risk.ts +12 -0
- package/src/bollharness/src/scripts/hooks/session-start-toolkit-reminder.ts +12 -0
- package/src/bollharness/src/scripts/hooks/stop-evaluator.ts +164 -0
- package/src/bollharness/src/scripts/hooks/tool-call-counter.ts +10 -0
- package/src/bollharness/src/scripts/hooks/trace-analyzer.ts +14 -0
- package/src/bollharness/src/scripts/install/install-trust-token.ts +13 -0
- package/src/bollharness/src/scripts/install/multi_project_registry.ts +13 -0
- package/src/bollharness/src/scripts/install/phase2_auto.ts +28 -0
- package/src/bollharness/src/scripts/install/pre_commit_installer.ts +10 -0
- package/src/bollharness/src/scripts/install/tier_selector.ts +10 -0
- package/src/bollharness/src/scripts/install/transcript_miner.ts +13 -0
- package/src/bollharness/src/scripts/lib/claim_patterns.ts +11 -0
- package/src/bollharness/src/scripts/lib/sanitize_patterns.ts +13 -0
- package/src/bollharness/src/scripts/sanitize.ts +9 -0
- package/src/bollharness/templates/persona/default.json +19 -0
- 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/.gitignore.append +16 -0
- package/src/bollharness/templates/scaffold/CLAUDE.md +89 -0
- package/src/bollharness/templates/scaffold/docs/INDEX.md +3 -0
- package/src/bollharness/templates/scaffold/docs/decisions/ADR_TEMPLATE.md +38 -0
- package/src/bollharness/templates/scaffold/docs/decisions/PLAN_TEMPLATE.md +45 -0
- package/src/bollharness/templates/scaffold/docs/decisions/tasks/.gitkeep +2 -0
- package/src/bollharness/templates/scaffold/docs/issues/.gitkeep +0 -0
- package/src/bollharness/templates/scaffold/docs/issues/GUARD_ISSUE_TEMPLATE.md +35 -0
- package/src/bollharness/templates/scaffold/docs/issues/ISSUE_TEMPLATE.md +51 -0
- package/src/bollharness/tsconfig.json +26 -0
- package/src/bollharness-integration/channel-judgment-engine.ts +634 -0
- package/src/bollharness-integration/context-chain-router.ts +474 -0
- package/src/bollharness-integration/context-router-judgment.ts +339 -0
- package/src/bollharness-integration/context-router.ts +583 -0
- package/src/bollharness-integration/gate-state-machine.ts +444 -0
- package/src/bollharness-integration/gate-transition-hooks.ts +137 -0
- package/src/bollharness-integration/guard-checker.ts +451 -0
- package/src/bollharness-integration/index.ts +219 -0
- package/src/bollharness-integration/integration.ts +538 -0
- package/src/bollharness-integration/judgment-prompts.yaml +535 -0
- package/src/bollharness-integration/llm-judgment-engine.ts +712 -0
- package/src/bollharness-integration/skill-adapter.ts +646 -0
- package/src/cli/interface.ts +211 -0
- package/src/constraint-runtime/package-lock.json +48 -0
- package/src/constraint-runtime/package.json +34 -0
- package/src/constraint-runtime/src/_archive_helper.ts +16 -0
- package/src/constraint-runtime/src/agent/coordinator.ts +71 -0
- package/src/constraint-runtime/src/agent/index.ts +1 -0
- package/src/constraint-runtime/src/assistant/index.ts +15 -0
- package/src/constraint-runtime/src/bootstrap/index.ts +15 -0
- package/src/constraint-runtime/src/bootstrap_graph.ts +17 -0
- package/src/constraint-runtime/src/bridge/index.ts +15 -0
- package/src/constraint-runtime/src/buddy/index.ts +15 -0
- package/src/constraint-runtime/src/cli/index.ts +15 -0
- package/src/constraint-runtime/src/command_graph.ts +20 -0
- package/src/constraint-runtime/src/commands.ts +83 -0
- package/src/constraint-runtime/src/components/index.ts +15 -0
- package/src/constraint-runtime/src/constants/index.ts +15 -0
- package/src/constraint-runtime/src/constraint/budget.ts +25 -0
- package/src/constraint-runtime/src/constraint/index.ts +3 -0
- package/src/constraint-runtime/src/constraint/permission.ts +28 -0
- package/src/constraint-runtime/src/context.ts +45 -0
- package/src/constraint-runtime/src/coordinator/index.ts +15 -0
- package/src/constraint-runtime/src/cost_hook.ts +6 -0
- package/src/constraint-runtime/src/cost_tracker.ts +9 -0
- package/src/constraint-runtime/src/deferred_init.ts +18 -0
- package/src/constraint-runtime/src/direct_modes.ts +13 -0
- package/src/constraint-runtime/src/dynamic-tool-loader.ts +115 -0
- package/src/constraint-runtime/src/entrypoints/index.ts +15 -0
- package/src/constraint-runtime/src/execution_registry.ts +41 -0
- package/src/constraint-runtime/src/history.ts +16 -0
- package/src/constraint-runtime/src/hooks/index.ts +15 -0
- package/src/constraint-runtime/src/index.ts +28 -0
- package/src/constraint-runtime/src/ink.ts +4 -0
- package/src/constraint-runtime/src/keybindings/index.ts +15 -0
- package/src/constraint-runtime/src/memdir/index.ts +15 -0
- package/src/constraint-runtime/src/migrations/index.ts +15 -0
- package/src/constraint-runtime/src/models.ts +49 -0
- package/src/constraint-runtime/src/moreright/index.ts +15 -0
- package/src/constraint-runtime/src/native_ts/index.ts +15 -0
- package/src/constraint-runtime/src/output_styles/index.ts +15 -0
- package/src/constraint-runtime/src/parity_audit.ts +23 -0
- package/src/constraint-runtime/src/plugins/index.ts +15 -0
- package/src/constraint-runtime/src/port_manifest.ts +20 -0
- package/src/constraint-runtime/src/prefetch.ts +17 -0
- package/src/constraint-runtime/src/query.ts +7 -0
- package/src/constraint-runtime/src/reference_data/archive_surface_snapshot.json +63 -0
- package/src/constraint-runtime/src/reference_data/commands_snapshot.json +1037 -0
- package/src/constraint-runtime/src/reference_data/subsystems/OpenCLI.json +10 -0
- package/src/constraint-runtime/src/reference_data/subsystems/PolymarketSDK.json +12 -0
- package/src/constraint-runtime/src/reference_data/subsystems/SafeSDK.json +14 -0
- package/src/constraint-runtime/src/reference_data/subsystems/assistant.json +8 -0
- package/src/constraint-runtime/src/reference_data/subsystems/bootstrap.json +8 -0
- package/src/constraint-runtime/src/reference_data/subsystems/bridge.json +32 -0
- package/src/constraint-runtime/src/reference_data/subsystems/buddy.json +13 -0
- package/src/constraint-runtime/src/reference_data/subsystems/cli.json +26 -0
- package/src/constraint-runtime/src/reference_data/subsystems/components.json +32 -0
- package/src/constraint-runtime/src/reference_data/subsystems/constants.json +28 -0
- package/src/constraint-runtime/src/reference_data/subsystems/coordinator.json +8 -0
- package/src/constraint-runtime/src/reference_data/subsystems/entrypoints.json +15 -0
- package/src/constraint-runtime/src/reference_data/subsystems/hooks.json +32 -0
- package/src/constraint-runtime/src/reference_data/subsystems/keybindings.json +21 -0
- package/src/constraint-runtime/src/reference_data/subsystems/memdir.json +15 -0
- package/src/constraint-runtime/src/reference_data/subsystems/migrations.json +18 -0
- package/src/constraint-runtime/src/reference_data/subsystems/moreright.json +8 -0
- package/src/constraint-runtime/src/reference_data/subsystems/native_ts.json +11 -0
- package/src/constraint-runtime/src/reference_data/subsystems/outputStyles.json +8 -0
- package/src/constraint-runtime/src/reference_data/subsystems/plugins.json +9 -0
- package/src/constraint-runtime/src/reference_data/subsystems/remote.json +11 -0
- package/src/constraint-runtime/src/reference_data/subsystems/schemas.json +8 -0
- package/src/constraint-runtime/src/reference_data/subsystems/screens.json +10 -0
- package/src/constraint-runtime/src/reference_data/subsystems/server.json +10 -0
- package/src/constraint-runtime/src/reference_data/subsystems/services.json +32 -0
- package/src/constraint-runtime/src/reference_data/subsystems/skills.json +27 -0
- package/src/constraint-runtime/src/reference_data/subsystems/state.json +13 -0
- package/src/constraint-runtime/src/reference_data/subsystems/types.json +18 -0
- package/src/constraint-runtime/src/reference_data/subsystems/upstreamproxy.json +9 -0
- package/src/constraint-runtime/src/reference_data/subsystems/utils.json +32 -0
- package/src/constraint-runtime/src/reference_data/subsystems/vim.json +12 -0
- package/src/constraint-runtime/src/reference_data/subsystems/voice.json +8 -0
- package/src/constraint-runtime/src/reference_data/tools_snapshot.json +1042 -0
- package/src/constraint-runtime/src/remote/index.ts +15 -0
- package/src/constraint-runtime/src/remote_runtime.ts +17 -0
- package/src/constraint-runtime/src/runtime/index.ts +1 -0
- package/src/constraint-runtime/src/runtime/session.ts +42 -0
- package/src/constraint-runtime/src/schemas/index.ts +15 -0
- package/src/constraint-runtime/src/screens/index.ts +15 -0
- package/src/constraint-runtime/src/server/index.ts +15 -0
- package/src/constraint-runtime/src/services/index.ts +15 -0
- package/src/constraint-runtime/src/session_store.ts +32 -0
- package/src/constraint-runtime/src/setup.ts +50 -0
- package/src/constraint-runtime/src/skills/index.ts +1 -0
- package/src/constraint-runtime/src/skills/skill-registry.ts +40 -0
- package/src/constraint-runtime/src/state/index.ts +15 -0
- package/src/constraint-runtime/src/system_init.ts +21 -0
- package/src/constraint-runtime/src/thinking/engine.ts +61 -0
- package/src/constraint-runtime/src/thinking/index.ts +1 -0
- package/src/constraint-runtime/src/tool_pool.ts +20 -0
- package/src/constraint-runtime/src/tools/OpenCLI/execAdapter.ts +12 -0
- package/src/constraint-runtime/src/tools/OpenCLI/listAdapters.ts +12 -0
- package/src/constraint-runtime/src/tools/OpenCLI/runCommand.ts +13 -0
- package/src/constraint-runtime/src/tools/PolymarketSDK/cancelOrder.ts +10 -0
- package/src/constraint-runtime/src/tools/PolymarketSDK/createOrder.ts +13 -0
- package/src/constraint-runtime/src/tools/PolymarketSDK/getMarket.ts +14 -0
- package/src/constraint-runtime/src/tools/PolymarketSDK/getOrders.ts +10 -0
- package/src/constraint-runtime/src/tools/PolymarketSDK/listMarkets.ts +24 -0
- package/src/constraint-runtime/src/tools/SafeSDK/confirmTransaction.ts +13 -0
- package/src/constraint-runtime/src/tools/SafeSDK/createTransaction.ts +23 -0
- package/src/constraint-runtime/src/tools/SafeSDK/deploySafe.ts +12 -0
- package/src/constraint-runtime/src/tools/SafeSDK/executeTransaction.ts +12 -0
- package/src/constraint-runtime/src/tools/SafeSDK/getBalance.ts +10 -0
- package/src/constraint-runtime/src/tools/SafeSDK/getPendingTransactions.ts +10 -0
- package/src/constraint-runtime/src/tools/SafeSDK/proposeTransaction.ts +14 -0
- package/src/constraint-runtime/src/tools/WalletTools/autoPay.ts +58 -0
- package/src/constraint-runtime/src/tools/WalletTools/createWallet.ts +19 -0
- package/src/constraint-runtime/src/tools/WalletTools/getBalance.ts +28 -0
- package/src/constraint-runtime/src/tools/WalletTools/importWallet.ts +34 -0
- package/src/constraint-runtime/src/tools/WalletTools/sendTransaction.ts +50 -0
- package/src/constraint-runtime/src/tools/WalletTools/signMessage.ts +23 -0
- package/src/constraint-runtime/src/tools/WalletTools/transferToken.ts +49 -0
- package/src/constraint-runtime/src/tools.ts +100 -0
- package/src/constraint-runtime/src/transcript.ts +23 -0
- package/src/constraint-runtime/src/types/index.ts +15 -0
- package/src/constraint-runtime/src/upstream_proxy/index.ts +15 -0
- package/src/constraint-runtime/src/utils/index.ts +15 -0
- package/src/constraint-runtime/src/vim/index.ts +15 -0
- package/src/constraint-runtime/src/voice/index.ts +15 -0
- package/src/constraint-runtime/tests/agent.test.ts +20 -0
- package/src/constraint-runtime/tests/constraint.test.ts +47 -0
- package/src/constraint-runtime/tests/skill.test.ts +23 -0
- package/src/constraint-runtime/tests/thinking.test.ts +28 -0
- package/src/constraint-runtime/tsconfig.json +13 -0
- package/src/constraints/index.ts +6 -0
- package/src/documents/reader.ts +80 -0
- package/src/electron-preload.ts +25 -0
- package/src/electron.ts +200 -0
- package/src/index.ts +1606 -0
- package/src/llm/config-store.ts +312 -0
- package/src/llm/llm-judgment-client.ts +470 -0
- package/src/llm/pi-ai.ts +522 -0
- package/src/network/agent-network.ts +800 -0
- package/src/network/hybrid-messenger.ts +199 -0
- package/src/network/iroh-bootstrap.ts +57 -0
- package/src/network/iroh-discovery.ts +207 -0
- package/src/network/iroh-integration.ts +158 -0
- package/src/network/iroh-transport.ts +594 -0
- package/src/network/p2p.ts +963 -0
- package/src/network/storage/adapters/json-adapter.ts +439 -0
- package/src/network/storage/index.ts +187 -0
- package/src/network/storage/types.ts +166 -0
- package/src/pi-ecosystem/index.ts +453 -0
- package/src/pi-ecosystem-colony/index.ts +482 -0
- package/src/pi-ecosystem-goals/index.ts +585 -0
- package/src/pi-ecosystem-judgment/decision.ts +431 -0
- package/src/pi-ecosystem-judgment/distillation.ts +398 -0
- package/src/pi-ecosystem-judgment/human-value-store.ts +580 -0
- package/src/pi-ecosystem-judgment/index.ts +678 -0
- package/src/pi-ecosystem-judgment/value-injection.ts +744 -0
- package/src/pi-ecosystem-mcp/index.ts +427 -0
- package/src/pi-ecosystem-subagents/index.ts +408 -0
- package/src/social/ant-colony/AdaptiveHeartbeat.ts +131 -0
- package/src/social/ant-colony/PheromoneEngine.ts +302 -0
- package/src/social/ant-colony/index.ts +18 -0
- package/src/social/ant-colony/types.ts +94 -0
- package/src/social/channels/ChannelManager.ts +485 -0
- package/src/social/channels/DiapChannelBridge.ts +501 -0
- package/src/social/channels/InterestMatcher.ts +189 -0
- package/src/social/channels/agent-workflow-config.json +214 -0
- package/src/social/channels/agent-workflow-config.yaml +334 -0
- package/src/social/channels/channel-agent-session.ts +407 -0
- package/src/social/channels/channel-heartbeat-agent.ts +622 -0
- package/src/social/channels/diap-doc-parser.ts +282 -0
- package/src/social/channels/harness-workflow-integrator.ts +594 -0
- package/src/social/channels/index.ts +22 -0
- package/src/social/channels/types.ts +115 -0
- package/src/social/global-shared-context.ts +506 -0
- package/src/social/heartbeat.ts +1041 -0
- package/src/social/persona/enhanced-persona.ts +359 -0
- package/src/test/ai-judgment-test.ts +92 -0
- package/src/test/bollharness-integration.test.ts +398 -0
- package/src/test/channel-agent-multi-dialogue.ts +265 -0
- package/src/test/channel-heartbeat-agent-test.ts +244 -0
- package/src/test/constraint-layer.test.ts +191 -0
- package/src/test/diap-identity-test.ts +222 -0
- package/src/test/diap-quick-test.ts +73 -0
- package/src/test/global-shared-context.test.ts +393 -0
- package/src/test/harness-judgment-injection.test.ts +353 -0
- package/src/test/harness-workflow-integrator-test.ts +285 -0
- package/src/test/human-value-store.test.ts +316 -0
- package/src/test/hybrid-integration-test.ts +126 -0
- package/src/test/hybrid-messenger-verify.ts +68 -0
- package/src/test/iroh-bistream-debug.ts +50 -0
- package/src/test/iroh-communication.test.ts +81 -0
- package/src/test/iroh-debug-test.ts +69 -0
- package/src/test/iroh-diap-test.ts +90 -0
- package/src/test/iroh-direct-connect.ts +65 -0
- package/src/test/iroh-e2e-fixed.ts +106 -0
- package/src/test/iroh-e2e-same-process.ts +83 -0
- package/src/test/iroh-e2e.ts +83 -0
- package/src/test/iroh-final-e2e.ts +84 -0
- package/src/test/iroh-relay-test.ts +46 -0
- package/src/test/iroh-simple-test.ts +49 -0
- package/src/test/iroh-transport-verify.ts +60 -0
- package/src/test/iroh-transport.test.ts +47 -0
- package/src/test/iroh-two-nodes.ts +87 -0
- package/src/test/iroh-verify.ts +55 -0
- package/src/test/judgment-decision.test.ts +373 -0
- package/src/test/llm-judgment-integration.test.ts +257 -0
- package/src/test/p2p-agent-complex-dialogue.ts +490 -0
- package/src/test/p2p-agent-dialogue.ts +423 -0
- package/src/test/p2p-agent-full-bidirectional.ts +686 -0
- package/src/test/p2p-agent-harness-flow.ts +562 -0
- package/src/test/p2p-agent-harness-single.ts +175 -0
- package/src/test/p2p-ai-dialogue-test.ts +374 -0
- package/src/test/p2p-cid-connect-test.ts +245 -0
- package/src/test/p2p-connect-receiver.ts +85 -0
- package/src/test/p2p-iroh-test.ts +214 -0
- package/src/test/p2p-minimal-test.ts +264 -0
- package/src/test/p2p-node-1.ts +172 -0
- package/src/test/p2p-node-2.ts +172 -0
- package/src/test/p2p-server.ts +335 -0
- package/src/test/p2p-two-nodes-test.ts +542 -0
- package/src/test/pi-sdk.test.ts +47 -0
- package/src/test/set-persona.ts +56 -0
- package/src/test/simple.test.ts +11 -0
- package/src/test/storage-integration.test.ts +191 -0
- package/src/test/subagent-manager.test.ts +392 -0
- package/src/test/test-gate-flow.test.ts +92 -0
- package/src/test/workflow-engine.test.ts +101 -0
- package/src/web/api-config.html +265 -0
- package/src/web/client.js +1401 -0
- package/src/web/components/p2p/P2PModal.tsx +328 -0
- package/src/web/components/p2p/index.ts +404 -0
- package/src/web/components/p2p/index.tsx +297 -0
- package/src/web/components/p2p/p2p-connection.ts +186 -0
- package/src/web/components/p2p/p2p-identity.ts +92 -0
- package/src/web/components/p2p/p2p-manager.ts +109 -0
- package/src/web/components/p2p/p2p-messages.ts +219 -0
- package/src/web/components/p2p/p2p-modal.ts +685 -0
- package/src/web/components/p2p/p2p-store-memory.ts +162 -0
- package/src/web/components/p2p/types.ts +112 -0
- package/src/web/design.md +99 -0
- package/src/web/index.html +192 -0
- package/src/web/server.ts +1878 -0
- package/src/web/style.css +3260 -0
- package/src/workflows/collaboration.ts +455 -0
- package/src/workflows/index.ts +64 -0
- package/tsconfig.electron.json +20 -0
- package/tsconfig.json +19 -0
- package/vitest.config.ts +12 -0
- package//346/203/263/346/263/225.md +79 -0
|
@@ -0,0 +1,792 @@
|
|
|
1
|
+
# Document Agent Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
|
|
4
|
+
|
|
5
|
+
**Goal:** 实现基于 OpenClaw 双层架构的 AI 文档处理智能体,支持完全自主运行
|
|
6
|
+
|
|
7
|
+
**Architecture:** 约束层(Prompt Guardrails)+ 执行层(Code-Driven Workflow),通过重试机制和 guardrail 实现安全可控的自主决策
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** TypeScript, libp2p, Minimax LLM
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 任务 1: 创建约束层 (ConstraintLayer)
|
|
14
|
+
|
|
15
|
+
**Files:**
|
|
16
|
+
- Create: `src/agents/constraint-layer.ts`
|
|
17
|
+
- Modify: `src/agents/pi-sdk.ts` (集成约束层)
|
|
18
|
+
- Test: `src/test/constraint-layer.test.ts`
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
### Task 1.1: 定义约束层接口与类型
|
|
23
|
+
|
|
24
|
+
**Files:**
|
|
25
|
+
- Create: `src/agents/constraint-layer.ts`
|
|
26
|
+
|
|
27
|
+
**Step 1: 创建约束层基础类型和接口**
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
export interface Guardrail {
|
|
31
|
+
name: string;
|
|
32
|
+
check: (context: WorkflowContext, step?: WorkflowStep) => Promise<boolean>;
|
|
33
|
+
onFail?: 'block' | 'warn' | 'retry';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ConstraintRule {
|
|
37
|
+
id: string;
|
|
38
|
+
description: string;
|
|
39
|
+
guardrails: Guardrail[];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface WorkflowContext {
|
|
43
|
+
document?: DocumentContent;
|
|
44
|
+
summary?: string;
|
|
45
|
+
improved?: string;
|
|
46
|
+
qualityScore?: number;
|
|
47
|
+
peers: string[];
|
|
48
|
+
logs: OperationLog[];
|
|
49
|
+
metadata?: Record<string, unknown>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface OperationLog {
|
|
53
|
+
timestamp: number;
|
|
54
|
+
action: string;
|
|
55
|
+
details: Record<string, unknown>;
|
|
56
|
+
status: 'success' | 'failed' | 'blocked' | 'warn';
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Step 2: 实现 SYSTEM_PROMPT 约束模板**
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
export const SYSTEM_PROMPT = `
|
|
64
|
+
你是一个文档处理Agent,在以下规则下运行:
|
|
65
|
+
|
|
66
|
+
【边界规则】
|
|
67
|
+
1. 只处理:txt, md, pdf, docx 格式文档
|
|
68
|
+
2. 不修改原始文件,只输出改进版本
|
|
69
|
+
3. 发送前必须记录操作日志
|
|
70
|
+
|
|
71
|
+
【自主权限】
|
|
72
|
+
- ✅ 自主决定:摘要详细程度、chunk分块策略
|
|
73
|
+
- ✅ 自主决定:重试次数(最多3次)
|
|
74
|
+
- ✅ 自主决定:是否需要补充信息
|
|
75
|
+
- ❌ 必须确认:首次向新对等节点发送文档
|
|
76
|
+
- ❌ 必须确认:删除操作
|
|
77
|
+
|
|
78
|
+
【敏感操作拦截】
|
|
79
|
+
if (操作 === '发送文档' && 对等节点不在已知列表) {
|
|
80
|
+
拦截 → 记录 → 等待确认
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
|
|
84
|
+
export const AUTONOMOUS_ACTIONS = ['summarize', 'chunk', 'improve'];
|
|
85
|
+
export const CONFIRM_REQUIRED_ACTIONS = ['send', 'delete'];
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Step 3: 实现约束层类**
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
export class ConstraintLayer {
|
|
92
|
+
private rules: Map<string, ConstraintRule> = new Map();
|
|
93
|
+
private logs: OperationLog[] = [];
|
|
94
|
+
|
|
95
|
+
constructor() {
|
|
96
|
+
this.registerDefaultRules();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private registerDefaultRules(): void {
|
|
100
|
+
// 未知节点发送拦截
|
|
101
|
+
this.registerRule({
|
|
102
|
+
id: 'unknown-peer-send',
|
|
103
|
+
description: '阻止向未知对等节点发送文档',
|
|
104
|
+
guardrails: [{
|
|
105
|
+
name: 'validateSendTarget',
|
|
106
|
+
check: async (ctx, step) => {
|
|
107
|
+
const targetPeer = step?.config?.peerId as string;
|
|
108
|
+
if (!targetPeer) return true;
|
|
109
|
+
const isKnown = ctx.peers.includes(targetPeer);
|
|
110
|
+
if (!isKnown) {
|
|
111
|
+
this.log('BLOCKED: Unknown peer', { targetPeer }, 'blocked');
|
|
112
|
+
}
|
|
113
|
+
return isKnown;
|
|
114
|
+
},
|
|
115
|
+
onFail: 'block'
|
|
116
|
+
}]
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// 摘要质量检查
|
|
120
|
+
this.registerRule({
|
|
121
|
+
id: 'summary-quality',
|
|
122
|
+
description: '确保摘要质量达标',
|
|
123
|
+
guardrails: [{
|
|
124
|
+
name: 'validateSummaryQuality',
|
|
125
|
+
check: async (ctx) => {
|
|
126
|
+
if (ctx.qualityScore !== undefined && ctx.qualityScore < 0.5) {
|
|
127
|
+
this.log('WARN: Low quality summary', { score: ctx.qualityScore }, 'warn');
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
return true;
|
|
131
|
+
},
|
|
132
|
+
onFail: 'retry'
|
|
133
|
+
}]
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
registerRule(rule: ConstraintRule): void {
|
|
138
|
+
this.rules.set(rule.id, rule);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async checkGuardrails(context: WorkflowContext, step?: WorkflowStep): Promise<{
|
|
142
|
+
passed: boolean;
|
|
143
|
+
blocked?: Guardrail;
|
|
144
|
+
}> {
|
|
145
|
+
for (const rule of this.rules.values()) {
|
|
146
|
+
for (const guardrail of rule.guardrails) {
|
|
147
|
+
const passed = await guardrail.check(context, step);
|
|
148
|
+
if (!passed) {
|
|
149
|
+
return { passed: false, blocked: guardrail };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return { passed: true };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
log(action: string, details: Record<string, unknown>, status: OperationLog['status']): void {
|
|
157
|
+
this.logs.push({
|
|
158
|
+
timestamp: Date.now(),
|
|
159
|
+
action,
|
|
160
|
+
details,
|
|
161
|
+
status
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
getLogs(): OperationLog[] {
|
|
166
|
+
return [...this.logs];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
isAutonomousAction(action: string): boolean {
|
|
170
|
+
return AUTONOMOUS_ACTIONS.includes(action);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
requiresConfirmation(action: string): boolean {
|
|
174
|
+
return CONFIRM_REQUIRED_ACTIONS.includes(action);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Step 4: 提交**
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
git add src/agents/constraint-layer.ts
|
|
183
|
+
git commit -m "feat: add constraint layer with guardrails"
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## 任务 2: 创建工作流引擎 (WorkflowEngine)
|
|
189
|
+
|
|
190
|
+
**Files:**
|
|
191
|
+
- Create: `src/agents/workflow-engine.ts`
|
|
192
|
+
- Modify: `src/agents/pi-sdk.ts`
|
|
193
|
+
- Test: `src/test/workflow-engine.test.ts`
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
### Task 2.1: 定义工作流步骤类型
|
|
198
|
+
|
|
199
|
+
**Files:**
|
|
200
|
+
- Modify: `src/agents/pi-sdk.ts` (扩展 WorkflowStep 接口)
|
|
201
|
+
|
|
202
|
+
**Step 1: 更新 WorkflowStep 接口**
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
// 在 pi-sdk.ts 中添加
|
|
206
|
+
export interface WorkflowStepConfig {
|
|
207
|
+
path?: string;
|
|
208
|
+
requirements?: string;
|
|
209
|
+
context?: string;
|
|
210
|
+
peerId?: string;
|
|
211
|
+
message?: string;
|
|
212
|
+
content?: string;
|
|
213
|
+
maxChunkSize?: number;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export interface WorkflowStep {
|
|
217
|
+
id: string;
|
|
218
|
+
type: 'read' | 'chunk' | 'summarize' | 'improve' | 'review' | 'send' | 'report';
|
|
219
|
+
config?: WorkflowStepConfig;
|
|
220
|
+
retry: {
|
|
221
|
+
max: number;
|
|
222
|
+
current: number;
|
|
223
|
+
backoffMs: number;
|
|
224
|
+
};
|
|
225
|
+
onFail: 'skip' | 'abort' | 'retry';
|
|
226
|
+
guardrail?: (context: WorkflowContext) => Promise<boolean>;
|
|
227
|
+
guardrailOnRetry?: boolean;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export interface StepResult {
|
|
231
|
+
status: 'success' | 'failed' | 'skipped' | 'blocked';
|
|
232
|
+
result?: unknown;
|
|
233
|
+
error?: string;
|
|
234
|
+
guardrailFailed?: string;
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Task 2.2: 实现 WorkflowEngine
|
|
239
|
+
|
|
240
|
+
**Files:**
|
|
241
|
+
- Create: `src/agents/workflow-engine.ts`
|
|
242
|
+
|
|
243
|
+
**Step 1: 实现 WorkflowEngine 类**
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
import { WorkflowStep, StepResult, Workflow, WorkflowContext, WorkflowStepConfig } from './pi-sdk.js';
|
|
247
|
+
import { documentReader, DocumentContent } from '../documents/reader.js';
|
|
248
|
+
import { getMinimax } from '../llm/minimax.js';
|
|
249
|
+
import { p2pNetwork } from '../network/p2p.js';
|
|
250
|
+
import { ConstraintLayer } from './constraint-layer.js';
|
|
251
|
+
|
|
252
|
+
export class WorkflowEngine {
|
|
253
|
+
private constraintLayer: ConstraintLayer;
|
|
254
|
+
|
|
255
|
+
constructor(constraintLayer?: ConstraintLayer) {
|
|
256
|
+
this.constraintLayer = constraintLayer || new ConstraintLayer();
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
async executeWorkflow(steps: WorkflowStep[], initialContext?: Partial<WorkflowContext>): Promise<Workflow> {
|
|
260
|
+
const workflow: Workflow = {
|
|
261
|
+
id: `wf-${Date.now()}`,
|
|
262
|
+
steps,
|
|
263
|
+
status: 'running',
|
|
264
|
+
results: new Map()
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
const context: WorkflowContext = {
|
|
268
|
+
peers: p2pNetwork.getPeers(),
|
|
269
|
+
logs: [],
|
|
270
|
+
...initialContext
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
for (const step of steps) {
|
|
274
|
+
const result = await this.executeStep(step, context);
|
|
275
|
+
workflow.results.set(step.id, result);
|
|
276
|
+
|
|
277
|
+
if (result.status === 'blocked' || (result.status === 'failed' && step.onFail === 'abort')) {
|
|
278
|
+
workflow.status = 'failed';
|
|
279
|
+
return workflow;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
workflow.status = 'completed';
|
|
284
|
+
return workflow;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
async executeStep(step: WorkflowStep, context: WorkflowContext): Promise<StepResult> {
|
|
288
|
+
// 前置 guardrail 检查
|
|
289
|
+
if (step.guardrail) {
|
|
290
|
+
const guardrailPassed = await this.runGuardrail(step, context, true);
|
|
291
|
+
if (!guardrailPassed) {
|
|
292
|
+
return { status: 'blocked', guardrailFailed: step.guardrail.name };
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// 执行步骤,带重试
|
|
297
|
+
for (let attempt = 0; attempt <= step.retry.max; attempt++) {
|
|
298
|
+
try {
|
|
299
|
+
const result = await this.runStep(step, context);
|
|
300
|
+
|
|
301
|
+
// 后置 guardrail 检查(重试时默认也执行)
|
|
302
|
+
if (step.guardrailOnRetry !== false && step.guardrail) {
|
|
303
|
+
const guardrailPassed = await this.runGuardrail(step, context, false);
|
|
304
|
+
if (!guardrailPassed) {
|
|
305
|
+
return { status: 'blocked', guardrailFailed: step.guardrail.name };
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return { status: 'success', result };
|
|
310
|
+
} catch (error) {
|
|
311
|
+
if (attempt === step.retry.max) {
|
|
312
|
+
this.constraintLayer.log(`Step ${step.id} failed after ${attempt + 1} attempts`, { error: String(error) }, 'failed');
|
|
313
|
+
return {
|
|
314
|
+
status: step.onFail === 'skip' ? 'skipped' : 'failed',
|
|
315
|
+
error: String(error)
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// 指数退避
|
|
320
|
+
const backoffMs = step.retry.backoffMs * Math.pow(2, attempt);
|
|
321
|
+
this.constraintLayer.log(`Step ${step.id} attempt ${attempt + 1} failed, retrying in ${backoffMs}ms`, {}, 'warn');
|
|
322
|
+
await this.sleep(backoffMs);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return { status: 'failed', error: 'Max retries exceeded' };
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
private async runStep(step: WorkflowStep, context: WorkflowContext): Promise<unknown> {
|
|
330
|
+
switch (step.type) {
|
|
331
|
+
case 'read': {
|
|
332
|
+
const path = step.config?.path;
|
|
333
|
+
if (!path) throw new Error('Read step requires path config');
|
|
334
|
+
const content = await documentReader.read(path);
|
|
335
|
+
context.document = content;
|
|
336
|
+
return content;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
case 'chunk': {
|
|
340
|
+
if (!context.document) throw new Error('No document loaded');
|
|
341
|
+
const maxSize = step.config?.maxChunkSize || 4000;
|
|
342
|
+
return documentReader.chunk(context.document.text, maxSize);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
case 'summarize': {
|
|
346
|
+
if (!context.document) throw new Error('No document loaded');
|
|
347
|
+
const llm = getMinimax();
|
|
348
|
+
const chunks = documentReader.chunk(context.document.text, step.config?.maxChunkSize || 4000);
|
|
349
|
+
const summaries: string[] = [];
|
|
350
|
+
let totalQuality = 0;
|
|
351
|
+
|
|
352
|
+
for (const chunk of chunks) {
|
|
353
|
+
const result = await llm.summarize(chunk, step.config?.context);
|
|
354
|
+
summaries.push(result.summary);
|
|
355
|
+
totalQuality += result.qualityScore;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
context.summary = summaries.join('\n\n');
|
|
359
|
+
context.qualityScore = totalQuality / chunks.length;
|
|
360
|
+
return { summary: context.summary, qualityScore: context.qualityScore };
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
case 'improve': {
|
|
364
|
+
if (!context.document) throw new Error('No document loaded');
|
|
365
|
+
const llm = getMinimax();
|
|
366
|
+
const improved = await llm.improveContent(
|
|
367
|
+
context.document.text,
|
|
368
|
+
step.config?.requirements || '',
|
|
369
|
+
step.config?.context
|
|
370
|
+
);
|
|
371
|
+
context.improved = improved;
|
|
372
|
+
return { improved };
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
case 'send': {
|
|
376
|
+
const peerId = step.config?.peerId;
|
|
377
|
+
const message = step.config?.message || context.summary || '';
|
|
378
|
+
if (!peerId) throw new Error('Send step requires peerId config');
|
|
379
|
+
await p2pNetwork.sendMessage(peerId, 'message', message);
|
|
380
|
+
this.constraintLayer.log(`Sent message to ${peerId}`, { peerId, messageLength: message.length }, 'success');
|
|
381
|
+
return { sent: true, peerId };
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
case 'report': {
|
|
385
|
+
const content = step.config?.content || context.summary || '';
|
|
386
|
+
await p2pNetwork.broadcast('report', content);
|
|
387
|
+
this.constraintLayer.log('Broadcast report', { contentLength: content.length }, 'success');
|
|
388
|
+
return { broadcasted: true };
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
case 'review': {
|
|
392
|
+
return { status: 'reviewed', qualityScore: context.qualityScore };
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
default:
|
|
396
|
+
throw new Error(`Unknown step type: ${step.type}`);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
private async runGuardrail(step: WorkflowStep, context: WorkflowContext, isPreCheck: boolean): Promise<boolean> {
|
|
401
|
+
if (!step.guardrail) return true;
|
|
402
|
+
try {
|
|
403
|
+
return await step.guardrail(context);
|
|
404
|
+
} catch (error) {
|
|
405
|
+
this.constraintLayer.log(
|
|
406
|
+
`Guardrail ${step.guardrail.name} error`,
|
|
407
|
+
{ error: String(error), isPreCheck },
|
|
408
|
+
'failed'
|
|
409
|
+
);
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
private sleep(ms: number): Promise<void> {
|
|
415
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
getConstraintLayer(): ConstraintLayer {
|
|
419
|
+
return this.constraintLayer;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
**Step 2: 提交**
|
|
425
|
+
|
|
426
|
+
```bash
|
|
427
|
+
git add src/agents/workflow-engine.ts
|
|
428
|
+
git commit -m "feat: add workflow engine with retry and guardrails"
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
---
|
|
432
|
+
|
|
433
|
+
## 任务 3: 集成约束层和工作流引擎到 AgentSession
|
|
434
|
+
|
|
435
|
+
**Files:**
|
|
436
|
+
- Modify: `src/agents/pi-sdk.ts`
|
|
437
|
+
|
|
438
|
+
---
|
|
439
|
+
|
|
440
|
+
### Task 3.1: 更新 AgentSession 集成新组件
|
|
441
|
+
|
|
442
|
+
**Step 1: 添加导入和新字段**
|
|
443
|
+
|
|
444
|
+
```typescript
|
|
445
|
+
import { ConstraintLayer, SYSTEM_PROMPT } from './constraint-layer.js';
|
|
446
|
+
import { WorkflowEngine } from './workflow-engine.js';
|
|
447
|
+
|
|
448
|
+
// 在 PiAgentSession 类中添加
|
|
449
|
+
class PiAgentSession implements AgentSession {
|
|
450
|
+
private cwd: string;
|
|
451
|
+
private peerId: string;
|
|
452
|
+
private identity: IdentityDoc;
|
|
453
|
+
private minimaxAvailable = false;
|
|
454
|
+
private workflows: Map<string, Workflow> = new Map();
|
|
455
|
+
private constraintLayer: ConstraintLayer;
|
|
456
|
+
private workflowEngine: WorkflowEngine;
|
|
457
|
+
// ... existing fields
|
|
458
|
+
}
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
**Step 2: 在构造函数中初始化**
|
|
462
|
+
|
|
463
|
+
```typescript
|
|
464
|
+
constructor(config: AgentSessionConfig) {
|
|
465
|
+
this.cwd = config.cwd;
|
|
466
|
+
this.peerId = config.peerId || 'local';
|
|
467
|
+
this.identity = config.identityDoc || this.createDefaultIdentity();
|
|
468
|
+
this.minimaxAvailable = this.checkMinimax();
|
|
469
|
+
this.constraintLayer = new ConstraintLayer();
|
|
470
|
+
this.workflowEngine = new WorkflowEngine(this.constraintLayer);
|
|
471
|
+
}
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
**Step 3: 添加 runWorkflow 实现**
|
|
475
|
+
|
|
476
|
+
```typescript
|
|
477
|
+
async runWorkflow(steps: WorkflowStep[]): Promise<Workflow> {
|
|
478
|
+
const context = {
|
|
479
|
+
peers: this.getPeers(),
|
|
480
|
+
logs: []
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
// 约束层预检查
|
|
484
|
+
const checkResult = await this.constraintLayer.checkGuardrails(context as WorkflowContext);
|
|
485
|
+
if (!checkResult.passed && checkResult.blocked) {
|
|
486
|
+
console.warn(`Guardrail blocked: ${checkResult.blocked.name}`);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
return this.workflowEngine.executeWorkflow(steps, context);
|
|
490
|
+
}
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
**Step 4: 添加便捷工作流方法**
|
|
494
|
+
|
|
495
|
+
```typescript
|
|
496
|
+
async summarizeDocumentWorkflow(filePath: string, targetPeer?: string): Promise<Workflow> {
|
|
497
|
+
const steps: WorkflowStep[] = [
|
|
498
|
+
{
|
|
499
|
+
id: 'read',
|
|
500
|
+
type: 'read',
|
|
501
|
+
config: { path: filePath },
|
|
502
|
+
retry: { max: 3, current: 0, backoffMs: 1000 },
|
|
503
|
+
onFail: 'abort'
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
id: 'summarize',
|
|
507
|
+
type: 'summarize',
|
|
508
|
+
config: { context: `File: ${filePath}` },
|
|
509
|
+
retry: { max: 3, current: 0, backoffMs: 1000 },
|
|
510
|
+
onFail: 'skip',
|
|
511
|
+
guardrail: (ctx) => Promise.resolve(ctx.qualityScore !== undefined && ctx.qualityScore >= 0.5)
|
|
512
|
+
}
|
|
513
|
+
];
|
|
514
|
+
|
|
515
|
+
if (targetPeer) {
|
|
516
|
+
steps.push({
|
|
517
|
+
id: 'send',
|
|
518
|
+
type: 'send',
|
|
519
|
+
config: { peerId: targetPeer },
|
|
520
|
+
retry: { max: 2, current: 0, backoffMs: 2000 },
|
|
521
|
+
onFail: 'skip'
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
return this.runWorkflow(steps);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
async improveAndSendWorkflow(filePath: string, requirements: string, targetPeer: string): Promise<Workflow> {
|
|
529
|
+
const steps: WorkflowStep[] = [
|
|
530
|
+
{
|
|
531
|
+
id: 'read',
|
|
532
|
+
type: 'read',
|
|
533
|
+
config: { path: filePath },
|
|
534
|
+
retry: { max: 3, current: 0, backoffMs: 1000 },
|
|
535
|
+
onFail: 'abort'
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
id: 'improve',
|
|
539
|
+
type: 'improve',
|
|
540
|
+
config: { requirements, context: `File: ${filePath}` },
|
|
541
|
+
retry: { max: 2, current: 0, backoffMs: 1500 },
|
|
542
|
+
onFail: 'skip'
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
id: 'send',
|
|
546
|
+
type: 'send',
|
|
547
|
+
config: { peerId: targetPeer, message: '改进后的文档' },
|
|
548
|
+
retry: { max: 2, current: 0, backoffMs: 2000 },
|
|
549
|
+
onFail: 'skip'
|
|
550
|
+
}
|
|
551
|
+
];
|
|
552
|
+
|
|
553
|
+
return this.runWorkflow(steps);
|
|
554
|
+
}
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
**Step 5: 提交**
|
|
558
|
+
|
|
559
|
+
```bash
|
|
560
|
+
git add src/agents/pi-sdk.ts
|
|
561
|
+
git commit -m "feat: integrate constraint layer and workflow engine into AgentSession"
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
---
|
|
565
|
+
|
|
566
|
+
## 任务 4: 添加测试
|
|
567
|
+
|
|
568
|
+
**Files:**
|
|
569
|
+
- Create: `src/test/constraint-layer.test.ts`
|
|
570
|
+
- Create: `src/test/workflow-engine.test.ts`
|
|
571
|
+
|
|
572
|
+
---
|
|
573
|
+
|
|
574
|
+
### Task 4.1: 约束层测试
|
|
575
|
+
|
|
576
|
+
**Step 1: 编写测试**
|
|
577
|
+
|
|
578
|
+
```typescript
|
|
579
|
+
import { describe, it, expect } from 'vitest';
|
|
580
|
+
import { ConstraintLayer, WorkflowContext } from '../agents/constraint-layer.js';
|
|
581
|
+
|
|
582
|
+
describe('ConstraintLayer', () => {
|
|
583
|
+
const layer = new ConstraintLayer();
|
|
584
|
+
|
|
585
|
+
describe('checkGuardrails', () => {
|
|
586
|
+
it('should pass when no guardrails fail', async () => {
|
|
587
|
+
const context: WorkflowContext = {
|
|
588
|
+
peers: ['peer1', 'peer2'],
|
|
589
|
+
logs: []
|
|
590
|
+
};
|
|
591
|
+
|
|
592
|
+
const result = await layer.checkGuardrails(context);
|
|
593
|
+
expect(result.passed).toBe(true);
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
it('should block send to unknown peer', async () => {
|
|
597
|
+
const context: WorkflowContext = {
|
|
598
|
+
peers: ['peer1', 'peer2'],
|
|
599
|
+
logs: []
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
const result = await layer.checkGuardrails(context, {
|
|
603
|
+
id: 'send',
|
|
604
|
+
type: 'send',
|
|
605
|
+
config: { peerId: 'unknown-peer' },
|
|
606
|
+
retry: { max: 0, current: 0, backoffMs: 0 },
|
|
607
|
+
onFail: 'block'
|
|
608
|
+
} as any);
|
|
609
|
+
|
|
610
|
+
expect(result.passed).toBe(false);
|
|
611
|
+
expect(result.blocked?.name).toBe('validateSendTarget');
|
|
612
|
+
});
|
|
613
|
+
|
|
614
|
+
it('should allow send to known peer', async () => {
|
|
615
|
+
const context: WorkflowContext = {
|
|
616
|
+
peers: ['peer1', 'peer2'],
|
|
617
|
+
logs: []
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
const result = await layer.checkGuardrails(context, {
|
|
621
|
+
id: 'send',
|
|
622
|
+
type: 'send',
|
|
623
|
+
config: { peerId: 'peer1' },
|
|
624
|
+
retry: { max: 0, current: 0, backoffMs: 0 },
|
|
625
|
+
onFail: 'block'
|
|
626
|
+
} as any);
|
|
627
|
+
|
|
628
|
+
expect(result.passed).toBe(true);
|
|
629
|
+
});
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
describe('isAutonomousAction', () => {
|
|
633
|
+
it('should identify autonomous actions', () => {
|
|
634
|
+
expect(layer.isAutonomousAction('summarize')).toBe(true);
|
|
635
|
+
expect(layer.isAutonomousAction('chunk')).toBe(true);
|
|
636
|
+
expect(layer.isAutonomousAction('improve')).toBe(true);
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
it('should identify confirmation-required actions', () => {
|
|
640
|
+
expect(layer.requiresConfirmation('send')).toBe(true);
|
|
641
|
+
expect(layer.requiresConfirmation('delete')).toBe(true);
|
|
642
|
+
});
|
|
643
|
+
});
|
|
644
|
+
|
|
645
|
+
describe('logging', () => {
|
|
646
|
+
it('should record operations', () => {
|
|
647
|
+
layer.log('test action', { key: 'value' }, 'success');
|
|
648
|
+
const logs = layer.getLogs();
|
|
649
|
+
expect(logs).toHaveLength(1);
|
|
650
|
+
expect(logs[0].action).toBe('test action');
|
|
651
|
+
expect(logs[0].status).toBe('success');
|
|
652
|
+
});
|
|
653
|
+
});
|
|
654
|
+
});
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
**Step 2: 运行测试验证**
|
|
658
|
+
|
|
659
|
+
```bash
|
|
660
|
+
npm test -- src/test/constraint-layer.test.ts
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
**Step 3: 提交**
|
|
664
|
+
|
|
665
|
+
```bash
|
|
666
|
+
git add src/test/constraint-layer.test.ts
|
|
667
|
+
git commit -m "test: add constraint layer tests"
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
### Task 4.2: 工作流引擎测试
|
|
671
|
+
|
|
672
|
+
**Step 1: 编写测试**
|
|
673
|
+
|
|
674
|
+
```typescript
|
|
675
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
676
|
+
import { WorkflowEngine, WorkflowStep } from '../agents/workflow-engine.js';
|
|
677
|
+
import { WorkflowContext } from '../agents/constraint-layer.js';
|
|
678
|
+
|
|
679
|
+
// Mock dependencies
|
|
680
|
+
vi.mock('../documents/reader.js', () => ({
|
|
681
|
+
documentReader: {
|
|
682
|
+
read: vi.fn().mockResolvedValue({ text: 'test content', metadata: { filename: 'test.txt', size: 12, type: '.txt' } }),
|
|
683
|
+
chunk: vi.fn().mockReturnValue(['test content'])
|
|
684
|
+
}
|
|
685
|
+
}));
|
|
686
|
+
|
|
687
|
+
vi.mock('../llm/minimax.js', () => ({
|
|
688
|
+
getMinimax: vi.fn().mockReturnValue({
|
|
689
|
+
summarize: vi.fn().mockResolvedValue({ summary: 'test summary', qualityScore: 0.8 })
|
|
690
|
+
})
|
|
691
|
+
}));
|
|
692
|
+
|
|
693
|
+
describe('WorkflowEngine', () => {
|
|
694
|
+
let engine: WorkflowEngine;
|
|
695
|
+
|
|
696
|
+
beforeEach(() => {
|
|
697
|
+
engine = new WorkflowEngine();
|
|
698
|
+
});
|
|
699
|
+
|
|
700
|
+
describe('executeStep', () => {
|
|
701
|
+
it('should execute read step successfully', async () => {
|
|
702
|
+
const step: WorkflowStep = {
|
|
703
|
+
id: 'read',
|
|
704
|
+
type: 'read',
|
|
705
|
+
config: { path: 'test.txt' },
|
|
706
|
+
retry: { max: 0, current: 0, backoffMs: 0 },
|
|
707
|
+
onFail: 'abort'
|
|
708
|
+
};
|
|
709
|
+
|
|
710
|
+
const context: WorkflowContext = { peers: [], logs: [] };
|
|
711
|
+
const result = await engine.executeStep(step, context);
|
|
712
|
+
|
|
713
|
+
expect(result.status).toBe('success');
|
|
714
|
+
expect(context.document).toBeDefined();
|
|
715
|
+
});
|
|
716
|
+
|
|
717
|
+
it('should retry on failure up to max attempts', async () => {
|
|
718
|
+
const attemptTracker = { count: 0 };
|
|
719
|
+
const engineWithRetry = new WorkflowEngine();
|
|
720
|
+
|
|
721
|
+
// Custom step that fails twice then succeeds
|
|
722
|
+
const step: WorkflowStep = {
|
|
723
|
+
id: 'test',
|
|
724
|
+
type: 'read',
|
|
725
|
+
config: { path: 'test.txt' },
|
|
726
|
+
retry: { max: 3, current: 0, backoffMs: 10 },
|
|
727
|
+
onFail: 'abort'
|
|
728
|
+
};
|
|
729
|
+
|
|
730
|
+
const context: WorkflowContext = { peers: [], logs: [] };
|
|
731
|
+
const result = await engineWithRetry.executeStep(step, context);
|
|
732
|
+
|
|
733
|
+
expect(result.status).toBe('success');
|
|
734
|
+
});
|
|
735
|
+
|
|
736
|
+
it('should skip when onFail is skip and max retries exceeded', async () => {
|
|
737
|
+
const step: WorkflowStep = {
|
|
738
|
+
id: 'fail',
|
|
739
|
+
type: 'read',
|
|
740
|
+
config: { path: 'nonexistent.txt' },
|
|
741
|
+
retry: { max: 0, current: 0, backoffMs: 0 },
|
|
742
|
+
onFail: 'skip'
|
|
743
|
+
};
|
|
744
|
+
|
|
745
|
+
const context: WorkflowContext = { peers: [], logs: [] };
|
|
746
|
+
const result = await engine.executeStep(step, context);
|
|
747
|
+
|
|
748
|
+
expect(result.status).toBe('skipped');
|
|
749
|
+
});
|
|
750
|
+
});
|
|
751
|
+
});
|
|
752
|
+
```
|
|
753
|
+
|
|
754
|
+
**Step 2: 运行测试验证**
|
|
755
|
+
|
|
756
|
+
```bash
|
|
757
|
+
npm test -- src/test/workflow-engine.test.ts
|
|
758
|
+
```
|
|
759
|
+
|
|
760
|
+
**Step 3: 提交**
|
|
761
|
+
|
|
762
|
+
```bash
|
|
763
|
+
git add src/test/workflow-engine.test.ts
|
|
764
|
+
git commit -m "test: add workflow engine tests"
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
---
|
|
768
|
+
|
|
769
|
+
## 任务 5: 验证构建
|
|
770
|
+
|
|
771
|
+
**Step 1: 运行 TypeScript 编译**
|
|
772
|
+
|
|
773
|
+
```bash
|
|
774
|
+
npm run build
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
Expected: 编译成功,无错误
|
|
778
|
+
|
|
779
|
+
**Step 2: 运行所有测试**
|
|
780
|
+
|
|
781
|
+
```bash
|
|
782
|
+
npm test
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
Expected: 所有测试通过
|
|
786
|
+
|
|
787
|
+
**Step 3: 最终提交**
|
|
788
|
+
|
|
789
|
+
```bash
|
|
790
|
+
git add -A
|
|
791
|
+
git commit -m "feat: complete document agent with constraint layer and workflow engine"
|
|
792
|
+
```
|