@kognai/clawrouter-x402 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.
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @kognai/clawrouter-x402 — Kognai's viem-backed x402 ModelRouter.
3
+ *
4
+ * TICKET-215 Phase 3b-3 Wave C (a): clawrouter-v2 lives here (NOT in
5
+ * @kognai/orchestrator-core) so the core engine never depends on viem. Kognai's
6
+ * orchestrator injects `x402Router` into the core router seam at startup
7
+ * (setModelRouter); products that don't route on-chain simply don't install or
8
+ * inject this package, and viem stays out of their dependency tree.
9
+ *
10
+ * viem itself is loaded via dynamic require() inside the payment path (see
11
+ * clawrouter-v2.ts), so importing this module does not eagerly pull viem —
12
+ * but the package declares viem as a dependency so it resolves at pay time.
13
+ */
14
+ import type { ModelRouter } from '../../orchestrator-core/src/lib/model-router-contract';
15
+ /**
16
+ * The ModelRouter implementation Kognai injects:
17
+ * import { x402Router } from '@kognai/clawrouter-x402';
18
+ * setModelRouter(x402Router);
19
+ */
20
+ export declare const x402Router: ModelRouter;
21
+ export * from './clawrouter-v2';
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ /**
3
+ * @kognai/clawrouter-x402 — Kognai's viem-backed x402 ModelRouter.
4
+ *
5
+ * TICKET-215 Phase 3b-3 Wave C (a): clawrouter-v2 lives here (NOT in
6
+ * @kognai/orchestrator-core) so the core engine never depends on viem. Kognai's
7
+ * orchestrator injects `x402Router` into the core router seam at startup
8
+ * (setModelRouter); products that don't route on-chain simply don't install or
9
+ * inject this package, and viem stays out of their dependency tree.
10
+ *
11
+ * viem itself is loaded via dynamic require() inside the payment path (see
12
+ * clawrouter-v2.ts), so importing this module does not eagerly pull viem —
13
+ * but the package declares viem as a dependency so it resolves at pay time.
14
+ */
15
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ var desc = Object.getOwnPropertyDescriptor(m, k);
18
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
19
+ desc = { enumerable: true, get: function() { return m[k]; } };
20
+ }
21
+ Object.defineProperty(o, k2, desc);
22
+ }) : (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ o[k2] = m[k];
25
+ }));
26
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
27
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.x402Router = void 0;
31
+ const clawrouter_v2_1 = require("./clawrouter-v2");
32
+ /**
33
+ * The ModelRouter implementation Kognai injects:
34
+ * import { x402Router } from '@kognai/clawrouter-x402';
35
+ * setModelRouter(x402Router);
36
+ */
37
+ exports.x402Router = {
38
+ routeCall: clawrouter_v2_1.routeCall,
39
+ callLLM: clawrouter_v2_1.callLLM,
40
+ healthCheck: clawrouter_v2_1.clawRouterHealthCheck,
41
+ getDailyCostDigest: clawrouter_v2_1.getDailyCostDigest,
42
+ };
43
+ // Re-export the full clawrouter-v2 surface (raw functions + types) so existing
44
+ // direct importers keep working via the scripts/lib/clawrouter-v2 shim.
45
+ __exportStar(require("./clawrouter-v2"), exports);
@@ -0,0 +1,61 @@
1
+ /**
2
+ * ACP — Agent Capability Protocol v1
3
+ *
4
+ * Defines capability declarations for each agent in the Kognai swarm.
5
+ * Each agent declares what it CAN and CANNOT do, enabling:
6
+ * - Constitution enforcement (prevent agents from exceeding scope)
7
+ * - CTO approval gate capability checks
8
+ * - Task routing based on declared capabilities
9
+ *
10
+ * Capability tiers:
11
+ * T1 (Foundation): read, write, search
12
+ * T2 (Content): llm_call, tts, video_gen, script_gen
13
+ * T3 (Integration): api_call, db_query, telegram, stripe
14
+ * T4 (System): deploy, pm2, git_push, shell_exec
15
+ *
16
+ * Sprint 650 — ACP v1 implementation
17
+ */
18
+ export type CapabilityTier = 'T1' | 'T2' | 'T3' | 'T4';
19
+ export type Capability = 'read_files' | 'write_files' | 'search_code' | 'git_read' | 'llm_call_local' | 'llm_call_cloud' | 'tts_generate' | 'video_composite' | 'script_generate' | 'image_generate' | 'avatar_generate' | 'api_call_external' | 'db_query' | 'db_write' | 'telegram_send' | 'stripe_read' | 'stripe_write' | 'youtube_read' | 'tiktok_post' | 'deploy' | 'pm2_manage' | 'git_push' | 'shell_exec' | 'env_modify';
20
+ export interface AgentCapabilityDeclaration {
21
+ agent_id: string;
22
+ display_name: string;
23
+ tier: CapabilityTier;
24
+ capabilities: Capability[];
25
+ denied: Capability[];
26
+ scope: string;
27
+ max_model_tier: 'nano' | 'local' | 'power' | 'cloud' | 'apex';
28
+ }
29
+ export interface CapabilityCheckResult {
30
+ allowed: boolean;
31
+ agent_id: string;
32
+ capability: Capability;
33
+ reason: string;
34
+ }
35
+ /** Get all registered agents */
36
+ export declare function getAllAgents(): AgentCapabilityDeclaration[];
37
+ /** Get a specific agent by ID */
38
+ export declare function getAgent(agentId: string): AgentCapabilityDeclaration | undefined;
39
+ /** Check if an agent has a specific capability */
40
+ export declare function checkCapability(agentId: string, capability: Capability): CapabilityCheckResult;
41
+ /** Check multiple capabilities at once */
42
+ export declare function checkCapabilities(agentId: string, capabilities: Capability[]): CapabilityCheckResult[];
43
+ /** Get all agents with a specific capability */
44
+ export declare function getAgentsWithCapability(capability: Capability): AgentCapabilityDeclaration[];
45
+ /** Get the tier for a capability */
46
+ export declare function getCapabilityTier(capability: Capability): CapabilityTier | undefined;
47
+ /** Validate that a sprint's task assignments respect ACP */
48
+ export declare function validateSprintAssignments(tasks: Array<{
49
+ agent: string;
50
+ required_capabilities: Capability[];
51
+ }>): {
52
+ valid: boolean;
53
+ violations: CapabilityCheckResult[];
54
+ };
55
+ /** Get summary stats */
56
+ export declare function getRegistryStats(): {
57
+ total_agents: number;
58
+ by_tier: Record<CapabilityTier, number>;
59
+ kognai_agents: number;
60
+ scs001_agents: number;
61
+ };
@@ -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,13 @@
1
+ export interface EnginePaths {
2
+ root: string;
3
+ swarmState: string;
4
+ sprints: string;
5
+ failureLibrary: string;
6
+ ksl: string;
7
+ logs: string;
8
+ }
9
+ /**
10
+ * Resolve all engine paths from a root. Precedence: explicit arg → KOGNAI_ROOT
11
+ * env → process.cwd(). Individual dirs accept env overrides for non-standard layouts.
12
+ */
13
+ export declare function resolveEnginePaths(root?: string): EnginePaths;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveEnginePaths = resolveEnginePaths;
4
+ /**
5
+ * engine-paths.ts — TICKET-215 Phase 3: the path-parameterization seam.
6
+ *
7
+ * The core engine historically hardcoded repo-specific paths (.swarm-state,
8
+ * data/failure-library, workspace/sprints, …) via `resolve(__dirname, '../../…')`,
9
+ * which only works when the code physically lives in the consuming repo. That
10
+ * coupling is what blocked packaging the engine.
11
+ *
12
+ * This module centralizes every repo-specific path behind a single resolver,
13
+ * defaulted from `KOGNAI_ROOT` (or `process.cwd()`) so behavior is unchanged when
14
+ * the engine runs from a product repo root — but now overridable, so the same
15
+ * package can serve Kognai, Voxight, and Invoica from their own roots.
16
+ */
17
+ const path_1 = require("path");
18
+ /**
19
+ * Resolve all engine paths from a root. Precedence: explicit arg → KOGNAI_ROOT
20
+ * env → process.cwd(). Individual dirs accept env overrides for non-standard layouts.
21
+ */
22
+ function resolveEnginePaths(root) {
23
+ const r = root || process.env.KOGNAI_ROOT || process.cwd();
24
+ return {
25
+ root: r,
26
+ swarmState: process.env.KOGNAI_SWARM_STATE || (0, path_1.join)(r, '.swarm-state'),
27
+ sprints: process.env.KOGNAI_SPRINTS_DIR || (0, path_1.join)(r, 'workspace', 'sprints'),
28
+ failureLibrary: process.env.KOGNAI_FAILURE_DIR || (0, path_1.join)(r, 'data', 'failure-library'),
29
+ ksl: process.env.KOGNAI_KSL_DIR || (0, path_1.join)(r, 'workspace', 'ksl'),
30
+ logs: process.env.KOGNAI_LOGS_DIR || (0, path_1.join)(r, 'logs'),
31
+ };
32
+ }