@aionis/substrate 0.1.4 → 0.1.6
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/CHANGELOG.md +12 -0
- package/README.md +101 -10
- package/dist/candidate-index.d.ts +25 -0
- package/dist/candidate-index.d.ts.map +1 -0
- package/dist/candidate-index.js +217 -0
- package/dist/candidate-index.js.map +1 -0
- package/dist/embedding-projection.d.ts +16 -0
- package/dist/embedding-projection.d.ts.map +1 -0
- package/dist/embedding-projection.js +101 -0
- package/dist/embedding-projection.js.map +1 -0
- package/dist/file-substrate.d.ts +3 -0
- package/dist/file-substrate.d.ts.map +1 -1
- package/dist/file-substrate.js +47 -1
- package/dist/file-substrate.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/search.d.ts +11 -2
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +78 -7
- package/dist/search.js.map +1 -1
- package/dist/sqlite-substrate.d.ts +3 -0
- package/dist/sqlite-substrate.d.ts.map +1 -1
- package/dist/sqlite-substrate.js +61 -6
- package/dist/sqlite-substrate.js.map +1 -1
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/zvec-candidate-index.d.ts +42 -0
- package/dist/zvec-candidate-index.d.ts.map +1 -0
- package/dist/zvec-candidate-index.js +463 -0
- package/dist/zvec-candidate-index.js.map +1 -0
- package/docs/ADAPTER_CONTRACT.md +12 -2
- package/docs/API_USAGE.md +135 -0
- package/docs/CLI.md +21 -1
- package/docs/PRODUCT_CONTRACT.md +136 -0
- package/docs/RUNTIME_DUAL_WRITE_EXPERIMENT.md +14 -0
- package/docs/RUNTIME_ZVEC_CANDIDATE_INDEX.md +80 -0
- package/docs/STORE_CONTRACT.md +15 -0
- package/docs/V0_2_ROADMAP.md +12 -1
- package/docs/ZVEC_PROVIDER_EMBEDDING_EVAL.md +216 -0
- package/docs/ZVEC_SCALE_MAINTENANCE.md +89 -0
- package/examples/live-sidecar/index.mjs +189 -0
- package/package.json +16 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,18 @@ All notable changes to Aionis Substrate are documented here.
|
|
|
4
4
|
|
|
5
5
|
## Unreleased
|
|
6
6
|
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Live sidecar integration example that builds a real Runtime Lite SQLite source, mirrors it through the checkpointed sidecar, and previews governed context buckets.
|
|
10
|
+
- Optional candidate index boundary with rebuild, verify, write-through node sync, and candidate-id narrowing before canonical Substrate scoring.
|
|
11
|
+
- Optional Zvec-backed candidate index adapter for local vector preselection while keeping file/SQLite as truth storage.
|
|
12
|
+
- Runtime Zvec candidate-index validation gate that imports real Runtime Lite SQLite scopes into isolated Substrate stores and checks Zvec health plus canonical-search parity.
|
|
13
|
+
- Zvec scale-maintenance gate that writes a SQLite truth store with a Zvec candidate sidecar, verifies write-through health, wide-search parity, narrow seeded recovery, lifecycle-transition sync, compaction, and reopen rebuild.
|
|
14
|
+
- Provider-backed Zvec embedding eval that calls OpenAI-compatible or MiniMax native embeddings endpoints and reports raw Zvec candidate hit rate separately from final Substrate search hit rate.
|
|
15
|
+
- Candidate-index semantic fusion that lets Zvec/provider candidates influence final `searchNodes()` ranking without bypassing scope, lifecycle, authority, confidence, or target-file filters.
|
|
16
|
+
- DashScope native `text-embedding-v4` provider eval with query/document projection, optional query instructions, and projection-aware reports.
|
|
17
|
+
- Stable SDK embedding projection helpers for provider hosts: `buildAionisEmbeddingDocument`, `buildAionisEmbeddingQuery`, and `AIONIS_EMBEDDING_PROJECTION_VERSION`.
|
|
18
|
+
|
|
7
19
|
## 0.1.4 - 2026-06-26
|
|
8
20
|
|
|
9
21
|
### Added
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Aionis Substrate is an independent storage-contract project for Aionis memory an
|
|
|
4
4
|
|
|
5
5
|
It defines the durable substrate Aionis needs for governed working memory: append-only evidence, lifecycle state, relations, feedback, decision receipts, and context admission buckets.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Aionis Runtime can use this layer as a durable governed memory substrate. Agents and Runtime policy remain above it; file/SQLite remain the truth store; optional indexes such as Zvec can accelerate candidate preselection.
|
|
8
8
|
|
|
9
9
|
## Status
|
|
10
10
|
|
|
@@ -47,6 +47,24 @@ npx aionis-substrate live-sidecar --source ./runtime.sqlite --target ./substrate
|
|
|
47
47
|
npx aionis-substrate live-sidecar --source ./runtime.sqlite --target ./substrate.sqlite --adapter sqlite --checkpoint ./runtime-live-checkpoint.json --scope repo-a --watch --iterations 20 --interval-ms 5000
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
## Two-Minute Live Sidecar Demo
|
|
51
|
+
|
|
52
|
+
From a cloned repository:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm run example:live-sidecar
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The demo creates a real Runtime Lite SQLite source, inserts current route, failed
|
|
59
|
+
branch, and raw-trace pointer evidence, mirrors that source into a separate
|
|
60
|
+
Substrate SQLite store through `runRuntimeLiveSidecarOnce`, and previews the
|
|
61
|
+
governed context buckets. The expected output shows:
|
|
62
|
+
|
|
63
|
+
- `current-route` in `use_now`;
|
|
64
|
+
- `failed-branch` in `do_not_use`;
|
|
65
|
+
- `raw-trace` in `rehydrate`;
|
|
66
|
+
- the second sidecar run applying zero unchanged rows.
|
|
67
|
+
|
|
50
68
|
## Goal
|
|
51
69
|
|
|
52
70
|
Define the storage semantics Aionis needs before choosing or building a storage engine:
|
|
@@ -58,15 +76,11 @@ Define the storage semantics Aionis needs before choosing or building a storage
|
|
|
58
76
|
- decision traces that explain why memory was admitted, downgraded, blocked, or deferred
|
|
59
77
|
- controlled forgetting as state transitions, not silent deletion
|
|
60
78
|
|
|
61
|
-
##
|
|
79
|
+
## Product Boundary
|
|
62
80
|
|
|
63
|
-
-
|
|
64
|
-
- not a vector index;
|
|
65
|
-
- not a chat memory store;
|
|
66
|
-
- not a benchmark harness;
|
|
67
|
-
- not the full Aionis Runtime policy engine.
|
|
81
|
+
Aionis Substrate owns durable memory evidence, lifecycle state, relation graph, feedback receipts, audit reads, side-effect-free preview, and the minimum governed context contract.
|
|
68
82
|
|
|
69
|
-
|
|
83
|
+
Aionis Runtime owns richer admission policy, product orchestration, Agent-facing guide behavior, and model/provider workflows above this storage-contract layer.
|
|
70
84
|
|
|
71
85
|
## Current Scope
|
|
72
86
|
|
|
@@ -82,7 +96,10 @@ This first version ships two embedded adapters:
|
|
|
82
96
|
- the SQLite adapter persists schema metadata, records applied schema migrations, and rejects stores created by a newer unsupported schema.
|
|
83
97
|
- event-log backups can be exported, checksum-verified, and restored to either file or SQLite stores.
|
|
84
98
|
- checkpoint compaction can rewrite a store event log to one checksum-covered checkpoint event without changing governed state.
|
|
85
|
-
- `searchNodes` provides scoped deterministic lexical/structured search over memory nodes without mutating events or admission state.
|
|
99
|
+
- `searchNodes` provides scoped deterministic lexical/structured search over memory nodes without mutating events or admission state.
|
|
100
|
+
- stores can be opened with an optional candidate index. The index is rebuilt on open by default, receives write-through node updates, can be verified for missing/orphan/stale entries, and only narrows candidate ids before Substrate reloads truth nodes and scores them.
|
|
101
|
+
- `createZvecCandidateIndex` provides an optional Zvec-backed candidate index for local vector preselection. Substrate fuses candidate-index rank into final search while preserving scope, lifecycle, authority, confidence, and target-file filters. It requires installing `@zvec/zvec`; file/SQLite remain the truth store.
|
|
102
|
+
- `buildAionisEmbeddingDocument` and `buildAionisEmbeddingQuery` expose the stable SDK projection for hosts that generate provider vectors before writing nodes or querying Zvec.
|
|
86
103
|
- `importRuntimeLiteSnapshot` can import an existing Runtime Lite SQLite database into an isolated Substrate store through a read-only source connection.
|
|
87
104
|
- `runRuntimeLiveSidecarOnce`, `runRuntimeLiveSidecarWatch`, and `aionis-substrate live-sidecar` incrementally mirror Runtime Lite evidence into a separate Substrate target through a checkpoint file.
|
|
88
105
|
|
|
@@ -106,8 +123,19 @@ Checkpoint compaction is documented in [docs/CHECKPOINT_COMPACTION.md](docs/CHEC
|
|
|
106
123
|
|
|
107
124
|
Runtime snapshot import is documented in [docs/RUNTIME_SNAPSHOT_IMPORT.md](docs/RUNTIME_SNAPSHOT_IMPORT.md).
|
|
108
125
|
|
|
126
|
+
The product contract is documented in [docs/PRODUCT_CONTRACT.md](docs/PRODUCT_CONTRACT.md).
|
|
127
|
+
|
|
109
128
|
Runtime live sidecar sync is documented in [docs/RUNTIME_LIVE_SIDECAR.md](docs/RUNTIME_LIVE_SIDECAR.md).
|
|
110
129
|
|
|
130
|
+
Published Runtime bridge validation is documented in the release checks section below. It installs the published npm package into a fresh temporary project, reads a real Runtime Lite SQLite source, writes only separate Substrate target stores, and verifies snapshot/live parity plus checkpoint idempotency.
|
|
131
|
+
|
|
132
|
+
Runtime Zvec candidate-index validation is documented in [docs/RUNTIME_ZVEC_CANDIDATE_INDEX.md](docs/RUNTIME_ZVEC_CANDIDATE_INDEX.md).
|
|
133
|
+
|
|
134
|
+
Zvec scale and maintenance validation is documented in [docs/ZVEC_SCALE_MAINTENANCE.md](docs/ZVEC_SCALE_MAINTENANCE.md).
|
|
135
|
+
|
|
136
|
+
Provider-backed Zvec embedding validation is documented in [docs/ZVEC_PROVIDER_EMBEDDING_EVAL.md](docs/ZVEC_PROVIDER_EMBEDDING_EVAL.md).
|
|
137
|
+
The provider eval supports OpenAI-compatible embedding endpoints and MiniMax native embeddings for checking Zvec candidate preselection with real provider vectors.
|
|
138
|
+
|
|
111
139
|
Runtime reference corpus parity is documented in [docs/RUNTIME_REFERENCE_CORPUS.md](docs/RUNTIME_REFERENCE_CORPUS.md).
|
|
112
140
|
|
|
113
141
|
Runtime sidecar stabilization is documented in [docs/RUNTIME_SIDECAR_STABILIZATION.md](docs/RUNTIME_SIDECAR_STABILIZATION.md).
|
|
@@ -137,10 +165,11 @@ Node 24+ is required because the project runs TypeScript directly.
|
|
|
137
165
|
## Minimal API Loop
|
|
138
166
|
|
|
139
167
|
```ts
|
|
140
|
-
import { openSqliteAionisSubstrate } from "@aionis/substrate";
|
|
168
|
+
import { createMemoryCandidateIndex, openSqliteAionisSubstrate } from "@aionis/substrate";
|
|
141
169
|
|
|
142
170
|
const store = await openSqliteAionisSubstrate({
|
|
143
171
|
path: "./aionis-substrate.sqlite",
|
|
172
|
+
candidateIndex: createMemoryCandidateIndex(),
|
|
144
173
|
});
|
|
145
174
|
|
|
146
175
|
await store.putNode({
|
|
@@ -210,6 +239,18 @@ npm run check:runtime-corpus -- \
|
|
|
210
239
|
|
|
211
240
|
This scans Runtime Lite SQLite files read-only, imports selected scopes into temporary Substrate stores, and writes an aggregate matrix report under `reports/runtime-snapshot-corpus-*`. The report includes bucket totals, node/relation/feedback/decision coverage, source-table presence, skip reasons, and Runtime JSON issues.
|
|
212
241
|
|
|
242
|
+
Runtime Zvec candidate-index check:
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
npm run check:runtime-zvec-index -- \
|
|
246
|
+
--root /path/to/AionisRuntime-focused/.tmp \
|
|
247
|
+
--max-scopes 20 \
|
|
248
|
+
--min-nodes 3 \
|
|
249
|
+
--probes-per-scope 8
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
This imports real Runtime Lite SQLite scopes into isolated Substrate SQLite stores, rebuilds a Zvec candidate index, verifies missing/orphan/stale health, and checks that wide candidate search preserves canonical Substrate search while narrow candidate search recovers seeded real Runtime memory nodes.
|
|
253
|
+
|
|
213
254
|
Runtime live sidecar mirror:
|
|
214
255
|
|
|
215
256
|
```bash
|
|
@@ -286,6 +327,23 @@ npm run check:runtime-dual-write -- \
|
|
|
286
327
|
|
|
287
328
|
The soak report includes per-scenario latency summaries, chain-probe latency, reopen latency, event-sequence continuity, and SQLite file sizes.
|
|
288
329
|
|
|
330
|
+
Runtime product bridge gate:
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
npm run check:runtime-product-bridge -- \
|
|
334
|
+
--runtime-root /path/to/AionisRuntime-focused
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
This is the product-level bridge check. It runs real focused Runtime
|
|
338
|
+
`observe -> guide -> feedback -> measure`, verifies external Substrate
|
|
339
|
+
dual-write parity, closes and reopens the Substrate store, runs lifecycle/relation
|
|
340
|
+
chain probes, mirrors the Runtime Lite SQLite source through read-only
|
|
341
|
+
`live-sidecar`, re-runs `live-sidecar` to prove checkpoint idempotency, and then
|
|
342
|
+
compares the mirrored Substrate `previewContext` buckets back against Runtime
|
|
343
|
+
guide surfaces. The default gate runs 4 fixed scenarios, 96 deterministic
|
|
344
|
+
generated scenarios, and 16 chain probes. It writes a single
|
|
345
|
+
`product-bridge-gate-summary.json` report and exits non-zero if any stage fails.
|
|
346
|
+
|
|
289
347
|
## Development Checks
|
|
290
348
|
|
|
291
349
|
```bash
|
|
@@ -297,6 +355,7 @@ npm run check:runtime-live-sidecar-soak
|
|
|
297
355
|
npm run check:pack
|
|
298
356
|
npm run check:install-smoke
|
|
299
357
|
npm run example:basic
|
|
358
|
+
npm run example:live-sidecar
|
|
300
359
|
```
|
|
301
360
|
|
|
302
361
|
The CI workflow runs the same checks on every push and pull request.
|
|
@@ -318,10 +377,13 @@ After publishing to npm, run the registry package checks:
|
|
|
318
377
|
```bash
|
|
319
378
|
npm run check:registry-install
|
|
320
379
|
npm run check:published-runtime-smoke
|
|
380
|
+
AIONIS_RUNTIME_SQLITE_SOURCE=/path/to/aionis-lite.sqlite npm run check:published-runtime-bridge
|
|
321
381
|
```
|
|
322
382
|
|
|
323
383
|
These commands install `@aionis/substrate@<package.json version>` from the npm registry into a fresh temporary project. `check:published-runtime-smoke` also creates a Runtime Lite SQLite fixture and verifies published-package snapshot import into a separate Substrate store.
|
|
324
384
|
|
|
385
|
+
`check:published-runtime-bridge` is the real Runtime bridge gate. It reads the Runtime Lite SQLite source passed through `AIONIS_RUNTIME_SQLITE_SOURCE`, imports it into an isolated snapshot store, runs checkpointed `live-sidecar` twice into an isolated live store, verifies the second pass does not mutate the target, verifies snapshot/live event parity, and verifies the Runtime source file was not modified.
|
|
386
|
+
|
|
325
387
|
## Scale Smoke
|
|
326
388
|
|
|
327
389
|
```bash
|
|
@@ -333,3 +395,32 @@ npm run check:scale -- \
|
|
|
333
395
|
```
|
|
334
396
|
|
|
335
397
|
The scale smoke writes a temporary SQLite substrate, verifies event sequence continuity, runs scoped search, compiles context, compacts the store, reopens it, and writes a report under `reports/scale-*`.
|
|
398
|
+
|
|
399
|
+
SQLite + Zvec scale maintenance:
|
|
400
|
+
|
|
401
|
+
```bash
|
|
402
|
+
npm run check:zvec-scale -- \
|
|
403
|
+
--nodes 10000 \
|
|
404
|
+
--scopes 10 \
|
|
405
|
+
--relations 2000 \
|
|
406
|
+
--feedback 1000 \
|
|
407
|
+
--probes 100 \
|
|
408
|
+
--narrow-candidate-limit 20
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
This writes a temporary SQLite truth store with a Zvec candidate sidecar, verifies write-through index health, compares wide-window Zvec search against canonical Substrate search, checks narrow-window seeded recovery, transitions lifecycle state, compacts, reopens, and writes a report under `reports/zvec-scale-*`.
|
|
412
|
+
|
|
413
|
+
Provider-backed Zvec embedding eval:
|
|
414
|
+
|
|
415
|
+
```bash
|
|
416
|
+
AIONIS_EMBEDDING_API_KEY=... \
|
|
417
|
+
AIONIS_EMBEDDING_MODEL=text-embedding-3-small \
|
|
418
|
+
npm run check:zvec-provider-embedding -- \
|
|
419
|
+
--base-url https://api.openai.com/v1 \
|
|
420
|
+
--nodes 240 \
|
|
421
|
+
--scopes 4 \
|
|
422
|
+
--queries 20 \
|
|
423
|
+
--candidate-limit 20
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
This uses a real embedding provider, stores provider vectors on generated Substrate nodes, runs Zvec candidate search, and reports both raw Zvec candidate hit rate and final Substrate search hit rate. The runner supports OpenAI-compatible endpoints, MiniMax native embeddings, and DashScope native `text-embedding-v4` with query/document projection.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AionisMemoryNode, AionisMemorySearchInput, AionisMemorySearchReason } from "./types.ts";
|
|
2
|
+
export type AionisCandidateIndexSearchResult = {
|
|
3
|
+
scope: string;
|
|
4
|
+
memoryId: string;
|
|
5
|
+
score: number;
|
|
6
|
+
reasons: AionisMemorySearchReason[];
|
|
7
|
+
};
|
|
8
|
+
export type AionisCandidateIndexHealthReport = {
|
|
9
|
+
ok: boolean;
|
|
10
|
+
sourceCount: number;
|
|
11
|
+
indexedCount: number;
|
|
12
|
+
missingNodeIds: string[];
|
|
13
|
+
orphanNodeIds: string[];
|
|
14
|
+
staleNodeIds: string[];
|
|
15
|
+
};
|
|
16
|
+
export type AionisCandidateIndex = {
|
|
17
|
+
upsertNode(node: AionisMemoryNode): Promise<void>;
|
|
18
|
+
deleteNode(scope: string, id: string): Promise<void>;
|
|
19
|
+
search(input: AionisMemorySearchInput): Promise<AionisCandidateIndexSearchResult[] | null>;
|
|
20
|
+
rebuild(nodes: AionisMemoryNode[]): Promise<AionisCandidateIndexHealthReport>;
|
|
21
|
+
verify(nodes: AionisMemoryNode[]): Promise<AionisCandidateIndexHealthReport>;
|
|
22
|
+
close?(): Promise<void>;
|
|
23
|
+
};
|
|
24
|
+
export declare function createMemoryCandidateIndex(nodes?: AionisMemoryNode[]): AionisCandidateIndex;
|
|
25
|
+
//# sourceMappingURL=candidate-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"candidate-index.d.ts","sourceRoot":"","sources":["../src/candidate-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,gCAAgC,GAAG;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,wBAAwB,EAAE,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,EAAE,EAAE,OAAO,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,MAAM,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,gCAAgC,EAAE,GAAG,IAAI,CAAC,CAAC;IAC3F,OAAO,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAAC;IAC9E,MAAM,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAAC;IAC7E,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB,CAAC;AAyJF,wBAAgB,0BAA0B,CAAC,KAAK,GAAE,gBAAgB,EAAO,GAAG,oBAAoB,CA0E/F"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
const DEFAULT_INDEX_LIMIT = 200;
|
|
2
|
+
function indexKey(scope, id) {
|
|
3
|
+
return `${scope}\u0000${id}`;
|
|
4
|
+
}
|
|
5
|
+
function normalizeText(value) {
|
|
6
|
+
return value.toLowerCase().normalize("NFKC");
|
|
7
|
+
}
|
|
8
|
+
function tokenize(value) {
|
|
9
|
+
return Array.from(new Set(normalizeText(value).match(/[\p{L}\p{N}_./:-]+/gu) ?? []));
|
|
10
|
+
}
|
|
11
|
+
function normalizePath(value) {
|
|
12
|
+
return value.trim().replaceAll("\\", "/").replace(/\/+/g, "/").toLowerCase();
|
|
13
|
+
}
|
|
14
|
+
function stableMetadataText(metadata) {
|
|
15
|
+
if (!metadata)
|
|
16
|
+
return "";
|
|
17
|
+
return Object.entries(metadata)
|
|
18
|
+
.filter(([, value]) => typeof value === "string" || typeof value === "number" || typeof value === "boolean")
|
|
19
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
20
|
+
.map(([key, value]) => `${key}:${String(value)}`)
|
|
21
|
+
.join(" ");
|
|
22
|
+
}
|
|
23
|
+
function nodeSearchText(node) {
|
|
24
|
+
return [
|
|
25
|
+
node.id,
|
|
26
|
+
node.kind,
|
|
27
|
+
node.title ?? "",
|
|
28
|
+
node.summary,
|
|
29
|
+
...(node.targetFiles ?? []),
|
|
30
|
+
node.payloadRef ?? "",
|
|
31
|
+
node.agentId ?? "",
|
|
32
|
+
node.teamId ?? "",
|
|
33
|
+
stableMetadataText(node.metadata),
|
|
34
|
+
].filter(Boolean).join(" ");
|
|
35
|
+
}
|
|
36
|
+
function nodeFingerprint(node) {
|
|
37
|
+
return JSON.stringify({
|
|
38
|
+
id: node.id,
|
|
39
|
+
scope: node.scope,
|
|
40
|
+
kind: node.kind,
|
|
41
|
+
title: node.title ?? null,
|
|
42
|
+
summary: node.summary,
|
|
43
|
+
lifecycle: node.lifecycle,
|
|
44
|
+
authority: node.authority,
|
|
45
|
+
confidence: node.confidence,
|
|
46
|
+
targetFiles: node.targetFiles ?? [],
|
|
47
|
+
payloadRef: node.payloadRef ?? null,
|
|
48
|
+
agentId: node.agentId ?? null,
|
|
49
|
+
teamId: node.teamId ?? null,
|
|
50
|
+
metadata: node.metadata ?? {},
|
|
51
|
+
updatedAt: node.updatedAt,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function toIndexedNode(node) {
|
|
55
|
+
const text = nodeSearchText(node);
|
|
56
|
+
return {
|
|
57
|
+
node,
|
|
58
|
+
fingerprint: nodeFingerprint(node),
|
|
59
|
+
text: normalizeText(text),
|
|
60
|
+
tokens: new Set(tokenize(text)),
|
|
61
|
+
targetFiles: new Set((node.targetFiles ?? []).map(normalizePath).filter(Boolean)),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function hasAnyTargetFile(indexed, targetFiles) {
|
|
65
|
+
if (targetFiles.length === 0)
|
|
66
|
+
return true;
|
|
67
|
+
return targetFiles.some((target) => indexed.targetFiles.has(normalizePath(target)));
|
|
68
|
+
}
|
|
69
|
+
function setContains(filter, value) {
|
|
70
|
+
return !filter || filter.has(value);
|
|
71
|
+
}
|
|
72
|
+
function compareIso(value, boundary) {
|
|
73
|
+
return value.localeCompare(boundary);
|
|
74
|
+
}
|
|
75
|
+
function scoreQuery(indexed, query) {
|
|
76
|
+
const queryTokens = tokenize(query ?? "");
|
|
77
|
+
if (queryTokens.length === 0)
|
|
78
|
+
return {
|
|
79
|
+
score: indexed.node.confidence,
|
|
80
|
+
reasons: [{ code: "candidate_index_scope_match", detail: `scope=${indexed.node.scope}` }],
|
|
81
|
+
};
|
|
82
|
+
let score = indexed.node.confidence;
|
|
83
|
+
const matched = [];
|
|
84
|
+
for (const token of queryTokens) {
|
|
85
|
+
if (indexed.tokens.has(token)) {
|
|
86
|
+
score += 2;
|
|
87
|
+
matched.push(token);
|
|
88
|
+
}
|
|
89
|
+
else if (indexed.text.includes(token)) {
|
|
90
|
+
score += 1;
|
|
91
|
+
matched.push(token);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (matched.length === 0)
|
|
95
|
+
return null;
|
|
96
|
+
return {
|
|
97
|
+
score,
|
|
98
|
+
reasons: [{
|
|
99
|
+
code: "candidate_index_query_match",
|
|
100
|
+
detail: `candidate index matched ${matched.length}/${queryTokens.length} query tokens: ${matched.join(", ")}`,
|
|
101
|
+
}],
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function healthFrom(indexed, nodes) {
|
|
105
|
+
const source = new Map(nodes.map((node) => [indexKey(node.scope, node.id), node]));
|
|
106
|
+
const missingNodeIds = [];
|
|
107
|
+
const orphanNodeIds = [];
|
|
108
|
+
const staleNodeIds = [];
|
|
109
|
+
for (const [key, node] of source) {
|
|
110
|
+
const current = indexed.get(key);
|
|
111
|
+
if (!current) {
|
|
112
|
+
missingNodeIds.push(node.id);
|
|
113
|
+
}
|
|
114
|
+
else if (current.fingerprint !== nodeFingerprint(node)) {
|
|
115
|
+
staleNodeIds.push(node.id);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
for (const [key, current] of indexed) {
|
|
119
|
+
if (!source.has(key))
|
|
120
|
+
orphanNodeIds.push(current.node.id);
|
|
121
|
+
}
|
|
122
|
+
missingNodeIds.sort();
|
|
123
|
+
orphanNodeIds.sort();
|
|
124
|
+
staleNodeIds.sort();
|
|
125
|
+
return {
|
|
126
|
+
ok: missingNodeIds.length === 0 && orphanNodeIds.length === 0 && staleNodeIds.length === 0,
|
|
127
|
+
sourceCount: source.size,
|
|
128
|
+
indexedCount: indexed.size,
|
|
129
|
+
missingNodeIds,
|
|
130
|
+
orphanNodeIds,
|
|
131
|
+
staleNodeIds,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
export function createMemoryCandidateIndex(nodes = []) {
|
|
135
|
+
const indexed = new Map();
|
|
136
|
+
for (const node of nodes)
|
|
137
|
+
indexed.set(indexKey(node.scope, node.id), toIndexedNode(node));
|
|
138
|
+
return {
|
|
139
|
+
async upsertNode(node) {
|
|
140
|
+
indexed.set(indexKey(node.scope, node.id), toIndexedNode(node));
|
|
141
|
+
},
|
|
142
|
+
async deleteNode(scope, id) {
|
|
143
|
+
indexed.delete(indexKey(scope, id));
|
|
144
|
+
},
|
|
145
|
+
async search(input) {
|
|
146
|
+
const scope = input.scope.trim();
|
|
147
|
+
if (!scope)
|
|
148
|
+
throw new Error("scope is required");
|
|
149
|
+
const limit = input.limit === undefined ? DEFAULT_INDEX_LIMIT : input.limit;
|
|
150
|
+
if (!Number.isInteger(limit) || limit < 1)
|
|
151
|
+
throw new Error("limit must be a positive integer");
|
|
152
|
+
if (input.minConfidence !== undefined && (!Number.isFinite(input.minConfidence) || input.minConfidence < 0 || input.minConfidence > 1)) {
|
|
153
|
+
throw new Error("minConfidence must be between 0 and 1");
|
|
154
|
+
}
|
|
155
|
+
const kindFilter = input.kinds === undefined ? null : new Set(input.kinds);
|
|
156
|
+
const lifecycleFilter = input.lifecycle === undefined ? null : new Set(input.lifecycle);
|
|
157
|
+
const authorityFilter = input.authority === undefined ? null : new Set(input.authority);
|
|
158
|
+
const targetFiles = input.targetFiles?.map((item) => item.trim()).filter(Boolean) ?? [];
|
|
159
|
+
const results = [];
|
|
160
|
+
for (const item of indexed.values()) {
|
|
161
|
+
const node = item.node;
|
|
162
|
+
if (node.scope !== scope)
|
|
163
|
+
continue;
|
|
164
|
+
if (!setContains(kindFilter, node.kind))
|
|
165
|
+
continue;
|
|
166
|
+
if (!setContains(lifecycleFilter, node.lifecycle))
|
|
167
|
+
continue;
|
|
168
|
+
if (!setContains(authorityFilter, node.authority))
|
|
169
|
+
continue;
|
|
170
|
+
if (input.agentId !== undefined && node.agentId !== input.agentId)
|
|
171
|
+
continue;
|
|
172
|
+
if (input.teamId !== undefined && node.teamId !== input.teamId)
|
|
173
|
+
continue;
|
|
174
|
+
if (input.minConfidence !== undefined && node.confidence < input.minConfidence)
|
|
175
|
+
continue;
|
|
176
|
+
if (input.updatedAfter !== undefined && compareIso(node.updatedAt, input.updatedAfter) < 0)
|
|
177
|
+
continue;
|
|
178
|
+
if (input.updatedBefore !== undefined && compareIso(node.updatedAt, input.updatedBefore) > 0)
|
|
179
|
+
continue;
|
|
180
|
+
if (!hasAnyTargetFile(item, targetFiles))
|
|
181
|
+
continue;
|
|
182
|
+
const query = scoreQuery(item, input.query);
|
|
183
|
+
if (!query)
|
|
184
|
+
continue;
|
|
185
|
+
results.push({
|
|
186
|
+
scope: node.scope,
|
|
187
|
+
memoryId: node.id,
|
|
188
|
+
score: query.score,
|
|
189
|
+
reasons: query.reasons,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
return results
|
|
193
|
+
.sort((a, b) => {
|
|
194
|
+
const byScore = b.score - a.score;
|
|
195
|
+
if (byScore !== 0)
|
|
196
|
+
return byScore;
|
|
197
|
+
const aNode = indexed.get(indexKey(a.scope, a.memoryId))?.node;
|
|
198
|
+
const bNode = indexed.get(indexKey(b.scope, b.memoryId))?.node;
|
|
199
|
+
const byTime = (bNode?.updatedAt ?? "").localeCompare(aNode?.updatedAt ?? "");
|
|
200
|
+
if (byTime !== 0)
|
|
201
|
+
return byTime;
|
|
202
|
+
return a.memoryId.localeCompare(b.memoryId);
|
|
203
|
+
})
|
|
204
|
+
.slice(0, limit);
|
|
205
|
+
},
|
|
206
|
+
async rebuild(nodes) {
|
|
207
|
+
indexed.clear();
|
|
208
|
+
for (const node of nodes)
|
|
209
|
+
indexed.set(indexKey(node.scope, node.id), toIndexedNode(node));
|
|
210
|
+
return healthFrom(indexed, nodes);
|
|
211
|
+
},
|
|
212
|
+
async verify(nodes) {
|
|
213
|
+
return healthFrom(indexed, nodes);
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=candidate-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"candidate-index.js","sourceRoot":"","sources":["../src/candidate-index.ts"],"names":[],"mappings":"AA0CA,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEhC,SAAS,QAAQ,CAAC,KAAa,EAAE,EAAU;IACzC,OAAO,GAAG,KAAK,SAAS,EAAE,EAAE,CAAC;AAC/B,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC7B,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,sBAAsB,C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B;YACpC,OAAO,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACpC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AionisMemoryNode, AionisMemoryNodeInput } from "./types.ts";
|
|
2
|
+
export declare const AIONIS_EMBEDDING_PROJECTION_VERSION = "aionis_substrate_embedding_projection_v1";
|
|
3
|
+
export type AionisEmbeddingProjectionMode = "plain" | "structured";
|
|
4
|
+
export type AionisEmbeddingDocumentOptions = {
|
|
5
|
+
projection?: AionisEmbeddingProjectionMode;
|
|
6
|
+
includeIdentity?: boolean;
|
|
7
|
+
includeOwner?: boolean;
|
|
8
|
+
metadataKeys?: "all" | string[] | false;
|
|
9
|
+
};
|
|
10
|
+
export type AionisEmbeddingQueryOptions = {
|
|
11
|
+
projection?: AionisEmbeddingProjectionMode;
|
|
12
|
+
task?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function buildAionisEmbeddingDocument(node: AionisMemoryNode | AionisMemoryNodeInput, options?: AionisEmbeddingDocumentOptions): string;
|
|
15
|
+
export declare function buildAionisEmbeddingQuery(query: string, options?: AionisEmbeddingQueryOptions): string;
|
|
16
|
+
//# sourceMappingURL=embedding-projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedding-projection.d.ts","sourceRoot":"","sources":["../src/embedding-projection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE1E,eAAO,MAAM,mCAAmC,6CAA6C,CAAC;AAE9F,MAAM,MAAM,6BAA6B,GAAG,OAAO,GAAG,YAAY,CAAC;AAEnE,MAAM,MAAM,8BAA8B,GAAG;IAC3C,UAAU,CAAC,EAAE,6BAA6B,CAAC;IAC3C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,UAAU,CAAC,EAAE,6BAA6B,CAAC;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AA0EF,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,gBAAgB,GAAG,qBAAqB,EAC9C,OAAO,GAAE,8BAAmC,GAC3C,MAAM,CAmBR;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,2BAAgC,GACxC,MAAM,CAWR"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export const AIONIS_EMBEDDING_PROJECTION_VERSION = "aionis_substrate_embedding_projection_v1";
|
|
2
|
+
const VECTOR_METADATA_KEYS = new Set([
|
|
3
|
+
"embedding",
|
|
4
|
+
"embedding_vector",
|
|
5
|
+
"vector",
|
|
6
|
+
"query_vector",
|
|
7
|
+
]);
|
|
8
|
+
function normalizeText(value) {
|
|
9
|
+
return value
|
|
10
|
+
.normalize("NFKC")
|
|
11
|
+
.replace(/\s+/g, " ")
|
|
12
|
+
.trim();
|
|
13
|
+
}
|
|
14
|
+
function optionalValue(value) {
|
|
15
|
+
if (value === null || value === undefined)
|
|
16
|
+
return null;
|
|
17
|
+
if (typeof value === "string") {
|
|
18
|
+
const normalized = normalizeText(value);
|
|
19
|
+
return normalized.length > 0 ? normalized : null;
|
|
20
|
+
}
|
|
21
|
+
if (typeof value === "number" || typeof value === "boolean")
|
|
22
|
+
return String(value);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
function joinList(values) {
|
|
26
|
+
const normalized = (values ?? [])
|
|
27
|
+
.map((value) => normalizeText(value))
|
|
28
|
+
.filter(Boolean)
|
|
29
|
+
.sort((a, b) => a.localeCompare(b));
|
|
30
|
+
return normalized.length > 0 ? normalized.join(", ") : null;
|
|
31
|
+
}
|
|
32
|
+
function stableMetadataText(metadata, metadataKeys = false) {
|
|
33
|
+
if (!metadata)
|
|
34
|
+
return null;
|
|
35
|
+
if (metadataKeys === false)
|
|
36
|
+
return null;
|
|
37
|
+
const allowedKeys = Array.isArray(metadataKeys) ? new Set(metadataKeys) : null;
|
|
38
|
+
const rows = Object.entries(metadata)
|
|
39
|
+
.filter(([key, value]) => !VECTOR_METADATA_KEYS.has(key) &&
|
|
40
|
+
(allowedKeys === null || allowedKeys.has(key)) &&
|
|
41
|
+
optionalValue(value) !== null)
|
|
42
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
43
|
+
.map(([key, value]) => `${key}=${optionalValue(value)}`);
|
|
44
|
+
return rows.length > 0 ? rows.join("; ") : null;
|
|
45
|
+
}
|
|
46
|
+
function line(label, value) {
|
|
47
|
+
const normalized = optionalValue(value);
|
|
48
|
+
return normalized === null ? null : `${label}: ${normalized}`;
|
|
49
|
+
}
|
|
50
|
+
function plainDocumentText(node, options) {
|
|
51
|
+
return [
|
|
52
|
+
node.title,
|
|
53
|
+
node.summary,
|
|
54
|
+
node.kind,
|
|
55
|
+
node.lifecycle,
|
|
56
|
+
node.authority,
|
|
57
|
+
joinList(node.targetFiles),
|
|
58
|
+
node.payloadRef,
|
|
59
|
+
options.includeOwner ? node.agentId : null,
|
|
60
|
+
options.includeOwner ? node.teamId : null,
|
|
61
|
+
stableMetadataText(node.metadata, options.metadataKeys),
|
|
62
|
+
].flatMap((value) => {
|
|
63
|
+
const normalized = optionalValue(value);
|
|
64
|
+
return normalized === null ? [] : [normalized];
|
|
65
|
+
}).join(" ");
|
|
66
|
+
}
|
|
67
|
+
export function buildAionisEmbeddingDocument(node, options = {}) {
|
|
68
|
+
const projection = options.projection ?? "structured";
|
|
69
|
+
if (projection === "plain")
|
|
70
|
+
return plainDocumentText(node, options);
|
|
71
|
+
return [
|
|
72
|
+
AIONIS_EMBEDDING_PROJECTION_VERSION,
|
|
73
|
+
"type: memory_document",
|
|
74
|
+
options.includeIdentity ? line("id", node.id) : null,
|
|
75
|
+
options.includeIdentity ? line("scope", node.scope) : null,
|
|
76
|
+
line("kind", node.kind),
|
|
77
|
+
line("lifecycle", node.lifecycle),
|
|
78
|
+
line("authority", node.authority),
|
|
79
|
+
line("title", node.title),
|
|
80
|
+
line("summary", node.summary),
|
|
81
|
+
line("target_files", joinList(node.targetFiles)),
|
|
82
|
+
line("payload_ref", node.payloadRef),
|
|
83
|
+
options.includeOwner ? line("agent_id", node.agentId) : null,
|
|
84
|
+
options.includeOwner ? line("team_id", node.teamId) : null,
|
|
85
|
+
line("metadata", stableMetadataText(node.metadata, options.metadataKeys)),
|
|
86
|
+
].filter((value) => value !== null).join("\n");
|
|
87
|
+
}
|
|
88
|
+
export function buildAionisEmbeddingQuery(query, options = {}) {
|
|
89
|
+
const normalizedQuery = normalizeText(query);
|
|
90
|
+
const projection = options.projection ?? "structured";
|
|
91
|
+
if (projection === "plain")
|
|
92
|
+
return normalizedQuery;
|
|
93
|
+
const task = normalizeText(options.task ?? "retrieve the memory document that best answers this implementation question");
|
|
94
|
+
return [
|
|
95
|
+
AIONIS_EMBEDDING_PROJECTION_VERSION,
|
|
96
|
+
"type: retrieval_query",
|
|
97
|
+
`task: ${task}`,
|
|
98
|
+
`query: ${normalizedQuery}`,
|
|
99
|
+
].join("\n");
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=embedding-projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedding-projection.js","sourceRoot":"","sources":["../src/embedding-projection.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mCAAmC,GAAG,0CAA0C,CAAC;AAgB9F,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,WAAW;IACX,kBAAkB;IAClB,QAAQ;IACR,cAAc;CACf,CAAC,CAAC;AAEH,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,KAAK;SACT,SAAS,CAAC,MAAM,CAAC;SACjB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACp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I,CAAC,WAAW,CAAC,CAAC;QAChD,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC;QACpC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI;QAC5D,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI;QAC1D,IAAI,CAAC,UAAU,EAAE,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;KAC1E,CAAC,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,KAAa,EACb,UAAuC,EAAE;IAEzC,MAAM,eAAe,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,YAAY,CAAC;IACtD,IAAI,UAAU,KAAK,OAAO;QAAE,OAAO,eAAe,CAAC;IACnD,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,IAAI,IAAI,6EAA6E,CAAC,CAAC;IAC1H,OAAO;QACL,mCAAmC;QACnC,uBAAuB;QACvB,SAAS,IAAI,EAAE;QACf,UAAU,eAAe,EAAE;KAC5B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
package/dist/file-substrate.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import type { AionisCandidateIndex } from "./candidate-index.ts";
|
|
1
2
|
import type { AionisSubstrate } from "./types.ts";
|
|
2
3
|
export type FileAionisSubstrateOptions = {
|
|
3
4
|
dir: string;
|
|
4
5
|
now?: () => Date;
|
|
6
|
+
candidateIndex?: AionisCandidateIndex | null;
|
|
7
|
+
rebuildCandidateIndexOnOpen?: boolean;
|
|
5
8
|
};
|
|
6
9
|
export declare function openFileAionisSubstrate(options: FileAionisSubstrateOptions): Promise<AionisSubstrate>;
|
|
7
10
|
//# sourceMappingURL=file-substrate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-substrate.d.ts","sourceRoot":"","sources":["../src/file-substrate.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAcV,eAAe,EAChB,MAAM,YAAY,CAAC;AAGpB,MAAM,MAAM,0BAA0B,GAAG;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"file-substrate.d.ts","sourceRoot":"","sources":["../src/file-substrate.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAcV,eAAe,EAChB,MAAM,YAAY,CAAC;AAGpB,MAAM,MAAM,0BAA0B,GAAG;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB,cAAc,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC7C,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC,CAAC;AAyEF,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,eAAe,CAAC,CA+b3G"}
|