@leitwerk-dev/process-sdk 0.2.1 → 0.3.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 (60) hide show
  1. package/README.md +12 -0
  2. package/dist/{chunk-I7U6HCLN.js → chunk-GVBLXKSR.js} +1 -1
  3. package/dist/chunk-GVBLXKSR.js.map +1 -0
  4. package/dist/core-capabilities.d.ts +2 -0
  5. package/dist/core-capabilities.d.ts.map +1 -1
  6. package/dist/define-process.d.ts +3 -0
  7. package/dist/define-process.d.ts.map +1 -1
  8. package/dist/{extension-api-B4gG5w1K.d.ts → extension-api-DM-AvWOW.d.ts} +211 -14
  9. package/dist/extension-api.d.ts +19 -5
  10. package/dist/extension-api.d.ts.map +1 -1
  11. package/dist/external-source-poll.d.ts +18 -12
  12. package/dist/external-source-poll.d.ts.map +1 -1
  13. package/dist/flow.d.ts +118 -13
  14. package/dist/flow.d.ts.map +1 -1
  15. package/dist/index.d.ts +6 -4
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +647 -82
  18. package/dist/index.js.map +1 -1
  19. package/dist/integration-http.d.ts +4 -4
  20. package/dist/integration-http.d.ts.map +1 -1
  21. package/dist/json-data.d.ts +1 -1
  22. package/dist/json-data.d.ts.map +1 -1
  23. package/dist/mapped-turn.d.ts +185 -0
  24. package/dist/mapped-turn.d.ts.map +1 -0
  25. package/dist/pi-config-public.js +1 -1
  26. package/dist/pi-config.js +1 -1
  27. package/dist/repository-feedback.d.ts +32 -26
  28. package/dist/repository-feedback.d.ts.map +1 -1
  29. package/dist/repository-https.d.ts +1 -1
  30. package/dist/repository-https.d.ts.map +1 -1
  31. package/dist/repository-issue-watcher.d.ts +30 -25
  32. package/dist/repository-issue-watcher.d.ts.map +1 -1
  33. package/dist/repository-source-config.d.ts +29 -44
  34. package/dist/repository-source-config.d.ts.map +1 -1
  35. package/dist/subprocess-env.d.ts +1 -1
  36. package/dist/subprocess-env.d.ts.map +1 -1
  37. package/dist/tool-arguments.d.ts +3 -3
  38. package/dist/tool-arguments.d.ts.map +1 -1
  39. package/dist/turn-semantics.d.ts.map +1 -1
  40. package/dist/types.d.ts +15 -7
  41. package/dist/types.d.ts.map +1 -1
  42. package/package.json +6 -6
  43. package/src/core-capabilities.ts +2 -0
  44. package/src/define-process.ts +83 -0
  45. package/src/extension-api.ts +23 -5
  46. package/src/external-source-poll.ts +65 -11
  47. package/src/flow.ts +448 -31
  48. package/src/index.ts +38 -2
  49. package/src/integration-http.ts +3 -3
  50. package/src/json-data.ts +1 -1
  51. package/src/mapped-turn.ts +386 -0
  52. package/src/repository-feedback.ts +48 -20
  53. package/src/repository-https.ts +1 -1
  54. package/src/repository-issue-watcher.ts +48 -21
  55. package/src/repository-source-config.ts +66 -23
  56. package/src/subprocess-env.ts +1 -1
  57. package/src/tool-arguments.ts +3 -3
  58. package/src/turn-semantics.ts +76 -1
  59. package/src/types.ts +15 -7
  60. package/dist/chunk-I7U6HCLN.js.map +0 -1
@@ -0,0 +1,386 @@
1
+ import type {
2
+ ProcessInstance,
3
+ ProcessProject,
4
+ ProcessTurnTerminalLifecycleStatus,
5
+ TurnId,
6
+ } from "@leitwerk-dev/domain";
7
+ import type { Codec, ProcessTurnOutcomeEvent } from "./extension-api.js";
8
+ import { SafeOutcomePlanningError } from "./extension-api.js";
9
+
10
+ /** @public */
11
+ type MaybePromise<T> = T | Promise<T>;
12
+
13
+ /** Maximum length of a mapped item key. @internal */
14
+ export const MAPPED_ITEM_KEY_MAX_LENGTH = 200;
15
+ /** Maximum length of a mapped item label. @internal */
16
+ export const MAPPED_ITEM_LABEL_MAX_LENGTH = 200;
17
+ /** Maximum number of items frozen by one mapped run. @internal */
18
+ export const MAPPED_ITEM_MAX_COUNT = 500;
19
+ /** Graph trigger used by a mapped turn's collection route. @internal */
20
+ export const MAPPED_COLLECT_TRIGGER = "collect" as const;
21
+
22
+ /** @internal */
23
+ export function mappedCollectTrigger(branchId?: string): string {
24
+ return branchId === undefined ? MAPPED_COLLECT_TRIGGER : `${MAPPED_COLLECT_TRIGGER}:${branchId}`;
25
+ }
26
+
27
+ /** Durable snapshot of process data available to mapped-turn server callbacks. @public */
28
+ export interface MappedTurnServerContext<TParams = unknown, TState = unknown> {
29
+ /** @public */
30
+ readonly process: ProcessInstance;
31
+ /** @internal */
32
+ readonly projects: readonly ProcessProject[];
33
+ /** @public */
34
+ readonly params: TParams;
35
+ /** @public */
36
+ readonly state: TState;
37
+ }
38
+
39
+ /** Active item of a mapped LLM turn, as delivered to one worker turn. @public */
40
+ export interface MappedTurnItemContext<TItem = unknown> {
41
+ /** Frozen, codec-validated item value. @public */
42
+ readonly item: TItem;
43
+ /** Stable key unique within the run. @public */
44
+ readonly itemKey: string;
45
+ /** Short plain-text label shown to operators. @public */
46
+ readonly itemLabel: string;
47
+ /** Zero-based position in the frozen order. @public */
48
+ readonly itemIndex: number;
49
+ /** Number of frozen items in the run. @public */
50
+ readonly itemCount: number;
51
+ }
52
+
53
+ /** Serialized active item carried by worker payloads and turn records. @internal */
54
+ export interface MappedTurnIteration {
55
+ /** @internal */
56
+ readonly runId: string;
57
+ /** @internal */
58
+ readonly itemKey: string;
59
+ /** @internal */
60
+ readonly itemLabel: string;
61
+ /** @internal */
62
+ readonly itemIndex: number;
63
+ /** @internal */
64
+ readonly itemCount: number;
65
+ /** JSON value produced by the item codec. @internal */
66
+ readonly item: unknown;
67
+ }
68
+
69
+ /** @public */
70
+ export interface MappedItemInput<TItem = unknown> {
71
+ /** @public */
72
+ readonly item: TItem;
73
+ /** @public */
74
+ readonly index: number;
75
+ }
76
+
77
+ /** @public */
78
+ export interface MappedSnapshotInput<TParams = unknown, TState = unknown, TItem = unknown> {
79
+ /** @public */
80
+ readonly params: TParams;
81
+ /** @public */
82
+ readonly state: TState;
83
+ /** @public */
84
+ readonly items: readonly TItem[];
85
+ }
86
+
87
+ /** Context passed to a mapped outcome's `yield` callback. @public */
88
+ export interface MappedOutcomeContext<TParams = unknown, TState = unknown, TItem = unknown>
89
+ extends MappedTurnServerContext<TParams, TState>,
90
+ MappedTurnItemContext<TItem> {}
91
+
92
+ /** @public */
93
+ export interface MappedYieldInput<TParams = unknown, TState = unknown, TItem = unknown> {
94
+ /** @public */
95
+ readonly ctx: MappedOutcomeContext<TParams, TState, TItem>;
96
+ /** @public */
97
+ readonly event: ProcessTurnOutcomeEvent;
98
+ }
99
+
100
+ /** @public */
101
+ export type MappedItemYield<
102
+ TParams = unknown,
103
+ TState = unknown,
104
+ TItem = unknown,
105
+ TResult = unknown,
106
+ > = (input: MappedYieldInput<TParams, TState, TItem>) => MaybePromise<TResult>;
107
+
108
+ /** @public */
109
+ export type MappedCollect<TParams = unknown, TState = unknown, TResult = unknown> = (
110
+ ctx: MappedTurnServerContext<TParams, TState>,
111
+ orderedResults: readonly TResult[],
112
+ ) => MaybePromise<TState>;
113
+
114
+ /** Route applied once, after collection. @internal */
115
+ export type MappedCollectRouting<TParams = unknown, TState = unknown> =
116
+ | {
117
+ /** @internal */
118
+ kind: "static";
119
+ /** @internal */
120
+ to?: TurnId;
121
+ /** @internal */
122
+ lifecycleStatus?: ProcessTurnTerminalLifecycleStatus;
123
+ }
124
+ | {
125
+ /** @internal */
126
+ kind: "branches";
127
+ /** @internal */
128
+ branches: Readonly<Record<string, TurnId>>;
129
+ /** @internal */
130
+ choose(ctx: MappedTurnServerContext<TParams, TState>): MaybePromise<string>;
131
+ };
132
+
133
+ /**
134
+ * Durable sequential iteration of one LLM turn over frozen items. Items run one
135
+ * at a time; each item yields a typed result, and business state and routing
136
+ * change once, when all results are collected.
137
+ * @public
138
+ */
139
+ export interface MappedLlmTurnSpec<
140
+ TParams = unknown,
141
+ TState = unknown,
142
+ TItem = unknown,
143
+ TResult = unknown,
144
+ > {
145
+ /** Evaluated once when the turn is entered. @public */
146
+ items(ctx: MappedTurnServerContext<TParams, TState>): readonly unknown[] | null | undefined;
147
+ /** @public */
148
+ itemCodec: Codec<TItem>;
149
+ /** @public */
150
+ resultCodec: Codec<TResult>;
151
+ /** @public */
152
+ key(input: MappedItemInput<TItem>): string;
153
+ /** Defaults to the item key. @public */
154
+ label?(input: MappedItemInput<TItem>): string;
155
+ /** Applied in the freezing transaction, before any item starts. @public */
156
+ stateAfterSnapshot?(input: MappedSnapshotInput<TParams, TState, TItem>): TState;
157
+ /** @internal */
158
+ yields: Readonly<Record<string, MappedItemYield<TParams, TState, TItem, TResult>>>;
159
+ /** @internal */
160
+ collect: MappedCollect<TParams, TState, TResult>;
161
+ /** @internal */
162
+ routing: MappedCollectRouting<TParams, TState>;
163
+ }
164
+
165
+ /** @internal */
166
+ export interface FrozenMappedItem {
167
+ /** @internal */
168
+ index: number;
169
+ /** @internal */
170
+ key: string;
171
+ /** @internal */
172
+ label: string;
173
+ /** @internal */
174
+ itemJson: string;
175
+ }
176
+
177
+ /** @internal */
178
+ export interface MappedFreezeResult<TState = unknown> {
179
+ /** @internal */
180
+ items: FrozenMappedItem[];
181
+ /** State to persist in the freezing transaction, when `stateAfterSnapshot` is declared. @internal */
182
+ state?: TState;
183
+ }
184
+
185
+ /** @internal */
186
+ export interface MappedCollectResult<TState = unknown> {
187
+ /** @internal */
188
+ state: TState;
189
+ /** @internal */
190
+ route: {
191
+ /** @internal */
192
+ trigger: string;
193
+ /** @internal */
194
+ nextTurnId?: TurnId;
195
+ /** @internal */
196
+ lifecycleStatus?: ProcessTurnTerminalLifecycleStatus;
197
+ };
198
+ }
199
+
200
+ function toJsonValue(value: unknown, context: string): string {
201
+ let json: string | undefined;
202
+ try {
203
+ json = JSON.stringify(value);
204
+ } catch {
205
+ json = undefined;
206
+ }
207
+ if (json === undefined) {
208
+ throw new SafeOutcomePlanningError("invalid_mapped_value", `${context} is not JSON`);
209
+ }
210
+ return json;
211
+ }
212
+
213
+ function plainText(value: string): string {
214
+ return value.replace(/\s+/g, " ").trim();
215
+ }
216
+
217
+ function errorMessage(error: unknown): string {
218
+ return error instanceof Error ? error.message : String(error);
219
+ }
220
+
221
+ /** Evaluates, validates, and serializes the items of a mapped turn. @internal */
222
+ export function freezeMappedItems<TParams, TState>(
223
+ turnId: TurnId,
224
+ spec: MappedLlmTurnSpec<TParams, TState>,
225
+ ctx: MappedTurnServerContext<TParams, TState>,
226
+ ): MappedFreezeResult<TState> {
227
+ const raw = spec.items(ctx) ?? [];
228
+ if (!Array.isArray(raw)) {
229
+ throw new SafeOutcomePlanningError(
230
+ "invalid_mapped_items",
231
+ `Mapped turn '${turnId}' items must be an array`,
232
+ );
233
+ }
234
+ if (raw.length > MAPPED_ITEM_MAX_COUNT) {
235
+ throw new SafeOutcomePlanningError(
236
+ "invalid_mapped_items",
237
+ `Mapped turn '${turnId}' may freeze at most ${MAPPED_ITEM_MAX_COUNT} items`,
238
+ );
239
+ }
240
+ const parsed: unknown[] = [];
241
+ const items: FrozenMappedItem[] = [];
242
+ const keys = new Set<string>();
243
+ for (const [index, value] of raw.entries()) {
244
+ let item: unknown;
245
+ try {
246
+ item = spec.itemCodec.parse(value);
247
+ } catch (error) {
248
+ throw new SafeOutcomePlanningError(
249
+ "invalid_mapped_item",
250
+ `Mapped turn '${turnId}' item ${index} is invalid: ${errorMessage(error)}`,
251
+ );
252
+ }
253
+ const key = spec.key({ item, index });
254
+ if (typeof key !== "string" || key.trim() === "" || key.length > MAPPED_ITEM_KEY_MAX_LENGTH) {
255
+ throw new SafeOutcomePlanningError(
256
+ "invalid_mapped_item_key",
257
+ `Mapped turn '${turnId}' item ${index} needs a non-empty key of at most ${MAPPED_ITEM_KEY_MAX_LENGTH} characters`,
258
+ );
259
+ }
260
+ if (keys.has(key)) {
261
+ throw new SafeOutcomePlanningError(
262
+ "duplicate_mapped_item_key",
263
+ `Mapped turn '${turnId}' repeats item key '${key}'`,
264
+ );
265
+ }
266
+ keys.add(key);
267
+ const rawLabel = spec.label ? spec.label({ item, index }) : key;
268
+ const label = plainText(typeof rawLabel === "string" ? rawLabel : "") || key;
269
+ parsed.push(item);
270
+ items.push({
271
+ index,
272
+ key,
273
+ label: label.slice(0, MAPPED_ITEM_LABEL_MAX_LENGTH),
274
+ itemJson: toJsonValue(
275
+ spec.itemCodec.serialize(item),
276
+ `Mapped turn '${turnId}' item '${key}'`,
277
+ ),
278
+ });
279
+ }
280
+ return {
281
+ items,
282
+ ...(spec.stateAfterSnapshot
283
+ ? {
284
+ state: spec.stateAfterSnapshot({
285
+ params: ctx.params,
286
+ state: ctx.state,
287
+ items: parsed,
288
+ }),
289
+ }
290
+ : {}),
291
+ };
292
+ }
293
+
294
+ /** Maps one item outcome to its serialized, codec-validated result. @internal */
295
+ export async function yieldMappedItemResult<TParams, TState>(input: {
296
+ /** @internal */
297
+ turnId: TurnId;
298
+ /** @internal */
299
+ spec: MappedLlmTurnSpec<TParams, TState>;
300
+ /** @internal */
301
+ ctx: MappedTurnServerContext<TParams, TState>;
302
+ /** @internal */
303
+ iteration: MappedTurnIteration;
304
+ /** @internal */
305
+ event: ProcessTurnOutcomeEvent;
306
+ }): Promise<string> {
307
+ const yieldResult = input.spec.yields[input.event.outcome];
308
+ if (!yieldResult) {
309
+ throw new SafeOutcomePlanningError(
310
+ "unknown_mapped_outcome",
311
+ `Mapped turn '${input.turnId}' has no result for outcome '${input.event.outcome}'`,
312
+ );
313
+ }
314
+ const item = input.spec.itemCodec.parse(input.iteration.item);
315
+ const value = await yieldResult({
316
+ ctx: {
317
+ ...input.ctx,
318
+ item,
319
+ itemKey: input.iteration.itemKey,
320
+ itemLabel: input.iteration.itemLabel,
321
+ itemIndex: input.iteration.itemIndex,
322
+ itemCount: input.iteration.itemCount,
323
+ },
324
+ event: input.event,
325
+ });
326
+ let result: unknown;
327
+ try {
328
+ result = input.spec.resultCodec.parse(value);
329
+ } catch (error) {
330
+ throw new SafeOutcomePlanningError(
331
+ "invalid_mapped_result",
332
+ `Mapped turn '${input.turnId}' produced an invalid result for item '${input.iteration.itemKey}': ${errorMessage(error)}`,
333
+ );
334
+ }
335
+ return toJsonValue(
336
+ input.spec.resultCodec.serialize(result),
337
+ `Mapped turn '${input.turnId}' result for item '${input.iteration.itemKey}'`,
338
+ );
339
+ }
340
+
341
+ /** Collects ordered results once and resolves the turn's single business route. @internal */
342
+ export async function collectMappedResults<TParams, TState>(input: {
343
+ /** @internal */
344
+ turnId: TurnId;
345
+ /** @internal */
346
+ spec: MappedLlmTurnSpec<TParams, TState>;
347
+ /** @internal */
348
+ ctx: MappedTurnServerContext<TParams, TState>;
349
+ /** Serialized results in frozen item order. @internal */
350
+ resultJsons: readonly string[];
351
+ }): Promise<MappedCollectResult<TState>> {
352
+ const results = input.resultJsons.map((json, index) => {
353
+ try {
354
+ return input.spec.resultCodec.parse(JSON.parse(json));
355
+ } catch (error) {
356
+ throw new SafeOutcomePlanningError(
357
+ "invalid_mapped_result",
358
+ `Mapped turn '${input.turnId}' stored an invalid result at item ${index}: ${errorMessage(error)}`,
359
+ );
360
+ }
361
+ });
362
+ const state = await input.spec.collect(input.ctx, results);
363
+ const routing = input.spec.routing;
364
+ if (routing.kind === "static") {
365
+ return {
366
+ state,
367
+ route: {
368
+ trigger: mappedCollectTrigger(),
369
+ ...(routing.to !== undefined ? { nextTurnId: routing.to } : {}),
370
+ ...(routing.lifecycleStatus !== undefined
371
+ ? { lifecycleStatus: routing.lifecycleStatus }
372
+ : {}),
373
+ },
374
+ };
375
+ }
376
+ const branchId = await routing.choose({ ...input.ctx, state });
377
+ if (!Object.hasOwn(routing.branches, branchId)) {
378
+ throw new Error(
379
+ `Mapped turn '${input.turnId}' collection selected unknown branch '${branchId}'`,
380
+ );
381
+ }
382
+ return {
383
+ state,
384
+ route: { trigger: mappedCollectTrigger(branchId), nextTurnId: routing.branches[branchId] },
385
+ };
386
+ }
@@ -4,38 +4,35 @@ import { asUnknownRecord } from "@leitwerk-dev/domain";
4
4
  export interface RepositoryFeedbackItem {
5
5
  /** @public */
6
6
  kind: "conversation" | "review" | "inline";
7
- /** @internal */
7
+ /** @public */
8
8
  id: number;
9
9
  /** @public */
10
10
  body: string;
11
- /** @internal */
11
+ /** @public */
12
12
  createdAt: string;
13
13
  /** @public */
14
14
  author: string;
15
- /** @internal */
15
+ /** @public */
16
16
  path?: string;
17
- /** @internal */
17
+ /** @public */
18
18
  line?: number | null;
19
19
  }
20
20
 
21
- /** Batch already-authorized, unseen feedback after its quiet period. @internal */
21
+ /** Batch already-authorized, unseen feedback after its quiet period. @public */
22
22
  export function repositoryFeedbackBatch(
23
23
  unseen: readonly RepositoryFeedbackItem[],
24
- config: Record<`${RepositoryFeedbackItem["kind"]}Cursor`, number> & {
25
- /** @internal */
26
- quietPeriodMs: number;
27
- },
24
+ config: RepositoryFeedbackBatchConfig,
28
25
  now: number,
29
- ) {
26
+ ): RepositoryFeedbackBatch | null {
30
27
  if (!unseen.length) return null;
31
28
  const latest = Math.max(...unseen.map((item) => Date.parse(item.createdAt) || 0));
32
29
  if (now - latest < config.quietPeriodMs) return null;
33
30
  const cursors = {
34
- /** @internal */
31
+ /** @public */
35
32
  conversationCursor: config.conversationCursor,
36
- /** @internal */
33
+ /** @public */
37
34
  reviewCursor: config.reviewCursor,
38
- /** @internal */
35
+ /** @public */
39
36
  inlineCursor: config.inlineCursor,
40
37
  };
41
38
  for (const item of unseen) {
@@ -43,24 +40,24 @@ export function repositoryFeedbackBatch(
43
40
  cursors[key] = Math.max(cursors[key], item.id);
44
41
  }
45
42
  return {
46
- /** @internal */
43
+ /** @public */
47
44
  event: {
48
- /** @internal */
45
+ /** @public */
49
46
  feedbackIds: unseen.map(({ kind, id }) => ({
50
- /** @internal */
47
+ /** @public */
51
48
  kind,
52
- /** @internal */
49
+ /** @public */
53
50
  id,
54
51
  })),
55
- /** @internal */
52
+ /** @public */
56
53
  cursors,
57
54
  },
58
- /** @internal */
55
+ /** @public */
59
56
  mergeKey: `${cursors.conversationCursor}:${cursors.reviewCursor}:${cursors.inlineCursor}`,
60
57
  };
61
58
  }
62
59
 
63
- /** Normalize common forge feedback fields; reject empty bodies and missing identities. @internal */
60
+ /** Normalize common forge feedback fields; reject empty bodies and missing identities. @public */
64
61
  export function normalizeRepositoryFeedback(
65
62
  kind: RepositoryFeedbackItem["kind"],
66
63
  item: Record<string, unknown>,
@@ -83,3 +80,34 @@ export function normalizeRepositoryFeedback(
83
80
  ...(typeof item.line === "number" ? { line: item.line } : {}),
84
81
  };
85
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
+ }
@@ -1,4 +1,4 @@
1
- /** Canonical, credential-free HTTPS repository URL. Reject ambiguous Git credential paths. @internal */
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 {
@@ -1,34 +1,35 @@
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
 
5
6
  /** @public */
6
7
  export interface RepositoryIssueWatcherConfig {
7
- /** @internal */
8
+ /** @public */
8
9
  profile: string;
9
- /** @internal */
10
+ /** @public */
10
11
  pollInterval: string;
11
- /** @internal */
12
+ /** @public */
12
13
  repositories: {
13
- /** @internal */
14
+ /** @public */
14
15
  include: readonly string[];
15
- /** @internal */
16
+ /** @public */
16
17
  exclude: readonly string[];
17
18
  };
18
- /** @internal */
19
+ /** @public */
19
20
  labels: {
20
- /** @internal */
21
+ /** @public */
21
22
  trigger: string;
22
- /** @internal */
23
+ /** @public */
23
24
  done: string;
24
25
  };
25
26
  }
26
27
 
27
- /** @internal */
28
+ /** @public */
28
29
  export function matchesRepository(
29
30
  config: Pick<RepositoryIssueWatcherConfig, "repositories">,
30
31
  repository: {
31
- /** @internal */
32
+ /** @public */
32
33
  full_name: string;
33
34
  },
34
35
  ): boolean {
@@ -59,12 +60,12 @@ function repositoryNames(value: unknown, path: string): readonly string[] {
59
60
  });
60
61
  }
61
62
 
62
- /** Parse shared issue watcher fields; extensions choose the legacy type and label policy. @internal */
63
+ /** Parse shared issue watcher fields; extensions choose the legacy type and label policy. @public */
63
64
  export function parseRepositoryIssueWatcherConfig(
64
65
  raw: unknown,
65
66
  legacyType: string,
66
67
  distinctLabels = false,
67
- ) {
68
+ ): ParsedRepositoryIssueWatcherConfig {
68
69
  const config = record(raw, "watcher config");
69
70
  if (config.type !== undefined && config.type !== legacyType)
70
71
  throw new Error(`type must be '${legacyType}' when specified`);
@@ -90,26 +91,28 @@ export function parseRepositoryIssueWatcherConfig(
90
91
  if (distinctLabels && parsed.labels.trigger === parsed.labels.done)
91
92
  throw new Error("Trigger and done labels must differ");
92
93
  return {
93
- /** @internal */
94
+ /** @public */
94
95
  config: parsed,
95
- /** @internal */
96
+ /** @public */
96
97
  enabled: config.enabled,
97
- /** @internal */
98
+ /** @public */
98
99
  launchModelConfig: parseProcessWatcherLaunchModelConfig(config.launch),
99
100
  };
100
101
  }
101
102
 
102
- /** @internal */
103
- export function presentRepositoryIssueWatcherConfig(config: RepositoryIssueWatcherConfig) {
103
+ /** @public */
104
+ export function presentRepositoryIssueWatcherConfig(
105
+ config: RepositoryIssueWatcherConfig,
106
+ ): RepositoryIssueWatcherPresentation {
104
107
  return {
105
- /** @internal */
108
+ /** @public */
106
109
  targetSummary: `Profile ${config.profile} · trigger ${config.labels.trigger}`,
107
- /** @internal */
110
+ /** @public */
108
111
  details: [
109
112
  {
110
- /** @internal */
113
+ /** @public */
111
114
  label: "Profile",
112
- /** @internal */
115
+ /** @public */
113
116
  value: config.profile,
114
117
  },
115
118
  { label: "Included repositories", value: config.repositories.include.join(", ") || "all" },
@@ -120,3 +123,27 @@ export function presentRepositoryIssueWatcherConfig(config: RepositoryIssueWatch
120
123
  ],
121
124
  };
122
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
+ }