@bli-cockpit/telemetry-core 0.1.54 → 0.1.55
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/evidence-transcripts.d.ts +65 -0
- package/dist/evidence-transcripts.js +81 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Does Tower hold this transcript?" — the wire contract for asking
|
|
3
|
+
* (BLI-11122).
|
|
4
|
+
*
|
|
5
|
+
* On 2026-09-30 an agent freeing disk deleted 1,491 Codex transcripts on the
|
|
6
|
+
* premise that they were already in Tower; 349 had no copy. Nothing could
|
|
7
|
+
* answer the question per file, so the agent guessed. `cockpit sources check`
|
|
8
|
+
* answers it: it lists every CURRENT transcript object the caller owns through
|
|
9
|
+
* this door and compares each against the local file.
|
|
10
|
+
*
|
|
11
|
+
* Current means: not superseded by a later snapshot of the same session, and
|
|
12
|
+
* not excluded. A redaction-crash stub is listed with `stub: true`, because a
|
|
13
|
+
* stub is a promise to come back, not a delivery (see `evidence-stubs.ts`).
|
|
14
|
+
*
|
|
15
|
+
* Read-only, scoped to the caller's own operator rows, one bounded page per
|
|
16
|
+
* call, keyset on the unique ref id under the 1,000-row REST cap.
|
|
17
|
+
*/
|
|
18
|
+
import { z } from "zod";
|
|
19
|
+
export declare const EVIDENCE_TRANSCRIPTS_SCHEMA_VERSION = "evidence-transcripts.v1";
|
|
20
|
+
/** One page holds at most this many objects (under the 1,000-row REST cap). */
|
|
21
|
+
export declare const EVIDENCE_TRANSCRIPTS_MAX_PAGE = 500;
|
|
22
|
+
export declare const EvidenceTranscriptsRequestSchema: z.ZodObject<{
|
|
23
|
+
schema_version: z.ZodLiteral<"evidence-transcripts.v1">;
|
|
24
|
+
after: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
25
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
}, z.core.$strict>;
|
|
27
|
+
export type EvidenceTranscriptsRequest = z.infer<typeof EvidenceTranscriptsRequestSchema>;
|
|
28
|
+
export declare const EvidenceTranscriptObjectSchema: z.ZodObject<{
|
|
29
|
+
ref_id: z.ZodString;
|
|
30
|
+
object_key: z.ZodString;
|
|
31
|
+
byte_size: z.ZodNullable<z.ZodNumber>;
|
|
32
|
+
content_hash_sha256: z.ZodNullable<z.ZodString>;
|
|
33
|
+
stub: z.ZodBoolean;
|
|
34
|
+
received_at: z.ZodString;
|
|
35
|
+
}, z.core.$strict>;
|
|
36
|
+
export type EvidenceTranscriptObject = z.infer<typeof EvidenceTranscriptObjectSchema>;
|
|
37
|
+
export declare const EvidenceTranscriptsResponseSchema: z.ZodObject<{
|
|
38
|
+
schema_version: z.ZodLiteral<"evidence-transcripts.v1">;
|
|
39
|
+
objects: z.ZodArray<z.ZodObject<{
|
|
40
|
+
ref_id: z.ZodString;
|
|
41
|
+
object_key: z.ZodString;
|
|
42
|
+
byte_size: z.ZodNullable<z.ZodNumber>;
|
|
43
|
+
content_hash_sha256: z.ZodNullable<z.ZodString>;
|
|
44
|
+
stub: z.ZodBoolean;
|
|
45
|
+
received_at: z.ZodString;
|
|
46
|
+
}, z.core.$strict>>;
|
|
47
|
+
next_after: z.ZodNullable<z.ZodString>;
|
|
48
|
+
}, z.core.$strict>;
|
|
49
|
+
export type EvidenceTranscriptsResponse = z.infer<typeof EvidenceTranscriptsResponseSchema>;
|
|
50
|
+
export interface TranscriptFileIdentity {
|
|
51
|
+
source: "codex" | "claude_code";
|
|
52
|
+
session_id: string;
|
|
53
|
+
/** The Claude subagent file's key segment, or null for the session's main transcript. */
|
|
54
|
+
sidecar: string | null;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Which local transcript file an object stands for, read off its key:
|
|
58
|
+
* `.../codex/<session>/<hash16>.jsonl`, `.../claude/<session>/<hash16>.jsonl`
|
|
59
|
+
* or `.../claude/<session>/subagents/<sidecar>-<hash16>.jsonl`. The collector
|
|
60
|
+
* names objects this way (`raw-evidence-codex-reader.ts`,
|
|
61
|
+
* `raw-evidence-claude-reader.ts`); anything else is null, never a guess.
|
|
62
|
+
*/
|
|
63
|
+
export declare function transcriptFileFromObjectKey(objectKey: string): TranscriptFileIdentity | null;
|
|
64
|
+
/** The one string both sides key a transcript file by. */
|
|
65
|
+
export declare function transcriptFileKey(identity: TranscriptFileIdentity): string;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Does Tower hold this transcript?" — the wire contract for asking
|
|
3
|
+
* (BLI-11122).
|
|
4
|
+
*
|
|
5
|
+
* On 2026-09-30 an agent freeing disk deleted 1,491 Codex transcripts on the
|
|
6
|
+
* premise that they were already in Tower; 349 had no copy. Nothing could
|
|
7
|
+
* answer the question per file, so the agent guessed. `cockpit sources check`
|
|
8
|
+
* answers it: it lists every CURRENT transcript object the caller owns through
|
|
9
|
+
* this door and compares each against the local file.
|
|
10
|
+
*
|
|
11
|
+
* Current means: not superseded by a later snapshot of the same session, and
|
|
12
|
+
* not excluded. A redaction-crash stub is listed with `stub: true`, because a
|
|
13
|
+
* stub is a promise to come back, not a delivery (see `evidence-stubs.ts`).
|
|
14
|
+
*
|
|
15
|
+
* Read-only, scoped to the caller's own operator rows, one bounded page per
|
|
16
|
+
* call, keyset on the unique ref id under the 1,000-row REST cap.
|
|
17
|
+
*/
|
|
18
|
+
import { z } from "zod";
|
|
19
|
+
import { IsoDateTimeSchema, NonEmptyStringSchema } from "./common.js";
|
|
20
|
+
export const EVIDENCE_TRANSCRIPTS_SCHEMA_VERSION = "evidence-transcripts.v1";
|
|
21
|
+
/** One page holds at most this many objects (under the 1,000-row REST cap). */
|
|
22
|
+
export const EVIDENCE_TRANSCRIPTS_MAX_PAGE = 500;
|
|
23
|
+
export const EvidenceTranscriptsRequestSchema = z
|
|
24
|
+
.object({
|
|
25
|
+
schema_version: z.literal(EVIDENCE_TRANSCRIPTS_SCHEMA_VERSION),
|
|
26
|
+
/** Keyset cursor: the last ref id of the previous page, or null for the first. */
|
|
27
|
+
after: z.string().uuid().nullable().optional(),
|
|
28
|
+
limit: z.number().int().min(1).max(EVIDENCE_TRANSCRIPTS_MAX_PAGE).optional(),
|
|
29
|
+
})
|
|
30
|
+
.strict();
|
|
31
|
+
export const EvidenceTranscriptObjectSchema = z
|
|
32
|
+
.object({
|
|
33
|
+
ref_id: z.string().uuid(),
|
|
34
|
+
object_key: NonEmptyStringSchema,
|
|
35
|
+
/** Stored bytes; null only on legacy rows written before sizes were kept. */
|
|
36
|
+
byte_size: z.number().int().nonnegative().nullable(),
|
|
37
|
+
/** sha256 of the stored (redacted) bytes; null only on legacy rows. */
|
|
38
|
+
content_hash_sha256: z
|
|
39
|
+
.string()
|
|
40
|
+
.regex(/^[0-9a-f]{64}$/u)
|
|
41
|
+
.nullable(),
|
|
42
|
+
/** The 42-byte redaction-crash marker: no session byte is stored. */
|
|
43
|
+
stub: z.boolean(),
|
|
44
|
+
received_at: IsoDateTimeSchema,
|
|
45
|
+
})
|
|
46
|
+
.strict();
|
|
47
|
+
export const EvidenceTranscriptsResponseSchema = z
|
|
48
|
+
.object({
|
|
49
|
+
schema_version: z.literal(EVIDENCE_TRANSCRIPTS_SCHEMA_VERSION),
|
|
50
|
+
objects: z.array(EvidenceTranscriptObjectSchema),
|
|
51
|
+
/** Pass as `after` to read the next page; null once the list is exhausted. */
|
|
52
|
+
next_after: z.string().uuid().nullable(),
|
|
53
|
+
})
|
|
54
|
+
.strict();
|
|
55
|
+
/**
|
|
56
|
+
* Which local transcript file an object stands for, read off its key:
|
|
57
|
+
* `.../codex/<session>/<hash16>.jsonl`, `.../claude/<session>/<hash16>.jsonl`
|
|
58
|
+
* or `.../claude/<session>/subagents/<sidecar>-<hash16>.jsonl`. The collector
|
|
59
|
+
* names objects this way (`raw-evidence-codex-reader.ts`,
|
|
60
|
+
* `raw-evidence-claude-reader.ts`); anything else is null, never a guess.
|
|
61
|
+
*/
|
|
62
|
+
export function transcriptFileFromObjectKey(objectKey) {
|
|
63
|
+
const main = /(?:^|\/)(codex|claude)\/([A-Za-z0-9._-]{1,80})\/[0-9a-f]{16}\.jsonl$/u.exec(objectKey);
|
|
64
|
+
if (main) {
|
|
65
|
+
return {
|
|
66
|
+
source: main[1] === "codex" ? "codex" : "claude_code",
|
|
67
|
+
session_id: main[2],
|
|
68
|
+
sidecar: null,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const sidecar = /(?:^|\/)claude\/([A-Za-z0-9._-]{1,80})\/subagents\/([A-Za-z0-9._-]{1,80})-[0-9a-f]{16}\.jsonl$/u.exec(objectKey);
|
|
72
|
+
if (!sidecar)
|
|
73
|
+
return null;
|
|
74
|
+
return { source: "claude_code", session_id: sidecar[1], sidecar: sidecar[2] };
|
|
75
|
+
}
|
|
76
|
+
/** The one string both sides key a transcript file by. */
|
|
77
|
+
export function transcriptFileKey(identity) {
|
|
78
|
+
return identity.sidecar
|
|
79
|
+
? `${identity.source}:${identity.session_id}:subagents/${identity.sidecar}`
|
|
80
|
+
: `${identity.source}:${identity.session_id}`;
|
|
81
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./decision-event-id.js";
|
|
|
7
7
|
export * from "./evidence-completeness.js";
|
|
8
8
|
export * from "./evidence-reconcile.js";
|
|
9
9
|
export * from "./evidence-stubs.js";
|
|
10
|
+
export * from "./evidence-transcripts.js";
|
|
10
11
|
export * from "./evidence-upload.js";
|
|
11
12
|
export * from "./ingest-dto.js";
|
|
12
13
|
export * from "./local-config.js";
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./decision-event-id.js";
|
|
|
7
7
|
export * from "./evidence-completeness.js";
|
|
8
8
|
export * from "./evidence-reconcile.js";
|
|
9
9
|
export * from "./evidence-stubs.js";
|
|
10
|
+
export * from "./evidence-transcripts.js";
|
|
10
11
|
export * from "./evidence-upload.js";
|
|
11
12
|
export * from "./ingest-dto.js";
|
|
12
13
|
export * from "./local-config.js";
|