chainlesschain 0.47.8 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/chainlesschain.js +0 -0
- package/package.json +10 -8
- package/src/assets/web-panel/.build-hash +1 -1
- package/src/assets/web-panel/assets/{AppLayout-6SPt_8Y_.js → AppLayout-Rvi759IS.js} +1 -1
- package/src/assets/web-panel/assets/Dashboard-BS-tzGNj.css +1 -0
- package/src/assets/web-panel/assets/{Dashboard-Br7kCwKJ.js → Dashboard-DBhFxXYQ.js} +2 -2
- package/src/assets/web-panel/assets/{index-tN-8TosE.js → index-uL0cZ8N_.js} +2 -2
- package/src/assets/web-panel/index.html +2 -2
- package/src/commands/activitypub.js +533 -0
- package/src/commands/codegen.js +303 -0
- package/src/commands/collab.js +482 -0
- package/src/commands/compliance.js +597 -6
- package/src/commands/crosschain.js +382 -0
- package/src/commands/dbevo.js +388 -0
- package/src/commands/dev.js +411 -0
- package/src/commands/federation.js +427 -0
- package/src/commands/fusion.js +332 -0
- package/src/commands/governance.js +505 -0
- package/src/commands/hardening.js +110 -0
- package/src/commands/incentive.js +373 -0
- package/src/commands/inference.js +304 -0
- package/src/commands/infra.js +361 -0
- package/src/commands/kg.js +371 -0
- package/src/commands/marketplace.js +326 -0
- package/src/commands/matrix.js +283 -0
- package/src/commands/mcp.js +441 -18
- package/src/commands/nlprog.js +329 -0
- package/src/commands/nostr.js +196 -7
- package/src/commands/ops.js +408 -0
- package/src/commands/perception.js +385 -0
- package/src/commands/pqc.js +34 -0
- package/src/commands/privacy.js +345 -0
- package/src/commands/quantization.js +280 -0
- package/src/commands/recommend.js +336 -0
- package/src/commands/reputation.js +349 -0
- package/src/commands/runtime.js +500 -0
- package/src/commands/sla.js +352 -0
- package/src/commands/social.js +265 -0
- package/src/commands/stress.js +252 -0
- package/src/commands/tech.js +268 -0
- package/src/commands/tenant.js +576 -0
- package/src/commands/trust.js +366 -0
- package/src/harness/mcp-client.js +330 -54
- package/src/index.js +114 -0
- package/src/lib/activitypub-bridge.js +623 -0
- package/src/lib/aiops.js +523 -0
- package/src/lib/autonomous-developer.js +524 -0
- package/src/lib/code-agent.js +442 -0
- package/src/lib/collaboration-governance.js +556 -0
- package/src/lib/community-governance.js +649 -0
- package/src/lib/compliance-framework-reporter.js +600 -0
- package/src/lib/content-recommendation.js +600 -0
- package/src/lib/cross-chain.js +669 -0
- package/src/lib/dbevo.js +669 -0
- package/src/lib/decentral-infra.js +445 -0
- package/src/lib/federation-hardening.js +587 -0
- package/src/lib/hardening-manager.js +409 -0
- package/src/lib/inference-network.js +407 -0
- package/src/lib/knowledge-graph.js +530 -0
- package/src/lib/matrix-bridge.js +252 -0
- package/src/lib/mcp-client.js +3 -0
- package/src/lib/mcp-registry.js +347 -0
- package/src/lib/mcp-scaffold.js +385 -0
- package/src/lib/multimodal.js +698 -0
- package/src/lib/nl-programming.js +595 -0
- package/src/lib/nostr-bridge.js +214 -38
- package/src/lib/perception.js +500 -0
- package/src/lib/pqc-manager.js +141 -9
- package/src/lib/privacy-computing.js +575 -0
- package/src/lib/protocol-fusion.js +535 -0
- package/src/lib/quantization.js +362 -0
- package/src/lib/reputation-optimizer.js +509 -0
- package/src/lib/skill-marketplace.js +397 -0
- package/src/lib/sla-manager.js +484 -0
- package/src/lib/social-graph.js +408 -0
- package/src/lib/stix-parser.js +167 -0
- package/src/lib/stress-tester.js +383 -0
- package/src/lib/tech-learning-engine.js +651 -0
- package/src/lib/tenant-saas.js +831 -0
- package/src/lib/threat-intel.js +268 -0
- package/src/lib/token-incentive.js +513 -0
- package/src/lib/topic-classifier.js +400 -0
- package/src/lib/trust-security.js +473 -0
- package/src/lib/ueba.js +403 -0
- package/src/lib/universal-runtime.js +771 -0
- package/src/assets/web-panel/assets/Dashboard-CKeMmCoT.css +0 -1
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collaboration Governance commands (Phase 64)
|
|
3
|
+
* chainlesschain collab decision-types|strategies|metrics|priorities|permissions|
|
|
4
|
+
* propose|decisions|show|vote|tally|execute|
|
|
5
|
+
* set-level|agent|agents|match|optimize
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import fs from "fs";
|
|
9
|
+
import chalk from "chalk";
|
|
10
|
+
import { logger } from "../lib/logger.js";
|
|
11
|
+
import { bootstrap, shutdown } from "../runtime/bootstrap.js";
|
|
12
|
+
import {
|
|
13
|
+
ensureGovernanceTables,
|
|
14
|
+
listDecisionTypes,
|
|
15
|
+
listConflictStrategies,
|
|
16
|
+
listQualityMetrics,
|
|
17
|
+
listPriorityLevels,
|
|
18
|
+
listPermissionTiers,
|
|
19
|
+
createDecision,
|
|
20
|
+
getDecision,
|
|
21
|
+
listDecisions,
|
|
22
|
+
vote,
|
|
23
|
+
tallyDecision,
|
|
24
|
+
markExecuted,
|
|
25
|
+
setAutonomyLevel,
|
|
26
|
+
getAutonomyLevel,
|
|
27
|
+
listAutonomyAgents,
|
|
28
|
+
calculateSkillMatch,
|
|
29
|
+
optimizeTaskAssignment,
|
|
30
|
+
calculatePriority,
|
|
31
|
+
} from "../lib/collaboration-governance.js";
|
|
32
|
+
|
|
33
|
+
function _dbFromCtx(ctx) {
|
|
34
|
+
if (!ctx.db) {
|
|
35
|
+
logger.error("Database not available");
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
const db = ctx.db.getDatabase();
|
|
39
|
+
ensureGovernanceTables(db);
|
|
40
|
+
return db;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function _readJsonFile(filePath) {
|
|
44
|
+
const raw = fs.readFileSync(filePath, "utf-8");
|
|
45
|
+
return JSON.parse(raw);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function _printDecision(d) {
|
|
49
|
+
logger.log(
|
|
50
|
+
` ${chalk.bold("ID:")} ${chalk.cyan(d.decisionId.slice(0, 8))}`,
|
|
51
|
+
);
|
|
52
|
+
logger.log(` ${chalk.bold("Type:")} ${d.type}`);
|
|
53
|
+
logger.log(` ${chalk.bold("Status:")} ${d.status}`);
|
|
54
|
+
logger.log(` ${chalk.bold("Proposal:")} ${d.proposal}`);
|
|
55
|
+
const voteCount = Object.keys(d.votes || {}).length;
|
|
56
|
+
logger.log(` ${chalk.bold("Votes:")} ${voteCount}`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function registerCollabCommand(program) {
|
|
60
|
+
const collab = program
|
|
61
|
+
.command("collab")
|
|
62
|
+
.description(
|
|
63
|
+
"Collaboration governance — decisions, voting, autonomy levels, task assignment",
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
collab
|
|
67
|
+
.command("decision-types")
|
|
68
|
+
.description("List known decision types")
|
|
69
|
+
.option("--json", "Output as JSON")
|
|
70
|
+
.action((options) => {
|
|
71
|
+
const types = listDecisionTypes();
|
|
72
|
+
if (options.json) {
|
|
73
|
+
console.log(JSON.stringify(types, null, 2));
|
|
74
|
+
} else {
|
|
75
|
+
for (const t of types) logger.log(` ${chalk.cyan(t)}`);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
collab
|
|
80
|
+
.command("strategies")
|
|
81
|
+
.description("List conflict resolution strategies")
|
|
82
|
+
.option("--json", "Output as JSON")
|
|
83
|
+
.action((options) => {
|
|
84
|
+
const strategies = listConflictStrategies();
|
|
85
|
+
if (options.json) {
|
|
86
|
+
console.log(JSON.stringify(strategies, null, 2));
|
|
87
|
+
} else {
|
|
88
|
+
for (const s of strategies) {
|
|
89
|
+
const extra = s.types || s.algorithms || s.rules || [];
|
|
90
|
+
logger.log(` ${chalk.cyan(s.name.padEnd(14))} ${extra.join(", ")}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
collab
|
|
96
|
+
.command("metrics")
|
|
97
|
+
.description("List quality metrics")
|
|
98
|
+
.option("--json", "Output as JSON")
|
|
99
|
+
.action((options) => {
|
|
100
|
+
const metrics = listQualityMetrics();
|
|
101
|
+
if (options.json) {
|
|
102
|
+
console.log(JSON.stringify(metrics, null, 2));
|
|
103
|
+
} else {
|
|
104
|
+
for (const m of metrics) logger.log(` ${chalk.cyan(m)}`);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
collab
|
|
109
|
+
.command("priorities")
|
|
110
|
+
.description("List priority levels")
|
|
111
|
+
.option("--json", "Output as JSON")
|
|
112
|
+
.action((options) => {
|
|
113
|
+
const levels = listPriorityLevels();
|
|
114
|
+
if (options.json) {
|
|
115
|
+
console.log(JSON.stringify(levels, null, 2));
|
|
116
|
+
} else {
|
|
117
|
+
for (const l of levels) {
|
|
118
|
+
logger.log(` ${chalk.cyan(`P${l.value}`)} ${chalk.bold(l.name)}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
collab
|
|
124
|
+
.command("permissions")
|
|
125
|
+
.description("List permission tiers (L0..L4)")
|
|
126
|
+
.option("--json", "Output as JSON")
|
|
127
|
+
.action((options) => {
|
|
128
|
+
const tiers = listPermissionTiers();
|
|
129
|
+
if (options.json) {
|
|
130
|
+
console.log(JSON.stringify(tiers, null, 2));
|
|
131
|
+
} else {
|
|
132
|
+
for (const t of tiers) {
|
|
133
|
+
logger.log(
|
|
134
|
+
` ${chalk.cyan(t.tier)} ${chalk.bold(`L${t.level}`)} ${t.permissions.join(", ")}`,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
collab
|
|
141
|
+
.command("propose <type> <proposal>")
|
|
142
|
+
.description(
|
|
143
|
+
"Propose a governance decision (type: task_assignment|resource_allocation|conflict_resolution|policy_update|autonomy_level)",
|
|
144
|
+
)
|
|
145
|
+
.option("--json", "Output as JSON")
|
|
146
|
+
.action(async (type, proposal, options) => {
|
|
147
|
+
try {
|
|
148
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
149
|
+
const db = _dbFromCtx(ctx);
|
|
150
|
+
const decision = createDecision(db, { type, proposal });
|
|
151
|
+
if (options.json) {
|
|
152
|
+
console.log(JSON.stringify(decision, null, 2));
|
|
153
|
+
} else {
|
|
154
|
+
logger.success("Decision proposed");
|
|
155
|
+
_printDecision(decision);
|
|
156
|
+
}
|
|
157
|
+
await shutdown();
|
|
158
|
+
} catch (err) {
|
|
159
|
+
logger.error(`Failed: ${err.message}`);
|
|
160
|
+
process.exit(1);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
collab
|
|
165
|
+
.command("decisions")
|
|
166
|
+
.description("List governance decisions")
|
|
167
|
+
.option("-t, --type <type>", "Filter by type")
|
|
168
|
+
.option(
|
|
169
|
+
"-s, --status <status>",
|
|
170
|
+
"Filter by status (pending|voting|approved|rejected|executed)",
|
|
171
|
+
)
|
|
172
|
+
.option("--limit <n>", "Maximum entries", parseInt, 50)
|
|
173
|
+
.option("--json", "Output as JSON")
|
|
174
|
+
.action(async (options) => {
|
|
175
|
+
try {
|
|
176
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
177
|
+
_dbFromCtx(ctx);
|
|
178
|
+
const rows = listDecisions({
|
|
179
|
+
type: options.type,
|
|
180
|
+
status: options.status,
|
|
181
|
+
limit: options.limit,
|
|
182
|
+
});
|
|
183
|
+
if (options.json) {
|
|
184
|
+
console.log(JSON.stringify(rows, null, 2));
|
|
185
|
+
} else if (rows.length === 0) {
|
|
186
|
+
logger.info("No decisions.");
|
|
187
|
+
} else {
|
|
188
|
+
for (const d of rows) {
|
|
189
|
+
const voteCount = Object.keys(d.votes || {}).length;
|
|
190
|
+
logger.log(
|
|
191
|
+
` ${chalk.cyan(d.decisionId.slice(0, 8))} [${d.status.padEnd(8)}] ${d.type.padEnd(20)} votes=${voteCount} ${d.proposal}`,
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
await shutdown();
|
|
196
|
+
} catch (err) {
|
|
197
|
+
logger.error(`Failed: ${err.message}`);
|
|
198
|
+
process.exit(1);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
collab
|
|
203
|
+
.command("show <decision-id>")
|
|
204
|
+
.description("Show full details of a decision")
|
|
205
|
+
.option("--json", "Output as JSON")
|
|
206
|
+
.action(async (decisionId, options) => {
|
|
207
|
+
try {
|
|
208
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
209
|
+
_dbFromCtx(ctx);
|
|
210
|
+
const decision = getDecision(decisionId);
|
|
211
|
+
if (!decision) {
|
|
212
|
+
logger.error(`Decision not found: ${decisionId}`);
|
|
213
|
+
process.exit(1);
|
|
214
|
+
}
|
|
215
|
+
if (options.json) {
|
|
216
|
+
console.log(JSON.stringify(decision, null, 2));
|
|
217
|
+
} else {
|
|
218
|
+
_printDecision(decision);
|
|
219
|
+
if (decision.resolution) {
|
|
220
|
+
logger.log(
|
|
221
|
+
` ${chalk.bold("Outcome:")} ${decision.resolution.outcome}`,
|
|
222
|
+
);
|
|
223
|
+
logger.log(
|
|
224
|
+
` ${chalk.bold("Tally:")} approve=${decision.resolution.tally.approve} reject=${decision.resolution.tally.reject} abstain=${decision.resolution.tally.abstain}`,
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
for (const [agent, v] of Object.entries(decision.votes || {})) {
|
|
228
|
+
logger.log(
|
|
229
|
+
` ${chalk.cyan(agent)} → ${v.vote}${v.reason ? ` (${v.reason})` : ""}`,
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
await shutdown();
|
|
234
|
+
} catch (err) {
|
|
235
|
+
logger.error(`Failed: ${err.message}`);
|
|
236
|
+
process.exit(1);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
collab
|
|
241
|
+
.command("vote <decision-id> <agent-id> <vote>")
|
|
242
|
+
.description("Cast a vote (vote: approve|reject|abstain)")
|
|
243
|
+
.option("-r, --reason <text>", "Reason for vote")
|
|
244
|
+
.option("--json", "Output as JSON")
|
|
245
|
+
.action(async (decisionId, agentId, voteValue, options) => {
|
|
246
|
+
try {
|
|
247
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
248
|
+
const db = _dbFromCtx(ctx);
|
|
249
|
+
const decision = vote(
|
|
250
|
+
db,
|
|
251
|
+
decisionId,
|
|
252
|
+
agentId,
|
|
253
|
+
voteValue,
|
|
254
|
+
options.reason || "",
|
|
255
|
+
);
|
|
256
|
+
if (options.json) {
|
|
257
|
+
console.log(JSON.stringify(decision, null, 2));
|
|
258
|
+
} else {
|
|
259
|
+
logger.success(
|
|
260
|
+
`Vote recorded: ${agentId} → ${voteValue} on ${decisionId.slice(0, 8)}`,
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
await shutdown();
|
|
264
|
+
} catch (err) {
|
|
265
|
+
logger.error(`Failed: ${err.message}`);
|
|
266
|
+
process.exit(1);
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
collab
|
|
271
|
+
.command("tally <decision-id>")
|
|
272
|
+
.description("Tally votes and transition decision status")
|
|
273
|
+
.option(
|
|
274
|
+
"-q, --quorum <n>",
|
|
275
|
+
"Quorum ratio 0..1 (default 0.5)",
|
|
276
|
+
parseFloat,
|
|
277
|
+
0.5,
|
|
278
|
+
)
|
|
279
|
+
.option(
|
|
280
|
+
"-t, --threshold <n>",
|
|
281
|
+
"Approval threshold 0..1 (default 0.6)",
|
|
282
|
+
parseFloat,
|
|
283
|
+
0.6,
|
|
284
|
+
)
|
|
285
|
+
.option(
|
|
286
|
+
"-n, --total-voters <n>",
|
|
287
|
+
"Total eligible voters (defaults to actual voters count)",
|
|
288
|
+
parseInt,
|
|
289
|
+
)
|
|
290
|
+
.option("--json", "Output as JSON")
|
|
291
|
+
.action(async (decisionId, options) => {
|
|
292
|
+
try {
|
|
293
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
294
|
+
const db = _dbFromCtx(ctx);
|
|
295
|
+
const decision = tallyDecision(db, decisionId, {
|
|
296
|
+
quorum: options.quorum,
|
|
297
|
+
threshold: options.threshold,
|
|
298
|
+
totalVoters: options.totalVoters,
|
|
299
|
+
});
|
|
300
|
+
if (options.json) {
|
|
301
|
+
console.log(JSON.stringify(decision, null, 2));
|
|
302
|
+
} else {
|
|
303
|
+
logger.success(`Tallied → ${decision.status}`);
|
|
304
|
+
logger.log(
|
|
305
|
+
` ${chalk.bold("Outcome:")} ${decision.resolution.outcome}`,
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
await shutdown();
|
|
309
|
+
} catch (err) {
|
|
310
|
+
logger.error(`Failed: ${err.message}`);
|
|
311
|
+
process.exit(1);
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
collab
|
|
316
|
+
.command("execute <decision-id>")
|
|
317
|
+
.description("Mark an approved decision as executed")
|
|
318
|
+
.action(async (decisionId) => {
|
|
319
|
+
try {
|
|
320
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
321
|
+
const db = _dbFromCtx(ctx);
|
|
322
|
+
markExecuted(db, decisionId);
|
|
323
|
+
logger.success(`Executed ${decisionId.slice(0, 8)}`);
|
|
324
|
+
await shutdown();
|
|
325
|
+
} catch (err) {
|
|
326
|
+
logger.error(`Failed: ${err.message}`);
|
|
327
|
+
process.exit(1);
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
collab
|
|
332
|
+
.command("set-level <agent-id> <level>")
|
|
333
|
+
.description("Set an agent's autonomy level (0..4)")
|
|
334
|
+
.option("-r, --reason <text>", "Reason for adjustment")
|
|
335
|
+
.option("--json", "Output as JSON")
|
|
336
|
+
.action(async (agentId, level, options) => {
|
|
337
|
+
try {
|
|
338
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
339
|
+
const db = _dbFromCtx(ctx);
|
|
340
|
+
const record = setAutonomyLevel(db, agentId, parseInt(level, 10), {
|
|
341
|
+
reason: options.reason,
|
|
342
|
+
});
|
|
343
|
+
if (options.json) {
|
|
344
|
+
console.log(JSON.stringify(record, null, 2));
|
|
345
|
+
} else {
|
|
346
|
+
logger.success(`Level set: ${agentId} → L${record.currentLevel}`);
|
|
347
|
+
logger.log(
|
|
348
|
+
` ${chalk.bold("Permissions:")} ${record.permissions.join(", ")}`,
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
await shutdown();
|
|
352
|
+
} catch (err) {
|
|
353
|
+
logger.error(`Failed: ${err.message}`);
|
|
354
|
+
process.exit(1);
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
collab
|
|
359
|
+
.command("agent <agent-id>")
|
|
360
|
+
.description("Show agent autonomy level")
|
|
361
|
+
.option("--json", "Output as JSON")
|
|
362
|
+
.action(async (agentId, options) => {
|
|
363
|
+
try {
|
|
364
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
365
|
+
_dbFromCtx(ctx);
|
|
366
|
+
const record = getAutonomyLevel(agentId);
|
|
367
|
+
if (!record) {
|
|
368
|
+
logger.error(`Agent not found: ${agentId}`);
|
|
369
|
+
process.exit(1);
|
|
370
|
+
}
|
|
371
|
+
if (options.json) {
|
|
372
|
+
console.log(JSON.stringify(record, null, 2));
|
|
373
|
+
} else {
|
|
374
|
+
logger.log(` ${chalk.bold("Agent:")} ${record.agentId}`);
|
|
375
|
+
logger.log(` ${chalk.bold("Level:")} L${record.currentLevel}`);
|
|
376
|
+
logger.log(
|
|
377
|
+
` ${chalk.bold("Permissions:")} ${record.permissions.join(", ")}`,
|
|
378
|
+
);
|
|
379
|
+
logger.log(
|
|
380
|
+
` ${chalk.bold("History:")} ${record.adjustmentHistory.length} adjustment(s)`,
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
await shutdown();
|
|
384
|
+
} catch (err) {
|
|
385
|
+
logger.error(`Failed: ${err.message}`);
|
|
386
|
+
process.exit(1);
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
collab
|
|
391
|
+
.command("agents")
|
|
392
|
+
.description("List agents with autonomy levels")
|
|
393
|
+
.option("-l, --level <n>", "Filter by level 0..4", parseInt)
|
|
394
|
+
.option("--limit <n>", "Maximum entries", parseInt, 50)
|
|
395
|
+
.option("--json", "Output as JSON")
|
|
396
|
+
.action(async (options) => {
|
|
397
|
+
try {
|
|
398
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
399
|
+
_dbFromCtx(ctx);
|
|
400
|
+
const rows = listAutonomyAgents({
|
|
401
|
+
level: options.level,
|
|
402
|
+
limit: options.limit,
|
|
403
|
+
});
|
|
404
|
+
if (options.json) {
|
|
405
|
+
console.log(JSON.stringify(rows, null, 2));
|
|
406
|
+
} else if (rows.length === 0) {
|
|
407
|
+
logger.info("No agents.");
|
|
408
|
+
} else {
|
|
409
|
+
for (const r of rows) {
|
|
410
|
+
logger.log(
|
|
411
|
+
` ${chalk.cyan(r.agentId.padEnd(20))} L${r.currentLevel} ${r.permissions.join(", ")}`,
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
await shutdown();
|
|
416
|
+
} catch (err) {
|
|
417
|
+
logger.error(`Failed: ${err.message}`);
|
|
418
|
+
process.exit(1);
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
collab
|
|
423
|
+
.command("match <required-skills-json> <agent-skills-json>")
|
|
424
|
+
.description(
|
|
425
|
+
"Compute skill match score (inputs are JSON file paths; required: [{name,requiredLevel,weight}], agent: {skillName: level})",
|
|
426
|
+
)
|
|
427
|
+
.option("--json", "Output as JSON")
|
|
428
|
+
.action(async (requiredPath, agentPath, options) => {
|
|
429
|
+
try {
|
|
430
|
+
const required = _readJsonFile(requiredPath);
|
|
431
|
+
const agent = _readJsonFile(agentPath);
|
|
432
|
+
const score = calculateSkillMatch(required, agent);
|
|
433
|
+
if (options.json) {
|
|
434
|
+
console.log(
|
|
435
|
+
JSON.stringify({ score: Number(score.toFixed(3)) }, null, 2),
|
|
436
|
+
);
|
|
437
|
+
} else {
|
|
438
|
+
logger.log(` ${chalk.bold("Skill Match:")} ${score.toFixed(3)}`);
|
|
439
|
+
}
|
|
440
|
+
} catch (err) {
|
|
441
|
+
logger.error(`Failed: ${err.message}`);
|
|
442
|
+
process.exit(1);
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
collab
|
|
447
|
+
.command("optimize <tasks-json> <agents-json>")
|
|
448
|
+
.description(
|
|
449
|
+
"Optimize task assignment (tasks: [{id,urgency,importance,complexity,dependencies,requiredSkills}], agents: [{id,skills,currentLoad,maxCapacity}])",
|
|
450
|
+
)
|
|
451
|
+
.option("--json", "Output as JSON")
|
|
452
|
+
.action(async (tasksPath, agentsPath, options) => {
|
|
453
|
+
try {
|
|
454
|
+
const tasks = _readJsonFile(tasksPath);
|
|
455
|
+
const agents = _readJsonFile(agentsPath);
|
|
456
|
+
const result = optimizeTaskAssignment(tasks, agents);
|
|
457
|
+
if (options.json) {
|
|
458
|
+
console.log(JSON.stringify(result, null, 2));
|
|
459
|
+
} else {
|
|
460
|
+
logger.success(
|
|
461
|
+
`Assigned ${result.assigned}/${result.totalTasks} tasks (${result.unassignedCount} unassigned)`,
|
|
462
|
+
);
|
|
463
|
+
for (const a of result.assignments) {
|
|
464
|
+
logger.log(
|
|
465
|
+
` ${chalk.cyan(a.taskId.padEnd(16))} → ${chalk.bold(a.agentId.padEnd(16))} skill=${a.skillScore} priority=${a.priority}`,
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
for (const u of result.unassigned) {
|
|
469
|
+
logger.log(
|
|
470
|
+
` ${chalk.yellow(u.taskId.padEnd(16))} ${chalk.yellow("unassigned")} (${u.reason})`,
|
|
471
|
+
);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
} catch (err) {
|
|
475
|
+
logger.error(`Failed: ${err.message}`);
|
|
476
|
+
process.exit(1);
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
// silence unused-import lint
|
|
481
|
+
void calculatePriority;
|
|
482
|
+
}
|