@leitwerk-dev/process-sdk 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/README.md +12 -0
  2. package/dist/browser-ui-extension.d.ts +20 -0
  3. package/dist/browser-ui-extension.d.ts.map +1 -1
  4. package/dist/capabilities.d.ts +6 -0
  5. package/dist/capabilities.d.ts.map +1 -1
  6. package/dist/{chunk-LIIP7FMU.js → chunk-5R6MVLHC.js} +1 -1
  7. package/dist/chunk-5R6MVLHC.js.map +1 -0
  8. package/dist/chunk-DVXW2ZUV.js +1 -0
  9. package/dist/chunk-DVXW2ZUV.js.map +1 -0
  10. package/dist/{chunk-TA4KO53Q.js → chunk-I7U6HCLN.js} +1 -7
  11. package/dist/chunk-I7U6HCLN.js.map +1 -0
  12. package/dist/{chunk-WFY2WWZE.js → chunk-TM2LTSW4.js} +1 -1
  13. package/dist/chunk-TM2LTSW4.js.map +1 -0
  14. package/dist/codecs.d.ts +1 -0
  15. package/dist/codecs.d.ts.map +1 -1
  16. package/dist/commit-message.d.ts +5 -0
  17. package/dist/commit-message.d.ts.map +1 -1
  18. package/dist/core-capabilities.d.ts +338 -20
  19. package/dist/core-capabilities.d.ts.map +1 -1
  20. package/dist/define-process.d.ts +195 -18
  21. package/dist/define-process.d.ts.map +1 -1
  22. package/dist/event-bus.d.ts +1 -0
  23. package/dist/event-bus.d.ts.map +1 -1
  24. package/dist/{extension-api-CcqZCYJx.d.ts → extension-api-3Vr3RE8S.d.ts} +1000 -108
  25. package/dist/extension-api.d.ts +385 -50
  26. package/dist/extension-api.d.ts.map +1 -1
  27. package/dist/external-action-source.d.ts +3 -1
  28. package/dist/external-action-source.d.ts.map +1 -1
  29. package/dist/external-source-poll.d.ts +18 -5
  30. package/dist/external-source-poll.d.ts.map +1 -1
  31. package/dist/flow.d.ts +308 -11
  32. package/dist/flow.d.ts.map +1 -1
  33. package/dist/form-contract.d.ts +1 -1
  34. package/dist/form-contract.d.ts.map +1 -1
  35. package/dist/fs-utils.d.ts +4 -0
  36. package/dist/fs-utils.d.ts.map +1 -1
  37. package/dist/git-binary.d.ts +2 -1
  38. package/dist/git-binary.d.ts.map +1 -1
  39. package/dist/git-binary.js.map +1 -1
  40. package/dist/graph-fragments.d.ts +16 -0
  41. package/dist/graph-fragments.d.ts.map +1 -1
  42. package/dist/host-capabilities.d.ts +9 -3
  43. package/dist/host-capabilities.d.ts.map +1 -1
  44. package/dist/index.d.ts +26 -26
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +270 -81
  47. package/dist/index.js.map +1 -1
  48. package/dist/integration-http.d.ts +14 -3
  49. package/dist/integration-http.d.ts.map +1 -1
  50. package/dist/json-data.d.ts +1 -1
  51. package/dist/json-data.d.ts.map +1 -1
  52. package/dist/leaf-outcome-renderer.d.ts +35 -0
  53. package/dist/leaf-outcome-renderer.d.ts.map +1 -1
  54. package/dist/leaf-outcome-renderer.js +12 -0
  55. package/dist/leaf-outcome-renderer.js.map +1 -1
  56. package/dist/leaf-outcomes.d.ts +3 -0
  57. package/dist/leaf-outcomes.d.ts.map +1 -1
  58. package/dist/model-provider.d.ts +144 -12
  59. package/dist/model-provider.d.ts.map +1 -1
  60. package/dist/pi-config-public.d.ts +2 -0
  61. package/dist/pi-config-public.d.ts.map +1 -0
  62. package/dist/pi-config-public.js +15 -0
  63. package/dist/pi-config-public.js.map +1 -0
  64. package/dist/pi-config.d.ts +40 -0
  65. package/dist/pi-config.d.ts.map +1 -1
  66. package/dist/pi-config.js +1 -1
  67. package/dist/process-definition-internals.d.ts +4 -0
  68. package/dist/process-definition-internals.d.ts.map +1 -1
  69. package/dist/process-flow-view.d.ts +2 -0
  70. package/dist/process-flow-view.d.ts.map +1 -1
  71. package/dist/process-graph.d.ts +34 -0
  72. package/dist/process-graph.d.ts.map +1 -1
  73. package/dist/process-launcher-builder.d.ts +5 -0
  74. package/dist/process-launcher-builder.d.ts.map +1 -1
  75. package/dist/process-watcher-builder.d.ts +5 -0
  76. package/dist/process-watcher-builder.d.ts.map +1 -1
  77. package/dist/process-watcher-source.d.ts +3 -1
  78. package/dist/process-watcher-source.d.ts.map +1 -1
  79. package/dist/project-binding.d.ts +5 -1
  80. package/dist/project-binding.d.ts.map +1 -1
  81. package/dist/registry-utils.d.ts +6 -0
  82. package/dist/registry-utils.d.ts.map +1 -1
  83. package/dist/repository-feedback.d.ts +36 -12
  84. package/dist/repository-feedback.d.ts.map +1 -1
  85. package/dist/repository-git-env.d.ts +6 -2
  86. package/dist/repository-git-env.d.ts.map +1 -1
  87. package/dist/repository-http.d.ts +13 -1
  88. package/dist/repository-http.d.ts.map +1 -1
  89. package/dist/repository-https.d.ts +1 -1
  90. package/dist/repository-https.d.ts.map +1 -1
  91. package/dist/repository-issue-watcher.d.ts +31 -6
  92. package/dist/repository-issue-watcher.d.ts.map +1 -1
  93. package/dist/repository-reconciliation.d.ts +5 -0
  94. package/dist/repository-reconciliation.d.ts.map +1 -0
  95. package/dist/repository-source-config.d.ts +29 -18
  96. package/dist/repository-source-config.d.ts.map +1 -1
  97. package/dist/repository-types.d.ts +28 -1
  98. package/dist/repository-types.d.ts.map +1 -1
  99. package/dist/review-flow-public.d.ts +2 -0
  100. package/dist/review-flow-public.d.ts.map +1 -0
  101. package/dist/review-flow-public.js +11 -0
  102. package/dist/review-flow-public.js.map +1 -0
  103. package/dist/review-flow.d.ts +6 -0
  104. package/dist/review-flow.d.ts.map +1 -1
  105. package/dist/review-flow.js +1 -1
  106. package/dist/runtime-internals-public.d.ts +2 -0
  107. package/dist/runtime-internals-public.d.ts.map +1 -0
  108. package/dist/runtime-internals-public.js +16 -0
  109. package/dist/runtime-internals-public.js.map +1 -0
  110. package/dist/runtime-internals.js +2 -1
  111. package/dist/server-events.d.ts +67 -0
  112. package/dist/server-events.d.ts.map +1 -1
  113. package/dist/server-process-builder.d.ts +7 -0
  114. package/dist/server-process-builder.d.ts.map +1 -1
  115. package/dist/state-helpers.d.ts +6 -0
  116. package/dist/state-helpers.d.ts.map +1 -1
  117. package/dist/subprocess-env.d.ts +3 -0
  118. package/dist/subprocess-env.d.ts.map +1 -1
  119. package/dist/tool-arguments.d.ts +4 -2
  120. package/dist/tool-arguments.d.ts.map +1 -1
  121. package/dist/tool-renderers.d.ts +6 -0
  122. package/dist/tool-renderers.d.ts.map +1 -1
  123. package/dist/turn-semantics.d.ts +14 -1
  124. package/dist/turn-semantics.d.ts.map +1 -1
  125. package/dist/types.d.ts +205 -24
  126. package/dist/types.d.ts.map +1 -1
  127. package/dist/ui-process-builder.d.ts +5 -0
  128. package/dist/ui-process-builder.d.ts.map +1 -1
  129. package/dist/worker-process-builder.d.ts +5 -0
  130. package/dist/worker-process-builder.d.ts.map +1 -1
  131. package/package.json +16 -15
  132. package/src/browser-ui-extension.ts +20 -0
  133. package/src/capabilities.ts +9 -1
  134. package/src/codecs.ts +1 -0
  135. package/src/commit-message.ts +5 -0
  136. package/src/core-capabilities.ts +398 -35
  137. package/src/define-process.ts +198 -23
  138. package/src/event-bus.ts +1 -0
  139. package/src/extension-api.ts +399 -55
  140. package/src/external-action-source.ts +7 -2
  141. package/src/external-source-poll.ts +72 -6
  142. package/src/flow.ts +352 -23
  143. package/src/form-contract.ts +0 -4
  144. package/src/fs-utils.ts +4 -0
  145. package/src/git-binary.ts +2 -1
  146. package/src/graph-fragments.ts +16 -0
  147. package/src/host-capabilities.ts +9 -6
  148. package/src/index.ts +14 -202
  149. package/src/integration-http.ts +15 -3
  150. package/src/json-data.ts +1 -1
  151. package/src/leaf-outcome-renderer.ts +35 -0
  152. package/src/leaf-outcomes.ts +3 -0
  153. package/src/model-provider.ts +169 -20
  154. package/src/pi-config-public.ts +7 -0
  155. package/src/pi-config.ts +47 -2
  156. package/src/process-definition-internals.ts +4 -0
  157. package/src/process-flow-view.ts +2 -0
  158. package/src/process-graph.ts +34 -0
  159. package/src/process-launcher-builder.ts +5 -0
  160. package/src/process-watcher-builder.ts +5 -0
  161. package/src/process-watcher-source.ts +6 -4
  162. package/src/project-binding.ts +5 -1
  163. package/src/registry-utils.ts +6 -0
  164. package/src/repository-feedback.ts +59 -5
  165. package/src/repository-git-env.ts +6 -2
  166. package/src/repository-http.ts +19 -2
  167. package/src/repository-https.ts +1 -1
  168. package/src/repository-issue-watcher.ts +64 -7
  169. package/src/repository-reconciliation.ts +30 -0
  170. package/src/repository-source-config.ts +66 -4
  171. package/src/repository-types.ts +43 -5
  172. package/src/review-flow-public.ts +5 -0
  173. package/src/review-flow.ts +6 -0
  174. package/src/runtime-internals-public.ts +7 -0
  175. package/src/server-events.ts +67 -0
  176. package/src/server-process-builder.ts +10 -1
  177. package/src/state-helpers.ts +6 -0
  178. package/src/subprocess-env.ts +3 -0
  179. package/src/tool-arguments.ts +4 -2
  180. package/src/tool-renderers.ts +6 -0
  181. package/src/turn-semantics.ts +15 -2
  182. package/src/types.ts +212 -30
  183. package/src/ui-process-builder.ts +8 -1
  184. package/src/worker-process-builder.ts +8 -1
  185. package/dist/chunk-LIIP7FMU.js.map +0 -1
  186. package/dist/chunk-TA4KO53Q.js.map +0 -1
  187. package/dist/chunk-WFY2WWZE.js.map +0 -1
package/src/pi-config.ts CHANGED
@@ -9,10 +9,14 @@ import {
9
9
  type ResolvedProcessPiConfig,
10
10
  } from "./types.js";
11
11
 
12
+ /** @internal */
12
13
  type TemplateScalar = string | number | boolean;
14
+ /** @internal */
13
15
  type TemplateValue = TemplateScalar | TemplateContext | readonly TemplateValue[] | undefined;
14
16
 
17
+ /** @internal */
15
18
  export interface TemplateContext {
19
+ /** @internal */
16
20
  [key: string]: TemplateValue;
17
21
  }
18
22
 
@@ -33,18 +37,30 @@ function toTemplateContextRecord(value: unknown): TemplateContext {
33
37
  return context;
34
38
  }
35
39
 
40
+ /** @internal */
36
41
  export function createTemplateContext(input: {
42
+ /** @internal */
37
43
  params?: unknown;
44
+ /** @internal */
38
45
  process?: {
46
+ /** @internal */
39
47
  processId?: string | null;
48
+ /** @internal */
40
49
  externalId?: string | null;
50
+ /** @internal */
41
51
  externalUrl?: string | null;
52
+ /** @internal */
42
53
  selectedTurnId?: string | null;
43
54
  };
55
+ /** @internal */
44
56
  projects?: ReadonlyArray<{
57
+ /** @internal */
45
58
  key: string;
59
+ /** @internal */
46
60
  repoLocator: string;
61
+ /** @internal */
47
62
  baseBranch: string;
63
+ /** @internal */
48
64
  workBranch?: string | null;
49
65
  }>;
50
66
  }): TemplateContext {
@@ -67,18 +83,31 @@ export function createTemplateContext(input: {
67
83
  return context;
68
84
  }
69
85
 
86
+ /** @internal */
70
87
  export function interpolateTemplate(template: string, context: TemplateContext): string {
71
88
  return Mustache.render(template, context);
72
89
  }
73
90
 
91
+ /** @internal */
74
92
  type TurnToolDefinitionLike =
75
- | { kind: "llm"; availableTools: readonly PiBuiltInToolName[] }
76
- | { kind: string };
93
+ | {
94
+ /** @internal */
95
+ kind: "llm";
96
+ /** @internal */
97
+ availableTools: readonly PiBuiltInToolName[];
98
+ }
99
+ | {
100
+ /** @internal */
101
+ kind: string;
102
+ };
77
103
 
104
+ /** @internal */
78
105
  type ProcessTurnBindingLike = {
106
+ /** @internal */
79
107
  definition: TurnToolDefinitionLike;
80
108
  };
81
109
 
110
+ /** @internal */
82
111
  type ProcessToolSource = TurnToolDefinitionLike | ProcessTurnBindingLike;
83
112
 
84
113
  function isTurnDefinitionSource(source: ProcessToolSource): source is TurnToolDefinitionLike {
@@ -89,6 +118,7 @@ function resolveToolSourceDefinition(source: ProcessToolSource): TurnToolDefinit
89
118
  return isTurnDefinitionSource(source) ? source : source.definition;
90
119
  }
91
120
 
121
+ /** @internal */
92
122
  export function validatePiBuiltInToolArray(
93
123
  toolNames: readonly unknown[],
94
124
  context: string,
@@ -124,8 +154,11 @@ export function validatePiBuiltInToolArray(
124
154
  return errors;
125
155
  }
126
156
 
157
+ /** @internal */
127
158
  export function resolveTurnAvailableToolNames(input: {
159
+ /** @internal */
128
160
  turnId: string;
161
+ /** @internal */
129
162
  turnDef: LlmTurnDefinition<string, unknown, unknown>;
130
163
  }): string[] {
131
164
  const errors = validatePiBuiltInToolArray(
@@ -138,6 +171,7 @@ export function resolveTurnAvailableToolNames(input: {
138
171
  return [...input.turnDef.availableTools];
139
172
  }
140
173
 
174
+ /** @internal */
141
175
  export function collectProcessAvailableToolNames(
142
176
  turns: Iterable<ProcessToolSource> | undefined,
143
177
  ): string[] {
@@ -196,11 +230,17 @@ Guidelines:
196
230
  - Show file paths clearly when working with files.`;
197
231
  }
198
232
 
233
+ /** @internal */
199
234
  export function resolveProcessPiConfig(input: {
235
+ /** @internal */
200
236
  processId: string;
237
+ /** @internal */
201
238
  processPiConfig?: ProcessPiConfig;
239
+ /** @internal */
202
240
  turns?: Iterable<ProcessToolSource>;
241
+ /** @internal */
203
242
  configSnapshot?: ConfigSnapshot;
243
+ /** @internal */
204
244
  templateContext: TemplateContext;
205
245
  }): ResolvedProcessPiConfig {
206
246
  const processConfig = input.configSnapshot?.process_configs?.[input.processId];
@@ -237,6 +277,7 @@ export { resolveTurnAvailableToolNames as resolveTurnActiveToolNames };
237
277
 
238
278
  // Mirror Pi's PI_CODING_AGENT_DIR expansion semantics from
239
279
  // pi-mono/packages/coding-agent/src/config.ts.
280
+ /** @internal */
240
281
  export function expandPiAgentDir(agentDir: string): string {
241
282
  if (agentDir === "~") {
242
283
  return homedir();
@@ -247,9 +288,13 @@ export function expandPiAgentDir(agentDir: string): string {
247
288
  return agentDir;
248
289
  }
249
290
 
291
+ /** @internal */
250
292
  export function resolvePiAgentDir(options: {
293
+ /** @internal */
251
294
  agentDir?: string | null;
295
+ /** @internal */
252
296
  configSnapshot?: ConfigSnapshot;
297
+ /** @internal */
253
298
  fallbackDir: string;
254
299
  }): string {
255
300
  const configuredAgentDir =
@@ -18,14 +18,17 @@ if (!registryHolder[registryKey]) {
18
18
  }
19
19
  const registry = registryHolder[registryKey];
20
20
 
21
+ /** @internal */
21
22
  export function markDefinedProcess(value: object): void {
22
23
  registry.definedProcesses.add(value);
23
24
  }
24
25
 
26
+ /** @internal */
25
27
  export function isDefinedProcess(value: unknown): boolean {
26
28
  return typeof value === "object" && value !== null && registry.definedProcesses.has(value);
27
29
  }
28
30
 
31
+ /** @internal */
29
32
  export function setProcessTurnTransitions(
30
33
  binding: object,
31
34
  transitions: readonly ProcessTurnTransition[],
@@ -36,6 +39,7 @@ export function setProcessTurnTransitions(
36
39
  );
37
40
  }
38
41
 
42
+ /** @internal */
39
43
  export function getProcessTurnTransitions(
40
44
  binding: ProcessTurnBinding<unknown> | undefined,
41
45
  ): readonly ProcessTurnTransition[] {
@@ -169,6 +169,7 @@ function dedupeTransitions(transitions: readonly ProcessTurnTransition[]): Proce
169
169
  * here and dropped later during edge construction. Entry turns and the declared
170
170
  * happy path are remapped/filtered to stay consistent.
171
171
  */
172
+ /** @internal */
172
173
  export function collapseRoutingTurns(graph: ProcessGraphView): ProcessGraphView {
173
174
  const routingIds = new Set<TurnId>();
174
175
  for (const [turnId, turn] of graph.turns) {
@@ -332,6 +333,7 @@ function transitionLabel(transition: { outcome?: string; trigger?: string }): st
332
333
  * The `aborted` end state is always present because abort is reachable from any
333
334
  * active turn, even when no explicit transition targets it.
334
335
  */
336
+ /** @internal */
335
337
  export function buildProcessFlowView(rawGraph: ProcessGraphView): ProcessFlowView {
336
338
  const graph = collapseRoutingTurns(rawGraph);
337
339
  const entryTurnIds = [...graph.entryTurnIds].filter((turnId) => graph.turns.has(turnId));
@@ -10,29 +10,50 @@ import type { TurnDefinition } from "./define-process.js";
10
10
  import type { ExtensionProcessDefinition, ProcessTurnBinding } from "./extension-api.js";
11
11
  import { getProcessTurnTransitions } from "./process-definition-internals.js";
12
12
 
13
+ /** @internal */
13
14
  export type ProcessGraphSource = ExtensionProcessDefinition<unknown, unknown>;
15
+ /** @internal */
14
16
  export type ProcessGraphRegistry = ReadonlyMap<string, ProcessGraphSource>;
15
17
 
18
+ /** @internal */
16
19
  export interface ProcessGraphTurnView {
20
+ /** @internal */
17
21
  turnType: ProcessTurnType;
22
+ /** @internal */
18
23
  description: string;
24
+ /** @internal */
19
25
  transitions: readonly ProcessTurnTransition[];
26
+ /** @internal */
20
27
  reviewProduct?: string;
28
+ /** @internal */
21
29
  resultSemanticRef?: ProcessSemanticEntryRefKey;
30
+ /** @internal */
22
31
  publishedProduct?: string;
32
+ /** @internal */
23
33
  publishedProducts?: readonly string[];
34
+ /** @internal */
24
35
  consumedProducts?: readonly string[];
36
+ /** @internal */
25
37
  optionalConsumedProducts?: readonly string[];
38
+ /** @internal */
26
39
  requiredSemanticMarkdownRefs?: readonly ProcessSemanticEntryRefKey[];
40
+ /** @internal */
27
41
  optionalSemanticMarkdownRefs?: readonly ProcessSemanticEntryRefKey[];
42
+ /** @internal */
28
43
  turnResultMarkdownRequired?: boolean;
29
44
  }
30
45
 
46
+ /** @internal */
31
47
  export interface ProcessGraphView {
48
+ /** @internal */
32
49
  id: string;
50
+ /** @internal */
33
51
  primaryEntryTurnId: TurnId;
52
+ /** @internal */
34
53
  entryTurnIds: ReadonlySet<TurnId>;
54
+ /** @internal */
35
55
  happyPath: readonly TurnId[] | null;
56
+ /** @internal */
36
57
  turns: ReadonlyMap<TurnId, ProcessGraphTurnView>;
37
58
  }
38
59
 
@@ -110,6 +131,7 @@ function toTurnView(
110
131
  * All server lifecycle, validation, model-selection and serialization code should use this view
111
132
  * instead of maintaining a second graph representation.
112
133
  */
134
+ /** @internal */
113
135
  export function toProcessGraphView(definition: ProcessGraphSource): ProcessGraphView {
114
136
  const turns = new Map<TurnId, ProcessGraphTurnView>();
115
137
  for (const [turnId, binding] of definition.turns) {
@@ -124,10 +146,12 @@ export function toProcessGraphView(definition: ProcessGraphSource): ProcessGraph
124
146
  };
125
147
  }
126
148
 
149
+ /** @internal */
127
150
  export function hasProcessGraph(registry: ProcessGraphRegistry, processId: string): boolean {
128
151
  return registry.has(processId);
129
152
  }
130
153
 
154
+ /** @internal */
131
155
  export function getProcessGraph(
132
156
  registry: ProcessGraphRegistry,
133
157
  processId: string,
@@ -139,10 +163,12 @@ export function getProcessGraph(
139
163
  return toProcessGraphView(definition);
140
164
  }
141
165
 
166
+ /** @internal */
142
167
  export function getAllProcessGraphs(registry: ProcessGraphRegistry): readonly ProcessGraphView[] {
143
168
  return [...registry.values()].map((definition) => toProcessGraphView(definition));
144
169
  }
145
170
 
171
+ /** @internal */
146
172
  export function getProcessTurnGraph(
147
173
  registry: ProcessGraphRegistry,
148
174
  processId: string,
@@ -151,6 +177,7 @@ export function getProcessTurnGraph(
151
177
  return getProcessGraph(registry, processId).turns.get(turnId);
152
178
  }
153
179
 
180
+ /** @internal */
154
181
  export function getTurnTransitionsForProcessGraph(
155
182
  registry: ProcessGraphRegistry,
156
183
  processId: string,
@@ -159,6 +186,7 @@ export function getTurnTransitionsForProcessGraph(
159
186
  return getProcessTurnGraph(registry, processId, turnId)?.transitions ?? [];
160
187
  }
161
188
 
189
+ /** @internal */
162
190
  export function getReachableTurnIdsForProcessGraph(
163
191
  registry: ProcessGraphRegistry,
164
192
  processId: string,
@@ -166,6 +194,7 @@ export function getReachableTurnIdsForProcessGraph(
166
194
  return [...getProcessGraph(registry, processId).turns.keys()];
167
195
  }
168
196
 
197
+ /** @internal */
169
198
  export function isTurnAvailableForProcessGraph(
170
199
  registry: ProcessGraphRegistry,
171
200
  processId: string,
@@ -174,6 +203,7 @@ export function isTurnAvailableForProcessGraph(
174
203
  return getProcessGraph(registry, processId).turns.has(turnId);
175
204
  }
176
205
 
206
+ /** @internal */
177
207
  export function serializeProcessGraph(
178
208
  registry: ProcessGraphRegistry,
179
209
  processId: string,
@@ -191,6 +221,7 @@ export function serializeProcessGraph(
191
221
  };
192
222
  }
193
223
 
224
+ /** @internal */
194
225
  export function listLlmTurnIdsForProcessGraph(
195
226
  registry: ProcessGraphRegistry,
196
227
  processId: string,
@@ -204,6 +235,7 @@ function isTerminalLifecycleStatus(value: string | undefined): value is "complet
204
235
  return value === "completed" || value === "aborted";
205
236
  }
206
237
 
238
+ /** @internal */
207
239
  export function validateProcessGraphEntryTurns(graph: ProcessGraphView): readonly string[] {
208
240
  const errors: string[] = [];
209
241
  for (const turnId of graph.entryTurnIds) {
@@ -214,6 +246,7 @@ export function validateProcessGraphEntryTurns(graph: ProcessGraphView): readonl
214
246
  return errors;
215
247
  }
216
248
 
249
+ /** @internal */
217
250
  export function validateProcessGraphProducts(graph: ProcessGraphView): readonly string[] {
218
251
  const errors: string[] = [];
219
252
  const publishedProducts = new Set<string>();
@@ -249,6 +282,7 @@ export function validateProcessGraphProducts(graph: ProcessGraphView): readonly
249
282
  return errors;
250
283
  }
251
284
 
285
+ /** @internal */
252
286
  export function validateProcessGraphTurnTransitions(graph: ProcessGraphView): readonly string[] {
253
287
  const errors: string[] = [];
254
288
  for (const [turnId, turn] of graph.turns) {
@@ -5,7 +5,9 @@ import type {
5
5
  } from "./extension-api.js";
6
6
  import { cloneMap, registerUnique } from "./registry-utils.js";
7
7
 
8
+ /** @public */
8
9
  export interface BuiltProcessLauncherDefinition<TParams = unknown> {
10
+ /** @public */
9
11
  launchers: ReadonlyMap<string, ProcessLauncherDefinition<TParams>>;
10
12
  }
11
13
 
@@ -27,7 +29,9 @@ function validateLauncherDefinition<TParams>(def: ProcessLauncherDefinition<TPar
27
29
  }
28
30
  }
29
31
 
32
+ /** @internal */
30
33
  export function createProcessLauncherBuilder<TParams = unknown>(): ProcessLauncherAPI<TParams> & {
34
+ /** @internal */
31
35
  getDefinition(): BuiltProcessLauncherDefinition<TParams>;
32
36
  } {
33
37
  const launchers = new Map<string, ProcessLauncherDefinition<TParams>>();
@@ -47,6 +51,7 @@ export function createProcessLauncherBuilder<TParams = unknown>(): ProcessLaunch
47
51
  };
48
52
  }
49
53
 
54
+ /** @public */
50
55
  export function buildProcessLaunchers<TParams = unknown, TState = unknown>(
51
56
  process: ExtensionProcessDefinition<TParams, TState>,
52
57
  ): BuiltProcessLauncherDefinition<TParams> | undefined {
@@ -5,7 +5,9 @@ import type {
5
5
  } from "./extension-api.js";
6
6
  import { cloneMap, registerUnique } from "./registry-utils.js";
7
7
 
8
+ /** @public */
8
9
  export interface BuiltProcessWatcherDefinition<TParams = unknown> {
10
+ /** @public */
9
11
  watchers: ReadonlyMap<string, ProcessWatcherDefinition<TParams, unknown, unknown>>;
10
12
  }
11
13
 
@@ -26,7 +28,9 @@ function validateWatcherDefinition<TParams>(
26
28
  }
27
29
  }
28
30
 
31
+ /** @internal */
29
32
  export function createProcessWatcherBuilder<TParams = unknown>(): ProcessWatcherAPI<TParams> & {
33
+ /** @internal */
30
34
  getDefinition(): BuiltProcessWatcherDefinition<TParams>;
31
35
  } {
32
36
  const watchers = new Map<string, ProcessWatcherDefinition<TParams, unknown, unknown>>();
@@ -53,6 +57,7 @@ export function createProcessWatcherBuilder<TParams = unknown>(): ProcessWatcher
53
57
  };
54
58
  }
55
59
 
60
+ /** @public */
56
61
  export function buildProcessWatchers<TParams = unknown, TState = unknown>(
57
62
  process: ExtensionProcessDefinition<TParams, TState>,
58
63
  ): BuiltProcessWatcherDefinition<TParams> | undefined {
@@ -12,10 +12,11 @@ function nonEmptyString(value: unknown, path: string): string {
12
12
  return value;
13
13
  }
14
14
 
15
- /** Parse the shared launch-model fragment nested inside extension-owned watcher config. */
16
- export function parseProcessWatcherLaunchModelConfig(
17
- value: unknown,
18
- ): LaunchModelConfigInput & { skillIds: string[] } {
15
+ /** Parse the shared launch-model fragment nested inside extension-owned watcher config. @public */
16
+ export function parseProcessWatcherLaunchModelConfig(value: unknown): LaunchModelConfigInput & {
17
+ /** @internal */
18
+ skillIds: string[];
19
+ } {
19
20
  if (value === undefined) return { defaultModelProfileId: null, turnConfigs: {}, skillIds: [] };
20
21
  const launch = record(value, "launch");
21
22
  const rawSkills = launch.skills === undefined ? [] : launch.skills;
@@ -48,6 +49,7 @@ export function parseProcessWatcherLaunchModelConfig(
48
49
  };
49
50
  }
50
51
 
52
+ /** @public */
51
53
  export function defineProcessWatcherSource<TConfig, TEvent = unknown>(
52
54
  source: ProcessWatcherSource<TConfig, TEvent>,
53
55
  ): ProcessWatcherSource<TConfig, TEvent> {
@@ -1,13 +1,17 @@
1
1
  import type { IntegrationToolExecutionContext } from "./extension-api.js";
2
2
  import { objectArg } from "./tool-arguments.js";
3
3
 
4
+ /** @public */
4
5
  export interface RepositoryProjectBinding {
6
+ /** @public */
5
7
  owner: string;
8
+ /** @public */
6
9
  repo: string;
10
+ /** @public */
7
11
  profile: string;
8
12
  }
9
13
 
10
- /** Validate an authorized project's binding, retaining extension-selected legacy metadata. */
14
+ /** Validate an authorized project's binding, retaining extension-selected legacy metadata. @public */
11
15
  export function resolveRepositoryProjectBinding(
12
16
  ctx: Pick<IntegrationToolExecutionContext, "project" | "process">,
13
17
  provider: string,
@@ -1,8 +1,12 @@
1
+ /** @internal */
1
2
  export interface UniqueRegistrationOptions<TValue> {
3
+ /** @internal */
2
4
  duplicateMessage: string;
5
+ /** @internal */
3
6
  validate?: (value: TValue) => void;
4
7
  }
5
8
 
9
+ /** @internal */
6
10
  export function registerUnique<TKey, TValue>(
7
11
  registry: Map<TKey, TValue>,
8
12
  key: TKey,
@@ -16,10 +20,12 @@ export function registerUnique<TKey, TValue>(
16
20
  registry.set(key, value);
17
21
  }
18
22
 
23
+ /** @internal */
19
24
  export function cloneMap<TKey, TValue>(registry: ReadonlyMap<TKey, TValue>): Map<TKey, TValue> {
20
25
  return new Map(registry);
21
26
  }
22
27
 
28
+ /** @internal */
23
29
  export function cloneArrayValueMap<TKey, TValue>(
24
30
  registry: ReadonlyMap<TKey, readonly TValue[]>,
25
31
  ): Map<TKey, readonly TValue[]> {
@@ -1,27 +1,38 @@
1
1
  import { asUnknownRecord } from "@leitwerk-dev/domain";
2
2
 
3
+ /** @public */
3
4
  export interface RepositoryFeedbackItem {
5
+ /** @public */
4
6
  kind: "conversation" | "review" | "inline";
7
+ /** @public */
5
8
  id: number;
9
+ /** @public */
6
10
  body: string;
11
+ /** @public */
7
12
  createdAt: string;
13
+ /** @public */
8
14
  author: string;
15
+ /** @public */
9
16
  path?: string;
17
+ /** @public */
10
18
  line?: number | null;
11
19
  }
12
20
 
13
- /** Batch already-authorized, unseen feedback after its quiet period. */
21
+ /** Batch already-authorized, unseen feedback after its quiet period. @public */
14
22
  export function repositoryFeedbackBatch(
15
23
  unseen: readonly RepositoryFeedbackItem[],
16
- config: Record<`${RepositoryFeedbackItem["kind"]}Cursor`, number> & { quietPeriodMs: number },
24
+ config: RepositoryFeedbackBatchConfig,
17
25
  now: number,
18
- ) {
26
+ ): RepositoryFeedbackBatch | null {
19
27
  if (!unseen.length) return null;
20
28
  const latest = Math.max(...unseen.map((item) => Date.parse(item.createdAt) || 0));
21
29
  if (now - latest < config.quietPeriodMs) return null;
22
30
  const cursors = {
31
+ /** @public */
23
32
  conversationCursor: config.conversationCursor,
33
+ /** @public */
24
34
  reviewCursor: config.reviewCursor,
35
+ /** @public */
25
36
  inlineCursor: config.inlineCursor,
26
37
  };
27
38
  for (const item of unseen) {
@@ -29,12 +40,24 @@ export function repositoryFeedbackBatch(
29
40
  cursors[key] = Math.max(cursors[key], item.id);
30
41
  }
31
42
  return {
32
- event: { feedbackIds: unseen.map(({ kind, id }) => ({ kind, id })), cursors },
43
+ /** @public */
44
+ event: {
45
+ /** @public */
46
+ feedbackIds: unseen.map(({ kind, id }) => ({
47
+ /** @public */
48
+ kind,
49
+ /** @public */
50
+ id,
51
+ })),
52
+ /** @public */
53
+ cursors,
54
+ },
55
+ /** @public */
33
56
  mergeKey: `${cursors.conversationCursor}:${cursors.reviewCursor}:${cursors.inlineCursor}`,
34
57
  };
35
58
  }
36
59
 
37
- /** Normalize common forge feedback fields; reject empty bodies and missing identities. */
60
+ /** Normalize common forge feedback fields; reject empty bodies and missing identities. @public */
38
61
  export function normalizeRepositoryFeedback(
39
62
  kind: RepositoryFeedbackItem["kind"],
40
63
  item: Record<string, unknown>,
@@ -57,3 +80,34 @@ export function normalizeRepositoryFeedback(
57
80
  ...(typeof item.line === "number" ? { line: item.line } : {}),
58
81
  };
59
82
  }
83
+ /** @public */
84
+ export interface RepositoryFeedbackCursors {
85
+ /** @public */
86
+ conversationCursor: number;
87
+ /** @public */
88
+ reviewCursor: number;
89
+ /** @public */
90
+ inlineCursor: number;
91
+ }
92
+ /** @public */
93
+ export interface RepositoryFeedbackBatchConfig extends RepositoryFeedbackCursors {
94
+ /** @public */
95
+ quietPeriodMs: number;
96
+ }
97
+ /** @public */
98
+ export interface RepositoryFeedbackBatch {
99
+ /** @public */
100
+ event: {
101
+ /** @public */
102
+ feedbackIds: {
103
+ /** @public */
104
+ kind: RepositoryFeedbackItem["kind"];
105
+ /** @public */
106
+ id: number;
107
+ }[];
108
+ /** @public */
109
+ cursors: RepositoryFeedbackCursors;
110
+ };
111
+ /** @public */
112
+ mergeKey: string;
113
+ }
@@ -9,29 +9,32 @@ function wrapperKey(projectKey: string): string {
9
9
  return `${INTERNAL_REPOSITORY_GIT_SSH_ENV_PREFIX}${encodeURIComponent(projectKey).replace(/%/g, "_")}`;
10
10
  }
11
11
 
12
- /** Worker-internal registration; the wrapper path is never copied to ordinary subprocesses. */
12
+ /** Worker-internal registration; the wrapper path is never copied to ordinary subprocesses. @internal */
13
13
  export function setRepositoryGitSshWrapper(projectKey: string, wrapperPath: string): void {
14
14
  process.env[wrapperKey(projectKey)] = wrapperPath;
15
15
  }
16
16
 
17
+ /** @internal */
17
18
  export function clearRepositoryGitSshWrappers(): void {
18
19
  for (const key of Object.keys(process.env)) {
19
20
  if (key.startsWith(INTERNAL_REPOSITORY_GIT_SSH_ENV_PREFIX)) delete process.env[key];
20
21
  }
21
22
  }
22
23
 
24
+ /** @internal */
23
25
  export function setRepositoryGitHttpsHelper(projectKey: string, helperPath: string): void {
24
26
  process.env[`${INTERNAL_REPOSITORY_GIT_HTTPS_ENV_PREFIX}${encodeURIComponent(projectKey)}`] =
25
27
  helperPath;
26
28
  }
27
29
 
30
+ /** @internal */
28
31
  export function clearRepositoryGitHttpsHelpers(): void {
29
32
  for (const key of Object.keys(process.env)) {
30
33
  if (key.startsWith(INTERNAL_REPOSITORY_GIT_HTTPS_ENV_PREFIX)) delete process.env[key];
31
34
  }
32
35
  }
33
36
 
34
- /** Safe environment for a trusted Git invocation for one process project. */
37
+ /** Safe environment for a trusted Git invocation for one process project. @public */
35
38
  export function repositoryGitSubprocessEnv(
36
39
  projectKey: string,
37
40
  overrides: SubprocessEnvInput = {},
@@ -60,6 +63,7 @@ export function repositoryGitSubprocessEnv(
60
63
  return env;
61
64
  }
62
65
 
66
+ /** @public */
63
67
  export function repositoryGitArgs(args: readonly string[]): string[] {
64
68
  return ["-c", "core.hooksPath=/dev/null", ...args];
65
69
  }
@@ -1,18 +1,21 @@
1
1
  import { IntegrationHttpClient } from "./integration-http.js";
2
2
  import type { RepositoryIssue, RepositoryPullRequest } from "./repository-types.js";
3
3
 
4
- /** Common forge endpoints; extensions retain authentication and specialized operations. */
4
+ /** Common forge endpoints; extensions retain authentication and specialized operations. @public */
5
5
  export class RepositoryHttpClient<Comment = Record<string, unknown>> extends IntegrationHttpClient {
6
+ /** @internal */
6
7
  protected repositoryPath(owner: string, repo: string): string {
7
8
  return `/repos/${owner}/${repo}`;
8
9
  }
9
10
 
11
+ /** @internal */
10
12
  getIssue(owner: string, repo: string, number: number, signal?: AbortSignal) {
11
13
  return this.request<RepositoryIssue>(`${this.repositoryPath(owner, repo)}/issues/${number}`, {
12
14
  signal,
13
15
  });
14
16
  }
15
17
 
18
+ /** @public */
16
19
  listIssueComments(owner: string, repo: string, number: number, signal?: AbortSignal) {
17
20
  return this.pages<Comment>(
18
21
  `${this.repositoryPath(owner, repo)}/issues/${number}/comments`,
@@ -20,6 +23,7 @@ export class RepositoryHttpClient<Comment = Record<string, unknown>> extends Int
20
23
  );
21
24
  }
22
25
 
26
+ /** @public */
23
27
  addIssueComment(owner: string, repo: string, number: number, body: string, signal?: AbortSignal) {
24
28
  return this.writeJson(
25
29
  `${this.repositoryPath(owner, repo)}/issues/${number}/comments`,
@@ -29,10 +33,20 @@ export class RepositoryHttpClient<Comment = Record<string, unknown>> extends Int
29
33
  );
30
34
  }
31
35
 
36
+ /** @public */
32
37
  createPullRequest(
33
38
  owner: string,
34
39
  repo: string,
35
- input: { title: string; body: string; head: string; base: string },
40
+ input: {
41
+ /** @public */
42
+ title: string;
43
+ /** @public */
44
+ body: string;
45
+ /** @public */
46
+ head: string;
47
+ /** @public */
48
+ base: string;
49
+ },
36
50
  ) {
37
51
  return this.writeJson<RepositoryPullRequest>(
38
52
  `${this.repositoryPath(owner, repo)}/pulls`,
@@ -41,6 +55,7 @@ export class RepositoryHttpClient<Comment = Record<string, unknown>> extends Int
41
55
  );
42
56
  }
43
57
 
58
+ /** @public */
44
59
  getPullRequest(owner: string, repo: string, number: number, signal?: AbortSignal) {
45
60
  return this.request<RepositoryPullRequest>(
46
61
  `${this.repositoryPath(owner, repo)}/pulls/${number}`,
@@ -48,12 +63,14 @@ export class RepositoryHttpClient<Comment = Record<string, unknown>> extends Int
48
63
  );
49
64
  }
50
65
 
66
+ /** @internal */
51
67
  listPullRequests(owner: string, repo: string, state = "open") {
52
68
  return this.pages<RepositoryPullRequest>(
53
69
  `${this.repositoryPath(owner, repo)}/pulls?state=${encodeURIComponent(state)}`,
54
70
  );
55
71
  }
56
72
 
73
+ /** @public */
57
74
  updatePullRequest(
58
75
  owner: string,
59
76
  repo: string,
@@ -1,4 +1,4 @@
1
- /** Canonical, credential-free HTTPS repository URL. Reject ambiguous Git credential paths. */
1
+ /** Canonical, credential-free HTTPS repository URL. Reject ambiguous Git credential paths. @public */
2
2
  export function repositoryHttpsUrl(value: string): URL {
3
3
  let url: URL;
4
4
  try {