@leitwerk-dev/domain 0.1.2 → 0.1.3
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/actor.d.ts +18 -0
- package/dist/actor.d.ts.map +1 -0
- package/dist/actor.js +72 -0
- package/dist/actor.js.map +1 -0
- package/dist/domain-model.d.ts +472 -0
- package/dist/domain-model.d.ts.map +1 -0
- package/dist/domain-model.js +171 -0
- package/dist/domain-model.js.map +1 -0
- package/dist/index.d.ts +18 -811
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -1005
- package/dist/index.js.map +1 -1
- package/dist/launcher-recent-values.d.ts +10 -0
- package/dist/launcher-recent-values.d.ts.map +1 -0
- package/dist/launcher-recent-values.js +60 -0
- package/dist/launcher-recent-values.js.map +1 -0
- package/dist/markdown-normalize.d.ts +4 -0
- package/dist/markdown-normalize.d.ts.map +1 -0
- package/dist/markdown-normalize.js +14 -0
- package/dist/markdown-normalize.js.map +1 -0
- package/dist/process-definitions.d.ts +68 -0
- package/dist/process-definitions.d.ts.map +1 -0
- package/dist/process-definitions.js +2 -0
- package/dist/process-definitions.js.map +1 -0
- package/dist/process-model-config.d.ts +24 -0
- package/dist/process-model-config.d.ts.map +1 -0
- package/dist/process-model-config.js +68 -0
- package/dist/process-model-config.js.map +1 -0
- package/dist/process-row-slots.d.ts +17 -0
- package/dist/process-row-slots.d.ts.map +1 -0
- package/dist/process-row-slots.js +45 -0
- package/dist/process-row-slots.js.map +1 -0
- package/dist/process-state-json.d.ts +16 -0
- package/dist/process-state-json.d.ts.map +1 -0
- package/dist/process-state-json.js +102 -0
- package/dist/process-state-json.js.map +1 -0
- package/dist/repo-locator.d.ts +10 -0
- package/dist/repo-locator.d.ts.map +1 -0
- package/dist/repo-locator.js +82 -0
- package/dist/repo-locator.js.map +1 -0
- package/dist/review-subject.d.ts +9 -0
- package/dist/review-subject.d.ts.map +1 -0
- package/dist/review-subject.js +18 -0
- package/dist/review-subject.js.map +1 -0
- package/dist/semantic-entry-refs.d.ts +34 -0
- package/dist/semantic-entry-refs.d.ts.map +1 -0
- package/dist/semantic-entry-refs.js +79 -0
- package/dist/semantic-entry-refs.js.map +1 -0
- package/dist/string-normalize.d.ts +12 -0
- package/dist/string-normalize.d.ts.map +1 -0
- package/dist/string-normalize.js +28 -0
- package/dist/string-normalize.js.map +1 -0
- package/dist/turn-acceptance.d.ts +3 -0
- package/dist/turn-acceptance.d.ts.map +1 -0
- package/dist/turn-acceptance.js +2 -0
- package/dist/turn-acceptance.js.map +1 -0
- package/dist/turn-annotations.d.ts +33 -0
- package/dist/turn-annotations.d.ts.map +1 -0
- package/dist/turn-annotations.js +49 -0
- package/dist/turn-annotations.js.map +1 -0
- package/dist/turn-recovery.d.ts +26 -0
- package/dist/turn-recovery.d.ts.map +1 -0
- package/dist/turn-recovery.js +70 -0
- package/dist/turn-recovery.js.map +1 -0
- package/dist/turn-start-resolution.d.ts +65 -0
- package/dist/turn-start-resolution.d.ts.map +1 -0
- package/dist/turn-start-resolution.js +97 -0
- package/dist/turn-start-resolution.js.map +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,1006 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const question = requiredTrimmedString(
|
|
17
|
-
candidate?.question,
|
|
18
|
-
`questions[${questionIndex}].question`
|
|
19
|
-
);
|
|
20
|
-
if (candidate?.selection !== "single" && candidate?.selection !== "multiple") {
|
|
21
|
-
throw new Error(`questions[${questionIndex}].selection must be 'single' or 'multiple'`);
|
|
22
|
-
}
|
|
23
|
-
if (!Array.isArray(candidate.options) || candidate.options.length === 0) {
|
|
24
|
-
throw new Error(`questions[${questionIndex}].options must not be empty`);
|
|
25
|
-
}
|
|
26
|
-
const labels = /* @__PURE__ */ new Set();
|
|
27
|
-
const questionId = `question_${questionIndex + 1}`;
|
|
28
|
-
const options = candidate.options.map((option, optionIndex) => {
|
|
29
|
-
const label = requiredTrimmedString(
|
|
30
|
-
option?.label,
|
|
31
|
-
`questions[${questionIndex}].options[${optionIndex}].label`
|
|
32
|
-
);
|
|
33
|
-
const key = label.toLocaleLowerCase();
|
|
34
|
-
if (labels.has(key)) {
|
|
35
|
-
throw new Error(`questions[${questionIndex}] contains duplicate option '${label}'`);
|
|
36
|
-
}
|
|
37
|
-
labels.add(key);
|
|
38
|
-
return {
|
|
39
|
-
id: `${questionId}_option_${optionIndex + 1}`,
|
|
40
|
-
label,
|
|
41
|
-
details: typeof option.details === "string" && option.details.trim() !== "" ? option.details.trim() : null
|
|
42
|
-
};
|
|
43
|
-
});
|
|
44
|
-
return { id: questionId, question, selection: candidate.selection, options };
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
function emptyQuestionDrafts(questions) {
|
|
48
|
-
return questions.map(() => ({ selectedOptionIds: [], freeText: "", comment: "" }));
|
|
49
|
-
}
|
|
50
|
-
function normalizeQuestionDrafts(questions, value) {
|
|
51
|
-
if (!Array.isArray(value) || value.length !== questions.length) {
|
|
52
|
-
throw new Error("Every question must have one draft answer in question order");
|
|
53
|
-
}
|
|
54
|
-
return questions.map((question, index) => {
|
|
55
|
-
const answer = value[index];
|
|
56
|
-
if (!Array.isArray(answer?.selectedOptionIds)) {
|
|
57
|
-
throw new Error(`Question ${index + 1} has a malformed selection`);
|
|
58
|
-
}
|
|
59
|
-
const selectedOptionIds = answer.selectedOptionIds.map((id) => {
|
|
60
|
-
if (typeof id !== "string" || !question.options.some((option) => option.id === id)) {
|
|
61
|
-
throw new Error(`Question ${index + 1} contains an unknown selection`);
|
|
62
|
-
}
|
|
63
|
-
return id;
|
|
64
|
-
});
|
|
65
|
-
if (new Set(selectedOptionIds).size !== selectedOptionIds.length) {
|
|
66
|
-
throw new Error(`Question ${index + 1} contains duplicate selections`);
|
|
67
|
-
}
|
|
68
|
-
if (question.selection === "single" && selectedOptionIds.length > 1) {
|
|
69
|
-
throw new Error(`Question ${index + 1} accepts only one selection`);
|
|
70
|
-
}
|
|
71
|
-
if (typeof answer.freeText !== "string" || typeof answer.comment !== "string") {
|
|
72
|
-
throw new Error(`Question ${index + 1} contains malformed text`);
|
|
73
|
-
}
|
|
74
|
-
return { selectedOptionIds, freeText: answer.freeText, comment: answer.comment };
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
function canonicalizeQuestionAnswers(questions, value) {
|
|
78
|
-
return normalizeQuestionDrafts(questions, value).map((answer, index) => {
|
|
79
|
-
const question = questions[index];
|
|
80
|
-
if (!question) throw new Error(`Question ${index + 1} is missing`);
|
|
81
|
-
const options = answer.selectedOptionIds.map(
|
|
82
|
-
(id) => question.options.find((option) => option.id === id)?.label ?? ""
|
|
83
|
-
);
|
|
84
|
-
const freeText = answer.freeText.trim();
|
|
85
|
-
const comment = answer.comment.trim();
|
|
86
|
-
if (options.length === 0 && freeText === "") {
|
|
87
|
-
throw new Error(`Question ${index + 1} requires an answer`);
|
|
88
|
-
}
|
|
89
|
-
return [options.join(", "), freeText, comment ? `Context: ${comment}` : ""].filter(Boolean).join("\n");
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
var WORKER_ERROR_CLASSES = [
|
|
93
|
-
"llm_error",
|
|
94
|
-
"git_error",
|
|
95
|
-
"pi_crash",
|
|
96
|
-
"pipeline_error",
|
|
97
|
-
"infrastructure",
|
|
98
|
-
"protocol_error",
|
|
99
|
-
"operator_abort"
|
|
100
|
-
];
|
|
101
|
-
function isWorkerErrorClass(value) {
|
|
102
|
-
return WORKER_ERROR_CLASSES.includes(value);
|
|
103
|
-
}
|
|
104
|
-
function isTurnFailureCode(value) {
|
|
105
|
-
return value === "branch_drift";
|
|
106
|
-
}
|
|
107
|
-
var PROCESS_TURN_TYPES = [
|
|
108
|
-
"llm",
|
|
109
|
-
"human",
|
|
110
|
-
"external",
|
|
111
|
-
"automatic",
|
|
112
|
-
"server_automatic"
|
|
113
|
-
];
|
|
114
|
-
function isProcessTurnType(value) {
|
|
115
|
-
return typeof value === "string" && PROCESS_TURN_TYPES.includes(value);
|
|
116
|
-
}
|
|
117
|
-
function isWorkerOwnedTurnType(turnType) {
|
|
118
|
-
return turnType === "llm" || turnType === "automatic";
|
|
119
|
-
}
|
|
120
|
-
function isWaitingTurnType(turnType) {
|
|
121
|
-
return turnType === "human" || turnType === "external";
|
|
122
|
-
}
|
|
123
|
-
function lifecycleStatusForSelectedTurnType(turnType) {
|
|
124
|
-
return isWaitingTurnType(turnType) ? "waiting" : "active";
|
|
125
|
-
}
|
|
126
|
-
var PROCESS_SELECTED_TURN_MODEL_SOURCES = [
|
|
127
|
-
"action_override",
|
|
128
|
-
"launch_override",
|
|
129
|
-
"instance_turn_config",
|
|
130
|
-
"process_config_turn",
|
|
131
|
-
"instance_default",
|
|
132
|
-
"process_config_default",
|
|
133
|
-
"catalog_default",
|
|
134
|
-
"legacy_persisted"
|
|
135
|
-
];
|
|
136
|
-
function isProcessSelectedTurnModelSource(value) {
|
|
137
|
-
return PROCESS_SELECTED_TURN_MODEL_SOURCES.includes(value);
|
|
138
|
-
}
|
|
139
|
-
var PROCESS_TURN_RECORD_PATH_TYPES = ["primary", "root_branch", "leaf_branch"];
|
|
140
|
-
function formatPathTypeLabel(pathType) {
|
|
141
|
-
switch (pathType) {
|
|
142
|
-
case "primary":
|
|
143
|
-
return "Continuing the main path";
|
|
144
|
-
case "root_branch":
|
|
145
|
-
return "Starting from the beginning";
|
|
146
|
-
case "leaf_branch":
|
|
147
|
-
return "Exploring an alternative";
|
|
148
|
-
default:
|
|
149
|
-
return "Path";
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// src/actor.ts
|
|
154
|
-
var ACTOR_KINDS = ["user", "channel", "system"];
|
|
155
|
-
var ACTOR_PROVIDERS = [
|
|
156
|
-
"forgejo",
|
|
157
|
-
"gitlab",
|
|
158
|
-
"telegram"
|
|
159
|
-
];
|
|
160
|
-
function isActorKind(value) {
|
|
161
|
-
return typeof value === "string" && ACTOR_KINDS.includes(value);
|
|
162
|
-
}
|
|
163
|
-
function normalizeProvider(value) {
|
|
164
|
-
if (typeof value !== "string") {
|
|
165
|
-
return null;
|
|
166
|
-
}
|
|
167
|
-
return ACTOR_PROVIDERS.includes(value) ? value : null;
|
|
168
|
-
}
|
|
169
|
-
function normalizeActor(value) {
|
|
170
|
-
if (typeof value !== "object" || value === null) {
|
|
171
|
-
return null;
|
|
172
|
-
}
|
|
173
|
-
const candidate = value;
|
|
174
|
-
const id = typeof candidate.id === "string" ? candidate.id.trim() : "";
|
|
175
|
-
if (id === "") {
|
|
176
|
-
return null;
|
|
177
|
-
}
|
|
178
|
-
const kind = isActorKind(candidate.kind) ? candidate.kind : "system";
|
|
179
|
-
const provider = normalizeProvider(candidate.provider);
|
|
180
|
-
const displayName = typeof candidate.displayName === "string" && candidate.displayName.trim() !== "" ? candidate.displayName : void 0;
|
|
181
|
-
return {
|
|
182
|
-
id,
|
|
183
|
-
kind,
|
|
184
|
-
provider,
|
|
185
|
-
...displayName !== void 0 ? { displayName } : {}
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
function serializeActor(actor) {
|
|
189
|
-
return JSON.stringify({
|
|
190
|
-
id: actor.id,
|
|
191
|
-
kind: actor.kind,
|
|
192
|
-
provider: actor.provider,
|
|
193
|
-
...actor.displayName !== void 0 ? { displayName: actor.displayName } : {}
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
function parseActorOrSystem(value) {
|
|
197
|
-
if (value === null || value === void 0 || value.trim() === "") {
|
|
198
|
-
return SYSTEM_ACTOR;
|
|
199
|
-
}
|
|
200
|
-
try {
|
|
201
|
-
return normalizeActor(JSON.parse(value)) ?? SYSTEM_ACTOR;
|
|
202
|
-
} catch {
|
|
203
|
-
return SYSTEM_ACTOR;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
var SERIALIZED_SYSTEM_ACTOR = serializeActor(SYSTEM_ACTOR);
|
|
207
|
-
|
|
208
|
-
// src/launcher-recent-values.ts
|
|
209
|
-
var DEFAULT_LAUNCHER_RECENT_VALUE_LIMIT = 5;
|
|
210
|
-
function hasCredentialBearingAbsoluteUrl(value) {
|
|
211
|
-
if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(value)) {
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
214
|
-
try {
|
|
215
|
-
const url = new URL(value);
|
|
216
|
-
return url.protocol !== "file:" && (url.username !== "" || url.password !== "");
|
|
217
|
-
} catch {
|
|
218
|
-
return false;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
function redactCredentialBearingAbsoluteUrl(value) {
|
|
222
|
-
if (!hasCredentialBearingAbsoluteUrl(value)) {
|
|
223
|
-
return value;
|
|
224
|
-
}
|
|
225
|
-
const url = new URL(value);
|
|
226
|
-
url.username = "";
|
|
227
|
-
url.password = "";
|
|
228
|
-
return url.toString();
|
|
229
|
-
}
|
|
230
|
-
function normalizeLauncherRecentValue(value) {
|
|
231
|
-
const normalizedValue = typeof value === "string" ? value.trim() : "";
|
|
232
|
-
if (!normalizedValue) {
|
|
233
|
-
return null;
|
|
234
|
-
}
|
|
235
|
-
if (hasCredentialBearingAbsoluteUrl(normalizedValue)) {
|
|
236
|
-
return null;
|
|
237
|
-
}
|
|
238
|
-
return normalizedValue;
|
|
239
|
-
}
|
|
240
|
-
function normalizeLauncherRecentValues(values, limit = DEFAULT_LAUNCHER_RECENT_VALUE_LIMIT) {
|
|
241
|
-
const nextValues = [];
|
|
242
|
-
const seen = /* @__PURE__ */ new Set();
|
|
243
|
-
for (const value of values) {
|
|
244
|
-
const normalizedValue = normalizeLauncherRecentValue(value);
|
|
245
|
-
if (!normalizedValue || seen.has(normalizedValue)) {
|
|
246
|
-
continue;
|
|
247
|
-
}
|
|
248
|
-
seen.add(normalizedValue);
|
|
249
|
-
nextValues.push(normalizedValue);
|
|
250
|
-
if (nextValues.length >= limit) {
|
|
251
|
-
break;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
return nextValues;
|
|
255
|
-
}
|
|
256
|
-
function addLauncherRecentValue(existingValues, value, limit = DEFAULT_LAUNCHER_RECENT_VALUE_LIMIT) {
|
|
257
|
-
const normalizedValue = normalizeLauncherRecentValue(value);
|
|
258
|
-
if (!normalizedValue) {
|
|
259
|
-
return normalizeLauncherRecentValues(existingValues, limit);
|
|
260
|
-
}
|
|
261
|
-
return normalizeLauncherRecentValues([normalizedValue, ...existingValues], limit);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// src/markdown-normalize.ts
|
|
265
|
-
function normalizeMarkdownLineEndings(markdown) {
|
|
266
|
-
return markdown.replace(/\r\n?/g, "\n");
|
|
267
|
-
}
|
|
268
|
-
function normalizeMarkdownText(markdown) {
|
|
269
|
-
return normalizeMarkdownLineEndings(markdown).trim();
|
|
270
|
-
}
|
|
271
|
-
function normalizeOptionalMarkdown(value) {
|
|
272
|
-
if (typeof value !== "string") {
|
|
273
|
-
return null;
|
|
274
|
-
}
|
|
275
|
-
const normalized = normalizeMarkdownText(value);
|
|
276
|
-
return normalized === "" ? null : normalized;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// src/process-model-config.ts
|
|
280
|
-
import * as v from "valibot";
|
|
281
|
-
|
|
282
|
-
// src/string-normalize.ts
|
|
283
|
-
function trimString(value) {
|
|
284
|
-
return typeof value === "string" ? value.trim() : "";
|
|
285
|
-
}
|
|
286
|
-
function trimToNull(value) {
|
|
287
|
-
const trimmed = trimString(value);
|
|
288
|
-
return trimmed === "" ? null : trimmed;
|
|
289
|
-
}
|
|
290
|
-
function normalizeStringArray(value) {
|
|
291
|
-
if (!Array.isArray(value)) {
|
|
292
|
-
return [];
|
|
293
|
-
}
|
|
294
|
-
return value.map((entry) => trimString(entry)).filter((entry) => entry.length > 0);
|
|
295
|
-
}
|
|
296
|
-
function humanizeProcessLabel(identifier) {
|
|
297
|
-
return trimString(identifier).replace(/[_-]+/g, " ").replace(/\s+/g, " ").replace(/\b\w/g, (letter) => letter.toUpperCase()).trim();
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// src/process-model-config.ts
|
|
301
|
-
var jsonObjectSchema = v.custom(
|
|
302
|
-
(value) => typeof value === "object" && value !== null && !Array.isArray(value),
|
|
303
|
-
"Expected object"
|
|
304
|
-
);
|
|
305
|
-
var instanceTurnConfigSchema = v.pipe(
|
|
306
|
-
jsonObjectSchema,
|
|
307
|
-
v.object({
|
|
308
|
-
modelProfileId: v.optional(v.unknown())
|
|
309
|
-
})
|
|
310
|
-
);
|
|
311
|
-
var strictInstanceTurnConfigsJsonSchema = v.pipe(
|
|
312
|
-
v.string(),
|
|
313
|
-
v.parseJson(),
|
|
314
|
-
jsonObjectSchema,
|
|
315
|
-
v.record(v.string(), instanceTurnConfigSchema)
|
|
316
|
-
);
|
|
317
|
-
function normalizeInstanceTurnConfigs(turnConfigs) {
|
|
318
|
-
const next = {};
|
|
319
|
-
for (const [turnId, turnConfig] of Object.entries(turnConfigs)) {
|
|
320
|
-
const modelProfileId = trimToNull(turnConfig.modelProfileId);
|
|
321
|
-
next[turnId] = modelProfileId ? { modelProfileId } : {};
|
|
322
|
-
}
|
|
323
|
-
return next;
|
|
324
|
-
}
|
|
325
|
-
function getFirstIssuePathKey(issue) {
|
|
326
|
-
const pathItem = issue.path?.[0];
|
|
327
|
-
return typeof pathItem?.key === "string" ? pathItem.key : void 0;
|
|
328
|
-
}
|
|
329
|
-
function parseStrictInstanceTurnConfigsJson(processId, turnConfigsJson) {
|
|
330
|
-
if (!turnConfigsJson) return { ok: true, value: {} };
|
|
331
|
-
const result = v.safeParse(strictInstanceTurnConfigsJsonSchema, turnConfigsJson, {
|
|
332
|
-
abortEarly: true
|
|
333
|
-
});
|
|
334
|
-
if (!result.success) {
|
|
335
|
-
const issue = result.issues[0];
|
|
336
|
-
if (issue?.type === "parse_json") {
|
|
337
|
-
return {
|
|
338
|
-
ok: false,
|
|
339
|
-
error: { code: "invalid_turn_configs_json", processId, reason: "invalid_json" }
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
const turnId = issue ? getFirstIssuePathKey(issue) : void 0;
|
|
343
|
-
return {
|
|
344
|
-
ok: false,
|
|
345
|
-
error: {
|
|
346
|
-
code: "invalid_turn_configs_json",
|
|
347
|
-
processId,
|
|
348
|
-
reason: turnId !== void 0 ? "turn_config_not_object" : "not_object",
|
|
349
|
-
...turnId !== void 0 ? { turnId } : {}
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
return { ok: true, value: normalizeInstanceTurnConfigs(result.output) };
|
|
354
|
-
}
|
|
355
|
-
function serializeInstanceTurnConfigs(turnConfigs) {
|
|
356
|
-
const normalizedEntries = Object.entries(turnConfigs).map(([turnId, turnConfig]) => {
|
|
357
|
-
const modelProfileId = trimToNull(turnConfig.modelProfileId);
|
|
358
|
-
return [turnId, modelProfileId ? { modelProfileId } : {}];
|
|
359
|
-
}).filter(([, turnConfig]) => Object.keys(turnConfig).length > 0);
|
|
360
|
-
return normalizedEntries.length === 0 ? null : JSON.stringify(Object.fromEntries(normalizedEntries));
|
|
361
|
-
}
|
|
362
|
-
function normalizeLaunchModelConfigInput(input) {
|
|
363
|
-
const defaultModelProfileId = trimToNull(input.defaultModelProfileId);
|
|
364
|
-
const nextTurnConfigs = {};
|
|
365
|
-
for (const [turnId, turnConfig] of Object.entries(input.turnConfigs ?? {})) {
|
|
366
|
-
const modelProfileId = trimToNull(turnConfig.modelProfileId);
|
|
367
|
-
if (modelProfileId) nextTurnConfigs[turnId] = { modelProfileId };
|
|
368
|
-
}
|
|
369
|
-
return { defaultModelProfileId, turnConfigs: nextTurnConfigs };
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
// src/process-row-slots.ts
|
|
373
|
-
function getProcessStatusCategory(lifecycleStatus) {
|
|
374
|
-
if (lifecycleStatus === "error") return "error";
|
|
375
|
-
if (lifecycleStatus === "active") return "active";
|
|
376
|
-
if (lifecycleStatus === "waiting") return "waiting";
|
|
377
|
-
if (lifecycleStatus === "completed" || lifecycleStatus === "aborted") return "terminal";
|
|
378
|
-
return "discovered";
|
|
379
|
-
}
|
|
380
|
-
function buildProcessRowSlot(process, projects) {
|
|
381
|
-
const externalLinkCount = projects.filter((p) => p.externalId !== null).length;
|
|
382
|
-
const title = process.title ?? process.externalId ?? process.id;
|
|
383
|
-
const subtitle = `${process.processId} \xB7 ${projects.length} component${projects.length !== 1 ? "s" : ""}`;
|
|
384
|
-
return {
|
|
385
|
-
instanceId: process.id,
|
|
386
|
-
processId: process.processId,
|
|
387
|
-
title,
|
|
388
|
-
subtitle,
|
|
389
|
-
selectedTurnId: process.selectedTurnId,
|
|
390
|
-
lifecycleStatus: process.lifecycleStatus,
|
|
391
|
-
statusCategory: getProcessStatusCategory(process.lifecycleStatus),
|
|
392
|
-
projectCount: projects.length,
|
|
393
|
-
externalId: process.externalId,
|
|
394
|
-
externalLinkCount
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
function sortProcessRows(rows) {
|
|
398
|
-
const categoryOrder = {
|
|
399
|
-
error: 0,
|
|
400
|
-
active: 1,
|
|
401
|
-
waiting: 2,
|
|
402
|
-
discovered: 3,
|
|
403
|
-
terminal: 4
|
|
404
|
-
};
|
|
405
|
-
return [...rows].sort((a, b) => {
|
|
406
|
-
const catA = categoryOrder[a.statusCategory] ?? 4;
|
|
407
|
-
const catB = categoryOrder[b.statusCategory] ?? 4;
|
|
408
|
-
if (catA !== catB) return catA - catB;
|
|
409
|
-
return a.title.localeCompare(b.title);
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
// src/semantic-entry-refs.ts
|
|
414
|
-
var PROCESS_SEMANTIC_ENTRY_REF_KEYS = [
|
|
415
|
-
"plan",
|
|
416
|
-
"review",
|
|
417
|
-
"currentPrimaryPathLeaf",
|
|
418
|
-
"rootEntry"
|
|
419
|
-
];
|
|
420
|
-
var PRODUCT_NAME_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
421
|
-
function isValidProcessProductName(value) {
|
|
422
|
-
return PRODUCT_NAME_PATTERN.test(value);
|
|
423
|
-
}
|
|
424
|
-
function assertValidProcessProductName(value) {
|
|
425
|
-
if (!isValidProcessProductName(value)) {
|
|
426
|
-
throw new Error(
|
|
427
|
-
`Invalid process product name '${value}'. Product names must match ${PRODUCT_NAME_PATTERN.source}`
|
|
428
|
-
);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
function parseSemanticEntryId(value) {
|
|
432
|
-
if (typeof value !== "string") {
|
|
433
|
-
return null;
|
|
434
|
-
}
|
|
435
|
-
const trimmed = value.trim();
|
|
436
|
-
return trimmed.length > 0 ? trimmed : null;
|
|
437
|
-
}
|
|
438
|
-
function isProcessSemanticEntryRefKey(value) {
|
|
439
|
-
return PROCESS_SEMANTIC_ENTRY_REF_KEYS.includes(value);
|
|
440
|
-
}
|
|
441
|
-
function parseSemanticEntryRef(value) {
|
|
442
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
443
|
-
return null;
|
|
444
|
-
}
|
|
445
|
-
const record2 = value;
|
|
446
|
-
const entryId = parseSemanticEntryId(record2.entryId);
|
|
447
|
-
if (!entryId) {
|
|
448
|
-
return null;
|
|
449
|
-
}
|
|
450
|
-
return {
|
|
451
|
-
entryId,
|
|
452
|
-
turnRecordId: parseSemanticEntryId(record2.turnRecordId)
|
|
453
|
-
};
|
|
454
|
-
}
|
|
455
|
-
function createEmptyProcessSemanticEntryRefs() {
|
|
456
|
-
return {
|
|
457
|
-
plan: null,
|
|
458
|
-
review: null,
|
|
459
|
-
currentPrimaryPathLeaf: null,
|
|
460
|
-
rootEntry: null
|
|
461
|
-
};
|
|
462
|
-
}
|
|
463
|
-
function createEmptyProcessProductRefs() {
|
|
464
|
-
return {};
|
|
465
|
-
}
|
|
466
|
-
function parseProcessProductRefs(value) {
|
|
467
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
468
|
-
return createEmptyProcessProductRefs();
|
|
469
|
-
}
|
|
470
|
-
const refs = {};
|
|
471
|
-
for (const [name, rawRef] of Object.entries(value)) {
|
|
472
|
-
if (!isValidProcessProductName(name)) {
|
|
473
|
-
continue;
|
|
474
|
-
}
|
|
475
|
-
const ref = parseSemanticEntryRef(rawRef);
|
|
476
|
-
if (ref) {
|
|
477
|
-
refs[name] = ref;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
return refs;
|
|
481
|
-
}
|
|
482
|
-
function parseProcessSemanticEntryRefs(value) {
|
|
483
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
484
|
-
return createEmptyProcessSemanticEntryRefs();
|
|
485
|
-
}
|
|
486
|
-
const record2 = value;
|
|
487
|
-
return {
|
|
488
|
-
plan: parseSemanticEntryRef(record2.plan),
|
|
489
|
-
review: parseSemanticEntryRef(record2.review),
|
|
490
|
-
currentPrimaryPathLeaf: parseSemanticEntryRef(record2.currentPrimaryPathLeaf),
|
|
491
|
-
rootEntry: parseSemanticEntryRef(record2.rootEntry)
|
|
492
|
-
};
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
// src/process-state-json.ts
|
|
496
|
-
function formatMalformedSubject(defaultLabel, context) {
|
|
497
|
-
if (typeof context === "string") {
|
|
498
|
-
return context;
|
|
499
|
-
}
|
|
500
|
-
const label = context?.label ?? defaultLabel;
|
|
501
|
-
return context?.processId ? `${label} for process '${context.processId}'` : label;
|
|
502
|
-
}
|
|
503
|
-
function parseProcessStateJsonStrict(stateJson, context) {
|
|
504
|
-
if (!stateJson) {
|
|
505
|
-
return {};
|
|
506
|
-
}
|
|
507
|
-
const subject = formatMalformedSubject("stateJson", context);
|
|
508
|
-
let parsed;
|
|
509
|
-
try {
|
|
510
|
-
parsed = JSON.parse(stateJson);
|
|
511
|
-
} catch (error) {
|
|
512
|
-
throw new Error(
|
|
513
|
-
`Malformed ${subject}: ${error instanceof Error ? error.message : String(error)}`
|
|
514
|
-
);
|
|
515
|
-
}
|
|
516
|
-
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
517
|
-
throw new Error(`Malformed ${subject}: expected a JSON object`);
|
|
518
|
-
}
|
|
519
|
-
return parsed;
|
|
520
|
-
}
|
|
521
|
-
function parseProcessStateJsonLenient(stateJson) {
|
|
522
|
-
try {
|
|
523
|
-
return parseProcessStateJsonStrict(stateJson);
|
|
524
|
-
} catch {
|
|
525
|
-
return {};
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
function parseSemanticEntryRefsStrict(value, context) {
|
|
529
|
-
if (value === void 0) {
|
|
530
|
-
return createEmptyProcessSemanticEntryRefs();
|
|
531
|
-
}
|
|
532
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
533
|
-
throw new Error(
|
|
534
|
-
`Malformed ${formatMalformedSubject("semanticEntryRefs", {
|
|
535
|
-
label: "semanticEntryRefs",
|
|
536
|
-
processId: context?.processId
|
|
537
|
-
})}: expected an object when present`
|
|
538
|
-
);
|
|
539
|
-
}
|
|
540
|
-
return parseProcessSemanticEntryRefs(value);
|
|
541
|
-
}
|
|
542
|
-
function parseSemanticEntryRefsLenient(value) {
|
|
543
|
-
try {
|
|
544
|
-
return parseSemanticEntryRefsStrict(value);
|
|
545
|
-
} catch {
|
|
546
|
-
return createEmptyProcessSemanticEntryRefs();
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
function parseProductRefsStrict(value, context) {
|
|
550
|
-
if (value === void 0) {
|
|
551
|
-
return createEmptyProcessProductRefs();
|
|
552
|
-
}
|
|
553
|
-
const subject = formatMalformedSubject("productRefs", {
|
|
554
|
-
label: "productRefs",
|
|
555
|
-
processId: context?.processId
|
|
556
|
-
});
|
|
557
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
558
|
-
throw new Error(`Malformed ${subject}: expected an object when present`);
|
|
559
|
-
}
|
|
560
|
-
const refs = {};
|
|
561
|
-
for (const [name, rawRef] of Object.entries(value)) {
|
|
562
|
-
if (!isValidProcessProductName(name)) {
|
|
563
|
-
throw new Error(`Malformed ${subject}: invalid product name '${name}'`);
|
|
564
|
-
}
|
|
565
|
-
const ref = parseSemanticEntryRef(rawRef);
|
|
566
|
-
if (!ref) {
|
|
567
|
-
throw new Error(`Malformed ${subject}: product '${name}' must reference an entry`);
|
|
568
|
-
}
|
|
569
|
-
refs[name] = ref;
|
|
570
|
-
}
|
|
571
|
-
return refs;
|
|
572
|
-
}
|
|
573
|
-
function parseProductRefsLenient(value) {
|
|
574
|
-
try {
|
|
575
|
-
return parseProductRefsStrict(value);
|
|
576
|
-
} catch {
|
|
577
|
-
return createEmptyProcessProductRefs();
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
function parseSemanticEntryRefsFromStateJsonStrict(stateJson, context) {
|
|
581
|
-
const stateRecord = parseProcessStateJsonStrict(stateJson, context);
|
|
582
|
-
return parseSemanticEntryRefsStrict(
|
|
583
|
-
stateRecord.semanticEntryRefs,
|
|
584
|
-
typeof context === "string" ? void 0 : context
|
|
585
|
-
);
|
|
586
|
-
}
|
|
587
|
-
function parseSemanticEntryRefsFromStateJsonLenient(stateJson) {
|
|
588
|
-
const stateRecord = parseProcessStateJsonLenient(stateJson);
|
|
589
|
-
return parseSemanticEntryRefsLenient(stateRecord.semanticEntryRefs);
|
|
590
|
-
}
|
|
591
|
-
function parseProductRefsFromStateJsonStrict(stateJson, context) {
|
|
592
|
-
const stateRecord = parseProcessStateJsonStrict(stateJson, context);
|
|
593
|
-
return parseProductRefsStrict(
|
|
594
|
-
stateRecord.productRefs,
|
|
595
|
-
typeof context === "string" ? void 0 : context
|
|
596
|
-
);
|
|
597
|
-
}
|
|
598
|
-
function parseProductRefsFromStateJsonLenient(stateJson) {
|
|
599
|
-
const stateRecord = parseProcessStateJsonLenient(stateJson);
|
|
600
|
-
return parseProductRefsLenient(stateRecord.productRefs);
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
// src/repo-locator.ts
|
|
604
|
-
function trimRepoLocator(value) {
|
|
605
|
-
return value.trim();
|
|
606
|
-
}
|
|
607
|
-
function isFileUrl(value) {
|
|
608
|
-
try {
|
|
609
|
-
const url = new URL(value);
|
|
610
|
-
if (url.protocol !== "file:") {
|
|
611
|
-
return false;
|
|
612
|
-
}
|
|
613
|
-
return (url.hostname === "" || url.hostname === "localhost") && url.pathname.startsWith("/") && decodeURIComponent(url.pathname).length > 1;
|
|
614
|
-
} catch {
|
|
615
|
-
return false;
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
function isLocalFilesystemPath(value) {
|
|
619
|
-
return value.startsWith("/") || value.startsWith("./") || value.startsWith("../") || value.startsWith("~/") || isFileUrl(value);
|
|
620
|
-
}
|
|
621
|
-
var scpLikeGitUrlPattern = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+:[^\s]+$/;
|
|
622
|
-
var explicitRemoteGitUrlPattern = /^(?:https?|ssh|git):\/\//;
|
|
623
|
-
function hasRepositoryPath(pathname) {
|
|
624
|
-
return pathname.split("/").filter(Boolean).length >= 1;
|
|
625
|
-
}
|
|
626
|
-
function isRemoteGitUrl(value) {
|
|
627
|
-
if (scpLikeGitUrlPattern.test(value)) {
|
|
628
|
-
const path = value.slice(value.indexOf(":") + 1);
|
|
629
|
-
return hasRepositoryPath(path);
|
|
630
|
-
}
|
|
631
|
-
if (!explicitRemoteGitUrlPattern.test(value)) {
|
|
632
|
-
return false;
|
|
633
|
-
}
|
|
634
|
-
try {
|
|
635
|
-
const url = new URL(value);
|
|
636
|
-
return ["http:", "https:", "ssh:", "git:"].includes(url.protocol) && !!url.hostname && hasRepositoryPath(url.pathname);
|
|
637
|
-
} catch {
|
|
638
|
-
return false;
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
function detectRepoLocatorKind(value) {
|
|
642
|
-
const trimmed = trimRepoLocator(value);
|
|
643
|
-
if (trimmed.length === 0) {
|
|
644
|
-
return null;
|
|
645
|
-
}
|
|
646
|
-
if (isLocalFilesystemPath(trimmed)) {
|
|
647
|
-
return "local_path";
|
|
648
|
-
}
|
|
649
|
-
if (isRemoteGitUrl(trimmed)) {
|
|
650
|
-
return "remote_url";
|
|
651
|
-
}
|
|
652
|
-
return null;
|
|
653
|
-
}
|
|
654
|
-
function parseRepoLocator(value) {
|
|
655
|
-
if (typeof value !== "string") {
|
|
656
|
-
return null;
|
|
657
|
-
}
|
|
658
|
-
const trimmed = trimRepoLocator(value);
|
|
659
|
-
const kind = detectRepoLocatorKind(trimmed);
|
|
660
|
-
if (!kind) {
|
|
661
|
-
return null;
|
|
662
|
-
}
|
|
663
|
-
return { kind, value: trimmed };
|
|
664
|
-
}
|
|
665
|
-
function isRepoLocator(value) {
|
|
666
|
-
return parseRepoLocator(value) !== null;
|
|
667
|
-
}
|
|
668
|
-
function assertRepoLocator(value, fieldName = "repoLocator") {
|
|
669
|
-
const parsed = parseRepoLocator(value);
|
|
670
|
-
if (!parsed) {
|
|
671
|
-
throw new Error(`${fieldName} must be a remote URL or local filesystem path`);
|
|
672
|
-
}
|
|
673
|
-
return parsed.value;
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
// src/review-subject.ts
|
|
677
|
-
var REVIEW_SUBJECT_KINDS = ["plan", "implementation"];
|
|
678
|
-
function isReviewSubjectKind(value) {
|
|
679
|
-
return REVIEW_SUBJECT_KINDS.includes(value);
|
|
680
|
-
}
|
|
681
|
-
function createReviewSubject(kind) {
|
|
682
|
-
return { kind };
|
|
683
|
-
}
|
|
684
|
-
function parseReviewSubject(value) {
|
|
685
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
686
|
-
return null;
|
|
687
|
-
}
|
|
688
|
-
const record2 = value;
|
|
689
|
-
if (typeof record2.kind !== "string" || !isReviewSubjectKind(record2.kind)) {
|
|
690
|
-
return null;
|
|
691
|
-
}
|
|
692
|
-
return { kind: record2.kind };
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
// src/turn-acceptance.ts
|
|
696
|
-
var TURN_ACCEPTANCE_STATES = ["accepted", "requires_changes", "neutral"];
|
|
697
|
-
|
|
698
|
-
// src/turn-annotations.ts
|
|
699
|
-
var TURN_ANNOTATION_REFERENCE_KINDS = [
|
|
700
|
-
"turn_record",
|
|
701
|
-
"entry",
|
|
702
|
-
"semantic_entry_ref"
|
|
703
|
-
];
|
|
704
|
-
function parseNonEmptyString(value) {
|
|
705
|
-
if (typeof value !== "string") {
|
|
706
|
-
return null;
|
|
707
|
-
}
|
|
708
|
-
const trimmed = value.trim();
|
|
709
|
-
return trimmed.length > 0 ? trimmed : null;
|
|
710
|
-
}
|
|
711
|
-
function parseTurnAnnotationReferenceRole(value) {
|
|
712
|
-
return parseNonEmptyString(value);
|
|
713
|
-
}
|
|
714
|
-
function parseTurnAnnotationReference(value) {
|
|
715
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
716
|
-
return null;
|
|
717
|
-
}
|
|
718
|
-
const record2 = value;
|
|
719
|
-
const kind = parseNonEmptyString(record2.kind);
|
|
720
|
-
const role = parseTurnAnnotationReferenceRole(record2.role);
|
|
721
|
-
if (!kind) {
|
|
722
|
-
return null;
|
|
723
|
-
}
|
|
724
|
-
if (kind === "turn_record") {
|
|
725
|
-
const turnRecordId = parseNonEmptyString(record2.turnRecordId);
|
|
726
|
-
return turnRecordId ? { kind, turnRecordId, role } : null;
|
|
727
|
-
}
|
|
728
|
-
if (kind === "entry") {
|
|
729
|
-
const entryId = parseNonEmptyString(record2.entryId);
|
|
730
|
-
return entryId ? { kind, entryId, role } : null;
|
|
731
|
-
}
|
|
732
|
-
if (kind === "semantic_entry_ref") {
|
|
733
|
-
const ref = parseNonEmptyString(record2.ref);
|
|
734
|
-
return ref && isProcessSemanticEntryRefKey(ref) ? { kind, ref, role } : null;
|
|
735
|
-
}
|
|
736
|
-
return null;
|
|
737
|
-
}
|
|
738
|
-
function parseTurnAnnotationReferences(value) {
|
|
739
|
-
if (!Array.isArray(value)) {
|
|
740
|
-
return [];
|
|
741
|
-
}
|
|
742
|
-
return value.map((reference) => parseTurnAnnotationReference(reference)).filter((reference) => reference !== null);
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
// src/turn-recovery.ts
|
|
746
|
-
var DEFAULT_CONTINUE_PROMPT = "continue";
|
|
747
|
-
var FAILED_TURN_RECOVERY_CODES = [
|
|
748
|
-
"generic_continue",
|
|
749
|
-
"missing_outcome_tool",
|
|
750
|
-
"missing_markdown_result",
|
|
751
|
-
"missing_required_tool_calls"
|
|
752
|
-
];
|
|
753
|
-
var FAILED_TURN_RECOVERY_METADATA_KEY = "failedTurnRecovery";
|
|
754
|
-
var CONTINUE_PROMPT_METADATA_KEY = "continuePrompt";
|
|
755
|
-
function isFailedTurnRecoveryCode(value) {
|
|
756
|
-
return FAILED_TURN_RECOVERY_CODES.includes(value);
|
|
757
|
-
}
|
|
758
|
-
function normalizeUniqueStringArray(value) {
|
|
759
|
-
const normalized = normalizeStringArray(value);
|
|
760
|
-
return normalized.length > 0 ? [...new Set(normalized)] : void 0;
|
|
761
|
-
}
|
|
762
|
-
function isRecord(value) {
|
|
763
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
764
|
-
}
|
|
765
|
-
function normalizeContinuePrompt(value) {
|
|
766
|
-
return trimToNull(value);
|
|
767
|
-
}
|
|
768
|
-
function createGenericFailedTurnRecoveryContext(overrides = {}) {
|
|
769
|
-
return {
|
|
770
|
-
strategy: "continue",
|
|
771
|
-
suggestedContinuePrompt: DEFAULT_CONTINUE_PROMPT,
|
|
772
|
-
failureCode: "generic_continue",
|
|
773
|
-
...overrides
|
|
774
|
-
};
|
|
775
|
-
}
|
|
776
|
-
function buildFailedTurnRecoveryMetadata(turnRecordId, context = {}) {
|
|
777
|
-
return {
|
|
778
|
-
[FAILED_TURN_RECOVERY_METADATA_KEY]: {
|
|
779
|
-
turnRecordId,
|
|
780
|
-
...createGenericFailedTurnRecoveryContext(context)
|
|
781
|
-
}
|
|
782
|
-
};
|
|
783
|
-
}
|
|
784
|
-
function readFailedTurnRecoveryContext(metadata, expectedTurnRecordId) {
|
|
785
|
-
if (!metadata) {
|
|
786
|
-
return null;
|
|
787
|
-
}
|
|
788
|
-
const raw = metadata[FAILED_TURN_RECOVERY_METADATA_KEY];
|
|
789
|
-
if (!isRecord(raw)) {
|
|
790
|
-
return null;
|
|
791
|
-
}
|
|
792
|
-
if (expectedTurnRecordId) {
|
|
793
|
-
const turnRecordId = trimToNull(raw.turnRecordId);
|
|
794
|
-
if (turnRecordId !== expectedTurnRecordId) {
|
|
795
|
-
return null;
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
if (raw.strategy !== "continue") {
|
|
799
|
-
return null;
|
|
800
|
-
}
|
|
801
|
-
const suggestedContinuePrompt = normalizeContinuePrompt(raw.suggestedContinuePrompt);
|
|
802
|
-
const failureCode = trimToNull(raw.failureCode);
|
|
803
|
-
if (!suggestedContinuePrompt || !failureCode || !isFailedTurnRecoveryCode(failureCode)) {
|
|
804
|
-
return null;
|
|
805
|
-
}
|
|
806
|
-
const missingToolNames = normalizeUniqueStringArray(raw.missingToolNames);
|
|
807
|
-
return {
|
|
808
|
-
strategy: "continue",
|
|
809
|
-
suggestedContinuePrompt,
|
|
810
|
-
failureCode,
|
|
811
|
-
...missingToolNames ? { missingToolNames } : {}
|
|
812
|
-
};
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
// src/turn-start-resolution.ts
|
|
816
|
-
function defaultProcessTurnStartSelection(branchType) {
|
|
817
|
-
switch (branchType) {
|
|
818
|
-
case "primary":
|
|
819
|
-
case "leaf_branch":
|
|
820
|
-
return { kind: "current_leaf" };
|
|
821
|
-
case "root_branch":
|
|
822
|
-
return { kind: "session_root" };
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
function resolveProcessTurnStartSelection(input) {
|
|
826
|
-
return input.startFrom ?? defaultProcessTurnStartSelection(input.branchType);
|
|
827
|
-
}
|
|
828
|
-
function resolveExistingProcessEntryId(entryId, entryExists) {
|
|
829
|
-
if (!entryId) {
|
|
830
|
-
return null;
|
|
831
|
-
}
|
|
832
|
-
return entryExists && !entryExists(entryId) ? null : entryId;
|
|
833
|
-
}
|
|
834
|
-
function resolveProcessSemanticRefEntryId(input) {
|
|
835
|
-
const fromState = resolveExistingProcessEntryId(
|
|
836
|
-
input.semanticEntryRefs?.[input.ref]?.entryId ?? null,
|
|
837
|
-
input.entryExists
|
|
838
|
-
);
|
|
839
|
-
if (fromState) {
|
|
840
|
-
return fromState;
|
|
841
|
-
}
|
|
842
|
-
if (input.ref === "currentPrimaryPathLeaf") {
|
|
843
|
-
return resolveExistingProcessEntryId(input.currentLeafId, input.entryExists);
|
|
844
|
-
}
|
|
845
|
-
if (input.ref === "rootEntry") {
|
|
846
|
-
return resolveExistingProcessEntryId(input.rootEntryId, input.entryExists);
|
|
847
|
-
}
|
|
848
|
-
return null;
|
|
849
|
-
}
|
|
850
|
-
function resolveProcessProductRefEntryId(input) {
|
|
851
|
-
const productName = input.productName.trim();
|
|
852
|
-
if (!productName) {
|
|
853
|
-
return null;
|
|
854
|
-
}
|
|
855
|
-
return resolveExistingProcessEntryId(
|
|
856
|
-
input.productRefs?.[productName]?.entryId ?? null,
|
|
857
|
-
input.entryExists
|
|
858
|
-
);
|
|
859
|
-
}
|
|
860
|
-
function resolveProcessTurnStartTarget(input) {
|
|
861
|
-
switch (input.selection.kind) {
|
|
862
|
-
case "current_leaf": {
|
|
863
|
-
return {
|
|
864
|
-
forkPiEntryId: resolveExistingProcessEntryId(input.currentLeafId, input.entryExists),
|
|
865
|
-
startTarget: { kind: "current_leaf" }
|
|
866
|
-
};
|
|
867
|
-
}
|
|
868
|
-
case "session_root": {
|
|
869
|
-
return {
|
|
870
|
-
forkPiEntryId: null,
|
|
871
|
-
startTarget: { kind: "root" }
|
|
872
|
-
};
|
|
873
|
-
}
|
|
874
|
-
case "entry": {
|
|
875
|
-
return {
|
|
876
|
-
forkPiEntryId: input.selection.entryId,
|
|
877
|
-
startTarget: { kind: "entry", entryId: input.selection.entryId }
|
|
878
|
-
};
|
|
879
|
-
}
|
|
880
|
-
case "semantic_ref": {
|
|
881
|
-
const entryId = resolveProcessSemanticRefEntryId({
|
|
882
|
-
ref: input.selection.ref,
|
|
883
|
-
semanticEntryRefs: input.semanticEntryRefs,
|
|
884
|
-
currentLeafId: input.currentLeafId,
|
|
885
|
-
rootEntryId: input.rootEntryId,
|
|
886
|
-
entryExists: input.entryExists
|
|
887
|
-
});
|
|
888
|
-
if (entryId) {
|
|
889
|
-
return {
|
|
890
|
-
forkPiEntryId: entryId,
|
|
891
|
-
startTarget: { kind: "entry", entryId }
|
|
892
|
-
};
|
|
893
|
-
}
|
|
894
|
-
return resolveProcessTurnStartTarget({
|
|
895
|
-
...input,
|
|
896
|
-
selection: input.selection.fallback ?? defaultProcessTurnStartSelection(input.branchType)
|
|
897
|
-
});
|
|
898
|
-
}
|
|
899
|
-
case "product_ref": {
|
|
900
|
-
const entryId = resolveProcessProductRefEntryId({
|
|
901
|
-
productName: input.selection.productName,
|
|
902
|
-
productRefs: input.productRefs,
|
|
903
|
-
entryExists: input.entryExists
|
|
904
|
-
});
|
|
905
|
-
if (entryId) {
|
|
906
|
-
return {
|
|
907
|
-
forkPiEntryId: entryId,
|
|
908
|
-
startTarget: { kind: "entry", entryId }
|
|
909
|
-
};
|
|
910
|
-
}
|
|
911
|
-
return resolveProcessTurnStartTarget({
|
|
912
|
-
...input,
|
|
913
|
-
selection: input.selection.fallback ?? defaultProcessTurnStartSelection(input.branchType)
|
|
914
|
-
});
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
export {
|
|
919
|
-
ADMIN_ACTOR,
|
|
920
|
-
CONTINUE_PROMPT_METADATA_KEY,
|
|
921
|
-
DEFAULT_CONTINUE_PROMPT,
|
|
922
|
-
DEFAULT_LAUNCHER_RECENT_VALUE_LIMIT,
|
|
923
|
-
FAILED_TURN_RECOVERY_CODES,
|
|
924
|
-
FAILED_TURN_RECOVERY_METADATA_KEY,
|
|
925
|
-
PROCESS_SELECTED_TURN_MODEL_SOURCES,
|
|
926
|
-
PROCESS_SEMANTIC_ENTRY_REF_KEYS,
|
|
927
|
-
PROCESS_TURN_RECORD_PATH_TYPES,
|
|
928
|
-
PROCESS_TURN_TYPES,
|
|
929
|
-
REVIEW_SUBJECT_KINDS,
|
|
930
|
-
SERIALIZED_SYSTEM_ACTOR,
|
|
931
|
-
SYSTEM_ACTOR,
|
|
932
|
-
TELEGRAM_ACTOR,
|
|
933
|
-
TURN_ACCEPTANCE_STATES,
|
|
934
|
-
TURN_ANNOTATION_REFERENCE_KINDS,
|
|
935
|
-
WORKER_ERROR_CLASSES,
|
|
936
|
-
addLauncherRecentValue,
|
|
937
|
-
assertRepoLocator,
|
|
938
|
-
assertValidProcessProductName,
|
|
939
|
-
buildFailedTurnRecoveryMetadata,
|
|
940
|
-
buildProcessRowSlot,
|
|
941
|
-
canonicalizeQuestionAnswers,
|
|
942
|
-
createEmptyProcessProductRefs,
|
|
943
|
-
createEmptyProcessSemanticEntryRefs,
|
|
944
|
-
createGenericFailedTurnRecoveryContext,
|
|
945
|
-
createReviewSubject,
|
|
946
|
-
defaultProcessTurnStartSelection,
|
|
947
|
-
detectRepoLocatorKind,
|
|
948
|
-
emptyQuestionDrafts,
|
|
949
|
-
formatPathTypeLabel,
|
|
950
|
-
getProcessStatusCategory,
|
|
951
|
-
humanizeProcessLabel,
|
|
952
|
-
isFailedTurnRecoveryCode,
|
|
953
|
-
isProcessSelectedTurnModelSource,
|
|
954
|
-
isProcessSemanticEntryRefKey,
|
|
955
|
-
isProcessTurnType,
|
|
956
|
-
isRepoLocator,
|
|
957
|
-
isReviewSubjectKind,
|
|
958
|
-
isTurnFailureCode,
|
|
959
|
-
isValidProcessProductName,
|
|
960
|
-
isWaitingTurnType,
|
|
961
|
-
isWorkerErrorClass,
|
|
962
|
-
isWorkerOwnedTurnType,
|
|
963
|
-
lifecycleStatusForSelectedTurnType,
|
|
964
|
-
normalizeActor,
|
|
965
|
-
normalizeAskQuestionsInput,
|
|
966
|
-
normalizeContinuePrompt,
|
|
967
|
-
normalizeLaunchModelConfigInput,
|
|
968
|
-
normalizeLauncherRecentValue,
|
|
969
|
-
normalizeLauncherRecentValues,
|
|
970
|
-
normalizeMarkdownLineEndings,
|
|
971
|
-
normalizeMarkdownText,
|
|
972
|
-
normalizeOptionalMarkdown,
|
|
973
|
-
normalizeStringArray,
|
|
974
|
-
parseActorOrSystem,
|
|
975
|
-
parseProcessProductRefs,
|
|
976
|
-
parseProcessSemanticEntryRefs,
|
|
977
|
-
parseProcessStateJsonLenient,
|
|
978
|
-
parseProcessStateJsonStrict,
|
|
979
|
-
parseProductRefsFromStateJsonLenient,
|
|
980
|
-
parseProductRefsFromStateJsonStrict,
|
|
981
|
-
parseProductRefsLenient,
|
|
982
|
-
parseProductRefsStrict,
|
|
983
|
-
parseRepoLocator,
|
|
984
|
-
parseReviewSubject,
|
|
985
|
-
parseSemanticEntryRef,
|
|
986
|
-
parseSemanticEntryRefsFromStateJsonLenient,
|
|
987
|
-
parseSemanticEntryRefsFromStateJsonStrict,
|
|
988
|
-
parseSemanticEntryRefsLenient,
|
|
989
|
-
parseSemanticEntryRefsStrict,
|
|
990
|
-
parseStrictInstanceTurnConfigsJson,
|
|
991
|
-
parseTurnAnnotationReference,
|
|
992
|
-
parseTurnAnnotationReferences,
|
|
993
|
-
readFailedTurnRecoveryContext,
|
|
994
|
-
redactCredentialBearingAbsoluteUrl,
|
|
995
|
-
resolveExistingProcessEntryId,
|
|
996
|
-
resolveProcessProductRefEntryId,
|
|
997
|
-
resolveProcessSemanticRefEntryId,
|
|
998
|
-
resolveProcessTurnStartSelection,
|
|
999
|
-
resolveProcessTurnStartTarget,
|
|
1000
|
-
serializeActor,
|
|
1001
|
-
serializeInstanceTurnConfigs,
|
|
1002
|
-
sortProcessRows,
|
|
1003
|
-
trimString,
|
|
1004
|
-
trimToNull
|
|
1005
|
-
};
|
|
1
|
+
export { normalizeActor, parseActorOrSystem, SERIALIZED_SYSTEM_ACTOR, serializeActor, } from "./actor.js";
|
|
2
|
+
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";
|
|
3
|
+
export { addLauncherRecentValue, DEFAULT_LAUNCHER_RECENT_VALUE_LIMIT, normalizeLauncherRecentValue, normalizeLauncherRecentValues, redactCredentialBearingAbsoluteUrl, } from "./launcher-recent-values.js";
|
|
4
|
+
export { normalizeMarkdownLineEndings, normalizeMarkdownText, normalizeOptionalMarkdown, } from "./markdown-normalize.js";
|
|
5
|
+
export { normalizeLaunchModelConfigInput, parseStrictInstanceTurnConfigsJson, serializeInstanceTurnConfigs, } from "./process-model-config.js";
|
|
6
|
+
export { buildProcessRowSlot, getProcessStatusCategory, sortProcessRows, } from "./process-row-slots.js";
|
|
7
|
+
export { parseProcessStateJsonLenient, parseProcessStateJsonStrict, parseProductRefsFromStateJsonLenient, parseProductRefsFromStateJsonStrict, parseProductRefsLenient, parseProductRefsStrict, parseSemanticEntryRefsFromStateJsonLenient, parseSemanticEntryRefsFromStateJsonStrict, parseSemanticEntryRefsLenient, parseSemanticEntryRefsStrict, } from "./process-state-json.js";
|
|
8
|
+
export { assertRepoLocator, detectRepoLocatorKind, isRepoLocator, parseRepoLocator, } from "./repo-locator.js";
|
|
9
|
+
export { createReviewSubject, isReviewSubjectKind, parseReviewSubject, REVIEW_SUBJECT_KINDS, } from "./review-subject.js";
|
|
10
|
+
export { assertValidProcessProductName, createEmptyProcessProductRefs, createEmptyProcessSemanticEntryRefs, isProcessSemanticEntryRefKey, isValidProcessProductName, PROCESS_SEMANTIC_ENTRY_REF_KEYS, parseProcessProductRefs, parseProcessSemanticEntryRefs, parseSemanticEntryRef, } from "./semantic-entry-refs.js";
|
|
11
|
+
export { humanizeProcessLabel, normalizeStringArray, trimString, trimToNull, } from "./string-normalize.js";
|
|
12
|
+
export { TURN_ACCEPTANCE_STATES } from "./turn-acceptance.js";
|
|
13
|
+
export { parseTurnAnnotationReference, parseTurnAnnotationReferences, TURN_ANNOTATION_REFERENCE_KINDS, } from "./turn-annotations.js";
|
|
14
|
+
export { buildFailedTurnRecoveryMetadata, CONTINUE_PROMPT_METADATA_KEY, createGenericFailedTurnRecoveryContext, DEFAULT_CONTINUE_PROMPT, FAILED_TURN_RECOVERY_CODES, FAILED_TURN_RECOVERY_METADATA_KEY, isFailedTurnRecoveryCode, normalizeContinuePrompt, readFailedTurnRecoveryContext, } from "./turn-recovery.js";
|
|
15
|
+
export { defaultProcessTurnStartSelection, resolveExistingProcessEntryId, resolveProcessProductRefEntryId, resolveProcessSemanticRefEntryId, resolveProcessTurnStartSelection, resolveProcessTurnStartTarget, } from "./turn-start-resolution.js";
|
|
1006
16
|
//# sourceMappingURL=index.js.map
|