@voce-engine/core 0.1.0-rc.1
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 +1 -0
- package/README.md +9 -0
- package/dist/canonical.d.ts +4 -0
- package/dist/canonical.js +30 -0
- package/dist/evidence.d.ts +31 -0
- package/dist/evidence.js +1053 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +608 -0
- package/dist/m4.d.ts +157 -0
- package/dist/m4.js +2250 -0
- package/dist/m5.d.ts +183 -0
- package/dist/m5.js +2433 -0
- package/dist/m6.d.ts +182 -0
- package/dist/m6.js +1183 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Apache License 2.0
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# @voce-engine/core
|
|
2
|
+
|
|
3
|
+
Deterministic ScenarioPack resolution, constraint compilation, reference planning, Prompt IR, offline execution, and evaluation primitives.
|
|
4
|
+
|
|
5
|
+
> `0.1.0-rc.1` is a release candidate, not production-ready. APIs may change before `0.1.0`.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @voce-engine/core@0.1.0-rc.1
|
|
9
|
+
```
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { JsonValue } from '@voce-engine/contracts';
|
|
2
|
+
export declare function canonicalize(value: JsonValue): string;
|
|
3
|
+
export declare function sha256(value: JsonValue): string;
|
|
4
|
+
export declare function hashWithoutSelf<T extends Record<string, unknown>>(value: T, field: string): string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
function compareCodeUnits(a, b) {
|
|
3
|
+
const length = Math.min(a.length, b.length);
|
|
4
|
+
for (let index = 0; index < length; index += 1) {
|
|
5
|
+
const difference = a.charCodeAt(index) - b.charCodeAt(index);
|
|
6
|
+
if (difference !== 0)
|
|
7
|
+
return difference;
|
|
8
|
+
}
|
|
9
|
+
return a.length - b.length;
|
|
10
|
+
}
|
|
11
|
+
export function canonicalize(value) {
|
|
12
|
+
if (value === null || typeof value === 'boolean' || typeof value === 'string')
|
|
13
|
+
return JSON.stringify(value);
|
|
14
|
+
if (typeof value === 'number') {
|
|
15
|
+
if (!Number.isFinite(value))
|
|
16
|
+
throw new Error('CANONICAL_JSON_NUMBER_INVALID');
|
|
17
|
+
return JSON.stringify(value);
|
|
18
|
+
}
|
|
19
|
+
if (Array.isArray(value))
|
|
20
|
+
return `[${value.map(canonicalize).join(',')}]`;
|
|
21
|
+
return `{${Object.keys(value).sort(compareCodeUnits).map((key) => `${JSON.stringify(key)}:${canonicalize(value[key])}`).join(',')}}`;
|
|
22
|
+
}
|
|
23
|
+
export function sha256(value) {
|
|
24
|
+
return `sha256:${createHash('sha256').update(canonicalize(value)).digest('hex')}`;
|
|
25
|
+
}
|
|
26
|
+
export function hashWithoutSelf(value, field) {
|
|
27
|
+
const copy = { ...value };
|
|
28
|
+
delete copy[field];
|
|
29
|
+
return sha256(copy);
|
|
30
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { BindingDecision, EvidenceAndSourceResolver as EvidenceAndSourceResolverContract, EvidenceAndSourceResolverInput, EvidenceAndSourceResolverResult, Observation, ObservationDecision, ReferenceInterpreter as ReferenceInterpreterContract, ReferenceInterpreterInput, ReferenceInterpreterResult, RequestedScopePlan, SourceBinding } from '@voce-engine/contracts';
|
|
2
|
+
export declare const EVIDENCE_RESOLVER_VERSION = "voce.evidence-source-resolver/v1alpha1";
|
|
3
|
+
export declare const MANUAL_REFERENCE_INTERPRETER_VERSION = "voce.manual-reference-interpreter/v1alpha1";
|
|
4
|
+
export declare const FIXTURE_REFERENCE_INTERPRETER_VERSION = "voce.fixture-reference-interpreter/v1alpha1";
|
|
5
|
+
export declare const FIXED_DECISION_TIME = "1970-01-01T00:00:00.000Z";
|
|
6
|
+
export declare function computeObservationContentHash(observation: Observation): string;
|
|
7
|
+
export declare function createObservation(input: Omit<Observation, 'contentHash'>): Observation;
|
|
8
|
+
export declare function computeSourceBindingContentHash(binding: SourceBinding): string;
|
|
9
|
+
export declare const computeBindingHash: typeof computeSourceBindingContentHash;
|
|
10
|
+
export declare const computeSourceBindingHash: typeof computeSourceBindingContentHash;
|
|
11
|
+
export declare const computeObservationHash: typeof computeObservationContentHash;
|
|
12
|
+
export declare function createSourceBinding(input: Omit<SourceBinding, 'contentHash'>): SourceBinding;
|
|
13
|
+
export declare function computeObservationDecisionHash(decision: ObservationDecision): string;
|
|
14
|
+
export declare function createObservationDecision(input: Omit<ObservationDecision, 'decisionHash'>): ObservationDecision;
|
|
15
|
+
export declare function computeBindingDecisionHash(decision: BindingDecision): string;
|
|
16
|
+
export declare function createBindingDecision(input: Omit<BindingDecision, 'decisionHash'>): BindingDecision;
|
|
17
|
+
type RequestedScopePlanHashInput = Omit<RequestedScopePlan, 'planHash'>;
|
|
18
|
+
export declare function computeRequestedScopePlanHash(plan: RequestedScopePlanHashInput): string;
|
|
19
|
+
export declare class ManualReferenceInterpreter implements ReferenceInterpreterContract {
|
|
20
|
+
interpret(input: ReferenceInterpreterInput): ReferenceInterpreterResult;
|
|
21
|
+
}
|
|
22
|
+
export declare class FixtureReferenceInterpreter implements ReferenceInterpreterContract {
|
|
23
|
+
interpret(input: ReferenceInterpreterInput): ReferenceInterpreterResult;
|
|
24
|
+
}
|
|
25
|
+
export declare class EvidenceAndSourceResolver implements EvidenceAndSourceResolverContract {
|
|
26
|
+
resolve(input: EvidenceAndSourceResolverInput): EvidenceAndSourceResolverResult;
|
|
27
|
+
}
|
|
28
|
+
export declare const DeterministicEvidenceAndSourceResolver: typeof EvidenceAndSourceResolver;
|
|
29
|
+
export declare function resolveEvidenceAndSource(input: EvidenceAndSourceResolverInput): EvidenceAndSourceResolverResult;
|
|
30
|
+
export declare function createEvidenceAndSourceResolver(): EvidenceAndSourceResolver;
|
|
31
|
+
export {};
|