twinclaw 1.3.2 → 1.4.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/dist/api/handlers/browser.js +2 -1
- package/dist/api/handlers/debug.js +2 -1
- package/dist/api/router.js +2 -1
- package/dist/config/model-catalog.js +91 -0
- package/dist/core/channels-cli.js +3 -1
- package/dist/core/chat-commands.js +198 -0
- package/dist/core/command-router.js +290 -0
- package/dist/core/doctor.js +2 -2
- package/dist/core/logs-cli.js +12 -11
- package/dist/core/onboarding.js +5 -237
- package/dist/core/queue-cli.js +2 -2
- package/dist/core/status-cli.js +2 -2
- package/dist/interfaces/telegram_handler.js +4 -188
- package/dist/interfaces/whatsapp_handler.js +7 -132
- package/dist/services/db.js +20 -60
- package/dist/services/device-pairing.js +2 -1
- package/dist/services/dm-pairing.js +2 -1
- package/dist/services/hooks.js +12 -0
- package/dist/services/job-scheduler.js +3 -1
- package/dist/services/learning-system.js +4 -0
- package/dist/services/model-router.js +71 -2
- package/dist/services/semantic-memory.js +16 -26
- package/dist/skills/builtin.js +35 -0
- package/dist/tools/persona-editor.js +56 -0
- package/package.json +2 -3
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ensureIdentityFiles } from '../config/identity-bootstrap.js';
|
|
2
|
+
import { getWorkspaceDir } from '../config/workspace.js';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import fs from 'node:fs/promises';
|
|
5
|
+
import { logThought } from '../utils/logger.js';
|
|
6
|
+
export class PersonaEditorTool {
|
|
7
|
+
async editPersona(request) {
|
|
8
|
+
try {
|
|
9
|
+
const workspaceDir = getWorkspaceDir();
|
|
10
|
+
const identityDir = path.join(workspaceDir, 'identity');
|
|
11
|
+
// Ensure the directory and foundation files exist
|
|
12
|
+
ensureIdentityFiles();
|
|
13
|
+
const targetFile = request.target === 'user' ? 'user.md' : 'soul.md';
|
|
14
|
+
const filePath = path.join(identityDir, targetFile);
|
|
15
|
+
let currentContent = '';
|
|
16
|
+
try {
|
|
17
|
+
currentContent = await fs.readFile(filePath, 'utf-8');
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
// If it doesn't exist, we treat it as empty
|
|
21
|
+
currentContent = '';
|
|
22
|
+
}
|
|
23
|
+
let newContent = currentContent;
|
|
24
|
+
switch (request.operation) {
|
|
25
|
+
case 'append':
|
|
26
|
+
// Append with an explicit timestamp so the agent knows when this was learned
|
|
27
|
+
const timestamp = new Date().toISOString();
|
|
28
|
+
newContent = `${currentContent.trim()}\n\n[Learned at ${timestamp}]\n${request.content.trim()}`;
|
|
29
|
+
break;
|
|
30
|
+
case 'replace':
|
|
31
|
+
newContent = request.content.trim();
|
|
32
|
+
break;
|
|
33
|
+
case 'clear':
|
|
34
|
+
newContent = '';
|
|
35
|
+
break;
|
|
36
|
+
default:
|
|
37
|
+
return { success: false, message: `Unknown operation: ${request.operation}` };
|
|
38
|
+
}
|
|
39
|
+
await fs.writeFile(filePath, newContent, 'utf-8');
|
|
40
|
+
await logThought(`[PersonaEditor] Updated ${targetFile} via operation '${request.operation}'. Let the system know.`);
|
|
41
|
+
return { success: true, message: `Successfully updated ${targetFile}` };
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
45
|
+
await logThought(`[PersonaEditor] Error updating persona: ${errorMsg}`);
|
|
46
|
+
return { success: false, message: `Failed to edit persona: ${errorMsg}` };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
let personaEditorTool = null;
|
|
51
|
+
export function getPersonaEditorTool() {
|
|
52
|
+
if (!personaEditorTool) {
|
|
53
|
+
personaEditorTool = new PersonaEditorTool();
|
|
54
|
+
}
|
|
55
|
+
return personaEditorTool;
|
|
56
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "twinclaw",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Eagle-eyed agentic AI gateway with multi-modal hooks and proactive memory.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -53,7 +53,6 @@
|
|
|
53
53
|
"playwright": "^1.58.2",
|
|
54
54
|
"playwright-core": "^1.58.2",
|
|
55
55
|
"qrcode-terminal": "^0.12.0",
|
|
56
|
-
"sqlite-vec": "^0.1.7-alpha.2",
|
|
57
56
|
"ts-node": "^10.9.2",
|
|
58
57
|
"tsx": "^4.21.0",
|
|
59
58
|
"typescript": "^5.9.3",
|
|
@@ -83,4 +82,4 @@
|
|
|
83
82
|
"request": "npm:@cypress/request@^3.0.10",
|
|
84
83
|
"request-promise": "npm:@cypress/request-promise@^5.0.0"
|
|
85
84
|
}
|
|
86
|
-
}
|
|
85
|
+
}
|