@leitwerk-dev/domain 0.1.0 → 0.1.2

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.
Files changed (69) hide show
  1. package/dist/index.d.ts +811 -18
  2. package/dist/index.js +1005 -15
  3. package/dist/index.js.map +1 -1
  4. package/package.json +1 -1
  5. package/dist/actor.d.ts +0 -18
  6. package/dist/actor.d.ts.map +0 -1
  7. package/dist/actor.js +0 -72
  8. package/dist/actor.js.map +0 -1
  9. package/dist/domain-model.d.ts +0 -472
  10. package/dist/domain-model.d.ts.map +0 -1
  11. package/dist/domain-model.js +0 -171
  12. package/dist/domain-model.js.map +0 -1
  13. package/dist/index.d.ts.map +0 -1
  14. package/dist/launcher-recent-values.d.ts +0 -10
  15. package/dist/launcher-recent-values.d.ts.map +0 -1
  16. package/dist/launcher-recent-values.js +0 -60
  17. package/dist/launcher-recent-values.js.map +0 -1
  18. package/dist/markdown-normalize.d.ts +0 -4
  19. package/dist/markdown-normalize.d.ts.map +0 -1
  20. package/dist/markdown-normalize.js +0 -14
  21. package/dist/markdown-normalize.js.map +0 -1
  22. package/dist/process-definitions.d.ts +0 -68
  23. package/dist/process-definitions.d.ts.map +0 -1
  24. package/dist/process-definitions.js +0 -2
  25. package/dist/process-definitions.js.map +0 -1
  26. package/dist/process-model-config.d.ts +0 -24
  27. package/dist/process-model-config.d.ts.map +0 -1
  28. package/dist/process-model-config.js +0 -68
  29. package/dist/process-model-config.js.map +0 -1
  30. package/dist/process-row-slots.d.ts +0 -17
  31. package/dist/process-row-slots.d.ts.map +0 -1
  32. package/dist/process-row-slots.js +0 -45
  33. package/dist/process-row-slots.js.map +0 -1
  34. package/dist/process-state-json.d.ts +0 -16
  35. package/dist/process-state-json.d.ts.map +0 -1
  36. package/dist/process-state-json.js +0 -102
  37. package/dist/process-state-json.js.map +0 -1
  38. package/dist/repo-locator.d.ts +0 -10
  39. package/dist/repo-locator.d.ts.map +0 -1
  40. package/dist/repo-locator.js +0 -82
  41. package/dist/repo-locator.js.map +0 -1
  42. package/dist/review-subject.d.ts +0 -9
  43. package/dist/review-subject.d.ts.map +0 -1
  44. package/dist/review-subject.js +0 -18
  45. package/dist/review-subject.js.map +0 -1
  46. package/dist/semantic-entry-refs.d.ts +0 -34
  47. package/dist/semantic-entry-refs.d.ts.map +0 -1
  48. package/dist/semantic-entry-refs.js +0 -79
  49. package/dist/semantic-entry-refs.js.map +0 -1
  50. package/dist/string-normalize.d.ts +0 -12
  51. package/dist/string-normalize.d.ts.map +0 -1
  52. package/dist/string-normalize.js +0 -28
  53. package/dist/string-normalize.js.map +0 -1
  54. package/dist/turn-acceptance.d.ts +0 -3
  55. package/dist/turn-acceptance.d.ts.map +0 -1
  56. package/dist/turn-acceptance.js +0 -2
  57. package/dist/turn-acceptance.js.map +0 -1
  58. package/dist/turn-annotations.d.ts +0 -33
  59. package/dist/turn-annotations.d.ts.map +0 -1
  60. package/dist/turn-annotations.js +0 -49
  61. package/dist/turn-annotations.js.map +0 -1
  62. package/dist/turn-recovery.d.ts +0 -26
  63. package/dist/turn-recovery.d.ts.map +0 -1
  64. package/dist/turn-recovery.js +0 -70
  65. package/dist/turn-recovery.js.map +0 -1
  66. package/dist/turn-start-resolution.d.ts +0 -65
  67. package/dist/turn-start-resolution.d.ts.map +0 -1
  68. package/dist/turn-start-resolution.js +0 -97
  69. package/dist/turn-start-resolution.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,18 +1,811 @@
1
- export { normalizeActor, parseActorOrSystem, SERIALIZED_SYSTEM_ACTOR, serializeActor, } from "./actor.js";
2
- export type { Actor, ActorKind, CurrentExecutionRef, DurableModelSelection, ExternalWriteLog, ExternalWriteType, FutureExecution, FutureExecutionBlockReason, FutureExecutionKind, FutureExecutionScheduleKind, InputKind, InputSource, JsonObject, LlmContextMode, ModelPolicyFailureCode, ModelSelectionKind, ModelSelectionProvenance, ModelSelectionSource, NormalizedQuestion, PreparedTurnStart, ProcessCustomizableFields, ProcessEvent, ProcessInput, ProcessInputTarget, ProcessInstance, ProcessLeafOutcomeSnapshot, ProcessLeafOutcomeSnapshotStatus, ProcessLifecycleStatus, ProcessProject, ProcessQuestionRequest, ProcessSelectedTurnModelSource, ProcessTurnRecord, ProcessTurnRecordPathType, ProcessTurnRecordStatus, ProcessTurnType, QuestionAnswerDraft, ResolvedTurnStart, TransitionTrigger, TurnFailedPayload, TurnFailureCode, TurnId, TurnOutcomePayload, TurnStartContinuation, TurnStartKind, TurnStartPreparationFailureCode, TurnStartRecord, TurnStartRecordState, WorkerBootstrapReceipt, WorkerErrorClass, WorkerLease, WorkerState, } from "./domain-model.js";
3
- export { ADMIN_ACTOR, canonicalizeQuestionAnswers, emptyQuestionDrafts, formatPathTypeLabel, isProcessSelectedTurnModelSource, isProcessTurnType, isTurnFailureCode, isWaitingTurnType, isWorkerErrorClass, isWorkerOwnedTurnType, lifecycleStatusForSelectedTurnType, normalizeAskQuestionsInput, PROCESS_SELECTED_TURN_MODEL_SOURCES, PROCESS_TURN_RECORD_PATH_TYPES, PROCESS_TURN_TYPES, SYSTEM_ACTOR, TELEGRAM_ACTOR, WORKER_ERROR_CLASSES, } from "./domain-model.js";
4
- export { addLauncherRecentValue, DEFAULT_LAUNCHER_RECENT_VALUE_LIMIT, normalizeLauncherRecentValue, normalizeLauncherRecentValues, redactCredentialBearingAbsoluteUrl, } from "./launcher-recent-values.js";
5
- export { normalizeMarkdownLineEndings, normalizeMarkdownText, normalizeOptionalMarkdown, } from "./markdown-normalize.js";
6
- export type { ProcessFlowEdge, ProcessFlowEdgeKind, ProcessFlowEndState, ProcessFlowNode, ProcessFlowNodeRole, ProcessFlowView, ProcessTurnTerminalLifecycleStatus, ProcessTurnTransition, SerializedProcessGraph, } from "./process-definitions.js";
7
- export { type InstanceTurnConfigInput, type InstanceTurnConfigMap, type InstanceTurnConfigsJsonError, type LaunchModelConfigInput, normalizeLaunchModelConfigInput, parseStrictInstanceTurnConfigsJson, serializeInstanceTurnConfigs, } from "./process-model-config.js";
8
- export { buildProcessRowSlot, getProcessStatusCategory, type ProcessRowSlot, sortProcessRows, } from "./process-row-slots.js";
9
- export { type ProcessStateJsonParseContext, parseProcessStateJsonLenient, parseProcessStateJsonStrict, parseProductRefsFromStateJsonLenient, parseProductRefsFromStateJsonStrict, parseProductRefsLenient, parseProductRefsStrict, parseSemanticEntryRefsFromStateJsonLenient, parseSemanticEntryRefsFromStateJsonStrict, parseSemanticEntryRefsLenient, parseSemanticEntryRefsStrict, } from "./process-state-json.js";
10
- export { assertRepoLocator, detectRepoLocatorKind, isRepoLocator, type ParsedRepoLocator, parseRepoLocator, type RepoLocatorKind, } from "./repo-locator.js";
11
- export { createReviewSubject, isReviewSubjectKind, parseReviewSubject, REVIEW_SUBJECT_KINDS, type ReviewSubject, type ReviewSubjectKind, } from "./review-subject.js";
12
- export { assertValidProcessProductName, createEmptyProcessProductRefs, createEmptyProcessSemanticEntryRefs, isProcessSemanticEntryRefKey, isValidProcessProductName, PROCESS_SEMANTIC_ENTRY_REF_KEYS, type ProcessProductRef, type ProcessProductRefs, type ProcessSemanticEntryRefKey, type ProcessSemanticEntryRefs, parseProcessProductRefs, parseProcessSemanticEntryRefs, parseSemanticEntryRef, type SemanticEntryRef, } from "./semantic-entry-refs.js";
13
- export { humanizeProcessLabel, normalizeStringArray, trimString, trimToNull, } from "./string-normalize.js";
14
- export { TURN_ACCEPTANCE_STATES, type TurnAcceptanceState } from "./turn-acceptance.js";
15
- export { type EntryTurnAnnotationReference, type ProcessTurnAnnotation, parseTurnAnnotationReference, parseTurnAnnotationReferences, type SemanticEntryRefTurnAnnotationReference, TURN_ANNOTATION_REFERENCE_KINDS, type TurnAnnotationReference, type TurnAnnotationReferenceKind, type TurnAnnotationReferenceRole, type TurnRecordAnnotationReference, } from "./turn-annotations.js";
16
- export { buildFailedTurnRecoveryMetadata, CONTINUE_PROMPT_METADATA_KEY, createGenericFailedTurnRecoveryContext, DEFAULT_CONTINUE_PROMPT, FAILED_TURN_RECOVERY_CODES, FAILED_TURN_RECOVERY_METADATA_KEY, type FailedTurnRecoveryCode, type FailedTurnRecoveryContext, isFailedTurnRecoveryCode, normalizeContinuePrompt, readFailedTurnRecoveryContext, } from "./turn-recovery.js";
17
- export { defaultProcessTurnStartSelection, type ProcessTurnStartFallback, type ProcessTurnStartFromCurrentLeaf, type ProcessTurnStartFromEntry, type ProcessTurnStartFromProductRef, type ProcessTurnStartFromSemanticRef, type ProcessTurnStartFromSessionRoot, type ProcessTurnStartResolution, type ProcessTurnStartSelection, type ProcessTurnStartTarget, resolveExistingProcessEntryId, resolveProcessProductRefEntryId, resolveProcessSemanticRefEntryId, resolveProcessTurnStartSelection, resolveProcessTurnStartTarget, } from "./turn-start-resolution.js";
18
- //# sourceMappingURL=index.d.ts.map
1
+ type RepoLocatorKind = "remote_url" | "local_path";
2
+ interface ParsedRepoLocator {
3
+ kind: RepoLocatorKind;
4
+ value: string;
5
+ }
6
+ declare function detectRepoLocatorKind(value: string): RepoLocatorKind | null;
7
+ declare function parseRepoLocator(value: unknown): ParsedRepoLocator | null;
8
+ declare function isRepoLocator(value: unknown): value is string;
9
+ declare function assertRepoLocator(value: unknown, fieldName?: string): string;
10
+
11
+ declare const PROCESS_SEMANTIC_ENTRY_REF_KEYS: readonly ["plan", "review", "currentPrimaryPathLeaf", "rootEntry"];
12
+ type ProcessSemanticEntryRefKey = (typeof PROCESS_SEMANTIC_ENTRY_REF_KEYS)[number];
13
+ interface SemanticEntryRef {
14
+ entryId: string;
15
+ turnRecordId: string | null;
16
+ }
17
+ type ProcessProductRef = SemanticEntryRef;
18
+ type ProcessProductRefs = Record<string, ProcessProductRef>;
19
+ declare function isValidProcessProductName(value: string): boolean;
20
+ declare function assertValidProcessProductName(value: string): void;
21
+ /**
22
+ * Stage 2 keeps these refs as structural placeholders initialized to `null`.
23
+ * Current runtime population:
24
+ * - `rootEntry` during worker bootstrap and subsequent worker tree-fact reporting
25
+ * - `currentPrimaryPathLeaf` during worker bootstrap, successful primary turns,
26
+ * and prompt-style primary-path input delivery
27
+ * - `plan` during successful planning turns; it remains the current plan through
28
+ * implementation until another planning turn replaces it
29
+ * - `review` during successful review turns; it remains the current review until
30
+ * another review turn replaces it
31
+ */
32
+ interface ProcessSemanticEntryRefs {
33
+ plan: SemanticEntryRef | null;
34
+ review: SemanticEntryRef | null;
35
+ currentPrimaryPathLeaf: SemanticEntryRef | null;
36
+ rootEntry: SemanticEntryRef | null;
37
+ }
38
+ declare function isProcessSemanticEntryRefKey(value: string): value is ProcessSemanticEntryRefKey;
39
+ declare function parseSemanticEntryRef(value: unknown): SemanticEntryRef | null;
40
+ declare function createEmptyProcessSemanticEntryRefs(): ProcessSemanticEntryRefs;
41
+ declare function createEmptyProcessProductRefs(): ProcessProductRefs;
42
+ declare function parseProcessProductRefs(value: unknown): ProcessProductRefs;
43
+ declare function parseProcessSemanticEntryRefs(value: unknown): ProcessSemanticEntryRefs;
44
+
45
+ declare const DEFAULT_CONTINUE_PROMPT = "continue";
46
+ declare const FAILED_TURN_RECOVERY_CODES: readonly ["generic_continue", "missing_outcome_tool", "missing_markdown_result", "missing_required_tool_calls"];
47
+ type FailedTurnRecoveryCode = (typeof FAILED_TURN_RECOVERY_CODES)[number];
48
+ interface FailedTurnRecoveryContext {
49
+ strategy: "continue";
50
+ suggestedContinuePrompt: string;
51
+ failureCode: FailedTurnRecoveryCode;
52
+ missingToolNames?: string[];
53
+ }
54
+ type FailedTurnRecoveryOverrides = Partial<Omit<FailedTurnRecoveryContext, "strategy">>;
55
+ declare const FAILED_TURN_RECOVERY_METADATA_KEY = "failedTurnRecovery";
56
+ declare const CONTINUE_PROMPT_METADATA_KEY = "continuePrompt";
57
+ declare function isFailedTurnRecoveryCode(value: string): value is FailedTurnRecoveryCode;
58
+ declare function normalizeContinuePrompt(value: unknown): string | null;
59
+ declare function createGenericFailedTurnRecoveryContext(overrides?: FailedTurnRecoveryOverrides): FailedTurnRecoveryContext;
60
+ declare function buildFailedTurnRecoveryMetadata(turnRecordId: string, context?: FailedTurnRecoveryOverrides): {
61
+ failedTurnRecovery: {
62
+ strategy: "continue";
63
+ suggestedContinuePrompt: string;
64
+ failureCode: FailedTurnRecoveryCode;
65
+ missingToolNames?: string[];
66
+ turnRecordId: string;
67
+ };
68
+ };
69
+ declare function readFailedTurnRecoveryContext(metadata: Record<string, unknown> | null | undefined, expectedTurnRecordId?: string | null): FailedTurnRecoveryContext | null;
70
+
71
+ interface ProcessTurnStartFromCurrentLeaf {
72
+ kind: "current_leaf";
73
+ }
74
+ interface ProcessTurnStartFromSessionRoot {
75
+ /** Start with no persisted Pi entry in context. The kickoff entry has parentId null. */
76
+ kind: "session_root";
77
+ }
78
+ interface ProcessTurnStartFromEntry {
79
+ kind: "entry";
80
+ entryId: string;
81
+ }
82
+ type ProcessTurnStartFallback = ProcessTurnStartFromCurrentLeaf | ProcessTurnStartFromSessionRoot | ProcessTurnStartFromEntry;
83
+ interface ProcessTurnStartFromSemanticRef {
84
+ kind: "semantic_ref";
85
+ ref: ProcessSemanticEntryRefKey;
86
+ fallback?: ProcessTurnStartSelection;
87
+ }
88
+ interface ProcessTurnStartFromProductRef {
89
+ kind: "product_ref";
90
+ productName: string;
91
+ fallback?: ProcessTurnStartSelection;
92
+ }
93
+ type ProcessTurnStartSelection = ProcessTurnStartFallback | ProcessTurnStartFromSemanticRef | ProcessTurnStartFromProductRef;
94
+ type ProcessTurnStartTarget = {
95
+ kind: "current_leaf";
96
+ } | {
97
+ kind: "entry";
98
+ entryId: string;
99
+ } | {
100
+ kind: "root";
101
+ };
102
+ interface ProcessTurnStartResolution {
103
+ forkPiEntryId: string | null;
104
+ startTarget: ProcessTurnStartTarget;
105
+ }
106
+ declare function defaultProcessTurnStartSelection(branchType: ProcessTurnRecordPathType): ProcessTurnStartFallback;
107
+ declare function resolveProcessTurnStartSelection(input: {
108
+ branchType: ProcessTurnRecordPathType;
109
+ startFrom?: ProcessTurnStartSelection;
110
+ }): ProcessTurnStartSelection;
111
+ declare function resolveExistingProcessEntryId(entryId: string | null, entryExists?: ((entryId: string) => boolean) | undefined): string | null;
112
+ declare function resolveProcessSemanticRefEntryId(input: {
113
+ ref: keyof ProcessSemanticEntryRefs;
114
+ semanticEntryRefs?: ProcessSemanticEntryRefs | null;
115
+ currentLeafId: string | null;
116
+ rootEntryId: string | null;
117
+ entryExists?: (entryId: string) => boolean;
118
+ }): string | null;
119
+ declare function resolveProcessProductRefEntryId(input: {
120
+ productName: string;
121
+ productRefs?: ProcessProductRefs | null;
122
+ entryExists?: (entryId: string) => boolean;
123
+ }): string | null;
124
+ declare function resolveProcessTurnStartTarget(input: {
125
+ branchType: ProcessTurnRecordPathType;
126
+ selection: ProcessTurnStartSelection;
127
+ currentLeafId: string | null;
128
+ rootEntryId: string | null;
129
+ semanticEntryRefs?: ProcessSemanticEntryRefs | null;
130
+ productRefs?: ProcessProductRefs | null;
131
+ entryExists?: (entryId: string) => boolean;
132
+ }): ProcessTurnStartResolution;
133
+
134
+ type TransitionTrigger = "start" | "advance" | "revision_requested" | "plan_approved" | "feedback_received" | "operator_re_review" | "mr_merged" | "abort" | "mr_state_waiting";
135
+ type InputSource = "external_comment" | "app_steer" | "action_prompt" | "watcher_event" | "llm_review" | "system";
136
+ /**
137
+ * Stable principal that drove an action, orthogonal to `InputSource` (the
138
+ * channel an input arrived through) and `TransitionTrigger` (the graph edge a
139
+ * transition followed). An `Actor` answers "who acted", not "how" or "why".
140
+ */
141
+ type ActorKind = "user" | "channel" | "system";
142
+ interface Actor {
143
+ /**
144
+ * Stable principal id, namespaced by provider where applicable.
145
+ * e.g. "forgejo:alice", "telegram", "system", "admin".
146
+ */
147
+ id: string;
148
+ kind: ActorKind;
149
+ /** Origin that vouched for this actor. `null` for system/admin/local. */
150
+ provider: "forgejo" | "gitlab" | "telegram" | null;
151
+ /** Optional human-readable name for UI display. */
152
+ displayName?: string;
153
+ }
154
+ /** Watcher / scheduler / startup reconciliation and other internal callers. */
155
+ declare const SYSTEM_ACTOR: Actor;
156
+ /**
157
+ * Unauthenticated default for human-driven web/HTTP/WS actions when no SSO
158
+ * provider is configured. Keeps an auth-disabled leitwerk behaving exactly
159
+ * as it does today while still attributing actions to a stable principal.
160
+ */
161
+ declare const ADMIN_ACTOR: Actor;
162
+ /** Single collapsed principal for all Telegram-originated actions. */
163
+ declare const TELEGRAM_ACTOR: Actor;
164
+ type QuestionSelectionMode = "single" | "multiple";
165
+ interface NormalizedQuestionOption {
166
+ id: string;
167
+ label: string;
168
+ details: string | null;
169
+ }
170
+ interface NormalizedQuestion {
171
+ id: string;
172
+ question: string;
173
+ selection: QuestionSelectionMode;
174
+ options: readonly NormalizedQuestionOption[];
175
+ }
176
+ interface QuestionAnswerDraft {
177
+ selectedOptionIds: readonly string[];
178
+ freeText: string;
179
+ comment: string;
180
+ }
181
+ interface ProcessQuestionRequest {
182
+ id: string;
183
+ instanceId: string;
184
+ turnRecordId: string;
185
+ toolCallId: string;
186
+ questions: readonly NormalizedQuestion[];
187
+ status: "open" | "answered" | "cancelled";
188
+ answers: readonly string[] | null;
189
+ askedAt: string;
190
+ answeredAt: string | null;
191
+ answeredBy: Actor | null;
192
+ cancelledAt: string | null;
193
+ }
194
+ /** Normalize an LLM-authored request into immutable, position-stable identities. */
195
+ declare function normalizeAskQuestionsInput(value: unknown): NormalizedQuestion[];
196
+ declare function emptyQuestionDrafts(questions: readonly NormalizedQuestion[]): QuestionAnswerDraft[];
197
+ /** Validate a complete structured draft and produce one canonical free-text answer per question. */
198
+ declare function canonicalizeQuestionAnswers(questions: readonly NormalizedQuestion[], value: unknown): string[];
199
+ /**
200
+ * Durable operator/system input queued for worker delivery.
201
+ * `action_prompt` is the conventional source for action-originated follow-up
202
+ * prompts. Delivery semantics are owned by `ProcessInput.target`, not by
203
+ * `source` or `kind`.
204
+ */
205
+ type InputKind = "instruction" | "action" | "system_event";
206
+ type ProcessInputTarget = {
207
+ semanticRef: ProcessSemanticEntryRefKey;
208
+ productName?: never;
209
+ } | {
210
+ productName: string;
211
+ semanticRef?: never;
212
+ };
213
+ declare const WORKER_ERROR_CLASSES: readonly ["llm_error", "git_error", "pi_crash", "pipeline_error", "infrastructure", "protocol_error", "operator_abort"];
214
+ type WorkerErrorClass = (typeof WORKER_ERROR_CLASSES)[number];
215
+ declare function isWorkerErrorClass(value: string): value is WorkerErrorClass;
216
+ type TurnFailureCode = "branch_drift";
217
+ declare function isTurnFailureCode(value: string): value is TurnFailureCode;
218
+ /** Extension-defined stable turn identifier. */
219
+ type TurnId = string;
220
+ declare const PROCESS_TURN_TYPES: readonly ["llm", "human", "external", "automatic", "server_automatic"];
221
+ type ProcessTurnType = (typeof PROCESS_TURN_TYPES)[number];
222
+ interface TurnOutcomePayload {
223
+ instanceId: string;
224
+ turnRecordId: string;
225
+ turnId: TurnId;
226
+ turnType: ProcessTurnType;
227
+ outcome: string;
228
+ params: Record<string, unknown>;
229
+ pathType?: ProcessTurnRecordPathType;
230
+ forkPiEntryId?: string | null;
231
+ resultPiEntryId?: string | null;
232
+ turnResultMarkdown?: string | null;
233
+ rootEntryId?: string | null;
234
+ state?: unknown;
235
+ }
236
+ interface TurnFailedPayload {
237
+ instanceId: string;
238
+ turnRecordId: string;
239
+ turnId: TurnId;
240
+ turnType: ProcessTurnType;
241
+ pathType: ProcessTurnRecordPathType;
242
+ forkPiEntryId?: string | null;
243
+ resultPiEntryId?: string | null;
244
+ errorSummary: string;
245
+ errorClass?: WorkerErrorClass;
246
+ failureCode?: TurnFailureCode | null;
247
+ failureDetails?: Record<string, unknown> | null;
248
+ recoveryContext?: FailedTurnRecoveryContext | null;
249
+ }
250
+ type ProcessLifecycleStatus = "discovered" | "active" | "waiting" | "error" | "completed" | "aborted";
251
+ declare function isProcessTurnType(value: unknown): value is ProcessTurnType;
252
+ declare function isWorkerOwnedTurnType(turnType: ProcessTurnType): boolean;
253
+ declare function isWaitingTurnType(turnType: ProcessTurnType): boolean;
254
+ declare function lifecycleStatusForSelectedTurnType(turnType: ProcessTurnType): Extract<ProcessLifecycleStatus, "active" | "waiting">;
255
+ type ProcessSelectedTurnModelSource = "action_override" | "launch_override" | "instance_turn_config" | "process_config_turn" | "instance_default" | "process_config_default" | "catalog_default" | "legacy_persisted";
256
+ type ModelSelectionKind = "explicit" | "inherited";
257
+ type ModelSelectionSource = ProcessSelectedTurnModelSource;
258
+ /** Durable intent and resolution path for one effective model selection. */
259
+ interface ModelSelectionProvenance {
260
+ kind: ModelSelectionKind;
261
+ source: ModelSelectionSource;
262
+ }
263
+ interface DurableModelSelection {
264
+ modelProfileId: string;
265
+ provenance: ModelSelectionProvenance;
266
+ }
267
+ type ModelPolicyFailureCode = "invalid_model_configuration" | "unknown_model_profile" | "model_profile_not_allowed" | "model_required" | "model_unavailable" | "model_stale" | "stale_evaluation_snapshot";
268
+ interface FutureExecutionBlockReason {
269
+ code: ModelPolicyFailureCode;
270
+ selection: DurableModelSelection | null;
271
+ summary: string;
272
+ detectedAt: string;
273
+ /** Present when the block depends on a runtime availability snapshot. */
274
+ availabilityRevision?: number;
275
+ }
276
+ /** JSON object persisted as non-secret turn-start configuration. */
277
+ type JsonObject = Record<string, unknown>;
278
+ /** The one durable technical execution currently owned by a process. */
279
+ type CurrentExecutionRef = {
280
+ kind: "worker_start";
281
+ id: string;
282
+ } | {
283
+ kind: "server_turn";
284
+ id: string;
285
+ } | null;
286
+ /** Immutable non-secret inputs resolved for a worker-owned turn start. */
287
+ type ResolvedTurnStart = {
288
+ kind: "llm";
289
+ model: {
290
+ profileId: string;
291
+ providerId: string;
292
+ modelId: string;
293
+ thinkingLevel: string;
294
+ };
295
+ /** Frozen provenance used to resolve this prepared start. */
296
+ modelSelectionProvenance?: ModelSelectionProvenance;
297
+ /** Status revision evaluated before preparation. Diagnostic only. */
298
+ availabilityRevision?: number;
299
+ providerOptions: Record<string, string>;
300
+ providerWorkerConfig: {
301
+ version: number;
302
+ value: JsonObject;
303
+ } | null;
304
+ piResourceSnapshotDigest: string;
305
+ workerRuntimeProfileId: string;
306
+ piSettings: JsonObject;
307
+ } | {
308
+ kind: "automatic";
309
+ };
310
+ type TurnStartKind = "selected_turn" | "retry" | "continue" | "startup_retry";
311
+ interface TurnStartContinuation {
312
+ continueFromPiEntryId: string;
313
+ continuePrompt: string;
314
+ savedPrimaryLeafEntryId: string | null;
315
+ }
316
+ type TurnStartPreparationFailureCode = "invalid_model_configuration" | "model_required" | "model_unavailable" | "model_stale" | "provider_options_required" | "provider_preflight_failed";
317
+ type TurnStartRecordState = {
318
+ kind: "preparation_failed";
319
+ requestedModelProfileId: string | null;
320
+ providerOptions: Record<string, string>;
321
+ code: TurnStartPreparationFailureCode;
322
+ safeSummary: string;
323
+ modelSelectionProvenance?: ModelSelectionProvenance;
324
+ availabilityRevision?: number;
325
+ } | {
326
+ kind: "starting";
327
+ start: ResolvedTurnStart;
328
+ } | {
329
+ kind: "bootstrap_failed";
330
+ start: ResolvedTurnStart;
331
+ failedWorkerLeaseId: string | null;
332
+ code: string;
333
+ safeSummary: string;
334
+ } | {
335
+ kind: "accepted";
336
+ start: ResolvedTurnStart;
337
+ turnRecordId: string;
338
+ acceptedWorkerLeaseId: string;
339
+ } | {
340
+ kind: "superseded";
341
+ start: ResolvedTurnStart | null;
342
+ };
343
+ /** Durable preparation for a single worker-owned selected turn, not an attempt. */
344
+ interface TurnStartRecord {
345
+ id: string;
346
+ instanceId: string;
347
+ turnId: TurnId;
348
+ turnType: Extract<ProcessTurnType, "llm" | "automatic">;
349
+ /** Reserved id used when, and only when, this start is accepted. */
350
+ proposedTurnRecordId: string;
351
+ startKind: TurnStartKind;
352
+ recoveryTurnRecordId: string | null;
353
+ continuation: TurnStartContinuation | null;
354
+ state: TurnStartRecordState;
355
+ createdAt: string;
356
+ updatedAt: string;
357
+ }
358
+ /** Tree positioning selected during bootstrap, before a turn is accepted. */
359
+ interface PreparedTurnStart {
360
+ pathType: ProcessTurnRecordPathType;
361
+ /** Durable authored context mode used to reconcile pre-prompt positioning and compaction. */
362
+ contextMode: LlmContextMode;
363
+ startTarget: ProcessTurnStartTarget;
364
+ forkPiEntryId: string | null;
365
+ }
366
+ type LlmContextMode = "full" | "compacted" | "fresh" | "fresh_seeded";
367
+ /** Immutable, lease-correlated proof of successful worker bootstrap. */
368
+ type WorkerBootstrapReceipt = {
369
+ kind: "llm";
370
+ startRecordId: string;
371
+ workerLeaseId: string;
372
+ receiptEpoch: string;
373
+ verifiedResourceSnapshotDigest: string;
374
+ credentialRevision: number | null;
375
+ loadedResourceIds: string[];
376
+ resolvedModel: {
377
+ providerId: string;
378
+ modelId: string;
379
+ };
380
+ preparedStart: PreparedTurnStart | null;
381
+ readyAt: string;
382
+ } | {
383
+ kind: "automatic";
384
+ startRecordId: string;
385
+ workerLeaseId: string;
386
+ receiptEpoch: string;
387
+ readyAt: string;
388
+ };
389
+ declare const PROCESS_SELECTED_TURN_MODEL_SOURCES: readonly ["action_override", "launch_override", "instance_turn_config", "process_config_turn", "instance_default", "process_config_default", "catalog_default", "legacy_persisted"];
390
+ declare function isProcessSelectedTurnModelSource(value: unknown): value is ProcessSelectedTurnModelSource;
391
+ interface ProcessCustomizableFields {
392
+ title?: string | null;
393
+ externalId?: string | null;
394
+ externalUrl?: string | null;
395
+ metadata?: Record<string, unknown> | null;
396
+ defaultModelProfileId?: string | null;
397
+ initialDefaultModelProfileId?: string | null;
398
+ turnConfigsJson?: string | null;
399
+ selectedTurnModelProfileId?: string | null;
400
+ selectedTurnModelKind?: ModelSelectionKind | null;
401
+ selectedTurnModelSource?: ProcessSelectedTurnModelSource | null;
402
+ }
403
+ interface ProcessInstance {
404
+ id: string;
405
+ /** Canonical process identifier from the extension catalog. */
406
+ processId: string;
407
+ /** Durable pointer to the currently selected business turn, if any. */
408
+ selectedTurnId: TurnId | null;
409
+ /** High-level lifecycle bucket for scheduling and operator state. */
410
+ lifecycleStatus: ProcessLifecycleStatus;
411
+ /** Single durable technical execution reference; null for waiting/terminal states. */
412
+ currentExecution: CurrentExecutionRef;
413
+ planRevision: number;
414
+ /** Short operator-facing process title used in process lists and related UI. */
415
+ title: string | null;
416
+ /** Provider-agnostic external reference (e.g. Jira issue key, GitLab MR path). */
417
+ externalId: string | null;
418
+ /** URL to the external resource, if applicable. */
419
+ externalUrl: string | null;
420
+ /** Extension-owned JSON metadata blob. */
421
+ metadata: Record<string, unknown> | null;
422
+ /** Instance-scoped default model profile used when no turn override applies. */
423
+ defaultModelProfileId?: string | null;
424
+ /** Effective default model at creation time, retained for historical inspection. */
425
+ initialDefaultModelProfileId?: string | null;
426
+ /** JSON-serialized per-turn runtime config overrides for this instance. */
427
+ turnConfigsJson?: string | null;
428
+ /** Frozen effective model profile for the currently selected LLM turn, if any. */
429
+ selectedTurnModelProfileId?: string | null;
430
+ /** Explicit operator intent or inherited policy resolution for the selected model. */
431
+ selectedTurnModelKind?: ModelSelectionKind | null;
432
+ /** Resolution path that selected `selectedTurnModelProfileId`; null for empty selections. */
433
+ selectedTurnModelSource?: ProcessSelectedTurnModelSource | null;
434
+ /** JSON-serialized process params. */
435
+ paramsJson: string | null;
436
+ /** JSON-serialized process state. */
437
+ stateJson: string | null;
438
+ createdAt: string;
439
+ updatedAt: string;
440
+ /** Set once when the process first reaches a terminal lifecycle status. */
441
+ closedAt?: string | null;
442
+ }
443
+ interface ProcessProject {
444
+ id: string;
445
+ instanceId: string;
446
+ key: string;
447
+ /** Repository source identifier. May be a remote URL or a local filesystem path. */
448
+ repoLocator: string;
449
+ repoLocatorKind: RepoLocatorKind;
450
+ baseBranch: string;
451
+ workBranch: string | null;
452
+ /** Provider-agnostic external identifier (e.g. MR IID, PR number). */
453
+ externalId: string | null;
454
+ /** URL to the external resource (e.g. MR URL, PR URL). */
455
+ externalUrl: string | null;
456
+ /** Extension-owned JSON metadata blob. */
457
+ metadata: Record<string, unknown> | null;
458
+ pipelineStatus: string | null;
459
+ createdAt: string;
460
+ updatedAt: string;
461
+ }
462
+ interface ProcessInput {
463
+ id: string;
464
+ instanceId: string;
465
+ sequence: number;
466
+ source: InputSource;
467
+ kind: InputKind;
468
+ target: ProcessInputTarget | null;
469
+ bodyMarkdown: string;
470
+ /** Stable principal that queued this input. Defaults to `SYSTEM_ACTOR`. */
471
+ actor: Actor;
472
+ receivedAt: string;
473
+ consumedAt: string | null;
474
+ }
475
+ type FutureExecutionKind = "launch" | "action";
476
+ type FutureExecutionScheduleKind = "once" | "cron";
477
+ interface FutureExecution {
478
+ id: string;
479
+ kind: FutureExecutionKind;
480
+ scheduleKind: FutureExecutionScheduleKind;
481
+ /** Canonical target process identifier. */
482
+ processId: string;
483
+ /** Populated only for scheduled actions on an existing process instance. */
484
+ instanceId: string | null;
485
+ launcherId: string | null;
486
+ actionId: string | null;
487
+ /** JSON-serialized kind-specific payload. */
488
+ payloadJson: string;
489
+ cronExpression: string | null;
490
+ nextRunAt: string;
491
+ /** Immediate LLM selection caused by this execution, if known. */
492
+ modelSelection?: DurableModelSelection | null;
493
+ /** Structured model-policy block. Blocked rows remain durable. */
494
+ blockedReason?: FutureExecutionBlockReason | null;
495
+ createdAt: string;
496
+ updatedAt: string;
497
+ }
498
+ interface ProcessEvent {
499
+ id: string;
500
+ instanceId: string;
501
+ eventType: string;
502
+ data: Record<string, unknown>;
503
+ createdAt: string;
504
+ }
505
+ type ProcessLeafOutcomeSnapshotStatus = "ready" | "capture_error";
506
+ interface ProcessLeafOutcomeSnapshot {
507
+ id: string;
508
+ instanceId: string;
509
+ leafEntryId: string;
510
+ turnRecordId: string | null;
511
+ rendererId: string | null;
512
+ schemaVersion: number | null;
513
+ props: Record<string, unknown> | null;
514
+ fallbackMarkdown: string | null;
515
+ status: ProcessLeafOutcomeSnapshotStatus;
516
+ warningCode: string | null;
517
+ warningMessage: string | null;
518
+ anchoredAt: string;
519
+ createdAt: string;
520
+ }
521
+ type ProcessTurnRecordStatus = "running" | "succeeded" | "failed" | "superseded";
522
+ /**
523
+ * Structural tree position for a turn record.
524
+ * - `primary`: continue the primary path from the current leaf
525
+ * - `root_branch`: start from the implicit session root with no prior Pi entry context
526
+ * - `leaf_branch`: fork from the current leaf as a side path
527
+ */
528
+ declare const PROCESS_TURN_RECORD_PATH_TYPES: readonly ["primary", "root_branch", "leaf_branch"];
529
+ type ProcessTurnRecordPathType = (typeof PROCESS_TURN_RECORD_PATH_TYPES)[number];
530
+ interface ProcessTurnRecord {
531
+ id: string;
532
+ instanceId: string;
533
+ turnId: TurnId;
534
+ turnType: ProcessTurnType;
535
+ status: ProcessTurnRecordStatus;
536
+ attemptNumber: number;
537
+ parentTurnRecordId: string | null;
538
+ pathType: ProcessTurnRecordPathType;
539
+ forkPiEntryId: string | null;
540
+ /** Accepted worker-start preparation that created this worker-owned record. */
541
+ turnStartRecordId?: string | null;
542
+ /** Lease whose receipt first authorized this worker-owned record. */
543
+ acceptedWorkerLeaseId?: string | null;
544
+ resultPiEntryId: string | null;
545
+ modelProfileId: string | null;
546
+ modelSelectionProvenance?: ModelSelectionProvenance | null;
547
+ turnResultMarkdown: string | null;
548
+ errorSummary: string | null;
549
+ errorClass: WorkerErrorClass | null;
550
+ startedAt: string;
551
+ endedAt: string | null;
552
+ }
553
+ interface WorkerLease {
554
+ id: string;
555
+ instanceId: string;
556
+ workerId: string;
557
+ /** Durable server-owned supervision state for the current worker lease. */
558
+ state: WorkerState;
559
+ /** Server epoch this lease belongs to, used to reject stale snapshot writes. */
560
+ serverEpoch?: string | null;
561
+ /** Hash of the lease-scoped WebSocket connect token. The raw token is never stored. */
562
+ connectTokenHash?: string | null;
563
+ /** Hash of the lease-scoped HTTP session-snapshot credential. The raw token is never stored. */
564
+ snapshotTokenHash?: string | null;
565
+ /** Fingerprint of the effective instance model policy/config snapshot used to start this worker. */
566
+ modelPolicyFingerprint?: string | null;
567
+ /** First valid lease-correlated bootstrap receipt; written once by the server. */
568
+ bootstrapReceipt?: WorkerBootstrapReceipt | null;
569
+ /** Updated from heartbeats for liveness/recovery diagnostics. */
570
+ lastHeartbeatAt: string | null;
571
+ startedAt: string;
572
+ /** Set once the lease is no longer active for supervision. */
573
+ exitedAt: string | null;
574
+ }
575
+ /**
576
+ * Durable worker lease states owned by the server.
577
+ * `absent` is conceptual in lifecycle logic and usually represented by
578
+ * the absence of an active lease row.
579
+ */
580
+ type WorkerState = "absent" | "spawning" | "bootstrapping" | "idle" | "busy" | "draining" | "failed" | "cleanup" | "exited";
581
+ /**
582
+ * External write type identifier. Extensions define their own write types
583
+ * as plain strings (e.g. "jira.approved_plan_comment", "gitlab.create_mr").
584
+ */
585
+ type ExternalWriteType = string;
586
+ interface ExternalWriteLog {
587
+ id: string;
588
+ instanceId: string;
589
+ writeType: ExternalWriteType;
590
+ dedupKey: string;
591
+ completedAt: string;
592
+ metadata: Record<string, unknown>;
593
+ }
594
+ /**
595
+ * Returns a human-readable, operator-facing label for the structural path
596
+ * position of a turn record. These labels avoid internal domain terms such
597
+ * as "primary" or "root_branch" in favour of plain descriptions of what the
598
+ * turn is doing relative to the main path.
599
+ */
600
+ declare function formatPathTypeLabel(pathType: ProcessTurnRecordPathType): string;
601
+
602
+ /**
603
+ * Builds a validated `Actor`, dropping unknown fields and falling back to
604
+ * defaults for invalid kind/provider. Returns `null` when no stable id is
605
+ * present so callers can decide on a fallback actor.
606
+ */
607
+ declare function normalizeActor(value: unknown): Actor | null;
608
+ /** Serializes an `Actor` to a stable JSON string for durable storage. */
609
+ declare function serializeActor(actor: Actor): string;
610
+ /**
611
+ * Parses a durable actor JSON value, falling back to `SYSTEM_ACTOR` when the
612
+ * stored value is missing or malformed. Used when reading legacy rows that
613
+ * predate actor attribution.
614
+ */
615
+ declare function parseActorOrSystem(value: string | null | undefined): Actor;
616
+ /** Canonical serialized form of `SYSTEM_ACTOR`, used as the durable default. */
617
+ declare const SERIALIZED_SYSTEM_ACTOR: string;
618
+
619
+ declare const DEFAULT_LAUNCHER_RECENT_VALUE_LIMIT = 5;
620
+ /**
621
+ * Strip any embedded credentials (`user:pass@`) from an absolute non-`file:` URL,
622
+ * returning the value unchanged when it is not such a URL.
623
+ */
624
+ declare function redactCredentialBearingAbsoluteUrl(value: string): string;
625
+ declare function normalizeLauncherRecentValue(value: unknown): string | null;
626
+ declare function normalizeLauncherRecentValues(values: readonly unknown[], limit?: number): string[];
627
+ declare function addLauncherRecentValue(existingValues: readonly string[], value: string, limit?: number): string[];
628
+
629
+ declare function normalizeMarkdownLineEndings(markdown: string): string;
630
+ declare function normalizeMarkdownText(markdown: string): string;
631
+ declare function normalizeOptionalMarkdown(value: unknown): string | null;
632
+
633
+ type ProcessTurnTerminalLifecycleStatus = Extract<ProcessLifecycleStatus, "completed" | "aborted">;
634
+ interface ProcessTurnTransition {
635
+ nextTurnId?: TurnId;
636
+ lifecycleStatus?: ProcessTurnTerminalLifecycleStatus;
637
+ outcome?: string;
638
+ trigger?: string;
639
+ }
640
+ /** Wire DTO used by HTTP clients that need serialized process graph data. */
641
+ interface SerializedProcessGraph {
642
+ id: string;
643
+ entryTurnIds: TurnId[];
644
+ reachableTurnIds: TurnId[];
645
+ turnTransitions: Record<TurnId, ProcessTurnTransition[]>;
646
+ }
647
+ /** Whether a flow node sits on the declared happy path (`spine`) or hangs off it (`branch`). */
648
+ type ProcessFlowNodeRole = "spine" | "branch";
649
+ /**
650
+ * Classification of a flow edge relative to the spine:
651
+ * - `forward`: progresses along the spine toward completion
652
+ * - `loopback`: returns to an earlier or equal spine position (revision/dismiss loops)
653
+ * - `branch`: leaves the spine toward an offshoot node
654
+ * - `terminal`: ends the process with a lifecycle status
655
+ */
656
+ type ProcessFlowEdgeKind = "forward" | "loopback" | "branch" | "terminal";
657
+ interface ProcessFlowNode {
658
+ turnId: TurnId;
659
+ description: string;
660
+ turnType: ProcessTurnType;
661
+ role: ProcessFlowNodeRole;
662
+ /** Position on the spine when `role === "spine"`, otherwise `null`. */
663
+ spineIndex: number | null;
664
+ /** The spine node this branch hangs off, when derivable. `null` for spine nodes. */
665
+ anchorTurnId: TurnId | null;
666
+ /** True when this turn is a launch entry point. */
667
+ isEntry: boolean;
668
+ }
669
+ interface ProcessFlowEdge {
670
+ from: TurnId;
671
+ /** Target turn for non-terminal edges. */
672
+ to: TurnId | null;
673
+ /** Lifecycle status for `terminal` edges. */
674
+ lifecycleStatus: ProcessTurnTerminalLifecycleStatus | null;
675
+ kind: ProcessFlowEdgeKind;
676
+ /** Optional human-facing edge label derived from outcome/trigger metadata. */
677
+ label: string | null;
678
+ }
679
+ interface ProcessFlowEndState {
680
+ lifecycleStatus: ProcessTurnTerminalLifecycleStatus;
681
+ /**
682
+ * True when the end state is not reached by an explicit graph transition.
683
+ * Abort is always reachable from any active turn, so it is synthesized.
684
+ */
685
+ synthetic: boolean;
686
+ }
687
+ /**
688
+ * Spine-first projection of a process graph for operator-facing flow diagrams.
689
+ * The `spine` is the happy path; everything else hangs off it as branches and loops.
690
+ */
691
+ interface ProcessFlowView {
692
+ processId: string;
693
+ entryTurnIds: TurnId[];
694
+ spine: TurnId[];
695
+ nodes: ProcessFlowNode[];
696
+ edges: ProcessFlowEdge[];
697
+ endStates: ProcessFlowEndState[];
698
+ }
699
+
700
+ interface InstanceTurnConfigInput {
701
+ modelProfileId?: string | null;
702
+ }
703
+ type InstanceTurnConfigMap = Record<string, InstanceTurnConfigInput>;
704
+ interface LaunchModelConfigInput {
705
+ defaultModelProfileId?: string | null;
706
+ turnConfigs?: InstanceTurnConfigMap;
707
+ }
708
+ interface InstanceTurnConfigsJsonError {
709
+ code: "invalid_turn_configs_json";
710
+ processId: string;
711
+ reason: "invalid_json" | "not_object" | "turn_config_not_object";
712
+ turnId?: string;
713
+ }
714
+ declare function parseStrictInstanceTurnConfigsJson(processId: string, turnConfigsJson: string | null | undefined): {
715
+ ok: true;
716
+ value: InstanceTurnConfigMap;
717
+ } | {
718
+ ok: false;
719
+ error: InstanceTurnConfigsJsonError;
720
+ };
721
+ declare function serializeInstanceTurnConfigs(turnConfigs: InstanceTurnConfigMap): string | null;
722
+ declare function normalizeLaunchModelConfigInput(input: LaunchModelConfigInput): LaunchModelConfigInput;
723
+
724
+ interface ProcessRowSlot {
725
+ instanceId: string;
726
+ processId: string;
727
+ title: string;
728
+ subtitle: string;
729
+ selectedTurnId: string | null;
730
+ lifecycleStatus: ProcessLifecycleStatus;
731
+ statusCategory: "error" | "active" | "waiting" | "terminal" | "discovered";
732
+ projectCount: number;
733
+ externalId: string | null;
734
+ externalLinkCount: number;
735
+ }
736
+ declare function getProcessStatusCategory(lifecycleStatus: ProcessLifecycleStatus): ProcessRowSlot["statusCategory"];
737
+ declare function buildProcessRowSlot(process: ProcessInstance, projects: ReadonlyArray<ProcessProject>): ProcessRowSlot;
738
+ declare function sortProcessRows(rows: ProcessRowSlot[]): ProcessRowSlot[];
739
+
740
+ interface ProcessStateJsonParseContext {
741
+ label?: string;
742
+ processId?: string;
743
+ }
744
+ declare function parseProcessStateJsonStrict(stateJson: string | null | undefined, context?: string | ProcessStateJsonParseContext): Record<string, unknown>;
745
+ declare function parseProcessStateJsonLenient(stateJson: string | null | undefined): Record<string, unknown>;
746
+ declare function parseSemanticEntryRefsStrict(value: unknown, context?: ProcessStateJsonParseContext): ProcessSemanticEntryRefs;
747
+ declare function parseSemanticEntryRefsLenient(value: unknown): ProcessSemanticEntryRefs;
748
+ declare function parseProductRefsStrict(value: unknown, context?: ProcessStateJsonParseContext): ProcessProductRefs;
749
+ declare function parseProductRefsLenient(value: unknown): ProcessProductRefs;
750
+ declare function parseSemanticEntryRefsFromStateJsonStrict(stateJson: string | null | undefined, context?: string | ProcessStateJsonParseContext): ProcessSemanticEntryRefs;
751
+ declare function parseSemanticEntryRefsFromStateJsonLenient(stateJson: string | null | undefined): ProcessSemanticEntryRefs;
752
+ declare function parseProductRefsFromStateJsonStrict(stateJson: string | null | undefined, context?: string | ProcessStateJsonParseContext): ProcessProductRefs;
753
+ declare function parseProductRefsFromStateJsonLenient(stateJson: string | null | undefined): ProcessProductRefs;
754
+
755
+ declare const REVIEW_SUBJECT_KINDS: readonly ["plan", "implementation"];
756
+ type ReviewSubjectKind = (typeof REVIEW_SUBJECT_KINDS)[number];
757
+ interface ReviewSubject {
758
+ kind: ReviewSubjectKind;
759
+ }
760
+ declare function isReviewSubjectKind(value: string): value is ReviewSubjectKind;
761
+ declare function createReviewSubject(kind: ReviewSubjectKind): ReviewSubject;
762
+ declare function parseReviewSubject(value: unknown): ReviewSubject | null;
763
+
764
+ declare function trimString(value: unknown): string;
765
+ declare function trimToNull(value: unknown): string | null;
766
+ declare function normalizeStringArray(value: unknown): string[];
767
+ /**
768
+ * Single source of truth for turning an internal identifier (an action id,
769
+ * outcome id, or trigger) into a human-readable Title Case label, e.g.
770
+ * `approve_plan` -> `Approve Plan`. All operator-facing surfaces (action forms,
771
+ * flow diagrams) must route through this so the translation lives in one place
772
+ * and can later be swapped for a localized lookup.
773
+ */
774
+ declare function humanizeProcessLabel(identifier: unknown): string;
775
+
776
+ declare const TURN_ACCEPTANCE_STATES: readonly ["accepted", "requires_changes", "neutral"];
777
+ type TurnAcceptanceState = (typeof TURN_ACCEPTANCE_STATES)[number];
778
+
779
+ declare const TURN_ANNOTATION_REFERENCE_KINDS: readonly ["turn_record", "entry", "semantic_entry_ref"];
780
+ type TurnAnnotationReferenceKind = (typeof TURN_ANNOTATION_REFERENCE_KINDS)[number];
781
+ type TurnAnnotationReferenceRole = string;
782
+ interface TurnRecordAnnotationReference {
783
+ kind: "turn_record";
784
+ turnRecordId: string;
785
+ role: TurnAnnotationReferenceRole | null;
786
+ }
787
+ interface EntryTurnAnnotationReference {
788
+ kind: "entry";
789
+ entryId: string;
790
+ role: TurnAnnotationReferenceRole | null;
791
+ }
792
+ interface SemanticEntryRefTurnAnnotationReference {
793
+ kind: "semantic_entry_ref";
794
+ ref: ProcessSemanticEntryRefKey;
795
+ role: TurnAnnotationReferenceRole | null;
796
+ }
797
+ type TurnAnnotationReference = TurnRecordAnnotationReference | EntryTurnAnnotationReference | SemanticEntryRefTurnAnnotationReference;
798
+ interface ProcessTurnAnnotation {
799
+ id: string;
800
+ instanceId: string;
801
+ annotationType: string;
802
+ annotationKey: string | null;
803
+ references: TurnAnnotationReference[];
804
+ payload: Record<string, unknown>;
805
+ createdAt: string;
806
+ updatedAt: string;
807
+ }
808
+ declare function parseTurnAnnotationReference(value: unknown): TurnAnnotationReference | null;
809
+ declare function parseTurnAnnotationReferences(value: unknown): TurnAnnotationReference[];
810
+
811
+ export { ADMIN_ACTOR, type Actor, type ActorKind, CONTINUE_PROMPT_METADATA_KEY, type CurrentExecutionRef, DEFAULT_CONTINUE_PROMPT, DEFAULT_LAUNCHER_RECENT_VALUE_LIMIT, type DurableModelSelection, type EntryTurnAnnotationReference, type ExternalWriteLog, type ExternalWriteType, FAILED_TURN_RECOVERY_CODES, FAILED_TURN_RECOVERY_METADATA_KEY, type FailedTurnRecoveryCode, type FailedTurnRecoveryContext, type FutureExecution, type FutureExecutionBlockReason, type FutureExecutionKind, type FutureExecutionScheduleKind, type InputKind, type InputSource, type InstanceTurnConfigInput, type InstanceTurnConfigMap, type InstanceTurnConfigsJsonError, type JsonObject, type LaunchModelConfigInput, type LlmContextMode, type ModelPolicyFailureCode, type ModelSelectionKind, type ModelSelectionProvenance, type ModelSelectionSource, type NormalizedQuestion, PROCESS_SELECTED_TURN_MODEL_SOURCES, PROCESS_SEMANTIC_ENTRY_REF_KEYS, PROCESS_TURN_RECORD_PATH_TYPES, PROCESS_TURN_TYPES, type ParsedRepoLocator, type PreparedTurnStart, type ProcessCustomizableFields, type ProcessEvent, type ProcessFlowEdge, type ProcessFlowEdgeKind, type ProcessFlowEndState, type ProcessFlowNode, type ProcessFlowNodeRole, type ProcessFlowView, type ProcessInput, type ProcessInputTarget, type ProcessInstance, type ProcessLeafOutcomeSnapshot, type ProcessLeafOutcomeSnapshotStatus, type ProcessLifecycleStatus, type ProcessProductRef, type ProcessProductRefs, type ProcessProject, type ProcessQuestionRequest, type ProcessRowSlot, type ProcessSelectedTurnModelSource, type ProcessSemanticEntryRefKey, type ProcessSemanticEntryRefs, type ProcessStateJsonParseContext, type ProcessTurnAnnotation, type ProcessTurnRecord, type ProcessTurnRecordPathType, type ProcessTurnRecordStatus, type ProcessTurnStartFallback, type ProcessTurnStartFromCurrentLeaf, type ProcessTurnStartFromEntry, type ProcessTurnStartFromProductRef, type ProcessTurnStartFromSemanticRef, type ProcessTurnStartFromSessionRoot, type ProcessTurnStartResolution, type ProcessTurnStartSelection, type ProcessTurnStartTarget, type ProcessTurnTerminalLifecycleStatus, type ProcessTurnTransition, type ProcessTurnType, type QuestionAnswerDraft, REVIEW_SUBJECT_KINDS, type RepoLocatorKind, type ResolvedTurnStart, type ReviewSubject, type ReviewSubjectKind, SERIALIZED_SYSTEM_ACTOR, SYSTEM_ACTOR, type SemanticEntryRef, type SemanticEntryRefTurnAnnotationReference, type SerializedProcessGraph, TELEGRAM_ACTOR, TURN_ACCEPTANCE_STATES, TURN_ANNOTATION_REFERENCE_KINDS, type TransitionTrigger, type TurnAcceptanceState, type TurnAnnotationReference, type TurnAnnotationReferenceKind, type TurnAnnotationReferenceRole, type TurnFailedPayload, type TurnFailureCode, type TurnId, type TurnOutcomePayload, type TurnRecordAnnotationReference, type TurnStartContinuation, type TurnStartKind, type TurnStartPreparationFailureCode, type TurnStartRecord, type TurnStartRecordState, WORKER_ERROR_CLASSES, type WorkerBootstrapReceipt, type WorkerErrorClass, type WorkerLease, type WorkerState, addLauncherRecentValue, assertRepoLocator, assertValidProcessProductName, buildFailedTurnRecoveryMetadata, buildProcessRowSlot, canonicalizeQuestionAnswers, createEmptyProcessProductRefs, createEmptyProcessSemanticEntryRefs, createGenericFailedTurnRecoveryContext, createReviewSubject, defaultProcessTurnStartSelection, detectRepoLocatorKind, emptyQuestionDrafts, formatPathTypeLabel, getProcessStatusCategory, humanizeProcessLabel, isFailedTurnRecoveryCode, isProcessSelectedTurnModelSource, isProcessSemanticEntryRefKey, isProcessTurnType, isRepoLocator, isReviewSubjectKind, isTurnFailureCode, isValidProcessProductName, isWaitingTurnType, isWorkerErrorClass, isWorkerOwnedTurnType, lifecycleStatusForSelectedTurnType, normalizeActor, normalizeAskQuestionsInput, normalizeContinuePrompt, normalizeLaunchModelConfigInput, normalizeLauncherRecentValue, normalizeLauncherRecentValues, normalizeMarkdownLineEndings, normalizeMarkdownText, normalizeOptionalMarkdown, normalizeStringArray, parseActorOrSystem, parseProcessProductRefs, parseProcessSemanticEntryRefs, parseProcessStateJsonLenient, parseProcessStateJsonStrict, parseProductRefsFromStateJsonLenient, parseProductRefsFromStateJsonStrict, parseProductRefsLenient, parseProductRefsStrict, parseRepoLocator, parseReviewSubject, parseSemanticEntryRef, parseSemanticEntryRefsFromStateJsonLenient, parseSemanticEntryRefsFromStateJsonStrict, parseSemanticEntryRefsLenient, parseSemanticEntryRefsStrict, parseStrictInstanceTurnConfigsJson, parseTurnAnnotationReference, parseTurnAnnotationReferences, readFailedTurnRecoveryContext, redactCredentialBearingAbsoluteUrl, resolveExistingProcessEntryId, resolveProcessProductRefEntryId, resolveProcessSemanticRefEntryId, resolveProcessTurnStartSelection, resolveProcessTurnStartTarget, serializeActor, serializeInstanceTurnConfigs, sortProcessRows, trimString, trimToNull };