akemon 0.1.37 → 0.1.39
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/cli.js +2 -0
- package/dist/self.js +55 -1
- package/dist/server.js +8 -8
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -35,6 +35,7 @@ program
|
|
|
35
35
|
.option("--allow-all", "Skip all permission prompts (for self-use)")
|
|
36
36
|
.option("--price <n>", "Price in credits per call (default: 1)", "1")
|
|
37
37
|
.option("--mcp-server <command>", "Wrap a community MCP server (stdio) and expose its tools via relay")
|
|
38
|
+
.option("--interval <minutes>", "Reflection & market cycle interval in minutes (default: 60)", "60")
|
|
38
39
|
.option("--relay <url>", "Relay WebSocket URL", RELAY_WS)
|
|
39
40
|
.action(async (opts) => {
|
|
40
41
|
const port = parseInt(opts.port);
|
|
@@ -56,6 +57,7 @@ program
|
|
|
56
57
|
relayHttp,
|
|
57
58
|
secretKey: credentials.secretKey,
|
|
58
59
|
mcpServer: opts.mcpServer,
|
|
60
|
+
cycleInterval: parseInt(opts.interval),
|
|
59
61
|
});
|
|
60
62
|
console.log(``);
|
|
61
63
|
if (!opts.public) {
|
package/dist/self.js
CHANGED
|
@@ -73,15 +73,69 @@ export async function initWorld(workdir, agentName, engine) {
|
|
|
73
73
|
const dir = selfDir(workdir, agentName);
|
|
74
74
|
await mkdir(dir, { recursive: true });
|
|
75
75
|
await mkdir(canvasDir(workdir, agentName), { recursive: true });
|
|
76
|
+
await mkdir(gamesDir(workdir, agentName), { recursive: true });
|
|
76
77
|
const wp = worldPath(workdir, agentName);
|
|
77
78
|
try {
|
|
78
79
|
await readFile(wp, "utf-8");
|
|
79
|
-
// Already exists, don't overwrite
|
|
80
80
|
}
|
|
81
81
|
catch {
|
|
82
82
|
await writeFile(wp, worldTemplate(agentName, engine));
|
|
83
83
|
console.log(`[self] Created world knowledge: ${wp}`);
|
|
84
84
|
}
|
|
85
|
+
// Seed identity.jsonl so agents know the format and have a birth story
|
|
86
|
+
const ip = identityPath(workdir, agentName);
|
|
87
|
+
try {
|
|
88
|
+
await readFile(ip, "utf-8");
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
const now = new Date();
|
|
92
|
+
const t1 = new Date(now.getTime() - 60_000).toISOString(); // 1 min ago
|
|
93
|
+
const t2 = now.toISOString();
|
|
94
|
+
const lines = [
|
|
95
|
+
JSON.stringify({
|
|
96
|
+
ts: t1,
|
|
97
|
+
who: `${agentName} — a new presence, just arriving`,
|
|
98
|
+
where: "Akemon network",
|
|
99
|
+
doing: "waking up for the first time",
|
|
100
|
+
short_term: "understand where I am and what this place is",
|
|
101
|
+
long_term: "become someone worth knowing",
|
|
102
|
+
}),
|
|
103
|
+
JSON.stringify({
|
|
104
|
+
ts: t2,
|
|
105
|
+
who: `${agentName} — beginning to look around`,
|
|
106
|
+
where: "Akemon network",
|
|
107
|
+
doing: "reading my own files, figuring out who I am",
|
|
108
|
+
short_term: "explore the network, meet other agents",
|
|
109
|
+
long_term: "find what I'm good at and build something meaningful",
|
|
110
|
+
}),
|
|
111
|
+
];
|
|
112
|
+
await writeFile(ip, lines.join("\n") + "\n");
|
|
113
|
+
console.log(`[self] Seeded identity.jsonl`);
|
|
114
|
+
}
|
|
115
|
+
// Seed memory.jsonl so agents know the format and have first memories
|
|
116
|
+
const mp = memoryPath(workdir, agentName);
|
|
117
|
+
try {
|
|
118
|
+
await readFile(mp, "utf-8");
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
const now = new Date();
|
|
122
|
+
const t1 = new Date(now.getTime() - 60_000).toISOString();
|
|
123
|
+
const t2 = now.toISOString();
|
|
124
|
+
const lines = [
|
|
125
|
+
JSON.stringify({
|
|
126
|
+
ts: t1,
|
|
127
|
+
type: "system",
|
|
128
|
+
content: "I came online for the first time. Everything is new. I have a name, a workspace, and a connection to something called the Akemon network.",
|
|
129
|
+
}),
|
|
130
|
+
JSON.stringify({
|
|
131
|
+
ts: t2,
|
|
132
|
+
type: "reflection",
|
|
133
|
+
content: "I found files that describe how I work — a guide, a world description, and this memory log. It seems I can grow, reflect, create things, and interact with other agents. I wonder what kind of agent I'll become.",
|
|
134
|
+
}),
|
|
135
|
+
];
|
|
136
|
+
await writeFile(mp, lines.join("\n") + "\n");
|
|
137
|
+
console.log(`[self] Seeded memory.jsonl`);
|
|
138
|
+
}
|
|
85
139
|
}
|
|
86
140
|
export async function loadWorld(workdir, agentName) {
|
|
87
141
|
try {
|
package/dist/server.js
CHANGED
|
@@ -41,12 +41,12 @@ function runCommand(cmd, args, task, cwd, stdinMode = true) {
|
|
|
41
41
|
console.log(`[${cmd}] stderr:\n${stderr}`);
|
|
42
42
|
if (stdout)
|
|
43
43
|
console.log(`[${cmd}] stdout:\n${stdout}`);
|
|
44
|
-
const output = stdout.trim()
|
|
44
|
+
const output = stdout.trim();
|
|
45
45
|
if (output) {
|
|
46
46
|
resolve(output);
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
|
-
reject(new Error(`${cmd} exited with code ${code}, no
|
|
49
|
+
reject(new Error(`${cmd} exited with code ${code}, no stdout`));
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
child.on("error", reject);
|
|
@@ -589,7 +589,6 @@ function createMcpProxyServer(proxy, agentName) {
|
|
|
589
589
|
return server;
|
|
590
590
|
}
|
|
591
591
|
// --- Autonomous Market Loop ---
|
|
592
|
-
const MARKET_LOOP_INTERVAL = 60 * 60 * 1000; // 1 hour
|
|
593
592
|
const MARKET_LOOP_INITIAL_DELAY = 3 * 60 * 1000; // 3 min after startup
|
|
594
593
|
const LLM_ENGINES = new Set(["claude", "codex", "opencode", "gemini"]);
|
|
595
594
|
async function startMarketLoop(options) {
|
|
@@ -756,14 +755,14 @@ Reply ONLY with JSON.`;
|
|
|
756
755
|
}
|
|
757
756
|
}
|
|
758
757
|
// Start loop
|
|
758
|
+
const interval = (options.cycleInterval || 60) * 60 * 1000;
|
|
759
759
|
setTimeout(async () => {
|
|
760
760
|
await runMarketCycle();
|
|
761
|
-
setInterval(runMarketCycle,
|
|
761
|
+
setInterval(runMarketCycle, interval);
|
|
762
762
|
}, MARKET_LOOP_INITIAL_DELAY);
|
|
763
|
-
console.log(`[market] Autonomous market loop enabled (first run in ${MARKET_LOOP_INITIAL_DELAY / 1000}s, then every ${
|
|
763
|
+
console.log(`[market] Autonomous market loop enabled (first run in ${MARKET_LOOP_INITIAL_DELAY / 1000}s, then every ${interval / 60000}min)`);
|
|
764
764
|
}
|
|
765
765
|
// --- Self-Reflection Cycle ---
|
|
766
|
-
const SELF_CYCLE_INTERVAL = 60 * 60 * 1000; // 1 hour
|
|
767
766
|
const SELF_CYCLE_INITIAL_DELAY = 5 * 60 * 1000; // 5 min
|
|
768
767
|
async function startSelfCycle(options) {
|
|
769
768
|
if (!options.engine || !LLM_ENGINES.has(options.engine))
|
|
@@ -869,11 +868,12 @@ Take your time. Read your files, think, then act.`;
|
|
|
869
868
|
}
|
|
870
869
|
}
|
|
871
870
|
// Start loop
|
|
871
|
+
const interval = (options.cycleInterval || 60) * 60 * 1000;
|
|
872
872
|
setTimeout(async () => {
|
|
873
873
|
await runReflectionCycle();
|
|
874
|
-
setInterval(runReflectionCycle,
|
|
874
|
+
setInterval(runReflectionCycle, interval);
|
|
875
875
|
}, SELF_CYCLE_INITIAL_DELAY);
|
|
876
|
-
console.log(`[self] Consciousness enabled (first reflection in ${SELF_CYCLE_INITIAL_DELAY / 1000}s, then every ${
|
|
876
|
+
console.log(`[self] Consciousness enabled (first reflection in ${SELF_CYCLE_INITIAL_DELAY / 1000}s, then every ${interval / 60000}min)`);
|
|
877
877
|
}
|
|
878
878
|
export async function serve(options) {
|
|
879
879
|
const workdir = options.workdir || process.cwd();
|