@bli-cockpit/telemetry-core 0.1.1 → 0.1.3

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/dist/common.d.ts CHANGED
@@ -38,6 +38,12 @@ export declare const CaptureProvenanceSchema: z.ZodObject<{
38
38
  collector_version: z.ZodString;
39
39
  repo: z.ZodString;
40
40
  branch: z.ZodString;
41
+ repo_label: z.ZodOptional<z.ZodString>;
42
+ repo_fingerprint: z.ZodOptional<z.ZodString>;
43
+ repo_origin_url: z.ZodOptional<z.ZodString>;
44
+ worktree_label: z.ZodOptional<z.ZodString>;
45
+ worktree_fingerprint: z.ZodOptional<z.ZodString>;
46
+ worktree_is_primary: z.ZodOptional<z.ZodBoolean>;
41
47
  operator_id: z.ZodString;
42
48
  session_id: z.ZodString;
43
49
  work_context_id: z.ZodString;
package/dist/common.js CHANGED
@@ -34,6 +34,12 @@ export const CaptureProvenanceSchema = z
34
34
  collector_version: VersionStringSchema,
35
35
  repo: NonEmptyStringSchema,
36
36
  branch: NonEmptyStringSchema,
37
+ repo_label: NonEmptyStringSchema.optional(),
38
+ repo_fingerprint: NonEmptyStringSchema.optional(),
39
+ repo_origin_url: NonEmptyStringSchema.optional(),
40
+ worktree_label: NonEmptyStringSchema.optional(),
41
+ worktree_fingerprint: NonEmptyStringSchema.optional(),
42
+ worktree_is_primary: z.boolean().optional(),
37
43
  operator_id: NonEmptyStringSchema,
38
44
  session_id: NonEmptyStringSchema,
39
45
  work_context_id: NonEmptyStringSchema,
@@ -0,0 +1,376 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Chunked raw-evidence upload wire contract.
4
+ *
5
+ * Raw evidence bytes move in chunks small enough to clear serverless
6
+ * request-body limits (Vercel rejects bodies around 4.5MB). The server keeps a
7
+ * durable per-object ledger so interrupted uploads resume instead of
8
+ * re-sending bytes, and identical content is acknowledged without re-upload.
9
+ */
10
+ export declare const RAW_EVIDENCE_UPLOAD_MAX_FILE_BYTES: number;
11
+ export declare const RAW_EVIDENCE_UPLOAD_MAX_CHUNK_BYTES: number;
12
+ export declare const RAW_EVIDENCE_UPLOAD_DEFAULT_CHUNK_BYTES: number;
13
+ export declare const RAW_EVIDENCE_UPLOAD_MAX_CHUNK_COUNT = 64;
14
+ export declare const RAW_EVIDENCE_UPLOAD_MAX_OBJECTS_PER_BEGIN = 25;
15
+ export declare const CODEX_SESSION_REPORT_MAX_SESSIONS = 200;
16
+ export declare const RawEvidenceUploadBeginObjectSchema: z.ZodObject<{
17
+ pointer: z.ZodObject<{
18
+ raw_evidence_pointer_id: z.ZodString;
19
+ privacy_classification: z.ZodEnum<{
20
+ local_only_raw_evidence: "local_only_raw_evidence";
21
+ remote_short_retention_raw_evidence: "remote_short_retention_raw_evidence";
22
+ remote_durable_raw_evidence: "remote_durable_raw_evidence";
23
+ }>;
24
+ retention_policy: z.ZodObject<{
25
+ mode: z.ZodEnum<{
26
+ local_only: "local_only";
27
+ remote_short_retention: "remote_short_retention";
28
+ remote_durable: "remote_durable";
29
+ }>;
30
+ privacy_classification: z.ZodEnum<{
31
+ local_only_raw_evidence: "local_only_raw_evidence";
32
+ remote_short_retention_raw_evidence: "remote_short_retention_raw_evidence";
33
+ remote_durable_raw_evidence: "remote_durable_raw_evidence";
34
+ }>;
35
+ remote_retention_days: z.ZodOptional<z.ZodNumber>;
36
+ expires_at: z.ZodOptional<z.ZodString>;
37
+ }, z.core.$strict>;
38
+ storage_scope: z.ZodEnum<{
39
+ local_file: "local_file";
40
+ remote_object: "remote_object";
41
+ }>;
42
+ storage_bucket: z.ZodOptional<z.ZodString>;
43
+ local_path: z.ZodOptional<z.ZodString>;
44
+ object_key: z.ZodOptional<z.ZodString>;
45
+ content_hash_sha256: z.ZodOptional<z.ZodString>;
46
+ byte_size: z.ZodOptional<z.ZodNumber>;
47
+ media_type: z.ZodOptional<z.ZodString>;
48
+ redacted_summary: z.ZodOptional<z.ZodString>;
49
+ }, z.core.$strict>;
50
+ chunk_size_bytes: z.ZodNumber;
51
+ chunk_count: z.ZodNumber;
52
+ }, z.core.$strict>;
53
+ export type RawEvidenceUploadBeginObject = z.infer<typeof RawEvidenceUploadBeginObjectSchema>;
54
+ export declare const RawEvidenceUploadBeginRequestSchema: z.ZodObject<{
55
+ schema_version: z.ZodLiteral<"ambient-raw-evidence-upload-begin.v1">;
56
+ generated_at: z.ZodString;
57
+ provenance: z.ZodObject<{
58
+ capture_source: z.ZodEnum<{
59
+ unknown: "unknown";
60
+ codex_jsonl: "codex_jsonl";
61
+ codex_otel: "codex_otel";
62
+ car_state: "car_state";
63
+ git_state: "git_state";
64
+ github_state: "github_state";
65
+ linear_state: "linear_state";
66
+ mcp_local: "mcp_local";
67
+ claude_hooks: "claude_hooks";
68
+ manual_event: "manual_event";
69
+ collector_runtime: "collector_runtime";
70
+ }>;
71
+ capture_adapter_version: z.ZodString;
72
+ collector_version: z.ZodString;
73
+ repo: z.ZodString;
74
+ branch: z.ZodString;
75
+ repo_label: z.ZodOptional<z.ZodString>;
76
+ repo_fingerprint: z.ZodOptional<z.ZodString>;
77
+ repo_origin_url: z.ZodOptional<z.ZodString>;
78
+ worktree_label: z.ZodOptional<z.ZodString>;
79
+ worktree_fingerprint: z.ZodOptional<z.ZodString>;
80
+ worktree_is_primary: z.ZodOptional<z.ZodBoolean>;
81
+ operator_id: z.ZodString;
82
+ session_id: z.ZodString;
83
+ work_context_id: z.ZodString;
84
+ }, z.core.$strict>;
85
+ objects: z.ZodArray<z.ZodObject<{
86
+ pointer: z.ZodObject<{
87
+ raw_evidence_pointer_id: z.ZodString;
88
+ privacy_classification: z.ZodEnum<{
89
+ local_only_raw_evidence: "local_only_raw_evidence";
90
+ remote_short_retention_raw_evidence: "remote_short_retention_raw_evidence";
91
+ remote_durable_raw_evidence: "remote_durable_raw_evidence";
92
+ }>;
93
+ retention_policy: z.ZodObject<{
94
+ mode: z.ZodEnum<{
95
+ local_only: "local_only";
96
+ remote_short_retention: "remote_short_retention";
97
+ remote_durable: "remote_durable";
98
+ }>;
99
+ privacy_classification: z.ZodEnum<{
100
+ local_only_raw_evidence: "local_only_raw_evidence";
101
+ remote_short_retention_raw_evidence: "remote_short_retention_raw_evidence";
102
+ remote_durable_raw_evidence: "remote_durable_raw_evidence";
103
+ }>;
104
+ remote_retention_days: z.ZodOptional<z.ZodNumber>;
105
+ expires_at: z.ZodOptional<z.ZodString>;
106
+ }, z.core.$strict>;
107
+ storage_scope: z.ZodEnum<{
108
+ local_file: "local_file";
109
+ remote_object: "remote_object";
110
+ }>;
111
+ storage_bucket: z.ZodOptional<z.ZodString>;
112
+ local_path: z.ZodOptional<z.ZodString>;
113
+ object_key: z.ZodOptional<z.ZodString>;
114
+ content_hash_sha256: z.ZodOptional<z.ZodString>;
115
+ byte_size: z.ZodOptional<z.ZodNumber>;
116
+ media_type: z.ZodOptional<z.ZodString>;
117
+ redacted_summary: z.ZodOptional<z.ZodString>;
118
+ }, z.core.$strict>;
119
+ chunk_size_bytes: z.ZodNumber;
120
+ chunk_count: z.ZodNumber;
121
+ }, z.core.$strict>>;
122
+ }, z.core.$strict>;
123
+ export type RawEvidenceUploadBeginRequest = z.infer<typeof RawEvidenceUploadBeginRequestSchema>;
124
+ export declare const RawEvidenceUploadDispositionSchema: z.ZodEnum<{
125
+ new: "new";
126
+ resume: "resume";
127
+ already_committed: "already_committed";
128
+ conflict: "conflict";
129
+ }>;
130
+ export type RawEvidenceUploadDisposition = z.infer<typeof RawEvidenceUploadDispositionSchema>;
131
+ export declare const RawEvidenceUploadBeginResponseObjectSchema: z.ZodObject<{
132
+ object_key: z.ZodString;
133
+ raw_evidence_pointer_id: z.ZodString;
134
+ disposition: z.ZodEnum<{
135
+ new: "new";
136
+ resume: "resume";
137
+ already_committed: "already_committed";
138
+ conflict: "conflict";
139
+ }>;
140
+ upload_id: z.ZodOptional<z.ZodString>;
141
+ received_chunk_indexes: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
142
+ reason: z.ZodOptional<z.ZodString>;
143
+ }, z.core.$strict>;
144
+ export type RawEvidenceUploadBeginResponseObject = z.infer<typeof RawEvidenceUploadBeginResponseObjectSchema>;
145
+ export declare const RawEvidenceUploadBeginResponseSchema: z.ZodObject<{
146
+ ok: z.ZodLiteral<true>;
147
+ objects: z.ZodArray<z.ZodObject<{
148
+ object_key: z.ZodString;
149
+ raw_evidence_pointer_id: z.ZodString;
150
+ disposition: z.ZodEnum<{
151
+ new: "new";
152
+ resume: "resume";
153
+ already_committed: "already_committed";
154
+ conflict: "conflict";
155
+ }>;
156
+ upload_id: z.ZodOptional<z.ZodString>;
157
+ received_chunk_indexes: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
158
+ reason: z.ZodOptional<z.ZodString>;
159
+ }, z.core.$strict>>;
160
+ }, z.core.$strict>;
161
+ export type RawEvidenceUploadBeginResponse = z.infer<typeof RawEvidenceUploadBeginResponseSchema>;
162
+ export declare const RawEvidenceUploadChunkRequestSchema: z.ZodObject<{
163
+ schema_version: z.ZodLiteral<"ambient-raw-evidence-upload-chunk.v1">;
164
+ generated_at: z.ZodString;
165
+ provenance: z.ZodObject<{
166
+ capture_source: z.ZodEnum<{
167
+ unknown: "unknown";
168
+ codex_jsonl: "codex_jsonl";
169
+ codex_otel: "codex_otel";
170
+ car_state: "car_state";
171
+ git_state: "git_state";
172
+ github_state: "github_state";
173
+ linear_state: "linear_state";
174
+ mcp_local: "mcp_local";
175
+ claude_hooks: "claude_hooks";
176
+ manual_event: "manual_event";
177
+ collector_runtime: "collector_runtime";
178
+ }>;
179
+ capture_adapter_version: z.ZodString;
180
+ collector_version: z.ZodString;
181
+ repo: z.ZodString;
182
+ branch: z.ZodString;
183
+ repo_label: z.ZodOptional<z.ZodString>;
184
+ repo_fingerprint: z.ZodOptional<z.ZodString>;
185
+ repo_origin_url: z.ZodOptional<z.ZodString>;
186
+ worktree_label: z.ZodOptional<z.ZodString>;
187
+ worktree_fingerprint: z.ZodOptional<z.ZodString>;
188
+ worktree_is_primary: z.ZodOptional<z.ZodBoolean>;
189
+ operator_id: z.ZodString;
190
+ session_id: z.ZodString;
191
+ work_context_id: z.ZodString;
192
+ }, z.core.$strict>;
193
+ upload_id: z.ZodString;
194
+ object_key: z.ZodString;
195
+ chunk_index: z.ZodNumber;
196
+ chunk_count: z.ZodNumber;
197
+ chunk_hash_sha256: z.ZodString;
198
+ content_base64: z.ZodString;
199
+ }, z.core.$strict>;
200
+ export type RawEvidenceUploadChunkRequest = z.infer<typeof RawEvidenceUploadChunkRequestSchema>;
201
+ export declare const RawEvidenceUploadChunkResponseSchema: z.ZodObject<{
202
+ ok: z.ZodLiteral<true>;
203
+ upload_id: z.ZodString;
204
+ chunk_index: z.ZodNumber;
205
+ received_chunk_count: z.ZodNumber;
206
+ }, z.core.$strict>;
207
+ export type RawEvidenceUploadChunkResponse = z.infer<typeof RawEvidenceUploadChunkResponseSchema>;
208
+ export declare const RawEvidenceUploadCommitRequestSchema: z.ZodObject<{
209
+ schema_version: z.ZodLiteral<"ambient-raw-evidence-upload-commit.v1">;
210
+ generated_at: z.ZodString;
211
+ provenance: z.ZodObject<{
212
+ capture_source: z.ZodEnum<{
213
+ unknown: "unknown";
214
+ codex_jsonl: "codex_jsonl";
215
+ codex_otel: "codex_otel";
216
+ car_state: "car_state";
217
+ git_state: "git_state";
218
+ github_state: "github_state";
219
+ linear_state: "linear_state";
220
+ mcp_local: "mcp_local";
221
+ claude_hooks: "claude_hooks";
222
+ manual_event: "manual_event";
223
+ collector_runtime: "collector_runtime";
224
+ }>;
225
+ capture_adapter_version: z.ZodString;
226
+ collector_version: z.ZodString;
227
+ repo: z.ZodString;
228
+ branch: z.ZodString;
229
+ repo_label: z.ZodOptional<z.ZodString>;
230
+ repo_fingerprint: z.ZodOptional<z.ZodString>;
231
+ repo_origin_url: z.ZodOptional<z.ZodString>;
232
+ worktree_label: z.ZodOptional<z.ZodString>;
233
+ worktree_fingerprint: z.ZodOptional<z.ZodString>;
234
+ worktree_is_primary: z.ZodOptional<z.ZodBoolean>;
235
+ operator_id: z.ZodString;
236
+ session_id: z.ZodString;
237
+ work_context_id: z.ZodString;
238
+ }, z.core.$strict>;
239
+ upload_id: z.ZodString;
240
+ object_key: z.ZodString;
241
+ }, z.core.$strict>;
242
+ export type RawEvidenceUploadCommitRequest = z.infer<typeof RawEvidenceUploadCommitRequestSchema>;
243
+ export declare const RawEvidenceUploadCommitResponseSchema: z.ZodObject<{
244
+ ok: z.ZodLiteral<true>;
245
+ status: z.ZodEnum<{
246
+ already_committed: "already_committed";
247
+ committed: "committed";
248
+ }>;
249
+ object_key: z.ZodString;
250
+ content_hash_sha256: z.ZodString;
251
+ byte_size: z.ZodNumber;
252
+ chunk_count: z.ZodNumber;
253
+ }, z.core.$strict>;
254
+ export type RawEvidenceUploadCommitResponse = z.infer<typeof RawEvidenceUploadCommitResponseSchema>;
255
+ /**
256
+ * Codex session attribution report.
257
+ *
258
+ * The collector attributes Codex session JSONL files to repos/worktrees with
259
+ * deterministic metadata signals. Sessions that cannot be attributed are
260
+ * reported here with reason labels and safe pointers (session id, file hash,
261
+ * cwd basename/hash) instead of being duplicated into every repo's evidence
262
+ * pack or silently dropped. No content-bearing fields are allowed.
263
+ */
264
+ export declare const CodexSessionAttributionStateSchema: z.ZodEnum<{
265
+ attributed: "attributed";
266
+ ambiguous: "ambiguous";
267
+ unattributed: "unattributed";
268
+ skipped: "skipped";
269
+ }>;
270
+ export type CodexSessionAttributionState = z.infer<typeof CodexSessionAttributionStateSchema>;
271
+ export declare const CodexSessionUploadStateSchema: z.ZodEnum<{
272
+ uploaded: "uploaded";
273
+ reused_existing: "reused_existing";
274
+ upload_failed: "upload_failed";
275
+ not_uploaded: "not_uploaded";
276
+ }>;
277
+ export type CodexSessionUploadState = z.infer<typeof CodexSessionUploadStateSchema>;
278
+ export declare const CodexSessionAttributionSchema: z.ZodObject<{
279
+ codex_session_id: z.ZodString;
280
+ observed_at: z.ZodString;
281
+ attribution_state: z.ZodEnum<{
282
+ attributed: "attributed";
283
+ ambiguous: "ambiguous";
284
+ unattributed: "unattributed";
285
+ skipped: "skipped";
286
+ }>;
287
+ attribution_reason: z.ZodString;
288
+ attribution_score: z.ZodOptional<z.ZodNumber>;
289
+ path_score: z.ZodOptional<z.ZodNumber>;
290
+ signals: z.ZodDefault<z.ZodArray<z.ZodString>>;
291
+ session_file_hash_sha256: z.ZodOptional<z.ZodString>;
292
+ session_file_byte_size: z.ZodOptional<z.ZodNumber>;
293
+ session_file_mtime: z.ZodOptional<z.ZodString>;
294
+ repo_fingerprint: z.ZodOptional<z.ZodString>;
295
+ worktree_fingerprint: z.ZodOptional<z.ZodString>;
296
+ repo_label: z.ZodOptional<z.ZodString>;
297
+ branch: z.ZodOptional<z.ZodString>;
298
+ cwd_basename: z.ZodOptional<z.ZodString>;
299
+ cwd_hash: z.ZodOptional<z.ZodString>;
300
+ raw_evidence_pointer_id: z.ZodOptional<z.ZodString>;
301
+ upload_state: z.ZodOptional<z.ZodEnum<{
302
+ uploaded: "uploaded";
303
+ reused_existing: "reused_existing";
304
+ upload_failed: "upload_failed";
305
+ not_uploaded: "not_uploaded";
306
+ }>>;
307
+ }, z.core.$strict>;
308
+ export type CodexSessionAttribution = z.infer<typeof CodexSessionAttributionSchema>;
309
+ export declare const CodexSessionAttributionReportRequestSchema: z.ZodObject<{
310
+ schema_version: z.ZodLiteral<"ambient-codex-session-attributions.v1">;
311
+ generated_at: z.ZodString;
312
+ provenance: z.ZodObject<{
313
+ capture_source: z.ZodEnum<{
314
+ unknown: "unknown";
315
+ codex_jsonl: "codex_jsonl";
316
+ codex_otel: "codex_otel";
317
+ car_state: "car_state";
318
+ git_state: "git_state";
319
+ github_state: "github_state";
320
+ linear_state: "linear_state";
321
+ mcp_local: "mcp_local";
322
+ claude_hooks: "claude_hooks";
323
+ manual_event: "manual_event";
324
+ collector_runtime: "collector_runtime";
325
+ }>;
326
+ capture_adapter_version: z.ZodString;
327
+ collector_version: z.ZodString;
328
+ repo: z.ZodString;
329
+ branch: z.ZodString;
330
+ repo_label: z.ZodOptional<z.ZodString>;
331
+ repo_fingerprint: z.ZodOptional<z.ZodString>;
332
+ repo_origin_url: z.ZodOptional<z.ZodString>;
333
+ worktree_label: z.ZodOptional<z.ZodString>;
334
+ worktree_fingerprint: z.ZodOptional<z.ZodString>;
335
+ worktree_is_primary: z.ZodOptional<z.ZodBoolean>;
336
+ operator_id: z.ZodString;
337
+ session_id: z.ZodString;
338
+ work_context_id: z.ZodString;
339
+ }, z.core.$strict>;
340
+ sessions: z.ZodArray<z.ZodObject<{
341
+ codex_session_id: z.ZodString;
342
+ observed_at: z.ZodString;
343
+ attribution_state: z.ZodEnum<{
344
+ attributed: "attributed";
345
+ ambiguous: "ambiguous";
346
+ unattributed: "unattributed";
347
+ skipped: "skipped";
348
+ }>;
349
+ attribution_reason: z.ZodString;
350
+ attribution_score: z.ZodOptional<z.ZodNumber>;
351
+ path_score: z.ZodOptional<z.ZodNumber>;
352
+ signals: z.ZodDefault<z.ZodArray<z.ZodString>>;
353
+ session_file_hash_sha256: z.ZodOptional<z.ZodString>;
354
+ session_file_byte_size: z.ZodOptional<z.ZodNumber>;
355
+ session_file_mtime: z.ZodOptional<z.ZodString>;
356
+ repo_fingerprint: z.ZodOptional<z.ZodString>;
357
+ worktree_fingerprint: z.ZodOptional<z.ZodString>;
358
+ repo_label: z.ZodOptional<z.ZodString>;
359
+ branch: z.ZodOptional<z.ZodString>;
360
+ cwd_basename: z.ZodOptional<z.ZodString>;
361
+ cwd_hash: z.ZodOptional<z.ZodString>;
362
+ raw_evidence_pointer_id: z.ZodOptional<z.ZodString>;
363
+ upload_state: z.ZodOptional<z.ZodEnum<{
364
+ uploaded: "uploaded";
365
+ reused_existing: "reused_existing";
366
+ upload_failed: "upload_failed";
367
+ not_uploaded: "not_uploaded";
368
+ }>>;
369
+ }, z.core.$strict>>;
370
+ }, z.core.$strict>;
371
+ export type CodexSessionAttributionReportRequest = z.infer<typeof CodexSessionAttributionReportRequestSchema>;
372
+ export declare const CodexSessionAttributionReportResponseSchema: z.ZodObject<{
373
+ ok: z.ZodLiteral<true>;
374
+ recorded_count: z.ZodNumber;
375
+ }, z.core.$strict>;
376
+ export type CodexSessionAttributionReportResponse = z.infer<typeof CodexSessionAttributionReportResponseSchema>;
@@ -0,0 +1,184 @@
1
+ import { z } from "zod";
2
+ import { CaptureProvenanceSchema, IsoDateTimeSchema, NonEmptyStringSchema, Sha256Schema, } from "./common.js";
3
+ import { RawEvidencePointerSchema } from "./privacy.js";
4
+ /**
5
+ * Chunked raw-evidence upload wire contract.
6
+ *
7
+ * Raw evidence bytes move in chunks small enough to clear serverless
8
+ * request-body limits (Vercel rejects bodies around 4.5MB). The server keeps a
9
+ * durable per-object ledger so interrupted uploads resume instead of
10
+ * re-sending bytes, and identical content is acknowledged without re-upload.
11
+ */
12
+ export const RAW_EVIDENCE_UPLOAD_MAX_FILE_BYTES = 10 * 1024 * 1024;
13
+ export const RAW_EVIDENCE_UPLOAD_MAX_CHUNK_BYTES = 3 * 1024 * 1024;
14
+ export const RAW_EVIDENCE_UPLOAD_DEFAULT_CHUNK_BYTES = 2 * 1024 * 1024;
15
+ export const RAW_EVIDENCE_UPLOAD_MAX_CHUNK_COUNT = 64;
16
+ export const RAW_EVIDENCE_UPLOAD_MAX_OBJECTS_PER_BEGIN = 25;
17
+ export const CODEX_SESSION_REPORT_MAX_SESSIONS = 200;
18
+ const SafeLabelSchema = z
19
+ .string()
20
+ .trim()
21
+ .min(1)
22
+ .max(120)
23
+ .regex(/^[a-z0-9_:.-]+$/i);
24
+ const BasenameSchema = z
25
+ .string()
26
+ .trim()
27
+ .min(1)
28
+ .max(160)
29
+ .regex(/^[^/\\]+$/);
30
+ export const RawEvidenceUploadBeginObjectSchema = z
31
+ .object({
32
+ pointer: RawEvidencePointerSchema,
33
+ chunk_size_bytes: z
34
+ .number()
35
+ .int()
36
+ .positive()
37
+ .max(RAW_EVIDENCE_UPLOAD_MAX_CHUNK_BYTES),
38
+ chunk_count: z
39
+ .number()
40
+ .int()
41
+ .positive()
42
+ .max(RAW_EVIDENCE_UPLOAD_MAX_CHUNK_COUNT),
43
+ })
44
+ .strict();
45
+ export const RawEvidenceUploadBeginRequestSchema = z
46
+ .object({
47
+ schema_version: z.literal("ambient-raw-evidence-upload-begin.v1"),
48
+ generated_at: IsoDateTimeSchema,
49
+ provenance: CaptureProvenanceSchema,
50
+ objects: z
51
+ .array(RawEvidenceUploadBeginObjectSchema)
52
+ .min(1)
53
+ .max(RAW_EVIDENCE_UPLOAD_MAX_OBJECTS_PER_BEGIN),
54
+ })
55
+ .strict();
56
+ export const RawEvidenceUploadDispositionSchema = z.enum([
57
+ "new",
58
+ "resume",
59
+ "already_committed",
60
+ "conflict",
61
+ ]);
62
+ export const RawEvidenceUploadBeginResponseObjectSchema = z
63
+ .object({
64
+ object_key: NonEmptyStringSchema,
65
+ raw_evidence_pointer_id: NonEmptyStringSchema,
66
+ disposition: RawEvidenceUploadDispositionSchema,
67
+ upload_id: NonEmptyStringSchema.optional(),
68
+ received_chunk_indexes: z.array(z.number().int().nonnegative()).default([]),
69
+ reason: SafeLabelSchema.optional(),
70
+ })
71
+ .strict();
72
+ export const RawEvidenceUploadBeginResponseSchema = z
73
+ .object({
74
+ ok: z.literal(true),
75
+ objects: z.array(RawEvidenceUploadBeginResponseObjectSchema),
76
+ })
77
+ .strict();
78
+ export const RawEvidenceUploadChunkRequestSchema = z
79
+ .object({
80
+ schema_version: z.literal("ambient-raw-evidence-upload-chunk.v1"),
81
+ generated_at: IsoDateTimeSchema,
82
+ provenance: CaptureProvenanceSchema,
83
+ upload_id: NonEmptyStringSchema,
84
+ object_key: NonEmptyStringSchema,
85
+ chunk_index: z.number().int().nonnegative(),
86
+ chunk_count: z
87
+ .number()
88
+ .int()
89
+ .positive()
90
+ .max(RAW_EVIDENCE_UPLOAD_MAX_CHUNK_COUNT),
91
+ chunk_hash_sha256: Sha256Schema,
92
+ content_base64: z.string().min(1),
93
+ })
94
+ .strict();
95
+ export const RawEvidenceUploadChunkResponseSchema = z
96
+ .object({
97
+ ok: z.literal(true),
98
+ upload_id: NonEmptyStringSchema,
99
+ chunk_index: z.number().int().nonnegative(),
100
+ received_chunk_count: z.number().int().nonnegative(),
101
+ })
102
+ .strict();
103
+ export const RawEvidenceUploadCommitRequestSchema = z
104
+ .object({
105
+ schema_version: z.literal("ambient-raw-evidence-upload-commit.v1"),
106
+ generated_at: IsoDateTimeSchema,
107
+ provenance: CaptureProvenanceSchema,
108
+ upload_id: NonEmptyStringSchema,
109
+ object_key: NonEmptyStringSchema,
110
+ })
111
+ .strict();
112
+ export const RawEvidenceUploadCommitResponseSchema = z
113
+ .object({
114
+ ok: z.literal(true),
115
+ status: z.enum(["committed", "already_committed"]),
116
+ object_key: NonEmptyStringSchema,
117
+ content_hash_sha256: Sha256Schema,
118
+ byte_size: z.number().int().nonnegative(),
119
+ chunk_count: z.number().int().nonnegative(),
120
+ })
121
+ .strict();
122
+ /**
123
+ * Codex session attribution report.
124
+ *
125
+ * The collector attributes Codex session JSONL files to repos/worktrees with
126
+ * deterministic metadata signals. Sessions that cannot be attributed are
127
+ * reported here with reason labels and safe pointers (session id, file hash,
128
+ * cwd basename/hash) instead of being duplicated into every repo's evidence
129
+ * pack or silently dropped. No content-bearing fields are allowed.
130
+ */
131
+ export const CodexSessionAttributionStateSchema = z.enum([
132
+ "attributed",
133
+ "ambiguous",
134
+ "unattributed",
135
+ "skipped",
136
+ ]);
137
+ export const CodexSessionUploadStateSchema = z.enum([
138
+ "uploaded",
139
+ "reused_existing",
140
+ "upload_failed",
141
+ "not_uploaded",
142
+ ]);
143
+ export const CodexSessionAttributionSchema = z
144
+ .object({
145
+ codex_session_id: NonEmptyStringSchema.max(120),
146
+ observed_at: IsoDateTimeSchema,
147
+ attribution_state: CodexSessionAttributionStateSchema,
148
+ attribution_reason: SafeLabelSchema,
149
+ attribution_score: z.number().min(0).max(1).optional(),
150
+ path_score: z.number().min(0).max(1).optional(),
151
+ signals: z.array(SafeLabelSchema).max(20).default([]),
152
+ session_file_hash_sha256: Sha256Schema.optional(),
153
+ session_file_byte_size: z.number().int().nonnegative().optional(),
154
+ session_file_mtime: IsoDateTimeSchema.optional(),
155
+ repo_fingerprint: SafeLabelSchema.optional(),
156
+ worktree_fingerprint: SafeLabelSchema.optional(),
157
+ repo_label: BasenameSchema.optional(),
158
+ branch: z.string().trim().min(1).max(200).optional(),
159
+ cwd_basename: BasenameSchema.optional(),
160
+ cwd_hash: z
161
+ .string()
162
+ .regex(/^[a-f0-9]{16,64}$/)
163
+ .optional(),
164
+ raw_evidence_pointer_id: NonEmptyStringSchema.optional(),
165
+ upload_state: CodexSessionUploadStateSchema.optional(),
166
+ })
167
+ .strict();
168
+ export const CodexSessionAttributionReportRequestSchema = z
169
+ .object({
170
+ schema_version: z.literal("ambient-codex-session-attributions.v1"),
171
+ generated_at: IsoDateTimeSchema,
172
+ provenance: CaptureProvenanceSchema,
173
+ sessions: z
174
+ .array(CodexSessionAttributionSchema)
175
+ .min(1)
176
+ .max(CODEX_SESSION_REPORT_MAX_SESSIONS),
177
+ })
178
+ .strict();
179
+ export const CodexSessionAttributionReportResponseSchema = z
180
+ .object({
181
+ ok: z.literal(true),
182
+ recorded_count: z.number().int().nonnegative(),
183
+ })
184
+ .strict();
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./common.js";
2
+ export * from "./evidence-upload.js";
2
3
  export * from "./ingest-dto.js";
3
4
  export * from "./local-config.js";
4
5
  export * from "./paths.js";
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./common.js";
2
+ export * from "./evidence-upload.js";
2
3
  export * from "./ingest-dto.js";
3
4
  export * from "./local-config.js";
4
5
  export * from "./paths.js";
@@ -47,6 +47,12 @@ export declare const TelemetryIngestEventDtoSchema: z.ZodObject<{
47
47
  collector_version: z.ZodString;
48
48
  repo: z.ZodString;
49
49
  branch: z.ZodString;
50
+ repo_label: z.ZodOptional<z.ZodString>;
51
+ repo_fingerprint: z.ZodOptional<z.ZodString>;
52
+ repo_origin_url: z.ZodOptional<z.ZodString>;
53
+ worktree_label: z.ZodOptional<z.ZodString>;
54
+ worktree_fingerprint: z.ZodOptional<z.ZodString>;
55
+ worktree_is_primary: z.ZodOptional<z.ZodBoolean>;
50
56
  operator_id: z.ZodString;
51
57
  session_id: z.ZodString;
52
58
  work_context_id: z.ZodString;
@@ -156,6 +162,12 @@ export declare const TelemetryIngestEventDtoSchema: z.ZodObject<{
156
162
  collector_version: z.ZodString;
157
163
  repo: z.ZodString;
158
164
  branch: z.ZodString;
165
+ repo_label: z.ZodOptional<z.ZodString>;
166
+ repo_fingerprint: z.ZodOptional<z.ZodString>;
167
+ repo_origin_url: z.ZodOptional<z.ZodString>;
168
+ worktree_label: z.ZodOptional<z.ZodString>;
169
+ worktree_fingerprint: z.ZodOptional<z.ZodString>;
170
+ worktree_is_primary: z.ZodOptional<z.ZodBoolean>;
159
171
  operator_id: z.ZodString;
160
172
  session_id: z.ZodString;
161
173
  work_context_id: z.ZodString;
@@ -264,6 +276,13 @@ export declare const TelemetryIngestEnvelopeSchema: z.ZodObject<{
264
276
  work_context_id: z.ZodString;
265
277
  repo: z.ZodString;
266
278
  branch: z.ZodString;
279
+ repo_label: z.ZodOptional<z.ZodString>;
280
+ repo_fingerprint: z.ZodOptional<z.ZodString>;
281
+ repo_origin_url: z.ZodOptional<z.ZodString>;
282
+ head_sha: z.ZodOptional<z.ZodString>;
283
+ worktree_label: z.ZodOptional<z.ZodString>;
284
+ worktree_fingerprint: z.ZodOptional<z.ZodString>;
285
+ worktree_is_primary: z.ZodOptional<z.ZodBoolean>;
267
286
  operator_id: z.ZodString;
268
287
  session_id: z.ZodString;
269
288
  started_at: z.ZodString;
@@ -303,6 +322,12 @@ export declare const TelemetryIngestEnvelopeSchema: z.ZodObject<{
303
322
  collector_version: z.ZodString;
304
323
  repo: z.ZodString;
305
324
  branch: z.ZodString;
325
+ repo_label: z.ZodOptional<z.ZodString>;
326
+ repo_fingerprint: z.ZodOptional<z.ZodString>;
327
+ repo_origin_url: z.ZodOptional<z.ZodString>;
328
+ worktree_label: z.ZodOptional<z.ZodString>;
329
+ worktree_fingerprint: z.ZodOptional<z.ZodString>;
330
+ worktree_is_primary: z.ZodOptional<z.ZodBoolean>;
306
331
  operator_id: z.ZodString;
307
332
  session_id: z.ZodString;
308
333
  work_context_id: z.ZodString;
@@ -342,6 +367,12 @@ export declare const TelemetryIngestEnvelopeSchema: z.ZodObject<{
342
367
  collector_version: z.ZodString;
343
368
  repo: z.ZodString;
344
369
  branch: z.ZodString;
370
+ repo_label: z.ZodOptional<z.ZodString>;
371
+ repo_fingerprint: z.ZodOptional<z.ZodString>;
372
+ repo_origin_url: z.ZodOptional<z.ZodString>;
373
+ worktree_label: z.ZodOptional<z.ZodString>;
374
+ worktree_fingerprint: z.ZodOptional<z.ZodString>;
375
+ worktree_is_primary: z.ZodOptional<z.ZodBoolean>;
345
376
  operator_id: z.ZodString;
346
377
  session_id: z.ZodString;
347
378
  work_context_id: z.ZodString;
@@ -451,6 +482,12 @@ export declare const TelemetryIngestEnvelopeSchema: z.ZodObject<{
451
482
  collector_version: z.ZodString;
452
483
  repo: z.ZodString;
453
484
  branch: z.ZodString;
485
+ repo_label: z.ZodOptional<z.ZodString>;
486
+ repo_fingerprint: z.ZodOptional<z.ZodString>;
487
+ repo_origin_url: z.ZodOptional<z.ZodString>;
488
+ worktree_label: z.ZodOptional<z.ZodString>;
489
+ worktree_fingerprint: z.ZodOptional<z.ZodString>;
490
+ worktree_is_primary: z.ZodOptional<z.ZodBoolean>;
454
491
  operator_id: z.ZodString;
455
492
  session_id: z.ZodString;
456
493
  work_context_id: z.ZodString;
@@ -548,8 +585,8 @@ export declare const TelemetryIngestEnvelopeSchema: z.ZodObject<{
548
585
  work_context_id: z.ZodOptional<z.ZodString>;
549
586
  status: z.ZodEnum<{
550
587
  ok: "ok";
551
- partial: "partial";
552
588
  skipped: "skipped";
589
+ partial: "partial";
553
590
  failed: "failed";
554
591
  }>;
555
592
  started_at: z.ZodString;
@@ -688,6 +725,12 @@ export declare const TelemetryIngestEnvelopeSchema: z.ZodObject<{
688
725
  collector_version: z.ZodString;
689
726
  repo: z.ZodString;
690
727
  branch: z.ZodString;
728
+ repo_label: z.ZodOptional<z.ZodString>;
729
+ repo_fingerprint: z.ZodOptional<z.ZodString>;
730
+ repo_origin_url: z.ZodOptional<z.ZodString>;
731
+ worktree_label: z.ZodOptional<z.ZodString>;
732
+ worktree_fingerprint: z.ZodOptional<z.ZodString>;
733
+ worktree_is_primary: z.ZodOptional<z.ZodBoolean>;
691
734
  operator_id: z.ZodString;
692
735
  session_id: z.ZodString;
693
736
  work_context_id: z.ZodString;
@@ -94,6 +94,12 @@ export declare const RiskFlagSchema: z.ZodObject<{
94
94
  collector_version: z.ZodString;
95
95
  repo: z.ZodString;
96
96
  branch: z.ZodString;
97
+ repo_label: z.ZodOptional<z.ZodString>;
98
+ repo_fingerprint: z.ZodOptional<z.ZodString>;
99
+ repo_origin_url: z.ZodOptional<z.ZodString>;
100
+ worktree_label: z.ZodOptional<z.ZodString>;
101
+ worktree_fingerprint: z.ZodOptional<z.ZodString>;
102
+ worktree_is_primary: z.ZodOptional<z.ZodBoolean>;
97
103
  operator_id: z.ZodString;
98
104
  session_id: z.ZodString;
99
105
  work_context_id: z.ZodString;
@@ -97,8 +97,8 @@ export declare const SourceScanResultSchema: z.ZodObject<{
97
97
  work_context_id: z.ZodOptional<z.ZodString>;
98
98
  status: z.ZodEnum<{
99
99
  ok: "ok";
100
- partial: "partial";
101
100
  skipped: "skipped";
101
+ partial: "partial";
102
102
  failed: "failed";
103
103
  }>;
104
104
  started_at: z.ZodString;
@@ -237,6 +237,12 @@ export declare const SourceScanResultSchema: z.ZodObject<{
237
237
  collector_version: z.ZodString;
238
238
  repo: z.ZodString;
239
239
  branch: z.ZodString;
240
+ repo_label: z.ZodOptional<z.ZodString>;
241
+ repo_fingerprint: z.ZodOptional<z.ZodString>;
242
+ repo_origin_url: z.ZodOptional<z.ZodString>;
243
+ worktree_label: z.ZodOptional<z.ZodString>;
244
+ worktree_fingerprint: z.ZodOptional<z.ZodString>;
245
+ worktree_is_primary: z.ZodOptional<z.ZodBoolean>;
240
246
  operator_id: z.ZodString;
241
247
  session_id: z.ZodString;
242
248
  work_context_id: z.ZodString;
@@ -29,6 +29,13 @@ export declare const LocalWorkContextSchema: z.ZodObject<{
29
29
  work_context_id: z.ZodString;
30
30
  repo: z.ZodString;
31
31
  branch: z.ZodString;
32
+ repo_label: z.ZodOptional<z.ZodString>;
33
+ repo_fingerprint: z.ZodOptional<z.ZodString>;
34
+ repo_origin_url: z.ZodOptional<z.ZodString>;
35
+ head_sha: z.ZodOptional<z.ZodString>;
36
+ worktree_label: z.ZodOptional<z.ZodString>;
37
+ worktree_fingerprint: z.ZodOptional<z.ZodString>;
38
+ worktree_is_primary: z.ZodOptional<z.ZodBoolean>;
32
39
  operator_id: z.ZodString;
33
40
  session_id: z.ZodString;
34
41
  started_at: z.ZodString;
@@ -68,6 +75,12 @@ export declare const LocalWorkContextSchema: z.ZodObject<{
68
75
  collector_version: z.ZodString;
69
76
  repo: z.ZodString;
70
77
  branch: z.ZodString;
78
+ repo_label: z.ZodOptional<z.ZodString>;
79
+ repo_fingerprint: z.ZodOptional<z.ZodString>;
80
+ repo_origin_url: z.ZodOptional<z.ZodString>;
81
+ worktree_label: z.ZodOptional<z.ZodString>;
82
+ worktree_fingerprint: z.ZodOptional<z.ZodString>;
83
+ worktree_is_primary: z.ZodOptional<z.ZodBoolean>;
71
84
  operator_id: z.ZodString;
72
85
  session_id: z.ZodString;
73
86
  work_context_id: z.ZodString;
@@ -23,6 +23,13 @@ export const LocalWorkContextSchema = z
23
23
  work_context_id: NonEmptyStringSchema,
24
24
  repo: NonEmptyStringSchema,
25
25
  branch: NonEmptyStringSchema,
26
+ repo_label: NonEmptyStringSchema.optional(),
27
+ repo_fingerprint: NonEmptyStringSchema.optional(),
28
+ repo_origin_url: NonEmptyStringSchema.optional(),
29
+ head_sha: NonEmptyStringSchema.optional(),
30
+ worktree_label: NonEmptyStringSchema.optional(),
31
+ worktree_fingerprint: NonEmptyStringSchema.optional(),
32
+ worktree_is_primary: z.boolean().optional(),
26
33
  operator_id: NonEmptyStringSchema,
27
34
  session_id: NonEmptyStringSchema,
28
35
  started_at: IsoDateTimeSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bli-cockpit/telemetry-core",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",