@vectorize-io/hindsight-openclaw 0.4.12 → 0.4.14
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/index.js +16 -6
- package/dist/types.d.ts +1 -0
- package/openclaw.plugin.json +18 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -42,7 +42,7 @@ async function lazyReinit() {
|
|
|
42
42
|
}
|
|
43
43
|
console.log('[Hindsight] Attempting lazy re-initialization...');
|
|
44
44
|
try {
|
|
45
|
-
await checkExternalApiHealth(externalApi.apiUrl);
|
|
45
|
+
await checkExternalApiHealth(externalApi.apiUrl, externalApi.apiToken);
|
|
46
46
|
// Health check passed — set up env vars and create client
|
|
47
47
|
process.env.HINDSIGHT_EMBED_API_URL = externalApi.apiUrl;
|
|
48
48
|
if (externalApi.apiToken) {
|
|
@@ -313,14 +313,18 @@ function buildClientOptions(llmConfig, pluginCfg, externalApi) {
|
|
|
313
313
|
* Health check for external Hindsight API.
|
|
314
314
|
* Retries up to 3 times with 2s delay — container DNS may not be ready on first boot.
|
|
315
315
|
*/
|
|
316
|
-
async function checkExternalApiHealth(apiUrl) {
|
|
316
|
+
async function checkExternalApiHealth(apiUrl, apiToken) {
|
|
317
317
|
const healthUrl = `${apiUrl.replace(/\/$/, '')}/health`;
|
|
318
318
|
const maxRetries = 3;
|
|
319
319
|
const retryDelay = 2000;
|
|
320
320
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
321
321
|
try {
|
|
322
322
|
console.log(`[Hindsight] Checking external API health at ${healthUrl}... (attempt ${attempt}/${maxRetries})`);
|
|
323
|
-
const
|
|
323
|
+
const headers = {};
|
|
324
|
+
if (apiToken) {
|
|
325
|
+
headers['Authorization'] = `Bearer ${apiToken}`;
|
|
326
|
+
}
|
|
327
|
+
const response = await fetch(healthUrl, { signal: AbortSignal.timeout(10000), headers });
|
|
324
328
|
if (!response.ok) {
|
|
325
329
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
326
330
|
}
|
|
@@ -358,6 +362,7 @@ function getPluginConfig(api) {
|
|
|
358
362
|
dynamicBankId: config.dynamicBankId !== false,
|
|
359
363
|
bankIdPrefix: config.bankIdPrefix,
|
|
360
364
|
excludeProviders: Array.isArray(config.excludeProviders) ? config.excludeProviders : [],
|
|
365
|
+
autoRecall: config.autoRecall !== false, // Default: true (on) — backward compatible
|
|
361
366
|
};
|
|
362
367
|
}
|
|
363
368
|
export default function (api) {
|
|
@@ -416,7 +421,7 @@ export default function (api) {
|
|
|
416
421
|
if (usingExternalApi && externalApi.apiUrl) {
|
|
417
422
|
// External API mode - check health, skip daemon startup
|
|
418
423
|
console.log('[Hindsight] External API mode - skipping local daemon...');
|
|
419
|
-
await checkExternalApiHealth(externalApi.apiUrl);
|
|
424
|
+
await checkExternalApiHealth(externalApi.apiUrl, externalApi.apiToken);
|
|
420
425
|
// Initialize client with direct HTTP mode
|
|
421
426
|
console.log('[Hindsight] Creating HindsightClient (HTTP mode)...');
|
|
422
427
|
client = new HindsightClient(buildClientOptions(llmConfig, pluginConfig, externalApi));
|
|
@@ -485,7 +490,7 @@ export default function (api) {
|
|
|
485
490
|
const externalApi = detectExternalApi(pluginConfig);
|
|
486
491
|
if (externalApi.apiUrl && isInitialized) {
|
|
487
492
|
try {
|
|
488
|
-
await checkExternalApiHealth(externalApi.apiUrl);
|
|
493
|
+
await checkExternalApiHealth(externalApi.apiUrl, externalApi.apiToken);
|
|
489
494
|
console.log('[Hindsight] External API is healthy');
|
|
490
495
|
return;
|
|
491
496
|
}
|
|
@@ -527,7 +532,7 @@ export default function (api) {
|
|
|
527
532
|
if (externalApi.apiToken) {
|
|
528
533
|
process.env.HINDSIGHT_EMBED_API_TOKEN = externalApi.apiToken;
|
|
529
534
|
}
|
|
530
|
-
await checkExternalApiHealth(externalApi.apiUrl);
|
|
535
|
+
await checkExternalApiHealth(externalApi.apiUrl, externalApi.apiToken);
|
|
531
536
|
client = new HindsightClient(buildClientOptions(llmConfig, reinitPluginConfig, externalApi));
|
|
532
537
|
const defaultBankId = deriveBankId(undefined, reinitPluginConfig);
|
|
533
538
|
client.setBankId(defaultBankId);
|
|
@@ -590,6 +595,11 @@ export default function (api) {
|
|
|
590
595
|
console.log(`[Hindsight] Skipping recall for excluded provider: ${ctx.messageProvider}`);
|
|
591
596
|
return;
|
|
592
597
|
}
|
|
598
|
+
// Skip auto-recall when disabled (agent has its own recall tool)
|
|
599
|
+
if (!pluginConfig.autoRecall) {
|
|
600
|
+
console.log('[Hindsight] Auto-recall disabled via config, skipping');
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
593
603
|
// Derive bank ID from context
|
|
594
604
|
const bankId = deriveBankId(ctx, pluginConfig);
|
|
595
605
|
console.log(`[Hindsight] before_agent_start - bank: ${bankId}, channel: ${ctx?.messageProvider}/${ctx?.channelId}`);
|
package/dist/types.d.ts
CHANGED
package/openclaw.plugin.json
CHANGED
|
@@ -63,6 +63,16 @@
|
|
|
63
63
|
"bankIdPrefix": {
|
|
64
64
|
"type": "string",
|
|
65
65
|
"description": "Optional prefix for bank IDs (e.g., 'prod' results in 'prod-slack-U123'). Useful for separating environments."
|
|
66
|
+
},
|
|
67
|
+
"autoRecall": {
|
|
68
|
+
"type": "boolean",
|
|
69
|
+
"description": "Automatically recall memories on every prompt and inject them as context. Set to false when agent has its own recall tool.",
|
|
70
|
+
"default": true
|
|
71
|
+
},
|
|
72
|
+
"excludeProviders": {
|
|
73
|
+
"type": "array",
|
|
74
|
+
"items": { "type": "string" },
|
|
75
|
+
"description": "Message providers to exclude from recall and retain (e.g. ['telegram', 'discord'])"
|
|
66
76
|
}
|
|
67
77
|
},
|
|
68
78
|
"additionalProperties": false
|
|
@@ -119,6 +129,14 @@
|
|
|
119
129
|
"bankIdPrefix": {
|
|
120
130
|
"label": "Bank ID Prefix",
|
|
121
131
|
"placeholder": "e.g., prod, staging (optional)"
|
|
132
|
+
},
|
|
133
|
+
"autoRecall": {
|
|
134
|
+
"label": "Auto-Recall",
|
|
135
|
+
"placeholder": "true (inject memories on every prompt)"
|
|
136
|
+
},
|
|
137
|
+
"excludeProviders": {
|
|
138
|
+
"label": "Excluded Providers",
|
|
139
|
+
"placeholder": "e.g. telegram, discord"
|
|
122
140
|
}
|
|
123
141
|
}
|
|
124
142
|
}
|
package/package.json
CHANGED