@leitwerk-dev/protocol 0.1.8 → 0.2.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/dist/api-token-contracts.d.ts +25 -0
- package/dist/api-token-contracts.d.ts.map +1 -0
- package/dist/{chunk-ABLI5SG5.js → chunk-J4VMD5ST.js} +17 -26
- package/dist/chunk-J4VMD5ST.js.map +1 -0
- package/dist/{chunk-J7LXDQAN.js → chunk-Z4IU6KEN.js} +40 -6
- package/dist/chunk-Z4IU6KEN.js.map +1 -0
- package/dist/compact-turn-summary.d.ts +31 -0
- package/dist/compact-turn-summary.d.ts.map +1 -0
- package/dist/config-snapshot.d.ts +2 -0
- package/dist/config-snapshot.d.ts.map +1 -1
- package/dist/config-snapshot.js +1 -1
- package/dist/config-snapshot.js.map +1 -1
- package/dist/extension-ui-contracts.d.ts +27 -0
- package/dist/extension-ui-contracts.d.ts.map +1 -0
- package/dist/form-contract.js +1 -1
- package/dist/form-contract.js.map +1 -1
- package/dist/{http-contracts-ClFoqwI3.d.ts → http-contracts-ht8DDU4J.d.ts} +152 -29
- package/dist/http-contracts.d.ts +98 -30
- package/dist/http-contracts.d.ts.map +1 -1
- package/dist/http-contracts.js +32 -432
- package/dist/http-contracts.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1196 -20
- package/dist/index.js.map +1 -1
- package/dist/initial-prompt.d.ts.map +1 -1
- package/dist/launcher-contract.js +1 -1
- package/dist/launcher-contract.js.map +1 -1
- package/dist/live-turn-projection.d.ts +1 -1
- package/dist/live-turn-projection.d.ts.map +1 -1
- package/dist/protocol.d.ts +63 -16
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +37 -259
- package/dist/protocol.js.map +1 -1
- package/dist/streamable-events.d.ts +1 -1
- package/dist/streamable-events.d.ts.map +1 -1
- package/dist/ticket-creation-contracts.d.ts +33 -0
- package/dist/ticket-creation-contracts.d.ts.map +1 -0
- package/dist/timeline-projection.d.ts +1 -1
- package/dist/timeline-projection.d.ts.map +1 -1
- package/dist/tool-renderer-contract.js +10 -21
- package/dist/tool-renderer-contract.js.map +1 -1
- package/dist/tool-result-truncation.d.ts +6 -0
- package/dist/tool-result-truncation.d.ts.map +1 -0
- package/dist/turn-continuation.d.ts +1 -1
- package/dist/turn-continuation.d.ts.map +1 -1
- package/dist/turn-trace-projection.d.ts +5 -0
- package/dist/turn-trace-projection.d.ts.map +1 -0
- package/dist/usage-snapshot.d.ts +3 -1
- package/dist/usage-snapshot.d.ts.map +1 -1
- package/dist/ws-event-payloads.d.ts +2 -1
- package/dist/ws-event-payloads.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/api-token-contracts.ts +24 -0
- package/src/compact-turn-summary.ts +119 -0
- package/src/config-snapshot.ts +2 -0
- package/src/extension-ui-contracts.ts +45 -0
- package/src/http-contracts.ts +128 -59
- package/src/index.ts +5 -0
- package/src/initial-prompt.ts +3 -6
- package/src/live-turn-projection.ts +41 -113
- package/src/protocol.ts +52 -12
- package/src/streamable-events.ts +2 -0
- package/src/ticket-creation-contracts.ts +34 -0
- package/src/timeline-projection.ts +5 -1
- package/src/tool-result-truncation.ts +94 -0
- package/src/turn-continuation.ts +22 -46
- package/src/turn-trace-projection.ts +42 -0
- package/src/usage-snapshot.ts +25 -59
- package/src/ws-event-payloads.ts +5 -14
- package/dist/chunk-ABLI5SG5.js.map +0 -1
- package/dist/chunk-J7LXDQAN.js.map +0 -1
- package/dist/external-review.js +0 -2
- package/dist/external-review.js.map +0 -1
- package/dist/initial-prompt.js +0 -103
- package/dist/initial-prompt.js.map +0 -1
- package/dist/live-turn-projection.js +0 -395
- package/dist/live-turn-projection.js.map +0 -1
- package/dist/pi-session-message.js +0 -27
- package/dist/pi-session-message.js.map +0 -1
- package/dist/primary-path-snapshot.js +0 -2
- package/dist/primary-path-snapshot.js.map +0 -1
- package/dist/session-entry-tree.js +0 -42
- package/dist/session-entry-tree.js.map +0 -1
- package/dist/streamable-events.js +0 -17
- package/dist/streamable-events.js.map +0 -1
- package/dist/text-preview.js +0 -23
- package/dist/text-preview.js.map +0 -1
- package/dist/timeline-projection.js +0 -30
- package/dist/timeline-projection.js.map +0 -1
- package/dist/timestamp-ordering.js +0 -15
- package/dist/timestamp-ordering.js.map +0 -1
- package/dist/turn-continuation.js +0 -179
- package/dist/turn-continuation.js.map +0 -1
- package/dist/usage-by-turn-record.js +0 -25
- package/dist/usage-by-turn-record.js.map +0 -1
- package/dist/usage-snapshot.js +0 -120
- package/dist/usage-snapshot.js.map +0 -1
- package/dist/ws-event-payloads.js +0 -47
- package/dist/ws-event-payloads.js.map +0 -1
package/src/turn-continuation.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
isPiSessionMessageEntryType,
|
|
5
5
|
isPiSessionMessageEntryWithRecord,
|
|
6
6
|
} from "./pi-session-message.js";
|
|
7
|
-
import {
|
|
7
|
+
import type { ReadonlyEntryTree } from "./session-entry-tree.js";
|
|
8
8
|
import { compareTimestampStrings, happenedOnOrAfterStart } from "./timestamp-ordering.js";
|
|
9
9
|
|
|
10
10
|
export interface ContinuationTreeEntry {
|
|
@@ -37,12 +37,6 @@ export interface TurnContinuationIndex<TEntry extends ContinuationTreeEntry> {
|
|
|
37
37
|
buildSlice(turnRecord: ContinuationTurnRecordLike, bounds?: ContinuationSliceBounds): TEntry[];
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
function createEntriesById(
|
|
41
|
-
entries: readonly ContinuationTreeEntry[],
|
|
42
|
-
): Map<string, ContinuationTreeEntry> {
|
|
43
|
-
return new Map(entries.map((entry) => [entry.id, entry]));
|
|
44
|
-
}
|
|
45
|
-
|
|
46
40
|
function branchContainsAncestor(
|
|
47
41
|
entriesById: ReadonlyMap<string, ContinuationTreeEntry>,
|
|
48
42
|
entryId: string,
|
|
@@ -70,10 +64,16 @@ function happenedOnOrBeforeEnd(entryTimestamp: string, endedAt: string | null):
|
|
|
70
64
|
return compareTimestampStrings(entryTimestamp, endedAt) <= 0;
|
|
71
65
|
}
|
|
72
66
|
|
|
73
|
-
function
|
|
67
|
+
function isContinuableEntryWithinBounds(
|
|
74
68
|
entry: ContinuationTreeEntry | undefined,
|
|
69
|
+
startedAt: string | null,
|
|
70
|
+
endedAt: string | null,
|
|
75
71
|
): entry is ContinuationTreeEntry {
|
|
76
|
-
return
|
|
72
|
+
return (
|
|
73
|
+
(isPiSessionMessageEntryType(entry) || entry?.type === "compaction") &&
|
|
74
|
+
happenedOnOrAfterStart(entry.timestamp, startedAt) &&
|
|
75
|
+
happenedOnOrBeforeEnd(entry.timestamp, endedAt)
|
|
76
|
+
);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
function isExplicitLeafUsable(
|
|
@@ -84,19 +84,10 @@ function isExplicitLeafUsable(
|
|
|
84
84
|
endedAt: string | null,
|
|
85
85
|
): boolean {
|
|
86
86
|
const leafEntry = entriesById.get(leafId);
|
|
87
|
-
if (!
|
|
87
|
+
if (!isContinuableEntryWithinBounds(leafEntry, startedAt, endedAt)) {
|
|
88
88
|
return false;
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
if (!happenedOnOrBeforeEnd(leafEntry.timestamp, endedAt)) {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
if (!forkPiEntryId) {
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
return branchContainsAncestor(entriesById, leafId, forkPiEntryId);
|
|
90
|
+
return !forkPiEntryId || branchContainsAncestor(entriesById, leafId, forkPiEntryId);
|
|
100
91
|
}
|
|
101
92
|
|
|
102
93
|
function findLatestContinuableEntryIdOnBranch(
|
|
@@ -106,16 +97,7 @@ function findLatestContinuableEntryIdOnBranch(
|
|
|
106
97
|
): string | null {
|
|
107
98
|
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
108
99
|
const entry = entries[index];
|
|
109
|
-
if (!entry) {
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
if (!isContinuableEntryType(entry)) {
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
if (!happenedOnOrAfterStart(entry.timestamp, options.startedAt)) {
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
if (!happenedOnOrBeforeEnd(entry.timestamp, options.endedAt)) {
|
|
100
|
+
if (!isContinuableEntryWithinBounds(entry, options.startedAt, options.endedAt)) {
|
|
119
101
|
continue;
|
|
120
102
|
}
|
|
121
103
|
if (options.ancestorId && !branchContainsAncestor(entriesById, entry.id, options.ancestorId)) {
|
|
@@ -126,11 +108,6 @@ function findLatestContinuableEntryIdOnBranch(
|
|
|
126
108
|
return null;
|
|
127
109
|
}
|
|
128
110
|
|
|
129
|
-
function readMessageRole(entry: ContinuationTreeEntry | undefined): string | null {
|
|
130
|
-
const role = entry?.message?.role;
|
|
131
|
-
return typeof role === "string" && role.trim() !== "" ? role : null;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
111
|
function resolveTurnContinuationLeafEntryIdFromIndex(
|
|
135
112
|
entries: readonly ContinuationTreeEntry[],
|
|
136
113
|
entriesById: ReadonlyMap<string, ContinuationTreeEntry>,
|
|
@@ -165,14 +142,13 @@ function resolveTurnContinuationLeafEntryIdFromIndex(
|
|
|
165
142
|
export function createTurnContinuationIndex<TEntry extends ContinuationTreeEntry>(
|
|
166
143
|
entries: readonly TEntry[],
|
|
167
144
|
): TurnContinuationIndex<TEntry> {
|
|
168
|
-
const
|
|
169
|
-
const entriesById = createEntriesById(orderedEntries);
|
|
145
|
+
const entriesById = new Map(entries.map((entry) => [entry.id, entry]));
|
|
170
146
|
|
|
171
147
|
const resolveLeafEntryId = (
|
|
172
148
|
turnRecord: ContinuationTurnRecordLike,
|
|
173
149
|
bounds: ContinuationSliceBounds = {},
|
|
174
150
|
): string | null =>
|
|
175
|
-
resolveTurnContinuationLeafEntryIdFromIndex(
|
|
151
|
+
resolveTurnContinuationLeafEntryIdFromIndex(entries, entriesById, turnRecord, bounds);
|
|
176
152
|
|
|
177
153
|
const buildSlice = (
|
|
178
154
|
turnRecord: ContinuationTurnRecordLike,
|
|
@@ -185,7 +161,7 @@ export function createTurnContinuationIndex<TEntry extends ContinuationTreeEntry
|
|
|
185
161
|
const forkPiEntryId = trimToNull(turnRecord.forkPiEntryId);
|
|
186
162
|
const reversedSlice: TEntry[] = [];
|
|
187
163
|
const visited = new Set<string>();
|
|
188
|
-
let current = entriesById.get(continuationLeafId)
|
|
164
|
+
let current = entriesById.get(continuationLeafId);
|
|
189
165
|
let foundFork = forkPiEntryId === null;
|
|
190
166
|
while (current && !visited.has(current.id)) {
|
|
191
167
|
visited.add(current.id);
|
|
@@ -194,9 +170,7 @@ export function createTurnContinuationIndex<TEntry extends ContinuationTreeEntry
|
|
|
194
170
|
break;
|
|
195
171
|
}
|
|
196
172
|
reversedSlice.push(current);
|
|
197
|
-
current = current.parentId
|
|
198
|
-
? (entriesById.get(current.parentId) as TEntry | undefined)
|
|
199
|
-
: undefined;
|
|
173
|
+
current = current.parentId ? entriesById.get(current.parentId) : undefined;
|
|
200
174
|
}
|
|
201
175
|
if (!foundFork) {
|
|
202
176
|
return [];
|
|
@@ -236,7 +210,7 @@ export function buildTurnContinuationSlice<TEntry extends ContinuationTreeEntry>
|
|
|
236
210
|
turnRecord: ContinuationTurnRecordLike,
|
|
237
211
|
bounds: ContinuationSliceBounds = {},
|
|
238
212
|
): TEntry[] {
|
|
239
|
-
return
|
|
213
|
+
return createTurnContinuationIndex(entries).buildSlice(turnRecord, bounds);
|
|
240
214
|
}
|
|
241
215
|
|
|
242
216
|
export interface BranchUserPromptSnapshot {
|
|
@@ -254,7 +228,7 @@ export function extractFirstUserPromptOnBranch<TEntry extends ContinuationTreeEn
|
|
|
254
228
|
}
|
|
255
229
|
const branch = tree.getBranch(resolvedLeafId);
|
|
256
230
|
for (const entry of branch) {
|
|
257
|
-
if (!isPiSessionMessageEntryWithRecord(entry) ||
|
|
231
|
+
if (!isPiSessionMessageEntryWithRecord(entry) || entry.message.role !== "user") {
|
|
258
232
|
continue;
|
|
259
233
|
}
|
|
260
234
|
const text = extractPiSessionMessageText(entry.message.content).trim();
|
|
@@ -278,10 +252,12 @@ export function resolveTurnContinuationUserPrompt(
|
|
|
278
252
|
if (!continuationLeafId) {
|
|
279
253
|
return null;
|
|
280
254
|
}
|
|
281
|
-
const continuationLeaf =
|
|
255
|
+
const continuationLeaf = new Map(entries.map((entry) => [entry.id, entry])).get(
|
|
256
|
+
continuationLeafId,
|
|
257
|
+
);
|
|
282
258
|
if (
|
|
283
259
|
!isPiSessionMessageEntryWithRecord(continuationLeaf) ||
|
|
284
|
-
|
|
260
|
+
continuationLeaf.message.role !== "user"
|
|
285
261
|
) {
|
|
286
262
|
return null;
|
|
287
263
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { TurnTraceSnapshot } from "./http-contracts.js";
|
|
2
|
+
import {
|
|
3
|
+
type MutableLiveTurnProjection,
|
|
4
|
+
snapshotLiveTurnProjection,
|
|
5
|
+
} from "./live-turn-projection.js";
|
|
6
|
+
import { extractPiSessionMessageText } from "./pi-session-message.js";
|
|
7
|
+
import { isToolResultTruncated } from "./tool-result-truncation.js";
|
|
8
|
+
|
|
9
|
+
/** Share the recorded tool content presentation between live HTTP history and live frames. */
|
|
10
|
+
export function snapshotTurnTrace(
|
|
11
|
+
projection: MutableLiveTurnProjection,
|
|
12
|
+
piInput: TurnTraceSnapshot["piInput"] = null,
|
|
13
|
+
): TurnTraceSnapshot {
|
|
14
|
+
const snapshot = snapshotLiveTurnProjection(projection);
|
|
15
|
+
return {
|
|
16
|
+
...snapshot,
|
|
17
|
+
piInput,
|
|
18
|
+
toolCalls: snapshot.toolCalls.map(({ result, ...tool }) => {
|
|
19
|
+
const record =
|
|
20
|
+
result && typeof result === "object" ? (result as Record<string, unknown>) : null;
|
|
21
|
+
const resultText =
|
|
22
|
+
result == null
|
|
23
|
+
? null
|
|
24
|
+
: typeof result === "string"
|
|
25
|
+
? result
|
|
26
|
+
: record && "content" in record
|
|
27
|
+
? extractPiSessionMessageText(record.content)
|
|
28
|
+
: JSON.stringify(result, null, 2);
|
|
29
|
+
return {
|
|
30
|
+
...tool,
|
|
31
|
+
resultText,
|
|
32
|
+
truncated:
|
|
33
|
+
("truncated" in tool && tool.truncated === true) ||
|
|
34
|
+
isToolResultTruncated({
|
|
35
|
+
resultText,
|
|
36
|
+
resultDetails: record?.details,
|
|
37
|
+
resultValue: result,
|
|
38
|
+
}),
|
|
39
|
+
};
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
42
|
+
}
|
package/src/usage-snapshot.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { copiedUnknownRecordSchema as unknownRecordSchema } from "@leitwerk-dev/domain";
|
|
1
2
|
import * as v from "valibot";
|
|
2
3
|
|
|
3
4
|
export interface UsageCostSnapshot {
|
|
@@ -8,7 +9,7 @@ export interface UsageCostSnapshot {
|
|
|
8
9
|
total: number;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
export interface
|
|
12
|
+
export interface UsageTokenCounts {
|
|
12
13
|
input: number;
|
|
13
14
|
output: number;
|
|
14
15
|
/** Provider-reported reasoning/thinking tokens. This is a subset of output tokens. */
|
|
@@ -16,6 +17,9 @@ export interface UsageSnapshot {
|
|
|
16
17
|
cacheRead: number;
|
|
17
18
|
cacheWrite: number;
|
|
18
19
|
totalTokens: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface UsageSnapshot extends UsageTokenCounts {
|
|
19
23
|
cost: UsageCostSnapshot | null;
|
|
20
24
|
/** Number of model requests represented by this aggregate, when known. */
|
|
21
25
|
requestCount?: number;
|
|
@@ -23,17 +27,8 @@ export interface UsageSnapshot {
|
|
|
23
27
|
maxInputTokens?: number;
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
v.check(
|
|
29
|
-
(value) => typeof value === "object" && value !== null && !Array.isArray(value),
|
|
30
|
-
"Expected object",
|
|
31
|
-
),
|
|
32
|
-
v.record(v.string(), v.unknown()),
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
function readNumber(value: unknown): number {
|
|
36
|
-
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
30
|
+
function readFiniteNumber(value: unknown): number | undefined {
|
|
31
|
+
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
37
32
|
}
|
|
38
33
|
|
|
39
34
|
function normalizeUsageCostSnapshot(value: unknown): UsageCostSnapshot | null {
|
|
@@ -42,34 +37,26 @@ function normalizeUsageCostSnapshot(value: unknown): UsageCostSnapshot | null {
|
|
|
42
37
|
return null;
|
|
43
38
|
}
|
|
44
39
|
const record = parsedValue.output;
|
|
45
|
-
const input =
|
|
46
|
-
const output =
|
|
47
|
-
const cacheRead =
|
|
48
|
-
const cacheWrite =
|
|
49
|
-
const total =
|
|
50
|
-
typeof record.total === "number" && Number.isFinite(record.total)
|
|
51
|
-
? record.total
|
|
52
|
-
: input + output + cacheRead + cacheWrite;
|
|
40
|
+
const input = readFiniteNumber(record.input) ?? 0;
|
|
41
|
+
const output = readFiniteNumber(record.output) ?? 0;
|
|
42
|
+
const cacheRead = readFiniteNumber(record.cacheRead) ?? 0;
|
|
43
|
+
const cacheWrite = readFiniteNumber(record.cacheWrite) ?? 0;
|
|
53
44
|
return {
|
|
54
45
|
input,
|
|
55
46
|
output,
|
|
56
47
|
cacheRead,
|
|
57
48
|
cacheWrite,
|
|
58
|
-
total,
|
|
49
|
+
total: readFiniteNumber(record.total) ?? input + output + cacheRead + cacheWrite,
|
|
59
50
|
};
|
|
60
51
|
}
|
|
61
52
|
|
|
62
|
-
function cloneUsageCostSnapshot(cost: UsageCostSnapshot): UsageCostSnapshot {
|
|
63
|
-
return { ...cost };
|
|
64
|
-
}
|
|
65
|
-
|
|
66
53
|
export function cloneUsageSnapshot(usage: UsageSnapshot | null | undefined): UsageSnapshot | null {
|
|
67
54
|
if (!usage) {
|
|
68
55
|
return null;
|
|
69
56
|
}
|
|
70
57
|
return {
|
|
71
58
|
...usage,
|
|
72
|
-
cost: usage.cost ?
|
|
59
|
+
cost: usage.cost ? { ...usage.cost } : null,
|
|
73
60
|
};
|
|
74
61
|
}
|
|
75
62
|
|
|
@@ -79,39 +66,18 @@ export function normalizeUsageSnapshot(value: unknown): UsageSnapshot | null {
|
|
|
79
66
|
return null;
|
|
80
67
|
}
|
|
81
68
|
const record = parsedValue.output;
|
|
82
|
-
const input =
|
|
83
|
-
const output =
|
|
84
|
-
const reasoning =
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
: undefined;
|
|
88
|
-
const cacheRead = readNumber(record.cacheRead);
|
|
89
|
-
const cacheWrite = readNumber(record.cacheWrite);
|
|
90
|
-
const totalTokens =
|
|
91
|
-
typeof record.totalTokens === "number" && Number.isFinite(record.totalTokens)
|
|
92
|
-
? record.totalTokens
|
|
93
|
-
: input + output + cacheRead + cacheWrite;
|
|
69
|
+
const input = readFiniteNumber(record.input) ?? 0;
|
|
70
|
+
const output = readFiniteNumber(record.output) ?? 0;
|
|
71
|
+
const reasoning = readFiniteNumber(record.reasoning);
|
|
72
|
+
const cacheRead = readFiniteNumber(record.cacheRead) ?? 0;
|
|
73
|
+
const cacheWrite = readFiniteNumber(record.cacheWrite) ?? 0;
|
|
94
74
|
const cost = normalizeUsageCostSnapshot(record.cost);
|
|
95
|
-
const
|
|
96
|
-
typeof record.requestCount === "number" && Number.isFinite(record.requestCount)
|
|
97
|
-
? Math.max(0, Math.floor(record.requestCount))
|
|
98
|
-
: 1;
|
|
99
|
-
const maxInputTokens =
|
|
100
|
-
typeof record.maxInputTokens === "number" && Number.isFinite(record.maxInputTokens)
|
|
101
|
-
? Math.max(0, record.maxInputTokens)
|
|
102
|
-
: input;
|
|
75
|
+
const maxInputTokens = readFiniteNumber(record.maxInputTokens);
|
|
103
76
|
const hasExplicitUsageTelemetry =
|
|
104
77
|
["input", "output", "reasoning", "cacheRead", "cacheWrite", "totalTokens"].some(
|
|
105
|
-
(key) =>
|
|
78
|
+
(key) => readFiniteNumber(record[key]) !== undefined,
|
|
106
79
|
) || cost !== null;
|
|
107
|
-
if (
|
|
108
|
-
!hasExplicitUsageTelemetry &&
|
|
109
|
-
input === 0 &&
|
|
110
|
-
output === 0 &&
|
|
111
|
-
cacheRead === 0 &&
|
|
112
|
-
cacheWrite === 0 &&
|
|
113
|
-
totalTokens === 0
|
|
114
|
-
) {
|
|
80
|
+
if (!hasExplicitUsageTelemetry) {
|
|
115
81
|
return null;
|
|
116
82
|
}
|
|
117
83
|
return {
|
|
@@ -120,10 +86,10 @@ export function normalizeUsageSnapshot(value: unknown): UsageSnapshot | null {
|
|
|
120
86
|
...(reasoning !== undefined ? { reasoning } : {}),
|
|
121
87
|
cacheRead,
|
|
122
88
|
cacheWrite,
|
|
123
|
-
totalTokens,
|
|
89
|
+
totalTokens: readFiniteNumber(record.totalTokens) ?? input + output + cacheRead + cacheWrite,
|
|
124
90
|
cost,
|
|
125
|
-
requestCount,
|
|
126
|
-
maxInputTokens,
|
|
91
|
+
requestCount: Math.max(0, Math.floor(readFiniteNumber(record.requestCount) ?? 1)),
|
|
92
|
+
maxInputTokens: maxInputTokens !== undefined ? Math.max(0, maxInputTokens) : input,
|
|
127
93
|
};
|
|
128
94
|
}
|
|
129
95
|
|
|
@@ -132,7 +98,7 @@ export function mergeUsageSnapshots(
|
|
|
132
98
|
usage: UsageSnapshot | null,
|
|
133
99
|
): UsageSnapshot | null {
|
|
134
100
|
if (!usage) {
|
|
135
|
-
return
|
|
101
|
+
return cloneUsageSnapshot(total);
|
|
136
102
|
}
|
|
137
103
|
if (!total) {
|
|
138
104
|
return cloneUsageSnapshot(usage);
|
package/src/ws-event-payloads.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { asUnknownRecord, trimToNull as readWsEventNonEmptyString } from "@leitwerk-dev/domain";
|
|
2
|
+
|
|
1
3
|
export interface WsEventPayloadRecord extends Record<string, unknown> {}
|
|
2
4
|
|
|
3
5
|
export interface ResolveWsEventToolCallIdOptions {
|
|
@@ -7,18 +9,10 @@ export interface ResolveWsEventToolCallIdOptions {
|
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
export function asWsEventPayloadRecord(value: unknown): WsEventPayloadRecord {
|
|
10
|
-
return
|
|
11
|
-
? (value as WsEventPayloadRecord)
|
|
12
|
-
: {};
|
|
12
|
+
return asUnknownRecord(value) ?? {};
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export
|
|
16
|
-
if (typeof value !== "string") {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
const trimmed = value.trim();
|
|
20
|
-
return trimmed.length > 0 ? trimmed : null;
|
|
21
|
-
}
|
|
15
|
+
export { readWsEventNonEmptyString };
|
|
22
16
|
|
|
23
17
|
export function readWsEventTimestamp(
|
|
24
18
|
data: WsEventPayloadRecord,
|
|
@@ -52,10 +46,7 @@ export function readWsEventToolName(data: WsEventPayloadRecord): string {
|
|
|
52
46
|
export function readWsEventToolArguments(
|
|
53
47
|
data: WsEventPayloadRecord,
|
|
54
48
|
): Record<string, unknown> | null {
|
|
55
|
-
|
|
56
|
-
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
57
|
-
? (value as Record<string, unknown>)
|
|
58
|
-
: null;
|
|
49
|
+
return asUnknownRecord(data.arguments ?? data.args);
|
|
59
50
|
}
|
|
60
51
|
|
|
61
52
|
export function readWsEventToolCallId(data: WsEventPayloadRecord): string | null {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/http-contracts.ts"],"sourcesContent":["import {\n\ttype Actor,\n\ttype DurableModelSelection,\n\ttype FutureExecutionBlockReason,\n\ttype InstanceTurnConfigMap,\n\ttype LaunchModelConfigInput,\n\tnormalizeActor,\n\tnormalizeLaunchModelConfigInput,\n\ttype ProcessEvent,\n\ttype ProcessFlowView,\n\ttype ProcessInput,\n\ttype ProcessInstance,\n\ttype ProcessLeafOutcomeSnapshot,\n\ttype ProcessProject,\n\ttype ProcessQuestionRequest,\n\ttype ProcessRowSlot,\n\ttype ProcessSelectedTurnModelSource,\n\ttype ProcessTurnAnnotation,\n\ttype ProcessTurnRecord,\n\ttype ProcessTurnType,\n\ttype QuestionAnswerDraft,\n\ttype SerializedProcessGraph,\n\ttrimToNull,\n\ttype WorkerLease,\n} from \"@leitwerk-dev/domain\";\nimport * as v from \"valibot\";\nimport type {\n\tActionFormDefinition,\n\tActionFormFieldDefinition,\n\tFormFieldOptionDefinition,\n} from \"./form-contract.js\";\nimport type { LauncherValidationError, UiLauncherSummaryBase } from \"./launcher-contract.js\";\nimport type {\n\tPrimaryPathSnapshot,\n\tPrimaryPathStreamingAssistantSnapshot,\n\tPrimaryPathToolCallSnapshot,\n\tPrimaryPathTraceItemSnapshot,\n\tTurnUsageSnapshot,\n} from \"./primary-path-snapshot.js\";\nimport {\n\terr,\n\tnullableStringSchema,\n\tok,\n\toptionalNullableStringSchema,\n\ttype ParseResult,\n\tparseLiteral,\n\tparseSchema,\n\tunknownRecordSchema,\n} from \"./protocol.js\";\nimport type { ToolCallRendererDefinition } from \"./tool-renderer-contract.js\";\n\nexport interface AuthMeResponseBody {\n\tauthEnabled: boolean;\n\tactor: Actor | null;\n}\n\nexport interface ProcessListItem {\n\tprocess: ProcessInstance;\n\tprojects: ProcessProject[];\n\tworkerLease: WorkerLease | null;\n\tprocessDisplayName: string | null;\n}\n\nexport type ScheduleMode = \"now\" | \"once\" | \"cron\";\n\nexport type ScheduleConfigInput = {\n\tmode: ScheduleMode;\n\trunAt?: string | null;\n\tcronExpression?: string | null;\n};\n\nexport interface FutureExecutionBaseSummary {\n\tid: string;\n\tkind: \"launch\" | \"action\";\n\tscheduleKind: \"once\" | \"cron\";\n\tprocessId: string;\n\tnextRunAt: string;\n\tcronExpression: string | null;\n\ttitle: string;\n\tsubtitle: string;\n\tstatus?: \"scheduled\" | \"blocked\";\n\tmodelSelection?: DurableModelSelection | null;\n\tblockedReason?: FutureExecutionBlockReason | null;\n}\n\nexport type LauncherModelConfigDefaults = LaunchModelConfigInput;\n\nexport interface FutureLaunchSummary extends FutureExecutionBaseSummary {\n\tkind: \"launch\";\n\tlauncherId: string;\n\tlauncherLabel: string;\n\tlaunchTitle: string | null;\n\tlauncherInput: Record<string, unknown>;\n\tskillIds: string[];\n\tmodelConfig: LauncherModelConfigDefaults;\n}\n\nexport interface FutureActionSummary extends FutureExecutionBaseSummary {\n\tkind: \"action\";\n\tinstanceId: string;\n\tactionId: string;\n\tactionLabel: string;\n\tnextTurnModelProfileId: string | null;\n}\n\nexport type FutureExecutionSummary = FutureLaunchSummary | FutureActionSummary;\n\nexport type ProcessActionFieldDefinition = ActionFormFieldDefinition;\nexport type ProcessActionFormDefinition = ActionFormDefinition;\n\nexport type ProcessActionPreviewSummary = {\n\tkind: \"turn\" | \"terminal\";\n\tturnId: string | null;\n\tturnKind: ProcessTurnType | null;\n\tdescription: string;\n};\n\nexport interface ProcessActionSummary {\n\tid: string;\n\tlabel: string;\n\tdescription: string | null;\n\tpreview: ProcessActionPreviewSummary | null;\n\tsupportsScheduling: boolean;\n\tsupportsNextTurnModelOverride: boolean;\n\tform?: ProcessActionFormDefinition;\n}\n\nexport interface ScheduledActionDetail {\n\tid: string;\n\tnextRunAt: string;\n\tactionId: string;\n\tactionLabel: string;\n\tinput: Record<string, unknown>;\n\tnextTurnModelProfileId: string | null;\n\tstatus?: \"scheduled\" | \"blocked\";\n\tmodelSelection?: DurableModelSelection | null;\n\tblockedReason?: FutureExecutionBlockReason | null;\n\taction: ProcessActionSummary;\n}\n\nexport type ProcessActionModelResolutionSource =\n\t| ProcessSelectedTurnModelSource\n\t| \"persisted_selection\"\n\t| \"none\";\n\nexport interface ProcessActionModelResolutionPreview {\n\tstatus: \"resolved\" | \"none\" | \"error\";\n\tmodelProfileId: string | null;\n\tsource: ProcessActionModelResolutionSource | null;\n\terror: string | null;\n}\n\nexport interface ProcessActionWarmPromptCacheContext {\n\tpreviousModelProfileId: string;\n\tcompatibleModelProfileIds: readonly string[];\n\texpiresAt: string;\n}\n\nexport interface PromptCacheSwitchResolution {\n\tswitchingModelMayBypassPromptCache: boolean;\n\trecommendedModelProfileId: string | null;\n}\n\nexport function resolvePromptCacheSwitch(input: {\n\tcontext: ProcessActionWarmPromptCacheContext | null | undefined;\n\teffectiveModelProfileId: string;\n\tselectableModelProfileIds?: readonly string[];\n\tnow?: number;\n}): PromptCacheSwitchResolution {\n\tconst expiresAtMs = input.context ? Date.parse(input.context.expiresAt) : Number.NaN;\n\tif (\n\t\t!input.context ||\n\t\t!Number.isFinite(expiresAtMs) ||\n\t\t(input.now ?? Date.now()) > expiresAtMs ||\n\t\tinput.context.compatibleModelProfileIds.includes(input.effectiveModelProfileId)\n\t) {\n\t\treturn { switchingModelMayBypassPromptCache: false, recommendedModelProfileId: null };\n\t}\n\tconst selectableIds = input.selectableModelProfileIds\n\t\t? new Set(input.selectableModelProfileIds)\n\t\t: null;\n\tconst recommendations = input.context.compatibleModelProfileIds.filter(\n\t\t(profileId) => !selectableIds || selectableIds.has(profileId),\n\t);\n\treturn {\n\t\tswitchingModelMayBypassPromptCache: true,\n\t\trecommendedModelProfileId: recommendations.includes(input.context.previousModelProfileId)\n\t\t\t? input.context.previousModelProfileId\n\t\t\t: (recommendations[0] ?? null),\n\t};\n}\n\nexport interface ProcessActionModelPreview {\n\tkind: \"llm_turn\" | \"not_applicable\" | \"unavailable\";\n\tturnId: string | null;\n\tdescription: string | null;\n\tresolvedModel?: ProcessActionModelResolutionPreview;\n\twarmPromptCache?: ProcessActionWarmPromptCacheContext;\n\tunavailableReason?:\n\t\t| \"action_not_found\"\n\t\t| \"action_not_visible\"\n\t\t| \"invalid_action_input\"\n\t\t| \"action_failed\";\n\tunavailableMessage?: string | null;\n}\n\nexport type ProcessExternalSourceSummary = {\n\tid: string;\n\tkind: string;\n\texternalActionId?: string;\n\tsourceKind?: string;\n\tlabel: string | null;\n\tdescription: string | null;\n};\n\nexport type ProcessExternalTriggerSummary = ProcessExternalSourceSummary;\n\nexport interface ProcessSelectedTurnSummary {\n\tturnId: string;\n\tkind: ProcessTurnType;\n\tdescription: string;\n\tcommentary: string | null;\n\texternalTriggers: ProcessExternalSourceSummary[];\n}\n\nexport type ModelProfileAvailability = \"available\" | \"unavailable\" | \"stale\";\n\nexport type ModelProfileOptionSummary = {\n\tid: string;\n\tlabel: string;\n\tdescription: string;\n\tavailability: ModelProfileAvailability;\n\tsafeReason?: string | null;\n\tcheckedAt?: string | null;\n};\n\nexport interface ProviderOptionChoiceSummary {\n\tvalue: string;\n\tlabel: string;\n}\n\nexport interface ProviderOptionFieldSummary {\n\tid: string;\n\tlabel: string;\n\trequired: boolean;\n\tminLength: number | null;\n\tmaxLength: number | null;\n\tdefaultValue: string | null;\n\t/** Advisory values. Values outside this list can still be valid. */\n\tchoices: readonly ProviderOptionChoiceSummary[];\n}\n\nexport interface ModelProviderOptionsResponseBody {\n\tmodelProfileId: string;\n\tproviderId: string;\n\tfields: readonly ProviderOptionFieldSummary[];\n\tchoicesStatus: \"available\" | \"unavailable\";\n\tchoicesUnavailableReason: string | null;\n}\n\nexport interface ProcessTurnModelConfigurationView {\n\tturnId: string;\n\tdescription: string;\n\tpathType: string;\n\tprocessConfigModelProfileId: string | null;\n\tinstanceModelProfileId: string | null;\n\teffectiveConfiguredModelProfileId: string | null;\n\tsource: \"instance\" | \"process_config\" | \"default\";\n}\n\nexport type ProcessModelConfigurationIssueView = {\n\tcode: \"invalid_turn_configs_json\";\n\treason: \"invalid_json\" | \"not_object\" | \"turn_config_not_object\";\n\tturnId?: string;\n};\n\nexport interface ProcessModelConfigurationView {\n\tstate:\n\t\t| { kind: \"ready\" }\n\t\t| { kind: \"blocked\"; issues: readonly ProcessModelConfigurationIssueView[] };\n\tavailableProfiles: readonly ModelProfileOptionSummary[];\n\teffectiveSelectedTurn: {\n\t\tturnId: string;\n\t\tdescription: string;\n\t\tmodelProfileId: string;\n\t\tsource: ProcessActionModelResolutionSource;\n\t} | null;\n\tdefaultModel: {\n\t\tprocessConfigModelProfileId: string | null;\n\t\tinstanceModelProfileId: string | null;\n\t\teffectiveModelProfileId: string | null;\n\t\tsource: \"instance\" | \"process_config\" | \"catalog_default\" | \"none\";\n\t};\n\tturns: readonly ProcessTurnModelConfigurationView[];\n}\n\nexport type ProcessRunToolParameterView = {\n\tname: string;\n\ttype: string;\n\tdescription: string;\n\trequired: boolean;\n};\n\nexport type ProcessRunToolView = {\n\tname: string;\n\tdescription: string;\n\tparameters: readonly ProcessRunToolParameterView[];\n};\n\nexport type ProcessRunTurnView = {\n\tturnId: string;\n\tdescription: string;\n\tpathType: string;\n\tconsumedProducts: readonly string[];\n\tpublishedProducts: readonly string[];\n\tactivePiToolNames: readonly string[];\n\toutcomeActions: readonly ProcessRunToolView[];\n};\n\nexport type ProcessRunDetailsView = {\n\tsystemPrompt: string | null;\n\tappendSystemPrompt: string | null;\n\tavailablePiToolNames: readonly string[];\n\tturns: readonly ProcessRunTurnView[];\n};\n\nexport interface ProcessLaunchConfigurationParameterView {\n\tfieldId: string;\n\tlabel: string;\n\tvalue: string | null;\n}\n\nexport interface ProcessLaunchConfigurationProjectView {\n\tkey: string;\n\trepoLocator: string;\n\trepoLocatorKind: ProcessProject[\"repoLocatorKind\"];\n\tbaseBranch: string;\n\tworkBranch: string | null;\n\texternalId: string | null;\n\texternalUrl: string | null;\n\tpipelineStatus: string | null;\n}\n\nexport interface ProcessLaunchConfigurationView {\n\tlauncherId: string | null;\n\tlauncherLabel: string | null;\n\tlauncherSchemaTitle: string | null;\n\tparamsParseError: string | null;\n\tparameters: readonly ProcessLaunchConfigurationParameterView[];\n\tprojects: readonly ProcessLaunchConfigurationProjectView[];\n}\n\nexport interface PiSessionUsageSnapshot {\n\tinput: number;\n\toutput: number;\n\t/** Provider-reported reasoning/thinking tokens. This is a subset of output tokens. */\n\treasoning?: number;\n\tcacheRead: number;\n\tcacheWrite: number;\n\ttotalTokens: number;\n\tcost?: {\n\t\tinput: number;\n\t\toutput: number;\n\t\tcacheRead: number;\n\t\tcacheWrite: number;\n\t\ttotal: number;\n\t};\n}\n\nexport type PiSessionTextContentBlock = { type: \"text\"; text: string };\n\nexport type PiSessionThinkingContentBlock = {\n\ttype: \"thinking\";\n\tthinking: string;\n\tredacted?: boolean;\n};\n\nexport type PiSessionToolCallContentBlock = {\n\ttype: \"toolCall\";\n\tid: string;\n\tname: string;\n\targuments: Record<string, unknown>;\n};\n\nexport type PiSessionImageContentBlock = {\n\ttype: \"image\";\n\tdata: string;\n\tmimeType: string;\n};\n\nexport type PiSessionContentBlock =\n\t| PiSessionTextContentBlock\n\t| PiSessionThinkingContentBlock\n\t| PiSessionToolCallContentBlock\n\t| PiSessionImageContentBlock;\n\nexport interface PiSessionMessageRecord {\n\trole?: string;\n\tcontent?: string | PiSessionContentBlock[];\n\ttoolCallId?: string;\n\ttoolName?: string;\n\tdetails?: unknown;\n\tisError?: boolean;\n\tusage?: PiSessionUsageSnapshot;\n\tstopReason?: string;\n\terrorMessage?: string;\n\tprovider?: string;\n\tmodel?: string;\n\ttimestamp?: number;\n}\n\nexport interface PiSessionEntry {\n\ttype: string;\n\tid: string;\n\tparentId: string | null;\n\ttimestamp: string;\n\tmessage?: PiSessionMessageRecord;\n\ttargetId?: string;\n\tlabel?: string;\n}\n\nexport interface ProcessDiagnosticsData {\n\tprocess: ProcessInstance;\n\tprojects: ProcessProject[];\n\tinputs: ProcessInput[];\n\tevents: ProcessEvent[];\n\tleafOutcomeSnapshots: ProcessLeafOutcomeSnapshot[];\n\tturnRecords: ProcessTurnRecord[];\n\tturnAnnotations: ProcessTurnAnnotation[];\n\tworkerLease: WorkerLease | null;\n\tprocessDisplayName: string | null;\n\tprocessGraph: SerializedProcessGraph;\n\tprocessFlow: ProcessFlowView;\n\tpiSessionEntries: PiSessionEntry[];\n\tdefinesLeafOutcome: boolean;\n\tselectedTurn?: ProcessSelectedTurnSummary | null;\n\tscheduledAction?: ScheduledActionDetail | null;\n\tmodelConfiguration: ProcessModelConfigurationView;\n\trunDetails: ProcessRunDetailsView;\n\tlaunchConfiguration: ProcessLaunchConfigurationView;\n\tactions: ProcessActionSummary[];\n\ttoolRenderers: ToolCallRendererDefinition[];\n}\n\nexport interface ProcessDetailData extends ProcessDiagnosticsData {\n\tprimaryPath: PrimaryPathSnapshot;\n}\n\nexport interface LauncherModelConfigSchema {\n\tavailableProfiles: readonly ModelProfileOptionSummary[];\n\tllmTurns: ReadonlyArray<{\n\t\tturnId: string;\n\t\tdescription: string;\n\t}>;\n}\n\nexport type LauncherDefaultModelPreview = {\n\tsource: \"instance_default\" | \"process_config_default\" | \"catalog_default\" | \"none\";\n\tprofile: ModelProfileOptionSummary | null;\n};\n\nexport interface LauncherTurnModelConfigPreview {\n\tturnId: string;\n\tdescription: string;\n\teffective: {\n\t\tsource: ProcessActionModelResolutionSource;\n\t\tprofile: ModelProfileOptionSummary | null;\n\t};\n}\n\nexport type LauncherModelConfigPreview = {\n\tdefaultModel: LauncherDefaultModelPreview;\n\tturns: readonly LauncherTurnModelConfigPreview[];\n};\n\nexport type UiLauncherSummary = UiLauncherSummaryBase & {\n\tmodelConfigSchema?: LauncherModelConfigSchema;\n\tprocessFlow?: ProcessFlowView;\n};\n\nexport type ProcessRetryConfig = {\n\tlauncherId: string;\n\ttitle: string | null;\n\tlauncherInput: Record<string, unknown>;\n\tskillIds: string[];\n\tmodelConfig: LauncherModelConfigDefaults;\n};\n\nexport type WatcherLaunchModelSummary = {\n\tdefaultModelProfileId: string | null;\n\tturnConfigs: Array<{ turnId: string; modelProfileId: string | null }>;\n};\n\nexport interface WatcherPresentationField {\n\tlabel: string;\n\tvalue: string;\n\tformat?: \"text\" | \"code\";\n}\n\nexport interface WatcherSummary {\n\tprocessId: string;\n\tprocessDisplayName: string;\n\twatcherId: string;\n\tlabel: string;\n\tdescription: string;\n\tsourceId: string;\n\tsourceLabel: string;\n\tenabled: boolean;\n\tconfigPath: string;\n\ttargetSummary: string;\n\tdetails: WatcherPresentationField[];\n\tlaunchModel: WatcherLaunchModelSummary;\n}\n\nexport interface SkillUsageSummary {\n\tattachedAllTime: number;\n\tattachedLast30Days: number;\n\tinvokedAllTime: number;\n\tinvokedLast30Days: number;\n}\n\nexport interface SkillRepositorySummary {\n\tid: string;\n\tlabel: string;\n\turl: string;\n\tref: string;\n\tpath: string;\n\tlastRefreshedAt: string | null;\n\terror: string | null;\n}\n\nexport interface SkillCatalogItem {\n\trepositoryId: string;\n\tid: string;\n\tlabel: string;\n\tdescription: string | null;\n\tsourcePath: string;\n\tsourceRevision: string;\n\tregistered: boolean;\n\tupdateAvailable: boolean;\n\tconflict: boolean;\n\tstale: boolean;\n\tusage: SkillUsageSummary;\n}\n\nexport type SkillRegistrationKind = \"configuration\" | \"catalog\";\n\nexport interface InstalledSkillCatalogItem {\n\tid: string;\n\tlabel: string;\n\tdescription: string | null;\n\tactiveRevisionId: string;\n\tactiveSourceRevision: string | null;\n\tregistrationKind: SkillRegistrationKind;\n\tsourceRepositoryId: string | null;\n\tupdateAvailable: boolean;\n\tusage: SkillUsageSummary;\n}\n\nexport interface SkillRevisionSummary {\n\tid: string;\n\tsourceRevision: string | null;\n\timportedAt: string;\n\tactive: boolean;\n}\n\nexport interface SkillUsageProcessSummary {\n\tinstanceId: string;\n\ttitle: string;\n\tattachedAt: string;\n\tinvocationCount: number;\n\tlastInvokedAt: string | null;\n}\n\nexport interface SkillCatalogDetail extends SkillCatalogItem {\n\tskillMarkdown: string;\n\tprocesses: SkillUsageProcessSummary[];\n}\n\nexport interface InstalledSkillCatalogDetail extends InstalledSkillCatalogItem {\n\tskillMarkdown: string;\n\tprocesses: SkillUsageProcessSummary[];\n\trevisions: SkillRevisionSummary[];\n}\n\nexport type ErrorResponseBody = { error?: string | null; code?: string | null };\n\nexport type ProcessesListResponseBody = {\n\tprocesses: ProcessListItem[];\n\tfutureExecutions: FutureExecutionSummary[];\n};\n\nexport interface ProcessOverviewItem extends ProcessRowSlot {\n\tprocessDisplayName: string | null;\n\t/** Nullable durable title before external-id/instance-id display fallback. */\n\tprocessTitle: string | null;\n\tinitialPromptPreview: string | null;\n\tcreatedAt: string;\n\tupdatedAt: string;\n\tclosedAt: string | null;\n}\n\ninterface FutureExecutionOverviewItemBase {\n\tid: string;\n\tscheduleKind: \"once\" | \"cron\";\n\tprocessId: string;\n\tnextRunAt: string;\n\tcronExpression: string | null;\n\ttitle: string;\n\tinitialPromptPreview: string | null;\n\tstatus?: \"scheduled\" | \"blocked\";\n\tblockedReason?: FutureExecutionBlockReason | null;\n}\n\nexport interface FutureLaunchOverviewItem extends FutureExecutionOverviewItemBase {\n\tkind: \"launch\";\n\tinstanceId: null;\n\tlauncherId: string;\n\tlauncherLabel: string;\n}\n\nexport interface FutureActionOverviewItem extends FutureExecutionOverviewItemBase {\n\tkind: \"action\";\n\tinstanceId: string;\n\tactionId: string;\n\tactionLabel: string;\n}\n\nexport type FutureExecutionOverviewItem = FutureLaunchOverviewItem | FutureActionOverviewItem;\n\nexport interface ProcessesOverviewResponseBody {\n\tprocesses: ProcessOverviewItem[];\n\tfutureExecutions: FutureExecutionOverviewItem[];\n\t/** True when the bounded sidebar response omitted less-recent rows. */\n\ttruncated: boolean;\n}\n\nexport interface ProcessBrowsePagination {\n\tlimit: number;\n\toffset: number;\n\ttotal: number;\n\tprocessTotal: number;\n\tfutureExecutionTotal: number;\n\thasMore: boolean;\n}\n\nexport interface ProcessBrowseFacets {\n\tstatusCounts: Record<\n\t\t\"all\" | \"running\" | \"scheduled\" | \"needs_attention\" | \"completed\" | \"aborted\",\n\t\tnumber\n\t>;\n\tprocessTypes: Array<{ value: string; label: string; count: number }>;\n}\n\nexport type ProcessBrowseItem =\n\t| { kind: \"process\"; item: ProcessOverviewItem }\n\t| { kind: \"future\"; item: FutureExecutionOverviewItem };\n\nexport interface ProcessBrowseResponseBody {\n\t/** Globally sorted page. The browser must preserve this server-owned order. */\n\titems: ProcessBrowseItem[];\n\tpagination: ProcessBrowsePagination;\n\tfacets: ProcessBrowseFacets;\n}\n\nexport type TurnTraceToolCallSnapshot = Omit<PrimaryPathToolCallSnapshot, \"result\"> & {\n\tresultText: string | null;\n\ttruncated: boolean;\n};\n\nexport type TurnPiInputPartRole = \"user\" | \"system\" | \"unknown\";\n\nexport interface TurnPiInputPart {\n\trole: TurnPiInputPartRole;\n\ttext: string;\n\tcreatedAt: string;\n}\n\nexport interface TurnPiInputSnapshot {\n\tparts: TurnPiInputPart[];\n\tfullPrompt: string;\n\tcreatedAt: string;\n\tuserInput?: string | null;\n}\n\nexport interface TurnTraceSnapshot {\n\tassistant: PrimaryPathStreamingAssistantSnapshot;\n\ttoolCalls: TurnTraceToolCallSnapshot[];\n\ttraceItems: PrimaryPathTraceItemSnapshot[];\n\tusage: TurnUsageSnapshot | null;\n\tpiInput: TurnPiInputSnapshot | null;\n}\n\nexport interface TurnTracePreview {\n\tturnRecordId: string;\n\tassistantTextPreview: string;\n\tassistantTextTruncated: boolean;\n\tthinkingPreview: string;\n\tthinkingPreviewTruncated: boolean;\n\ttoolCallCount: number;\n\ttraceItemCount: number;\n\thasReasoningDetails: boolean;\n\tusage: TurnUsageSnapshot | null;\n\tpiInput: { createdAt: string | null; partCount: number; userInputPreview: string | null } | null;\n}\n\nexport type ProcessTimelineTurnPresentation =\n\t| \"llm_turn\"\n\t| \"automatic_turn\"\n\t| \"operator_decision\"\n\t| \"external_trigger\";\n\nexport interface ProcessTimelineTurnSummary {\n\tid: string;\n\tturnId: string;\n\tturnType: ProcessTurnType;\n\tdisplayTurn: string;\n\toutcome: string;\n\tsummary: string;\n\toutput: string;\n\tturnResultMarkdown: string;\n\tpathType: ProcessTurnRecord[\"pathType\"];\n\tcreatedAt: string;\n\tpresentation: ProcessTimelineTurnPresentation;\n\tstatus: \"completed\" | \"in_progress\";\n\tmodelProfileId: string | null;\n\t/** Durable lineage needed by the chronicle rail and input correlation. */\n\tattemptNumber: number;\n\tparentTurnRecordId: string | null;\n\tstartedAt: string;\n\tendedAt: string | null;\n\tactionSource: \"ui\" | \"external\" | \"scheduled\" | null;\n}\n\nexport type ProcessTimelineInputSummary = Pick<\n\tProcessInput,\n\t\"id\" | \"sequence\" | \"source\" | \"kind\" | \"bodyMarkdown\" | \"receivedAt\" | \"consumedAt\"\n>;\n\nexport interface ProcessExternalTriggerSignal {\n\ttriggerId: string;\n\tstate: \"error\" | \"armed\" | \"triggered\" | \"waiting\";\n\toccurredAt: string | null;\n\tsecondaryDetail: string | null;\n}\n\nexport interface ProcessTimelineSnapshot {\n\tprompt: { text: string | null; createdAt: string | null };\n\tturns: ProcessTimelineTurnSummary[];\n\ttracePreviewsByTurnRecordId: Record<string, TurnTracePreview>;\n\tinputs: ProcessTimelineInputSummary[];\n\texternalTriggerSignals: ProcessExternalTriggerSignal[];\n}\n\nexport interface CurrentErrorSummary {\n\ttitle: string;\n\tsummary: string;\n\tguidance?: string;\n\ttechnicalDetail?: string | null;\n}\n\nexport interface CurrentTurnRecoverySummary extends CurrentErrorSummary {\n\tturnRecordId: string;\n\tdefaultContinuePrompt: string;\n\tcanContinue: boolean;\n\tdefaultModelProfileId: string | null;\n\tproviderOptions: Record<string, string>;\n}\n\nexport interface StartupRecoverySummary extends CurrentErrorSummary {\n\tstartRecordId: string;\n\tkind: \"preparation_failed\" | \"bootstrap_failed\";\n\taction: \"choose_model\" | \"retry_startup\";\n\tdefaultModelProfileId: string | null;\n\tproviderOptions: Record<string, string>;\n}\n\nexport type CurrentProcessErrorSummary = CurrentErrorSummary;\n\nexport interface ProcessUsageEstimateSnapshot {\n\tusage: TurnUsageSnapshot;\n\tincludesLiveTurn: boolean;\n\ttotalLlmTurnCount: number;\n\tcoveredTurnCount: number;\n\tmissingUsageTurnCount: number;\n\tmissingCostTurnCount: number;\n\tisPartial: boolean;\n}\n\nexport interface PrimaryPathUiSnapshot extends PrimaryPathSnapshot {\n\tentryCount: number;\n\tentriesOmitted: true;\n}\n\nexport type ProcessUiSnapshotProcess = Pick<\n\tProcessInstance,\n\t| \"id\"\n\t| \"processId\"\n\t| \"selectedTurnId\"\n\t| \"lifecycleStatus\"\n\t| \"currentExecution\"\n\t| \"planRevision\"\n\t| \"title\"\n\t| \"externalId\"\n\t| \"externalUrl\"\n\t| \"initialDefaultModelProfileId\"\n\t| \"createdAt\"\n\t| \"updatedAt\"\n\t| \"closedAt\"\n>;\n\n/**\n * Initial render contract for process detail. Raw process events, inputs,\n * session entries, projects, and full durable records belong to diagnostics;\n * this DTO carries only browser-facing projections.\n */\nexport interface ProcessDetailUiSnapshotResponseBody {\n\tprocess: ProcessUiSnapshotProcess;\n\t/** Durable requests in Chronicle order; at most one is open for the current turn. */\n\tquestionRequests: ProcessQuestionRequest[];\n\tleafOutcomeSnapshots: ProcessLeafOutcomeSnapshot[];\n\tprocessDisplayName: string | null;\n\tprocessFlow: ProcessFlowView;\n\tdefinesLeafOutcome: boolean;\n\tselectedTurn: ProcessSelectedTurnSummary | null;\n\tscheduledAction: ScheduledActionDetail | null;\n\tmodelConfiguration: ProcessModelConfigurationView;\n\trunDetails: ProcessRunDetailsView;\n\tlaunchConfiguration: ProcessLaunchConfigurationView;\n\tactions: ProcessActionSummary[];\n\ttoolRenderers: ToolCallRendererDefinition[];\n\tprimaryPath: PrimaryPathUiSnapshot;\n\ttimeline: ProcessTimelineSnapshot;\n\tinstanceTree: ProcessInstanceTreeResponseBody;\n\trecovery: CurrentTurnRecoverySummary | null;\n\tstartupRecovery: StartupRecoverySummary | null;\n\tprocessError: CurrentProcessErrorSummary | null;\n\tusageEstimate: ProcessUsageEstimateSnapshot | null;\n\tpersistedModelSelectionWarning: string | null;\n\tsession: { signature: string | null };\n}\n\nexport type InstanceTreeTurnResultState = \"succeeded\" | \"failed\" | \"aborted\" | \"pending\";\n\n/** Redacted, semantic process history. Pi message/activity categories are never exposed. */\nexport interface InstanceTreeNodeSummary {\n\tid: string;\n\tparentId: string | null;\n\tlabel: string;\n\tpathType: \"primary\" | \"root_branch\" | \"leaf_branch\";\n\tresultState: InstanceTreeTurnResultState;\n\ttimestamp: string;\n}\n\nexport interface InstanceTreeEdgeSummary {\n\tid: string;\n\tsourceNodeId: string;\n\ttargetNodeId: string | null;\n\thasContext: boolean;\n\tproductLabels: readonly string[];\n\tactionLabel: string | null;\n\tendState: \"not_applied\" | \"completed\" | null;\n}\n\nexport interface ProcessInstanceTreeResponseBody {\n\tcurrentLeafId: string | null;\n\tnodes: InstanceTreeNodeSummary[];\n\tedges: InstanceTreeEdgeSummary[];\n}\n\nexport interface TurnReasoningDetailResponseBody {\n\tinstanceId: string;\n\tturnRecordId: string;\n\tsessionSignature: string | null;\n\treasoning: TurnTraceSnapshot;\n}\n\nexport interface SubmitQuestionAnswersRequestBody {\n\tdraft: QuestionAnswerDraft[];\n}\n\nexport type QuestionRequestMutationResponseBody = {\n\trequest: ProcessQuestionRequest;\n};\n\nexport type FutureExecutionDetailResponseBody = FutureExecutionSummary;\n\nexport type LaunchersResponseBody = { launchers: UiLauncherSummary[] };\n\nexport type WatchersResponseBody = { watchers: WatcherSummary[] };\nexport type SkillCatalogDetailResponseBody = { skill: SkillCatalogDetail };\nexport type InstalledSkillCatalogDetailResponseBody = { skill: InstalledSkillCatalogDetail };\nexport type SkillsCatalogResponseBody = {\n\trepositories: SkillRepositorySummary[];\n\tavailableSkills: SkillCatalogItem[];\n\tinstalledSkills: InstalledSkillCatalogItem[];\n};\n\nexport interface LauncherDefaultsResponseBody {\n\tdefaults: Record<string, unknown>;\n\ttitle: string | null;\n\tmodelConfig: LauncherModelConfigDefaults;\n\twarnings?: LauncherValidationError[];\n}\n\nexport type LauncherOptionsResponseBody = {\n\toptions: Record<string, readonly FormFieldOptionDefinition[]>;\n};\n\nexport type LauncherRecentValuesResponseBody = {\n\tvalues: Record<string, readonly string[]>;\n};\n\nexport type LauncherModelConfigPreviewResponseBody = { preview: LauncherModelConfigPreview };\n\nexport interface LauncherMutationResponseBody {\n\tkind?: \"scheduled\";\n\tprocess?: ProcessInstance | null;\n\tfutureExecution?: FutureLaunchSummary | null;\n\tprojects?: ProcessProject[];\n\terrors?: LauncherValidationError[];\n\terror?: string | null;\n}\n\nexport type ScheduledActionMutationResponseBody = {\n\tkind?: \"scheduled\";\n\tscheduledAction?: ScheduledActionDetail | null;\n\terror?: string | null;\n};\n\nexport type ProcessRetryConfigResponseBody = ProcessRetryConfig;\n\nexport type ProcessActionModelPreviewResponseBody = { preview: ProcessActionModelPreview };\n\nexport type ProcessDiagnosticsResponseBody = ProcessDiagnosticsData;\n\nexport type PrimaryPathSnapshotResponseBody = PrimaryPathSnapshot;\n\nexport type CronPreviewResponseBody = { nextRunAt: string };\n\ntype ParsedLauncherRequestBody = {\n\ttitle: string | null;\n\ttitleProvided: boolean;\n\tlauncherInput: Record<string, unknown>;\n\tlauncherInputProvided: boolean;\n\tskillIds?: string[];\n\tmodelConfig: LauncherModelConfigDefaults;\n\tmodelConfigProvided: boolean;\n\tschedule: ParsedScheduleRequest;\n\tscheduleProvided: boolean;\n};\n\ntype ParsedActionRequestBody = {\n\tinput: Record<string, unknown>;\n\tinputProvided: boolean;\n\tnextTurnModelProfileId?: string | null;\n\tnextTurnModelProfileIdProvided: boolean;\n\tschedule: ParsedScheduleRequest;\n\tscheduleProvided: boolean;\n};\n\nconst SCHEDULE_MODES = [\"now\", \"once\", \"cron\"] as const;\nconst PROCESS_LIFECYCLE_STATUSES = [\n\t\"discovered\",\n\t\"active\",\n\t\"waiting\",\n\t\"error\",\n\t\"completed\",\n\t\"aborted\",\n] as const;\nconst launcherStructuredBodySchema = v.strictObject({\n\ttitle: v.optional(nullableStringSchema),\n\tlauncherInput: v.optional(unknownRecordSchema),\n\tskillIds: v.optional(v.array(v.string())),\n\tmodelConfig: v.optional(v.unknown()),\n\tschedule: v.optional(v.unknown()),\n});\nconst actionStructuredBodySchema = v.strictObject({\n\tinput: v.optional(unknownRecordSchema),\n\tnextTurnModelProfileId: optionalNullableStringSchema,\n\tschedule: v.optional(v.unknown()),\n});\nconst futureLaunchPayloadInputSchema = v.object({\n\tlauncherInput: v.optional(v.nullable(unknownRecordSchema)),\n\tmodelConfig: v.optional(v.unknown()),\n\tactor: v.optional(v.nullable(unknownRecordSchema)),\n\tlaunchPlan: v.object({\n\t\tlauncherId: v.string(),\n\t\tprocessId: v.string(),\n\t\thandoffDedupKey: optionalNullableStringSchema,\n\t\tprocessInput: v.object({\n\t\t\tprocessId: v.string(),\n\t\t\tselectedTurnId: optionalNullableStringSchema,\n\t\t\tlifecycleStatus: v.picklist(PROCESS_LIFECYCLE_STATUSES),\n\t\t\ttitle: optionalNullableStringSchema,\n\t\t\texternalId: optionalNullableStringSchema,\n\t\t\texternalUrl: optionalNullableStringSchema,\n\t\t\tmetadata: v.optional(v.nullable(unknownRecordSchema)),\n\t\t\tdefaultModelProfileId: optionalNullableStringSchema,\n\t\t\tturnConfigsJson: optionalNullableStringSchema,\n\t\t\tselectedTurnModelProfileId: optionalNullableStringSchema,\n\t\t\tselectedTurnModelKind: v.optional(v.nullable(v.picklist([\"explicit\", \"inherited\"]))),\n\t\t\tselectedTurnModelSource: v.optional(\n\t\t\t\tv.nullable(\n\t\t\t\t\tv.picklist([\n\t\t\t\t\t\t\"action_override\",\n\t\t\t\t\t\t\"launch_override\",\n\t\t\t\t\t\t\"instance_turn_config\",\n\t\t\t\t\t\t\"process_config_turn\",\n\t\t\t\t\t\t\"instance_default\",\n\t\t\t\t\t\t\"process_config_default\",\n\t\t\t\t\t\t\"catalog_default\",\n\t\t\t\t\t\t\"legacy_persisted\",\n\t\t\t\t\t]),\n\t\t\t\t),\n\t\t\t),\n\t\t\tparamsJson: optionalNullableStringSchema,\n\t\t\tstateJson: optionalNullableStringSchema,\n\t\t}),\n\t\ttitleSourceFields: v.optional(\n\t\t\tv.nullable(v.array(v.object({ label: v.string(), value: v.string() }))),\n\t\t),\n\t\tprojectInputs: v.optional(\n\t\t\tv.nullable(\n\t\t\t\tv.array(\n\t\t\t\t\tv.object({\n\t\t\t\t\t\tkey: v.string(),\n\t\t\t\t\t\trepoLocator: v.string(),\n\t\t\t\t\t\tbaseBranch: v.string(),\n\t\t\t\t\t\tworkBranch: optionalNullableStringSchema,\n\t\t\t\t\t\texternalId: optionalNullableStringSchema,\n\t\t\t\t\t\texternalUrl: optionalNullableStringSchema,\n\t\t\t\t\t\tmetadata: v.optional(v.nullable(unknownRecordSchema)),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t),\n\t\t),\n\t\tstartTurnId: optionalNullableStringSchema,\n\t}),\n\tselectedSkillIds: v.optional(v.array(v.string())),\n\tresourceSelections: v.optional(\n\t\tv.array(v.object({ skillId: v.string(), revisionId: v.string() })),\n\t),\n});\nconst futureActionPayloadInputSchema = v.object({\n\tinput: v.optional(v.nullable(unknownRecordSchema)),\n\tnextTurnModelProfileId: optionalNullableStringSchema,\n\tactionLabel: optionalNullableStringSchema,\n\tactor: v.optional(v.nullable(unknownRecordSchema)),\n});\n\nexport type ParsedScheduleRequest =\n\t| { mode: \"now\" }\n\t| { mode: \"once\"; runAt: string }\n\t| { mode: \"cron\"; cronExpression: string };\ntype ValidatedScheduleRequest =\n\t| { mode: \"now\"; nextRunAt: null; cronExpression: null }\n\t| { mode: \"once\"; nextRunAt: string; cronExpression: null }\n\t| { mode: \"cron\"; nextRunAt: string; cronExpression: string };\n\ntype FutureLaunchPayloadBase = v.InferOutput<typeof futureLaunchPayloadInputSchema>;\ntype FutureActionPayloadBase = v.InferOutput<typeof futureActionPayloadInputSchema>;\nconst cloneUnknownRecord = (value?: Record<string, unknown> | null) =>\n\tvalue ? { ...value } : null;\nconst cloneTurnConfigMap = (turnConfigs: InstanceTurnConfigMap = {}) =>\n\tObject.fromEntries(\n\t\tObject.entries(turnConfigs as Record<string, InstanceTurnConfigMap[string]>).map(\n\t\t\t([turnId, turnConfig]) => [turnId, { ...turnConfig }],\n\t\t),\n\t) as InstanceTurnConfigMap;\nconst normalizeFutureLaunchPayload = (payload: FutureLaunchPayloadBase) => {\n\tconst modelConfig = normalizeLaunchModelConfigInput(\n\t\t(payload.modelConfig ?? {}) as LaunchModelConfigInput,\n\t);\n\treturn {\n\t\tlauncherInput: cloneUnknownRecord(payload.launcherInput) ?? {},\n\t\tmodelConfig: {\n\t\t\tdefaultModelProfileId: modelConfig.defaultModelProfileId ?? null,\n\t\t\tturnConfigs: cloneTurnConfigMap(modelConfig.turnConfigs),\n\t\t},\n\t\tactor: normalizeActor(payload.actor),\n\t\tselectedSkillIds: [\n\t\t\t...(payload.selectedSkillIds ??\n\t\t\t\tpayload.resourceSelections?.map(({ skillId }) => skillId) ??\n\t\t\t\t[]),\n\t\t],\n\t\tresourceSelections: (payload.resourceSelections ?? []).map((selection) => ({ ...selection })),\n\t\tlaunchPlan: {\n\t\t\tlauncherId: payload.launchPlan.launcherId,\n\t\t\tprocessId: payload.launchPlan.processId,\n\t\t\thandoffDedupKey: trimToNull(payload.launchPlan.handoffDedupKey) ?? null,\n\t\t\tprocessInput: {\n\t\t\t\tprocessId: payload.launchPlan.processInput.processId,\n\t\t\t\tselectedTurnId: payload.launchPlan.processInput.selectedTurnId ?? null,\n\t\t\t\tlifecycleStatus: payload.launchPlan.processInput.lifecycleStatus,\n\t\t\t\ttitle: payload.launchPlan.processInput.title ?? null,\n\t\t\t\texternalId: payload.launchPlan.processInput.externalId ?? null,\n\t\t\t\texternalUrl: payload.launchPlan.processInput.externalUrl ?? null,\n\t\t\t\tmetadata: cloneUnknownRecord(payload.launchPlan.processInput.metadata),\n\t\t\t\tdefaultModelProfileId: payload.launchPlan.processInput.defaultModelProfileId ?? null,\n\t\t\t\tturnConfigsJson: payload.launchPlan.processInput.turnConfigsJson ?? null,\n\t\t\t\tselectedTurnModelProfileId:\n\t\t\t\t\tpayload.launchPlan.processInput.selectedTurnModelProfileId ?? null,\n\t\t\t\tselectedTurnModelKind: payload.launchPlan.processInput.selectedTurnModelKind ?? null,\n\t\t\t\tselectedTurnModelSource: payload.launchPlan.processInput.selectedTurnModelSource ?? null,\n\t\t\t\tparamsJson: payload.launchPlan.processInput.paramsJson ?? null,\n\t\t\t\tstateJson: payload.launchPlan.processInput.stateJson ?? null,\n\t\t\t},\n\t\t\ttitleSourceFields: (payload.launchPlan.titleSourceFields ?? []).map((field) => ({\n\t\t\t\t...field,\n\t\t\t})),\n\t\t\tprojectInputs: (payload.launchPlan.projectInputs ?? []).map((project) => ({\n\t\t\t\tkey: project.key,\n\t\t\t\trepoLocator: project.repoLocator,\n\t\t\t\tbaseBranch: project.baseBranch,\n\t\t\t\tworkBranch: project.workBranch ?? null,\n\t\t\t\texternalId: project.externalId ?? null,\n\t\t\t\texternalUrl: project.externalUrl ?? null,\n\t\t\t\tmetadata: cloneUnknownRecord(project.metadata),\n\t\t\t})),\n\t\t\tstartTurnId: payload.launchPlan.startTurnId ?? null,\n\t\t},\n\t};\n};\nconst normalizeFutureActionPayload = (payload: FutureActionPayloadBase) => ({\n\tinput: cloneUnknownRecord(payload.input) ?? {},\n\tnextTurnModelProfileId: trimToNull(payload.nextTurnModelProfileId) ?? null,\n\tactionLabel: trimToNull(payload.actionLabel) ?? null,\n\tactor: normalizeActor(payload.actor),\n});\n\nexport type FutureLaunchPayload = ReturnType<typeof normalizeFutureLaunchPayload>;\nexport type FutureActionPayload = ReturnType<typeof normalizeFutureActionPayload>;\n\nfunction hasOwn(object: Record<string, unknown>, key: string): boolean {\n\treturn Object.hasOwn(object, key);\n}\n\nfunction parseJsonPayload(payloadJson: string, context: string): ParseResult<unknown> {\n\ttry {\n\t\treturn ok(JSON.parse(payloadJson));\n\t} catch {\n\t\treturn err(`${context} must be valid JSON`);\n\t}\n}\n\nfunction parseRecord(value: unknown, context: string): ParseResult<Record<string, unknown>> {\n\treturn parseSchema(unknownRecordSchema, value, context);\n}\n\nfunction parseLauncherTurnConfigMap(\n\tvalue: unknown,\n\tcontext: string,\n): ParseResult<InstanceTurnConfigMap> {\n\tconst record = parseRecord(value, context);\n\tif (!record.ok) {\n\t\treturn record;\n\t}\n\tconst turnConfigs: InstanceTurnConfigMap = {};\n\tfor (const [turnId, turnConfigValue] of Object.entries(record.value)) {\n\t\tconst turnConfig = parseRecord(turnConfigValue, `${context}.${turnId}`);\n\t\tif (!turnConfig.ok) {\n\t\t\treturn turnConfig;\n\t\t}\n\t\tconst modelProfileId =\n\t\t\ttrimToNull(turnConfig.value.modelProfileId) ?? trimToNull(turnConfig.value.model_profile);\n\t\tturnConfigs[turnId] = modelProfileId ? { modelProfileId } : {};\n\t}\n\treturn ok(turnConfigs);\n}\n\nexport function parseScheduleRequestInput(value: unknown): ParseResult<ParsedScheduleRequest> {\n\tif (value === undefined || value === null) {\n\t\treturn ok({ mode: \"now\" });\n\t}\n\tconst record = parseRecord(value, \"schedule\");\n\tif (!record.ok) {\n\t\treturn record;\n\t}\n\tconst mode = parseLiteral(record.value.mode ?? \"now\", SCHEDULE_MODES, \"schedule.mode\");\n\tif (!mode.ok || mode.value === \"now\") {\n\t\treturn mode.ok ? ok({ mode: \"now\" }) : mode;\n\t}\n\tif (mode.value === \"once\") {\n\t\tconst runAt = typeof record.value.runAt === \"string\" ? record.value.runAt : null;\n\t\treturn runAt && !Number.isNaN(Date.parse(runAt))\n\t\t\t? ok({ mode: \"once\", runAt: new Date(runAt).toISOString() })\n\t\t\t: err(\"runAt must be a valid ISO datetime\");\n\t}\n\tconst cronExpression = trimToNull(record.value.cronExpression);\n\treturn cronExpression\n\t\t? ok({ mode: \"cron\", cronExpression })\n\t\t: err(\"cronExpression is required for cron schedules\");\n}\n\nexport function validateScheduleRequestInput(\n\tschedule: ParsedScheduleRequest,\n\tallowedModes: readonly ScheduleMode[],\n\toptions: {\n\t\tnow?: () => Date;\n\t\tresolveCronNextRunAt?: (expression: string, now: Date) => string;\n\t} = {},\n): ParseResult<ValidatedScheduleRequest> {\n\tif (!allowedModes.includes(schedule.mode)) {\n\t\treturn err(`Unsupported schedule mode '${schedule.mode}'`);\n\t}\n\tif (schedule.mode === \"now\") {\n\t\treturn ok({ mode: \"now\", nextRunAt: null, cronExpression: null });\n\t}\n\tconst now = options.now ?? (() => new Date());\n\tif (schedule.mode === \"once\") {\n\t\tconst runAt = new Date(schedule.runAt);\n\t\treturn Number.isNaN(runAt.getTime())\n\t\t\t? err(\"runAt must be a valid ISO datetime\")\n\t\t\t: runAt.getTime() <= now().getTime()\n\t\t\t\t? err(\"Scheduled time must be in the future\")\n\t\t\t\t: ok({ mode: \"once\", nextRunAt: runAt.toISOString(), cronExpression: null });\n\t}\n\tif (!options.resolveCronNextRunAt) {\n\t\treturn err(\"resolveCronNextRunAt is required for cron schedules\");\n\t}\n\ttry {\n\t\treturn ok({\n\t\t\tmode: \"cron\",\n\t\t\tnextRunAt: options.resolveCronNextRunAt(schedule.cronExpression, now()),\n\t\t\tcronExpression: schedule.cronExpression,\n\t\t});\n\t} catch (error) {\n\t\treturn err(error instanceof Error ? error.message : \"Invalid cron expression\");\n\t}\n}\n\nexport function parseLauncherTurnConfigsJson(\n\tturnConfigsJson: string | null | undefined,\n): ParseResult<InstanceTurnConfigMap> {\n\tif (!turnConfigsJson) {\n\t\treturn ok({});\n\t}\n\tconst parsed = parseJsonPayload(turnConfigsJson, \"turnConfigsJson\");\n\treturn parsed.ok ? parseLauncherTurnConfigMap(parsed.value, \"turnConfigsJson\") : parsed;\n}\n\nexport function parseLauncherInputJson(\n\tlauncherInputJson: string | null | undefined,\n\tcontext = \"launcherInputJson\",\n): ParseResult<Record<string, unknown>> {\n\tif (launcherInputJson === undefined || launcherInputJson === null) {\n\t\treturn ok({});\n\t}\n\tconst parsed = parseJsonPayload(launcherInputJson, context);\n\treturn parsed.ok ? parseRecord(parsed.value, context) : parsed;\n}\n\nexport function parseLauncherModelConfigInput(\n\tvalue: unknown,\n\tcontext = \"modelConfig\",\n): ParseResult<LaunchModelConfigInput> {\n\tif (value === undefined || value === null) {\n\t\treturn ok({});\n\t}\n\tconst record = parseRecord(value, context);\n\tif (!record.ok) {\n\t\treturn record;\n\t}\n\tconst defaultModelProfileId = trimToNull(record.value.defaultModelProfileId);\n\tif (\n\t\thasOwn(record.value, \"defaultModelProfileId\") &&\n\t\trecord.value.defaultModelProfileId !== null &&\n\t\ttypeof record.value.defaultModelProfileId !== \"string\"\n\t) {\n\t\treturn err(`${context}.defaultModelProfileId must be a string or null`);\n\t}\n\tconst turnConfigs =\n\t\trecord.value.turnConfigs === undefined\n\t\t\t? ok(undefined)\n\t\t\t: parseLauncherTurnConfigMap(record.value.turnConfigs, `${context}.turnConfigs`);\n\treturn turnConfigs.ok\n\t\t? ok(\n\t\t\t\tnormalizeLaunchModelConfigInput({\n\t\t\t\t\t...(defaultModelProfileId ? { defaultModelProfileId } : {}),\n\t\t\t\t\t...(turnConfigs.value ? { turnConfigs: turnConfigs.value } : {}),\n\t\t\t\t}),\n\t\t\t)\n\t\t: turnConfigs;\n}\n\nfunction hasInlineScheduleFields(object: Record<string, unknown>): boolean {\n\treturn hasOwn(object, \"mode\") || hasOwn(object, \"runAt\") || hasOwn(object, \"cronExpression\");\n}\n\nexport function parseLauncherRequestBody(value: unknown): ParseResult<ParsedLauncherRequestBody> {\n\tif (value === undefined || value === null) {\n\t\treturn ok({\n\t\t\ttitle: null,\n\t\t\ttitleProvided: false,\n\t\t\tlauncherInput: {},\n\t\t\tlauncherInputProvided: false,\n\t\t\tmodelConfig: {},\n\t\t\tmodelConfigProvided: false,\n\t\t\tschedule: { mode: \"now\" },\n\t\t\tscheduleProvided: false,\n\t\t});\n\t}\n\tconst record = parseRecord(value, \"launcher request body\");\n\tif (!record.ok) {\n\t\treturn record;\n\t}\n\tif (\n\t\thasOwn(record.value, \"title\") ||\n\t\trecord.value.launcherInput !== undefined ||\n\t\trecord.value.skillIds !== undefined ||\n\t\trecord.value.modelConfig !== undefined ||\n\t\trecord.value.schedule !== undefined\n\t) {\n\t\tif (\n\t\t\tObject.keys(record.value).some(\n\t\t\t\t(key) =>\n\t\t\t\t\tkey !== \"title\" &&\n\t\t\t\t\tkey !== \"launcherInput\" &&\n\t\t\t\t\tkey !== \"skillIds\" &&\n\t\t\t\t\tkey !== \"modelConfig\" &&\n\t\t\t\t\tkey !== \"schedule\",\n\t\t\t)\n\t\t) {\n\t\t\treturn err(\n\t\t\t\t\"launcher request body must use { title, launcherInput, skillIds, modelConfig, schedule }\",\n\t\t\t);\n\t\t}\n\t\tconst parsed = parseSchema(launcherStructuredBodySchema, value, \"launcher request body\");\n\t\tif (!parsed.ok) {\n\t\t\treturn parsed;\n\t\t}\n\t\tconst modelConfig = parseLauncherModelConfigInput(parsed.value.modelConfig);\n\t\tif (!modelConfig.ok) {\n\t\t\treturn modelConfig;\n\t\t}\n\t\tconst schedule = parseScheduleRequestInput(parsed.value.schedule);\n\t\tif (!schedule.ok) {\n\t\t\treturn schedule;\n\t\t}\n\t\tconst skillIds = parsed.value.skillIds ?? [];\n\t\tif (new Set(skillIds).size !== skillIds.length) {\n\t\t\treturn err(\"skillIds must not contain duplicates\");\n\t\t}\n\t\treturn ok({\n\t\t\ttitle: parsed.value.title ?? null,\n\t\t\ttitleProvided: hasOwn(record.value, \"title\"),\n\t\t\tlauncherInput: parsed.value.launcherInput ?? {},\n\t\t\tlauncherInputProvided: hasOwn(record.value, \"launcherInput\"),\n\t\t\t...(hasOwn(record.value, \"skillIds\") ? { skillIds: [...skillIds] } : {}),\n\t\t\tmodelConfig: modelConfig.value,\n\t\t\tmodelConfigProvided: hasOwn(record.value, \"modelConfig\"),\n\t\t\tschedule: schedule.value,\n\t\t\tscheduleProvided: hasOwn(record.value, \"schedule\"),\n\t\t});\n\t}\n\tconst modelConfig = parseLauncherModelConfigInput(record.value, \"modelConfig\");\n\tif (!modelConfig.ok) {\n\t\treturn modelConfig;\n\t}\n\tconst schedule = parseScheduleRequestInput(record.value);\n\tif (!schedule.ok) {\n\t\treturn schedule;\n\t}\n\treturn ok({\n\t\ttitle: null,\n\t\ttitleProvided: false,\n\t\tlauncherInput: record.value,\n\t\tlauncherInputProvided: true,\n\t\tmodelConfig: modelConfig.value,\n\t\tmodelConfigProvided: true,\n\t\tschedule: schedule.value,\n\t\tscheduleProvided: hasInlineScheduleFields(record.value),\n\t});\n}\n\nexport function parseActionRequestBody(value: unknown): ParseResult<ParsedActionRequestBody> {\n\tif (value === undefined || value === null) {\n\t\treturn ok({\n\t\t\tinput: {},\n\t\t\tinputProvided: false,\n\t\t\tnextTurnModelProfileIdProvided: false,\n\t\t\tschedule: { mode: \"now\" },\n\t\t\tscheduleProvided: false,\n\t\t});\n\t}\n\tconst record = parseRecord(value, \"action request body\");\n\tif (!record.ok) {\n\t\treturn record;\n\t}\n\tconst nextTurnModelProfileIdProvided = hasOwn(record.value, \"nextTurnModelProfileId\");\n\tif (\n\t\trecord.value.input !== undefined ||\n\t\tnextTurnModelProfileIdProvided ||\n\t\trecord.value.schedule !== undefined\n\t) {\n\t\tif (\n\t\t\tObject.keys(record.value).some(\n\t\t\t\t(key) => key !== \"input\" && key !== \"nextTurnModelProfileId\" && key !== \"schedule\",\n\t\t\t)\n\t\t) {\n\t\t\treturn err(\"action request body must use { input, nextTurnModelProfileId }\");\n\t\t}\n\t\tconst parsed = parseSchema(actionStructuredBodySchema, value, \"action request body\");\n\t\tif (!parsed.ok) {\n\t\t\treturn parsed;\n\t\t}\n\t\tconst schedule = parseScheduleRequestInput(parsed.value.schedule);\n\t\tif (!schedule.ok) {\n\t\t\treturn schedule;\n\t\t}\n\t\treturn ok({\n\t\t\tinput: parsed.value.input ?? {},\n\t\t\tinputProvided: hasOwn(record.value, \"input\"),\n\t\t\tnextTurnModelProfileIdProvided,\n\t\t\tschedule: schedule.value,\n\t\t\tscheduleProvided: hasOwn(record.value, \"schedule\"),\n\t\t\t...(nextTurnModelProfileIdProvided\n\t\t\t\t? { nextTurnModelProfileId: parsed.value.nextTurnModelProfileId ?? null }\n\t\t\t\t: {}),\n\t\t});\n\t}\n\tconst schedule = parseScheduleRequestInput(record.value);\n\tif (!schedule.ok) {\n\t\treturn schedule;\n\t}\n\treturn ok({\n\t\tinput: record.value,\n\t\tinputProvided: true,\n\t\tnextTurnModelProfileIdProvided,\n\t\tschedule: schedule.value,\n\t\tscheduleProvided: hasInlineScheduleFields(record.value),\n\t\t...(nextTurnModelProfileIdProvided\n\t\t\t? { nextTurnModelProfileId: trimToNull(record.value.nextTurnModelProfileId) }\n\t\t\t: {}),\n\t});\n}\n\nexport function serializeFutureLaunchPayload(payload: unknown): string {\n\treturn JSON.stringify(normalizeFutureLaunchPayload(payload as FutureLaunchPayloadBase));\n}\n\nexport function parseFutureLaunchPayloadObject(\n\tvalue: unknown,\n\tcontext = \"Scheduled launch payload\",\n): ParseResult<FutureLaunchPayload> {\n\tconst parsed = parseSchema(futureLaunchPayloadInputSchema, value, context);\n\treturn parsed.ok ? ok(normalizeFutureLaunchPayload(parsed.value)) : parsed;\n}\n\nexport function parseFutureLaunchPayloadJson(\n\tpayloadJson: string,\n): ParseResult<FutureLaunchPayload> {\n\tconst parsed = parseJsonPayload(payloadJson, \"Scheduled launch payload\");\n\treturn parsed.ok ? parseFutureLaunchPayloadObject(parsed.value) : parsed;\n}\n\nexport function serializeFutureActionPayload(payload: unknown): string {\n\treturn JSON.stringify(normalizeFutureActionPayload(payload as FutureActionPayloadBase));\n}\n\nexport function parseFutureActionPayloadObject(\n\tvalue: unknown,\n\tcontext = \"Scheduled action payload\",\n): ParseResult<FutureActionPayload> {\n\tconst parsed = parseSchema(futureActionPayloadInputSchema, value, context);\n\treturn parsed.ok ? ok(normalizeFutureActionPayload(parsed.value)) : parsed;\n}\n\nexport function parseFutureActionPayloadJson(\n\tpayloadJson: string,\n): ParseResult<FutureActionPayload> {\n\tconst parsed = parseJsonPayload(payloadJson, \"Scheduled action payload\");\n\treturn parsed.ok ? parseFutureActionPayloadObject(parsed.value) : parsed;\n}\n"],"mappings":";;;;;;;;;;;AAAA;AAAA,EAMC;AAAA,EACA;AAAA,EAeA;AAAA,OAEM;AACP,YAAY,OAAO;AA0IZ,SAAS,yBAAyB,OAKT;AAC/B,QAAM,cAAc,MAAM,UAAU,KAAK,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AC,IAAI;AACrE;AAEO,SAAS,6BACf,aACmC;AACnC,QAAM,SAAS,iBAAiB,aAAa,0BAA0B;AACvE,SAAO,OAAO,KAAK,+BAA+B,OAAO,KAAK,IAAI;AACnE;AAEO,SAAS,6BAA6B,SAA0B;AACtE,SAAO,KAAK,UAAU,6BAA6B,OAAkC,CAAC;AACvF;AAEO,SAAS,+BACf,OACA,UAAU,4BACyB;AACnC,QAAM,SAAS,YAAY,gCAAgC,OAAO,OAAO;AACzE,SAAO,OAAO,KAAK,GAAG,6BAA6B,OAAO,KAAK,CAAC,IAAI;AACrE;AAEO,SAAS,6BACf,aACmC;AACnC,QAAM,SAAS,iBAAiB,aAAa,0BAA0B;AACvE,SAAO,OAAO,KAAK,+BAA+B,OAAO,KAAK,IAAI;AACnE;","names":["object","modelConfig","schedule"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/protocol.ts"],"sourcesContent":["import {\n\ttype FutureExecutionKind,\n\tPROCESS_SEMANTIC_ENTRY_REF_KEYS,\n\tPROCESS_TURN_RECORD_PATH_TYPES,\n\tPROCESS_TURN_TYPES,\n\ttype ProcessInput,\n\ttype ProcessInstance,\n\ttype ProcessProject,\n\ttype WorkerLease,\n} from \"@leitwerk-dev/domain\";\nimport * as v from \"valibot\";\nimport type { StreamableWorkerEventType } from \"./streamable-events.js\";\n\nexport type ParseResult<T> = { ok: true; value: T } | { ok: false; error: string };\n\nexport const ok = <T>(value: T): ParseResult<T> => ({ ok: true, value });\nexport const err = (error: string): ParseResult<never> => ({ ok: false, error });\nexport const unknownRecordSchema = v.custom<Record<string, unknown>>(\n\t(value): value is Record<string, unknown> =>\n\t\ttypeof value === \"object\" && value !== null && !Array.isArray(value),\n\t\"must be an object\",\n);\nexport const nullableStringSchema = v.nullable(v.string());\nexport const optionalNullableStringSchema = v.optional(nullableStringSchema);\n\nexport function parseSchema<TSchema extends v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>>(\n\tschema: TSchema,\n\tvalue: unknown,\n\tcontext: string,\n): ParseResult<v.InferOutput<TSchema>> {\n\tconst parsed = v.safeParse(schema, value);\n\tif (parsed.success) {\n\t\treturn ok(parsed.output);\n\t}\n\tconst issue = parsed.issues?.[0];\n\tconst target = issue ? [context, v.getDotPath(issue)].filter(Boolean).join(\".\") : context;\n\treturn err(\n\t\tissue?.message === \"must be an object\"\n\t\t\t? `${target} must be an object`\n\t\t\t: `${target} ${issue?.message ?? \"is invalid\"}`,\n\t);\n}\n\nexport function parseLiteral<T extends string>(\n\tvalue: unknown,\n\tallowed: readonly T[],\n\tcontext: string,\n): ParseResult<T> {\n\treturn v.is(v.picklist(allowed), value)\n\t\t? ok(value as T)\n\t\t: err(`${context} must be one of: ${allowed.join(\", \")}`);\n}\n\nexport const WS_PROTOCOL_VERSION = \"leitwerk/ws/v1\";\n\nexport const WS_PROCESS_TYPES = {\n\tTOAST: \"process.toast\",\n\tFUTURE_UPDATED: \"future.updated\",\n} as const;\n\nexport const WS_PRIMARY_PATH_TYPES = {\n\tTURN_STARTED: \"primary_path.turn_started\",\n\tASSISTANT_PARTIAL: \"primary_path.assistant_partial\",\n\tUSAGE_UPDATED: \"primary_path.usage_updated\",\n\tASSISTANT_COMMITTED: \"primary_path.assistant_committed\",\n\tTOOL_CALL_STARTED: \"primary_path.tool_call_started\",\n\tTOOL_CALL_COMPLETED: \"primary_path.tool_call_completed\",\n\tTURN_ANNOTATION_CHANGED: \"primary_path.turn_annotation_changed\",\n\tLABEL_CHANGED: \"primary_path.label_changed\",\n\tCHANGED: \"primary_path.changed\",\n} as const;\n\nexport const WS_PI_STREAM_TYPES = {\n\tSTARTED: \"pi.stream.started\",\n\tDELTA: \"pi.stream.delta\",\n\tCOMPLETED: \"pi.stream.completed\",\n\tTOOL_STARTED: \"pi.tool.started\",\n\tTOOL_COMPLETED: \"pi.tool.completed\",\n\tLABEL_CHANGED: \"pi.label.changed\",\n\tERROR: \"pi.error\",\n\tRETRY_START: \"pi.retry.start\",\n\tRETRY_END: \"pi.retry.end\",\n\tUSAGE: \"pi.usage\",\n} as const;\n\ntype PiPayload<T = Record<string, never>> = {\n\tturnId?: string | null;\n\tturnRecordId?: string | null;\n\ttimestamp?: string;\n} & T;\n\nconst finiteNumberSchema = v.pipe(v.number(), v.finite());\nconst semanticEntryRefSchema = v.object({\n\tentryId: v.string(),\n\tturnRecordId: nullableStringSchema,\n});\nconst primaryPathBasePayloadEntries = {\n\tturnRecordId: nullableStringSchema,\n\tpiTurnId: nullableStringSchema,\n\ttimestamp: v.string(),\n};\nconst primaryPathTreeEntries = {\n\trootEntry: v.nullable(semanticEntryRefSchema),\n\tcurrentLeaf: v.nullable(semanticEntryRefSchema),\n};\nconst primaryPathTreeSchema = v.object(primaryPathTreeEntries);\nconst processTurnRecordSummarySchema = v.object({\n\tid: v.string(),\n\tturnId: v.string(),\n\tturnType: v.picklist(PROCESS_TURN_TYPES),\n\tpathType: v.picklist(PROCESS_TURN_RECORD_PATH_TYPES),\n\tstartedAt: v.string(),\n});\nconst usageCostSnapshotSchema = v.object({\n\tinput: finiteNumberSchema,\n\toutput: finiteNumberSchema,\n\treasoning: v.optional(finiteNumberSchema),\n\tcacheRead: finiteNumberSchema,\n\tcacheWrite: finiteNumberSchema,\n\ttotal: finiteNumberSchema,\n});\nconst usageSnapshotSchema = v.object({\n\tinput: finiteNumberSchema,\n\toutput: finiteNumberSchema,\n\tcacheRead: finiteNumberSchema,\n\tcacheWrite: finiteNumberSchema,\n\ttotalTokens: finiteNumberSchema,\n\tcost: v.nullable(usageCostSnapshotSchema),\n});\nconst turnAnnotationReferenceSchema = v.variant(\"kind\", [\n\tv.object({\n\t\tkind: v.literal(\"turn_record\"),\n\t\tturnRecordId: v.string(),\n\t\trole: nullableStringSchema,\n\t}),\n\tv.object({\n\t\tkind: v.literal(\"entry\"),\n\t\tentryId: v.string(),\n\t\trole: nullableStringSchema,\n\t}),\n\tv.object({\n\t\tkind: v.literal(\"semantic_entry_ref\"),\n\t\tref: v.picklist(PROCESS_SEMANTIC_ENTRY_REF_KEYS),\n\t\trole: nullableStringSchema,\n\t}),\n]);\nconst processTurnAnnotationSchema = v.object({\n\tid: v.string(),\n\tinstanceId: v.string(),\n\tannotationType: v.string(),\n\tannotationKey: nullableStringSchema,\n\treferences: v.array(turnAnnotationReferenceSchema),\n\tpayload: unknownRecordSchema,\n\tcreatedAt: v.string(),\n\tupdatedAt: v.string(),\n});\nconst PRIMARY_PATH_PAYLOAD_SCHEMAS = {\n\t[WS_PRIMARY_PATH_TYPES.TURN_STARTED]: v.object({\n\t\tturnRecord: processTurnRecordSummarySchema,\n\t}),\n\t[WS_PRIMARY_PATH_TYPES.ASSISTANT_PARTIAL]: v.object({\n\t\t...primaryPathBasePayloadEntries,\n\t\ttext: v.string(),\n\t\tstreamType: v.string(),\n\t}),\n\t[WS_PRIMARY_PATH_TYPES.USAGE_UPDATED]: v.object({\n\t\t...primaryPathBasePayloadEntries,\n\t\tusage: usageSnapshotSchema,\n\t}),\n\t[WS_PRIMARY_PATH_TYPES.ASSISTANT_COMMITTED]: v.object({\n\t\tturnRecord: processTurnRecordSummarySchema,\n\t\t...primaryPathTreeEntries,\n\t}),\n\t[WS_PRIMARY_PATH_TYPES.TOOL_CALL_STARTED]: v.object({\n\t\t...primaryPathBasePayloadEntries,\n\t\ttoolCallId: v.string(),\n\t\ttoolName: v.string(),\n\t\targuments: v.nullable(unknownRecordSchema),\n\t}),\n\t[WS_PRIMARY_PATH_TYPES.TOOL_CALL_COMPLETED]: v.object({\n\t\t...primaryPathBasePayloadEntries,\n\t\ttoolCallId: v.string(),\n\t\ttoolName: v.string(),\n\t\tresult: v.unknown(),\n\t\tisError: v.boolean(),\n\t}),\n\t[WS_PRIMARY_PATH_TYPES.TURN_ANNOTATION_CHANGED]: v.object({\n\t\tchange: v.picklist([\"created\", \"updated\"] as const),\n\t\tannotation: processTurnAnnotationSchema,\n\t}),\n\t[WS_PRIMARY_PATH_TYPES.LABEL_CHANGED]: v.object({\n\t\t...primaryPathBasePayloadEntries,\n\t\ttargetId: nullableStringSchema,\n\t\tlabel: nullableStringSchema,\n\t}),\n\t[WS_PRIMARY_PATH_TYPES.CHANGED]: primaryPathTreeSchema,\n} as const satisfies Record<\n\t(typeof WS_PRIMARY_PATH_TYPES)[keyof typeof WS_PRIMARY_PATH_TYPES],\n\tv.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>\n>;\ntype PrimaryPathPayloadByType = {\n\t[K in keyof typeof PRIMARY_PATH_PAYLOAD_SCHEMAS]: v.InferOutput<\n\t\t(typeof PRIMARY_PATH_PAYLOAD_SCHEMAS)[K]\n\t>;\n};\ntype PrimaryPathTree = v.InferOutput<typeof primaryPathTreeSchema>;\ntype PiUsagePayload = PiPayload<{\n\tinput?: number;\n\toutput?: number;\n\tcacheRead?: number;\n\tcacheWrite?: number;\n\ttotalTokens?: number;\n\tcost?: {\n\t\tinput?: number;\n\t\toutput?: number;\n\t\tcacheRead?: number;\n\t\tcacheWrite?: number;\n\t\ttotal?: number;\n\t};\n\tcacheHitRate?: number;\n}>;\n\nexport type WsDurability = \"durable\" | \"ephemeral\";\n\nexport type ProcessAttentionTarget =\n\t| { kind: \"action_required\" }\n\t| { kind: \"turn_failed\" }\n\t| { kind: \"worker_failed\" }\n\t| { kind: \"question_request\"; requestId: string };\n\nexport type WsPayloadByType = {\n\thello: { serverVersion: string };\n\tpong: Record<string, never>;\n\t\"process.created\": { process: ProcessInstance; processId: string; launcherId?: string };\n\t\"process.updated\": { process: Partial<ProcessInstance>; changedFields?: readonly string[] };\n\t\"process.deleted\": { instanceId: string };\n\t\"project.updated\": {\n\t\tprojectId: string;\n\t\tproject: {\n\t\t\tkey: string;\n\t\t\trepoLocator: string;\n\t\t\trepoLocatorKind: ProcessProject[\"repoLocatorKind\"];\n\t\t\tbranch: string;\n\t\t\tbaseBranch: string;\n\t\t\tworkBranch: string | null;\n\t\t\texternalId: string | null;\n\t\t\texternalUrl: string | null;\n\t\t\tpipelineStatus: string | null;\n\t\t};\n\t};\n\t\"worker.state\": {\n\t\tworker: WorkerLease;\n\t\tworkerId: string;\n\t\tstate: WorkerLease[\"state\"];\n\t\tpreviousState: WorkerLease[\"state\"];\n\t\treason: string;\n\t};\n\t\"process.input.queued\": { instanceId: string; input: ProcessInput };\n\t\"process.input.acknowledged\": { instanceId: string; inputId: string; sequence: number };\n\t\"process.event\": { eventType: string; level: string; message: string };\n\t[WS_PROCESS_TYPES.TOAST]: {\n\t\tinstanceId: string;\n\t\tlevel: \"warn\" | \"error\";\n\t\tmessage: string;\n\t\teventType: string;\n\t\tdedupeKey: string;\n\t\tttlMs: number;\n\t\t/** Optional typed Chronicle target applied only when the operator opens the toast. */\n\t\tfocusTarget?: ProcessAttentionTarget;\n\t};\n\t[WS_PROCESS_TYPES.FUTURE_UPDATED]: {\n\t\tfutureExecutionId: string;\n\t\toperation: \"created\" | \"updated\" | \"deleted\";\n\t\tkind: FutureExecutionKind;\n\t};\n\t\"plan.updated\": { planRevision: number; reviewState: string; approved: boolean; summary: string };\n\t\"review.updated\": {\n\t\thasIssues: boolean;\n\t\tissueCount: number;\n\t\treviewMarkdown?: string;\n\t\tnextTurnId: string | null;\n\t};\n\t[WS_PI_STREAM_TYPES.STARTED]: PiPayload;\n\t[WS_PI_STREAM_TYPES.DELTA]: PiPayload<{\n\t\ttext?: string;\n\t\tdelta?: string;\n\t\tchunk?: string;\n\t\tstreamType?: string;\n\t}>;\n\t[WS_PI_STREAM_TYPES.COMPLETED]: PiPayload;\n\t[WS_PI_STREAM_TYPES.TOOL_STARTED]: PiPayload<{\n\t\ttoolCallId?: string;\n\t\ttoolName?: string;\n\t\tname?: string;\n\t\targuments?: Record<string, unknown>;\n\t\targs?: Record<string, unknown>;\n\t}>;\n\t[WS_PI_STREAM_TYPES.TOOL_COMPLETED]: PiPayload<{\n\t\ttoolCallId?: string;\n\t\ttoolName?: string;\n\t\tname?: string;\n\t\tresult?: unknown;\n\t\tisError?: boolean;\n\t}>;\n\t[WS_PI_STREAM_TYPES.LABEL_CHANGED]: PiPayload<{\n\t\ttargetId?: string | null;\n\t\tlabel?: string | null;\n\t}>;\n\t[WS_PI_STREAM_TYPES.ERROR]: PiPayload<{\n\t\tmessage?: string;\n\t\terrorMessage?: string;\n\t\tsource?: string;\n\t\ttoolName?: string;\n\t\tstopReason?: string;\n\t\tprovider?: string;\n\t\tmodel?: string;\n\t}>;\n\t[WS_PI_STREAM_TYPES.RETRY_START]: PiPayload<{\n\t\tattempt?: number;\n\t\tmaxAttempts?: number;\n\t\tdelayMs?: number;\n\t\terrorMessage?: string;\n\t\tmessage?: string;\n\t}>;\n\t[WS_PI_STREAM_TYPES.RETRY_END]: PiPayload<{\n\t\tsuccess?: boolean;\n\t\tattempt?: number;\n\t\tfinalError?: string;\n\t\tmessage?: string;\n\t}>;\n\t[WS_PI_STREAM_TYPES.USAGE]: PiUsagePayload;\n\t[WS_PRIMARY_PATH_TYPES.TURN_STARTED]: PrimaryPathPayloadByType[typeof WS_PRIMARY_PATH_TYPES.TURN_STARTED];\n\t[WS_PRIMARY_PATH_TYPES.ASSISTANT_PARTIAL]: PrimaryPathPayloadByType[typeof WS_PRIMARY_PATH_TYPES.ASSISTANT_PARTIAL];\n\t[WS_PRIMARY_PATH_TYPES.USAGE_UPDATED]: PrimaryPathPayloadByType[typeof WS_PRIMARY_PATH_TYPES.USAGE_UPDATED];\n\t[WS_PRIMARY_PATH_TYPES.ASSISTANT_COMMITTED]: PrimaryPathPayloadByType[typeof WS_PRIMARY_PATH_TYPES.ASSISTANT_COMMITTED];\n\t[WS_PRIMARY_PATH_TYPES.TOOL_CALL_STARTED]: PrimaryPathPayloadByType[typeof WS_PRIMARY_PATH_TYPES.TOOL_CALL_STARTED];\n\t[WS_PRIMARY_PATH_TYPES.TOOL_CALL_COMPLETED]: PrimaryPathPayloadByType[typeof WS_PRIMARY_PATH_TYPES.TOOL_CALL_COMPLETED];\n\t[WS_PRIMARY_PATH_TYPES.TURN_ANNOTATION_CHANGED]: PrimaryPathPayloadByType[typeof WS_PRIMARY_PATH_TYPES.TURN_ANNOTATION_CHANGED];\n\t[WS_PRIMARY_PATH_TYPES.LABEL_CHANGED]: PrimaryPathPayloadByType[typeof WS_PRIMARY_PATH_TYPES.LABEL_CHANGED];\n\t[WS_PRIMARY_PATH_TYPES.CHANGED]: PrimaryPathTree;\n};\n\nexport const WS_FRAME_DURABILITY = {\n\thello: \"ephemeral\",\n\tpong: \"ephemeral\",\n\t\"process.created\": \"durable\",\n\t\"process.updated\": \"durable\",\n\t\"process.deleted\": \"durable\",\n\t\"project.updated\": \"durable\",\n\t\"worker.state\": \"durable\",\n\t\"process.input.queued\": \"durable\",\n\t\"process.input.acknowledged\": \"durable\",\n\t\"process.event\": \"durable\",\n\t[WS_PROCESS_TYPES.TOAST]: \"ephemeral\",\n\t[WS_PROCESS_TYPES.FUTURE_UPDATED]: \"durable\",\n\t\"plan.updated\": \"durable\",\n\t\"review.updated\": \"durable\",\n\t[WS_PI_STREAM_TYPES.STARTED]: \"ephemeral\",\n\t[WS_PI_STREAM_TYPES.DELTA]: \"ephemeral\",\n\t[WS_PI_STREAM_TYPES.COMPLETED]: \"ephemeral\",\n\t[WS_PI_STREAM_TYPES.TOOL_STARTED]: \"ephemeral\",\n\t[WS_PI_STREAM_TYPES.TOOL_COMPLETED]: \"ephemeral\",\n\t[WS_PI_STREAM_TYPES.LABEL_CHANGED]: \"ephemeral\",\n\t[WS_PI_STREAM_TYPES.ERROR]: \"ephemeral\",\n\t[WS_PI_STREAM_TYPES.RETRY_START]: \"ephemeral\",\n\t[WS_PI_STREAM_TYPES.RETRY_END]: \"ephemeral\",\n\t[WS_PI_STREAM_TYPES.USAGE]: \"ephemeral\",\n\t[WS_PRIMARY_PATH_TYPES.TURN_STARTED]: \"durable\",\n\t[WS_PRIMARY_PATH_TYPES.ASSISTANT_PARTIAL]: \"ephemeral\",\n\t[WS_PRIMARY_PATH_TYPES.USAGE_UPDATED]: \"ephemeral\",\n\t[WS_PRIMARY_PATH_TYPES.ASSISTANT_COMMITTED]: \"durable\",\n\t[WS_PRIMARY_PATH_TYPES.TOOL_CALL_STARTED]: \"ephemeral\",\n\t[WS_PRIMARY_PATH_TYPES.TOOL_CALL_COMPLETED]: \"ephemeral\",\n\t[WS_PRIMARY_PATH_TYPES.TURN_ANNOTATION_CHANGED]: \"durable\",\n\t[WS_PRIMARY_PATH_TYPES.LABEL_CHANGED]: \"durable\",\n\t[WS_PRIMARY_PATH_TYPES.CHANGED]: \"durable\",\n} as const satisfies Record<keyof WsPayloadByType, WsDurability>;\n\nexport type WsDurabilityByType = typeof WS_FRAME_DURABILITY;\nexport type KnownWsFrameType = keyof WsPayloadByType;\nexport type KnownDurableWsFrameType = {\n\t[K in KnownWsFrameType]: WsDurabilityByType[K] extends \"durable\" ? K : never;\n}[KnownWsFrameType];\nexport type KnownEphemeralWsFrameType = {\n\t[K in KnownWsFrameType]: WsDurabilityByType[K] extends \"ephemeral\" ? K : never;\n}[KnownWsFrameType];\nexport type WsFrameOfType<T extends KnownWsFrameType> = {\n\tprotocol: typeof WS_PROTOCOL_VERSION;\n\ttype: T;\n\tdurability: WsDurabilityByType[T];\n\tsentAt: string;\n\tinstanceId?: string;\n\tpayload: WsPayloadByType[T];\n};\nexport type DurableWsFrameInput = {\n\t[K in KnownDurableWsFrameType]: { type: K; instanceId?: string; payload: WsPayloadByType[K] };\n}[KnownDurableWsFrameType];\nexport type EphemeralWsFrameInput = {\n\t[K in KnownEphemeralWsFrameType]: { type: K; instanceId?: string; payload: WsPayloadByType[K] };\n}[KnownEphemeralWsFrameType];\nexport type WsFrame = { [K in KnownWsFrameType]: WsFrameOfType<K> }[KnownWsFrameType];\nexport type PrimaryPathWsFrameType =\n\t(typeof WS_PRIMARY_PATH_TYPES)[keyof typeof WS_PRIMARY_PATH_TYPES];\nexport type PrimaryPathWsFrame = Extract<WsFrame, { type: PrimaryPathWsFrameType }>;\n\nconst KNOWN_WS_FRAME_TYPES = Object.keys(WS_FRAME_DURABILITY) as KnownWsFrameType[];\nconst PRIMARY_PATH_WS_FRAME_TYPES = Object.values(\n\tWS_PRIMARY_PATH_TYPES,\n) as PrimaryPathWsFrameType[];\nconst WS_FRAME_SCHEMA = v.looseObject({\n\tprotocol: v.literal(WS_PROTOCOL_VERSION),\n\ttype: v.picklist(KNOWN_WS_FRAME_TYPES),\n\tdurability: v.picklist([\"durable\", \"ephemeral\"] as const),\n\tsentAt: v.string(),\n\tinstanceId: v.optional(v.string()),\n\tpayload: unknownRecordSchema,\n});\n\nexport function parsePrimaryPathWsFrameInput(value: unknown): ParseResult<PrimaryPathWsFrame> {\n\tconst frame = parseWsFrame(value);\n\tif (!frame.ok) {\n\t\treturn frame;\n\t}\n\tconst type = parseLiteral(\n\t\tframe.value.type,\n\t\tPRIMARY_PATH_WS_FRAME_TYPES,\n\t\t\"primary_path ws frame.type\",\n\t);\n\tif (!type.ok) {\n\t\treturn type;\n\t}\n\tconst payload = parseSchema(\n\t\tPRIMARY_PATH_PAYLOAD_SCHEMAS[type.value],\n\t\tframe.value.payload,\n\t\t`primary_path ws frame.payload (${type.value})`,\n\t);\n\treturn payload.ok\n\t\t? ok({ ...frame.value, type: type.value, payload: payload.value } as PrimaryPathWsFrame)\n\t\t: payload;\n}\n\nexport function parseWsFrame(value: unknown): ParseResult<WsFrame> {\n\tconst frame = parseSchema(WS_FRAME_SCHEMA, value, \"ws frame\");\n\tif (!frame.ok) {\n\t\treturn frame;\n\t}\n\treturn frame.value.durability !== WS_FRAME_DURABILITY[frame.value.type]\n\t\t? err(\n\t\t\t\t`ws frame.durability must be '${WS_FRAME_DURABILITY[frame.value.type]}' for type '${frame.value.type}'`,\n\t\t\t)\n\t\t: ok(frame.value as WsFrame);\n}\n\nexport function createDurableWsFrame(input: DurableWsFrameInput & { sentAt?: string }): WsFrame {\n\treturn {\n\t\tprotocol: WS_PROTOCOL_VERSION,\n\t\ttype: input.type,\n\t\tdurability: \"durable\",\n\t\tsentAt: input.sentAt ?? new Date().toISOString(),\n\t\t...(input.instanceId ? { instanceId: input.instanceId } : {}),\n\t\tpayload: input.payload,\n\t} as WsFrame;\n}\n\nexport function createEphemeralWsFrame(input: {\n\ttype: KnownEphemeralWsFrameType;\n\tinstanceId?: string;\n\tpayload: WsPayloadByType[KnownEphemeralWsFrameType];\n\tsentAt?: string;\n}): WsFrame {\n\treturn {\n\t\tprotocol: WS_PROTOCOL_VERSION,\n\t\ttype: input.type,\n\t\tdurability: \"ephemeral\",\n\t\tsentAt: input.sentAt ?? new Date().toISOString(),\n\t\t...(input.instanceId ? { instanceId: input.instanceId } : {}),\n\t\tpayload: input.payload,\n\t} as WsFrame;\n}\n\nconst WORKER_TO_WS_TYPE: Record<StreamableWorkerEventType, string> = {\n\t\"pi.stream.delta\": WS_PI_STREAM_TYPES.DELTA,\n\t\"pi.turn.start\": WS_PI_STREAM_TYPES.STARTED,\n\t\"pi.turn.end\": WS_PI_STREAM_TYPES.COMPLETED,\n\t\"pi.tool.call\": WS_PI_STREAM_TYPES.TOOL_STARTED,\n\t\"pi.tool.result\": WS_PI_STREAM_TYPES.TOOL_COMPLETED,\n\t\"pi.label.changed\": WS_PI_STREAM_TYPES.LABEL_CHANGED,\n\t\"pi.error\": WS_PI_STREAM_TYPES.ERROR,\n\t\"pi.retry.start\": WS_PI_STREAM_TYPES.RETRY_START,\n\t\"pi.retry.end\": WS_PI_STREAM_TYPES.RETRY_END,\n\t\"pi.usage\": WS_PI_STREAM_TYPES.USAGE,\n};\n\nexport type RawPiDiagnosticWsFrameType =\n\t(typeof WS_PI_STREAM_TYPES)[keyof typeof WS_PI_STREAM_TYPES];\n\nexport function mapWorkerEventToWsType(workerEventType: string): RawPiDiagnosticWsFrameType | null {\n\treturn (\n\t\t((WORKER_TO_WS_TYPE as Partial<Record<string, string>>)[workerEventType] as\n\t\t\t| RawPiDiagnosticWsFrameType\n\t\t\t| undefined) ?? null\n\t);\n}\n"],"mappings":";AAAA;AAAA,EAEC;AAAA,EACA;AAAA,EACA;AAA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AU,oBAAI,KAAK,GAAE,YAAY;AAAA,IAC/C,GAAI,MAAM,aAAa,EAAE,YAAY,MAAM,WAAW,IAAI,CAAC;AAAA,IAC3D,SAAS,MAAM;AAAA,EAChB;AACD;AAEO,SAAS,uBAAuB,OAK3B;AACX,SAAO;AAAA,IACN,UAAU;AAAA,IACV,MAAM,MAAM;AAAA,IACZ,YAAY;AAAA,IACZ,QAAQ,MAAM,WAAU,oBAAI,KAAK,GAAE,YAAY;AAAA,IAC/C,GAAI,MAAM,aAAa,EAAE,YAAY,MAAM,WAAW,IAAI,CAAC;AAAA,IAC3D,SAAS,MAAM;AAAA,EAChB;AACD;AAEA,IAAM,oBAA+D;AAAA,EACpE,mBAAmB,mBAAmB;AAAA,EACtC,iBAAiB,mBAAmB;AAAA,EACpC,eAAe,mBAAmB;AAAA,EAClC,gBAAgB,mBAAmB;AAAA,EACnC,kBAAkB,mBAAmB;AAAA,EACrC,oBAAoB,mBAAmB;AAAA,EACvC,YAAY,mBAAmB;AAAA,EAC/B,kBAAkB,mBAAmB;AAAA,EACrC,gBAAgB,mBAAmB;AAAA,EACnC,YAAY,mBAAmB;AAChC;AAKO,SAAS,uBAAuB,iBAA4D;AAClG,SACG,kBAAsD,eAAe,KAEtD;AAEnB;","names":[]}
|
package/dist/external-review.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"external-review.js","sourceRoot":"","sources":["../src/external-review.ts"],"names":[],"mappings":""}
|