@schift-io/knowledge-scope 0.1.0 → 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.
@@ -90,6 +90,15 @@ export declare const AuthorizationSubjectSchema: import("zod").ZodReadonly<impor
90
90
  }, {
91
91
  kind: "schift_search";
92
92
  indexRef: string;
93
+ }>, import("zod").ZodObject<{
94
+ kind: import("zod").ZodLiteral<"local_documents">;
95
+ indexRef: import("zod").ZodString;
96
+ }, "strict", import("zod").ZodTypeAny, {
97
+ kind: "local_documents";
98
+ indexRef: string;
99
+ }, {
100
+ kind: "local_documents";
101
+ indexRef: string;
93
102
  }>, import("zod").ZodObject<{
94
103
  kind: import("zod").ZodLiteral<"web_search">;
95
104
  provider: import("zod").ZodEnum<["customer", "schift"]>;
@@ -148,6 +157,9 @@ export declare const AuthorizationSubjectSchema: import("zod").ZodReadonly<impor
148
157
  }> | Readonly<{
149
158
  kind: "schift_search";
150
159
  indexRef: string;
160
+ }> | Readonly<{
161
+ kind: "local_documents";
162
+ indexRef: string;
151
163
  }> | Readonly<{
152
164
  kind: "web_search";
153
165
  provider: "customer" | "schift";
@@ -194,6 +206,9 @@ export declare const AuthorizationSubjectSchema: import("zod").ZodReadonly<impor
194
206
  }> | Readonly<{
195
207
  kind: "schift_search";
196
208
  indexRef: string;
209
+ }> | Readonly<{
210
+ kind: "local_documents";
211
+ indexRef: string;
197
212
  }> | Readonly<{
198
213
  kind: "web_search";
199
214
  provider: "customer" | "schift";
@@ -1,5 +1,6 @@
1
1
  import { type KnowledgeScopeApplicationPort, type MountApplicationRequest, type ServedKnowledgeScopeApi } from "./api.js";
2
2
  import { type JsonValue } from "./json.js";
3
+ import { type LocalDocumentImportPort } from "./local-quickstart.js";
3
4
  import { type OnboardingEnvironment } from "./onboarding-config.js";
4
5
  export type PortableAuthoringPort = Readonly<{
5
6
  validate: (directory: string) => Promise<JsonValue>;
@@ -8,6 +9,7 @@ export type PortableAuthoringPort = Readonly<{
8
9
  }>;
9
10
  export type CliDependencies = Readonly<{
10
11
  environment?: OnboardingEnvironment;
12
+ localDocuments?: LocalDocumentImportPort;
11
13
  authoring: PortableAuthoringPort;
12
14
  embedded: KnowledgeScopeApplicationPort;
13
15
  remote: (apiUrl: string) => KnowledgeScopeApplicationPort;
@@ -102,6 +102,15 @@ export declare const ProviderResultSchema: z.ZodReadonly<z.ZodObject<{
102
102
  }, {
103
103
  kind: "schift_search";
104
104
  indexRef: string;
105
+ }>, z.ZodObject<{
106
+ kind: z.ZodLiteral<"local_documents">;
107
+ indexRef: z.ZodString;
108
+ }, "strict", z.ZodTypeAny, {
109
+ kind: "local_documents";
110
+ indexRef: string;
111
+ }, {
112
+ kind: "local_documents";
113
+ indexRef: string;
105
114
  }>, z.ZodObject<{
106
115
  kind: z.ZodLiteral<"web_search">;
107
116
  provider: z.ZodEnum<["customer", "schift"]>;
@@ -128,6 +137,9 @@ export declare const ProviderResultSchema: z.ZodReadonly<z.ZodObject<{
128
137
  }> | Readonly<{
129
138
  kind: "schift_search";
130
139
  indexRef: string;
140
+ }> | Readonly<{
141
+ kind: "local_documents";
142
+ indexRef: string;
131
143
  }> | Readonly<{
132
144
  kind: "web_search";
133
145
  provider: "customer" | "schift";
@@ -156,6 +168,9 @@ export declare const ProviderResultSchema: z.ZodReadonly<z.ZodObject<{
156
168
  }> | Readonly<{
157
169
  kind: "schift_search";
158
170
  indexRef: string;
171
+ }> | Readonly<{
172
+ kind: "local_documents";
173
+ indexRef: string;
159
174
  }> | Readonly<{
160
175
  kind: "web_search";
161
176
  provider: "customer" | "schift";
@@ -167,6 +167,15 @@ export declare const KnowledgeScopePackSchema: z.ZodReadonly<z.ZodEffects<z.ZodO
167
167
  }, {
168
168
  kind: "schift_search";
169
169
  indexRef: string;
170
+ }>, z.ZodObject<{
171
+ kind: z.ZodLiteral<"local_documents">;
172
+ indexRef: z.ZodString;
173
+ }, "strict", z.ZodTypeAny, {
174
+ kind: "local_documents";
175
+ indexRef: string;
176
+ }, {
177
+ kind: "local_documents";
178
+ indexRef: string;
170
179
  }>, z.ZodObject<{
171
180
  kind: z.ZodLiteral<"web_search">;
172
181
  provider: z.ZodEnum<["customer", "schift"]>;
@@ -216,6 +225,9 @@ export declare const KnowledgeScopePackSchema: z.ZodReadonly<z.ZodEffects<z.ZodO
216
225
  }> | Readonly<{
217
226
  kind: "schift_search";
218
227
  indexRef: string;
228
+ }> | Readonly<{
229
+ kind: "local_documents";
230
+ indexRef: string;
219
231
  }> | Readonly<{
220
232
  kind: "web_search";
221
233
  provider: "customer" | "schift";
@@ -243,6 +255,9 @@ export declare const KnowledgeScopePackSchema: z.ZodReadonly<z.ZodEffects<z.ZodO
243
255
  }> | Readonly<{
244
256
  kind: "schift_search";
245
257
  indexRef: string;
258
+ }> | Readonly<{
259
+ kind: "local_documents";
260
+ indexRef: string;
246
261
  }> | Readonly<{
247
262
  kind: "web_search";
248
263
  provider: "customer" | "schift";
@@ -697,6 +712,9 @@ export declare const KnowledgeScopePackSchema: z.ZodReadonly<z.ZodEffects<z.ZodO
697
712
  }> | Readonly<{
698
713
  kind: "schift_search";
699
714
  indexRef: string;
715
+ }> | Readonly<{
716
+ kind: "local_documents";
717
+ indexRef: string;
700
718
  }> | Readonly<{
701
719
  kind: "web_search";
702
720
  provider: "customer" | "schift";
@@ -799,6 +817,9 @@ export declare const KnowledgeScopePackSchema: z.ZodReadonly<z.ZodEffects<z.ZodO
799
817
  }> | Readonly<{
800
818
  kind: "schift_search";
801
819
  indexRef: string;
820
+ }> | Readonly<{
821
+ kind: "local_documents";
822
+ indexRef: string;
802
823
  }> | Readonly<{
803
824
  kind: "web_search";
804
825
  provider: "customer" | "schift";
@@ -901,6 +922,9 @@ export declare const KnowledgeScopePackSchema: z.ZodReadonly<z.ZodEffects<z.ZodO
901
922
  }> | Readonly<{
902
923
  kind: "schift_search";
903
924
  indexRef: string;
925
+ }> | Readonly<{
926
+ kind: "local_documents";
927
+ indexRef: string;
904
928
  }> | Readonly<{
905
929
  kind: "web_search";
906
930
  provider: "customer" | "schift";
@@ -1003,6 +1027,9 @@ export declare const KnowledgeScopePackSchema: z.ZodReadonly<z.ZodEffects<z.ZodO
1003
1027
  }> | Readonly<{
1004
1028
  kind: "schift_search";
1005
1029
  indexRef: string;
1030
+ }> | Readonly<{
1031
+ kind: "local_documents";
1032
+ indexRef: string;
1006
1033
  }> | Readonly<{
1007
1034
  kind: "web_search";
1008
1035
  provider: "customer" | "schift";
@@ -31,6 +31,15 @@ export declare const QueryProviderSchema: z.ZodReadonly<z.ZodDiscriminatedUnion<
31
31
  }, {
32
32
  kind: "schift_search";
33
33
  indexRef: string;
34
+ }>, z.ZodObject<{
35
+ kind: z.ZodLiteral<"local_documents">;
36
+ indexRef: z.ZodString;
37
+ }, "strict", z.ZodTypeAny, {
38
+ kind: "local_documents";
39
+ indexRef: string;
40
+ }, {
41
+ kind: "local_documents";
42
+ indexRef: string;
34
43
  }>, z.ZodObject<{
35
44
  kind: z.ZodLiteral<"web_search">;
36
45
  provider: z.ZodEnum<["customer", "schift"]>;
@@ -73,6 +82,15 @@ export declare const QueryCapabilitySchema: z.ZodReadonly<z.ZodObject<{
73
82
  }, {
74
83
  kind: "schift_search";
75
84
  indexRef: string;
85
+ }>, z.ZodObject<{
86
+ kind: z.ZodLiteral<"local_documents">;
87
+ indexRef: z.ZodString;
88
+ }, "strict", z.ZodTypeAny, {
89
+ kind: "local_documents";
90
+ indexRef: string;
91
+ }, {
92
+ kind: "local_documents";
93
+ indexRef: string;
76
94
  }>, z.ZodObject<{
77
95
  kind: z.ZodLiteral<"web_search">;
78
96
  provider: z.ZodEnum<["customer", "schift"]>;
@@ -122,6 +140,9 @@ export declare const QueryCapabilitySchema: z.ZodReadonly<z.ZodObject<{
122
140
  }> | Readonly<{
123
141
  kind: "schift_search";
124
142
  indexRef: string;
143
+ }> | Readonly<{
144
+ kind: "local_documents";
145
+ indexRef: string;
125
146
  }> | Readonly<{
126
147
  kind: "web_search";
127
148
  provider: "customer" | "schift";
@@ -149,6 +170,9 @@ export declare const QueryCapabilitySchema: z.ZodReadonly<z.ZodObject<{
149
170
  }> | Readonly<{
150
171
  kind: "schift_search";
151
172
  indexRef: string;
173
+ }> | Readonly<{
174
+ kind: "local_documents";
175
+ indexRef: string;
152
176
  }> | Readonly<{
153
177
  kind: "web_search";
154
178
  provider: "customer" | "schift";
@@ -211,6 +235,15 @@ export declare const KnowledgeScopeDefinitionBaseSchema: z.ZodObject<{
211
235
  }, {
212
236
  kind: "schift_search";
213
237
  indexRef: string;
238
+ }>, z.ZodObject<{
239
+ kind: z.ZodLiteral<"local_documents">;
240
+ indexRef: z.ZodString;
241
+ }, "strict", z.ZodTypeAny, {
242
+ kind: "local_documents";
243
+ indexRef: string;
244
+ }, {
245
+ kind: "local_documents";
246
+ indexRef: string;
214
247
  }>, z.ZodObject<{
215
248
  kind: z.ZodLiteral<"web_search">;
216
249
  provider: z.ZodEnum<["customer", "schift"]>;
@@ -260,6 +293,9 @@ export declare const KnowledgeScopeDefinitionBaseSchema: z.ZodObject<{
260
293
  }> | Readonly<{
261
294
  kind: "schift_search";
262
295
  indexRef: string;
296
+ }> | Readonly<{
297
+ kind: "local_documents";
298
+ indexRef: string;
263
299
  }> | Readonly<{
264
300
  kind: "web_search";
265
301
  provider: "customer" | "schift";
@@ -287,6 +323,9 @@ export declare const KnowledgeScopeDefinitionBaseSchema: z.ZodObject<{
287
323
  }> | Readonly<{
288
324
  kind: "schift_search";
289
325
  indexRef: string;
326
+ }> | Readonly<{
327
+ kind: "local_documents";
328
+ indexRef: string;
290
329
  }> | Readonly<{
291
330
  kind: "web_search";
292
331
  provider: "customer" | "schift";
@@ -644,6 +683,9 @@ export declare const KnowledgeScopeDefinitionBaseSchema: z.ZodObject<{
644
683
  }> | Readonly<{
645
684
  kind: "schift_search";
646
685
  indexRef: string;
686
+ }> | Readonly<{
687
+ kind: "local_documents";
688
+ indexRef: string;
647
689
  }> | Readonly<{
648
690
  kind: "web_search";
649
691
  provider: "customer" | "schift";
@@ -725,6 +767,9 @@ export declare const KnowledgeScopeDefinitionBaseSchema: z.ZodObject<{
725
767
  }> | Readonly<{
726
768
  kind: "schift_search";
727
769
  indexRef: string;
770
+ }> | Readonly<{
771
+ kind: "local_documents";
772
+ indexRef: string;
728
773
  }> | Readonly<{
729
774
  kind: "web_search";
730
775
  provider: "customer" | "schift";
@@ -833,6 +878,15 @@ export declare const KnowledgeScopeDefinitionSchema: z.ZodReadonly<z.ZodEffects<
833
878
  }, {
834
879
  kind: "schift_search";
835
880
  indexRef: string;
881
+ }>, z.ZodObject<{
882
+ kind: z.ZodLiteral<"local_documents">;
883
+ indexRef: z.ZodString;
884
+ }, "strict", z.ZodTypeAny, {
885
+ kind: "local_documents";
886
+ indexRef: string;
887
+ }, {
888
+ kind: "local_documents";
889
+ indexRef: string;
836
890
  }>, z.ZodObject<{
837
891
  kind: z.ZodLiteral<"web_search">;
838
892
  provider: z.ZodEnum<["customer", "schift"]>;
@@ -882,6 +936,9 @@ export declare const KnowledgeScopeDefinitionSchema: z.ZodReadonly<z.ZodEffects<
882
936
  }> | Readonly<{
883
937
  kind: "schift_search";
884
938
  indexRef: string;
939
+ }> | Readonly<{
940
+ kind: "local_documents";
941
+ indexRef: string;
885
942
  }> | Readonly<{
886
943
  kind: "web_search";
887
944
  provider: "customer" | "schift";
@@ -909,6 +966,9 @@ export declare const KnowledgeScopeDefinitionSchema: z.ZodReadonly<z.ZodEffects<
909
966
  }> | Readonly<{
910
967
  kind: "schift_search";
911
968
  indexRef: string;
969
+ }> | Readonly<{
970
+ kind: "local_documents";
971
+ indexRef: string;
912
972
  }> | Readonly<{
913
973
  kind: "web_search";
914
974
  provider: "customer" | "schift";
@@ -1266,6 +1326,9 @@ export declare const KnowledgeScopeDefinitionSchema: z.ZodReadonly<z.ZodEffects<
1266
1326
  }> | Readonly<{
1267
1327
  kind: "schift_search";
1268
1328
  indexRef: string;
1329
+ }> | Readonly<{
1330
+ kind: "local_documents";
1331
+ indexRef: string;
1269
1332
  }> | Readonly<{
1270
1333
  kind: "web_search";
1271
1334
  provider: "customer" | "schift";
@@ -1347,6 +1410,9 @@ export declare const KnowledgeScopeDefinitionSchema: z.ZodReadonly<z.ZodEffects<
1347
1410
  }> | Readonly<{
1348
1411
  kind: "schift_search";
1349
1412
  indexRef: string;
1413
+ }> | Readonly<{
1414
+ kind: "local_documents";
1415
+ indexRef: string;
1350
1416
  }> | Readonly<{
1351
1417
  kind: "web_search";
1352
1418
  provider: "customer" | "schift";
@@ -1428,6 +1494,9 @@ export declare const KnowledgeScopeDefinitionSchema: z.ZodReadonly<z.ZodEffects<
1428
1494
  }> | Readonly<{
1429
1495
  kind: "schift_search";
1430
1496
  indexRef: string;
1497
+ }> | Readonly<{
1498
+ kind: "local_documents";
1499
+ indexRef: string;
1431
1500
  }> | Readonly<{
1432
1501
  kind: "web_search";
1433
1502
  provider: "customer" | "schift";
@@ -1509,6 +1578,9 @@ export declare const KnowledgeScopeDefinitionSchema: z.ZodReadonly<z.ZodEffects<
1509
1578
  }> | Readonly<{
1510
1579
  kind: "schift_search";
1511
1580
  indexRef: string;
1581
+ }> | Readonly<{
1582
+ kind: "local_documents";
1583
+ indexRef: string;
1512
1584
  }> | Readonly<{
1513
1585
  kind: "web_search";
1514
1586
  provider: "customer" | "schift";
@@ -1711,6 +1783,15 @@ export declare const CandidateEnvelopeSchema: z.ZodReadonly<z.ZodObject<{
1711
1783
  }, {
1712
1784
  kind: "schift_search";
1713
1785
  indexRef: string;
1786
+ }>, z.ZodObject<{
1787
+ kind: z.ZodLiteral<"local_documents">;
1788
+ indexRef: z.ZodString;
1789
+ }, "strict", z.ZodTypeAny, {
1790
+ kind: "local_documents";
1791
+ indexRef: string;
1792
+ }, {
1793
+ kind: "local_documents";
1794
+ indexRef: string;
1714
1795
  }>, z.ZodObject<{
1715
1796
  kind: z.ZodLiteral<"web_search">;
1716
1797
  provider: z.ZodEnum<["customer", "schift"]>;
@@ -1767,6 +1848,9 @@ export declare const CandidateEnvelopeSchema: z.ZodReadonly<z.ZodObject<{
1767
1848
  }> | Readonly<{
1768
1849
  kind: "schift_search";
1769
1850
  indexRef: string;
1851
+ }> | Readonly<{
1852
+ kind: "local_documents";
1853
+ indexRef: string;
1770
1854
  }> | Readonly<{
1771
1855
  kind: "web_search";
1772
1856
  provider: "customer" | "schift";
@@ -1818,6 +1902,9 @@ export declare const CandidateEnvelopeSchema: z.ZodReadonly<z.ZodObject<{
1818
1902
  }> | Readonly<{
1819
1903
  kind: "schift_search";
1820
1904
  indexRef: string;
1905
+ }> | Readonly<{
1906
+ kind: "local_documents";
1907
+ indexRef: string;
1821
1908
  }> | Readonly<{
1822
1909
  kind: "web_search";
1823
1910
  provider: "customer" | "schift";
@@ -24,3 +24,4 @@ export type { RecordsOperationExecutor } from "./adapters/provider-port.js";
24
24
  export type { OpenConnectorInputMapper, TrustedEffectiveScope } from "./adapters/types.js";
25
25
  export { evaluateRetrieval, compareRetrievalReports, fingerprintRetrievalDataset, RetrievalEvaluationError } from "./evaluation.js";
26
26
  export type { RetrievalDataset, RetrievalCapture, RetrievalEvaluationReport } from "./evaluation.js";
27
+ export { LocalDocumentStore, LocalDocumentError, LOCAL_LIMITS } from "./local-documents/index.js";
@@ -0,0 +1,32 @@
1
+ import { type Stats } from "node:fs";
2
+ export declare class LocalDocumentError extends Error {
3
+ readonly code: "local_source_invalid" | "local_limit_exceeded" | "local_snapshot_invalid" | "local_scope_invalid";
4
+ readonly name = "LocalDocumentError";
5
+ constructor(code: "local_source_invalid" | "local_limit_exceeded" | "local_snapshot_invalid" | "local_scope_invalid");
6
+ }
7
+ export declare const LOCAL_LIMITS: {
8
+ readonly files: 100;
9
+ readonly fileBytes: 1048576;
10
+ readonly totalBytes: 8388608;
11
+ readonly snapshotBytes: 16777216;
12
+ readonly chunks: 4000;
13
+ readonly entries: 2000;
14
+ readonly depth: 16;
15
+ readonly chunkCharacters: 2000;
16
+ };
17
+ type FileIdentity = Readonly<Pick<Stats, "dev" | "ino" | "size" | "mtimeMs" | "ctimeMs" | "nlink">>;
18
+ type DirectoryIdentity = Readonly<{
19
+ path: string;
20
+ dev: number;
21
+ ino: number;
22
+ }>;
23
+ export type CollectedFile = Readonly<{
24
+ path: string;
25
+ root: string;
26
+ identity: FileIdentity;
27
+ ancestors: readonly DirectoryIdentity[];
28
+ }>;
29
+ export declare const mapLocalFileError: (error: unknown, ownerOnly: boolean) => never;
30
+ export declare const readBounded: (source: string | CollectedFile, maxBytes: number, ownerOnly?: boolean) => Promise<string>;
31
+ export declare const collectFiles: (source: string) => Promise<readonly CollectedFile[]>;
32
+ export {};
@@ -0,0 +1,17 @@
1
+ import { type ProviderResult } from "@schift-io/knowledge-scope/context-pack";
2
+ import type { ProviderExecutionContext } from "../application-execution.js";
3
+ import type { KnowledgeScopeStateStoreOptions } from "../state-store.js";
4
+ export { LocalDocumentError, LOCAL_LIMITS } from "./files.js";
5
+ /** Private snapshots belong to the local filesystem owner, not a multi-user ACL service. */
6
+ export declare class LocalDocumentStore {
7
+ readonly home: string;
8
+ constructor(options?: KnowledgeScopeStateStoreOptions);
9
+ private directory;
10
+ ingest(sourcePath: string): Promise<Readonly<{
11
+ indexRef: string;
12
+ documentCount: number;
13
+ chunkCount: number;
14
+ }>>;
15
+ private read;
16
+ execute(context: ProviderExecutionContext): Promise<readonly ProviderResult[]>;
17
+ }
@@ -0,0 +1,47 @@
1
+ import { z } from "zod";
2
+ export declare const SnapshotSchema: z.ZodReadonly<z.ZodObject<{
3
+ version: z.ZodLiteral<1>;
4
+ capturedAt: z.ZodString;
5
+ documents: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
6
+ uri: z.ZodString;
7
+ text: z.ZodString;
8
+ revision: z.ZodString;
9
+ }, "strict", z.ZodTypeAny, {
10
+ revision: string;
11
+ uri: string;
12
+ text: string;
13
+ }, {
14
+ revision: string;
15
+ uri: string;
16
+ text: string;
17
+ }>>, "many">>;
18
+ }, "strict", z.ZodTypeAny, {
19
+ version: 1;
20
+ capturedAt: string;
21
+ documents: readonly Readonly<{
22
+ revision: string;
23
+ uri: string;
24
+ text: string;
25
+ }>[];
26
+ }, {
27
+ version: 1;
28
+ capturedAt: string;
29
+ documents: readonly Readonly<{
30
+ revision: string;
31
+ uri: string;
32
+ text: string;
33
+ }>[];
34
+ }>>;
35
+ export type Snapshot = z.infer<typeof SnapshotSchema>;
36
+ export type Chunk = Readonly<{
37
+ document: Snapshot["documents"][number];
38
+ text: string;
39
+ lineStart: number;
40
+ lineEnd: number;
41
+ id: string;
42
+ }>;
43
+ export declare const digest: (value: string) => string;
44
+ export declare const snapshotId: (snapshot: Snapshot) => string;
45
+ export declare const buildSnapshot: (source: string) => Promise<Snapshot>;
46
+ export declare const chunksFor: (snapshot: Snapshot) => readonly Chunk[];
47
+ export declare const lexicalTerms: (text: string) => readonly string[];
@@ -0,0 +1,6 @@
1
+ import type { KnowledgeScopeApplicationPort } from "./api.js";
2
+ import type { JsonValue } from "./json.js";
3
+ export declare const queryProject: (request: Readonly<{
4
+ installationId: string;
5
+ query: string;
6
+ }>, application: KnowledgeScopeApplicationPort) => Promise<JsonValue>;
@@ -0,0 +1,15 @@
1
+ import type { CliDependencies } from "./cli.js";
2
+ import { type JsonValue } from "./json.js";
3
+ export type LocalDocumentImportPort = Readonly<{
4
+ ingest: (sourcePath: string) => Promise<Readonly<{
5
+ indexRef: string;
6
+ documentCount: number;
7
+ chunkCount: number;
8
+ }>>;
9
+ }>;
10
+ export declare const localQuickstart: (request: Readonly<{
11
+ directory: string;
12
+ source: string;
13
+ tenant: string;
14
+ query: string;
15
+ }>, dependencies: CliDependencies) => Promise<JsonValue>;