@clawchatsai/connector 0.0.87 → 0.0.88
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 +80 -88
- package/package.json +3 -4
- package/prebuilds/darwin-arm64/node_datachannel.node +0 -0
- package/prebuilds/darwin-x64/node_datachannel.node +0 -0
- package/prebuilds/linux-arm/node_datachannel.node +0 -0
- package/prebuilds/linux-arm64/node_datachannel.node +0 -0
- package/prebuilds/linux-x64/node_datachannel.node +0 -0
- package/prebuilds/linuxmusl-arm64/node_datachannel.node +0 -0
- package/prebuilds/linuxmusl-x64/node_datachannel.node +0 -0
- package/prebuilds/win32-arm64/node_datachannel.node +0 -0
- package/prebuilds/win32-x64/node_datachannel.node +0 -0
- package/server/config.js +5 -4
- package/server/controllers/agents.js +20 -0
- package/server/controllers/settings.js +28 -0
- package/server/controllers/static.js +56 -0
- package/server/controllers/transcribe.js +3 -10
- package/server/index.js +24 -49
- package/server/providers/memory-config.js +52 -0
- package/server/providers/memory.js +3 -39
- package/server/store/workspace-store.js +31 -0
- package/dist/updater.d.ts +0 -21
- package/dist/updater.js +0 -64
- package/server.js +0 -2392
|
@@ -1,42 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// Discover memory backend configuration from env vars and OpenClaw config
|
|
6
|
-
export function discoverMemoryConfig() {
|
|
7
|
-
const defaults = { provider: 'qdrant', host: 'localhost', port: 6333, collection: null };
|
|
8
|
-
let oc = null;
|
|
9
|
-
for (const cfgPath of [path.join(os.homedir(), '.openclaw', 'openclaw.json'), '/etc/openclaw/openclaw.json']) {
|
|
10
|
-
try { oc = JSON.parse(fs.readFileSync(cfgPath, 'utf8')); break; } catch { /* try next */ }
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
let cfg = { ...defaults };
|
|
14
|
-
if (oc) {
|
|
15
|
-
const vs = oc.plugins?.slots?.memory ? oc.plugins?.entries?.[oc.plugins.slots.memory]?.config?.oss?.vectorStore : null;
|
|
16
|
-
if (vs) {
|
|
17
|
-
if (vs.provider) cfg.provider = vs.provider;
|
|
18
|
-
if (vs.config?.host) cfg.host = vs.config.host;
|
|
19
|
-
if (vs.config?.port) cfg.port = vs.config.port;
|
|
20
|
-
if (vs.config?.collectionName) cfg.collection = vs.config.collectionName;
|
|
21
|
-
if (vs.config?.user) cfg.pgUser = vs.config.user;
|
|
22
|
-
if (vs.config?.password) cfg.pgPassword = vs.config.password;
|
|
23
|
-
if (vs.config?.dbname) cfg.pgDbName = vs.config.dbname;
|
|
24
|
-
}
|
|
25
|
-
const wsDir = oc.agents?.defaults?.workspace;
|
|
26
|
-
if (wsDir) cfg.workspaceDir = wsDir;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (process.env.MEMORY_PROVIDER) cfg.provider = process.env.MEMORY_PROVIDER;
|
|
30
|
-
if (process.env.MEMORY_HOST || process.env.QDRANT_HOST) cfg.host = process.env.MEMORY_HOST || process.env.QDRANT_HOST;
|
|
31
|
-
if (process.env.MEMORY_PORT || process.env.QDRANT_PORT) cfg.port = parseInt(process.env.MEMORY_PORT || process.env.QDRANT_PORT, 10);
|
|
32
|
-
if (process.env.MEMORY_COLLECTION || process.env.QDRANT_COLLECTION) cfg.collection = process.env.MEMORY_COLLECTION || process.env.QDRANT_COLLECTION;
|
|
33
|
-
if (process.env.MEMORY_PG_URL) cfg.pgUrl = process.env.MEMORY_PG_URL;
|
|
34
|
-
if (process.env.QDRANT_URL && !process.env.MEMORY_HOST) {
|
|
35
|
-
try { const u = new URL(process.env.QDRANT_URL); cfg.host = u.hostname; if (u.port) cfg.port = parseInt(u.port, 10); } catch { /* ignore */ }
|
|
36
|
-
}
|
|
37
|
-
if (!cfg.workspaceDir) cfg.workspaceDir = path.join(os.homedir(), '.openclaw', 'workspace');
|
|
38
|
-
return cfg;
|
|
39
|
-
}
|
|
1
|
+
// Config discovery (file reads only) lives in memory-config.js.
|
|
2
|
+
// This file contains only provider implementations (network calls, no file reads).
|
|
3
|
+
export { discoverMemoryConfig } from './memory-config.js';
|
|
40
4
|
|
|
41
5
|
export async function autoDetectQdrantCollection(config) {
|
|
42
6
|
if (config.collection) return config.collection;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Factory that returns workspace config read/write helpers bound to a specific file path.
|
|
5
|
+
* Keeps file I/O out of the HTTP router (server/index.js).
|
|
6
|
+
*/
|
|
7
|
+
export function createWorkspaceStore(workspacesFile) {
|
|
8
|
+
let cache = null;
|
|
9
|
+
|
|
10
|
+
function getWorkspaces() {
|
|
11
|
+
if (!cache) {
|
|
12
|
+
try {
|
|
13
|
+
cache = JSON.parse(fs.readFileSync(workspacesFile, 'utf8'));
|
|
14
|
+
} catch {
|
|
15
|
+
cache = {
|
|
16
|
+
active: 'default',
|
|
17
|
+
workspaces: { default: { name: 'default', label: 'Default', createdAt: Date.now() } },
|
|
18
|
+
};
|
|
19
|
+
fs.writeFileSync(workspacesFile, JSON.stringify(cache, null, 2));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return cache;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function setWorkspaces(data) {
|
|
26
|
+
cache = data;
|
|
27
|
+
fs.writeFileSync(workspacesFile, JSON.stringify(data, null, 2));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return { getWorkspaces, setWorkspaces };
|
|
31
|
+
}
|
package/dist/updater.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auto-update checker for the @clawchatsai/connector plugin.
|
|
3
|
-
*
|
|
4
|
-
* Checks the npm registry for newer versions and can trigger
|
|
5
|
-
* an in-place update via the OpenClaw plugin CLI.
|
|
6
|
-
*/
|
|
7
|
-
export interface UpdateInfo {
|
|
8
|
-
current: string;
|
|
9
|
-
latest: string;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Check npm registry for updates.
|
|
13
|
-
* Returns UpdateInfo if a newer version is available, null otherwise.
|
|
14
|
-
* Silently returns null on any network or parse error.
|
|
15
|
-
*/
|
|
16
|
-
export declare function checkForUpdates(): Promise<UpdateInfo | null>;
|
|
17
|
-
/**
|
|
18
|
-
* Run the OpenClaw plugin update command.
|
|
19
|
-
* Throws an Error if the command exits with a non-zero code or times out.
|
|
20
|
-
*/
|
|
21
|
-
export declare function performUpdate(): Promise<void>;
|
package/dist/updater.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auto-update checker for the @clawchatsai/connector plugin.
|
|
3
|
-
*
|
|
4
|
-
* Checks the npm registry for newer versions and can trigger
|
|
5
|
-
* an in-place update via the OpenClaw plugin CLI.
|
|
6
|
-
*/
|
|
7
|
-
import { execFile } from 'node:child_process';
|
|
8
|
-
import { PLUGIN_VERSION } from './index.js';
|
|
9
|
-
/**
|
|
10
|
-
* Compare two semver strings. Returns true if `a` is greater than `b`.
|
|
11
|
-
* Handles major.minor.patch only — no pre-release suffixes.
|
|
12
|
-
*/
|
|
13
|
-
function semverGt(a, b) {
|
|
14
|
-
const parse = (v) => {
|
|
15
|
-
const parts = v.split('.').map(Number);
|
|
16
|
-
return [parts[0] ?? 0, parts[1] ?? 0, parts[2] ?? 0];
|
|
17
|
-
};
|
|
18
|
-
const [aMaj, aMin, aPat] = parse(a);
|
|
19
|
-
const [bMaj, bMin, bPat] = parse(b);
|
|
20
|
-
if (aMaj !== bMaj)
|
|
21
|
-
return aMaj > bMaj;
|
|
22
|
-
if (aMin !== bMin)
|
|
23
|
-
return aMin > bMin;
|
|
24
|
-
return aPat > bPat;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Check npm registry for updates.
|
|
28
|
-
* Returns UpdateInfo if a newer version is available, null otherwise.
|
|
29
|
-
* Silently returns null on any network or parse error.
|
|
30
|
-
*/
|
|
31
|
-
export async function checkForUpdates() {
|
|
32
|
-
try {
|
|
33
|
-
const res = await fetch('https://registry.npmjs.org/@clawchatsai%2Fconnector/latest');
|
|
34
|
-
if (!res.ok)
|
|
35
|
-
return null;
|
|
36
|
-
const data = await res.json();
|
|
37
|
-
const latest = data.version;
|
|
38
|
-
if (typeof latest !== 'string')
|
|
39
|
-
return null;
|
|
40
|
-
if (!semverGt(latest, PLUGIN_VERSION))
|
|
41
|
-
return null;
|
|
42
|
-
return { current: PLUGIN_VERSION, latest };
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Run the OpenClaw plugin update command.
|
|
50
|
-
* Throws an Error if the command exits with a non-zero code or times out.
|
|
51
|
-
*/
|
|
52
|
-
export async function performUpdate() {
|
|
53
|
-
return new Promise((resolve, reject) => {
|
|
54
|
-
const child = execFile('openclaw', ['plugins', 'update', '@clawchatsai/connector'], { timeout: 120_000 }, (error) => {
|
|
55
|
-
if (error) {
|
|
56
|
-
reject(new Error(`Plugin update failed: ${error.message}`));
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
resolve();
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
child; // reference kept to satisfy linter — callback handles lifecycle
|
|
63
|
-
});
|
|
64
|
-
}
|