@mclawnet/agent 0.5.8 → 0.6.1
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/cli.js +168 -61
- package/dist/__tests__/cli.test.d.ts +2 -0
- package/dist/__tests__/cli.test.d.ts.map +1 -0
- package/dist/__tests__/service-config.test.d.ts +2 -0
- package/dist/__tests__/service-config.test.d.ts.map +1 -0
- package/dist/__tests__/service-linux.test.d.ts +2 -0
- package/dist/__tests__/service-linux.test.d.ts.map +1 -0
- package/dist/__tests__/service-macos.test.d.ts +2 -0
- package/dist/__tests__/service-macos.test.d.ts.map +1 -0
- package/dist/__tests__/service-windows.test.d.ts +2 -0
- package/dist/__tests__/service-windows.test.d.ts.map +1 -0
- package/dist/backend-adapter.d.ts +2 -0
- package/dist/backend-adapter.d.ts.map +1 -1
- package/dist/{chunk-KHPEQTWF.js → chunk-KITKMSBE.js} +166 -90
- package/dist/chunk-KITKMSBE.js.map +1 -0
- package/dist/chunk-W3LSW4XY.js +95 -0
- package/dist/chunk-W3LSW4XY.js.map +1 -0
- package/dist/hub-connection.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/linux-5KQ4SCAA.js +175 -0
- package/dist/linux-5KQ4SCAA.js.map +1 -0
- package/dist/macos-FGY546NC.js +173 -0
- package/dist/macos-FGY546NC.js.map +1 -0
- package/dist/service/config.d.ts +19 -0
- package/dist/service/config.d.ts.map +1 -0
- package/dist/service/index.d.ts +6 -0
- package/dist/service/index.d.ts.map +1 -0
- package/dist/service/index.js +46 -0
- package/dist/service/index.js.map +1 -0
- package/dist/service/linux.d.ts +18 -0
- package/dist/service/linux.d.ts.map +1 -0
- package/dist/service/macos.d.ts +18 -0
- package/dist/service/macos.d.ts.map +1 -0
- package/dist/service/types.d.ts +19 -0
- package/dist/service/types.d.ts.map +1 -0
- package/dist/service/windows.d.ts +18 -0
- package/dist/service/windows.d.ts.map +1 -0
- package/dist/session-manager.d.ts +4 -7
- package/dist/session-manager.d.ts.map +1 -1
- package/dist/skill-loader.d.ts +8 -0
- package/dist/skill-loader.d.ts.map +1 -0
- package/dist/start.d.ts.map +1 -1
- package/dist/start.js +1 -1
- package/dist/windows-PIJ4CMWX.js +164 -0
- package/dist/windows-PIJ4CMWX.js.map +1 -0
- package/package.json +18 -16
- package/skills/academic-search/SKILL.md +147 -0
- package/skills/architecture/SKILL.md +294 -0
- package/skills/changelog-generator/SKILL.md +112 -0
- package/skills/chart-visualization/SKILL.md +183 -0
- package/skills/code-review/SKILL.md +304 -0
- package/skills/codebase-health/SKILL.md +281 -0
- package/skills/consulting-analysis/SKILL.md +584 -0
- package/skills/content-research-writer/SKILL.md +546 -0
- package/skills/data-analysis/SKILL.md +194 -0
- package/skills/deep-research/SKILL.md +198 -0
- package/skills/docx/SKILL.md +211 -0
- package/skills/github-deep-research/SKILL.md +207 -0
- package/skills/image-generation/SKILL.md +209 -0
- package/skills/lead-research-assistant/SKILL.md +207 -0
- package/skills/mcp-builder/SKILL.md +304 -0
- package/skills/meeting-insights-analyzer/SKILL.md +335 -0
- package/skills/pair-programming/SKILL.md +196 -0
- package/skills/pdf/SKILL.md +309 -0
- package/skills/performance-analysis/SKILL.md +261 -0
- package/skills/podcast-generation/SKILL.md +224 -0
- package/skills/pptx/SKILL.md +497 -0
- package/skills/project-learnings/SKILL.md +280 -0
- package/skills/security-audit/SKILL.md +211 -0
- package/skills/skill-creator/SKILL.md +200 -0
- package/skills/technical-writing/SKILL.md +286 -0
- package/skills/testing/SKILL.md +363 -0
- package/skills/video-generation/SKILL.md +247 -0
- package/skills/web-design-guidelines/SKILL.md +203 -0
- package/skills/webapp-testing/SKILL.md +162 -0
- package/skills/workflow-automation/SKILL.md +299 -0
- package/skills/xlsx/SKILL.md +305 -0
- package/dist/chunk-KHPEQTWF.js.map +0 -1
|
@@ -95,7 +95,7 @@ import {
|
|
|
95
95
|
MAX_RECONNECT_MS,
|
|
96
96
|
WS_CLOSE_INVALID_TOKEN
|
|
97
97
|
} from "@mclawnet/shared";
|
|
98
|
-
import { listRecoverableSwarms, recoverSwarm, listRoles, loadRole, listRecoverableSwarmIds, deleteSwarmSnapshot } from "@mclawnet/swarm";
|
|
98
|
+
import { listRecoverableSwarms, recoverSwarm, listRoles, loadRole, listRecoverableSwarmIds, deleteSwarmSnapshot, listTemplates, loadTemplate } from "@mclawnet/swarm";
|
|
99
99
|
|
|
100
100
|
// src/fs-handler.ts
|
|
101
101
|
import { readdir } from "fs/promises";
|
|
@@ -519,9 +519,11 @@ var HubConnection = class {
|
|
|
519
519
|
const def = loadRole(name);
|
|
520
520
|
return {
|
|
521
521
|
name: def.name,
|
|
522
|
-
displayName: def.
|
|
522
|
+
displayName: def.displayName || def.description || def.name,
|
|
523
523
|
description: def.description || "",
|
|
524
524
|
capabilities: def.capabilities || [],
|
|
525
|
+
type: def.type,
|
|
526
|
+
color: def.color,
|
|
525
527
|
promptBody: def.promptBody || ""
|
|
526
528
|
};
|
|
527
529
|
} catch {
|
|
@@ -535,6 +537,35 @@ var HubConnection = class {
|
|
|
535
537
|
});
|
|
536
538
|
return true;
|
|
537
539
|
}
|
|
540
|
+
if (msg.type === "list_templates") {
|
|
541
|
+
log2.info("list_templates");
|
|
542
|
+
try {
|
|
543
|
+
const names = listTemplates();
|
|
544
|
+
const templates = names.map((name) => {
|
|
545
|
+
const tpl = loadTemplate(name);
|
|
546
|
+
return {
|
|
547
|
+
name: tpl.name,
|
|
548
|
+
displayName: tpl.displayName,
|
|
549
|
+
description: tpl.description,
|
|
550
|
+
icon: tpl.icon,
|
|
551
|
+
roles: tpl.roles
|
|
552
|
+
};
|
|
553
|
+
});
|
|
554
|
+
this.send({
|
|
555
|
+
type: "templates_list_result",
|
|
556
|
+
sessionId: msg.sessionId,
|
|
557
|
+
templates
|
|
558
|
+
});
|
|
559
|
+
} catch (err) {
|
|
560
|
+
log2.error({ err }, "list_templates failed");
|
|
561
|
+
this.send({
|
|
562
|
+
type: "templates_list_result",
|
|
563
|
+
sessionId: msg.sessionId,
|
|
564
|
+
templates: []
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
return true;
|
|
568
|
+
}
|
|
538
569
|
if (msg.type === "generic.request") {
|
|
539
570
|
const handler = this.namespaceHandlers.get(msg.namespace);
|
|
540
571
|
if (handler) {
|
|
@@ -590,10 +621,11 @@ var HubConnection = class {
|
|
|
590
621
|
sessionId,
|
|
591
622
|
error: "\u8702\u7FA4\u4EFB\u52A1\u5DF2\u5B8C\u6210\uFF0C\u65E0\u6CD5\u7EE7\u7EED\u64CD\u4F5C\u3002\u8BF7\u521B\u5EFA\u65B0\u7684\u8702\u7FA4\u4EFB\u52A1\u3002"
|
|
592
623
|
});
|
|
593
|
-
} else if (crewConfig?.roles) {
|
|
594
|
-
|
|
624
|
+
} else if (crewConfig?.templateName || crewConfig?.roles) {
|
|
625
|
+
const templateName = crewConfig.templateName;
|
|
595
626
|
const roles = crewConfig.roles;
|
|
596
|
-
|
|
627
|
+
log2.info({ sessionId, templateName, rolesCount: roles?.length }, "swarm.execute: creating new swarm");
|
|
628
|
+
this.swarmCoordinator.create(sessionId, { workDir, templateName, roles, task: content }).catch((err) => {
|
|
597
629
|
this.send({
|
|
598
630
|
type: "session.error",
|
|
599
631
|
sessionId,
|
|
@@ -746,17 +778,14 @@ var HubConnection = class {
|
|
|
746
778
|
};
|
|
747
779
|
|
|
748
780
|
// src/session-manager.ts
|
|
749
|
-
import { writeFileSync as writeFileSync2, unlinkSync } from "fs";
|
|
750
|
-
import { tmpdir } from "os";
|
|
751
|
-
import { join as join3, dirname } from "path";
|
|
752
|
-
import { createRequire } from "module";
|
|
753
781
|
import { createLogger as createLogger3 } from "@mclawnet/logger";
|
|
754
782
|
import { buildMemorySection } from "@mclawnet/memory";
|
|
755
783
|
var log3 = createLogger3({ module: "agent/session-manager" });
|
|
784
|
+
var DEFAULT_MAX_PROCESSES = 10;
|
|
785
|
+
var MAX_PROCESSES = Number(process.env.CLAWNET_MAX_PROCESSES) || DEFAULT_MAX_PROCESSES;
|
|
756
786
|
var SessionManager = class {
|
|
757
787
|
sessions = /* @__PURE__ */ new Map();
|
|
758
788
|
conversationBuffer = /* @__PURE__ */ new Map();
|
|
759
|
-
mcpConfigPaths = /* @__PURE__ */ new Map();
|
|
760
789
|
adapter;
|
|
761
790
|
onOutput;
|
|
762
791
|
onTurnComplete;
|
|
@@ -773,24 +802,22 @@ var SessionManager = class {
|
|
|
773
802
|
if (this.sessions.has(options.sessionId)) {
|
|
774
803
|
throw new Error(`Session ${options.sessionId} already exists`);
|
|
775
804
|
}
|
|
805
|
+
if (this.sessions.size >= MAX_PROCESSES) {
|
|
806
|
+
throw new Error(`Process limit reached (${MAX_PROCESSES}). Cannot create new session.`);
|
|
807
|
+
}
|
|
776
808
|
if (options.roleId) {
|
|
777
809
|
try {
|
|
778
810
|
const memorySection = buildMemorySection(options.roleId);
|
|
779
|
-
|
|
811
|
+
const roleHint = `
|
|
812
|
+
|
|
813
|
+
[Memory Context] Your roleId is "${options.roleId}". Always use this roleId when calling memory_search, memory_store, memory_stats, or memory_reflect.`;
|
|
814
|
+
options.systemPrompt = options.systemPrompt ? `${memorySection}${roleHint}
|
|
780
815
|
|
|
781
|
-
${options.systemPrompt}` : memorySection
|
|
782
|
-
log3.debug({ roleId: options.roleId, sessionId: options.sessionId }, "memory prompt injected");
|
|
816
|
+
${options.systemPrompt}` : `${memorySection}${roleHint}`;
|
|
817
|
+
log3.debug({ roleId: options.roleId, sessionId: options.sessionId }, "memory prompt + roleId hint injected");
|
|
783
818
|
} catch (err) {
|
|
784
819
|
log3.warn({ err, roleId: options.roleId }, "failed to build memory section, proceeding without");
|
|
785
820
|
}
|
|
786
|
-
if (!options.mcpConfigPath) {
|
|
787
|
-
try {
|
|
788
|
-
options.mcpConfigPath = this.createMemoryMcpConfig(options.sessionId, options.roleId);
|
|
789
|
-
log3.debug({ roleId: options.roleId, sessionId: options.sessionId }, "memory MCP config created");
|
|
790
|
-
} catch (err) {
|
|
791
|
-
log3.warn({ err, roleId: options.roleId }, "failed to create memory MCP config, proceeding without");
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
821
|
}
|
|
795
822
|
try {
|
|
796
823
|
const process2 = await this.adapter.spawn(options);
|
|
@@ -832,7 +859,6 @@ ${options.systemPrompt}` : memorySection;
|
|
|
832
859
|
const process2 = this.sessions.get(sessionId);
|
|
833
860
|
if (!process2) return;
|
|
834
861
|
this.conversationBuffer.delete(sessionId);
|
|
835
|
-
this.cleanupMcpConfig(sessionId);
|
|
836
862
|
this.sessions.delete(sessionId);
|
|
837
863
|
await this.adapter.stop(process2);
|
|
838
864
|
}
|
|
@@ -845,7 +871,6 @@ ${options.systemPrompt}` : memorySection;
|
|
|
845
871
|
});
|
|
846
872
|
}
|
|
847
873
|
this.conversationBuffer.delete(sessionId);
|
|
848
|
-
this.cleanupMcpConfig(sessionId);
|
|
849
874
|
this.sessions.delete(sessionId);
|
|
850
875
|
await this.adapter.stop(process2);
|
|
851
876
|
}
|
|
@@ -858,7 +883,6 @@ ${options.systemPrompt}` : memorySection;
|
|
|
858
883
|
});
|
|
859
884
|
}
|
|
860
885
|
this.conversationBuffer.delete(sessionId);
|
|
861
|
-
this.cleanupMcpConfig(sessionId);
|
|
862
886
|
this.sessions.delete(sessionId);
|
|
863
887
|
await this.adapter.stop(process2).catch(() => {
|
|
864
888
|
});
|
|
@@ -872,50 +896,101 @@ ${options.systemPrompt}` : memorySection;
|
|
|
872
896
|
get activeSessionCount() {
|
|
873
897
|
return this.sessions.size;
|
|
874
898
|
}
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
899
|
+
};
|
|
900
|
+
|
|
901
|
+
// src/start.ts
|
|
902
|
+
import { SwarmCoordinator, initRoles } from "@mclawnet/swarm";
|
|
903
|
+
|
|
904
|
+
// src/skill-loader.ts
|
|
905
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync2, copyFileSync, readdirSync as readdirSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
906
|
+
import { join as join3, dirname } from "path";
|
|
907
|
+
import { homedir as homedir3 } from "os";
|
|
908
|
+
import { createRequire } from "module";
|
|
909
|
+
import { fileURLToPath } from "url";
|
|
910
|
+
import { createLogger as createLogger4 } from "@mclawnet/logger";
|
|
911
|
+
var log4 = createLogger4({ module: "agent/skill-loader" });
|
|
912
|
+
var CLAWNET_DIR = join3(homedir3(), ".clawnet");
|
|
913
|
+
var SKILLS_DIR = join3(CLAWNET_DIR, ".claude", "skills");
|
|
914
|
+
var MCP_CONFIG_PATH = join3(CLAWNET_DIR, "mcp.json");
|
|
915
|
+
async function initSkills() {
|
|
916
|
+
ensureSkillsDir();
|
|
917
|
+
copyBuiltinSkills();
|
|
918
|
+
ensureMcpConfig();
|
|
919
|
+
}
|
|
920
|
+
function ensureSkillsDir() {
|
|
921
|
+
if (!existsSync3(SKILLS_DIR)) {
|
|
922
|
+
mkdirSync2(SKILLS_DIR, { recursive: true });
|
|
923
|
+
log4.info({ dir: SKILLS_DIR }, "created skills directory");
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
function copyBuiltinSkills() {
|
|
927
|
+
const thisFile = fileURLToPath(import.meta.url);
|
|
928
|
+
const srcDir = join3(dirname(thisFile), "..", "skills");
|
|
929
|
+
if (!existsSync3(srcDir)) {
|
|
930
|
+
log4.debug({ srcDir }, "no built-in skills directory found, skipping");
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
let entries;
|
|
934
|
+
try {
|
|
935
|
+
entries = readdirSync2(srcDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
|
|
936
|
+
} catch {
|
|
937
|
+
log4.warn({ srcDir }, "failed to read built-in skills directory");
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
for (const skillName of entries) {
|
|
941
|
+
const srcSkillMd = join3(srcDir, skillName, "SKILL.md");
|
|
942
|
+
const destDir = join3(SKILLS_DIR, skillName);
|
|
943
|
+
const destSkillMd = join3(destDir, "SKILL.md");
|
|
944
|
+
if (!existsSync3(srcSkillMd)) continue;
|
|
945
|
+
if (existsSync3(destSkillMd)) {
|
|
946
|
+
log4.debug({ skill: skillName }, "skill already exists, skipping");
|
|
947
|
+
continue;
|
|
948
|
+
}
|
|
949
|
+
try {
|
|
950
|
+
mkdirSync2(destDir, { recursive: true });
|
|
951
|
+
copyFileSync(srcSkillMd, destSkillMd);
|
|
952
|
+
log4.info({ skill: skillName }, "copied built-in skill");
|
|
953
|
+
} catch (err) {
|
|
954
|
+
log4.warn({ skill: skillName, err }, "failed to copy built-in skill");
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
function ensureMcpConfig() {
|
|
959
|
+
if (existsSync3(MCP_CONFIG_PATH)) {
|
|
960
|
+
log4.debug("mcp.json already exists, skipping");
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
963
|
+
let mcpServerPath;
|
|
964
|
+
try {
|
|
878
965
|
const req = createRequire(import.meta.url);
|
|
879
966
|
const memoryPkgDir = dirname(req.resolve("@mclawnet/memory/package.json"));
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
JSON.stringify({
|
|
885
|
-
mcpServers: {
|
|
886
|
-
"clawnet-memory": {
|
|
887
|
-
command: "node",
|
|
888
|
-
args: [mcpServerPath, "--role-id", roleId]
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
})
|
|
892
|
-
);
|
|
893
|
-
this.mcpConfigPaths.set(sessionId, configPath);
|
|
894
|
-
log3.debug({ sessionId, roleId, configPath, mcpServerPath }, "memory MCP config file written");
|
|
895
|
-
return configPath;
|
|
967
|
+
mcpServerPath = join3(memoryPkgDir, "dist", "mcp", "server.js");
|
|
968
|
+
} catch {
|
|
969
|
+
log4.warn("could not resolve @mclawnet/memory package path, skipping mcp.json generation");
|
|
970
|
+
return;
|
|
896
971
|
}
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
unlinkSync(configPath);
|
|
903
|
-
} catch {
|
|
972
|
+
const config = {
|
|
973
|
+
mcpServers: {
|
|
974
|
+
"clawnet-memory": {
|
|
975
|
+
command: "node",
|
|
976
|
+
args: [mcpServerPath]
|
|
904
977
|
}
|
|
905
|
-
this.mcpConfigPaths.delete(sessionId);
|
|
906
|
-
log3.debug({ sessionId, configPath }, "memory MCP config file cleaned up");
|
|
907
978
|
}
|
|
979
|
+
};
|
|
980
|
+
try {
|
|
981
|
+
mkdirSync2(CLAWNET_DIR, { recursive: true });
|
|
982
|
+
writeFileSync2(MCP_CONFIG_PATH, JSON.stringify(config, null, 2) + "\n");
|
|
983
|
+
log4.info({ path: MCP_CONFIG_PATH }, "generated default mcp.json");
|
|
984
|
+
} catch (err) {
|
|
985
|
+
log4.warn({ err }, "failed to generate mcp.json");
|
|
908
986
|
}
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
// src/start.ts
|
|
912
|
-
import { SwarmCoordinator, initRoles } from "@mclawnet/swarm";
|
|
987
|
+
}
|
|
913
988
|
|
|
914
989
|
// src/brain-bridge.ts
|
|
915
|
-
import { existsSync as
|
|
990
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3, readdirSync as readdirSync3 } from "fs";
|
|
916
991
|
import { join as join4 } from "path";
|
|
917
|
-
import { createLogger as
|
|
918
|
-
var
|
|
992
|
+
import { createLogger as createLogger5 } from "@mclawnet/logger";
|
|
993
|
+
var log5 = createLogger5({ module: "brain-bridge" });
|
|
919
994
|
var BrainBridge = class {
|
|
920
995
|
constructor(hub, options) {
|
|
921
996
|
this.hub = hub;
|
|
@@ -923,7 +998,7 @@ var BrainBridge = class {
|
|
|
923
998
|
this.brainHome = options?.brainHomePath || process.env.BRAIN_HOME || join4(home, "BrainData");
|
|
924
999
|
this.brainCorePath = options?.brainCorePath || join4(home, ".brain", "BrainCore");
|
|
925
1000
|
this.hub.registerNamespace("brain", (msg) => this.handleRequest(msg));
|
|
926
|
-
|
|
1001
|
+
log5.info(
|
|
927
1002
|
{ brainHome: this.brainHome, brainCorePath: this.brainCorePath },
|
|
928
1003
|
"BrainBridge initialized"
|
|
929
1004
|
);
|
|
@@ -931,11 +1006,11 @@ var BrainBridge = class {
|
|
|
931
1006
|
brainHome;
|
|
932
1007
|
brainCorePath;
|
|
933
1008
|
async handleRequest(msg) {
|
|
934
|
-
|
|
1009
|
+
log5.info({ action: msg.action, requestId: msg.requestId }, "brain request");
|
|
935
1010
|
switch (msg.action) {
|
|
936
1011
|
case "setup_status": {
|
|
937
1012
|
const status = this.checkSetup();
|
|
938
|
-
|
|
1013
|
+
log5.info({ status }, "setup_status result");
|
|
939
1014
|
return { status };
|
|
940
1015
|
}
|
|
941
1016
|
case "get_briefing":
|
|
@@ -943,20 +1018,20 @@ var BrainBridge = class {
|
|
|
943
1018
|
case "get_meeting_recap":
|
|
944
1019
|
return await this.getMeetingRecap(msg.params.recapPath);
|
|
945
1020
|
default:
|
|
946
|
-
|
|
1021
|
+
log5.warn({ action: msg.action }, "unknown brain action");
|
|
947
1022
|
throw new Error(`Unknown brain action: ${msg.action}`);
|
|
948
1023
|
}
|
|
949
1024
|
}
|
|
950
1025
|
checkSetup() {
|
|
951
|
-
if (!
|
|
1026
|
+
if (!existsSync4(this.brainCorePath)) {
|
|
952
1027
|
return "not_installed";
|
|
953
1028
|
}
|
|
954
1029
|
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
955
1030
|
const installJson = join4(home, ".brain", "install.json");
|
|
956
|
-
if (!
|
|
1031
|
+
if (!existsSync4(installJson)) {
|
|
957
1032
|
return "needs_config";
|
|
958
1033
|
}
|
|
959
|
-
if (!
|
|
1034
|
+
if (!existsSync4(this.brainHome)) {
|
|
960
1035
|
return "needs_config";
|
|
961
1036
|
}
|
|
962
1037
|
return "ready";
|
|
@@ -965,16 +1040,16 @@ var BrainBridge = class {
|
|
|
965
1040
|
async getBriefing(date) {
|
|
966
1041
|
const targetDate = date || (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
967
1042
|
const reportsDir = join4(this.brainHome, "reports", "daily");
|
|
968
|
-
if (!
|
|
969
|
-
|
|
1043
|
+
if (!existsSync4(reportsDir)) {
|
|
1044
|
+
log5.info({ reportsDir }, "get_briefing: reports dir not found");
|
|
970
1045
|
return { briefing: null, actions: [], projects: [], meetings: [], feed: [] };
|
|
971
1046
|
}
|
|
972
|
-
const files =
|
|
1047
|
+
const files = readdirSync3(reportsDir).filter((f) => f.includes(targetDate) && f.endsWith(".md")).sort().reverse();
|
|
973
1048
|
if (files.length === 0) {
|
|
974
|
-
|
|
1049
|
+
log5.info({ targetDate }, "get_briefing: no report for date");
|
|
975
1050
|
return { briefing: null, actions: [], projects: [], meetings: [], feed: [] };
|
|
976
1051
|
}
|
|
977
|
-
|
|
1052
|
+
log5.info({ targetDate, file: files[0] }, "get_briefing: reading report");
|
|
978
1053
|
const content = readFileSync3(join4(reportsDir, files[0]), "utf-8");
|
|
979
1054
|
const tldrMatch = content.match(/## TL;DR\n([\s\S]*?)(?=\n---|\n## )/);
|
|
980
1055
|
const tldr = tldrMatch ? tldrMatch[1].trim() : content.slice(0, 200);
|
|
@@ -982,7 +1057,7 @@ var BrainBridge = class {
|
|
|
982
1057
|
const projects = this.parseProjects(content);
|
|
983
1058
|
const meetings = this.parseMeetings(content);
|
|
984
1059
|
const feed = this.parseFeed(content);
|
|
985
|
-
|
|
1060
|
+
log5.info(
|
|
986
1061
|
{ actions: actions.length, projects: projects.length, meetings: meetings.length, feed: feed.length },
|
|
987
1062
|
"get_briefing: parsed"
|
|
988
1063
|
);
|
|
@@ -1175,8 +1250,8 @@ var BrainBridge = class {
|
|
|
1175
1250
|
return { error: "No recap path provided" };
|
|
1176
1251
|
}
|
|
1177
1252
|
const fullPath = join4(this.brainHome, recapPath);
|
|
1178
|
-
if (!
|
|
1179
|
-
|
|
1253
|
+
if (!existsSync4(fullPath)) {
|
|
1254
|
+
log5.warn({ fullPath }, "meeting recap file not found");
|
|
1180
1255
|
return { error: "Recap file not found" };
|
|
1181
1256
|
}
|
|
1182
1257
|
const content = readFileSync3(fullPath, "utf-8");
|
|
@@ -1212,10 +1287,10 @@ var BrainBridge = class {
|
|
|
1212
1287
|
};
|
|
1213
1288
|
|
|
1214
1289
|
// src/fs-bridge.ts
|
|
1215
|
-
import { existsSync as
|
|
1290
|
+
import { existsSync as existsSync5, readFileSync as readFileSync4, statSync as statSync2 } from "fs";
|
|
1216
1291
|
import { extname, isAbsolute } from "path";
|
|
1217
|
-
import { createLogger as
|
|
1218
|
-
var
|
|
1292
|
+
import { createLogger as createLogger6 } from "@mclawnet/logger";
|
|
1293
|
+
var log6 = createLogger6({ module: "fs-bridge" });
|
|
1219
1294
|
var MAX_TEXT_SIZE = 5 * 1024 * 1024;
|
|
1220
1295
|
var MIME_MAP = {
|
|
1221
1296
|
".ts": "text/typescript",
|
|
@@ -1253,10 +1328,10 @@ var FsBridge = class {
|
|
|
1253
1328
|
constructor(hub) {
|
|
1254
1329
|
this.hub = hub;
|
|
1255
1330
|
this.hub.registerNamespace("fs", (msg) => this.handleRequest(msg));
|
|
1256
|
-
|
|
1331
|
+
log6.info("FsBridge initialized");
|
|
1257
1332
|
}
|
|
1258
1333
|
async handleRequest(msg) {
|
|
1259
|
-
|
|
1334
|
+
log6.info({ action: msg.action, requestId: msg.requestId }, "fs request");
|
|
1260
1335
|
switch (msg.action) {
|
|
1261
1336
|
case "read":
|
|
1262
1337
|
return this.readFile(msg.params);
|
|
@@ -1270,7 +1345,7 @@ var FsBridge = class {
|
|
|
1270
1345
|
if (!isAbsolute(filePath)) {
|
|
1271
1346
|
throw new Error(`Access denied: only absolute paths allowed`);
|
|
1272
1347
|
}
|
|
1273
|
-
if (!
|
|
1348
|
+
if (!existsSync5(filePath)) {
|
|
1274
1349
|
throw new Error(`File not found: ${filePath}`);
|
|
1275
1350
|
}
|
|
1276
1351
|
const stat2 = statSync2(filePath);
|
|
@@ -1293,29 +1368,30 @@ var FsBridge = class {
|
|
|
1293
1368
|
};
|
|
1294
1369
|
|
|
1295
1370
|
// src/start.ts
|
|
1296
|
-
import { createLogger as
|
|
1297
|
-
var
|
|
1371
|
+
import { createLogger as createLogger7 } from "@mclawnet/logger";
|
|
1372
|
+
var log7 = createLogger7({ module: "agent" });
|
|
1298
1373
|
async function startAgent(options) {
|
|
1299
1374
|
const config = loadConfig(options.config);
|
|
1300
1375
|
if (!config.token) {
|
|
1301
|
-
|
|
1376
|
+
log7.error("no token configured \u2014 set CLAWNET_TOKEN or use --token");
|
|
1302
1377
|
process.exit(1);
|
|
1303
1378
|
}
|
|
1304
|
-
|
|
1305
|
-
|
|
1379
|
+
log7.info({ backend: options.adapter.type }, "starting agent");
|
|
1380
|
+
log7.info({ hubUrl: config.hubUrl }, "connecting to hub");
|
|
1306
1381
|
await initRoles();
|
|
1382
|
+
await initSkills();
|
|
1307
1383
|
const hub = new HubConnection({
|
|
1308
1384
|
hubUrl: config.hubUrl,
|
|
1309
1385
|
token: config.token,
|
|
1310
1386
|
hostname: config.name,
|
|
1311
1387
|
onConnect: (agentId) => {
|
|
1312
|
-
|
|
1388
|
+
log7.info({ agentId }, "connected to hub");
|
|
1313
1389
|
},
|
|
1314
1390
|
onDisconnect: (code, reason) => {
|
|
1315
|
-
|
|
1391
|
+
log7.info({ code, reason }, "disconnected from hub");
|
|
1316
1392
|
},
|
|
1317
1393
|
onError: (err) => {
|
|
1318
|
-
|
|
1394
|
+
log7.error({ err }, "hub connection error");
|
|
1319
1395
|
}
|
|
1320
1396
|
});
|
|
1321
1397
|
let swarmCoordinator;
|
|
@@ -1353,7 +1429,7 @@ async function startAgent(options) {
|
|
|
1353
1429
|
const brainBridge = new BrainBridge(hub);
|
|
1354
1430
|
const fsBridge = new FsBridge(hub);
|
|
1355
1431
|
const shutdown = async () => {
|
|
1356
|
-
|
|
1432
|
+
log7.info("shutting down");
|
|
1357
1433
|
await sessionManager.closeAll();
|
|
1358
1434
|
hub.destroy();
|
|
1359
1435
|
process.exit(0);
|
|
@@ -1373,4 +1449,4 @@ export {
|
|
|
1373
1449
|
FsBridge,
|
|
1374
1450
|
startAgent
|
|
1375
1451
|
};
|
|
1376
|
-
//# sourceMappingURL=chunk-
|
|
1452
|
+
//# sourceMappingURL=chunk-KITKMSBE.js.map
|