@hippodid/openclaw-plugin 1.0.0 → 1.0.2
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/file-sync.d.ts +18 -0
- package/dist/file-sync.d.ts.map +1 -0
- package/dist/file-sync.js +172 -0
- package/dist/file-sync.js.map +1 -0
- package/dist/hippodid-client.d.ts +11 -0
- package/dist/hippodid-client.d.ts.map +1 -0
- package/dist/hippodid-client.js +155 -0
- package/dist/hippodid-client.js.map +1 -0
- package/dist/hooks/auto-capture.d.ts +7 -0
- package/dist/hooks/auto-capture.d.ts.map +1 -0
- package/dist/hooks/auto-capture.js +45 -0
- package/dist/hooks/auto-capture.js.map +1 -0
- package/dist/hooks/auto-recall.d.ts +7 -0
- package/dist/hooks/auto-recall.d.ts.map +1 -0
- package/dist/hooks/auto-recall.js +46 -0
- package/dist/hooks/auto-recall.js.map +1 -0
- package/dist/hooks/memory-flush.d.ts +7 -0
- package/dist/hooks/memory-flush.d.ts.map +1 -0
- package/dist/hooks/memory-flush.js +14 -0
- package/dist/hooks/memory-flush.js.map +1 -0
- package/dist/hooks/session-lifecycle.d.ts +8 -0
- package/dist/hooks/session-lifecycle.d.ts.map +1 -0
- package/dist/hooks/session-lifecycle.js +29 -0
- package/dist/hooks/session-lifecycle.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +164 -0
- package/dist/index.js.map +1 -0
- package/dist/tier-manager.d.ts +16 -0
- package/dist/tier-manager.d.ts.map +1 -0
- package/dist/tier-manager.js +57 -0
- package/dist/tier-manager.js.map +1 -0
- package/dist/types.d.ts +123 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/dist/workspace-detector.d.ts +5 -0
- package/dist/workspace-detector.d.ts.map +1 -0
- package/dist/workspace-detector.js +88 -0
- package/dist/workspace-detector.js.map +1 -0
- package/package.json +8 -2
- package/src/hooks/auto-capture.ts +1 -1
- package/src/hooks/auto-recall.ts +1 -1
- package/src/hooks/memory-flush.ts +1 -1
- package/src/hooks/session-lifecycle.ts +2 -2
- package/src/index.ts +136 -62
- package/src/types.ts +2 -4
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
|
-
import type { OpenClawPluginAPI, PluginConfig } from './types.js';
|
|
3
|
+
import type { OpenClawPluginAPI, PluginConfig, WatchPathConfig } from './types.js';
|
|
4
4
|
import { createClient, type HippoDidClient } from './hippodid-client.js';
|
|
5
5
|
import { createFileSync, type FileSync } from './file-sync.js';
|
|
6
6
|
import { resolveWatchPaths } from './workspace-detector.js';
|
|
@@ -10,74 +10,146 @@ import { createSessionHooks } from './hooks/session-lifecycle.js';
|
|
|
10
10
|
import { createAutoRecallHook } from './hooks/auto-recall.js';
|
|
11
11
|
import { createAutoCaptureHook } from './hooks/auto-capture.js';
|
|
12
12
|
|
|
13
|
-
export const id = 'hippodid';
|
|
14
|
-
|
|
15
13
|
const VERSION = '1.0.0';
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
warn: (msg: string) => console.warn(msg),
|
|
23
|
-
error: (msg: string) => console.error(msg),
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const client = createClient(config.apiKey, config.baseUrl);
|
|
27
|
-
const tierManager = createTierManager(client, config.characterId, logger);
|
|
28
|
-
const watchPaths = resolveWatchPaths(config);
|
|
29
|
-
const effectiveSyncInterval = Math.max(config.syncIntervalSeconds, 60);
|
|
30
|
-
const fileSync = createFileSync(client, config, watchPaths, logger, effectiveSyncInterval);
|
|
31
|
-
|
|
32
|
-
const registerMemoryFlush = createMemoryFlushHook(fileSync, logger);
|
|
33
|
-
registerMemoryFlush(api);
|
|
34
|
-
|
|
35
|
-
const registerSessionHooks = createSessionHooks(
|
|
36
|
-
fileSync,
|
|
37
|
-
tierManager,
|
|
38
|
-
config.autoRecall,
|
|
39
|
-
logger,
|
|
40
|
-
);
|
|
41
|
-
registerSessionHooks(api);
|
|
42
|
-
|
|
43
|
-
tierManager.initialize().then((tier) => {
|
|
44
|
-
if (tierManager.shouldMountAutoRecall(config.autoRecall)) {
|
|
45
|
-
const registerAutoRecall = createAutoRecallHook(client, config, logger);
|
|
46
|
-
registerAutoRecall(api);
|
|
47
|
-
}
|
|
15
|
+
const plugin = {
|
|
16
|
+
id: 'hippodid',
|
|
17
|
+
name: 'HippoDid Memory',
|
|
18
|
+
description:
|
|
19
|
+
'Persistent cloud memory for OpenClaw — survives context compaction',
|
|
48
20
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
21
|
+
configSchema: {
|
|
22
|
+
type: 'object' as const,
|
|
23
|
+
required: ['apiKey', 'characterId'],
|
|
24
|
+
additionalProperties: false,
|
|
25
|
+
properties: {
|
|
26
|
+
apiKey: { type: 'string' as const },
|
|
27
|
+
characterId: { type: 'string' as const },
|
|
28
|
+
baseUrl: {
|
|
29
|
+
type: 'string' as const,
|
|
30
|
+
default: 'https://api.hippodid.com',
|
|
31
|
+
},
|
|
32
|
+
syncIntervalSeconds: {
|
|
33
|
+
type: 'number' as const,
|
|
34
|
+
default: 300,
|
|
35
|
+
minimum: 60,
|
|
36
|
+
},
|
|
37
|
+
autoRecall: { type: 'boolean' as const, default: false },
|
|
38
|
+
autoCapture: { type: 'boolean' as const, default: false },
|
|
39
|
+
additionalPaths: {
|
|
40
|
+
type: 'array' as const,
|
|
41
|
+
items: {
|
|
42
|
+
type: 'object' as const,
|
|
43
|
+
properties: {
|
|
44
|
+
path: { type: 'string' as const },
|
|
45
|
+
label: { type: 'string' as const },
|
|
46
|
+
},
|
|
47
|
+
required: ['path'],
|
|
48
|
+
},
|
|
49
|
+
default: [],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
register(api: OpenClawPluginAPI): void {
|
|
55
|
+
try {
|
|
56
|
+
const config = resolveConfig(api.config);
|
|
57
|
+
const logger = api.logger ?? {
|
|
58
|
+
info: (msg: string) => console.log(msg),
|
|
59
|
+
warn: (msg: string) => console.warn(msg),
|
|
60
|
+
error: (msg: string) => console.error(msg),
|
|
61
|
+
};
|
|
57
62
|
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
const client = createClient(config.apiKey, config.baseUrl);
|
|
64
|
+
const tierManager = createTierManager(
|
|
65
|
+
client,
|
|
66
|
+
config.characterId,
|
|
67
|
+
logger,
|
|
68
|
+
);
|
|
69
|
+
const watchPaths = resolveWatchPaths(config);
|
|
70
|
+
const effectiveSyncInterval = Math.max(
|
|
71
|
+
config.syncIntervalSeconds,
|
|
72
|
+
60,
|
|
73
|
+
);
|
|
74
|
+
const fileSync = createFileSync(
|
|
75
|
+
client,
|
|
76
|
+
config,
|
|
77
|
+
watchPaths,
|
|
78
|
+
logger,
|
|
79
|
+
effectiveSyncInterval,
|
|
80
|
+
);
|
|
64
81
|
|
|
65
|
-
logger.info(
|
|
66
|
-
|
|
82
|
+
logger.info('hippodid: plugin loaded');
|
|
83
|
+
|
|
84
|
+
const registerMemoryFlush = createMemoryFlushHook(fileSync, logger);
|
|
85
|
+
registerMemoryFlush(api);
|
|
86
|
+
|
|
87
|
+
const registerSessionHooks = createSessionHooks(
|
|
88
|
+
fileSync,
|
|
89
|
+
tierManager,
|
|
90
|
+
config.autoRecall,
|
|
91
|
+
logger,
|
|
67
92
|
);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
93
|
+
registerSessionHooks(api);
|
|
94
|
+
|
|
95
|
+
tierManager
|
|
96
|
+
.initialize()
|
|
97
|
+
.then((tier) => {
|
|
98
|
+
if (tierManager.shouldMountAutoRecall(config.autoRecall)) {
|
|
99
|
+
const registerAutoRecall = createAutoRecallHook(
|
|
100
|
+
client,
|
|
101
|
+
config,
|
|
102
|
+
logger,
|
|
103
|
+
);
|
|
104
|
+
registerAutoRecall(api);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (tierManager.shouldMountAutoCapture(config.autoCapture)) {
|
|
108
|
+
const registerAutoCapture = createAutoCaptureHook(
|
|
109
|
+
client,
|
|
110
|
+
config,
|
|
111
|
+
logger,
|
|
112
|
+
);
|
|
113
|
+
registerAutoCapture(api);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (tierManager.shouldMountFileSync(config.autoCapture)) {
|
|
117
|
+
fileSync.start();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const autoRecallStatus = tierManager.shouldMountAutoRecall(
|
|
121
|
+
config.autoRecall,
|
|
122
|
+
)
|
|
123
|
+
? 'ON'
|
|
124
|
+
: 'OFF';
|
|
125
|
+
const autoCaptureStatus = tierManager.shouldMountAutoCapture(
|
|
126
|
+
config.autoCapture,
|
|
127
|
+
)
|
|
128
|
+
? 'ON'
|
|
129
|
+
: 'OFF';
|
|
130
|
+
|
|
131
|
+
logger.info(
|
|
132
|
+
`hippodid: v${VERSION} | character: ${config.characterId} | tier: ${tier.tier} | watching ${watchPaths.length} paths | autoRecall: ${autoRecallStatus} | autoCapture: ${autoCaptureStatus}`,
|
|
133
|
+
);
|
|
134
|
+
})
|
|
135
|
+
.catch((e) => {
|
|
136
|
+
logger.warn(
|
|
137
|
+
`hippodid: tier initialization failed, running in free mode: ${e instanceof Error ? e.message : 'unknown'}`,
|
|
138
|
+
);
|
|
139
|
+
fileSync.start();
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
registerCommands(api, config, client, fileSync, tierManager, logger);
|
|
143
|
+
} catch (e) {
|
|
144
|
+
const msg = e instanceof Error ? e.message : 'unknown';
|
|
145
|
+
(api.logger ?? console).error(
|
|
146
|
+
`hippodid: plugin initialization failed: ${msg}`,
|
|
71
147
|
);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const msg = e instanceof Error ? e.message : 'unknown';
|
|
78
|
-
(api.logger ?? console).error(`hippodid: plugin initialization failed: ${msg}`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export default plugin;
|
|
81
153
|
|
|
82
154
|
function resolveConfig(raw: PluginConfig): PluginConfig {
|
|
83
155
|
return {
|
|
@@ -123,7 +195,9 @@ function registerCommands(
|
|
|
123
195
|
);
|
|
124
196
|
}
|
|
125
197
|
} else {
|
|
126
|
-
logger.warn(
|
|
198
|
+
logger.warn(
|
|
199
|
+
`Could not fetch sync status: ${statusResult.error.message}`,
|
|
200
|
+
);
|
|
127
201
|
}
|
|
128
202
|
},
|
|
129
203
|
});
|
package/src/types.ts
CHANGED
|
@@ -127,7 +127,7 @@ export interface FileTrackingEntry {
|
|
|
127
127
|
lastSyncedAt: Date;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
// --- OpenClaw Plugin API (local type,
|
|
130
|
+
// --- OpenClaw Plugin API (local type, matches openclaw/plugin-sdk/core) ---
|
|
131
131
|
|
|
132
132
|
export interface OpenClawPluginAPI {
|
|
133
133
|
config: PluginConfig;
|
|
@@ -136,9 +136,7 @@ export interface OpenClawPluginAPI {
|
|
|
136
136
|
warn(message: string): void;
|
|
137
137
|
error(message: string): void;
|
|
138
138
|
};
|
|
139
|
-
|
|
140
|
-
on(event: string, handler: (...args: any[]) => void | Promise<void>): void;
|
|
141
|
-
};
|
|
139
|
+
on(event: string, handler: (...args: any[]) => void | Promise<void>): void;
|
|
142
140
|
context: {
|
|
143
141
|
prepend(content: string): void;
|
|
144
142
|
};
|