@chosengeneration/light-code 0.180.0 → 0.181.0
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/cli.cjs +1012 -859
- package/dist/server.cjs +122 -19
- package/package.json +1 -1
package/dist/server.cjs
CHANGED
|
@@ -48183,10 +48183,12 @@ var RestTransport = class {
|
|
|
48183
48183
|
http;
|
|
48184
48184
|
connection;
|
|
48185
48185
|
extraHeaders;
|
|
48186
|
-
|
|
48186
|
+
explain;
|
|
48187
|
+
constructor(http, connection, extraHeaders = () => ({}), explain = () => "") {
|
|
48187
48188
|
this.http = http;
|
|
48188
48189
|
this.connection = connection;
|
|
48189
48190
|
this.extraHeaders = extraHeaders;
|
|
48191
|
+
this.explain = explain;
|
|
48190
48192
|
}
|
|
48191
48193
|
get label() {
|
|
48192
48194
|
return this.connection.label ?? this.connection.url;
|
|
@@ -48238,7 +48240,7 @@ var RestTransport = class {
|
|
|
48238
48240
|
const result = await this.send(path65, method, body, signal);
|
|
48239
48241
|
if (result.status < 200 || result.status >= 300) {
|
|
48240
48242
|
const detail = typeof result.body === "string" ? result.body : JSON.stringify(result.body ?? "");
|
|
48241
|
-
throw new VectorStoreError(`${method} ${path65} on ${this.label} returned HTTP ${String(result.status)}. ${detail.slice(0, 300)}
|
|
48243
|
+
throw new VectorStoreError(`${method} ${path65} on ${this.label} returned HTTP ${String(result.status)}. ${detail.slice(0, 300)}` + this.explain(result.body), result.status);
|
|
48242
48244
|
}
|
|
48243
48245
|
return result.body;
|
|
48244
48246
|
}
|
|
@@ -48247,6 +48249,84 @@ function isSafeCollectionName(name) {
|
|
|
48247
48249
|
return /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,254}$/.test(name) && !name.includes("..");
|
|
48248
48250
|
}
|
|
48249
48251
|
|
|
48252
|
+
// ../../packages/core/dist/rag/serverKind.js
|
|
48253
|
+
function identifyServer(body) {
|
|
48254
|
+
if (typeof body === "string") {
|
|
48255
|
+
return /no handler found for uri/i.test(body) ? "opensearch" : void 0;
|
|
48256
|
+
}
|
|
48257
|
+
if (body === null || typeof body !== "object")
|
|
48258
|
+
return void 0;
|
|
48259
|
+
const record2 = body;
|
|
48260
|
+
const version2 = record2.version;
|
|
48261
|
+
if (typeof record2.cluster_name === "string" && typeof version2 === "object" && typeof version2?.number === "string") {
|
|
48262
|
+
return "opensearch";
|
|
48263
|
+
}
|
|
48264
|
+
if (typeof record2.title === "string" && /qdrant/i.test(record2.title))
|
|
48265
|
+
return "qdrant";
|
|
48266
|
+
if ("nanosecond heartbeat" in record2)
|
|
48267
|
+
return "chroma";
|
|
48268
|
+
const error51 = record2.error;
|
|
48269
|
+
if (typeof error51 === "string")
|
|
48270
|
+
return identifyServer(error51);
|
|
48271
|
+
if (error51 !== null && typeof error51 === "object" && Array.isArray(error51.root_cause)) {
|
|
48272
|
+
return "opensearch";
|
|
48273
|
+
}
|
|
48274
|
+
return void 0;
|
|
48275
|
+
}
|
|
48276
|
+
var NAMES = { opensearch: "OpenSearch", qdrant: "Qdrant", chroma: "Chroma" };
|
|
48277
|
+
function wrongServerMessage(expected, body, label) {
|
|
48278
|
+
const actual = identifyServer(body);
|
|
48279
|
+
if (actual === void 0 || actual === expected)
|
|
48280
|
+
return void 0;
|
|
48281
|
+
return `${label} answers like ${NAMES[actual]}, but this connection's type is ${NAMES[expected]}. In Settings \u2192 Search, edit the connection and set Type to ${NAMES[actual]}` + (actual === "opensearch" ? "" : `, or enter your ${NAMES[expected]} server's address`) + ".";
|
|
48282
|
+
}
|
|
48283
|
+
function wrongServerHint(expected, body, label) {
|
|
48284
|
+
const message5 = wrongServerMessage(expected, body, label);
|
|
48285
|
+
return message5 === void 0 ? "" : ` ${message5}`;
|
|
48286
|
+
}
|
|
48287
|
+
async function probeVectorStore(http, kind, connection, signal) {
|
|
48288
|
+
const rest = new RestTransport(http, connection, () => qdrantKeyHeader(kind, connection));
|
|
48289
|
+
const label = rest.label;
|
|
48290
|
+
const root = await rest.send("/", "GET", void 0, signal);
|
|
48291
|
+
const mismatch = wrongServerMessage(kind, root.body, label);
|
|
48292
|
+
if (mismatch !== void 0)
|
|
48293
|
+
throw new VectorStoreError(mismatch, root.status);
|
|
48294
|
+
if (kind === "opensearch") {
|
|
48295
|
+
const info = await new OpenSearchClient(http, connection).ping(signal);
|
|
48296
|
+
return `Connected to ${info.clusterName ?? "the cluster"}${info.version !== void 0 ? ` (OpenSearch ${info.version})` : ""}.`;
|
|
48297
|
+
}
|
|
48298
|
+
if (kind === "qdrant") {
|
|
48299
|
+
const listed = await rest.send("/collections", "GET", void 0, signal);
|
|
48300
|
+
if (listed.status === 401 || listed.status === 403) {
|
|
48301
|
+
throw new VectorStoreError(`${label} refused the credentials (HTTP ${String(listed.status)}). Qdrant takes its API key in the Password box, with Username left empty.`, listed.status);
|
|
48302
|
+
}
|
|
48303
|
+
if (listed.status < 200 || listed.status >= 300 || !Array.isArray(listed.body?.result?.collections)) {
|
|
48304
|
+
throw new VectorStoreError(`${label} did not answer as Qdrant (GET /collections returned HTTP ${String(listed.status)}).` + wrongServerHint("qdrant", listed.body, label), listed.status);
|
|
48305
|
+
}
|
|
48306
|
+
const version3 = root.body?.version;
|
|
48307
|
+
const count3 = listed.body.result.collections.length;
|
|
48308
|
+
return `Connected to Qdrant${typeof version3 === "string" ? ` ${version3}` : ""} - ${String(count3)} collection${count3 === 1 ? "" : "s"}.`;
|
|
48309
|
+
}
|
|
48310
|
+
const beat = await rest.send("/api/v2/heartbeat", "GET", void 0, signal);
|
|
48311
|
+
if (beat.status === 404 || beat.status === 410) {
|
|
48312
|
+
throw new VectorStoreError(`${label} does not speak the Chroma v2 API. Light Code needs Chroma 1.0 or newer.` + wrongServerHint("chroma", beat.body, label), beat.status);
|
|
48313
|
+
}
|
|
48314
|
+
if (beat.status < 200 || beat.status >= 300 || identifyServer(beat.body) !== "chroma") {
|
|
48315
|
+
throw new VectorStoreError(`${label} did not answer as Chroma (GET /api/v2/heartbeat returned HTTP ${String(beat.status)}).` + wrongServerHint("chroma", beat.body, label), beat.status);
|
|
48316
|
+
}
|
|
48317
|
+
const version2 = await rest.send("/api/v2/version", "GET", void 0, signal);
|
|
48318
|
+
return `Connected to Chroma${typeof version2.body === "string" && version2.status === 200 ? ` ${version2.body}` : ""}.`;
|
|
48319
|
+
}
|
|
48320
|
+
function qdrantKeyHeader(kind, connection) {
|
|
48321
|
+
if (kind !== "qdrant")
|
|
48322
|
+
return {};
|
|
48323
|
+
const { username, password } = connection;
|
|
48324
|
+
if ((username === void 0 || username.length === 0) && password !== void 0 && password.length > 0) {
|
|
48325
|
+
return { "api-key": password };
|
|
48326
|
+
}
|
|
48327
|
+
return {};
|
|
48328
|
+
}
|
|
48329
|
+
|
|
48250
48330
|
// ../../packages/core/dist/rag/chroma/chroma.js
|
|
48251
48331
|
var DEFAULT_TENANT = "default_tenant";
|
|
48252
48332
|
var DEFAULT_DATABASE = "default_database";
|
|
@@ -48260,7 +48340,7 @@ var ChromaBase = class {
|
|
|
48260
48340
|
constructor(http, connection, tenant = DEFAULT_TENANT, database = DEFAULT_DATABASE) {
|
|
48261
48341
|
this.tenant = tenant;
|
|
48262
48342
|
this.database = database;
|
|
48263
|
-
this.rest = new RestTransport(http, connection);
|
|
48343
|
+
this.rest = new RestTransport(http, connection, () => ({}), (body) => wrongServerHint("chroma", body, connection.label ?? connection.url));
|
|
48264
48344
|
}
|
|
48265
48345
|
get base() {
|
|
48266
48346
|
return `/api/v2/tenants/${encodeURIComponent(this.tenant)}/databases/${encodeURIComponent(this.database)}`;
|
|
@@ -48279,7 +48359,7 @@ var ChromaBase = class {
|
|
|
48279
48359
|
throw new VectorStoreError(`${this.rest.label} does not speak the Chroma v2 API. Light Code needs Chroma 1.0 or newer \u2014 the v1 endpoints were removed upstream and are not implemented here.`, result.status);
|
|
48280
48360
|
}
|
|
48281
48361
|
if (result.status < 200 || result.status >= 300) {
|
|
48282
|
-
throw new VectorStoreError(`Could not read collection "${collection}" from ${this.rest.label} (HTTP ${String(result.status)})
|
|
48362
|
+
throw new VectorStoreError(`Could not read collection "${collection}" from ${this.rest.label} (HTTP ${String(result.status)}).` + wrongServerHint("chroma", result.body, this.rest.label), result.status);
|
|
48283
48363
|
}
|
|
48284
48364
|
const body = result.body;
|
|
48285
48365
|
return typeof body.id === "string" ? body : void 0;
|
|
@@ -48548,7 +48628,7 @@ function toMatch(point) {
|
|
|
48548
48628
|
var QdrantBase = class {
|
|
48549
48629
|
rest;
|
|
48550
48630
|
constructor(http, connection) {
|
|
48551
|
-
this.rest = new RestTransport(http, connection, () => apiKeyHeader(connection));
|
|
48631
|
+
this.rest = new RestTransport(http, connection, () => apiKeyHeader(connection), (body) => wrongServerHint("qdrant", body, connection.label ?? connection.url));
|
|
48552
48632
|
}
|
|
48553
48633
|
assertName(collection) {
|
|
48554
48634
|
if (!isSafeCollectionName(collection)) {
|
|
@@ -48627,7 +48707,7 @@ var QdrantIndexWriter = class extends QdrantBase {
|
|
|
48627
48707
|
if (result.status === 404)
|
|
48628
48708
|
return void 0;
|
|
48629
48709
|
if (result.status < 200 || result.status >= 300) {
|
|
48630
|
-
throw new VectorStoreError(`Could not read collection "${collection}" (HTTP ${String(result.status)})
|
|
48710
|
+
throw new VectorStoreError(`Could not read collection "${collection}" (HTTP ${String(result.status)}).` + wrongServerHint("qdrant", result.body, this.rest.label), result.status);
|
|
48631
48711
|
}
|
|
48632
48712
|
const vectors = result.body.result?.config?.params?.vectors;
|
|
48633
48713
|
if (vectors === void 0)
|
|
@@ -48722,7 +48802,7 @@ var QdrantIndexWriter = class extends QdrantBase {
|
|
|
48722
48802
|
if (result.status === 404)
|
|
48723
48803
|
return { documents: [] };
|
|
48724
48804
|
if (result.status < 200 || result.status >= 300) {
|
|
48725
|
-
throw new VectorStoreError(`Could not read "${collection}" (HTTP ${String(result.status)})
|
|
48805
|
+
throw new VectorStoreError(`Could not read "${collection}" (HTTP ${String(result.status)}).` + wrongServerHint("qdrant", result.body, this.rest.label), result.status);
|
|
48726
48806
|
}
|
|
48727
48807
|
const documents = [];
|
|
48728
48808
|
for (const point of result.body.result?.points ?? []) {
|
|
@@ -48757,7 +48837,7 @@ var QdrantIndexWriter = class extends QdrantBase {
|
|
|
48757
48837
|
if (result.status === 404)
|
|
48758
48838
|
return [];
|
|
48759
48839
|
if (result.status < 200 || result.status >= 300) {
|
|
48760
|
-
throw new VectorStoreError(`Could not list "${collection}" (HTTP ${String(result.status)})
|
|
48840
|
+
throw new VectorStoreError(`Could not list "${collection}" (HTTP ${String(result.status)}).` + wrongServerHint("qdrant", result.body, this.rest.label), result.status);
|
|
48761
48841
|
}
|
|
48762
48842
|
for (const point of result.body.result?.points ?? []) {
|
|
48763
48843
|
const path65 = point.payload?.path;
|
|
@@ -83859,9 +83939,14 @@ ${preview.text}` } : {}
|
|
|
83859
83939
|
const loaded = await loadSkills(dirs);
|
|
83860
83940
|
skills = loaded.skills;
|
|
83861
83941
|
skillIssues = loaded.issues;
|
|
83862
|
-
|
|
83863
|
-
|
|
83942
|
+
const signature = loaded.issues.map((issue2) => `${issue2.filePath}\0${issue2.detail}`).join("\n");
|
|
83943
|
+
if (signature !== loggedSkillIssues) {
|
|
83944
|
+
loggedSkillIssues = signature;
|
|
83945
|
+
for (const issue2 of loaded.issues)
|
|
83946
|
+
logger.warn(`skill ${issue2.filePath}: ${issue2.detail}`);
|
|
83947
|
+
}
|
|
83864
83948
|
};
|
|
83949
|
+
let loggedSkillIssues = "";
|
|
83865
83950
|
let skillWatchers = [];
|
|
83866
83951
|
let skillWatchTimer;
|
|
83867
83952
|
function stopWatchingSkills() {
|
|
@@ -92700,13 +92785,17 @@ ${last}` : ""}`);
|
|
|
92700
92785
|
await postEmbedder(config2);
|
|
92701
92786
|
}
|
|
92702
92787
|
async function clientFromInput(input) {
|
|
92788
|
+
const { store, id } = await storeFromInput(input);
|
|
92789
|
+
return openSearchClientFor(store, id);
|
|
92790
|
+
}
|
|
92791
|
+
async function storeFromInput(input) {
|
|
92703
92792
|
const id = input.id ?? "__unsaved__";
|
|
92704
92793
|
if (input.username !== void 0 && input.username.length > 0)
|
|
92705
92794
|
await secrets.set(searchUserRefFor(id), input.username);
|
|
92706
92795
|
if (input.password !== void 0 && input.password.length > 0)
|
|
92707
92796
|
await secrets.set(searchPasswordRefFor(id), input.password);
|
|
92708
92797
|
const store = {
|
|
92709
|
-
kind: "opensearch",
|
|
92798
|
+
kind: input.kind ?? "opensearch",
|
|
92710
92799
|
label: input.label.length > 0 ? input.label : "Untitled",
|
|
92711
92800
|
url: input.url,
|
|
92712
92801
|
...await secrets.get(searchUserRefFor(id)) !== void 0 ? { usernameRef: searchUserRefFor(id) } : {},
|
|
@@ -92714,7 +92803,7 @@ ${last}` : ""}`);
|
|
|
92714
92803
|
...input.caFile !== void 0 && input.caFile.length > 0 ? { caFile: input.caFile } : {},
|
|
92715
92804
|
...input.rejectUnauthorized !== void 0 ? { rejectUnauthorized: input.rejectUnauthorized } : {}
|
|
92716
92805
|
};
|
|
92717
|
-
return
|
|
92806
|
+
return { store, id };
|
|
92718
92807
|
}
|
|
92719
92808
|
async function handleSaveSearchConnection(input) {
|
|
92720
92809
|
try {
|
|
@@ -92772,12 +92861,9 @@ ${last}` : ""}`);
|
|
|
92772
92861
|
}
|
|
92773
92862
|
async function handleTestSearchConnection(input) {
|
|
92774
92863
|
try {
|
|
92775
|
-
const
|
|
92776
|
-
|
|
92777
|
-
|
|
92778
|
-
ok: true,
|
|
92779
|
-
detail: `Connected to ${info.clusterName ?? "the cluster"}${info.version !== void 0 ? ` (OpenSearch ${info.version})` : ""}.`
|
|
92780
|
-
});
|
|
92864
|
+
const { store, id } = await storeFromInput(input);
|
|
92865
|
+
const detail = await probeVectorStore(httpClient, store.kind, await vectorStoreConnectionFor(store, id));
|
|
92866
|
+
post({ type: "searchTestResult", ok: true, detail });
|
|
92781
92867
|
} catch (error51) {
|
|
92782
92868
|
post({
|
|
92783
92869
|
type: "searchTestResult",
|
|
@@ -96768,6 +96854,12 @@ connections, config:activeVectorStoreId the current one, config:embedder the emb
|
|
|
96768
96854
|
model, and config:retrieval the rest. All user-scope only \u2014 a repository able to set the embedder
|
|
96769
96855
|
URL would exfiltrate your source the moment you opened it.
|
|
96770
96856
|
|
|
96857
|
+
**Each connection has a Type, and it must match the server.** A new connection starts as Qdrant;
|
|
96858
|
+
for a team OpenSearch cluster set Type to OpenSearch. Every connection in the list shows its type,
|
|
96859
|
+
and Test connection speaks that type, so a mismatch fails there. A mismatched connection shows up at
|
|
96860
|
+
indexing as "Could not read collection ... (HTTP 400)", which now ends by saying the address answers
|
|
96861
|
+
like OpenSearch - the fix is the Type, not the project or index name.
|
|
96862
|
+
|
|
96771
96863
|
**Retrieval is exposed as tools the model calls**, never as tool definitions that change per turn.
|
|
96772
96864
|
\`search_codebase\` and \`search_docs\` return results as tool *results*, mid-conversation, where
|
|
96773
96865
|
they cost nothing at the front of the prompt.
|
|
@@ -99765,7 +99857,11 @@ walkthrough, whose steps link straight into the tab each one is about. On the No
|
|
|
99765
99857
|
"conversation lost",
|
|
99766
99858
|
"draft lost",
|
|
99767
99859
|
"typed message gone",
|
|
99768
|
-
"host.log"
|
|
99860
|
+
"host.log",
|
|
99861
|
+
"crash log",
|
|
99862
|
+
"why did it crash",
|
|
99863
|
+
"exit code",
|
|
99864
|
+
"out of memory"
|
|
99769
99865
|
],
|
|
99770
99866
|
body: `
|
|
99771
99867
|
**The agent crashed, or python.exe "stopped working".** A Python tool's worker that crashes is restarted on the
|
|
@@ -99777,6 +99873,13 @@ conversation is saved as the turn goes - after your message and after each tool
|
|
|
99777
99873
|
kept by the agent as well, so a restart loses neither. Each chat's log is \`host.log\` in its data folder, with the
|
|
99778
99874
|
run before as \`host.previous.log\`: an error the agent survived is written there as "kept running".
|
|
99779
99875
|
|
|
99876
|
+
**Why did the Fire Code agent stop?** The stopped chat says it: the exit code in words (out of memory, a native
|
|
99877
|
+
crash, ended from outside such as antivirus or Task Manager) and where the crashed run's log is kept - a copy in
|
|
99878
|
+
\`crashes/host-<date>.log\` in the chat's data folder that a Restart never overwrites (the newest ten are kept). An
|
|
99879
|
+
out-of-memory stop also leaves a Node report in \`crash-reports\`. The log has a \`[memory]\` line every ten minutes
|
|
99880
|
+
and a warning near the heap limit, so growth before a crash shows; a log that ends without "exiting through Node"
|
|
99881
|
+
means the process was killed or crashed natively. Send the kept log and the report when asking for a fix.
|
|
99882
|
+
|
|
99780
99883
|
**A button is greyed out.** Hover over it: every control that can be disabled says why in its
|
|
99781
99884
|
tooltip - nothing changed since the last save, a field still empty, a reply still running, a
|
|
99782
99885
|
feature switched off elsewhere - and usually what to do about it.
|