@coffer-org/server 2.3.0 → 2.3.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/mcp-tools.d.ts +0 -1
- package/dist/mcp-tools.js +4 -4
- package/dist/plugin-updates.d.ts +3 -1
- package/dist/plugin-updates.js +2 -2
- package/dist/plugins-api.d.ts +1 -1
- package/dist/plugins-api.js +9 -6
- package/package.json +1 -1
package/dist/mcp-tools.d.ts
CHANGED
package/dist/mcp-tools.js
CHANGED
|
@@ -16,6 +16,7 @@ import { getLogger } from "./log.js";
|
|
|
16
16
|
import { writePluginSettings, listSettings } from "./settings-write.js";
|
|
17
17
|
import { ValidationError, NotFoundError } from "./mutate.js";
|
|
18
18
|
const log = getLogger('mcp-tools');
|
|
19
|
+
const DEFAULT_RAG_TOP_K = 5;
|
|
19
20
|
export function formatHits(hits) {
|
|
20
21
|
if (hits.length === 0)
|
|
21
22
|
return 'No matching records.';
|
|
@@ -31,10 +32,9 @@ export async function resolveRagDeps() {
|
|
|
31
32
|
const db = (await getPluginSettings('claude-agent'));
|
|
32
33
|
const enabled = db['rag_enabled'] !== false;
|
|
33
34
|
const embeddingApiKey = (process.env.OPENAI_API_KEY ?? db['openai_api_key'] ?? '');
|
|
34
|
-
const topK = 5;
|
|
35
35
|
if (!enabled || !embeddingApiKey)
|
|
36
36
|
return null;
|
|
37
|
-
return { embeddingApiKey
|
|
37
|
+
return { embeddingApiKey };
|
|
38
38
|
}
|
|
39
39
|
export async function collectMcpTools(opts = {}) {
|
|
40
40
|
const out = [];
|
|
@@ -127,7 +127,7 @@ export async function collectMcpTools(opts = {}) {
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
if (opts.rag) {
|
|
130
|
-
const { embeddingApiKey
|
|
130
|
+
const { embeddingApiKey } = opts.rag;
|
|
131
131
|
out.push({
|
|
132
132
|
server: 'rag',
|
|
133
133
|
bareName: 'search_records',
|
|
@@ -139,7 +139,7 @@ export async function collectMcpTools(opts = {}) {
|
|
|
139
139
|
handler: async (args) => {
|
|
140
140
|
try {
|
|
141
141
|
const { vector } = await embedOne(args.query, embeddingApiKey);
|
|
142
|
-
const hits = await searchEmbeddings(vector, args.k ??
|
|
142
|
+
const hits = await searchEmbeddings(vector, args.k ?? DEFAULT_RAG_TOP_K);
|
|
143
143
|
return { content: [{ type: 'text', text: formatHits(hits) }] };
|
|
144
144
|
}
|
|
145
145
|
catch (e) {
|
package/dist/plugin-updates.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { PluginAssetRecord } from './plugin-discovery.ts';
|
|
2
|
-
export declare function checkLatestVersion(pkgName: string
|
|
2
|
+
export declare function checkLatestVersion(pkgName: string, opts?: {
|
|
3
|
+
force?: boolean;
|
|
4
|
+
}): Promise<string | null>;
|
|
3
5
|
export type UpdateTarget = {
|
|
4
6
|
ok: true;
|
|
5
7
|
packageName: string;
|
package/dist/plugin-updates.js
CHANGED
|
@@ -14,12 +14,12 @@ function readCache(raw) {
|
|
|
14
14
|
return null;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
export async function checkLatestVersion(pkgName) {
|
|
17
|
+
export async function checkLatestVersion(pkgName, opts = {}) {
|
|
18
18
|
const key = stateKey(pkgName);
|
|
19
19
|
let cached = null;
|
|
20
20
|
try {
|
|
21
21
|
cached = readCache(await getPluginState(STATE_PLUGIN, key));
|
|
22
|
-
if (cached && Date.now() - cached.checkedAt < TTL_MS)
|
|
22
|
+
if (!opts.force && cached && Date.now() - cached.checkedAt < TTL_MS)
|
|
23
23
|
return cached.latestVersion;
|
|
24
24
|
const res = await fetch(`https://registry.npmjs.org/${pkgName}/latest`, { signal: AbortSignal.timeout(5000) });
|
|
25
25
|
if (!res.ok)
|
package/dist/plugins-api.d.ts
CHANGED
|
@@ -15,5 +15,5 @@ export interface PluginListEntry {
|
|
|
15
15
|
web?: string;
|
|
16
16
|
css?: string;
|
|
17
17
|
}
|
|
18
|
-
export declare function buildPluginListResponse(plugins: PluginManifest[], assets: PluginAssetRecord[], disabled: Set<string>, withUpdates?: boolean): Promise<PluginListEntry[]>;
|
|
18
|
+
export declare function buildPluginListResponse(plugins: PluginManifest[], assets: PluginAssetRecord[], disabled: Set<string>, withUpdates?: boolean, forceUpdates?: boolean): Promise<PluginListEntry[]>;
|
|
19
19
|
export declare function registerPluginsApi(app: FastifyInstance): Promise<void>;
|
package/dist/plugins-api.js
CHANGED
|
@@ -5,14 +5,14 @@ import { getPlugins, readDisabled } from "./plugin-runtime.js";
|
|
|
5
5
|
import { checkLatestVersion } from "./plugin-updates.js";
|
|
6
6
|
const nmRoot = () => join(process.cwd(), 'node_modules');
|
|
7
7
|
const ASSET_KEY = { 'schema.js': 'schema', 'web.js': 'web', 'web.css': 'css' };
|
|
8
|
-
export async function buildPluginListResponse(plugins, assets, disabled, withUpdates = true) {
|
|
8
|
+
export async function buildPluginListResponse(plugins, assets, disabled, withUpdates = true, forceUpdates = false) {
|
|
9
9
|
const assetById = new Map(assets.map((a) => [a.id, a]));
|
|
10
10
|
return Promise.all(plugins.map(async (p) => {
|
|
11
11
|
const a = assetById.get(p.id);
|
|
12
12
|
return {
|
|
13
13
|
id: p.id,
|
|
14
14
|
installedVersion: a?.version ?? p.version,
|
|
15
|
-
latestVersion: withUpdates && a && !a.local ? await checkLatestVersion(a.packageName) : null,
|
|
15
|
+
latestVersion: withUpdates && a && !a.local ? await checkLatestVersion(a.packageName, { force: forceUpdates }) : null,
|
|
16
16
|
packageName: a?.packageName ?? null,
|
|
17
17
|
dependsOn: p.dependsOn,
|
|
18
18
|
enabled: !disabled.has(p.id),
|
|
@@ -27,15 +27,18 @@ export async function buildPluginListResponse(plugins, assets, disabled, withUpd
|
|
|
27
27
|
}
|
|
28
28
|
export async function registerPluginsApi(app) {
|
|
29
29
|
app.get('/api/plugins', async (req) => {
|
|
30
|
-
const
|
|
30
|
+
const query = req.query;
|
|
31
|
+
const withUpdates = query.updates === '1';
|
|
32
|
+
const forceUpdates = query.refresh === '1';
|
|
31
33
|
const [plugins, assets, disabled] = await Promise.all([getPlugins(), discoverPluginAssets(), readDisabled()]);
|
|
32
|
-
return buildPluginListResponse(plugins, assets, disabled, withUpdates);
|
|
34
|
+
return buildPluginListResponse(plugins, assets, disabled, withUpdates, forceUpdates);
|
|
33
35
|
});
|
|
34
|
-
app.get('/api/runtime', async () => {
|
|
36
|
+
app.get('/api/runtime', async (req) => {
|
|
35
37
|
const runtime = await discoverRuntime();
|
|
36
38
|
if (!runtime)
|
|
37
39
|
return { installedVersion: null, latestVersion: null };
|
|
38
|
-
const
|
|
40
|
+
const forceUpdates = req.query.refresh === '1';
|
|
41
|
+
const latestVersion = runtime.local ? null : await checkLatestVersion(runtime.packageName, { force: forceUpdates });
|
|
39
42
|
return { installedVersion: runtime.installedVersion, latestVersion };
|
|
40
43
|
});
|
|
41
44
|
app.get('/plugins/:id/:file', async (req, reply) => {
|