@toolproof-core/lib 1.0.36 → 1.0.37

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 (78) hide show
  1. package/dist/integrations/firebase/firebaseAdminHelpers.d.ts +1 -2
  2. package/dist/integrations/firebase/firebaseAdminHelpers.js +5 -14
  3. package/dist/lookups/lookups.d.ts +17 -24
  4. package/dist/lookups/lookups.js +10 -0
  5. package/dist/types/types.d.ts +10 -6
  6. package/dist/utils/cosmosDataExtraction.d.ts +5 -0
  7. package/dist/utils/cosmosDataExtraction.js +15 -0
  8. package/dist/utils/identifierGeneration.d.ts +2 -0
  9. package/dist/utils/identifierGeneration.js +5 -0
  10. package/dist/utils/mutableStrategyOverlay.d.ts +55 -0
  11. package/dist/utils/mutableStrategyOverlay.js +115 -0
  12. package/dist/utils/resourceCreation.d.ts +11 -0
  13. package/dist/utils/resourceCreation.js +32 -0
  14. package/dist/utils/stepCreation.d.ts +9 -0
  15. package/dist/utils/stepCreation.js +79 -0
  16. package/dist/utils/stepParallelization.d.ts +2 -0
  17. package/dist/utils/stepParallelization.js +129 -0
  18. package/dist/utils/strategyAssembly.d.ts +3 -0
  19. package/dist/utils/strategyAssembly.js +6 -0
  20. package/dist/utils/strategyCanonicalization.d.ts +4 -0
  21. package/dist/utils/strategyCanonicalization.js +215 -0
  22. package/dist/utils/strategyExtraction.d.ts +17 -0
  23. package/dist/utils/strategyExtraction.js +88 -0
  24. package/dist/utils/strategyStateResolution.d.ts +17 -0
  25. package/dist/utils/{resolveStrategyStateChain.js → strategyStateResolution.js} +5 -4
  26. package/dist/utils/strategyThreading.d.ts +2 -0
  27. package/dist/utils/strategyThreading.js +10 -0
  28. package/dist/utils/toolStepPaths.d.ts +2 -0
  29. package/dist/utils/toolStepPaths.js +21 -0
  30. package/package.json +41 -21
  31. package/src/integrations/firebase/firebaseAdminHelpers.ts +5 -17
  32. package/src/lookups/lookups.ts +16 -6
  33. package/src/types/types.ts +10 -4
  34. package/src/utils/cosmosDataExtraction.ts +25 -0
  35. package/src/utils/identifierGeneration.ts +12 -0
  36. package/src/utils/mutableStrategyOverlay.ts +286 -0
  37. package/src/utils/resourceCreation.ts +87 -0
  38. package/src/utils/stepCreation.ts +114 -0
  39. package/src/utils/stepParallelization.ts +181 -0
  40. package/src/utils/strategyAssembly.ts +14 -0
  41. package/src/utils/strategyCanonicalization.ts +294 -0
  42. package/src/utils/strategyExtraction.ts +150 -0
  43. package/src/utils/strategyStateResolution.ts +57 -0
  44. package/src/utils/strategyThreading.ts +27 -0
  45. package/src/utils/toolStepPaths.ts +34 -0
  46. package/tsconfig.tsbuildinfo +1 -1
  47. package/dist/integrations/firebase/createStep.d.ts +0 -10
  48. package/dist/integrations/firebase/createStep.js +0 -17
  49. package/dist/integrations/firebase/createThreadedStrategy.d.ts +0 -2
  50. package/dist/integrations/firebase/createThreadedStrategy.js +0 -8
  51. package/dist/utils/creation/resourceCreation.d.ts +0 -21
  52. package/dist/utils/creation/resourceCreation.js +0 -67
  53. package/dist/utils/creation/stepCreation.d.ts +0 -10
  54. package/dist/utils/creation/stepCreation.js +0 -64
  55. package/dist/utils/creation/threadedStrategyCreation.d.ts +0 -18
  56. package/dist/utils/creation/threadedStrategyCreation.js +0 -16
  57. package/dist/utils/extractData.d.ts +0 -12
  58. package/dist/utils/extractData.js +0 -78
  59. package/dist/utils/parallelizeSteps.d.ts +0 -3
  60. package/dist/utils/parallelizeSteps.js +0 -159
  61. package/dist/utils/resolveStrategyStateChain.d.ts +0 -20
  62. package/dist/utils/roleSpec.d.ts +0 -16
  63. package/dist/utils/roleSpec.js +0 -57
  64. package/dist/utils/strategyState.d.ts +0 -12
  65. package/dist/utils/strategyState.js +0 -58
  66. package/dist/utils_2/threadedStrategyCreation.d.ts +0 -5
  67. package/dist/utils_2/threadedStrategyCreation.js +0 -12
  68. package/src/integrations/firebase/createStep.ts +0 -41
  69. package/src/integrations/firebase/createThreadedStrategy.ts +0 -19
  70. package/src/utils/creation/resourceCreation.ts +0 -140
  71. package/src/utils/creation/stepCreation.ts +0 -95
  72. package/src/utils/creation/threadedStrategyCreation.ts +0 -42
  73. package/src/utils/extractData.ts +0 -137
  74. package/src/utils/parallelizeSteps.ts +0 -239
  75. package/src/utils/resolveStrategyStateChain.ts +0 -58
  76. package/src/utils/roleSpec.ts +0 -84
  77. package/src/utils/strategyState.ts +0 -128
  78. package/src/utils_2/threadedStrategyCreation.ts +0 -19
@@ -1,239 +0,0 @@
1
- import type {
2
- BranchStep,
3
- ForStep,
4
- ToolStepPath,
5
- ToolStep,
6
- Step,
7
- WhileStep,
8
- } from '@toolproof-core/genesis';
9
- import { CONSTANTS } from '../lookups/lookups.js';
10
- import type { StrategyState } from './strategyState.js';
11
-
12
- type ToolStepSlot = 'self' | 'case.when' | 'case.what' | 'cases.when' | 'cases.what';
13
-
14
- function toUnthreadedToolStepPath(opts: {
15
- stepIndex: number;
16
- toolStepSlot: ToolStepSlot;
17
- caseIndex?: number;
18
- }): ToolStepPath {
19
- const base = `/steps/${opts.stepIndex}`;
20
- switch (opts.toolStepSlot) {
21
- case 'self':
22
- return `${base}/self` as ToolStepPath;
23
- case 'case.when':
24
- return `${base}/case/when` as ToolStepPath;
25
- case 'case.what':
26
- return `${base}/case/what` as ToolStepPath;
27
- case 'cases.when':
28
- if (typeof opts.caseIndex !== 'number') {
29
- throw new Error('Expected caseIndex for cases.when path');
30
- }
31
- return `${base}/cases/${opts.caseIndex}/when` as ToolStepPath;
32
- case 'cases.what':
33
- if (typeof opts.caseIndex !== 'number') {
34
- throw new Error('Expected caseIndex for cases.what path');
35
- }
36
- return `${base}/cases/${opts.caseIndex}/what` as ToolStepPath;
37
- default: {
38
- const _exhaustive: never = opts.toolStepSlot;
39
- return _exhaustive;
40
- }
41
- }
42
- }
43
-
44
-
45
- export function getIndependentThreads(steps: Step[], strategyState: StrategyState): Step[][] {
46
- type OwnerIndex = number;
47
-
48
- const getOwnerLabel = (ownerIndex: OwnerIndex) => {
49
- const step = steps[ownerIndex];
50
- return `steps[${ownerIndex}] stepKind=${(step as any)?.stepKind ?? 'unknown'}`;
51
- };
52
-
53
- // Map each canonical toolStepPath (including macro-nested tool steps) to its owning top-level step index.
54
- const toolStepPathToOwner = new Map<ToolStepPath, OwnerIndex>();
55
- const toolStepByPath = new Map<ToolStepPath, ToolStep>();
56
-
57
- const addToolStep = (
58
- toolStep: ToolStep | undefined,
59
- ownerIndex: OwnerIndex,
60
- toolStepPath: ToolStepPath,
61
- ) => {
62
- if (!toolStep) return;
63
-
64
- const existingOwner = toolStepPathToOwner.get(toolStepPath);
65
- if (existingOwner !== undefined) {
66
- throw new Error(
67
- `Duplicate toolStepPath '${toolStepPath}' found in ${getOwnerLabel(ownerIndex)} and ${getOwnerLabel(existingOwner)}`
68
- );
69
- }
70
-
71
- toolStepPathToOwner.set(toolStepPath, ownerIndex);
72
- toolStepByPath.set(toolStepPath, toolStep);
73
- };
74
-
75
- steps.forEach((step, ownerIndex) => {
76
- if (step.stepKind === CONSTANTS.Enums.StepKind.tool) {
77
- addToolStep(
78
- step as ToolStep,
79
- ownerIndex,
80
- toUnthreadedToolStepPath({ stepIndex: ownerIndex, toolStepSlot: 'self' }),
81
- );
82
- return;
83
- }
84
-
85
- if (step.stepKind === CONSTANTS.Enums.StepKind.for) {
86
- const loop = step as ForStep;
87
- addToolStep(
88
- loop.case?.what,
89
- ownerIndex,
90
- toUnthreadedToolStepPath({ stepIndex: ownerIndex, toolStepSlot: 'case.what' }),
91
- );
92
- addToolStep(
93
- loop.case?.when,
94
- ownerIndex,
95
- toUnthreadedToolStepPath({ stepIndex: ownerIndex, toolStepSlot: 'case.when' }),
96
- );
97
- return;
98
- }
99
-
100
- if (step.stepKind === CONSTANTS.Enums.StepKind.while) {
101
- const loop = step as WhileStep;
102
- addToolStep(
103
- loop.case?.what,
104
- ownerIndex,
105
- toUnthreadedToolStepPath({ stepIndex: ownerIndex, toolStepSlot: 'case.what' }),
106
- );
107
- addToolStep(
108
- loop.case?.when,
109
- ownerIndex,
110
- toUnthreadedToolStepPath({ stepIndex: ownerIndex, toolStepSlot: 'case.when' }),
111
- );
112
- return;
113
- }
114
-
115
- if (step.stepKind === CONSTANTS.Enums.StepKind.branch) {
116
- const branch = step as BranchStep;
117
- for (const [caseIndex, caseItem] of (branch.cases ?? []).entries()) {
118
- addToolStep(
119
- caseItem?.what,
120
- ownerIndex,
121
- toUnthreadedToolStepPath({ stepIndex: ownerIndex, toolStepSlot: 'cases.what', caseIndex }),
122
- );
123
- addToolStep(
124
- caseItem?.when,
125
- ownerIndex,
126
- toUnthreadedToolStepPath({ stepIndex: ownerIndex, toolStepSlot: 'cases.when', caseIndex }),
127
- );
128
- }
129
- return;
130
- }
131
- });
132
-
133
- // Undirected adjacency used for connected components (thread groups).
134
- const ownerAdj = new Map<OwnerIndex, Set<OwnerIndex>>();
135
- // Directed dependencies used for strict ordering validation: owner -> producers it depends on.
136
- const ownerDeps = new Map<OwnerIndex, Set<OwnerIndex>>();
137
-
138
- const ensureOwner = (ownerIndex: OwnerIndex) => {
139
- if (!ownerAdj.has(ownerIndex)) ownerAdj.set(ownerIndex, new Set());
140
- if (!ownerDeps.has(ownerIndex)) ownerDeps.set(ownerIndex, new Set());
141
- };
142
-
143
- for (let i = 0; i < steps.length; i++) {
144
- ensureOwner(i);
145
- }
146
-
147
- // Discover dependencies from strategyState.
148
- for (const [toolStepPath, ownerIndex] of toolStepPathToOwner) {
149
- ensureOwner(ownerIndex);
150
-
151
- const toolStep = toolStepByPath.get(toolStepPath);
152
- const inputBindings = toolStep?.roleBindingSpec?.inputBindings ?? [];
153
- const bucket = strategyState?.[toolStepPath] ?? ({} as any);
154
-
155
- for (const inputRoleId of inputBindings) {
156
- const entry = bucket?.[inputRoleId] as any;
157
- if (!entry || entry.strategyStateInputKind !== 'internalInputPotential') continue;
158
-
159
- const creatorToolStepPath = typeof entry?.toolStepRoleAddress?.toolStepPath === 'string'
160
- ? entry.toolStepRoleAddress.toolStepPath as ToolStepPath
161
- : undefined;
162
- if (!creatorToolStepPath) {
163
- throw new Error(
164
- `Unresolvable internalInputPotential in toolStep '${toolStepPath}' (${getOwnerLabel(ownerIndex)}): missing toolStepRoleAddress.toolStepPath for role '${inputRoleId}'`
165
- );
166
- }
167
-
168
- const producerOwner = toolStepPathToOwner.get(creatorToolStepPath);
169
- if (producerOwner === undefined) {
170
- throw new Error(
171
- `Unresolvable internalInputPotential in toolStep '${toolStepPath}' (${getOwnerLabel(ownerIndex)}): source toolStepPath '${creatorToolStepPath}' not found in strategy steps`
172
- );
173
- }
174
-
175
- ensureOwner(producerOwner);
176
- ownerAdj.get(ownerIndex)!.add(producerOwner);
177
- ownerAdj.get(producerOwner)!.add(ownerIndex);
178
- ownerDeps.get(ownerIndex)!.add(producerOwner);
179
- }
180
- }
181
-
182
- // Connected components over owners.
183
- const visited = new Set<OwnerIndex>();
184
- const components: OwnerIndex[][] = [];
185
-
186
- for (let ownerIndex = 0; ownerIndex < steps.length; ownerIndex++) {
187
- if (visited.has(ownerIndex)) continue;
188
- const component: OwnerIndex[] = [];
189
- const queue: OwnerIndex[] = [ownerIndex];
190
- visited.add(ownerIndex);
191
- while (queue.length > 0) {
192
- const node = queue.shift()!;
193
- component.push(node);
194
- for (const neighbor of ownerAdj.get(node) ?? []) {
195
- if (!visited.has(neighbor)) {
196
- visited.add(neighbor);
197
- queue.push(neighbor);
198
- }
199
- }
200
- }
201
- components.push(component);
202
- }
203
-
204
- // Strict validation: within a thread, the linear order must not contain forward refs.
205
- for (const comp of components) {
206
- const compSet = new Set(comp);
207
- const ownersInOrder = steps.map((_, i) => i).filter((i) => compSet.has(i));
208
-
209
- const position = new Map<OwnerIndex, number>();
210
- ownersInOrder.forEach((owner, idx) => position.set(owner, idx));
211
-
212
- for (const consumerOwner of ownersInOrder) {
213
- const deps = ownerDeps.get(consumerOwner);
214
- if (!deps || deps.size === 0) continue;
215
-
216
- const consumerPos = position.get(consumerOwner)!;
217
- for (const producerOwner of deps) {
218
- const producerPos = position.get(producerOwner);
219
- if (producerPos === undefined) {
220
- throw new Error(
221
- `Internal error: dependency producer ${getOwnerLabel(producerOwner)} missing from computed thread for ${getOwnerLabel(consumerOwner)}`
222
- );
223
- }
224
- if (producerPos >= consumerPos) {
225
- throw new Error(
226
- `Invalid step order in thread: ${getOwnerLabel(consumerOwner)} depends on ${getOwnerLabel(producerOwner)}, but producer is not scheduled before consumer`
227
- );
228
- }
229
- }
230
- }
231
- }
232
-
233
- return components
234
- .map((compOwners) => {
235
- const ownerSet = new Set(compOwners);
236
- return steps.filter((_, i) => ownerSet.has(i));
237
- })
238
- .filter((group) => group.length > 0);
239
- }
@@ -1,58 +0,0 @@
1
- import type {
2
- ToolStepRoleAddress,
3
- ExternalInputPotential,
4
- InputResource,
5
- InternalInputPotential,
6
- StrategyStateInputEntry,
7
- ThreadedStrategyState,
8
- ThreadedToolStepRoleAddress,
9
- UnthreadedStrategyState,
10
- UnthreadedToolStepRoleAddress,
11
- } from '@toolproof-core/genesis';
12
- import { getStrategyStateEntry, type StrategyState } from './strategyState.js';
13
-
14
- type ToolStepRoleAddressForStrategyState<TStrategyState extends StrategyState> =
15
- TStrategyState extends UnthreadedStrategyState
16
- ? UnthreadedToolStepRoleAddress
17
- : TStrategyState extends ThreadedStrategyState
18
- ? ThreadedToolStepRoleAddress
19
- : ToolStepRoleAddress;
20
-
21
- export type ResolveResult =
22
- | { status: 'inputResource'; entry: InputResource; path: ToolStepRoleAddress[] }
23
- | { status: 'externalInputPotential'; entry: ExternalInputPotential; path: ToolStepRoleAddress[] }
24
- | { status: 'unresolved'; reason: 'not-found' | 'cycle' | 'depth-exceeded'; path: ToolStepRoleAddress[] };
25
-
26
- export function resolveStrategyStateChain<TStrategyState extends StrategyState>(
27
- strategyState: TStrategyState,
28
- start: ToolStepRoleAddressForStrategyState<TStrategyState>,
29
- opts?: { maxDepth?: number }
30
- ): ResolveResult {
31
- const maxDepth = opts?.maxDepth ?? 50;
32
- const visited = new Set<string>();
33
- const path: ToolStepRoleAddress[] = [];
34
- let current: ToolStepRoleAddressForStrategyState<TStrategyState> = start;
35
-
36
- for (let depth = 0; depth <= maxDepth; depth++) {
37
- path.push(current);
38
- const visitKey = `${current.toolStepPath}::${current.roleName}`;
39
- if (visited.has(visitKey)) {
40
- return { status: 'unresolved', reason: 'cycle', path };
41
- }
42
- visited.add(visitKey);
43
-
44
- const entry = getStrategyStateEntry(strategyState, current) as StrategyStateInputEntry | undefined;
45
- if (!entry) return { status: 'unresolved', reason: 'not-found', path };
46
-
47
- if (entry.strategyStateInputKind === 'inputResource') {
48
- return { status: 'inputResource', entry, path };
49
- }
50
- if (entry.strategyStateInputKind === 'externalInputPotential') {
51
- return { status: 'externalInputPotential', entry, path };
52
- }
53
-
54
- current = (entry as InternalInputPotential).toolStepRoleAddress as ToolStepRoleAddressForStrategyState<TStrategyState>;
55
- }
56
-
57
- return { status: 'unresolved', reason: 'depth-exceeded', path };
58
- }
@@ -1,84 +0,0 @@
1
- import type {
2
- RoleName,
3
- RoleValue,
4
- Step,
5
- StepArrayArray,
6
- Tool,
7
- ToolStep,
8
- } from '@toolproof-core/genesis';
9
-
10
- export type StrategyStepGraph =
11
- | { steps: Step[] }
12
- | { stepsByThreadIndex: StepArrayArray };
13
-
14
- export interface ToolRoleDescriptor extends RoleValue {
15
- id: RoleName;
16
- name: string;
17
- }
18
-
19
- export function getInputRoleEntries(tool: Tool): Array<[RoleName, RoleValue]> {
20
- return Object.entries(tool.roleSpec.inputRoleValueByName) as Array<[RoleName, RoleValue]>;
21
- }
22
-
23
- export function getOutputRoleEntries(tool: Tool): Array<[RoleName, RoleValue]> {
24
- return Object.entries(tool.roleSpec.outputRoleValueByName) as Array<[RoleName, RoleValue]>;
25
- }
26
-
27
- export function getInputRoleNames(tool: Tool): RoleName[] {
28
- return getInputRoleEntries(tool).map(([roleName]) => roleName);
29
- }
30
-
31
- export function getOutputRoleNames(tool: Tool): RoleName[] {
32
- return getOutputRoleEntries(tool).map(([roleName]) => roleName);
33
- }
34
-
35
- export function toToolRoleDescriptor([roleName, roleValue]: [RoleName, RoleValue]): ToolRoleDescriptor {
36
- return {
37
- id: roleName,
38
- name: roleName,
39
- ...roleValue,
40
- };
41
- }
42
-
43
- export function extractToolStepsFromStrategy(strategy: StrategyStepGraph): ToolStep[] {
44
- const toolSteps: ToolStep[] = [];
45
-
46
- const visitStep = (step: Step) => {
47
- switch (step.stepKind) {
48
- case 'tool': {
49
- toolSteps.push(step);
50
- return;
51
- }
52
- case 'branch': {
53
- for (const conditional of step.cases) {
54
- toolSteps.push(conditional.when, conditional.what);
55
- }
56
- return;
57
- }
58
- case 'while':
59
- case 'for': {
60
- toolSteps.push(step.case.when, step.case.what);
61
- return;
62
- }
63
- default: {
64
- const _exhaustive: never = step;
65
- return _exhaustive;
66
- }
67
- }
68
- };
69
-
70
- if ('steps' in strategy) {
71
- for (const step of strategy.steps) {
72
- visitStep(step);
73
- }
74
- return toolSteps;
75
- }
76
-
77
- for (const threadSteps of strategy.stepsByThreadIndex) {
78
- for (const step of threadSteps) {
79
- visitStep(step);
80
- }
81
- }
82
-
83
- return toolSteps;
84
- }
@@ -1,128 +0,0 @@
1
- import type {
2
- ToolStepRoleAddress,
3
- ToolStepPath,
4
- Resource,
5
- InputResource,
6
- InternalInputPotential,
7
- ExternalInputPotential,
8
- Strategy,
9
- StrategyStateInputEntry,
10
- StrategyStateInputEntryByRoleName,
11
- ThreadedStrategyState,
12
- ThreadedToolStepPath,
13
- ThreadedToolStepRoleAddress,
14
- UnthreadedStrategyState,
15
- UnthreadedToolStepPath,
16
- UnthreadedToolStepRoleAddress,
17
- } from '@toolproof-core/genesis';
18
-
19
- export type StrategyState = Strategy['strategyState'];
20
-
21
- type ToolStepPathForStrategyState<TStrategyState extends StrategyState> =
22
- TStrategyState extends UnthreadedStrategyState
23
- ? UnthreadedToolStepPath
24
- : TStrategyState extends ThreadedStrategyState
25
- ? ThreadedToolStepPath
26
- : ToolStepPath;
27
-
28
- type ToolStepRoleAddressForStrategyState<TStrategyState extends StrategyState> =
29
- TStrategyState extends UnthreadedStrategyState
30
- ? UnthreadedToolStepRoleAddress
31
- : TStrategyState extends ThreadedStrategyState
32
- ? ThreadedToolStepRoleAddress
33
- : ToolStepRoleAddress;
34
-
35
- export function getStrategyStateBucket<TStrategyState extends StrategyState>(
36
- strategyState: TStrategyState,
37
- toolStepPath: ToolStepPathForStrategyState<TStrategyState>,
38
- ): StrategyStateInputEntryByRoleName | undefined {
39
- return strategyState[toolStepPath] as StrategyStateInputEntryByRoleName | undefined;
40
- }
41
-
42
- export function getStrategyStateEntry<TStrategyState extends StrategyState>(
43
- strategyState: TStrategyState,
44
- toolStepRoleAddress: ToolStepRoleAddressForStrategyState<TStrategyState>,
45
- ): StrategyStateInputEntry | undefined {
46
- const toolStepPath = toolStepRoleAddress.toolStepPath as ToolStepPathForStrategyState<TStrategyState>;
47
- return getStrategyStateBucket(strategyState, toolStepPath)?.[toolStepRoleAddress.roleName];
48
- }
49
-
50
- export function setStrategyStateEntry<TStrategyState extends StrategyState>(
51
- strategyState: TStrategyState,
52
- toolStepRoleAddress: ToolStepRoleAddressForStrategyState<TStrategyState>,
53
- entry: StrategyStateInputEntry,
54
- ): TStrategyState {
55
- const toolStepPath = toolStepRoleAddress.toolStepPath as ToolStepPathForStrategyState<TStrategyState>;
56
- const bucket = getStrategyStateBucket(strategyState, toolStepPath) ?? {};
57
-
58
- return {
59
- ...strategyState,
60
- [toolStepPath]: {
61
- ...bucket,
62
- [toolStepRoleAddress.roleName]: entry,
63
- },
64
- } as TStrategyState;
65
- }
66
-
67
- export function clearStrategyStateEntry<TStrategyState extends StrategyState>(
68
- strategyState: TStrategyState,
69
- toolStepRoleAddress: ToolStepRoleAddressForStrategyState<TStrategyState>,
70
- ): TStrategyState {
71
- const toolStepPath = toolStepRoleAddress.toolStepPath as ToolStepPathForStrategyState<TStrategyState>;
72
- const bucket = getStrategyStateBucket(strategyState, toolStepPath);
73
- if (!bucket || !(toolStepRoleAddress.roleName in bucket)) {
74
- return strategyState;
75
- }
76
-
77
- const nextBucket = { ...bucket };
78
- delete nextBucket[toolStepRoleAddress.roleName];
79
-
80
- return {
81
- ...strategyState,
82
- [toolStepPath]: nextBucket,
83
- } as TStrategyState;
84
- }
85
-
86
- export function bindInputResource<TStrategyState extends StrategyState>(
87
- strategyState: TStrategyState,
88
- target: ToolStepRoleAddressForStrategyState<TStrategyState>,
89
- resource: Resource,
90
- ): TStrategyState {
91
- const inputResource: InputResource = {
92
- ...resource,
93
- strategyStateInputKind: 'inputResource',
94
- };
95
-
96
- return setStrategyStateEntry(strategyState, target, inputResource);
97
- }
98
-
99
- export function bindInternalInputPotential<TStrategyState extends StrategyState>(
100
- strategyState: TStrategyState,
101
- target: ToolStepRoleAddressForStrategyState<TStrategyState>,
102
- source: ToolStepRoleAddressForStrategyState<TStrategyState>,
103
- ): TStrategyState {
104
- const sourceEntry = getStrategyStateEntry(strategyState, source);
105
- if (!sourceEntry) {
106
- throw new Error(`resourceEntry not found for source (${source.toolStepPath}, ${source.roleName})`);
107
- }
108
-
109
- const internalInputPotential: InternalInputPotential = {
110
- strategyStateInputKind: 'internalInputPotential',
111
- toolStepRoleAddress: {
112
- toolStepPath: source.toolStepPath,
113
- roleName: source.roleName,
114
- },
115
- };
116
-
117
- return setStrategyStateEntry(strategyState, target, internalInputPotential);
118
- }
119
-
120
- export function bindExternalInputPotential<TStrategyState extends StrategyState>(
121
- strategyState: TStrategyState,
122
- target: ToolStepRoleAddressForStrategyState<TStrategyState>,
123
- ): TStrategyState {
124
- const externalInputPotential: ExternalInputPotential = {
125
- strategyStateInputKind: 'externalInputPotential',
126
- };
127
- return setStrategyStateEntry(strategyState, target, externalInputPotential);
128
- }
@@ -1,19 +0,0 @@
1
- import type { UnthreadedStrategy, ThreadedStrategy, StepArray, StepArrayArray, UnthreadedStrategyState, ThreadedStrategyState } from "@toolproof-core/genesis/types";
2
-
3
-
4
- export const __UnthreadedStrategyToThreadedStrategy = (unthreadedStrategy: UnthreadedStrategy): ThreadedStrategy => {
5
- throw new Error('Not implemented yet');
6
- }
7
-
8
- export const __UnthreadedStrategyStateToThreadedStrategyState = (unthreadedStrategyState: UnthreadedStrategyState): ThreadedStrategyState => {
9
- throw new Error('Not implemented yet');
10
- }
11
-
12
- export const __StepArrayToStepArrayArray = (stepArray: StepArray): StepArrayArray => {
13
- throw new Error('Not implemented yet');
14
- }
15
-
16
- export const __Foo = (unthreadedStrategy: UnthreadedStrategy, draft: any): UnthreadedStrategy => {
17
- throw new Error('Not implemented yet');
18
- }
19
-