@toolproof-core/genesis 1.0.48 → 1.0.50

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 (93) hide show
  1. package/dist/src/implementations/tools.d.ts +100 -0
  2. package/dist/src/implementations/tools.js +135 -0
  3. package/dist/src/index.d.ts +9 -8
  4. package/dist/src/index.js +4 -3
  5. package/dist/src/utils/resourceTypes.d.ts +2 -1
  6. package/dist/src/utils/resourceTypes.js +22 -6
  7. package/dist/src/utils/schemaRefNormalization.js +3 -3
  8. package/dist/src/utils/standaloneTypes.js +2 -2
  9. package/dist/src/utils/timestampedResources.d.ts +16 -0
  10. package/dist/src/utils/timestampedResources.js +17 -0
  11. package/dist/src/utils/typeGenerationPostProcess.js +2 -2
  12. package/dist/src/utils/zodCodegen.js +3 -3
  13. package/generated-src/declarations/booleans.json +4 -0
  14. package/generated-src/declarations/booleans.ts +2 -0
  15. package/generated-src/declarations/naturals.json +13 -0
  16. package/generated-src/declarations/naturals.ts +2 -0
  17. package/generated-src/{resourceTypes → declarations}/resourceTypes.json +176 -39
  18. package/generated-src/declarations/resourceTypes.ts +2 -0
  19. package/generated-src/declarations/tools.json +705 -0
  20. package/generated-src/declarations/tools.ts +2 -0
  21. package/generated-src/implementations/tools.ts +214 -0
  22. package/generated-src/{derived → lookups}/constants.ts +4 -5
  23. package/generated-src/metadata/Core.json +51 -114
  24. package/generated-src/metadata/dependencyMap.json +16 -2
  25. package/generated-src/metadata/terminals.json +3 -4
  26. package/generated-src/schemas/schemas.json +198 -29
  27. package/generated-src/schemas/standalone/Resource.json +4 -8
  28. package/generated-src/schemas/standalone/ResourceType.json +21 -5
  29. package/generated-src/schemas/standalone/Strategy.json +4 -8
  30. package/generated-src/schemas/standalone/StrategyTrace.json +4 -8
  31. package/generated-src/schemas/standalone/Suite.json +646 -0
  32. package/generated-src/schemas/standalone/Suite.ts +2 -0
  33. package/generated-src/schemas/standalone/Tool.json +48 -23
  34. package/generated-src/schemas/zod/Resource.ts +2 -2
  35. package/generated-src/schemas/zod/ResourceType.ts +1 -1
  36. package/generated-src/schemas/zod/Strategy.ts +3 -3
  37. package/generated-src/schemas/zod/StrategyTrace.ts +3 -3
  38. package/generated-src/schemas/zod/Suite.ts +44 -0
  39. package/generated-src/schemas/zod/Tool.ts +7 -2
  40. package/generated-src/schemas/zod/index.ts +1 -0
  41. package/{src/genesis/resources → generated-src/timestampedResources}/booleans.json +19 -23
  42. package/generated-src/timestampedResources/booleans.ts +2 -0
  43. package/{src/genesis/resources → generated-src/timestampedResources}/naturals.json +100 -111
  44. package/generated-src/timestampedResources/naturals.ts +2 -0
  45. package/generated-src/{resources → timestampedResources}/resourceTypes.json +202 -66
  46. package/generated-src/timestampedResources/resourceTypes.ts +2 -0
  47. package/{src/genesis/resources → generated-src/timestampedResources}/tools.json +824 -839
  48. package/generated-src/timestampedResources/tools.ts +2 -0
  49. package/generated-src/types/standalone/BooleanResource.d.ts +2 -2
  50. package/generated-src/types/standalone/ErrorResource.d.ts +2 -2
  51. package/generated-src/types/standalone/GoalResource.d.ts +2 -2
  52. package/generated-src/types/standalone/NaturalResource.d.ts +2 -2
  53. package/generated-src/types/standalone/ResourceResource.d.ts +2 -2
  54. package/generated-src/types/standalone/ResourceTypeResource.d.ts +2 -2
  55. package/generated-src/types/standalone/StrategyResource.d.ts +2 -2
  56. package/generated-src/types/standalone/StrategyTraceResource.d.ts +2 -2
  57. package/generated-src/types/standalone/SuiteResource.d.ts +3 -0
  58. package/generated-src/types/standalone/SuiteResource.js +1 -0
  59. package/generated-src/types/standalone/ToolResource.d.ts +2 -2
  60. package/generated-src/types/types.d.ts +57 -14
  61. package/package.json +18 -13
  62. package/src/declarations/booleans.json +4 -0
  63. package/src/declarations/naturals.json +13 -0
  64. package/src/{genesis → declarations/resourceTypes}/resourceTypeShells.json +52 -46
  65. package/src/{genesis → declarations/resourceTypes}/schemas.json +1838 -1669
  66. package/src/declarations/tools.json +705 -0
  67. package/src/implementations/tools.ts +214 -0
  68. package/src/index.ts +131 -27
  69. package/src/utils/constantsAndMappings.ts +194 -194
  70. package/src/utils/coreProjection.ts +52 -52
  71. package/src/utils/resourceTypes.ts +70 -38
  72. package/src/utils/schemaDependencies.ts +114 -114
  73. package/src/utils/schemaObjectNormalization.ts +70 -70
  74. package/src/utils/schemaRefNormalization.ts +82 -82
  75. package/src/utils/schemaShims.ts +16 -16
  76. package/src/utils/standaloneSchemas.ts +113 -113
  77. package/src/utils/standaloneTypes.ts +27 -27
  78. package/src/utils/standaloneZodSchemas.ts +71 -71
  79. package/src/utils/timestampedResources.ts +42 -0
  80. package/src/utils/typeGeneration.ts +30 -30
  81. package/src/utils/typeGenerationPostProcess.ts +245 -245
  82. package/src/utils/typeGenerationPreflight.ts +118 -118
  83. package/src/utils/zodCodegen.ts +548 -548
  84. package/toolproof.json +19 -0
  85. package/dist/src/genesis/resources/implementations/foo.d.ts +0 -1
  86. package/dist/src/genesis/resources/implementations/foo.js +0 -184
  87. package/dist/src/utils/resources.d.ts +0 -5
  88. package/dist/src/utils/resources.js +0 -17
  89. package/generated-src/resourceTypes/resourceTypes.ts +0 -2
  90. package/generated-src/resources/resourceTypes.ts +0 -2
  91. package/src/genesis/resources/implementations/foo.ts +0 -183
  92. package/src/utils/resources.ts +0 -26
  93. /package/generated-src/{derived → lookups}/mappings.ts +0 -0
package/toolproof.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": {
3
+ "kind": "json-pointer",
4
+ "filePath": "package.json",
5
+ "pointer": "/name"
6
+ },
7
+ "version": {
8
+ "kind": "json-pointer",
9
+ "filePath": "package.json",
10
+ "pointer": "/version"
11
+ },
12
+ "description": {
13
+ "kind": "json-pointer",
14
+ "filePath": "package.json",
15
+ "pointer": "/description"
16
+ },
17
+ "resourceTypesPath": "generated-src/declarations/resourceTypes.json",
18
+ "toolsPath": "generated-src/declarations/tools.json"
19
+ }
@@ -1 +0,0 @@
1
- export {};
@@ -1,184 +0,0 @@
1
- export {};
2
- /* import type { Resource } from '@toolproof-core/genesis';
3
- import { createMaterializedFromPotential } from '@toolproof-core/lib/create-resource';
4
-
5
- function extractNaturalValue(resource: Resource): number {
6
- const value: unknown = resource.value;
7
- if (typeof value === 'number' && Number.isInteger(value) && value >= 0) {
8
- return value;
9
- }
10
- throw new Error(`Invalid Natural resource: value must be a non-negative integer`);
11
- }
12
-
13
- function createMockOutput(potentialOutput: any, value: number): Resource {
14
- const mockPath = `mock://natural/${value}`;
15
-
16
- const materialized = createMaterializedFromPotential(potentialOutput, value);
17
-
18
- return {
19
- ...materialized,
20
- path: mockPath,
21
- };
22
- }
23
-
24
- function createMockErrorOutput(
25
- potentialOutput: any,
26
- name: string,
27
- description: string,
28
- details?: Record<string, unknown>
29
- ): Resource {
30
- const value: unknown = {
31
- name,
32
- description,
33
- ...(details ? { details } : {}),
34
- };
35
-
36
- const mockPath = `mock://error/${encodeURIComponent(name)}`;
37
-
38
- const materialized = createMaterializedFromPotential(potentialOutput, value);
39
-
40
- return {
41
- ...materialized,
42
- path: mockPath,
43
- };
44
- }
45
-
46
- export function mockAdd(inputs: Record<string, Resource | any>): Record<string, Resource> {
47
- const addendOne = inputs['AddendOne'] as Resource;
48
- const addendTwo = inputs['AddendTwo'] as Resource;
49
- const sumOutput = inputs['Sum'] as any;
50
-
51
- const value1 = extractNaturalValue(addendOne);
52
- const value2 = extractNaturalValue(addendTwo);
53
- const result = value1 + value2;
54
-
55
- return {
56
- Sum: createMockOutput(sumOutput, result),
57
- };
58
- }
59
-
60
- export function mockSubtract(inputs: Record<string, Resource | any>): Record<string, Resource> {
61
- const minuend = inputs['Minuend'] as Resource;
62
- const subtrahend = inputs['Subtrahend'] as Resource;
63
- const differenceOutput = inputs['Difference'] as any;
64
-
65
- const errorOutput = inputs['ErrorOutput'] as any | undefined;
66
-
67
- const value1 = extractNaturalValue(minuend);
68
- const value2 = extractNaturalValue(subtrahend);
69
-
70
- if (value2 > value1) {
71
- if (!errorOutput) {
72
- throw new Error(
73
- `Subtract mock tool cannot emit error: missing 'ErrorOutput' potential output (subtrahend ${value2} > minuend ${value1})`
74
- );
75
- }
76
-
77
- return {
78
- ErrorOutput: createMockErrorOutput(
79
- errorOutput,
80
- 'SubtractInvalidInput',
81
- `Subtrahend (${value2}) is larger than minuend (${value1}); subtraction would result in a negative value.`,
82
- {
83
- minuend: value1,
84
- subtrahend: value2,
85
- }
86
- ),
87
- };
88
- }
89
-
90
- const result = value1 - value2;
91
-
92
- return {
93
- Difference: createMockOutput(differenceOutput, result),
94
- };
95
- }
96
-
97
- export function mockMultiply(inputs: Record<string, Resource | any>): Record<string, Resource> {
98
- const multiplicand = inputs['Multiplicand'] as Resource;
99
- const multiplier = inputs['Multiplier'] as Resource;
100
- const productOutput = inputs['Product'] as any;
101
-
102
- const value1 = extractNaturalValue(multiplicand);
103
- const value2 = extractNaturalValue(multiplier);
104
- const result = value1 * value2;
105
-
106
- return {
107
- Product: createMockOutput(productOutput, result),
108
- };
109
- }
110
-
111
- export function mockDouble(inputs: Record<string, Resource | any>): Record<string, Resource> {
112
- const N = inputs['N'] as Resource;
113
- const DoubledOutput = inputs['Doubled'] as any;
114
-
115
- const value = extractNaturalValue(N);
116
- const result = value * 2;
117
-
118
- return {
119
- Doubled: createMockOutput(DoubledOutput, result),
120
- };
121
- }
122
-
123
- export function mockDivide(inputs: Record<string, Resource | any>): Record<string, Resource> {
124
- const dividend = inputs['Dividend'] as Resource;
125
- const divisor = inputs['Divisor'] as Resource;
126
- const quotientOutput = inputs['Quotient'] as any;
127
- const remainderOutput = inputs['Remainder'] as any;
128
-
129
- const errorOutput = inputs['ErrorOutput'] as any | undefined;
130
-
131
- const value1 = extractNaturalValue(dividend);
132
- const value2 = extractNaturalValue(divisor);
133
-
134
- if (value2 === 0) {
135
- if (!errorOutput) {
136
- throw new Error(
137
- `Divide mock tool cannot emit error: missing 'ErrorOutput' potential output (division by zero; dividend ${value1})`
138
- );
139
- }
140
-
141
- return {
142
- ErrorOutput: createMockErrorOutput(
143
- errorOutput,
144
- 'DivideByZero',
145
- `Cannot divide by zero (dividend ${value1}, divisor ${value2}).`,
146
- {
147
- dividend: value1,
148
- divisor: value2,
149
- }
150
- ),
151
- };
152
- }
153
-
154
- const quotient = Math.floor(value1 / value2);
155
- const remainder = value1 % value2;
156
-
157
- return {
158
- Quotient: createMockOutput(quotientOutput, quotient),
159
- Remainder: createMockOutput(remainderOutput, remainder),
160
- };
161
- }
162
-
163
- export function executeMockNumericalTool(
164
- toolName: string,
165
- payload: Record<string, Resource | any>
166
- ): Record<string, Resource> {
167
- const normalizedName = toolName.toLowerCase();
168
-
169
- switch (normalizedName) {
170
- case 'add':
171
- return mockAdd(payload);
172
- case 'subtract':
173
- return mockSubtract(payload);
174
- case 'multiply':
175
- return mockMultiply(payload);
176
- case 'double':
177
- return mockDouble(payload);
178
- case 'divide':
179
- return mockDivide(payload);
180
- default:
181
- throw new Error(`Unknown numerical tool: ${toolName}`);
182
- }
183
- }
184
- */
@@ -1,5 +0,0 @@
1
- type JsonObject = Record<string, unknown>;
2
- type ResourceTypeByName = Record<string, JsonObject>;
3
- type ResourceByName = Record<string, JsonObject>;
4
- export declare function generateResources(resourceTypes: ResourceTypeByName): ResourceByName;
5
- export {};
@@ -1,17 +0,0 @@
1
- const GENESIS_TIMESTAMP = '2025-11-30T00:00:00.000Z';
2
- export function generateResources(resourceTypes) {
3
- const resources = {};
4
- for (const [name, resourceType] of Object.entries(resourceTypes)) {
5
- resources[name] = {
6
- id: `RESOURCE-${name}`,
7
- resourceTypeHandle: 'TYPE-ResourceType',
8
- provenance: {
9
- resourceProvenanceKind: 'genesis',
10
- },
11
- version: 1,
12
- timestamp: GENESIS_TIMESTAMP,
13
- value: resourceType,
14
- };
15
- }
16
- return resources;
17
- }
@@ -1,2 +0,0 @@
1
- import resourceTypes from './resourceTypes.json' with { type: 'json' };
2
- export default resourceTypes;
@@ -1,2 +0,0 @@
1
- import resources from './resourceTypes.json' with { type: 'json' };
2
- export default resources;
@@ -1,183 +0,0 @@
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
- }
183
- */
@@ -1,26 +0,0 @@
1
- type JsonObject = Record<string, unknown>;
2
-
3
- type ResourceTypeByName = Record<string, JsonObject>;
4
-
5
- type ResourceByName = Record<string, JsonObject>;
6
-
7
- const GENESIS_TIMESTAMP = '2025-11-30T00:00:00.000Z';
8
-
9
- export function generateResources(resourceTypes: ResourceTypeByName): ResourceByName {
10
- const resources: ResourceByName = {};
11
-
12
- for (const [name, resourceType] of Object.entries(resourceTypes)) {
13
- resources[name] = {
14
- id: `RESOURCE-${name}`,
15
- resourceTypeHandle: 'TYPE-ResourceType',
16
- provenance: {
17
- resourceProvenanceKind: 'genesis',
18
- },
19
- version: 1,
20
- timestamp: GENESIS_TIMESTAMP,
21
- value: resourceType,
22
- };
23
- }
24
-
25
- return resources;
26
- }
File without changes