@manifesto-ai/core 2.8.0 → 2.10.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.
Files changed (41) hide show
  1. package/README.md +6 -5
  2. package/dist/core/action-availability.d.ts +27 -0
  3. package/dist/core/apply.d.ts +11 -0
  4. package/dist/core/compute.d.ts +16 -0
  5. package/dist/core/explain.d.ts +13 -0
  6. package/dist/core/index.d.ts +4 -0
  7. package/dist/core/system-delta.d.ts +8 -0
  8. package/dist/core/validate.d.ts +15 -0
  9. package/dist/core/validation-utils.d.ts +22 -0
  10. package/dist/errors.d.ts +29 -0
  11. package/dist/evaluator/computed.d.ts +13 -0
  12. package/dist/evaluator/context.d.ts +61 -0
  13. package/dist/evaluator/dag.d.ts +29 -0
  14. package/dist/evaluator/expr.d.ts +10 -0
  15. package/dist/evaluator/flow.d.ts +35 -0
  16. package/dist/evaluator/index.d.ts +5 -0
  17. package/dist/factories.d.ts +21 -0
  18. package/dist/index.d.ts +20 -1715
  19. package/dist/index.js +1 -18499
  20. package/dist/index.js.map +1 -1
  21. package/dist/schema/action.d.ts +13 -0
  22. package/dist/schema/common.d.ts +36 -0
  23. package/dist/schema/computed.d.ts +22 -0
  24. package/dist/schema/defaults.d.ts +11 -0
  25. package/dist/schema/domain.d.ts +49 -0
  26. package/dist/schema/expr.d.ts +482 -0
  27. package/dist/schema/field.d.ts +47 -0
  28. package/dist/schema/flow.d.ts +108 -0
  29. package/dist/schema/host-context.d.ts +11 -0
  30. package/dist/schema/index.d.ts +14 -0
  31. package/dist/schema/patch.d.ts +105 -0
  32. package/dist/schema/result.d.ts +175 -0
  33. package/dist/schema/snapshot.d.ts +132 -0
  34. package/dist/schema/trace.d.ts +97 -0
  35. package/dist/schema/type-spec.d.ts +33 -0
  36. package/dist/utils/canonical.d.ts +37 -0
  37. package/dist/utils/hash.d.ts +54 -0
  38. package/dist/utils/index.d.ts +4 -0
  39. package/dist/utils/patch-path.d.ts +15 -0
  40. package/dist/utils/path.d.ts +41 -0
  41. package/package.json +8 -4
@@ -0,0 +1,108 @@
1
+ import { z } from "zod";
2
+ import { type ExprNode } from "./expr.js";
3
+ /**
4
+ * FlowNode - Declarative state transition programs
5
+ * Flows do NOT execute; they describe.
6
+ * Flows do NOT return values; they modify Snapshot.
7
+ * Flows are NOT Turing-complete; they always terminate.
8
+ */
9
+ export type FlowNode = SeqFlow | IfFlow | PatchFlow | EffectFlow | CallFlow | HaltFlow | FailFlow;
10
+ /**
11
+ * Patch operations
12
+ */
13
+ export declare const PatchOp: z.ZodEnum<{
14
+ set: "set";
15
+ unset: "unset";
16
+ merge: "merge";
17
+ }>;
18
+ export type PatchOp = z.infer<typeof PatchOp>;
19
+ /**
20
+ * seq - Execute steps in order
21
+ */
22
+ export declare const SeqFlow: z.ZodType<{
23
+ kind: "seq";
24
+ steps: FlowNode[];
25
+ }>;
26
+ export type SeqFlow = z.infer<typeof SeqFlow>;
27
+ /**
28
+ * if - Conditional execution
29
+ */
30
+ export declare const IfFlow: z.ZodType<{
31
+ kind: "if";
32
+ cond: ExprNode;
33
+ then: FlowNode;
34
+ else?: FlowNode;
35
+ }>;
36
+ export type IfFlow = z.infer<typeof IfFlow>;
37
+ /**
38
+ * patch - State mutation declaration
39
+ */
40
+ export declare const PatchFlow: z.ZodObject<{
41
+ kind: z.ZodLiteral<"patch">;
42
+ op: z.ZodEnum<{
43
+ set: "set";
44
+ unset: "unset";
45
+ merge: "merge";
46
+ }>;
47
+ path: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
48
+ kind: z.ZodLiteral<"prop">;
49
+ name: z.ZodString;
50
+ }, z.core.$strip>, z.ZodObject<{
51
+ kind: z.ZodLiteral<"index">;
52
+ index: z.ZodNumber;
53
+ }, z.core.$strip>], "kind">>;
54
+ value: z.ZodOptional<z.ZodType<ExprNode, unknown, z.core.$ZodTypeInternals<ExprNode, unknown>>>;
55
+ }, z.core.$strip>;
56
+ export type PatchFlow = z.infer<typeof PatchFlow>;
57
+ /**
58
+ * effect - External operation requirement declaration
59
+ * Effects are NOT executed by Core. They are declarations recorded in Snapshot.
60
+ */
61
+ export declare const EffectFlow: z.ZodObject<{
62
+ kind: z.ZodLiteral<"effect">;
63
+ type: z.ZodString;
64
+ params: z.ZodRecord<z.ZodString, z.ZodType<ExprNode, unknown, z.core.$ZodTypeInternals<ExprNode, unknown>>>;
65
+ }, z.core.$strip>;
66
+ export type EffectFlow = z.infer<typeof EffectFlow>;
67
+ /**
68
+ * call - Invoke another flow by name
69
+ * Does NOT pass arguments or return values.
70
+ * The called Flow reads from the same Snapshot.
71
+ */
72
+ export declare const CallFlow: z.ZodObject<{
73
+ kind: z.ZodLiteral<"call">;
74
+ flow: z.ZodString;
75
+ }, z.core.$strip>;
76
+ export type CallFlow = z.infer<typeof CallFlow>;
77
+ /**
78
+ * halt - Stop flow execution normally (not an error)
79
+ */
80
+ export declare const HaltFlow: z.ZodObject<{
81
+ kind: z.ZodLiteral<"halt">;
82
+ reason: z.ZodOptional<z.ZodString>;
83
+ }, z.core.$strip>;
84
+ export type HaltFlow = z.infer<typeof HaltFlow>;
85
+ /**
86
+ * fail - Stop flow execution with an error
87
+ * The error is recorded in Snapshot.
88
+ */
89
+ export declare const FailFlow: z.ZodObject<{
90
+ kind: z.ZodLiteral<"fail">;
91
+ code: z.ZodString;
92
+ message: z.ZodOptional<z.ZodType<ExprNode, unknown, z.core.$ZodTypeInternals<ExprNode, unknown>>>;
93
+ }, z.core.$strip>;
94
+ export type FailFlow = z.infer<typeof FailFlow>;
95
+ export declare const FlowNodeSchema: z.ZodType<FlowNode>;
96
+ /**
97
+ * Flow node kinds enum
98
+ */
99
+ export declare const FlowKind: z.ZodEnum<{
100
+ if: "if";
101
+ patch: "patch";
102
+ effect: "effect";
103
+ call: "call";
104
+ halt: "halt";
105
+ fail: "fail";
106
+ seq: "seq";
107
+ }>;
108
+ export type FlowKind = z.infer<typeof FlowKind>;
@@ -0,0 +1,11 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * HostContext - Explicit host-provided inputs for determinism
4
+ */
5
+ export declare const HostContext: z.ZodObject<{
6
+ now: z.ZodNumber;
7
+ randomSeed: z.ZodString;
8
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
9
+ durationMs: z.ZodOptional<z.ZodNumber>;
10
+ }, z.core.$strip>;
11
+ export type HostContext = z.infer<typeof HostContext>;
@@ -0,0 +1,14 @@
1
+ export * from "./common.js";
2
+ export * from "./field.js";
3
+ export * from "./expr.js";
4
+ export * from "./flow.js";
5
+ export * from "./computed.js";
6
+ export * from "./action.js";
7
+ export * from "./domain.js";
8
+ export * from "./type-spec.js";
9
+ export * from "./snapshot.js";
10
+ export * from "./defaults.js";
11
+ export * from "./patch.js";
12
+ export * from "./host-context.js";
13
+ export * from "./trace.js";
14
+ export * from "./result.js";
@@ -0,0 +1,105 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * PatchSegment - A single segment in a patch path.
4
+ */
5
+ export declare const PatchSegment: z.ZodDiscriminatedUnion<[z.ZodObject<{
6
+ kind: z.ZodLiteral<"prop">;
7
+ name: z.ZodString;
8
+ }, z.core.$strip>, z.ZodObject<{
9
+ kind: z.ZodLiteral<"index">;
10
+ index: z.ZodNumber;
11
+ }, z.core.$strip>], "kind">;
12
+ export type PatchSegment = z.infer<typeof PatchSegment>;
13
+ /**
14
+ * PatchPath - Path segments rooted at snapshot.data.
15
+ */
16
+ export declare const PatchPath: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
17
+ kind: z.ZodLiteral<"prop">;
18
+ name: z.ZodString;
19
+ }, z.core.$strip>, z.ZodObject<{
20
+ kind: z.ZodLiteral<"index">;
21
+ index: z.ZodNumber;
22
+ }, z.core.$strip>], "kind">>;
23
+ export type PatchPath = z.infer<typeof PatchPath>;
24
+ /**
25
+ * Patch - A single state modification operation.
26
+ * Only three operations: set, unset, merge.
27
+ */
28
+ export declare const Patch: z.ZodDiscriminatedUnion<[z.ZodObject<{
29
+ op: z.ZodLiteral<"set">;
30
+ path: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
31
+ kind: z.ZodLiteral<"prop">;
32
+ name: z.ZodString;
33
+ }, z.core.$strip>, z.ZodObject<{
34
+ kind: z.ZodLiteral<"index">;
35
+ index: z.ZodNumber;
36
+ }, z.core.$strip>], "kind">>;
37
+ value: z.ZodUnknown;
38
+ }, z.core.$strip>, z.ZodObject<{
39
+ op: z.ZodLiteral<"unset">;
40
+ path: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
41
+ kind: z.ZodLiteral<"prop">;
42
+ name: z.ZodString;
43
+ }, z.core.$strip>, z.ZodObject<{
44
+ kind: z.ZodLiteral<"index">;
45
+ index: z.ZodNumber;
46
+ }, z.core.$strip>], "kind">>;
47
+ }, z.core.$strip>, z.ZodObject<{
48
+ op: z.ZodLiteral<"merge">;
49
+ path: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
50
+ kind: z.ZodLiteral<"prop">;
51
+ name: z.ZodString;
52
+ }, z.core.$strip>, z.ZodObject<{
53
+ kind: z.ZodLiteral<"index">;
54
+ index: z.ZodNumber;
55
+ }, z.core.$strip>], "kind">>;
56
+ value: z.ZodRecord<z.ZodString, z.ZodUnknown>;
57
+ }, z.core.$strip>], "op">;
58
+ export type Patch = z.infer<typeof Patch>;
59
+ /**
60
+ * SetPatch - Set value at path
61
+ */
62
+ export type SetPatch = Extract<Patch, {
63
+ op: "set";
64
+ }>;
65
+ /**
66
+ * UnsetPatch - Remove value at path
67
+ */
68
+ export type UnsetPatch = Extract<Patch, {
69
+ op: "unset";
70
+ }>;
71
+ /**
72
+ * MergePatch - Shallow merge object at path
73
+ */
74
+ export type MergePatch = Extract<Patch, {
75
+ op: "merge";
76
+ }>;
77
+ /**
78
+ * Intent - A request to perform an action
79
+ */
80
+ export declare const Intent: z.ZodObject<{
81
+ type: z.ZodString;
82
+ input: z.ZodOptional<z.ZodUnknown>;
83
+ intentId: z.ZodString;
84
+ }, z.core.$strip>;
85
+ export type Intent = z.infer<typeof Intent>;
86
+ /**
87
+ * Helper to create a prop segment
88
+ */
89
+ export declare function propSegment(name: string): PatchSegment;
90
+ /**
91
+ * Helper to create an index segment
92
+ */
93
+ export declare function indexSegment(index: number): PatchSegment;
94
+ /**
95
+ * Helper to create a set patch
96
+ */
97
+ export declare function setPatch(path: PatchPath, value: unknown): SetPatch;
98
+ /**
99
+ * Helper to create an unset patch
100
+ */
101
+ export declare function unsetPatch(path: PatchPath): UnsetPatch;
102
+ /**
103
+ * Helper to create a merge patch
104
+ */
105
+ export declare function mergePatch(path: PatchPath, value: Record<string, unknown>): MergePatch;
@@ -0,0 +1,175 @@
1
+ import { z } from "zod";
2
+ import { TraceNode } from "./trace.js";
3
+ /**
4
+ * ComputeStatus - Result of a compute() call
5
+ */
6
+ export declare const ComputeStatus: z.ZodEnum<{
7
+ error: "error";
8
+ pending: "pending";
9
+ complete: "complete";
10
+ halted: "halted";
11
+ }>;
12
+ export type ComputeStatus = z.infer<typeof ComputeStatus>;
13
+ /**
14
+ * SystemDelta - Declarative system transition emitted by compute().
15
+ */
16
+ export declare const SystemDelta: z.ZodObject<{
17
+ status: z.ZodOptional<z.ZodEnum<{
18
+ error: "error";
19
+ idle: "idle";
20
+ computing: "computing";
21
+ pending: "pending";
22
+ }>>;
23
+ currentAction: z.ZodOptional<z.ZodNullable<z.ZodString>>;
24
+ lastError: z.ZodOptional<z.ZodNullable<z.ZodObject<{
25
+ code: z.ZodString;
26
+ message: z.ZodString;
27
+ source: z.ZodObject<{
28
+ actionId: z.ZodString;
29
+ nodePath: z.ZodString;
30
+ }, z.core.$strip>;
31
+ timestamp: z.ZodNumber;
32
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
33
+ }, z.core.$strip>>>;
34
+ addRequirements: z.ZodArray<z.ZodObject<{
35
+ id: z.ZodString;
36
+ type: z.ZodString;
37
+ params: z.ZodRecord<z.ZodString, z.ZodUnknown>;
38
+ actionId: z.ZodString;
39
+ flowPosition: z.ZodObject<{
40
+ nodePath: z.ZodString;
41
+ snapshotVersion: z.ZodNumber;
42
+ }, z.core.$strip>;
43
+ createdAt: z.ZodNumber;
44
+ }, z.core.$strip>>;
45
+ removeRequirementIds: z.ZodArray<z.ZodString>;
46
+ }, z.core.$strip>;
47
+ export type SystemDelta = z.infer<typeof SystemDelta>;
48
+ /**
49
+ * ComputeResult - Result of compute() call
50
+ */
51
+ export declare const ComputeResult: z.ZodObject<{
52
+ patches: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
53
+ op: z.ZodLiteral<"set">;
54
+ path: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
55
+ kind: z.ZodLiteral<"prop">;
56
+ name: z.ZodString;
57
+ }, z.core.$strip>, z.ZodObject<{
58
+ kind: z.ZodLiteral<"index">;
59
+ index: z.ZodNumber;
60
+ }, z.core.$strip>], "kind">>;
61
+ value: z.ZodUnknown;
62
+ }, z.core.$strip>, z.ZodObject<{
63
+ op: z.ZodLiteral<"unset">;
64
+ path: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
65
+ kind: z.ZodLiteral<"prop">;
66
+ name: z.ZodString;
67
+ }, z.core.$strip>, z.ZodObject<{
68
+ kind: z.ZodLiteral<"index">;
69
+ index: z.ZodNumber;
70
+ }, z.core.$strip>], "kind">>;
71
+ }, z.core.$strip>, z.ZodObject<{
72
+ op: z.ZodLiteral<"merge">;
73
+ path: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
74
+ kind: z.ZodLiteral<"prop">;
75
+ name: z.ZodString;
76
+ }, z.core.$strip>, z.ZodObject<{
77
+ kind: z.ZodLiteral<"index">;
78
+ index: z.ZodNumber;
79
+ }, z.core.$strip>], "kind">>;
80
+ value: z.ZodRecord<z.ZodString, z.ZodUnknown>;
81
+ }, z.core.$strip>], "op">>;
82
+ systemDelta: z.ZodObject<{
83
+ status: z.ZodOptional<z.ZodEnum<{
84
+ error: "error";
85
+ idle: "idle";
86
+ computing: "computing";
87
+ pending: "pending";
88
+ }>>;
89
+ currentAction: z.ZodOptional<z.ZodNullable<z.ZodString>>;
90
+ lastError: z.ZodOptional<z.ZodNullable<z.ZodObject<{
91
+ code: z.ZodString;
92
+ message: z.ZodString;
93
+ source: z.ZodObject<{
94
+ actionId: z.ZodString;
95
+ nodePath: z.ZodString;
96
+ }, z.core.$strip>;
97
+ timestamp: z.ZodNumber;
98
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
99
+ }, z.core.$strip>>>;
100
+ addRequirements: z.ZodArray<z.ZodObject<{
101
+ id: z.ZodString;
102
+ type: z.ZodString;
103
+ params: z.ZodRecord<z.ZodString, z.ZodUnknown>;
104
+ actionId: z.ZodString;
105
+ flowPosition: z.ZodObject<{
106
+ nodePath: z.ZodString;
107
+ snapshotVersion: z.ZodNumber;
108
+ }, z.core.$strip>;
109
+ createdAt: z.ZodNumber;
110
+ }, z.core.$strip>>;
111
+ removeRequirementIds: z.ZodArray<z.ZodString>;
112
+ }, z.core.$strip>;
113
+ trace: z.ZodObject<{
114
+ root: z.ZodType<TraceNode, unknown, z.core.$ZodTypeInternals<TraceNode, unknown>>;
115
+ nodes: z.ZodRecord<z.ZodString, z.ZodType<TraceNode, unknown, z.core.$ZodTypeInternals<TraceNode, unknown>>>;
116
+ intent: z.ZodObject<{
117
+ type: z.ZodString;
118
+ input: z.ZodUnknown;
119
+ }, z.core.$strip>;
120
+ baseVersion: z.ZodNumber;
121
+ resultVersion: z.ZodNumber;
122
+ duration: z.ZodNumber;
123
+ terminatedBy: z.ZodEnum<{
124
+ error: "error";
125
+ effect: "effect";
126
+ halt: "halt";
127
+ complete: "complete";
128
+ }>;
129
+ }, z.core.$strip>;
130
+ status: z.ZodEnum<{
131
+ error: "error";
132
+ pending: "pending";
133
+ complete: "complete";
134
+ halted: "halted";
135
+ }>;
136
+ }, z.core.$strip>;
137
+ export type ComputeResult = z.infer<typeof ComputeResult>;
138
+ /**
139
+ * ValidationError - Single validation error
140
+ */
141
+ export declare const ValidationError: z.ZodObject<{
142
+ code: z.ZodString;
143
+ message: z.ZodString;
144
+ path: z.ZodOptional<z.ZodString>;
145
+ }, z.core.$strip>;
146
+ export type ValidationError = z.infer<typeof ValidationError>;
147
+ /**
148
+ * ValidationResult - Result of validate() call
149
+ */
150
+ export declare const ValidationResult: z.ZodObject<{
151
+ valid: z.ZodBoolean;
152
+ errors: z.ZodArray<z.ZodObject<{
153
+ code: z.ZodString;
154
+ message: z.ZodString;
155
+ path: z.ZodOptional<z.ZodString>;
156
+ }, z.core.$strip>>;
157
+ }, z.core.$strip>;
158
+ export type ValidationResult = z.infer<typeof ValidationResult>;
159
+ /**
160
+ * ExplainResult - Result of explain() call
161
+ */
162
+ export declare const ExplainResult: z.ZodObject<{
163
+ value: z.ZodUnknown;
164
+ trace: z.ZodType<TraceNode, unknown, z.core.$ZodTypeInternals<TraceNode, unknown>>;
165
+ deps: z.ZodArray<z.ZodString>;
166
+ }, z.core.$strip>;
167
+ export type ExplainResult = z.infer<typeof ExplainResult>;
168
+ /**
169
+ * Create a successful validation result
170
+ */
171
+ export declare function validResult(): ValidationResult;
172
+ /**
173
+ * Create a failed validation result
174
+ */
175
+ export declare function invalidResult(errors: ValidationError[]): ValidationResult;
@@ -0,0 +1,132 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * ErrorValue - Errors are values in Snapshot, not exceptions.
4
+ */
5
+ export declare const ErrorValue: z.ZodObject<{
6
+ code: z.ZodString;
7
+ message: z.ZodString;
8
+ source: z.ZodObject<{
9
+ actionId: z.ZodString;
10
+ nodePath: z.ZodString;
11
+ }, z.core.$strip>;
12
+ timestamp: z.ZodNumber;
13
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
14
+ }, z.core.$strip>;
15
+ export type ErrorValue = z.infer<typeof ErrorValue>;
16
+ /**
17
+ * FlowPosition - Position in the flow where effect was encountered
18
+ */
19
+ export declare const FlowPosition: z.ZodObject<{
20
+ nodePath: z.ZodString;
21
+ snapshotVersion: z.ZodNumber;
22
+ }, z.core.$strip>;
23
+ export type FlowPosition = z.infer<typeof FlowPosition>;
24
+ /**
25
+ * Requirement - A recorded effect declaration waiting for Host fulfillment
26
+ */
27
+ export declare const Requirement: z.ZodObject<{
28
+ id: z.ZodString;
29
+ type: z.ZodString;
30
+ params: z.ZodRecord<z.ZodString, z.ZodUnknown>;
31
+ actionId: z.ZodString;
32
+ flowPosition: z.ZodObject<{
33
+ nodePath: z.ZodString;
34
+ snapshotVersion: z.ZodNumber;
35
+ }, z.core.$strip>;
36
+ createdAt: z.ZodNumber;
37
+ }, z.core.$strip>;
38
+ export type Requirement = z.infer<typeof Requirement>;
39
+ /**
40
+ * SystemState - Internal system state
41
+ */
42
+ export declare const SystemState: z.ZodObject<{
43
+ status: z.ZodEnum<{
44
+ error: "error";
45
+ idle: "idle";
46
+ computing: "computing";
47
+ pending: "pending";
48
+ }>;
49
+ lastError: z.ZodNullable<z.ZodObject<{
50
+ code: z.ZodString;
51
+ message: z.ZodString;
52
+ source: z.ZodObject<{
53
+ actionId: z.ZodString;
54
+ nodePath: z.ZodString;
55
+ }, z.core.$strip>;
56
+ timestamp: z.ZodNumber;
57
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
58
+ }, z.core.$strip>>;
59
+ pendingRequirements: z.ZodArray<z.ZodObject<{
60
+ id: z.ZodString;
61
+ type: z.ZodString;
62
+ params: z.ZodRecord<z.ZodString, z.ZodUnknown>;
63
+ actionId: z.ZodString;
64
+ flowPosition: z.ZodObject<{
65
+ nodePath: z.ZodString;
66
+ snapshotVersion: z.ZodNumber;
67
+ }, z.core.$strip>;
68
+ createdAt: z.ZodNumber;
69
+ }, z.core.$strip>>;
70
+ currentAction: z.ZodNullable<z.ZodString>;
71
+ }, z.core.$strip>;
72
+ export type SystemState = z.infer<typeof SystemState>;
73
+ /**
74
+ * SnapshotMeta - Snapshot metadata
75
+ */
76
+ export declare const SnapshotMeta: z.ZodObject<{
77
+ version: z.ZodNumber;
78
+ timestamp: z.ZodNumber;
79
+ randomSeed: z.ZodString;
80
+ schemaHash: z.ZodString;
81
+ }, z.core.$strip>;
82
+ export type SnapshotMeta = z.infer<typeof SnapshotMeta>;
83
+ /**
84
+ * Snapshot - Immutable, point-in-time representation of world state.
85
+ * This is the ONLY medium of communication between Core and Host.
86
+ */
87
+ export declare const Snapshot: z.ZodObject<{
88
+ data: z.ZodUnknown;
89
+ computed: z.ZodRecord<z.ZodString, z.ZodUnknown>;
90
+ system: z.ZodObject<{
91
+ status: z.ZodEnum<{
92
+ error: "error";
93
+ idle: "idle";
94
+ computing: "computing";
95
+ pending: "pending";
96
+ }>;
97
+ lastError: z.ZodNullable<z.ZodObject<{
98
+ code: z.ZodString;
99
+ message: z.ZodString;
100
+ source: z.ZodObject<{
101
+ actionId: z.ZodString;
102
+ nodePath: z.ZodString;
103
+ }, z.core.$strip>;
104
+ timestamp: z.ZodNumber;
105
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
106
+ }, z.core.$strip>>;
107
+ pendingRequirements: z.ZodArray<z.ZodObject<{
108
+ id: z.ZodString;
109
+ type: z.ZodString;
110
+ params: z.ZodRecord<z.ZodString, z.ZodUnknown>;
111
+ actionId: z.ZodString;
112
+ flowPosition: z.ZodObject<{
113
+ nodePath: z.ZodString;
114
+ snapshotVersion: z.ZodNumber;
115
+ }, z.core.$strip>;
116
+ createdAt: z.ZodNumber;
117
+ }, z.core.$strip>>;
118
+ currentAction: z.ZodNullable<z.ZodString>;
119
+ }, z.core.$strip>;
120
+ input: z.ZodUnknown;
121
+ meta: z.ZodObject<{
122
+ version: z.ZodNumber;
123
+ timestamp: z.ZodNumber;
124
+ randomSeed: z.ZodString;
125
+ schemaHash: z.ZodString;
126
+ }, z.core.$strip>;
127
+ }, z.core.$strip>;
128
+ export type Snapshot = z.infer<typeof Snapshot>;
129
+ /**
130
+ * Create initial system state
131
+ */
132
+ export declare function createInitialSystemState(): SystemState;
@@ -0,0 +1,97 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * TraceNodeKind - Types of trace nodes
4
+ */
5
+ export declare const TraceNodeKind: z.ZodEnum<{
6
+ error: "error";
7
+ computed: "computed";
8
+ expr: "expr";
9
+ patch: "patch";
10
+ effect: "effect";
11
+ call: "call";
12
+ flow: "flow";
13
+ halt: "halt";
14
+ branch: "branch";
15
+ }>;
16
+ export type TraceNodeKind = z.infer<typeof TraceNodeKind>;
17
+ /**
18
+ * TraceNode - A single node in the execution trace.
19
+ * Enables explainability - every computation produces a trace.
20
+ */
21
+ export type TraceNode = {
22
+ /**
23
+ * Unique identifier for this trace node
24
+ */
25
+ id: string;
26
+ /**
27
+ * Type of trace node
28
+ */
29
+ kind: TraceNodeKind;
30
+ /**
31
+ * Path in the schema that produced this trace
32
+ */
33
+ sourcePath: string;
34
+ /**
35
+ * Input values at this point
36
+ */
37
+ inputs: Record<string, unknown>;
38
+ /**
39
+ * Output value produced
40
+ */
41
+ output: unknown;
42
+ /**
43
+ * Child trace nodes
44
+ */
45
+ children: TraceNode[];
46
+ /**
47
+ * Timestamp
48
+ */
49
+ timestamp: number;
50
+ };
51
+ export declare const TraceNode: z.ZodType<TraceNode>;
52
+ /**
53
+ * TraceTermination - How the computation ended
54
+ */
55
+ export declare const TraceTermination: z.ZodEnum<{
56
+ error: "error";
57
+ effect: "effect";
58
+ halt: "halt";
59
+ complete: "complete";
60
+ }>;
61
+ export type TraceTermination = z.infer<typeof TraceTermination>;
62
+ /**
63
+ * TraceGraph - Complete trace of a computation
64
+ */
65
+ export declare const TraceGraph: z.ZodObject<{
66
+ root: z.ZodType<TraceNode, unknown, z.core.$ZodTypeInternals<TraceNode, unknown>>;
67
+ nodes: z.ZodRecord<z.ZodString, z.ZodType<TraceNode, unknown, z.core.$ZodTypeInternals<TraceNode, unknown>>>;
68
+ intent: z.ZodObject<{
69
+ type: z.ZodString;
70
+ input: z.ZodUnknown;
71
+ }, z.core.$strip>;
72
+ baseVersion: z.ZodNumber;
73
+ resultVersion: z.ZodNumber;
74
+ duration: z.ZodNumber;
75
+ terminatedBy: z.ZodEnum<{
76
+ error: "error";
77
+ effect: "effect";
78
+ halt: "halt";
79
+ complete: "complete";
80
+ }>;
81
+ }, z.core.$strip>;
82
+ export type TraceGraph = z.infer<typeof TraceGraph>;
83
+ /**
84
+ * TraceContext - Deterministic trace ID generation
85
+ */
86
+ export type TraceContext = {
87
+ readonly nextId: () => string;
88
+ readonly timestamp: number;
89
+ };
90
+ /**
91
+ * Create a trace context for a single compute pass
92
+ */
93
+ export declare function createTraceContext(timestamp: number): TraceContext;
94
+ /**
95
+ * Create a trace node
96
+ */
97
+ export declare function createTraceNode(trace: TraceContext, kind: TraceNodeKind, sourcePath: string, inputs: Record<string, unknown>, output: unknown, children?: TraceNode[]): TraceNode;
@@ -0,0 +1,33 @@
1
+ import { z } from "zod";
2
+ export type TypeDefinition = {
3
+ kind: "primitive";
4
+ type: string;
5
+ } | {
6
+ kind: "array";
7
+ element: TypeDefinition;
8
+ } | {
9
+ kind: "record";
10
+ key: TypeDefinition;
11
+ value: TypeDefinition;
12
+ } | {
13
+ kind: "object";
14
+ fields: Record<string, {
15
+ type: TypeDefinition;
16
+ optional: boolean;
17
+ }>;
18
+ } | {
19
+ kind: "union";
20
+ types: TypeDefinition[];
21
+ } | {
22
+ kind: "literal";
23
+ value: string | number | boolean | null;
24
+ } | {
25
+ kind: "ref";
26
+ name: string;
27
+ };
28
+ export declare const TypeDefinition: z.ZodType<TypeDefinition>;
29
+ export declare const TypeSpec: z.ZodObject<{
30
+ name: z.ZodString;
31
+ definition: z.ZodType<TypeDefinition, unknown, z.core.$ZodTypeInternals<TypeDefinition, unknown>>;
32
+ }, z.core.$strip>;
33
+ export type TypeSpec = z.infer<typeof TypeSpec>;