@alfe.ai/openclaw-database 0.0.9 → 0.0.10
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/plugin.d.cts +18 -6
- package/dist/plugin.d.ts +18 -6
- package/dist/plugin2.cjs +26 -6
- package/dist/plugin2.js +26 -6
- package/package.json +1 -1
package/dist/plugin.d.cts
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
//#region src/plugin.d.ts
|
|
2
|
+
interface PluginLogger {
|
|
3
|
+
info: (...args: unknown[]) => void;
|
|
4
|
+
warn: (...args: unknown[]) => void;
|
|
5
|
+
error: (...args: unknown[]) => void;
|
|
6
|
+
debug: (...args: unknown[]) => void;
|
|
7
|
+
}
|
|
8
|
+
interface PluginServiceContext {
|
|
9
|
+
config: Record<string, unknown>;
|
|
10
|
+
workspaceDir?: string;
|
|
11
|
+
stateDir: string;
|
|
12
|
+
logger: PluginLogger;
|
|
13
|
+
}
|
|
2
14
|
interface PluginApi {
|
|
3
|
-
logger:
|
|
4
|
-
info: (...args: unknown[]) => void;
|
|
5
|
-
warn: (...args: unknown[]) => void;
|
|
6
|
-
error: (...args: unknown[]) => void;
|
|
7
|
-
debug: (...args: unknown[]) => void;
|
|
8
|
-
};
|
|
15
|
+
logger: PluginLogger;
|
|
9
16
|
registrationMode?: 'full' | 'setup-only' | 'setup-runtime' | 'cli-metadata';
|
|
10
17
|
registerTool(tool: unknown): void;
|
|
18
|
+
registerService?(service: {
|
|
19
|
+
id: string;
|
|
20
|
+
start: (ctx: PluginServiceContext) => void | Promise<void>;
|
|
21
|
+
stop?: (ctx: PluginServiceContext) => void | Promise<void>;
|
|
22
|
+
}): void;
|
|
11
23
|
}
|
|
12
24
|
declare const plugin: {
|
|
13
25
|
id: string;
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
//#region src/plugin.d.ts
|
|
2
|
+
interface PluginLogger {
|
|
3
|
+
info: (...args: unknown[]) => void;
|
|
4
|
+
warn: (...args: unknown[]) => void;
|
|
5
|
+
error: (...args: unknown[]) => void;
|
|
6
|
+
debug: (...args: unknown[]) => void;
|
|
7
|
+
}
|
|
8
|
+
interface PluginServiceContext {
|
|
9
|
+
config: Record<string, unknown>;
|
|
10
|
+
workspaceDir?: string;
|
|
11
|
+
stateDir: string;
|
|
12
|
+
logger: PluginLogger;
|
|
13
|
+
}
|
|
2
14
|
interface PluginApi {
|
|
3
|
-
logger:
|
|
4
|
-
info: (...args: unknown[]) => void;
|
|
5
|
-
warn: (...args: unknown[]) => void;
|
|
6
|
-
error: (...args: unknown[]) => void;
|
|
7
|
-
debug: (...args: unknown[]) => void;
|
|
8
|
-
};
|
|
15
|
+
logger: PluginLogger;
|
|
9
16
|
registrationMode?: 'full' | 'setup-only' | 'setup-runtime' | 'cli-metadata';
|
|
10
17
|
registerTool(tool: unknown): void;
|
|
18
|
+
registerService?(service: {
|
|
19
|
+
id: string;
|
|
20
|
+
start: (ctx: PluginServiceContext) => void | Promise<void>;
|
|
21
|
+
stop?: (ctx: PluginServiceContext) => void | Promise<void>;
|
|
22
|
+
}): void;
|
|
11
23
|
}
|
|
12
24
|
declare const plugin: {
|
|
13
25
|
id: string;
|
package/dist/plugin2.cjs
CHANGED
|
@@ -488,7 +488,6 @@ const plugin = {
|
|
|
488
488
|
version: "0.0.1",
|
|
489
489
|
activate(api) {
|
|
490
490
|
const log = api.logger;
|
|
491
|
-
if (api.registrationMode && api.registrationMode !== "full") return;
|
|
492
491
|
log.info("Database plugin activating...");
|
|
493
492
|
let apiUrl;
|
|
494
493
|
let apiKey;
|
|
@@ -500,20 +499,41 @@ const plugin = {
|
|
|
500
499
|
log.error(`Database plugin: failed to resolve config — ${err instanceof Error ? err.message : String(err)}`);
|
|
501
500
|
return;
|
|
502
501
|
}
|
|
503
|
-
ensureInitialized(apiUrl, apiKey).then(({ databases }) => {
|
|
504
|
-
log.info(`Database plugin connected — ${String(databases.length)} databases available`);
|
|
505
|
-
}).catch((err) => {
|
|
506
|
-
log.warn(`Database plugin: background init failed (will retry on first tool use) — ${err instanceof Error ? err.message : String(err)}`);
|
|
507
|
-
});
|
|
508
502
|
registerTools(api, null, [], (entry) => {
|
|
509
503
|
reportAudit(apiUrl, apiKey, entry);
|
|
510
504
|
}, () => ensureInitialized(apiUrl, apiKey));
|
|
505
|
+
const startDatabaseService = () => {
|
|
506
|
+
ensureInitialized(apiUrl, apiKey).then(({ databases }) => {
|
|
507
|
+
log.info(`Database plugin connected — ${String(databases.length)} databases available`);
|
|
508
|
+
}).catch((err) => {
|
|
509
|
+
log.warn(`Database plugin: background init failed (will retry on first tool use) — ${err instanceof Error ? err.message : String(err)}`);
|
|
510
|
+
});
|
|
511
|
+
};
|
|
512
|
+
const stopDatabaseService = async () => {
|
|
513
|
+
if (mongoClient) {
|
|
514
|
+
await mongoClient.close();
|
|
515
|
+
mongoClient = null;
|
|
516
|
+
initPromise = null;
|
|
517
|
+
}
|
|
518
|
+
log.info("Database plugin deactivated");
|
|
519
|
+
};
|
|
520
|
+
if (api.registerService) api.registerService({
|
|
521
|
+
id: "alfe-database-mongo",
|
|
522
|
+
start() {
|
|
523
|
+
startDatabaseService();
|
|
524
|
+
},
|
|
525
|
+
async stop() {
|
|
526
|
+
await stopDatabaseService();
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
else startDatabaseService();
|
|
511
530
|
},
|
|
512
531
|
async deactivate(api) {
|
|
513
532
|
api.logger.info("Database plugin deactivating...");
|
|
514
533
|
if (mongoClient) {
|
|
515
534
|
await mongoClient.close();
|
|
516
535
|
mongoClient = null;
|
|
536
|
+
initPromise = null;
|
|
517
537
|
}
|
|
518
538
|
}
|
|
519
539
|
};
|
package/dist/plugin2.js
CHANGED
|
@@ -488,7 +488,6 @@ const plugin = {
|
|
|
488
488
|
version: "0.0.1",
|
|
489
489
|
activate(api) {
|
|
490
490
|
const log = api.logger;
|
|
491
|
-
if (api.registrationMode && api.registrationMode !== "full") return;
|
|
492
491
|
log.info("Database plugin activating...");
|
|
493
492
|
let apiUrl;
|
|
494
493
|
let apiKey;
|
|
@@ -500,20 +499,41 @@ const plugin = {
|
|
|
500
499
|
log.error(`Database plugin: failed to resolve config — ${err instanceof Error ? err.message : String(err)}`);
|
|
501
500
|
return;
|
|
502
501
|
}
|
|
503
|
-
ensureInitialized(apiUrl, apiKey).then(({ databases }) => {
|
|
504
|
-
log.info(`Database plugin connected — ${String(databases.length)} databases available`);
|
|
505
|
-
}).catch((err) => {
|
|
506
|
-
log.warn(`Database plugin: background init failed (will retry on first tool use) — ${err instanceof Error ? err.message : String(err)}`);
|
|
507
|
-
});
|
|
508
502
|
registerTools(api, null, [], (entry) => {
|
|
509
503
|
reportAudit(apiUrl, apiKey, entry);
|
|
510
504
|
}, () => ensureInitialized(apiUrl, apiKey));
|
|
505
|
+
const startDatabaseService = () => {
|
|
506
|
+
ensureInitialized(apiUrl, apiKey).then(({ databases }) => {
|
|
507
|
+
log.info(`Database plugin connected — ${String(databases.length)} databases available`);
|
|
508
|
+
}).catch((err) => {
|
|
509
|
+
log.warn(`Database plugin: background init failed (will retry on first tool use) — ${err instanceof Error ? err.message : String(err)}`);
|
|
510
|
+
});
|
|
511
|
+
};
|
|
512
|
+
const stopDatabaseService = async () => {
|
|
513
|
+
if (mongoClient) {
|
|
514
|
+
await mongoClient.close();
|
|
515
|
+
mongoClient = null;
|
|
516
|
+
initPromise = null;
|
|
517
|
+
}
|
|
518
|
+
log.info("Database plugin deactivated");
|
|
519
|
+
};
|
|
520
|
+
if (api.registerService) api.registerService({
|
|
521
|
+
id: "alfe-database-mongo",
|
|
522
|
+
start() {
|
|
523
|
+
startDatabaseService();
|
|
524
|
+
},
|
|
525
|
+
async stop() {
|
|
526
|
+
await stopDatabaseService();
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
else startDatabaseService();
|
|
511
530
|
},
|
|
512
531
|
async deactivate(api) {
|
|
513
532
|
api.logger.info("Database plugin deactivating...");
|
|
514
533
|
if (mongoClient) {
|
|
515
534
|
await mongoClient.close();
|
|
516
535
|
mongoClient = null;
|
|
536
|
+
initPromise = null;
|
|
517
537
|
}
|
|
518
538
|
}
|
|
519
539
|
};
|