@manifesto-ai/core 2.7.1 → 2.9.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 +1 -1
- package/dist/core/action-availability.d.ts +27 -0
- package/dist/core/apply.d.ts +11 -0
- package/dist/core/compute.d.ts +16 -0
- package/dist/core/explain.d.ts +13 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/system-delta.d.ts +8 -0
- package/dist/core/validate.d.ts +15 -0
- package/dist/core/validation-utils.d.ts +22 -0
- package/dist/errors.d.ts +29 -0
- package/dist/evaluator/computed.d.ts +13 -0
- package/dist/evaluator/context.d.ts +61 -0
- package/dist/evaluator/dag.d.ts +29 -0
- package/dist/evaluator/expr.d.ts +10 -0
- package/dist/evaluator/flow.d.ts +35 -0
- package/dist/evaluator/index.d.ts +5 -0
- package/dist/factories.d.ts +21 -0
- package/dist/index.d.ts +28 -1746
- package/dist/index.js +231 -212
- package/dist/index.js.map +1 -1
- package/dist/schema/action.d.ts +13 -0
- package/dist/schema/common.d.ts +36 -0
- package/dist/schema/computed.d.ts +22 -0
- package/dist/schema/defaults.d.ts +11 -0
- package/dist/schema/domain.d.ts +49 -0
- package/dist/schema/expr.d.ts +482 -0
- package/dist/schema/field.d.ts +47 -0
- package/dist/schema/flow.d.ts +108 -0
- package/dist/schema/host-context.d.ts +11 -0
- package/dist/schema/index.d.ts +14 -0
- package/dist/schema/patch.d.ts +105 -0
- package/dist/schema/result.d.ts +175 -0
- package/dist/schema/snapshot.d.ts +132 -0
- package/dist/schema/trace.d.ts +97 -0
- package/dist/schema/type-spec.d.ts +33 -0
- package/dist/utils/canonical.d.ts +37 -0
- package/dist/utils/hash.d.ts +54 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/patch-path.d.ts +15 -0
- package/dist/utils/path.d.ts +41 -0
- package/package.json +4 -4
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical form utilities for deterministic hashing
|
|
3
|
+
*
|
|
4
|
+
* Algorithm:
|
|
5
|
+
* 1. Sort all object keys alphabetically (recursive)
|
|
6
|
+
* 2. Remove all keys with undefined value
|
|
7
|
+
* 3. Preserve keys with null value
|
|
8
|
+
* 4. Serialize using JSON with no whitespace
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Recursively sort object keys alphabetically
|
|
12
|
+
*/
|
|
13
|
+
export declare function sortKeys(obj: unknown): unknown;
|
|
14
|
+
/**
|
|
15
|
+
* Convert object to canonical JSON string
|
|
16
|
+
* - Keys are sorted alphabetically
|
|
17
|
+
* - Undefined values are removed
|
|
18
|
+
* - No whitespace
|
|
19
|
+
*/
|
|
20
|
+
export declare function toCanonical(obj: unknown): string;
|
|
21
|
+
/**
|
|
22
|
+
* Canonicalize JSON per RFC 8785 (JCS)
|
|
23
|
+
* - Objects: keys sorted by Unicode code points
|
|
24
|
+
* - Arrays: preserve order
|
|
25
|
+
* - Undefined/function/symbol: omitted in objects, null in arrays
|
|
26
|
+
* - Non-finite numbers: null
|
|
27
|
+
*/
|
|
28
|
+
export declare function toJcs(value: unknown): string;
|
|
29
|
+
export declare function compareUnicodeCodePoints(a: string, b: string): number;
|
|
30
|
+
/**
|
|
31
|
+
* Parse canonical JSON string
|
|
32
|
+
*/
|
|
33
|
+
export declare function fromCanonical<T>(canonical: string): T;
|
|
34
|
+
/**
|
|
35
|
+
* Check if two objects are equal in canonical form
|
|
36
|
+
*/
|
|
37
|
+
export declare function canonicalEqual(a: unknown, b: unknown): boolean;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export type SchemaHashMode = "semantic" | "effective";
|
|
2
|
+
export type SchemaHashInput = {
|
|
3
|
+
id: string;
|
|
4
|
+
version: string;
|
|
5
|
+
types: Record<string, unknown>;
|
|
6
|
+
state: {
|
|
7
|
+
fields: Record<string, unknown>;
|
|
8
|
+
};
|
|
9
|
+
computed: {
|
|
10
|
+
fields: Record<string, {
|
|
11
|
+
deps: string[];
|
|
12
|
+
expr: unknown;
|
|
13
|
+
description?: string;
|
|
14
|
+
}>;
|
|
15
|
+
};
|
|
16
|
+
actions: Record<string, unknown>;
|
|
17
|
+
meta?: {
|
|
18
|
+
name?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
authors?: string[];
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* SHA-256 hash using Web Crypto API
|
|
25
|
+
* Works in both browser and Node.js
|
|
26
|
+
*/
|
|
27
|
+
export declare function sha256(message: string): Promise<string>;
|
|
28
|
+
/**
|
|
29
|
+
* SHA-256 hash using a synchronous pure JS implementation
|
|
30
|
+
*/
|
|
31
|
+
export declare function sha256Sync(message: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Hash a schema in canonical form
|
|
34
|
+
*/
|
|
35
|
+
export declare function hashSchema(schema: SchemaHashInput, mode?: SchemaHashMode): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Hash a schema in canonical form (sync)
|
|
38
|
+
*/
|
|
39
|
+
export declare function hashSchemaSync(schema: SchemaHashInput, mode?: SchemaHashMode): string;
|
|
40
|
+
export declare function hashSchemaEffective(schema: SchemaHashInput): Promise<string>;
|
|
41
|
+
export declare function hashSchemaEffectiveSync(schema: SchemaHashInput): string;
|
|
42
|
+
/**
|
|
43
|
+
* Generate deterministic requirement ID
|
|
44
|
+
* Based on: schemaHash, intentId, actionId, flowNodePath
|
|
45
|
+
*/
|
|
46
|
+
export declare function generateRequirementId(schemaHash: string, intentId: string, actionId: string, flowNodePath: string): Promise<string>;
|
|
47
|
+
/**
|
|
48
|
+
* Generate deterministic requirement ID (sync)
|
|
49
|
+
*/
|
|
50
|
+
export declare function generateRequirementIdSync(schemaHash: string, intentId: string, actionId: string, flowNodePath: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* Generate a trace node ID
|
|
53
|
+
*/
|
|
54
|
+
export declare function generateTraceId(index?: number): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PatchPath } from "../schema/patch.js";
|
|
2
|
+
/**
|
|
3
|
+
* Render PatchPath for logs and error messages only.
|
|
4
|
+
*/
|
|
5
|
+
export declare function patchPathToDisplayString(path: PatchPath): string;
|
|
6
|
+
/**
|
|
7
|
+
* Convert a legacy semantic string path into PatchPath segments.
|
|
8
|
+
* This helper exists for internal bridging only.
|
|
9
|
+
*/
|
|
10
|
+
export declare function semanticPathToPatchPath(path: string): PatchPath;
|
|
11
|
+
export declare function isSafePatchPath(path: PatchPath): boolean;
|
|
12
|
+
export declare function getByPatchPath(obj: unknown, path: PatchPath): unknown;
|
|
13
|
+
export declare function setByPatchPath(obj: unknown, path: PatchPath, value: unknown): unknown;
|
|
14
|
+
export declare function unsetByPatchPath(obj: unknown, path: PatchPath): unknown;
|
|
15
|
+
export declare function mergeAtPatchPath(obj: unknown, path: PatchPath, value: Record<string, unknown>): unknown;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { SemanticPath } from "../schema/common.js";
|
|
2
|
+
/**
|
|
3
|
+
* Parse a dot-separated path into segments.
|
|
4
|
+
*
|
|
5
|
+
* Supports escaping literal dots inside segments via backslash (for example `a\\.b` -> `a.b`).
|
|
6
|
+
*/
|
|
7
|
+
export declare function parsePath(path: SemanticPath): string[];
|
|
8
|
+
/**
|
|
9
|
+
* Join path segments into a semantic path
|
|
10
|
+
*/
|
|
11
|
+
export declare function joinPath(...segments: string[]): SemanticPath;
|
|
12
|
+
/**
|
|
13
|
+
* Get value at path from object
|
|
14
|
+
* Returns undefined for non-existent paths (never throws)
|
|
15
|
+
*/
|
|
16
|
+
export declare function getByPath(obj: unknown, path: SemanticPath): unknown;
|
|
17
|
+
/**
|
|
18
|
+
* Immutably set value at path
|
|
19
|
+
* Creates intermediate objects as needed
|
|
20
|
+
*/
|
|
21
|
+
export declare function setByPath(obj: unknown, path: SemanticPath, value: unknown): unknown;
|
|
22
|
+
/**
|
|
23
|
+
* Immutably remove value at path
|
|
24
|
+
*/
|
|
25
|
+
export declare function unsetByPath(obj: unknown, path: SemanticPath): unknown;
|
|
26
|
+
/**
|
|
27
|
+
* Immutably shallow merge at path
|
|
28
|
+
*/
|
|
29
|
+
export declare function mergeAtPath(obj: unknown, path: SemanticPath, value: Record<string, unknown>): unknown;
|
|
30
|
+
/**
|
|
31
|
+
* Check if a path exists in an object
|
|
32
|
+
*/
|
|
33
|
+
export declare function hasPath(obj: unknown, path: SemanticPath): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Get parent path
|
|
36
|
+
*/
|
|
37
|
+
export declare function parentPath(path: SemanticPath): SemanticPath;
|
|
38
|
+
/**
|
|
39
|
+
* Get last segment of path
|
|
40
|
+
*/
|
|
41
|
+
export declare function lastSegment(path: SemanticPath): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manifesto-ai/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "Manifesto Core - Pure semantic calculator for deterministic state computation",
|
|
5
5
|
"author": "eggplantiny <eggplantiny@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
],
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"typescript": "^5.9.3",
|
|
39
|
-
"vite": "^
|
|
40
|
-
"vitest": "^4.1.
|
|
39
|
+
"vite": "^8.0.3",
|
|
40
|
+
"vitest": "^4.1.2"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
|
-
"build": "tsup",
|
|
43
|
+
"build": "rm -rf dist && tsup && tsc -p tsconfig.build.json --emitDeclarationOnly --declarationMap false --outDir dist",
|
|
44
44
|
"dev": "tsc --watch",
|
|
45
45
|
"clean": "rm -rf dist",
|
|
46
46
|
"lint": "echo 'lint not configured'",
|