@a-company/paradigm 5.3.3 → 5.5.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.
@@ -13,8 +13,8 @@ import "./chunk-PDX44BCA.js";
13
13
  // src/platform-server/index.ts
14
14
  import express from "express";
15
15
  import * as http from "http";
16
- import * as path3 from "path";
17
- import * as fs3 from "fs";
16
+ import * as path4 from "path";
17
+ import * as fs4 from "fs";
18
18
  import { fileURLToPath } from "url";
19
19
  import chalk from "chalk";
20
20
 
@@ -950,9 +950,156 @@ function createAmbientRouter(projectDir, wsContext) {
950
950
  return router;
951
951
  }
952
952
 
953
+ // src/platform-server/routes/team.ts
954
+ import { Router as Router4 } from "express";
955
+ import * as fs3 from "fs";
956
+ import * as path3 from "path";
957
+ import * as os from "os";
958
+ import * as yaml3 from "js-yaml";
959
+ function readJsonl(filePath) {
960
+ if (!fs3.existsSync(filePath)) return [];
961
+ try {
962
+ return fs3.readFileSync(filePath, "utf-8").trim().split("\n").filter((line) => line.trim()).map((line) => {
963
+ try {
964
+ return JSON.parse(line);
965
+ } catch {
966
+ return null;
967
+ }
968
+ }).filter((v) => v !== null);
969
+ } catch {
970
+ return [];
971
+ }
972
+ }
973
+ function loadAgentProfiles() {
974
+ const globalDir = path3.join(os.homedir(), ".paradigm", "agents");
975
+ const profiles = [];
976
+ if (!fs3.existsSync(globalDir)) return profiles;
977
+ for (const file of fs3.readdirSync(globalDir).filter((f) => f.endsWith(".agent"))) {
978
+ try {
979
+ const content = fs3.readFileSync(path3.join(globalDir, file), "utf-8");
980
+ const p = yaml3.load(content);
981
+ if (!p?.id) continue;
982
+ const expertise = p.expertise || [];
983
+ expertise.sort((a, b) => b.confidence - a.confidence);
984
+ profiles.push({
985
+ id: p.id,
986
+ role: p.role || p.id,
987
+ nickname: p.nickname,
988
+ benched: p.benched || false,
989
+ expertiseCount: expertise.length,
990
+ topExpertise: expertise.slice(0, 3).map((e) => ({
991
+ symbol: e.symbol,
992
+ confidence: parseFloat(e.confidence.toFixed(2))
993
+ })),
994
+ threshold: p.attention?.threshold
995
+ });
996
+ } catch {
997
+ }
998
+ }
999
+ return profiles;
1000
+ }
1001
+ function loadTeamThreads() {
1002
+ const mailDir = path3.join(os.homedir(), ".paradigm", "mail", "agents");
1003
+ if (!fs3.existsSync(mailDir)) return [];
1004
+ const allMessages = [];
1005
+ try {
1006
+ for (const agentDir of fs3.readdirSync(mailDir, { withFileTypes: true })) {
1007
+ if (!agentDir.isDirectory()) continue;
1008
+ const agentPath = path3.join(mailDir, agentDir.name);
1009
+ for (const file of ["inbox.jsonl", "outbox.jsonl"]) {
1010
+ const filePath = path3.join(agentPath, file);
1011
+ const notes = readJsonl(filePath);
1012
+ for (const note of notes) {
1013
+ if (!note.threadRoot?.startsWith("thr-orch-")) continue;
1014
+ if (allMessages.some((m) => m.id === note.id)) continue;
1015
+ allMessages.push({
1016
+ id: note.id,
1017
+ threadRoot: note.threadRoot,
1018
+ timestamp: note.timestamp,
1019
+ sender: {
1020
+ name: note.sender?.name || "unknown",
1021
+ role: note.sender?.role,
1022
+ project: note.sender?.project
1023
+ },
1024
+ intent: note.intent || "context",
1025
+ text: note.content?.text || "",
1026
+ symbols: note.symbols || [],
1027
+ diff: note.content?.diff,
1028
+ decision: note.content?.decision
1029
+ });
1030
+ }
1031
+ }
1032
+ }
1033
+ } catch {
1034
+ }
1035
+ const threadMap = /* @__PURE__ */ new Map();
1036
+ for (const msg of allMessages) {
1037
+ const threadId = msg.threadRoot;
1038
+ if (!threadMap.has(threadId)) threadMap.set(threadId, []);
1039
+ threadMap.get(threadId).push(msg);
1040
+ }
1041
+ const threads = [];
1042
+ for (const [threadId, messages] of threadMap) {
1043
+ messages.sort((a, b) => a.timestamp.localeCompare(b.timestamp));
1044
+ const stripped = threadId.replace("thr-orch-", "");
1045
+ const parts = stripped.split("-");
1046
+ const displayName = parts[0] ? `Team ${parts[0]}` : threadId;
1047
+ threads.push({
1048
+ id: threadId,
1049
+ displayName,
1050
+ messages,
1051
+ lastActivity: messages[messages.length - 1]?.timestamp || ""
1052
+ });
1053
+ }
1054
+ threads.sort((a, b) => b.lastActivity.localeCompare(a.lastActivity));
1055
+ return threads;
1056
+ }
1057
+ function createTeamRouter(projectDir) {
1058
+ const router = Router4();
1059
+ router.get("/roster", (_req, res) => {
1060
+ try {
1061
+ const agents = loadAgentProfiles();
1062
+ const active = agents.filter((a) => !a.benched);
1063
+ const benched = agents.filter((a) => a.benched);
1064
+ res.json({ active, benched, total: agents.length });
1065
+ } catch (err) {
1066
+ res.status(500).json({ error: "Failed to load roster", detail: String(err) });
1067
+ }
1068
+ });
1069
+ router.get("/threads", (_req, res) => {
1070
+ try {
1071
+ const threads = loadTeamThreads();
1072
+ res.json({ threads, count: threads.length });
1073
+ } catch (err) {
1074
+ res.status(500).json({ error: "Failed to load threads", detail: String(err) });
1075
+ }
1076
+ });
1077
+ router.patch("/agents/:id/bench", (req, res) => {
1078
+ try {
1079
+ const { id } = req.params;
1080
+ const { benched } = req.body;
1081
+ const globalDir = path3.join(os.homedir(), ".paradigm", "agents");
1082
+ const filePath = path3.join(globalDir, `${id}.agent`);
1083
+ if (!fs3.existsSync(filePath)) {
1084
+ res.status(404).json({ error: `Agent "${id}" not found` });
1085
+ return;
1086
+ }
1087
+ const content = fs3.readFileSync(filePath, "utf-8");
1088
+ const profile = yaml3.load(content);
1089
+ profile.benched = benched;
1090
+ profile.updated = (/* @__PURE__ */ new Date()).toISOString();
1091
+ fs3.writeFileSync(filePath, yaml3.dump(profile, { lineWidth: 120, noRefs: true, sortKeys: false }), "utf-8");
1092
+ res.json({ id, benched, updated: profile.updated });
1093
+ } catch (err) {
1094
+ res.status(500).json({ error: "Failed to update agent", detail: String(err) });
1095
+ }
1096
+ });
1097
+ return router;
1098
+ }
1099
+
953
1100
  // src/platform-server/index.ts
954
1101
  var __filename = fileURLToPath(import.meta.url);
955
- var __dirname = path3.dirname(__filename);
1102
+ var __dirname = path4.dirname(__filename);
956
1103
  var log = {
957
1104
  component(name) {
958
1105
  const symbol = chalk.magenta(`#${name}`);
@@ -977,7 +1124,7 @@ var log = {
977
1124
  }
978
1125
  };
979
1126
  function resolveSections(options) {
980
- const always = ["overview", "lore", "graph", "git", "ambient"];
1127
+ const always = ["overview", "lore", "graph", "git", "ambient", "team"];
981
1128
  const requested = options.sections ?? [...always, "sentinel", "university", "symphony", "docs"];
982
1129
  const enabled = /* @__PURE__ */ new Set();
983
1130
  for (const section of requested) {
@@ -986,15 +1133,15 @@ function resolveSections(options) {
986
1133
  continue;
987
1134
  }
988
1135
  if (section === "sentinel") {
989
- const sentinelRoutesPath = path3.join(options.projectDir, ".paradigm");
990
- if (fs3.existsSync(sentinelRoutesPath)) {
1136
+ const sentinelRoutesPath = path4.join(options.projectDir, ".paradigm");
1137
+ if (fs4.existsSync(sentinelRoutesPath)) {
991
1138
  enabled.add(section);
992
1139
  }
993
1140
  } else if (section === "university") {
994
1141
  enabled.add(section);
995
1142
  } else if (section === "symphony") {
996
- const mailDir = path3.join(process.env.HOME || "~", ".paradigm", "score");
997
- if (fs3.existsSync(mailDir)) {
1143
+ const mailDir = path4.join(process.env.HOME || "~", ".paradigm", "score");
1144
+ if (fs4.existsSync(mailDir)) {
998
1145
  enabled.add(section);
999
1146
  }
1000
1147
  } else {
@@ -1038,15 +1185,15 @@ function createPlatformApp(options) {
1038
1185
  res.json({ status: "ok", timestamp: (/* @__PURE__ */ new Date()).toISOString() });
1039
1186
  });
1040
1187
  app.set("agentRouterSlot", true);
1041
- let uiDistPath = path3.join(__dirname, "..", "platform-ui", "dist");
1042
- if (!fs3.existsSync(uiDistPath)) {
1043
- uiDistPath = path3.join(__dirname, "..", "..", "platform-ui", "dist");
1188
+ let uiDistPath = path4.join(__dirname, "..", "platform-ui", "dist");
1189
+ if (!fs4.existsSync(uiDistPath)) {
1190
+ uiDistPath = path4.join(__dirname, "..", "..", "platform-ui", "dist");
1044
1191
  }
1045
- if (fs3.existsSync(uiDistPath)) {
1192
+ if (fs4.existsSync(uiDistPath)) {
1046
1193
  app.use(express.static(uiDistPath));
1047
1194
  app.get("{*path}", (req, res, next) => {
1048
1195
  if (!req.path.startsWith("/api")) {
1049
- res.sendFile(path3.join(uiDistPath, "index.html"));
1196
+ res.sendFile(path4.join(uiDistPath, "index.html"));
1050
1197
  } else {
1051
1198
  next();
1052
1199
  }
@@ -1080,6 +1227,7 @@ async function startPlatformServer(options) {
1080
1227
  const wsContext = attachWebSocket(httpServer);
1081
1228
  app.use("/api/platform/agent-command", createAgentRouter(wsContext));
1082
1229
  app.use("/api/ambient", createAmbientRouter(options.projectDir, wsContext));
1230
+ app.use("/api/team", createTeamRouter(options.projectDir));
1083
1231
  if (sections.has("sentinel")) {
1084
1232
  try {
1085
1233
  const { createSentinelBridge } = await import("./sentinel-bridge-MDUXTQRL.js");
@@ -3,9 +3,10 @@ import {
3
3
  getReindexToolsList,
4
4
  handleReindexTool,
5
5
  rebuildStaticFiles
6
- } from "./chunk-S6MZ2IEX.js";
7
- import "./chunk-5VKJBNJL.js";
6
+ } from "./chunk-SU3WDCRR.js";
8
7
  import "./chunk-L27I3CPZ.js";
8
+ import "./chunk-SDDCVUCV.js";
9
+ import "./chunk-5VKJBNJL.js";
9
10
  import "./chunk-7N7GSU6K.js";
10
11
  export {
11
12
  getReindexToolsList,
@@ -10,7 +10,7 @@ async function serveCommand(options) {
10
10
  const sections = options.sections ? options.sections.split(",").map((s) => s.trim()) : void 0;
11
11
  console.log(chalk.cyan("\n Starting Paradigm Platform...\n"));
12
12
  try {
13
- const { startPlatformServer } = await import("./platform-server-PMD57BEG.js");
13
+ const { startPlatformServer } = await import("./platform-server-2D6S6YTK.js");
14
14
  await startPlatformServer({ port, projectDir, open: shouldOpen, sections });
15
15
  console.log(chalk.green(` Platform running at ${chalk.bold(`http://localhost:${port}`)}`));
16
16
  console.log(chalk.gray(" Press Ctrl+C to stop\n"));
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ appendSessionWorkEntry,
4
+ clearSessionWorkLog,
5
+ getAgentEntries,
6
+ getAgentVerdicts,
7
+ getContributingAgents,
8
+ init_session_work_log,
9
+ readSessionWorkLog
10
+ } from "./chunk-SDDCVUCV.js";
11
+ import "./chunk-7N7GSU6K.js";
12
+ init_session_work_log();
13
+ export {
14
+ appendSessionWorkEntry,
15
+ clearSessionWorkLog,
16
+ getAgentEntries,
17
+ getAgentVerdicts,
18
+ getContributingAgents,
19
+ readSessionWorkLog
20
+ };