@reticlehq/core 1.3.0 → 2.0.0

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 (80) hide show
  1. package/README.md +14 -86
  2. package/dist/brand.d.ts +21 -0
  3. package/dist/brand.d.ts.map +1 -0
  4. package/dist/brand.js +16 -0
  5. package/dist/brand.js.map +1 -0
  6. package/dist/constants.d.ts +371 -0
  7. package/dist/constants.d.ts.map +1 -0
  8. package/dist/constants.js +343 -0
  9. package/dist/constants.js.map +1 -0
  10. package/dist/flow-constants.d.ts +175 -0
  11. package/dist/flow-constants.d.ts.map +1 -0
  12. package/dist/flow-constants.js +162 -0
  13. package/dist/flow-constants.js.map +1 -0
  14. package/dist/flow-types.d.ts +1182 -0
  15. package/dist/flow-types.d.ts.map +1 -0
  16. package/dist/flow-types.js +144 -0
  17. package/dist/flow-types.js.map +1 -0
  18. package/dist/index.d.ts +13 -2
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +13 -5543
  21. package/dist/index.js.map +1 -0
  22. package/dist/messages.d.ts +424 -0
  23. package/dist/messages.d.ts.map +1 -0
  24. package/dist/messages.js +103 -0
  25. package/dist/messages.js.map +1 -0
  26. package/dist/notices.d.ts +47 -0
  27. package/dist/notices.d.ts.map +1 -0
  28. package/dist/notices.js +51 -0
  29. package/dist/notices.js.map +1 -0
  30. package/dist/schema/command-message.json +41 -0
  31. package/dist/schema/command-result.json +34 -0
  32. package/dist/schema/event-message.json +77 -0
  33. package/dist/schema/event-type.json +35 -0
  34. package/dist/schema/hello-message.json +59 -0
  35. package/dist/schema/reticle-event.json +63 -0
  36. package/dist/schema/reticle-message.json +193 -0
  37. package/dist/security.d.ts +5 -0
  38. package/dist/security.d.ts.map +1 -0
  39. package/dist/security.js +22 -0
  40. package/dist/security.js.map +1 -0
  41. package/dist/session-constants.d.ts +116 -0
  42. package/dist/session-constants.d.ts.map +1 -0
  43. package/dist/session-constants.js +113 -0
  44. package/dist/session-constants.js.map +1 -0
  45. package/dist/state-select.d.ts +23 -0
  46. package/dist/state-select.d.ts.map +1 -0
  47. package/dist/state-select.js +60 -0
  48. package/dist/state-select.js.map +1 -0
  49. package/dist/toon.d.ts +44 -0
  50. package/dist/toon.d.ts.map +1 -0
  51. package/dist/toon.js +153 -0
  52. package/dist/toon.js.map +1 -0
  53. package/dist/types.d.ts +833 -0
  54. package/dist/types.d.ts.map +1 -0
  55. package/dist/types.js +165 -0
  56. package/dist/types.js.map +1 -0
  57. package/dist/upgrade.d.ts +74 -0
  58. package/dist/upgrade.d.ts.map +1 -0
  59. package/dist/upgrade.js +88 -0
  60. package/dist/upgrade.js.map +1 -0
  61. package/dist/verification-run.d.ts +1195 -0
  62. package/dist/verification-run.d.ts.map +1 -0
  63. package/dist/verification-run.js +261 -0
  64. package/dist/verification-run.js.map +1 -0
  65. package/package.json +32 -79
  66. package/dist/babel.d.ts +0 -7
  67. package/dist/babel.js +0 -32
  68. package/dist/cli.d.ts +0 -1
  69. package/dist/cli.js +0 -11264
  70. package/dist/eslint.d.ts +0 -1
  71. package/dist/eslint.js +0 -134
  72. package/dist/loader.cjs +0 -52
  73. package/dist/next.d.ts +0 -21
  74. package/dist/next.js +0 -24
  75. package/dist/server.d.ts +0 -1
  76. package/dist/server.js +0 -9486
  77. package/dist/test.d.ts +0 -1
  78. package/dist/test.js +0 -9368
  79. package/dist/vite.d.ts +0 -1
  80. package/dist/vite.js +0 -196
@@ -0,0 +1,162 @@
1
+ /**
2
+ * On-disk artifact constants: the project history, flow files, replay/drift status, the recorder
3
+ * lifecycle, heal outcomes, and the structured-annotation vocabulary. Split out of constants.ts so
4
+ * each file stays one cohesive unit under the size cap; re-exported from constants.ts (and so from
5
+ * the package index) — every existing `@reticlehq/core` import is unchanged.
6
+ */
7
+ /**
8
+ * Schema version stamped into project.json so a reader can reject/upgrade old files.
9
+ */
10
+ export const PROJECT_FILE_VERSION = 1;
11
+ /**
12
+ * Structured outcome when reading project.json fails (never thrown to the agent).
13
+ * Mirrors ContractReadError. NOTE: recordRun() self-heals a MALFORMED file (starts fresh) so a
14
+ * corrupt history never wedges the agent; only the READ path (reticle_project) surfaces MALFORMED.
15
+ */
16
+ export const ProjectReadError = {
17
+ MISSING: 'project-missing', // no .reticle/project.json on disk
18
+ MALFORMED: 'project-malformed', // present but not valid JSON / fails schema
19
+ };
20
+ /** How a run record was produced. */
21
+ export const RunKind = {
22
+ FLOW_REPLAY: 'flow_replay', // auto-recorded by reticle_flow_replay
23
+ MANUAL: 'manual', // explicitly recorded via reticle_run_record
24
+ };
25
+ /**
26
+ * The persisted outcome of a run. Distinct from ReplayStatus (a wire/replay
27
+ * concept of ok|drift|error): RunStatus is the history concept and adds pass/fail. The replay
28
+ * site maps ReplayStatus.OK→PASS, DRIFT→DRIFT, ERROR→ERROR.
29
+ */
30
+ export const RunStatus = {
31
+ PASS: 'pass',
32
+ DRIFT: 'drift',
33
+ ERROR: 'error',
34
+ FAIL: 'fail',
35
+ };
36
+ /**
37
+ * Bounds on project.json so the file stays small + diffable. recordRun keeps the
38
+ * last PER_NAME runs of any single name, then caps the whole list to TOTAL most-recent overall.
39
+ */
40
+ export const PROJECT_RUN_CAP = {
41
+ PER_NAME: 50,
42
+ TOTAL: 200,
43
+ };
44
+ /** Schema version stamped onto on-disk flow files (.reticle/flows/<name>.json). */
45
+ export const FLOW_FILE_VERSION = 1;
46
+ /** How a flow step is anchored to the live DOM at replay time (semantic, never a volatile ref). */
47
+ export const AnchorKind = {
48
+ TESTID: 'testid', // { kind:'testid', value }
49
+ ROLE: 'role', // { kind:'role', role, name? } — best-effort fallback
50
+ SIGNAL: 'signal', // { kind:'signal', name } — wait/assert anchors
51
+ COMPONENT: 'component', // { kind:'component', component?, source?, role?, name? } — auto-anchor (no testid)
52
+ };
53
+ /**
54
+ * The role marker for a DEGRADED step — one recorded with no resolvable
55
+ * testid. It is kept (never dropped) but a volatile eXX ref is NEVER persisted in its place;
56
+ * the step carries this placeholder ROLE anchor + degraded:true, a legible "add a data-testid
57
+ * here" marker that a human/self-healing pass re-binds. Satisfies the anchor min(1).
58
+ */
59
+ export const DEGRADED_ANCHOR_ROLE = 'unresolved';
60
+ /** Structured failure codes for flow disk ops (returned, never thrown as free strings). */
61
+ export const FlowErrorCode = {
62
+ INVALID_NAME: 'flow_invalid_name', // path traversal / illegal chars
63
+ NOT_FOUND: 'flow_not_found', // load of a missing flow
64
+ PARSE_FAILED: 'flow_parse_failed', // on-disk JSON failed zod validation
65
+ NO_RECORDING: 'flow_no_recording', // save with no compiled program by that name
66
+ };
67
+ /** A flow name must be a single safe path segment (no '/', '\\', '..', leading dot). */
68
+ export const FLOW_NAME_PATTERN = /^[a-z0-9][a-z0-9-_]{0,63}$/i;
69
+ /**
70
+ * The outcome of replaying an on-disk flow by re-resolving its
71
+ * semantic anchors against the live DOM. `drift` (an anchor missed → contract changed) is
72
+ * cleanly separated from `error` (the flow could not load or an action failed) and `ok`.
73
+ */
74
+ export const ReplayStatus = {
75
+ OK: 'ok', // every anchor resolved and every step ran green
76
+ DRIFT: 'drift', // an anchor missed (testid renamed / signal not observed) — legible drift returned
77
+ ERROR: 'error', // the flow could not load or a resolved action failed
78
+ };
79
+ /**
80
+ * Why an anchor failed to resolve at replay time (the "whose fault is
81
+ * it" reason kind). Drives the human `reason` sentence and whether a nearest-match is offered.
82
+ */
83
+ export const DriftReason = {
84
+ TESTID_NOT_FOUND: 'testid_not_found', // a testid anchor resolved to zero live elements
85
+ SIGNAL_NOT_OBSERVED: 'signal_not_observed', // a signal anchor never fired within the timeout
86
+ COMPONENT_NOT_FOUND: 'component_not_found', // a component/source auto-anchor resolved to zero live elements
87
+ STATE_MISMATCH: 'state_mismatch', // a step's expect.state assertion did not hold against the store
88
+ };
89
+ /** Default timeout (ms) a signal anchor waits to be observed at replay. */
90
+ export const FLOW_SIGNAL_TIMEOUT_MS = 4000;
91
+ /**
92
+ * The structured annotation kinds a human can attach while recording.
93
+ * FIRST CUT: only these four structured kinds compile to flow fields (via a toolbar menu +
94
+ * a signal <select> drawn from registered capabilities). Free natural-language annotation →
95
+ * predicate compilation is explicitly OUT this cut (no NL parser). `wait-for` / `ignore-region`
96
+ * from the plan grammar are also future — only the four requested kinds ship here.
97
+ */
98
+ export const AnnotationKind = {
99
+ ASSERT_SIGNAL: 'assert-signal', // → step.expect.signal (invariant)
100
+ ASSERT_VISIBLE: 'assert-visible', // → step.expect.element (invariant)
101
+ ASSERT_STATE: 'assert-state', // → step.expect.state (store-truth invariant on the last step)
102
+ MARK_DYNAMIC: 'mark-dynamic', // → flow.dynamic[] (don't assert words/content)
103
+ SUCCESS_STATE: 'success-state', // → flow.success (golden end condition)
104
+ INTENT: 'intent', // → flow.intent (the business goal this flow exists to verify)
105
+ };
106
+ /** Recorder lifecycle phases (drives the toolbar UI + the capture gate). */
107
+ export const RecorderPhase = {
108
+ IDLE: 'idle', // listeners inert, no steps captured
109
+ RECORDING: 'recording', // capture-phase listeners live
110
+ ANNOTATING: 'annotating', // recording paused, awaiting an annotation target/kind
111
+ };
112
+ /**
113
+ * Structured codes for the recorded-save server tool (returned, never thrown).
114
+ */
115
+ export const RecordedSaveError = {
116
+ NO_RECORDED_FLOW: 'flow_no_recorded', // no FLOW_RECORDED event for the session
117
+ INVALID_NAME: 'flow_invalid_name', // reuses FlowErrorCode.INVALID_NAME semantics
118
+ };
119
+ /**
120
+ * Outcome of reticle_flow_heal (distinct from ReplayStatus — adds heal verbs).
121
+ * Rebinds testid anchors only (role/name/signal re-anchoring is future). A confident nearest-match
122
+ * is required before any disk write — the "never silently rewrite" invariant.
123
+ */
124
+ export const HealStatus = {
125
+ HEALED: 'healed', // apply:true and >=1 anchor rewritten on disk
126
+ DRIFT: 'drift', // apply:false: confident proposal(s) returned, file untouched
127
+ UNHEALABLE: 'unhealable', // drift exists but no proposal cleared the confidence floor
128
+ NOTHING_TO_HEAL: 'nothing_to_heal', // replay was green
129
+ CONSEQUENCE_BROKEN: 'consequence_broken', // rebind resolves a locator but the flow's success consequence no longer fires — REFUSED (file untouched)
130
+ ERROR: 'error', // flow missing/malformed/invalid-name, or a resolved action failed
131
+ };
132
+ /**
133
+ * Minimum normalized confidence (0,1] a nearest-match rebind must clear before it is
134
+ * eligible to be APPLIED (or surfaced as a confident proposal). Below this, drift is reported but
135
+ * NEVER auto-rewritten — the "never silently rewrite" invariant has a single numeric home here.
136
+ */
137
+ export const HEAL_CONFIDENCE_MIN = 0.5;
138
+ /**
139
+ * What a structured annotation binds to. STEP folds onto the LAST captured
140
+ * step's expect (assert-signal / assert-visible); FLOW folds onto the flow header (mark-dynamic →
141
+ * dynamic[], success-state → success).
142
+ */
143
+ export const AnnotationTarget = {
144
+ STEP: 'step',
145
+ FLOW: 'flow',
146
+ };
147
+ /**
148
+ * Structured failure codes for the annotate compiler/tool (returned, never
149
+ * thrown / free strings). NO_ACTIVE_RECORDING = annotate() with nothing recording; NO_STEP_TO_
150
+ * ANNOTATE = an assert-* with zero captured steps yet; UNKNOWN_KIND = kind ∉ AnnotationKind (or a
151
+ * free natural-language string — see AnnotationSchema's FUTURE note); MISSING_FIELD = e.g. a
152
+ * success-state with neither signal nor testid.
153
+ */
154
+ export const AnnotationErrorCode = {
155
+ NO_ACTIVE_RECORDING: 'annotate_no_recording',
156
+ NO_STEP_TO_ANNOTATE: 'annotate_no_step',
157
+ UNKNOWN_KIND: 'annotate_unknown_kind',
158
+ MISSING_FIELD: 'annotate_missing_field',
159
+ };
160
+ /** Leading word of the compiled-predicate confirmation ("will assert …"). */
161
+ export const COMPILED_PREDICATE_PREFIX = 'will';
162
+ //# sourceMappingURL=flow-constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flow-constants.js","sourceRoot":"","sources":["../src/flow-constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAEtC;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,OAAO,EAA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