@toolproof-core/lib 1.0.33 → 1.0.36

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 (90) hide show
  1. package/dist/integrations/firebase/createStep.d.ts +2 -3
  2. package/dist/integrations/firebase/createStep.js +7 -33
  3. package/dist/integrations/firebase/createThreadedStrategy.d.ts +2 -0
  4. package/dist/integrations/firebase/createThreadedStrategy.js +8 -0
  5. package/dist/integrations/firebase/firebaseAdminHelpers.d.ts +4 -10
  6. package/dist/integrations/firebase/firebaseAdminHelpers.js +43 -136
  7. package/dist/integrations/firebase/firebaseAdminInit.d.ts +0 -1
  8. package/dist/integrations/firebase/firebaseAdminInit.js +0 -1
  9. package/dist/lookups/lookups.d.ts +221 -0
  10. package/dist/lookups/lookups.js +23 -0
  11. package/dist/types/types.d.ts +8 -12
  12. package/dist/types/types.js +2 -3
  13. package/dist/utils/creation/resourceCreation.d.ts +18 -18
  14. package/dist/utils/creation/resourceCreation.js +49 -48
  15. package/dist/utils/creation/stepCreation.d.ts +7 -48
  16. package/dist/utils/creation/stepCreation.js +16 -42
  17. package/dist/utils/creation/threadedStrategyCreation.d.ts +18 -0
  18. package/dist/utils/creation/threadedStrategyCreation.js +16 -0
  19. package/dist/utils/extractData.d.ts +9 -10
  20. package/dist/utils/extractData.js +29 -25
  21. package/dist/utils/parallelizeSteps.d.ts +1 -2
  22. package/dist/utils/parallelizeSteps.js +52 -37
  23. package/dist/utils/resolveStrategyStateChain.d.ts +20 -0
  24. package/dist/utils/{resolveResourceChain.js → resolveStrategyStateChain.js} +6 -11
  25. package/dist/utils/roleSpec.d.ts +7 -3
  26. package/dist/utils/roleSpec.js +0 -1
  27. package/dist/utils/strategyState.d.ts +11 -6
  28. package/dist/utils/strategyState.js +41 -12
  29. package/dist/utils_2/threadedStrategyCreation.d.ts +5 -0
  30. package/dist/utils_2/threadedStrategyCreation.js +12 -0
  31. package/package.json +15 -15
  32. package/src/integrations/firebase/createStep.ts +9 -39
  33. package/src/integrations/firebase/createThreadedStrategy.ts +19 -0
  34. package/src/integrations/firebase/firebaseAdminHelpers.ts +61 -163
  35. package/src/lookups/lookups.ts +25 -0
  36. package/src/types/types.ts +9 -12
  37. package/src/utils/creation/resourceCreation.ts +140 -121
  38. package/src/utils/creation/stepCreation.ts +25 -95
  39. package/src/utils/creation/threadedStrategyCreation.ts +42 -0
  40. package/src/utils/extractData.ts +46 -38
  41. package/src/utils/parallelizeSteps.ts +92 -40
  42. package/src/utils/resolveStrategyStateChain.ts +58 -0
  43. package/src/utils/roleSpec.ts +7 -3
  44. package/src/utils/strategyState.ts +99 -27
  45. package/src/utils_2/threadedStrategyCreation.ts +19 -0
  46. package/tsconfig.tsbuildinfo +1 -1
  47. package/dist/artifacts/artifacts.d.ts +0 -175
  48. package/dist/artifacts/artifacts.d.ts.map +0 -1
  49. package/dist/artifacts/artifacts.js +0 -48
  50. package/dist/artifacts/artifacts.js.map +0 -1
  51. package/dist/integrations/firebase/createRunnableStrategy.d.ts +0 -3
  52. package/dist/integrations/firebase/createRunnableStrategy.d.ts.map +0 -1
  53. package/dist/integrations/firebase/createRunnableStrategy.js +0 -9
  54. package/dist/integrations/firebase/createRunnableStrategy.js.map +0 -1
  55. package/dist/integrations/firebase/createStep.d.ts.map +0 -1
  56. package/dist/integrations/firebase/createStep.js.map +0 -1
  57. package/dist/integrations/firebase/firebaseAdminHelpers.d.ts.map +0 -1
  58. package/dist/integrations/firebase/firebaseAdminHelpers.js.map +0 -1
  59. package/dist/integrations/firebase/firebaseAdminInit.d.ts.map +0 -1
  60. package/dist/integrations/firebase/firebaseAdminInit.js.map +0 -1
  61. package/dist/types/types.d.ts.map +0 -1
  62. package/dist/types/types.js.map +0 -1
  63. package/dist/utils/bindInputRoleToResource.d.ts +0 -6
  64. package/dist/utils/bindInputRoleToResource.d.ts.map +0 -1
  65. package/dist/utils/bindInputRoleToResource.js +0 -25
  66. package/dist/utils/bindInputRoleToResource.js.map +0 -1
  67. package/dist/utils/creation/resourceCreation.d.ts.map +0 -1
  68. package/dist/utils/creation/resourceCreation.js.map +0 -1
  69. package/dist/utils/creation/runnableStrategyCreation.d.ts +0 -4
  70. package/dist/utils/creation/runnableStrategyCreation.d.ts.map +0 -1
  71. package/dist/utils/creation/runnableStrategyCreation.js +0 -17
  72. package/dist/utils/creation/runnableStrategyCreation.js.map +0 -1
  73. package/dist/utils/creation/stepCreation.d.ts.map +0 -1
  74. package/dist/utils/creation/stepCreation.js.map +0 -1
  75. package/dist/utils/extractData.d.ts.map +0 -1
  76. package/dist/utils/extractData.js.map +0 -1
  77. package/dist/utils/parallelizeSteps.d.ts.map +0 -1
  78. package/dist/utils/parallelizeSteps.js.map +0 -1
  79. package/dist/utils/resolveResourceChain.d.ts +0 -19
  80. package/dist/utils/resolveResourceChain.d.ts.map +0 -1
  81. package/dist/utils/resolveResourceChain.js.map +0 -1
  82. package/dist/utils/roleSpec.d.ts.map +0 -1
  83. package/dist/utils/roleSpec.js.map +0 -1
  84. package/dist/utils/strategyState.d.ts.map +0 -1
  85. package/dist/utils/strategyState.js.map +0 -1
  86. package/src/artifacts/artifacts.ts +0 -49
  87. package/src/integrations/firebase/createRunnableStrategy.ts +0 -18
  88. package/src/utils/bindInputRoleToResource.ts +0 -53
  89. package/src/utils/creation/runnableStrategyCreation.ts +0 -28
  90. package/src/utils/resolveResourceChain.ts +0 -52
@@ -1,53 +0,0 @@
1
- import type {
2
- CreationContext,
3
- Resource,
4
- ReferenceInput,
5
- ValueInput,
6
- } from '@toolproof-core/schema';
7
- import {
8
- clearStrategyStateEntry,
9
- getStrategyStateEntry,
10
- setStrategyStateEntry,
11
- type StrategyState,
12
- } from './strategyState.js';
13
-
14
-
15
- export function bindInputResInStrategyState(
16
- strategyState: StrategyState,
17
- target: CreationContext,
18
- resource: Resource
19
- ): StrategyState {
20
- const entry: ValueInput = {
21
- strategyStateInputKind: 'valueInput',
22
- resourceTypeId: resource.resourceTypeId,
23
- nucleus: resource.nucleus,
24
- };
25
-
26
- return setStrategyStateEntry(strategyState, target, entry);
27
- }
28
-
29
- export function bindInputRefInStrategyState(
30
- strategyState: StrategyState,
31
- target: CreationContext,
32
- source: CreationContext
33
- ): StrategyState {
34
- const sourceEntry = getStrategyStateEntry(strategyState, source);
35
- if (!sourceEntry) {
36
- throw new Error(`resourceEntry not found for source (${source.toolStepPath}, ${source.roleName})`);
37
- }
38
-
39
- const entry: ReferenceInput = {
40
- strategyStateInputKind: 'referenceInput',
41
- toolStepPath: source.toolStepPath,
42
- roleName: source.roleName,
43
- };
44
-
45
- return setStrategyStateEntry(strategyState, target, entry);
46
- }
47
-
48
- export function clearInputBindingInStrategyState(
49
- strategyState: StrategyState,
50
- target: CreationContext
51
- ): StrategyState {
52
- return clearStrategyStateEntry(strategyState, target);
53
- }
@@ -1,28 +0,0 @@
1
- import type {
2
- Step,
3
- Strategy,
4
- StrategyId,
5
- } from '@toolproof-core/schema';
6
- import { getIndependentThreads } from '../parallelizeSteps.js';
7
- import { CONSTANTS } from '../../artifacts/artifacts.js';
8
-
9
- export function getRunnableStrategyThreadGroups(rawStrategy: Strategy): Step[][] {
10
- if ('steps' in rawStrategy) {
11
- return getIndependentThreads(rawStrategy.steps, rawStrategy.strategyState as any);
12
- }
13
-
14
- return rawStrategy.stepsByThreadIndex;
15
- }
16
-
17
- export function buildRunnableStrategy(
18
- threadStepGroups: Step[][],
19
- runnableStrategyId: StrategyId,
20
- rawStrategy: Strategy,
21
- ): Strategy {
22
- return {
23
- id: runnableStrategyId,
24
- strategyKind: CONSTANTS.Enums.StrategyKind.threaded,
25
- stepsByThreadIndex: threadStepGroups,
26
- strategyState: rawStrategy.strategyState,
27
- };
28
- }
@@ -1,52 +0,0 @@
1
- import type {
2
- CreationContext,
3
- ExternalInput,
4
- ReferenceInput,
5
- StrategyStateInputEntry,
6
- ValueInput,
7
- } from '@toolproof-core/schema';
8
- import { getStrategyStateEntry, type StrategyState } from './strategyState.js';
9
-
10
- export type ResolveResult =
11
- | { status: 'valueInput'; entry: ValueInput; path: CreationContext[] }
12
- | { status: 'externalInput'; entry: ExternalInput; path: CreationContext[] }
13
- | { status: 'unresolved'; reason: 'not-found' | 'cycle' | 'depth-exceeded'; path: CreationContext[] };
14
-
15
- export function resolveResourceChain(
16
- strategyState: StrategyState,
17
- start: CreationContext,
18
- opts?: { maxDepth?: number }
19
- ): ResolveResult {
20
- const maxDepth = opts?.maxDepth ?? 50;
21
- const visited = new Set<string>();
22
- const path: CreationContext[] = [];
23
- let current: CreationContext = start;
24
-
25
- for (let depth = 0; depth <= maxDepth; depth++) {
26
- path.push(current);
27
- const visitKey = `${current.toolStepPath}::${current.roleName}`;
28
- if (visited.has(visitKey)) {
29
- return { status: 'unresolved', reason: 'cycle', path };
30
- }
31
- visited.add(visitKey);
32
-
33
- const entry = getStrategyStateEntry(strategyState, current) as StrategyStateInputEntry | undefined;
34
- if (!entry) return { status: 'unresolved', reason: 'not-found', path };
35
-
36
- if (entry.strategyStateInputKind === 'valueInput') {
37
- return { status: 'valueInput', entry: entry, path };
38
- }
39
- if (entry.strategyStateInputKind === 'externalInput') {
40
- return { status: 'externalInput', entry: entry, path };
41
- }
42
-
43
- current = {
44
- toolStepPath: (entry as ReferenceInput).toolStepPath,
45
- roleName: (entry as ReferenceInput).roleName,
46
- };
47
- continue;
48
-
49
- }
50
-
51
- return { status: 'unresolved', reason: 'depth-exceeded', path };
52
- }