@intentic/iq-engine 1.222.0 → 1.224.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/README.md +40 -13
- package/dist/host/child.d.ts +2 -0
- package/dist/host/child.d.ts.map +1 -0
- package/dist/host/child.js +134 -0
- package/dist/host/child.js.map +1 -0
- package/dist/host/client.d.ts +6 -0
- package/dist/host/client.d.ts.map +1 -0
- package/dist/host/client.js +146 -0
- package/dist/host/client.js.map +1 -0
- package/dist/host/protocol.d.ts +72 -0
- package/dist/host/protocol.d.ts.map +1 -0
- package/dist/host/protocol.js +2 -0
- package/dist/host/protocol.js.map +1 -0
- package/package.json +17 -6
package/README.md
CHANGED
|
@@ -40,10 +40,10 @@ host that plots them: the daemon serves it at `/workspace/health` and the browse
|
|
|
40
40
|
codebase-health panel from it. One ranking, two presentations — the verbs keep printing text for the agent.
|
|
41
41
|
|
|
42
42
|
**Part of the iq dependency island.** The CLI (`@intentic/iq`) and the benchmark harness are its only
|
|
43
|
-
*search-shaped* consumers; the daemon holds ONE long-lived `
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
*search-shaped* consumers; the daemon holds ONE long-lived engine — as a `createEngineClient` handle, see below
|
|
44
|
+
— and calls `run` / `health` on it for `/workspace/search` and `/workspace/health`, which is the only reason
|
|
45
|
+
app code imports this package at all. Nothing else should: every other path to these results is the
|
|
46
|
+
`sandbox-contract` wire shape (`WorkspaceSearch*`, `WorkspaceHealth*`), never an import.
|
|
47
47
|
|
|
48
48
|
## Two engines, and why the resident one has threads
|
|
49
49
|
|
|
@@ -58,28 +58,55 @@ a few hundred milliseconds per query, tokenized in JS, yielding at no point. Sco
|
|
|
58
58
|
again and no longer does: since the vector table took over the ranking it is tens of milliseconds, and it is the
|
|
59
59
|
reranker alone that would otherwise stall every agent stream the daemon is serving.
|
|
60
60
|
|
|
61
|
+
## And why the whole thing is a separate process
|
|
62
|
+
|
|
63
|
+
Threads moved the CPU off the daemon's loop. They could not move the MEMORY: a worker thread shares its
|
|
64
|
+
process's address space, so the two models, the index cache and the workspace sweep were all resident in the
|
|
65
|
+
daemon. Measured there: about 2 GB of resident memory against 360 MB of JavaScript heap. On a box under memory
|
|
66
|
+
pressure most of a gigabyte of the *control plane* — the thing every browser request, every agent turn and
|
|
67
|
+
every git poll goes through — was paged out to serve a search nobody had asked for yet. It showed up as tens of
|
|
68
|
+
milliseconds of baseline event-loop delay and multi-second stalls with no I/O to blame.
|
|
69
|
+
|
|
70
|
+
So [host/client.ts](src/host/client.ts) is a `ResidentEngine` by interface and a proxy by implementation: it
|
|
71
|
+
forks [host/child.ts](src/host/child.ts), which builds the real engine over there and answers over an IPC
|
|
72
|
+
channel. The daemon keeps a small hot set and pays one round trip plus a structured clone per query, which
|
|
73
|
+
against a search that runs BM25, a vector scan and a cross-encoder is noise.
|
|
74
|
+
|
|
75
|
+
Two consequences worth knowing. `metrics()` is **synchronous** and a process boundary is not, so the child
|
|
76
|
+
*pushes* a snapshot whenever the numbers move and the client answers from the last one — with the sweep's
|
|
77
|
+
timestamp rather than its age, so an idle engine's figures keep aging instead of freezing at the last push. And
|
|
78
|
+
an `AbortSignal` does not cross a boundary at all: the client forwards the abort as a message, and the child
|
|
79
|
+
raises it on a controller of its own so it still reaches the ripgrep child it was always meant to kill.
|
|
80
|
+
|
|
61
81
|
```dag
|
|
62
|
-
{ "title": "One index, three threads", "direction": "LR",
|
|
63
|
-
"nodes": [{ "id": "
|
|
82
|
+
{ "title": "One index, its own process, three threads", "direction": "LR",
|
|
83
|
+
"nodes": [{ "id": "daemon", "label": "Sandbox daemon", "note": "keeps none of this", "accent": "2" },
|
|
84
|
+
{ "id": "host", "label": "Engine main thread", "note": "BM25, rg, fusion, render", "accent": "4" },
|
|
64
85
|
{ "id": "index", "label": "Index worker", "note": "the only writer", "accent": "4" },
|
|
65
86
|
{ "id": "query", "label": "Query worker", "note": "vectors + cross-encoder", "accent": "4" },
|
|
66
87
|
{ "id": "db", "label": "index.db", "note": "SQLite, WAL", "accent": "neutral" }],
|
|
67
|
-
"edges": [{ "from": "
|
|
88
|
+
"edges": [{ "from": "daemon", "to": "host", "dashed": true },
|
|
89
|
+
{ "from": "host", "to": "db" }, { "from": "query", "to": "db" }, { "from": "index", "to": "db" },
|
|
68
90
|
{ "from": "host", "to": "index", "dashed": true }, { "from": "host", "to": "query", "dashed": true }] }
|
|
69
91
|
```
|
|
70
92
|
|
|
71
|
-
Write-ahead logging is what makes
|
|
72
|
-
messages — a change notification out to the indexer, a query out to
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
93
|
+
Write-ahead logging is what makes the three-thread part safe: one writer, two readers, no waiting. Every dashed
|
|
94
|
+
edge is messages — the daemon's query and its answer, a change notification out to the indexer, a query out to
|
|
95
|
+
the scorer. Notice that nothing but the engine's own main thread ever holds the daemon's, and that the box
|
|
96
|
+
around the right-hand four is a process the daemon can lose: a child that dies fails the calls it was holding,
|
|
97
|
+
says so through the host's `onQueryError`, and the next search brings up a fresh one.
|
|
98
|
+
|
|
99
|
+
The engine's `metrics()` reports its cached file count, dirty/applied sequence lag, generation, and query-worker
|
|
100
|
+
liveness/backlog without walking the sweep; the sandbox folds those numbers into its durable resource time
|
|
101
|
+
series so a growing host heap can be compared with the state this engine actually retains.
|
|
76
102
|
|
|
77
103
|
## Key files
|
|
78
104
|
|
|
79
105
|
- [src/verbs](src/verbs) — one file per search verb; the surface `iq` dispatches into.
|
|
80
106
|
- [src/engines](src/engines) — the four searches: lexical, structural, semantic, git.
|
|
81
107
|
- [src/plan](src/plan) — intent detection and rank fusion; how four answers become one.
|
|
82
|
-
- [src/query](src/query) — the two model stages behind an interface, and the thread
|
|
108
|
+
- [src/query](src/query) — the two model stages behind an interface, and the thread they run on.
|
|
109
|
+
- [src/host](src/host) — the client/child pair that puts the resident engine in its own process.
|
|
83
110
|
- [src/indexer](src/indexer) — building and updating the disk index.
|
|
84
111
|
- [src/render](src/render) — fitting results into a token budget.
|
|
85
112
|
- [src/store](src/store) — the `node:sqlite` index itself.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"child.d.ts","sourceRoot":"","sources":["../../src/host/child.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { createResidentEngine } from "../index.js";
|
|
2
|
+
const send = process.send?.bind(process);
|
|
3
|
+
if (send === undefined) {
|
|
4
|
+
throw new Error("iq engine child started without an IPC channel");
|
|
5
|
+
}
|
|
6
|
+
const emit = (event) => {
|
|
7
|
+
if (process.connected) {
|
|
8
|
+
send(event, () => undefined);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
const describe = (error) => {
|
|
12
|
+
const failure = error instanceof Error ? error : new Error(String(error));
|
|
13
|
+
return { message: failure.message, ...(failure.stack !== undefined ? { stack: failure.stack } : {}) };
|
|
14
|
+
};
|
|
15
|
+
let engine;
|
|
16
|
+
let broken;
|
|
17
|
+
const running = new Map();
|
|
18
|
+
const answer = async (id, work) => {
|
|
19
|
+
try {
|
|
20
|
+
emit({ type: "settled", id, value: await work() });
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
emit({ type: "failed", id, ...describe(error) });
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
let published;
|
|
27
|
+
const METRICS_INTERVAL_MS = 2000;
|
|
28
|
+
const snapshot = () => {
|
|
29
|
+
if (engine === undefined) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
const { sweepAgeMs, ...rest } = engine.metrics();
|
|
33
|
+
return { ...rest, sweptAt: sweepAgeMs === undefined ? undefined : Date.now() - sweepAgeMs };
|
|
34
|
+
};
|
|
35
|
+
const same = (a, b) => a.files === b.files &&
|
|
36
|
+
a.generation === b.generation &&
|
|
37
|
+
a.dirtySequence === b.dirtySequence &&
|
|
38
|
+
a.appliedSequence === b.appliedSequence &&
|
|
39
|
+
a.revalidated === b.revalidated &&
|
|
40
|
+
a.sweptAt === b.sweptAt &&
|
|
41
|
+
a.embedBacklog === b.embedBacklog &&
|
|
42
|
+
a.queryWorker.live === b.queryWorker.live &&
|
|
43
|
+
a.queryWorker.pendingRequests === b.queryWorker.pendingRequests;
|
|
44
|
+
const publishMetrics = () => {
|
|
45
|
+
const current = snapshot();
|
|
46
|
+
if (current === undefined || (published !== undefined && same(published, current))) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
published = current;
|
|
50
|
+
emit({ type: "metrics", metrics: current });
|
|
51
|
+
};
|
|
52
|
+
const ticker = setInterval(publishMetrics, METRICS_INTERVAL_MS);
|
|
53
|
+
ticker.unref();
|
|
54
|
+
process.on("message", (message) => {
|
|
55
|
+
if (message.type === "init") {
|
|
56
|
+
try {
|
|
57
|
+
engine = createResidentEngine({
|
|
58
|
+
...message.options,
|
|
59
|
+
onIndexError: (error) => emit({ type: "indexError", ...describe(error) }),
|
|
60
|
+
onQueryError: (error) => emit({ type: "queryError", ...describe(error) }),
|
|
61
|
+
onIndexProgress: (remaining) => {
|
|
62
|
+
emit({ type: "indexProgress", remaining });
|
|
63
|
+
publishMetrics();
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
broken = error;
|
|
69
|
+
emit({ type: "indexError", ...describe(error) });
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (message.type === "abort") {
|
|
74
|
+
running.get(message.id)?.abort();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (engine === undefined) {
|
|
78
|
+
if (message.type !== "dirty") {
|
|
79
|
+
emit({ type: "failed", id: message.id, ...describe(broken ?? new Error("iq engine child received a request before init")) });
|
|
80
|
+
}
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const live = engine;
|
|
84
|
+
if (message.type === "dirty") {
|
|
85
|
+
live.markDirty();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (message.type === "warm") {
|
|
89
|
+
void answer(message.id, async () => {
|
|
90
|
+
const status = await live.warm();
|
|
91
|
+
publishMetrics();
|
|
92
|
+
return status;
|
|
93
|
+
});
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (message.type === "health") {
|
|
97
|
+
void answer(message.id, () => live.health(message.request));
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (message.type === "run") {
|
|
101
|
+
const controller = new AbortController();
|
|
102
|
+
running.set(message.id, controller);
|
|
103
|
+
void answer(message.id, async () => {
|
|
104
|
+
try {
|
|
105
|
+
return await live.run(message.request, controller.signal);
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
running.delete(message.id);
|
|
109
|
+
publishMetrics();
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const { id } = message;
|
|
115
|
+
void (async () => {
|
|
116
|
+
try {
|
|
117
|
+
await live.close();
|
|
118
|
+
emit({ type: "settled", id, value: undefined });
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
emit({ type: "failed", id, ...describe(error) });
|
|
122
|
+
}
|
|
123
|
+
engine = undefined;
|
|
124
|
+
clearInterval(ticker);
|
|
125
|
+
process.disconnect();
|
|
126
|
+
})();
|
|
127
|
+
});
|
|
128
|
+
process.on("disconnect", () => {
|
|
129
|
+
void (async () => {
|
|
130
|
+
await engine?.close().catch(() => undefined);
|
|
131
|
+
process.exit(0);
|
|
132
|
+
})();
|
|
133
|
+
});
|
|
134
|
+
//# sourceMappingURL=child.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"child.js","sourceRoot":"","sources":["../../src/host/child.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAuB,MAAM,aAAa,CAAC;AAUxE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;AACzC,IAAI,IAAI,KAAK,S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ACP,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;gBAC3B,cAAc,EAAE,CAAC;YACrB,CAAC;QACL,CAAC,CAAC,CAAC;QACH,OAAO;IACX,CAAC;IAKD,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC;IACvB,KAAK,CAAC,KAAK,IAAI,EAAE;QACb,IAAI,CAAC;YACD,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;YACnB,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QACpD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACrD,CAAC;QACD,MAAM,GAAG,SAAS,CAAC;QACnB,aAAa,CAAC,MAAM,CAAC,CAAC;QACtB,OAAO,CAAC,UAAU,EAAE,CAAC;IACzB,CAAC,CAAC,EAAE,CAAC;AACT,CAAC,CAAC,CAAC;AAIH,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,KAAK,CAAC,KAAK,IAAI,EAAE;QACb,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC,CAAC,EAAE,CAAC;AACT,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ResidentEngine, ResidentEngineOptions } from "../index.js";
|
|
2
|
+
export interface EngineClient extends ResidentEngine {
|
|
3
|
+
pid(): number | undefined;
|
|
4
|
+
}
|
|
5
|
+
export declare const createEngineClient: (options: ResidentEngineOptions) => EngineClient;
|
|
6
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/host/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAyB,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAiEhG,MAAM,WAAW,YAAa,SAAQ,cAAc;IAChD,GAAG,IAAI,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED,eAAO,MAAM,kBAAkB,YAAa,qBAAqB,KAAG,YA4JnE,CAAC"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { fork } from "node:child_process";
|
|
2
|
+
const childModule = new URL("../../dist/host/child.js", import.meta.url);
|
|
3
|
+
const COLD = {
|
|
4
|
+
files: 0,
|
|
5
|
+
generation: 0,
|
|
6
|
+
dirtySequence: 0,
|
|
7
|
+
appliedSequence: 0,
|
|
8
|
+
revalidated: false,
|
|
9
|
+
sweptAt: undefined,
|
|
10
|
+
embedBacklog: 0,
|
|
11
|
+
queryWorker: { live: false, pendingRequests: 0 },
|
|
12
|
+
};
|
|
13
|
+
const rebuild = (message, stack) => {
|
|
14
|
+
const error = new Error(message);
|
|
15
|
+
if (stack !== undefined) {
|
|
16
|
+
error.stack = stack;
|
|
17
|
+
}
|
|
18
|
+
return error;
|
|
19
|
+
};
|
|
20
|
+
export const createEngineClient = (options) => {
|
|
21
|
+
const { onIndexError, onQueryError, onIndexProgress, ...init } = options;
|
|
22
|
+
const pending = new Map();
|
|
23
|
+
let child;
|
|
24
|
+
let nextId = 0;
|
|
25
|
+
let metrics = COLD;
|
|
26
|
+
let closed = false;
|
|
27
|
+
const fail = (error) => {
|
|
28
|
+
const orphaned = [...pending.values()];
|
|
29
|
+
pending.clear();
|
|
30
|
+
for (const waiting of orphaned) {
|
|
31
|
+
waiting.forget();
|
|
32
|
+
waiting.reject(error);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const receive = (event) => {
|
|
36
|
+
if (event.type === "metrics") {
|
|
37
|
+
metrics = event.metrics;
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (event.type === "indexProgress") {
|
|
41
|
+
onIndexProgress?.(event.remaining);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (event.type === "indexError") {
|
|
45
|
+
onIndexError?.(rebuild(event.message, event.stack));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (event.type === "queryError") {
|
|
49
|
+
onQueryError?.(rebuild(event.message, event.stack));
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const waiting = pending.get(event.id);
|
|
53
|
+
if (waiting === undefined) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
pending.delete(event.id);
|
|
57
|
+
waiting.forget();
|
|
58
|
+
if (event.type === "failed") {
|
|
59
|
+
waiting.reject(rebuild(event.message, event.stack));
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
waiting.resolve(event.value);
|
|
63
|
+
};
|
|
64
|
+
const start = () => {
|
|
65
|
+
if (child !== undefined || closed) {
|
|
66
|
+
return child;
|
|
67
|
+
}
|
|
68
|
+
const started = fork(childModule, { serialization: "advanced", stdio: ["ignore", "inherit", "inherit", "ipc"] });
|
|
69
|
+
started.on("message", (message) => receive(message));
|
|
70
|
+
started.on("exit", (code, signal) => {
|
|
71
|
+
child = undefined;
|
|
72
|
+
metrics = COLD;
|
|
73
|
+
if (closed) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const how = signal ?? `code ${String(code)}`;
|
|
77
|
+
onQueryError?.(new Error(`iq engine process exited (${how}) — a new one starts on the next search`));
|
|
78
|
+
fail(new Error(`iq engine process exited (${how})`));
|
|
79
|
+
});
|
|
80
|
+
started.on("error", (error) => {
|
|
81
|
+
onQueryError?.(error);
|
|
82
|
+
});
|
|
83
|
+
child = started;
|
|
84
|
+
started.send({ type: "init", options: init });
|
|
85
|
+
return started;
|
|
86
|
+
};
|
|
87
|
+
const call = (build, signal) => {
|
|
88
|
+
const channel = start();
|
|
89
|
+
if (channel === undefined) {
|
|
90
|
+
return Promise.reject(new Error("iq engine is closed"));
|
|
91
|
+
}
|
|
92
|
+
const id = nextId;
|
|
93
|
+
nextId += 1;
|
|
94
|
+
return new Promise((resolve, reject) => {
|
|
95
|
+
const abort = () => {
|
|
96
|
+
channel.send({ type: "abort", id }, () => undefined);
|
|
97
|
+
};
|
|
98
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
99
|
+
pending.set(id, { resolve, reject, forget: () => signal?.removeEventListener("abort", abort) });
|
|
100
|
+
channel.send(build(id), (error) => {
|
|
101
|
+
if (error !== null) {
|
|
102
|
+
pending.delete(id);
|
|
103
|
+
signal?.removeEventListener("abort", abort);
|
|
104
|
+
reject(error);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
if (signal?.aborted === true) {
|
|
108
|
+
abort();
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
start();
|
|
113
|
+
return {
|
|
114
|
+
pid: () => child?.pid,
|
|
115
|
+
metrics: () => ({
|
|
116
|
+
files: metrics.files,
|
|
117
|
+
generation: metrics.generation,
|
|
118
|
+
dirtySequence: metrics.dirtySequence,
|
|
119
|
+
appliedSequence: metrics.appliedSequence,
|
|
120
|
+
revalidated: metrics.revalidated,
|
|
121
|
+
sweepAgeMs: metrics.sweptAt === undefined ? undefined : Date.now() - metrics.sweptAt,
|
|
122
|
+
embedBacklog: metrics.embedBacklog,
|
|
123
|
+
queryWorker: metrics.queryWorker,
|
|
124
|
+
}),
|
|
125
|
+
run: (request, signal) => call((id) => ({ type: "run", id, request }), signal),
|
|
126
|
+
health: (request) => call((id) => ({ type: "health", id, request })),
|
|
127
|
+
warm: () => call((id) => ({ type: "warm", id })),
|
|
128
|
+
markDirty: () => {
|
|
129
|
+
start()?.send({ type: "dirty" }, () => undefined);
|
|
130
|
+
},
|
|
131
|
+
async close() {
|
|
132
|
+
if (closed) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (child === undefined) {
|
|
136
|
+
closed = true;
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const finished = call((id) => ({ type: "close", id })).catch(() => undefined);
|
|
140
|
+
closed = true;
|
|
141
|
+
await finished;
|
|
142
|
+
fail(new Error("iq engine is closed"));
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/host/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,IAAI,EAAE,MAAM,oBAAoB,CAAC;AA+B7D,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,0BAA0B,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAazE,MAAM,IAAI,GAA0B;IAChC,KAAK,EAAE,CAAC;IACR,UAAU,EAAE,CAAC;IACb,aAAa,EAAE,CAAC;IAChB,eAAe,EAAE,CAAC;IAClB,WAAW,EAAE,KAAK;IAClB,OAAO,EAAE,SAAS;IAClB,YAAY,EAAE,CAAC;IACf,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC,EAAE;CACnD,CAAC;AAEF,MAAM,OAAO,GAAG,CAAC,OAAe,EAAE,KAAc,EAAS,EAAE;IACvD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IACjC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;IACxB,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AAUF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAA8B,EAAgB,EAAE;IAC/E,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IACzE,MAAM,OAAO,GAAG,IAAI,GAA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AC9G,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAyB;QAGxE,SAAS,EAAE,GAAG,EAAE;YACZ,KAAK,EAAE,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAA0B,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC9E,CAAC;QACD,KAAK,CAAC,KAAK;YACP,IAAI,MAAM,EAAE,CAAC;gBACT,OAAO;YACX,CAAC;YACD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACtB,MAAM,GAAG,IAAI,CAAC;gBACd,OAAO;YACX,CAAC;YAMD,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YAC9E,MAAM,GAAG,IAAI,CAAC;YACd,MAAM,QAAQ,CAAC;YACf,IAAI,CAAC,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC;QAC3C,CAAC;KACJ,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { CodebaseHealth, HealthRequest } from "../engines/health.js";
|
|
2
|
+
import type { Feature } from "../features.js";
|
|
3
|
+
import type { IndexStatus, QueryOutcome, QueryRequest } from "../types.js";
|
|
4
|
+
export interface EngineInit {
|
|
5
|
+
readonly root: string;
|
|
6
|
+
readonly indexDir?: string;
|
|
7
|
+
readonly rgPath?: string;
|
|
8
|
+
readonly modelDir?: string;
|
|
9
|
+
readonly features?: ReadonlySet<Feature>;
|
|
10
|
+
}
|
|
11
|
+
export type EngineRequest = {
|
|
12
|
+
readonly type: "init";
|
|
13
|
+
readonly options: EngineInit;
|
|
14
|
+
} | {
|
|
15
|
+
readonly type: "run";
|
|
16
|
+
readonly id: number;
|
|
17
|
+
readonly request: QueryRequest;
|
|
18
|
+
} | {
|
|
19
|
+
readonly type: "abort";
|
|
20
|
+
readonly id: number;
|
|
21
|
+
} | {
|
|
22
|
+
readonly type: "health";
|
|
23
|
+
readonly id: number;
|
|
24
|
+
readonly request: HealthRequest;
|
|
25
|
+
} | {
|
|
26
|
+
readonly type: "warm";
|
|
27
|
+
readonly id: number;
|
|
28
|
+
} | {
|
|
29
|
+
readonly type: "dirty";
|
|
30
|
+
} | {
|
|
31
|
+
readonly type: "close";
|
|
32
|
+
readonly id: number;
|
|
33
|
+
};
|
|
34
|
+
export interface EngineMetricsSnapshot {
|
|
35
|
+
readonly files: number;
|
|
36
|
+
readonly generation: number;
|
|
37
|
+
readonly dirtySequence: number;
|
|
38
|
+
readonly appliedSequence: number;
|
|
39
|
+
readonly revalidated: boolean;
|
|
40
|
+
readonly sweptAt: number | undefined;
|
|
41
|
+
readonly embedBacklog: number;
|
|
42
|
+
readonly queryWorker: {
|
|
43
|
+
readonly live: boolean;
|
|
44
|
+
readonly pendingRequests: number;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export type EngineAnswer = QueryOutcome | CodebaseHealth | IndexStatus | undefined;
|
|
48
|
+
export type EngineEvent = {
|
|
49
|
+
readonly type: "settled";
|
|
50
|
+
readonly id: number;
|
|
51
|
+
readonly value: EngineAnswer;
|
|
52
|
+
} | {
|
|
53
|
+
readonly type: "failed";
|
|
54
|
+
readonly id: number;
|
|
55
|
+
readonly message: string;
|
|
56
|
+
readonly stack?: string;
|
|
57
|
+
} | {
|
|
58
|
+
readonly type: "metrics";
|
|
59
|
+
readonly metrics: EngineMetricsSnapshot;
|
|
60
|
+
} | {
|
|
61
|
+
readonly type: "indexError";
|
|
62
|
+
readonly message: string;
|
|
63
|
+
readonly stack?: string;
|
|
64
|
+
} | {
|
|
65
|
+
readonly type: "queryError";
|
|
66
|
+
readonly message: string;
|
|
67
|
+
readonly stack?: string;
|
|
68
|
+
} | {
|
|
69
|
+
readonly type: "indexProgress";
|
|
70
|
+
readonly remaining: number;
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/host/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAY3E,MAAM,WAAW,UAAU;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CAC5C;AAED,MAAM,MAAM,aAAa,GACnB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAA;CAAE,GACvD;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAA;CAAE,GAG7E;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC/C;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EA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AAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAA;CAAE,GAGrE;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAClF;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAClF;IAAE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/host/protocol.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentic/iq-engine",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.224.0",
|
|
4
4
|
"description": "Search engine behind the iq CLI — disk index (node:sqlite), lexical/structural/semantic/git engines, rank fusion, budget renderer",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -29,6 +29,17 @@
|
|
|
29
29
|
"default": "./dist/index.js"
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
|
+
"./host": {
|
|
33
|
+
"types": "./dist/host/client.d.ts",
|
|
34
|
+
"import": {
|
|
35
|
+
"@intentic/src": "./src/host/client.ts",
|
|
36
|
+
"default": "./dist/host/client.js"
|
|
37
|
+
},
|
|
38
|
+
"require": {
|
|
39
|
+
"@intentic/src": "./src/host/client.ts",
|
|
40
|
+
"default": "./dist/host/client.js"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
32
43
|
"./testing": {
|
|
33
44
|
"types": "./dist/testing.d.ts",
|
|
34
45
|
"import": {
|
|
@@ -51,16 +62,16 @@
|
|
|
51
62
|
"@huggingface/transformers": "4.2.0",
|
|
52
63
|
"sqlite-vec": "0.1.9",
|
|
53
64
|
"tslib": "2.8.1",
|
|
54
|
-
"@intentic/constants": "1.
|
|
55
|
-
"@intentic/sandbox-contract": "1.
|
|
56
|
-
"@intentic/workspace-ignore": "1.
|
|
65
|
+
"@intentic/constants": "1.224.0",
|
|
66
|
+
"@intentic/sandbox-contract": "1.224.0",
|
|
67
|
+
"@intentic/workspace-ignore": "1.224.0"
|
|
57
68
|
},
|
|
58
69
|
"devDependencies": {
|
|
59
70
|
"@types/node": "24.13.2",
|
|
60
71
|
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
61
72
|
"vitest": "4.1.10",
|
|
62
|
-
"@intentic/
|
|
63
|
-
"@intentic/
|
|
73
|
+
"@intentic/testing": "0.0.0",
|
|
74
|
+
"@intentic/tsconfig": "0.0.0"
|
|
64
75
|
},
|
|
65
76
|
"scripts": {
|
|
66
77
|
"build": "tsgo",
|