@autorag/librarian 2.13.10 → 2.13.12
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/agent/decision-backends.d.ts +1 -1
- package/dist/cli/config.d.ts +1 -1
- package/dist/cli/index.js +29 -7
- package/dist/core.js +29 -7
- package/dist/index.js +66 -10
- package/dist/mcp/index.js +66 -10
- package/dist/mcp/server.d.ts +16 -0
- package/dist/profiles.js +29 -7
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ClassifierApi, type ClassifierContext, type ClassifierModel, type ClassifierResult, type ModelsClassifierOptions } from "@earendil-works/pi-ai";
|
|
2
2
|
import { type BackendRequest, type BackendResponse, type JevBackend } from "jev-use";
|
|
3
3
|
/**
|
|
4
4
|
* Decision models come from pi's model catalog: pi-ai ships every provider's typed-question
|
package/dist/cli/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Api, type Model } from "@earendil-works/pi-ai";
|
|
2
2
|
import { ModelRuntime } from "@earendil-works/pi-coding-agent";
|
|
3
3
|
import type { AutoRAGAgentOptions, AutoRAGRefreshLimits, AutoRAGRetrievalLimits } from "../agent/agent.js";
|
|
4
4
|
import { type LoadLocalAutoRAGModelOptions } from "../agent/local-model.js";
|
package/dist/cli/index.js
CHANGED
|
@@ -1740,6 +1740,9 @@ import { homedir as homedir2 } from "node:os";
|
|
|
1740
1740
|
import { join as join7 } from "node:path";
|
|
1741
1741
|
import { parse as parse2 } from "smol-toml";
|
|
1742
1742
|
function loadLocalAutoRAGModel(options = {}) {
|
|
1743
|
+
if (process.env.AUTORAG_AUTH_MODE === "environment") {
|
|
1744
|
+
throw new Error("External model config discovery is disabled; configure the model endpoint and its environment key explicitly.");
|
|
1745
|
+
}
|
|
1743
1746
|
const configPath = options.configPath ?? join7(homedir2(), ".codex", "config.toml");
|
|
1744
1747
|
const config = parse2(readFileSync7(configPath, "utf8"));
|
|
1745
1748
|
const provider = config.model_provider;
|
|
@@ -2667,6 +2670,8 @@ var init_models = __esm(() => {
|
|
|
2667
2670
|
import { join as join9 } from "node:path";
|
|
2668
2671
|
import { getAgentDir, readStoredCredential } from "@earendil-works/pi-coding-agent";
|
|
2669
2672
|
function readDazziLoginToken(agentDir = getAgentDir()) {
|
|
2673
|
+
if (process.env.AUTORAG_AUTH_MODE === "environment")
|
|
2674
|
+
return;
|
|
2670
2675
|
return resolveCredentialKey(readStoredCredential(PROVIDER_ID, join9(agentDir, "auth.json")));
|
|
2671
2676
|
}
|
|
2672
2677
|
function isDazziSignedIn(agentDir = getAgentDir()) {
|
|
@@ -15738,6 +15743,7 @@ var init_types3 = __esm(() => {
|
|
|
15738
15743
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
15739
15744
|
import { existsSync as existsSync15, mkdirSync as mkdirSync13, readFileSync as readFileSync17, unlinkSync as unlinkSync2, writeFileSync as writeFileSync9 } from "node:fs";
|
|
15740
15745
|
import { basename as basename6, dirname as dirname13, isAbsolute as isAbsolute6, join as join24, resolve as resolve7 } from "node:path";
|
|
15746
|
+
import { InMemoryCredentialStore } from "@earendil-works/pi-ai";
|
|
15741
15747
|
import { findEnvKeys, getEnvApiKey } from "@earendil-works/pi-ai/compat";
|
|
15742
15748
|
import { getAgentDir as getAgentDir2, ModelRuntime, SettingsManager } from "@earendil-works/pi-coding-agent";
|
|
15743
15749
|
function resolveConfigPath(input) {
|
|
@@ -16781,10 +16787,20 @@ function resolveAgentDir(options) {
|
|
|
16781
16787
|
return options.agentDir ?? getAgentDir2();
|
|
16782
16788
|
}
|
|
16783
16789
|
function getModelRuntime(agentDir) {
|
|
16784
|
-
const
|
|
16790
|
+
const environmentOnly = process.env.AUTORAG_AUTH_MODE === "environment";
|
|
16791
|
+
const cacheKey = `${environmentOnly ? "environment" : "stored"}:${agentDir}`;
|
|
16792
|
+
const cached = modelRuntimeCache.get(cacheKey);
|
|
16785
16793
|
if (cached !== undefined)
|
|
16786
16794
|
return cached;
|
|
16787
16795
|
const created = (async () => {
|
|
16796
|
+
if (environmentOnly) {
|
|
16797
|
+
return ModelRuntime.create({
|
|
16798
|
+
credentials: new InMemoryCredentialStore,
|
|
16799
|
+
modelsPath: null,
|
|
16800
|
+
allowModelNetwork: false,
|
|
16801
|
+
refreshOnCreate: false
|
|
16802
|
+
});
|
|
16803
|
+
}
|
|
16788
16804
|
const runtime = await ModelRuntime.create({
|
|
16789
16805
|
authPath: join24(agentDir, "auth.json"),
|
|
16790
16806
|
modelsPath: join24(agentDir, "models.json"),
|
|
@@ -16793,9 +16809,9 @@ function getModelRuntime(agentDir) {
|
|
|
16793
16809
|
await registerDazziProvider(runtime);
|
|
16794
16810
|
return runtime;
|
|
16795
16811
|
})();
|
|
16796
|
-
modelRuntimeCache.set(
|
|
16812
|
+
modelRuntimeCache.set(cacheKey, created);
|
|
16797
16813
|
created.catch(() => {
|
|
16798
|
-
modelRuntimeCache.delete(
|
|
16814
|
+
modelRuntimeCache.delete(cacheKey);
|
|
16799
16815
|
});
|
|
16800
16816
|
return created;
|
|
16801
16817
|
}
|
|
@@ -16826,6 +16842,8 @@ function localRuntimeAuth(local) {
|
|
|
16826
16842
|
};
|
|
16827
16843
|
}
|
|
16828
16844
|
async function resolvePiDefaultModel(runtime, options) {
|
|
16845
|
+
if (process.env.AUTORAG_AUTH_MODE === "environment")
|
|
16846
|
+
return;
|
|
16829
16847
|
let provider;
|
|
16830
16848
|
let id;
|
|
16831
16849
|
try {
|
|
@@ -32152,17 +32170,21 @@ var init_datasource_skill = __esm(() => {
|
|
|
32152
32170
|
|
|
32153
32171
|
// src/agent/decision-backends.ts
|
|
32154
32172
|
import { join as join48 } from "node:path";
|
|
32173
|
+
import {
|
|
32174
|
+
InMemoryCredentialStore as InMemoryCredentialStore2
|
|
32175
|
+
} from "@earendil-works/pi-ai";
|
|
32155
32176
|
import { getAgentDir as getAgentDir3, ModelRuntime as ModelRuntime3 } from "@earendil-works/pi-coding-agent";
|
|
32156
32177
|
import { BackendError as BackendError3 } from "jev-use";
|
|
32157
32178
|
function runtimeFor(agentDir) {
|
|
32158
|
-
|
|
32179
|
+
const environmentOnly = process.env.AUTORAG_AUTH_MODE === "environment";
|
|
32180
|
+
const cacheKey = `${environmentOnly ? "environment" : "stored"}:${agentDir}`;
|
|
32181
|
+
let runtime = runtimes.get(cacheKey);
|
|
32159
32182
|
if (runtime === undefined) {
|
|
32160
32183
|
runtime = ModelRuntime3.create({
|
|
32161
|
-
authPath: join48(agentDir, "auth.json"),
|
|
32162
|
-
modelsPath: join48(agentDir, "models.json"),
|
|
32184
|
+
...environmentOnly ? { credentials: new InMemoryCredentialStore2, modelsPath: null, refreshOnCreate: false } : { authPath: join48(agentDir, "auth.json"), modelsPath: join48(agentDir, "models.json") },
|
|
32163
32185
|
allowModelNetwork: false
|
|
32164
32186
|
});
|
|
32165
|
-
runtimes.set(
|
|
32187
|
+
runtimes.set(cacheKey, runtime);
|
|
32166
32188
|
}
|
|
32167
32189
|
return runtime;
|
|
32168
32190
|
}
|
package/dist/core.js
CHANGED
|
@@ -11569,6 +11569,8 @@ var init_models = __esm(() => {
|
|
|
11569
11569
|
import { join as join28 } from "node:path";
|
|
11570
11570
|
import { getAgentDir, readStoredCredential } from "@earendil-works/pi-coding-agent";
|
|
11571
11571
|
function readDazziLoginToken(agentDir = getAgentDir()) {
|
|
11572
|
+
if (process.env.AUTORAG_AUTH_MODE === "environment")
|
|
11573
|
+
return;
|
|
11572
11574
|
return resolveCredentialKey(readStoredCredential(PROVIDER_ID, join28(agentDir, "auth.json")));
|
|
11573
11575
|
}
|
|
11574
11576
|
function isDazziSignedIn(agentDir = getAgentDir()) {
|
|
@@ -16776,6 +16778,9 @@ import { homedir as homedir3 } from "node:os";
|
|
|
16776
16778
|
import { join as join32 } from "node:path";
|
|
16777
16779
|
import { parse as parse2 } from "smol-toml";
|
|
16778
16780
|
function loadLocalAutoRAGModel(options = {}) {
|
|
16781
|
+
if (process.env.AUTORAG_AUTH_MODE === "environment") {
|
|
16782
|
+
throw new Error("External model config discovery is disabled; configure the model endpoint and its environment key explicitly.");
|
|
16783
|
+
}
|
|
16779
16784
|
const configPath = options.configPath ?? join32(homedir3(), ".codex", "config.toml");
|
|
16780
16785
|
const config = parse2(readFileSync16(configPath, "utf8"));
|
|
16781
16786
|
const provider = config.model_provider;
|
|
@@ -27929,6 +27934,7 @@ var init_factory = __esm(() => {
|
|
|
27929
27934
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
27930
27935
|
import { existsSync as existsSync27, mkdirSync as mkdirSync21, readFileSync as readFileSync24, unlinkSync as unlinkSync3, writeFileSync as writeFileSync14 } from "node:fs";
|
|
27931
27936
|
import { basename as basename13, dirname as dirname24, isAbsolute as isAbsolute11, join as join43, resolve as resolve15 } from "node:path";
|
|
27937
|
+
import { InMemoryCredentialStore } from "@earendil-works/pi-ai";
|
|
27932
27938
|
import { findEnvKeys, getEnvApiKey } from "@earendil-works/pi-ai/compat";
|
|
27933
27939
|
import { getAgentDir as getAgentDir2, ModelRuntime, SettingsManager } from "@earendil-works/pi-coding-agent";
|
|
27934
27940
|
function resolveConfigPath(input) {
|
|
@@ -28972,10 +28978,20 @@ function resolveAgentDir(options) {
|
|
|
28972
28978
|
return options.agentDir ?? getAgentDir2();
|
|
28973
28979
|
}
|
|
28974
28980
|
function getModelRuntime(agentDir) {
|
|
28975
|
-
const
|
|
28981
|
+
const environmentOnly = process.env.AUTORAG_AUTH_MODE === "environment";
|
|
28982
|
+
const cacheKey = `${environmentOnly ? "environment" : "stored"}:${agentDir}`;
|
|
28983
|
+
const cached = modelRuntimeCache.get(cacheKey);
|
|
28976
28984
|
if (cached !== undefined)
|
|
28977
28985
|
return cached;
|
|
28978
28986
|
const created = (async () => {
|
|
28987
|
+
if (environmentOnly) {
|
|
28988
|
+
return ModelRuntime.create({
|
|
28989
|
+
credentials: new InMemoryCredentialStore,
|
|
28990
|
+
modelsPath: null,
|
|
28991
|
+
allowModelNetwork: false,
|
|
28992
|
+
refreshOnCreate: false
|
|
28993
|
+
});
|
|
28994
|
+
}
|
|
28979
28995
|
const runtime = await ModelRuntime.create({
|
|
28980
28996
|
authPath: join43(agentDir, "auth.json"),
|
|
28981
28997
|
modelsPath: join43(agentDir, "models.json"),
|
|
@@ -28984,9 +29000,9 @@ function getModelRuntime(agentDir) {
|
|
|
28984
29000
|
await registerDazziProvider(runtime);
|
|
28985
29001
|
return runtime;
|
|
28986
29002
|
})();
|
|
28987
|
-
modelRuntimeCache.set(
|
|
29003
|
+
modelRuntimeCache.set(cacheKey, created);
|
|
28988
29004
|
created.catch(() => {
|
|
28989
|
-
modelRuntimeCache.delete(
|
|
29005
|
+
modelRuntimeCache.delete(cacheKey);
|
|
28990
29006
|
});
|
|
28991
29007
|
return created;
|
|
28992
29008
|
}
|
|
@@ -29017,6 +29033,8 @@ function localRuntimeAuth(local) {
|
|
|
29017
29033
|
};
|
|
29018
29034
|
}
|
|
29019
29035
|
async function resolvePiDefaultModel(runtime, options) {
|
|
29036
|
+
if (process.env.AUTORAG_AUTH_MODE === "environment")
|
|
29037
|
+
return;
|
|
29020
29038
|
let provider;
|
|
29021
29039
|
let id;
|
|
29022
29040
|
try {
|
|
@@ -33957,17 +33975,21 @@ var init_datasource_skill = __esm(() => {
|
|
|
33957
33975
|
|
|
33958
33976
|
// src/agent/decision-backends.ts
|
|
33959
33977
|
import { join as join52 } from "node:path";
|
|
33978
|
+
import {
|
|
33979
|
+
InMemoryCredentialStore as InMemoryCredentialStore2
|
|
33980
|
+
} from "@earendil-works/pi-ai";
|
|
33960
33981
|
import { getAgentDir as getAgentDir5, ModelRuntime as ModelRuntime4 } from "@earendil-works/pi-coding-agent";
|
|
33961
33982
|
import { BackendError as BackendError3 } from "jev-use";
|
|
33962
33983
|
function runtimeFor(agentDir) {
|
|
33963
|
-
|
|
33984
|
+
const environmentOnly = process.env.AUTORAG_AUTH_MODE === "environment";
|
|
33985
|
+
const cacheKey = `${environmentOnly ? "environment" : "stored"}:${agentDir}`;
|
|
33986
|
+
let runtime = runtimes.get(cacheKey);
|
|
33964
33987
|
if (runtime === undefined) {
|
|
33965
33988
|
runtime = ModelRuntime4.create({
|
|
33966
|
-
authPath: join52(agentDir, "auth.json"),
|
|
33967
|
-
modelsPath: join52(agentDir, "models.json"),
|
|
33989
|
+
...environmentOnly ? { credentials: new InMemoryCredentialStore2, modelsPath: null, refreshOnCreate: false } : { authPath: join52(agentDir, "auth.json"), modelsPath: join52(agentDir, "models.json") },
|
|
33968
33990
|
allowModelNetwork: false
|
|
33969
33991
|
});
|
|
33970
|
-
runtimes.set(
|
|
33992
|
+
runtimes.set(cacheKey, runtime);
|
|
33971
33993
|
}
|
|
33972
33994
|
return runtime;
|
|
33973
33995
|
}
|
package/dist/index.js
CHANGED
|
@@ -11569,6 +11569,8 @@ var init_models = __esm(() => {
|
|
|
11569
11569
|
import { join as join28 } from "node:path";
|
|
11570
11570
|
import { getAgentDir, readStoredCredential } from "@earendil-works/pi-coding-agent";
|
|
11571
11571
|
function readDazziLoginToken(agentDir = getAgentDir()) {
|
|
11572
|
+
if (process.env.AUTORAG_AUTH_MODE === "environment")
|
|
11573
|
+
return;
|
|
11572
11574
|
return resolveCredentialKey(readStoredCredential(PROVIDER_ID, join28(agentDir, "auth.json")));
|
|
11573
11575
|
}
|
|
11574
11576
|
function isDazziSignedIn(agentDir = getAgentDir()) {
|
|
@@ -16776,6 +16778,9 @@ import { homedir as homedir3 } from "node:os";
|
|
|
16776
16778
|
import { join as join32 } from "node:path";
|
|
16777
16779
|
import { parse as parse2 } from "smol-toml";
|
|
16778
16780
|
function loadLocalAutoRAGModel(options = {}) {
|
|
16781
|
+
if (process.env.AUTORAG_AUTH_MODE === "environment") {
|
|
16782
|
+
throw new Error("External model config discovery is disabled; configure the model endpoint and its environment key explicitly.");
|
|
16783
|
+
}
|
|
16779
16784
|
const configPath = options.configPath ?? join32(homedir3(), ".codex", "config.toml");
|
|
16780
16785
|
const config = parse2(readFileSync16(configPath, "utf8"));
|
|
16781
16786
|
const provider = config.model_provider;
|
|
@@ -27929,6 +27934,7 @@ var init_factory = __esm(() => {
|
|
|
27929
27934
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
27930
27935
|
import { existsSync as existsSync27, mkdirSync as mkdirSync21, readFileSync as readFileSync24, unlinkSync as unlinkSync3, writeFileSync as writeFileSync14 } from "node:fs";
|
|
27931
27936
|
import { basename as basename13, dirname as dirname24, isAbsolute as isAbsolute11, join as join43, resolve as resolve15 } from "node:path";
|
|
27937
|
+
import { InMemoryCredentialStore } from "@earendil-works/pi-ai";
|
|
27932
27938
|
import { findEnvKeys, getEnvApiKey } from "@earendil-works/pi-ai/compat";
|
|
27933
27939
|
import { getAgentDir as getAgentDir2, ModelRuntime, SettingsManager } from "@earendil-works/pi-coding-agent";
|
|
27934
27940
|
function resolveConfigPath(input) {
|
|
@@ -28972,10 +28978,20 @@ function resolveAgentDir(options) {
|
|
|
28972
28978
|
return options.agentDir ?? getAgentDir2();
|
|
28973
28979
|
}
|
|
28974
28980
|
function getModelRuntime(agentDir) {
|
|
28975
|
-
const
|
|
28981
|
+
const environmentOnly = process.env.AUTORAG_AUTH_MODE === "environment";
|
|
28982
|
+
const cacheKey = `${environmentOnly ? "environment" : "stored"}:${agentDir}`;
|
|
28983
|
+
const cached = modelRuntimeCache.get(cacheKey);
|
|
28976
28984
|
if (cached !== undefined)
|
|
28977
28985
|
return cached;
|
|
28978
28986
|
const created = (async () => {
|
|
28987
|
+
if (environmentOnly) {
|
|
28988
|
+
return ModelRuntime.create({
|
|
28989
|
+
credentials: new InMemoryCredentialStore,
|
|
28990
|
+
modelsPath: null,
|
|
28991
|
+
allowModelNetwork: false,
|
|
28992
|
+
refreshOnCreate: false
|
|
28993
|
+
});
|
|
28994
|
+
}
|
|
28979
28995
|
const runtime = await ModelRuntime.create({
|
|
28980
28996
|
authPath: join43(agentDir, "auth.json"),
|
|
28981
28997
|
modelsPath: join43(agentDir, "models.json"),
|
|
@@ -28984,9 +29000,9 @@ function getModelRuntime(agentDir) {
|
|
|
28984
29000
|
await registerDazziProvider(runtime);
|
|
28985
29001
|
return runtime;
|
|
28986
29002
|
})();
|
|
28987
|
-
modelRuntimeCache.set(
|
|
29003
|
+
modelRuntimeCache.set(cacheKey, created);
|
|
28988
29004
|
created.catch(() => {
|
|
28989
|
-
modelRuntimeCache.delete(
|
|
29005
|
+
modelRuntimeCache.delete(cacheKey);
|
|
28990
29006
|
});
|
|
28991
29007
|
return created;
|
|
28992
29008
|
}
|
|
@@ -29017,6 +29033,8 @@ function localRuntimeAuth(local) {
|
|
|
29017
29033
|
};
|
|
29018
29034
|
}
|
|
29019
29035
|
async function resolvePiDefaultModel(runtime, options) {
|
|
29036
|
+
if (process.env.AUTORAG_AUTH_MODE === "environment")
|
|
29037
|
+
return;
|
|
29020
29038
|
let provider;
|
|
29021
29039
|
let id;
|
|
29022
29040
|
try {
|
|
@@ -33957,17 +33975,21 @@ var init_datasource_skill = __esm(() => {
|
|
|
33957
33975
|
|
|
33958
33976
|
// src/agent/decision-backends.ts
|
|
33959
33977
|
import { join as join52 } from "node:path";
|
|
33978
|
+
import {
|
|
33979
|
+
InMemoryCredentialStore as InMemoryCredentialStore2
|
|
33980
|
+
} from "@earendil-works/pi-ai";
|
|
33960
33981
|
import { getAgentDir as getAgentDir5, ModelRuntime as ModelRuntime4 } from "@earendil-works/pi-coding-agent";
|
|
33961
33982
|
import { BackendError as BackendError3 } from "jev-use";
|
|
33962
33983
|
function runtimeFor(agentDir) {
|
|
33963
|
-
|
|
33984
|
+
const environmentOnly = process.env.AUTORAG_AUTH_MODE === "environment";
|
|
33985
|
+
const cacheKey = `${environmentOnly ? "environment" : "stored"}:${agentDir}`;
|
|
33986
|
+
let runtime = runtimes.get(cacheKey);
|
|
33964
33987
|
if (runtime === undefined) {
|
|
33965
33988
|
runtime = ModelRuntime4.create({
|
|
33966
|
-
authPath: join52(agentDir, "auth.json"),
|
|
33967
|
-
modelsPath: join52(agentDir, "models.json"),
|
|
33989
|
+
...environmentOnly ? { credentials: new InMemoryCredentialStore2, modelsPath: null, refreshOnCreate: false } : { authPath: join52(agentDir, "auth.json"), modelsPath: join52(agentDir, "models.json") },
|
|
33968
33990
|
allowModelNetwork: false
|
|
33969
33991
|
});
|
|
33970
|
-
runtimes.set(
|
|
33992
|
+
runtimes.set(cacheKey, runtime);
|
|
33971
33993
|
}
|
|
33972
33994
|
return runtime;
|
|
33973
33995
|
}
|
|
@@ -43294,6 +43316,37 @@ function jsonResult(value, isError = false) {
|
|
|
43294
43316
|
function toolError(code, message, extra = {}) {
|
|
43295
43317
|
return jsonResult({ ok: false, errorCode: code, message, ...extra }, true);
|
|
43296
43318
|
}
|
|
43319
|
+
var DIAGNOSTIC_EXAMPLES_PER_CODE = 3;
|
|
43320
|
+
function capDiagnostics(diagnostics) {
|
|
43321
|
+
const byCode = new Map;
|
|
43322
|
+
for (const entry of diagnostics) {
|
|
43323
|
+
const list = byCode.get(entry.code);
|
|
43324
|
+
if (list === undefined)
|
|
43325
|
+
byCode.set(entry.code, [entry]);
|
|
43326
|
+
else
|
|
43327
|
+
list.push(entry);
|
|
43328
|
+
}
|
|
43329
|
+
const out = [];
|
|
43330
|
+
for (const [code, entries] of byCode) {
|
|
43331
|
+
out.push(...entries.slice(0, DIAGNOSTIC_EXAMPLES_PER_CODE));
|
|
43332
|
+
const rest = entries.slice(DIAGNOSTIC_EXAMPLES_PER_CODE);
|
|
43333
|
+
if (rest.length === 0)
|
|
43334
|
+
continue;
|
|
43335
|
+
const reasons = new Map;
|
|
43336
|
+
for (const entry of rest) {
|
|
43337
|
+
const key = entry.reason ?? "unspecified";
|
|
43338
|
+
reasons.set(key, (reasons.get(key) ?? 0) + 1);
|
|
43339
|
+
}
|
|
43340
|
+
const split = [...reasons].map(([reason, count]) => `${reason}: ${count}`).join(", ");
|
|
43341
|
+
const severity = entries.some((entry) => entry.severity === "error") ? "error" : entries.some((entry) => entry.severity === "warning") ? "warning" : "info";
|
|
43342
|
+
out.push({
|
|
43343
|
+
code,
|
|
43344
|
+
severity,
|
|
43345
|
+
message: `${rest.length} more ${code} entries omitted (${split}); the first ${DIAGNOSTIC_EXAMPLES_PER_CODE} are shown above.`
|
|
43346
|
+
});
|
|
43347
|
+
}
|
|
43348
|
+
return out;
|
|
43349
|
+
}
|
|
43297
43350
|
function convertResult(details) {
|
|
43298
43351
|
const { result, links } = details;
|
|
43299
43352
|
const files = result.files.slice(0, MAX_CONVERT_FILES).map((file) => ({
|
|
@@ -43439,7 +43492,10 @@ function createAutoRAGMcpServer(lite, options = {}) {
|
|
|
43439
43492
|
inputSchema: emptyInput,
|
|
43440
43493
|
outputSchema: objectOutput,
|
|
43441
43494
|
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
43442
|
-
}, async () =>
|
|
43495
|
+
}, async () => {
|
|
43496
|
+
const status = await lite.getRefreshStatus();
|
|
43497
|
+
return jsonResult({ ...status, diagnostics: capDiagnostics(status.diagnostics) });
|
|
43498
|
+
});
|
|
43443
43499
|
}
|
|
43444
43500
|
if (isToolEnabled("autorag.search", options)) {
|
|
43445
43501
|
server.registerTool("autorag.search", {
|
|
@@ -43478,7 +43534,7 @@ function createAutoRAGMcpServer(lite, options = {}) {
|
|
|
43478
43534
|
content: result.content
|
|
43479
43535
|
})),
|
|
43480
43536
|
unsearched: retrieved.unsearched,
|
|
43481
|
-
diagnostics: [...status.diagnostics, ...retrieved.diagnostics]
|
|
43537
|
+
diagnostics: capDiagnostics([...status.diagnostics, ...retrieved.diagnostics])
|
|
43482
43538
|
});
|
|
43483
43539
|
} catch (error) {
|
|
43484
43540
|
return toolError(error instanceof RetrievalSelectionError ? "invalid-selection" : "search-failed", error instanceof Error ? error.message : String(error), { retryable: !(error instanceof RetrievalSelectionError) });
|
|
@@ -43533,7 +43589,7 @@ function createAutoRAGMcpServer(lite, options = {}) {
|
|
|
43533
43589
|
content: result.content
|
|
43534
43590
|
})),
|
|
43535
43591
|
unsearched: retrieved.unsearched,
|
|
43536
|
-
diagnostics: [...status.diagnostics, ...retrieved.diagnostics]
|
|
43592
|
+
diagnostics: capDiagnostics([...status.diagnostics, ...retrieved.diagnostics])
|
|
43537
43593
|
});
|
|
43538
43594
|
} catch (error) {
|
|
43539
43595
|
return toolError(error instanceof RetrievalSelectionError ? "invalid-selection" : "search-failed", error instanceof Error ? error.message : String(error), { datasourceId: entry.datasourceId, retryable: !(error instanceof RetrievalSelectionError) });
|
package/dist/mcp/index.js
CHANGED
|
@@ -11570,6 +11570,8 @@ var init_models = __esm(() => {
|
|
|
11570
11570
|
import { join as join28 } from "node:path";
|
|
11571
11571
|
import { getAgentDir, readStoredCredential } from "@earendil-works/pi-coding-agent";
|
|
11572
11572
|
function readDazziLoginToken(agentDir = getAgentDir()) {
|
|
11573
|
+
if (process.env.AUTORAG_AUTH_MODE === "environment")
|
|
11574
|
+
return;
|
|
11573
11575
|
return resolveCredentialKey(readStoredCredential(PROVIDER_ID, join28(agentDir, "auth.json")));
|
|
11574
11576
|
}
|
|
11575
11577
|
function isDazziSignedIn(agentDir = getAgentDir()) {
|
|
@@ -16777,6 +16779,9 @@ import { homedir as homedir3 } from "node:os";
|
|
|
16777
16779
|
import { join as join32 } from "node:path";
|
|
16778
16780
|
import { parse as parse2 } from "smol-toml";
|
|
16779
16781
|
function loadLocalAutoRAGModel(options = {}) {
|
|
16782
|
+
if (process.env.AUTORAG_AUTH_MODE === "environment") {
|
|
16783
|
+
throw new Error("External model config discovery is disabled; configure the model endpoint and its environment key explicitly.");
|
|
16784
|
+
}
|
|
16780
16785
|
const configPath = options.configPath ?? join32(homedir3(), ".codex", "config.toml");
|
|
16781
16786
|
const config = parse2(readFileSync16(configPath, "utf8"));
|
|
16782
16787
|
const provider = config.model_provider;
|
|
@@ -27930,6 +27935,7 @@ var init_factory = __esm(() => {
|
|
|
27930
27935
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
27931
27936
|
import { existsSync as existsSync27, mkdirSync as mkdirSync21, readFileSync as readFileSync24, unlinkSync as unlinkSync3, writeFileSync as writeFileSync14 } from "node:fs";
|
|
27932
27937
|
import { basename as basename13, dirname as dirname24, isAbsolute as isAbsolute11, join as join43, resolve as resolve15 } from "node:path";
|
|
27938
|
+
import { InMemoryCredentialStore } from "@earendil-works/pi-ai";
|
|
27933
27939
|
import { findEnvKeys, getEnvApiKey } from "@earendil-works/pi-ai/compat";
|
|
27934
27940
|
import { getAgentDir as getAgentDir2, ModelRuntime, SettingsManager } from "@earendil-works/pi-coding-agent";
|
|
27935
27941
|
function resolveConfigPath(input) {
|
|
@@ -28973,10 +28979,20 @@ function resolveAgentDir(options) {
|
|
|
28973
28979
|
return options.agentDir ?? getAgentDir2();
|
|
28974
28980
|
}
|
|
28975
28981
|
function getModelRuntime(agentDir) {
|
|
28976
|
-
const
|
|
28982
|
+
const environmentOnly = process.env.AUTORAG_AUTH_MODE === "environment";
|
|
28983
|
+
const cacheKey = `${environmentOnly ? "environment" : "stored"}:${agentDir}`;
|
|
28984
|
+
const cached = modelRuntimeCache.get(cacheKey);
|
|
28977
28985
|
if (cached !== undefined)
|
|
28978
28986
|
return cached;
|
|
28979
28987
|
const created = (async () => {
|
|
28988
|
+
if (environmentOnly) {
|
|
28989
|
+
return ModelRuntime.create({
|
|
28990
|
+
credentials: new InMemoryCredentialStore,
|
|
28991
|
+
modelsPath: null,
|
|
28992
|
+
allowModelNetwork: false,
|
|
28993
|
+
refreshOnCreate: false
|
|
28994
|
+
});
|
|
28995
|
+
}
|
|
28980
28996
|
const runtime = await ModelRuntime.create({
|
|
28981
28997
|
authPath: join43(agentDir, "auth.json"),
|
|
28982
28998
|
modelsPath: join43(agentDir, "models.json"),
|
|
@@ -28985,9 +29001,9 @@ function getModelRuntime(agentDir) {
|
|
|
28985
29001
|
await registerDazziProvider(runtime);
|
|
28986
29002
|
return runtime;
|
|
28987
29003
|
})();
|
|
28988
|
-
modelRuntimeCache.set(
|
|
29004
|
+
modelRuntimeCache.set(cacheKey, created);
|
|
28989
29005
|
created.catch(() => {
|
|
28990
|
-
modelRuntimeCache.delete(
|
|
29006
|
+
modelRuntimeCache.delete(cacheKey);
|
|
28991
29007
|
});
|
|
28992
29008
|
return created;
|
|
28993
29009
|
}
|
|
@@ -29018,6 +29034,8 @@ function localRuntimeAuth(local) {
|
|
|
29018
29034
|
};
|
|
29019
29035
|
}
|
|
29020
29036
|
async function resolvePiDefaultModel(runtime, options) {
|
|
29037
|
+
if (process.env.AUTORAG_AUTH_MODE === "environment")
|
|
29038
|
+
return;
|
|
29021
29039
|
let provider;
|
|
29022
29040
|
let id;
|
|
29023
29041
|
try {
|
|
@@ -33958,17 +33976,21 @@ var init_datasource_skill = __esm(() => {
|
|
|
33958
33976
|
|
|
33959
33977
|
// src/agent/decision-backends.ts
|
|
33960
33978
|
import { join as join52 } from "node:path";
|
|
33979
|
+
import {
|
|
33980
|
+
InMemoryCredentialStore as InMemoryCredentialStore2
|
|
33981
|
+
} from "@earendil-works/pi-ai";
|
|
33961
33982
|
import { getAgentDir as getAgentDir5, ModelRuntime as ModelRuntime4 } from "@earendil-works/pi-coding-agent";
|
|
33962
33983
|
import { BackendError as BackendError3 } from "jev-use";
|
|
33963
33984
|
function runtimeFor(agentDir) {
|
|
33964
|
-
|
|
33985
|
+
const environmentOnly = process.env.AUTORAG_AUTH_MODE === "environment";
|
|
33986
|
+
const cacheKey = `${environmentOnly ? "environment" : "stored"}:${agentDir}`;
|
|
33987
|
+
let runtime = runtimes.get(cacheKey);
|
|
33965
33988
|
if (runtime === undefined) {
|
|
33966
33989
|
runtime = ModelRuntime4.create({
|
|
33967
|
-
authPath: join52(agentDir, "auth.json"),
|
|
33968
|
-
modelsPath: join52(agentDir, "models.json"),
|
|
33990
|
+
...environmentOnly ? { credentials: new InMemoryCredentialStore2, modelsPath: null, refreshOnCreate: false } : { authPath: join52(agentDir, "auth.json"), modelsPath: join52(agentDir, "models.json") },
|
|
33969
33991
|
allowModelNetwork: false
|
|
33970
33992
|
});
|
|
33971
|
-
runtimes.set(
|
|
33993
|
+
runtimes.set(cacheKey, runtime);
|
|
33972
33994
|
}
|
|
33973
33995
|
return runtime;
|
|
33974
33996
|
}
|
|
@@ -43115,6 +43137,37 @@ function jsonResult(value, isError = false) {
|
|
|
43115
43137
|
function toolError(code, message, extra = {}) {
|
|
43116
43138
|
return jsonResult({ ok: false, errorCode: code, message, ...extra }, true);
|
|
43117
43139
|
}
|
|
43140
|
+
var DIAGNOSTIC_EXAMPLES_PER_CODE = 3;
|
|
43141
|
+
function capDiagnostics(diagnostics) {
|
|
43142
|
+
const byCode = new Map;
|
|
43143
|
+
for (const entry of diagnostics) {
|
|
43144
|
+
const list = byCode.get(entry.code);
|
|
43145
|
+
if (list === undefined)
|
|
43146
|
+
byCode.set(entry.code, [entry]);
|
|
43147
|
+
else
|
|
43148
|
+
list.push(entry);
|
|
43149
|
+
}
|
|
43150
|
+
const out = [];
|
|
43151
|
+
for (const [code, entries] of byCode) {
|
|
43152
|
+
out.push(...entries.slice(0, DIAGNOSTIC_EXAMPLES_PER_CODE));
|
|
43153
|
+
const rest = entries.slice(DIAGNOSTIC_EXAMPLES_PER_CODE);
|
|
43154
|
+
if (rest.length === 0)
|
|
43155
|
+
continue;
|
|
43156
|
+
const reasons = new Map;
|
|
43157
|
+
for (const entry of rest) {
|
|
43158
|
+
const key = entry.reason ?? "unspecified";
|
|
43159
|
+
reasons.set(key, (reasons.get(key) ?? 0) + 1);
|
|
43160
|
+
}
|
|
43161
|
+
const split = [...reasons].map(([reason, count]) => `${reason}: ${count}`).join(", ");
|
|
43162
|
+
const severity = entries.some((entry) => entry.severity === "error") ? "error" : entries.some((entry) => entry.severity === "warning") ? "warning" : "info";
|
|
43163
|
+
out.push({
|
|
43164
|
+
code,
|
|
43165
|
+
severity,
|
|
43166
|
+
message: `${rest.length} more ${code} entries omitted (${split}); the first ${DIAGNOSTIC_EXAMPLES_PER_CODE} are shown above.`
|
|
43167
|
+
});
|
|
43168
|
+
}
|
|
43169
|
+
return out;
|
|
43170
|
+
}
|
|
43118
43171
|
function convertResult(details) {
|
|
43119
43172
|
const { result, links } = details;
|
|
43120
43173
|
const files = result.files.slice(0, MAX_CONVERT_FILES).map((file) => ({
|
|
@@ -43260,7 +43313,10 @@ function createAutoRAGMcpServer(lite, options = {}) {
|
|
|
43260
43313
|
inputSchema: emptyInput,
|
|
43261
43314
|
outputSchema: objectOutput,
|
|
43262
43315
|
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
43263
|
-
}, async () =>
|
|
43316
|
+
}, async () => {
|
|
43317
|
+
const status = await lite.getRefreshStatus();
|
|
43318
|
+
return jsonResult({ ...status, diagnostics: capDiagnostics(status.diagnostics) });
|
|
43319
|
+
});
|
|
43264
43320
|
}
|
|
43265
43321
|
if (isToolEnabled("autorag.search", options)) {
|
|
43266
43322
|
server.registerTool("autorag.search", {
|
|
@@ -43299,7 +43355,7 @@ function createAutoRAGMcpServer(lite, options = {}) {
|
|
|
43299
43355
|
content: result.content
|
|
43300
43356
|
})),
|
|
43301
43357
|
unsearched: retrieved.unsearched,
|
|
43302
|
-
diagnostics: [...status.diagnostics, ...retrieved.diagnostics]
|
|
43358
|
+
diagnostics: capDiagnostics([...status.diagnostics, ...retrieved.diagnostics])
|
|
43303
43359
|
});
|
|
43304
43360
|
} catch (error) {
|
|
43305
43361
|
return toolError(error instanceof RetrievalSelectionError ? "invalid-selection" : "search-failed", error instanceof Error ? error.message : String(error), { retryable: !(error instanceof RetrievalSelectionError) });
|
|
@@ -43354,7 +43410,7 @@ function createAutoRAGMcpServer(lite, options = {}) {
|
|
|
43354
43410
|
content: result.content
|
|
43355
43411
|
})),
|
|
43356
43412
|
unsearched: retrieved.unsearched,
|
|
43357
|
-
diagnostics: [...status.diagnostics, ...retrieved.diagnostics]
|
|
43413
|
+
diagnostics: capDiagnostics([...status.diagnostics, ...retrieved.diagnostics])
|
|
43358
43414
|
});
|
|
43359
43415
|
} catch (error) {
|
|
43360
43416
|
return toolError(error instanceof RetrievalSelectionError ? "invalid-selection" : "search-failed", error instanceof Error ? error.message : String(error), { datasourceId: entry.datasourceId, retryable: !(error instanceof RetrievalSelectionError) });
|
package/dist/mcp/server.d.ts
CHANGED
|
@@ -6,4 +6,20 @@ export interface AutoRAGMcpServerOptions {
|
|
|
6
6
|
/** Test/embedded override; defaults to the current Node platform. */
|
|
7
7
|
readonly platform?: NodeJS.Platform;
|
|
8
8
|
}
|
|
9
|
+
interface DiagnosticLike {
|
|
10
|
+
readonly code: string;
|
|
11
|
+
readonly severity: string;
|
|
12
|
+
readonly message: string;
|
|
13
|
+
readonly source?: string;
|
|
14
|
+
readonly reason?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Keep an MCP response small when one code repeats once per file. A corpus whose parser changed reports one
|
|
18
|
+
* `stale-index` entry per source (1,100 of them, about 750 KB, on a real 160k-file index), which the model then has to
|
|
19
|
+
* read through on every search and status call. Each code keeps its first few entries verbatim and one summary entry
|
|
20
|
+
* says how many more there were and how they split by `reason`, so "why is it stale" survives and a different code is
|
|
21
|
+
* never hidden behind a flood of this one. Short lists pass through unchanged.
|
|
22
|
+
*/
|
|
23
|
+
export declare function capDiagnostics<T extends DiagnosticLike>(diagnostics: readonly T[]): (T | DiagnosticLike)[];
|
|
9
24
|
export declare function createAutoRAGMcpServer(lite: AutoRAGLite, options?: AutoRAGMcpServerOptions): McpServer;
|
|
25
|
+
export {};
|
package/dist/profiles.js
CHANGED
|
@@ -195,6 +195,9 @@ import { homedir } from "node:os";
|
|
|
195
195
|
import { join } from "node:path";
|
|
196
196
|
import { parse } from "smol-toml";
|
|
197
197
|
function loadLocalAutoRAGModel(options = {}) {
|
|
198
|
+
if (process.env.AUTORAG_AUTH_MODE === "environment") {
|
|
199
|
+
throw new Error("External model config discovery is disabled; configure the model endpoint and its environment key explicitly.");
|
|
200
|
+
}
|
|
198
201
|
const configPath = options.configPath ?? join(homedir(), ".codex", "config.toml");
|
|
199
202
|
const config = parse(readFileSync(configPath, "utf8"));
|
|
200
203
|
const provider = config.model_provider;
|
|
@@ -1122,6 +1125,8 @@ var init_models = __esm(() => {
|
|
|
1122
1125
|
import { join as join3 } from "node:path";
|
|
1123
1126
|
import { getAgentDir, readStoredCredential } from "@earendil-works/pi-coding-agent";
|
|
1124
1127
|
function readDazziLoginToken(agentDir = getAgentDir()) {
|
|
1128
|
+
if (process.env.AUTORAG_AUTH_MODE === "environment")
|
|
1129
|
+
return;
|
|
1125
1130
|
return resolveCredentialKey(readStoredCredential(PROVIDER_ID, join3(agentDir, "auth.json")));
|
|
1126
1131
|
}
|
|
1127
1132
|
function isDazziSignedIn(agentDir = getAgentDir()) {
|
|
@@ -15274,6 +15279,7 @@ var init_types3 = __esm(() => {
|
|
|
15274
15279
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
15275
15280
|
import { existsSync as existsSync13, mkdirSync as mkdirSync12, readFileSync as readFileSync15, unlinkSync as unlinkSync2, writeFileSync as writeFileSync9 } from "node:fs";
|
|
15276
15281
|
import { basename as basename5, dirname as dirname11, isAbsolute as isAbsolute5, join as join22, resolve as resolve6 } from "node:path";
|
|
15282
|
+
import { InMemoryCredentialStore } from "@earendil-works/pi-ai";
|
|
15277
15283
|
import { findEnvKeys, getEnvApiKey } from "@earendil-works/pi-ai/compat";
|
|
15278
15284
|
import { getAgentDir as getAgentDir2, ModelRuntime, SettingsManager } from "@earendil-works/pi-coding-agent";
|
|
15279
15285
|
function resolveConfigPath(input) {
|
|
@@ -16317,10 +16323,20 @@ function resolveAgentDir(options) {
|
|
|
16317
16323
|
return options.agentDir ?? getAgentDir2();
|
|
16318
16324
|
}
|
|
16319
16325
|
function getModelRuntime(agentDir) {
|
|
16320
|
-
const
|
|
16326
|
+
const environmentOnly = process.env.AUTORAG_AUTH_MODE === "environment";
|
|
16327
|
+
const cacheKey = `${environmentOnly ? "environment" : "stored"}:${agentDir}`;
|
|
16328
|
+
const cached = modelRuntimeCache.get(cacheKey);
|
|
16321
16329
|
if (cached !== undefined)
|
|
16322
16330
|
return cached;
|
|
16323
16331
|
const created = (async () => {
|
|
16332
|
+
if (environmentOnly) {
|
|
16333
|
+
return ModelRuntime.create({
|
|
16334
|
+
credentials: new InMemoryCredentialStore,
|
|
16335
|
+
modelsPath: null,
|
|
16336
|
+
allowModelNetwork: false,
|
|
16337
|
+
refreshOnCreate: false
|
|
16338
|
+
});
|
|
16339
|
+
}
|
|
16324
16340
|
const runtime = await ModelRuntime.create({
|
|
16325
16341
|
authPath: join22(agentDir, "auth.json"),
|
|
16326
16342
|
modelsPath: join22(agentDir, "models.json"),
|
|
@@ -16329,9 +16345,9 @@ function getModelRuntime(agentDir) {
|
|
|
16329
16345
|
await registerDazziProvider(runtime);
|
|
16330
16346
|
return runtime;
|
|
16331
16347
|
})();
|
|
16332
|
-
modelRuntimeCache.set(
|
|
16348
|
+
modelRuntimeCache.set(cacheKey, created);
|
|
16333
16349
|
created.catch(() => {
|
|
16334
|
-
modelRuntimeCache.delete(
|
|
16350
|
+
modelRuntimeCache.delete(cacheKey);
|
|
16335
16351
|
});
|
|
16336
16352
|
return created;
|
|
16337
16353
|
}
|
|
@@ -16362,6 +16378,8 @@ function localRuntimeAuth(local) {
|
|
|
16362
16378
|
};
|
|
16363
16379
|
}
|
|
16364
16380
|
async function resolvePiDefaultModel(runtime, options) {
|
|
16381
|
+
if (process.env.AUTORAG_AUTH_MODE === "environment")
|
|
16382
|
+
return;
|
|
16365
16383
|
let provider;
|
|
16366
16384
|
let id;
|
|
16367
16385
|
try {
|
|
@@ -32518,17 +32536,21 @@ var init_datasource_skill = __esm(() => {
|
|
|
32518
32536
|
|
|
32519
32537
|
// src/agent/decision-backends.ts
|
|
32520
32538
|
import { join as join49 } from "node:path";
|
|
32539
|
+
import {
|
|
32540
|
+
InMemoryCredentialStore as InMemoryCredentialStore2
|
|
32541
|
+
} from "@earendil-works/pi-ai";
|
|
32521
32542
|
import { getAgentDir as getAgentDir4, ModelRuntime as ModelRuntime3 } from "@earendil-works/pi-coding-agent";
|
|
32522
32543
|
import { BackendError as BackendError3 } from "jev-use";
|
|
32523
32544
|
function runtimeFor(agentDir) {
|
|
32524
|
-
|
|
32545
|
+
const environmentOnly = process.env.AUTORAG_AUTH_MODE === "environment";
|
|
32546
|
+
const cacheKey = `${environmentOnly ? "environment" : "stored"}:${agentDir}`;
|
|
32547
|
+
let runtime = runtimes.get(cacheKey);
|
|
32525
32548
|
if (runtime === undefined) {
|
|
32526
32549
|
runtime = ModelRuntime3.create({
|
|
32527
|
-
authPath: join49(agentDir, "auth.json"),
|
|
32528
|
-
modelsPath: join49(agentDir, "models.json"),
|
|
32550
|
+
...environmentOnly ? { credentials: new InMemoryCredentialStore2, modelsPath: null, refreshOnCreate: false } : { authPath: join49(agentDir, "auth.json"), modelsPath: join49(agentDir, "models.json") },
|
|
32529
32551
|
allowModelNetwork: false
|
|
32530
32552
|
});
|
|
32531
|
-
runtimes.set(
|
|
32553
|
+
runtimes.set(cacheKey, runtime);
|
|
32532
32554
|
}
|
|
32533
32555
|
return runtime;
|
|
32534
32556
|
}
|
package/package.json
CHANGED