@leitwerk-dev/domain 0.1.9 → 0.2.1

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 (95) hide show
  1. package/dist/actor.d.ts +4 -2
  2. package/dist/actor.d.ts.map +1 -1
  3. package/dist/domain-model.d.ts +457 -60
  4. package/dist/domain-model.d.ts.map +1 -1
  5. package/dist/index.d.ts +16 -14
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +966 -15
  8. package/dist/index.js.map +1 -1
  9. package/dist/launcher-recent-values.d.ts +5 -0
  10. package/dist/launcher-recent-values.d.ts.map +1 -1
  11. package/dist/markdown-normalize.d.ts +3 -0
  12. package/dist/markdown-normalize.d.ts.map +1 -1
  13. package/dist/number-normalize.d.ts +3 -0
  14. package/dist/number-normalize.d.ts.map +1 -0
  15. package/dist/process-definitions.d.ts +37 -8
  16. package/dist/process-definitions.d.ts.map +1 -1
  17. package/dist/process-model-config.d.ts +18 -0
  18. package/dist/process-model-config.d.ts.map +1 -1
  19. package/dist/process-row-slots.d.ts +14 -0
  20. package/dist/process-row-slots.d.ts.map +1 -1
  21. package/dist/process-state-json.d.ts +13 -0
  22. package/dist/process-state-json.d.ts.map +1 -1
  23. package/dist/repo-locator.d.ts +8 -0
  24. package/dist/repo-locator.d.ts.map +1 -1
  25. package/dist/semantic-entry-refs.d.ts +22 -0
  26. package/dist/semantic-entry-refs.d.ts.map +1 -1
  27. package/dist/startup-observation.d.ts +75 -0
  28. package/dist/startup-observation.d.ts.map +1 -0
  29. package/dist/string-normalize.d.ts +10 -0
  30. package/dist/string-normalize.d.ts.map +1 -1
  31. package/dist/turn-acceptance.d.ts +2 -0
  32. package/dist/turn-acceptance.d.ts.map +1 -1
  33. package/dist/turn-annotations.d.ts +27 -0
  34. package/dist/turn-annotations.d.ts.map +1 -1
  35. package/dist/turn-recovery.d.ts +30 -1
  36. package/dist/turn-recovery.d.ts.map +1 -1
  37. package/dist/turn-start-resolution.d.ts +48 -1
  38. package/dist/turn-start-resolution.d.ts.map +1 -1
  39. package/dist/unknown-record.d.ts +8 -0
  40. package/dist/unknown-record.d.ts.map +1 -0
  41. package/package.json +2 -2
  42. package/src/actor.ts +8 -10
  43. package/src/domain-model.ts +511 -80
  44. package/src/index.ts +18 -38
  45. package/src/launcher-recent-values.ts +11 -11
  46. package/src/markdown-normalize.ts +3 -0
  47. package/src/number-normalize.ts +11 -0
  48. package/src/process-definitions.ts +37 -8
  49. package/src/process-model-config.ts +27 -1
  50. package/src/process-row-slots.ts +14 -0
  51. package/src/process-state-json.ts +13 -0
  52. package/src/repo-locator.ts +10 -6
  53. package/src/semantic-entry-refs.ts +40 -22
  54. package/src/startup-observation.ts +106 -0
  55. package/src/string-normalize.ts +38 -0
  56. package/src/turn-acceptance.ts +2 -0
  57. package/src/turn-annotations.ts +34 -21
  58. package/src/turn-recovery.ts +38 -8
  59. package/src/turn-start-resolution.ts +70 -30
  60. package/src/unknown-record.ts +18 -0
  61. package/dist/actor.js +0 -62
  62. package/dist/actor.js.map +0 -1
  63. package/dist/domain-model.js +0 -169
  64. package/dist/domain-model.js.map +0 -1
  65. package/dist/launcher-recent-values.js +0 -60
  66. package/dist/launcher-recent-values.js.map +0 -1
  67. package/dist/markdown-normalize.js +0 -14
  68. package/dist/markdown-normalize.js.map +0 -1
  69. package/dist/process-definitions.js +0 -2
  70. package/dist/process-definitions.js.map +0 -1
  71. package/dist/process-model-config.js +0 -68
  72. package/dist/process-model-config.js.map +0 -1
  73. package/dist/process-row-slots.js +0 -45
  74. package/dist/process-row-slots.js.map +0 -1
  75. package/dist/process-state-json.js +0 -102
  76. package/dist/process-state-json.js.map +0 -1
  77. package/dist/repo-locator.js +0 -82
  78. package/dist/repo-locator.js.map +0 -1
  79. package/dist/semantic-entry-refs.js +0 -79
  80. package/dist/semantic-entry-refs.js.map +0 -1
  81. package/dist/string-normalize.js +0 -28
  82. package/dist/string-normalize.js.map +0 -1
  83. package/dist/turn-acceptance.js +0 -2
  84. package/dist/turn-acceptance.js.map +0 -1
  85. package/dist/turn-annotations.js +0 -49
  86. package/dist/turn-annotations.js.map +0 -1
  87. package/dist/turn-progress.d.ts +0 -4
  88. package/dist/turn-progress.d.ts.map +0 -1
  89. package/dist/turn-progress.js +0 -10
  90. package/dist/turn-progress.js.map +0 -1
  91. package/dist/turn-recovery.js +0 -70
  92. package/dist/turn-recovery.js.map +0 -1
  93. package/dist/turn-start-resolution.js +0 -97
  94. package/dist/turn-start-resolution.js.map +0 -1
  95. package/src/turn-progress.ts +0 -15
@@ -5,52 +5,84 @@ import type {
5
5
  ProcessSemanticEntryRefs,
6
6
  } from "./semantic-entry-refs.js";
7
7
 
8
+ /** @internal */
8
9
  export interface ProcessTurnStartFromCurrentLeaf {
10
+ /** @internal */
9
11
  kind: "current_leaf";
10
12
  }
11
13
 
14
+ /** @internal */
12
15
  export interface ProcessTurnStartFromSessionRoot {
13
- /** Start with no persisted Pi entry in context. The kickoff entry has parentId null. */
16
+ /** Start with no persisted Pi entry in context. The kickoff entry has parentId null. @internal */
14
17
  kind: "session_root";
15
18
  }
16
19
 
20
+ /** @internal */
17
21
  export interface ProcessTurnStartFromEntry {
22
+ /** @internal */
18
23
  kind: "entry";
24
+ /** @internal */
19
25
  entryId: string;
20
26
  }
21
27
 
28
+ /** @internal */
22
29
  export type ProcessTurnStartFallback =
23
30
  | ProcessTurnStartFromCurrentLeaf
24
31
  | ProcessTurnStartFromSessionRoot
25
32
  | ProcessTurnStartFromEntry;
26
33
 
34
+ /** @internal */
27
35
  export interface ProcessTurnStartFromSemanticRef {
36
+ /** @internal */
28
37
  kind: "semantic_ref";
38
+ /** @internal */
29
39
  ref: ProcessSemanticEntryRefKey;
40
+ /** @internal */
30
41
  fallback?: ProcessTurnStartSelection;
31
42
  }
32
43
 
44
+ /** @internal */
33
45
  export interface ProcessTurnStartFromProductRef {
46
+ /** @internal */
34
47
  kind: "product_ref";
48
+ /** @internal */
35
49
  productName: string;
50
+ /** @internal */
36
51
  fallback?: ProcessTurnStartSelection;
37
52
  }
38
53
 
54
+ /** @internal */
39
55
  export type ProcessTurnStartSelection =
40
56
  | ProcessTurnStartFallback
41
57
  | ProcessTurnStartFromSemanticRef
42
58
  | ProcessTurnStartFromProductRef;
43
59
 
60
+ /** @internal */
44
61
  export type ProcessTurnStartTarget =
45
- | { kind: "current_leaf" }
46
- | { kind: "entry"; entryId: string }
47
- | { kind: "root" };
48
-
62
+ | {
63
+ /** @internal */
64
+ kind: "current_leaf";
65
+ }
66
+ | {
67
+ /** @internal */
68
+ kind: "entry";
69
+ /** @internal */
70
+ entryId: string;
71
+ }
72
+ | {
73
+ /** @internal */
74
+ kind: "root";
75
+ };
76
+
77
+ /** @internal */
49
78
  export interface ProcessTurnStartResolution {
79
+ /** @internal */
50
80
  forkPiEntryId: string | null;
81
+ /** @internal */
51
82
  startTarget: ProcessTurnStartTarget;
52
83
  }
53
84
 
85
+ /** @internal */
54
86
  export function defaultProcessTurnStartSelection(
55
87
  branchType: ProcessTurnRecordPathType,
56
88
  ): ProcessTurnStartFallback {
@@ -63,13 +95,17 @@ export function defaultProcessTurnStartSelection(
63
95
  }
64
96
  }
65
97
 
98
+ /** @internal */
66
99
  export function resolveProcessTurnStartSelection(input: {
100
+ /** @internal */
67
101
  branchType: ProcessTurnRecordPathType;
102
+ /** @internal */
68
103
  startFrom?: ProcessTurnStartSelection;
69
104
  }): ProcessTurnStartSelection {
70
105
  return input.startFrom ?? defaultProcessTurnStartSelection(input.branchType);
71
106
  }
72
107
 
108
+ /** @internal */
73
109
  export function resolveExistingProcessEntryId(
74
110
  entryId: string | null,
75
111
  entryExists?: ((entryId: string) => boolean) | undefined,
@@ -80,11 +116,17 @@ export function resolveExistingProcessEntryId(
80
116
  return entryExists && !entryExists(entryId) ? null : entryId;
81
117
  }
82
118
 
119
+ /** @internal */
83
120
  export function resolveProcessSemanticRefEntryId(input: {
121
+ /** @internal */
84
122
  ref: keyof ProcessSemanticEntryRefs;
123
+ /** @internal */
85
124
  semanticEntryRefs?: ProcessSemanticEntryRefs | null;
125
+ /** @internal */
86
126
  currentLeafId: string | null;
127
+ /** @internal */
87
128
  rootEntryId: string | null;
129
+ /** @internal */
88
130
  entryExists?: (entryId: string) => boolean;
89
131
  }): string | null {
90
132
  const fromState = resolveExistingProcessEntryId(
@@ -103,9 +145,13 @@ export function resolveProcessSemanticRefEntryId(input: {
103
145
  return null;
104
146
  }
105
147
 
148
+ /** @internal */
106
149
  export function resolveProcessProductRefEntryId(input: {
150
+ /** @internal */
107
151
  productName: string;
152
+ /** @internal */
108
153
  productRefs?: ProcessProductRefs | null;
154
+ /** @internal */
109
155
  entryExists?: (entryId: string) => boolean;
110
156
  }): string | null {
111
157
  const productName = input.productName.trim();
@@ -118,13 +164,21 @@ export function resolveProcessProductRefEntryId(input: {
118
164
  );
119
165
  }
120
166
 
167
+ /** @internal */
121
168
  export function resolveProcessTurnStartTarget(input: {
169
+ /** @internal */
122
170
  branchType: ProcessTurnRecordPathType;
171
+ /** @internal */
123
172
  selection: ProcessTurnStartSelection;
173
+ /** @internal */
124
174
  currentLeafId: string | null;
175
+ /** @internal */
125
176
  rootEntryId: string | null;
177
+ /** @internal */
126
178
  semanticEntryRefs?: ProcessSemanticEntryRefs | null;
179
+ /** @internal */
127
180
  productRefs?: ProcessProductRefs | null;
181
+ /** @internal */
128
182
  entryExists?: (entryId: string) => boolean;
129
183
  }): ProcessTurnStartResolution {
130
184
  switch (input.selection.kind) {
@@ -146,32 +200,18 @@ export function resolveProcessTurnStartTarget(input: {
146
200
  startTarget: { kind: "entry", entryId: input.selection.entryId },
147
201
  };
148
202
  }
149
- case "semantic_ref": {
150
- const entryId = resolveProcessSemanticRefEntryId({
151
- ref: input.selection.ref,
152
- semanticEntryRefs: input.semanticEntryRefs,
153
- currentLeafId: input.currentLeafId,
154
- rootEntryId: input.rootEntryId,
155
- entryExists: input.entryExists,
156
- });
157
- if (entryId) {
158
- return {
159
- forkPiEntryId: entryId,
160
- startTarget: { kind: "entry", entryId },
161
- };
162
- }
163
-
164
- return resolveProcessTurnStartTarget({
165
- ...input,
166
- selection: input.selection.fallback ?? defaultProcessTurnStartSelection(input.branchType),
167
- });
168
- }
203
+ case "semantic_ref":
169
204
  case "product_ref": {
170
- const entryId = resolveProcessProductRefEntryId({
171
- productName: input.selection.productName,
172
- productRefs: input.productRefs,
173
- entryExists: input.entryExists,
174
- });
205
+ const entryId =
206
+ input.selection.kind === "semantic_ref"
207
+ ? resolveProcessSemanticRefEntryId({
208
+ ...input,
209
+ ref: input.selection.ref,
210
+ })
211
+ : resolveProcessProductRefEntryId({
212
+ ...input,
213
+ productName: input.selection.productName,
214
+ });
175
215
  if (entryId) {
176
216
  return {
177
217
  forkPiEntryId: entryId,
@@ -0,0 +1,18 @@
1
+ import * as v from "valibot";
2
+
3
+ /** Parse non-array objects into a fresh record using Valibot's key handling. @internal */
4
+ export const copiedUnknownRecordSchema = v.pipe(
5
+ v.unknown(),
6
+ v.check(isUnknownRecord, "Expected object"),
7
+ v.record(v.string(), v.unknown()),
8
+ );
9
+
10
+ /** @internal */
11
+ export function isUnknownRecord(value: unknown): value is Record<string, unknown> {
12
+ return typeof value === "object" && value !== null && !Array.isArray(value);
13
+ }
14
+
15
+ /** @internal */
16
+ export function asUnknownRecord(value: unknown): Record<string, unknown> | null {
17
+ return isUnknownRecord(value) ? value : null;
18
+ }
package/dist/actor.js DELETED
@@ -1,62 +0,0 @@
1
- import { SYSTEM_ACTOR } from "./domain-model.js";
2
- const ACTOR_KINDS = ["user", "channel", "system"];
3
- function isActorKind(value) {
4
- return typeof value === "string" && ACTOR_KINDS.includes(value);
5
- }
6
- function normalizeProvider(value) {
7
- return typeof value === "string" && value.trim() !== "" ? value.trim() : null;
8
- }
9
- /**
10
- * Builds a validated `Actor`, dropping unknown fields and falling back to
11
- * defaults for invalid kind/provider. Returns `null` when no stable id is
12
- * present so callers can decide on a fallback actor.
13
- */
14
- export function normalizeActor(value) {
15
- if (typeof value !== "object" || value === null) {
16
- return null;
17
- }
18
- const candidate = value;
19
- const id = typeof candidate.id === "string" ? candidate.id.trim() : "";
20
- if (id === "") {
21
- return null;
22
- }
23
- const kind = isActorKind(candidate.kind) ? candidate.kind : "system";
24
- const provider = normalizeProvider(candidate.provider);
25
- const displayName = typeof candidate.displayName === "string" && candidate.displayName.trim() !== ""
26
- ? candidate.displayName
27
- : undefined;
28
- return {
29
- id,
30
- kind,
31
- provider,
32
- ...(displayName !== undefined ? { displayName } : {}),
33
- };
34
- }
35
- /** Serializes an `Actor` to a stable JSON string for durable storage. */
36
- export function serializeActor(actor) {
37
- return JSON.stringify({
38
- id: actor.id,
39
- kind: actor.kind,
40
- provider: actor.provider,
41
- ...(actor.displayName !== undefined ? { displayName: actor.displayName } : {}),
42
- });
43
- }
44
- /**
45
- * Parses a durable actor JSON value, falling back to `SYSTEM_ACTOR` when the
46
- * stored value is missing or malformed. Used when reading legacy rows that
47
- * predate actor attribution.
48
- */
49
- export function parseActorOrSystem(value) {
50
- if (value === null || value === undefined || value.trim() === "") {
51
- return SYSTEM_ACTOR;
52
- }
53
- try {
54
- return normalizeActor(JSON.parse(value)) ?? SYSTEM_ACTOR;
55
- }
56
- catch {
57
- return SYSTEM_ACTOR;
58
- }
59
- }
60
- /** Canonical serialized form of `SYSTEM_ACTOR`, used as the durable default. */
61
- export const SERIALIZED_SYSTEM_ACTOR = serializeActor(SYSTEM_ACTOR);
62
- //# sourceMappingURL=actor.js.map
package/dist/actor.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"actor.js","sourceRoot":"","sources":["../src/actor.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE7E,MAAM,WAAW,GAAyB,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AACxE,SAAS,WAAW,CAAC,KAAc;IAClC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,WAAiC,CAAC,QAAQ,CAAC,KAA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KAAY;IAC1C,OAAO,IAAI,CAAC,SAAS,CAAC;QACrB,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,GAAG,CAAC,KAAK,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9E,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAgC;IAClE,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAClE,OAAO,YAAY,CAAC;IACrB,CAAC;IACD,IAAI,CAAC;QACJ,OAAO,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,YAAY,CAAC;IAC1D,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,YAAY,CAAC;IACrB,CAAC;AACF,CAAC;AAED,gFAAgF;AAChF,MAAM,CAAC,MAAM,uBAAuB,GAAG,cAAc,CAAC,YAAY,CAAC,CAAC"}
@@ -1,169 +0,0 @@
1
- /** Watcher / scheduler / startup reconciliation and other internal callers. */
2
- export const SYSTEM_ACTOR = { id: "system", kind: "system", provider: null };
3
- /**
4
- * Unauthenticated default for human-driven web/HTTP/WS actions when no SSO
5
- * provider is configured. Keeps an auth-disabled leitwerk behaving exactly
6
- * as it does today while still attributing actions to a stable principal.
7
- */
8
- export const ADMIN_ACTOR = { id: "admin", kind: "user", provider: null };
9
- function requiredTrimmedString(value, field) {
10
- if (typeof value !== "string" || value.trim() === "") {
11
- throw new Error(`${field} must be a non-empty string`);
12
- }
13
- return value.trim();
14
- }
15
- /** Normalize an LLM-authored request into immutable, position-stable identities. */
16
- export function normalizeAskQuestionsInput(value) {
17
- const questions = value?.questions;
18
- if (!Array.isArray(questions))
19
- throw new Error("questions must be an array");
20
- if (questions.length === 0)
21
- throw new Error("questions must not be empty");
22
- return questions.map((candidate, questionIndex) => {
23
- const question = requiredTrimmedString(candidate?.question, `questions[${questionIndex}].question`);
24
- if (candidate?.selection !== "single" && candidate?.selection !== "multiple") {
25
- throw new Error(`questions[${questionIndex}].selection must be 'single' or 'multiple'`);
26
- }
27
- if (!Array.isArray(candidate.options) || candidate.options.length === 0) {
28
- throw new Error(`questions[${questionIndex}].options must not be empty`);
29
- }
30
- const labels = new Set();
31
- const questionId = `question_${questionIndex + 1}`;
32
- const options = candidate.options.map((option, optionIndex) => {
33
- const label = requiredTrimmedString(option?.label, `questions[${questionIndex}].options[${optionIndex}].label`);
34
- const key = label.toLocaleLowerCase();
35
- if (labels.has(key)) {
36
- throw new Error(`questions[${questionIndex}] contains duplicate option '${label}'`);
37
- }
38
- labels.add(key);
39
- return {
40
- id: `${questionId}_option_${optionIndex + 1}`,
41
- label,
42
- details: typeof option.details === "string" && option.details.trim() !== ""
43
- ? option.details.trim()
44
- : null,
45
- };
46
- });
47
- return { id: questionId, question, selection: candidate.selection, options };
48
- });
49
- }
50
- export function emptyQuestionDrafts(questions) {
51
- return questions.map(() => ({ selectedOptionIds: [], freeText: "", comment: "" }));
52
- }
53
- function normalizeQuestionDrafts(questions, value) {
54
- if (!Array.isArray(value) || value.length !== questions.length) {
55
- throw new Error("Every question must have one draft answer in question order");
56
- }
57
- return questions.map((question, index) => {
58
- const answer = value[index];
59
- if (!Array.isArray(answer?.selectedOptionIds)) {
60
- throw new Error(`Question ${index + 1} has a malformed selection`);
61
- }
62
- const selectedOptionIds = answer.selectedOptionIds.map((id) => {
63
- if (typeof id !== "string" || !question.options.some((option) => option.id === id)) {
64
- throw new Error(`Question ${index + 1} contains an unknown selection`);
65
- }
66
- return id;
67
- });
68
- if (new Set(selectedOptionIds).size !== selectedOptionIds.length) {
69
- throw new Error(`Question ${index + 1} contains duplicate selections`);
70
- }
71
- if (question.selection === "single" && selectedOptionIds.length > 1) {
72
- throw new Error(`Question ${index + 1} accepts only one selection`);
73
- }
74
- if (typeof answer.freeText !== "string" || typeof answer.comment !== "string") {
75
- throw new Error(`Question ${index + 1} contains malformed text`);
76
- }
77
- return { selectedOptionIds, freeText: answer.freeText, comment: answer.comment };
78
- });
79
- }
80
- /** Validate a complete structured draft and produce one canonical free-text answer per question. */
81
- export function canonicalizeQuestionAnswers(questions, value) {
82
- return normalizeQuestionDrafts(questions, value).map((answer, index) => {
83
- const question = questions[index];
84
- if (!question)
85
- throw new Error(`Question ${index + 1} is missing`);
86
- const options = answer.selectedOptionIds.map((id) => question.options.find((option) => option.id === id)?.label ?? "");
87
- const freeText = answer.freeText.trim();
88
- const comment = answer.comment.trim();
89
- if (options.length === 0 && freeText === "") {
90
- throw new Error(`Question ${index + 1} requires an answer`);
91
- }
92
- return [options.join(", "), freeText, comment ? `Context: ${comment}` : ""]
93
- .filter(Boolean)
94
- .join("\n");
95
- });
96
- }
97
- export const WORKER_ERROR_CLASSES = [
98
- "llm_error",
99
- "git_error",
100
- "pi_crash",
101
- "pipeline_error",
102
- "infrastructure",
103
- "protocol_error",
104
- "operator_abort",
105
- ];
106
- export function isWorkerErrorClass(value) {
107
- return WORKER_ERROR_CLASSES.includes(value);
108
- }
109
- export function isTurnFailureCode(value) {
110
- return value === "branch_drift";
111
- }
112
- export const PROCESS_TURN_TYPES = [
113
- "llm",
114
- "human",
115
- "external",
116
- "automatic",
117
- "server_automatic",
118
- ];
119
- export function isProcessTurnType(value) {
120
- return typeof value === "string" && PROCESS_TURN_TYPES.includes(value);
121
- }
122
- export function isWorkerOwnedTurnType(turnType) {
123
- return turnType === "llm" || turnType === "automatic";
124
- }
125
- export function isWaitingTurnType(turnType) {
126
- return turnType === "human" || turnType === "external";
127
- }
128
- export function lifecycleStatusForSelectedTurnType(turnType) {
129
- return isWaitingTurnType(turnType) ? "waiting" : "active";
130
- }
131
- export const PROCESS_SELECTED_TURN_MODEL_SOURCES = [
132
- "action_override",
133
- "launch_override",
134
- "instance_turn_config",
135
- "process_config_turn",
136
- "instance_default",
137
- "process_config_default",
138
- "catalog_default",
139
- "legacy_persisted",
140
- ];
141
- export function isProcessSelectedTurnModelSource(value) {
142
- return PROCESS_SELECTED_TURN_MODEL_SOURCES.includes(value);
143
- }
144
- /**
145
- * Structural tree position for a turn record.
146
- * - `primary`: continue the primary path from the current leaf
147
- * - `root_branch`: start from the implicit session root with no prior Pi entry context
148
- * - `leaf_branch`: fork from the current leaf as a side path
149
- */
150
- export const PROCESS_TURN_RECORD_PATH_TYPES = ["primary", "root_branch", "leaf_branch"];
151
- /**
152
- * Returns a human-readable, operator-facing label for the structural path
153
- * position of a turn record. These labels avoid internal domain terms such
154
- * as "primary" or "root_branch" in favour of plain descriptions of what the
155
- * turn is doing relative to the main path.
156
- */
157
- export function formatPathTypeLabel(pathType) {
158
- switch (pathType) {
159
- case "primary":
160
- return "Continuing the main path";
161
- case "root_branch":
162
- return "Starting from the beginning";
163
- case "leaf_branch":
164
- return "Exploring an alternative";
165
- default:
166
- return "Path";
167
- }
168
- }
169
- //# sourceMappingURL=domain-model.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"domain-model.js","sourceRoot":"","sources":["../src/domain-model.ts"],"names":[],"mappings":"AA4CA,+EAA+E;AAC/E,MAAM,CAAC,MAAM,YAAY,GAAU,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAEpF;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAU,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAqChF,SAAS,qBAAqB,CAAC,KAAc,EAAE,KAAa;IAC3D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACtD,MAA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AAC,MAAM,8BAA8B,GAAG,CAAC,SAAS,EAAE,aAAa,EAAE,aAAa,CAAU,CAAC;AAkFjG;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAmC;IACtE,QAAQ,QAAQ,EAAE,CAAC;QAClB,KAAK,SAAS;YACb,OAAO,0BAA0B,CAAC;QACnC,KAAK,aAAa;YACjB,OAAO,6BAA6B,CAAC;QACtC,KAAK,aAAa;YACjB,OAAO,0BAA0B,CAAC;QACnC;YACC,OAAO,MAAM,CAAC;IAChB,CAAC;AACF,CAAC"}
@@ -1,60 +0,0 @@
1
- export const DEFAULT_LAUNCHER_RECENT_VALUE_LIMIT = 5;
2
- function hasCredentialBearingAbsoluteUrl(value) {
3
- if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(value)) {
4
- return false;
5
- }
6
- try {
7
- const url = new URL(value);
8
- return url.protocol !== "file:" && (url.username !== "" || url.password !== "");
9
- }
10
- catch {
11
- return false;
12
- }
13
- }
14
- /**
15
- * Strip any embedded credentials (`user:pass@`) from an absolute non-`file:` URL,
16
- * returning the value unchanged when it is not such a URL.
17
- */
18
- export function redactCredentialBearingAbsoluteUrl(value) {
19
- if (!hasCredentialBearingAbsoluteUrl(value)) {
20
- return value;
21
- }
22
- const url = new URL(value);
23
- url.username = "";
24
- url.password = "";
25
- return url.toString();
26
- }
27
- export function normalizeLauncherRecentValue(value) {
28
- const normalizedValue = typeof value === "string" ? value.trim() : "";
29
- if (!normalizedValue) {
30
- return null;
31
- }
32
- if (hasCredentialBearingAbsoluteUrl(normalizedValue)) {
33
- return null;
34
- }
35
- return normalizedValue;
36
- }
37
- export function normalizeLauncherRecentValues(values, limit = DEFAULT_LAUNCHER_RECENT_VALUE_LIMIT) {
38
- const nextValues = [];
39
- const seen = new Set();
40
- for (const value of values) {
41
- const normalizedValue = normalizeLauncherRecentValue(value);
42
- if (!normalizedValue || seen.has(normalizedValue)) {
43
- continue;
44
- }
45
- seen.add(normalizedValue);
46
- nextValues.push(normalizedValue);
47
- if (nextValues.length >= limit) {
48
- break;
49
- }
50
- }
51
- return nextValues;
52
- }
53
- export function addLauncherRecentValue(existingValues, value, limit = DEFAULT_LAUNCHER_RECENT_VALUE_LIMIT) {
54
- const normalizedValue = normalizeLauncherRecentValue(value);
55
- if (!normalizedValue) {
56
- return normalizeLauncherRecentValues(existingValues, limit);
57
- }
58
- return normalizeLauncherRecentValues([normalizedValue, ...existingValues], limit);
59
- }
60
- //# sourceMappingURL=launcher-recent-values.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"launcher-recent-values.js","sourceRoot":"","sources":["../src/launcher-recent-values.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,CAAC;AAErD,SAAS,+BAA+B,CAAC,KAAa;IACrD,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7C,OAAO,KAAK,CAAC;IACd,CAAC;IACD,IAAI,CAAC;QACJ,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;QAC3B,OAAO,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,KAAK,EAAE,IAAI,GAAG,CAAC,QAAQ,KAAK,EAAE,CAAC,CAAC;IACjF,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kCAAkC,CAAC,KAAa;IAC/D,IAAI,CAAC,+BAA+B,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7C,OAAO,KAAK,CAAC;IACd,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3B,GAAG,CAAC,QAAQ,GAAG,EAAE,CAAC;IAClB,GAAG,CAAC,QAAQ,GAAG,EAAE,CAAC;IAClB,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACvB,CAAC;AAED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AE,KAAK,CAAC,CAAC;AACnF,CAAC"}
@@ -1,14 +0,0 @@
1
- export function normalizeMarkdownLineEndings(markdown) {
2
- return markdown.replace(/\r\n?/g, "\n");
3
- }
4
- export function normalizeMarkdownText(markdown) {
5
- return normalizeMarkdownLineEndings(markdown).trim();
6
- }
7
- export function normalizeOptionalMarkdown(value) {
8
- if (typeof value !== "string") {
9
- return null;
10
- }
11
- const normalized = normalizeMarkdownText(value);
12
- return normalized === "" ? null : normalized;
13
- }
14
- //# sourceMappingURL=markdown-normalize.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"markdown-normalize.js","sourceRoot":"","sources":["../src/markdown-normalize.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,4BAA4B,CAAC,QAAgB;IAC5D,OAAO,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,QAAgB;IACrD,OAAO,4BAA4B,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,KAAc;IACvD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IACb,CAAC;IACD,MAAM,UAAU,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAChD,OAAO,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC;AAC9C,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=process-definitions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process-definitions.js","sourceRoot":"","sources":["../src/process-definitions.ts"],"names":[],"mappings":""}
@@ -1,68 +0,0 @@
1
- import * as v from "valibot";
2
- import { trimToNull } from "./string-normalize.js";
3
- const jsonObjectSchema = v.custom((value) => typeof value === "object" && value !== null && !Array.isArray(value), "Expected object");
4
- const instanceTurnConfigSchema = v.pipe(jsonObjectSchema, v.object({
5
- modelProfileId: v.optional(v.unknown()),
6
- }));
7
- const strictInstanceTurnConfigsJsonSchema = v.pipe(v.string(), v.parseJson(), jsonObjectSchema, v.record(v.string(), instanceTurnConfigSchema));
8
- function normalizeInstanceTurnConfigs(turnConfigs) {
9
- const next = {};
10
- for (const [turnId, turnConfig] of Object.entries(turnConfigs)) {
11
- const modelProfileId = trimToNull(turnConfig.modelProfileId);
12
- next[turnId] = modelProfileId ? { modelProfileId } : {};
13
- }
14
- return next;
15
- }
16
- function getFirstIssuePathKey(issue) {
17
- const pathItem = issue.path?.[0];
18
- return typeof pathItem?.key === "string" ? pathItem.key : undefined;
19
- }
20
- export function parseStrictInstanceTurnConfigsJson(processId, turnConfigsJson) {
21
- if (!turnConfigsJson)
22
- return { ok: true, value: {} };
23
- const result = v.safeParse(strictInstanceTurnConfigsJsonSchema, turnConfigsJson, {
24
- abortEarly: true,
25
- });
26
- if (!result.success) {
27
- const issue = result.issues[0];
28
- if (issue?.type === "parse_json") {
29
- return {
30
- ok: false,
31
- error: { code: "invalid_turn_configs_json", processId, reason: "invalid_json" },
32
- };
33
- }
34
- const turnId = issue ? getFirstIssuePathKey(issue) : undefined;
35
- return {
36
- ok: false,
37
- error: {
38
- code: "invalid_turn_configs_json",
39
- processId,
40
- reason: turnId !== undefined ? "turn_config_not_object" : "not_object",
41
- ...(turnId !== undefined ? { turnId } : {}),
42
- },
43
- };
44
- }
45
- return { ok: true, value: normalizeInstanceTurnConfigs(result.output) };
46
- }
47
- export function serializeInstanceTurnConfigs(turnConfigs) {
48
- const normalizedEntries = Object.entries(turnConfigs)
49
- .map(([turnId, turnConfig]) => {
50
- const modelProfileId = trimToNull(turnConfig.modelProfileId);
51
- return [turnId, modelProfileId ? { modelProfileId } : {}];
52
- })
53
- .filter(([, turnConfig]) => Object.keys(turnConfig).length > 0);
54
- return normalizedEntries.length === 0
55
- ? null
56
- : JSON.stringify(Object.fromEntries(normalizedEntries));
57
- }
58
- export function normalizeLaunchModelConfigInput(input) {
59
- const defaultModelProfileId = trimToNull(input.defaultModelProfileId);
60
- const nextTurnConfigs = {};
61
- for (const [turnId, turnConfig] of Object.entries(input.turnConfigs ?? {})) {
62
- const modelProfileId = trimToNull(turnConfig.modelProfileId);
63
- if (modelProfileId)
64
- nextTurnConfigs[turnId] = { modelProfileId };
65
- }
66
- return { defaultModelProfileId, turnConfigs: nextTurnConfigs };
67
- }
68
- //# sourceMappingURL=process-model-config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process-model-config.js","sourceRoot":"","sources":["../src/process-model-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAoBnD,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAChC,CAAC,KAAK,EAAoC,EAAE,CAC3C,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EACrE,iBAAiB,CACjB,CAAC;AAEF,MAAM,wBAAwB,GAAG,CAAC,CAAC,IAAI,CACtC,gBAAgB,EAChB,CAAC,CAAC,MAAM,CAAC;IACR,cAAc,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;CACvC,CAAC,CACF,CAAC;AAEF,MAAM,mCAAmC,GAAG,CAAC,CAAC,IAAI,CACjD,CAAC,CAAC,MAAM,EAAE,EACV,CAAC,CAAC,SAAS,EAAE,EACb,gBAAgB,EAChB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,wBAAwB,CAAC,CAC9C,CAAC;AAEF,SAAS,4BAA4B,CACpC,WAAyD;IAEzD,MAAM,IAAI,GAA0B,EAAE,CAAC;IACvC,KAAK,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,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