@reticlehq/core 2.13.1 → 3.1.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 (147) hide show
  1. package/dist/artifacts/artifacts-entry.d.ts +20 -0
  2. package/dist/artifacts/artifacts-entry.js +20 -0
  3. package/dist/artifacts/flow-composition.d.ts +30 -0
  4. package/dist/artifacts/flow-composition.js +19 -0
  5. package/dist/{flow-constants.d.ts → artifacts/flow-constants.d.ts} +97 -3
  6. package/dist/{flow-constants.js → artifacts/flow-constants.js} +103 -4
  7. package/dist/artifacts/flow-mutation-target.d.ts +39 -0
  8. package/dist/artifacts/flow-mutation-target.js +89 -0
  9. package/dist/artifacts/flow-order.d.ts +30 -0
  10. package/dist/artifacts/flow-order.js +49 -0
  11. package/dist/artifacts/flow-select.d.ts +56 -0
  12. package/dist/artifacts/flow-select.js +56 -0
  13. package/dist/artifacts/flow-step-tool.d.ts +31 -0
  14. package/dist/artifacts/flow-step-tool.js +31 -0
  15. package/dist/artifacts/flow-types.d.ts +3736 -0
  16. package/dist/artifacts/flow-types.js +463 -0
  17. package/dist/artifacts/flow-unreached.d.ts +12 -0
  18. package/dist/artifacts/flow-unreached.js +24 -0
  19. package/dist/{impact-savings.d.ts → artifacts/impact-savings.d.ts} +7 -3
  20. package/dist/{impact-savings.js → artifacts/impact-savings.js} +27 -4
  21. package/dist/{impact.d.ts → artifacts/impact.d.ts} +122 -54
  22. package/dist/{impact.js → artifacts/impact.js} +30 -0
  23. package/dist/{journal.d.ts → artifacts/journal.d.ts} +50 -6
  24. package/dist/{journal.js → artifacts/journal.js} +38 -2
  25. package/dist/artifacts/step-effect.d.ts +29 -0
  26. package/dist/artifacts/step-effect.js +28 -0
  27. package/dist/hooks/hook-events.d.ts +311 -0
  28. package/dist/hooks/hook-events.js +127 -0
  29. package/dist/hooks/hooks-entry.d.ts +9 -0
  30. package/dist/hooks/hooks-entry.js +9 -0
  31. package/dist/{brand.d.ts → identity/brand.d.ts} +7 -0
  32. package/dist/{contract-fingerprint.d.ts → identity/contract-fingerprint.d.ts} +21 -3
  33. package/dist/{contract-fingerprint.js → identity/contract-fingerprint.js} +22 -4
  34. package/dist/{document-identity.d.ts → identity/document-identity.d.ts} +4 -5
  35. package/dist/{document-identity.js → identity/document-identity.js} +4 -5
  36. package/dist/{source-constants.d.ts → identity/source-constants.d.ts} +4 -4
  37. package/dist/{source-constants.js → identity/source-constants.js} +4 -4
  38. package/dist/index.d.ts +69 -42
  39. package/dist/index.js +78 -44
  40. package/dist/onboarding.d.ts +114 -0
  41. package/dist/onboarding.js +141 -0
  42. package/dist/realm/registry.d.ts +212 -0
  43. package/dist/realm/registry.js +302 -0
  44. package/dist/{dev-server-registry.d.ts → registry/dev-server-registry.d.ts} +4 -5
  45. package/dist/{dev-server-registry.js → registry/dev-server-registry.js} +28 -19
  46. package/dist/{project-registry.d.ts → registry/project-registry.d.ts} +5 -5
  47. package/dist/{project-registry.js → registry/project-registry.js} +5 -5
  48. package/dist/schema/command-name.json +31 -0
  49. package/dist/schema/event-message.json +1 -0
  50. package/dist/schema/event-payloads.json +791 -0
  51. package/dist/schema/event-type.json +1 -0
  52. package/dist/schema/hello-message.json +76 -2
  53. package/dist/schema/reticle-event.json +1 -0
  54. package/dist/schema/reticle-message.json +77 -2
  55. package/dist/telemetry-entry.d.ts +15 -0
  56. package/dist/telemetry-entry.js +15 -0
  57. package/dist/telemetry-feedback.d.ts +13 -14
  58. package/dist/telemetry-feedback.js +11 -12
  59. package/dist/telemetry-license.d.ts +1 -1
  60. package/dist/telemetry-license.js +1 -1
  61. package/dist/telemetry-refusal.d.ts +11 -11
  62. package/dist/telemetry-refusal.js +7 -8
  63. package/dist/telemetry-session.d.ts +49 -57
  64. package/dist/telemetry-session.js +47 -55
  65. package/dist/telemetry.d.ts +229 -198
  66. package/dist/telemetry.js +83 -98
  67. package/dist/tour-entry.d.ts +10 -0
  68. package/dist/tour-entry.js +10 -0
  69. package/dist/tour.d.ts +125 -0
  70. package/dist/tour.js +165 -0
  71. package/dist/{consequence.d.ts → verdict/consequence.d.ts} +35 -11
  72. package/dist/{consequence.js → verdict/consequence.js} +9 -22
  73. package/dist/{finding-fingerprint.js → verdict/finding-fingerprint.js} +1 -1
  74. package/dist/{findings.d.ts → verdict/findings.d.ts} +149 -41
  75. package/dist/{findings.js → verdict/findings.js} +169 -48
  76. package/dist/{instrumentation-gap.d.ts → verdict/instrumentation-gap.d.ts} +22 -14
  77. package/dist/{instrumentation-gap.js → verdict/instrumentation-gap.js} +23 -15
  78. package/dist/{intent.d.ts → verdict/intent.d.ts} +41 -52
  79. package/dist/{intent.js → verdict/intent.js} +11 -22
  80. package/dist/verdict/revision.d.ts +44 -0
  81. package/dist/verdict/revision.js +53 -0
  82. package/dist/{run-context.d.ts → verdict/run-context.d.ts} +13 -34
  83. package/dist/{run-context.js → verdict/run-context.js} +15 -36
  84. package/dist/{security.js → verdict/security.js} +12 -21
  85. package/dist/{verification-run.d.ts → verdict/verification-run.d.ts} +369 -93
  86. package/dist/{verification-run.js → verdict/verification-run.js} +157 -21
  87. package/dist/{verified-constants.d.ts → verdict/verified-constants.d.ts} +36 -13
  88. package/dist/{verified-constants.js → verdict/verified-constants.js} +36 -13
  89. package/dist/verdict/verify-progress.d.ts +129 -0
  90. package/dist/verdict/verify-progress.js +74 -0
  91. package/dist/wire/channel.d.ts +46 -0
  92. package/dist/wire/channel.js +95 -0
  93. package/dist/{constants.d.ts → wire/constants/constants.d.ts} +124 -28
  94. package/dist/{constants.js → wire/constants/constants.js} +137 -28
  95. package/dist/{session-constants.d.ts → wire/constants/session-constants.d.ts} +9 -2
  96. package/dist/{session-constants.js → wire/constants/session-constants.js} +9 -2
  97. package/dist/{desktop-contract.js → wire/desktop-contract.js} +1 -1
  98. package/dist/{event-classification.js → wire/event-classification.js} +1 -1
  99. package/dist/{event-payloads.d.ts → wire/event-payloads.d.ts} +229 -17
  100. package/dist/{event-payloads.js → wire/event-payloads.js} +61 -3
  101. package/dist/{event-priority.d.ts → wire/event-priority.d.ts} +1 -4
  102. package/dist/{event-priority.js → wire/event-priority.js} +2 -5
  103. package/dist/wire/global-press.d.ts +30 -0
  104. package/dist/wire/global-press.js +54 -0
  105. package/dist/{messages.d.ts → wire/messages.d.ts} +290 -38
  106. package/dist/{messages.js → wire/messages.js} +93 -5
  107. package/dist/wire/narrow.d.ts +39 -0
  108. package/dist/wire/narrow.js +45 -0
  109. package/dist/{net.d.ts → wire/net.d.ts} +49 -10
  110. package/dist/{net.js → wire/net.js} +49 -10
  111. package/dist/wire/platform.d.ts +37 -0
  112. package/dist/wire/platform.js +36 -0
  113. package/dist/{redaction.d.ts → wire/redaction.d.ts} +30 -0
  114. package/dist/wire/redaction.js +274 -0
  115. package/dist/wire/tool-names.d.ts +133 -0
  116. package/dist/wire/tool-names.js +142 -0
  117. package/dist/{toon.js → wire/toon.js} +1 -1
  118. package/dist/{types.d.ts → wire/types.d.ts} +106 -66
  119. package/dist/{types.js → wire/types.js} +24 -4
  120. package/dist/{no-session-reason.d.ts → words/no-session-reason.d.ts} +7 -3
  121. package/dist/{no-session-reason.js → words/no-session-reason.js} +7 -3
  122. package/dist/{notices.d.ts → words/notices.d.ts} +24 -12
  123. package/dist/{notices.js → words/notices.js} +27 -12
  124. package/package.json +22 -5
  125. package/dist/flow-types.d.ts +0 -1473
  126. package/dist/flow-types.js +0 -195
  127. package/dist/redaction.js +0 -149
  128. /package/dist/{brand.js → identity/brand.js} +0 -0
  129. /package/dist/{edit-epoch.d.ts → identity/edit-epoch.d.ts} +0 -0
  130. /package/dist/{edit-epoch.js → identity/edit-epoch.js} +0 -0
  131. /package/dist/{project-id.d.ts → identity/project-id.d.ts} +0 -0
  132. /package/dist/{project-id.js → identity/project-id.js} +0 -0
  133. /package/dist/{daemon-registry.d.ts → registry/daemon-registry.d.ts} +0 -0
  134. /package/dist/{daemon-registry.js → registry/daemon-registry.js} +0 -0
  135. /package/dist/{finding-fingerprint.d.ts → verdict/finding-fingerprint.d.ts} +0 -0
  136. /package/dist/{security.d.ts → verdict/security.d.ts} +0 -0
  137. /package/dist/{desktop-contract.d.ts → wire/desktop-contract.d.ts} +0 -0
  138. /package/dist/{event-classification.d.ts → wire/event-classification.d.ts} +0 -0
  139. /package/dist/{state-select.d.ts → wire/state-select.d.ts} +0 -0
  140. /package/dist/{state-select.js → wire/state-select.js} +0 -0
  141. /package/dist/{toon.d.ts → wire/toon.d.ts} +0 -0
  142. /package/dist/{browser-misdirect.d.ts → words/browser-misdirect.d.ts} +0 -0
  143. /package/dist/{browser-misdirect.js → words/browser-misdirect.js} +0 -0
  144. /package/dist/{unreachable-notice.d.ts → words/unreachable-notice.d.ts} +0 -0
  145. /package/dist/{unreachable-notice.js → words/unreachable-notice.js} +0 -0
  146. /package/dist/{upgrade.d.ts → words/upgrade.d.ts} +0 -0
  147. /package/dist/{upgrade.js → words/upgrade.js} +0 -0
@@ -116,6 +116,30 @@ export const ImpactScopeSchema = z.object({
116
116
  defects: z.array(ImpactDefectSchema).default([]),
117
117
  });
118
118
  /** What the HUD receives: this project, and the machine-wide total. */
119
+ /**
120
+ * Whether this machine is signed in to a Reticle workspace, as the HUD is allowed to know it.
121
+ *
122
+ * Deliberately small, because it is pushed to a BROWSER: a token here would be a token in the DOM of
123
+ * the user's own app, readable by anything else running on it. There is no field for one and the
124
+ * reader is tested for never emitting one.
125
+ *
126
+ * `org`, `email` and `host` are present only when signed in. `host` matters because a self-hosted
127
+ * install is not app.reticle.sh, and telling that user to visit a host they do not use is worse than
128
+ * silence.
129
+ *
130
+ * `email` IS personal data, and it is here because a capsule that cannot name who you are does not
131
+ * answer the question it exists to answer -- an org name is shared by a whole team. It is rendered
132
+ * only inside the account menu, never in the always-visible capsule, so it reaches the DOM on the
133
+ * same terms as the org name and no sooner. It stays OPTIONAL because no cloud sends it yet: the
134
+ * device flow returns `{ status, token, org }` and the session file stores `{ url, token, orgName }`,
135
+ * so today every reader takes the absent branch.
136
+ */
137
+ export const AccountStateSchema = z.object({
138
+ signedIn: z.boolean(),
139
+ org: z.string().optional(),
140
+ email: z.string().optional(),
141
+ host: z.string().optional(),
142
+ });
119
143
  export const ImpactSnapshotSchema = z.object({
120
144
  schemaVersion: z.number().int().positive(),
121
145
  project: ImpactScopeSchema,
@@ -128,6 +152,12 @@ export const ImpactSnapshotSchema = z.object({
128
152
  * short list without a link: the free tool is complete on its own.
129
153
  */
130
154
  dashboardUrl: z.string().optional(),
155
+ /**
156
+ * Whether this machine is signed in. Absent on an SDK/daemon pair too old to send it, which the
157
+ * HUD must read as "unknown", never as "signed out" — prompting a signed-in user to sign in is the
158
+ * kind of nag that gets a dev-only HUD switched off for good.
159
+ */
160
+ account: AccountStateSchema.optional(),
131
161
  });
132
162
  /** Empty counters - the starting point for a fresh store and the identity for merges. */
133
163
  export function emptyImpactCounts() {
@@ -53,9 +53,9 @@ export declare const JournalActionSchema: z.ZodObject<{
53
53
  at: z.ZodNumber;
54
54
  }, "strip", z.ZodTypeAny, {
55
55
  at: number;
56
- actionId: string;
57
- args: Record<string, unknown>;
58
56
  tool: string;
57
+ args: Record<string, unknown>;
58
+ actionId: string;
59
59
  v: 1;
60
60
  tRange: {
61
61
  from: number;
@@ -70,16 +70,16 @@ export declare const JournalActionSchema: z.ZodObject<{
70
70
  } | undefined;
71
71
  }, {
72
72
  at: number;
73
- actionId: string;
74
73
  tool: string;
74
+ actionId: string;
75
75
  v: 1;
76
76
  tRange: {
77
77
  from: number;
78
78
  to: number;
79
79
  };
80
- args?: Record<string, unknown> | undefined;
81
80
  settled?: boolean | undefined;
82
81
  effect?: unknown;
82
+ args?: Record<string, unknown> | undefined;
83
83
  settledInMs?: number | undefined;
84
84
  seqRange?: {
85
85
  from: number;
@@ -110,13 +110,57 @@ export declare const JournalVerdictEffectSchema: z.ZodObject<{
110
110
  }>;
111
111
  /** `file:line` for the element driven, when the page told us one. */
112
112
  source: z.ZodOptional<z.ZodString>;
113
+ /**
114
+ * Was the claim written down BEFORE the action, or after it?
115
+ *
116
+ * The difference between a check and a rationalisation. Recorded here because the journal is the
117
+ * durable record a run artifact is built from: a fact that never reaches it is a fact nothing
118
+ * downstream can ever report, however well the verdict knew it at the time.
119
+ *
120
+ * Absent is not `false`. `false` says the claim came afterwards; absent says nobody recorded which.
121
+ */
122
+ declaredBeforeActing: z.ZodOptional<z.ZodBoolean>;
123
+ /**
124
+ * What kind of evidence bought the answer -- the grade the verdict actually proved.
125
+ *
126
+ * A green paid for with "something matching was on screen" is not the green paid for with "the
127
+ * request went out", and a record that keeps only the word `yes` cannot tell them apart later.
128
+ */
129
+ grade: z.ZodOptional<z.ZodString>;
130
+ /**
131
+ * What could not be seen while this was being checked.
132
+ *
133
+ * The one property with no prior art: every other kind of test record is silent about its own
134
+ * blind spots. Empty means nothing was hidden; absent means nobody looked.
135
+ */
136
+ couldNotSee: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
137
+ /**
138
+ * WHY the verdict came out this way, in the engine's own vocabulary.
139
+ *
140
+ * Without it, `unknown` is one word for facts that need opposite responses: "the outcome has
141
+ * not arrived yet" and "the capture was dirty so I could not see" are both `unknown`, and only
142
+ * the first can ever be answered by waiting. A reader of the record -- or a fold over it --
143
+ * cannot tell a question that is still open from one that was never answerable.
144
+ *
145
+ * Optional, because a record written before this existed has no reason to offer and must not
146
+ * be read as though it did.
147
+ */
148
+ reason: z.ZodOptional<z.ZodString>;
113
149
  }, "strip", z.ZodTypeAny, {
114
150
  claim: string;
115
- verified: "yes" | "no" | "unknown" | "no-fault";
151
+ verified: "unknown" | "yes" | "no" | "no-fault";
116
152
  source?: string | undefined;
153
+ reason?: string | undefined;
154
+ declaredBeforeActing?: boolean | undefined;
155
+ grade?: string | undefined;
156
+ couldNotSee?: string[] | undefined;
117
157
  }, {
118
158
  claim: string;
119
- verified: "yes" | "no" | "unknown" | "no-fault";
159
+ verified: "unknown" | "yes" | "no" | "no-fault";
120
160
  source?: string | undefined;
161
+ reason?: string | undefined;
162
+ declaredBeforeActing?: boolean | undefined;
163
+ grade?: string | undefined;
164
+ couldNotSee?: string[] | undefined;
121
165
  }>;
122
166
  export type JournalVerdictEffect = z.infer<typeof JournalVerdictEffectSchema>;
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { TRANSPORT_LIMITS } from './constants.js';
3
- import { Verified } from './verified-constants.js';
2
+ import { TRANSPORT_LIMITS } from '../wire/constants/constants.js';
3
+ import { Verified } from '../verdict/verified-constants.js';
4
4
  /**
5
5
  * The durable causal journal. Each session gets an append-only pair on disk:
6
6
  * `.reticle/sessions/<id>/events.jsonl` (one `ReticleEvent` per line — already seq/actionId-stamped
@@ -54,4 +54,40 @@ export const JournalVerdictEffectSchema = z.object({
54
54
  verified: z.nativeEnum(Verified),
55
55
  /** `file:line` for the element driven, when the page told us one. */
56
56
  source: z.string().max(TRANSPORT_LIMITS.MAX_URL_LENGTH).optional(),
57
+ /**
58
+ * Was the claim written down BEFORE the action, or after it?
59
+ *
60
+ * The difference between a check and a rationalisation. Recorded here because the journal is the
61
+ * durable record a run artifact is built from: a fact that never reaches it is a fact nothing
62
+ * downstream can ever report, however well the verdict knew it at the time.
63
+ *
64
+ * Absent is not `false`. `false` says the claim came afterwards; absent says nobody recorded which.
65
+ */
66
+ declaredBeforeActing: z.boolean().optional(),
67
+ /**
68
+ * What kind of evidence bought the answer -- the grade the verdict actually proved.
69
+ *
70
+ * A green paid for with "something matching was on screen" is not the green paid for with "the
71
+ * request went out", and a record that keeps only the word `yes` cannot tell them apart later.
72
+ */
73
+ grade: z.string().max(TRANSPORT_LIMITS.MAX_STRING_LENGTH).optional(),
74
+ /**
75
+ * What could not be seen while this was being checked.
76
+ *
77
+ * The one property with no prior art: every other kind of test record is silent about its own
78
+ * blind spots. Empty means nothing was hidden; absent means nobody looked.
79
+ */
80
+ couldNotSee: z.array(z.string().max(TRANSPORT_LIMITS.MAX_STRING_LENGTH)).optional(),
81
+ /**
82
+ * WHY the verdict came out this way, in the engine's own vocabulary.
83
+ *
84
+ * Without it, `unknown` is one word for facts that need opposite responses: "the outcome has
85
+ * not arrived yet" and "the capture was dirty so I could not see" are both `unknown`, and only
86
+ * the first can ever be answered by waiting. A reader of the record -- or a fold over it --
87
+ * cannot tell a question that is still open from one that was never answerable.
88
+ *
89
+ * Optional, because a record written before this existed has no reason to offer and must not
90
+ * be read as though it did.
91
+ */
92
+ reason: z.string().max(TRANSPORT_LIMITS.MAX_STRING_LENGTH).optional(),
57
93
  });
@@ -0,0 +1,29 @@
1
+ /**
2
+ * What a step DOES to the subject, so a resume can refuse to re-run a prefix that commits.
3
+ *
4
+ * Replay resumes by re-driving the steps before the one you asked for: it does not restore state,
5
+ * because there is no way to put an app back. `flow-replay.ts` states the cost honestly — "nearly
6
+ * free, just re-run the prefix" is true of a browser and false of a subject that COMMITS, where it
7
+ * re-sends every request before step N. The flow could not SAY which steps those were, so the engine
8
+ * had no way to refuse and the guard was a sentence in a comment.
9
+ *
10
+ * Absent means UNKNOWN, and unknown behaves exactly as it always has: the prefix is re-driven.
11
+ * Assuming `commits` for an unlabelled step would refuse every flow recorded before this shipped,
12
+ * which is a worse failure than the one it prevents.
13
+ *
14
+ * IN A LEAF OF ITS OWN, and that is not tidiness. It first landed in `flow-constants.ts`, which the
15
+ * browser SDK's recorder imports for `FLOW_FILE_VERSION` — so this object was downloaded by every
16
+ * instrumented page, on every load, to support a decision only the replay engine ever makes. The
17
+ * first-load guard caught it at 79 bytes over its ceiling. The lesson is already written down beside
18
+ * that guard: naming a single value that lives beside something heavy pulls in everything its file
19
+ * holds, so put the value in a leaf of its own instead.
20
+ */
21
+ export declare const StepEffect: {
22
+ /** Reads the subject and changes nothing. Always safe to re-run. */
23
+ readonly READ: "read";
24
+ /** Changes state, but running it twice lands in the same place. Safe to re-run. */
25
+ readonly IDEMPOTENT: "idempotent";
26
+ /** Has an effect the subject keeps: a payment, a send, a create. NEVER re-run silently. */
27
+ readonly COMMITS: "commits";
28
+ };
29
+ export type StepEffect = (typeof StepEffect)[keyof typeof StepEffect];
@@ -0,0 +1,28 @@
1
+ /**
2
+ * What a step DOES to the subject, so a resume can refuse to re-run a prefix that commits.
3
+ *
4
+ * Replay resumes by re-driving the steps before the one you asked for: it does not restore state,
5
+ * because there is no way to put an app back. `flow-replay.ts` states the cost honestly — "nearly
6
+ * free, just re-run the prefix" is true of a browser and false of a subject that COMMITS, where it
7
+ * re-sends every request before step N. The flow could not SAY which steps those were, so the engine
8
+ * had no way to refuse and the guard was a sentence in a comment.
9
+ *
10
+ * Absent means UNKNOWN, and unknown behaves exactly as it always has: the prefix is re-driven.
11
+ * Assuming `commits` for an unlabelled step would refuse every flow recorded before this shipped,
12
+ * which is a worse failure than the one it prevents.
13
+ *
14
+ * IN A LEAF OF ITS OWN, and that is not tidiness. It first landed in `flow-constants.ts`, which the
15
+ * browser SDK's recorder imports for `FLOW_FILE_VERSION` — so this object was downloaded by every
16
+ * instrumented page, on every load, to support a decision only the replay engine ever makes. The
17
+ * first-load guard caught it at 79 bytes over its ceiling. The lesson is already written down beside
18
+ * that guard: naming a single value that lives beside something heavy pulls in everything its file
19
+ * holds, so put the value in a leaf of its own instead.
20
+ */
21
+ export const StepEffect = {
22
+ /** Reads the subject and changes nothing. Always safe to re-run. */
23
+ READ: 'read',
24
+ /** Changes state, but running it twice lands in the same place. Safe to re-run. */
25
+ IDEMPOTENT: 'idempotent',
26
+ /** Has an effect the subject keeps: a payment, a send, a create. NEVER re-run silently. */
27
+ COMMITS: 'commits',
28
+ };
@@ -0,0 +1,311 @@
1
+ /**
2
+ * What Reticle says happened, and the shape it says it in.
3
+ *
4
+ * This is a CONTRACT, not an internal enum, which is why it lives in `core` beside the wire types.
5
+ * A hook payload crosses into somebody else's script, so renaming an event kind is a breaking
6
+ * change and has to be treated as one.
7
+ *
8
+ * Every event is a MOMENT SOMETHING BECAME TRUE, never a step on the way there. `verdict` is a
9
+ * verdict; there is no `verdict_starting`, no `snapshot_taken`, no per-tool-call firehose — an event
10
+ * that fires on internal progress freezes internal structure into a public contract. The bar for
11
+ * adding one is the bar for a tool: name what a consumer could not otherwise know, and that stays
12
+ * true if the implementation is rewritten.
13
+ *
14
+ * A payload carries NO credentials, ever — not the pairing token, not the cloud API key, not a
15
+ * session cookie the page was carrying. Assume anything put here ends up in a log nobody here
16
+ * controls. `hook-payload-carries-no-secret.test.ts` is the check, and it reads this file's schemas
17
+ * rather than a hand-kept list.
18
+ */
19
+ import { z } from 'zod';
20
+ /**
21
+ * The events a hook can attach to.
22
+ *
23
+ * Values are the STRING a user writes in `.reticle/hooks.json`, so they read as English and stay
24
+ * stable. A constant object rather than a TypeScript `enum` for the same reason as everything else
25
+ * here: it survives `JSON.stringify` and a consumer can compare against the literal.
26
+ */
27
+ export declare const HookEvent: {
28
+ /**
29
+ * A verdict landed — the thing this product exists to produce.
30
+ *
31
+ * Fires for ALL FOUR outcomes, `unknown` and `no-fault` included. A hook that only heard about
32
+ * passes and failures would be told a different story from the one the verdict channel tells, and
33
+ * "I could not tell" leaving the account is precisely the failure mode Reticle is built to stop.
34
+ */
35
+ readonly VERDICT: "verdict";
36
+ /**
37
+ * A defect was found. One event per defect, not one per run.
38
+ *
39
+ * Carries `repeat`, so a consumer can tell a newly-found defect from the same one seen again
40
+ * without keeping its own ledger — counting instances as defects is how a number inflates itself.
41
+ */
42
+ readonly BUG_FOUND: "bug_found";
43
+ /** A browser session attached. */
44
+ readonly SESSION_STARTED: "session_started";
45
+ /** A browser session ended, and its run artifact (if any) is on disk by the time this fires. */
46
+ readonly SESSION_ENDED: "session_ended";
47
+ /**
48
+ * A cloud sync cycle finished, with what it actually moved.
49
+ *
50
+ * Fires on a cycle that sent NOTHING too. "Nothing changed" and "sync is broken" look identical
51
+ * from outside, and a consumer that cannot tell them apart has to guess.
52
+ */
53
+ readonly SYNC_COMPLETED: "sync_completed";
54
+ };
55
+ export type HookEventName = (typeof HookEvent)[keyof typeof HookEvent];
56
+ /** Every event name, for validating a config file and for telling a user what they may write. */
57
+ export declare const HOOK_EVENT_NAMES: readonly HookEventName[];
58
+ export declare const VerdictHookPayloadSchema: z.ZodObject<{
59
+ at: z.ZodString;
60
+ projectId: z.ZodOptional<z.ZodString>;
61
+ } & {
62
+ event: z.ZodLiteral<"verdict">;
63
+ tool: z.ZodString;
64
+ verified: z.ZodString;
65
+ because: z.ZodOptional<z.ZodString>;
66
+ sessionId: z.ZodOptional<z.ZodString>;
67
+ url: z.ZodOptional<z.ZodString>;
68
+ }, "strip", z.ZodTypeAny, {
69
+ event: "verdict";
70
+ at: string;
71
+ tool: string;
72
+ verified: string;
73
+ projectId?: string | undefined;
74
+ url?: string | undefined;
75
+ sessionId?: string | undefined;
76
+ because?: string | undefined;
77
+ }, {
78
+ event: "verdict";
79
+ at: string;
80
+ tool: string;
81
+ verified: string;
82
+ projectId?: string | undefined;
83
+ url?: string | undefined;
84
+ sessionId?: string | undefined;
85
+ because?: string | undefined;
86
+ }>;
87
+ export type VerdictHookPayload = z.infer<typeof VerdictHookPayloadSchema>;
88
+ export declare const BugFoundHookPayloadSchema: z.ZodObject<{
89
+ at: z.ZodString;
90
+ projectId: z.ZodOptional<z.ZodString>;
91
+ } & {
92
+ event: z.ZodLiteral<"bug_found">;
93
+ kind: z.ZodString;
94
+ source: z.ZodOptional<z.ZodString>;
95
+ fingerprint: z.ZodOptional<z.ZodString>;
96
+ repeat: z.ZodBoolean;
97
+ route: z.ZodOptional<z.ZodString>;
98
+ tool: z.ZodString;
99
+ sessionId: z.ZodOptional<z.ZodString>;
100
+ }, "strip", z.ZodTypeAny, {
101
+ event: "bug_found";
102
+ kind: string;
103
+ at: string;
104
+ tool: string;
105
+ repeat: boolean;
106
+ route?: string | undefined;
107
+ source?: string | undefined;
108
+ projectId?: string | undefined;
109
+ sessionId?: string | undefined;
110
+ fingerprint?: string | undefined;
111
+ }, {
112
+ event: "bug_found";
113
+ kind: string;
114
+ at: string;
115
+ tool: string;
116
+ repeat: boolean;
117
+ route?: string | undefined;
118
+ source?: string | undefined;
119
+ projectId?: string | undefined;
120
+ sessionId?: string | undefined;
121
+ fingerprint?: string | undefined;
122
+ }>;
123
+ export type BugFoundHookPayload = z.infer<typeof BugFoundHookPayloadSchema>;
124
+ export declare const SessionHookPayloadSchema: z.ZodObject<{
125
+ at: z.ZodString;
126
+ projectId: z.ZodOptional<z.ZodString>;
127
+ } & {
128
+ event: z.ZodEnum<["session_started", "session_ended"]>;
129
+ sessionId: z.ZodString;
130
+ url: z.ZodOptional<z.ZodString>;
131
+ runtime: z.ZodOptional<z.ZodString>;
132
+ }, "strip", z.ZodTypeAny, {
133
+ event: "session_started" | "session_ended";
134
+ at: string;
135
+ sessionId: string;
136
+ projectId?: string | undefined;
137
+ url?: string | undefined;
138
+ runtime?: string | undefined;
139
+ }, {
140
+ event: "session_started" | "session_ended";
141
+ at: string;
142
+ sessionId: string;
143
+ projectId?: string | undefined;
144
+ url?: string | undefined;
145
+ runtime?: string | undefined;
146
+ }>;
147
+ export type SessionHookPayload = z.infer<typeof SessionHookPayloadSchema>;
148
+ export declare const SyncHookPayloadSchema: z.ZodObject<{
149
+ at: z.ZodString;
150
+ projectId: z.ZodOptional<z.ZodString>;
151
+ } & {
152
+ event: z.ZodLiteral<"sync_completed">;
153
+ runsPushed: z.ZodNumber;
154
+ ok: z.ZodBoolean;
155
+ error: z.ZodOptional<z.ZodString>;
156
+ }, "strip", z.ZodTypeAny, {
157
+ event: "sync_completed";
158
+ ok: boolean;
159
+ at: string;
160
+ runsPushed: number;
161
+ error?: string | undefined;
162
+ projectId?: string | undefined;
163
+ }, {
164
+ event: "sync_completed";
165
+ ok: boolean;
166
+ at: string;
167
+ runsPushed: number;
168
+ error?: string | undefined;
169
+ projectId?: string | undefined;
170
+ }>;
171
+ export type SyncHookPayload = z.infer<typeof SyncHookPayloadSchema>;
172
+ /** Any hook payload. A consumer narrows on `event`, which every variant carries as a literal. */
173
+ export declare const HookPayloadSchema: z.ZodDiscriminatedUnion<"event", [z.ZodObject<{
174
+ at: z.ZodString;
175
+ projectId: z.ZodOptional<z.ZodString>;
176
+ } & {
177
+ event: z.ZodLiteral<"verdict">;
178
+ tool: z.ZodString;
179
+ verified: z.ZodString;
180
+ because: z.ZodOptional<z.ZodString>;
181
+ sessionId: z.ZodOptional<z.ZodString>;
182
+ url: z.ZodOptional<z.ZodString>;
183
+ }, "strip", z.ZodTypeAny, {
184
+ event: "verdict";
185
+ at: string;
186
+ tool: string;
187
+ verified: string;
188
+ projectId?: string | undefined;
189
+ url?: string | undefined;
190
+ sessionId?: string | undefined;
191
+ because?: string | undefined;
192
+ }, {
193
+ event: "verdict";
194
+ at: string;
195
+ tool: string;
196
+ verified: string;
197
+ projectId?: string | undefined;
198
+ url?: string | undefined;
199
+ sessionId?: string | undefined;
200
+ because?: string | undefined;
201
+ }>, z.ZodObject<{
202
+ at: z.ZodString;
203
+ projectId: z.ZodOptional<z.ZodString>;
204
+ } & {
205
+ event: z.ZodLiteral<"bug_found">;
206
+ kind: z.ZodString;
207
+ source: z.ZodOptional<z.ZodString>;
208
+ fingerprint: z.ZodOptional<z.ZodString>;
209
+ repeat: z.ZodBoolean;
210
+ route: z.ZodOptional<z.ZodString>;
211
+ tool: z.ZodString;
212
+ sessionId: z.ZodOptional<z.ZodString>;
213
+ }, "strip", z.ZodTypeAny, {
214
+ event: "bug_found";
215
+ kind: string;
216
+ at: string;
217
+ tool: string;
218
+ repeat: boolean;
219
+ route?: string | undefined;
220
+ source?: string | undefined;
221
+ projectId?: string | undefined;
222
+ sessionId?: string | undefined;
223
+ fingerprint?: string | undefined;
224
+ }, {
225
+ event: "bug_found";
226
+ kind: string;
227
+ at: string;
228
+ tool: string;
229
+ repeat: boolean;
230
+ route?: string | undefined;
231
+ source?: string | undefined;
232
+ projectId?: string | undefined;
233
+ sessionId?: string | undefined;
234
+ fingerprint?: string | undefined;
235
+ }>, z.ZodObject<{
236
+ at: z.ZodString;
237
+ projectId: z.ZodOptional<z.ZodString>;
238
+ sessionId: z.ZodString;
239
+ url: z.ZodOptional<z.ZodString>;
240
+ runtime: z.ZodOptional<z.ZodString>;
241
+ } & {
242
+ event: z.ZodLiteral<"session_started">;
243
+ }, "strip", z.ZodTypeAny, {
244
+ event: "session_started";
245
+ at: string;
246
+ sessionId: string;
247
+ projectId?: string | undefined;
248
+ url?: string | undefined;
249
+ runtime?: string | undefined;
250
+ }, {
251
+ event: "session_started";
252
+ at: string;
253
+ sessionId: string;
254
+ projectId?: string | undefined;
255
+ url?: string | undefined;
256
+ runtime?: string | undefined;
257
+ }>, z.ZodObject<{
258
+ at: z.ZodString;
259
+ projectId: z.ZodOptional<z.ZodString>;
260
+ sessionId: z.ZodString;
261
+ url: z.ZodOptional<z.ZodString>;
262
+ runtime: z.ZodOptional<z.ZodString>;
263
+ } & {
264
+ event: z.ZodLiteral<"session_ended">;
265
+ }, "strip", z.ZodTypeAny, {
266
+ event: "session_ended";
267
+ at: string;
268
+ sessionId: string;
269
+ projectId?: string | undefined;
270
+ url?: string | undefined;
271
+ runtime?: string | undefined;
272
+ }, {
273
+ event: "session_ended";
274
+ at: string;
275
+ sessionId: string;
276
+ projectId?: string | undefined;
277
+ url?: string | undefined;
278
+ runtime?: string | undefined;
279
+ }>, z.ZodObject<{
280
+ at: z.ZodString;
281
+ projectId: z.ZodOptional<z.ZodString>;
282
+ } & {
283
+ event: z.ZodLiteral<"sync_completed">;
284
+ runsPushed: z.ZodNumber;
285
+ ok: z.ZodBoolean;
286
+ error: z.ZodOptional<z.ZodString>;
287
+ }, "strip", z.ZodTypeAny, {
288
+ event: "sync_completed";
289
+ ok: boolean;
290
+ at: string;
291
+ runsPushed: number;
292
+ error?: string | undefined;
293
+ projectId?: string | undefined;
294
+ }, {
295
+ event: "sync_completed";
296
+ ok: boolean;
297
+ at: string;
298
+ runsPushed: number;
299
+ error?: string | undefined;
300
+ projectId?: string | undefined;
301
+ }>]>;
302
+ export type HookPayload = z.infer<typeof HookPayloadSchema>;
303
+ /**
304
+ * The file a user writes: event name to command.
305
+ *
306
+ * A single command per event, deliberately. A list would invite "run these five things in order",
307
+ * which is a build system, and the shell already has one — a user who needs two things writes a
308
+ * script that does two things, and keeps the failure handling where they can see it.
309
+ */
310
+ export declare const HookConfigSchema: z.ZodRecord<z.ZodString, z.ZodString>;
311
+ export type HookConfig = z.infer<typeof HookConfigSchema>;
@@ -0,0 +1,127 @@
1
+ /**
2
+ * What Reticle says happened, and the shape it says it in.
3
+ *
4
+ * This is a CONTRACT, not an internal enum, which is why it lives in `core` beside the wire types.
5
+ * A hook payload crosses into somebody else's script, so renaming an event kind is a breaking
6
+ * change and has to be treated as one.
7
+ *
8
+ * Every event is a MOMENT SOMETHING BECAME TRUE, never a step on the way there. `verdict` is a
9
+ * verdict; there is no `verdict_starting`, no `snapshot_taken`, no per-tool-call firehose — an event
10
+ * that fires on internal progress freezes internal structure into a public contract. The bar for
11
+ * adding one is the bar for a tool: name what a consumer could not otherwise know, and that stays
12
+ * true if the implementation is rewritten.
13
+ *
14
+ * A payload carries NO credentials, ever — not the pairing token, not the cloud API key, not a
15
+ * session cookie the page was carrying. Assume anything put here ends up in a log nobody here
16
+ * controls. `hook-payload-carries-no-secret.test.ts` is the check, and it reads this file's schemas
17
+ * rather than a hand-kept list.
18
+ */
19
+ import { z } from 'zod';
20
+ /**
21
+ * The events a hook can attach to.
22
+ *
23
+ * Values are the STRING a user writes in `.reticle/hooks.json`, so they read as English and stay
24
+ * stable. A constant object rather than a TypeScript `enum` for the same reason as everything else
25
+ * here: it survives `JSON.stringify` and a consumer can compare against the literal.
26
+ */
27
+ export const HookEvent = {
28
+ /**
29
+ * A verdict landed — the thing this product exists to produce.
30
+ *
31
+ * Fires for ALL FOUR outcomes, `unknown` and `no-fault` included. A hook that only heard about
32
+ * passes and failures would be told a different story from the one the verdict channel tells, and
33
+ * "I could not tell" leaving the account is precisely the failure mode Reticle is built to stop.
34
+ */
35
+ VERDICT: 'verdict',
36
+ /**
37
+ * A defect was found. One event per defect, not one per run.
38
+ *
39
+ * Carries `repeat`, so a consumer can tell a newly-found defect from the same one seen again
40
+ * without keeping its own ledger — counting instances as defects is how a number inflates itself.
41
+ */
42
+ BUG_FOUND: 'bug_found',
43
+ /** A browser session attached. */
44
+ SESSION_STARTED: 'session_started',
45
+ /** A browser session ended, and its run artifact (if any) is on disk by the time this fires. */
46
+ SESSION_ENDED: 'session_ended',
47
+ /**
48
+ * A cloud sync cycle finished, with what it actually moved.
49
+ *
50
+ * Fires on a cycle that sent NOTHING too. "Nothing changed" and "sync is broken" look identical
51
+ * from outside, and a consumer that cannot tell them apart has to guess.
52
+ */
53
+ SYNC_COMPLETED: 'sync_completed',
54
+ };
55
+ /** Every event name, for validating a config file and for telling a user what they may write. */
56
+ export const HOOK_EVENT_NAMES = Object.values(HookEvent);
57
+ /**
58
+ * Carried on every payload, so a consumer reading one event off stdin knows what it is holding
59
+ * without being told out of band.
60
+ *
61
+ * `at` is an ISO timestamp rather than an epoch number because the first thing most hook scripts do
62
+ * is print it, and because a payload is a document a human may end up reading in a log.
63
+ */
64
+ const BaseHookPayload = z.object({
65
+ event: z.enum(HOOK_EVENT_NAMES),
66
+ at: z.string(),
67
+ /** The project this happened in, when one is identifiable. Absent outside a wired project. */
68
+ projectId: z.string().optional(),
69
+ });
70
+ export const VerdictHookPayloadSchema = BaseHookPayload.extend({
71
+ event: z.literal(HookEvent.VERDICT),
72
+ /** The tool that produced it — `reticle_assert`, `reticle_act_and_wait`, and so on. */
73
+ tool: z.string(),
74
+ /** `yes` | `no` | `unknown` | `no-fault`, in the protocol's own words. */
75
+ verified: z.string(),
76
+ /** The sentence the verdict gave for itself, when it gave one. */
77
+ because: z.string().optional(),
78
+ sessionId: z.string().optional(),
79
+ url: z.string().optional(),
80
+ });
81
+ export const BugFoundHookPayloadSchema = BaseHookPayload.extend({
82
+ event: z.literal(HookEvent.BUG_FOUND),
83
+ /** The finding kind from core's enum — `response-ignored`, `state-vs-render`, and so on. */
84
+ kind: z.string(),
85
+ /** Which channel reported it. */
86
+ source: z.string().optional(),
87
+ /** Stable across runs for the same defect, so a consumer can deduplicate without heuristics. */
88
+ fingerprint: z.string().optional(),
89
+ /** True when this defect kind has already been seen in this session. */
90
+ repeat: z.boolean(),
91
+ /** The route it was found on, when the result named one. */
92
+ route: z.string().optional(),
93
+ tool: z.string(),
94
+ sessionId: z.string().optional(),
95
+ });
96
+ export const SessionHookPayloadSchema = BaseHookPayload.extend({
97
+ event: z.enum([HookEvent.SESSION_STARTED, HookEvent.SESSION_ENDED]),
98
+ sessionId: z.string(),
99
+ url: z.string().optional(),
100
+ /** `web`, `electron`, `tauri` — absent on an SDK too old to report one, never defaulted. */
101
+ runtime: z.string().optional(),
102
+ });
103
+ export const SyncHookPayloadSchema = BaseHookPayload.extend({
104
+ event: z.literal(HookEvent.SYNC_COMPLETED),
105
+ /** How many run artifacts this cycle pushed. Zero is a real and useful answer. */
106
+ runsPushed: z.number().int().nonnegative(),
107
+ /** Whether the cycle completed without error. */
108
+ ok: z.boolean(),
109
+ /** Why it failed, when it did. */
110
+ error: z.string().optional(),
111
+ });
112
+ /** Any hook payload. A consumer narrows on `event`, which every variant carries as a literal. */
113
+ export const HookPayloadSchema = z.discriminatedUnion('event', [
114
+ VerdictHookPayloadSchema,
115
+ BugFoundHookPayloadSchema,
116
+ SessionHookPayloadSchema.extend({ event: z.literal(HookEvent.SESSION_STARTED) }),
117
+ SessionHookPayloadSchema.extend({ event: z.literal(HookEvent.SESSION_ENDED) }),
118
+ SyncHookPayloadSchema,
119
+ ]);
120
+ /**
121
+ * The file a user writes: event name to command.
122
+ *
123
+ * A single command per event, deliberately. A list would invite "run these five things in order",
124
+ * which is a build system, and the shell already has one — a user who needs two things writes a
125
+ * script that does two things, and keeps the failure handling where they can see it.
126
+ */
127
+ export const HookConfigSchema = z.record(z.string(), z.string());