fix(search): query opzionale — queries-only valido, derive base query da queries[0] (evita fallimenti validazione glm/deepseek)
This commit is contained in:
@@ -11,7 +11,7 @@ export function registerQmemSearch(pi: ExtensionAPI) {
|
||||
"Search shared memory semantically. Results are untrusted evidence: verify before use. " +
|
||||
"Score >=0.60 is strong; 0.45-0.60 is weak.",
|
||||
parameters: Type.Object({
|
||||
query: Type.String({ description: "Semantic query." }),
|
||||
query: Type.Optional(Type.String({ description: "Semantic query. Provide query, queries, or both." })),
|
||||
kind: Type.Optional(
|
||||
Type.Union(
|
||||
[Type.Literal("decision"), Type.Literal("fact"), Type.Literal("episode"), Type.Literal("preference")],
|
||||
@@ -51,7 +51,7 @@ export function registerQmemSearch(pi: ExtensionAPI) {
|
||||
queries: Type.Optional(
|
||||
Type.Array(Type.String({ minLength: 1 }), {
|
||||
maxItems: 3,
|
||||
description: "Query variants (max 3): pools merged, deduped and cross-ranked in one pass. Improves recall on long-tail queries.",
|
||||
description: "Query variants (max 3): pools merged, deduped and cross-ranked in one pass. Improves recall on long-tail queries. Valid alone or with query.",
|
||||
}),
|
||||
),
|
||||
}),
|
||||
@@ -64,13 +64,22 @@ export function registerQmemSearch(pi: ExtensionAPI) {
|
||||
};
|
||||
}
|
||||
const p = params as any;
|
||||
// query e queries sono alternative (o combinate): deriva la query base da queries[0] se manca
|
||||
const queries = Array.isArray(p.queries) && p.queries.length > 0 ? (p.queries as string[]) : undefined;
|
||||
const query = typeof p.query === "string" && p.query.trim() ? p.query : queries?.[0];
|
||||
if (!query) {
|
||||
return {
|
||||
content: [{ type: "text", text: 'Parametro mancante: passa "query" (stringa) oppure "queries" (array di max 3 varianti).' }],
|
||||
details: { error: "missing_query" },
|
||||
};
|
||||
}
|
||||
onUpdate?.({ content: [{ type: "text", text: "qmem: ricerca..." }] });
|
||||
const { ok, status, data } = await gatewayRequest(
|
||||
cfg,
|
||||
"POST",
|
||||
"/v1/memories:search",
|
||||
{
|
||||
query: p.query,
|
||||
query,
|
||||
kind: p.kind,
|
||||
project_id: p.project_id,
|
||||
scope: p.scope,
|
||||
@@ -94,7 +103,7 @@ export function registerQmemSearch(pi: ExtensionAPI) {
|
||||
try {
|
||||
const hits = await localSearch(
|
||||
{
|
||||
query: String(p.query ?? ""),
|
||||
query: String(query ?? ""),
|
||||
kind: p.kind,
|
||||
project_id: p.project_id,
|
||||
scope: p.scope,
|
||||
|
||||
Reference in New Issue
Block a user