@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
@@ -1,17 +1,37 @@
1
+ import type { LaunchModelConfigInput } from "@leitwerk-dev/domain";
1
2
  import { parseDurationMs } from "@leitwerk-dev/watcher-utils";
2
3
  import { parseProcessWatcherLaunchModelConfig } from "./process-watcher-source.js";
3
4
  import { objectArg } from "./tool-arguments.js";
4
5
 
6
+ /** @public */
5
7
  export interface RepositoryIssueWatcherConfig {
8
+ /** @public */
6
9
  profile: string;
10
+ /** @public */
7
11
  pollInterval: string;
8
- repositories: { include: readonly string[]; exclude: readonly string[] };
9
- labels: { trigger: string; done: string };
12
+ /** @public */
13
+ repositories: {
14
+ /** @public */
15
+ include: readonly string[];
16
+ /** @public */
17
+ exclude: readonly string[];
18
+ };
19
+ /** @public */
20
+ labels: {
21
+ /** @public */
22
+ trigger: string;
23
+ /** @public */
24
+ done: string;
25
+ };
10
26
  }
11
27
 
28
+ /** @public */
12
29
  export function matchesRepository(
13
30
  config: Pick<RepositoryIssueWatcherConfig, "repositories">,
14
- repository: { full_name: string },
31
+ repository: {
32
+ /** @public */
33
+ full_name: string;
34
+ },
15
35
  ): boolean {
16
36
  const { include = [], exclude = [] } = config.repositories ?? {};
17
37
  return (
@@ -40,12 +60,12 @@ function repositoryNames(value: unknown, path: string): readonly string[] {
40
60
  });
41
61
  }
42
62
 
43
- /** Parse shared issue watcher fields; extensions choose the legacy type and label policy. */
63
+ /** Parse shared issue watcher fields; extensions choose the legacy type and label policy. @public */
44
64
  export function parseRepositoryIssueWatcherConfig(
45
65
  raw: unknown,
46
66
  legacyType: string,
47
67
  distinctLabels = false,
48
- ) {
68
+ ): ParsedRepositoryIssueWatcherConfig {
49
69
  const config = record(raw, "watcher config");
50
70
  if (config.type !== undefined && config.type !== legacyType)
51
71
  throw new Error(`type must be '${legacyType}' when specified`);
@@ -71,17 +91,30 @@ export function parseRepositoryIssueWatcherConfig(
71
91
  if (distinctLabels && parsed.labels.trigger === parsed.labels.done)
72
92
  throw new Error("Trigger and done labels must differ");
73
93
  return {
94
+ /** @public */
74
95
  config: parsed,
96
+ /** @public */
75
97
  enabled: config.enabled,
98
+ /** @public */
76
99
  launchModelConfig: parseProcessWatcherLaunchModelConfig(config.launch),
77
100
  };
78
101
  }
79
102
 
80
- export function presentRepositoryIssueWatcherConfig(config: RepositoryIssueWatcherConfig) {
103
+ /** @public */
104
+ export function presentRepositoryIssueWatcherConfig(
105
+ config: RepositoryIssueWatcherConfig,
106
+ ): RepositoryIssueWatcherPresentation {
81
107
  return {
108
+ /** @public */
82
109
  targetSummary: `Profile ${config.profile} · trigger ${config.labels.trigger}`,
110
+ /** @public */
83
111
  details: [
84
- { label: "Profile", value: config.profile },
112
+ {
113
+ /** @public */
114
+ label: "Profile",
115
+ /** @public */
116
+ value: config.profile,
117
+ },
85
118
  { label: "Included repositories", value: config.repositories.include.join(", ") || "all" },
86
119
  { label: "Excluded repositories", value: config.repositories.exclude.join(", ") || "none" },
87
120
  { label: "Trigger label", value: config.labels.trigger },
@@ -90,3 +123,27 @@ export function presentRepositoryIssueWatcherConfig(config: RepositoryIssueWatch
90
123
  ],
91
124
  };
92
125
  }
126
+ /** @public */
127
+ export interface ParsedRepositoryIssueWatcherConfig {
128
+ /** @public */
129
+ config: RepositoryIssueWatcherConfig;
130
+ /** @public */
131
+ enabled: boolean;
132
+ /** @public */
133
+ launchModelConfig: LaunchModelConfigInput & {
134
+ /** @public */
135
+ skillIds: string[];
136
+ };
137
+ }
138
+ /** @public */
139
+ export interface RepositoryIssueWatcherPresentation {
140
+ /** @public */
141
+ targetSummary: string;
142
+ /** @public */
143
+ details: {
144
+ /** @public */
145
+ label: string;
146
+ /** @public */
147
+ value: string;
148
+ }[];
149
+ }
@@ -0,0 +1,30 @@
1
+ import { IntegrationHttpError } from "./integration-http.js";
2
+
3
+ /** @internal */
4
+ export async function existingObject<T>(read: () => Promise<T>): Promise<T | null> {
5
+ try {
6
+ return await read();
7
+ } catch (error) {
8
+ if (error instanceof IntegrationHttpError && error.status === 404) return null;
9
+ throw error;
10
+ }
11
+ }
12
+
13
+ /** @internal */
14
+ export function matchesPatch(current: object, patch: Record<string, unknown>): boolean {
15
+ const fields = current as Record<string, unknown>;
16
+ return Object.entries(patch).every(([key, expected]) => {
17
+ const labelKey = Array.isArray(expected) && typeof expected[0] === "number" ? "id" : "name";
18
+ const normalize = (value: unknown) =>
19
+ key === "labels" && Array.isArray(value)
20
+ ? [
21
+ ...new Set(
22
+ value.map((label) =>
23
+ typeof label === "object" && label !== null ? label[labelKey] : label,
24
+ ),
25
+ ),
26
+ ].sort()
27
+ : value;
28
+ return JSON.stringify(normalize(fields[key])) === JSON.stringify(normalize(expected));
29
+ });
30
+ }
@@ -1,7 +1,10 @@
1
1
  import { asUnknownRecord } from "@leitwerk-dev/domain";
2
+ import type { RepositoryFeedbackBatchConfig } from "./repository-feedback.js";
2
3
 
3
- /** Parse common forge source fields, preserving polling defaults and permissive string handling. */
4
- export function parseRepositoryPullRequestConfig(value: unknown) {
4
+ /** Parse common forge source fields, preserving polling defaults and permissive string handling. @public */
5
+ export function parseRepositoryPullRequestConfig(
6
+ value: unknown,
7
+ ): RepositoryPullRequestSourceConfig | null {
5
8
  const config = asUnknownRecord(value) ?? {};
6
9
  if (
7
10
  typeof config.profile !== "string" ||
@@ -15,31 +18,48 @@ export function parseRepositoryPullRequestConfig(value: unknown) {
15
18
  ? config.terminalOutcome
16
19
  : undefined;
17
20
  return {
21
+ /** @public */
18
22
  profile: config.profile,
23
+ /** @public */
19
24
  owner: config.owner,
25
+ /** @public */
20
26
  repo: config.repo,
27
+ /** @public */
21
28
  prNumber: config.prNumber,
29
+ /** @public */
22
30
  pollInterval: typeof config.pollInterval === "string" ? config.pollInterval : "30s",
31
+ /** @public */
23
32
  terminalOutcome,
33
+ /** @public */
24
34
  disabled: config.disabled === true,
25
35
  };
26
36
  }
27
37
 
28
- export function parseRepositoryFeedbackConfig(value: unknown) {
38
+ /** @public */
39
+ export function parseRepositoryFeedbackConfig(
40
+ value: unknown,
41
+ ): RepositoryFeedbackSourceConfig | null {
29
42
  const base = parseRepositoryPullRequestConfig(value);
30
43
  const config = asUnknownRecord(value) ?? {};
31
44
  if (!base) return null;
32
45
  return {
33
46
  ...base,
47
+ /** @public */
34
48
  conversationCursor:
35
49
  typeof config.conversationCursor === "number" ? config.conversationCursor : 0,
50
+ /** @public */
36
51
  reviewCursor: typeof config.reviewCursor === "number" ? config.reviewCursor : 0,
52
+ /** @public */
37
53
  inlineCursor: typeof config.inlineCursor === "number" ? config.inlineCursor : 0,
54
+ /** @public */
38
55
  quietPeriodMs: typeof config.quietPeriodMs === "number" ? config.quietPeriodMs : 120_000,
39
56
  };
40
57
  }
41
58
 
42
- export function parseRepositoryIssueCancelledConfig(value: unknown) {
59
+ /** @public */
60
+ export function parseRepositoryIssueCancelledConfig(
61
+ value: unknown,
62
+ ): RepositoryIssueCancelledSourceConfig | null {
43
63
  const config = asUnknownRecord(value) ?? {};
44
64
  if (
45
65
  typeof config.profile !== "string" ||
@@ -50,11 +70,53 @@ export function parseRepositoryIssueCancelledConfig(value: unknown) {
50
70
  )
51
71
  return null;
52
72
  return {
73
+ /** @public */
53
74
  profile: config.profile,
75
+ /** @public */
54
76
  owner: config.owner,
77
+ /** @public */
55
78
  repo: config.repo,
79
+ /** @public */
56
80
  issueNumber: config.issueNumber,
81
+ /** @public */
57
82
  triggerLabel: config.triggerLabel,
83
+ /** @public */
58
84
  pollInterval: typeof config.pollInterval === "string" ? config.pollInterval : "30s",
59
85
  };
60
86
  }
87
+ /** @public */
88
+ export interface RepositoryPullRequestSourceConfig {
89
+ /** @public */
90
+ profile: string;
91
+ /** @public */
92
+ owner: string;
93
+ /** @public */
94
+ repo: string;
95
+ /** @public */
96
+ prNumber: number;
97
+ /** @public */
98
+ pollInterval: string;
99
+ /** @public */
100
+ terminalOutcome: "merged" | "closed" | undefined;
101
+ /** @public */
102
+ disabled: boolean;
103
+ }
104
+ /** @public */
105
+ export interface RepositoryFeedbackSourceConfig
106
+ extends RepositoryPullRequestSourceConfig,
107
+ RepositoryFeedbackBatchConfig {}
108
+ /** @public */
109
+ export interface RepositoryIssueCancelledSourceConfig {
110
+ /** @public */
111
+ profile: string;
112
+ /** @public */
113
+ owner: string;
114
+ /** @public */
115
+ repo: string;
116
+ /** @public */
117
+ issueNumber: number;
118
+ /** @public */
119
+ triggerLabel: string;
120
+ /** @public */
121
+ pollInterval: string;
122
+ }
@@ -1,25 +1,63 @@
1
- /** Common issue and pull-request response fields used by repository integrations. */
1
+ /** Common issue and pull-request response fields used by repository integrations. @public */
2
2
  export interface RepositoryIssue {
3
+ /** @public */
3
4
  number: number;
5
+ /** @public */
4
6
  title: string;
7
+ /** @public */
5
8
  body: string | null;
9
+ /** @public */
6
10
  state: string;
11
+ /** @public */
7
12
  html_url: string;
13
+ /** @public */
8
14
  updated_at: string;
9
- user: { login: string };
10
- labels: Array<{ id: number; name: string }>;
15
+ /** @public */
16
+ user: {
17
+ /** @public */
18
+ login: string;
19
+ };
20
+ /** @public */
21
+ labels: Array<{
22
+ /** @public */
23
+ id: number;
24
+ /** @public */
25
+ name: string;
26
+ }>;
11
27
  }
12
28
 
29
+ /** @public */
13
30
  export interface RepositoryPullRequest {
31
+ /** @public */
14
32
  number: number;
33
+ /** @internal */
15
34
  title: string;
35
+ /** @internal */
16
36
  body: string | null;
37
+ /** @internal */
17
38
  state: string;
39
+ /** @public */
18
40
  merged: boolean;
41
+ /** @internal */
19
42
  mergeable?: boolean | null;
43
+ /** @internal */
20
44
  mergeable_state?: string | null;
45
+ /** @public */
21
46
  merge_commit_sha: string | null;
47
+ /** @public */
22
48
  html_url: string;
23
- head: { ref: string; sha: string };
24
- base: { ref: string; sha: string };
49
+ /** @public */
50
+ head: {
51
+ /** @internal */
52
+ ref: string;
53
+ /** @public */
54
+ sha: string;
55
+ };
56
+ /** @internal */
57
+ base: {
58
+ /** @internal */
59
+ ref: string;
60
+ /** @internal */
61
+ sha: string;
62
+ };
25
63
  }
@@ -0,0 +1,5 @@
1
+ export {
2
+ buildPlanSavedEventPayload,
3
+ buildReviewCompletedEventPayload,
4
+ buildReviewRequestedEventPayload,
5
+ } from "./review-flow.js";
@@ -5,6 +5,7 @@ import type {
5
5
  ReviewRequestedEvent,
6
6
  } from "./server-events.js";
7
7
 
8
+ /** @internal */
8
9
  export function filterStringArray(value: unknown): string[] {
9
10
  return Array.isArray(value)
10
11
  ? value.filter((entry): entry is string => typeof entry === "string")
@@ -26,8 +27,11 @@ function resolveOutcomeMarkdown(
26
27
  return typeof value === "string" ? value : undefined;
27
28
  }
28
29
 
30
+ /** @internal */
29
31
  export function buildPlanSavedEventPayload(input: {
32
+ /** @internal */
30
33
  planRevision: number;
34
+ /** @internal */
31
35
  event: Pick<ProcessTurnOutcomeEvent, "params" | "turnResultMarkdown">;
32
36
  }): Omit<PlanSavedEvent, "instanceId"> {
33
37
  return {
@@ -38,6 +42,7 @@ export function buildPlanSavedEventPayload(input: {
38
42
  };
39
43
  }
40
44
 
45
+ /** @internal */
41
46
  export function buildReviewRequestedEventPayload(
42
47
  event: Pick<ProcessTurnOutcomeEvent, "params">,
43
48
  ): Omit<ReviewRequestedEvent, "instanceId"> {
@@ -46,6 +51,7 @@ export function buildReviewRequestedEventPayload(
46
51
  };
47
52
  }
48
53
 
54
+ /** @internal */
49
55
  export function buildReviewCompletedEventPayload(
50
56
  event: Pick<ProcessTurnOutcomeEvent, "outcome" | "params" | "turnResultMarkdown">,
51
57
  ): Omit<ReviewCompletedEvent, "instanceId"> {
@@ -0,0 +1,7 @@
1
+ export {
2
+ getProcessTurnTransitions,
3
+ isDefinedProcess,
4
+ markDefinedProcess,
5
+ registerUnique,
6
+ setProcessTurnTransitions,
7
+ } from "./runtime-internals.js";
@@ -7,99 +7,166 @@ import type {
7
7
  WorkerErrorClass,
8
8
  } from "@leitwerk-dev/domain";
9
9
 
10
+ /** @internal */
10
11
  export interface ProcessCreatedEvent {
12
+ /** @internal */
11
13
  instanceId: string;
14
+ /** @internal */
12
15
  process: ProcessInstance;
16
+ /** @internal */
13
17
  projects: readonly ProcessProject[];
18
+ /** @internal */
14
19
  launcherId?: string | null;
15
20
  }
16
21
 
22
+ /** @internal */
17
23
  export interface ProcessUpdatedEvent {
24
+ /** @internal */
18
25
  instanceId: string;
26
+ /** @internal */
19
27
  process: ProcessInstance;
28
+ /** @internal */
20
29
  changedFields: readonly string[];
21
30
  }
22
31
 
32
+ /** @internal */
23
33
  export interface TurnStartedEvent {
34
+ /** @internal */
24
35
  instanceId: string;
36
+ /** @internal */
25
37
  turnRecord: ProcessTurnRecord;
26
38
  }
27
39
 
40
+ /** @internal */
28
41
  export interface TurnFailedEvent {
42
+ /** @internal */
29
43
  instanceId: string;
44
+ /** @internal */
30
45
  turnRecord: ProcessTurnRecord;
46
+ /** @internal */
31
47
  errorSummary: string;
48
+ /** @internal */
32
49
  errorClass?: WorkerErrorClass | null;
33
50
  }
34
51
 
52
+ /** @internal */
35
53
  export interface LeafOutcomeCapturedEvent {
54
+ /** @internal */
36
55
  instanceId: string;
56
+ /** @internal */
37
57
  snapshot: ProcessLeafOutcomeSnapshot;
38
58
  }
39
59
 
60
+ /** @internal */
40
61
  export interface ReviewRequestedEvent {
62
+ /** @internal */
41
63
  instanceId: string;
64
+ /** @internal */
42
65
  workerId?: string;
66
+ /** @internal */
43
67
  changedProjects: string[];
44
68
  }
45
69
 
70
+ /** @internal */
46
71
  export interface QuestionRequestedEvent {
72
+ /** @internal */
47
73
  instanceId: string;
74
+ /** @internal */
48
75
  request: ProcessQuestionRequest;
49
76
  }
50
77
 
78
+ /** @internal */
51
79
  export interface TurnOutcomeEvent {
80
+ /** @internal */
52
81
  instanceId: string;
82
+ /** @internal */
53
83
  turnRecordId: string;
84
+ /** @internal */
54
85
  turnId: string;
86
+ /** @internal */
55
87
  outcome: string;
88
+ /** @internal */
56
89
  params: Record<string, unknown>;
90
+ /** @internal */
57
91
  turnResultMarkdown?: string | null;
58
92
  }
59
93
 
94
+ /** @internal */
60
95
  export interface PlanApprovedEvent {
96
+ /** @internal */
61
97
  instanceId: string;
98
+ /** @internal */
62
99
  externalId: string | null;
100
+ /** @internal */
63
101
  planRevision: number;
64
102
  }
65
103
 
104
+ /** @internal */
66
105
  export interface PlanRevisionRequestedEvent {
106
+ /** @internal */
67
107
  instanceId: string;
108
+ /** @internal */
68
109
  message: string;
69
110
  }
70
111
 
112
+ /** @internal */
71
113
  export interface PlanSavedEvent {
114
+ /** @internal */
72
115
  instanceId: string;
116
+ /** @internal */
73
117
  planRevision: number;
118
+ /** @internal */
74
119
  summary: string;
120
+ /** @internal */
75
121
  planMarkdown: string;
122
+ /** @internal */
76
123
  acceptanceCriteria: string[];
77
124
  }
78
125
 
126
+ /** @internal */
79
127
  export interface ReviewCompletedEvent {
128
+ /** @internal */
80
129
  instanceId: string;
130
+ /** @internal */
81
131
  hasIssues: boolean;
132
+ /** @internal */
82
133
  issueCount: number;
134
+ /** @internal */
83
135
  reviewMarkdown?: string;
84
136
  }
85
137
 
138
+ /** @internal */
86
139
  export interface ServerExtensionEventMap {
140
+ /** @internal */
87
141
  process_created: ProcessCreatedEvent;
142
+ /** @internal */
88
143
  process_updated: ProcessUpdatedEvent;
144
+ /** @internal */
89
145
  turn_started: TurnStartedEvent;
146
+ /** @internal */
90
147
  turn_failed: TurnFailedEvent;
148
+ /** @internal */
91
149
  leaf_outcome_captured: LeafOutcomeCapturedEvent;
150
+ /** @internal */
92
151
  question_requested: QuestionRequestedEvent;
152
+ /** @internal */
93
153
  review_requested: ReviewRequestedEvent;
154
+ /** @internal */
94
155
  turn_outcome: TurnOutcomeEvent;
156
+ /** @internal */
95
157
  plan_approved: PlanApprovedEvent;
158
+ /** @internal */
96
159
  plan_revision_requested: PlanRevisionRequestedEvent;
160
+ /** @internal */
97
161
  plan_saved: PlanSavedEvent;
162
+ /** @internal */
98
163
  review_completed: ReviewCompletedEvent;
99
164
  }
100
165
 
166
+ /** @internal */
101
167
  export type ServerExtensionEventName = keyof ServerExtensionEventMap;
102
168
 
169
+ /** @internal */
103
170
  export type ServerExtensionEventPayloadInputMap = {
104
171
  [K in keyof ServerExtensionEventMap]: Omit<ServerExtensionEventMap[K], "instanceId">;
105
172
  };
@@ -11,21 +11,30 @@ import {
11
11
  validateProcessActionSchedulingDefinition,
12
12
  } from "./turn-semantics.js";
13
13
 
14
+ /** @internal */
14
15
  export type ServerTurnOutcomeHandler<TParams = unknown, TState = unknown> = (
15
16
  event: ProcessTurnOutcomeEvent,
16
17
  ctx: ServerProcessContext<TParams, TState>,
17
18
  ) => void | Promise<void>;
18
19
 
20
+ /** @internal */
19
21
  export interface BuiltServerProcessDefinition<TParams = unknown, TState = unknown> {
22
+ /** @internal */
20
23
  actions: ReadonlyMap<string, ProcessActionDefinition<TParams, TState>>;
24
+ /** @internal */
21
25
  turnOutcomeHandlers: ReadonlyMap<string, readonly ServerTurnOutcomeHandler<TParams, TState>[]>;
26
+ /** @internal */
22
27
  cleanupHandlers: readonly ProcessCleanupHandler<TParams, TState>[];
23
28
  }
24
29
 
30
+ /** @internal */
25
31
  export function createServerProcessBuilder<TParams = unknown, TState = unknown>(): ServerProcessAPI<
26
32
  TParams,
27
33
  TState
28
- > & { getDefinition(): BuiltServerProcessDefinition<TParams, TState> } {
34
+ > & {
35
+ /** @internal */
36
+ getDefinition(): BuiltServerProcessDefinition<TParams, TState>;
37
+ } {
29
38
  const actions = new Map<string, ProcessActionDefinition<TParams, TState>>();
30
39
  const turnOutcomeHandlers = new Map<string, ServerTurnOutcomeHandler<TParams, TState>[]>();
31
40
  const cleanupHandlers: ProcessCleanupHandler<TParams, TState>[] = [];
@@ -9,16 +9,21 @@ import {
9
9
  } from "@leitwerk-dev/domain";
10
10
  import type { Codec } from "./extension-api.js";
11
11
 
12
+ /** @public */
12
13
  export interface StructuralProcessState {
14
+ /** @internal */
13
15
  semanticEntryRefs: ProcessSemanticEntryRefs;
16
+ /** @internal */
14
17
  productRefs: ProcessProductRefs;
15
18
  }
16
19
 
20
+ /** @internal */
17
21
  export const structuralStateCodec: Codec<StructuralProcessState> = {
18
22
  parse: parseStructuralProcessState,
19
23
  serialize: (value) => value,
20
24
  };
21
25
 
26
+ /** @public */
22
27
  export function createEmptyStructuralProcessState(): StructuralProcessState {
23
28
  return {
24
29
  semanticEntryRefs: createEmptyProcessSemanticEntryRefs(),
@@ -26,6 +31,7 @@ export function createEmptyStructuralProcessState(): StructuralProcessState {
26
31
  };
27
32
  }
28
33
 
34
+ /** @public */
29
35
  export function parseStructuralProcessState(value: unknown): StructuralProcessState {
30
36
  const record = asUnknownRecord(value) ?? {};
31
37
  return {
@@ -4,11 +4,13 @@ import {
4
4
  WORKER_SNAPSHOT_TOKEN_ENV,
5
5
  } from "@leitwerk-dev/worker-protocol";
6
6
 
7
+ /** @public */
7
8
  export type SubprocessEnvInput = Record<string, string | undefined>;
8
9
 
9
10
  export const INTERNAL_REPOSITORY_GIT_SSH_ENV_PREFIX = "LEITWERK_INTERNAL_REPOSITORY_GIT_SSH_";
10
11
  export const INTERNAL_REPOSITORY_GIT_HTTPS_ENV_PREFIX = "LEITWERK_INTERNAL_REPOSITORY_GIT_HTTPS_";
11
12
 
13
+ /** @internal */
12
14
  export const WORKER_SUBPROCESS_SENSITIVE_ENV_KEYS = [
13
15
  WORKER_IPC_CONNECT_TOKEN_ENV,
14
16
  WORKER_IPC_RECONNECT_ENV,
@@ -32,6 +34,7 @@ const SENSITIVE_ENV_KEYS = new Set<string>([
32
34
  * process itself. Repository scripts, git hooks, package managers, and other
33
35
  * tool subprocesses must not receive them.
34
36
  */
37
+ /** @public */
35
38
  export function sanitizeWorkerSubprocessEnv(
36
39
  baseEnv: SubprocessEnvInput = process.env,
37
40
  overrides: SubprocessEnvInput = {},
@@ -1,4 +1,4 @@
1
- /** Object parameters for a tool bound to a current process project. */
1
+ /** Object parameters for a tool bound to a current process project. @public */
2
2
  export function projectParameters(
3
3
  properties: Record<string, unknown> = {},
4
4
  required: readonly string[] = Object.keys(properties),
@@ -13,6 +13,7 @@ export function projectParameters(
13
13
  };
14
14
  }
15
15
 
16
+ /** @public */
16
17
  export function objectArg(
17
18
  value: unknown,
18
19
  message = "Tool arguments must be an object",
@@ -21,7 +22,7 @@ export function objectArg(
21
22
  return value as Record<string, unknown>;
22
23
  }
23
24
 
24
- /** Read required integration-tool arguments at the runtime boundary. */
25
+ /** Read required integration-tool arguments at the runtime boundary. @public */
25
26
  export function stringArg(args: Record<string, unknown>, name: string): string {
26
27
  const value = args[name];
27
28
  if (typeof value !== "string" || !value.trim())
@@ -29,6 +30,7 @@ export function stringArg(args: Record<string, unknown>, name: string): string {
29
30
  return value.trim();
30
31
  }
31
32
 
33
+ /** @public */
32
34
  export function numberArg(args: Record<string, unknown>, name: string): number {
33
35
  const value = args[name];
34
36
  if (typeof value !== "number" || !Number.isInteger(value) || value <= 0)