@yaklabs-ai/plugin-sdk 0.13.6 → 0.13.8

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.
@@ -0,0 +1,310 @@
1
+ /** Builds a {@link TranscriptReview} from a session's records streamed in commit order. */
2
+ export declare function createTranscriptReview(options?: TranscriptReviewOptions): TranscriptReviewBuilder;
3
+
4
+ /** An instant as UTC ISO-8601 with milliseconds (`2026-10-15T07:00:00.000Z`). */
5
+ export declare function formatReviewInstant(ms: number): string;
6
+
7
+ declare type Obj = Readonly<Record<string, unknown>>;
8
+
9
+ /** A content array's blocks; a string content is one text block. */
10
+ export declare function reviewContentBlocks(content: unknown): readonly Obj[];
11
+
12
+ /** The text blocks of a content value, joined by newlines. */
13
+ export declare function reviewContentText(content: unknown): string;
14
+
15
+ /** A context record's `{customType, details, content}`, from either stored spelling. */
16
+ export declare function reviewContextOf(entry: unknown): {
17
+ readonly customType?: string;
18
+ readonly details?: Obj;
19
+ readonly content: unknown;
20
+ } | undefined;
21
+
22
+ /** What one entry is, read without a fold (also what the fold records per entry). */
23
+ export declare interface ReviewEntryDescription {
24
+ readonly entryId?: string;
25
+ /** The stored-transcript kind (`user`, `tool_result`, `custom_message:<t>`, `custom:<t>`, ...). */
26
+ readonly kind: string;
27
+ readonly recordClass: TranscriptReviewRecordClass;
28
+ /** A context record's or custom entry's type. */
29
+ readonly customType?: string;
30
+ /** The record's own time: the message timestamp, else the entry's, else a run marker's. */
31
+ readonly timestampMs?: number;
32
+ /** A human message's `clientIntentId`; a context record's `details.clientIntentId`. */
33
+ readonly clientIntentId?: string;
34
+ }
35
+
36
+ /**
37
+ * Epoch ms from a number or an ISO-8601 instant with an offset (`2026-10-15T07:00:00Z`);
38
+ * `undefined` otherwise. Stored entries carry either, by generation.
39
+ */
40
+ export declare function reviewInstantMs(value: unknown): number | undefined;
41
+
42
+ /** Records that hold system prompt content: never expanded, never shown. */
43
+ export declare const SYSTEM_PROMPT_CUSTOM_TYPES: ReadonlySet<string>;
44
+
45
+ /**
46
+ * Context records that carry a task or its result, and that a reader of a span must see:
47
+ * a child's report, a collaborator's message, a finished background task, a person's answer
48
+ * delivered as context (`ui_action`), pasted content, a sent draft, a service turn. Only these
49
+ * may open a span when they carry the opening input's id. `dynamic_context` also carries
50
+ * `details.clientIntentId` and is never one of them.
51
+ */
52
+ export declare const TASK_CONTEXT_TYPES: ReadonlySet<string>;
53
+
54
+ /** One `toolCall` block of an assistant message. */
55
+ export declare interface ToolCallAttempt {
56
+ /** 0-based, in store order. */
57
+ readonly index: number;
58
+ readonly position: number;
59
+ readonly entryId?: string;
60
+ /** The block's index in the message content. */
61
+ readonly block: number;
62
+ readonly toolCallId?: string;
63
+ readonly tool: string;
64
+ /**
65
+ * A label for the call: `command` for shell tools, else `path` / `uri` / `url`, else
66
+ * `command`. At most {@link ATTEMPT_SUBJECT_MAX_CHARS} characters, so a fold over a long
67
+ * session never holds whole commands; the full call is one `&entry=` read away.
68
+ */
69
+ readonly subject?: string;
70
+ /** The subject's full length in characters, when it was cut to the label limit. */
71
+ readonly subjectLength?: number;
72
+ /** Every string argument value (at any depth) that starts with `<scheme>://`. */
73
+ readonly uris: readonly string[];
74
+ /** Position of the result paired to it. */
75
+ readonly result?: number;
76
+ /** Results that answered its id again after it was paired. */
77
+ readonly extraResults: readonly number[];
78
+ /** Results that matched it among several open attempts. */
79
+ readonly ambiguousResults: readonly number[];
80
+ }
81
+
82
+ export declare interface ToolCallOutcome {
83
+ /** `ambiguous` when a result matched it among several open attempts and none was paired. */
84
+ readonly status: "ok" | "failed" | "no-result" | "ambiguous";
85
+ readonly isError: boolean;
86
+ readonly exitCode?: number;
87
+ readonly timedOut: boolean;
88
+ readonly resultPosition?: number;
89
+ readonly resultEntryId?: string;
90
+ readonly firstErrorLine?: string;
91
+ }
92
+
93
+ /** One tool result record. */
94
+ export declare interface ToolResultFact {
95
+ readonly position: number;
96
+ readonly entryId?: string;
97
+ readonly toolCallId?: string;
98
+ readonly tool?: string;
99
+ readonly pairing: ToolResultPairing;
100
+ /** The paired attempt (`paired`), or the answered attempt (`extra`). */
101
+ readonly attempt?: number;
102
+ /** The open attempts it matched (`ambiguous`). */
103
+ readonly candidates: readonly number[];
104
+ readonly isError: boolean;
105
+ /** A shell tool's `details.exitCode`. */
106
+ readonly exitCode?: number;
107
+ readonly timedOut: boolean;
108
+ /** isError, a non-zero exit code, or a time-out. */
109
+ readonly failed: boolean;
110
+ /** The first error line of a failed result (see {@link firstErrorLine}). */
111
+ readonly firstErrorLine?: string;
112
+ }
113
+
114
+ /** Where a tool result's pairing landed. */
115
+ export declare type ToolResultPairing =
116
+ /** The single earlier open attempt with its id. */
117
+ "paired"
118
+ /** Its id's attempt was already answered: a further result. */
119
+ | "extra"
120
+ /** Several attempts with its id were open: not paired. */
121
+ | "ambiguous"
122
+ /** No earlier attempt carried its id (a result before its call). */
123
+ | "orphan"
124
+ /** The result carries no `toolCallId`. */
125
+ | "no-id";
126
+
127
+ /** The finished fold over one session. */
128
+ export declare interface TranscriptReview {
129
+ readonly records: readonly TranscriptReviewRecord[];
130
+ /** The first record at or after the time bound; it and everything after are invisible. */
131
+ readonly cutAt?: {
132
+ readonly position: number;
133
+ readonly entryId?: string;
134
+ readonly timestampMs: number;
135
+ };
136
+ readonly untilMs?: number;
137
+ readonly inputs: readonly TranscriptReviewRunInput[];
138
+ readonly runs: ReadonlyMap<string, TranscriptReviewRun>;
139
+ /** The store has run records; without them spans fall back to human-verified messages. */
140
+ readonly hasRuns: boolean;
141
+ readonly spans: readonly TranscriptReviewSpan[];
142
+ readonly attempts: readonly ToolCallAttempt[];
143
+ readonly results: readonly ToolResultFact[];
144
+ /** One past the last visible position. */
145
+ readonly endPosition: number;
146
+ recordAt(position: number): TranscriptReviewRecord | undefined;
147
+ recordOfEntry(entryId: string): TranscriptReviewRecord | undefined;
148
+ /** The span whose own work holds this position; `undefined` before the first span. */
149
+ spanAt(position: number): TranscriptReviewSpan | undefined;
150
+ /** A run's own extent: its boundary to the next run's boundary (or the end). */
151
+ runExtent(runId: string): {
152
+ readonly start: number;
153
+ readonly end: number;
154
+ } | undefined;
155
+ /** The run input carrying this input id. */
156
+ inputById(inputId: string): TranscriptReviewRunInput | undefined;
157
+ attemptAt(position: number, block: number): ToolCallAttempt | undefined;
158
+ /** Every attempt of the assistant message at this position, in block order. */
159
+ attemptsAt(position: number): readonly ToolCallAttempt[];
160
+ resultAt(position: number): ToolResultFact | undefined;
161
+ /**
162
+ * An attempt's outcome. `uptoPosition` ignores a paired result after it (a range that ends
163
+ * before the answer reads `no-result`).
164
+ */
165
+ outcome(attempt: ToolCallAttempt, uptoPosition?: number): ToolCallOutcome;
166
+ }
167
+
168
+ export declare interface TranscriptReviewBuilder {
169
+ /** `"stop"` once the time bound is reached: this record and every later one are ignored. */
170
+ add(record: TranscriptReviewRecordInput): "continue" | "stop";
171
+ finish(): TranscriptReview;
172
+ }
173
+
174
+ /** Why a span's own work ends where it does. */
175
+ export declare type TranscriptReviewClose = "next-opener" | "next-opener-unresolved" | "time-bound" | "end-of-store";
176
+
177
+ export declare interface TranscriptReviewOpener {
178
+ readonly position: number;
179
+ readonly entryId?: string;
180
+ readonly customType?: string;
181
+ }
182
+
183
+ /** How a span's opener was found. */
184
+ export declare type TranscriptReviewOpenerVia =
185
+ /** A human-verified message whose `clientIntentId` equals the run's first input id. */
186
+ "message"
187
+ /** A task-bearing context record whose `details.clientIntentId` equals it (a card answer). */
188
+ | "context"
189
+ /** No record carries the first input id: the span exists, reachable by run. */
190
+ | "unresolved"
191
+ /** The store has no run records: each human-verified message opens a span. */
192
+ | "fallback";
193
+
194
+ export declare interface TranscriptReviewOptions {
195
+ /**
196
+ * Time bound in epoch milliseconds. The first record whose own timestamp is at or after it,
197
+ * and every record after that one, are invisible: `add` answers `"stop"` from then on.
198
+ */
199
+ readonly untilMs?: number;
200
+ }
201
+
202
+ /** The facts the fold keeps about one record. */
203
+ export declare interface TranscriptReviewRecord extends ReviewEntryDescription {
204
+ readonly position: number;
205
+ readonly messageLine?: number;
206
+ /** An assistant message with visible text (the "previous answer" a span shows). */
207
+ readonly hasProse: boolean;
208
+ }
209
+
210
+ /** What a record is, for review. Finer than the stored-transcript kind where review needs it. */
211
+ export declare type TranscriptReviewRecordClass =
212
+ /** A user-role message the daemon verified as a person's (`clientIntentId` + `details.deliveryId`). */
213
+ "human"
214
+ /** A user-role message of unrecorded origin (a joined steer's delivered text, an old log). */
215
+ | "user" | "assistant" | "tool_result"
216
+ /** A custom-role context message (`custom_message:<type>`). */
217
+ | "context"
218
+ /** A system-role message. */
219
+ | "system"
220
+ /** `session_run_started`, `session_run_input` or `session_run_state`. */
221
+ | "run_marker"
222
+ /** Any other custom entry: bookkeeping the model never sees. */
223
+ | "custom" | "compaction" | "branch_summary" | "other" | "unreadable";
224
+
225
+ /** One stored record, as a caller streams it in. */
226
+ export declare interface TranscriptReviewRecordInput {
227
+ /** 1-based, commit order, every record (the port's position). */
228
+ readonly position: number;
229
+ /** Its line in the default `sessions://<id>.jsonl` view, when it is one. */
230
+ readonly messageLine?: number;
231
+ /** The parsed stored entry; absent for a record that did not parse. */
232
+ readonly entry?: unknown;
233
+ }
234
+
235
+ /** One run, by id. */
236
+ export declare interface TranscriptReviewRun {
237
+ readonly runId: string;
238
+ readonly startedPosition?: number;
239
+ readonly firstInput?: TranscriptReviewRunInput;
240
+ /** The last `session_run_state` value seen, and where. */
241
+ readonly lastState?: {
242
+ readonly position: number;
243
+ readonly state?: string;
244
+ };
245
+ /**
246
+ * Where the run begins: the earliest of its start record, its first input and (for a run
247
+ * with neither) its first state record.
248
+ */
249
+ readonly boundary: number;
250
+ }
251
+
252
+ /** One `session_run_input` record. */
253
+ export declare interface TranscriptReviewRunInput {
254
+ readonly position: number;
255
+ readonly entryId?: string;
256
+ readonly runId?: string;
257
+ /** `prompt`, `steer`, `follow_up`, ... */
258
+ readonly channel?: string;
259
+ /** `human_send`, `queued_human`, `scheduled_wake`, ... */
260
+ readonly cause?: string;
261
+ readonly inputId?: string;
262
+ readonly acceptedAtMs?: number;
263
+ /** Its cause is one of {@link HUMAN_INPUT_CAUSES}. */
264
+ readonly human: boolean;
265
+ /** The first input of its run: it opened that run. Otherwise it JOINED a running run. */
266
+ readonly opensRun: boolean;
267
+ /** Position of the human-verified message whose `clientIntentId` equals `inputId`. */
268
+ readonly linkedMessage?: number;
269
+ /** Position of the task-bearing context record whose `details.clientIntentId` equals `inputId`. */
270
+ readonly linkedContext?: number;
271
+ }
272
+
273
+ /**
274
+ * One review span: from a person's run-opening input to the next one. It holds every later run
275
+ * (wakes, continuations) and every human input that joined a running run. A grouping for review,
276
+ * not a claim about causality.
277
+ */
278
+ export declare interface TranscriptReviewSpan {
279
+ /** 0-based, in store order. */
280
+ readonly index: number;
281
+ /**
282
+ * First position of the span's own work: its run's boundary, or the opener's position when
283
+ * the opener was stored before its run's markers.
284
+ */
285
+ readonly boundary: number;
286
+ /** One past the last position of its own work: the next span's boundary, or the end. */
287
+ readonly end: number;
288
+ /**
289
+ * One past the last position of the closing context: through the next span's opener when it
290
+ * resolved (that run's start and the person's next message, shown and not attributed), else
291
+ * equal to `end`.
292
+ */
293
+ readonly closingEnd: number;
294
+ readonly runId?: string;
295
+ readonly opener?: TranscriptReviewOpener;
296
+ readonly openerVia: TranscriptReviewOpenerVia;
297
+ /** The opening run's first input (the opener's own input). */
298
+ readonly firstInput?: TranscriptReviewRunInput;
299
+ /** Runs with a start record or an input inside the span's own work, in order. */
300
+ readonly ownRuns: readonly string[];
301
+ /** Runs with an input only in the closing context. */
302
+ readonly closingRuns: readonly string[];
303
+ /** Human inputs inside the span that joined a running run (steer, follow-up). */
304
+ readonly joined: readonly TranscriptReviewRunInput[];
305
+ readonly close: TranscriptReviewClose;
306
+ /** The last assistant message with visible text before the span. */
307
+ readonly previousAnswer?: number;
308
+ }
309
+
310
+ export { }