@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
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
PrimaryPathActiveTurnSnapshot,
|
|
3
|
+
PrimaryPathToolCallSnapshot,
|
|
4
|
+
} from "./primary-path-snapshot.js";
|
|
5
|
+
import {
|
|
6
|
+
mergeUsageSnapshots,
|
|
7
|
+
normalizeUsageSnapshot,
|
|
8
|
+
type UsageSnapshot,
|
|
9
|
+
} from "./usage-snapshot.js";
|
|
10
|
+
import {
|
|
11
|
+
readWsEventStreamText,
|
|
12
|
+
readWsEventTimestamp,
|
|
13
|
+
readWsEventToolCallId,
|
|
14
|
+
readWsEventToolName,
|
|
15
|
+
} from "./ws-event-payloads.js";
|
|
16
|
+
|
|
17
|
+
export const REASONING_PREVIEW_MAX_CHARS = 1_024;
|
|
18
|
+
|
|
19
|
+
export interface CompactTurnSummary {
|
|
20
|
+
assistant: { text: string; thinking: string; lastUpdatedAt: string | null };
|
|
21
|
+
currentTool: Pick<
|
|
22
|
+
PrimaryPathToolCallSnapshot,
|
|
23
|
+
"toolCallId" | "toolName" | "status" | "isError"
|
|
24
|
+
> | null;
|
|
25
|
+
usage: UsageSnapshot | null;
|
|
26
|
+
toolCallCount: number;
|
|
27
|
+
traceItemCount: number;
|
|
28
|
+
/** The last persisted event incorporated into this projection. */
|
|
29
|
+
throughEventSequence: number;
|
|
30
|
+
lastTraceKind: "thinking" | "tool_call" | "operational_event" | null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Initial-page state. It never contains trace items, tool arguments or results. */
|
|
34
|
+
export interface CompactActiveTurnSnapshot
|
|
35
|
+
extends CompactTurnSummary,
|
|
36
|
+
Pick<
|
|
37
|
+
PrimaryPathActiveTurnSnapshot,
|
|
38
|
+
"turnRecordId" | "turnId" | "turnType" | "pathType" | "startedAt"
|
|
39
|
+
> {
|
|
40
|
+
summaryPending: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function emptyCompactTurnSummary(): CompactTurnSummary {
|
|
44
|
+
return {
|
|
45
|
+
assistant: { text: "", thinking: "", lastUpdatedAt: null },
|
|
46
|
+
currentTool: null,
|
|
47
|
+
usage: null,
|
|
48
|
+
toolCallCount: 0,
|
|
49
|
+
traceItemCount: 0,
|
|
50
|
+
throughEventSequence: 0,
|
|
51
|
+
lastTraceKind: null,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Retain paragraph context; wrapping and blank-line removal belong to the preview viewport. */
|
|
56
|
+
export function reasoningPreviewTail(text: string): string {
|
|
57
|
+
const normalized = text.replace(/\r\n?/g, "\n");
|
|
58
|
+
const lines = normalized.split("\n").filter((line) => line.trim() !== "");
|
|
59
|
+
const separator = /\n[^\S\n]*$/.test(normalized) ? "\n" : "";
|
|
60
|
+
return (lines.join("\n") + separator).slice(-REASONING_PREVIEW_MAX_CHARS);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function applyEventToCompactTurnSummary(
|
|
64
|
+
previous: CompactTurnSummary,
|
|
65
|
+
event: {
|
|
66
|
+
eventType: string;
|
|
67
|
+
data: Record<string, unknown>;
|
|
68
|
+
createdAt: string;
|
|
69
|
+
eventSequence: number;
|
|
70
|
+
},
|
|
71
|
+
): CompactTurnSummary {
|
|
72
|
+
if (event.eventSequence <= previous.throughEventSequence) return previous;
|
|
73
|
+
const next = {
|
|
74
|
+
...previous,
|
|
75
|
+
assistant: { ...previous.assistant },
|
|
76
|
+
throughEventSequence: event.eventSequence,
|
|
77
|
+
};
|
|
78
|
+
const { eventType, data } = event;
|
|
79
|
+
if (eventType === "pi.stream.delta") {
|
|
80
|
+
const text = readWsEventStreamText(data);
|
|
81
|
+
const key = data.streamType === "thinking" ? "thinking" : "text";
|
|
82
|
+
next.assistant[key] = reasoningPreviewTail(next.assistant[key] + text);
|
|
83
|
+
if (text) next.assistant.lastUpdatedAt = readWsEventTimestamp(data, event.createdAt);
|
|
84
|
+
if (key === "thinking" && text) {
|
|
85
|
+
if (next.lastTraceKind !== "thinking") next.traceItemCount++;
|
|
86
|
+
next.lastTraceKind = "thinking";
|
|
87
|
+
}
|
|
88
|
+
} else if (eventType === "pi.tool.call" || eventType === "pi.tool.result") {
|
|
89
|
+
const isResult = eventType === "pi.tool.result";
|
|
90
|
+
const toolCallId = (readWsEventToolCallId(data) ?? `tool-${event.eventSequence}`).slice(0, 256);
|
|
91
|
+
if (!isResult) {
|
|
92
|
+
next.toolCallCount++;
|
|
93
|
+
next.traceItemCount++;
|
|
94
|
+
next.lastTraceKind = "tool_call";
|
|
95
|
+
}
|
|
96
|
+
if (!isResult || !next.currentTool || next.currentTool.toolCallId === toolCallId) {
|
|
97
|
+
next.currentTool = {
|
|
98
|
+
toolCallId: toolCallId.slice(0, 256),
|
|
99
|
+
toolName: readWsEventToolName(data).slice(0, 256),
|
|
100
|
+
status: isResult ? "completed" : "running",
|
|
101
|
+
isError: data.isError === true,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
} else if (eventType === "pi.usage") {
|
|
105
|
+
next.usage = mergeUsageSnapshots(next.usage, normalizeUsageSnapshot(data));
|
|
106
|
+
} else if (
|
|
107
|
+
[
|
|
108
|
+
"pi.error",
|
|
109
|
+
"pi.retry.start",
|
|
110
|
+
"pi.retry.end",
|
|
111
|
+
"pi.compaction.start",
|
|
112
|
+
"pi.compaction.end",
|
|
113
|
+
].includes(eventType)
|
|
114
|
+
) {
|
|
115
|
+
next.traceItemCount++;
|
|
116
|
+
next.lastTraceKind = "operational_event";
|
|
117
|
+
}
|
|
118
|
+
return next;
|
|
119
|
+
}
|
package/src/config-snapshot.ts
CHANGED
|
@@ -144,6 +144,8 @@ export interface ProcessConfigSnapshot {
|
|
|
144
144
|
* selection. Must reference a configured `worker_runtime_profiles` entry.
|
|
145
145
|
*/
|
|
146
146
|
worker_runtime_profile?: string;
|
|
147
|
+
/** Server-only process-volume capacity override, for example 128Mi or 1Gi. */
|
|
148
|
+
storage_size?: string;
|
|
147
149
|
pi?: ProcessPiConfigSnapshot;
|
|
148
150
|
turn_configs: Record<string, ProcessTurnConfigSnapshot>;
|
|
149
151
|
/** Extension-owned watcher configuration, keyed by code-defined watcher id. */
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { isUnknownRecord } from "@leitwerk-dev/domain";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
|
|
4
|
+
// Wire shape only; the catalog validates manifests and hosts check supported versions.
|
|
5
|
+
const recordSchema = v.custom<Record<string, unknown>>(isUnknownRecord);
|
|
6
|
+
const versionSchema = v.custom<number>((value) => typeof value === "number");
|
|
7
|
+
|
|
8
|
+
export const leafOutcomeRendererDescriptorSchema = v.pipe(
|
|
9
|
+
recordSchema,
|
|
10
|
+
v.object({
|
|
11
|
+
ok: v.literal(true),
|
|
12
|
+
rendererId: v.string(),
|
|
13
|
+
kind: v.literal("custom_element"),
|
|
14
|
+
tagName: v.string(),
|
|
15
|
+
modulePath: v.string(),
|
|
16
|
+
rendererApiVersion: versionSchema,
|
|
17
|
+
extensionManifestId: v.string(),
|
|
18
|
+
moduleUrl: v.string(),
|
|
19
|
+
}),
|
|
20
|
+
);
|
|
21
|
+
export type LeafOutcomeRendererDescriptor = v.InferOutput<
|
|
22
|
+
typeof leafOutcomeRendererDescriptorSchema
|
|
23
|
+
>;
|
|
24
|
+
|
|
25
|
+
export const leafOutcomeRendererFailureSchema = v.pipe(
|
|
26
|
+
recordSchema,
|
|
27
|
+
v.object({
|
|
28
|
+
ok: v.literal(false),
|
|
29
|
+
rendererId: v.string(),
|
|
30
|
+
code: v.string(),
|
|
31
|
+
message: v.string(),
|
|
32
|
+
}),
|
|
33
|
+
);
|
|
34
|
+
export type LeafOutcomeRendererFailure = v.InferOutput<typeof leafOutcomeRendererFailureSchema>;
|
|
35
|
+
|
|
36
|
+
export const browserUiExtensionDescriptorSchema = v.pipe(
|
|
37
|
+
recordSchema,
|
|
38
|
+
v.object({
|
|
39
|
+
extensionManifestId: v.string(),
|
|
40
|
+
modulePath: v.string(),
|
|
41
|
+
moduleUrl: v.string(),
|
|
42
|
+
browserApiVersion: versionSchema,
|
|
43
|
+
}),
|
|
44
|
+
);
|
|
45
|
+
export type BrowserUiExtensionDescriptor = v.InferOutput<typeof browserUiExtensionDescriptorSchema>;
|
package/src/http-contracts.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
type FutureExecutionBlockReason,
|
|
5
5
|
type InstanceTurnConfigMap,
|
|
6
6
|
type LaunchModelConfigInput,
|
|
7
|
+
type LaunchRun,
|
|
7
8
|
normalizeActor,
|
|
8
9
|
normalizeLaunchModelConfigInput,
|
|
9
10
|
type ProcessEvent,
|
|
@@ -15,15 +16,18 @@ import {
|
|
|
15
16
|
type ProcessQuestionRequest,
|
|
16
17
|
type ProcessRowSlot,
|
|
17
18
|
type ProcessSelectedTurnModelSource,
|
|
19
|
+
type ProcessToolApprovalRequest,
|
|
18
20
|
type ProcessTurnAnnotation,
|
|
19
21
|
type ProcessTurnRecord,
|
|
20
22
|
type ProcessTurnType,
|
|
21
23
|
type QuestionAnswerDraft,
|
|
22
24
|
type SerializedProcessGraph,
|
|
25
|
+
type TurnProgressReport,
|
|
23
26
|
trimToNull,
|
|
24
27
|
type WorkerLease,
|
|
25
28
|
} from "@leitwerk-dev/domain";
|
|
26
29
|
import * as v from "valibot";
|
|
30
|
+
import type { CompactActiveTurnSnapshot } from "./compact-turn-summary.js";
|
|
27
31
|
import type {
|
|
28
32
|
ActionFormDefinition,
|
|
29
33
|
ActionFormFieldDefinition,
|
|
@@ -48,12 +52,32 @@ import {
|
|
|
48
52
|
unknownRecordSchema,
|
|
49
53
|
} from "./protocol.js";
|
|
50
54
|
import type { ToolCallRendererDefinition } from "./tool-renderer-contract.js";
|
|
55
|
+
import type { UsageCostSnapshot, UsageTokenCounts } from "./usage-snapshot.js";
|
|
56
|
+
|
|
57
|
+
export interface StartLaunchRunResponseBody {
|
|
58
|
+
launchRunId: string;
|
|
59
|
+
instanceId: string | null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface LaunchRunResponseBody {
|
|
63
|
+
launchRun: LaunchRun;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface ProcessLaunchRunsResponseBody {
|
|
67
|
+
launchRuns: LaunchRun[];
|
|
68
|
+
}
|
|
51
69
|
|
|
52
70
|
export interface AuthMeResponseBody {
|
|
53
71
|
authEnabled: boolean;
|
|
54
72
|
actor: Actor | null;
|
|
55
73
|
}
|
|
56
74
|
|
|
75
|
+
export interface SessionTransferOperationView {
|
|
76
|
+
attemptId: string;
|
|
77
|
+
phase: string;
|
|
78
|
+
blocksManualTurns: boolean;
|
|
79
|
+
}
|
|
80
|
+
|
|
57
81
|
export interface ProcessListItem {
|
|
58
82
|
process: ProcessInstance;
|
|
59
83
|
projects: ProcessProject[];
|
|
@@ -350,21 +374,8 @@ export interface ProcessLaunchConfigurationView {
|
|
|
350
374
|
projects: readonly ProcessLaunchConfigurationProjectView[];
|
|
351
375
|
}
|
|
352
376
|
|
|
353
|
-
export interface PiSessionUsageSnapshot {
|
|
354
|
-
|
|
355
|
-
output: number;
|
|
356
|
-
/** Provider-reported reasoning/thinking tokens. This is a subset of output tokens. */
|
|
357
|
-
reasoning?: number;
|
|
358
|
-
cacheRead: number;
|
|
359
|
-
cacheWrite: number;
|
|
360
|
-
totalTokens: number;
|
|
361
|
-
cost?: {
|
|
362
|
-
input: number;
|
|
363
|
-
output: number;
|
|
364
|
-
cacheRead: number;
|
|
365
|
-
cacheWrite: number;
|
|
366
|
-
total: number;
|
|
367
|
-
};
|
|
377
|
+
export interface PiSessionUsageSnapshot extends UsageTokenCounts {
|
|
378
|
+
cost?: UsageCostSnapshot;
|
|
368
379
|
}
|
|
369
380
|
|
|
370
381
|
export type PiSessionTextContentBlock = { type: "text"; text: string };
|
|
@@ -540,6 +551,7 @@ export interface SkillCatalogItem {
|
|
|
540
551
|
updateAvailable: boolean;
|
|
541
552
|
conflict: boolean;
|
|
542
553
|
stale: boolean;
|
|
554
|
+
modelInvocable: boolean;
|
|
543
555
|
usage: SkillUsageSummary;
|
|
544
556
|
}
|
|
545
557
|
|
|
@@ -554,6 +566,7 @@ export interface InstalledSkillCatalogItem {
|
|
|
554
566
|
registrationKind: SkillRegistrationKind;
|
|
555
567
|
sourceRepositoryId: string | null;
|
|
556
568
|
updateAvailable: boolean;
|
|
569
|
+
modelInvocable: boolean;
|
|
557
570
|
usage: SkillUsageSummary;
|
|
558
571
|
}
|
|
559
572
|
|
|
@@ -600,16 +613,9 @@ export interface ProcessOverviewItem extends ProcessRowSlot {
|
|
|
600
613
|
closedAt: string | null;
|
|
601
614
|
}
|
|
602
615
|
|
|
603
|
-
interface FutureExecutionOverviewItemBase
|
|
604
|
-
|
|
605
|
-
scheduleKind: "once" | "cron";
|
|
606
|
-
processId: string;
|
|
607
|
-
nextRunAt: string;
|
|
608
|
-
cronExpression: string | null;
|
|
609
|
-
title: string;
|
|
616
|
+
interface FutureExecutionOverviewItemBase
|
|
617
|
+
extends Omit<FutureExecutionBaseSummary, "kind" | "subtitle" | "modelSelection"> {
|
|
610
618
|
initialPromptPreview: string | null;
|
|
611
|
-
status?: "scheduled" | "blocked";
|
|
612
|
-
blockedReason?: FutureExecutionBlockReason | null;
|
|
613
619
|
}
|
|
614
620
|
|
|
615
621
|
export interface FutureLaunchOverviewItem extends FutureExecutionOverviewItemBase {
|
|
@@ -719,6 +725,10 @@ export interface ProcessTimelineTurnSummary {
|
|
|
719
725
|
summary: string;
|
|
720
726
|
output: string;
|
|
721
727
|
turnResultMarkdown: string;
|
|
728
|
+
resultSummary?: string;
|
|
729
|
+
reviewedTurnRecordId?: string;
|
|
730
|
+
resources?: import("@leitwerk-dev/domain").TurnProgressLink[];
|
|
731
|
+
transition?: { selectedTurnId: string; targetTurnRecordId?: string; accepted: boolean };
|
|
722
732
|
pathType: ProcessTurnRecord["pathType"];
|
|
723
733
|
createdAt: string;
|
|
724
734
|
presentation: ProcessTimelineTurnPresentation;
|
|
@@ -730,6 +740,8 @@ export interface ProcessTimelineTurnSummary {
|
|
|
730
740
|
startedAt: string;
|
|
731
741
|
endedAt: string | null;
|
|
732
742
|
actionSource: "ui" | "external" | "scheduled" | null;
|
|
743
|
+
progress?: TurnProgressReport | null;
|
|
744
|
+
progressRecordedAt?: string;
|
|
733
745
|
}
|
|
734
746
|
|
|
735
747
|
export type ProcessTimelineInputSummary = Pick<
|
|
@@ -737,7 +749,18 @@ export type ProcessTimelineInputSummary = Pick<
|
|
|
737
749
|
"id" | "sequence" | "source" | "kind" | "bodyMarkdown" | "receivedAt" | "consumedAt"
|
|
738
750
|
>;
|
|
739
751
|
|
|
752
|
+
export interface ProcessExternalObservation {
|
|
753
|
+
summary: string;
|
|
754
|
+
links?: import("@leitwerk-dev/domain").TurnProgressLink[];
|
|
755
|
+
observedAt: string;
|
|
756
|
+
subject: string;
|
|
757
|
+
revision: string;
|
|
758
|
+
}
|
|
759
|
+
|
|
740
760
|
export interface ProcessExternalTriggerSignal {
|
|
761
|
+
observation?: ProcessExternalObservation;
|
|
762
|
+
refreshError?: string | null;
|
|
763
|
+
refreshedAt?: string;
|
|
741
764
|
triggerId: string;
|
|
742
765
|
state: "error" | "armed" | "triggered" | "waiting";
|
|
743
766
|
occurredAt: string | null;
|
|
@@ -763,6 +786,7 @@ export interface CurrentTurnRecoverySummary extends CurrentErrorSummary {
|
|
|
763
786
|
turnRecordId: string;
|
|
764
787
|
defaultContinuePrompt: string;
|
|
765
788
|
canContinue: boolean;
|
|
789
|
+
supportsModelOverride: boolean;
|
|
766
790
|
defaultModelProfileId: string | null;
|
|
767
791
|
providerOptions: Record<string, string>;
|
|
768
792
|
}
|
|
@@ -775,6 +799,39 @@ export interface StartupRecoverySummary extends CurrentErrorSummary {
|
|
|
775
799
|
providerOptions: Record<string, string>;
|
|
776
800
|
}
|
|
777
801
|
|
|
802
|
+
export type StartupAttemptStatus = "starting" | "failed" | "succeeded" | "recovered" | "superseded";
|
|
803
|
+
|
|
804
|
+
export interface StartupAttemptStepSummary {
|
|
805
|
+
/** Observed phase interval; absent for older servers or unavailable evidence. */
|
|
806
|
+
startedAt?: string | null;
|
|
807
|
+
endedAt?: string | null;
|
|
808
|
+
detail?: string;
|
|
809
|
+
id: "start_worker" | "connect_worker" | "prepare_workspace" | "start_first_turn";
|
|
810
|
+
label: string;
|
|
811
|
+
status: "pending" | "in_progress" | "completed" | "failed" | "superseded";
|
|
812
|
+
occurredAt: string | null;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
/** Worker-start history derived from correlated start, lease, readiness, and turn records. */
|
|
816
|
+
export interface StartupAttemptSummary {
|
|
817
|
+
startRecordId: string;
|
|
818
|
+
workerLeaseId: string | null;
|
|
819
|
+
status: StartupAttemptStatus;
|
|
820
|
+
startedAt: string;
|
|
821
|
+
readyAt: string | null;
|
|
822
|
+
durationMs: number | null;
|
|
823
|
+
summary: string | null;
|
|
824
|
+
recoveredByStartRecordId: string | null;
|
|
825
|
+
steps: StartupAttemptStepSummary[];
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
export interface ProcessStartupSummary {
|
|
829
|
+
workerStarts?: import("@leitwerk-dev/domain").PhysicalWorkerStart[];
|
|
830
|
+
authoritativeAttemptId: string | null;
|
|
831
|
+
attempts: StartupAttemptSummary[];
|
|
832
|
+
recovery: StartupRecoverySummary | null;
|
|
833
|
+
}
|
|
834
|
+
|
|
778
835
|
export type CurrentProcessErrorSummary = CurrentErrorSummary;
|
|
779
836
|
|
|
780
837
|
export interface ProcessUsageEstimateSnapshot {
|
|
@@ -787,7 +844,11 @@ export interface ProcessUsageEstimateSnapshot {
|
|
|
787
844
|
isPartial: boolean;
|
|
788
845
|
}
|
|
789
846
|
|
|
790
|
-
export interface PrimaryPathUiSnapshot extends PrimaryPathSnapshot {
|
|
847
|
+
export interface PrimaryPathUiSnapshot extends Omit<PrimaryPathSnapshot, "turnState"> {
|
|
848
|
+
throughEventSequence: number;
|
|
849
|
+
turnState: Omit<PrimaryPathSnapshot["turnState"], "activeTurn"> & {
|
|
850
|
+
activeTurn: CompactActiveTurnSnapshot | null;
|
|
851
|
+
};
|
|
791
852
|
entryCount: number;
|
|
792
853
|
entriesOmitted: true;
|
|
793
854
|
}
|
|
@@ -816,8 +877,11 @@ export type ProcessUiSnapshotProcess = Pick<
|
|
|
816
877
|
*/
|
|
817
878
|
export interface ProcessDetailUiSnapshotResponseBody {
|
|
818
879
|
process: ProcessUiSnapshotProcess;
|
|
880
|
+
/** Next turn on the declared happy path, including human decisions. */
|
|
881
|
+
plannedNextTurn?: Pick<ProcessSelectedTurnSummary, "turnId" | "description"> | null;
|
|
819
882
|
/** Durable requests in Chronicle order; at most one is open for the current turn. */
|
|
820
883
|
questionRequests: ProcessQuestionRequest[];
|
|
884
|
+
toolApprovalRequests: ProcessToolApprovalRequest[];
|
|
821
885
|
leafOutcomeSnapshots: ProcessLeafOutcomeSnapshot[];
|
|
822
886
|
processDisplayName: string | null;
|
|
823
887
|
processFlow: ProcessFlowView;
|
|
@@ -833,11 +897,15 @@ export interface ProcessDetailUiSnapshotResponseBody {
|
|
|
833
897
|
timeline: ProcessTimelineSnapshot;
|
|
834
898
|
instanceTree: ProcessInstanceTreeResponseBody;
|
|
835
899
|
recovery: CurrentTurnRecoverySummary | null;
|
|
900
|
+
/** Authoritative startup history and current remediation. */
|
|
901
|
+
startup: ProcessStartupSummary;
|
|
902
|
+
/** Compatibility alias for startup.recovery. */
|
|
836
903
|
startupRecovery: StartupRecoverySummary | null;
|
|
837
904
|
processError: CurrentProcessErrorSummary | null;
|
|
838
905
|
usageEstimate: ProcessUsageEstimateSnapshot | null;
|
|
839
906
|
persistedModelSelectionWarning: string | null;
|
|
840
907
|
session: { signature: string | null };
|
|
908
|
+
sessionTransfer: SessionTransferOperationView | null;
|
|
841
909
|
}
|
|
842
910
|
|
|
843
911
|
export type InstanceTreeTurnResultState = "succeeded" | "failed" | "aborted" | "pending";
|
|
@@ -869,6 +937,8 @@ export interface ProcessInstanceTreeResponseBody {
|
|
|
869
937
|
}
|
|
870
938
|
|
|
871
939
|
export interface TurnReasoningDetailResponseBody {
|
|
940
|
+
state: "live" | "committed";
|
|
941
|
+
throughEventSequence: number;
|
|
872
942
|
instanceId: string;
|
|
873
943
|
turnRecordId: string;
|
|
874
944
|
sessionSignature: string | null;
|
|
@@ -922,6 +992,12 @@ export interface LauncherMutationResponseBody {
|
|
|
922
992
|
error?: string | null;
|
|
923
993
|
}
|
|
924
994
|
|
|
995
|
+
export interface FutureLaunchMutationResponseBody {
|
|
996
|
+
kind: "scheduled";
|
|
997
|
+
futureExecution: FutureLaunchSummary | null;
|
|
998
|
+
error?: string | null;
|
|
999
|
+
}
|
|
1000
|
+
|
|
925
1001
|
export type ScheduledActionMutationResponseBody = {
|
|
926
1002
|
kind?: "scheduled";
|
|
927
1003
|
scheduledAction?: ScheduledActionDetail | null;
|
|
@@ -938,7 +1014,7 @@ export type PrimaryPathSnapshotResponseBody = PrimaryPathSnapshot;
|
|
|
938
1014
|
|
|
939
1015
|
export type CronPreviewResponseBody = { nextRunAt: string };
|
|
940
1016
|
|
|
941
|
-
type ParsedLauncherRequestBody = {
|
|
1017
|
+
export type ParsedLauncherRequestBody = {
|
|
942
1018
|
title: string | null;
|
|
943
1019
|
titleProvided: boolean;
|
|
944
1020
|
launcherInput: Record<string, unknown>;
|
|
@@ -950,7 +1026,7 @@ type ParsedLauncherRequestBody = {
|
|
|
950
1026
|
scheduleProvided: boolean;
|
|
951
1027
|
};
|
|
952
1028
|
|
|
953
|
-
type ParsedActionRequestBody = {
|
|
1029
|
+
export type ParsedActionRequestBody = {
|
|
954
1030
|
input: Record<string, unknown>;
|
|
955
1031
|
inputProvided: boolean;
|
|
956
1032
|
nextTurnModelProfileId?: string | null;
|
|
@@ -1062,12 +1138,6 @@ type FutureLaunchPayloadBase = v.InferOutput<typeof futureLaunchPayloadInputSche
|
|
|
1062
1138
|
type FutureActionPayloadBase = v.InferOutput<typeof futureActionPayloadInputSchema>;
|
|
1063
1139
|
const cloneUnknownRecord = (value?: Record<string, unknown> | null) =>
|
|
1064
1140
|
value ? { ...value } : null;
|
|
1065
|
-
const cloneTurnConfigMap = (turnConfigs: InstanceTurnConfigMap = {}) =>
|
|
1066
|
-
Object.fromEntries(
|
|
1067
|
-
Object.entries(turnConfigs as Record<string, InstanceTurnConfigMap[string]>).map(
|
|
1068
|
-
([turnId, turnConfig]) => [turnId, { ...turnConfig }],
|
|
1069
|
-
),
|
|
1070
|
-
) as InstanceTurnConfigMap;
|
|
1071
1141
|
const normalizeFutureLaunchPayload = (payload: FutureLaunchPayloadBase) => {
|
|
1072
1142
|
const modelConfig = normalizeLaunchModelConfigInput(
|
|
1073
1143
|
(payload.modelConfig ?? {}) as LaunchModelConfigInput,
|
|
@@ -1076,7 +1146,7 @@ const normalizeFutureLaunchPayload = (payload: FutureLaunchPayloadBase) => {
|
|
|
1076
1146
|
launcherInput: cloneUnknownRecord(payload.launcherInput) ?? {},
|
|
1077
1147
|
modelConfig: {
|
|
1078
1148
|
defaultModelProfileId: modelConfig.defaultModelProfileId ?? null,
|
|
1079
|
-
turnConfigs:
|
|
1149
|
+
turnConfigs: { ...modelConfig.turnConfigs },
|
|
1080
1150
|
},
|
|
1081
1151
|
actor: normalizeActor(payload.actor),
|
|
1082
1152
|
selectedSkillIds: [
|
|
@@ -1132,10 +1202,6 @@ const normalizeFutureActionPayload = (payload: FutureActionPayloadBase) => ({
|
|
|
1132
1202
|
export type FutureLaunchPayload = ReturnType<typeof normalizeFutureLaunchPayload>;
|
|
1133
1203
|
export type FutureActionPayload = ReturnType<typeof normalizeFutureActionPayload>;
|
|
1134
1204
|
|
|
1135
|
-
function hasOwn(object: Record<string, unknown>, key: string): boolean {
|
|
1136
|
-
return Object.hasOwn(object, key);
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
1205
|
function parseJsonPayload(payloadJson: string, context: string): ParseResult<unknown> {
|
|
1140
1206
|
try {
|
|
1141
1207
|
return ok(JSON.parse(payloadJson));
|
|
@@ -1264,7 +1330,7 @@ export function parseLauncherModelConfigInput(
|
|
|
1264
1330
|
}
|
|
1265
1331
|
const defaultModelProfileId = trimToNull(record.value.defaultModelProfileId);
|
|
1266
1332
|
if (
|
|
1267
|
-
hasOwn(record.value, "defaultModelProfileId") &&
|
|
1333
|
+
Object.hasOwn(record.value, "defaultModelProfileId") &&
|
|
1268
1334
|
record.value.defaultModelProfileId !== null &&
|
|
1269
1335
|
typeof record.value.defaultModelProfileId !== "string"
|
|
1270
1336
|
) {
|
|
@@ -1285,7 +1351,11 @@ export function parseLauncherModelConfigInput(
|
|
|
1285
1351
|
}
|
|
1286
1352
|
|
|
1287
1353
|
function hasInlineScheduleFields(object: Record<string, unknown>): boolean {
|
|
1288
|
-
return
|
|
1354
|
+
return (
|
|
1355
|
+
Object.hasOwn(object, "mode") ||
|
|
1356
|
+
Object.hasOwn(object, "runAt") ||
|
|
1357
|
+
Object.hasOwn(object, "cronExpression")
|
|
1358
|
+
);
|
|
1289
1359
|
}
|
|
1290
1360
|
|
|
1291
1361
|
export function parseLauncherRequestBody(value: unknown): ParseResult<ParsedLauncherRequestBody> {
|
|
@@ -1306,7 +1376,7 @@ export function parseLauncherRequestBody(value: unknown): ParseResult<ParsedLaun
|
|
|
1306
1376
|
return record;
|
|
1307
1377
|
}
|
|
1308
1378
|
if (
|
|
1309
|
-
hasOwn(record.value, "title") ||
|
|
1379
|
+
Object.hasOwn(record.value, "title") ||
|
|
1310
1380
|
record.value.launcherInput !== undefined ||
|
|
1311
1381
|
record.value.skillIds !== undefined ||
|
|
1312
1382
|
record.value.modelConfig !== undefined ||
|
|
@@ -1314,12 +1384,7 @@ export function parseLauncherRequestBody(value: unknown): ParseResult<ParsedLaun
|
|
|
1314
1384
|
) {
|
|
1315
1385
|
if (
|
|
1316
1386
|
Object.keys(record.value).some(
|
|
1317
|
-
(key) =>
|
|
1318
|
-
key !== "title" &&
|
|
1319
|
-
key !== "launcherInput" &&
|
|
1320
|
-
key !== "skillIds" &&
|
|
1321
|
-
key !== "modelConfig" &&
|
|
1322
|
-
key !== "schedule",
|
|
1387
|
+
(key) => !Object.hasOwn(launcherStructuredBodySchema.entries, key),
|
|
1323
1388
|
)
|
|
1324
1389
|
) {
|
|
1325
1390
|
return err(
|
|
@@ -1344,14 +1409,14 @@ export function parseLauncherRequestBody(value: unknown): ParseResult<ParsedLaun
|
|
|
1344
1409
|
}
|
|
1345
1410
|
return ok({
|
|
1346
1411
|
title: parsed.value.title ?? null,
|
|
1347
|
-
titleProvided: hasOwn(record.value, "title"),
|
|
1412
|
+
titleProvided: Object.hasOwn(record.value, "title"),
|
|
1348
1413
|
launcherInput: parsed.value.launcherInput ?? {},
|
|
1349
|
-
launcherInputProvided: hasOwn(record.value, "launcherInput"),
|
|
1350
|
-
...(hasOwn(record.value, "skillIds") ? { skillIds: [...skillIds] } : {}),
|
|
1414
|
+
launcherInputProvided: Object.hasOwn(record.value, "launcherInput"),
|
|
1415
|
+
...(Object.hasOwn(record.value, "skillIds") ? { skillIds: [...skillIds] } : {}),
|
|
1351
1416
|
modelConfig: modelConfig.value,
|
|
1352
|
-
modelConfigProvided: hasOwn(record.value, "modelConfig"),
|
|
1417
|
+
modelConfigProvided: Object.hasOwn(record.value, "modelConfig"),
|
|
1353
1418
|
schedule: schedule.value,
|
|
1354
|
-
scheduleProvided: hasOwn(record.value, "schedule"),
|
|
1419
|
+
scheduleProvided: Object.hasOwn(record.value, "schedule"),
|
|
1355
1420
|
});
|
|
1356
1421
|
}
|
|
1357
1422
|
const modelConfig = parseLauncherModelConfigInput(record.value, "modelConfig");
|
|
@@ -1388,7 +1453,7 @@ export function parseActionRequestBody(value: unknown): ParseResult<ParsedAction
|
|
|
1388
1453
|
if (!record.ok) {
|
|
1389
1454
|
return record;
|
|
1390
1455
|
}
|
|
1391
|
-
const nextTurnModelProfileIdProvided = hasOwn(record.value, "nextTurnModelProfileId");
|
|
1456
|
+
const nextTurnModelProfileIdProvided = Object.hasOwn(record.value, "nextTurnModelProfileId");
|
|
1392
1457
|
if (
|
|
1393
1458
|
record.value.input !== undefined ||
|
|
1394
1459
|
nextTurnModelProfileIdProvided ||
|
|
@@ -1396,7 +1461,7 @@ export function parseActionRequestBody(value: unknown): ParseResult<ParsedAction
|
|
|
1396
1461
|
) {
|
|
1397
1462
|
if (
|
|
1398
1463
|
Object.keys(record.value).some(
|
|
1399
|
-
(key) =>
|
|
1464
|
+
(key) => !Object.hasOwn(actionStructuredBodySchema.entries, key),
|
|
1400
1465
|
)
|
|
1401
1466
|
) {
|
|
1402
1467
|
return err("action request body must use { input, nextTurnModelProfileId }");
|
|
@@ -1411,10 +1476,10 @@ export function parseActionRequestBody(value: unknown): ParseResult<ParsedAction
|
|
|
1411
1476
|
}
|
|
1412
1477
|
return ok({
|
|
1413
1478
|
input: parsed.value.input ?? {},
|
|
1414
|
-
inputProvided: hasOwn(record.value, "input"),
|
|
1479
|
+
inputProvided: Object.hasOwn(record.value, "input"),
|
|
1415
1480
|
nextTurnModelProfileIdProvided,
|
|
1416
1481
|
schedule: schedule.value,
|
|
1417
|
-
scheduleProvided: hasOwn(record.value, "schedule"),
|
|
1482
|
+
scheduleProvided: Object.hasOwn(record.value, "schedule"),
|
|
1418
1483
|
...(nextTurnModelProfileIdProvided
|
|
1419
1484
|
? { nextTurnModelProfileId: parsed.value.nextTurnModelProfileId ?? null }
|
|
1420
1485
|
: {}),
|
|
@@ -1430,9 +1495,6 @@ export function parseActionRequestBody(value: unknown): ParseResult<ParsedAction
|
|
|
1430
1495
|
nextTurnModelProfileIdProvided,
|
|
1431
1496
|
schedule: schedule.value,
|
|
1432
1497
|
scheduleProvided: hasInlineScheduleFields(record.value),
|
|
1433
|
-
...(nextTurnModelProfileIdProvided
|
|
1434
|
-
? { nextTurnModelProfileId: trimToNull(record.value.nextTurnModelProfileId) }
|
|
1435
|
-
: {}),
|
|
1436
1498
|
});
|
|
1437
1499
|
}
|
|
1438
1500
|
|
|
@@ -1473,3 +1535,10 @@ export function parseFutureActionPayloadJson(
|
|
|
1473
1535
|
const parsed = parseJsonPayload(payloadJson, "Scheduled action payload");
|
|
1474
1536
|
return parsed.ok ? parseFutureActionPayloadObject(parsed.value) : parsed;
|
|
1475
1537
|
}
|
|
1538
|
+
|
|
1539
|
+
export type {
|
|
1540
|
+
ApiTokenMetadata,
|
|
1541
|
+
ApiTokenPolicy,
|
|
1542
|
+
ApiTokensResponseBody,
|
|
1543
|
+
CreateApiTokenResponseBody,
|
|
1544
|
+
} from "./api-token-contracts.js";
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
export * from "./compact-turn-summary.js";
|
|
1
2
|
export * from "./config-snapshot.js";
|
|
3
|
+
export * from "./extension-ui-contracts.js";
|
|
2
4
|
export * from "./external-review.js";
|
|
3
5
|
export * from "./form-contract.js";
|
|
4
6
|
export * from "./http-contracts.js";
|
|
@@ -11,10 +13,13 @@ export * from "./protocol.js";
|
|
|
11
13
|
export * from "./session-entry-tree.js";
|
|
12
14
|
export * from "./streamable-events.js";
|
|
13
15
|
export * from "./text-preview.js";
|
|
16
|
+
export * from "./ticket-creation-contracts.js";
|
|
14
17
|
export * from "./timeline-projection.js";
|
|
15
18
|
export * from "./timestamp-ordering.js";
|
|
16
19
|
export * from "./tool-renderer-contract.js";
|
|
20
|
+
export * from "./tool-result-truncation.js";
|
|
17
21
|
export * from "./turn-continuation.js";
|
|
22
|
+
export * from "./turn-trace-projection.js";
|
|
18
23
|
export * from "./usage-by-turn-record.js";
|
|
19
24
|
export * from "./usage-snapshot.js";
|
|
20
25
|
export * from "./ws-event-payloads.js";
|
package/src/initial-prompt.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isUnknownRecord as isRecord } from "@leitwerk-dev/domain";
|
|
1
2
|
import type { FutureExecutionOverviewItem, FutureExecutionSummary } from "./http-contracts.js";
|
|
2
3
|
|
|
3
4
|
// Best-effort extraction of an operator-facing prompt/command from launch params
|
|
@@ -20,10 +21,6 @@ export const INITIAL_PROMPT_FIELD_PRIORITY = [
|
|
|
20
21
|
"description",
|
|
21
22
|
] as const;
|
|
22
23
|
|
|
23
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
24
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
24
|
function normalizePromptValue(value: string): string | null {
|
|
28
25
|
const normalized = value.replace(/\s+/g, " ").trim();
|
|
29
26
|
return normalized.length > 0 ? normalized : null;
|
|
@@ -42,7 +39,7 @@ export function truncatePromptPreview(
|
|
|
42
39
|
function readStringField(record: Record<string, unknown>, fieldName: string): string | null {
|
|
43
40
|
const exact = record[fieldName];
|
|
44
41
|
if (typeof exact === "string") {
|
|
45
|
-
return
|
|
42
|
+
return exact.trim() ? exact : null;
|
|
46
43
|
}
|
|
47
44
|
|
|
48
45
|
const normalizedFieldName = fieldName.toLowerCase();
|
|
@@ -50,7 +47,7 @@ function readStringField(record: Record<string, unknown>, fieldName: string): st
|
|
|
50
47
|
if (key.toLowerCase() !== normalizedFieldName || typeof value !== "string") {
|
|
51
48
|
continue;
|
|
52
49
|
}
|
|
53
|
-
return
|
|
50
|
+
return value.trim() ? value : null;
|
|
54
51
|
}
|
|
55
52
|
|
|
56
53
|
return null;
|