@kognai/orchestrator-core 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.
Files changed (144) hide show
  1. package/README.md +44 -0
  2. package/dist/index.d.ts +63 -0
  3. package/dist/index.js +175 -0
  4. package/dist/lib/aar-middleware.d.ts +6 -0
  5. package/dist/lib/aar-middleware.js +70 -0
  6. package/dist/lib/aar-types.d.ts +34 -0
  7. package/dist/lib/aar-types.js +4 -0
  8. package/dist/lib/acp-engine.d.ts +68 -0
  9. package/dist/lib/acp-engine.js +123 -0
  10. package/dist/lib/acp.d.ts +61 -0
  11. package/dist/lib/acp.js +425 -0
  12. package/dist/lib/agent-registry.d.ts +50 -0
  13. package/dist/lib/agent-registry.js +137 -0
  14. package/dist/lib/anthropic-direct.d.ts +27 -0
  15. package/dist/lib/anthropic-direct.js +109 -0
  16. package/dist/lib/asmr-extractor.d.ts +40 -0
  17. package/dist/lib/asmr-extractor.js +151 -0
  18. package/dist/lib/asmr-retrieval.d.ts +76 -0
  19. package/dist/lib/asmr-retrieval.js +311 -0
  20. package/dist/lib/asmr.d.ts +8 -0
  21. package/dist/lib/asmr.js +24 -0
  22. package/dist/lib/brainx-client.d.ts +72 -0
  23. package/dist/lib/brainx-client.js +200 -0
  24. package/dist/lib/brainx-embed.d.ts +14 -0
  25. package/dist/lib/brainx-embed.js +139 -0
  26. package/dist/lib/brainx-swarm-bridge.d.ts +93 -0
  27. package/dist/lib/brainx-swarm-bridge.js +242 -0
  28. package/dist/lib/byterover-client.d.ts +19 -0
  29. package/dist/lib/byterover-client.js +59 -0
  30. package/dist/lib/ceo-wallet.d.ts +37 -0
  31. package/dist/lib/ceo-wallet.js +176 -0
  32. package/dist/lib/chomsky-gate.d.ts +24 -0
  33. package/dist/lib/chomsky-gate.js +178 -0
  34. package/dist/lib/chomsky-runner.d.ts +29 -0
  35. package/dist/lib/chomsky-runner.js +157 -0
  36. package/dist/lib/citizen-score-contract.d.ts +72 -0
  37. package/dist/lib/citizen-score-contract.js +16 -0
  38. package/dist/lib/citizen-score-registry.d.ts +25 -0
  39. package/dist/lib/citizen-score-registry.js +65 -0
  40. package/dist/lib/citizenship.d.ts +103 -0
  41. package/dist/lib/citizenship.js +272 -0
  42. package/dist/lib/clawrouter-client.d.ts +37 -0
  43. package/dist/lib/clawrouter-client.js +148 -0
  44. package/dist/lib/code-asset-crystalliser.d.ts +41 -0
  45. package/dist/lib/code-asset-crystalliser.js +181 -0
  46. package/dist/lib/code-failure-logger.d.ts +27 -0
  47. package/dist/lib/code-failure-logger.js +42 -0
  48. package/dist/lib/cto-approval-gate.d.ts +45 -0
  49. package/dist/lib/cto-approval-gate.js +478 -0
  50. package/dist/lib/cto-gate-types.d.ts +28 -0
  51. package/dist/lib/cto-gate-types.js +8 -0
  52. package/dist/lib/decomposer-feedback.d.ts +54 -0
  53. package/dist/lib/decomposer-feedback.js +115 -0
  54. package/dist/lib/emotional-safety-gate.d.ts +48 -0
  55. package/dist/lib/emotional-safety-gate.js +97 -0
  56. package/dist/lib/engine-paths.d.ts +13 -0
  57. package/dist/lib/engine-paths.js +32 -0
  58. package/dist/lib/event-bus-listener.d.ts +8 -0
  59. package/dist/lib/event-bus-listener.js +144 -0
  60. package/dist/lib/event-bus-publisher.d.ts +25 -0
  61. package/dist/lib/event-bus-publisher.js +188 -0
  62. package/dist/lib/event-bus-types.d.ts +73 -0
  63. package/dist/lib/event-bus-types.js +23 -0
  64. package/dist/lib/failure-library.d.ts +178 -0
  65. package/dist/lib/failure-library.js +349 -0
  66. package/dist/lib/ksl/error-log.d.ts +28 -0
  67. package/dist/lib/ksl/error-log.js +43 -0
  68. package/dist/lib/ksl/index.d.ts +9 -0
  69. package/dist/lib/ksl/index.js +25 -0
  70. package/dist/lib/ksl/orchestrator-tap.d.ts +16 -0
  71. package/dist/lib/ksl/orchestrator-tap.js +85 -0
  72. package/dist/lib/ksl/record-writer.d.ts +46 -0
  73. package/dist/lib/ksl/record-writer.js +45 -0
  74. package/dist/lib/llm-cost-table.d.ts +36 -0
  75. package/dist/lib/llm-cost-table.js +90 -0
  76. package/dist/lib/local-model-router.d.ts +27 -0
  77. package/dist/lib/local-model-router.js +61 -0
  78. package/dist/lib/mc-client.d.ts +51 -0
  79. package/dist/lib/mc-client.js +249 -0
  80. package/dist/lib/model-router-contract.d.ts +91 -0
  81. package/dist/lib/model-router-contract.js +19 -0
  82. package/dist/lib/model-router-registry.d.ts +24 -0
  83. package/dist/lib/model-router-registry.js +52 -0
  84. package/dist/lib/model-router.d.ts +20 -0
  85. package/dist/lib/model-router.js +79 -0
  86. package/dist/lib/monotask-state-machine.d.ts +19 -0
  87. package/dist/lib/monotask-state-machine.js +131 -0
  88. package/dist/lib/neutral-prompt-checker.d.ts +22 -0
  89. package/dist/lib/neutral-prompt-checker.js +130 -0
  90. package/dist/lib/notion-direct.d.ts +92 -0
  91. package/dist/lib/notion-direct.js +381 -0
  92. package/dist/lib/ollama-client.d.ts +37 -0
  93. package/dist/lib/ollama-client.js +158 -0
  94. package/dist/lib/omel/credential-vault.d.ts +57 -0
  95. package/dist/lib/omel/credential-vault.js +324 -0
  96. package/dist/lib/omel/human-brake.d.ts +32 -0
  97. package/dist/lib/omel/human-brake.js +289 -0
  98. package/dist/lib/omel/index.d.ts +10 -0
  99. package/dist/lib/omel/index.js +26 -0
  100. package/dist/lib/omel/phantom-workspace.d.ts +31 -0
  101. package/dist/lib/omel/phantom-workspace.js +256 -0
  102. package/dist/lib/omel/wipe-witness.d.ts +75 -0
  103. package/dist/lib/omel/wipe-witness.js +398 -0
  104. package/dist/lib/orchestrate-engine.d.ts +25 -0
  105. package/dist/lib/orchestrate-engine.js +4436 -0
  106. package/dist/lib/perm-judge.d.ts +46 -0
  107. package/dist/lib/perm-judge.js +173 -0
  108. package/dist/lib/plumber/conformance.d.ts +54 -0
  109. package/dist/lib/plumber/conformance.js +121 -0
  110. package/dist/lib/plumber/index.d.ts +9 -0
  111. package/dist/lib/plumber/index.js +25 -0
  112. package/dist/lib/plumber/observer.d.ts +52 -0
  113. package/dist/lib/plumber/observer.js +180 -0
  114. package/dist/lib/plumber/types.d.ts +78 -0
  115. package/dist/lib/plumber/types.js +29 -0
  116. package/dist/lib/research-impl-gate.d.ts +16 -0
  117. package/dist/lib/research-impl-gate.js +105 -0
  118. package/dist/lib/sherlock-memory.d.ts +29 -0
  119. package/dist/lib/sherlock-memory.js +105 -0
  120. package/dist/lib/skill-crystalliser.d.ts +44 -0
  121. package/dist/lib/skill-crystalliser.js +60 -0
  122. package/dist/lib/sprint-runner-engine.d.ts +27 -0
  123. package/dist/lib/sprint-runner-engine.js +1042 -0
  124. package/dist/lib/sprint-state.d.ts +71 -0
  125. package/dist/lib/sprint-state.js +202 -0
  126. package/dist/lib/stuck-handler.d.ts +17 -0
  127. package/dist/lib/stuck-handler.js +249 -0
  128. package/dist/lib/task-contract-checker.d.ts +17 -0
  129. package/dist/lib/task-contract-checker.js +29 -0
  130. package/dist/lib/task-router/index.d.ts +17 -0
  131. package/dist/lib/task-router/index.js +52 -0
  132. package/dist/lib/task-router/router/generate-execution-id.d.ts +10 -0
  133. package/dist/lib/task-router/router/generate-execution-id.js +24 -0
  134. package/dist/lib/task-router/router/resolve-route.d.ts +2 -0
  135. package/dist/lib/task-router/router/resolve-route.js +49 -0
  136. package/dist/lib/task-router/types.d.ts +79 -0
  137. package/dist/lib/task-router/types.js +39 -0
  138. package/dist/lib/token-budget-validator.d.ts +44 -0
  139. package/dist/lib/token-budget-validator.js +84 -0
  140. package/dist/lib/trust-score-updater.d.ts +30 -0
  141. package/dist/lib/trust-score-updater.js +107 -0
  142. package/dist/lib/wallet-state.d.ts +26 -0
  143. package/dist/lib/wallet-state.js +85 -0
  144. package/package.json +27 -0
@@ -0,0 +1,425 @@
1
+ "use strict";
2
+ /**
3
+ * ACP — Agent Capability Protocol v1
4
+ *
5
+ * Defines capability declarations for each agent in the Kognai swarm.
6
+ * Each agent declares what it CAN and CANNOT do, enabling:
7
+ * - Constitution enforcement (prevent agents from exceeding scope)
8
+ * - CTO approval gate capability checks
9
+ * - Task routing based on declared capabilities
10
+ *
11
+ * Capability tiers:
12
+ * T1 (Foundation): read, write, search
13
+ * T2 (Content): llm_call, tts, video_gen, script_gen
14
+ * T3 (Integration): api_call, db_query, telegram, stripe
15
+ * T4 (System): deploy, pm2, git_push, shell_exec
16
+ *
17
+ * Sprint 650 — ACP v1 implementation
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.getAllAgents = getAllAgents;
21
+ exports.getAgent = getAgent;
22
+ exports.checkCapability = checkCapability;
23
+ exports.checkCapabilities = checkCapabilities;
24
+ exports.getAgentsWithCapability = getAgentsWithCapability;
25
+ exports.getCapabilityTier = getCapabilityTier;
26
+ exports.validateSprintAssignments = validateSprintAssignments;
27
+ exports.getRegistryStats = getRegistryStats;
28
+ // ── Capability Tier Map ───────────────────────────────────────────────
29
+ const TIER_CAPABILITIES = {
30
+ T1: ['read_files', 'write_files', 'search_code', 'git_read'],
31
+ T2: ['llm_call_local', 'llm_call_cloud', 'tts_generate', 'video_composite',
32
+ 'script_generate', 'image_generate', 'avatar_generate'],
33
+ T3: ['api_call_external', 'db_query', 'db_write', 'telegram_send',
34
+ 'stripe_read', 'stripe_write', 'youtube_read', 'tiktok_post'],
35
+ T4: ['deploy', 'pm2_manage', 'git_push', 'shell_exec', 'env_modify'],
36
+ };
37
+ // ── Agent Registry ────────────────────────────────────────────────────
38
+ const REGISTRY = [
39
+ // ─── Kognai Core Agents ─────────────────────────────────
40
+ {
41
+ agent_id: 'ceo', display_name: 'CEO', tier: 'T4',
42
+ capabilities: ['read_files', 'write_files', 'search_code', 'git_read', 'llm_call_local', 'llm_call_cloud', 'shell_exec', 'git_push'],
43
+ denied: ['stripe_write', 'tiktok_post', 'env_modify'],
44
+ scope: 'Strategy, vision, agent coordination. No financial ops or posting.',
45
+ max_model_tier: 'apex',
46
+ },
47
+ {
48
+ agent_id: 'cto', display_name: 'CTO', tier: 'T4',
49
+ capabilities: ['read_files', 'write_files', 'search_code', 'git_read', 'llm_call_local', 'llm_call_cloud', 'shell_exec', 'git_push', 'deploy', 'pm2_manage'],
50
+ denied: ['stripe_write', 'tiktok_post'],
51
+ scope: 'Architecture review, sprint approval, deployment, infra management.',
52
+ max_model_tier: 'cloud',
53
+ },
54
+ {
55
+ agent_id: 'cfo', display_name: 'CFO', tier: 'T3',
56
+ capabilities: ['read_files', 'search_code', 'git_read', 'llm_call_local', 'stripe_read', 'db_query'],
57
+ denied: ['write_files', 'shell_exec', 'git_push', 'deploy', 'stripe_write'],
58
+ scope: 'Financial reporting, cost tracking, budget analysis. Read-only financial access.',
59
+ max_model_tier: 'power',
60
+ },
61
+ {
62
+ agent_id: 'cmo', display_name: 'CMO', tier: 'T2',
63
+ capabilities: ['read_files', 'write_files', 'search_code', 'git_read', 'llm_call_local'],
64
+ denied: ['shell_exec', 'deploy', 'db_write', 'stripe_write'],
65
+ scope: 'Marketing strategy, content planning, brand narrative.',
66
+ max_model_tier: 'power',
67
+ },
68
+ {
69
+ agent_id: 'supervisor', display_name: 'Supervisor', tier: 'T3',
70
+ capabilities: ['read_files', 'search_code', 'git_read', 'llm_call_local', 'db_query'],
71
+ denied: ['write_files', 'shell_exec', 'deploy', 'git_push'],
72
+ scope: 'Sprint review, quality validation. Read-only analysis.',
73
+ max_model_tier: 'power',
74
+ },
75
+ {
76
+ agent_id: 'devops', display_name: 'DevOps', tier: 'T4',
77
+ capabilities: ['read_files', 'write_files', 'search_code', 'git_read', 'shell_exec', 'deploy', 'pm2_manage', 'git_push', 'env_modify'],
78
+ denied: ['stripe_write', 'tiktok_post', 'llm_call_cloud'],
79
+ scope: 'Infrastructure, deployment, monitoring, PM2 process management.',
80
+ max_model_tier: 'power',
81
+ },
82
+ {
83
+ agent_id: 'security', display_name: 'Security', tier: 'T3',
84
+ capabilities: ['read_files', 'search_code', 'git_read', 'llm_call_local', 'db_query'],
85
+ denied: ['write_files', 'shell_exec', 'deploy', 'git_push', 'db_write'],
86
+ scope: 'Security audit, vulnerability scanning. Read-only.',
87
+ max_model_tier: 'power',
88
+ },
89
+ {
90
+ agent_id: 'achiri', display_name: 'Achiri', tier: 'T3',
91
+ capabilities: ['read_files', 'write_files', 'llm_call_local', 'llm_call_cloud', 'db_query', 'db_write', 'telegram_send'],
92
+ denied: ['shell_exec', 'deploy', 'git_push', 'stripe_write'],
93
+ scope: 'AI companion conversations, memory, Tunisian cultural adaptation.',
94
+ max_model_tier: 'cloud',
95
+ },
96
+ {
97
+ agent_id: 'backend-core', display_name: 'Backend Core', tier: 'T3',
98
+ capabilities: ['read_files', 'write_files', 'search_code', 'git_read', 'db_query', 'db_write', 'api_call_external'],
99
+ denied: ['deploy', 'shell_exec', 'stripe_write'],
100
+ scope: 'Backend API development, database operations.',
101
+ max_model_tier: 'power',
102
+ },
103
+ {
104
+ agent_id: 'backend-ledger', display_name: 'Backend Ledger', tier: 'T3',
105
+ capabilities: ['read_files', 'write_files', 'search_code', 'git_read', 'db_query', 'db_write'],
106
+ denied: ['deploy', 'shell_exec', 'stripe_write'],
107
+ scope: 'Ledger management, financial record keeping.',
108
+ max_model_tier: 'power',
109
+ },
110
+ {
111
+ agent_id: 'backend-tax', display_name: 'Backend Tax', tier: 'T3',
112
+ capabilities: ['read_files', 'write_files', 'search_code', 'git_read', 'db_query'],
113
+ denied: ['deploy', 'shell_exec', 'stripe_write', 'db_write'],
114
+ scope: 'Tax calculation logic. Read-only DB.',
115
+ max_model_tier: 'local',
116
+ },
117
+ {
118
+ agent_id: 'bizdev', display_name: 'BizDev', tier: 'T2',
119
+ capabilities: ['read_files', 'write_files', 'search_code', 'git_read', 'llm_call_local'],
120
+ denied: ['shell_exec', 'deploy', 'db_write', 'stripe_write'],
121
+ scope: 'Business development strategy and research.',
122
+ max_model_tier: 'power',
123
+ },
124
+ {
125
+ agent_id: 'conflict-analyzer', display_name: 'Conflict Analyzer', tier: 'T1',
126
+ capabilities: ['read_files', 'search_code', 'git_read'],
127
+ denied: ['write_files', 'shell_exec', 'deploy', 'db_write'],
128
+ scope: 'Detect conflicts between agent outputs. Read-only.',
129
+ max_model_tier: 'local',
130
+ },
131
+ {
132
+ agent_id: 'conway-integration', display_name: 'Conway Integration', tier: 'T2',
133
+ capabilities: ['read_files', 'write_files', 'search_code', 'git_read', 'llm_call_local'],
134
+ denied: ['shell_exec', 'deploy', 'db_write'],
135
+ scope: 'Conway governance protocol integration.',
136
+ max_model_tier: 'power',
137
+ },
138
+ {
139
+ agent_id: 'execution-verifier', display_name: 'Execution Verifier', tier: 'T1',
140
+ capabilities: ['read_files', 'search_code', 'git_read'],
141
+ denied: ['write_files', 'shell_exec', 'deploy'],
142
+ scope: 'Verify sprint execution results. Read-only.',
143
+ max_model_tier: 'local',
144
+ },
145
+ {
146
+ agent_id: 'execution-watchdog', display_name: 'Execution Watchdog', tier: 'T2',
147
+ capabilities: ['read_files', 'search_code', 'git_read', 'llm_call_local', 'telegram_send'],
148
+ denied: ['write_files', 'shell_exec', 'deploy'],
149
+ scope: 'Monitor execution health, alert on anomalies.',
150
+ max_model_tier: 'local',
151
+ },
152
+ {
153
+ agent_id: 'frontend', display_name: 'Frontend', tier: 'T2',
154
+ capabilities: ['read_files', 'write_files', 'search_code', 'git_read', 'llm_call_local'],
155
+ denied: ['shell_exec', 'deploy', 'db_write', 'stripe_write'],
156
+ scope: 'Frontend UI development.',
157
+ max_model_tier: 'power',
158
+ },
159
+ {
160
+ agent_id: 'invoica-x-admin', display_name: 'Invoica X Admin', tier: 'T3',
161
+ capabilities: ['read_files', 'write_files', 'search_code', 'git_read', 'api_call_external'],
162
+ denied: ['shell_exec', 'deploy', 'db_write'],
163
+ scope: 'Invoica cross-product administration.',
164
+ max_model_tier: 'power',
165
+ },
166
+ {
167
+ agent_id: 'market-intelligence', display_name: 'Market Intelligence', tier: 'T3',
168
+ capabilities: ['read_files', 'write_files', 'search_code', 'git_read', 'llm_call_local', 'api_call_external'],
169
+ denied: ['shell_exec', 'deploy', 'db_write'],
170
+ scope: 'Market research, competitor analysis, trend tracking.',
171
+ max_model_tier: 'power',
172
+ },
173
+ {
174
+ agent_id: 'pipeline-health-monitor', display_name: 'Pipeline Health Monitor', tier: 'T3',
175
+ capabilities: ['read_files', 'search_code', 'git_read', 'db_query', 'telegram_send'],
176
+ denied: ['write_files', 'shell_exec', 'deploy'],
177
+ scope: 'Monitor pipeline health metrics, send alerts.',
178
+ max_model_tier: 'local',
179
+ },
180
+ {
181
+ agent_id: 'skills', display_name: 'Skills Manager', tier: 'T2',
182
+ capabilities: ['read_files', 'write_files', 'search_code', 'git_read', 'llm_call_local'],
183
+ denied: ['shell_exec', 'deploy', 'db_write'],
184
+ scope: 'OpenClaw skills registry management.',
185
+ max_model_tier: 'power',
186
+ },
187
+ {
188
+ agent_id: 'sprint-retrospective', display_name: 'Sprint Retrospective', tier: 'T2',
189
+ capabilities: ['read_files', 'write_files', 'search_code', 'git_read', 'llm_call_local'],
190
+ denied: ['shell_exec', 'deploy', 'db_write'],
191
+ scope: 'Sprint analysis and retrospective reports.',
192
+ max_model_tier: 'power',
193
+ },
194
+ {
195
+ agent_id: 'telegram-support', display_name: 'Telegram Support', tier: 'T3',
196
+ capabilities: ['read_files', 'search_code', 'git_read', 'telegram_send', 'llm_call_local'],
197
+ denied: ['write_files', 'shell_exec', 'deploy', 'db_write'],
198
+ scope: 'Telegram bot command handling and notifications.',
199
+ max_model_tier: 'local',
200
+ },
201
+ {
202
+ agent_id: 'test-failure-predictor', display_name: 'Test Failure Predictor', tier: 'T1',
203
+ capabilities: ['read_files', 'search_code', 'git_read'],
204
+ denied: ['write_files', 'shell_exec', 'deploy'],
205
+ scope: 'Predict likely test failures from code changes.',
206
+ max_model_tier: 'local',
207
+ },
208
+ {
209
+ agent_id: 'test-runner', display_name: 'Test Runner', tier: 'T2',
210
+ capabilities: ['read_files', 'search_code', 'git_read', 'shell_exec'],
211
+ denied: ['write_files', 'deploy', 'git_push', 'db_write'],
212
+ scope: 'Execute test suites. Shell access for test commands only.',
213
+ max_model_tier: 'local',
214
+ },
215
+ {
216
+ agent_id: 'test-utility-generator', display_name: 'Test Utility Generator', tier: 'T2',
217
+ capabilities: ['read_files', 'write_files', 'search_code', 'git_read', 'llm_call_local'],
218
+ denied: ['shell_exec', 'deploy', 'db_write'],
219
+ scope: 'Generate test fixtures and utility code.',
220
+ max_model_tier: 'local',
221
+ },
222
+ {
223
+ agent_id: 'x-admin', display_name: 'X Admin', tier: 'T3',
224
+ capabilities: ['read_files', 'write_files', 'search_code', 'git_read', 'api_call_external'],
225
+ denied: ['shell_exec', 'deploy', 'db_write'],
226
+ scope: 'X/Twitter administration and posting.',
227
+ max_model_tier: 'power',
228
+ },
229
+ // ─── SCS-001 Pipeline Agents ────────────────────────────
230
+ {
231
+ agent_id: 'scs001-orchestrator', display_name: 'SCS-001 Orchestrator', tier: 'T3',
232
+ capabilities: ['read_files', 'write_files', 'search_code', 'llm_call_local', 'llm_call_cloud', 'api_call_external', 'telegram_send'],
233
+ denied: ['deploy', 'git_push', 'stripe_write', 'env_modify'],
234
+ scope: 'Video pipeline orchestration. Coordinates all SCS-001 agents.',
235
+ max_model_tier: 'cloud',
236
+ },
237
+ {
238
+ agent_id: 'scs001-discovery', display_name: 'SCS-001 Discovery', tier: 'T3',
239
+ capabilities: ['read_files', 'write_files', 'api_call_external', 'youtube_read'],
240
+ denied: ['shell_exec', 'deploy', 'db_write'],
241
+ scope: 'Discover trending topics and YouTube clips.',
242
+ max_model_tier: 'local',
243
+ },
244
+ {
245
+ agent_id: 'scs001-clip-detection', display_name: 'SCS-001 Clip Detection', tier: 'T2',
246
+ capabilities: ['read_files', 'write_files', 'llm_call_local'],
247
+ denied: ['shell_exec', 'deploy', 'api_call_external'],
248
+ scope: 'Detect and score clips from downloaded videos.',
249
+ max_model_tier: 'power',
250
+ },
251
+ {
252
+ agent_id: 'scs001-insight', display_name: 'SCS-001 Insight', tier: 'T2',
253
+ capabilities: ['read_files', 'write_files', 'llm_call_local', 'llm_call_cloud'],
254
+ denied: ['shell_exec', 'deploy', 'api_call_external'],
255
+ scope: 'Generate insight briefs from qualified clips.',
256
+ max_model_tier: 'cloud',
257
+ },
258
+ {
259
+ agent_id: 'scs001-script', display_name: 'SCS-001 Script', tier: 'T2',
260
+ capabilities: ['read_files', 'write_files', 'llm_call_local', 'llm_call_cloud', 'script_generate'],
261
+ denied: ['shell_exec', 'deploy', 'api_call_external'],
262
+ scope: 'Generate video scripts from insight briefs. LLM rewrite.',
263
+ max_model_tier: 'cloud',
264
+ },
265
+ {
266
+ agent_id: 'scs001-script-validator', display_name: 'SCS-001 Script Validator', tier: 'T1',
267
+ capabilities: ['read_files'],
268
+ denied: ['write_files', 'shell_exec', 'deploy'],
269
+ scope: 'Validate script bundles for quality and format compliance.',
270
+ max_model_tier: 'nano',
271
+ },
272
+ {
273
+ agent_id: 'scs001-scorer', display_name: 'SCS-001 Scorer', tier: 'T1',
274
+ capabilities: ['read_files', 'write_files'],
275
+ denied: ['shell_exec', 'deploy', 'api_call_external'],
276
+ scope: 'Score content quality and viral potential.',
277
+ max_model_tier: 'local',
278
+ },
279
+ {
280
+ agent_id: 'scs001-editing', display_name: 'SCS-001 Editing', tier: 'T2',
281
+ capabilities: ['read_files', 'write_files', 'shell_exec', 'video_composite', 'tts_generate'],
282
+ denied: ['deploy', 'git_push', 'api_call_external'],
283
+ scope: 'Video editing, FFmpeg composition, TTS generation.',
284
+ max_model_tier: 'local',
285
+ },
286
+ {
287
+ agent_id: 'scs001-caption', display_name: 'SCS-001 Caption', tier: 'T2',
288
+ capabilities: ['read_files', 'write_files', 'shell_exec', 'video_composite'],
289
+ denied: ['deploy', 'git_push'],
290
+ scope: 'Burn captions and subtitles into video.',
291
+ max_model_tier: 'local',
292
+ },
293
+ {
294
+ agent_id: 'scs001-qc', display_name: 'SCS-001 QC', tier: 'T2',
295
+ capabilities: ['read_files', 'write_files', 'llm_call_local'],
296
+ denied: ['shell_exec', 'deploy', 'api_call_external'],
297
+ scope: 'Quality control checks on finished videos.',
298
+ max_model_tier: 'power',
299
+ },
300
+ {
301
+ agent_id: 'scs001-publishing', display_name: 'SCS-001 Publishing', tier: 'T3',
302
+ capabilities: ['read_files', 'write_files', 'api_call_external', 'tiktok_post', 'telegram_send'],
303
+ denied: ['shell_exec', 'deploy', 'git_push'],
304
+ scope: 'Publish videos to TikTok and notify via Telegram.',
305
+ max_model_tier: 'local',
306
+ },
307
+ {
308
+ agent_id: 'scs001-hosting', display_name: 'SCS-001 Hosting', tier: 'T3',
309
+ capabilities: ['read_files', 'write_files', 'api_call_external'],
310
+ denied: ['shell_exec', 'deploy', 'git_push'],
311
+ scope: 'Upload and host video files.',
312
+ max_model_tier: 'local',
313
+ },
314
+ {
315
+ agent_id: 'scs001-analytics', display_name: 'SCS-001 Analytics', tier: 'T3',
316
+ capabilities: ['read_files', 'write_files', 'db_query', 'api_call_external'],
317
+ denied: ['shell_exec', 'deploy', 'db_write'],
318
+ scope: 'View analytics, engagement metrics, performance tracking.',
319
+ max_model_tier: 'local',
320
+ },
321
+ {
322
+ agent_id: 'scs001-trend', display_name: 'SCS-001 Trend', tier: 'T3',
323
+ capabilities: ['read_files', 'write_files', 'api_call_external', 'llm_call_local'],
324
+ denied: ['shell_exec', 'deploy', 'db_write'],
325
+ scope: 'Track trending topics across platforms.',
326
+ max_model_tier: 'power',
327
+ },
328
+ {
329
+ agent_id: 'scs001-experiment', display_name: 'SCS-001 Experiment', tier: 'T2',
330
+ capabilities: ['read_files', 'write_files', 'llm_call_local'],
331
+ denied: ['shell_exec', 'deploy', 'api_call_external'],
332
+ scope: 'A/B testing framework for content optimization.',
333
+ max_model_tier: 'local',
334
+ },
335
+ {
336
+ agent_id: 'scs001-flywheel', display_name: 'SCS-001 Flywheel', tier: 'T2',
337
+ capabilities: ['read_files', 'write_files', 'llm_call_local'],
338
+ denied: ['shell_exec', 'deploy', 'api_call_external'],
339
+ scope: 'Content flywheel optimization and feedback loops.',
340
+ max_model_tier: 'local',
341
+ },
342
+ {
343
+ agent_id: 'scs001-failure-library', display_name: 'SCS-001 Failure Library', tier: 'T1',
344
+ capabilities: ['read_files', 'write_files'],
345
+ denied: ['shell_exec', 'deploy', 'api_call_external'],
346
+ scope: 'Track and learn from pipeline failures.',
347
+ max_model_tier: 'nano',
348
+ },
349
+ {
350
+ agent_id: 'scs001-viral-downloader', display_name: 'SCS-001 Viral Downloader', tier: 'T3',
351
+ capabilities: ['read_files', 'write_files', 'api_call_external', 'shell_exec'],
352
+ denied: ['deploy', 'git_push', 'db_write'],
353
+ scope: 'Download viral video clips for analysis. Shell for yt-dlp.',
354
+ max_model_tier: 'local',
355
+ },
356
+ ];
357
+ // ── Public API ────────────────────────────────────────────────────────
358
+ /** Get all registered agents */
359
+ function getAllAgents() {
360
+ return [...REGISTRY];
361
+ }
362
+ /** Get a specific agent by ID */
363
+ function getAgent(agentId) {
364
+ return REGISTRY.find(a => a.agent_id === agentId);
365
+ }
366
+ /** Check if an agent has a specific capability */
367
+ function checkCapability(agentId, capability) {
368
+ const agent = getAgent(agentId);
369
+ if (!agent) {
370
+ return { allowed: false, agent_id: agentId, capability, reason: `Agent "${agentId}" not registered in ACP` };
371
+ }
372
+ // Explicit denials always override
373
+ if (agent.denied.includes(capability)) {
374
+ return { allowed: false, agent_id: agentId, capability, reason: `Capability "${capability}" explicitly denied for ${agent.display_name}` };
375
+ }
376
+ // Check if capability is in agent's granted list
377
+ if (agent.capabilities.includes(capability)) {
378
+ return { allowed: true, agent_id: agentId, capability, reason: `Capability "${capability}" granted to ${agent.display_name}` };
379
+ }
380
+ return { allowed: false, agent_id: agentId, capability, reason: `Capability "${capability}" not declared for ${agent.display_name}` };
381
+ }
382
+ /** Check multiple capabilities at once */
383
+ function checkCapabilities(agentId, capabilities) {
384
+ return capabilities.map(cap => checkCapability(agentId, cap));
385
+ }
386
+ /** Get all agents with a specific capability */
387
+ function getAgentsWithCapability(capability) {
388
+ return REGISTRY.filter(a => a.capabilities.includes(capability) && !a.denied.includes(capability));
389
+ }
390
+ /** Get the tier for a capability */
391
+ function getCapabilityTier(capability) {
392
+ for (const [tier, caps] of Object.entries(TIER_CAPABILITIES)) {
393
+ if (caps.includes(capability))
394
+ return tier;
395
+ }
396
+ return undefined;
397
+ }
398
+ /** Validate that a sprint's task assignments respect ACP */
399
+ function validateSprintAssignments(tasks) {
400
+ const violations = [];
401
+ for (const task of tasks) {
402
+ for (const cap of task.required_capabilities) {
403
+ const result = checkCapability(task.agent, cap);
404
+ if (!result.allowed)
405
+ violations.push(result);
406
+ }
407
+ }
408
+ return { valid: violations.length === 0, violations };
409
+ }
410
+ /** Get summary stats */
411
+ function getRegistryStats() {
412
+ const byTier = { T1: 0, T2: 0, T3: 0, T4: 0 };
413
+ let scs001 = 0;
414
+ for (const a of REGISTRY) {
415
+ byTier[a.tier]++;
416
+ if (a.agent_id.startsWith('scs001-'))
417
+ scs001++;
418
+ }
419
+ return {
420
+ total_agents: REGISTRY.length,
421
+ by_tier: byTier,
422
+ kognai_agents: REGISTRY.length - scs001,
423
+ scs001_agents: scs001,
424
+ };
425
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * agent-registry.ts — Inventory of executable agents + sprint-task validation.
3
+ *
4
+ * Sprint-runner uses this at sprint load to catch tasks assigned to
5
+ * non-executable agents (the "miner-or-founder" pattern from sprint-1556
6
+ * on 2026-05-19) before the orchestrator spawns and silently soft-rejects
7
+ * them then burns tokens on CEO/CTO meta-analysis.
8
+ *
9
+ * IMPORTANT: this registry only includes agents the orchestrator can
10
+ * actually execute. That is the set the orchestrator loads at construct
11
+ * time (see scripts/orchestrate-agents-v2.ts, the agentDirs loop):
12
+ *
13
+ * ./agents/{name}/prompt.md where {name} is NOT in skipAgents
14
+ *
15
+ * `skipAgents` = ['ceo', 'supervisor', 'skills', 'cto', 'cmo'] — those
16
+ * are orchestration brains loaded by separate methods, not coding agents
17
+ * eligible to be assigned a sub-task by name. A task assigned to one of
18
+ * them would fail `this.agents.get()` lookup at executeSubTask.
19
+ *
20
+ * `kognai-agents/` and `workspace/agents/` are NOT included: the
21
+ * orchestrator never loads from those dirs, so a task whose `agent`
22
+ * field references a name found only there would pass a naive registry
23
+ * check and then crash at execution — the very pattern we're catching.
24
+ *
25
+ * Created: sprint-1566 task `agent_registry_validation` (F2).
26
+ * Tightened: codex P1 review on PR #8 (2026-05-21).
27
+ *
28
+ * TICKET-215 Phase 3b-3: the repo root now resolves via engine-paths
29
+ * (KOGNAI_ROOT / cwd) instead of `process.cwd()` directly, so the module is
30
+ * location-independent and can live in @kognai/orchestrator-core. When run
31
+ * from a product repo root, resolveEnginePaths().root === the old cwd — same
32
+ * <root>/agents scan, no behavior change.
33
+ */
34
+ /** Returns the set of agents the orchestrator can dispatch to as a
35
+ * sub-task executor. Cached for the process lifetime — agent dirs are
36
+ * stable across a sprint-runner tick. */
37
+ export declare function listKnownAgents(): Set<string>;
38
+ /** Force-refresh the cache. Useful in tests or after agent dirs change mid-run. */
39
+ export declare function _resetCache(): void;
40
+ export interface SprintValidationResult {
41
+ ok: boolean;
42
+ unknown_agents: string[];
43
+ affected_tasks: string[];
44
+ blocked_marked: boolean;
45
+ }
46
+ /** Read a sprint JSON, find tasks whose agent isn't in the registry, mark
47
+ * them blocked with a clear blocked_reason, persist back to disk.
48
+ * Returns { ok: false } if any tasks were rejected, with the offending
49
+ * agent names + task ids so the caller can escalate. */
50
+ export declare function validateSprintAgents(sprintPath: string): SprintValidationResult;
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ /**
3
+ * agent-registry.ts — Inventory of executable agents + sprint-task validation.
4
+ *
5
+ * Sprint-runner uses this at sprint load to catch tasks assigned to
6
+ * non-executable agents (the "miner-or-founder" pattern from sprint-1556
7
+ * on 2026-05-19) before the orchestrator spawns and silently soft-rejects
8
+ * them then burns tokens on CEO/CTO meta-analysis.
9
+ *
10
+ * IMPORTANT: this registry only includes agents the orchestrator can
11
+ * actually execute. That is the set the orchestrator loads at construct
12
+ * time (see scripts/orchestrate-agents-v2.ts, the agentDirs loop):
13
+ *
14
+ * ./agents/{name}/prompt.md where {name} is NOT in skipAgents
15
+ *
16
+ * `skipAgents` = ['ceo', 'supervisor', 'skills', 'cto', 'cmo'] — those
17
+ * are orchestration brains loaded by separate methods, not coding agents
18
+ * eligible to be assigned a sub-task by name. A task assigned to one of
19
+ * them would fail `this.agents.get()` lookup at executeSubTask.
20
+ *
21
+ * `kognai-agents/` and `workspace/agents/` are NOT included: the
22
+ * orchestrator never loads from those dirs, so a task whose `agent`
23
+ * field references a name found only there would pass a naive registry
24
+ * check and then crash at execution — the very pattern we're catching.
25
+ *
26
+ * Created: sprint-1566 task `agent_registry_validation` (F2).
27
+ * Tightened: codex P1 review on PR #8 (2026-05-21).
28
+ *
29
+ * TICKET-215 Phase 3b-3: the repo root now resolves via engine-paths
30
+ * (KOGNAI_ROOT / cwd) instead of `process.cwd()` directly, so the module is
31
+ * location-independent and can live in @kognai/orchestrator-core. When run
32
+ * from a product repo root, resolveEnginePaths().root === the old cwd — same
33
+ * <root>/agents scan, no behavior change.
34
+ */
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.listKnownAgents = listKnownAgents;
37
+ exports._resetCache = _resetCache;
38
+ exports.validateSprintAgents = validateSprintAgents;
39
+ const fs_1 = require("fs");
40
+ const path_1 = require("path");
41
+ const engine_paths_1 = require("./engine-paths");
42
+ const ROOT = (0, engine_paths_1.resolveEnginePaths)().root;
43
+ /** Mirror orchestrate-agents-v2.ts:2180 — names that are NOT loaded as
44
+ * coding sub-task executors (they're handled by separate code paths). */
45
+ const SKIP_AGENTS = new Set(['ceo', 'supervisor', 'skills', 'cto', 'cmo']);
46
+ /** Pseudo-agents that are valid even though they don't have a directory:
47
+ * - 'coder' is the default fallback in orchestrate-agents-v2.ts:2418
48
+ * (`subtask.agent || 'coder'`); a real `./agents/coder/prompt.md`
49
+ * also exists, so this serves as belt-and-braces. */
50
+ const PSEUDO_AGENTS = new Set([
51
+ 'coder',
52
+ ]);
53
+ let _cached = null;
54
+ /** Returns the set of agents the orchestrator can dispatch to as a
55
+ * sub-task executor. Cached for the process lifetime — agent dirs are
56
+ * stable across a sprint-runner tick. */
57
+ function listKnownAgents() {
58
+ if (_cached)
59
+ return _cached;
60
+ const names = new Set(PSEUDO_AGENTS);
61
+ const dir = (0, path_1.join)(ROOT, 'agents');
62
+ if ((0, fs_1.existsSync)(dir)) {
63
+ try {
64
+ const entries = (0, fs_1.readdirSync)(dir, { withFileTypes: true });
65
+ for (const e of entries) {
66
+ if (!e.isDirectory() || e.name.startsWith('.'))
67
+ continue;
68
+ if (SKIP_AGENTS.has(e.name))
69
+ continue;
70
+ // Match orchestrator's existsSync(`./agents/${d}/prompt.md`) gate
71
+ if (!(0, fs_1.existsSync)((0, path_1.join)(dir, e.name, 'prompt.md')))
72
+ continue;
73
+ names.add(e.name);
74
+ }
75
+ }
76
+ catch { /* skip on permission/io error */ }
77
+ }
78
+ _cached = names;
79
+ return names;
80
+ }
81
+ /** Force-refresh the cache. Useful in tests or after agent dirs change mid-run. */
82
+ function _resetCache() { _cached = null; }
83
+ /** Read a sprint JSON, find tasks whose agent isn't in the registry, mark
84
+ * them blocked with a clear blocked_reason, persist back to disk.
85
+ * Returns { ok: false } if any tasks were rejected, with the offending
86
+ * agent names + task ids so the caller can escalate. */
87
+ function validateSprintAgents(sprintPath) {
88
+ const empty = { ok: true, unknown_agents: [], affected_tasks: [], blocked_marked: false };
89
+ if (!(0, fs_1.existsSync)(sprintPath))
90
+ return empty;
91
+ let sprint;
92
+ try {
93
+ sprint = JSON.parse((0, fs_1.readFileSync)(sprintPath, 'utf8'));
94
+ }
95
+ catch {
96
+ return empty;
97
+ } // corrupt sprint — defer to other validators
98
+ if (!Array.isArray(sprint.tasks))
99
+ return empty;
100
+ const known = listKnownAgents();
101
+ const unknownAgents = new Set();
102
+ const affectedTasks = [];
103
+ let mutated = false;
104
+ for (const t of sprint.tasks) {
105
+ if (!t || typeof t !== 'object')
106
+ continue;
107
+ // Default agent is 'coder' per orchestrate-agents-v2.ts:2479
108
+ const agentName = t.agent || 'coder';
109
+ // Tasks already in a terminal/blocked state don't trip the validator
110
+ if (t.status === 'done' || t.status === 'done-manual' || t.status === 'rejected' ||
111
+ t.status === 'rejected-stuck' || t.status === 'skipped' || t.status === 'blocked' ||
112
+ t.status === 'replaced-by-split')
113
+ continue;
114
+ if (!known.has(agentName)) {
115
+ unknownAgents.add(agentName);
116
+ affectedTasks.push(t.id);
117
+ // Mutate: mark blocked with a clear reason so sprint-runner skips it
118
+ // and the founder sees what to fix. Reversible — founder can change
119
+ // the agent assignment and re-set status to 'pending'.
120
+ t.status = 'blocked';
121
+ t.blocked_reason = `Unknown agent "${agentName}". Valid agents include: ${[...known].slice(0, 10).sort().join(', ')}, ... (${known.size} total). Edit task.agent to a valid name and reset status to pending.`;
122
+ mutated = true;
123
+ }
124
+ }
125
+ if (mutated) {
126
+ try {
127
+ (0, fs_1.writeFileSync)(sprintPath, JSON.stringify(sprint, null, 2));
128
+ }
129
+ catch { /* persist failure — non-fatal; caller still sees the rejection list */ }
130
+ }
131
+ return {
132
+ ok: unknownAgents.size === 0,
133
+ unknown_agents: [...unknownAgents],
134
+ affected_tasks: affectedTasks,
135
+ blocked_marked: mutated,
136
+ };
137
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * anthropic-direct.ts — Minimal Anthropic Messages API client.
3
+ *
4
+ * Bypasses OpenClaw gateway entirely. OpenClaw is an agentic gateway that
5
+ * wraps requests with its workspace agent's IDENTITY.md (e.g. "Nova"),
6
+ * overriding caller-supplied system prompts. For senior-coder we need a
7
+ * clean, identity-less Sonnet call.
8
+ *
9
+ * Zero npm deps (uses node `https`). Reads ANTHROPIC_API_KEY from env.
10
+ *
11
+ * Created: 2026-04-28 after senior-coder responses came back as "Nova".
12
+ */
13
+ export interface AnthropicCallOpts {
14
+ model: string;
15
+ system: string;
16
+ user: string;
17
+ max_tokens?: number;
18
+ temperature?: number;
19
+ timeout_ms?: number;
20
+ }
21
+ export interface AnthropicCallResult {
22
+ content: string;
23
+ input_tokens: number;
24
+ output_tokens: number;
25
+ stop_reason: string;
26
+ }
27
+ export declare function callAnthropic(opts: AnthropicCallOpts): Promise<AnthropicCallResult>;