@schift-io/knowledge-scope 0.1.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/LICENSE +202 -0
- package/README.md +387 -0
- package/dist/context-pack.js +4771 -0
- package/dist/index.js +8044 -0
- package/dist/main.js +7550 -0
- package/dist/types/adapters/evidence-policy.d.ts +3 -0
- package/dist/types/adapters/gates.d.ts +13 -0
- package/dist/types/adapters/http-policy.d.ts +10 -0
- package/dist/types/adapters/open-connector.d.ts +20 -0
- package/dist/types/adapters/provider-port.d.ts +27 -0
- package/dist/types/adapters/response.d.ts +12 -0
- package/dist/types/adapters/schift-search-headers.d.ts +2 -0
- package/dist/types/adapters/schift-search-identity.d.ts +14 -0
- package/dist/types/adapters/schift-search.d.ts +17 -0
- package/dist/types/adapters/types.d.ts +136 -0
- package/dist/types/api-contract.d.ts +164 -0
- package/dist/types/api.d.ts +30 -0
- package/dist/types/application-batch.d.ts +4 -0
- package/dist/types/application-execution.d.ts +30 -0
- package/dist/types/application.d.ts +47 -0
- package/dist/types/authorization.d.ts +228 -0
- package/dist/types/cli-options.d.ts +6 -0
- package/dist/types/cli.d.ts +24 -0
- package/dist/types/client-error.d.ts +5 -0
- package/dist/types/client-validation.d.ts +8 -0
- package/dist/types/client.d.ts +18 -0
- package/dist/types/context-pack/bounded-json.d.ts +3 -0
- package/dist/types/context-pack/canonical.d.ts +12 -0
- package/dist/types/context-pack/index.d.ts +73 -0
- package/dist/types/context-pack/knowledge-scope-admission.d.ts +23 -0
- package/dist/types/context-pack/knowledge-scope-batch.d.ts +85 -0
- package/dist/types/context-pack/knowledge-scope-execution.d.ts +297 -0
- package/dist/types/context-pack/knowledge-scope-lock.d.ts +71 -0
- package/dist/types/context-pack/knowledge-scope-mount.d.ts +1094 -0
- package/dist/types/context-pack/knowledge-scope.d.ts +1843 -0
- package/dist/types/context-pack/scalars.d.ts +13 -0
- package/dist/types/doctor-config.d.ts +6 -0
- package/dist/types/doctor.d.ts +7 -0
- package/dist/types/errors.d.ts +8 -0
- package/dist/types/evaluation/contracts.d.ts +718 -0
- package/dist/types/evaluation.d.ts +20 -0
- package/dist/types/index.d.ts +26 -0
- package/dist/types/json.d.ts +17 -0
- package/dist/types/limits.d.ts +10 -0
- package/dist/types/main.d.ts +10 -0
- package/dist/types/onboarding-config.d.ts +9 -0
- package/dist/types/portable.d.ts +14 -0
- package/dist/types/quickstart.d.ts +10 -0
- package/dist/types/schema-subset.d.ts +9 -0
- package/dist/types/state-contract.d.ts +2867 -0
- package/dist/types/state-store.d.ts +29 -0
- package/docs/PILOT.md +184 -0
- package/examples/batch-consumer.mjs +19 -0
- package/examples/consumer.mjs +17 -0
- package/examples/evaluation/README.md +34 -0
- package/examples/evaluation/run.mjs +21 -0
- package/examples/evaluation/synthetic.json +59 -0
- package/examples/mount-bindings.json +31 -0
- package/examples/support-scope/schemas/query-input.json +6 -0
- package/examples/support-scope/schemas/result-row.json +6 -0
- package/examples/support-scope/scope.json +48 -0
- package/package.json +58 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type RetrievalEvaluationReport } from "./evaluation/contracts.js";
|
|
2
|
+
export { RetrievalEvaluationError, retrievalDatasetSchema, retrievalCaptureSchema, retrievalReportSchema } from "./evaluation/contracts.js";
|
|
3
|
+
export type { RetrievalDataset, RetrievalCapture, RetrievalEvaluationReport } from "./evaluation/contracts.js";
|
|
4
|
+
/** Fingerprints the labels as well as snapshot and per-question input identities. */
|
|
5
|
+
export declare function fingerprintRetrievalDataset(value: unknown): string;
|
|
6
|
+
/** Offline label matching only. Citation equality does not prove URL liveness or source truth. */
|
|
7
|
+
export declare function evaluateRetrieval(value: unknown): RetrievalEvaluationReport;
|
|
8
|
+
/** Right minus left; null means that metric has no labeled denominator. No winner is inferred. */
|
|
9
|
+
export declare function compareRetrievalReports(leftValue: unknown, rightValue: unknown): {
|
|
10
|
+
baselineAdapter: string;
|
|
11
|
+
candidateAdapter: string;
|
|
12
|
+
datasetFingerprint: string;
|
|
13
|
+
topK: number;
|
|
14
|
+
delta: {
|
|
15
|
+
recallAtK: number | null;
|
|
16
|
+
citationMatchRate: number | null;
|
|
17
|
+
forbiddenEvidenceCount: number;
|
|
18
|
+
decisionMatchRate: number;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export { createKnowledgeScopeApi, createRemoteKnowledgeScopeApplication, serveKnowledgeScopeApi, KnowledgeScopeApiError, } from "./api.js";
|
|
2
|
+
export type { KnowledgeScopeApplicationPort, MountApplicationRequest, RunApplicationRequest, RunBatchApplicationRequest, AdmitApplicationRequest, UnmountApplicationRequest, ServedKnowledgeScopeApi, } from "./api.js";
|
|
3
|
+
export { runKnowledgeScopeCli } from "./cli.js";
|
|
4
|
+
export type { CliDependencies, CliStreams, PortableAuthoringPort } from "./cli.js";
|
|
5
|
+
export { createCliDependencies, main } from "./main.js";
|
|
6
|
+
export { GLOBAL_MAX_RESULT_BYTES, GLOBAL_MAX_RESULT_ROWS, KnowledgeScopeApplication, MAX_BINDINGS, MAX_CANDIDATES, } from "./application.js";
|
|
7
|
+
export type { KnowledgeScopeApplicationOptions, KnowledgeScopeInspection, KnowledgeScopeRunResult, MountKnowledgeScopeInput, ProviderExecutionContext, ProviderExecutionPort, } from "./application.js";
|
|
8
|
+
export { createPortableLock, loadPortableScope, verifyPortableLock, } from "./portable.js";
|
|
9
|
+
export type { PortableKnowledgeScope } from "./portable.js";
|
|
10
|
+
export { KNOWLEDGE_SCOPE_ERROR_CODES, KnowledgeScopeProductError, } from "./errors.js";
|
|
11
|
+
export type { KnowledgeScopeErrorCode } from "./errors.js";
|
|
12
|
+
export { createHttpProviderExecutionPort, HttpProviderAdapterError, normalizeDefaultOpenConnectorRow, } from "./adapters/provider-port.js";
|
|
13
|
+
export type { HttpProviderExecutionOptions, HttpProviderRuntimeResolver, } from "./adapters/provider-port.js";
|
|
14
|
+
export { ADAPTER_FAILURE_CODES } from "./adapters/types.js";
|
|
15
|
+
export type { AdapterCapability, AdapterExecutionRequest, AdapterFailure, AdapterFailureCode, AdapterResult, AdapterSourceBinding, CitationFact, HttpRequest, HttpResponseLike, HttpTransport, OpenConnectorCapability, OpenConnectorNormalizedRow, OpenConnectorRowNormalizer, OpenConnectorRuntime, ProviderResultFact, SchemaValidationResult, SchemaValidator, SchiftSearchCapability, SchiftSearchRuntime, SourceClass, } from "./adapters/types.js";
|
|
16
|
+
export { KnowledgeScopeStateStore } from "./state-store.js";
|
|
17
|
+
export type { KnowledgeScopeStateStoreOptions, StateStoreFaults, } from "./state-store.js";
|
|
18
|
+
export { KnowledgeScopeAuthorization } from "./authorization.js";
|
|
19
|
+
export type { KnowledgeScopeAuthorizationOptions } from "./authorization.js";
|
|
20
|
+
export type { JsonObject, JsonPrimitive, JsonValue } from "./json.js";
|
|
21
|
+
export { createKnowledgeScopeClient, KnowledgeScopeClientError } from "./client.js";
|
|
22
|
+
export type { KnowledgeScopeClient } from "./client.js";
|
|
23
|
+
export type { RecordsOperationExecutor } from "./adapters/provider-port.js";
|
|
24
|
+
export type { OpenConnectorInputMapper, TrustedEffectiveScope } from "./adapters/types.js";
|
|
25
|
+
export { evaluateRetrieval, compareRetrievalReports, fingerprintRetrievalDataset, RetrievalEvaluationError } from "./evaluation.js";
|
|
26
|
+
export type { RetrievalDataset, RetrievalCapture, RetrievalEvaluationReport } from "./evaluation.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type JsonPrimitive = boolean | number | string | null;
|
|
2
|
+
export type JsonValue = JsonPrimitive | readonly JsonValue[] | JsonObject;
|
|
3
|
+
export type JsonObject = {
|
|
4
|
+
readonly [key: string]: JsonValue;
|
|
5
|
+
};
|
|
6
|
+
export declare const DEFAULT_MAX_JSON_BYTES = 1048576;
|
|
7
|
+
export declare const DEFAULT_MAX_JSON_DEPTH = 16;
|
|
8
|
+
export declare const DEFAULT_MAX_JSON_NODES = 100000;
|
|
9
|
+
export declare const decodeUtf8Strict: (bytes: Uint8Array) => string;
|
|
10
|
+
export type ParseJsonOptions = Readonly<{
|
|
11
|
+
maxBytes?: number;
|
|
12
|
+
maxDepth?: number;
|
|
13
|
+
maxNodes?: number;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const parseJsonText: (text: string, _sourceName: string, options?: ParseJsonOptions) => JsonValue;
|
|
16
|
+
export declare const canonicalJson: (value: unknown) => string;
|
|
17
|
+
export declare const sha256Digest: (value: JsonValue) => Promise<string>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const MAX_BINDINGS = 64;
|
|
2
|
+
export declare const MAX_CANDIDATES = 100;
|
|
3
|
+
export declare const GLOBAL_MAX_RESULT_ROWS = 100;
|
|
4
|
+
export declare const GLOBAL_MAX_RESULT_BYTES: number;
|
|
5
|
+
/** Shared accumulator for one execution, including every operation and binding. */
|
|
6
|
+
export declare class ExecutionBudget {
|
|
7
|
+
private rows;
|
|
8
|
+
private bytes;
|
|
9
|
+
consume(rows: number, bytes: number): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { type ProviderExecutionPort } from "./application.js";
|
|
3
|
+
import { type CliDependencies } from "./cli.js";
|
|
4
|
+
export type KnowledgeScopeCliOptions = Readonly<{
|
|
5
|
+
provider?: ProviderExecutionPort;
|
|
6
|
+
home?: string;
|
|
7
|
+
environment?: Readonly<Record<string, string | undefined>>;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const createCliDependencies: (options?: KnowledgeScopeCliOptions) => CliDependencies;
|
|
10
|
+
export declare const main: (argv?: readonly string[]) => Promise<number>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { JsonValue } from "./json.js";
|
|
2
|
+
export type OnboardingEnvironment = Readonly<Record<string, string | undefined>>;
|
|
3
|
+
export declare class OnboardingError extends Error {
|
|
4
|
+
readonly code: string;
|
|
5
|
+
readonly details: Readonly<Record<string, JsonValue>>;
|
|
6
|
+
readonly name = "OnboardingError";
|
|
7
|
+
constructor(code: string, details?: Readonly<Record<string, JsonValue>>);
|
|
8
|
+
}
|
|
9
|
+
export declare const searchConfiguration: (environment: OnboardingEnvironment) => readonly string[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type KnowledgeScopeDefinition, type KnowledgeScopeLock } from "@schift-io/knowledge-scope/context-pack";
|
|
2
|
+
import { type JsonValue } from "./json.js";
|
|
3
|
+
export type PortableKnowledgeScope = Readonly<{
|
|
4
|
+
directory: string;
|
|
5
|
+
definition: KnowledgeScopeDefinition;
|
|
6
|
+
files: Readonly<Record<string, JsonValue>>;
|
|
7
|
+
lock?: KnowledgeScopeLock;
|
|
8
|
+
}>;
|
|
9
|
+
export type LoadPortableScopeOptions = Readonly<{
|
|
10
|
+
readLock?: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const loadPortableScope: (directory: string, options?: LoadPortableScopeOptions) => Promise<PortableKnowledgeScope>;
|
|
13
|
+
export declare const createPortableLock: (directory: string) => Promise<KnowledgeScopeLock>;
|
|
14
|
+
export declare const verifyPortableLock: (directory: string) => Promise<boolean>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CliDependencies } from "./cli.js";
|
|
2
|
+
import { type JsonValue } from "./json.js";
|
|
3
|
+
import { type OnboardingEnvironment } from "./onboarding-config.js";
|
|
4
|
+
export type QuickstartRequest = Readonly<{
|
|
5
|
+
directory: string;
|
|
6
|
+
index: string;
|
|
7
|
+
tenant: string;
|
|
8
|
+
query: string;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const quickstart: (request: QuickstartRequest, dependencies: CliDependencies, environment: OnboardingEnvironment) => Promise<JsonValue>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type JsonValue } from "./json.js";
|
|
2
|
+
export type SchemaValidationResult = Readonly<{
|
|
3
|
+
valid: true;
|
|
4
|
+
}> | Readonly<{
|
|
5
|
+
valid: false;
|
|
6
|
+
path: string;
|
|
7
|
+
reason: string;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const compileSchemaSubset: (rawSchema: unknown) => ((value: JsonValue) => SchemaValidationResult);
|