@retrace-dev/core 0.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.
- package/LICENSE +202 -0
- package/README.md +5 -0
- package/dist/chain.d.ts +25 -0
- package/dist/chain.js +70 -0
- package/dist/explain.d.ts +8 -0
- package/dist/explain.js +30 -0
- package/dist/export.d.ts +53 -0
- package/dist/export.js +85 -0
- package/dist/gdrive.d.ts +32 -0
- package/dist/gdrive.js +129 -0
- package/dist/github.d.ts +30 -0
- package/dist/github.js +112 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +12 -0
- package/dist/lineage.d.ts +50 -0
- package/dist/lineage.js +150 -0
- package/dist/report.d.ts +6 -0
- package/dist/report.js +79 -0
- package/dist/router.d.ts +136 -0
- package/dist/router.js +391 -0
- package/dist/schema.d.ts +708 -0
- package/dist/schema.js +177 -0
- package/dist/signing.d.ts +13 -0
- package/dist/signing.js +55 -0
- package/dist/status.d.ts +49 -0
- package/dist/status.js +85 -0
- package/dist/store.d.ts +66 -0
- package/dist/store.js +84 -0
- package/dist/ui-html.d.ts +1 -0
- package/dist/ui-html.js +2 -0
- package/package.json +26 -0
- package/ui/retrace.html +479 -0
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,708 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrace core schema — the six dimensions of provenance:
|
|
3
|
+
* WHO (actor) · WHAT (action + artifacts + change) · WHEN (timestamp/seq)
|
|
4
|
+
* WHERE (location) · WHY (intent + caused_by) · HOW (method)
|
|
5
|
+
* plus integrity (hash chain).
|
|
6
|
+
*
|
|
7
|
+
* Deliberately close to W3C PROV (Agent / Activity / Entity) so we can export later.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
export declare const ActorType: z.ZodEnum<["human", "agent", "system"]>;
|
|
11
|
+
export type ActorType = z.infer<typeof ActorType>;
|
|
12
|
+
export declare const Actor: z.ZodObject<{
|
|
13
|
+
type: z.ZodEnum<["human", "agent", "system"]>;
|
|
14
|
+
/** Stable identifier: email, agent name, service id */
|
|
15
|
+
id: z.ZodString;
|
|
16
|
+
display_name: z.ZodOptional<z.ZodString>;
|
|
17
|
+
/** For agents: model + version that performed the action */
|
|
18
|
+
model: z.ZodOptional<z.ZodString>;
|
|
19
|
+
version: z.ZodOptional<z.ZodString>;
|
|
20
|
+
/** Delegation: an agent acting for a human, or a sub-agent for a parent agent */
|
|
21
|
+
on_behalf_of: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
type: "human" | "agent" | "system";
|
|
24
|
+
id: string;
|
|
25
|
+
display_name?: string | undefined;
|
|
26
|
+
model?: string | undefined;
|
|
27
|
+
version?: string | undefined;
|
|
28
|
+
on_behalf_of?: string | undefined;
|
|
29
|
+
}, {
|
|
30
|
+
type: "human" | "agent" | "system";
|
|
31
|
+
id: string;
|
|
32
|
+
display_name?: string | undefined;
|
|
33
|
+
model?: string | undefined;
|
|
34
|
+
version?: string | undefined;
|
|
35
|
+
on_behalf_of?: string | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
export type Actor = z.infer<typeof Actor>;
|
|
38
|
+
/** Small controlled verb vocabulary. `other` requires `action_detail`. */
|
|
39
|
+
export declare const Action: z.ZodEnum<["created", "edited", "deleted", "read", "executed", "approved", "rejected", "sent", "received", "moved", "renamed", "instructed", "committed", "merged", "other"]>;
|
|
40
|
+
export type Action = z.infer<typeof Action>;
|
|
41
|
+
/**
|
|
42
|
+
* PROV role of an artifact within an event: was it an input the activity `used`, an output it `generated`, or `both`
|
|
43
|
+
* (read then rewritten). Optional — absence means "unspecified" and is a legal, permanent state: events sealed before
|
|
44
|
+
* this field existed are never backfilled or re-hashed (absence is information).
|
|
45
|
+
* Export mapping (for a future prov exporter): used → prov:used (Activity→Entity), generated → prov:wasGeneratedBy
|
|
46
|
+
* (Entity→Activity), both → both edges, absent → degrades to prov:wasInfluencedBy.
|
|
47
|
+
* Distinct from `derived_from`, which is Entity→Entity (prov:wasDerivedFrom) and unchanged. Invalidation (a deleted
|
|
48
|
+
* artifact, prov:wasInvalidatedBy) is deliberately NOT a role — a deleted ref stays absent until that is a first-class edge.
|
|
49
|
+
*/
|
|
50
|
+
export declare const ArtifactRole: z.ZodEnum<["used", "generated", "both"]>;
|
|
51
|
+
export type ArtifactRole = z.infer<typeof ArtifactRole>;
|
|
52
|
+
export declare const ArtifactRef: z.ZodObject<{
|
|
53
|
+
/** Stable id for the thing being worked on, e.g. "repo:slcwitit/rpg#src/fight.ts" or "doc:abc123" */
|
|
54
|
+
id: z.ZodString;
|
|
55
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
56
|
+
label: z.ZodOptional<z.ZodString>;
|
|
57
|
+
/** Lineage: this artifact was derived from these */
|
|
58
|
+
derived_from: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
59
|
+
/** PROV: input (used) / output (generated) / both. Body-only, hash-covered on new events; see ArtifactRole. */
|
|
60
|
+
role: z.ZodOptional<z.ZodEnum<["used", "generated", "both"]>>;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
id: string;
|
|
63
|
+
kind?: string | undefined;
|
|
64
|
+
label?: string | undefined;
|
|
65
|
+
derived_from?: string[] | undefined;
|
|
66
|
+
role?: "used" | "generated" | "both" | undefined;
|
|
67
|
+
}, {
|
|
68
|
+
id: string;
|
|
69
|
+
kind?: string | undefined;
|
|
70
|
+
label?: string | undefined;
|
|
71
|
+
derived_from?: string[] | undefined;
|
|
72
|
+
role?: "used" | "generated" | "both" | undefined;
|
|
73
|
+
}>;
|
|
74
|
+
export type ArtifactRef = z.infer<typeof ArtifactRef>;
|
|
75
|
+
/**
|
|
76
|
+
* Default role of an artifact ref for an action verb, for when the caller says nothing. `undefined` = leave absent.
|
|
77
|
+
* read → used · created/committed/merged → generated · edited/moved/renamed → both (the prior state is read, the new
|
|
78
|
+
* one written) · executed/sent/received/approved/rejected → used (the thing run/sent/reviewed was an input; an OUTPUT
|
|
79
|
+
* such as a deployment or report must be said by the caller) · deleted/instructed/other → absent.
|
|
80
|
+
* Adapters stamp what they authoritatively know and only fall back to this where the verb alone is the truth.
|
|
81
|
+
*/
|
|
82
|
+
export declare function defaultArtifactRole(action: Action): ArtifactRole | undefined;
|
|
83
|
+
/** Fill `role` from defaultArtifactRole ONLY where a ref has none — a caller-supplied role is never overwritten. Refs
|
|
84
|
+
* that get no default come back as they were (no `role` key, so hashes of role-less inputs are unaffected). */
|
|
85
|
+
export declare function applyDefaultRoles<T extends ArtifactRef>(action: Action, artifacts: T[]): T[];
|
|
86
|
+
export declare const Change: z.ZodObject<{
|
|
87
|
+
before_hash: z.ZodOptional<z.ZodString>;
|
|
88
|
+
after_hash: z.ZodOptional<z.ZodString>;
|
|
89
|
+
diff: z.ZodOptional<z.ZodString>;
|
|
90
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
91
|
+
}, "strip", z.ZodTypeAny, {
|
|
92
|
+
before_hash?: string | undefined;
|
|
93
|
+
after_hash?: string | undefined;
|
|
94
|
+
diff?: string | undefined;
|
|
95
|
+
summary?: string | undefined;
|
|
96
|
+
}, {
|
|
97
|
+
before_hash?: string | undefined;
|
|
98
|
+
after_hash?: string | undefined;
|
|
99
|
+
diff?: string | undefined;
|
|
100
|
+
summary?: string | undefined;
|
|
101
|
+
}>;
|
|
102
|
+
export declare const Location: z.ZodObject<{
|
|
103
|
+
/** repo path, doc section, URL, table, etc. */
|
|
104
|
+
path: z.ZodOptional<z.ZodString>;
|
|
105
|
+
url: z.ZodOptional<z.ZodString>;
|
|
106
|
+
environment: z.ZodOptional<z.ZodString>;
|
|
107
|
+
device: z.ZodOptional<z.ZodString>;
|
|
108
|
+
system: z.ZodOptional<z.ZodString>;
|
|
109
|
+
/** Run/session id of the producing process (backlog #15; body-only, like every location field). On the MCP path
|
|
110
|
+
* this is the harness's own session id when it exposes one (CLAUDE_CODE_SESSION_ID or GROK_SESSION_ID), so the same string appears on
|
|
111
|
+
* events from the agent AND on the commits it drives. It is a *session* key — subagents share it — not a per-run id. */
|
|
112
|
+
session: z.ZodOptional<z.ZodString>;
|
|
113
|
+
/** The MCP client that drove the write, verbatim from the `initialize` handshake as "<name>@<version>" — e.g.
|
|
114
|
+
* "claude-code@2.1.250", "cursor-vscode@1.7.3". Server-stamped only: it is evidence ABOUT the writer, so the
|
|
115
|
+
* writer may not assert it (see SERVER_ONLY in the MCP server). */
|
|
116
|
+
client: z.ZodOptional<z.ZodString>;
|
|
117
|
+
/** IDE / agent-development environment hosting the actor, e.g. "orca". Deliberately distinct from `system` (the tool
|
|
118
|
+
* that produced the event, "claude-code") and from `client` (which build of it): the IDE is the app AROUND both, and
|
|
119
|
+
* neither of the other two can express it. Only stamped when the IDE identifies itself in the environment. */
|
|
120
|
+
ide: z.ZodOptional<z.ZodString>;
|
|
121
|
+
/** Isolated workspace within `ide` — an Orca worktree id, a codespace or devcontainer name. This is what tells two
|
|
122
|
+
* parallel agents apart when they run the same project, on the same host, as the same actor. */
|
|
123
|
+
workspace: z.ZodOptional<z.ZodString>;
|
|
124
|
+
/** Whether the producing process had a controlling terminal: "tty" = a human at a keyboard, "agent" = spawned by a
|
|
125
|
+
* harness with none. Linux-only today (read from /proc/self/stat); absent everywhere else, and absence is a legal
|
|
126
|
+
* permanent state. EVIDENCE, never authority — it must not override the actor determination. */
|
|
127
|
+
surface: z.ZodOptional<z.ZodEnum<["tty", "agent"]>>;
|
|
128
|
+
}, "strip", z.ZodTypeAny, {
|
|
129
|
+
system?: string | undefined;
|
|
130
|
+
path?: string | undefined;
|
|
131
|
+
url?: string | undefined;
|
|
132
|
+
environment?: string | undefined;
|
|
133
|
+
device?: string | undefined;
|
|
134
|
+
session?: string | undefined;
|
|
135
|
+
client?: string | undefined;
|
|
136
|
+
ide?: string | undefined;
|
|
137
|
+
workspace?: string | undefined;
|
|
138
|
+
surface?: "agent" | "tty" | undefined;
|
|
139
|
+
}, {
|
|
140
|
+
system?: string | undefined;
|
|
141
|
+
path?: string | undefined;
|
|
142
|
+
url?: string | undefined;
|
|
143
|
+
environment?: string | undefined;
|
|
144
|
+
device?: string | undefined;
|
|
145
|
+
session?: string | undefined;
|
|
146
|
+
client?: string | undefined;
|
|
147
|
+
ide?: string | undefined;
|
|
148
|
+
workspace?: string | undefined;
|
|
149
|
+
surface?: "agent" | "tty" | undefined;
|
|
150
|
+
}>;
|
|
151
|
+
export type Location = z.infer<typeof Location>;
|
|
152
|
+
export declare const Method: z.ZodObject<{
|
|
153
|
+
tool: z.ZodOptional<z.ZodString>;
|
|
154
|
+
/** Reference to instruction/prompt that drove this (id, hash, or short text) */
|
|
155
|
+
instruction: z.ZodOptional<z.ZodString>;
|
|
156
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
157
|
+
automated: z.ZodOptional<z.ZodBoolean>;
|
|
158
|
+
tokens: z.ZodOptional<z.ZodNumber>;
|
|
159
|
+
cost_usd: z.ZodOptional<z.ZodNumber>;
|
|
160
|
+
}, "strip", z.ZodTypeAny, {
|
|
161
|
+
params?: Record<string, unknown> | undefined;
|
|
162
|
+
tool?: string | undefined;
|
|
163
|
+
instruction?: string | undefined;
|
|
164
|
+
automated?: boolean | undefined;
|
|
165
|
+
tokens?: number | undefined;
|
|
166
|
+
cost_usd?: number | undefined;
|
|
167
|
+
}, {
|
|
168
|
+
params?: Record<string, unknown> | undefined;
|
|
169
|
+
tool?: string | undefined;
|
|
170
|
+
instruction?: string | undefined;
|
|
171
|
+
automated?: boolean | undefined;
|
|
172
|
+
tokens?: number | undefined;
|
|
173
|
+
cost_usd?: number | undefined;
|
|
174
|
+
}>;
|
|
175
|
+
/** What a client submits. Server fills in id/seq/hash/prev_hash. */
|
|
176
|
+
export declare const EventInput: z.ZodObject<{
|
|
177
|
+
project: z.ZodString;
|
|
178
|
+
actor: z.ZodObject<{
|
|
179
|
+
type: z.ZodEnum<["human", "agent", "system"]>;
|
|
180
|
+
/** Stable identifier: email, agent name, service id */
|
|
181
|
+
id: z.ZodString;
|
|
182
|
+
display_name: z.ZodOptional<z.ZodString>;
|
|
183
|
+
/** For agents: model + version that performed the action */
|
|
184
|
+
model: z.ZodOptional<z.ZodString>;
|
|
185
|
+
version: z.ZodOptional<z.ZodString>;
|
|
186
|
+
/** Delegation: an agent acting for a human, or a sub-agent for a parent agent */
|
|
187
|
+
on_behalf_of: z.ZodOptional<z.ZodString>;
|
|
188
|
+
}, "strip", z.ZodTypeAny, {
|
|
189
|
+
type: "human" | "agent" | "system";
|
|
190
|
+
id: string;
|
|
191
|
+
display_name?: string | undefined;
|
|
192
|
+
model?: string | undefined;
|
|
193
|
+
version?: string | undefined;
|
|
194
|
+
on_behalf_of?: string | undefined;
|
|
195
|
+
}, {
|
|
196
|
+
type: "human" | "agent" | "system";
|
|
197
|
+
id: string;
|
|
198
|
+
display_name?: string | undefined;
|
|
199
|
+
model?: string | undefined;
|
|
200
|
+
version?: string | undefined;
|
|
201
|
+
on_behalf_of?: string | undefined;
|
|
202
|
+
}>;
|
|
203
|
+
action: z.ZodEnum<["created", "edited", "deleted", "read", "executed", "approved", "rejected", "sent", "received", "moved", "renamed", "instructed", "committed", "merged", "other"]>;
|
|
204
|
+
action_detail: z.ZodOptional<z.ZodString>;
|
|
205
|
+
artifacts: z.ZodArray<z.ZodObject<{
|
|
206
|
+
/** Stable id for the thing being worked on, e.g. "repo:slcwitit/rpg#src/fight.ts" or "doc:abc123" */
|
|
207
|
+
id: z.ZodString;
|
|
208
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
209
|
+
label: z.ZodOptional<z.ZodString>;
|
|
210
|
+
/** Lineage: this artifact was derived from these */
|
|
211
|
+
derived_from: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
212
|
+
/** PROV: input (used) / output (generated) / both. Body-only, hash-covered on new events; see ArtifactRole. */
|
|
213
|
+
role: z.ZodOptional<z.ZodEnum<["used", "generated", "both"]>>;
|
|
214
|
+
}, "strip", z.ZodTypeAny, {
|
|
215
|
+
id: string;
|
|
216
|
+
kind?: string | undefined;
|
|
217
|
+
label?: string | undefined;
|
|
218
|
+
derived_from?: string[] | undefined;
|
|
219
|
+
role?: "used" | "generated" | "both" | undefined;
|
|
220
|
+
}, {
|
|
221
|
+
id: string;
|
|
222
|
+
kind?: string | undefined;
|
|
223
|
+
label?: string | undefined;
|
|
224
|
+
derived_from?: string[] | undefined;
|
|
225
|
+
role?: "used" | "generated" | "both" | undefined;
|
|
226
|
+
}>, "many">;
|
|
227
|
+
change: z.ZodOptional<z.ZodObject<{
|
|
228
|
+
before_hash: z.ZodOptional<z.ZodString>;
|
|
229
|
+
after_hash: z.ZodOptional<z.ZodString>;
|
|
230
|
+
diff: z.ZodOptional<z.ZodString>;
|
|
231
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
232
|
+
}, "strip", z.ZodTypeAny, {
|
|
233
|
+
before_hash?: string | undefined;
|
|
234
|
+
after_hash?: string | undefined;
|
|
235
|
+
diff?: string | undefined;
|
|
236
|
+
summary?: string | undefined;
|
|
237
|
+
}, {
|
|
238
|
+
before_hash?: string | undefined;
|
|
239
|
+
after_hash?: string | undefined;
|
|
240
|
+
diff?: string | undefined;
|
|
241
|
+
summary?: string | undefined;
|
|
242
|
+
}>>;
|
|
243
|
+
timestamp: z.ZodOptional<z.ZodString>;
|
|
244
|
+
duration_ms: z.ZodOptional<z.ZodNumber>;
|
|
245
|
+
location: z.ZodOptional<z.ZodObject<{
|
|
246
|
+
/** repo path, doc section, URL, table, etc. */
|
|
247
|
+
path: z.ZodOptional<z.ZodString>;
|
|
248
|
+
url: z.ZodOptional<z.ZodString>;
|
|
249
|
+
environment: z.ZodOptional<z.ZodString>;
|
|
250
|
+
device: z.ZodOptional<z.ZodString>;
|
|
251
|
+
system: z.ZodOptional<z.ZodString>;
|
|
252
|
+
/** Run/session id of the producing process (backlog #15; body-only, like every location field). On the MCP path
|
|
253
|
+
* this is the harness's own session id when it exposes one (CLAUDE_CODE_SESSION_ID or GROK_SESSION_ID), so the same string appears on
|
|
254
|
+
* events from the agent AND on the commits it drives. It is a *session* key — subagents share it — not a per-run id. */
|
|
255
|
+
session: z.ZodOptional<z.ZodString>;
|
|
256
|
+
/** The MCP client that drove the write, verbatim from the `initialize` handshake as "<name>@<version>" — e.g.
|
|
257
|
+
* "claude-code@2.1.250", "cursor-vscode@1.7.3". Server-stamped only: it is evidence ABOUT the writer, so the
|
|
258
|
+
* writer may not assert it (see SERVER_ONLY in the MCP server). */
|
|
259
|
+
client: z.ZodOptional<z.ZodString>;
|
|
260
|
+
/** IDE / agent-development environment hosting the actor, e.g. "orca". Deliberately distinct from `system` (the tool
|
|
261
|
+
* that produced the event, "claude-code") and from `client` (which build of it): the IDE is the app AROUND both, and
|
|
262
|
+
* neither of the other two can express it. Only stamped when the IDE identifies itself in the environment. */
|
|
263
|
+
ide: z.ZodOptional<z.ZodString>;
|
|
264
|
+
/** Isolated workspace within `ide` — an Orca worktree id, a codespace or devcontainer name. This is what tells two
|
|
265
|
+
* parallel agents apart when they run the same project, on the same host, as the same actor. */
|
|
266
|
+
workspace: z.ZodOptional<z.ZodString>;
|
|
267
|
+
/** Whether the producing process had a controlling terminal: "tty" = a human at a keyboard, "agent" = spawned by a
|
|
268
|
+
* harness with none. Linux-only today (read from /proc/self/stat); absent everywhere else, and absence is a legal
|
|
269
|
+
* permanent state. EVIDENCE, never authority — it must not override the actor determination. */
|
|
270
|
+
surface: z.ZodOptional<z.ZodEnum<["tty", "agent"]>>;
|
|
271
|
+
}, "strip", z.ZodTypeAny, {
|
|
272
|
+
system?: string | undefined;
|
|
273
|
+
path?: string | undefined;
|
|
274
|
+
url?: string | undefined;
|
|
275
|
+
environment?: string | undefined;
|
|
276
|
+
device?: string | undefined;
|
|
277
|
+
session?: string | undefined;
|
|
278
|
+
client?: string | undefined;
|
|
279
|
+
ide?: string | undefined;
|
|
280
|
+
workspace?: string | undefined;
|
|
281
|
+
surface?: "agent" | "tty" | undefined;
|
|
282
|
+
}, {
|
|
283
|
+
system?: string | undefined;
|
|
284
|
+
path?: string | undefined;
|
|
285
|
+
url?: string | undefined;
|
|
286
|
+
environment?: string | undefined;
|
|
287
|
+
device?: string | undefined;
|
|
288
|
+
session?: string | undefined;
|
|
289
|
+
client?: string | undefined;
|
|
290
|
+
ide?: string | undefined;
|
|
291
|
+
workspace?: string | undefined;
|
|
292
|
+
surface?: "agent" | "tty" | undefined;
|
|
293
|
+
}>>;
|
|
294
|
+
/** WHY — free text reason */
|
|
295
|
+
intent: z.ZodOptional<z.ZodString>;
|
|
296
|
+
/** WHY — causal parent (event id). The instruction that led to this action. */
|
|
297
|
+
caused_by: z.ZodOptional<z.ZodString>;
|
|
298
|
+
method: z.ZodOptional<z.ZodObject<{
|
|
299
|
+
tool: z.ZodOptional<z.ZodString>;
|
|
300
|
+
/** Reference to instruction/prompt that drove this (id, hash, or short text) */
|
|
301
|
+
instruction: z.ZodOptional<z.ZodString>;
|
|
302
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
303
|
+
automated: z.ZodOptional<z.ZodBoolean>;
|
|
304
|
+
tokens: z.ZodOptional<z.ZodNumber>;
|
|
305
|
+
cost_usd: z.ZodOptional<z.ZodNumber>;
|
|
306
|
+
}, "strip", z.ZodTypeAny, {
|
|
307
|
+
params?: Record<string, unknown> | undefined;
|
|
308
|
+
tool?: string | undefined;
|
|
309
|
+
instruction?: string | undefined;
|
|
310
|
+
automated?: boolean | undefined;
|
|
311
|
+
tokens?: number | undefined;
|
|
312
|
+
cost_usd?: number | undefined;
|
|
313
|
+
}, {
|
|
314
|
+
params?: Record<string, unknown> | undefined;
|
|
315
|
+
tool?: string | undefined;
|
|
316
|
+
instruction?: string | undefined;
|
|
317
|
+
automated?: boolean | undefined;
|
|
318
|
+
tokens?: number | undefined;
|
|
319
|
+
cost_usd?: number | undefined;
|
|
320
|
+
}>>;
|
|
321
|
+
/** Client-provided idempotency key */
|
|
322
|
+
idempotency_key: z.ZodOptional<z.ZodString>;
|
|
323
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
324
|
+
}, "strip", z.ZodTypeAny, {
|
|
325
|
+
project: string;
|
|
326
|
+
actor: {
|
|
327
|
+
type: "human" | "agent" | "system";
|
|
328
|
+
id: string;
|
|
329
|
+
display_name?: string | undefined;
|
|
330
|
+
model?: string | undefined;
|
|
331
|
+
version?: string | undefined;
|
|
332
|
+
on_behalf_of?: string | undefined;
|
|
333
|
+
};
|
|
334
|
+
action: "received" | "created" | "edited" | "deleted" | "read" | "executed" | "approved" | "rejected" | "sent" | "moved" | "renamed" | "instructed" | "committed" | "merged" | "other";
|
|
335
|
+
artifacts: {
|
|
336
|
+
id: string;
|
|
337
|
+
kind?: string | undefined;
|
|
338
|
+
label?: string | undefined;
|
|
339
|
+
derived_from?: string[] | undefined;
|
|
340
|
+
role?: "used" | "generated" | "both" | undefined;
|
|
341
|
+
}[];
|
|
342
|
+
action_detail?: string | undefined;
|
|
343
|
+
change?: {
|
|
344
|
+
before_hash?: string | undefined;
|
|
345
|
+
after_hash?: string | undefined;
|
|
346
|
+
diff?: string | undefined;
|
|
347
|
+
summary?: string | undefined;
|
|
348
|
+
} | undefined;
|
|
349
|
+
timestamp?: string | undefined;
|
|
350
|
+
duration_ms?: number | undefined;
|
|
351
|
+
location?: {
|
|
352
|
+
system?: string | undefined;
|
|
353
|
+
path?: string | undefined;
|
|
354
|
+
url?: string | undefined;
|
|
355
|
+
environment?: string | undefined;
|
|
356
|
+
device?: string | undefined;
|
|
357
|
+
session?: string | undefined;
|
|
358
|
+
client?: string | undefined;
|
|
359
|
+
ide?: string | undefined;
|
|
360
|
+
workspace?: string | undefined;
|
|
361
|
+
surface?: "agent" | "tty" | undefined;
|
|
362
|
+
} | undefined;
|
|
363
|
+
intent?: string | undefined;
|
|
364
|
+
caused_by?: string | undefined;
|
|
365
|
+
method?: {
|
|
366
|
+
params?: Record<string, unknown> | undefined;
|
|
367
|
+
tool?: string | undefined;
|
|
368
|
+
instruction?: string | undefined;
|
|
369
|
+
automated?: boolean | undefined;
|
|
370
|
+
tokens?: number | undefined;
|
|
371
|
+
cost_usd?: number | undefined;
|
|
372
|
+
} | undefined;
|
|
373
|
+
idempotency_key?: string | undefined;
|
|
374
|
+
tags?: string[] | undefined;
|
|
375
|
+
}, {
|
|
376
|
+
project: string;
|
|
377
|
+
actor: {
|
|
378
|
+
type: "human" | "agent" | "system";
|
|
379
|
+
id: string;
|
|
380
|
+
display_name?: string | undefined;
|
|
381
|
+
model?: string | undefined;
|
|
382
|
+
version?: string | undefined;
|
|
383
|
+
on_behalf_of?: string | undefined;
|
|
384
|
+
};
|
|
385
|
+
action: "received" | "created" | "edited" | "deleted" | "read" | "executed" | "approved" | "rejected" | "sent" | "moved" | "renamed" | "instructed" | "committed" | "merged" | "other";
|
|
386
|
+
artifacts: {
|
|
387
|
+
id: string;
|
|
388
|
+
kind?: string | undefined;
|
|
389
|
+
label?: string | undefined;
|
|
390
|
+
derived_from?: string[] | undefined;
|
|
391
|
+
role?: "used" | "generated" | "both" | undefined;
|
|
392
|
+
}[];
|
|
393
|
+
action_detail?: string | undefined;
|
|
394
|
+
change?: {
|
|
395
|
+
before_hash?: string | undefined;
|
|
396
|
+
after_hash?: string | undefined;
|
|
397
|
+
diff?: string | undefined;
|
|
398
|
+
summary?: string | undefined;
|
|
399
|
+
} | undefined;
|
|
400
|
+
timestamp?: string | undefined;
|
|
401
|
+
duration_ms?: number | undefined;
|
|
402
|
+
location?: {
|
|
403
|
+
system?: string | undefined;
|
|
404
|
+
path?: string | undefined;
|
|
405
|
+
url?: string | undefined;
|
|
406
|
+
environment?: string | undefined;
|
|
407
|
+
device?: string | undefined;
|
|
408
|
+
session?: string | undefined;
|
|
409
|
+
client?: string | undefined;
|
|
410
|
+
ide?: string | undefined;
|
|
411
|
+
workspace?: string | undefined;
|
|
412
|
+
surface?: "agent" | "tty" | undefined;
|
|
413
|
+
} | undefined;
|
|
414
|
+
intent?: string | undefined;
|
|
415
|
+
caused_by?: string | undefined;
|
|
416
|
+
method?: {
|
|
417
|
+
params?: Record<string, unknown> | undefined;
|
|
418
|
+
tool?: string | undefined;
|
|
419
|
+
instruction?: string | undefined;
|
|
420
|
+
automated?: boolean | undefined;
|
|
421
|
+
tokens?: number | undefined;
|
|
422
|
+
cost_usd?: number | undefined;
|
|
423
|
+
} | undefined;
|
|
424
|
+
idempotency_key?: string | undefined;
|
|
425
|
+
tags?: string[] | undefined;
|
|
426
|
+
}>;
|
|
427
|
+
export type EventInput = z.infer<typeof EventInput>;
|
|
428
|
+
export declare const Event: z.ZodObject<{
|
|
429
|
+
project: z.ZodString;
|
|
430
|
+
actor: z.ZodObject<{
|
|
431
|
+
type: z.ZodEnum<["human", "agent", "system"]>;
|
|
432
|
+
/** Stable identifier: email, agent name, service id */
|
|
433
|
+
id: z.ZodString;
|
|
434
|
+
display_name: z.ZodOptional<z.ZodString>;
|
|
435
|
+
/** For agents: model + version that performed the action */
|
|
436
|
+
model: z.ZodOptional<z.ZodString>;
|
|
437
|
+
version: z.ZodOptional<z.ZodString>;
|
|
438
|
+
/** Delegation: an agent acting for a human, or a sub-agent for a parent agent */
|
|
439
|
+
on_behalf_of: z.ZodOptional<z.ZodString>;
|
|
440
|
+
}, "strip", z.ZodTypeAny, {
|
|
441
|
+
type: "human" | "agent" | "system";
|
|
442
|
+
id: string;
|
|
443
|
+
display_name?: string | undefined;
|
|
444
|
+
model?: string | undefined;
|
|
445
|
+
version?: string | undefined;
|
|
446
|
+
on_behalf_of?: string | undefined;
|
|
447
|
+
}, {
|
|
448
|
+
type: "human" | "agent" | "system";
|
|
449
|
+
id: string;
|
|
450
|
+
display_name?: string | undefined;
|
|
451
|
+
model?: string | undefined;
|
|
452
|
+
version?: string | undefined;
|
|
453
|
+
on_behalf_of?: string | undefined;
|
|
454
|
+
}>;
|
|
455
|
+
action: z.ZodEnum<["created", "edited", "deleted", "read", "executed", "approved", "rejected", "sent", "received", "moved", "renamed", "instructed", "committed", "merged", "other"]>;
|
|
456
|
+
action_detail: z.ZodOptional<z.ZodString>;
|
|
457
|
+
artifacts: z.ZodArray<z.ZodObject<{
|
|
458
|
+
/** Stable id for the thing being worked on, e.g. "repo:slcwitit/rpg#src/fight.ts" or "doc:abc123" */
|
|
459
|
+
id: z.ZodString;
|
|
460
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
461
|
+
label: z.ZodOptional<z.ZodString>;
|
|
462
|
+
/** Lineage: this artifact was derived from these */
|
|
463
|
+
derived_from: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
464
|
+
/** PROV: input (used) / output (generated) / both. Body-only, hash-covered on new events; see ArtifactRole. */
|
|
465
|
+
role: z.ZodOptional<z.ZodEnum<["used", "generated", "both"]>>;
|
|
466
|
+
}, "strip", z.ZodTypeAny, {
|
|
467
|
+
id: string;
|
|
468
|
+
kind?: string | undefined;
|
|
469
|
+
label?: string | undefined;
|
|
470
|
+
derived_from?: string[] | undefined;
|
|
471
|
+
role?: "used" | "generated" | "both" | undefined;
|
|
472
|
+
}, {
|
|
473
|
+
id: string;
|
|
474
|
+
kind?: string | undefined;
|
|
475
|
+
label?: string | undefined;
|
|
476
|
+
derived_from?: string[] | undefined;
|
|
477
|
+
role?: "used" | "generated" | "both" | undefined;
|
|
478
|
+
}>, "many">;
|
|
479
|
+
change: z.ZodOptional<z.ZodObject<{
|
|
480
|
+
before_hash: z.ZodOptional<z.ZodString>;
|
|
481
|
+
after_hash: z.ZodOptional<z.ZodString>;
|
|
482
|
+
diff: z.ZodOptional<z.ZodString>;
|
|
483
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
484
|
+
}, "strip", z.ZodTypeAny, {
|
|
485
|
+
before_hash?: string | undefined;
|
|
486
|
+
after_hash?: string | undefined;
|
|
487
|
+
diff?: string | undefined;
|
|
488
|
+
summary?: string | undefined;
|
|
489
|
+
}, {
|
|
490
|
+
before_hash?: string | undefined;
|
|
491
|
+
after_hash?: string | undefined;
|
|
492
|
+
diff?: string | undefined;
|
|
493
|
+
summary?: string | undefined;
|
|
494
|
+
}>>;
|
|
495
|
+
duration_ms: z.ZodOptional<z.ZodNumber>;
|
|
496
|
+
location: z.ZodOptional<z.ZodObject<{
|
|
497
|
+
/** repo path, doc section, URL, table, etc. */
|
|
498
|
+
path: z.ZodOptional<z.ZodString>;
|
|
499
|
+
url: z.ZodOptional<z.ZodString>;
|
|
500
|
+
environment: z.ZodOptional<z.ZodString>;
|
|
501
|
+
device: z.ZodOptional<z.ZodString>;
|
|
502
|
+
system: z.ZodOptional<z.ZodString>;
|
|
503
|
+
/** Run/session id of the producing process (backlog #15; body-only, like every location field). On the MCP path
|
|
504
|
+
* this is the harness's own session id when it exposes one (CLAUDE_CODE_SESSION_ID or GROK_SESSION_ID), so the same string appears on
|
|
505
|
+
* events from the agent AND on the commits it drives. It is a *session* key — subagents share it — not a per-run id. */
|
|
506
|
+
session: z.ZodOptional<z.ZodString>;
|
|
507
|
+
/** The MCP client that drove the write, verbatim from the `initialize` handshake as "<name>@<version>" — e.g.
|
|
508
|
+
* "claude-code@2.1.250", "cursor-vscode@1.7.3". Server-stamped only: it is evidence ABOUT the writer, so the
|
|
509
|
+
* writer may not assert it (see SERVER_ONLY in the MCP server). */
|
|
510
|
+
client: z.ZodOptional<z.ZodString>;
|
|
511
|
+
/** IDE / agent-development environment hosting the actor, e.g. "orca". Deliberately distinct from `system` (the tool
|
|
512
|
+
* that produced the event, "claude-code") and from `client` (which build of it): the IDE is the app AROUND both, and
|
|
513
|
+
* neither of the other two can express it. Only stamped when the IDE identifies itself in the environment. */
|
|
514
|
+
ide: z.ZodOptional<z.ZodString>;
|
|
515
|
+
/** Isolated workspace within `ide` — an Orca worktree id, a codespace or devcontainer name. This is what tells two
|
|
516
|
+
* parallel agents apart when they run the same project, on the same host, as the same actor. */
|
|
517
|
+
workspace: z.ZodOptional<z.ZodString>;
|
|
518
|
+
/** Whether the producing process had a controlling terminal: "tty" = a human at a keyboard, "agent" = spawned by a
|
|
519
|
+
* harness with none. Linux-only today (read from /proc/self/stat); absent everywhere else, and absence is a legal
|
|
520
|
+
* permanent state. EVIDENCE, never authority — it must not override the actor determination. */
|
|
521
|
+
surface: z.ZodOptional<z.ZodEnum<["tty", "agent"]>>;
|
|
522
|
+
}, "strip", z.ZodTypeAny, {
|
|
523
|
+
system?: string | undefined;
|
|
524
|
+
path?: string | undefined;
|
|
525
|
+
url?: string | undefined;
|
|
526
|
+
environment?: string | undefined;
|
|
527
|
+
device?: string | undefined;
|
|
528
|
+
session?: string | undefined;
|
|
529
|
+
client?: string | undefined;
|
|
530
|
+
ide?: string | undefined;
|
|
531
|
+
workspace?: string | undefined;
|
|
532
|
+
surface?: "agent" | "tty" | undefined;
|
|
533
|
+
}, {
|
|
534
|
+
system?: string | undefined;
|
|
535
|
+
path?: string | undefined;
|
|
536
|
+
url?: string | undefined;
|
|
537
|
+
environment?: string | undefined;
|
|
538
|
+
device?: string | undefined;
|
|
539
|
+
session?: string | undefined;
|
|
540
|
+
client?: string | undefined;
|
|
541
|
+
ide?: string | undefined;
|
|
542
|
+
workspace?: string | undefined;
|
|
543
|
+
surface?: "agent" | "tty" | undefined;
|
|
544
|
+
}>>;
|
|
545
|
+
intent: z.ZodOptional<z.ZodString>;
|
|
546
|
+
caused_by: z.ZodOptional<z.ZodString>;
|
|
547
|
+
method: z.ZodOptional<z.ZodObject<{
|
|
548
|
+
tool: z.ZodOptional<z.ZodString>;
|
|
549
|
+
/** Reference to instruction/prompt that drove this (id, hash, or short text) */
|
|
550
|
+
instruction: z.ZodOptional<z.ZodString>;
|
|
551
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
552
|
+
automated: z.ZodOptional<z.ZodBoolean>;
|
|
553
|
+
tokens: z.ZodOptional<z.ZodNumber>;
|
|
554
|
+
cost_usd: z.ZodOptional<z.ZodNumber>;
|
|
555
|
+
}, "strip", z.ZodTypeAny, {
|
|
556
|
+
params?: Record<string, unknown> | undefined;
|
|
557
|
+
tool?: string | undefined;
|
|
558
|
+
instruction?: string | undefined;
|
|
559
|
+
automated?: boolean | undefined;
|
|
560
|
+
tokens?: number | undefined;
|
|
561
|
+
cost_usd?: number | undefined;
|
|
562
|
+
}, {
|
|
563
|
+
params?: Record<string, unknown> | undefined;
|
|
564
|
+
tool?: string | undefined;
|
|
565
|
+
instruction?: string | undefined;
|
|
566
|
+
automated?: boolean | undefined;
|
|
567
|
+
tokens?: number | undefined;
|
|
568
|
+
cost_usd?: number | undefined;
|
|
569
|
+
}>>;
|
|
570
|
+
idempotency_key: z.ZodOptional<z.ZodString>;
|
|
571
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
572
|
+
} & {
|
|
573
|
+
id: z.ZodString;
|
|
574
|
+
seq: z.ZodNumber;
|
|
575
|
+
timestamp: z.ZodString;
|
|
576
|
+
prev_hash: z.ZodString;
|
|
577
|
+
hash: z.ZodString;
|
|
578
|
+
received_at: z.ZodString;
|
|
579
|
+
}, "strip", z.ZodTypeAny, {
|
|
580
|
+
id: string;
|
|
581
|
+
project: string;
|
|
582
|
+
actor: {
|
|
583
|
+
type: "human" | "agent" | "system";
|
|
584
|
+
id: string;
|
|
585
|
+
display_name?: string | undefined;
|
|
586
|
+
model?: string | undefined;
|
|
587
|
+
version?: string | undefined;
|
|
588
|
+
on_behalf_of?: string | undefined;
|
|
589
|
+
};
|
|
590
|
+
action: "received" | "created" | "edited" | "deleted" | "read" | "executed" | "approved" | "rejected" | "sent" | "moved" | "renamed" | "instructed" | "committed" | "merged" | "other";
|
|
591
|
+
artifacts: {
|
|
592
|
+
id: string;
|
|
593
|
+
kind?: string | undefined;
|
|
594
|
+
label?: string | undefined;
|
|
595
|
+
derived_from?: string[] | undefined;
|
|
596
|
+
role?: "used" | "generated" | "both" | undefined;
|
|
597
|
+
}[];
|
|
598
|
+
timestamp: string;
|
|
599
|
+
seq: number;
|
|
600
|
+
prev_hash: string;
|
|
601
|
+
hash: string;
|
|
602
|
+
received_at: string;
|
|
603
|
+
action_detail?: string | undefined;
|
|
604
|
+
change?: {
|
|
605
|
+
before_hash?: string | undefined;
|
|
606
|
+
after_hash?: string | undefined;
|
|
607
|
+
diff?: string | undefined;
|
|
608
|
+
summary?: string | undefined;
|
|
609
|
+
} | undefined;
|
|
610
|
+
duration_ms?: number | undefined;
|
|
611
|
+
location?: {
|
|
612
|
+
system?: string | undefined;
|
|
613
|
+
path?: string | undefined;
|
|
614
|
+
url?: string | undefined;
|
|
615
|
+
environment?: string | undefined;
|
|
616
|
+
device?: string | undefined;
|
|
617
|
+
session?: string | undefined;
|
|
618
|
+
client?: string | undefined;
|
|
619
|
+
ide?: string | undefined;
|
|
620
|
+
workspace?: string | undefined;
|
|
621
|
+
surface?: "agent" | "tty" | undefined;
|
|
622
|
+
} | undefined;
|
|
623
|
+
intent?: string | undefined;
|
|
624
|
+
caused_by?: string | undefined;
|
|
625
|
+
method?: {
|
|
626
|
+
params?: Record<string, unknown> | undefined;
|
|
627
|
+
tool?: string | undefined;
|
|
628
|
+
instruction?: string | undefined;
|
|
629
|
+
automated?: boolean | undefined;
|
|
630
|
+
tokens?: number | undefined;
|
|
631
|
+
cost_usd?: number | undefined;
|
|
632
|
+
} | undefined;
|
|
633
|
+
idempotency_key?: string | undefined;
|
|
634
|
+
tags?: string[] | undefined;
|
|
635
|
+
}, {
|
|
636
|
+
id: string;
|
|
637
|
+
project: string;
|
|
638
|
+
actor: {
|
|
639
|
+
type: "human" | "agent" | "system";
|
|
640
|
+
id: string;
|
|
641
|
+
display_name?: string | undefined;
|
|
642
|
+
model?: string | undefined;
|
|
643
|
+
version?: string | undefined;
|
|
644
|
+
on_behalf_of?: string | undefined;
|
|
645
|
+
};
|
|
646
|
+
action: "received" | "created" | "edited" | "deleted" | "read" | "executed" | "approved" | "rejected" | "sent" | "moved" | "renamed" | "instructed" | "committed" | "merged" | "other";
|
|
647
|
+
artifacts: {
|
|
648
|
+
id: string;
|
|
649
|
+
kind?: string | undefined;
|
|
650
|
+
label?: string | undefined;
|
|
651
|
+
derived_from?: string[] | undefined;
|
|
652
|
+
role?: "used" | "generated" | "both" | undefined;
|
|
653
|
+
}[];
|
|
654
|
+
timestamp: string;
|
|
655
|
+
seq: number;
|
|
656
|
+
prev_hash: string;
|
|
657
|
+
hash: string;
|
|
658
|
+
received_at: string;
|
|
659
|
+
action_detail?: string | undefined;
|
|
660
|
+
change?: {
|
|
661
|
+
before_hash?: string | undefined;
|
|
662
|
+
after_hash?: string | undefined;
|
|
663
|
+
diff?: string | undefined;
|
|
664
|
+
summary?: string | undefined;
|
|
665
|
+
} | undefined;
|
|
666
|
+
duration_ms?: number | undefined;
|
|
667
|
+
location?: {
|
|
668
|
+
system?: string | undefined;
|
|
669
|
+
path?: string | undefined;
|
|
670
|
+
url?: string | undefined;
|
|
671
|
+
environment?: string | undefined;
|
|
672
|
+
device?: string | undefined;
|
|
673
|
+
session?: string | undefined;
|
|
674
|
+
client?: string | undefined;
|
|
675
|
+
ide?: string | undefined;
|
|
676
|
+
workspace?: string | undefined;
|
|
677
|
+
surface?: "agent" | "tty" | undefined;
|
|
678
|
+
} | undefined;
|
|
679
|
+
intent?: string | undefined;
|
|
680
|
+
caused_by?: string | undefined;
|
|
681
|
+
method?: {
|
|
682
|
+
params?: Record<string, unknown> | undefined;
|
|
683
|
+
tool?: string | undefined;
|
|
684
|
+
instruction?: string | undefined;
|
|
685
|
+
automated?: boolean | undefined;
|
|
686
|
+
tokens?: number | undefined;
|
|
687
|
+
cost_usd?: number | undefined;
|
|
688
|
+
} | undefined;
|
|
689
|
+
idempotency_key?: string | undefined;
|
|
690
|
+
tags?: string[] | undefined;
|
|
691
|
+
}>;
|
|
692
|
+
export type Event = z.infer<typeof Event>;
|
|
693
|
+
/**
|
|
694
|
+
* The schema surface a build understands, derived from the zod shapes themselves so it can never drift from the code.
|
|
695
|
+
*
|
|
696
|
+
* This exists because the failure it detects is SILENT: `POST /events` re-parses with `EventInput.safeParse`, and zod
|
|
697
|
+
* strips keys it does not know, so a producer running newer code than the deployment loses those fields with no error
|
|
698
|
+
* anywhere — the event is accepted, sealed and hashed without them. It has happened twice (`location.session`,
|
|
699
|
+
* `bacabed`; `location.client`/`ide`/`workspace`/`surface`, 2026-08-28), both times found by eye.
|
|
700
|
+
* `GET /api` publishes this, and `npm run check-deploy` diffs a deployment against the local build.
|
|
701
|
+
*/
|
|
702
|
+
export declare function schemaSurface(): {
|
|
703
|
+
event: string[];
|
|
704
|
+
location: string[];
|
|
705
|
+
artifact: string[];
|
|
706
|
+
actions: string[];
|
|
707
|
+
};
|
|
708
|
+
export declare const GENESIS_HASH: string;
|