psyche-ai 9.1.2 → 9.2.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/adapters/openclaw.js +52 -14
- package/dist/autonomic.js +6 -2
- package/dist/chemistry.js +59 -1
- package/dist/classify.js +168 -1
- package/dist/cli.js +76 -0
- package/dist/core.d.ts +32 -2
- package/dist/core.js +123 -6
- package/dist/decision-bias.d.ts +15 -2
- package/dist/decision-bias.js +78 -1
- package/dist/diagnostics.d.ts +84 -0
- package/dist/diagnostics.js +481 -0
- package/dist/drives.js +5 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/prompt.d.ts +4 -1
- package/dist/prompt.js +23 -7
- package/dist/psyche-file.js +8 -2
- package/dist/storage.d.ts +10 -0
- package/dist/storage.js +22 -1
- package/package.json +1 -1
package/dist/storage.js
CHANGED
|
@@ -6,23 +6,32 @@
|
|
|
6
6
|
// MemoryStorageAdapter: in-memory for testing/serverless
|
|
7
7
|
// ============================================================
|
|
8
8
|
import { migrateToLatest } from "./psyche-file.js";
|
|
9
|
-
import { readFile, writeFile, access, rename, constants } from "node:fs/promises";
|
|
9
|
+
import { readFile, writeFile, appendFile, access, rename, constants } from "node:fs/promises";
|
|
10
10
|
import { join } from "node:path";
|
|
11
11
|
// ── MemoryStorageAdapter ─────────────────────────────────────
|
|
12
12
|
export class MemoryStorageAdapter {
|
|
13
13
|
state = null;
|
|
14
|
+
log = [];
|
|
14
15
|
async load() {
|
|
15
16
|
return this.state;
|
|
16
17
|
}
|
|
17
18
|
async save(state) {
|
|
18
19
|
this.state = state;
|
|
19
20
|
}
|
|
21
|
+
async appendLog(line) {
|
|
22
|
+
this.log.push(line);
|
|
23
|
+
}
|
|
24
|
+
async readLog() {
|
|
25
|
+
return [...this.log];
|
|
26
|
+
}
|
|
20
27
|
}
|
|
21
28
|
// ── FileStorageAdapter ───────────────────────────────────────
|
|
22
29
|
export class FileStorageAdapter {
|
|
23
30
|
filePath;
|
|
31
|
+
logPath;
|
|
24
32
|
constructor(dir, filename = "psyche-state.json") {
|
|
25
33
|
this.filePath = join(dir, filename);
|
|
34
|
+
this.logPath = join(dir, "diagnostics.jsonl");
|
|
26
35
|
}
|
|
27
36
|
async load() {
|
|
28
37
|
try {
|
|
@@ -59,4 +68,16 @@ export class FileStorageAdapter {
|
|
|
59
68
|
await writeFile(tmpPath, JSON.stringify(state, null, 2), "utf-8");
|
|
60
69
|
await rename(tmpPath, this.filePath);
|
|
61
70
|
}
|
|
71
|
+
async appendLog(line) {
|
|
72
|
+
await appendFile(this.logPath, line + "\n", "utf-8");
|
|
73
|
+
}
|
|
74
|
+
async readLog() {
|
|
75
|
+
try {
|
|
76
|
+
const content = await readFile(this.logPath, "utf-8");
|
|
77
|
+
return content.trim().split("\n").filter(Boolean);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
62
83
|
}
|