@a-company/paradigm 3.43.0 → 3.46.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/dist/{chunk-YW5OCVKB.js → chunk-FKJUBQU3.js} +14 -1
- package/dist/chunk-KVDYJLTC.js +121 -0
- package/dist/{symphony-ROEKK7VD.js → chunk-S2HO5MLR.js} +53 -431
- package/dist/{chunk-RGFANZ4Q.js → chunk-ZDHLG5VP.js} +14 -1
- package/dist/{chunk-CZEIK3Y2.js → chunk-ZMQA6SCO.js} +1 -1
- package/dist/{chunk-7WEKMZ46.js → chunk-ZSYVKSY6.js} +1 -1
- package/dist/{commands-LEPFD7S5.js → commands-5N4ILTPH.js} +13 -0
- package/dist/{dist-RVKYUCRU.js → dist-CM3MVWWW.js} +1 -1
- package/dist/{dist-Y7I3CFY5.js → dist-POMVY6WP.js} +2 -2
- package/dist/{habits-O37HTUKE.js → habits-RG5SVKXP.js} +2 -2
- package/dist/index.js +69 -48
- package/dist/mcp.js +89 -9
- package/dist/peers-RFQCWVLV.js +82 -0
- package/dist/{platform-server-KK4OCRTV.js → platform-server-H7Y6Q7O4.js} +10 -1
- package/dist/{reindex-NZQRGKPN.js → reindex-WIJMCJ4A.js} +1 -1
- package/dist/{sentinel-BKYTBT7M.js → sentinel-UOIGJWHH.js} +1 -1
- package/dist/{sentinel-bridge-IZTXYS5M.js → sentinel-bridge-APDXYAZS.js} +1 -1
- package/dist/sentinel-mcp.js +13 -0
- package/dist/sentinel.js +6 -6
- package/dist/{serve-3V2WXLGM.js → serve-KKEHE44G.js} +1 -1
- package/dist/{server-OFEJ2HJP.js → server-JV6UFGWZ.js} +1 -1
- package/dist/symphony-6K3HD7AW.js +791 -0
- package/dist/symphony-YCHBYN3E.js +326 -0
- package/dist/symphony-peers-APOGJPF4.js +120 -0
- package/dist/symphony-peers-HSY3RI3S.js +34 -0
- package/dist/symphony-relay-GTAJRCVF.js +683 -0
- package/dist/{triage-POXJ2TIX.js → triage-IZ4MDYNB.js} +2 -2
- package/dist/university-content/courses/para-501.json +84 -0
- package/package.json +1 -1
- package/platform-ui/dist/assets/{GitSection-DvyJBF_-.js → GitSection-BD3Ze06e.js} +1 -1
- package/platform-ui/dist/assets/{GraphSection-BiQrXqfs.js → GraphSection-SglITfSs.js} +1 -1
- package/platform-ui/dist/assets/{LoreSection-BaH1FaRb.js → LoreSection-bR5Km4Fd.js} +1 -1
- package/platform-ui/dist/assets/{SentinelSection-DemAznjI.js → SentinelSection-QSpAZArG.js} +1 -1
- package/platform-ui/dist/assets/SymphonySection-CobYJgvg.js +1 -0
- package/platform-ui/dist/assets/SymphonySection-zY0C5tFl.css +1 -0
- package/platform-ui/dist/assets/{index-DDKhCt-w.js → index-DbxeSMkV.js} +11 -11
- package/platform-ui/dist/index.html +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// ../sentinel/dist/chunk-
|
|
3
|
+
// ../sentinel/dist/chunk-OKYYIAML.js
|
|
4
4
|
import initSqlJs from "sql.js";
|
|
5
5
|
import { v4 as uuidv4 } from "uuid";
|
|
6
6
|
import * as path from "path";
|
|
@@ -598,6 +598,19 @@ var SentinelStorage = class {
|
|
|
598
598
|
);
|
|
599
599
|
this.save();
|
|
600
600
|
}
|
|
601
|
+
resolveIncident(id, options) {
|
|
602
|
+
this.updateIncident(id, {
|
|
603
|
+
status: "resolved",
|
|
604
|
+
resolvedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
605
|
+
});
|
|
606
|
+
if (options?.notes) {
|
|
607
|
+
this.addIncidentNote(id, {
|
|
608
|
+
author: "system",
|
|
609
|
+
content: options.notes,
|
|
610
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
}
|
|
601
614
|
addIncidentNote(incidentId, note) {
|
|
602
615
|
this.initializeSync();
|
|
603
616
|
const incident = this.getIncident(incidentId);
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// ../paradigm-mcp/src/utils/symphony-peers.ts
|
|
4
|
+
import * as fs from "fs";
|
|
5
|
+
import * as path from "path";
|
|
6
|
+
import * as os from "os";
|
|
7
|
+
import * as crypto from "crypto";
|
|
8
|
+
var SCORE_DIR = path.join(os.homedir(), ".paradigm", "score");
|
|
9
|
+
var PEERS_FILE = path.join(SCORE_DIR, "peers.json");
|
|
10
|
+
var PAIRING_TTL_MS = 5 * 60 * 1e3;
|
|
11
|
+
function loadPeers() {
|
|
12
|
+
try {
|
|
13
|
+
if (!fs.existsSync(PEERS_FILE)) return [];
|
|
14
|
+
const content = fs.readFileSync(PEERS_FILE, "utf-8");
|
|
15
|
+
const parsed = JSON.parse(content);
|
|
16
|
+
if (!Array.isArray(parsed)) return [];
|
|
17
|
+
return parsed;
|
|
18
|
+
} catch {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function savePeers(peers) {
|
|
23
|
+
if (!fs.existsSync(SCORE_DIR)) {
|
|
24
|
+
fs.mkdirSync(SCORE_DIR, { recursive: true });
|
|
25
|
+
}
|
|
26
|
+
fs.writeFileSync(PEERS_FILE, JSON.stringify(peers, null, 2), { mode: 384 });
|
|
27
|
+
}
|
|
28
|
+
function findPeer(id) {
|
|
29
|
+
const peers = loadPeers();
|
|
30
|
+
return peers.find((p) => p.id === id) ?? null;
|
|
31
|
+
}
|
|
32
|
+
function addPeer(peer) {
|
|
33
|
+
const peers = loadPeers();
|
|
34
|
+
const idx = peers.findIndex((p) => p.id === peer.id);
|
|
35
|
+
if (idx >= 0) {
|
|
36
|
+
peers[idx] = peer;
|
|
37
|
+
} else {
|
|
38
|
+
peers.push(peer);
|
|
39
|
+
}
|
|
40
|
+
savePeers(peers);
|
|
41
|
+
}
|
|
42
|
+
function revokePeer(id) {
|
|
43
|
+
const peers = loadPeers();
|
|
44
|
+
const peer = peers.find((p) => p.id === id);
|
|
45
|
+
if (!peer) return false;
|
|
46
|
+
peer.revoked = true;
|
|
47
|
+
savePeers(peers);
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
function forgetAllPeers() {
|
|
51
|
+
const peers = loadPeers();
|
|
52
|
+
const count = peers.length;
|
|
53
|
+
if (fs.existsSync(PEERS_FILE)) {
|
|
54
|
+
fs.unlinkSync(PEERS_FILE);
|
|
55
|
+
}
|
|
56
|
+
return count;
|
|
57
|
+
}
|
|
58
|
+
function updatePeerLastSeen(id) {
|
|
59
|
+
const peers = loadPeers();
|
|
60
|
+
const peer = peers.find((p) => p.id === id);
|
|
61
|
+
if (!peer) return;
|
|
62
|
+
peer.lastSeen = (/* @__PURE__ */ new Date()).toISOString();
|
|
63
|
+
savePeers(peers);
|
|
64
|
+
}
|
|
65
|
+
function updatePeerAgents(id, agents) {
|
|
66
|
+
const peers = loadPeers();
|
|
67
|
+
const peer = peers.find((p) => p.id === id);
|
|
68
|
+
if (!peer) return;
|
|
69
|
+
peer.agents = agents;
|
|
70
|
+
savePeers(peers);
|
|
71
|
+
}
|
|
72
|
+
function generatePairing() {
|
|
73
|
+
const sharedSecret = crypto.randomBytes(32).toString("hex");
|
|
74
|
+
const code = (parseInt(crypto.randomBytes(3).toString("hex"), 16) % 1e6).toString().padStart(6, "0");
|
|
75
|
+
const codeHash = crypto.createHash("sha256").update(code).digest("hex");
|
|
76
|
+
return {
|
|
77
|
+
code,
|
|
78
|
+
codeHash,
|
|
79
|
+
sharedSecret,
|
|
80
|
+
createdAt: Date.now()
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function verifyPairingCode(state, code) {
|
|
84
|
+
if (Date.now() - state.createdAt > PAIRING_TTL_MS) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
const hash = crypto.createHash("sha256").update(code).digest("hex");
|
|
88
|
+
return hash === state.codeHash;
|
|
89
|
+
}
|
|
90
|
+
function computeHmacProof(challenge, codeHash) {
|
|
91
|
+
return crypto.createHmac("sha256", codeHash).update(challenge).digest("hex");
|
|
92
|
+
}
|
|
93
|
+
function verifyHmacProof(challenge, codeHash, proof) {
|
|
94
|
+
const expected = computeHmacProof(challenge, codeHash);
|
|
95
|
+
if (expected.length !== proof.length) return false;
|
|
96
|
+
try {
|
|
97
|
+
return crypto.timingSafeEqual(
|
|
98
|
+
Buffer.from(expected, "hex"),
|
|
99
|
+
Buffer.from(proof, "hex")
|
|
100
|
+
);
|
|
101
|
+
} catch {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export {
|
|
107
|
+
PEERS_FILE,
|
|
108
|
+
PAIRING_TTL_MS,
|
|
109
|
+
loadPeers,
|
|
110
|
+
savePeers,
|
|
111
|
+
findPeer,
|
|
112
|
+
addPeer,
|
|
113
|
+
revokePeer,
|
|
114
|
+
forgetAllPeers,
|
|
115
|
+
updatePeerLastSeen,
|
|
116
|
+
updatePeerAgents,
|
|
117
|
+
generatePairing,
|
|
118
|
+
verifyPairingCode,
|
|
119
|
+
computeHmacProof,
|
|
120
|
+
verifyHmacProof
|
|
121
|
+
};
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import "./chunk-ZXMDA7VB.js";
|
|
3
|
-
|
|
4
|
-
// src/commands/symphony/index.ts
|
|
5
|
-
import chalk from "chalk";
|
|
6
|
-
import * as net from "net";
|
|
7
2
|
|
|
8
3
|
// ../paradigm-mcp/src/utils/symphony-loader.ts
|
|
9
4
|
import * as fs from "fs";
|
|
@@ -171,12 +166,15 @@ function getMyIdentity(projectDir) {
|
|
|
171
166
|
return null;
|
|
172
167
|
}
|
|
173
168
|
}
|
|
174
|
-
function markAgentPollTime(agentId) {
|
|
169
|
+
function markAgentPollTime(agentId, statusBlurb) {
|
|
175
170
|
const identityPath = path.join(getAgentDir(agentId), "identity.json");
|
|
176
171
|
if (!fs.existsSync(identityPath)) return;
|
|
177
172
|
try {
|
|
178
173
|
const identity = JSON.parse(fs.readFileSync(identityPath, "utf-8"));
|
|
179
174
|
identity.lastPoll = (/* @__PURE__ */ new Date()).toISOString();
|
|
175
|
+
if (statusBlurb !== void 0) {
|
|
176
|
+
identity.statusBlurb = statusBlurb || void 0;
|
|
177
|
+
}
|
|
180
178
|
fs.writeFileSync(identityPath, JSON.stringify(identity, null, 2), "utf-8");
|
|
181
179
|
} catch {
|
|
182
180
|
}
|
|
@@ -248,6 +246,9 @@ function appendToOutbox(agentId, message) {
|
|
|
248
246
|
ensureAgentDir(agentId);
|
|
249
247
|
appendJsonlLine(outboxPath(agentId), message);
|
|
250
248
|
}
|
|
249
|
+
function readOutbox(agentId) {
|
|
250
|
+
return readJsonlFile(outboxPath(agentId));
|
|
251
|
+
}
|
|
251
252
|
function acknowledgeMessages(agentId, lastMessageId) {
|
|
252
253
|
const filePath = ackPath(agentId);
|
|
253
254
|
ensureAgentDir(agentId);
|
|
@@ -561,6 +562,24 @@ function isPathDenied(filePath, config, user) {
|
|
|
561
562
|
}
|
|
562
563
|
return false;
|
|
563
564
|
}
|
|
565
|
+
function expireOldRequests() {
|
|
566
|
+
const requests = listFileRequests("pending");
|
|
567
|
+
let expired = 0;
|
|
568
|
+
for (const record of requests) {
|
|
569
|
+
const age = Date.now() - new Date(record.createdAt).getTime();
|
|
570
|
+
if (age > FILE_REQUEST_TTL_MS) {
|
|
571
|
+
record.status = "expired";
|
|
572
|
+
record.resolvedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
573
|
+
fs.writeFileSync(
|
|
574
|
+
fileRequestPath(record.request.requestId),
|
|
575
|
+
JSON.stringify(record, null, 2),
|
|
576
|
+
"utf-8"
|
|
577
|
+
);
|
|
578
|
+
expired++;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
return expired;
|
|
582
|
+
}
|
|
564
583
|
function isProcessAlive(pid) {
|
|
565
584
|
try {
|
|
566
585
|
process.kill(pid, 0);
|
|
@@ -570,430 +589,33 @@ function isProcessAlive(pid) {
|
|
|
570
589
|
}
|
|
571
590
|
}
|
|
572
591
|
|
|
573
|
-
// src/commands/symphony/index.ts
|
|
574
|
-
async function symphonyJoinCommand(options) {
|
|
575
|
-
const rootDir = process.cwd();
|
|
576
|
-
if (options.remote) {
|
|
577
|
-
console.log(chalk.yellow(`Remote linking to ${options.remote} \u2014 not yet implemented in Phase 0.`));
|
|
578
|
-
console.log(chalk.gray("Remote linking will be available in a future Symphony phase."));
|
|
579
|
-
return;
|
|
580
|
-
}
|
|
581
|
-
const identity = registerAgent(rootDir);
|
|
582
|
-
console.log(chalk.green(`\u2713 Joined as ${chalk.bold(identity.id)}`));
|
|
583
|
-
const sessions = discoverClaudeCodeSessions();
|
|
584
|
-
const others = sessions.filter((s) => s.id !== identity.id);
|
|
585
|
-
if (others.length > 0) {
|
|
586
|
-
console.log(chalk.cyan(`
|
|
587
|
-
Found ${others.length} other session${others.length !== 1 ? "s" : ""}:`));
|
|
588
|
-
for (const s of others) {
|
|
589
|
-
const status = isAgentAsleep(s) ? chalk.yellow("asleep") : chalk.green("awake");
|
|
590
|
-
console.log(` ${chalk.white(s.id)} \u2014 ${s.name} [${status}]`);
|
|
591
|
-
}
|
|
592
|
-
} else {
|
|
593
|
-
console.log(chalk.gray('\n No other sessions found. Open another terminal and run "paradigm symphony join".'));
|
|
594
|
-
}
|
|
595
|
-
console.log(chalk.gray(`
|
|
596
|
-
Tip: Set up polling with: /loop 10s paradigm_symphony_poll`));
|
|
597
|
-
}
|
|
598
|
-
async function symphonyLeaveCommand() {
|
|
599
|
-
const rootDir = process.cwd();
|
|
600
|
-
const agentId = resolveAgentIdentity(rootDir);
|
|
601
|
-
const success = unregisterAgent(agentId);
|
|
602
|
-
if (success) {
|
|
603
|
-
console.log(chalk.green(`\u2713 Left the score: ${agentId}`));
|
|
604
|
-
} else {
|
|
605
|
-
console.log(chalk.yellow(`No active part found for this project.`));
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
async function symphonyWhoamiCommand() {
|
|
609
|
-
const rootDir = process.cwd();
|
|
610
|
-
const identity = getMyIdentity(rootDir);
|
|
611
|
-
if (!identity) {
|
|
612
|
-
console.log(chalk.yellow('Not joined. Run "paradigm symphony join" first.'));
|
|
613
|
-
return;
|
|
614
|
-
}
|
|
615
|
-
const agents = listAgents();
|
|
616
|
-
const others = agents.filter((a) => a.id !== identity.id);
|
|
617
|
-
const threads = listThreads("active");
|
|
618
|
-
const unread = readInbox(identity.id);
|
|
619
|
-
console.log(chalk.cyan(`
|
|
620
|
-
${chalk.bold(identity.id)}`));
|
|
621
|
-
console.log(chalk.gray(` Project: ${identity.project}`));
|
|
622
|
-
console.log(chalk.gray(` Role: ${identity.role}`));
|
|
623
|
-
console.log(chalk.gray(` PID: ${identity.pid}`));
|
|
624
|
-
console.log(chalk.gray(` Started: ${identity.startedAt}`));
|
|
625
|
-
console.log(`
|
|
626
|
-
${chalk.white(`${others.length} linked peer${others.length !== 1 ? "s" : ""}`)} \u2014 ${chalk.white(`${threads.length} active thread${threads.length !== 1 ? "s" : ""}`)} \u2014 ${chalk.white(`${unread.length} unread`)}`);
|
|
627
|
-
}
|
|
628
|
-
async function symphonyListCommand(options) {
|
|
629
|
-
cleanStaleAgents();
|
|
630
|
-
const agents = listAgents();
|
|
631
|
-
if (options.json) {
|
|
632
|
-
console.log(JSON.stringify(agents, null, 2));
|
|
633
|
-
return;
|
|
634
|
-
}
|
|
635
|
-
if (agents.length === 0) {
|
|
636
|
-
console.log(chalk.yellow('No agents joined. Run "paradigm symphony join" in each terminal.'));
|
|
637
|
-
return;
|
|
638
|
-
}
|
|
639
|
-
console.log(chalk.cyan(`
|
|
640
|
-
Symphony Agents (${agents.length})
|
|
641
|
-
`));
|
|
642
|
-
console.log(chalk.gray(` ${"AGENT ID".padEnd(30)} ${"PROJECT".padEnd(15)} ${"ROLE".padEnd(10)} STATUS`));
|
|
643
|
-
console.log(chalk.gray(` ${"\u2500".repeat(30)} ${"\u2500".repeat(15)} ${"\u2500".repeat(10)} ${"\u2500".repeat(8)}`));
|
|
644
|
-
for (const agent of agents) {
|
|
645
|
-
const status = isAgentAsleep(agent) ? chalk.yellow("asleep") : chalk.green("awake");
|
|
646
|
-
console.log(` ${chalk.white(agent.id.padEnd(30))} ${agent.project.padEnd(15)} ${agent.role.padEnd(10)} ${status}`);
|
|
647
|
-
}
|
|
648
|
-
console.log();
|
|
649
|
-
}
|
|
650
|
-
async function symphonySendCommand(messageText, options) {
|
|
651
|
-
const rootDir = process.cwd();
|
|
652
|
-
let identity = getMyIdentity(rootDir);
|
|
653
|
-
if (!identity) {
|
|
654
|
-
identity = registerAgent(rootDir);
|
|
655
|
-
console.log(chalk.gray(`Auto-joined as ${identity.id}`));
|
|
656
|
-
}
|
|
657
|
-
const sender = {
|
|
658
|
-
id: identity.id,
|
|
659
|
-
name: identity.name,
|
|
660
|
-
type: "human",
|
|
661
|
-
// CLI notes come from the human
|
|
662
|
-
project: identity.project,
|
|
663
|
-
role: identity.role
|
|
664
|
-
};
|
|
665
|
-
let recipients;
|
|
666
|
-
if (options.to) {
|
|
667
|
-
recipients = [{ id: options.to, name: options.to, type: "agent" }];
|
|
668
|
-
}
|
|
669
|
-
let threadRoot = options.thread;
|
|
670
|
-
if (!threadRoot) {
|
|
671
|
-
const topic = messageText.length > 60 ? messageText.slice(0, 60) + "..." : messageText;
|
|
672
|
-
const thread = createThread(topic, sender);
|
|
673
|
-
threadRoot = thread.id;
|
|
674
|
-
}
|
|
675
|
-
const message = buildMessage({
|
|
676
|
-
sender,
|
|
677
|
-
recipients,
|
|
678
|
-
intent: "context",
|
|
679
|
-
text: messageText,
|
|
680
|
-
threadRoot
|
|
681
|
-
});
|
|
682
|
-
const deliveryCount = routeMessage(message);
|
|
683
|
-
console.log(chalk.green(`\u2713 Sent to ${deliveryCount} agent${deliveryCount !== 1 ? "s" : ""}`));
|
|
684
|
-
console.log(chalk.gray(` Thread: ${threadRoot}`));
|
|
685
|
-
console.log(chalk.gray(` Note: ${message.id}`));
|
|
686
|
-
}
|
|
687
|
-
async function symphonyReadCommand() {
|
|
688
|
-
const rootDir = process.cwd();
|
|
689
|
-
const identity = getMyIdentity(rootDir);
|
|
690
|
-
if (!identity) {
|
|
691
|
-
console.log(chalk.yellow('Not joined. Run "paradigm symphony join" first.'));
|
|
692
|
-
return;
|
|
693
|
-
}
|
|
694
|
-
markAgentPollTime(identity.id);
|
|
695
|
-
const messages = readInbox(identity.id);
|
|
696
|
-
if (messages.length === 0) {
|
|
697
|
-
console.log(chalk.gray("\n No unread notes.\n"));
|
|
698
|
-
return;
|
|
699
|
-
}
|
|
700
|
-
const byThread = /* @__PURE__ */ new Map();
|
|
701
|
-
for (const msg of messages) {
|
|
702
|
-
const tid = msg.threadRoot || "direct";
|
|
703
|
-
if (!byThread.has(tid)) byThread.set(tid, []);
|
|
704
|
-
byThread.get(tid).push(msg);
|
|
705
|
-
}
|
|
706
|
-
console.log(chalk.cyan(`
|
|
707
|
-
${messages.length} unread note${messages.length !== 1 ? "s" : ""}
|
|
708
|
-
`));
|
|
709
|
-
for (const [threadId, msgs] of byThread) {
|
|
710
|
-
let threadLabel = threadId;
|
|
711
|
-
if (threadId !== "direct") {
|
|
712
|
-
const thread = loadThread(threadId);
|
|
713
|
-
if (thread) threadLabel = `${thread.topic} (${threadId})`;
|
|
714
|
-
}
|
|
715
|
-
console.log(chalk.white(` \u250C\u2500 ${threadLabel}`));
|
|
716
|
-
for (let i = 0; i < msgs.length; i++) {
|
|
717
|
-
const msg = msgs[i];
|
|
718
|
-
const isLast = i === msgs.length - 1;
|
|
719
|
-
const prefix = isLast ? " \u2514\u2500" : " \u251C\u2500";
|
|
720
|
-
const time = new Date(msg.timestamp).toLocaleTimeString(void 0, { hour: "numeric", minute: "2-digit" });
|
|
721
|
-
console.log(`${prefix} ${chalk.cyan(msg.sender.name)} ${chalk.gray(`[${msg.intent}]`)} ${chalk.gray(time)}`);
|
|
722
|
-
const textLines = msg.content.text.split("\n");
|
|
723
|
-
const indent = isLast ? " " : " \u2502 ";
|
|
724
|
-
for (const line of textLines) {
|
|
725
|
-
console.log(`${indent}${line}`);
|
|
726
|
-
}
|
|
727
|
-
if (msg.symbols.length > 0) {
|
|
728
|
-
console.log(`${indent}${chalk.gray(`Symbols: ${msg.symbols.join(", ")}`)}`);
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
console.log();
|
|
732
|
-
}
|
|
733
|
-
const lastId = messages[messages.length - 1].id;
|
|
734
|
-
acknowledgeMessages(identity.id, lastId);
|
|
735
|
-
garbageCollect(identity.id);
|
|
736
|
-
}
|
|
737
|
-
async function symphonyThreadsCommand(options) {
|
|
738
|
-
const threads = listThreads();
|
|
739
|
-
if (options.json) {
|
|
740
|
-
console.log(JSON.stringify(threads, null, 2));
|
|
741
|
-
return;
|
|
742
|
-
}
|
|
743
|
-
if (threads.length === 0) {
|
|
744
|
-
console.log(chalk.gray("\n No threads.\n"));
|
|
745
|
-
return;
|
|
746
|
-
}
|
|
747
|
-
console.log(chalk.cyan(`
|
|
748
|
-
Threads (${threads.length})
|
|
749
|
-
`));
|
|
750
|
-
console.log(chalk.gray(` ${"ID".padEnd(14)} ${"TOPIC".padEnd(35)} ${"MSGS".padEnd(6)} ${"STATUS".padEnd(10)} LAST ACTIVITY`));
|
|
751
|
-
console.log(chalk.gray(` ${"\u2500".repeat(14)} ${"\u2500".repeat(35)} ${"\u2500".repeat(6)} ${"\u2500".repeat(10)} ${"\u2500".repeat(20)}`));
|
|
752
|
-
for (const thread of threads) {
|
|
753
|
-
const topic = thread.topic.length > 33 ? thread.topic.slice(0, 33) + ".." : thread.topic;
|
|
754
|
-
const status = thread.status === "active" ? chalk.green("active") : chalk.gray("resolved");
|
|
755
|
-
const lastAct = new Date(thread.lastActivity).toLocaleString(void 0, {
|
|
756
|
-
month: "short",
|
|
757
|
-
day: "numeric",
|
|
758
|
-
hour: "numeric",
|
|
759
|
-
minute: "2-digit"
|
|
760
|
-
});
|
|
761
|
-
console.log(` ${chalk.white(thread.id.padEnd(14))} ${topic.padEnd(35)} ${String(thread.messageCount).padEnd(6)} ${status.padEnd(10)} ${chalk.gray(lastAct)}`);
|
|
762
|
-
}
|
|
763
|
-
console.log();
|
|
764
|
-
}
|
|
765
|
-
async function symphonyThreadCommand(threadId) {
|
|
766
|
-
const thread = loadThread(threadId);
|
|
767
|
-
if (!thread) {
|
|
768
|
-
console.log(chalk.red(`Thread not found: ${threadId}`));
|
|
769
|
-
return;
|
|
770
|
-
}
|
|
771
|
-
const messages = getThreadMessages(threadId);
|
|
772
|
-
console.log(chalk.cyan(`
|
|
773
|
-
Thread: ${thread.topic}`));
|
|
774
|
-
console.log(chalk.gray(` ID: ${thread.id} | Status: ${thread.status} | Notes: ${thread.messageCount}`));
|
|
775
|
-
console.log(chalk.gray(` Participants: ${thread.participants.map((p) => p.name).join(", ")}`));
|
|
776
|
-
if (thread.decision) {
|
|
777
|
-
console.log(chalk.green(` Decision: ${thread.decision}`));
|
|
778
|
-
}
|
|
779
|
-
console.log(chalk.gray(`
|
|
780
|
-
${"\u2500".repeat(60)}
|
|
781
|
-
`));
|
|
782
|
-
for (const msg of messages) {
|
|
783
|
-
const time = new Date(msg.timestamp).toLocaleString(void 0, {
|
|
784
|
-
month: "short",
|
|
785
|
-
day: "numeric",
|
|
786
|
-
hour: "numeric",
|
|
787
|
-
minute: "2-digit"
|
|
788
|
-
});
|
|
789
|
-
console.log(` ${chalk.cyan(msg.sender.name)} ${chalk.gray(`[${msg.intent}]`)} ${chalk.gray(time)}`);
|
|
790
|
-
const textLines = msg.content.text.split("\n");
|
|
791
|
-
for (const line of textLines) {
|
|
792
|
-
console.log(` ${line}`);
|
|
793
|
-
}
|
|
794
|
-
if (msg.symbols.length > 0) {
|
|
795
|
-
console.log(` ${chalk.gray(`Symbols: ${msg.symbols.join(", ")}`)}`);
|
|
796
|
-
}
|
|
797
|
-
if (msg.content.decision) {
|
|
798
|
-
console.log(` ${chalk.green(`Decision: ${msg.content.decision}`)}`);
|
|
799
|
-
}
|
|
800
|
-
console.log();
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
async function symphonyResolveCommand(threadId, options) {
|
|
804
|
-
const thread = loadThread(threadId);
|
|
805
|
-
if (!thread) {
|
|
806
|
-
console.log(chalk.red(`Thread not found: ${threadId}`));
|
|
807
|
-
return;
|
|
808
|
-
}
|
|
809
|
-
const success = resolveThread(threadId, options.decision);
|
|
810
|
-
if (success) {
|
|
811
|
-
console.log(chalk.green(`\u2713 Thread resolved: ${thread.topic}`));
|
|
812
|
-
if (options.decision) {
|
|
813
|
-
console.log(chalk.gray(` Decision: ${options.decision}`));
|
|
814
|
-
}
|
|
815
|
-
console.log(chalk.gray(` Tip: Record this as lore with "paradigm lore record --title 'Thread: ${thread.topic}'"`));
|
|
816
|
-
} else {
|
|
817
|
-
console.log(chalk.red("Failed to resolve thread."));
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
async function symphonyStatusCommand(options) {
|
|
821
|
-
cleanStaleAgents();
|
|
822
|
-
const rootDir = process.cwd();
|
|
823
|
-
const identity = getMyIdentity(rootDir);
|
|
824
|
-
const agents = listAgents();
|
|
825
|
-
const threads = listThreads("active");
|
|
826
|
-
const pendingRequests = listFileRequests("pending");
|
|
827
|
-
const unread = identity ? readInbox(identity.id) : [];
|
|
828
|
-
if (options.json) {
|
|
829
|
-
console.log(JSON.stringify({
|
|
830
|
-
identity: identity ? { id: identity.id, project: identity.project, role: identity.role } : null,
|
|
831
|
-
agents: agents.map((a) => ({ id: a.id, status: isAgentAsleep(a) ? "asleep" : "awake" })),
|
|
832
|
-
activeThreads: threads.length,
|
|
833
|
-
unreadMessages: unread.length,
|
|
834
|
-
pendingFileRequests: pendingRequests.length
|
|
835
|
-
}, null, 2));
|
|
836
|
-
return;
|
|
837
|
-
}
|
|
838
|
-
console.log(chalk.cyan("\n Symphony Status\n"));
|
|
839
|
-
if (identity) {
|
|
840
|
-
console.log(` ${chalk.white("Identity:")} ${identity.id}`);
|
|
841
|
-
} else {
|
|
842
|
-
console.log(` ${chalk.yellow("Not joined.")} Run "paradigm symphony join" to join.`);
|
|
843
|
-
}
|
|
844
|
-
const awake = agents.filter((a) => !isAgentAsleep(a)).length;
|
|
845
|
-
console.log(` ${chalk.white("Agents:")} ${agents.length} joined (${awake} awake)`);
|
|
846
|
-
console.log(` ${chalk.white("Threads:")} ${threads.length} active`);
|
|
847
|
-
console.log(` ${chalk.white("Unread:")} ${unread.length} note${unread.length !== 1 ? "s" : ""}`);
|
|
848
|
-
console.log(` ${chalk.white("File Requests:")} ${pendingRequests.length} pending`);
|
|
849
|
-
console.log();
|
|
850
|
-
}
|
|
851
|
-
async function symphonyServeCommand(options) {
|
|
852
|
-
const port = parseInt(options.port || "3939", 10);
|
|
853
|
-
console.log(chalk.cyan(`
|
|
854
|
-
Starting Symphony TCP server on port ${port}...`));
|
|
855
|
-
console.log(chalk.gray(" Phase 0 stub \u2014 remote linking protocol not yet implemented.\n"));
|
|
856
|
-
const server = net.createServer((socket) => {
|
|
857
|
-
socket.write(JSON.stringify({ type: "hello", version: "0.1.0" }) + "\n");
|
|
858
|
-
socket.on("data", (data) => {
|
|
859
|
-
try {
|
|
860
|
-
const msg = JSON.parse(data.toString().trim());
|
|
861
|
-
socket.write(JSON.stringify({ type: "ack", received: msg.type }) + "\n");
|
|
862
|
-
} catch {
|
|
863
|
-
socket.write(JSON.stringify({ type: "error", message: "Invalid JSON" }) + "\n");
|
|
864
|
-
}
|
|
865
|
-
});
|
|
866
|
-
socket.on("error", () => {
|
|
867
|
-
});
|
|
868
|
-
});
|
|
869
|
-
server.listen(port, "0.0.0.0", () => {
|
|
870
|
-
console.log(chalk.green(` \u2713 Symphony server listening on 0.0.0.0:${port}`));
|
|
871
|
-
console.log(chalk.gray(` Connect from another machine: paradigm symphony join --remote <this-ip>:${port}`));
|
|
872
|
-
});
|
|
873
|
-
server.on("error", (err) => {
|
|
874
|
-
console.log(chalk.red(` Failed to start server: ${err.message}`));
|
|
875
|
-
});
|
|
876
|
-
await new Promise(() => {
|
|
877
|
-
});
|
|
878
|
-
}
|
|
879
|
-
async function symphonyRequestCommand(file, options) {
|
|
880
|
-
const rootDir = process.cwd();
|
|
881
|
-
let identity = getMyIdentity(rootDir);
|
|
882
|
-
if (!identity) {
|
|
883
|
-
identity = registerAgent(rootDir);
|
|
884
|
-
}
|
|
885
|
-
const from = options.from;
|
|
886
|
-
const reason = options.reason || "Needed for current task";
|
|
887
|
-
if (!from) {
|
|
888
|
-
console.log(chalk.red("--from is required. Specify which agent to request from."));
|
|
889
|
-
const agents = listAgents().filter((a) => a.id !== identity.id);
|
|
890
|
-
if (agents.length > 0) {
|
|
891
|
-
console.log(chalk.gray("\nAvailable agents:"));
|
|
892
|
-
for (const a of agents) {
|
|
893
|
-
console.log(chalk.gray(` ${a.id}`));
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
return;
|
|
897
|
-
}
|
|
898
|
-
const trust = loadTrustConfig();
|
|
899
|
-
if (isPathDenied(file, trust)) {
|
|
900
|
-
console.log(chalk.red(`\u2717 "${file}" is on the hard-deny list and cannot be requested.`));
|
|
901
|
-
return;
|
|
902
|
-
}
|
|
903
|
-
const record = createFileRequest({
|
|
904
|
-
filePath: file,
|
|
905
|
-
requester: {
|
|
906
|
-
id: identity.id,
|
|
907
|
-
name: identity.name,
|
|
908
|
-
type: "agent",
|
|
909
|
-
project: identity.project,
|
|
910
|
-
role: identity.role
|
|
911
|
-
},
|
|
912
|
-
reason
|
|
913
|
-
});
|
|
914
|
-
const msg = buildMessage({
|
|
915
|
-
sender: {
|
|
916
|
-
id: identity.id,
|
|
917
|
-
name: identity.name,
|
|
918
|
-
type: "agent",
|
|
919
|
-
project: identity.project,
|
|
920
|
-
role: identity.role
|
|
921
|
-
},
|
|
922
|
-
recipients: [{ id: from, name: from, type: "agent" }],
|
|
923
|
-
intent: "fileRequest",
|
|
924
|
-
text: `File request: ${file}
|
|
925
|
-
Reason: ${reason}`,
|
|
926
|
-
symbols: []
|
|
927
|
-
});
|
|
928
|
-
routeMessage(msg);
|
|
929
|
-
console.log(chalk.green(`\u2713 File request created: ${record.request.requestId}`));
|
|
930
|
-
console.log(chalk.gray(` File: ${file}`));
|
|
931
|
-
console.log(chalk.gray(` From: ${from}`));
|
|
932
|
-
console.log(chalk.gray(` Reason: ${reason}`));
|
|
933
|
-
console.log(chalk.gray(`
|
|
934
|
-
The owning agent's human must approve with:`));
|
|
935
|
-
console.log(chalk.white(` paradigm symphony approve ${record.request.requestId}`));
|
|
936
|
-
}
|
|
937
|
-
async function symphonyRequestsCommand() {
|
|
938
|
-
const requests = listFileRequests("pending");
|
|
939
|
-
if (requests.length === 0) {
|
|
940
|
-
console.log(chalk.gray("\n No pending file requests.\n"));
|
|
941
|
-
return;
|
|
942
|
-
}
|
|
943
|
-
console.log(chalk.cyan(`
|
|
944
|
-
Pending File Requests (${requests.length})
|
|
945
|
-
`));
|
|
946
|
-
for (const req of requests) {
|
|
947
|
-
const age = Date.now() - new Date(req.createdAt).getTime();
|
|
948
|
-
const ageMin = Math.round(age / 6e4);
|
|
949
|
-
console.log(` ${chalk.white(req.request.requestId)}`);
|
|
950
|
-
console.log(` File: ${req.request.filePath}`);
|
|
951
|
-
console.log(` From: ${req.request.requester.name} (${req.request.requester.id})`);
|
|
952
|
-
console.log(` Reason: ${req.request.reason}`);
|
|
953
|
-
console.log(chalk.gray(` ${ageMin}m ago`));
|
|
954
|
-
console.log(chalk.gray(` \u2192 paradigm symphony approve ${req.request.requestId}`));
|
|
955
|
-
console.log(chalk.gray(` \u2192 paradigm symphony deny ${req.request.requestId}`));
|
|
956
|
-
console.log();
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
async function symphonyApproveCommand(requestId, options) {
|
|
960
|
-
const rootDir = process.cwd();
|
|
961
|
-
const result = approveFileRequest(requestId, rootDir, options.redact);
|
|
962
|
-
if (!result.success) {
|
|
963
|
-
console.log(chalk.red(`\u2717 ${result.error}`));
|
|
964
|
-
return;
|
|
965
|
-
}
|
|
966
|
-
const label = options.redact ? "approved (redacted)" : "approved";
|
|
967
|
-
console.log(chalk.green(`\u2713 File request ${label}`));
|
|
968
|
-
console.log(chalk.gray(` File: ${result.delivery?.filePath}`));
|
|
969
|
-
console.log(chalk.gray(` Size: ${result.delivery?.size} bytes`));
|
|
970
|
-
console.log(chalk.gray(` SHA-256: ${result.delivery?.hash?.slice(0, 16)}...`));
|
|
971
|
-
}
|
|
972
|
-
async function symphonyDenyCommand(requestId, options) {
|
|
973
|
-
const success = denyFileRequest(requestId, options.reason);
|
|
974
|
-
if (success) {
|
|
975
|
-
console.log(chalk.green(`\u2713 File request denied: ${requestId}`));
|
|
976
|
-
if (options.reason) {
|
|
977
|
-
console.log(chalk.gray(` Reason: ${options.reason}`));
|
|
978
|
-
}
|
|
979
|
-
} else {
|
|
980
|
-
console.log(chalk.red(`\u2717 File request not found or already resolved: ${requestId}`));
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
592
|
export {
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
593
|
+
resolveAgentIdentity,
|
|
594
|
+
registerAgent,
|
|
595
|
+
unregisterAgent,
|
|
596
|
+
listAgents,
|
|
597
|
+
cleanStaleAgents,
|
|
598
|
+
getMyIdentity,
|
|
599
|
+
markAgentPollTime,
|
|
600
|
+
isAgentAsleep,
|
|
601
|
+
discoverClaudeCodeSessions,
|
|
602
|
+
appendToInbox,
|
|
603
|
+
readInbox,
|
|
604
|
+
readOutbox,
|
|
605
|
+
acknowledgeMessages,
|
|
606
|
+
garbageCollect,
|
|
607
|
+
createThread,
|
|
608
|
+
loadThread,
|
|
609
|
+
listThreads,
|
|
610
|
+
resolveThread,
|
|
611
|
+
getThreadMessages,
|
|
612
|
+
buildMessage,
|
|
613
|
+
routeMessage,
|
|
614
|
+
loadTrustConfig,
|
|
615
|
+
createFileRequest,
|
|
616
|
+
listFileRequests,
|
|
617
|
+
approveFileRequest,
|
|
618
|
+
denyFileRequest,
|
|
619
|
+
isPathDenied,
|
|
620
|
+
expireOldRequests
|
|
999
621
|
};
|
|
@@ -413,7 +413,7 @@ function enableSentinel(logger, clientOrOptions) {
|
|
|
413
413
|
return transport;
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
-
// ../sentinel/dist/chunk-
|
|
416
|
+
// ../sentinel/dist/chunk-OKYYIAML.js
|
|
417
417
|
import initSqlJs from "sql.js";
|
|
418
418
|
import { v4 as uuidv42 } from "uuid";
|
|
419
419
|
import * as path from "path";
|
|
@@ -1011,6 +1011,19 @@ var SentinelStorage = class {
|
|
|
1011
1011
|
);
|
|
1012
1012
|
this.save();
|
|
1013
1013
|
}
|
|
1014
|
+
resolveIncident(id, options) {
|
|
1015
|
+
this.updateIncident(id, {
|
|
1016
|
+
status: "resolved",
|
|
1017
|
+
resolvedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1018
|
+
});
|
|
1019
|
+
if (options?.notes) {
|
|
1020
|
+
this.addIncidentNote(id, {
|
|
1021
|
+
author: "system",
|
|
1022
|
+
content: options.notes,
|
|
1023
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1014
1027
|
addIncidentNote(incidentId, note) {
|
|
1015
1028
|
this.initializeSync();
|
|
1016
1029
|
const incident = this.getIncident(incidentId);
|