@opencraw/studio 0.0.5 → 0.0.7

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 (40) hide show
  1. package/dist/index.esm.js +1393 -82
  2. package/dist/src/explain-why/index.d.ts +5 -0
  3. package/dist/src/explain-why/item-hint.algorithm.d.ts +13 -0
  4. package/dist/src/explain-why/why-sentence.mapper.d.ts +48 -0
  5. package/dist/src/explain-why/why.use-case.d.ts +26 -0
  6. package/dist/src/index.d.ts +4 -3
  7. package/dist/src/page-snapshot/hidden-marks.algorithm.d.ts +23 -0
  8. package/dist/src/page-snapshot/index.d.ts +7 -0
  9. package/dist/src/page-snapshot/rewrite-document.mapper.d.ts +27 -0
  10. package/dist/src/page-snapshot/snapshot.store.d.ts +14 -0
  11. package/dist/src/page-snapshot/take-snapshot.use-case.d.ts +34 -0
  12. package/dist/src/sample-run/index.d.ts +3 -1
  13. package/dist/src/sample-run/last-run.store.d.ts +17 -0
  14. package/dist/src/sample-run/run-sample.use-case.d.ts +15 -7
  15. package/dist/src/sample-run/sample-run-record.contract.d.ts +30 -1
  16. package/dist/src/selector-inference/class-token.policy.d.ts +35 -0
  17. package/dist/src/selector-inference/dom-path.model.d.ts +73 -0
  18. package/dist/src/selector-inference/index.d.ts +12 -0
  19. package/dist/src/selector-inference/list-inference.algorithm.d.ts +43 -0
  20. package/dist/src/selector-inference/selector-candidates.algorithm.d.ts +22 -0
  21. package/dist/src/selector-inference/selector-ranking.policy.d.ts +27 -0
  22. package/dist/src/selector-inference/shadow-dom.error.d.ts +11 -0
  23. package/dist/src/selector-inference/take-kind.policy.d.ts +12 -0
  24. package/dist/src/studio-api/command.contract.d.ts +103 -0
  25. package/dist/src/studio-api/event.contract.d.ts +41 -1
  26. package/dist/src/studio-api/index.d.ts +12 -4
  27. package/dist/src/studio-api/infer-selector-view.contract.d.ts +68 -0
  28. package/dist/src/studio-api/snapshot-view.contract.d.ts +9 -0
  29. package/dist/src/studio-api/verify-selector-view.contract.d.ts +18 -0
  30. package/dist/src/studio-api/why-view.contract.d.ts +16 -0
  31. package/dist/src/studio-server/explain-why.handler.d.ts +14 -0
  32. package/dist/src/studio-server/infer-selector.handler.d.ts +18 -0
  33. package/dist/src/studio-server/studio-http.use-case.d.ts +3 -0
  34. package/dist/src/studio-server/take-snapshot.handler.d.ts +16 -0
  35. package/dist/src/studio-server/verify-selector.handler.d.ts +18 -0
  36. package/dist/src/studio-server/workspace.store.d.ts +9 -3
  37. package/dist/ui/assets/index-DV8i4Zza.js +13 -0
  38. package/dist/ui/index.html +1 -1
  39. package/package.json +5 -3
  40. package/dist/ui/assets/index-DYb-tdmr.js +0 -12
@@ -50,6 +50,76 @@ export declare const saveOutlineCommandSchema: z.ZodObject<{
50
50
  path: z.ZodString;
51
51
  outline: z.ZodType<import("./outline-view.contract").OutlineView, unknown, z.core.$ZodTypeInternals<import("./outline-view.contract").OutlineView, unknown>>;
52
52
  }, z.core.$strip>;
53
+ /**
54
+ * Captures the snapshot the content pane shows for a step (`page-snapshot`'s
55
+ * `take-snapshot.use-case.ts`), caching it by recipe and step path so
56
+ * switching the selected step does not always re-run the recipe.
57
+ */
58
+ export declare const takeSnapshotCommandSchema: z.ZodObject<{
59
+ type: z.ZodLiteral<"take-snapshot">;
60
+ recipeId: z.ZodString;
61
+ path: z.ZodString;
62
+ }, z.core.$strip>;
63
+ /**
64
+ * Verifies a candidate selector against the cached snapshot and, when
65
+ * reachable, the live page — the studio's own selection (`@opencraw/core`'s
66
+ * `countMatches`), never the browser's or a guess (issue #91).
67
+ */
68
+ export declare const verifySelectorCommandSchema: z.ZodObject<{
69
+ type: z.ZodLiteral<"verify-selector">;
70
+ recipeId: z.ZodString;
71
+ path: z.ZodString;
72
+ selector: z.ZodString;
73
+ }, z.core.$strip>;
74
+ export declare const inferSelectorCommandSchema: z.ZodObject<{
75
+ type: z.ZodLiteral<"infer-selector">;
76
+ recipeId: z.ZodString;
77
+ path: z.ZodString;
78
+ nodeIds: z.ZodUnion<readonly [z.ZodTuple<[z.ZodString], null>, z.ZodTuple<[z.ZodString, z.ZodString], null>]>;
79
+ }, z.core.$strip>;
80
+ /** A missing value in an emitted record, by its position in the last sample run's records (the order they streamed in, matching the UI's own `records` list). */
81
+ export declare const missingWhyTargetSchema: z.ZodObject<{
82
+ kind: z.ZodLiteral<"missing">;
83
+ recipeId: z.ZodString;
84
+ recordIndex: z.ZodInt;
85
+ field: z.ZodString;
86
+ }, z.core.$strip>;
87
+ /** A rejected record, by its position in the last sample run's `rejectedRecords`. */
88
+ export declare const rejectedWhyTargetSchema: z.ZodObject<{
89
+ kind: z.ZodLiteral<"rejected">;
90
+ recipeId: z.ZodString;
91
+ rejectedIndex: z.ZodInt;
92
+ }, z.core.$strip>;
93
+ export declare const whyTargetSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
94
+ kind: z.ZodLiteral<"missing">;
95
+ recipeId: z.ZodString;
96
+ recordIndex: z.ZodInt;
97
+ field: z.ZodString;
98
+ }, z.core.$strip>, z.ZodObject<{
99
+ kind: z.ZodLiteral<"rejected">;
100
+ recipeId: z.ZodString;
101
+ rejectedIndex: z.ZodInt;
102
+ }, z.core.$strip>], "kind">;
103
+ /**
104
+ * Explains one missing or rejected value from the recipe's last sample run
105
+ * (`explain-why.use-case.ts`, issue #92's Why? tab): the mapping trace and
106
+ * scope snapshot `run-sample` already kept, the step that bound the value's
107
+ * source id and whether it ran, was skipped or found nothing, and the
108
+ * missing-value policy that applied.
109
+ */
110
+ export declare const explainWhyCommandSchema: z.ZodObject<{
111
+ type: z.ZodLiteral<"explain-why">;
112
+ target: z.ZodDiscriminatedUnion<[z.ZodObject<{
113
+ kind: z.ZodLiteral<"missing">;
114
+ recipeId: z.ZodString;
115
+ recordIndex: z.ZodInt;
116
+ field: z.ZodString;
117
+ }, z.core.$strip>, z.ZodObject<{
118
+ kind: z.ZodLiteral<"rejected">;
119
+ recipeId: z.ZodString;
120
+ rejectedIndex: z.ZodInt;
121
+ }, z.core.$strip>], "kind">;
122
+ }, z.core.$strip>;
53
123
  export declare const studioCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
54
124
  type: z.ZodLiteral<"open-workspace">;
55
125
  folder: z.ZodString;
@@ -74,6 +144,32 @@ export declare const studioCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
74
144
  type: z.ZodLiteral<"save-outline">;
75
145
  path: z.ZodString;
76
146
  outline: z.ZodType<import("./outline-view.contract").OutlineView, unknown, z.core.$ZodTypeInternals<import("./outline-view.contract").OutlineView, unknown>>;
147
+ }, z.core.$strip>, z.ZodObject<{
148
+ type: z.ZodLiteral<"take-snapshot">;
149
+ recipeId: z.ZodString;
150
+ path: z.ZodString;
151
+ }, z.core.$strip>, z.ZodObject<{
152
+ type: z.ZodLiteral<"verify-selector">;
153
+ recipeId: z.ZodString;
154
+ path: z.ZodString;
155
+ selector: z.ZodString;
156
+ }, z.core.$strip>, z.ZodObject<{
157
+ type: z.ZodLiteral<"infer-selector">;
158
+ recipeId: z.ZodString;
159
+ path: z.ZodString;
160
+ nodeIds: z.ZodUnion<readonly [z.ZodTuple<[z.ZodString], null>, z.ZodTuple<[z.ZodString, z.ZodString], null>]>;
161
+ }, z.core.$strip>, z.ZodObject<{
162
+ type: z.ZodLiteral<"explain-why">;
163
+ target: z.ZodDiscriminatedUnion<[z.ZodObject<{
164
+ kind: z.ZodLiteral<"missing">;
165
+ recipeId: z.ZodString;
166
+ recordIndex: z.ZodInt;
167
+ field: z.ZodString;
168
+ }, z.core.$strip>, z.ZodObject<{
169
+ kind: z.ZodLiteral<"rejected">;
170
+ recipeId: z.ZodString;
171
+ rejectedIndex: z.ZodInt;
172
+ }, z.core.$strip>], "kind">;
77
173
  }, z.core.$strip>], "type">;
78
174
  export type SampleBudget = z.infer<typeof sampleBudgetSchema>;
79
175
  export type OpenWorkspaceCommand = z.infer<typeof openWorkspaceCommandSchema>;
@@ -82,6 +178,13 @@ export type StopRunCommand = z.infer<typeof stopRunCommandSchema>;
82
178
  export type SaveRecipeCommand = z.infer<typeof saveRecipeCommandSchema>;
83
179
  export type FetchStartPageCommand = z.infer<typeof fetchStartPageCommandSchema>;
84
180
  export type SaveOutlineCommand = z.infer<typeof saveOutlineCommandSchema>;
181
+ export type TakeSnapshotCommand = z.infer<typeof takeSnapshotCommandSchema>;
182
+ export type VerifySelectorCommand = z.infer<typeof verifySelectorCommandSchema>;
183
+ export type InferSelectorCommand = z.infer<typeof inferSelectorCommandSchema>;
184
+ export type MissingWhyTarget = z.infer<typeof missingWhyTargetSchema>;
185
+ export type RejectedWhyTarget = z.infer<typeof rejectedWhyTargetSchema>;
186
+ export type WhyTarget = z.infer<typeof whyTargetSchema>;
187
+ export type ExplainWhyCommand = z.infer<typeof explainWhyCommandSchema>;
85
188
  /** Every command the UI can send the server, over HTTP POST. */
86
189
  export type StudioCommand = z.infer<typeof studioCommandSchema>;
87
190
  //# sourceMappingURL=command.contract.d.ts.map
@@ -10,12 +10,36 @@ export declare const traceLineEventSchema: z.ZodObject<{
10
10
  type: z.ZodLiteral<"trace-line">;
11
11
  line: z.ZodString;
12
12
  }, z.core.$strip>;
13
- /** One record a sample run emitted. */
13
+ /** One entry of a mapping trace field: what a rule's `from` read, and the value after each transform, in order (`@opencraw/core`'s `FieldTrace`). */
14
+ export declare const fieldTraceSchema: z.ZodObject<{
15
+ from: z.ZodUnknown;
16
+ steps: z.ZodArray<z.ZodObject<{
17
+ op: z.ZodString;
18
+ value: z.ZodUnknown;
19
+ }, z.core.$strip>>;
20
+ }, z.core.$strip>;
21
+ /** One record a sample run emitted: `scope` (what it was mapped from) and `mapping` (each field's trace) ride along, so the Record tab (#92) can show a transform chain's real values without a second round trip. */
14
22
  export declare const recordEventSchema: z.ZodObject<{
15
23
  type: z.ZodLiteral<"record">;
16
24
  recipeId: z.ZodString;
17
25
  key: z.ZodNullable<z.ZodString>;
18
26
  data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
27
+ scope: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
28
+ mapping: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
29
+ from: z.ZodUnknown;
30
+ steps: z.ZodArray<z.ZodObject<{
31
+ op: z.ZodString;
32
+ value: z.ZodUnknown;
33
+ }, z.core.$strip>>;
34
+ }, z.core.$strip>>>;
35
+ }, z.core.$strip>;
36
+ /** One record a sample run rejected (a field's `skip-record` policy on a missing or uncoercible value). */
37
+ export declare const recordRejectedEventSchema: z.ZodObject<{
38
+ type: z.ZodLiteral<"record-rejected">;
39
+ recipeId: z.ZodString;
40
+ field: z.ZodString;
41
+ reason: z.ZodString;
42
+ scope: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
19
43
  }, z.core.$strip>;
20
44
  /** A sample run ended: how many records, and why it stopped when it did not finish on its own. */
21
45
  export declare const runFinishedEventSchema: z.ZodObject<{
@@ -44,6 +68,20 @@ export declare const studioEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
44
68
  recipeId: z.ZodString;
45
69
  key: z.ZodNullable<z.ZodString>;
46
70
  data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
71
+ scope: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
72
+ mapping: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
73
+ from: z.ZodUnknown;
74
+ steps: z.ZodArray<z.ZodObject<{
75
+ op: z.ZodString;
76
+ value: z.ZodUnknown;
77
+ }, z.core.$strip>>;
78
+ }, z.core.$strip>>>;
79
+ }, z.core.$strip>, z.ZodObject<{
80
+ type: z.ZodLiteral<"record-rejected">;
81
+ recipeId: z.ZodString;
82
+ field: z.ZodString;
83
+ reason: z.ZodString;
84
+ scope: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
47
85
  }, z.core.$strip>, z.ZodObject<{
48
86
  type: z.ZodLiteral<"run-finished">;
49
87
  recipeId: z.ZodString;
@@ -62,7 +100,9 @@ export declare const studioEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
62
100
  }, z.core.$strip>], "type">;
63
101
  export type StoppedBy = z.infer<typeof stoppedBySchema>;
64
102
  export type TraceLineEvent = z.infer<typeof traceLineEventSchema>;
103
+ export type FieldTraceView = z.infer<typeof fieldTraceSchema>;
65
104
  export type RecordEvent = z.infer<typeof recordEventSchema>;
105
+ export type RecordRejectedEvent = z.infer<typeof recordRejectedEventSchema>;
66
106
  export type RunFinishedEvent = z.infer<typeof runFinishedEventSchema>;
67
107
  export type WorkspaceChangedEvent = z.infer<typeof workspaceChangedEventSchema>;
68
108
  /** Every event the server pushes to the UI over the WebSocket. */
@@ -1,7 +1,13 @@
1
- export { sampleBudgetSchema, openWorkspaceCommandSchema, runSampleCommandSchema, stopRunCommandSchema, saveRecipeCommandSchema, fetchStartPageCommandSchema, saveOutlineCommandSchema, studioCommandSchema } from './command.contract.js';
2
- export type { SampleBudget, OpenWorkspaceCommand, RunSampleCommand, StopRunCommand, SaveRecipeCommand, FetchStartPageCommand, SaveOutlineCommand, StudioCommand } from './command.contract.js';
3
- export { stoppedBySchema, traceLineEventSchema, recordEventSchema, runFinishedEventSchema, workspaceChangedEventSchema, studioEventSchema } from './event.contract.js';
4
- export type { StoppedBy, TraceLineEvent, RecordEvent, RunFinishedEvent, WorkspaceChangedEvent, StudioEvent } from './event.contract.js';
1
+ export { sampleBudgetSchema, openWorkspaceCommandSchema, runSampleCommandSchema, stopRunCommandSchema, saveRecipeCommandSchema, fetchStartPageCommandSchema, saveOutlineCommandSchema, takeSnapshotCommandSchema, verifySelectorCommandSchema, inferSelectorCommandSchema, missingWhyTargetSchema, rejectedWhyTargetSchema, whyTargetSchema, explainWhyCommandSchema, studioCommandSchema } from './command.contract.js';
2
+ export type { SampleBudget, OpenWorkspaceCommand, RunSampleCommand, StopRunCommand, SaveRecipeCommand, FetchStartPageCommand, SaveOutlineCommand, TakeSnapshotCommand, VerifySelectorCommand, InferSelectorCommand, MissingWhyTarget, RejectedWhyTarget, WhyTarget, ExplainWhyCommand, StudioCommand } from './command.contract.js';
3
+ export { snapshotViewSchema } from './snapshot-view.contract.js';
4
+ export type { SnapshotView } from './snapshot-view.contract.js';
5
+ export { verifySelectorViewSchema } from './verify-selector-view.contract.js';
6
+ export type { VerifySelectorView } from './verify-selector-view.contract.js';
7
+ export { fieldPickSchema, inferSelectorViewSchema } from './infer-selector-view.contract.js';
8
+ export type { FieldPick, InferSelectorView } from './infer-selector-view.contract.js';
9
+ export { stoppedBySchema, fieldTraceSchema, traceLineEventSchema, recordEventSchema, recordRejectedEventSchema, runFinishedEventSchema, workspaceChangedEventSchema, studioEventSchema } from './event.contract.js';
10
+ export type { StoppedBy, FieldTraceView, TraceLineEvent, RecordEvent, RecordRejectedEvent, RunFinishedEvent, WorkspaceChangedEvent, StudioEvent } from './event.contract.js';
5
11
  export { recipeIssueSchema, recipeListingSchema, workspaceViewSchema } from './workspace-view.contract.js';
6
12
  export type { RecipeIssue, RecipeListing, WorkspaceView } from './workspace-view.contract.js';
7
13
  export { sampleRunRecordSchema, sampleRunViewSchema } from './sample-run-view.contract.js';
@@ -10,4 +16,6 @@ export { startPageViewSchema } from './start-page-view.contract.js';
10
16
  export type { StartPageView } from './start-page-view.contract.js';
11
17
  export { sentencePartSchema, outlineCardSchema, outlineBracketSchema, outlineNodeSchema, outlineViewSchema } from './outline-view.contract.js';
12
18
  export type { SentencePart, OutlineCard, OutlineBracket, OutlineNode, OutlineView } from './outline-view.contract.js';
19
+ export { whyViewSchema } from './why-view.contract.js';
20
+ export type { WhyView } from './why-view.contract.js';
13
21
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,68 @@
1
+ import { z } from 'zod';
2
+ /** One clicked node's field: the best selector found for it, verified against the snapshot. */
3
+ export declare const fieldPickSchema: z.ZodObject<{
4
+ selector: z.ZodString;
5
+ tier: z.ZodEnum<{
6
+ id: "id";
7
+ "data-attr": "data-attr";
8
+ class: "class";
9
+ structure: "structure";
10
+ position: "position";
11
+ }>;
12
+ take: z.ZodString;
13
+ matches: z.ZodNumber;
14
+ }, z.core.$strip>;
15
+ /**
16
+ * What `infer-selector` answers with (issue #91, studio plan §3.2):
17
+ * `"field"` for one clicked node — a `Read` card's shape; `"list"` for two
18
+ * similar nodes — the safe `extract`(items)+`forEach`(field) shape, item and
19
+ * field each verified separately; `"unsupported"` when the two picks are not
20
+ * a coherent list (different branches, the same node twice, or shadow DOM),
21
+ * with a message the card can show as-is.
22
+ */
23
+ export declare const inferSelectorViewSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
24
+ kind: z.ZodLiteral<"field">;
25
+ field: z.ZodObject<{
26
+ selector: z.ZodString;
27
+ tier: z.ZodEnum<{
28
+ id: "id";
29
+ "data-attr": "data-attr";
30
+ class: "class";
31
+ structure: "structure";
32
+ position: "position";
33
+ }>;
34
+ take: z.ZodString;
35
+ matches: z.ZodNumber;
36
+ }, z.core.$strip>;
37
+ }, z.core.$strip>, z.ZodObject<{
38
+ kind: z.ZodLiteral<"list">;
39
+ item: z.ZodObject<{
40
+ selector: z.ZodString;
41
+ tier: z.ZodEnum<{
42
+ id: "id";
43
+ "data-attr": "data-attr";
44
+ class: "class";
45
+ structure: "structure";
46
+ position: "position";
47
+ }>;
48
+ matches: z.ZodNumber;
49
+ }, z.core.$strip>;
50
+ field: z.ZodObject<{
51
+ selector: z.ZodString;
52
+ tier: z.ZodEnum<{
53
+ id: "id";
54
+ "data-attr": "data-attr";
55
+ class: "class";
56
+ structure: "structure";
57
+ position: "position";
58
+ }>;
59
+ take: z.ZodString;
60
+ matches: z.ZodNumber;
61
+ }, z.core.$strip>;
62
+ }, z.core.$strip>, z.ZodObject<{
63
+ kind: z.ZodLiteral<"unsupported">;
64
+ reason: z.ZodString;
65
+ }, z.core.$strip>], "kind">;
66
+ export type FieldPick = z.infer<typeof fieldPickSchema>;
67
+ export type InferSelectorView = z.infer<typeof inferSelectorViewSchema>;
68
+ //# sourceMappingURL=infer-selector-view.contract.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ /** What `take-snapshot` answers with: the rewritten document ready for the content pane's sandboxed iframe (studio plan §3.1, issue #91). */
3
+ export declare const snapshotViewSchema: z.ZodObject<{
4
+ html: z.ZodString;
5
+ nodeCount: z.ZodNumber;
6
+ baseUrl: z.ZodString;
7
+ }, z.core.$strip>;
8
+ export type SnapshotView = z.infer<typeof snapshotViewSchema>;
9
+ //# sourceMappingURL=snapshot-view.contract.d.ts.map
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * What `verify-selector` answers with: the match count against the snapshot
4
+ * and, when the live page could be reached, against it too (issue #91's
5
+ * "flag a selector that matches the snapshot but not the live page").
6
+ * `liveChecked` is `false` when the live page could not be fetched (offline,
7
+ * blocked by `allowedHosts`, a transient error) — the card shows the
8
+ * snapshot count alone rather than a misleading "0 on the live page".
9
+ */
10
+ export declare const verifySelectorViewSchema: z.ZodObject<{
11
+ selector: z.ZodString;
12
+ snapshotMatches: z.ZodNumber;
13
+ liveChecked: z.ZodBoolean;
14
+ liveMatches: z.ZodOptional<z.ZodNumber>;
15
+ liveError: z.ZodOptional<z.ZodString>;
16
+ }, z.core.$strip>;
17
+ export type VerifySelectorView = z.infer<typeof verifySelectorViewSchema>;
18
+ //# sourceMappingURL=verify-selector-view.contract.d.ts.map
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ /** What `explain-why` answers with: the sentence (`why-sentence.mapper.ts`'s `buildWhySentence`), plus the structured facts a click can act on — a link back to the step that bound the value, the policy that applied. */
3
+ export declare const whyViewSchema: z.ZodObject<{
4
+ sentence: z.ZodString;
5
+ field: z.ZodString;
6
+ recipeId: z.ZodString;
7
+ outcome: z.ZodEnum<{
8
+ missing: "missing";
9
+ rejected: "rejected";
10
+ }>;
11
+ stepPath: z.ZodOptional<z.ZodString>;
12
+ policy: z.ZodOptional<z.ZodString>;
13
+ reason: z.ZodOptional<z.ZodString>;
14
+ }, z.core.$strip>;
15
+ export type WhyView = z.infer<typeof whyViewSchema>;
16
+ //# sourceMappingURL=why-view.contract.d.ts.map
@@ -0,0 +1,14 @@
1
+ import type { ExplainWhyCommand, WhyView } from '../studio-api/index.js';
2
+ import type { StudioState } from './workspace.store.js';
3
+ /**
4
+ * Handles `explain-why` (issue #92's Why? tab): builds the sentence for a
5
+ * missing or rejected value from the recipe's last sample run, kept in
6
+ * `state.lastRuns` by `handleRunSample`.
7
+ *
8
+ * @param state - The server state: `folder` must already be set (`open-workspace` first).
9
+ * @param command - The command.
10
+ * @returns The explanation.
11
+ * @throws Error when no workspace is open, no sample run has finished for the target's recipe, or the target does not name a real record/field.
12
+ */
13
+ export declare function handleExplainWhy(state: StudioState, command: ExplainWhyCommand): Promise<WhyView>;
14
+ //# sourceMappingURL=explain-why.handler.d.ts.map
@@ -0,0 +1,18 @@
1
+ import type { InferSelectorCommand, InferSelectorView } from '../studio-api/index.js';
2
+ import type { StudioState } from './workspace.store.js';
3
+ /**
4
+ * Handles `infer-selector`: turns one or two picked nodes (their
5
+ * `data-oc-node` ids, off the cached snapshot) into a verified selector —
6
+ * one id for a `Read` card's field, two for the safe item+field list shape
7
+ * `selector-inference`'s `inferList` builds by construction (issue #91,
8
+ * studio plan §3.2). All the actual candidate/ranking/list-inference work
9
+ * is `selector-inference`'s (pure); this handler only locates the clicked
10
+ * nodes in the cached document and calls into it.
11
+ *
12
+ * @param state - The server state.
13
+ * @param command - The command; `command.path` must already have a cached snapshot (call `take-snapshot` first).
14
+ * @returns A field pick, a list pick, or `"unsupported"` with why.
15
+ * @throws Error when no workspace is open, or `command.path` has no cached snapshot yet.
16
+ */
17
+ export declare function handleInferSelector(state: StudioState, command: InferSelectorCommand): InferSelectorView;
18
+ //# sourceMappingURL=infer-selector.handler.d.ts.map
@@ -1,3 +1,4 @@
1
+ import type { BrowserSessionConfig } from '@opencraw/core';
1
2
  export interface StudioServerOptions {
2
3
  /** Where the built UI lives; default: `dist/ui` next to the running server code. */
3
4
  uiRoot?: string;
@@ -11,6 +12,8 @@ export interface StudioServerOptions {
11
12
  * the folder reaches it through the URL's `folder` query param).
12
13
  */
13
14
  initialFolder?: string;
15
+ /** Browser launch settings every web-mode command shares (`take-snapshot`, `verify-selector`, `run-sample`); an executable path override (e.g. `OPENCRAW_CHROMIUM`, read by the caller — the server itself has no opinion on env vars) for a sandbox with no full Playwright install. Default: Playwright's own bundled browser. */
16
+ browser?: BrowserSessionConfig;
14
17
  }
15
18
  /** The running server: its URL (token included, ready to open), the token alone, and how to stop it. */
16
19
  export interface StudioServer {
@@ -0,0 +1,16 @@
1
+ import type { SnapshotView, TakeSnapshotCommand } from '../studio-api/index.js';
2
+ import type { StudioState } from './workspace.store.js';
3
+ /**
4
+ * Handles `take-snapshot`: loads the named input recipe, captures its
5
+ * snapshot at `command.path` (only `"start"` is captured for now — see
6
+ * `page-snapshot`'s `take-snapshot.use-case.ts`), and caches it so a later
7
+ * `verify-selector`/`infer-selector` against the same recipe and path, or
8
+ * the UI reselecting the same step, does not recapture it.
9
+ *
10
+ * @param state - The server state: `folder` must already be set.
11
+ * @param command - The command.
12
+ * @returns The rewritten snapshot.
13
+ * @throws Error when no workspace is open, or the recipe cannot be found or loaded.
14
+ */
15
+ export declare function handleTakeSnapshot(state: StudioState, command: TakeSnapshotCommand): Promise<SnapshotView>;
16
+ //# sourceMappingURL=take-snapshot.handler.d.ts.map
@@ -0,0 +1,18 @@
1
+ import type { VerifySelectorCommand, VerifySelectorView } from '../studio-api/index.js';
2
+ import type { StudioState } from './workspace.store.js';
3
+ /**
4
+ * Handles `verify-selector`: runs a candidate through the engine's own
5
+ * selection (`@opencraw/core`'s `countMatches`) against the cached
6
+ * snapshot, and, best-effort, against the live page too — issue #91's "flag
7
+ * a selector that matches the snapshot but not the live page". The live
8
+ * page is fetched raw (`page-snapshot`'s `fetchStartPage`, the same reach
9
+ * `take-snapshot` has: only `"start"` today), not through the rewritten
10
+ * snapshot, so its match count is the site's own, not the studio's.
11
+ *
12
+ * @param state - The server state.
13
+ * @param command - The command; `command.path` must already have a cached snapshot (call `take-snapshot` first).
14
+ * @returns The match counts.
15
+ * @throws Error when no workspace is open, the recipe cannot be found, or `command.path` has no cached snapshot yet.
16
+ */
17
+ export declare function handleVerifySelector(state: StudioState, command: VerifySelectorCommand): Promise<VerifySelectorView>;
18
+ //# sourceMappingURL=verify-selector.handler.d.ts.map
@@ -1,13 +1,19 @@
1
- import type { SampleRunHandle } from '../sample-run/index.js';
1
+ import type { BrowserSessionConfig } from '@opencraw/core';
2
+ import type { SnapshotCache } from '../page-snapshot/index.js';
3
+ import type { LastRunCache, SampleRunHandle } from '../sample-run/index.js';
2
4
  import type { StudioEvent } from '../studio-api/index.js';
3
5
  import type { WsConnection } from './websocket.client.js';
4
- /** The server's mutable state: the opened folder, the run in progress (if any), and the connected event sockets. */
6
+ /** The server's mutable state: the opened folder, the run in progress (if any), the connected event sockets, the per-recipe snapshot cache `take-snapshot`/`verify-selector`/`infer-selector` share, each recipe's last finished sample run (`explain-why`, issue #92), and the browser launch settings every web-mode command (`take-snapshot`, `verify-selector`, `run-sample`) shares. */
5
7
  export interface StudioState {
6
8
  folder?: string;
7
9
  activeRun?: SampleRunHandle;
8
10
  sockets: Set<WsConnection>;
11
+ snapshots: SnapshotCache;
12
+ lastRuns: LastRunCache;
13
+ /** Set once at server start (`StudioServerOptions.browser`); every web-mode command reads it from here rather than each accepting its own. */
14
+ browser?: BrowserSessionConfig;
9
15
  }
10
- /** @returns Fresh state for a new server instance: no workspace open, no run, no sockets. */
16
+ /** @returns Fresh state for a new server instance: no workspace open, no run, no sockets, an empty snapshot cache, no last runs, Playwright's own default browser. */
11
17
  export declare function createStudioState(): StudioState;
12
18
  /**
13
19
  * Sends one event to every connected client. A socket that errors while