@leitwerk-dev/process-sdk 0.2.0 → 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 (186) hide show
  1. package/dist/browser-ui-extension.d.ts +20 -0
  2. package/dist/browser-ui-extension.d.ts.map +1 -1
  3. package/dist/capabilities.d.ts +6 -0
  4. package/dist/capabilities.d.ts.map +1 -1
  5. package/dist/{chunk-LIIP7FMU.js → chunk-5R6MVLHC.js} +1 -1
  6. package/dist/chunk-5R6MVLHC.js.map +1 -0
  7. package/dist/chunk-DVXW2ZUV.js +1 -0
  8. package/dist/chunk-DVXW2ZUV.js.map +1 -0
  9. package/dist/{chunk-TA4KO53Q.js → chunk-I7U6HCLN.js} +1 -7
  10. package/dist/chunk-I7U6HCLN.js.map +1 -0
  11. package/dist/{chunk-WFY2WWZE.js → chunk-TM2LTSW4.js} +1 -1
  12. package/dist/chunk-TM2LTSW4.js.map +1 -0
  13. package/dist/codecs.d.ts +1 -0
  14. package/dist/codecs.d.ts.map +1 -1
  15. package/dist/commit-message.d.ts +5 -0
  16. package/dist/commit-message.d.ts.map +1 -1
  17. package/dist/core-capabilities.d.ts +336 -20
  18. package/dist/core-capabilities.d.ts.map +1 -1
  19. package/dist/define-process.d.ts +195 -18
  20. package/dist/define-process.d.ts.map +1 -1
  21. package/dist/event-bus.d.ts +1 -0
  22. package/dist/event-bus.d.ts.map +1 -1
  23. package/dist/{extension-api-CcqZCYJx.d.ts → extension-api-B4gG5w1K.d.ts} +1000 -108
  24. package/dist/extension-api.d.ts +385 -50
  25. package/dist/extension-api.d.ts.map +1 -1
  26. package/dist/external-action-source.d.ts +3 -1
  27. package/dist/external-action-source.d.ts.map +1 -1
  28. package/dist/external-source-poll.d.ts +8 -1
  29. package/dist/external-source-poll.d.ts.map +1 -1
  30. package/dist/flow.d.ts +308 -11
  31. package/dist/flow.d.ts.map +1 -1
  32. package/dist/form-contract.d.ts +1 -1
  33. package/dist/form-contract.d.ts.map +1 -1
  34. package/dist/fs-utils.d.ts +4 -0
  35. package/dist/fs-utils.d.ts.map +1 -1
  36. package/dist/git-binary.d.ts +2 -1
  37. package/dist/git-binary.d.ts.map +1 -1
  38. package/dist/git-binary.js.map +1 -1
  39. package/dist/graph-fragments.d.ts +16 -0
  40. package/dist/graph-fragments.d.ts.map +1 -1
  41. package/dist/host-capabilities.d.ts +9 -3
  42. package/dist/host-capabilities.d.ts.map +1 -1
  43. package/dist/index.d.ts +24 -25
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +262 -80
  46. package/dist/index.js.map +1 -1
  47. package/dist/integration-http.d.ts +14 -3
  48. package/dist/integration-http.d.ts.map +1 -1
  49. package/dist/json-data.d.ts +1 -1
  50. package/dist/json-data.d.ts.map +1 -1
  51. package/dist/leaf-outcome-renderer.d.ts +35 -0
  52. package/dist/leaf-outcome-renderer.d.ts.map +1 -1
  53. package/dist/leaf-outcome-renderer.js +12 -0
  54. package/dist/leaf-outcome-renderer.js.map +1 -1
  55. package/dist/leaf-outcomes.d.ts +3 -0
  56. package/dist/leaf-outcomes.d.ts.map +1 -1
  57. package/dist/model-provider.d.ts +144 -12
  58. package/dist/model-provider.d.ts.map +1 -1
  59. package/dist/pi-config-public.d.ts +2 -0
  60. package/dist/pi-config-public.d.ts.map +1 -0
  61. package/dist/pi-config-public.js +15 -0
  62. package/dist/pi-config-public.js.map +1 -0
  63. package/dist/pi-config.d.ts +40 -0
  64. package/dist/pi-config.d.ts.map +1 -1
  65. package/dist/pi-config.js +1 -1
  66. package/dist/process-definition-internals.d.ts +4 -0
  67. package/dist/process-definition-internals.d.ts.map +1 -1
  68. package/dist/process-flow-view.d.ts +2 -0
  69. package/dist/process-flow-view.d.ts.map +1 -1
  70. package/dist/process-graph.d.ts +34 -0
  71. package/dist/process-graph.d.ts.map +1 -1
  72. package/dist/process-launcher-builder.d.ts +5 -0
  73. package/dist/process-launcher-builder.d.ts.map +1 -1
  74. package/dist/process-watcher-builder.d.ts +5 -0
  75. package/dist/process-watcher-builder.d.ts.map +1 -1
  76. package/dist/process-watcher-source.d.ts +3 -1
  77. package/dist/process-watcher-source.d.ts.map +1 -1
  78. package/dist/project-binding.d.ts +5 -1
  79. package/dist/project-binding.d.ts.map +1 -1
  80. package/dist/registry-utils.d.ts +6 -0
  81. package/dist/registry-utils.d.ts.map +1 -1
  82. package/dist/repository-feedback.d.ts +20 -2
  83. package/dist/repository-feedback.d.ts.map +1 -1
  84. package/dist/repository-git-env.d.ts +6 -2
  85. package/dist/repository-git-env.d.ts.map +1 -1
  86. package/dist/repository-http.d.ts +13 -1
  87. package/dist/repository-http.d.ts.map +1 -1
  88. package/dist/repository-https.d.ts +1 -1
  89. package/dist/repository-https.d.ts.map +1 -1
  90. package/dist/repository-issue-watcher.d.ts +21 -1
  91. package/dist/repository-issue-watcher.d.ts.map +1 -1
  92. package/dist/repository-reconciliation.d.ts +5 -0
  93. package/dist/repository-reconciliation.d.ts.map +1 -0
  94. package/dist/repository-source-config.d.ts +27 -1
  95. package/dist/repository-source-config.d.ts.map +1 -1
  96. package/dist/repository-types.d.ts +28 -1
  97. package/dist/repository-types.d.ts.map +1 -1
  98. package/dist/review-flow-public.d.ts +2 -0
  99. package/dist/review-flow-public.d.ts.map +1 -0
  100. package/dist/review-flow-public.js +11 -0
  101. package/dist/review-flow-public.js.map +1 -0
  102. package/dist/review-flow.d.ts +6 -0
  103. package/dist/review-flow.d.ts.map +1 -1
  104. package/dist/review-flow.js +1 -1
  105. package/dist/runtime-internals-public.d.ts +2 -0
  106. package/dist/runtime-internals-public.d.ts.map +1 -0
  107. package/dist/runtime-internals-public.js +16 -0
  108. package/dist/runtime-internals-public.js.map +1 -0
  109. package/dist/runtime-internals.js +2 -1
  110. package/dist/server-events.d.ts +67 -0
  111. package/dist/server-events.d.ts.map +1 -1
  112. package/dist/server-process-builder.d.ts +7 -0
  113. package/dist/server-process-builder.d.ts.map +1 -1
  114. package/dist/state-helpers.d.ts +6 -0
  115. package/dist/state-helpers.d.ts.map +1 -1
  116. package/dist/subprocess-env.d.ts +3 -0
  117. package/dist/subprocess-env.d.ts.map +1 -1
  118. package/dist/tool-arguments.d.ts +4 -2
  119. package/dist/tool-arguments.d.ts.map +1 -1
  120. package/dist/tool-renderers.d.ts +6 -0
  121. package/dist/tool-renderers.d.ts.map +1 -1
  122. package/dist/turn-semantics.d.ts +14 -1
  123. package/dist/turn-semantics.d.ts.map +1 -1
  124. package/dist/types.d.ts +205 -24
  125. package/dist/types.d.ts.map +1 -1
  126. package/dist/ui-process-builder.d.ts +5 -0
  127. package/dist/ui-process-builder.d.ts.map +1 -1
  128. package/dist/worker-process-builder.d.ts +5 -0
  129. package/dist/worker-process-builder.d.ts.map +1 -1
  130. package/package.json +16 -15
  131. package/src/browser-ui-extension.ts +20 -0
  132. package/src/capabilities.ts +9 -1
  133. package/src/codecs.ts +1 -0
  134. package/src/commit-message.ts +5 -0
  135. package/src/core-capabilities.ts +396 -35
  136. package/src/define-process.ts +198 -23
  137. package/src/event-bus.ts +1 -0
  138. package/src/extension-api.ts +399 -55
  139. package/src/external-action-source.ts +7 -2
  140. package/src/external-source-poll.ts +15 -3
  141. package/src/flow.ts +352 -23
  142. package/src/form-contract.ts +0 -4
  143. package/src/fs-utils.ts +4 -0
  144. package/src/git-binary.ts +2 -1
  145. package/src/graph-fragments.ts +16 -0
  146. package/src/host-capabilities.ts +9 -6
  147. package/src/index.ts +5 -201
  148. package/src/integration-http.ts +15 -3
  149. package/src/json-data.ts +1 -1
  150. package/src/leaf-outcome-renderer.ts +35 -0
  151. package/src/leaf-outcomes.ts +3 -0
  152. package/src/model-provider.ts +169 -20
  153. package/src/pi-config-public.ts +7 -0
  154. package/src/pi-config.ts +47 -2
  155. package/src/process-definition-internals.ts +4 -0
  156. package/src/process-flow-view.ts +2 -0
  157. package/src/process-graph.ts +34 -0
  158. package/src/process-launcher-builder.ts +5 -0
  159. package/src/process-watcher-builder.ts +5 -0
  160. package/src/process-watcher-source.ts +6 -4
  161. package/src/project-binding.ts +5 -1
  162. package/src/registry-utils.ts +6 -0
  163. package/src/repository-feedback.ts +30 -4
  164. package/src/repository-git-env.ts +6 -2
  165. package/src/repository-http.ts +19 -2
  166. package/src/repository-https.ts +1 -1
  167. package/src/repository-issue-watcher.ts +35 -5
  168. package/src/repository-reconciliation.ts +30 -0
  169. package/src/repository-source-config.ts +20 -1
  170. package/src/repository-types.ts +43 -5
  171. package/src/review-flow-public.ts +5 -0
  172. package/src/review-flow.ts +6 -0
  173. package/src/runtime-internals-public.ts +7 -0
  174. package/src/server-events.ts +67 -0
  175. package/src/server-process-builder.ts +10 -1
  176. package/src/state-helpers.ts +6 -0
  177. package/src/subprocess-env.ts +3 -0
  178. package/src/tool-arguments.ts +4 -2
  179. package/src/tool-renderers.ts +6 -0
  180. package/src/turn-semantics.ts +15 -2
  181. package/src/types.ts +212 -30
  182. package/src/ui-process-builder.ts +8 -1
  183. package/src/worker-process-builder.ts +8 -1
  184. package/dist/chunk-LIIP7FMU.js.map +0 -1
  185. package/dist/chunk-TA4KO53Q.js.map +0 -1
  186. package/dist/chunk-WFY2WWZE.js.map +0 -1
@@ -45,20 +45,30 @@ import type {
45
45
  TurnResultMarkdownBehavior,
46
46
  } from "./types.js";
47
47
 
48
+ /** @internal */
48
49
  type ProcessEventName = keyof ServerExtensionEventMap & string;
49
50
 
51
+ /** @internal */
50
52
  type ProcessEmittedEvent = {
53
+ /** @internal */
51
54
  type: ProcessEventName;
55
+ /** @internal */
52
56
  data: unknown;
53
57
  };
54
58
 
59
+ /** @public */
55
60
  type ProcessQueuedInput = Parameters<ServerProcessContext["queueInput"]>[0];
56
61
 
62
+ /** @public */
57
63
  type MaybePromise<T> = T | Promise<T>;
58
64
 
65
+ /** @public */
59
66
  type StaticRouteTarget = {
67
+ /** @public */
60
68
  to?: TurnId;
69
+ /** @internal */
61
70
  complete?: boolean;
71
+ /** @public */
62
72
  lifecycleStatus?: ProcessTurnTerminalLifecycleStatus;
63
73
  };
64
74
 
@@ -71,30 +81,46 @@ type NormalizedActionRoute = NormalizedRouteTarget & {
71
81
  trigger: string;
72
82
  };
73
83
 
84
+ /** @public */
74
85
  export interface ProcessRuntimeTurnContext<TParams = unknown, TState = unknown>
75
86
  extends WorkerProcessContext<TParams, TState> {}
76
87
 
88
+ /** @internal */
77
89
  export interface LlmTurnPreparationContext<TParams = unknown, TState = unknown>
78
90
  extends ProcessRuntimeTurnContext<TParams, TState> {
91
+ /** @internal */
79
92
  callIntegrationTool(name: string, args: Record<string, unknown>): Promise<unknown>;
93
+ /** @internal */
80
94
  reportProgress(report: TurnProgressReport): void;
81
95
  }
82
96
 
97
+ /** @public */
83
98
  export interface ProcessServerRuntimeContext<TParams = unknown, TState = unknown> {
99
+ /** @internal */
84
100
  readonly process: ServerProcessContext<TParams, TState>["process"];
101
+ /** @internal */
85
102
  readonly projects: ServerProcessContext<TParams, TState>["projects"];
103
+ /** @internal */
86
104
  readonly params: TParams;
105
+ /** @public */
87
106
  readonly state: TState;
107
+ /** @internal */
88
108
  readSemanticTurnResultMarkdown(ref: ProcessSemanticEntryRefKey): string | null;
109
+ /** @internal */
89
110
  readProductTurnResultMarkdown(productName: string): string | null;
111
+ /** @internal */
90
112
  reportProgress?(report: TurnProgressReport): void;
91
113
  }
92
114
 
115
+ /** @internal */
93
116
  export interface ProcessBroadcastEffect {
117
+ /** @internal */
94
118
  type: string;
119
+ /** @internal */
95
120
  payload: Record<string, unknown>;
96
121
  }
97
122
 
123
+ /** @public */
98
124
  export type ProcessPatchEffect = Partial<
99
125
  Pick<
100
126
  ProcessInstance,
@@ -109,137 +135,207 @@ export type ProcessPatchEffect = Partial<
109
135
  >
110
136
  >;
111
137
 
138
+ /** @public */
112
139
  export interface ProcessLifecycleEffects {
140
+ /** @public */
113
141
  processPatch?: ProcessPatchEffect;
142
+ /** @internal */
114
143
  broadcasts?: readonly ProcessBroadcastEffect[];
115
144
  }
116
145
 
146
+ /** @public */
117
147
  export interface ProcessEffectPlan<TState = unknown> extends ProcessLifecycleEffects {
148
+ /** @public */
118
149
  state?: TState;
150
+ /** @internal */
119
151
  emit?: readonly ProcessEmittedEvent[];
152
+ /** @public */
120
153
  queueInput?: readonly ProcessQueuedInput[];
121
154
  }
122
155
 
156
+ /** @internal */
123
157
  export interface SavePlanResultLifecycleIntent<TParams = unknown, TState = unknown> {
158
+ /** @internal */
124
159
  kind: "save_plan_result";
160
+ /** @internal */
125
161
  summaryParam: string;
162
+ /** @internal */
126
163
  acceptanceCriteriaParam: string;
164
+ /** @internal */
127
165
  planMarkdownParam: string;
166
+ /** @internal */
128
167
  emitEventType: ProcessEventName;
168
+ /** @internal */
129
169
  broadcastType: string;
170
+ /** @internal */
130
171
  state?: ProcessOutcomeEffect<TParams, TState>;
131
172
  }
132
173
 
174
+ /** @internal */
133
175
  export type ProcessOutcomeLifecycleIntent<
134
176
  TParams = unknown,
135
177
  TState = unknown,
136
178
  > = SavePlanResultLifecycleIntent<TParams, TState>;
137
179
 
180
+ /** @public */
138
181
  export interface ProcessActionExecution<TParams = unknown, TState = unknown> {
182
+ /** @public */
139
183
  readonly ctx: ProcessServerRuntimeContext<TParams, TState>;
184
+ /** @public */
140
185
  readonly input: Record<string, unknown>;
186
+ /** @internal */
141
187
  readonly turnId: TurnId;
188
+ /** @internal */
142
189
  readonly actionId: string;
190
+ /** @internal */
143
191
  readonly selectedBranchId?: string;
144
192
  }
145
193
 
194
+ /** @public */
146
195
  export interface ProcessOutcomeExecution<TParams = unknown, TState = unknown> {
196
+ /** @internal */
147
197
  readonly ctx: ProcessServerRuntimeContext<TParams, TState>;
198
+ /** @internal */
148
199
  readonly event: ProcessTurnOutcomeEvent;
200
+ /** @internal */
149
201
  readonly turnId: TurnId;
202
+ /** @internal */
150
203
  readonly outcome: string;
151
204
  }
152
205
 
206
+ /** @public */
153
207
  export type ProcessActionEffect<TParams = unknown, TState = unknown> = (
154
208
  input: ProcessActionExecution<TParams, TState>,
155
209
  ) => MaybePromise<ProcessEffectPlan<TState> | undefined>;
156
210
 
211
+ /** @public */
157
212
  export type ProcessActionBranchSelector<TParams = unknown, TState = unknown> = (
158
213
  input: Omit<ProcessActionExecution<TParams, TState>, "selectedBranchId">,
159
214
  ) => MaybePromise<string>;
160
215
 
216
+ /** @public */
161
217
  export type ProcessOutcomeEffect<TParams = unknown, TState = unknown> = (
162
218
  input: ProcessOutcomeExecution<TParams, TState>,
163
219
  ) => MaybePromise<ProcessEffectPlan<TState> | undefined>;
164
220
 
221
+ /** @internal */
165
222
  export type ProcessOutcomeBranchSelector<TParams = unknown, TState = unknown> = (
166
223
  input: ProcessOutcomeExecution<TParams, TState>,
167
224
  ) => MaybePromise<string>;
168
225
 
226
+ /** @internal */
169
227
  export interface ProcessOutcomeBranchSpec extends StaticRouteTarget {
228
+ /** @internal */
170
229
  trigger?: string;
171
230
  }
172
231
 
232
+ /** @internal */
173
233
  export interface ProcessActionExternalTrigger {
234
+ /** @internal */
174
235
  id: string;
236
+ /** @internal */
175
237
  label: string;
238
+ /** @internal */
176
239
  description: string;
177
240
  }
178
241
 
242
+ /** @internal */
179
243
  export interface ExternalActionInputPublication {
244
+ /** @internal */
180
245
  productName: string;
246
+ /** @internal */
181
247
  inputField: string;
182
248
  }
183
249
 
250
+ /** @public */
184
251
  export interface ProcessHumanTurnExternalActionSpec<
185
252
  TParams = unknown,
186
253
  TState = unknown,
187
254
  TEvent = unknown,
188
255
  TInput extends Record<string, unknown> = Record<string, unknown>,
189
256
  > extends StaticRouteTarget {
257
+ /** @internal */
190
258
  id: string;
259
+ /** @internal */
191
260
  source: ExternalActionSource<TParams, TState, TEvent, TInput>;
192
- /** Arms and exposes this action only when the current process snapshot matches. */
261
+ /** Arms and exposes this action only when the current process snapshot matches. @public */
193
262
  when?: (ctx: ExternalSourceResolveContext<TParams, TState>) => boolean;
263
+ /** @internal */
194
264
  label?: string;
265
+ /** @internal */
195
266
  description?: string;
267
+ /** @internal */
196
268
  publishInput?: ExternalActionInputPublication;
269
+ /** @public */
197
270
  effect?: ExternalSourceEffect<TParams, TState, TEvent, TInput>;
198
271
  }
199
272
 
273
+ /** @public */
200
274
  export interface ProcessActionBranchSpec extends StaticRouteTarget {
275
+ /** @internal */
201
276
  trigger?: string;
202
277
  }
203
278
 
279
+ /** @public */
204
280
  type StaticActionRouting = StaticRouteTarget & {
281
+ /** @internal */
205
282
  trigger?: string;
206
283
  };
207
284
 
285
+ /** @public */
208
286
  type BranchingActionRouting<TParams, TState> = {
287
+ /** @public */
209
288
  branches: Record<string, ProcessActionBranchSpec>;
289
+ /** @public */
210
290
  choose: ProcessActionBranchSelector<TParams, TState>;
211
291
  };
212
292
 
293
+ /** @public */
213
294
  interface BaseActionSpec<TParams, TState> {
295
+ /** @public */
214
296
  label: string;
297
+ /** @public */
215
298
  description?: string;
299
+ /** @internal */
216
300
  form?: FormDefinition;
301
+ /** @public */
217
302
  preview?: ProcessActionPreviewDefinition;
303
+ /** @public */
218
304
  schedulable?: boolean;
305
+ /** @public */
219
306
  effect?: ProcessActionEffect<TParams, TState>;
220
307
  }
221
308
 
309
+ /** @public */
222
310
  export type ProcessHumanTurnActionSpec<TParams = unknown, TState = unknown> = BaseActionSpec<
223
311
  TParams,
224
312
  TState
225
313
  > & {
314
+ /** @public */
226
315
  acceptanceState: TurnAcceptanceState;
316
+ /** @internal */
227
317
  externalTriggers?: readonly ProcessActionExternalTrigger[];
228
318
  } & (StaticActionRouting | BranchingActionRouting<TParams, TState>);
229
319
 
320
+ /** @public */
230
321
  interface ProcessToolOutcomeBaseSpec<TParams = unknown, TState = unknown> {
322
+ /** @internal */
231
323
  description: string;
324
+ /** @internal */
232
325
  parameters: Record<string, OutcomeToolParameterSpec>;
233
- /** Product published from this outcome's turn-result markdown, when this outcome is selected. */
326
+ /** Product published from this outcome's turn-result markdown, when this outcome is selected. @internal */
234
327
  publishedProduct?: string;
235
- /** Outcome parameter whose markdown value is captured as the turn result. */
328
+ /** Outcome parameter whose markdown value is captured as the turn result. @internal */
236
329
  turnResultMarkdownParameter?: string;
237
- /** Outcome parameter containing a concise operator-facing summary. */
330
+ /** Outcome parameter containing a concise operator-facing summary. @internal */
238
331
  resultSummaryParameter?: string;
332
+ /** @internal */
239
333
  effect?: ProcessOutcomeEffect<TParams, TState>;
334
+ /** @internal */
240
335
  lifecycleIntent?: ProcessOutcomeLifecycleIntent<TParams, TState>;
241
336
  }
242
337
 
338
+ /** @public */
243
339
  export type ProcessToolOutcomeSpec<
244
340
  TParams = unknown,
245
341
  TState = unknown,
@@ -247,143 +343,195 @@ export type ProcessToolOutcomeSpec<
247
343
  (
248
344
  | StaticRouteTarget
249
345
  | {
346
+ /** @internal */
250
347
  branches: Record<string, ProcessOutcomeBranchSpec>;
348
+ /** @internal */
251
349
  choose: ProcessOutcomeBranchSelector<TParams, TState>;
252
350
  }
253
351
  );
352
+ /** @public */
254
353
  export type HumanTurnOperatorAttention = "required" | "passive";
255
354
 
355
+ /** @public */
256
356
  export interface HumanTurnDefinition<TParams = unknown, TState = unknown> {
357
+ /** @public */
257
358
  kind: "human";
359
+ /** @public */
258
360
  description: string;
259
- /** Named product rendered as the subject of this human review turn. */
361
+ /** Named product rendered as the subject of this human review turn. @internal */
260
362
  reviewProduct?: string;
363
+ /** @internal */
261
364
  reviewSemanticRef?: ProcessSemanticEntryRefKey;
262
- /** Controls whether entering this turn should raise an action-required toast. */
365
+ /** Controls whether entering this turn should raise an action-required toast. @public */
263
366
  operatorAttention?: HumanTurnOperatorAttention;
367
+ /** @internal */
264
368
  notesFields?: readonly HumanTurnNotesField[];
369
+ /** @internal */
265
370
  commentary?: string;
371
+ /** @public */
266
372
  actions: Record<string, ProcessHumanTurnActionSpec<TParams, TState>>;
373
+ /** @internal */
267
374
  externalActions?: Record<string, ProcessHumanTurnExternalActionSpec<TParams, TState>>;
268
375
  }
269
376
 
377
+ /** @public */
270
378
  export interface ProcessTurnEndSpec<
271
379
  TParams = unknown,
272
380
  TState = unknown,
273
381
  TOutcome extends string = string,
274
382
  > extends StaticRouteTarget {
383
+ /** @public */
275
384
  outcome: TOutcome;
385
+ /** @public */
276
386
  params?: Record<string, unknown>;
387
+ /** @public */
277
388
  effect?: ProcessOutcomeEffect<TParams, TState>;
278
389
  }
279
390
 
391
+ /** @internal */
280
392
  export type OutcomeRouteSpec<TParams = unknown, TState = unknown> = StaticRouteTarget &
281
393
  Partial<Pick<ProcessToolOutcomeSpec<TParams, TState>, "description" | "parameters" | "effect">>;
282
394
 
395
+ /** @internal */
283
396
  export interface OutcomeRouteOptions {
397
+ /** @internal */
284
398
  strict?: boolean;
285
399
  }
286
400
 
401
+ /** @internal */
287
402
  export type LlmModelPurpose = "process_title_generation";
288
403
 
404
+ /** @public */
289
405
  export interface LlmTurnDefinition<
290
406
  TOutcome extends string = string,
291
407
  TParams = unknown,
292
408
  TState = unknown,
293
409
  > {
410
+ /** @public */
294
411
  kind: "llm";
412
+ /** @public */
295
413
  description: string;
296
- /** Code-defined model policy purpose. Purpose selections cannot be overridden per launch/action. */
414
+ /** Code-defined model policy purpose. Purpose selections cannot be overridden per launch/action. @internal */
297
415
  modelPurpose?: LlmModelPurpose;
298
- /** Built-in Pi tools active while this turn runs. */
416
+ /** Built-in Pi tools active while this turn runs. @public */
299
417
  availableTools: readonly PiBuiltInToolName[];
300
- /** Server-owned integration tools proxied over authenticated worker IPC. */
418
+ /** Server-owned integration tools proxied over authenticated worker IPC. @internal */
301
419
  integrationTools?: readonly string[];
302
- /** Resolve a constrained tool set from validated durable process data at turn start. */
420
+ /** Resolve a constrained tool set from validated durable process data at turn start. @public */
303
421
  resolveIntegrationTools?: (params: TParams, state: TState) => readonly string[];
304
- /** Opt in to the durable, operator-facing ask_questions custom tool. */
422
+ /** Opt in to the durable, operator-facing ask_questions custom tool. @internal */
305
423
  askQuestions?: boolean;
306
- /** Deterministic worker preparation that must complete before Pi is prompted. */
424
+ /** Deterministic worker preparation that must complete before Pi is prompted. @internal */
307
425
  prepare?(ctx: LlmTurnPreparationContext<TParams, TState>): MaybePromise<unknown>;
426
+ /** @public */
308
427
  completionMode?: TurnCompletionMode;
428
+ /** @public */
309
429
  branchType: TurnBranchType;
430
+ /** @public */
310
431
  context: TurnContextMode;
432
+ /** @internal */
311
433
  startFrom?: ProcessTurnStartSelection;
434
+ /** @internal */
312
435
  restorePrimaryLeafAfterTurn?: boolean;
436
+ /** @public */
313
437
  prompt(ctx: ProcessRuntimeTurnContext<TParams, TState>): string | Promise<string>;
438
+ /** @public */
314
439
  outcomes?: Partial<Record<TOutcome, ProcessToolOutcomeSpec<TParams, TState>>>;
440
+ /** @public */
315
441
  turnEnd?: ProcessTurnEndSpec<TParams, TState, TOutcome>;
442
+ /** @public */
316
443
  turnResultMarkdown?: TurnResultMarkdownBehavior;
444
+ /** @internal */
317
445
  reviewSemanticRef?: ProcessSemanticEntryRefKey;
446
+ /** @internal */
318
447
  resultSemanticRef?: ProcessSemanticEntryRefKey;
448
+ /** @internal */
319
449
  publishedProduct?: string;
450
+ /** @internal */
320
451
  consumedProducts?: readonly string[];
452
+ /** @internal */
321
453
  optionalConsumedProducts?: readonly string[];
454
+ /** @internal */
322
455
  requiredSemanticMarkdownRefs?: readonly ProcessSemanticEntryRefKey[];
456
+ /** @internal */
323
457
  optionalSemanticMarkdownRefs?: readonly ProcessSemanticEntryRefKey[];
324
458
  }
325
459
 
460
+ /** @public */
326
461
  export interface AutomaticTurnDefinition<
327
462
  TOutcome extends string = string,
328
463
  TParams = unknown,
329
464
  TState = unknown,
330
465
  > {
466
+ /** @public */
331
467
  kind: "automatic";
468
+ /** @public */
332
469
  description: string;
333
- /** Server-owned integration tools callable by this deterministic worker turn. */
470
+ /** Server-owned integration tools callable by this deterministic worker turn. @internal */
334
471
  integrationTools?: readonly string[];
335
- /** External events armed while this automatic turn is selected and waiting. */
472
+ /** External events armed while this automatic turn is selected and waiting. @public */
336
473
  externalActions?: Record<string, ProcessHumanTurnExternalActionSpec<TParams, TState>>;
474
+ /** @internal */
337
475
  outcomes?: Partial<Record<TOutcome, ProcessToolOutcomeSpec<TParams, TState>>>;
476
+ /** @internal */
338
477
  turnEnd?: ProcessTurnEndSpec<TParams, TState, TOutcome>;
478
+ /** @internal */
339
479
  reviewSemanticRef?: ProcessSemanticEntryRefKey;
480
+ /** @public */
340
481
  run(
341
482
  ctx: ProcessRuntimeTurnContext<TParams, TState>,
342
483
  ): Promise<WorkerCompleteInput<TOutcome>> | WorkerCompleteInput<TOutcome>;
343
484
  }
344
485
 
486
+ /** @internal */
345
487
  export interface ExternalSourceTransition<
346
488
  TParams = unknown,
347
489
  TState = unknown,
348
490
  TEvent = unknown,
349
491
  TInput extends Record<string, unknown> = Record<string, unknown>,
350
492
  > extends StaticRouteTarget {
493
+ /** @internal */
351
494
  source: ExternalActionSource<TParams, TState, TEvent, TInput>;
495
+ /** @internal */
352
496
  effect?: ExternalSourceEffect<TParams, TState, TEvent, TInput>;
353
497
  }
354
498
 
499
+ /** @public */
355
500
  export interface ExternalTurnDefinition<TParams = unknown, TState = unknown> {
501
+ /** @public */
356
502
  kind: "external";
503
+ /** @public */
357
504
  description: string;
505
+ /** @internal */
358
506
  transitions: readonly ExternalSourceTransition<TParams, TState>[];
507
+ /** @internal */
359
508
  reviewSemanticRef?: ProcessSemanticEntryRefKey;
360
509
  }
361
510
 
511
+ /** @public */
362
512
  export type TurnDefinition<TParams = unknown, TState = unknown> =
363
513
  | LlmTurnDefinition<string, TParams, TState>
364
514
  | AutomaticTurnDefinition<string, TParams, TState>
365
515
  | HumanTurnDefinition<TParams, TState>
366
516
  | ExternalTurnDefinition<TParams, TState>;
367
517
 
518
+ /** @public */
368
519
  export type TurnDefinitionRecord<TParams = unknown, TState = unknown> = Record<
369
520
  TurnId,
370
521
  TurnDefinition<TParams, TState>
371
522
  >;
372
523
 
373
- export type ProcessDefinition<TParams = unknown, TState = unknown> = ExtensionProcessDefinition<
374
- TParams,
375
- TState
376
- >;
377
-
524
+ /** @public */
378
525
  export interface DefinedProcessInput<TParams = unknown, TState = unknown>
379
526
  extends Omit<
380
527
  ExtensionProcessDefinition<TParams, TState>,
381
528
  "entryTurnId" | "alternateEntryTurnIds" | "turns"
382
529
  > {
383
- /** Primary entry used when a launch does not select a start turn explicitly. */
530
+ /** Primary entry used when a launch does not select a start turn explicitly. @public */
384
531
  entry: TurnId;
385
- /** Additional entry turns that launchers may select explicitly. */
532
+ /** Additional entry turns that launchers may select explicitly. @public */
386
533
  alternateEntries?: readonly TurnId[];
534
+ /** @public */
387
535
  turns: TurnDefinitionRecord<TParams, TState>;
388
536
  }
389
537
 
@@ -582,22 +730,33 @@ function resolveActionRouting<TParams, TState>(input: {
582
730
  };
583
731
  }
584
732
 
733
+ /** @internal */
585
734
  export function getExternalSourceTransitionId(input: {
735
+ /** @internal */
586
736
  turnId: TurnId;
737
+ /** @internal */
587
738
  source: ExternalActionSource;
739
+ /** @internal */
588
740
  index: number;
589
741
  }): string {
590
742
  return `${input.turnId}:${input.source.kind}:${input.index}`;
591
743
  }
592
744
 
745
+ /** @internal */
593
746
  export function getExternalActionArmingId(input: {
747
+ /** @internal */
594
748
  turnId: TurnId;
749
+ /** @internal */
595
750
  externalActionId: string;
596
751
  }): string {
597
752
  return `${input.turnId}:${input.externalActionId}`;
598
753
  }
599
754
 
600
- export function getExternalActionTransitionTrigger(input: { externalActionId: string }): string {
755
+ /** @internal */
756
+ export function getExternalActionTransitionTrigger(input: {
757
+ /** @internal */
758
+ externalActionId: string;
759
+ }): string {
601
760
  return `external:${input.externalActionId}`;
602
761
  }
603
762
 
@@ -1312,12 +1471,18 @@ function deriveHumanTurnActions<TParams, TState>(input: {
1312
1471
  };
1313
1472
  }
1314
1473
 
1474
+ /** @internal */
1315
1475
  export function resolveHumanTurnView<TParams, TState>(input: {
1476
+ /** @internal */
1316
1477
  turnId: TurnId;
1478
+ /** @internal */
1317
1479
  turn: HumanTurnDefinition<TParams, TState>;
1318
1480
  }): {
1481
+ /** @internal */
1319
1482
  actions: readonly HumanTurnActionView[];
1483
+ /** @internal */
1320
1484
  externalTriggers: readonly HumanTurnExternalTrigger[];
1485
+ /** @internal */
1321
1486
  externalActions: readonly HumanTurnExternalActionView[];
1322
1487
  } {
1323
1488
  const derived = deriveHumanTurnActions({
@@ -1715,9 +1880,10 @@ function buildDefinedProcess<TParams, TState>(
1715
1880
  };
1716
1881
  }
1717
1882
 
1883
+ /** @public */
1718
1884
  export function defineProcess<TParams = unknown, TState = unknown>(
1719
1885
  input: DefinedProcessInput<TParams, TState>,
1720
- ): ProcessDefinition<TParams, TState> {
1886
+ ): ExtensionProcessDefinition<TParams, TState> {
1721
1887
  const compiled = buildDefinedProcess(input);
1722
1888
  const process = {
1723
1889
  id: input.id,
@@ -1743,18 +1909,23 @@ export function defineProcess<TParams = unknown, TState = unknown>(
1743
1909
  return process;
1744
1910
  }
1745
1911
 
1912
+ /** @internal */
1746
1913
  type RoutableTurnDefinition<TOutcome extends string, TParams, TState> =
1747
1914
  | LlmTurnDefinition<TOutcome, TParams, TState>
1748
1915
  | AutomaticTurnDefinition<TOutcome, TParams, TState>;
1749
1916
 
1750
1917
  // biome-ignore-start lint/suspicious/noExplicitAny: conditional helper types must match and preserve any routable turn instantiation
1918
+ /** @internal */
1751
1919
  type RoutableOutcome<TTurn> =
1752
1920
  TTurn extends RoutableTurnDefinition<infer TOutcome, any, any> ? TOutcome : never;
1921
+ /** @internal */
1753
1922
  type RoutableParams<TTurn> =
1754
1923
  TTurn extends RoutableTurnDefinition<any, infer TParams, any> ? TParams : never;
1924
+ /** @internal */
1755
1925
  type RoutableState<TTurn> =
1756
1926
  TTurn extends RoutableTurnDefinition<any, any, infer TState> ? TState : never;
1757
1927
 
1928
+ /** @internal */
1758
1929
  export function routeTurnOutcomes<TTurn extends RoutableTurnDefinition<string, any, any>>(
1759
1930
  baseTurn: TTurn,
1760
1931
  routes: Partial<
@@ -1794,6 +1965,7 @@ export function routeTurnOutcomes<TTurn extends RoutableTurnDefinition<string, a
1794
1965
  }
1795
1966
  // biome-ignore-end lint/suspicious/noExplicitAny: end routable turn instantiation helper suppression
1796
1967
 
1968
+ /** @public */
1797
1969
  export function llmTurn<TParams = unknown, TState = unknown, TOutcome extends string = string>(
1798
1970
  input: Omit<LlmTurnDefinition<TOutcome, TParams, TState>, "kind">,
1799
1971
  ): LlmTurnDefinition<TOutcome, TParams, TState> {
@@ -1803,6 +1975,7 @@ export function llmTurn<TParams = unknown, TState = unknown, TOutcome extends st
1803
1975
  };
1804
1976
  }
1805
1977
 
1978
+ /** @internal */
1806
1979
  export function automaticTurn<
1807
1980
  TParams = unknown,
1808
1981
  TState = unknown,
@@ -1816,6 +1989,7 @@ export function automaticTurn<
1816
1989
  };
1817
1990
  }
1818
1991
 
1992
+ /** @public */
1819
1993
  export function humanTurn<TParams = unknown, TState = unknown>(
1820
1994
  input: Omit<HumanTurnDefinition<TParams, TState>, "kind">,
1821
1995
  ): HumanTurnDefinition<TParams, TState> {
@@ -1825,6 +1999,7 @@ export function humanTurn<TParams = unknown, TState = unknown>(
1825
1999
  };
1826
2000
  }
1827
2001
 
2002
+ /** @internal */
1828
2003
  export function externalTurn<TParams = unknown, TState = unknown>(
1829
2004
  input: Omit<ExternalTurnDefinition<TParams, TState>, "kind">,
1830
2005
  ): ExternalTurnDefinition<TParams, TState> {
package/src/event-bus.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { EventBus } from "./types.js";
2
2
 
3
+ /** @internal */
3
4
  export function createEventBus<
4
5
  TEventMap extends object = Record<string, unknown>,
5
6
  >(): EventBus<TEventMap> {