@avantf/dsh-mem 0.6.4 → 0.8.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 +19 -10
- package/lib/client.js +1665 -3466
- package/lib/dsh-build.json +6 -5
- package/lib/engine/graph-recall/in-memory.d.ts +93 -0
- package/lib/engine/graph-recall/index.d.ts +22 -0
- package/lib/engine/graph-recall/traverse.d.ts +119 -0
- package/lib/engine/graph-recall/types.d.ts +188 -0
- package/lib/engine/mem/config/config_files.d.ts +1 -1
- package/lib/engine/mem/config/loader.d.ts +2 -3
- package/lib/engine/mem/config/paths.d.ts +2 -13
- package/lib/engine/mem/db/dao/contradictions.d.ts +4 -22
- package/lib/engine/mem/db/dao/entities.d.ts +80 -7
- package/lib/engine/mem/db/dao/fact_sources.d.ts +3 -13
- package/lib/engine/mem/db/dao/facts.d.ts +311 -56
- package/lib/engine/mem/db/dao/triples.d.ts +1 -26
- package/lib/engine/mem/db/graph.d.ts +249 -0
- package/lib/engine/mem/db/journal_notes.d.ts +35 -0
- package/lib/engine/mem/db/migrations.d.ts +9 -0
- package/lib/engine/mem/db/port.d.ts +22 -3
- package/lib/engine/mem/db/schema.d.ts +119 -0
- package/lib/engine/mem/db/tokenizer.d.ts +9 -0
- package/lib/engine/mem/dbdrivers/fake/driver.d.ts +75 -0
- package/lib/engine/mem/dbdrivers/fake/index.d.ts +7 -0
- package/lib/engine/mem/dbdrivers/fake/surface.d.ts +34 -0
- package/lib/engine/mem/dbdrivers/fake/transport.d.ts +61 -0
- package/lib/engine/mem/dbdrivers/sqlite/connection.d.ts +14 -0
- package/lib/engine/mem/dbdrivers/sqlite/contradictions.d.ts +35 -0
- package/lib/engine/mem/dbdrivers/sqlite/dao/index.d.ts +16 -0
- package/lib/engine/mem/dbdrivers/sqlite/driver.d.ts +54 -0
- package/lib/engine/mem/dbdrivers/sqlite/facts.d.ts +117 -0
- package/lib/engine/mem/dbdrivers/sqlite/index.d.ts +6 -0
- package/lib/engine/mem/dbdrivers/sqlite/migrations.d.ts +15 -0
- package/lib/engine/mem/dbdrivers/sqlite/relations.d.ts +62 -0
- package/lib/engine/mem/dbdrivers/sqlite/search.d.ts +56 -0
- package/lib/engine/mem/dbdrivers/sqlite/sources.d.ts +37 -0
- package/lib/engine/mem/defaults.d.ts +3 -4
- package/lib/engine/mem/dispatch.d.ts +7 -32
- package/lib/engine/mem/entities/extract.d.ts +44 -47
- package/lib/engine/mem/eval/derived_runner.d.ts +6 -1
- package/lib/engine/mem/eval/relation_gold.d.ts +251 -0
- package/lib/engine/mem/eval/write_metrics.d.ts +1 -1
- package/lib/engine/mem/facts_io.d.ts +328 -0
- package/lib/engine/mem/index.d.ts +10 -2
- package/lib/engine/mem/interfaces/capabilities.d.ts +30 -0
- package/lib/engine/mem/interfaces/common.d.ts +11 -0
- package/lib/engine/mem/interfaces/errors.d.ts +65 -0
- package/lib/engine/mem/interfaces/index.d.ts +18 -0
- package/lib/engine/mem/interfaces/migrations.d.ts +21 -0
- package/lib/engine/mem/interfaces/repositories.d.ts +471 -0
- package/lib/engine/mem/interfaces/search_index.d.ts +113 -0
- package/lib/engine/mem/interfaces/storage_backend.d.ts +84 -0
- package/lib/engine/mem/interfaces/storage_driver.d.ts +43 -0
- package/lib/engine/mem/interfaces/version.d.ts +34 -0
- package/lib/engine/mem/lifecycle/contradiction.d.ts +2 -2
- package/lib/engine/mem/maintenance_paths.d.ts +41 -0
- package/lib/engine/mem/modelBootstrap.d.ts +1 -1
- package/lib/engine/mem/relations/confidence.d.ts +39 -0
- package/lib/engine/mem/relations/extract.d.ts +128 -0
- package/lib/engine/mem/relations/index.d.ts +32 -0
- package/lib/engine/mem/relations/name-quality.d.ts +78 -0
- package/lib/engine/mem/relations/normalize.d.ts +275 -0
- package/lib/engine/mem/relations/patterns.d.ts +67 -0
- package/lib/engine/mem/relations/statement.d.ts +88 -0
- package/lib/engine/mem/relations/types.d.ts +79 -0
- package/lib/engine/mem/runtime.d.ts +117 -90
- package/lib/engine/mem/storage/create.d.ts +42 -0
- package/lib/engine/mem/storage/errors.d.ts +65 -0
- package/lib/engine/mem/storage/index.d.ts +15 -0
- package/lib/engine/mem/storage/ports.d.ts +472 -0
- package/lib/engine/mem/storage/registry.d.ts +37 -0
- package/lib/engine/mem/storage/sqlite.d.ts +28 -0
- package/lib/engine/mem/store/common.d.ts +1 -1
- package/lib/engine/mem/store/entity_leg.d.ts +59 -2
- package/lib/engine/mem/store/entity_sweep.d.ts +4 -3
- package/lib/engine/mem/store/explicit_relations.d.ts +52 -0
- package/lib/engine/mem/store/facts_restore.d.ts +124 -0
- package/lib/engine/mem/store/floors.d.ts +4 -1
- package/lib/engine/mem/store/graph_reader.d.ts +146 -0
- package/lib/engine/mem/store/hybrid.d.ts +50 -13
- package/lib/engine/mem/store/kinds.d.ts +47 -0
- package/lib/engine/mem/store/legs.d.ts +24 -29
- package/lib/engine/mem/store/lexical.d.ts +36 -45
- package/lib/engine/mem/store/memory.d.ts +486 -82
- package/lib/engine/mem/store/recall_policy.d.ts +49 -0
- package/lib/engine/mem/store/relation_backfill.d.ts +210 -0
- package/lib/engine/mem/store/relation_planner.d.ts +191 -0
- package/lib/engine/mem/store/secret_guard.d.ts +0 -1
- package/lib/engine/mem/store/self_query.d.ts +4 -2
- package/lib/engine/mem/store/time_filter.d.ts +121 -0
- package/lib/engine/mem/store/titles.d.ts +52 -0
- package/lib/engine/mem/store/vector_repair.d.ts +44 -54
- package/lib/engine/mem-contract/config.d.ts +44 -38
- package/lib/engine/mem-contract/text.d.ts +1 -1
- package/lib/engine/mem-contract/tools.d.ts +184 -117
- package/lib/engine/mem-contract/types.d.ts +364 -288
- package/lib/index.js +13898 -11500
- package/lib/interface-version.json +1 -1
- package/lib/types/client/index.d.ts +2 -2
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/paging.d.ts +3 -12
- package/lib/types/client/paging.d.ts.map +1 -1
- package/lib/types/client/summarize.d.ts.map +1 -1
- package/lib/types/command.d.ts +61 -0
- package/lib/types/command.d.ts.map +1 -0
- package/lib/types/envinit-bootstrap.d.ts +1 -1
- package/lib/types/envinit.d.ts +2 -6
- package/lib/types/envinit.d.ts.map +1 -1
- package/lib/types/hints.d.ts +28 -24
- package/lib/types/hints.d.ts.map +1 -1
- package/lib/types/index.d.ts +21 -40
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/inject.d.ts +3 -2
- package/lib/types/inject.d.ts.map +1 -1
- package/lib/types/interface_gate.d.ts +9 -9
- package/lib/types/prompt.d.ts +17 -41
- package/lib/types/prompt.d.ts.map +1 -1
- package/lib/types/provision.d.ts +3 -0
- package/lib/types/provision.d.ts.map +1 -1
- package/lib/types/remote.d.ts +23 -9
- package/lib/types/remote.d.ts.map +1 -1
- package/lib/types/render.d.ts +3 -3
- package/lib/types/tool_schema.d.ts +4 -0
- package/lib/types/tool_schema.d.ts.map +1 -1
- package/lib/types/vectorMigration.d.ts +5 -7
- package/lib/types/vectorMigration.d.ts.map +1 -1
- package/package.json +16 -15
- package/lib/engine/mem/config/domains.d.ts +0 -20
- package/lib/engine/mem/db/dao/chunks.d.ts +0 -231
- package/lib/engine/mem/db/dao/documents.d.ts +0 -51
- package/lib/engine/mem/db/hash.d.ts +0 -2
- package/lib/engine/mem/db/knowledge.d.ts +0 -17
- package/lib/engine/mem/eval/index.d.ts +0 -4
- package/lib/engine/mem/git.d.ts +0 -73
- package/lib/engine/mem/router.d.ts +0 -51
- package/lib/engine/mem/store/doc_files.d.ts +0 -125
- package/lib/engine/mem/store/document_text.d.ts +0 -47
- package/lib/engine/mem/store/ingest_guard.d.ts +0 -25
- package/lib/engine/mem/store/knowledge.d.ts +0 -598
- package/lib/engine/mem/store/source_picker.d.ts +0 -43
- package/lib/engine/mem-retrieval/adapters/local_reranker.d.ts +0 -52
- package/lib/engine/mem-retrieval/adapters/none_reranker.d.ts +0 -10
- package/lib/engine/mem-retrieval/rerank.d.ts +0 -13
- package/lib/types/client/domains.d.ts +0 -53
- package/lib/types/client/domains.d.ts.map +0 -1
- package/lib/types/client/ingest.d.ts +0 -24
- package/lib/types/client/ingest.d.ts.map +0 -1
- package/lib/types/open.d.ts +0 -77
- package/lib/types/open.d.ts.map +0 -1
- package/lib/types/reconcile.d.ts +0 -64
- package/lib/types/reconcile.d.ts.map +0 -1
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { Reranker } from '../interfaces.js';
|
|
2
|
-
import { type ModelEnv } from './local_bge.js';
|
|
3
|
-
/** One text-classification result: transformers.js yields `{label, score}`; tolerate a raw `{data}` tensor too. */
|
|
4
|
-
type ClassifyResult = {
|
|
5
|
-
label?: string;
|
|
6
|
-
score?: number;
|
|
7
|
-
data?: number[];
|
|
8
|
-
};
|
|
9
|
-
/** The injected pipeline surface: a batch of (query, document) pairs in, scores out. */
|
|
10
|
-
export type ClassifyFn = (inputs: [string, string][], opts?: Record<string, unknown>) => Promise<ClassifyResult[]>;
|
|
11
|
-
/** Injectable seam: tests supply a fake classifier instead of the transformers.js import. */
|
|
12
|
-
export type RerankerPipeFactory = (model: string, env: ModelEnv) => Promise<ClassifyFn>;
|
|
13
|
-
/** Never hand the classifier a degenerate document; below this the score is meaningless. */
|
|
14
|
-
export declare const MIN_DOC_TOKENS = 16;
|
|
15
|
-
/**
|
|
16
|
-
* Local cross-encoder reranker via `@huggingface/transformers` (`bge-reranker`).
|
|
17
|
-
* Lazily imported; `warmUp()` configures the mirror/cache and triggers a load.
|
|
18
|
-
* Degrades to identity order when the package/model is not available.
|
|
19
|
-
*
|
|
20
|
-
* Like {@link LocalBgeBackend}, a failed warmup is retryable through
|
|
21
|
-
* `ensureWarm()` rather than being final until the next restart.
|
|
22
|
-
*/
|
|
23
|
-
export declare class LocalReranker implements Reranker {
|
|
24
|
-
readonly name = "bge_reranker";
|
|
25
|
-
private _available;
|
|
26
|
-
private _pipe;
|
|
27
|
-
private _warming;
|
|
28
|
-
private _lengthWarned;
|
|
29
|
-
private _window;
|
|
30
|
-
private readonly configuredMax;
|
|
31
|
-
private readonly model;
|
|
32
|
-
private readonly env;
|
|
33
|
-
private readonly pipeFactory;
|
|
34
|
-
private readonly gate;
|
|
35
|
-
constructor(model: string, env?: Partial<ModelEnv>, pipeFactory?: RerankerPipeFactory);
|
|
36
|
-
isAvailable(): boolean;
|
|
37
|
-
/** Fire-and-forget retry for call sites that only observe availability (see `warm_gate.ts`). */
|
|
38
|
-
ensureWarm(): void;
|
|
39
|
-
warmUp(): Promise<void>;
|
|
40
|
-
private _doWarmup;
|
|
41
|
-
private window;
|
|
42
|
-
/**
|
|
43
|
-
* Bound one document for a pair, given how much of the window the query already spends.
|
|
44
|
-
* Returns the document text unchanged when it fits.
|
|
45
|
-
*/
|
|
46
|
-
private boundDocument;
|
|
47
|
-
rerank(query: string, candidates: {
|
|
48
|
-
id: number;
|
|
49
|
-
text: string;
|
|
50
|
-
}[]): Promise<number[]>;
|
|
51
|
-
}
|
|
52
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Reranker } from '../interfaces.js';
|
|
2
|
-
/** `none` — reranking disabled (the default). Reports unavailable so callers skip the rerank pass entirely. */
|
|
3
|
-
export declare class NoneReranker implements Reranker {
|
|
4
|
-
readonly name = "none";
|
|
5
|
-
isAvailable(): boolean;
|
|
6
|
-
rerank(_query: string, candidates: {
|
|
7
|
-
id: number;
|
|
8
|
-
text: string;
|
|
9
|
-
}[]): Promise<number[]>;
|
|
10
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Reranker } from './interfaces.js';
|
|
2
|
-
/**
|
|
3
|
-
* The one rerank-and-reorder pass shared by every retrieval leg (memory search,
|
|
4
|
-
* knowledge search — the blocks were byte-identical and had already drifted once
|
|
5
|
-
* on the miss-sort sentinel).
|
|
6
|
-
*
|
|
7
|
-
* Contract: `reranker.rerank` returns candidate ids best-first; ids it omits sort
|
|
8
|
-
* last with their fused order preserved (stable sort). A disabled/unavailable
|
|
9
|
-
* reranker is a pass-through.
|
|
10
|
-
*/
|
|
11
|
-
export declare function rerankHits<T extends {
|
|
12
|
-
id: number;
|
|
13
|
-
}>(reranker: Reranker, query: string, hits: T[], textOf: (id: number) => string): Promise<T[]>;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The 知识域 picker's option list.
|
|
3
|
-
*
|
|
4
|
-
* The host's `kbDomains` returns `knowledge.domains` (the configured allowlist) ∪ the domains the
|
|
5
|
-
* library already holds. The union is the point: a historical name that the allowlist would not
|
|
6
|
-
* accept as NEW must stay selectable, or the tab offers a value the store then refuses.
|
|
7
|
-
* `restricted` mirrors "the allowlist is non-empty" — then the control is a closed `<select>` and
|
|
8
|
-
* a new domain is a config change, not a second spelling of an existing one. An explicitly empty
|
|
9
|
-
* allowlist means no restriction, so the control stays a free input.
|
|
10
|
-
*
|
|
11
|
-
* `DomainCatalog` itself is the CONTRACT's type (type-only import, erased from the bundle): the
|
|
12
|
-
* host store's `domainCatalog()` return and this picker name the same declaration, so the shape
|
|
13
|
-
* cannot be copied wrong on one half.
|
|
14
|
-
*/
|
|
15
|
-
import type { DomainCatalog } from '../../engine/mem-contract/index.js';
|
|
16
|
-
/** One `<option>`: `value` is what the form sends, `label` is what the user reads. */
|
|
17
|
-
export interface DomainOption {
|
|
18
|
-
value: string;
|
|
19
|
-
label: string;
|
|
20
|
-
}
|
|
21
|
-
/** The empty choice first, then every catalog domain in the host's order. */
|
|
22
|
-
export declare function domainOptions(catalog: DomainCatalog | null, emptyLabel: string): DomainOption[];
|
|
23
|
-
/**
|
|
24
|
-
* `'select'` when the allowlist is active (non-empty) — the control must not offer free input, or
|
|
25
|
-
* two spellings of one domain can still be created. `'input'` when it is empty (no restriction),
|
|
26
|
-
* and also while the catalog is not loaded yet: the form stays usable and the store is the final
|
|
27
|
-
* guard either way.
|
|
28
|
-
*/
|
|
29
|
-
export declare function domainPickerMode(catalog: DomainCatalog | null): 'select' | 'input';
|
|
30
|
-
/**
|
|
31
|
-
* What the 「+」 draft means, so the form and the store agree on the rules BEFORE a round-trip.
|
|
32
|
-
*
|
|
33
|
-
* `existing` is not an error: a name the picker already offers is a SELECTION (the user typed the
|
|
34
|
-
* option instead of choosing it), and writing it a second time would only produce a duplicate list
|
|
35
|
-
* entry. `invalid` is the case that must never reach the store: a `/` or `\` would become one level
|
|
36
|
-
* of the managed path (`docs/<domain>/<source>/<title>.md`), and `sanitizeSegment` rewrites it — so
|
|
37
|
-
* the picker would show a name that is not the directory name.
|
|
38
|
-
*/
|
|
39
|
-
export type NewDomainCheck = {
|
|
40
|
-
kind: 'empty';
|
|
41
|
-
} | {
|
|
42
|
-
kind: 'invalid';
|
|
43
|
-
reason: string;
|
|
44
|
-
} | {
|
|
45
|
-
kind: 'existing';
|
|
46
|
-
name: string;
|
|
47
|
-
} | {
|
|
48
|
-
kind: 'new';
|
|
49
|
-
name: string;
|
|
50
|
-
};
|
|
51
|
-
/** Classify one 「+」 draft against the domains the picker currently offers. */
|
|
52
|
-
export declare function checkNewDomain(raw: string, existing: readonly string[]): NewDomainCheck;
|
|
53
|
-
//# sourceMappingURL=domains.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"domains.d.ts","sourceRoot":"","sources":["../../../src/client/domains.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEzD,sFAAsF;AACtF,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAED,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,EAAE,UAAU,EAAE,MAAM,GAAG,YAAY,EAAE,CAG/F;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,GAAG,QAAQ,GAAG,OAAO,CAElF;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAEjC,8EAA8E;AAC9E,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,cAAc,CAOvF"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The 知识 tab's 入库 result: did it land, or is the host asking whether to REPLACE?
|
|
3
|
-
*
|
|
4
|
-
* Kept as pure functions (no React, no Remote) so the decision is unit-testable, matching
|
|
5
|
-
* `domains.ts`'s `checkNewDomain`. The host answers an unconfirmed collision with a
|
|
6
|
-
* `KbConflictReport` and writes NOTHING, so the client's job is exactly two steps: recognise the
|
|
7
|
-
* report, and phrase the question. The wiring that asks the user and re-sends with
|
|
8
|
-
* `overwrite: true` lives in `index.ts` (pinned by a source guard in `test/ingest.spec.ts`).
|
|
9
|
-
*
|
|
10
|
-
* The confirm text is capped at 8 documents: a directory import that collides with the whole
|
|
11
|
-
* library must produce a readable question, not a wall. The counts say what the rest are.
|
|
12
|
-
*/
|
|
13
|
-
import type { KbConflictReport } from '../../engine/mem-contract/index.js';
|
|
14
|
-
/**
|
|
15
|
-
* The host's collision report, or `null` for any other payload.
|
|
16
|
-
*
|
|
17
|
-
* Validated structurally rather than by a bare cast: the value crossed the Remote wire, and a
|
|
18
|
-
* truncated/garbled payload must fall through to the ordinary "完成" path instead of being shown
|
|
19
|
-
* as a confirmation for a conflict that was never reported.
|
|
20
|
-
*/
|
|
21
|
-
export declare function ingestConflict(value: unknown): KbConflictReport | null;
|
|
22
|
-
/** The question the 「入库」 form asks before re-running the SAME request with `overwrite`. */
|
|
23
|
-
export declare function conflictMessage(report: KbConflictReport): string;
|
|
24
|
-
//# sourceMappingURL=ingest.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ingest.d.ts","sourceRoot":"","sources":["../../../src/client/ingest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAK5D;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,CAMtE;AAED,2FAA2F;AAC3F,wBAAgB,eAAe,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAQhE"}
|
package/lib/types/open.d.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import type { OpenOutcome, OpenTarget } from '../engine/mem-contract/index.js';
|
|
2
|
-
/**
|
|
3
|
-
* The file names one command can have on PATH.
|
|
4
|
-
*
|
|
5
|
-
* On Windows a shim is `code.cmd` (or `.exe`/`.bat`), never the bare `code`, so probing only the
|
|
6
|
-
* bare name silently loses the editor and falls back to the OS default application. `PATHEXT` is
|
|
7
|
-
* what the shell itself uses; the default list is the fallback when it is not exported.
|
|
8
|
-
*/
|
|
9
|
-
export declare function commandFileNames(command: string, platform?: NodeJS.Platform, pathext?: string | undefined): string[];
|
|
10
|
-
/**
|
|
11
|
-
* The file name of `command` that actually exists on `env.PATH`, or `undefined`.
|
|
12
|
-
*
|
|
13
|
-
* Returning the NAME (not a boolean) is what lets the launcher see `code.cmd` and know it holds a
|
|
14
|
-
* batch shim. `[win]` — the win32 form is asserted from Linux with an injected platform/env.
|
|
15
|
-
*/
|
|
16
|
-
export declare function resolveOnPath(command: string, platform?: NodeJS.Platform, env?: NodeJS.ProcessEnv): string | undefined;
|
|
17
|
-
/** True for a Windows batch shim — the one shape Node will not spawn without a shell. */
|
|
18
|
-
export declare function isWindowsBatchShim(command: string, platform?: NodeJS.Platform): boolean;
|
|
19
|
-
/** Why a launch failed: the editor is not here (fall through) or the launch was refused (report). */
|
|
20
|
-
type LaunchFailure = 'missing' | 'refused';
|
|
21
|
-
/**
|
|
22
|
-
* Classify a synchronous spawn failure.
|
|
23
|
-
*
|
|
24
|
-
* `ENOENT` means the command is not there after all — the documented priority order just moves on,
|
|
25
|
-
* with no warning. Everything else (the `EINVAL` a `.cmd` gets without a shell, `EACCES`, a bad
|
|
26
|
-
* argument) is a wiring defect, and swallowing it is exactly how "open in VS Code" disappeared.
|
|
27
|
-
*/
|
|
28
|
-
export declare function classifyLaunchFailure(error: unknown): LaunchFailure;
|
|
29
|
-
/** The options the launch hands to `spawn`. */
|
|
30
|
-
export interface LaunchOptions {
|
|
31
|
-
detached: boolean;
|
|
32
|
-
stdio: 'ignore';
|
|
33
|
-
/** Required on Windows for a `.cmd`/`.bat` shim (CVE-2024-27980 forbids a shell-less spawn). */
|
|
34
|
-
shell?: boolean;
|
|
35
|
-
}
|
|
36
|
-
/** What to hand to `spawn` for one candidate. */
|
|
37
|
-
interface LaunchPlan {
|
|
38
|
-
command: string;
|
|
39
|
-
args: string[];
|
|
40
|
-
options: LaunchOptions;
|
|
41
|
-
}
|
|
42
|
-
/** The slice of `child_process.spawn` this module uses — narrow so a test can inject a fake. */
|
|
43
|
-
export type SpawnLike = (command: string, args: string[], options: LaunchOptions) => {
|
|
44
|
-
unref: () => void;
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* The concrete spawn shape for one candidate on `platform`.
|
|
48
|
-
*
|
|
49
|
-
* TWO Windows-only rules, both from the same root cause (CVE-2024-27980): a `.cmd`/`.bat` shim is
|
|
50
|
-
* spawned through `shell: true`; and the last-resort fallback is `cmd /c start`, whose quoted path
|
|
51
|
-
* must follow its own title argument or cmd treats the path AS the title. The plan is pure and
|
|
52
|
-
* takes the platform, so the win32 shapes are asserted on Linux (`[win]`, real-machine re-check
|
|
53
|
-
* still owed).
|
|
54
|
-
*/
|
|
55
|
-
export declare function launchPlan(command: string, arg: string, platform?: NodeJS.Platform): LaunchPlan;
|
|
56
|
-
/** Where a refused launch is reported; injectable so both failure paths are assertable. */
|
|
57
|
-
type WarnSink = (message: string) => void;
|
|
58
|
-
/** Host facts and side effects a caller (or a test) may replace. */
|
|
59
|
-
interface OpenDeps {
|
|
60
|
-
platform?: NodeJS.Platform;
|
|
61
|
-
env?: NodeJS.ProcessEnv;
|
|
62
|
-
spawn?: SpawnLike;
|
|
63
|
-
/** Defaults to `console.warn` (stderr): a refused launch must leave a trace. */
|
|
64
|
-
warn?: WarnSink;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Launch the configured/detected tool on one document path.
|
|
68
|
-
*
|
|
69
|
-
* @param documentPath - the managed `.md` path.
|
|
70
|
-
* @param target - `file` opens the document, `dir` opens the directory that holds it.
|
|
71
|
-
* @param configured - `knowledge.open.editor` from config (empty ⇒ auto-detect).
|
|
72
|
-
* @param deps - platform / env / spawn / warning sink, for tests.
|
|
73
|
-
* @throws when no candidate is available or every one of them fails to start.
|
|
74
|
-
*/
|
|
75
|
-
export declare function openDocumentPath(documentPath: string, target: OpenTarget, configured: string, deps?: OpenDeps): OpenOutcome;
|
|
76
|
-
export {};
|
|
77
|
-
//# sourceMappingURL=open.d.ts.map
|
package/lib/types/open.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../../src/open.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEnE;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE,MAAM,CAAC,QAA2B,EAC5C,OAAO,GAAE,MAAM,GAAG,SAAkC,GACnD,MAAM,EAAE,CAIV;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,OAAO,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E,SAAS,CAAA;IACjB,gFAAgF;IAChF,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,UAAU,EAClB,UAAU,EAAE,MAAM,EAClB,IAAI,GAAE,QAAa,GAClB,WAAW,CAiDb"}
|
package/lib/types/reconcile.d.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Corpus reconciliation: the throttled "did anything under `knowledge.docs.dir` change?" sweep behind
|
|
3
|
-
* `tools/result`.
|
|
4
|
-
*
|
|
5
|
-
* WHY IT IS ITS OWN MODULE. The plugin reaches the corpus through tool calls, so a finished tool call
|
|
6
|
-
* is the moment to ask the question — and the answer is cheap (`corpusDrift()` is one `stat` per
|
|
7
|
-
* document, reading nothing), which is what makes it affordable after EVERY tool result. Two things
|
|
8
|
-
* about it are easy to get wrong and are pinned by `test/reconcile.spec.ts` instead of by a mounted
|
|
9
|
-
* plugin: the THROTTLE (with a trailing run — skipping alone would drop the LAST edit, the one that
|
|
10
|
-
* matters) and the STOP rule (an in-flight pass must not keep writing after the plugin unmounted and
|
|
11
|
-
* its databases closed). `index.ts` is the assembly hub; this is the rule.
|
|
12
|
-
*
|
|
13
|
-
* @module @avantf/dsh-mem/reconcile
|
|
14
|
-
*/
|
|
15
|
-
/** The corpus surface a reconciler drives — structural, so a test can hand it a fake. */
|
|
16
|
-
interface ReconcileCorpus {
|
|
17
|
-
/** Re-ingest changed documents; `{}` is the full sweep that also reports corpus-level changes. */
|
|
18
|
-
sync(options: {
|
|
19
|
-
docId?: number;
|
|
20
|
-
}): Promise<unknown>;
|
|
21
|
-
/**
|
|
22
|
-
* One `stat` per document; no file is read. ASYNC because it is a per-document walk that yields
|
|
23
|
-
* the event loop every batch (see `KnowledgeStore.corpusDrift`), so it is another `await`
|
|
24
|
-
* boundary at which `stop()` is honoured.
|
|
25
|
-
*/
|
|
26
|
-
corpusDrift(): Promise<{
|
|
27
|
-
changed: number[];
|
|
28
|
-
missing: number[];
|
|
29
|
-
fileSetChanged: boolean;
|
|
30
|
-
}>;
|
|
31
|
-
}
|
|
32
|
-
/** What {@link createCorpusReconciler} needs from its caller. */
|
|
33
|
-
export interface ReconcileDeps {
|
|
34
|
-
corpus: ReconcileCorpus;
|
|
35
|
-
/** Minimum spacing between non-full checks (ms). */
|
|
36
|
-
minIntervalMs: number;
|
|
37
|
-
/** Called for a failed pass. The reconciler NEVER rethrows: a sync failure must not break the host. */
|
|
38
|
-
onError(error: unknown): void;
|
|
39
|
-
/** Clock seam (defaults to `Date.now`). */
|
|
40
|
-
now?(): number;
|
|
41
|
-
/** Timer seam (defaults to the global `setTimeout`); the handle is `unref`ed when it supports it. */
|
|
42
|
-
schedule?(fn: () => void, ms: number): ReturnType<typeof setTimeout>;
|
|
43
|
-
/** Timer-cancellation seam (defaults to the global `clearTimeout`). */
|
|
44
|
-
cancel?(handle: ReturnType<typeof setTimeout>): void;
|
|
45
|
-
}
|
|
46
|
-
/** The handle `index.ts` wires into an effect: request a check, and stop it on unmount. */
|
|
47
|
-
interface CorpusReconciler {
|
|
48
|
-
/** Run one check — `full` bypasses the throttle and takes the baseline after the sweep. */
|
|
49
|
-
request(full: boolean): Promise<void>;
|
|
50
|
-
/**
|
|
51
|
-
* Stop permanently: no further pass starts, a scheduled trailing check is cancelled, and a pass
|
|
52
|
-
* already in flight exits at its next `await` boundary without touching the corpus again.
|
|
53
|
-
*/
|
|
54
|
-
stop(): void;
|
|
55
|
-
/** Whether a pass is currently in flight (diagnostics and the unmount test). */
|
|
56
|
-
readonly running: boolean;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Build the reconciler. All state is closed over here, so a fresh mount gets a fresh one — the
|
|
60
|
-
* plugin can be unmounted and mounted again in one process.
|
|
61
|
-
*/
|
|
62
|
-
export declare function createCorpusReconciler(deps: ReconcileDeps): CorpusReconciler;
|
|
63
|
-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