@toolproof-core/lib 1.0.31 → 1.0.32

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 (45) hide show
  1. package/dist/integrations/firebase/createRunnableStrategy.d.ts +2 -2
  2. package/dist/integrations/firebase/createRunnableStrategy.d.ts.map +1 -1
  3. package/dist/integrations/firebase/createRunnableStrategy.js.map +1 -1
  4. package/dist/integrations/firebase/createStep.d.ts +8 -8
  5. package/dist/integrations/firebase/createStep.d.ts.map +1 -1
  6. package/dist/integrations/firebase/createStep.js.map +1 -1
  7. package/dist/integrations/firebase/firebaseAdminHelpers.d.ts +3 -3
  8. package/dist/integrations/firebase/firebaseAdminHelpers.d.ts.map +1 -1
  9. package/dist/integrations/firebase/firebaseAdminHelpers.js.map +1 -1
  10. package/dist/types/types.d.ts +3 -3
  11. package/dist/types/types.d.ts.map +1 -1
  12. package/dist/utils/bindInputRoleToResource.d.ts +4 -4
  13. package/dist/utils/bindInputRoleToResource.d.ts.map +1 -1
  14. package/dist/utils/bindInputRoleToResource.js.map +1 -1
  15. package/dist/utils/creation/resourceCreation.d.ts +8 -8
  16. package/dist/utils/creation/resourceCreation.d.ts.map +1 -1
  17. package/dist/utils/creation/resourceCreation.js.map +1 -1
  18. package/dist/utils/creation/runnableStrategyCreation.d.ts +3 -3
  19. package/dist/utils/creation/runnableStrategyCreation.d.ts.map +1 -1
  20. package/dist/utils/creation/runnableStrategyCreation.js.map +1 -1
  21. package/dist/utils/creation/stepCreation.d.ts +24 -24
  22. package/dist/utils/creation/stepCreation.d.ts.map +1 -1
  23. package/dist/utils/creation/stepCreation.js.map +1 -1
  24. package/dist/utils/extractData.d.ts +7 -7
  25. package/dist/utils/extractData.d.ts.map +1 -1
  26. package/dist/utils/extractData.js.map +1 -1
  27. package/dist/utils/parallelizeSteps.d.ts +2 -2
  28. package/dist/utils/parallelizeSteps.d.ts.map +1 -1
  29. package/dist/utils/parallelizeSteps.js.map +1 -1
  30. package/dist/utils/resolveResourceChain.d.ts +9 -9
  31. package/dist/utils/resolveResourceChain.d.ts.map +1 -1
  32. package/dist/utils/resolveResourceChain.js.map +1 -1
  33. package/package.json +2 -2
  34. package/src/integrations/firebase/createRunnableStrategy.ts +2 -2
  35. package/src/integrations/firebase/createStep.ts +13 -13
  36. package/src/integrations/firebase/firebaseAdminHelpers.ts +8 -8
  37. package/src/types/types.ts +5 -5
  38. package/src/utils/bindInputRoleToResource.ts +22 -22
  39. package/src/utils/creation/resourceCreation.ts +25 -25
  40. package/src/utils/creation/runnableStrategyCreation.ts +13 -13
  41. package/src/utils/creation/stepCreation.ts +42 -42
  42. package/src/utils/extractData.ts +33 -33
  43. package/src/utils/parallelizeSteps.ts +19 -19
  44. package/src/utils/resolveResourceChain.ts +21 -21
  45. package/tsconfig.tsbuildinfo +1 -1
@@ -1,17 +1,17 @@
1
1
  import type {
2
- BranchStepJson,
3
- ForStepJson,
4
- ToolStepIdJson,
5
- ToolStepJson,
6
- ResourceRoleIdJson,
7
- StepJson,
8
- StrategyStateJson,
9
- WhileStepJson,
2
+ BranchStep,
3
+ ForStep,
4
+ ToolStepId,
5
+ ToolStep,
6
+ ResourceRoleId,
7
+ Step,
8
+ StrategyState,
9
+ WhileStep,
10
10
  } from '@toolproof-core/schema';
11
11
  import { CONSTANTS } from '../artifacts/artifacts.js';
12
12
 
13
13
 
14
- export function getIndependentThreads(steps: StepJson[], strategyState: StrategyStateJson): StepJson[][] {
14
+ export function getIndependentThreads(steps: Step[], strategyState: StrategyState): Step[][] {
15
15
  type OwnerIndex = number;
16
16
 
17
17
  const getOwnerLabel = (ownerIndex: OwnerIndex) => {
@@ -20,11 +20,11 @@ export function getIndependentThreads(steps: StepJson[], strategyState: Strategy
20
20
  };
21
21
 
22
22
  // Map each toolStep.id (including macro-nested tool steps) to owning top-level step index.
23
- const toolStepIdToOwner = new Map<ToolStepIdJson, OwnerIndex>();
24
- const ownerToToolStepIds = new Map<OwnerIndex, ToolStepIdJson[]>();
25
- const toolStepById = new Map<ToolStepIdJson, ToolStepJson>();
23
+ const toolStepIdToOwner = new Map<ToolStepId, OwnerIndex>();
24
+ const ownerToToolStepIds = new Map<OwnerIndex, ToolStepId[]>();
25
+ const toolStepById = new Map<ToolStepId, ToolStep>();
26
26
 
27
- const addToolStep = (toolStep: ToolStepJson | undefined, ownerIndex: OwnerIndex) => {
27
+ const addToolStep = (toolStep: ToolStep | undefined, ownerIndex: OwnerIndex) => {
28
28
  if (!toolStep?.id) return;
29
29
 
30
30
  const existingOwner = toolStepIdToOwner.get(toolStep.id);
@@ -43,26 +43,26 @@ export function getIndependentThreads(steps: StepJson[], strategyState: Strategy
43
43
 
44
44
  steps.forEach((step, ownerIndex) => {
45
45
  if (step.stepKind === CONSTANTS.Enums.StepKind.tool) {
46
- addToolStep(step as ToolStepJson, ownerIndex);
46
+ addToolStep(step as ToolStep, ownerIndex);
47
47
  return;
48
48
  }
49
49
 
50
50
  if (step.stepKind === CONSTANTS.Enums.StepKind.for) {
51
- const loop = step as ForStepJson;
51
+ const loop = step as ForStep;
52
52
  addToolStep(loop.case?.what, ownerIndex);
53
53
  addToolStep(loop.case?.when, ownerIndex);
54
54
  return;
55
55
  }
56
56
 
57
57
  if (step.stepKind === CONSTANTS.Enums.StepKind.while) {
58
- const loop = step as WhileStepJson;
58
+ const loop = step as WhileStep;
59
59
  addToolStep(loop.case?.what, ownerIndex);
60
60
  addToolStep(loop.case?.when, ownerIndex);
61
61
  return;
62
62
  }
63
63
 
64
64
  if (step.stepKind === CONSTANTS.Enums.StepKind.branch) {
65
- const branch = step as BranchStepJson;
65
+ const branch = step as BranchStep;
66
66
  for (const caseItem of branch.cases ?? []) {
67
67
  addToolStep(caseItem?.what, ownerIndex);
68
68
  addToolStep(caseItem?.when, ownerIndex);
@@ -94,10 +94,10 @@ export function getIndependentThreads(steps: StepJson[], strategyState: Strategy
94
94
  const bucket = strategyState?.[toolStepId] ?? ({} as any);
95
95
 
96
96
  for (const inputRoleId of inputBindings) {
97
- const entry = bucket?.[inputRoleId as ResourceRoleIdJson] as any;
97
+ const entry = bucket?.[inputRoleId as ResourceRoleId] as any;
98
98
  if (!entry || entry.resourceShellKind !== 'internalInputPotential') continue;
99
99
 
100
- const creatorToolStepId = entry?.creationContext?.toolStepId as ToolStepIdJson | undefined;
100
+ const creatorToolStepId = entry?.creationContext?.toolStepId as ToolStepId | undefined;
101
101
  if (!creatorToolStepId) {
102
102
  throw new Error(
103
103
  `Unresolvable internalInputPotential in toolStep '${toolStepId}' (${getOwnerLabel(ownerIndex)}): missing creationContext.toolStepId for role '${inputRoleId}'`
@@ -1,29 +1,29 @@
1
1
  import type {
2
- CreationContextJson,
3
- ExternalInputPotentialShellJson,
4
- InternalInputPotentialShellJson,
5
- OutputPotentialShellJson,
6
- ResourceJson,
7
- ResourcePotentialJson,
8
- StrategyStateJson,
2
+ CreationContext,
3
+ ExternalInputPotentialShell,
4
+ InternalInputPotentialShell,
5
+ OutputPotentialShell,
6
+ Resource,
7
+ ResourcePotential,
8
+ StrategyState,
9
9
  } from '@toolproof-core/schema';
10
10
  import { CONSTANTS } from '../artifacts/artifacts.js';
11
11
 
12
12
  export type ResolveResult =
13
- | { status: typeof CONSTANTS.Enums.ResourceShellKind.materialized; entry: ResourceJson; path: CreationContextJson[] }
14
- | { status: typeof CONSTANTS.Enums.ResourceShellKind.externalInputPotential; entry: ExternalInputPotentialShellJson; path: CreationContextJson[] }
15
- | { status: typeof CONSTANTS.Enums.ResourceShellKind.outputPotential; entry: OutputPotentialShellJson; path: CreationContextJson[] }
16
- | { status: 'unresolved'; reason: 'not-found' | 'cycle' | 'depth-exceeded'; path: CreationContextJson[] };
13
+ | { status: typeof CONSTANTS.Enums.ResourceShellKind.materialized; entry: Resource; path: CreationContext[] }
14
+ | { status: typeof CONSTANTS.Enums.ResourceShellKind.externalInputPotential; entry: ExternalInputPotentialShell; path: CreationContext[] }
15
+ | { status: typeof CONSTANTS.Enums.ResourceShellKind.outputPotential; entry: OutputPotentialShell; path: CreationContext[] }
16
+ | { status: 'unresolved'; reason: 'not-found' | 'cycle' | 'depth-exceeded'; path: CreationContext[] };
17
17
 
18
18
  export function resolveResourceChain(
19
- strategyState: StrategyStateJson,
20
- start: CreationContextJson,
19
+ strategyState: StrategyState,
20
+ start: CreationContext,
21
21
  opts?: { maxDepth?: number }
22
22
  ): ResolveResult {
23
23
  const maxDepth = opts?.maxDepth ?? 50;
24
24
  const visited = new Set<string>();
25
- const path: CreationContextJson[] = [];
26
- let current: CreationContextJson = start;
25
+ const path: CreationContext[] = [];
26
+ let current: CreationContext = start;
27
27
 
28
28
  for (let depth = 0; depth <= maxDepth; depth++) {
29
29
  path.push(current);
@@ -36,25 +36,25 @@ export function resolveResourceChain(
36
36
  const bucket = strategyState[current.toolStepId];
37
37
  if (!bucket) return { status: 'unresolved', reason: 'not-found', path };
38
38
  const entry = bucket[current.resourceRoleId] as (
39
- | ResourceJson
40
- | ResourcePotentialJson
39
+ | Resource
40
+ | ResourcePotential
41
41
  | undefined
42
42
  );
43
43
  if (!entry) return { status: 'unresolved', reason: 'not-found', path };
44
44
 
45
45
  if (entry.resourceShellKind === CONSTANTS.Enums.ResourceShellKind.materialized) {
46
- return { status: CONSTANTS.Enums.ResourceShellKind.materialized, entry: entry as ResourceJson, path };
46
+ return { status: CONSTANTS.Enums.ResourceShellKind.materialized, entry: entry as Resource, path };
47
47
  }
48
48
  if (entry.resourceShellKind === CONSTANTS.Enums.ResourceShellKind.externalInputPotential) {
49
- return { status: CONSTANTS.Enums.ResourceShellKind.externalInputPotential, entry: entry as ExternalInputPotentialShellJson, path };
49
+ return { status: CONSTANTS.Enums.ResourceShellKind.externalInputPotential, entry: entry as ExternalInputPotentialShell, path };
50
50
  }
51
51
  if (entry.resourceShellKind === CONSTANTS.Enums.ResourceShellKind.outputPotential) {
52
- return { status: CONSTANTS.Enums.ResourceShellKind.outputPotential, entry: entry as OutputPotentialShellJson, path };
52
+ return { status: CONSTANTS.Enums.ResourceShellKind.outputPotential, entry: entry as OutputPotentialShell, path };
53
53
  }
54
54
 
55
55
  // internalInputPotential: follow ref backwards
56
56
  if (entry.resourceShellKind === CONSTANTS.Enums.ResourceShellKind.internalInputPotential) {
57
- current = (entry as InternalInputPotentialShellJson).creationContext;
57
+ current = (entry as InternalInputPotentialShell).creationContext;
58
58
  continue;
59
59
  }
60
60