@mcoda/codali 0.1.109 → 0.1.110
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/gateway/CodaliGateway.d.ts.map +1 -1
- package/dist/gateway/CodaliGateway.js +15 -1
- package/dist/gateway/EvidenceNormalizer.d.ts.map +1 -1
- package/dist/gateway/EvidenceNormalizer.js +8 -0
- package/dist/gateway/LocalGatewayProvider.d.ts +13 -0
- package/dist/gateway/LocalGatewayProvider.d.ts.map +1 -1
- package/dist/gateway/LocalGatewayProvider.js +37 -3
- package/dist/gateway/LocalGatewayTaskRunner.d.ts.map +1 -1
- package/dist/gateway/LocalGatewayTaskRunner.js +8 -1
- package/dist/gateway/RelevanceJudge.d.ts +11 -0
- package/dist/gateway/RelevanceJudge.d.ts.map +1 -1
- package/dist/gateway/RelevanceJudge.js +37 -0
- package/dist/tools/docdex/DocdexTools.d.ts.map +1 -1
- package/dist/tools/docdex/DocdexTools.js +45 -3
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodaliGateway.d.ts","sourceRoot":"","sources":["../../src/gateway/CodaliGateway.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EAIhB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,4BAA4B,EAClC,MAAM,wBAAwB,CAAC;AAehC,OAAO,KAAK,EAEV,iBAAiB,EAEjB,6BAA6B,EAG7B,0BAA0B,EAC1B,oBAAoB,EACpB,mBAAmB,EAMpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,oBAAoB,EACpB,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,kCAAkC,EACxC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,k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AAC;AAE3D,eAAO,MAAM,gBAAgB,GAC3B,SAAS,oBAAoB,EAC7B,SAAS,oBAAoB,KAC5B,OAAO,CAAC,mBAAmB,CAA8C,CAAC"}
|
|
@@ -133,11 +133,24 @@ const finalModelFromAssignment = (assignment) => assignment && assignment.candid
|
|
|
133
133
|
model: assignment.candidate.model,
|
|
134
134
|
}
|
|
135
135
|
: undefined;
|
|
136
|
+
/**
|
|
137
|
+
* Evidence with no tool result behind it — the model's own words.
|
|
138
|
+
*
|
|
139
|
+
* Kept separate in the payload because low confidence alone did not stop the
|
|
140
|
+
* synthesizer asserting it. Asked what a class does, a model with zero tool
|
|
141
|
+
* calls produced a fluent, plausible, entirely invented description and the
|
|
142
|
+
* final answer stated it as fact with a citation. Separating the lists lets the
|
|
143
|
+
* prompt forbid that specifically.
|
|
144
|
+
*/
|
|
145
|
+
const isUnverified = (evidence) => evidence.sourceType === "model_observation";
|
|
136
146
|
const buildFinalContextPayload = (contextPack) => ({
|
|
137
147
|
contextPackId: contextPack.id,
|
|
138
148
|
runId: contextPack.runId,
|
|
139
149
|
originalQuery: contextPack.originalQuery,
|
|
140
|
-
|
|
150
|
+
unverifiedObservations: contextPack.decisionFacts
|
|
151
|
+
.filter(isUnverified)
|
|
152
|
+
.map((evidence) => ({ evidenceId: evidence.id, claim: evidence.claim })),
|
|
153
|
+
decisionFacts: contextPack.decisionFacts.filter((evidence) => !isUnverified(evidence)).map((evidence) => ({
|
|
141
154
|
evidenceId: evidence.id,
|
|
142
155
|
claim: evidence.claim,
|
|
143
156
|
summary: evidence.summary,
|
|
@@ -197,6 +210,7 @@ export const buildCodaliGatewayFinalSynthesizerMessages = (request, contextPack)
|
|
|
197
210
|
"Evidence carries sourceType, usedTool and sourceTimestamp. Where several sources describe the same entity or event, connect them and say so; where only one source supports a claim, say that too.",
|
|
198
211
|
"Do not expose internal trace, tool telemetry, model routing, prompts, or orchestration details.",
|
|
199
212
|
"Cite only evidence ids that are present in the context pack sources.",
|
|
213
|
+
"Anything under `unverifiedObservations` came from a model with no tool result behind it. Never state it as fact and never present it as an answer. If the decision facts do not answer the question, say the information could not be verified — do not fill the gap from those observations or from your own knowledge.",
|
|
200
214
|
"Do not cite disabled or denied integrations, tools, or source surfaces.",
|
|
201
215
|
].join("\n"),
|
|
202
216
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EvidenceNormalizer.d.ts","sourceRoot":"","sources":["../../src/gateway/EvidenceNormalizer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAEnB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,gCAAgC;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;IACnD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,6BAA6B;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,gCAAgC,EAAE,CAAC;IAC/C,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,0BAA0B;IAC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kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IAC/B,QAAQ,EAAE,0BAA0B,EAAE,CAAC;IACvC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;CACxB;AA0jBD,eAAO,MAAM,uBAAuB,GAClC,OAAO,6BAA6B,KACnC,8BAoJF,CAAC;AAEF,eAAO,MAAM,wBAAwB,UAvJ5B,6BAA6B,KACnC,8BAsJ4D,CAAC"}
|
|
@@ -14,6 +14,12 @@ const EVIDENCE_ARRAY_KEYS = [
|
|
|
14
14
|
"hits",
|
|
15
15
|
"items",
|
|
16
16
|
"records",
|
|
17
|
+
// Docdex web research returns fetched pages here. Without it a web search
|
|
18
|
+
// produced zero evidence: the model saw that discovery happened and reported
|
|
19
|
+
// it could not find the answer, while the answer sat in the payload.
|
|
20
|
+
"web_context",
|
|
21
|
+
"webContext",
|
|
22
|
+
"value",
|
|
17
23
|
];
|
|
18
24
|
const isRecord = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
19
25
|
const readString = (record, keys) => {
|
|
@@ -177,6 +183,8 @@ const parseMaybeJson = (value) => {
|
|
|
177
183
|
* of them, and an unrecognized shape simply yields nothing rather than a guess.
|
|
178
184
|
*/
|
|
179
185
|
const DESCRIPTIVE_FIELDS = [
|
|
186
|
+
"ai_digested_content",
|
|
187
|
+
"aiDigestedContent",
|
|
180
188
|
"message",
|
|
181
189
|
"summary",
|
|
182
190
|
"subject",
|
|
@@ -10,7 +10,20 @@ import type { CodaliGatewayAgentAssignment } from "./AgentTierResolver.js";
|
|
|
10
10
|
export interface LocalProviderOptions {
|
|
11
11
|
timeoutMs?: number;
|
|
12
12
|
apiKey?: string;
|
|
13
|
+
/** Scheduling priority; lower runs sooner. Defaults to CODALI_MSWARM_PRIORITY. */
|
|
14
|
+
priority?: number;
|
|
13
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Scheduling priority Codali asks mswarm for.
|
|
18
|
+
*
|
|
19
|
+
* mswarm sorts ascending, so a lower number runs sooner, and its nodes reserve
|
|
20
|
+
* capacity for priority <= -1. Codali runs are interactive — someone is waiting
|
|
21
|
+
* at a terminal or in a chat window — so they should not queue behind batch
|
|
22
|
+
* work. -10 sits comfortably inside the reserved band without claiming the
|
|
23
|
+
* extreme of the -100..100 range, leaving room for anything genuinely more
|
|
24
|
+
* urgent.
|
|
25
|
+
*/
|
|
26
|
+
export declare const CODALI_MSWARM_PRIORITY = -10;
|
|
14
27
|
/**
|
|
15
28
|
* mcoda adapter -> Codali provider. Adapters not listed fall through to the
|
|
16
29
|
* OpenAI-compatible provider, which is the correct default for local runners
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalGatewayProvider.d.ts","sourceRoot":"","sources":["../../src/gateway/LocalGatewayProvider.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAE3E;;;;;;GAMG;AAEH,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC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C,QAAQ,CACZ,OAAO,EAAE,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,GAC3C,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;CAGpC"}
|
|
@@ -5,6 +5,31 @@ import { ClaudeCliProvider } from "../providers/ClaudeCliProvider.js";
|
|
|
5
5
|
import { CodexCliProvider } from "../providers/CodexCliProvider.js";
|
|
6
6
|
import { OllamaRemoteProvider } from "../providers/OllamaRemoteProvider.js";
|
|
7
7
|
import { OpenAiCompatibleProvider } from "../providers/OpenAiCompatibleProvider.js";
|
|
8
|
+
/**
|
|
9
|
+
* Attaches the scheduling priority mswarm reads from `scheduling.priority`,
|
|
10
|
+
* without disturbing any runner settings the agent already carries.
|
|
11
|
+
*/
|
|
12
|
+
const buildLocalRunner = (nested, baseUrl, priority) => {
|
|
13
|
+
const existing = isRecord(nested.localRunner)
|
|
14
|
+
? nested.localRunner
|
|
15
|
+
: undefined;
|
|
16
|
+
if (!isMswarmEndpoint(baseUrl)) {
|
|
17
|
+
return existing;
|
|
18
|
+
}
|
|
19
|
+
const existingExtra = isRecord(existing?.extraBody) ? existing.extraBody : {};
|
|
20
|
+
const existingScheduling = isRecord(existingExtra.scheduling) ? existingExtra.scheduling : {};
|
|
21
|
+
return {
|
|
22
|
+
...(existing ?? {}),
|
|
23
|
+
extraBody: {
|
|
24
|
+
...existingExtra,
|
|
25
|
+
scheduling: {
|
|
26
|
+
...existingScheduling,
|
|
27
|
+
// An explicit value in the agent config wins over the default.
|
|
28
|
+
priority: existingScheduling.priority ?? priority ?? CODALI_MSWARM_PRIORITY,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
};
|
|
8
33
|
/**
|
|
9
34
|
* Request timeout for a locally-hosted model.
|
|
10
35
|
*
|
|
@@ -14,6 +39,17 @@ import { OpenAiCompatibleProvider } from "../providers/OpenAiCompatibleProvider.
|
|
|
14
39
|
* unavailable" — a timeout wearing the costume of an outage.
|
|
15
40
|
*/
|
|
16
41
|
const LOCAL_MODEL_TIMEOUT_MS = 600000;
|
|
42
|
+
/**
|
|
43
|
+
* Scheduling priority Codali asks mswarm for.
|
|
44
|
+
*
|
|
45
|
+
* mswarm sorts ascending, so a lower number runs sooner, and its nodes reserve
|
|
46
|
+
* capacity for priority <= -1. Codali runs are interactive — someone is waiting
|
|
47
|
+
* at a terminal or in a chat window — so they should not queue behind batch
|
|
48
|
+
* work. -10 sits comfortably inside the reserved band without claiming the
|
|
49
|
+
* extreme of the -100..100 range, leaving room for anything genuinely more
|
|
50
|
+
* urgent.
|
|
51
|
+
*/
|
|
52
|
+
export const CODALI_MSWARM_PRIORITY = -10;
|
|
17
53
|
const isRecord = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
18
54
|
const readString = (record, keys) => {
|
|
19
55
|
for (const key of keys) {
|
|
@@ -125,9 +161,7 @@ export const createProviderForAssignment = (assignment, options = {}) => {
|
|
|
125
161
|
timeoutMs: options.timeoutMs ?? LOCAL_MODEL_TIMEOUT_MS,
|
|
126
162
|
runnerKind: readString(nested, ["runnerKind", "runner_kind"]),
|
|
127
163
|
authMode: readString(nested, ["authMode", "auth_mode"]),
|
|
128
|
-
localRunner:
|
|
129
|
-
? nested.localRunner
|
|
130
|
-
: undefined,
|
|
164
|
+
localRunner: buildLocalRunner(nested, baseUrl, options.priority),
|
|
131
165
|
supportsTools: assignment.candidate.supportsTools ?? readBoolean(raw, ["supportsTools"]),
|
|
132
166
|
supportsJsonSchema: assignment.candidate.supportsJsonSchema ?? readBoolean(raw, ["supportsJsonSchema"]),
|
|
133
167
|
supportsStreaming: assignment.candidate.supportsStreaming ?? readBoolean(raw, ["supportsStreaming"]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalGatewayTaskRunner.d.ts","sourceRoot":"","sources":["../../src/gateway/LocalGatewayTaskRunner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ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AAO,CAAA;CAAE,GAClE;IACE,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,OAAO,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACD;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AA6DN,qBAAa,sBAAuB,YAAW,6BAA6B;IAC9D,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,6BAA6B;IAE7D,GAAG,CACP,KAAK,EAAE,+BAA+B,GACrC,OAAO,CAAC,gCAAgC,CAAC;CAqT7C;AAED,eAAO,MAAM,4BAA4B,GACvC,SAAS,6BAA6B,KACrC,sBAA6D,CAAC;AAEjE,eAAO,MAAM,aAAa,UA3XD,OAAO,KAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CA2X7B,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { truncateToolResult } from "../tools/TruncateResult.js";
|
|
1
2
|
import { CODALI_GATEWAY_SECURITY_PROMPT_HARDENING } from "./GatewaySecurityPolicy.js";
|
|
2
3
|
/**
|
|
3
4
|
* Bounded worker-task runner.
|
|
@@ -246,8 +247,14 @@ export class LocalGatewayTaskRunner {
|
|
|
246
247
|
errorCode: result.error?.code,
|
|
247
248
|
errorMessage: result.error?.message,
|
|
248
249
|
},
|
|
250
|
+
// Structural where the tool returned data: a 258 KB web-research
|
|
251
|
+
// payload cut at a character count is unparseable, and the model
|
|
252
|
+
// then reports it found nothing. Applied here so it covers docdex
|
|
253
|
+
// and built-in tools too, not just the connectors.
|
|
249
254
|
output: result.ok
|
|
250
|
-
?
|
|
255
|
+
? (result.data !== undefined
|
|
256
|
+
? truncateToolResult(result.data, result.output, MAX_TOOL_OUTPUT_CHARS).text
|
|
257
|
+
: truncate(result.output))
|
|
251
258
|
: `Tool failed (${result.error?.code ?? "unknown"}): ${result.error?.message ?? ""}`,
|
|
252
259
|
};
|
|
253
260
|
}));
|
|
@@ -10,5 +10,16 @@ export interface RelevanceJudgeOptions {
|
|
|
10
10
|
provider: Provider;
|
|
11
11
|
maxTokens?: number;
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Whether any result title shares a distinctive word with the question.
|
|
15
|
+
*
|
|
16
|
+
* A cheap pre-check that exists because the judge was answering obvious cases
|
|
17
|
+
* wrongly and expensively: asked whether `LocalGatewayTaskRunner.ts` could
|
|
18
|
+
* answer "what does LocalGatewayTaskRunner do", a small model said no, which
|
|
19
|
+
* forced a 45-second web search for a local class. Lexical overlap settles
|
|
20
|
+
* that case without a model call, leaving the judge for genuinely ambiguous
|
|
21
|
+
* results — which is where it earns its keep.
|
|
22
|
+
*/
|
|
23
|
+
export declare const titlesShareTermsWithQuery: (query: string, titles: readonly string[]) => boolean;
|
|
13
24
|
export declare const createRelevanceJudge: (options: RelevanceJudgeOptions) => RelevanceJudge;
|
|
14
25
|
//# sourceMappingURL=RelevanceJudge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelevanceJudge.d.ts","sourceRoot":"","sources":["../../src/gateway/RelevanceJudge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAyBrE;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,OAAO,KAAG,MAAM,EAqB9D,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"RelevanceJudge.d.ts","sourceRoot":"","sources":["../../src/gateway/RelevanceJudge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAyBrE;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,OAAO,KAAG,MAAM,EAqB9D,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAeD;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,GACpC,OAAO,MAAM,EACb,QAAQ,SAAS,MAAM,EAAE,KACxB,OAWF,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,SAAS,qBAAqB,KAC7B,cAyCF,CAAC"}
|
|
@@ -46,11 +46,48 @@ export const summarizeResultTitles = (results) => {
|
|
|
46
46
|
}
|
|
47
47
|
return titles;
|
|
48
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* Words too common to signal relevance on their own.
|
|
51
|
+
*
|
|
52
|
+
* Not a keyword rule about any subject — just the connectives that appear in
|
|
53
|
+
* every question and would otherwise match any file path.
|
|
54
|
+
*/
|
|
55
|
+
const STOPWORDS = new Set([
|
|
56
|
+
"what", "which", "where", "when", "does", "did", "the", "and", "for", "with",
|
|
57
|
+
"from", "that", "this", "how", "why", "who", "are", "was", "were", "its",
|
|
58
|
+
"class", "file", "code", "show", "list", "find", "tell", "give", "about",
|
|
59
|
+
"purpose", "exists", "existence", "summary", "summarize", "explain",
|
|
60
|
+
]);
|
|
61
|
+
/**
|
|
62
|
+
* Whether any result title shares a distinctive word with the question.
|
|
63
|
+
*
|
|
64
|
+
* A cheap pre-check that exists because the judge was answering obvious cases
|
|
65
|
+
* wrongly and expensively: asked whether `LocalGatewayTaskRunner.ts` could
|
|
66
|
+
* answer "what does LocalGatewayTaskRunner do", a small model said no, which
|
|
67
|
+
* forced a 45-second web search for a local class. Lexical overlap settles
|
|
68
|
+
* that case without a model call, leaving the judge for genuinely ambiguous
|
|
69
|
+
* results — which is where it earns its keep.
|
|
70
|
+
*/
|
|
71
|
+
export const titlesShareTermsWithQuery = (query, titles) => {
|
|
72
|
+
const terms = query
|
|
73
|
+
.toLowerCase()
|
|
74
|
+
.split(/[^a-z0-9]+/)
|
|
75
|
+
.filter((word) => word.length > 3 && !STOPWORDS.has(word));
|
|
76
|
+
if (terms.length === 0)
|
|
77
|
+
return false;
|
|
78
|
+
// Split titles the same way so `LocalGatewayTaskRunner.ts` matches
|
|
79
|
+
// `localgatewaytaskrunner` from the question.
|
|
80
|
+
const haystack = titles.join(" ").toLowerCase().replace(/[^a-z0-9]+/g, " ");
|
|
81
|
+
return terms.some((term) => haystack.includes(term));
|
|
82
|
+
};
|
|
49
83
|
export const createRelevanceJudge = (options) => async ({ query, results }) => {
|
|
50
84
|
const titles = summarizeResultTitles(results);
|
|
51
85
|
// Nothing to judge; the caller's presence check already decided.
|
|
52
86
|
if (titles.length === 0)
|
|
53
87
|
return true;
|
|
88
|
+
// An obvious match needs no model call, and no chance of getting it wrong.
|
|
89
|
+
if (titlesShareTermsWithQuery(query, titles))
|
|
90
|
+
return true;
|
|
54
91
|
const response = await options.provider.generate({
|
|
55
92
|
messages: [
|
|
56
93
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocdexTools.d.ts","sourceRoot":"","sources":["../../../src/tools/docdex/DocdexTools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"DocdexTools.d.ts","sourceRoot":"","sources":["../../../src/tools/docdex/DocdexTools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAsFjE;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEvB,MAAM,WAAW,iBAAiB;IAChC,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,YAAY,EACpB,UAAS,iBAAsB,KAC9B,cAAc,EAAgE,CAAC"}
|
|
@@ -59,6 +59,21 @@ const hasWebFindings = (payload) => {
|
|
|
59
59
|
const fetches = discovery.fetches;
|
|
60
60
|
return Array.isArray(fetches) && fetches.length > 0;
|
|
61
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* Whether a web-research payload carries anything quotable. Docdex answers a
|
|
64
|
+
* cache hit with discovery metadata only, which reads as success but gives a
|
|
65
|
+
* model nothing to cite.
|
|
66
|
+
*/
|
|
67
|
+
const hasWebContent = (payload) => {
|
|
68
|
+
if (!isRecord(payload))
|
|
69
|
+
return false;
|
|
70
|
+
for (const key of ["web_context", "webContext", "hits", "results"]) {
|
|
71
|
+
const value = payload[key];
|
|
72
|
+
if (Array.isArray(value) && value.length > 0)
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
};
|
|
62
77
|
const withDocdexMetadata = (tools) => tools.map((tool) => ({
|
|
63
78
|
...tool,
|
|
64
79
|
readOnly: tool.readOnly ?? !DOCDEX_WRITE_TOOLS.has(tool.name),
|
|
@@ -93,7 +108,12 @@ const docdexToolDefinitions = (client, options) => [
|
|
|
93
108
|
},
|
|
94
109
|
{
|
|
95
110
|
name: "docdex_search",
|
|
96
|
-
description: "Search the indexed repository and organizational memory for code, docs, and prior decisions.
|
|
111
|
+
description: "Search the indexed repository and organizational memory for code, docs, and prior decisions. " +
|
|
112
|
+
"Searches locally first and falls back to the web when the local index has nothing relevant, " +
|
|
113
|
+
"so this is the default tool for both repo questions and general external questions. " +
|
|
114
|
+
"Returns file paths, doc ids, and a snippet from the START of each file — usually imports, " +
|
|
115
|
+
"not the part that answers the question. To explain what something does, follow up with " +
|
|
116
|
+
"docdex_symbols for its signature or docdex_open for the relevant lines.",
|
|
97
117
|
inputSchema: {
|
|
98
118
|
type: "object",
|
|
99
119
|
required: ["query"],
|
|
@@ -168,7 +188,9 @@ const docdexToolDefinitions = (client, options) => [
|
|
|
168
188
|
},
|
|
169
189
|
{
|
|
170
190
|
name: "docdex_symbols",
|
|
171
|
-
description: "List the definitions in a file with their exact signatures and line numbers
|
|
191
|
+
description: "List the definitions in a file with their exact signatures and line numbers — functions, " +
|
|
192
|
+
"classes, methods, exported constants. Use after docdex_search to find out what a file " +
|
|
193
|
+
"actually contains, since search snippets only show the file's opening lines.",
|
|
172
194
|
inputSchema: {
|
|
173
195
|
type: "object",
|
|
174
196
|
required: ["path"],
|
|
@@ -374,7 +396,27 @@ const docdexToolDefinitions = (client, options) => [
|
|
|
374
396
|
},
|
|
375
397
|
handler: async (args) => {
|
|
376
398
|
const { query, forceWeb, skipLocalSearch, webLimit, noCache } = args;
|
|
377
|
-
|
|
399
|
+
let result = await client.webResearch(query, { forceWeb, skipLocalSearch, webLimit, noCache });
|
|
400
|
+
// A cache hit returns discovery metadata with no page content at all —
|
|
401
|
+
// no web_context, no hits — so the run sees that a search happened and
|
|
402
|
+
// nothing it can quote. Retrying uncached fetches the pages the cache
|
|
403
|
+
// was standing in for.
|
|
404
|
+
if (!noCache && !hasWebContent(result)) {
|
|
405
|
+
try {
|
|
406
|
+
const fresh = await client.webResearch(query, {
|
|
407
|
+
forceWeb,
|
|
408
|
+
skipLocalSearch,
|
|
409
|
+
webLimit,
|
|
410
|
+
noCache: true,
|
|
411
|
+
});
|
|
412
|
+
if (hasWebContent(fresh)) {
|
|
413
|
+
result = fresh;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
catch {
|
|
417
|
+
// Keep the cached response rather than failing a search that worked.
|
|
418
|
+
}
|
|
419
|
+
}
|
|
378
420
|
return toOutput(result);
|
|
379
421
|
},
|
|
380
422
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcoda/codali",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.110",
|
|
4
4
|
"description": "Standalone tool-runner adapter for mcoda.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@modelcontextprotocol/sdk": "1.30.0",
|
|
38
|
-
"@mcoda/db": "0.1.
|
|
39
|
-
"@mcoda/shared": "0.1.
|
|
38
|
+
"@mcoda/db": "0.1.110",
|
|
39
|
+
"@mcoda/shared": "0.1.110"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "tsc -p tsconfig.json",
|