@dosu/seshi-model 0.0.0-stage → 0.10.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 +21 -0
- package/README.md +8 -2
- package/dist/index.js +1553 -0
- package/package.json +33 -4
- package/types/api.d.ts +219 -0
- package/types/authz.d.ts +18 -0
- package/types/canonical.d.ts +5 -0
- package/types/errors.d.ts +53 -0
- package/types/format-adapter.d.ts +66 -0
- package/types/generated/change.d.ts +81 -0
- package/types/generated/common.d.ts +253 -0
- package/types/generated/envelope.d.ts +228 -0
- package/types/generated/layout.d.ts +65 -0
- package/types/generated/metadata.d.ts +307 -0
- package/types/generated/trace.d.ts +484 -0
- package/types/index.d.ts +24 -0
- package/types/parse.d.ts +18 -0
- package/types/prefix-hash.d.ts +47 -0
- package/types/schemas/otlp.d.ts +51 -0
- package/types/schemas/renders.d.ts +95 -0
- package/types/schemas/store.d.ts +32 -0
- package/types/schemas/trace.d.ts +3 -0
- package/types/schemas/trajectory.d.ts +15 -0
- package/types/schemas/validate.d.ts +5 -0
- package/types/search.d.ts +91 -0
- package/types/spans.d.ts +156 -0
- package/types/version.d.ts +1 -0
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
/** Generated from spec/schemas/trace.schema.json by scripts/model-types.ts (`bun run types`). Do not edit: change the schema and regenerate. */
|
|
2
|
+
import type { Continuation, Normalizer, Provenance, Sha256 } from "./common.js";
|
|
3
|
+
/** The `schema` value of every Trace object. */
|
|
4
|
+
export declare const SCHEMA_ID: "seshi/trace/1";
|
|
5
|
+
/** `seshi/trace/1`: the one canonical stored trace (X6.2), the immutable, content-addressed object at `owners/<owner>/sessions/<archive_id>/trace.<content_hash>.json.gz`. Evolved from trajectory-v1: `records` are trajectory-v1 records with optional fields for what raw used to keep (X6.3), `llm_calls` holds model and token usage per LLM call, and `provenance` says where the data came from. `events` and `content_hash` are derived from the records exactly as before (spec/layout.md), so hashes do not change. Letta (trajectory-v1), OTLP and ATIF are rendered from it on read. */
|
|
6
|
+
export interface Trace {
|
|
7
|
+
schema: "seshi/trace/1";
|
|
8
|
+
/** sha256 of what was said: `source` (plus `@from_record` for a continuation), then each event's role and text (spec/layout.md). */
|
|
9
|
+
content_hash: Sha256;
|
|
10
|
+
/** The meta record's `source` (`claude-code`, `codex`, an ATIF document's harness, …). */
|
|
11
|
+
source: string;
|
|
12
|
+
/** The format the session was filed under (the archive id derives from it). */
|
|
13
|
+
agent: string;
|
|
14
|
+
project?: string;
|
|
15
|
+
branch?: string;
|
|
16
|
+
session_id: string | null;
|
|
17
|
+
/** The earliest event timestamp, as shipped; null when no event has one that parses. */
|
|
18
|
+
started_at: string | null;
|
|
19
|
+
/** The latest event timestamp, as shipped; null when no event has one that parses. */
|
|
20
|
+
ended_at: string | null;
|
|
21
|
+
/** The records after redaction and NUL stripping, meta record first: what `events` were derived from. */
|
|
22
|
+
records: TraceRecord[];
|
|
23
|
+
events: TraceEvent[];
|
|
24
|
+
metadata: TraceMetadata;
|
|
25
|
+
/** The LLM calls the session made, referenced from records by `llm_call`. Absent when the source records none. */
|
|
26
|
+
llm_calls?: LlmCall[];
|
|
27
|
+
provenance?: Provenance;
|
|
28
|
+
}
|
|
29
|
+
/** One record: trajectory-v1, plus optional fields trajectory-v1 lacks. */
|
|
30
|
+
export type TraceRecord = TraceMetaRecord | TraceTextRecord | TraceAssistantRecord | TraceToolResultRecord;
|
|
31
|
+
/** The first record, and only the first: what the session is. */
|
|
32
|
+
export interface TraceMetaRecord {
|
|
33
|
+
role: "meta";
|
|
34
|
+
source: string;
|
|
35
|
+
cwd?: string;
|
|
36
|
+
git_branch?: string;
|
|
37
|
+
/** The session's main model, when the source names one. */
|
|
38
|
+
model?: string;
|
|
39
|
+
/** The version of the agent harness that wrote the transcript. */
|
|
40
|
+
agent_version?: string;
|
|
41
|
+
}
|
|
42
|
+
/** A user prompt, a system message, an observation from the environment, or the model's reasoning. */
|
|
43
|
+
export interface TraceTextRecord {
|
|
44
|
+
role: "user" | "system" | "observation" | "reasoning";
|
|
45
|
+
content: string;
|
|
46
|
+
timestamp: string;
|
|
47
|
+
id?: RecordId;
|
|
48
|
+
llm_call?: LlmCallRef;
|
|
49
|
+
/** User records only: the agent or a plugin added this text to the user's turn, not the member (an OpenCode part marked `synthetic`, a pi extension's custom message). The model saw it. */
|
|
50
|
+
synthetic?: true;
|
|
51
|
+
/** User records only: how many injected items the integrator that added them asked seshi to leave out (`session_capture.omit`), here. Their text is not stored: the record's content is empty. */
|
|
52
|
+
omitted?: number;
|
|
53
|
+
}
|
|
54
|
+
/** What the assistant said, or the tools it called (or both). */
|
|
55
|
+
export interface TraceAssistantRecord {
|
|
56
|
+
role: "assistant";
|
|
57
|
+
content: string | null;
|
|
58
|
+
tool_calls?: TraceToolCall[];
|
|
59
|
+
timestamp: string;
|
|
60
|
+
id?: RecordId;
|
|
61
|
+
llm_call?: LlmCallRef;
|
|
62
|
+
}
|
|
63
|
+
export interface TraceToolCall {
|
|
64
|
+
/** The tool call id the agent assigned. */
|
|
65
|
+
id: string;
|
|
66
|
+
name: string;
|
|
67
|
+
/** The arguments as the agent sent them (usually JSON). */
|
|
68
|
+
args: string;
|
|
69
|
+
}
|
|
70
|
+
/** A tool call's result. */
|
|
71
|
+
export interface TraceToolResultRecord {
|
|
72
|
+
role: "tool";
|
|
73
|
+
tool_call_id: string;
|
|
74
|
+
content: string;
|
|
75
|
+
/** Whether the call succeeded, when the source says. */
|
|
76
|
+
ok?: boolean;
|
|
77
|
+
timestamp: string;
|
|
78
|
+
id?: RecordId;
|
|
79
|
+
/** Set when the result's content was replaced: the call touched a sensitive file or printed a secret (F2), or model review withheld it (`review`, F3.1). */
|
|
80
|
+
withheld?: "sensitive-file" | "secret-output" | "review";
|
|
81
|
+
/** How long the call ran, when the source says. */
|
|
82
|
+
duration_ms?: number;
|
|
83
|
+
}
|
|
84
|
+
/** The record's id in its source (a message uuid, a span id), for provenance. */
|
|
85
|
+
export type RecordId = string;
|
|
86
|
+
/** The `id` of the entry in `llm_calls` that produced this record. */
|
|
87
|
+
export type LlmCallRef = string;
|
|
88
|
+
/** One request to a model: which model, when, what it cost in tokens and how it ended. */
|
|
89
|
+
export interface LlmCall {
|
|
90
|
+
/** Unique within the trace. */
|
|
91
|
+
id: string;
|
|
92
|
+
/** The model that answered. */
|
|
93
|
+
model?: string;
|
|
94
|
+
/** `anthropic`, `openai`, `bedrock`, … */
|
|
95
|
+
provider?: string;
|
|
96
|
+
started_at?: string;
|
|
97
|
+
ended_at?: string;
|
|
98
|
+
duration_ms?: number;
|
|
99
|
+
usage?: TokenUsage;
|
|
100
|
+
/** Why generation stopped, in the provider's words. */
|
|
101
|
+
stop_reason?: string;
|
|
102
|
+
/** The provider's request or response id. */
|
|
103
|
+
request_id?: string;
|
|
104
|
+
/** Request parameters the source records (`temperature`, `max_tokens`, …). */
|
|
105
|
+
parameters?: {
|
|
106
|
+
[key: string]: string | number | boolean | null;
|
|
107
|
+
};
|
|
108
|
+
/** The error the call ended with, if it failed. */
|
|
109
|
+
error?: string;
|
|
110
|
+
}
|
|
111
|
+
/** Token counts as the provider reports them. */
|
|
112
|
+
export interface TokenUsage {
|
|
113
|
+
input_tokens?: number;
|
|
114
|
+
output_tokens?: number;
|
|
115
|
+
cache_read_input_tokens?: number;
|
|
116
|
+
cache_creation_input_tokens?: number;
|
|
117
|
+
reasoning_tokens?: number;
|
|
118
|
+
total_tokens?: number;
|
|
119
|
+
}
|
|
120
|
+
export type EventRole = "user" | "assistant" | "tool_call" | "tool_result" | "system" | "observation" | "reasoning";
|
|
121
|
+
/** One unit of a trace. `index` is stable for the life of the object; `text` is the canonical string excerpts are validated against. */
|
|
122
|
+
export interface TraceEvent {
|
|
123
|
+
index: number;
|
|
124
|
+
role: EventRole;
|
|
125
|
+
text: string;
|
|
126
|
+
/** The record's timestamp as shipped; null when it does not parse. */
|
|
127
|
+
timestamp: string | null;
|
|
128
|
+
tool_name?: string;
|
|
129
|
+
tool_call_id?: string;
|
|
130
|
+
ok?: boolean;
|
|
131
|
+
}
|
|
132
|
+
/** Lineage and scope attached at ingest, plus the meta record's `cwd`, `git_branch` and `model`. */
|
|
133
|
+
export interface TraceMetadata {
|
|
134
|
+
cwd?: string;
|
|
135
|
+
git_branch?: string;
|
|
136
|
+
model?: string;
|
|
137
|
+
/** The session this one was spawned by (a subagent, a fork). */
|
|
138
|
+
parent_session_id?: string;
|
|
139
|
+
continuation?: Continuation;
|
|
140
|
+
normalizer?: Normalizer;
|
|
141
|
+
[key: string]: unknown;
|
|
142
|
+
}
|
|
143
|
+
/** trace.schema.json as data, without its annotations: what `schemaProblems` checks against. */
|
|
144
|
+
export declare const JSON_SCHEMA: {
|
|
145
|
+
$id: string;
|
|
146
|
+
type: string;
|
|
147
|
+
properties: {
|
|
148
|
+
schema: {
|
|
149
|
+
const: string;
|
|
150
|
+
};
|
|
151
|
+
content_hash: {
|
|
152
|
+
$ref: string;
|
|
153
|
+
};
|
|
154
|
+
source: {
|
|
155
|
+
type: string;
|
|
156
|
+
minLength: number;
|
|
157
|
+
};
|
|
158
|
+
agent: {
|
|
159
|
+
type: string;
|
|
160
|
+
minLength: number;
|
|
161
|
+
};
|
|
162
|
+
project: {
|
|
163
|
+
type: string;
|
|
164
|
+
};
|
|
165
|
+
branch: {
|
|
166
|
+
type: string;
|
|
167
|
+
};
|
|
168
|
+
session_id: {
|
|
169
|
+
type: string[];
|
|
170
|
+
};
|
|
171
|
+
started_at: {
|
|
172
|
+
type: string[];
|
|
173
|
+
};
|
|
174
|
+
ended_at: {
|
|
175
|
+
type: string[];
|
|
176
|
+
};
|
|
177
|
+
records: {
|
|
178
|
+
type: string;
|
|
179
|
+
items: {
|
|
180
|
+
$ref: string;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
events: {
|
|
184
|
+
type: string;
|
|
185
|
+
items: {
|
|
186
|
+
$ref: string;
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
metadata: {
|
|
190
|
+
$ref: string;
|
|
191
|
+
};
|
|
192
|
+
llm_calls: {
|
|
193
|
+
type: string;
|
|
194
|
+
items: {
|
|
195
|
+
$ref: string;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
provenance: {
|
|
199
|
+
$ref: string;
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
required: string[];
|
|
203
|
+
additionalProperties: boolean;
|
|
204
|
+
$defs: {
|
|
205
|
+
TraceRecord: {
|
|
206
|
+
oneOf: {
|
|
207
|
+
$ref: string;
|
|
208
|
+
}[];
|
|
209
|
+
};
|
|
210
|
+
TraceMetaRecord: {
|
|
211
|
+
type: string;
|
|
212
|
+
properties: {
|
|
213
|
+
role: {
|
|
214
|
+
const: string;
|
|
215
|
+
};
|
|
216
|
+
source: {
|
|
217
|
+
type: string;
|
|
218
|
+
minLength: number;
|
|
219
|
+
};
|
|
220
|
+
cwd: {
|
|
221
|
+
type: string;
|
|
222
|
+
};
|
|
223
|
+
git_branch: {
|
|
224
|
+
type: string;
|
|
225
|
+
};
|
|
226
|
+
model: {
|
|
227
|
+
type: string;
|
|
228
|
+
};
|
|
229
|
+
agent_version: {
|
|
230
|
+
type: string;
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
required: string[];
|
|
234
|
+
additionalProperties: boolean;
|
|
235
|
+
};
|
|
236
|
+
TraceTextRecord: {
|
|
237
|
+
type: string;
|
|
238
|
+
properties: {
|
|
239
|
+
role: {
|
|
240
|
+
enum: string[];
|
|
241
|
+
};
|
|
242
|
+
content: {
|
|
243
|
+
type: string;
|
|
244
|
+
};
|
|
245
|
+
timestamp: {
|
|
246
|
+
type: string;
|
|
247
|
+
};
|
|
248
|
+
id: {
|
|
249
|
+
$ref: string;
|
|
250
|
+
};
|
|
251
|
+
llm_call: {
|
|
252
|
+
$ref: string;
|
|
253
|
+
};
|
|
254
|
+
synthetic: {
|
|
255
|
+
const: boolean;
|
|
256
|
+
};
|
|
257
|
+
omitted: {
|
|
258
|
+
type: string;
|
|
259
|
+
minimum: number;
|
|
260
|
+
};
|
|
261
|
+
};
|
|
262
|
+
required: string[];
|
|
263
|
+
additionalProperties: boolean;
|
|
264
|
+
};
|
|
265
|
+
TraceAssistantRecord: {
|
|
266
|
+
type: string;
|
|
267
|
+
properties: {
|
|
268
|
+
role: {
|
|
269
|
+
const: string;
|
|
270
|
+
};
|
|
271
|
+
content: {
|
|
272
|
+
type: string[];
|
|
273
|
+
};
|
|
274
|
+
tool_calls: {
|
|
275
|
+
type: string;
|
|
276
|
+
items: {
|
|
277
|
+
$ref: string;
|
|
278
|
+
};
|
|
279
|
+
};
|
|
280
|
+
timestamp: {
|
|
281
|
+
type: string;
|
|
282
|
+
};
|
|
283
|
+
id: {
|
|
284
|
+
$ref: string;
|
|
285
|
+
};
|
|
286
|
+
llm_call: {
|
|
287
|
+
$ref: string;
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
required: string[];
|
|
291
|
+
additionalProperties: boolean;
|
|
292
|
+
};
|
|
293
|
+
TraceToolCall: {
|
|
294
|
+
type: string;
|
|
295
|
+
properties: {
|
|
296
|
+
id: {
|
|
297
|
+
type: string;
|
|
298
|
+
minLength: number;
|
|
299
|
+
};
|
|
300
|
+
name: {
|
|
301
|
+
type: string;
|
|
302
|
+
minLength: number;
|
|
303
|
+
};
|
|
304
|
+
args: {
|
|
305
|
+
type: string;
|
|
306
|
+
};
|
|
307
|
+
};
|
|
308
|
+
required: string[];
|
|
309
|
+
additionalProperties: boolean;
|
|
310
|
+
};
|
|
311
|
+
TraceToolResultRecord: {
|
|
312
|
+
type: string;
|
|
313
|
+
properties: {
|
|
314
|
+
role: {
|
|
315
|
+
const: string;
|
|
316
|
+
};
|
|
317
|
+
tool_call_id: {
|
|
318
|
+
type: string;
|
|
319
|
+
minLength: number;
|
|
320
|
+
};
|
|
321
|
+
content: {
|
|
322
|
+
type: string;
|
|
323
|
+
};
|
|
324
|
+
ok: {
|
|
325
|
+
type: string;
|
|
326
|
+
};
|
|
327
|
+
timestamp: {
|
|
328
|
+
type: string;
|
|
329
|
+
};
|
|
330
|
+
id: {
|
|
331
|
+
$ref: string;
|
|
332
|
+
};
|
|
333
|
+
withheld: {
|
|
334
|
+
enum: string[];
|
|
335
|
+
};
|
|
336
|
+
duration_ms: {
|
|
337
|
+
type: string;
|
|
338
|
+
minimum: number;
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
required: string[];
|
|
342
|
+
additionalProperties: boolean;
|
|
343
|
+
};
|
|
344
|
+
RecordId: {
|
|
345
|
+
type: string;
|
|
346
|
+
minLength: number;
|
|
347
|
+
};
|
|
348
|
+
LlmCallRef: {
|
|
349
|
+
type: string;
|
|
350
|
+
minLength: number;
|
|
351
|
+
};
|
|
352
|
+
LlmCall: {
|
|
353
|
+
type: string;
|
|
354
|
+
properties: {
|
|
355
|
+
id: {
|
|
356
|
+
type: string;
|
|
357
|
+
minLength: number;
|
|
358
|
+
};
|
|
359
|
+
model: {
|
|
360
|
+
type: string;
|
|
361
|
+
};
|
|
362
|
+
provider: {
|
|
363
|
+
type: string;
|
|
364
|
+
};
|
|
365
|
+
started_at: {
|
|
366
|
+
type: string;
|
|
367
|
+
};
|
|
368
|
+
ended_at: {
|
|
369
|
+
type: string;
|
|
370
|
+
};
|
|
371
|
+
duration_ms: {
|
|
372
|
+
type: string;
|
|
373
|
+
minimum: number;
|
|
374
|
+
};
|
|
375
|
+
usage: {
|
|
376
|
+
$ref: string;
|
|
377
|
+
};
|
|
378
|
+
stop_reason: {
|
|
379
|
+
type: string;
|
|
380
|
+
};
|
|
381
|
+
request_id: {
|
|
382
|
+
type: string;
|
|
383
|
+
};
|
|
384
|
+
parameters: {
|
|
385
|
+
type: string;
|
|
386
|
+
additionalProperties: {
|
|
387
|
+
type: string[];
|
|
388
|
+
};
|
|
389
|
+
};
|
|
390
|
+
error: {
|
|
391
|
+
type: string;
|
|
392
|
+
};
|
|
393
|
+
};
|
|
394
|
+
required: string[];
|
|
395
|
+
additionalProperties: boolean;
|
|
396
|
+
};
|
|
397
|
+
TokenUsage: {
|
|
398
|
+
type: string;
|
|
399
|
+
properties: {
|
|
400
|
+
input_tokens: {
|
|
401
|
+
type: string;
|
|
402
|
+
minimum: number;
|
|
403
|
+
};
|
|
404
|
+
output_tokens: {
|
|
405
|
+
type: string;
|
|
406
|
+
minimum: number;
|
|
407
|
+
};
|
|
408
|
+
cache_read_input_tokens: {
|
|
409
|
+
type: string;
|
|
410
|
+
minimum: number;
|
|
411
|
+
};
|
|
412
|
+
cache_creation_input_tokens: {
|
|
413
|
+
type: string;
|
|
414
|
+
minimum: number;
|
|
415
|
+
};
|
|
416
|
+
reasoning_tokens: {
|
|
417
|
+
type: string;
|
|
418
|
+
minimum: number;
|
|
419
|
+
};
|
|
420
|
+
total_tokens: {
|
|
421
|
+
type: string;
|
|
422
|
+
minimum: number;
|
|
423
|
+
};
|
|
424
|
+
};
|
|
425
|
+
additionalProperties: boolean;
|
|
426
|
+
};
|
|
427
|
+
EventRole: {
|
|
428
|
+
enum: string[];
|
|
429
|
+
};
|
|
430
|
+
TraceEvent: {
|
|
431
|
+
type: string;
|
|
432
|
+
properties: {
|
|
433
|
+
index: {
|
|
434
|
+
type: string;
|
|
435
|
+
minimum: number;
|
|
436
|
+
};
|
|
437
|
+
role: {
|
|
438
|
+
$ref: string;
|
|
439
|
+
};
|
|
440
|
+
text: {
|
|
441
|
+
type: string;
|
|
442
|
+
};
|
|
443
|
+
timestamp: {
|
|
444
|
+
type: string[];
|
|
445
|
+
};
|
|
446
|
+
tool_name: {
|
|
447
|
+
type: string;
|
|
448
|
+
};
|
|
449
|
+
tool_call_id: {
|
|
450
|
+
type: string;
|
|
451
|
+
};
|
|
452
|
+
ok: {
|
|
453
|
+
type: string;
|
|
454
|
+
};
|
|
455
|
+
};
|
|
456
|
+
required: string[];
|
|
457
|
+
additionalProperties: boolean;
|
|
458
|
+
};
|
|
459
|
+
TraceMetadata: {
|
|
460
|
+
type: string;
|
|
461
|
+
properties: {
|
|
462
|
+
cwd: {
|
|
463
|
+
type: string;
|
|
464
|
+
};
|
|
465
|
+
git_branch: {
|
|
466
|
+
type: string;
|
|
467
|
+
};
|
|
468
|
+
model: {
|
|
469
|
+
type: string;
|
|
470
|
+
};
|
|
471
|
+
parent_session_id: {
|
|
472
|
+
type: string;
|
|
473
|
+
};
|
|
474
|
+
continuation: {
|
|
475
|
+
$ref: string;
|
|
476
|
+
};
|
|
477
|
+
normalizer: {
|
|
478
|
+
$ref: string;
|
|
479
|
+
};
|
|
480
|
+
};
|
|
481
|
+
additionalProperties: boolean;
|
|
482
|
+
};
|
|
483
|
+
};
|
|
484
|
+
};
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type { AllChangesPage, ChangesPage, Fetch, Identity, IngestOptions, IngestResult, ListSessionsOptions, ReadChangesOptions, SessionDB, SessionsPage, SessionUpload, ShippedPrefix, ShippedState, StaleSession, StaleSessionsPage, StorageView, StoredTrace, StoreSessionResult, Upload, } from "./api.js";
|
|
2
|
+
export { EMPTY_PREFIX_SHA256, isStub, MAX_IDEMPOTENCY_KEY_LENGTH } from "./api.js";
|
|
3
|
+
export type { Authorization, Authorizer } from "./authz.js";
|
|
4
|
+
export { canonicalText, stripNul } from "./canonical.js";
|
|
5
|
+
export { Forbidden, IngestRejected, OffsetMismatch, SessionConflict, SessionRejected, StoreError, Unauthorized, } from "./errors.js";
|
|
6
|
+
export type { Chunk, DocumentHead, FormatAdapter, FormatDetection, HeadValue, JsonObject, NormalizedTranscript, } from "./format-adapter.js";
|
|
7
|
+
export type { Caller, Envelope, LogPayload, Payload, SpanPayload, } from "./generated/envelope.js";
|
|
8
|
+
export { SCHEMA_ID as ENVELOPE_SCHEMA } from "./generated/envelope.js";
|
|
9
|
+
export { type ParseOptions, parseTrace } from "./parse.js";
|
|
10
|
+
export { canonicalJson, PrefixHash, prefixSha256, ResumableSha256 } from "./prefix-hash.js";
|
|
11
|
+
export type { OtlpAnyValue, OtlpKeyValue, OtlpSpan, OtlpSpanKind, OtlpStatus, OtlpTrace, } from "./schemas/otlp.js";
|
|
12
|
+
export { OTLP_TRACE_SCHEMA } from "./schemas/otlp.js";
|
|
13
|
+
export type { AtifDocument, AtifStep, LettaTrace, RenderedTrace, RenderedTraces, RenderFormat, } from "./schemas/renders.js";
|
|
14
|
+
export { isRenderFormat, LETTA_TRACE_SCHEMA, RENDER_FORMATS } from "./schemas/renders.js";
|
|
15
|
+
export type { AppliedEnvelope, BucketMode, CallerKind, ChangeEntry, ChangeKind, Claims, DroppedPrefix, LayoutMarker, LogEncoding, NormalizedState, Normalizer, OwnerBasis, Provenance, RawFormat, RedactionSummary, SessionMetadata, SessionStatus, SessionTraceRef, Sha256, SourceId, SourceKind, SourceLocation, Timestamp, TombstoneReason, Visibility, Writer, } from "./schemas/store.js";
|
|
16
|
+
export { CHANGE_SCHEMA, LAYOUT_SCHEMA, LAYOUT_SCHEMA_V1, LAYOUT_SCHEMAS, LEGACY_LAYOUT_SCHEMA, localWriter, METADATA_SCHEMA, UPLOAD_SOURCE, } from "./schemas/store.js";
|
|
17
|
+
export type { Continuation, EventRole, LlmCall, TokenUsage, Trace, TraceAssistantRecord, TraceEvent, TraceMetadata, TraceMetaRecord, TraceRecord, TraceTextRecord, TraceToolCall, TraceToolResultRecord, } from "./schemas/trace.js";
|
|
18
|
+
export { TRACE_SCHEMA } from "./schemas/trace.js";
|
|
19
|
+
export type { AssistantMessageRecord, AssistantToolCallRecord, MetaRecord, NormalizedRecord, ObservationRecord, ReasoningRecord, SystemRecord, ToolCall, ToolResultRecord, UserRecord, } from "./schemas/trajectory.js";
|
|
20
|
+
export { isScopeCoordinate, TrajectoryError, validateRecords, validateTraceRecords, } from "./schemas/trajectory.js";
|
|
21
|
+
export { type SchemaFile, schemaProblems } from "./schemas/validate.js";
|
|
22
|
+
export { SEARCH_SORTS, type SearchIndexState, type SearchMatch, type SearchRequest, type SearchResult, type SearchResults, type SearchSort, } from "./search.js";
|
|
23
|
+
export type { AssembledSpans, ReceivedSpan, SpanAdapter, SpanAttribute, SpanEvent, SpanLink, SpanPart, SpanResource, SpanStatus, SpanTool, SpanValue, } from "./spans.js";
|
|
24
|
+
export { VERSION } from "./version.js";
|
package/types/parse.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Provenance } from "./schemas/store.js";
|
|
2
|
+
import { type LlmCall, type Trace, type TraceMetadata } from "./schemas/trace.js";
|
|
3
|
+
export interface ParseOptions {
|
|
4
|
+
/** The harness name; defaults to the meta record's `source`. */
|
|
5
|
+
agent?: string;
|
|
6
|
+
session_id?: string;
|
|
7
|
+
/** Merged over the meta record's `cwd` / `git_branch` / `model`. */
|
|
8
|
+
metadata?: TraceMetadata;
|
|
9
|
+
project?: string;
|
|
10
|
+
branch?: string;
|
|
11
|
+
/** The LLM calls the records' `llm_call` fields name. */
|
|
12
|
+
llm_calls?: readonly LlmCall[];
|
|
13
|
+
/** Where the data came from. */
|
|
14
|
+
provenance?: Provenance;
|
|
15
|
+
}
|
|
16
|
+
/** Validate, strip NUL, derive events, hash. Throws `TrajectoryError` for anything that is not
|
|
17
|
+
* a trace. */
|
|
18
|
+
export declare function parseTrace(input: unknown, options?: ParseOptions): Trace;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** The prefix hash of a session's records, grown a chunk at a time.
|
|
2
|
+
*
|
|
3
|
+
* `prefix_sha256` is the sha256 of the canonical JSON of a session's records, and every answer
|
|
4
|
+
* carries it for the whole session so far. A whole upload has the records in hand and hashes
|
|
5
|
+
* them; a chunk does not have the ones before it, so the hash is carried between chunks as
|
|
6
|
+
* state instead: the sha256 mid-stream, after the records so far, saved in `metadata.json` and
|
|
7
|
+
* resumed for the next chunk. `node:crypto` cannot export a hash mid-stream, so this is its own
|
|
8
|
+
* SHA-256 (FIPS 180-4), checked against `node:crypto` in its tests. The result is the same
|
|
9
|
+
* `prefixSha256` a whole upload computes, so a client can go from chunks to a whole upload with
|
|
10
|
+
* `shipped` and still be continued. */
|
|
11
|
+
import type { NormalizedRecord } from "./schemas/trajectory.js";
|
|
12
|
+
/** JSON with object keys sorted at every level, so equal records always hash equally. */
|
|
13
|
+
export declare function canonicalJson(value: unknown): string;
|
|
14
|
+
/** sha256 (hex) of the canonical JSON of records[0:count]: a session's `prefix_sha256`. */
|
|
15
|
+
export declare function prefixSha256(records: readonly NormalizedRecord[], count: number): string;
|
|
16
|
+
/** SHA-256 whose state can be saved and resumed. */
|
|
17
|
+
export declare class ResumableSha256 {
|
|
18
|
+
private h;
|
|
19
|
+
private readonly block;
|
|
20
|
+
private pending;
|
|
21
|
+
private total;
|
|
22
|
+
private readonly w;
|
|
23
|
+
update(data: Uint8Array): this;
|
|
24
|
+
/** The digest of everything so far, in hex; hashing can go on after. */
|
|
25
|
+
digest(): string;
|
|
26
|
+
/** The state, as one string for `resume`. */
|
|
27
|
+
export(): string;
|
|
28
|
+
static resume(state: string): ResumableSha256;
|
|
29
|
+
private clone;
|
|
30
|
+
private compress;
|
|
31
|
+
}
|
|
32
|
+
/** `prefixSha256` of a record list, one record at a time, resumable between chunks. The digest
|
|
33
|
+
* after `n` records equals `prefixSha256(records, n)`. */
|
|
34
|
+
export declare class PrefixHash {
|
|
35
|
+
private readonly hash;
|
|
36
|
+
private count;
|
|
37
|
+
private constructor();
|
|
38
|
+
static empty(): PrefixHash;
|
|
39
|
+
/** The hash after `records`. */
|
|
40
|
+
static of(records: readonly unknown[]): PrefixHash;
|
|
41
|
+
/** Resume from `export()`. */
|
|
42
|
+
static resume(state: string): PrefixHash;
|
|
43
|
+
get records(): number;
|
|
44
|
+
append(record: unknown): void;
|
|
45
|
+
digest(): string;
|
|
46
|
+
export(): string;
|
|
47
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** OTLP/HTTP JSON, the subset the OTLP rendering of a trace uses: one
|
|
2
|
+
* `ExportTraceServiceRequest`, as `opentelemetry-proto`'s JSON mapping writes it (ids as
|
|
3
|
+
* lowercase hex, times as decimal strings of Unix nanoseconds, enums as integers). A rendering
|
|
4
|
+
* can be POSTed as-is to any collector's `/v1/traces`. */
|
|
5
|
+
/** The `seshi.schema` resource attribute of an OTLP rendering. */
|
|
6
|
+
export declare const OTLP_TRACE_SCHEMA: "seshi/trace-otlp/1";
|
|
7
|
+
export type OtlpAnyValue = {
|
|
8
|
+
stringValue: string;
|
|
9
|
+
} | {
|
|
10
|
+
boolValue: boolean;
|
|
11
|
+
} | {
|
|
12
|
+
intValue: string;
|
|
13
|
+
} | {
|
|
14
|
+
doubleValue: number;
|
|
15
|
+
};
|
|
16
|
+
export interface OtlpKeyValue {
|
|
17
|
+
key: string;
|
|
18
|
+
value: OtlpAnyValue;
|
|
19
|
+
}
|
|
20
|
+
/** `SPAN_KIND_INTERNAL` = 1, `SPAN_KIND_CLIENT` = 3. */
|
|
21
|
+
export type OtlpSpanKind = 1 | 3;
|
|
22
|
+
/** `STATUS_CODE_UNSET` = 0, `STATUS_CODE_OK` = 1, `STATUS_CODE_ERROR` = 2. */
|
|
23
|
+
export interface OtlpStatus {
|
|
24
|
+
code: 0 | 1 | 2;
|
|
25
|
+
message?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface OtlpSpan {
|
|
28
|
+
traceId: string;
|
|
29
|
+
spanId: string;
|
|
30
|
+
parentSpanId?: string;
|
|
31
|
+
name: string;
|
|
32
|
+
kind: OtlpSpanKind;
|
|
33
|
+
startTimeUnixNano: string;
|
|
34
|
+
endTimeUnixNano: string;
|
|
35
|
+
attributes: OtlpKeyValue[];
|
|
36
|
+
status: OtlpStatus;
|
|
37
|
+
}
|
|
38
|
+
export interface OtlpTrace {
|
|
39
|
+
resourceSpans: {
|
|
40
|
+
resource: {
|
|
41
|
+
attributes: OtlpKeyValue[];
|
|
42
|
+
};
|
|
43
|
+
scopeSpans: {
|
|
44
|
+
scope: {
|
|
45
|
+
name: string;
|
|
46
|
+
version: string;
|
|
47
|
+
};
|
|
48
|
+
spans: OtlpSpan[];
|
|
49
|
+
}[];
|
|
50
|
+
}[];
|
|
51
|
+
}
|