@oscharko-dev/keiko-local-knowledge 0.2.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/.tsbuildinfo +1 -0
- package/dist/bounded-document-extraction.d.ts +27 -0
- package/dist/bounded-document-extraction.d.ts.map +1 -0
- package/dist/bounded-document-extraction.js +214 -0
- package/dist/capsule-lifecycle.d.ts +33 -0
- package/dist/capsule-lifecycle.d.ts.map +1 -0
- package/dist/capsule-lifecycle.js +292 -0
- package/dist/capsule-set-lifecycle.d.ts +15 -0
- package/dist/capsule-set-lifecycle.d.ts.map +1 -0
- package/dist/capsule-set-lifecycle.js +158 -0
- package/dist/chunking/chunker-persist.d.ts +36 -0
- package/dist/chunking/chunker-persist.d.ts.map +1 -0
- package/dist/chunking/chunker-persist.js +74 -0
- package/dist/chunking/chunker-runner.d.ts +9 -0
- package/dist/chunking/chunker-runner.d.ts.map +1 -0
- package/dist/chunking/chunker-runner.js +218 -0
- package/dist/chunking/chunker.d.ts +7 -0
- package/dist/chunking/chunker.d.ts.map +1 -0
- package/dist/chunking/chunker.js +139 -0
- package/dist/chunking/citation-mapper.d.ts +4 -0
- package/dist/chunking/citation-mapper.d.ts.map +1 -0
- package/dist/chunking/citation-mapper.js +180 -0
- package/dist/chunking/index.d.ts +6 -0
- package/dist/chunking/index.d.ts.map +1 -0
- package/dist/chunking/index.js +8 -0
- package/dist/chunking/token-estimator.d.ts +3 -0
- package/dist/chunking/token-estimator.d.ts.map +1 -0
- package/dist/chunking/token-estimator.js +26 -0
- package/dist/chunking/types.d.ts +49 -0
- package/dist/chunking/types.d.ts.map +1 -0
- package/dist/chunking/types.js +26 -0
- package/dist/composition.d.ts +57 -0
- package/dist/composition.d.ts.map +1 -0
- package/dist/composition.js +310 -0
- package/dist/conversation/citation-attacher.d.ts +8 -0
- package/dist/conversation/citation-attacher.d.ts.map +1 -0
- package/dist/conversation/citation-attacher.js +55 -0
- package/dist/conversation/citation-excerpts.d.ts +4 -0
- package/dist/conversation/citation-excerpts.d.ts.map +1 -0
- package/dist/conversation/citation-excerpts.js +41 -0
- package/dist/conversation/grounded-answer-runner.d.ts +9 -0
- package/dist/conversation/grounded-answer-runner.d.ts.map +1 -0
- package/dist/conversation/grounded-answer-runner.js +61 -0
- package/dist/conversation/index.d.ts +5 -0
- package/dist/conversation/index.d.ts.map +1 -0
- package/dist/conversation/index.js +7 -0
- package/dist/conversation/model-gateway-answer-generator.d.ts +28 -0
- package/dist/conversation/model-gateway-answer-generator.d.ts.map +1 -0
- package/dist/conversation/model-gateway-answer-generator.js +105 -0
- package/dist/conversation/types.d.ts +35 -0
- package/dist/conversation/types.d.ts.map +1 -0
- package/dist/conversation/types.js +24 -0
- package/dist/discovery/discovery-runner.d.ts +23 -0
- package/dist/discovery/discovery-runner.d.ts.map +1 -0
- package/dist/discovery/discovery-runner.js +109 -0
- package/dist/discovery/extract-progressive.d.ts +17 -0
- package/dist/discovery/extract-progressive.d.ts.map +1 -0
- package/dist/discovery/extract-progressive.js +522 -0
- package/dist/discovery/extract.d.ts +26 -0
- package/dist/discovery/extract.d.ts.map +1 -0
- package/dist/discovery/extract.js +906 -0
- package/dist/discovery/glob.d.ts +10 -0
- package/dist/discovery/glob.d.ts.map +1 -0
- package/dist/discovery/glob.js +72 -0
- package/dist/discovery/index.d.ts +6 -0
- package/dist/discovery/index.d.ts.map +1 -0
- package/dist/discovery/index.js +8 -0
- package/dist/discovery/media-type.d.ts +4 -0
- package/dist/discovery/media-type.d.ts.map +1 -0
- package/dist/discovery/media-type.js +62 -0
- package/dist/discovery/persist.d.ts +63 -0
- package/dist/discovery/persist.d.ts.map +1 -0
- package/dist/discovery/persist.js +345 -0
- package/dist/discovery/test-support.d.ts +16 -0
- package/dist/discovery/test-support.d.ts.map +1 -0
- package/dist/discovery/test-support.js +127 -0
- package/dist/discovery/types.d.ts +63 -0
- package/dist/discovery/types.d.ts.map +1 -0
- package/dist/discovery/types.js +28 -0
- package/dist/discovery/walk.d.ts +12 -0
- package/dist/discovery/walk.d.ts.map +1 -0
- package/dist/discovery/walk.js +302 -0
- package/dist/errors.d.ts +13 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +22 -0
- package/dist/evaluations/dimensions.d.ts +14 -0
- package/dist/evaluations/dimensions.d.ts.map +1 -0
- package/dist/evaluations/dimensions.js +191 -0
- package/dist/evaluations/fixtures.d.ts +18 -0
- package/dist/evaluations/fixtures.d.ts.map +1 -0
- package/dist/evaluations/fixtures.js +858 -0
- package/dist/evaluations/index.d.ts +7 -0
- package/dist/evaluations/index.d.ts.map +1 -0
- package/dist/evaluations/index.js +10 -0
- package/dist/evaluations/report.d.ts +3 -0
- package/dist/evaluations/report.d.ts.map +1 -0
- package/dist/evaluations/report.js +31 -0
- package/dist/evaluations/runner-seed.d.ts +12 -0
- package/dist/evaluations/runner-seed.d.ts.map +1 -0
- package/dist/evaluations/runner-seed.js +175 -0
- package/dist/evaluations/runner.d.ts +8 -0
- package/dist/evaluations/runner.d.ts.map +1 -0
- package/dist/evaluations/runner.js +205 -0
- package/dist/evaluations/scripted-embedding-adapter.d.ts +13 -0
- package/dist/evaluations/scripted-embedding-adapter.d.ts.map +1 -0
- package/dist/evaluations/scripted-embedding-adapter.js +163 -0
- package/dist/evaluations/types.d.ts +116 -0
- package/dist/evaluations/types.d.ts.map +1 -0
- package/dist/evaluations/types.js +27 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/indexing/bounded-indexing.d.ts +41 -0
- package/dist/indexing/bounded-indexing.d.ts.map +1 -0
- package/dist/indexing/bounded-indexing.js +240 -0
- package/dist/indexing/checkpoint-persist.d.ts +8 -0
- package/dist/indexing/checkpoint-persist.d.ts.map +1 -0
- package/dist/indexing/checkpoint-persist.js +135 -0
- package/dist/indexing/checkpoint-resume.d.ts +20 -0
- package/dist/indexing/checkpoint-resume.d.ts.map +1 -0
- package/dist/indexing/checkpoint-resume.js +50 -0
- package/dist/indexing/embedding-batcher.d.ts +3 -0
- package/dist/indexing/embedding-batcher.d.ts.map +1 -0
- package/dist/indexing/embedding-batcher.js +390 -0
- package/dist/indexing/index.d.ts +7 -0
- package/dist/indexing/index.d.ts.map +1 -0
- package/dist/indexing/index.js +11 -0
- package/dist/indexing/job-persist.d.ts +46 -0
- package/dist/indexing/job-persist.d.ts.map +1 -0
- package/dist/indexing/job-persist.js +157 -0
- package/dist/indexing/job-resume.d.ts +4 -0
- package/dist/indexing/job-resume.d.ts.map +1 -0
- package/dist/indexing/job-resume.js +14 -0
- package/dist/indexing/orchestrator.d.ts +3 -0
- package/dist/indexing/orchestrator.d.ts.map +1 -0
- package/dist/indexing/orchestrator.js +1151 -0
- package/dist/indexing/types.d.ts +156 -0
- package/dist/indexing/types.d.ts.map +1 -0
- package/dist/indexing/types.js +30 -0
- package/dist/indexing/vector-persist.d.ts +32 -0
- package/dist/indexing/vector-persist.d.ts.map +1 -0
- package/dist/indexing/vector-persist.js +105 -0
- package/dist/parsers/_internal.d.ts +20 -0
- package/dist/parsers/_internal.d.ts.map +1 -0
- package/dist/parsers/_internal.js +122 -0
- package/dist/parsers/csv-parser.d.ts +3 -0
- package/dist/parsers/csv-parser.d.ts.map +1 -0
- package/dist/parsers/csv-parser.js +202 -0
- package/dist/parsers/docx-parser.d.ts +3 -0
- package/dist/parsers/docx-parser.d.ts.map +1 -0
- package/dist/parsers/docx-parser.js +390 -0
- package/dist/parsers/html-parser.d.ts +3 -0
- package/dist/parsers/html-parser.d.ts.map +1 -0
- package/dist/parsers/html-parser.js +310 -0
- package/dist/parsers/index.d.ts +15 -0
- package/dist/parsers/index.d.ts.map +1 -0
- package/dist/parsers/index.js +41 -0
- package/dist/parsers/json-parser.d.ts +3 -0
- package/dist/parsers/json-parser.d.ts.map +1 -0
- package/dist/parsers/json-parser.js +192 -0
- package/dist/parsers/large-document/capability-discovery.d.ts +27 -0
- package/dist/parsers/large-document/capability-discovery.d.ts.map +1 -0
- package/dist/parsers/large-document/capability-discovery.js +76 -0
- package/dist/parsers/large-document/diagnostics.d.ts +3 -0
- package/dist/parsers/large-document/diagnostics.d.ts.map +1 -0
- package/dist/parsers/large-document/diagnostics.js +11 -0
- package/dist/parsers/large-document/index.d.ts +15 -0
- package/dist/parsers/large-document/index.d.ts.map +1 -0
- package/dist/parsers/large-document/index.js +10 -0
- package/dist/parsers/large-document/legacy-format.d.ts +5 -0
- package/dist/parsers/large-document/legacy-format.d.ts.map +1 -0
- package/dist/parsers/large-document/legacy-format.js +25 -0
- package/dist/parsers/large-document/preflight.d.ts +9 -0
- package/dist/parsers/large-document/preflight.d.ts.map +1 -0
- package/dist/parsers/large-document/preflight.js +43 -0
- package/dist/parsers/large-document/progressive-extraction.d.ts +55 -0
- package/dist/parsers/large-document/progressive-extraction.d.ts.map +1 -0
- package/dist/parsers/large-document/progressive-extraction.js +123 -0
- package/dist/parsers/large-document/progressive-pdf.d.ts +20 -0
- package/dist/parsers/large-document/progressive-pdf.d.ts.map +1 -0
- package/dist/parsers/large-document/progressive-pdf.js +145 -0
- package/dist/parsers/large-document/synthetic-source.d.ts +9 -0
- package/dist/parsers/large-document/synthetic-source.d.ts.map +1 -0
- package/dist/parsers/large-document/synthetic-source.js +101 -0
- package/dist/parsers/large-document/window-builder.d.ts +24 -0
- package/dist/parsers/large-document/window-builder.d.ts.map +1 -0
- package/dist/parsers/large-document/window-builder.js +75 -0
- package/dist/parsers/ocr/index.d.ts +4 -0
- package/dist/parsers/ocr/index.d.ts.map +1 -0
- package/dist/parsers/ocr/index.js +4 -0
- package/dist/parsers/ocr/null-ocr-adapter.d.ts +3 -0
- package/dist/parsers/ocr/null-ocr-adapter.d.ts.map +1 -0
- package/dist/parsers/ocr/null-ocr-adapter.js +14 -0
- package/dist/parsers/ocr/ocr-pipeline-parser.d.ts +8 -0
- package/dist/parsers/ocr/ocr-pipeline-parser.d.ts.map +1 -0
- package/dist/parsers/ocr/ocr-pipeline-parser.js +147 -0
- package/dist/parsers/ocr/types.d.ts +16 -0
- package/dist/parsers/ocr/types.d.ts.map +1 -0
- package/dist/parsers/ocr/types.js +4 -0
- package/dist/parsers/parser-test-fixtures.d.ts +28 -0
- package/dist/parsers/parser-test-fixtures.d.ts.map +1 -0
- package/dist/parsers/parser-test-fixtures.js +139 -0
- package/dist/parsers/pdf-parser.d.ts +43 -0
- package/dist/parsers/pdf-parser.d.ts.map +1 -0
- package/dist/parsers/pdf-parser.js +388 -0
- package/dist/parsers/registry.d.ts +8 -0
- package/dist/parsers/registry.d.ts.map +1 -0
- package/dist/parsers/registry.js +57 -0
- package/dist/parsers/text-parser.d.ts +3 -0
- package/dist/parsers/text-parser.d.ts.map +1 -0
- package/dist/parsers/text-parser.js +214 -0
- package/dist/parsers/types.d.ts +53 -0
- package/dist/parsers/types.d.ts.map +1 -0
- package/dist/parsers/types.js +21 -0
- package/dist/parsers/unsupported-parser.d.ts +4 -0
- package/dist/parsers/unsupported-parser.d.ts.map +1 -0
- package/dist/parsers/unsupported-parser.js +97 -0
- package/dist/parsers/xlsx-parser.d.ts +3 -0
- package/dist/parsers/xlsx-parser.d.ts.map +1 -0
- package/dist/parsers/xlsx-parser.js +425 -0
- package/dist/privacy/audit-emitter.d.ts +5 -0
- package/dist/privacy/audit-emitter.d.ts.map +1 -0
- package/dist/privacy/audit-emitter.js +93 -0
- package/dist/privacy/diagnostic-redactor.d.ts +2 -0
- package/dist/privacy/diagnostic-redactor.d.ts.map +1 -0
- package/dist/privacy/diagnostic-redactor.js +153 -0
- package/dist/privacy/index.d.ts +5 -0
- package/dist/privacy/index.d.ts.map +1 -0
- package/dist/privacy/index.js +6 -0
- package/dist/privacy/retention-applier.d.ts +5 -0
- package/dist/privacy/retention-applier.d.ts.map +1 -0
- package/dist/privacy/retention-applier.js +88 -0
- package/dist/privacy/types.d.ts +98 -0
- package/dist/privacy/types.d.ts.map +1 -0
- package/dist/privacy/types.js +12 -0
- package/dist/qualityIntelligence/capsuleCorpus.d.ts +27 -0
- package/dist/qualityIntelligence/capsuleCorpus.d.ts.map +1 -0
- package/dist/qualityIntelligence/capsuleCorpus.js +58 -0
- package/dist/qualityIntelligence/index.d.ts +3 -0
- package/dist/qualityIntelligence/index.d.ts.map +1 -0
- package/dist/qualityIntelligence/index.js +5 -0
- package/dist/qualityIntelligence/qiHandoff.d.ts +36 -0
- package/dist/qualityIntelligence/qiHandoff.d.ts.map +1 -0
- package/dist/qualityIntelligence/qiHandoff.js +82 -0
- package/dist/retrieval/answer-grounding.d.ts +9 -0
- package/dist/retrieval/answer-grounding.d.ts.map +1 -0
- package/dist/retrieval/answer-grounding.js +31 -0
- package/dist/retrieval/context-pack-assembler.d.ts +24 -0
- package/dist/retrieval/context-pack-assembler.d.ts.map +1 -0
- package/dist/retrieval/context-pack-assembler.js +50 -0
- package/dist/retrieval/index.d.ts +6 -0
- package/dist/retrieval/index.d.ts.map +1 -0
- package/dist/retrieval/index.js +9 -0
- package/dist/retrieval/retrieval-runner.d.ts +10 -0
- package/dist/retrieval/retrieval-runner.d.ts.map +1 -0
- package/dist/retrieval/retrieval-runner.js +163 -0
- package/dist/retrieval/scoped-vector-search.d.ts +24 -0
- package/dist/retrieval/scoped-vector-search.d.ts.map +1 -0
- package/dist/retrieval/scoped-vector-search.js +864 -0
- package/dist/retrieval/types.d.ts +28 -0
- package/dist/retrieval/types.d.ts.map +1 -0
- package/dist/retrieval/types.js +33 -0
- package/dist/section-path-hash.d.ts +3 -0
- package/dist/section-path-hash.d.ts.map +1 -0
- package/dist/section-path-hash.js +9 -0
- package/dist/source-lifecycle.d.ts +14 -0
- package/dist/source-lifecycle.d.ts.map +1 -0
- package/dist/source-lifecycle.js +155 -0
- package/dist/source-routing-validation.d.ts +11 -0
- package/dist/source-routing-validation.d.ts.map +1 -0
- package/dist/source-routing-validation.js +140 -0
- package/dist/store-content-cipher.d.ts +11 -0
- package/dist/store-content-cipher.d.ts.map +1 -0
- package/dist/store-content-cipher.js +67 -0
- package/dist/store-content-encryption.d.ts +12 -0
- package/dist/store-content-encryption.d.ts.map +1 -0
- package/dist/store-content-encryption.js +275 -0
- package/dist/store-paths.d.ts +6 -0
- package/dist/store-paths.d.ts.map +1 -0
- package/dist/store-paths.js +61 -0
- package/dist/store.d.ts +30 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +219 -0
- package/dist/testing.d.ts +47 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +170 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +4 -0
- package/package.json +43 -0
package/dist/testing.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { chunkDocument } from "./chunking/chunker-runner.js";
|
|
2
|
+
import { createCapsule } from "./capsule-lifecycle.js";
|
|
3
|
+
import { insertDocumentRow, insertParsedUnitRow } from "./discovery/persist.js";
|
|
4
|
+
import { embedChunkBatch } from "./indexing/embedding-batcher.js";
|
|
5
|
+
import { addSourceToCapsule } from "./source-lifecycle.js";
|
|
6
|
+
const DEFAULT_EMBEDDING = {
|
|
7
|
+
provider: "openai",
|
|
8
|
+
modelId: "text-embedding-3-small",
|
|
9
|
+
vectorDimensions: 1536,
|
|
10
|
+
vectorMetric: "cosine",
|
|
11
|
+
};
|
|
12
|
+
export function deterministicVector(input, dimensions) {
|
|
13
|
+
const vec = new Float32Array(dimensions);
|
|
14
|
+
let hash = 0;
|
|
15
|
+
for (let i = 0; i < input.length; i += 1) {
|
|
16
|
+
hash = (hash * 31 + input.charCodeAt(i)) | 0;
|
|
17
|
+
}
|
|
18
|
+
vec[0] = input.length;
|
|
19
|
+
for (let i = 1; i < dimensions; i += 1) {
|
|
20
|
+
vec[i] = ((hash + i * 7) & 0xffff) / 0xffff;
|
|
21
|
+
}
|
|
22
|
+
return vec;
|
|
23
|
+
}
|
|
24
|
+
export function scriptedAdapter(options = {}) {
|
|
25
|
+
const identity = options.identity ?? DEFAULT_EMBEDDING;
|
|
26
|
+
const responder = options.responder ??
|
|
27
|
+
((request) => ({
|
|
28
|
+
ok: true,
|
|
29
|
+
value: {
|
|
30
|
+
vector: deterministicVector(request.input, identity.vectorDimensions),
|
|
31
|
+
modelId: identity.modelId,
|
|
32
|
+
...(identity.modelRevision !== undefined ? { modelRevision: identity.modelRevision } : {}),
|
|
33
|
+
},
|
|
34
|
+
}));
|
|
35
|
+
return {
|
|
36
|
+
endpoint: options.endpoint ?? "https://example.test/v1",
|
|
37
|
+
apiKey: options.apiKey ?? ["sk-", "test"].join(""),
|
|
38
|
+
request: async (request) => Promise.resolve(responder(request)),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function sampleCapsuleInput(overrides) {
|
|
42
|
+
return {
|
|
43
|
+
id: overrides.id,
|
|
44
|
+
displayName: overrides.displayName ?? "Engineering Capsule",
|
|
45
|
+
tags: ["alpha", "beta"],
|
|
46
|
+
retrievalEffort: "default",
|
|
47
|
+
outputMode: "answers",
|
|
48
|
+
answerGroundingPolicy: "require-citations",
|
|
49
|
+
embeddingModelIdentity: overrides.embeddingModelIdentity,
|
|
50
|
+
lifecycleState: "draft",
|
|
51
|
+
storageReference: "engineering/capsule-1",
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function sampleSourceInput(id) {
|
|
55
|
+
return {
|
|
56
|
+
id,
|
|
57
|
+
displayName: `Source ${String(id)}`,
|
|
58
|
+
tags: [],
|
|
59
|
+
scope: {
|
|
60
|
+
kind: "folder",
|
|
61
|
+
rootPath: "/srv/docs",
|
|
62
|
+
recursive: true,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function composeUnit(unit, documentId, textLength) {
|
|
67
|
+
if (unit !== undefined) {
|
|
68
|
+
return { ...unit, documentId };
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
kind: "page",
|
|
72
|
+
documentId,
|
|
73
|
+
pageNumber: 7,
|
|
74
|
+
pageLabel: "vii",
|
|
75
|
+
characterStart: 0,
|
|
76
|
+
characterEnd: textLength,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function normalizeSeedText(unit, text) {
|
|
80
|
+
const baseText = text ?? "alpha beta gamma delta epsilon zeta eta theta iota kappa lambda mu nu xi";
|
|
81
|
+
const requiredEnd = unit !== undefined && unit.kind !== "unsupported-media" ? unit.characterEnd : 0;
|
|
82
|
+
return baseText.length >= requiredEnd ? baseText : baseText.padEnd(requiredEnd, " x");
|
|
83
|
+
}
|
|
84
|
+
function resolveSeedOptions(options) {
|
|
85
|
+
const capsuleId = (options.capsuleId ?? "cap-1");
|
|
86
|
+
const sourceId = (options.sourceId ?? "src-1");
|
|
87
|
+
const documentId = (options.documentId ?? "doc-1");
|
|
88
|
+
const identity = options.identity ?? DEFAULT_EMBEDDING;
|
|
89
|
+
const text = normalizeSeedText(options.unit, options.text);
|
|
90
|
+
return {
|
|
91
|
+
capsuleId,
|
|
92
|
+
displayName: options.displayName ?? "Engineering Capsule",
|
|
93
|
+
sourceId,
|
|
94
|
+
documentId,
|
|
95
|
+
identity,
|
|
96
|
+
text,
|
|
97
|
+
contentHash: options.contentHash ?? "a".repeat(64),
|
|
98
|
+
safeDisplayName: options.safeDisplayName ?? "sample.txt",
|
|
99
|
+
unit: composeUnit(options.unit, documentId, text.length),
|
|
100
|
+
chunkingOptions: options.chunkingOptions ?? { maxTokens: 2, minTokens: 0, overlapTokens: 0 },
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function insertSeedRows(store, options) {
|
|
104
|
+
createCapsule(store, sampleCapsuleInput({
|
|
105
|
+
id: options.capsuleId,
|
|
106
|
+
displayName: options.displayName,
|
|
107
|
+
embeddingModelIdentity: options.identity,
|
|
108
|
+
}));
|
|
109
|
+
addSourceToCapsule(store, options.capsuleId, sampleSourceInput(options.sourceId));
|
|
110
|
+
insertDocumentRow(store._internal.db, {
|
|
111
|
+
id: options.documentId,
|
|
112
|
+
capsuleId: options.capsuleId,
|
|
113
|
+
sourceId: String(options.sourceId),
|
|
114
|
+
documentPath: "docs/sample.txt",
|
|
115
|
+
sizeBytes: 1024,
|
|
116
|
+
mediaType: "text/plain",
|
|
117
|
+
contentHash: options.contentHash,
|
|
118
|
+
parserId: "text",
|
|
119
|
+
parserVersion: "1",
|
|
120
|
+
lastExtractedAt: 1_700_000_000_000,
|
|
121
|
+
status: "extracted",
|
|
122
|
+
safeDisplayName: options.safeDisplayName,
|
|
123
|
+
});
|
|
124
|
+
insertParsedUnitRow(store._internal.db, store._internal.contentCipher, options.capsuleId, `unit-${String(options.capsuleId)}`, options.unit);
|
|
125
|
+
}
|
|
126
|
+
function buildSeedChunks(store, options) {
|
|
127
|
+
const chunkResult = chunkDocument(store, {
|
|
128
|
+
capsuleId: options.capsuleId,
|
|
129
|
+
sourceId: options.sourceId,
|
|
130
|
+
documentId: options.documentId,
|
|
131
|
+
sourceText: options.text,
|
|
132
|
+
}, options.chunkingOptions);
|
|
133
|
+
return {
|
|
134
|
+
chunkIds: chunkResult.chunkIds,
|
|
135
|
+
chunks: chunkResult.chunkIds.map((id, index) => ({
|
|
136
|
+
id,
|
|
137
|
+
capsuleId: options.capsuleId,
|
|
138
|
+
sourceId: options.sourceId,
|
|
139
|
+
documentId: options.documentId,
|
|
140
|
+
text: `chunk-${String(index)}-${String(options.capsuleId)}`,
|
|
141
|
+
})),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
async function embedSeedChunks(store, identity, chunks) {
|
|
145
|
+
let counter = 0;
|
|
146
|
+
await embedChunkBatch(chunks, {
|
|
147
|
+
adapter: scriptedAdapter({ identity }),
|
|
148
|
+
store,
|
|
149
|
+
pinnedIdentity: identity,
|
|
150
|
+
concurrency: 2,
|
|
151
|
+
now: () => 1_700_000_000_000,
|
|
152
|
+
idSource: () => {
|
|
153
|
+
counter += 1;
|
|
154
|
+
return `storage-${String(counter)}`;
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
export async function seedCapsuleWithVectors(store, options = {}) {
|
|
159
|
+
const resolved = resolveSeedOptions(options);
|
|
160
|
+
insertSeedRows(store, resolved);
|
|
161
|
+
const { chunkIds, chunks } = buildSeedChunks(store, resolved);
|
|
162
|
+
await embedSeedChunks(store, resolved.identity, chunks);
|
|
163
|
+
return {
|
|
164
|
+
capsuleId: resolved.capsuleId,
|
|
165
|
+
sourceId: resolved.sourceId,
|
|
166
|
+
documentId: resolved.documentId,
|
|
167
|
+
chunkIds,
|
|
168
|
+
vectorTexts: chunks.map((chunk) => chunk.text),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,6BAA6B,EAAG,OAAgB,CAAC"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Package version literal for @oscharko-dev/keiko-local-knowledge. Bumped lockstep with the
|
|
2
|
+
// package.json "version" field so a value-import gives consumers a single source of truth
|
|
3
|
+
// without parsing JSON at runtime.
|
|
4
|
+
export const KEIKO_LOCAL_KNOWLEDGE_VERSION = "0.1.0";
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@oscharko-dev/keiko-local-knowledge",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"description": "Internal local-knowledge package: on-disk capsule store (node:sqlite + WAL) and capsule/source/CapsuleSet lifecycle CRUD for the Local Knowledge Connector (Epic #189, Issue #193). Not published independently.",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./testing": {
|
|
15
|
+
"types": "./dist/testing.d.ts",
|
|
16
|
+
"import": "./dist/testing.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -b tsconfig.json",
|
|
21
|
+
"typecheck": "tsc -b tsconfig.json",
|
|
22
|
+
"test": "vitest run"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"sideEffects": false,
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=22"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@oscharko-dev/keiko-contracts": "0.2.0",
|
|
33
|
+
"@oscharko-dev/keiko-model-gateway": "0.2.0",
|
|
34
|
+
"@oscharko-dev/keiko-security": "0.2.0",
|
|
35
|
+
"@oscharko-dev/keiko-workspace": "0.2.0",
|
|
36
|
+
"@types/yauzl": "^3.3.0",
|
|
37
|
+
"pdfjs-dist": "^6.0.227",
|
|
38
|
+
"yauzl": "^3.3.2"
|
|
39
|
+
},
|
|
40
|
+
"optionalDependencies": {
|
|
41
|
+
"@napi-rs/canvas": "^1.0.0"
|
|
42
|
+
}
|
|
43
|
+
}
|