@toolproof-core/lib 1.0.26 → 1.0.28

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 (44) hide show
  1. package/dist/artifacts/artifacts.d.ts +30 -30
  2. package/dist/integrations/firebase/createRunnableStrategy.js +4 -4
  3. package/dist/integrations/firebase/createRunnableStrategy.js.map +1 -1
  4. package/dist/integrations/firebase/createStep.js +17 -17
  5. package/dist/integrations/firebase/createStep.js.map +1 -1
  6. package/dist/integrations/firebase/firebaseAdminHelpers.d.ts +5 -5
  7. package/dist/integrations/firebase/firebaseAdminHelpers.d.ts.map +1 -1
  8. package/dist/integrations/firebase/firebaseAdminHelpers.js +11 -11
  9. package/dist/integrations/firebase/firebaseAdminHelpers.js.map +1 -1
  10. package/dist/types/types.d.ts +6 -6
  11. package/dist/types/types.d.ts.map +1 -1
  12. package/dist/utils/bindInputRoleToResource.js +2 -2
  13. package/dist/utils/bindInputRoleToResource.js.map +1 -1
  14. package/dist/utils/creation/resourceCreation.d.ts +5 -5
  15. package/dist/utils/creation/resourceCreation.d.ts.map +1 -1
  16. package/dist/utils/creation/resourceCreation.js +14 -14
  17. package/dist/utils/creation/resourceCreation.js.map +1 -1
  18. package/dist/utils/creation/runnableStrategyCreation.d.ts +2 -2
  19. package/dist/utils/creation/runnableStrategyCreation.d.ts.map +1 -1
  20. package/dist/utils/creation/runnableStrategyCreation.js +7 -7
  21. package/dist/utils/creation/runnableStrategyCreation.js.map +1 -1
  22. package/dist/utils/creation/stepCreation.d.ts +17 -17
  23. package/dist/utils/creation/stepCreation.d.ts.map +1 -1
  24. package/dist/utils/creation/stepCreation.js +20 -20
  25. package/dist/utils/creation/stepCreation.js.map +1 -1
  26. package/dist/utils/extractData.d.ts +9 -9
  27. package/dist/utils/extractData.d.ts.map +1 -1
  28. package/dist/utils/extractData.js +22 -22
  29. package/dist/utils/extractData.js.map +1 -1
  30. package/dist/utils/parallelizeSteps.js +7 -7
  31. package/dist/utils/parallelizeSteps.js.map +1 -1
  32. package/package.json +2 -2
  33. package/src/integrations/firebase/createRunnableStrategy.ts +4 -4
  34. package/src/integrations/firebase/createStep.ts +17 -17
  35. package/src/integrations/firebase/firebaseAdminHelpers.ts +18 -18
  36. package/src/types/types.ts +6 -6
  37. package/src/utils/bindInputRoleToResource.ts +2 -2
  38. package/src/utils/creation/resourceCreation.ts +19 -19
  39. package/src/utils/creation/runnableStrategyCreation.ts +10 -10
  40. package/src/utils/creation/stepCreation.ts +39 -39
  41. package/src/utils/extractData.ts +42 -42
  42. package/src/utils/parallelizeSteps.ts +14 -14
  43. package/toolproof-core-lib-1.0.27.tgz +0 -0
  44. package/tsconfig.tsbuildinfo +1 -1
@@ -1,7 +1,7 @@
1
1
  import type {
2
2
  StepKindJson,
3
3
  ResourceJson,
4
- ResourceTypeIdentityJson,
4
+ ResourceTypeIdJson,
5
5
  } from '@toolproof-core/schema';
6
6
  import { CONSTANTS } from '../artifacts/artifacts.js';
7
7
  import { MAPPINGS } from '../artifacts/artifacts.js';
@@ -12,16 +12,16 @@ export type Collection = keyof typeof CONSTANTS.Persistence.Collections;
12
12
 
13
13
  export type SchemaLike = Record<string, unknown>;
14
14
 
15
- export type ResourcesByType = Record<ResourceTypeIdentityJson, ResourceJson[]>;
15
+ export type ResourcesByType = Record<ResourceTypeIdJson, ResourceJson[]>;
16
16
 
17
- export type IdentityName = keyof typeof MAPPINGS.IdentityNameToIdentityPrefix;
17
+ export type IdName = keyof typeof MAPPINGS.IdNameToIdPrefix;
18
18
 
19
- export type IdentityStringByIdentityName<K extends IdentityName> = `${(typeof MAPPINGS.IdentityNameToIdentityPrefix)[K]}${string}`;
19
+ export type IdStringByIdName<K extends IdName> = `${(typeof MAPPINGS.IdNameToIdPrefix)[K]}${string}`;
20
20
 
21
- export type StepIdentityStringByStepKind<K extends StepKindJson> = `${(typeof MAPPINGS.StepKindToStepIdentityPrefix)[K]}${string}`;
21
+ export type StepIdStringByStepKind<K extends StepKindJson> = `${(typeof MAPPINGS.StepKindToStepIdPrefix)[K]}${string}`;
22
22
 
23
23
  export interface NucleusBaseSmall<T extends string = string> {
24
- identity: T;
24
+ id: T;
25
25
  }
26
26
 
27
27
  export interface NucleusBaseLarge<T extends string = string> extends NucleusBaseSmall<T> {
@@ -56,7 +56,7 @@ export function bindInputRefInStrategyState(
56
56
  if (result.status === CONSTANTS.Enums.ResourceShellKind.externalInputPotential) {
57
57
  const externalInput = result.entry;
58
58
  const reusedExternalInput: ExternalInputPotentialShellJson = {
59
- identity: externalInput.identity,
59
+ id: externalInput.id,
60
60
  resourceTypeHandle: externalInput.resourceTypeHandle,
61
61
  resourceShellKind: CONSTANTS.Enums.ResourceShellKind.externalInputPotential,
62
62
  };
@@ -72,7 +72,7 @@ export function bindInputRefInStrategyState(
72
72
 
73
73
  if (result.status === CONSTANTS.Enums.ResourceShellKind.outputPotential) {
74
74
  const potentialInput: InternalInputPotentialShellJson = {
75
- identity: sourceEntry.identity,
75
+ id: sourceEntry.id,
76
76
  resourceTypeHandle: sourceEntry.resourceTypeHandle,
77
77
  creationContext: {
78
78
  toolStepHandle: source.toolStepHandle,
@@ -3,14 +3,14 @@ import type {
3
3
  ExternalInputPotentialShellJson,
4
4
  InternalInputPotentialShellJson,
5
5
  OutputPotentialShellJson,
6
- ResourceIdentityJson,
6
+ ResourceIdJson,
7
7
  ResourceJson,
8
- ResourceTypeIdentityJson,
8
+ ResourceTypeIdJson,
9
9
  } from '@toolproof-core/schema';
10
10
  import { CONSTANTS } from '../../artifacts/artifacts.js';
11
11
 
12
- export function generatePath(resourceTypeHandle: ResourceTypeIdentityJson, identity: ResourceIdentityJson): string {
13
- return `${resourceTypeHandle}/${identity}.json`;
12
+ export function generatePath(resourceTypeHandle: ResourceTypeIdJson, id: ResourceIdJson): string {
13
+ return `${resourceTypeHandle}/${id}.json`;
14
14
  }
15
15
 
16
16
  export function createMaterializedFromOutputPotential(
@@ -18,11 +18,11 @@ export function createMaterializedFromOutputPotential(
18
18
  nucleus: unknown,
19
19
  timestamp?: string,
20
20
  ): ResourceJson {
21
- const { identity, resourceTypeHandle, creationContext } = outputPotential;
22
- const path = generatePath(resourceTypeHandle, identity);
21
+ const { id, resourceTypeHandle, creationContext } = outputPotential;
22
+ const path = generatePath(resourceTypeHandle, id);
23
23
 
24
24
  return {
25
- identity,
25
+ id,
26
26
  resourceTypeHandle,
27
27
  creationContext,
28
28
  resourceShellKind: CONSTANTS.Enums.ResourceShellKind.materialized,
@@ -38,11 +38,11 @@ export function createMaterializedFromInputPotential(
38
38
  nucleus: unknown,
39
39
  timestamp?: string,
40
40
  ): ResourceJson {
41
- const { identity, resourceTypeHandle, creationContext } = inputPotential;
42
- const path = generatePath(resourceTypeHandle, identity);
41
+ const { id, resourceTypeHandle, creationContext } = inputPotential;
42
+ const path = generatePath(resourceTypeHandle, id);
43
43
 
44
44
  return {
45
- identity,
45
+ id,
46
46
  resourceTypeHandle,
47
47
  creationContext,
48
48
  resourceShellKind: CONSTANTS.Enums.ResourceShellKind.materialized,
@@ -66,23 +66,23 @@ export function createMaterializedFromPotential(
66
66
  }
67
67
 
68
68
  export function createExternalInputPotential(
69
- identity: ResourceIdentityJson,
70
- resourceTypeHandle: ResourceTypeIdentityJson,
69
+ id: ResourceIdJson,
70
+ resourceTypeHandle: ResourceTypeIdJson,
71
71
  ): ExternalInputPotentialShellJson {
72
72
  return {
73
- identity,
73
+ id,
74
74
  resourceTypeHandle,
75
75
  resourceShellKind: CONSTANTS.Enums.ResourceShellKind.externalInputPotential,
76
76
  };
77
77
  }
78
78
 
79
79
  export function createInputPotential(
80
- identity: ResourceIdentityJson,
81
- resourceTypeHandle: ResourceTypeIdentityJson,
80
+ id: ResourceIdJson,
81
+ resourceTypeHandle: ResourceTypeIdJson,
82
82
  creationContext: CreationContextJson,
83
83
  ): InternalInputPotentialShellJson {
84
84
  return {
85
- identity,
85
+ id,
86
86
  resourceTypeHandle,
87
87
  creationContext,
88
88
  resourceShellKind: CONSTANTS.Enums.ResourceShellKind.internalInputPotential,
@@ -90,12 +90,12 @@ export function createInputPotential(
90
90
  }
91
91
 
92
92
  export function createOutputPotential(
93
- identity: ResourceIdentityJson,
94
- resourceTypeHandle: ResourceTypeIdentityJson,
93
+ id: ResourceIdJson,
94
+ resourceTypeHandle: ResourceTypeIdJson,
95
95
  creationContext: CreationContextJson,
96
96
  ): OutputPotentialShellJson {
97
97
  return {
98
- identity,
98
+ id,
99
99
  resourceTypeHandle,
100
100
  creationContext,
101
101
  resourceShellKind: CONSTANTS.Enums.ResourceShellKind.outputPotential,
@@ -1,10 +1,10 @@
1
1
  import type {
2
2
  RawStrategyJson,
3
- RunnableStrategyIdentityJson,
3
+ RunnableStrategyIdJson,
4
4
  RunnableStrategyJson,
5
5
  StepJson,
6
6
  StepArrayByStrategyThreadJson,
7
- StrategyThreadIdentityJson,
7
+ StrategyThreadIdJson,
8
8
  } from '@toolproof-core/schema';
9
9
  import { getIndependentThreads } from '../parallelizeSteps.js';
10
10
 
@@ -14,28 +14,28 @@ export function getRunnableStrategyThreadGroups(rawStrategy: RawStrategyJson): S
14
14
 
15
15
  export function buildRunnableStrategy(
16
16
  rawStrategy: RawStrategyJson,
17
- runnableStrategyIdentity: RunnableStrategyIdentityJson,
17
+ runnableStrategyId: RunnableStrategyIdJson,
18
18
  threadStepGroups: StepJson[][],
19
- threadIdentities: StrategyThreadIdentityJson[],
19
+ threadIdentities: StrategyThreadIdJson[],
20
20
  ): RunnableStrategyJson {
21
21
  if (threadStepGroups.length !== threadIdentities.length) {
22
- throw new Error('buildRunnableStrategy requires one thread identity per thread group');
22
+ throw new Error('buildRunnableStrategy requires one thread id per thread group');
23
23
  }
24
24
 
25
25
  const stepsByStrategyThread: StepArrayByStrategyThreadJson = {};
26
26
 
27
27
  for (const [index, group] of threadStepGroups.entries()) {
28
- const threadIdentity = threadIdentities[index];
28
+ const threadId = threadIdentities[index];
29
29
 
30
- if (!threadIdentity) {
31
- throw new Error(`Missing thread identity for thread group index ${index}`);
30
+ if (!threadId) {
31
+ throw new Error(`Missing thread id for thread group index ${index}`);
32
32
  }
33
33
 
34
- stepsByStrategyThread[threadIdentity] = group;
34
+ stepsByStrategyThread[threadId] = group;
35
35
  }
36
36
 
37
37
  return {
38
- identity: runnableStrategyIdentity,
38
+ id: runnableStrategyId,
39
39
  stepsByStrategyThread,
40
40
  strategyState: rawStrategy.strategyState,
41
41
  };
@@ -1,14 +1,14 @@
1
1
  import type {
2
- BranchStepIdentityJson,
2
+ BranchStepIdJson,
3
3
  BranchStepJson,
4
4
  CaseJson,
5
- ForStepIdentityJson,
5
+ ForStepIdJson,
6
6
  ForStepJson,
7
7
  ToolJson,
8
- ToolStepIdentityJson,
8
+ ToolStepIdJson,
9
9
  ToolStepJson,
10
- ResourceRoleIdentityJson,
11
- WhileStepIdentityJson,
10
+ ResourceRoleIdJson,
11
+ WhileStepIdJson,
12
12
  WhileStepJson,
13
13
  } from '@toolproof-core/schema';
14
14
  import { CONSTANTS } from '../../artifacts/artifacts.js';
@@ -16,20 +16,20 @@ import { CONSTANTS } from '../../artifacts/artifacts.js';
16
16
  export type LoopStepBuildIdentities =
17
17
  | {
18
18
  stepKind: typeof CONSTANTS.Enums.StepKind.for;
19
- stepIdentity: ForStepIdentityJson;
20
- whatIdentity: ToolStepIdentityJson;
21
- whenIdentity: ToolStepIdentityJson;
19
+ stepId: ForStepIdJson;
20
+ whatId: ToolStepIdJson;
21
+ whenId: ToolStepIdJson;
22
22
  }
23
23
  | {
24
24
  stepKind: typeof CONSTANTS.Enums.StepKind.while;
25
- stepIdentity: WhileStepIdentityJson;
26
- whatIdentity: ToolStepIdentityJson;
27
- whenIdentity: ToolStepIdentityJson;
25
+ stepId: WhileStepIdJson;
26
+ whatId: ToolStepIdJson;
27
+ whenId: ToolStepIdJson;
28
28
  };
29
29
 
30
30
  export type BranchCaseBuildIdentities = {
31
- whatIdentity: ToolStepIdentityJson;
32
- whenIdentity: ToolStepIdentityJson;
31
+ whatId: ToolStepIdJson;
32
+ whenId: ToolStepIdJson;
33
33
  };
34
34
 
35
35
  function assertNonEmpty<T>(arr: T[], msg: string): asserts arr is [T, ...T[]] {
@@ -40,19 +40,19 @@ function assertNonEmpty<T>(arr: T[], msg: string): asserts arr is [T, ...T[]] {
40
40
 
41
41
  function getRoleBindingSpec(tool: ToolJson): ToolStepJson['roleBindingSpec'] {
42
42
  return {
43
- inputBindings: Object.keys(tool.roleSpec.inputRoleValueByIdentity) as ResourceRoleIdentityJson[],
44
- outputBindings: Object.keys(tool.roleSpec.outputRoleValueByIdentity) as ResourceRoleIdentityJson[],
43
+ inputBindings: Object.keys(tool.roleSpec.inputRoleValueById) as ResourceRoleIdJson[],
44
+ outputBindings: Object.keys(tool.roleSpec.outputRoleValueById) as ResourceRoleIdJson[],
45
45
  };
46
46
  }
47
47
 
48
48
  export function buildToolStepFromTool(
49
49
  tool: ToolJson,
50
- identity: ToolStepIdentityJson,
50
+ id: ToolStepIdJson,
51
51
  ): ToolStepJson {
52
52
  return {
53
- identity,
53
+ id,
54
54
  stepKind: CONSTANTS.Enums.StepKind.tool,
55
- toolHandle: tool.identity,
55
+ toolHandle: tool.id,
56
56
  roleBindingSpec: getRoleBindingSpec(tool),
57
57
  };
58
58
  }
@@ -62,19 +62,19 @@ export function buildLoopStepFromToolPair(
62
62
  whenTool: ToolJson,
63
63
  identities: LoopStepBuildIdentities,
64
64
  ): ForStepJson | WhileStepJson {
65
- const what = buildToolStepFromTool(whatTool, identities.whatIdentity);
66
- const when = buildToolStepFromTool(whenTool, identities.whenIdentity);
65
+ const what = buildToolStepFromTool(whatTool, identities.whatId);
66
+ const when = buildToolStepFromTool(whenTool, identities.whenId);
67
67
 
68
68
  if (identities.stepKind === CONSTANTS.Enums.StepKind.for) {
69
69
  return {
70
- identity: identities.stepIdentity,
70
+ id: identities.stepId,
71
71
  stepKind: CONSTANTS.Enums.StepKind.for,
72
72
  case: { what, when },
73
73
  };
74
74
  }
75
75
 
76
76
  return {
77
- identity: identities.stepIdentity,
77
+ id: identities.stepId,
78
78
  stepKind: CONSTANTS.Enums.StepKind.while,
79
79
  case: { what, when },
80
80
  };
@@ -82,11 +82,11 @@ export function buildLoopStepFromToolPair(
82
82
 
83
83
  export function buildBranchStepFromToolPairs(
84
84
  cases: Array<{ whatTool: ToolJson; whenTool: ToolJson }>,
85
- branchIdentity: BranchStepIdentityJson,
85
+ branchId: BranchStepIdJson,
86
86
  caseIdentities: BranchCaseBuildIdentities[],
87
87
  ): BranchStepJson {
88
88
  if (cases.length !== caseIdentities.length) {
89
- throw new Error('buildBranchStepFromToolPairs requires one identity pair per case');
89
+ throw new Error('buildBranchStepFromToolPairs requires one id pair per case');
90
90
  }
91
91
 
92
92
  const resolved = cases.map(({ whatTool, whenTool }, index) => {
@@ -96,15 +96,15 @@ export function buildBranchStepFromToolPairs(
96
96
  throw new Error(`Missing case identities for case index ${index}`);
97
97
  }
98
98
 
99
- const what = buildToolStepFromTool(whatTool, identities.whatIdentity);
100
- const when = buildToolStepFromTool(whenTool, identities.whenIdentity);
99
+ const what = buildToolStepFromTool(whatTool, identities.whatId);
100
+ const when = buildToolStepFromTool(whenTool, identities.whenId);
101
101
  return { what, when } satisfies CaseJson;
102
102
  });
103
103
 
104
104
  assertNonEmpty(resolved, 'buildBranchStepFromToolPairs requires at least one case');
105
105
 
106
106
  return {
107
- identity: branchIdentity,
107
+ id: branchId,
108
108
  stepKind: CONSTANTS.Enums.StepKind.branch,
109
109
  cases: resolved,
110
110
  };
@@ -113,22 +113,22 @@ export function buildBranchStepFromToolPairs(
113
113
  export function cloneForStepWithIdentities(
114
114
  forStep: ForStepJson,
115
115
  identities: {
116
- stepIdentity: ForStepIdentityJson;
117
- whatIdentity: ToolStepIdentityJson;
118
- whenIdentity: ToolStepIdentityJson;
116
+ stepId: ForStepIdJson;
117
+ whatId: ToolStepIdJson;
118
+ whenId: ToolStepIdJson;
119
119
  },
120
120
  ): ForStepJson {
121
121
  return {
122
- identity: identities.stepIdentity,
122
+ id: identities.stepId,
123
123
  stepKind: CONSTANTS.Enums.StepKind.for,
124
124
  case: {
125
125
  what: {
126
126
  ...forStep.case.what,
127
- identity: identities.whatIdentity,
127
+ id: identities.whatId,
128
128
  },
129
129
  when: {
130
130
  ...forStep.case.when,
131
- identity: identities.whenIdentity,
131
+ id: identities.whenId,
132
132
  },
133
133
  },
134
134
  };
@@ -137,22 +137,22 @@ export function cloneForStepWithIdentities(
137
137
  export function cloneWhileStepWithIdentities(
138
138
  whileStep: WhileStepJson,
139
139
  identities: {
140
- stepIdentity: WhileStepIdentityJson;
141
- whatIdentity: ToolStepIdentityJson;
142
- whenIdentity: ToolStepIdentityJson;
140
+ stepId: WhileStepIdJson;
141
+ whatId: ToolStepIdJson;
142
+ whenId: ToolStepIdJson;
143
143
  },
144
144
  ): WhileStepJson {
145
145
  return {
146
- identity: identities.stepIdentity,
146
+ id: identities.stepId,
147
147
  stepKind: CONSTANTS.Enums.StepKind.while,
148
148
  case: {
149
149
  what: {
150
150
  ...whileStep.case.what,
151
- identity: identities.whatIdentity,
151
+ id: identities.whatId,
152
152
  },
153
153
  when: {
154
154
  ...whileStep.case.when,
155
- identity: identities.whenIdentity,
155
+ id: identities.whenId,
156
156
  },
157
157
  },
158
158
  };
@@ -1,22 +1,22 @@
1
1
  import type {
2
2
  RawStrategyJson,
3
- ToolIdentityJson,
3
+ ToolIdJson,
4
4
  ToolJson,
5
- ToolStepIdentityJson,
5
+ ToolStepIdJson,
6
6
  ToolStepJson,
7
7
  StepJson,
8
- ResourceRoleIdentityJson,
8
+ ResourceRoleIdJson,
9
9
  ResourceRoleJson,
10
- ResourceIdentityJson,
11
- ResourceTypeIdentityJson,
10
+ ResourceIdJson,
11
+ ResourceTypeIdJson,
12
12
  ResourceJson,
13
13
  } from '@toolproof-core/schema';
14
14
  import { CONSTANTS } from '../artifacts/artifacts.js';
15
15
 
16
16
 
17
- export function extractToolHandlesFromRawStrategy(rawStrategy: RawStrategyJson): ToolIdentityJson[] {
17
+ export function extractToolHandlesFromRawStrategy(rawStrategy: RawStrategyJson): ToolIdJson[] {
18
18
  const toolSteps = extractToolStepsFromRawStrategy(rawStrategy);
19
- const ids = new Set<ToolIdentityJson>();
19
+ const ids = new Set<ToolIdJson>();
20
20
  for (const jStep of toolSteps) {
21
21
  ids.add(jStep.toolHandle);
22
22
  }
@@ -25,13 +25,13 @@ export function extractToolHandlesFromRawStrategy(rawStrategy: RawStrategyJson):
25
25
 
26
26
  export function extractToolStepsFromRawStrategy(rawStrategy: RawStrategyJson): ToolStepJson[] {
27
27
  const toolSteps: ToolStepJson[] = [];
28
- const seen = new Set<ToolStepIdentityJson>();
28
+ const seen = new Set<ToolStepIdJson>();
29
29
 
30
30
  const addToolStep = (toolStep: ToolStepJson) => {
31
- if (seen.has(toolStep.identity)) {
32
- throw new Error(`Duplicate tool step identity encountered: ${toolStep.identity}`);
31
+ if (seen.has(toolStep.id)) {
32
+ throw new Error(`Duplicate tool step id encountered: ${toolStep.id}`);
33
33
  }
34
- seen.add(toolStep.identity);
34
+ seen.add(toolStep.id);
35
35
  toolSteps.push(toolStep);
36
36
  };
37
37
 
@@ -69,23 +69,23 @@ export function extractToolStepsFromRawStrategy(rawStrategy: RawStrategyJson): T
69
69
  }
70
70
 
71
71
 
72
- export function extractRoleMapFromRawStrategy(rawStrategy: RawStrategyJson, toolMap: Map<ToolIdentityJson, ToolJson>): Map<ResourceRoleIdentityJson, ResourceRoleJson> {
73
- const roleMap = new Map<ResourceRoleIdentityJson, ResourceRoleJson>();
72
+ export function extractRoleMapFromRawStrategy(rawStrategy: RawStrategyJson, toolMap: Map<ToolIdJson, ToolJson>): Map<ResourceRoleIdJson, ResourceRoleJson> {
73
+ const roleMap = new Map<ResourceRoleIdJson, ResourceRoleJson>();
74
74
  const toolHandles = extractToolHandlesFromRawStrategy(rawStrategy);
75
75
 
76
76
  for (const toolHandle of toolHandles) {
77
77
  const tool = toolMap.get(toolHandle);
78
78
  if (!tool) continue;
79
79
 
80
- for (const [rid, role] of Object.entries(tool.roleSpec.inputRoleValueByIdentity)) {
81
- roleMap.set(rid as ResourceRoleIdentityJson, {
82
- identity: rid as ResourceRoleIdentityJson,
80
+ for (const [rid, role] of Object.entries(tool.roleSpec.inputRoleValueById)) {
81
+ roleMap.set(rid as ResourceRoleIdJson, {
82
+ id: rid as ResourceRoleIdJson,
83
83
  ...role,
84
84
  });
85
85
  }
86
- for (const [rid, role] of Object.entries(tool.roleSpec.outputRoleValueByIdentity)) {
87
- roleMap.set(rid as ResourceRoleIdentityJson, {
88
- identity: rid as ResourceRoleIdentityJson,
86
+ for (const [rid, role] of Object.entries(tool.roleSpec.outputRoleValueById)) {
87
+ roleMap.set(rid as ResourceRoleIdJson, {
88
+ id: rid as ResourceRoleIdJson,
89
89
  ...role,
90
90
  });
91
91
  }
@@ -94,11 +94,11 @@ export function extractRoleMapFromRawStrategy(rawStrategy: RawStrategyJson, tool
94
94
  return roleMap;
95
95
  }
96
96
 
97
- export function extractSingleNonErrorOutputTypeHandle(tool: ToolJson): ResourceTypeIdentityJson | null {
97
+ export function extractSingleNonErrorOutputTypeHandle(tool: ToolJson): ResourceTypeIdJson | null {
98
98
  const errorRoleId = CONSTANTS.Cosmos.ROLE_ErrorOutput;
99
- const outputEntries = Object.entries(tool.roleSpec.outputRoleValueByIdentity).filter(([roleId]) => roleId !== errorRoleId);
99
+ const outputEntries = Object.entries(tool.roleSpec.outputRoleValueById).filter(([roleId]) => roleId !== errorRoleId);
100
100
  if (!outputEntries || !outputEntries[0] || outputEntries.length !== 1) {
101
- throw new Error(`Tool ${tool.identity} must have exactly one non-error output role to be branchable/loopable`);
101
+ throw new Error(`Tool ${tool.id} must have exactly one non-error output role to be branchable/loopable`);
102
102
  } // ATTENTION_PUREIFY
103
103
  const outputRole = outputEntries[0][1];
104
104
  return outputRole.resourceTypeHandle;
@@ -107,27 +107,27 @@ export function extractSingleNonErrorOutputTypeHandle(tool: ToolJson): ResourceT
107
107
 
108
108
 
109
109
  export function extractResourceMapForType<TResource extends ResourceJson = ResourceJson>(
110
- resourcesByType: Partial<Record<ResourceTypeIdentityJson, TResource[]>>,
111
- resourceTypeHandle: ResourceTypeIdentityJson
112
- ): Map<ResourceIdentityJson, TResource> {
110
+ resourcesByType: Partial<Record<ResourceTypeIdJson, TResource[]>>,
111
+ resourceTypeHandle: ResourceTypeIdJson
112
+ ): Map<ResourceIdJson, TResource> {
113
113
  const resources = resourcesByType[resourceTypeHandle] ?? [];
114
- const map = new Map<ResourceIdentityJson, TResource>();
114
+ const map = new Map<ResourceIdJson, TResource>();
115
115
 
116
116
  for (const resource of resources) {
117
- map.set(resource.identity, resource);
117
+ map.set(resource.id, resource);
118
118
  }
119
119
 
120
120
  return map;
121
121
  }
122
122
 
123
- // Only use this for resource types whose nuclei are entity-like objects with their own intrinsic identity.
124
- export function extractIdentityKeyedNucleusMapForType<
123
+ // Only use this for resource types whose nuclei are entity-like objects with their own intrinsic id.
124
+ export function extractIdKeyedNucleusMapForType<
125
125
  TKey extends string = string,
126
- TNucleus extends { identity: string | number | boolean } = { identity: string | number | boolean },
126
+ TNucleus extends { id: string | number | boolean } = { id: string | number | boolean },
127
127
  TResource extends ResourceJson = ResourceJson
128
128
  >(
129
- resourcesByType: Partial<Record<ResourceTypeIdentityJson, TResource[]>>,
130
- resourceTypeHandle: ResourceTypeIdentityJson,
129
+ resourcesByType: Partial<Record<ResourceTypeIdJson, TResource[]>>,
130
+ resourceTypeHandle: ResourceTypeIdJson,
131
131
  ): Map<TKey, TNucleus> {
132
132
  const resourceMap = extractResourceMapForType<TResource>(resourcesByType, resourceTypeHandle);
133
133
  const out = new Map<TKey, TNucleus>();
@@ -136,33 +136,33 @@ export function extractIdentityKeyedNucleusMapForType<
136
136
  const data = (resource as any).nucleus as unknown;
137
137
  if (data === null || data === undefined) {
138
138
  throw new Error(
139
- `Expected resource '${resource.identity}' of type '${resourceTypeHandle}' to have a nucleus`
139
+ `Expected resource '${resource.id}' of type '${resourceTypeHandle}' to have a nucleus`
140
140
  );
141
141
  }
142
142
  if (typeof data !== 'object') {
143
143
  throw new Error(
144
- `Expected resource '${resource.identity}' of type '${resourceTypeHandle}' to have an object nucleus with identity`
144
+ `Expected resource '${resource.id}' of type '${resourceTypeHandle}' to have an object nucleus with id`
145
145
  );
146
146
  }
147
147
 
148
- const maybeIdentity = (data as any).identity as unknown;
149
- if (maybeIdentity === null || maybeIdentity === undefined) {
148
+ const maybeId = (data as any).id as unknown;
149
+ if (maybeId === null || maybeId === undefined) {
150
150
  throw new Error(
151
- `Expected resource '${resource.identity}' of type '${resourceTypeHandle}' to have nucleus.identity`
151
+ `Expected resource '${resource.id}' of type '${resourceTypeHandle}' to have nucleus.id`
152
152
  );
153
153
  }
154
154
  if (
155
- typeof maybeIdentity !== 'string' &&
156
- typeof maybeIdentity !== 'number' &&
157
- typeof maybeIdentity !== 'boolean'
155
+ typeof maybeId !== 'string' &&
156
+ typeof maybeId !== 'number' &&
157
+ typeof maybeId !== 'boolean'
158
158
  ) {
159
159
  throw new Error(
160
- `Expected resource '${resource.identity}' of type '${resourceTypeHandle}' to have nucleus.identity as string, number, or boolean`
160
+ `Expected resource '${resource.id}' of type '${resourceTypeHandle}' to have nucleus.id as string, number, or boolean`
161
161
  );
162
162
  }
163
163
 
164
164
  const value = data as TNucleus;
165
- const key = String(maybeIdentity) as TKey;
165
+ const key = String(maybeId) as TKey;
166
166
 
167
167
  out.set(key, value);
168
168
  }
@@ -1,9 +1,9 @@
1
1
  import type {
2
2
  BranchStepJson,
3
3
  ForStepJson,
4
- ToolStepIdentityJson,
4
+ ToolStepIdJson,
5
5
  ToolStepJson,
6
- ResourceRoleIdentityJson,
6
+ ResourceRoleIdJson,
7
7
  StepJson,
8
8
  StrategyStateJson,
9
9
  WhileStepJson,
@@ -19,25 +19,25 @@ export function getIndependentThreads(steps: StepJson[], strategyState: Strategy
19
19
  return `steps[${ownerIndex}] stepKind=${(step as any)?.stepKind ?? 'unknown'}`;
20
20
  };
21
21
 
22
- // Map each toolStep.identity (including macro-nested tool steps) to owning top-level step index.
23
- const toolStepIdToOwner = new Map<ToolStepIdentityJson, OwnerIndex>();
24
- const ownerToToolStepIds = new Map<OwnerIndex, ToolStepIdentityJson[]>();
25
- const toolStepById = new Map<ToolStepIdentityJson, ToolStepJson>();
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>();
26
26
 
27
27
  const addToolStep = (toolStep: ToolStepJson | undefined, ownerIndex: OwnerIndex) => {
28
- if (!toolStep?.identity) return;
28
+ if (!toolStep?.id) return;
29
29
 
30
- const existingOwner = toolStepIdToOwner.get(toolStep.identity);
30
+ const existingOwner = toolStepIdToOwner.get(toolStep.id);
31
31
  if (existingOwner !== undefined) {
32
32
  throw new Error(
33
- `Duplicate toolStep.identity '${toolStep.identity}' found in ${getOwnerLabel(ownerIndex)} and ${getOwnerLabel(existingOwner)}`
33
+ `Duplicate toolStep.id '${toolStep.id}' found in ${getOwnerLabel(ownerIndex)} and ${getOwnerLabel(existingOwner)}`
34
34
  );
35
35
  }
36
36
 
37
- toolStepIdToOwner.set(toolStep.identity, ownerIndex);
38
- toolStepById.set(toolStep.identity, toolStep);
37
+ toolStepIdToOwner.set(toolStep.id, ownerIndex);
38
+ toolStepById.set(toolStep.id, toolStep);
39
39
  const bucket = ownerToToolStepIds.get(ownerIndex) ?? [];
40
- bucket.push(toolStep.identity);
40
+ bucket.push(toolStep.id);
41
41
  ownerToToolStepIds.set(ownerIndex, bucket);
42
42
  };
43
43
 
@@ -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 inputRoleHandle of inputBindings) {
97
- const entry = bucket?.[inputRoleHandle as ResourceRoleIdentityJson] as any;
97
+ const entry = bucket?.[inputRoleHandle as ResourceRoleIdJson] as any;
98
98
  if (!entry || entry.resourceShellKind !== 'internalInputPotential') continue;
99
99
 
100
- const creatorToolStepHandle = entry?.creationContext?.toolStepHandle as ToolStepIdentityJson | undefined;
100
+ const creatorToolStepHandle = entry?.creationContext?.toolStepHandle as ToolStepIdJson | undefined;
101
101
  if (!creatorToolStepHandle) {
102
102
  throw new Error(
103
103
  `Unresolvable internalInputPotential in toolStep '${toolStepId}' (${getOwnerLabel(ownerIndex)}): missing creationContext.toolStepHandle for role '${inputRoleHandle}'`
Binary file