@toolproof-core/genesis 1.0.47

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 (112) hide show
  1. package/dist/src/utils/constantsAndMappings.d.ts +20 -0
  2. package/dist/src/utils/constantsAndMappings.js +155 -0
  3. package/dist/src/utils/coreProjection.d.ts +16 -0
  4. package/dist/src/utils/coreProjection.js +29 -0
  5. package/dist/src/utils/resourceTypes.d.ts +12 -0
  6. package/dist/src/utils/resourceTypes.js +17 -0
  7. package/dist/src/utils/resources.d.ts +5 -0
  8. package/dist/src/utils/resources.js +17 -0
  9. package/dist/src/utils/schemaDependencies.d.ts +13 -0
  10. package/dist/src/utils/schemaDependencies.js +94 -0
  11. package/dist/src/utils/schemaObjectNormalization.d.ts +1 -0
  12. package/dist/src/utils/schemaObjectNormalization.js +66 -0
  13. package/dist/src/utils/schemaRefNormalization.d.ts +2 -0
  14. package/dist/src/utils/schemaRefNormalization.js +76 -0
  15. package/dist/src/utils/schemaShims.d.ts +2 -0
  16. package/dist/src/utils/schemaShims.js +13 -0
  17. package/dist/src/utils/standaloneSchemas.d.ts +16 -0
  18. package/dist/src/utils/standaloneSchemas.js +101 -0
  19. package/dist/src/utils/standaloneTypes.d.ts +8 -0
  20. package/dist/src/utils/standaloneTypes.js +22 -0
  21. package/dist/src/utils/standaloneZodSchemas.d.ts +8 -0
  22. package/dist/src/utils/standaloneZodSchemas.js +53 -0
  23. package/dist/src/utils/typeGeneration.d.ts +1 -0
  24. package/dist/src/utils/typeGeneration.js +25 -0
  25. package/dist/src/utils/typeGenerationPostProcess.d.ts +2 -0
  26. package/dist/src/utils/typeGenerationPostProcess.js +166 -0
  27. package/dist/src/utils/typeGenerationPreflight.d.ts +2 -0
  28. package/dist/src/utils/typeGenerationPreflight.js +93 -0
  29. package/dist/src/utils/zodCodegen.d.ts +10 -0
  30. package/dist/src/utils/zodCodegen.js +521 -0
  31. package/generated-src/derived/constants.ts +130 -0
  32. package/generated-src/derived/mappings.ts +12 -0
  33. package/generated-src/metadata/Core.json +1919 -0
  34. package/generated-src/metadata/dependencyMap.json +283 -0
  35. package/generated-src/metadata/terminals.json +17 -0
  36. package/generated-src/resourceTypes/resourceTypes.json +375 -0
  37. package/generated-src/resourceTypes/resourceTypes.ts +2 -0
  38. package/generated-src/resources/resourceTypes.json +456 -0
  39. package/generated-src/resources/resourceTypes.ts +2 -0
  40. package/generated-src/schemas/schemas.json +1670 -0
  41. package/generated-src/schemas/schemas.ts +2 -0
  42. package/generated-src/schemas/standalone/Boolean.json +5 -0
  43. package/generated-src/schemas/standalone/Boolean.ts +2 -0
  44. package/generated-src/schemas/standalone/Error.json +78 -0
  45. package/generated-src/schemas/standalone/Error.ts +2 -0
  46. package/generated-src/schemas/standalone/Goal.json +53 -0
  47. package/generated-src/schemas/standalone/Goal.ts +2 -0
  48. package/generated-src/schemas/standalone/Natural.json +6 -0
  49. package/generated-src/schemas/standalone/Natural.ts +2 -0
  50. package/generated-src/schemas/standalone/Resource.json +170 -0
  51. package/generated-src/schemas/standalone/Resource.ts +2 -0
  52. package/generated-src/schemas/standalone/ResourceType.json +131 -0
  53. package/generated-src/schemas/standalone/ResourceType.ts +2 -0
  54. package/generated-src/schemas/standalone/Strategy.json +641 -0
  55. package/generated-src/schemas/standalone/Strategy.ts +2 -0
  56. package/generated-src/schemas/standalone/StrategyTrace.json +820 -0
  57. package/generated-src/schemas/standalone/StrategyTrace.ts +2 -0
  58. package/generated-src/schemas/standalone/Tool.json +508 -0
  59. package/generated-src/schemas/standalone/Tool.ts +2 -0
  60. package/generated-src/schemas/zod/Boolean.ts +6 -0
  61. package/generated-src/schemas/zod/Error.ts +11 -0
  62. package/generated-src/schemas/zod/Goal.ts +8 -0
  63. package/generated-src/schemas/zod/Natural.ts +6 -0
  64. package/generated-src/schemas/zod/Resource.ts +21 -0
  65. package/generated-src/schemas/zod/ResourceType.ts +14 -0
  66. package/generated-src/schemas/zod/Strategy.ts +68 -0
  67. package/generated-src/schemas/zod/StrategyTrace.ts +75 -0
  68. package/generated-src/schemas/zod/Tool.ts +29 -0
  69. package/generated-src/schemas/zod/index.ts +10 -0
  70. package/generated-src/types/standalone/BooleanResource.d.ts +3 -0
  71. package/generated-src/types/standalone/BooleanResource.js +1 -0
  72. package/generated-src/types/standalone/ErrorResource.d.ts +3 -0
  73. package/generated-src/types/standalone/ErrorResource.js +1 -0
  74. package/generated-src/types/standalone/GoalResource.d.ts +3 -0
  75. package/generated-src/types/standalone/GoalResource.js +1 -0
  76. package/generated-src/types/standalone/NaturalResource.d.ts +3 -0
  77. package/generated-src/types/standalone/NaturalResource.js +1 -0
  78. package/generated-src/types/standalone/ResourceResource.d.ts +3 -0
  79. package/generated-src/types/standalone/ResourceResource.js +1 -0
  80. package/generated-src/types/standalone/ResourceTypeResource.d.ts +3 -0
  81. package/generated-src/types/standalone/ResourceTypeResource.js +1 -0
  82. package/generated-src/types/standalone/StrategyResource.d.ts +3 -0
  83. package/generated-src/types/standalone/StrategyResource.js +1 -0
  84. package/generated-src/types/standalone/StrategyTraceResource.d.ts +3 -0
  85. package/generated-src/types/standalone/StrategyTraceResource.js +1 -0
  86. package/generated-src/types/standalone/ToolResource.d.ts +3 -0
  87. package/generated-src/types/standalone/ToolResource.js +1 -0
  88. package/generated-src/types/types.d.ts +701 -0
  89. package/generated-src/types/types.js +1 -0
  90. package/package.json +52 -0
  91. package/src/genesis/resourceTypeShells.json +47 -0
  92. package/src/genesis/resources/booleans.json +24 -0
  93. package/src/genesis/resources/implementations/foo.ts +182 -0
  94. package/src/genesis/resources/naturals.json +112 -0
  95. package/src/genesis/resources/tools.json +840 -0
  96. package/src/genesis/schemas.json +1670 -0
  97. package/src/index.ts +27 -0
  98. package/src/utils/constantsAndMappings.ts +195 -0
  99. package/src/utils/coreProjection.ts +53 -0
  100. package/src/utils/resourceTypes.ts +39 -0
  101. package/src/utils/resources.ts +26 -0
  102. package/src/utils/schemaDependencies.ts +115 -0
  103. package/src/utils/schemaObjectNormalization.ts +71 -0
  104. package/src/utils/schemaRefNormalization.ts +83 -0
  105. package/src/utils/schemaShims.ts +17 -0
  106. package/src/utils/standaloneSchemas.ts +114 -0
  107. package/src/utils/standaloneTypes.ts +28 -0
  108. package/src/utils/standaloneZodSchemas.ts +72 -0
  109. package/src/utils/typeGeneration.ts +31 -0
  110. package/src/utils/typeGenerationPostProcess.ts +246 -0
  111. package/src/utils/typeGenerationPreflight.ts +119 -0
  112. package/src/utils/zodCodegen.ts +549 -0
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@toolproof-core/genesis",
3
+ "version": "1.0.47",
4
+ "description": "JSON schemas and TypeScript types for ToolProof",
5
+ "main": "dist/src/index.js",
6
+ "types": "dist/src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/src/index.js",
10
+ "types": "./dist/src/index.d.ts"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist/src",
15
+ "src",
16
+ "generated-src"
17
+ ],
18
+ "type": "module",
19
+ "keywords": [],
20
+ "author": "",
21
+ "license": "ISC",
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "dependencies": {
26
+ "zod": "^4.3.6"
27
+ },
28
+ "devDependencies": {
29
+ "@types/node": "^20.8.1",
30
+ "json-schema-to-typescript": "^15.0.4",
31
+ "rimraf": "^5.0.0",
32
+ "typescript": "^5.9.3"
33
+ },
34
+ "scripts": {
35
+ "test": "echo \"Error: no test specified\" && exit 1",
36
+ "build": "tsc -b",
37
+ "build:scripts": "tsc -p tsconfig.scripts.json",
38
+ "normalizeAnchorsToPointers": "node ./dist/scripts/normalizeAnchorsToPointers.js",
39
+ "generateConstantsAndMappings": "node ./dist/scripts/generateConstantsAndMappings.js",
40
+ "generateDependencies": "node ./dist/scripts/generateDependencies.js",
41
+ "generateTerminals": "node ./dist/scripts/generateTerminals.js",
42
+ "generateCoreProjection": "node ./dist/scripts/generateCoreProjection.js",
43
+ "generateResourceTypes": "node ./dist/scripts/generateResourceTypes.js",
44
+ "generateResources": "node ./dist/scripts/generateResources.js",
45
+ "generateSchemaShims": "node ./dist/scripts/generateSchemaShims.js",
46
+ "generateStandaloneSchemas": "node ./dist/scripts/generateStandaloneSchemas.js",
47
+ "generateStandaloneZodSchemas": "node ./dist/scripts/generateStandaloneZodSchemas.js",
48
+ "generateTypes": "node ./dist/scripts/generateTypes.js",
49
+ "generateStandaloneTypes": "node ./dist/scripts/generateStandaloneTypes.js",
50
+ "update": "rimraf dist generated-src tsconfig.tsbuildinfo && pnpm run build:scripts && pnpm run normalizeAnchorsToPointers && pnpm run generateConstantsAndMappings && pnpm run generateStandaloneSchemas && pnpm run generateStandaloneZodSchemas && pnpm run generateResourceTypes && pnpm run generateResources && pnpm run generateSchemaShims && pnpm run generateTypes && pnpm run generateStandaloneTypes && pnpm run generateDependencies && pnpm run generateTerminals && pnpm run generateCoreProjection"
51
+ }
52
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "ResourceType": {
3
+ "handle": "TYPE-RESOURCE-TYPE",
4
+ "name": "ResourceType",
5
+ "description": ""
6
+ },
7
+ "Tool": {
8
+ "handle": "TYPE-TOOL",
9
+ "name": "Tool",
10
+ "description": ""
11
+ },
12
+ "Strategy": {
13
+ "handle": "TYPE-STRATEGY",
14
+ "name": "Strategy",
15
+ "description": ""
16
+ },
17
+ "StrategyTrace": {
18
+ "handle": "TYPE-STRATEGY_TRACE",
19
+ "name": "StrategyTrace",
20
+ "description": ""
21
+ },
22
+ "Goal": {
23
+ "handle": "TYPE-GOAL",
24
+ "name": "Goal",
25
+ "description": ""
26
+ },
27
+ "Error": {
28
+ "handle": "TYPE-ERROR",
29
+ "name": "Error",
30
+ "description": ""
31
+ },
32
+ "Boolean": {
33
+ "handle": "TYPE-BOOLEAN",
34
+ "name": "Boolean",
35
+ "description": ""
36
+ },
37
+ "Natural": {
38
+ "handle": "TYPE-NATURAL",
39
+ "name": "Natural",
40
+ "description": ""
41
+ },
42
+ "Resource": {
43
+ "handle": "TYPE-RESOURCE",
44
+ "name": "Resource",
45
+ "description": ""
46
+ }
47
+ }
@@ -0,0 +1,24 @@
1
+ [
2
+ {
3
+ "id": "RESOURCE-False",
4
+ "resourceTypeHandle": "TYPE-Boolean",
5
+ "provenance": {
6
+ "resourceProvenanceKind": "genesis"
7
+ },
8
+ "version": 1,
9
+
10
+ "timestamp": "2025-11-30T00:00:00.000Z",
11
+ "value": false
12
+ },
13
+ {
14
+ "id": "RESOURCE-True",
15
+ "resourceTypeHandle": "TYPE-Boolean",
16
+ "provenance": {
17
+ "resourceProvenanceKind": "genesis"
18
+ },
19
+ "version": 1,
20
+
21
+ "timestamp": "2025-11-30T00:00:00.000Z",
22
+ "value": true
23
+ }
24
+ ]
@@ -0,0 +1,182 @@
1
+ import type { Resource } from '@toolproof-core/genesis';
2
+ import { createMaterializedFromPotential } from '@toolproof-core/lib/create-resource';
3
+
4
+ function extractNaturalValue(resource: Resource): number {
5
+ const value: unknown = resource.value;
6
+ if (typeof value === 'number' && Number.isInteger(value) && value >= 0) {
7
+ return value;
8
+ }
9
+ throw new Error(`Invalid Natural resource: value must be a non-negative integer`);
10
+ }
11
+
12
+ function createMockOutput(potentialOutput: any, value: number): Resource {
13
+ const mockPath = `mock://natural/${value}`;
14
+
15
+ const materialized = createMaterializedFromPotential(potentialOutput, value);
16
+
17
+ return {
18
+ ...materialized,
19
+ path: mockPath,
20
+ };
21
+ }
22
+
23
+ function createMockErrorOutput(
24
+ potentialOutput: any,
25
+ name: string,
26
+ description: string,
27
+ details?: Record<string, unknown>
28
+ ): Resource {
29
+ const value: unknown = {
30
+ name,
31
+ description,
32
+ ...(details ? { details } : {}),
33
+ };
34
+
35
+ const mockPath = `mock://error/${encodeURIComponent(name)}`;
36
+
37
+ const materialized = createMaterializedFromPotential(potentialOutput, value);
38
+
39
+ return {
40
+ ...materialized,
41
+ path: mockPath,
42
+ };
43
+ }
44
+
45
+ export function mockAdd(inputs: Record<string, Resource | any>): Record<string, Resource> {
46
+ const addendOne = inputs['AddendOne'] as Resource;
47
+ const addendTwo = inputs['AddendTwo'] as Resource;
48
+ const sumOutput = inputs['Sum'] as any;
49
+
50
+ const value1 = extractNaturalValue(addendOne);
51
+ const value2 = extractNaturalValue(addendTwo);
52
+ const result = value1 + value2;
53
+
54
+ return {
55
+ Sum: createMockOutput(sumOutput, result),
56
+ };
57
+ }
58
+
59
+ export function mockSubtract(inputs: Record<string, Resource | any>): Record<string, Resource> {
60
+ const minuend = inputs['Minuend'] as Resource;
61
+ const subtrahend = inputs['Subtrahend'] as Resource;
62
+ const differenceOutput = inputs['Difference'] as any;
63
+
64
+ const errorOutput = inputs['ErrorOutput'] as any | undefined;
65
+
66
+ const value1 = extractNaturalValue(minuend);
67
+ const value2 = extractNaturalValue(subtrahend);
68
+
69
+ if (value2 > value1) {
70
+ if (!errorOutput) {
71
+ throw new Error(
72
+ `Subtract mock tool cannot emit error: missing 'ErrorOutput' potential output (subtrahend ${value2} > minuend ${value1})`
73
+ );
74
+ }
75
+
76
+ return {
77
+ ErrorOutput: createMockErrorOutput(
78
+ errorOutput,
79
+ 'SubtractInvalidInput',
80
+ `Subtrahend (${value2}) is larger than minuend (${value1}); subtraction would result in a negative value.`,
81
+ {
82
+ minuend: value1,
83
+ subtrahend: value2,
84
+ }
85
+ ),
86
+ };
87
+ }
88
+
89
+ const result = value1 - value2;
90
+
91
+ return {
92
+ Difference: createMockOutput(differenceOutput, result),
93
+ };
94
+ }
95
+
96
+ export function mockMultiply(inputs: Record<string, Resource | any>): Record<string, Resource> {
97
+ const multiplicand = inputs['Multiplicand'] as Resource;
98
+ const multiplier = inputs['Multiplier'] as Resource;
99
+ const productOutput = inputs['Product'] as any;
100
+
101
+ const value1 = extractNaturalValue(multiplicand);
102
+ const value2 = extractNaturalValue(multiplier);
103
+ const result = value1 * value2;
104
+
105
+ return {
106
+ Product: createMockOutput(productOutput, result),
107
+ };
108
+ }
109
+
110
+ export function mockDouble(inputs: Record<string, Resource | any>): Record<string, Resource> {
111
+ const N = inputs['N'] as Resource;
112
+ const DoubledOutput = inputs['Doubled'] as any;
113
+
114
+ const value = extractNaturalValue(N);
115
+ const result = value * 2;
116
+
117
+ return {
118
+ Doubled: createMockOutput(DoubledOutput, result),
119
+ };
120
+ }
121
+
122
+ export function mockDivide(inputs: Record<string, Resource | any>): Record<string, Resource> {
123
+ const dividend = inputs['Dividend'] as Resource;
124
+ const divisor = inputs['Divisor'] as Resource;
125
+ const quotientOutput = inputs['Quotient'] as any;
126
+ const remainderOutput = inputs['Remainder'] as any;
127
+
128
+ const errorOutput = inputs['ErrorOutput'] as any | undefined;
129
+
130
+ const value1 = extractNaturalValue(dividend);
131
+ const value2 = extractNaturalValue(divisor);
132
+
133
+ if (value2 === 0) {
134
+ if (!errorOutput) {
135
+ throw new Error(
136
+ `Divide mock tool cannot emit error: missing 'ErrorOutput' potential output (division by zero; dividend ${value1})`
137
+ );
138
+ }
139
+
140
+ return {
141
+ ErrorOutput: createMockErrorOutput(
142
+ errorOutput,
143
+ 'DivideByZero',
144
+ `Cannot divide by zero (dividend ${value1}, divisor ${value2}).`,
145
+ {
146
+ dividend: value1,
147
+ divisor: value2,
148
+ }
149
+ ),
150
+ };
151
+ }
152
+
153
+ const quotient = Math.floor(value1 / value2);
154
+ const remainder = value1 % value2;
155
+
156
+ return {
157
+ Quotient: createMockOutput(quotientOutput, quotient),
158
+ Remainder: createMockOutput(remainderOutput, remainder),
159
+ };
160
+ }
161
+
162
+ export function executeMockNumericalTool(
163
+ toolName: string,
164
+ payload: Record<string, Resource | any>
165
+ ): Record<string, Resource> {
166
+ const normalizedName = toolName.toLowerCase();
167
+
168
+ switch (normalizedName) {
169
+ case 'add':
170
+ return mockAdd(payload);
171
+ case 'subtract':
172
+ return mockSubtract(payload);
173
+ case 'multiply':
174
+ return mockMultiply(payload);
175
+ case 'double':
176
+ return mockDouble(payload);
177
+ case 'divide':
178
+ return mockDivide(payload);
179
+ default:
180
+ throw new Error(`Unknown numerical tool: ${toolName}`);
181
+ }
182
+ }
@@ -0,0 +1,112 @@
1
+ [
2
+ {
3
+ "id": "RESOURCE-0",
4
+ "resourceTypeHandle": "TYPE-Natural",
5
+ "provenance": {
6
+ "resourceProvenanceKind": "genesis"
7
+ },
8
+ "version": 1,
9
+ "timestamp": "2025-11-30T00:00:00.000Z",
10
+ "value": 0
11
+ },
12
+ {
13
+ "id": "RESOURCE-1",
14
+ "resourceTypeHandle": "TYPE-Natural",
15
+ "provenance": {
16
+ "resourceProvenanceKind": "genesis"
17
+ },
18
+ "version": 1,
19
+ "timestamp": "2025-11-30T00:00:00.000Z",
20
+ "value": 1
21
+ },
22
+ {
23
+ "id": "RESOURCE-2",
24
+ "resourceTypeHandle": "TYPE-Natural",
25
+ "provenance": {
26
+ "resourceProvenanceKind": "genesis"
27
+ },
28
+ "version": 1,
29
+ "timestamp": "2025-11-30T00:00:00.000Z",
30
+ "value": 2
31
+ },
32
+ {
33
+ "id": "RESOURCE-3",
34
+ "resourceTypeHandle": "TYPE-Natural",
35
+ "provenance": {
36
+ "resourceProvenanceKind": "genesis"
37
+ },
38
+ "version": 1,
39
+ "timestamp": "2025-11-30T00:00:00.000Z",
40
+ "value": 3
41
+ },
42
+ {
43
+ "id": "RESOURCE-4",
44
+ "resourceTypeHandle": "TYPE-Natural",
45
+ "provenance": {
46
+ "resourceProvenanceKind": "genesis"
47
+ },
48
+ "version": 1,
49
+ "timestamp": "2025-11-30T00:00:00.000Z",
50
+ "value": 4
51
+ },
52
+ {
53
+ "id": "RESOURCE-5",
54
+ "resourceTypeHandle": "TYPE-Natural",
55
+ "provenance": {
56
+ "resourceProvenanceKind": "genesis"
57
+ },
58
+ "version": 1,
59
+ "timestamp": "2025-11-30T00:00:00.000Z",
60
+ "value": 5
61
+ },
62
+ {
63
+ "id": "RESOURCE-6",
64
+ "resourceTypeHandle": "TYPE-Natural",
65
+ "provenance": {
66
+ "resourceProvenanceKind": "genesis"
67
+ },
68
+ "version": 1,
69
+ "timestamp": "2025-11-30T00:00:00.000Z",
70
+ "value": 6
71
+ },
72
+ {
73
+ "id": "RESOURCE-7",
74
+ "resourceTypeHandle": "TYPE-Natural",
75
+ "provenance": {
76
+ "resourceProvenanceKind": "genesis"
77
+ },
78
+ "version": 1,
79
+ "timestamp": "2025-11-30T00:00:00.000Z",
80
+ "value": 7
81
+ },
82
+ {
83
+ "id": "RESOURCE-8",
84
+ "resourceTypeHandle": "TYPE-Natural",
85
+ "provenance": {
86
+ "resourceProvenanceKind": "genesis"
87
+ },
88
+ "version": 1,
89
+ "timestamp": "2025-11-30T00:00:00.000Z",
90
+ "value": 8
91
+ },
92
+ {
93
+ "id": "RESOURCE-9",
94
+ "resourceTypeHandle": "TYPE-Natural",
95
+ "provenance": {
96
+ "resourceProvenanceKind": "genesis"
97
+ },
98
+ "version": 1,
99
+ "timestamp": "2025-11-30T00:00:00.000Z",
100
+ "value": 9
101
+ },
102
+ {
103
+ "id": "RESOURCE-100",
104
+ "resourceTypeHandle": "TYPE-Natural",
105
+ "provenance": {
106
+ "resourceProvenanceKind": "genesis"
107
+ },
108
+ "version": 1,
109
+ "timestamp": "2025-11-30T00:00:00.000Z",
110
+ "value": 100
111
+ }
112
+ ]