@toolproof-core/lib 1.0.49 → 1.0.51

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.
@@ -1,34 +1,20 @@
1
1
  import type {
2
- ToolStepPath,
3
- ToolStepPathSpec,
4
- } from '@toolproof-core/genesis';
2
+ StepPath,
3
+ StepPathSpec,
4
+ } from '@toolproof-core/genesis/types';
5
5
 
6
- function getToolStepPathSuffix(spec: Pick<ToolStepPathSpec, 'toolStepPathSlot' | 'caseIndex'>): string {
7
- if (spec.toolStepPathSlot === 'self') {
8
- return '/self';
9
- }
6
+ function getStepPathSuffix(spec: StepPathSpec): string {
7
+ return spec.segments
8
+ .map((segment) => {
9
+ if (segment.segmentKind === 'case') {
10
+ return `/case/${segment.slot}`;
11
+ }
10
12
 
11
- if (spec.toolStepPathSlot === 'cases/when' || spec.toolStepPathSlot === 'cases/what') {
12
- if (typeof spec.caseIndex !== 'number') {
13
- throw new Error('Expected caseIndex for branch tool-step path construction');
14
- }
15
-
16
- return `/cases/${spec.caseIndex}/${spec.toolStepPathSlot === 'cases/when' ? 'when' : 'what'}`;
17
- }
18
-
19
- if (spec.toolStepPathSlot === 'case/when') {
20
- return '/case/when';
21
- }
22
-
23
- if (spec.toolStepPathSlot === 'case/what') {
24
- return '/case/what';
25
- }
26
-
27
- throw new Error(
28
- `Unsupported tool-step path slot '${String(spec.toolStepPathSlot)}'`,
29
- );
13
+ return `/cases/${segment.caseIndex}/${segment.slot}`;
14
+ })
15
+ .join('');
30
16
  }
31
17
 
32
- export function toToolStepPath(spec: ToolStepPathSpec): ToolStepPath {
33
- return `/threads/${spec.threadIndex}/steps/${spec.stepIndex}${getToolStepPathSuffix(spec)}` as ToolStepPath;
18
+ export function toStepPath(spec: StepPathSpec): StepPath {
19
+ return `/threads/${spec.threadIndex}/steps/${spec.stepIndex}${getStepPathSuffix(spec)}` as StepPath;
34
20
  }