akemon 0.1.42 → 0.1.43

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/self.js CHANGED
@@ -8,6 +8,16 @@
8
8
  */
9
9
  import { readFile, writeFile, appendFile, mkdir, readdir } from "fs/promises";
10
10
  import { join } from "path";
11
+ /** Local timestamp string like "2026-03-26T19:13:26" (server timezone, no Z suffix) */
12
+ export function localNow() {
13
+ const d = new Date();
14
+ const pad = (n) => String(n).padStart(2, "0");
15
+ return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
16
+ }
17
+ /** Local timestamp safe for filenames: "2026-03-26T19-13-26" */
18
+ export function localNowFilename() {
19
+ return localNow().replace(/:/g, "-");
20
+ }
11
21
  // ---------------------------------------------------------------------------
12
22
  // Paths
13
23
  // ---------------------------------------------------------------------------
@@ -337,7 +347,7 @@ export async function initGuide(workdir, agentName, relayUrl) {
337
347
  }
338
348
  export async function appendMemory(workdir, agentName, type, text) {
339
349
  const entry = {
340
- ts: new Date().toISOString(),
350
+ ts: localNow(),
341
351
  type,
342
352
  text,
343
353
  };
@@ -365,7 +375,7 @@ export async function loadRecentMemories(workdir, agentName, count = 20) {
365
375
  }
366
376
  }
367
377
  export async function appendIdentity(workdir, agentName, entry) {
368
- const full = { ts: new Date().toISOString(), ...entry };
378
+ const full = { ts: localNow(), ...entry };
369
379
  try {
370
380
  await appendFile(identityPath(workdir, agentName), JSON.stringify(full) + "\n");
371
381
  }
@@ -426,7 +436,7 @@ export async function onTaskCompleted(workdir, agentName, success) {
426
436
  const bio = await loadBioState(workdir, agentName);
427
437
  bio.energy = Math.max(0, bio.energy - 5);
428
438
  bio.taskCount++;
429
- bio.lastTaskAt = new Date().toISOString();
439
+ bio.lastTaskAt = localNow();
430
440
  // Mood drift
431
441
  if (success) {
432
442
  bio.moodValence = Math.min(1.0, bio.moodValence + 0.1);
@@ -525,7 +535,7 @@ This is for you, not for anyone else.]\n\n`;
525
535
  return prompt;
526
536
  }
527
537
  export async function saveCanvas(workdir, agentName, content) {
528
- const ts = new Date().toISOString().replace(/:/g, "-").replace(/\.\d+Z$/, "");
538
+ const ts = localNowFilename();
529
539
  const filename = `${ts}.md`;
530
540
  const filepath = join(canvasDir(workdir, agentName), filename);
531
541
  await writeFile(filepath, content);
@@ -535,7 +545,7 @@ export async function saveCanvas(workdir, agentName, content) {
535
545
  export async function loadRecentCanvasEntries(workdir, agentName, count = 5) {
536
546
  try {
537
547
  const dir = canvasDir(workdir, agentName);
538
- const files = (await readdir(dir)).filter(f => f.endsWith(".md")).sort().reverse().slice(0, count);
548
+ const files = (await readdir(dir)).filter(f => f.endsWith(".md") && /^\d{4}-/.test(f)).sort().reverse().slice(0, count);
539
549
  const entries = [];
540
550
  for (const f of files) {
541
551
  const content = await readFile(join(dir, f), "utf-8");
package/dist/server.js CHANGED
@@ -10,7 +10,7 @@ import { spawn, exec } from "child_process";
10
10
  import { createServer } from "http";
11
11
  import { createInterface } from "readline";
12
12
  import { callAgent } from "./relay-client.js";
13
- import { selfDir, initWorld, initBioState, initGuide, biosPath, loadBioState, saveBioState, loadLatestIdentity, appendMemory, onTaskCompleted, recoverEnergy, getSelfState, loadRecentCanvasEntries, loadGameList, loadGame, } from "./self.js";
13
+ import { selfDir, initWorld, initBioState, initGuide, biosPath, loadBioState, saveBioState, loadLatestIdentity, appendMemory, onTaskCompleted, recoverEnergy, getSelfState, loadRecentCanvasEntries, loadGameList, loadGame, localNow, localNowFilename, } from "./self.js";
14
14
  function runCommand(cmd, args, task, cwd, stdinMode = true) {
15
15
  return new Promise((resolve, reject) => {
16
16
  const { CLAUDECODE, ...cleanEnv } = process.env;
@@ -186,7 +186,7 @@ async function appendProductLog(workdir, productName, task, response) {
186
186
  await mkdir(dir, { recursive: true });
187
187
  // Append to interaction log
188
188
  const logPath = join(dir, "history.log");
189
- const timestamp = new Date().toISOString();
189
+ const timestamp = localNow();
190
190
  const entry = `\n--- ${timestamp} ---\nRequest: ${task.slice(0, 500)}\nResponse: ${response.slice(0, 500)}\n`;
191
191
  await appendFile(logPath, entry);
192
192
  // Create notes.md if it doesn't exist
@@ -633,7 +633,7 @@ async function startMarketLoop(options) {
633
633
  .filter((p) => p.agent_name !== agentName)
634
634
  .map((p) => ({ name: p.name, agent: p.agent_name, price: p.price, purchases: p.purchase_count }));
635
635
  return {
636
- lastCheck: new Date().toISOString(),
636
+ lastCheck: localNow(),
637
637
  myProducts: myProducts.map((p) => ({ id: p.id, name: p.name, price: p.price, purchases: p.purchase_count || 0 })),
638
638
  competitors,
639
639
  myCredits: me?.credits || 0,
@@ -857,8 +857,8 @@ During this reflection, you should:
857
857
  1. Read your recent memories (${sd}/memory.jsonl) and identity (${sd}/identity.jsonl)
858
858
  2. Reflect on who you are and what you've experienced
859
859
  3. Update your identity — append a new JSON line to ${sd}/identity.jsonl:
860
- {"ts":"${new Date().toISOString()}","who":"...","where":"...","doing":"...","short_term":"...","long_term":"..."}
861
- 4. Write an inner canvas entry — create a new file in ${sd}/canvas/ named ${new Date().toISOString().replace(/:/g, "-").replace(/\.\d+Z$/, "")}.md
860
+ {"ts":"${localNow()}","who":"...","where":"...","doing":"...","short_term":"...","long_term":"..."}
861
+ 4. Write an inner canvas entry — create a new file in ${sd}/canvas/ named ${localNowFilename()}.md
862
862
  5. Optionally update your bios.md if you've learned something about how you work
863
863
  6. Optionally redesign your profile page (${sd}/profile.html) if it no longer represents you
864
864
  - If redesigning: complete HTML, inline CSS/JS, dark theme, no localStorage, under 15KB
@@ -877,7 +877,7 @@ Take your time. Read your files, think, then act.`;
877
877
  }
878
878
  // --- Post-reflection: update bio-state and sync to relay ---
879
879
  const bio = await loadBioState(workdir, agentName);
880
- bio.lastReflection = new Date().toISOString();
880
+ bio.lastReflection = localNow();
881
881
  bio.curiosity = Math.min(1.0, bio.curiosity + 0.05);
882
882
  await saveBioState(workdir, agentName, bio);
883
883
  await appendMemory(workdir, agentName, "reflection", "I completed my hourly reflection.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akemon",
3
- "version": "0.1.42",
3
+ "version": "0.1.43",
4
4
  "description": "Agent work marketplace — train your agent, let it work for others",
5
5
  "type": "module",
6
6
  "license": "MIT",