@bolloon/bolloon-agent 0.1.1 → 0.1.2

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.
Files changed (200) hide show
  1. package/bin/bolloon-cli.cjs +157 -0
  2. package/bin/bolloon-daemon.sh +207 -0
  3. package/bin/bolloon.cmd +11 -0
  4. package/dist/agents/constraint-layer.js +10 -15
  5. package/dist/agents/pi-sdk.js +433 -106
  6. package/dist/agents/protocol.js +82 -1
  7. package/dist/agents/subagent-manager.js +2 -2
  8. package/dist/agents/workflow-engine.js +15 -20
  9. package/dist/agents/workflow-pivot-loop.js +541 -0
  10. package/dist/bollharness/src/index.js +5 -0
  11. package/dist/bollharness/src/scripts/checks/check_adr_plan_numbering.js +6 -0
  12. package/dist/bollharness/src/scripts/checks/check_api_types.js +45 -0
  13. package/dist/bollharness/src/scripts/checks/check_artifact_link.js +146 -0
  14. package/dist/bollharness/src/scripts/checks/check_bridge_deps.js +6 -0
  15. package/dist/bollharness/src/scripts/checks/check_bugfix_binding.js +6 -0
  16. package/dist/bollharness/src/scripts/checks/check_bugfix_binding_ci.js +6 -0
  17. package/dist/bollharness/src/scripts/checks/check_doc_file_references.js +6 -0
  18. package/dist/bollharness/src/scripts/checks/check_doc_freshness.js +135 -0
  19. package/dist/bollharness/src/scripts/checks/check_doc_links.js +31 -0
  20. package/dist/bollharness/src/scripts/checks/check_file_existence_claims.js +6 -0
  21. package/dist/bollharness/src/scripts/checks/check_fragment_integrity.js +34 -0
  22. package/dist/bollharness/src/scripts/checks/check_hook_installed.js +63 -0
  23. package/dist/bollharness/src/scripts/checks/check_issue_closure.js +41 -0
  24. package/dist/bollharness/src/scripts/checks/check_mcp_parity.js +6 -0
  25. package/dist/bollharness/src/scripts/checks/check_security.js +48 -0
  26. package/dist/bollharness/src/scripts/checks/check_skill_parity.js +6 -0
  27. package/dist/bollharness/src/scripts/checks/check_versions.js +6 -0
  28. package/dist/bollharness/src/scripts/checks/finding.js +13 -0
  29. package/dist/bollharness/src/scripts/checks/next_decision_number.js +20 -0
  30. package/dist/bollharness/src/scripts/checks/regenerate_magic_docs.js +6 -0
  31. package/dist/bollharness/src/scripts/ci/detect_rebaseline_triggers.js +8 -0
  32. package/dist/bollharness/src/scripts/ci/scan_subprocess_cfg.js +8 -0
  33. package/dist/bollharness/src/scripts/ci/scan_verify_artifacts.js +8 -0
  34. package/dist/bollharness/src/scripts/ci/scan_yaml_schema.js +8 -0
  35. package/dist/bollharness/src/scripts/context_router.js +67 -0
  36. package/dist/bollharness/src/scripts/deploy-guard.js +157 -0
  37. package/dist/bollharness/src/scripts/guard-feedback.js +192 -0
  38. package/dist/bollharness/src/scripts/guard_router.js +158 -0
  39. package/dist/bollharness/src/scripts/hooks/_hook_output.js +6 -0
  40. package/dist/bollharness/src/scripts/hooks/auto-python3.js +6 -0
  41. package/dist/bollharness/src/scripts/hooks/deploy-progress-on-session-end.js +6 -0
  42. package/dist/bollharness/src/scripts/hooks/failure-analyzer.js +6 -0
  43. package/dist/bollharness/src/scripts/hooks/gate-judgment-inject.js +92 -0
  44. package/dist/bollharness/src/scripts/hooks/gate-transition-judgment.js +63 -0
  45. package/dist/bollharness/src/scripts/hooks/inbox-ack.js +6 -0
  46. package/dist/bollharness/src/scripts/hooks/inbox-inject-on-start.js +6 -0
  47. package/dist/bollharness/src/scripts/hooks/inbox-validate.js +6 -0
  48. package/dist/bollharness/src/scripts/hooks/inbox-write-ledger.js +6 -0
  49. package/dist/bollharness/src/scripts/hooks/initializer-agent.js +6 -0
  50. package/dist/bollharness/src/scripts/hooks/loop-detection.js +73 -0
  51. package/dist/bollharness/src/scripts/hooks/owner-guard.js +6 -0
  52. package/dist/bollharness/src/scripts/hooks/precompact.js +6 -0
  53. package/dist/bollharness/src/scripts/hooks/review-agent-gatekeeper.js +6 -0
  54. package/dist/bollharness/src/scripts/hooks/risk-tracker.js +108 -0
  55. package/dist/bollharness/src/scripts/hooks/sanitize-on-read.js +6 -0
  56. package/dist/bollharness/src/scripts/hooks/session-reflection.js +7 -0
  57. package/dist/bollharness/src/scripts/hooks/session-start-magic-docs.js +7 -0
  58. package/dist/bollharness/src/scripts/hooks/session-start-reset-risk.js +7 -0
  59. package/dist/bollharness/src/scripts/hooks/session-start-toolkit-reminder.js +7 -0
  60. package/dist/bollharness/src/scripts/hooks/stop-evaluator.js +157 -0
  61. package/dist/bollharness/src/scripts/hooks/tool-call-counter.js +6 -0
  62. package/dist/bollharness/src/scripts/hooks/trace-analyzer.js +10 -0
  63. package/dist/bollharness/src/scripts/install/install-trust-token.js +7 -0
  64. package/dist/bollharness/src/scripts/install/multi_project_registry.js +9 -0
  65. package/dist/bollharness/src/scripts/install/phase2_auto.js +21 -0
  66. package/dist/bollharness/src/scripts/install/pre_commit_installer.js +6 -0
  67. package/dist/bollharness/src/scripts/install/tier_selector.js +7 -0
  68. package/dist/bollharness/src/scripts/install/transcript_miner.js +7 -0
  69. package/dist/bollharness/src/scripts/lib/claim_patterns.js +10 -0
  70. package/dist/bollharness/src/scripts/lib/sanitize_patterns.js +12 -0
  71. package/dist/bollharness/src/scripts/sanitize.js +6 -0
  72. package/dist/bollharness-integration/channel-judgment-engine.js +530 -0
  73. package/dist/bollharness-integration/context-chain-router.js +383 -0
  74. package/dist/bollharness-integration/context-router-judgment.js +13 -21
  75. package/dist/bollharness-integration/context-router.js +22 -64
  76. package/dist/bollharness-integration/gate-state-machine.js +14 -19
  77. package/dist/bollharness-integration/gate-transition-hooks.js +16 -61
  78. package/dist/bollharness-integration/guard-checker.js +21 -68
  79. package/dist/bollharness-integration/index.js +14 -124
  80. package/dist/bollharness-integration/integration.js +13 -20
  81. package/dist/bollharness-integration/llm-judgment-engine.js +569 -0
  82. package/dist/bollharness-integration/skill-adapter.js +18 -64
  83. package/dist/cli-entry.js +261 -0
  84. package/dist/constraint-runtime/src/commands.js +17 -7
  85. package/dist/constraint-runtime/src/constraint/budget.js +1 -6
  86. package/dist/constraint-runtime/src/constraint/permission.js +1 -6
  87. package/dist/constraint-runtime/src/models.js +1 -3
  88. package/dist/constraint-runtime/src/tools.js +17 -7
  89. package/dist/constraints/index.js +1 -7
  90. package/dist/documents/reader.js +8 -49
  91. package/dist/heartbeat/DaemonManager.js +242 -0
  92. package/dist/heartbeat/HealthMonitor.js +285 -0
  93. package/dist/heartbeat/StartupVerifier.js +205 -0
  94. package/dist/heartbeat/Watchdog.js +168 -0
  95. package/dist/heartbeat/index.js +84 -0
  96. package/dist/heartbeat/types.js +5 -0
  97. package/dist/index.js +381 -28
  98. package/dist/llm/config-store.js +31 -57
  99. package/dist/llm/llm-judgment-client.js +389 -0
  100. package/dist/llm/pi-ai.js +9 -52
  101. package/dist/network/agent-network.js +46 -90
  102. package/dist/network/hybrid-messenger.js +125 -0
  103. package/dist/network/iroh-bootstrap.js +38 -0
  104. package/dist/network/iroh-discovery.js +145 -0
  105. package/dist/network/iroh-integration.js +9 -16
  106. package/dist/network/iroh-transport.js +10 -48
  107. package/dist/network/p2p.js +23 -62
  108. package/dist/network/storage/adapters/json-adapter.js +4 -42
  109. package/dist/network/storage/index.js +147 -0
  110. package/dist/network/storage/types.js +14 -0
  111. package/dist/pi-ecosystem/index.js +233 -0
  112. package/dist/pi-ecosystem-colony/index.js +29 -90
  113. package/dist/pi-ecosystem-goals/index.js +20 -74
  114. package/dist/pi-ecosystem-judgment/decision.js +29 -47
  115. package/dist/pi-ecosystem-judgment/distillation.js +16 -29
  116. package/dist/pi-ecosystem-judgment/human-value-store.js +13 -60
  117. package/dist/pi-ecosystem-judgment/index.js +21 -74
  118. package/dist/pi-ecosystem-judgment/value-injection.js +26 -72
  119. package/dist/pi-ecosystem-mcp/index.js +24 -78
  120. package/dist/pi-ecosystem-subagents/index.js +20 -69
  121. package/dist/social/ant-colony/AdaptiveHeartbeat.js +3 -8
  122. package/dist/social/ant-colony/PheromoneEngine.js +11 -49
  123. package/dist/social/ant-colony/index.js +6 -0
  124. package/dist/social/ant-colony/types.js +4 -8
  125. package/dist/social/channels/ChannelManager.js +8 -46
  126. package/dist/social/channels/DiapChannelBridge.js +9 -47
  127. package/dist/social/channels/InterestMatcher.js +2 -7
  128. package/dist/social/channels/channel-agent-session.js +309 -0
  129. package/dist/social/channels/channel-heartbeat-agent.js +494 -0
  130. package/dist/social/channels/diap-doc-parser.js +204 -0
  131. package/dist/social/channels/harness-workflow-integrator.js +446 -0
  132. package/dist/social/channels/index.js +9 -0
  133. package/dist/social/channels/types.js +3 -7
  134. package/dist/social/global-shared-context.js +6 -47
  135. package/dist/social/heartbeat.js +29 -72
  136. package/dist/social/persona/enhanced-persona.js +299 -0
  137. package/dist/web/client.js +302 -136
  138. package/dist/web/components/p2p/index.js +159 -9
  139. package/dist/web/components/p2p/p2p-connection.js +136 -0
  140. package/dist/web/components/p2p/p2p-manager.js +24 -0
  141. package/dist/web/components/p2p/p2p-store-memory.js +1 -1
  142. package/dist/web/components/p2p/types.js +7 -0
  143. package/dist/web/index.html +5 -0
  144. package/dist/web/style.css +118 -0
  145. package/package.json +12 -6
  146. package/scripts/build-cli.js +206 -0
  147. package/scripts/postinstall.js +153 -0
  148. package/src/agents/pi-sdk.ts +347 -28
  149. package/src/agents/protocol.ts +95 -1
  150. package/src/agents/workflow-pivot-loop.ts +674 -0
  151. package/src/bollharness/CLAUDE.md +73 -0
  152. package/src/bollharness/README.md +143 -0
  153. package/src/bollharness/README.zh-CN.md +131 -0
  154. package/src/bollharness/reference/boll-reference/scripts/hooks/stop-evaluator.md +57 -0
  155. package/src/bollharness/scripts/context-fragments/artifact-linkage.md +14 -0
  156. package/src/bollharness/scripts/context-fragments/auth-consumers.md +17 -0
  157. package/src/bollharness/scripts/context-fragments/bridge-constitution.md +13 -0
  158. package/src/bollharness/scripts/context-fragments/catalyst-distributed.md +18 -0
  159. package/src/bollharness/scripts/context-fragments/closure-checklist.md +13 -0
  160. package/src/bollharness/scripts/context-fragments/contract-consumers.md +15 -0
  161. package/src/bollharness/scripts/context-fragments/db-shared-structures.md +15 -0
  162. package/src/bollharness/scripts/context-fragments/fixed-three-layers.md +19 -0
  163. package/src/bollharness/scripts/context-fragments/general-dev-principles.md +11 -0
  164. package/src/bollharness/scripts/context-fragments/issue-first.md +8 -0
  165. package/src/bollharness/scripts/context-fragments/mcp-parity.md +16 -0
  166. package/src/bollharness/scripts/context-fragments/pi-agent-operations.md +108 -0
  167. package/src/bollharness/scripts/context-fragments/protocol-consumers.md +15 -0
  168. package/src/bollharness/scripts/context-fragments/run-events-consumers.md +15 -0
  169. package/src/bollharness/scripts/context-fragments/scene-fidelity.md +13 -0
  170. package/src/bollharness/scripts/context-fragments/truth-source-hierarchy.md +15 -0
  171. package/src/bollharness/scripts/context-fragments/two-language.md +15 -0
  172. package/src/bollharness/scripts/context-fragments/version-sources.md +14 -0
  173. package/src/bollharness/scripts/hooks/stop-evaluator.md +83 -0
  174. package/src/bollharness/templates/scaffold/CLAUDE.md +89 -0
  175. package/src/cli-entry.ts +304 -0
  176. package/src/heartbeat/DaemonManager.ts +283 -0
  177. package/src/heartbeat/HealthMonitor.ts +316 -0
  178. package/src/heartbeat/StartupVerifier.ts +223 -0
  179. package/src/heartbeat/Watchdog.ts +198 -0
  180. package/src/heartbeat/index.ts +108 -0
  181. package/src/heartbeat/types.ts +82 -0
  182. package/src/llm/config-store.ts +23 -5
  183. package/src/network/iroh-transport.ts +3 -3
  184. package/src/web/client.js +302 -136
  185. package/src/web/components/p2p/P2PModal.tsx +91 -3
  186. package/src/web/components/p2p/index.ts +171 -9
  187. package/src/web/components/p2p/p2p-connection.ts +153 -1
  188. package/src/web/components/p2p/p2p-manager.ts +39 -1
  189. package/src/web/components/p2p/p2p-store-memory.ts +1 -1
  190. package/src/web/components/p2p/p2p-tools.ts +315 -0
  191. package/src/web/components/p2p/types.ts +58 -0
  192. package/src/web/design.md +99 -0
  193. package/src/web/index.html +5 -0
  194. package/src/web/server.ts +353 -36
  195. package/src/web/style.css +118 -0
  196. package/tsconfig.cli.json +16 -0
  197. package/tsconfig.electron.json +1 -1
  198. package/tsconfig.json +1 -2
  199. package/dist/web/server.js +0 -1647
  200. package/dist/web/server.js.map +0 -1
@@ -0,0 +1,446 @@
1
+ /**
2
+ * Harness Workflow Integrator
3
+ *
4
+ * 将 Channel Agent 与 Bollharness 配置系统集成:
5
+ * 1. 加载 YAML 工作流配置
6
+ * 2. 实现 Gate 状态机
7
+ * 3. Skill 路由调度
8
+ * 4. 多智能体协作协调
9
+ */
10
+ import * as fs from 'fs/promises';
11
+ import * as path from 'path';
12
+ /**
13
+ * Harness Workflow Integrator 类
14
+ */
15
+ export class HarnessWorkflowIntegrator {
16
+ config = null;
17
+ currentGate = 0;
18
+ artifacts = new Map();
19
+ gateHistory = [];
20
+ initialized = false;
21
+ constructor() { }
22
+ /**
23
+ * 初始化,加载配置
24
+ */
25
+ async initialize(configPath) {
26
+ if (this.initialized)
27
+ return;
28
+ const defaultPath = path.join(process.env.HOME || '/tmp', '.bolloon', 'channels', 'agent-workflow-config.yaml');
29
+ const filePath = configPath || defaultPath;
30
+ try {
31
+ const content = await fs.readFile(filePath, 'utf-8');
32
+ this.config = JSON.parse(content);
33
+ this.initialized = true;
34
+ console.log(`[HarnessIntegrator] Loaded workflow config from ${filePath}`);
35
+ }
36
+ catch (e) {
37
+ // 使用内置默认配置
38
+ this.config = this.getDefaultConfig();
39
+ this.initialized = true;
40
+ console.log('[HarnessIntegrator] Using default workflow config');
41
+ }
42
+ }
43
+ /**
44
+ * 获取默认配置
45
+ */
46
+ getDefaultConfig() {
47
+ return {
48
+ version: '1.0',
49
+ workflows: {
50
+ default: {
51
+ name: '默认协作工作流',
52
+ description: '基于 Harness Gate 的多智能体协作工作流',
53
+ initial_gate: 0,
54
+ gates: {
55
+ 0: {
56
+ name: '问题锁定',
57
+ entry_condition: '用户提出需求',
58
+ required_artifact: '问题陈述 + Change Classification',
59
+ required_skills: ['arch'],
60
+ next_gate: 1
61
+ },
62
+ 1: {
63
+ name: '架构设计',
64
+ entry_condition: 'Gate 0 产物存在',
65
+ required_artifact: 'ADR草稿 + 消费方清单',
66
+ required_skills: ['arch', 'lead'],
67
+ next_gate: 2
68
+ },
69
+ 2: {
70
+ name: '架构审查',
71
+ entry_condition: 'ADR草稿完成',
72
+ required_artifact: '审查报告 (PASS/BLOCK)',
73
+ required_skills: ['arch', 'guardian-fixer'],
74
+ is_review_gate: true,
75
+ reviewer_type: 'independent',
76
+ next_gate: 3
77
+ },
78
+ 3: {
79
+ name: '计划制定',
80
+ entry_condition: 'Gate 2 PASS',
81
+ required_artifact: 'PLAN文档 + 架构覆盖矩阵',
82
+ required_skills: ['harness-eng', 'plan-lock'],
83
+ next_gate: 4
84
+ },
85
+ 4: {
86
+ name: '计划审查',
87
+ entry_condition: 'PLAN vN-final 冻结',
88
+ required_artifact: '审查报告 + plan-lock确认',
89
+ required_skills: ['arch', 'guardian-fixer'],
90
+ is_review_gate: true,
91
+ reviewer_type: 'independent',
92
+ next_gate: 5
93
+ },
94
+ 5: {
95
+ name: '任务分解',
96
+ entry_condition: 'Gate 4 PASS + plan-lock',
97
+ required_artifact: 'WP拆分 + TASK.md',
98
+ required_skills: ['task-arch', 'crystal-learn'],
99
+ next_gate: 6
100
+ },
101
+ 6: {
102
+ name: '任务审查',
103
+ entry_condition: '全部TASK.md完成',
104
+ required_artifact: '审查报告 (PASS/BLOCK)',
105
+ required_skills: ['task-arch', 'guardian-fixer'],
106
+ is_review_gate: true,
107
+ reviewer_type: 'independent',
108
+ next_gate: 7
109
+ },
110
+ 7: {
111
+ name: '代码实现',
112
+ entry_condition: 'Gate 6 PASS',
113
+ required_artifact: '代码 + LOG.md',
114
+ required_skills: ['harness-eng', 'harness-dev'],
115
+ next_gate: 8
116
+ },
117
+ 8: {
118
+ name: '测试验证',
119
+ entry_condition: '全部WP代码 + LOG.md存在',
120
+ required_artifact: '审查报告 + 验收确认',
121
+ required_skills: ['harness-eng', 'harness-eng-test'],
122
+ is_review_gate: true,
123
+ reviewer_type: 'independent',
124
+ next_gate: null
125
+ }
126
+ }
127
+ }
128
+ },
129
+ agent_roles: {
130
+ architect: {
131
+ name: '架构师',
132
+ description: '负责架构决策、方案比较',
133
+ capabilities: ['架构设计', '方案比较', '边界冻结'],
134
+ default_skills: ['arch', 'lead'],
135
+ triggers: ['架构设计', '方案比较']
136
+ },
137
+ developer: {
138
+ name: '开发工程师',
139
+ description: '负责代码实现和优化',
140
+ capabilities: ['代码编写', '调试', '重构'],
141
+ default_skills: ['harness-dev', 'harness-eng'],
142
+ triggers: ['实现', '写代码', '开发']
143
+ },
144
+ reviewer: {
145
+ name: '代码审查员',
146
+ description: '独立审查代码质量和架构',
147
+ capabilities: ['代码审查', '质量评估', '问题发现'],
148
+ default_skills: ['guardian-fixer', 'arch'],
149
+ triggers: ['代码审查', 'review', '审核']
150
+ }
151
+ },
152
+ skill_routing: {
153
+ keyword_to_skill: {
154
+ '架构': ['arch', 'lead'],
155
+ '设计': ['arch'],
156
+ 'review': ['guardian-fixer', 'arch'],
157
+ '代码': ['guardian-fixer', 'harness-dev'],
158
+ '安全': ['guardian-fixer', 'arch'],
159
+ '任务': ['task-arch', 'harness-eng'],
160
+ '分解': ['task-arch'],
161
+ '实现': ['harness-dev', 'harness-eng'],
162
+ '测试': ['harness-eng-test', 'guardian-fixer'],
163
+ '验证': ['harness-eng-test']
164
+ },
165
+ gate_to_skills: {
166
+ 0: ['arch', 'lead'],
167
+ 1: ['arch', 'lead'],
168
+ 2: ['guardian-fixer', 'arch'],
169
+ 3: ['harness-eng', 'plan-lock'],
170
+ 4: ['guardian-fixer', 'arch'],
171
+ 5: ['task-arch', 'crystal-learn'],
172
+ 6: ['task-arch', 'guardian-fixer'],
173
+ 7: ['harness-eng', 'harness-dev'],
174
+ 8: ['harness-eng', 'harness-eng-test']
175
+ }
176
+ },
177
+ fast_track: {
178
+ enabled: true,
179
+ conditions: [
180
+ '改动不超过 3 个文件',
181
+ 'Change Classification = implementation',
182
+ '无跨模块接缝',
183
+ '不影响用户心智或产品语义',
184
+ '不引入新的架构决策'
185
+ ],
186
+ required_steps: ['执行 skill', '单人审查']
187
+ },
188
+ parallel_execution: {
189
+ enabled: true,
190
+ contract: {
191
+ required_fields: ['write_set', 'parallel_tracks', 'depends_on', 'integration_owner', 'seam_owner', 'golden_journeys'],
192
+ seam_validation: {
193
+ enabled: true,
194
+ blocking: true,
195
+ message: '任何跨 WP 共享接口必须有 seam_owner'
196
+ }
197
+ }
198
+ },
199
+ collaboration_protocol: {
200
+ message_format: {
201
+ type: 'structured',
202
+ fields: ['type', 'from', 'to', 'content', 'gate', 'skill', 'timestamp', 'artifact']
203
+ },
204
+ state_sync: {
205
+ enabled: true,
206
+ interval_ms: 5000,
207
+ sync_on_gate_change: true
208
+ },
209
+ conflict_resolution: {
210
+ strategy: 'gate_based',
211
+ escalation_gates: [2, 4, 6, 8]
212
+ }
213
+ }
214
+ };
215
+ }
216
+ /**
217
+ * 获取当前 Gate 配置
218
+ */
219
+ getGateConfig(gate) {
220
+ if (!this.config)
221
+ return null;
222
+ return this.config.workflows.default.gates[gate] || null;
223
+ }
224
+ /**
225
+ * 获取当前 Gate
226
+ */
227
+ getCurrentGate() {
228
+ return this.currentGate;
229
+ }
230
+ /**
231
+ * 获取 Gate Pack (用于 Skill 输出)
232
+ */
233
+ getGatePack() {
234
+ const gateConfig = this.getGateConfig(this.currentGate);
235
+ return {
236
+ current_gate: this.currentGate,
237
+ entry_satisfied: this.checkEntryCondition(),
238
+ blockers: this.getBlockers(),
239
+ required_artifact: gateConfig?.required_artifact || '',
240
+ required_skills: gateConfig?.required_skills || [],
241
+ required_review_substrate: gateConfig?.is_review_gate ? '独立审查' : undefined
242
+ };
243
+ }
244
+ /**
245
+ * 检查入口条件是否满足
246
+ */
247
+ checkEntryCondition() {
248
+ if (this.currentGate === 0)
249
+ return true;
250
+ return this.artifacts.size > 0;
251
+ }
252
+ /**
253
+ * 获取阻塞条件
254
+ */
255
+ getBlockers() {
256
+ const blockers = [];
257
+ const gateConfig = this.getGateConfig(this.currentGate);
258
+ if (!gateConfig)
259
+ return blockers;
260
+ if (!this.checkEntryCondition()) {
261
+ blockers.push(`Gate ${this.currentGate} 入口条件未满足: ${gateConfig.entry_condition}`);
262
+ }
263
+ return blockers;
264
+ }
265
+ /**
266
+ * 提交产物到当前 Gate
267
+ */
268
+ submitArtifact(name, artifact) {
269
+ this.artifacts.set(name, artifact);
270
+ }
271
+ /**
272
+ * 获取产物
273
+ */
274
+ getArtifact(name) {
275
+ return this.artifacts.get(name);
276
+ }
277
+ /**
278
+ * 尝试转移 Gate
279
+ */
280
+ async transitionGate(reviewResult) {
281
+ const gateConfig = this.getGateConfig(this.currentGate);
282
+ if (!gateConfig) {
283
+ return {
284
+ success: false,
285
+ from: this.currentGate,
286
+ to: null,
287
+ blockers: ['无效的 Gate 配置'],
288
+ message: 'Gate 转移失败'
289
+ };
290
+ }
291
+ const blockers = [];
292
+ // 审查门需要审查结果
293
+ if (gateConfig.is_review_gate) {
294
+ if (!reviewResult) {
295
+ return {
296
+ success: false,
297
+ from: this.currentGate,
298
+ to: null,
299
+ blockers: ['审查门需要审查结果'],
300
+ message: `Gate ${this.currentGate} 是审查门,需要独立审查`
301
+ };
302
+ }
303
+ if (reviewResult.verdict === 'BLOCK') {
304
+ blockers.push(reviewResult.details || '审查未通过');
305
+ }
306
+ }
307
+ // 检查入口条件
308
+ if (!this.checkEntryCondition()) {
309
+ blockers.push(`入口条件未满足: ${gateConfig.entry_condition}`);
310
+ }
311
+ if (blockers.length > 0) {
312
+ return {
313
+ success: false,
314
+ from: this.currentGate,
315
+ to: this.currentGate,
316
+ blockers,
317
+ message: `Gate ${this.currentGate} BLOCKED`
318
+ };
319
+ }
320
+ // 执行转移
321
+ const nextGate = gateConfig.next_gate;
322
+ this.gateHistory.push(this.currentGate);
323
+ this.currentGate = nextGate ?? this.currentGate;
324
+ return {
325
+ success: true,
326
+ from: this.gateHistory[this.gateHistory.length - 1],
327
+ to: this.currentGate,
328
+ blockers: [],
329
+ message: nextGate === null ? '工作流完成' : `Gate ${this.gateHistory[this.gateHistory.length - 1]} → Gate ${this.currentGate}`
330
+ };
331
+ }
332
+ /**
333
+ * 基于关键词路由 Skill
334
+ */
335
+ routeSkillsByKeyword(message) {
336
+ if (!this.config)
337
+ return [];
338
+ const lowerMessage = message.toLowerCase();
339
+ const skills = new Set();
340
+ for (const [keyword, skillList] of Object.entries(this.config.skill_routing.keyword_to_skill)) {
341
+ if (lowerMessage.includes(keyword.toLowerCase())) {
342
+ skillList.forEach(s => skills.add(s));
343
+ }
344
+ }
345
+ // 如果没有匹配,返回当前 Gate 的默认 skills
346
+ if (skills.size === 0) {
347
+ const gateSkills = this.config.skill_routing.gate_to_skills[this.currentGate];
348
+ return gateSkills || [];
349
+ }
350
+ return Array.from(skills);
351
+ }
352
+ /**
353
+ * 基于当前 Gate 获取 Skills
354
+ */
355
+ getSkillsForCurrentGate() {
356
+ if (!this.config)
357
+ return [];
358
+ return this.config.skill_routing.gate_to_skills[this.currentGate] || [];
359
+ }
360
+ /**
361
+ * 获取智能体角色
362
+ */
363
+ getAgentRole(roleId) {
364
+ if (!this.config)
365
+ return null;
366
+ return this.config.agent_roles[roleId] || null;
367
+ }
368
+ /**
369
+ * 根据能力匹配智能体角色
370
+ */
371
+ matchAgentRole(capabilities) {
372
+ if (!this.config)
373
+ return null;
374
+ for (const role of Object.values(this.config.agent_roles)) {
375
+ const hasMatch = capabilities.some(cap => role.capabilities.some(rc => rc.includes(cap) || cap.includes(rc)));
376
+ if (hasMatch)
377
+ return role;
378
+ }
379
+ return this.config.agent_roles['architect'];
380
+ }
381
+ /**
382
+ * 检查是否可以使用快速通道
383
+ */
384
+ canUseFastTrack(changeDescription) {
385
+ if (!this.config?.fast_track.enabled) {
386
+ return { canUse: false, blockers: ['快速通道未启用'] };
387
+ }
388
+ const blockers = [];
389
+ const conditions = this.config.fast_track.conditions;
390
+ // 简化检查:实际应用中需要更复杂的分析
391
+ if (changeDescription.length > 500) {
392
+ blockers.push('改动可能超过 3 个文件');
393
+ }
394
+ if (changeDescription.includes('API') || changeDescription.includes('契约')) {
395
+ blockers.push('涉及契约变更');
396
+ }
397
+ if (changeDescription.includes('模块') || changeDescription.includes('跨模块')) {
398
+ blockers.push('涉及跨模块接缝');
399
+ }
400
+ return {
401
+ canUse: blockers.length === 0,
402
+ blockers
403
+ };
404
+ }
405
+ /**
406
+ * 获取工作流状态摘要
407
+ */
408
+ getWorkflowStatus() {
409
+ const gateConfig = this.getGateConfig(this.currentGate);
410
+ const totalGates = 9;
411
+ return {
412
+ currentGate: this.currentGate,
413
+ gateName: gateConfig?.name || '未知',
414
+ progress: `${this.currentGate}/${totalGates} Gates`,
415
+ blockers: this.getBlockers(),
416
+ history: [...this.gateHistory]
417
+ };
418
+ }
419
+ /**
420
+ * 重置工作流
421
+ */
422
+ reset() {
423
+ this.currentGate = 0;
424
+ this.artifacts.clear();
425
+ this.gateHistory = [];
426
+ }
427
+ /**
428
+ * 导出配置为 JSON
429
+ */
430
+ exportConfig() {
431
+ if (!this.config)
432
+ return '';
433
+ return JSON.stringify(this.config, null, 2);
434
+ }
435
+ }
436
+ // 单例实例
437
+ let integratorInstance = null;
438
+ export function createHarnessWorkflowIntegrator() {
439
+ return new HarnessWorkflowIntegrator();
440
+ }
441
+ export function getHarnessWorkflowIntegrator() {
442
+ if (!integratorInstance) {
443
+ integratorInstance = new HarnessWorkflowIntegrator();
444
+ }
445
+ return integratorInstance;
446
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Channel Agent Social Module - 频道智能体社交系统
3
+ *
4
+ * 基于 Diap 去中心化协议的对外社交频道系统
5
+ */
6
+ export { ChannelType, DEFAULT_CHANNEL_CONFIG } from './types.js';
7
+ export { InterestMatcher, interestMatcher } from './InterestMatcher.js';
8
+ export { ChannelManager } from './ChannelManager.js';
9
+ export { DiapChannelBridge } from './DiapChannelBridge.js';
@@ -1,21 +1,17 @@
1
- "use strict";
2
1
  /**
3
2
  * Channel Types - 频道智能体社交系统类型定义
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DEFAULT_CHANNEL_CONFIG = exports.ChannelType = void 0;
7
- var ChannelType;
4
+ export var ChannelType;
8
5
  (function (ChannelType) {
9
6
  ChannelType["INTEREST"] = "interest";
10
7
  ChannelType["CAPABILITY"] = "capability";
11
8
  ChannelType["REGION"] = "region";
12
9
  ChannelType["AD_HOC"] = "ad_hoc";
13
- })(ChannelType || (exports.ChannelType = ChannelType = {}));
14
- exports.DEFAULT_CHANNEL_CONFIG = {
10
+ })(ChannelType || (ChannelType = {}));
11
+ export const DEFAULT_CHANNEL_CONFIG = {
15
12
  broadcastInterval: 60 * 1000,
16
13
  matchThreshold: 0.5,
17
14
  maxChannels: 10,
18
15
  maxMembersPerChannel: 50,
19
16
  memberTimeout: 30 * 60 * 1000,
20
17
  };
21
- //# sourceMappingURL=types.js.map
@@ -1,48 +1,9 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.GlobalSharedContextManager = void 0;
37
- exports.getGlobalSharedContext = getGlobalSharedContext;
38
- exports.createGlobalSharedContext = createGlobalSharedContext;
39
- exports.resetGlobalSharedContext = resetGlobalSharedContext;
40
- const fs = __importStar(require("fs/promises"));
41
- const path = __importStar(require("path"));
1
+ import * as fs from 'fs/promises';
2
+ import * as path from 'path';
42
3
  const GLOBAL_CONTEXT_PATH = path.join(process.env.HOME || '/tmp', '.bolloon', 'sessions', 'global-context.json');
43
4
  const MAX_RECENT_ACTIONS = 50;
44
5
  const MAX_SHARED_KNOWLEDGE = 100;
45
- class GlobalSharedContextManager {
6
+ export class GlobalSharedContextManager {
46
7
  memory = {
47
8
  recentActions: [],
48
9
  sharedKnowledge: []
@@ -346,15 +307,14 @@ class GlobalSharedContextManager {
346
307
  await this.save();
347
308
  }
348
309
  }
349
- exports.GlobalSharedContextManager = GlobalSharedContextManager;
350
310
  let globalContextInstance = null;
351
- function getGlobalSharedContext() {
311
+ export function getGlobalSharedContext() {
352
312
  if (!globalContextInstance) {
353
313
  globalContextInstance = new GlobalSharedContextManager();
354
314
  }
355
315
  return globalContextInstance;
356
316
  }
357
- async function createGlobalSharedContext(contextPath) {
317
+ export async function createGlobalSharedContext(contextPath) {
358
318
  if (globalContextInstance) {
359
319
  return globalContextInstance;
360
320
  }
@@ -362,7 +322,6 @@ async function createGlobalSharedContext(contextPath) {
362
322
  await globalContextInstance.initialize();
363
323
  return globalContextInstance;
364
324
  }
365
- function resetGlobalSharedContext() {
325
+ export function resetGlobalSharedContext() {
366
326
  globalContextInstance = null;
367
327
  }
368
- //# sourceMappingURL=global-shared-context.js.map