@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
package/dist/index.js CHANGED
@@ -1,19 +1,7 @@
1
1
  import {
2
- FRAMEWORK_LLM_TOOL_NAMES,
3
- PI_BUILT_IN_TOOL_NAMES,
4
2
  RESERVED_INTEGRATION_TOOL_NAMES,
5
- TURN_COMPLETION_MODES,
6
- TURN_CONTEXT_MODES,
7
- collectProcessAvailableToolNames,
8
- resolveTurnAvailableToolNames,
9
3
  validatePiBuiltInToolArray
10
- } from "./chunk-TA4KO53Q.js";
11
- import {
12
- buildPlanSavedEventPayload,
13
- buildReviewCompletedEventPayload,
14
- buildReviewRequestedEventPayload,
15
- filterStringArray
16
- } from "./chunk-LIIP7FMU.js";
4
+ } from "./chunk-I7U6HCLN.js";
17
5
  import {
18
6
  cloneArrayValueMap,
19
7
  cloneMap,
@@ -21,7 +9,7 @@ import {
21
9
  markDefinedProcess,
22
10
  registerUnique,
23
11
  setProcessTurnTransitions
24
- } from "./chunk-WFY2WWZE.js";
12
+ } from "./chunk-TM2LTSW4.js";
25
13
 
26
14
  // src/capabilities.ts
27
15
  function createCapabilityToken(id, options = {}) {
@@ -47,7 +35,9 @@ var BUILT_IN_COMMIT_MESSAGE_RULES = "Write a concise imperative subject that sum
47
35
 
48
36
  // src/core-capabilities.ts
49
37
  var coreHostCapabilities = {
38
+ /** @public */
50
39
  serverSetup: createCapabilityToken("core:serverSetup"),
40
+ /** @internal */
51
41
  processModelSelection: createCapabilityToken(
52
42
  "core:processModelSelection"
53
43
  )
@@ -1131,12 +1121,6 @@ function humanTurn(input) {
1131
1121
  kind: "human"
1132
1122
  };
1133
1123
  }
1134
- function externalTurn(input) {
1135
- return {
1136
- ...input,
1137
- kind: "external"
1138
- };
1139
- }
1140
1124
 
1141
1125
  // src/event-bus.ts
1142
1126
  function createEventBus() {
@@ -1169,6 +1153,7 @@ function createEventBus() {
1169
1153
 
1170
1154
  // src/extension-api.ts
1171
1155
  var SafeLaunchPreparationError = class extends Error {
1156
+ /** @public */
1172
1157
  constructor(message, safeSummary) {
1173
1158
  super(message);
1174
1159
  this.safeSummary = safeSummary;
@@ -1190,6 +1175,7 @@ function defineExternalActionSource(metadata) {
1190
1175
  // src/external-source-poll.ts
1191
1176
  function createExternalSourcePollReporter(sources, result, options = {}) {
1192
1177
  return {
1178
+ /** @internal */
1193
1179
  async poll(kind, read) {
1194
1180
  for (const armed of sources.listArmed(kind)) {
1195
1181
  try {
@@ -1201,6 +1187,7 @@ function createExternalSourcePollReporter(sources, result, options = {}) {
1201
1187
  }
1202
1188
  }
1203
1189
  },
1190
+ /** @internal */
1204
1191
  async fire(armed, event, mergeKey) {
1205
1192
  const fired = await sources.fire({
1206
1193
  instanceId: armed.instanceId,
@@ -1213,6 +1200,7 @@ function createExternalSourcePollReporter(sources, result, options = {}) {
1213
1200
  else result.errors.push(`${armed.id}:fire_failed`);
1214
1201
  return fired.ok;
1215
1202
  },
1203
+ /** @internal */
1216
1204
  observe(armed, input) {
1217
1205
  if (sources.observe && armed.generation)
1218
1206
  return sources.observe({
@@ -1332,18 +1320,12 @@ function getProcessGraph(registry, processId) {
1332
1320
  }
1333
1321
  return toProcessGraphView(definition);
1334
1322
  }
1335
- function getAllProcessGraphs(registry) {
1336
- return [...registry.values()].map((definition) => toProcessGraphView(definition));
1337
- }
1338
1323
  function getProcessTurnGraph(registry, processId, turnId) {
1339
1324
  return getProcessGraph(registry, processId).turns.get(turnId);
1340
1325
  }
1341
1326
  function getTurnTransitionsForProcessGraph(registry, processId, turnId) {
1342
1327
  return getProcessTurnGraph(registry, processId, turnId)?.transitions ?? [];
1343
1328
  }
1344
- function getReachableTurnIdsForProcessGraph(registry, processId) {
1345
- return [...getProcessGraph(registry, processId).turns.keys()];
1346
- }
1347
1329
  function isTurnAvailableForProcessGraph(registry, processId, turnId) {
1348
1330
  return getProcessGraph(registry, processId).turns.has(turnId);
1349
1331
  }
@@ -1438,7 +1420,6 @@ function validateProcessGraphTurnTransitions(graph) {
1438
1420
 
1439
1421
  // src/flow.ts
1440
1422
  var DEFAULT_PLAN_RESULT_OUTCOME_ID = "plan_saved";
1441
- var DEFAULT_FLOW_PRODUCT_NAME = "default";
1442
1423
  var ASSISTANT_OUTPUT_TURN_RESULT = { mode: "assistant_output", required: true };
1443
1424
  var OUTCOME_TOOL_MARKDOWN_PARAMETER_NAME = "markdown";
1444
1425
  var OUTCOME_TOOL_ARGUMENT_TURN_RESULT = {
@@ -1632,8 +1613,11 @@ function wrapOutcomeCallback(callback) {
1632
1613
  });
1633
1614
  }
1634
1615
  var RouteAndEffectBuilder = class {
1616
+ /** @internal */
1635
1617
  target = null;
1618
+ /** @internal */
1636
1619
  flowEffect;
1620
+ /** @internal */
1637
1621
  setTarget(next) {
1638
1622
  if (this.target && next) {
1639
1623
  throw new Error("Flow route already declares a target");
@@ -1641,30 +1625,38 @@ var RouteAndEffectBuilder = class {
1641
1625
  this.target = next;
1642
1626
  return this;
1643
1627
  }
1628
+ /** @public */
1644
1629
  to(turnId) {
1645
1630
  return this.setTarget({ kind: "to", turnId });
1646
1631
  }
1632
+ /** @public */
1647
1633
  complete() {
1648
1634
  return this.setTarget({ kind: "complete" });
1649
1635
  }
1636
+ /** @public */
1650
1637
  lifecycleStatus(status) {
1651
1638
  return this.setTarget({ kind: "lifecycleStatus", status });
1652
1639
  }
1640
+ /** @internal */
1653
1641
  stay() {
1654
1642
  this.target = null;
1655
1643
  return this;
1656
1644
  }
1645
+ /** @public */
1657
1646
  state(fn) {
1658
1647
  this.flowEffect = async (input) => ({ state: await fn(input) });
1659
1648
  return this;
1660
1649
  }
1650
+ /** @public */
1661
1651
  effect(fn) {
1662
1652
  this.flowEffect = fn;
1663
1653
  return this;
1664
1654
  }
1655
+ /** @internal */
1665
1656
  hasRoute() {
1666
1657
  return this.target !== null;
1667
1658
  }
1659
+ /** @internal */
1668
1660
  buildRouteTarget() {
1669
1661
  return buildRouteTargetSpec(this.target);
1670
1662
  }
@@ -1685,11 +1677,15 @@ function isStringArray(value) {
1685
1677
  return Array.isArray(value) && value.every((entry) => typeof entry === "string");
1686
1678
  }
1687
1679
  var ParameterizedOutcomeBuilder = class extends RouteAndEffectBuilder {
1680
+ /** @internal */
1688
1681
  outcomeDescription = null;
1682
+ /** @internal */
1689
1683
  parameters = {};
1684
+ /** @internal */
1690
1685
  publishedMarkdownParameter = null;
1686
+ /** @internal */
1691
1687
  summaryParameter = null;
1692
- /** Optional concise result publication, separate from the full Markdown. */
1688
+ /** Optional concise result publication, separate from the full Markdown. @public */
1693
1689
  resultSummary(name = "resultSummary") {
1694
1690
  this.summaryParameter = name;
1695
1691
  return this.parameter(name, {
@@ -1697,16 +1693,21 @@ var ParameterizedOutcomeBuilder = class extends RouteAndEffectBuilder {
1697
1693
  description: "Concise summary of this attempt\u2019s outcome."
1698
1694
  });
1699
1695
  }
1696
+ /** @internal */
1700
1697
  publishedMarkdownFields() {
1701
1698
  return this.publishedMarkdownParameter ? {
1699
+ /** @internal */
1702
1700
  publishedProduct: this.publishedMarkdownParameter,
1701
+ /** @internal */
1703
1702
  turnResultMarkdownParameter: this.publishedMarkdownParameter
1704
1703
  } : {};
1705
1704
  }
1705
+ /** @public */
1706
1706
  description(text) {
1707
1707
  this.outcomeDescription = text;
1708
1708
  return this;
1709
1709
  }
1710
+ /** @internal */
1710
1711
  parameter(name, spec) {
1711
1712
  if (name.trim() === "") {
1712
1713
  throw new Error("Outcome parameter name must be non-empty");
@@ -1734,9 +1735,11 @@ var ParameterizedOutcomeBuilder = class extends RouteAndEffectBuilder {
1734
1735
  ...type === "array" ? { items: resolved.items ?? { type: "string" } } : {}
1735
1736
  });
1736
1737
  }
1738
+ /** @internal */
1737
1739
  string(name, options = {}) {
1738
1740
  return this.typedParameter(name, "string", options);
1739
1741
  }
1742
+ /** @public */
1740
1743
  markdown(name, options = {}) {
1741
1744
  const resolved = typeof options === "string" ? { description: options } : options;
1742
1745
  const { publish, ...parameterOptions } = resolved;
@@ -1753,27 +1756,35 @@ var ParameterizedOutcomeBuilder = class extends RouteAndEffectBuilder {
1753
1756
  requiredErrorCode: resolved.requiredErrorCode ?? (publish ? `${name}_required` : void 0)
1754
1757
  });
1755
1758
  }
1759
+ /** @public */
1756
1760
  requiredString(name, options = {}) {
1757
1761
  return this.typedParameter(name, "string", this.withRequired(name, options));
1758
1762
  }
1763
+ /** @internal */
1759
1764
  number(name, options = {}) {
1760
1765
  return this.typedParameter(name, "number", options);
1761
1766
  }
1767
+ /** @internal */
1762
1768
  requiredNumber(name, options = {}) {
1763
1769
  return this.typedParameter(name, "number", this.withRequired(name, options));
1764
1770
  }
1771
+ /** @internal */
1765
1772
  boolean(name, options = {}) {
1766
1773
  return this.typedParameter(name, "boolean", options);
1767
1774
  }
1775
+ /** @internal */
1768
1776
  requiredBoolean(name, options = {}) {
1769
1777
  return this.typedParameter(name, "boolean", this.withRequired(name, options));
1770
1778
  }
1779
+ /** @internal */
1771
1780
  stringArray(name, options = {}) {
1772
1781
  return this.typedParameter(name, "array", options);
1773
1782
  }
1783
+ /** @internal */
1774
1784
  requiredStringArray(name, options = {}) {
1775
1785
  return this.typedParameter(name, "array", this.withRequired(name, options));
1776
1786
  }
1787
+ /** @internal */
1777
1788
  enum(name, valuesOrOptions) {
1778
1789
  const resolved = isStringArray(valuesOrOptions) ? { values: [...valuesOrOptions] } : valuesOrOptions;
1779
1790
  const { values = [], ...options } = resolved;
@@ -1784,15 +1795,18 @@ var ParameterizedOutcomeBuilder = class extends RouteAndEffectBuilder {
1784
1795
  enum: [...values]
1785
1796
  });
1786
1797
  }
1798
+ /** @public */
1787
1799
  object(name, options = {}) {
1788
1800
  return this.typedParameter(name, "object", options);
1789
1801
  }
1802
+ /** @internal */
1790
1803
  array(name, options = {}) {
1791
1804
  return this.typedParameter(name, "array", options);
1792
1805
  }
1793
1806
  };
1794
1807
  var OutcomeToolBuilder = class extends ParameterizedOutcomeBuilder {
1795
1808
  stateRouting;
1809
+ /** @public */
1796
1810
  routeByState(branches, choose) {
1797
1811
  if (this.hasRoute() || this.stateRouting) {
1798
1812
  throw new Error("State-routed outcome cannot declare another route");
@@ -1803,6 +1817,7 @@ var OutcomeToolBuilder = class extends ParameterizedOutcomeBuilder {
1803
1817
  this.stateRouting = { branches, choose };
1804
1818
  return this;
1805
1819
  }
1820
+ /** @internal */
1806
1821
  build() {
1807
1822
  if (!this.outcomeDescription) {
1808
1823
  throw new Error("LLM outcome tool must declare .description(...)");
@@ -1831,11 +1846,13 @@ var OutcomeToolBuilder = class extends ParameterizedOutcomeBuilder {
1831
1846
  };
1832
1847
  var AutomaticOutcomeBuilder = class extends ParameterizedOutcomeBuilder {
1833
1848
  waits = false;
1849
+ /** @public */
1834
1850
  wait() {
1835
1851
  if (this.hasRoute()) throw new Error("Waiting outcome cannot declare another route");
1836
1852
  this.waits = true;
1837
1853
  return this;
1838
1854
  }
1855
+ /** @internal */
1839
1856
  build() {
1840
1857
  if (!this.outcomeDescription) {
1841
1858
  throw new Error("Automatic outcome must declare .description(...)");
@@ -1863,10 +1880,12 @@ var PlanResultBuilder = class extends RouteAndEffectBuilder {
1863
1880
  summarySpec = null;
1864
1881
  acceptanceCriteriaSpec = null;
1865
1882
  reviewTurnId = null;
1883
+ /** @internal */
1866
1884
  description(text) {
1867
1885
  this.resultDescription = text;
1868
1886
  return this;
1869
1887
  }
1888
+ /** @internal */
1870
1889
  summary(options = {}) {
1871
1890
  const resolved = typeof options === "string" ? { description: options } : options;
1872
1891
  this.summarySpec = textField({
@@ -1875,6 +1894,7 @@ var PlanResultBuilder = class extends RouteAndEffectBuilder {
1875
1894
  });
1876
1895
  return this;
1877
1896
  }
1897
+ /** @internal */
1878
1898
  acceptanceCriteria(options = {}) {
1879
1899
  const resolved = typeof options === "string" ? { description: options } : options;
1880
1900
  this.acceptanceCriteriaSpec = stringArrayField({
@@ -1885,10 +1905,12 @@ var PlanResultBuilder = class extends RouteAndEffectBuilder {
1885
1905
  });
1886
1906
  return this;
1887
1907
  }
1908
+ /** @internal */
1888
1909
  review(turnId) {
1889
1910
  this.reviewTurnId = turnId;
1890
1911
  return this.setTarget({ kind: "to", turnId });
1891
1912
  }
1913
+ /** @internal */
1892
1914
  buildOutcome() {
1893
1915
  if (!this.summarySpec) {
1894
1916
  throw new Error("plan result must declare .summary(...)");
@@ -1920,6 +1942,7 @@ var PlanResultBuilder = class extends RouteAndEffectBuilder {
1920
1942
  }
1921
1943
  };
1922
1944
  var TurnEndBuilder = class extends RouteAndEffectBuilder {
1945
+ /** @internal */
1923
1946
  constructor(outcomeId, parent) {
1924
1947
  super();
1925
1948
  this.outcomeId = outcomeId;
@@ -1931,12 +1954,15 @@ var TurnEndBuilder = class extends RouteAndEffectBuilder {
1931
1954
  if (!this.parent) throw new Error(`${this.builderName} builder is not attached to a turn`);
1932
1955
  return this.parent;
1933
1956
  }
1957
+ /** @internal */
1934
1958
  get id() {
1935
1959
  return this.turn.id;
1936
1960
  }
1961
+ /** @internal */
1937
1962
  get definition() {
1938
1963
  return this.turn.definition;
1939
1964
  }
1965
+ /** @internal */
1940
1966
  buildResult() {
1941
1967
  const effect = this.flowEffect ? wrapOutcomeCallback(this.flowEffect) : void 0;
1942
1968
  return {
@@ -1947,30 +1973,39 @@ var TurnEndBuilder = class extends RouteAndEffectBuilder {
1947
1973
  }
1948
1974
  };
1949
1975
  var PublishedResultBuilder = class extends TurnEndBuilder {
1976
+ /** @internal */
1950
1977
  builderName = "Published result";
1978
+ /** @internal */
1951
1979
  buildTurnEnd() {
1952
1980
  return this.buildResult();
1953
1981
  }
1954
1982
  };
1955
1983
  var LlmTurnEndBuilder = class extends TurnEndBuilder {
1984
+ /** @internal */
1956
1985
  builderName = "LLM turn end";
1986
+ /** @internal */
1957
1987
  constructor(outcomeId, parent) {
1958
1988
  super(outcomeId, parent);
1959
1989
  if (outcomeId.trim() === "") throw new Error("LLM turn end outcome must be non-empty");
1960
1990
  }
1991
+ /** @internal */
1961
1992
  build() {
1962
1993
  return this.buildResult();
1963
1994
  }
1964
1995
  };
1965
1996
  var DescribedTurnBuilder = class {
1997
+ /** @internal */
1966
1998
  constructor(turnId) {
1967
1999
  this.turnId = turnId;
1968
2000
  }
1969
2001
  turnId;
2002
+ /** @internal */
1970
2003
  turnDescription = null;
2004
+ /** @internal */
1971
2005
  get id() {
1972
2006
  return this.turnId;
1973
2007
  }
2008
+ /** @public */
1974
2009
  description(description) {
1975
2010
  this.turnDescription = description;
1976
2011
  return this;
@@ -1993,34 +2028,41 @@ var LlmFlowBuilder = class extends DescribedTurnBuilder {
1993
2028
  publishedResult = null;
1994
2029
  endResult = null;
1995
2030
  outcomeToolBuilders = /* @__PURE__ */ new Map();
2031
+ /** @internal */
1996
2032
  get definition() {
1997
2033
  return this.buildDefinition();
1998
2034
  }
2035
+ /** @internal */
1999
2036
  modelPurpose(purpose) {
2000
2037
  this.modelPurposeValue = purpose;
2001
2038
  return this;
2002
2039
  }
2040
+ /** @public */
2003
2041
  tools(...tools) {
2004
2042
  this.availableTools = tools;
2005
2043
  return this;
2006
2044
  }
2045
+ /** @public */
2007
2046
  integrationTools(...tools) {
2008
2047
  this.availableIntegrationTools = tools.map((tool) => tool.trim());
2009
2048
  return this;
2010
2049
  }
2050
+ /** @public */
2011
2051
  resolveIntegrationTools(resolver) {
2012
2052
  this.integrationToolResolver = resolver;
2013
2053
  return this;
2014
2054
  }
2055
+ /** @public */
2015
2056
  prepare(fn) {
2016
2057
  this.preparation = fn;
2017
2058
  return this;
2018
2059
  }
2019
- /** Enable durable operator questions for this LLM turn. */
2060
+ /** Enable durable operator questions for this LLM turn. @public */
2020
2061
  askQuestions() {
2021
2062
  this.questionsEnabled = true;
2022
2063
  return this;
2023
2064
  }
2065
+ /** @public */
2024
2066
  freshPrimary() {
2025
2067
  this.branchType = "primary";
2026
2068
  this.context = "fresh";
@@ -2028,6 +2070,7 @@ var LlmFlowBuilder = class extends DescribedTurnBuilder {
2028
2070
  this.restorePrimaryLeafAfterTurn = void 0;
2029
2071
  return this;
2030
2072
  }
2073
+ /** @internal */
2031
2074
  freshSeededPrimary() {
2032
2075
  this.branchType = "primary";
2033
2076
  this.context = "fresh_seeded";
@@ -2035,17 +2078,20 @@ var LlmFlowBuilder = class extends DescribedTurnBuilder {
2035
2078
  this.restorePrimaryLeafAfterTurn = void 0;
2036
2079
  return this;
2037
2080
  }
2081
+ /** @public */
2038
2082
  fullPrimary() {
2039
2083
  this.branchType = "primary";
2040
2084
  this.context = "full";
2041
2085
  return this;
2042
2086
  }
2087
+ /** @internal */
2043
2088
  rootBranchReview() {
2044
2089
  this.branchType = "root_branch";
2045
2090
  this.context = "full";
2046
2091
  this.restorePrimaryLeafAfterTurn = true;
2047
2092
  return this;
2048
2093
  }
2094
+ /** @public */
2049
2095
  continueFromPrimaryLeaf() {
2050
2096
  this.startFrom = {
2051
2097
  kind: "semantic_ref",
@@ -2054,6 +2100,7 @@ var LlmFlowBuilder = class extends DescribedTurnBuilder {
2054
2100
  };
2055
2101
  return this;
2056
2102
  }
2103
+ /** @internal */
2057
2104
  continueFromReviewBranch() {
2058
2105
  this.startFrom = {
2059
2106
  kind: "semantic_ref",
@@ -2062,9 +2109,11 @@ var LlmFlowBuilder = class extends DescribedTurnBuilder {
2062
2109
  };
2063
2110
  return this;
2064
2111
  }
2112
+ /** @internal */
2065
2113
  continueFromProductBranch(productName, fallback = { kind: "current_leaf" }) {
2066
2114
  return this.startFromProductBranch(productName, fallback);
2067
2115
  }
2116
+ /** @internal */
2068
2117
  startFromReviewBranch() {
2069
2118
  this.startFrom = {
2070
2119
  kind: "semantic_ref",
@@ -2073,6 +2122,7 @@ var LlmFlowBuilder = class extends DescribedTurnBuilder {
2073
2122
  };
2074
2123
  return this;
2075
2124
  }
2125
+ /** @internal */
2076
2126
  startFromProductBranch(productName, fallback = { kind: "session_root" }) {
2077
2127
  this.startFrom = {
2078
2128
  kind: "product_ref",
@@ -2081,18 +2131,22 @@ var LlmFlowBuilder = class extends DescribedTurnBuilder {
2081
2131
  };
2082
2132
  return this;
2083
2133
  }
2134
+ /** @internal */
2084
2135
  startFromRoot() {
2085
2136
  this.startFrom = { kind: "session_root" };
2086
2137
  return this;
2087
2138
  }
2139
+ /** @public */
2088
2140
  consume(productName) {
2089
2141
  this.consumedProductNames.add(normalizeProductName(productName));
2090
2142
  return this;
2091
2143
  }
2144
+ /** @public */
2092
2145
  optionalConsume(productName) {
2093
2146
  this.optionalConsumedProductNames.add(normalizeProductName(productName));
2094
2147
  return this;
2095
2148
  }
2149
+ /** @public */
2096
2150
  publish(productName) {
2097
2151
  const normalized = normalizeProductName(productName);
2098
2152
  if (this.publishedResult) {
@@ -2105,6 +2159,7 @@ var LlmFlowBuilder = class extends DescribedTurnBuilder {
2105
2159
  this.publishedResult = { productName: normalized, builder };
2106
2160
  return builder;
2107
2161
  }
2162
+ /** @public */
2108
2163
  end(outcomeId) {
2109
2164
  if (this.endResult) {
2110
2165
  throw new Error(`LLM turn '${this.turnId}' declares duplicate .end(...) completion`);
@@ -2118,6 +2173,7 @@ var LlmFlowBuilder = class extends DescribedTurnBuilder {
2118
2173
  this.endResult = new LlmTurnEndBuilder(outcomeId, this);
2119
2174
  return this.endResult;
2120
2175
  }
2176
+ /** @public */
2121
2177
  buildPrompt(fn) {
2122
2178
  this.promptBuilder = (ctx) => fn(
2123
2179
  createFlowPromptContext(ctx, [...this.consumedProductNames], [
@@ -2126,10 +2182,12 @@ var LlmFlowBuilder = class extends DescribedTurnBuilder {
2126
2182
  );
2127
2183
  return this;
2128
2184
  }
2185
+ /** @public */
2129
2186
  prompt(prompt) {
2130
2187
  this.promptBuilder = prompt;
2131
2188
  return this;
2132
2189
  }
2190
+ /** @public */
2133
2191
  outcomeTool(id, configure) {
2134
2192
  if (id.trim() === "") {
2135
2193
  throw new Error(`LLM turn '${this.turnId}' declares an empty outcome tool id`);
@@ -2176,6 +2234,7 @@ var LlmFlowBuilder = class extends DescribedTurnBuilder {
2176
2234
  prompt
2177
2235
  };
2178
2236
  }
2237
+ /** @internal */
2179
2238
  producesPlan(configure) {
2180
2239
  const definition = this.buildBaseDefinition();
2181
2240
  const plan = configure(new PlanResultBuilder());
@@ -2273,6 +2332,7 @@ var LlmFlowBuilder = class extends DescribedTurnBuilder {
2273
2332
  };
2274
2333
  var ExternalActionTurnBuilder = class extends DescribedTurnBuilder {
2275
2334
  externalActionBuilders = /* @__PURE__ */ new Map();
2335
+ /** @public */
2276
2336
  externalAction(externalActionId, source, configure) {
2277
2337
  if (this.externalActionBuilders.has(externalActionId)) {
2278
2338
  throw new Error(
@@ -2287,6 +2347,7 @@ var ExternalActionTurnBuilder = class extends DescribedTurnBuilder {
2287
2347
  );
2288
2348
  return this;
2289
2349
  }
2350
+ /** @internal */
2290
2351
  buildExternalActions() {
2291
2352
  return this.externalActionBuilders.size > 0 ? Object.fromEntries(
2292
2353
  [...this.externalActionBuilders].map(([id, builder]) => [id, builder.build()])
@@ -2294,21 +2355,26 @@ var ExternalActionTurnBuilder = class extends DescribedTurnBuilder {
2294
2355
  }
2295
2356
  };
2296
2357
  var AutomaticFlowBuilder = class extends ExternalActionTurnBuilder {
2358
+ /** @internal */
2297
2359
  turnKind = "Automatic";
2298
2360
  runFn = null;
2299
2361
  outcomeBuilders = /* @__PURE__ */ new Map();
2300
2362
  availableIntegrationTools = [];
2363
+ /** @internal */
2301
2364
  get definition() {
2302
2365
  return this.buildDefinition();
2303
2366
  }
2367
+ /** @public */
2304
2368
  run(fn) {
2305
2369
  this.runFn = fn;
2306
2370
  return this;
2307
2371
  }
2372
+ /** @public */
2308
2373
  integrationTools(...tools) {
2309
2374
  this.availableIntegrationTools = tools.map((tool) => tool.trim());
2310
2375
  return this;
2311
2376
  }
2377
+ /** @public */
2312
2378
  outcome(id, configure) {
2313
2379
  if (id.trim() === "") {
2314
2380
  throw new Error(`Automatic turn '${this.turnId}' declares an empty outcome id`);
@@ -2358,51 +2424,63 @@ function inferAcceptanceState(actionId) {
2358
2424
  return "neutral";
2359
2425
  }
2360
2426
  var HumanActionBuilder = class {
2427
+ /** @internal */
2361
2428
  constructor(actionId) {
2362
2429
  this.actionId = actionId;
2363
2430
  }
2364
2431
  actionId;
2365
2432
  spec = {};
2433
+ /** @public */
2366
2434
  label(label) {
2367
2435
  this.spec.label = label;
2368
2436
  return this;
2369
2437
  }
2438
+ /** @internal */
2370
2439
  description(description) {
2371
2440
  this.spec.description = description;
2372
2441
  return this;
2373
2442
  }
2443
+ /** @public */
2374
2444
  acceptanceState(state) {
2375
2445
  this.spec.acceptanceState = state;
2376
2446
  return this;
2377
2447
  }
2448
+ /** @public */
2378
2449
  form(form) {
2379
2450
  this.spec.form = form;
2380
2451
  return this;
2381
2452
  }
2453
+ /** @public */
2382
2454
  to(turnId) {
2383
2455
  this.spec.to = turnId;
2384
2456
  return this;
2385
2457
  }
2458
+ /** @internal */
2386
2459
  complete() {
2387
2460
  this.spec.complete = true;
2388
2461
  return this;
2389
2462
  }
2463
+ /** @public */
2390
2464
  lifecycleStatus(status) {
2391
2465
  this.spec.lifecycleStatus = status;
2392
2466
  return this;
2393
2467
  }
2468
+ /** @internal */
2394
2469
  trigger(trigger) {
2395
2470
  this.spec.trigger = trigger;
2396
2471
  return this;
2397
2472
  }
2473
+ /** @internal */
2398
2474
  schedulable(value = true) {
2399
2475
  this.spec.schedulable = value;
2400
2476
  return this;
2401
2477
  }
2478
+ /** @public */
2402
2479
  effect(effect) {
2403
2480
  this.spec.effect = effect;
2404
2481
  return this;
2405
2482
  }
2483
+ /** @internal */
2406
2484
  build() {
2407
2485
  return {
2408
2486
  label: typeof this.spec.label === "string" ? this.spec.label : humanizeProcessLabel(this.actionId),
@@ -2413,33 +2491,41 @@ var HumanActionBuilder = class {
2413
2491
  };
2414
2492
  var ExternalActionBuilder = class {
2415
2493
  spec;
2494
+ /** @internal */
2416
2495
  constructor(actionId, source) {
2417
2496
  this.spec = { id: actionId, source };
2418
2497
  }
2498
+ /** @public */
2419
2499
  label(label) {
2420
2500
  this.spec.label = label;
2421
2501
  return this;
2422
2502
  }
2503
+ /** @public */
2423
2504
  description(description) {
2424
2505
  this.spec.description = description;
2425
2506
  return this;
2426
2507
  }
2508
+ /** @public */
2427
2509
  when(condition) {
2428
2510
  this.spec.when = condition;
2429
2511
  return this;
2430
2512
  }
2513
+ /** @public */
2431
2514
  to(turnId) {
2432
2515
  this.spec.to = turnId;
2433
2516
  return this;
2434
2517
  }
2518
+ /** @internal */
2435
2519
  complete() {
2436
2520
  this.spec.complete = true;
2437
2521
  return this;
2438
2522
  }
2523
+ /** @public */
2439
2524
  lifecycleStatus(status) {
2440
2525
  this.spec.lifecycleStatus = status;
2441
2526
  return this;
2442
2527
  }
2528
+ /** @internal */
2443
2529
  publishInput(productName, options) {
2444
2530
  this.spec.publishInput = {
2445
2531
  productName: normalizeProductName(productName),
@@ -2447,15 +2533,18 @@ var ExternalActionBuilder = class {
2447
2533
  };
2448
2534
  return this;
2449
2535
  }
2536
+ /** @public */
2450
2537
  effect(effect) {
2451
2538
  this.spec.effect = effect;
2452
2539
  return this;
2453
2540
  }
2541
+ /** @internal */
2454
2542
  build() {
2455
2543
  return this.spec;
2456
2544
  }
2457
2545
  };
2458
2546
  var HumanFlowBuilder = class extends ExternalActionTurnBuilder {
2547
+ /** @internal */
2459
2548
  turnKind = "Human";
2460
2549
  reviewProductName;
2461
2550
  reviewSemanticRef;
@@ -2463,6 +2552,7 @@ var HumanFlowBuilder = class extends ExternalActionTurnBuilder {
2463
2552
  turnCommentary;
2464
2553
  notes;
2465
2554
  actions = /* @__PURE__ */ new Map();
2555
+ /** @public */
2466
2556
  get definition() {
2467
2557
  if (!this.turnDescription) {
2468
2558
  throw new Error(`Human turn '${this.turnId}' must declare .description(...)`);
@@ -2482,24 +2572,29 @@ var HumanFlowBuilder = class extends ExternalActionTurnBuilder {
2482
2572
  ...externalActions ? { externalActions } : {}
2483
2573
  };
2484
2574
  }
2575
+ /** @public */
2485
2576
  reviewProduct(productName) {
2486
2577
  const normalized = normalizeProductName(productName);
2487
2578
  this.reviewProductName = normalized;
2488
2579
  this.reviewSemanticRef = normalized === "plan" ? "plan" : normalized === "review" ? "review" : void 0;
2489
2580
  return this;
2490
2581
  }
2582
+ /** @public */
2491
2583
  operatorAttention(attention) {
2492
2584
  this.operatorAttentionValue = attention;
2493
2585
  return this;
2494
2586
  }
2587
+ /** @internal */
2495
2588
  commentary(commentary) {
2496
2589
  this.turnCommentary = commentary;
2497
2590
  return this;
2498
2591
  }
2592
+ /** @internal */
2499
2593
  notesFields(notes) {
2500
2594
  this.notes = notes;
2501
2595
  return this;
2502
2596
  }
2597
+ /** @public */
2503
2598
  action(actionId, configure) {
2504
2599
  if (this.actions.has(actionId)) {
2505
2600
  throw new Error(`Human turn '${this.turnId}' declares duplicate action '${actionId}'`);
@@ -2511,6 +2606,7 @@ var HumanFlowBuilder = class extends ExternalActionTurnBuilder {
2511
2606
  }
2512
2607
  };
2513
2608
  var ExternalRouteBuilder = class {
2609
+ /** @internal */
2514
2610
  constructor(parent, source) {
2515
2611
  this.parent = parent;
2516
2612
  this.source = source;
@@ -2519,9 +2615,11 @@ var ExternalRouteBuilder = class {
2519
2615
  source;
2520
2616
  externalEffect;
2521
2617
  target = null;
2618
+ /** @internal */
2522
2619
  get id() {
2523
2620
  return this.parent.id;
2524
2621
  }
2622
+ /** @internal */
2525
2623
  get definition() {
2526
2624
  return this.parent.definition;
2527
2625
  }
@@ -2532,35 +2630,46 @@ var ExternalRouteBuilder = class {
2532
2630
  this.target = next;
2533
2631
  return this;
2534
2632
  }
2633
+ /** @public */
2535
2634
  to(turnId) {
2536
2635
  return this.setTarget({ kind: "to", turnId });
2537
2636
  }
2637
+ /** @internal */
2538
2638
  complete() {
2539
2639
  return this.setTarget({ kind: "complete" });
2540
2640
  }
2641
+ /** @internal */
2541
2642
  lifecycleStatus(status) {
2542
2643
  return this.setTarget({ kind: "lifecycleStatus", status });
2543
2644
  }
2645
+ /** @internal */
2544
2646
  state(fn) {
2545
2647
  this.externalEffect = async (ctx) => ({
2546
2648
  state: await fn({ ctx, event: ctx.event, input: ctx.input })
2547
2649
  });
2548
2650
  return this;
2549
2651
  }
2652
+ /** @internal */
2550
2653
  effect(fn) {
2551
2654
  this.externalEffect = (ctx) => fn({ ctx, event: ctx.event, input: ctx.input });
2552
2655
  return this;
2553
2656
  }
2657
+ /** @internal */
2554
2658
  build() {
2555
2659
  return {
2660
+ /** @internal */
2556
2661
  source: this.source,
2557
2662
  ...buildRouteTargetSpec(this.target),
2558
- ...this.externalEffect ? { effect: this.externalEffect } : {}
2663
+ ...this.externalEffect ? {
2664
+ /** @internal */
2665
+ effect: this.externalEffect
2666
+ } : {}
2559
2667
  };
2560
2668
  }
2561
2669
  };
2562
2670
  var ExternalFlowBuilder = class extends DescribedTurnBuilder {
2563
2671
  routeBuilders = [];
2672
+ /** @internal */
2564
2673
  get definition() {
2565
2674
  if (!this.turnDescription) {
2566
2675
  this.turnDescription = this.routeBuilders[0]?.build().source.description ?? "Wait for an external source";
@@ -2574,6 +2683,7 @@ var ExternalFlowBuilder = class extends DescribedTurnBuilder {
2574
2683
  transitions: this.routeBuilders.map((builder) => builder.build())
2575
2684
  };
2576
2685
  }
2686
+ /** @public */
2577
2687
  from(source) {
2578
2688
  const builder = new ExternalRouteBuilder(this, source);
2579
2689
  this.routeBuilders.push(
@@ -2588,27 +2698,37 @@ function chainHooks(hooks) {
2588
2698
  };
2589
2699
  }
2590
2700
  var FlowComponentBuilder = class {
2701
+ /** @internal */
2591
2702
  turns = [];
2703
+ /** @internal */
2592
2704
  serverHooks = [];
2705
+ /** @internal */
2593
2706
  uiHooks = [];
2707
+ /** @internal */
2594
2708
  launcherHooks = [];
2709
+ /** @internal */
2595
2710
  watcherHooks = [];
2711
+ /** @public */
2596
2712
  turn(turn) {
2597
2713
  this.turns.push(turn);
2598
2714
  return this;
2599
2715
  }
2716
+ /** @internal */
2600
2717
  server(hook) {
2601
2718
  this.serverHooks.push(hook);
2602
2719
  return this;
2603
2720
  }
2721
+ /** @internal */
2604
2722
  action(definition) {
2605
2723
  this.serverHooks.push((api) => api.action(definition));
2606
2724
  return this;
2607
2725
  }
2726
+ /** @internal */
2608
2727
  ui(hook) {
2609
2728
  this.uiHooks.push(hook);
2610
2729
  return this;
2611
2730
  }
2731
+ /** @public */
2612
2732
  launcher(definitionOrHook) {
2613
2733
  if (typeof definitionOrHook === "function") {
2614
2734
  this.launcherHooks.push(definitionOrHook);
@@ -2617,6 +2737,7 @@ var FlowComponentBuilder = class {
2617
2737
  }
2618
2738
  return this;
2619
2739
  }
2740
+ /** @public */
2620
2741
  watcher(definitionOrHook) {
2621
2742
  if (typeof definitionOrHook === "function") {
2622
2743
  this.watcherHooks.push(definitionOrHook);
@@ -2627,7 +2748,9 @@ var FlowComponentBuilder = class {
2627
2748
  }
2628
2749
  };
2629
2750
  var FlowFragmentBuilder = class extends FlowComponentBuilder {
2751
+ /** @internal */
2630
2752
  name;
2753
+ /** @internal */
2631
2754
  constructor(name) {
2632
2755
  super();
2633
2756
  if (name.trim() === "") {
@@ -2650,6 +2773,7 @@ var FlowProcessBuilder = class extends FlowComponentBuilder {
2650
2773
  processPiConfig;
2651
2774
  developmentTools = false;
2652
2775
  docker = false;
2776
+ /** @internal */
2653
2777
  constructor(processId) {
2654
2778
  super();
2655
2779
  if (processId.trim() === "") {
@@ -2657,15 +2781,17 @@ var FlowProcessBuilder = class extends FlowComponentBuilder {
2657
2781
  }
2658
2782
  this.processId = processId;
2659
2783
  }
2784
+ /** @public */
2660
2785
  displayName(displayName) {
2661
2786
  this.processDisplayName = displayName;
2662
2787
  return this;
2663
2788
  }
2789
+ /** @public */
2664
2790
  entry(turnId) {
2665
2791
  this.entryTurnId = turnId;
2666
2792
  return this;
2667
2793
  }
2668
- /** Declare an additional turn that launchers may select as the first turn. */
2794
+ /** Declare an additional turn that launchers may select as the first turn. @internal */
2669
2795
  alternateEntry(turnId) {
2670
2796
  this.alternateEntryTurnIds.push(turnId);
2671
2797
  return this;
@@ -2675,38 +2801,44 @@ var FlowProcessBuilder = class extends FlowComponentBuilder {
2675
2801
  * through. Flow diagrams render this as the main line. Must start at the entry
2676
2802
  * turn and reference only declared turns without repeats.
2677
2803
  */
2804
+ /** @public */
2678
2805
  happyPath(...turnIds) {
2679
2806
  this.happyPathTurnIds = turnIds;
2680
2807
  return this;
2681
2808
  }
2809
+ /** @public */
2682
2810
  codecs(input) {
2683
2811
  this.paramsCodec = input.params;
2684
2812
  this.stateCodec = input.state;
2685
2813
  return this;
2686
2814
  }
2815
+ /** @public */
2687
2816
  initialState(fn) {
2688
2817
  this.initialStateFn = fn;
2689
2818
  return this;
2690
2819
  }
2820
+ /** @public */
2691
2821
  repositoryCredentials(fn) {
2692
2822
  this.repositoryCredentialsFn = fn;
2693
2823
  return this;
2694
2824
  }
2695
- /** Resolve new process-volume capacity on the server; operator configuration wins. */
2825
+ /** Resolve new process-volume capacity on the server; operator configuration wins. @internal */
2696
2826
  resolveStorageSize(fn) {
2697
2827
  this.storageSizeResolver = fn;
2698
2828
  return this;
2699
2829
  }
2830
+ /** @public */
2700
2831
  piConfig(config) {
2701
2832
  this.processPiConfig = config;
2702
2833
  return this;
2703
2834
  }
2704
- /** Declare runner-provided process runtime capabilities. */
2835
+ /** Declare runner-provided process runtime capabilities. @public */
2705
2836
  runtime(capabilities) {
2706
2837
  this.developmentTools = capabilities.developmentTools === true;
2707
2838
  this.docker = capabilities.docker === true;
2708
2839
  return this;
2709
2840
  }
2841
+ /** @internal */
2710
2842
  use(fragment) {
2711
2843
  this.turns.push(...fragment.turns);
2712
2844
  this.serverHooks.push(...fragment.serverHooks);
@@ -2715,6 +2847,7 @@ var FlowProcessBuilder = class extends FlowComponentBuilder {
2715
2847
  this.watcherHooks.push(...fragment.watcherHooks);
2716
2848
  return this;
2717
2849
  }
2850
+ /** @public */
2718
2851
  define() {
2719
2852
  if (!this.processDisplayName) {
2720
2853
  throw new Error(`Flow process '${this.processId}' must declare .displayName(...)`);
@@ -2769,21 +2902,27 @@ var FlowProcessBuilder = class extends FlowComponentBuilder {
2769
2902
  }
2770
2903
  };
2771
2904
  var flow = {
2905
+ /** @public */
2772
2906
  llm(turnId) {
2773
2907
  return new LlmFlowBuilder(turnId);
2774
2908
  },
2909
+ /** @public */
2775
2910
  automatic(turnId) {
2776
2911
  return new AutomaticFlowBuilder(turnId);
2777
2912
  },
2913
+ /** @public */
2778
2914
  human(turnId) {
2779
2915
  return new HumanFlowBuilder(turnId);
2780
2916
  },
2917
+ /** @public */
2781
2918
  external(turnId) {
2782
2919
  return new ExternalFlowBuilder(turnId);
2783
2920
  },
2921
+ /** @public */
2784
2922
  fragment(name) {
2785
2923
  return new FlowFragmentBuilder(name);
2786
2924
  },
2925
+ /** @public */
2787
2926
  process(processId) {
2788
2927
  return new FlowProcessBuilder(processId);
2789
2928
  }
@@ -2891,6 +3030,7 @@ function createCapabilityAccessor(provided = []) {
2891
3030
 
2892
3031
  // src/integration-http.ts
2893
3032
  var IntegrationHttpError = class extends Error {
3033
+ /** @internal */
2894
3034
  constructor(status, message) {
2895
3035
  super(message);
2896
3036
  this.status = status;
@@ -2898,7 +3038,13 @@ var IntegrationHttpError = class extends Error {
2898
3038
  status;
2899
3039
  };
2900
3040
  var IntegrationHttpClient = class {
2901
- constructor(provider, baseUrl, headers, pagination = { key: "per_page", size: 100 }) {
3041
+ /** @internal */
3042
+ constructor(provider, baseUrl, headers, pagination = {
3043
+ /** @internal */
3044
+ key: "per_page",
3045
+ /** @internal */
3046
+ size: 100
3047
+ }) {
2902
3048
  this.provider = provider;
2903
3049
  this.baseUrl = baseUrl;
2904
3050
  this.headers = headers;
@@ -2908,6 +3054,7 @@ var IntegrationHttpClient = class {
2908
3054
  baseUrl;
2909
3055
  headers;
2910
3056
  pagination;
3057
+ /** @internal */
2911
3058
  async response(path3, init = {}) {
2912
3059
  const response = await fetch(`${this.baseUrl}${path3}`, {
2913
3060
  ...init,
@@ -2924,13 +3071,16 @@ var IntegrationHttpClient = class {
2924
3071
  );
2925
3072
  return response;
2926
3073
  }
3074
+ /** @internal */
2927
3075
  async request(path3, init = {}) {
2928
3076
  const response = await this.response(path3, init);
2929
3077
  return response.status === 204 ? void 0 : response.json();
2930
3078
  }
3079
+ /** @internal */
2931
3080
  writeJson(path3, method, body, signal) {
2932
3081
  return this.request(path3, { method, body: JSON.stringify(body), signal });
2933
3082
  }
3083
+ /** @internal */
2934
3084
  async pages(path3, signal) {
2935
3085
  const items = [];
2936
3086
  const { key, size } = this.pagination;
@@ -3654,8 +3804,11 @@ function repositoryFeedbackBatch(unseen, config, now) {
3654
3804
  const latest = Math.max(...unseen.map((item) => Date.parse(item.createdAt) || 0));
3655
3805
  if (now - latest < config.quietPeriodMs) return null;
3656
3806
  const cursors = {
3807
+ /** @internal */
3657
3808
  conversationCursor: config.conversationCursor,
3809
+ /** @internal */
3658
3810
  reviewCursor: config.reviewCursor,
3811
+ /** @internal */
3659
3812
  inlineCursor: config.inlineCursor
3660
3813
  };
3661
3814
  for (const item of unseen) {
@@ -3663,7 +3816,19 @@ function repositoryFeedbackBatch(unseen, config, now) {
3663
3816
  cursors[key] = Math.max(cursors[key], item.id);
3664
3817
  }
3665
3818
  return {
3666
- event: { feedbackIds: unseen.map(({ kind, id }) => ({ kind, id })), cursors },
3819
+ /** @internal */
3820
+ event: {
3821
+ /** @internal */
3822
+ feedbackIds: unseen.map(({ kind, id }) => ({
3823
+ /** @internal */
3824
+ kind,
3825
+ /** @internal */
3826
+ id
3827
+ })),
3828
+ /** @internal */
3829
+ cursors
3830
+ },
3831
+ /** @internal */
3667
3832
  mergeKey: `${cursors.conversationCursor}:${cursors.reviewCursor}:${cursors.inlineCursor}`
3668
3833
  };
3669
3834
  }
@@ -3767,20 +3932,24 @@ function shellQuote(value) {
3767
3932
 
3768
3933
  // src/repository-http.ts
3769
3934
  var RepositoryHttpClient = class extends IntegrationHttpClient {
3935
+ /** @internal */
3770
3936
  repositoryPath(owner, repo) {
3771
3937
  return `/repos/${owner}/${repo}`;
3772
3938
  }
3939
+ /** @internal */
3773
3940
  getIssue(owner, repo, number, signal) {
3774
3941
  return this.request(`${this.repositoryPath(owner, repo)}/issues/${number}`, {
3775
3942
  signal
3776
3943
  });
3777
3944
  }
3945
+ /** @public */
3778
3946
  listIssueComments(owner, repo, number, signal) {
3779
3947
  return this.pages(
3780
3948
  `${this.repositoryPath(owner, repo)}/issues/${number}/comments`,
3781
3949
  signal
3782
3950
  );
3783
3951
  }
3952
+ /** @public */
3784
3953
  addIssueComment(owner, repo, number, body, signal) {
3785
3954
  return this.writeJson(
3786
3955
  `${this.repositoryPath(owner, repo)}/issues/${number}/comments`,
@@ -3789,6 +3958,7 @@ var RepositoryHttpClient = class extends IntegrationHttpClient {
3789
3958
  signal
3790
3959
  );
3791
3960
  }
3961
+ /** @public */
3792
3962
  createPullRequest(owner, repo, input) {
3793
3963
  return this.writeJson(
3794
3964
  `${this.repositoryPath(owner, repo)}/pulls`,
@@ -3796,17 +3966,20 @@ var RepositoryHttpClient = class extends IntegrationHttpClient {
3796
3966
  input
3797
3967
  );
3798
3968
  }
3969
+ /** @public */
3799
3970
  getPullRequest(owner, repo, number, signal) {
3800
3971
  return this.request(
3801
3972
  `${this.repositoryPath(owner, repo)}/pulls/${number}`,
3802
3973
  { signal }
3803
3974
  );
3804
3975
  }
3976
+ /** @internal */
3805
3977
  listPullRequests(owner, repo, state = "open") {
3806
3978
  return this.pages(
3807
3979
  `${this.repositoryPath(owner, repo)}/pulls?state=${encodeURIComponent(state)}`
3808
3980
  );
3809
3981
  }
3982
+ /** @public */
3810
3983
  updatePullRequest(owner, repo, number, patch, signal) {
3811
3984
  return this.writeJson(
3812
3985
  `${this.repositoryPath(owner, repo)}/pulls/${number}`,
@@ -3877,16 +4050,26 @@ function parseRepositoryIssueWatcherConfig(raw, legacyType, distinctLabels = fal
3877
4050
  if (distinctLabels && parsed.labels.trigger === parsed.labels.done)
3878
4051
  throw new Error("Trigger and done labels must differ");
3879
4052
  return {
4053
+ /** @internal */
3880
4054
  config: parsed,
4055
+ /** @internal */
3881
4056
  enabled: config.enabled,
4057
+ /** @internal */
3882
4058
  launchModelConfig: parseProcessWatcherLaunchModelConfig(config.launch)
3883
4059
  };
3884
4060
  }
3885
4061
  function presentRepositoryIssueWatcherConfig(config) {
3886
4062
  return {
4063
+ /** @internal */
3887
4064
  targetSummary: `Profile ${config.profile} \xB7 trigger ${config.labels.trigger}`,
4065
+ /** @internal */
3888
4066
  details: [
3889
- { label: "Profile", value: config.profile },
4067
+ {
4068
+ /** @internal */
4069
+ label: "Profile",
4070
+ /** @internal */
4071
+ value: config.profile
4072
+ },
3890
4073
  { label: "Included repositories", value: config.repositories.include.join(", ") || "all" },
3891
4074
  { label: "Excluded repositories", value: config.repositories.exclude.join(", ") || "none" },
3892
4075
  { label: "Trigger label", value: config.labels.trigger },
@@ -3896,6 +4079,30 @@ function presentRepositoryIssueWatcherConfig(config) {
3896
4079
  };
3897
4080
  }
3898
4081
 
4082
+ // src/repository-reconciliation.ts
4083
+ async function existingObject(read) {
4084
+ try {
4085
+ return await read();
4086
+ } catch (error) {
4087
+ if (error instanceof IntegrationHttpError && error.status === 404) return null;
4088
+ throw error;
4089
+ }
4090
+ }
4091
+ function matchesPatch(current, patch) {
4092
+ const fields = current;
4093
+ return Object.entries(patch).every(([key, expected]) => {
4094
+ const labelKey = Array.isArray(expected) && typeof expected[0] === "number" ? "id" : "name";
4095
+ const normalize = (value) => key === "labels" && Array.isArray(value) ? [
4096
+ ...new Set(
4097
+ value.map(
4098
+ (label) => typeof label === "object" && label !== null ? label[labelKey] : label
4099
+ )
4100
+ )
4101
+ ].sort() : value;
4102
+ return JSON.stringify(normalize(fields[key])) === JSON.stringify(normalize(expected));
4103
+ });
4104
+ }
4105
+
3899
4106
  // src/repository-source-config.ts
3900
4107
  import { asUnknownRecord as asUnknownRecord2 } from "@leitwerk-dev/domain";
3901
4108
  function parseRepositoryPullRequestConfig(value) {
@@ -3904,12 +4111,19 @@ function parseRepositoryPullRequestConfig(value) {
3904
4111
  return null;
3905
4112
  const terminalOutcome = config.terminalOutcome === "merged" || config.terminalOutcome === "closed" ? config.terminalOutcome : void 0;
3906
4113
  return {
4114
+ /** @internal */
3907
4115
  profile: config.profile,
4116
+ /** @internal */
3908
4117
  owner: config.owner,
4118
+ /** @internal */
3909
4119
  repo: config.repo,
4120
+ /** @internal */
3910
4121
  prNumber: config.prNumber,
4122
+ /** @internal */
3911
4123
  pollInterval: typeof config.pollInterval === "string" ? config.pollInterval : "30s",
4124
+ /** @internal */
3912
4125
  terminalOutcome,
4126
+ /** @internal */
3913
4127
  disabled: config.disabled === true
3914
4128
  };
3915
4129
  }
@@ -3919,9 +4133,13 @@ function parseRepositoryFeedbackConfig(value) {
3919
4133
  if (!base) return null;
3920
4134
  return {
3921
4135
  ...base,
4136
+ /** @internal */
3922
4137
  conversationCursor: typeof config.conversationCursor === "number" ? config.conversationCursor : 0,
4138
+ /** @internal */
3923
4139
  reviewCursor: typeof config.reviewCursor === "number" ? config.reviewCursor : 0,
4140
+ /** @internal */
3924
4141
  inlineCursor: typeof config.inlineCursor === "number" ? config.inlineCursor : 0,
4142
+ /** @internal */
3925
4143
  quietPeriodMs: typeof config.quietPeriodMs === "number" ? config.quietPeriodMs : 12e4
3926
4144
  };
3927
4145
  }
@@ -3930,11 +4148,17 @@ function parseRepositoryIssueCancelledConfig(value) {
3930
4148
  if (typeof config.profile !== "string" || typeof config.owner !== "string" || typeof config.repo !== "string" || typeof config.issueNumber !== "number" || typeof config.triggerLabel !== "string")
3931
4149
  return null;
3932
4150
  return {
4151
+ /** @internal */
3933
4152
  profile: config.profile,
4153
+ /** @internal */
3934
4154
  owner: config.owner,
4155
+ /** @internal */
3935
4156
  repo: config.repo,
4157
+ /** @internal */
3936
4158
  issueNumber: config.issueNumber,
4159
+ /** @internal */
3937
4160
  triggerLabel: config.triggerLabel,
4161
+ /** @internal */
3938
4162
  pollInterval: typeof config.pollInterval === "string" ? config.pollInterval : "30s"
3939
4163
  };
3940
4164
  }
@@ -4020,7 +4244,6 @@ function validateToolCallRendererDefinition(def) {
4020
4244
  }
4021
4245
 
4022
4246
  // src/turn-semantics.ts
4023
- import { defaultProcessTurnStartSelection } from "@leitwerk-dev/domain";
4024
4247
  function isLlmTurnDefinition(turnDef) {
4025
4248
  return turnDef.kind === "llm";
4026
4249
  }
@@ -4539,57 +4762,30 @@ function createWorkerProcessBuilder() {
4539
4762
  };
4540
4763
  }
4541
4764
  export {
4542
- AutomaticFlowBuilder,
4543
4765
  AutomaticOutcomeBuilder,
4544
4766
  BUILT_IN_COMMIT_MESSAGE_RULES,
4545
4767
  COMMIT_MESSAGE_PROJECT_METADATA_KEY,
4546
4768
  CORE_TOOL_CALL_RENDERERS,
4547
- DEFAULT_FLOW_PRODUCT_NAME,
4548
- DEFAULT_PLAN_RESULT_OUTCOME_ID,
4549
- ExternalActionBuilder,
4550
- ExternalFlowBuilder,
4551
- ExternalRouteBuilder,
4552
- FRAMEWORK_LLM_TOOL_NAMES,
4553
4769
  FlowFragmentBuilder,
4554
- FlowProcessBuilder,
4555
- HumanActionBuilder,
4556
4770
  HumanFlowBuilder,
4557
4771
  IntegrationHttpClient,
4558
4772
  IntegrationHttpError,
4559
- LlmFlowBuilder,
4560
- LlmTurnEndBuilder,
4561
- MARKDOWN_RESULT_TOOL_MARKDOWN_PATH,
4562
4773
  MARKDOWN_RESULT_TOOL_NAME,
4563
- MARKDOWN_RESULT_TOOL_RENDERER,
4564
- OutcomeToolBuilder,
4565
- PI_BUILT_IN_TOOL_NAMES,
4566
- PlanResultBuilder,
4567
- PublishedResultBuilder,
4568
4774
  REQUIRED_MARKDOWN_RESULT_TURN_RESULT,
4569
4775
  RESERVED_INTEGRATION_TOOL_NAMES,
4570
4776
  RepositoryHttpClient,
4571
4777
  SafeLaunchPreparationError,
4572
- TOOL_CALL_RENDERER_VALUE_KINDS,
4573
- TOOL_CALL_RENDERER_VALUE_SOURCES,
4574
- TURN_COMPLETION_MODES,
4575
- TURN_CONTEXT_MODES,
4576
- WORKER_SUBPROCESS_SENSITIVE_ENV_KEYS,
4577
4778
  acceptedReviewHandoffAction,
4578
4779
  assertValidLlmTurnDefinition,
4579
4780
  atomicWriteUtf8,
4580
4781
  automaticTurn,
4581
- buildPlanSavedEventPayload,
4582
4782
  buildProcessFlowView,
4583
4783
  buildProcessLaunchers,
4584
4784
  buildProcessWatchers,
4585
- buildReviewCompletedEventPayload,
4586
- buildReviewRequestedEventPayload,
4587
4785
  buildUiProcessDefinition,
4588
4786
  builtinPiProvider,
4589
4787
  clearRepositoryGitHttpsHelpers,
4590
4788
  clearRepositoryGitSshWrappers,
4591
- collapseRoutingTurns,
4592
- collectProcessAvailableToolNames,
4593
4789
  configuredPiProvider,
4594
4790
  coreHostCapabilities,
4595
4791
  createCapabilityAccessor,
@@ -4597,7 +4793,6 @@ export {
4597
4793
  createEmptyStructuralProcessState,
4598
4794
  createEventBus,
4599
4795
  createExternalSourcePollReporter,
4600
- createFlowAutomaticRunContext,
4601
4796
  createFlowPromptContext,
4602
4797
  createProcessLauncherBuilder,
4603
4798
  createProcessWatcherBuilder,
@@ -4606,7 +4801,6 @@ export {
4606
4801
  createUiProcessBuilder,
4607
4802
  createWorkerProcessBuilder,
4608
4803
  credentialBasedModelStatuses,
4609
- defaultProcessTurnStartSelection as defaultTurnStartSelection,
4610
4804
  defineExternalActionSource,
4611
4805
  defineModelProvider,
4612
4806
  defineModelProviders,
@@ -4617,18 +4811,15 @@ export {
4617
4811
  defineProviderOptions,
4618
4812
  defineWorkerConfig,
4619
4813
  emptyParamsCodec,
4620
- externalTurn,
4814
+ existingObject,
4621
4815
  filterProviderOptionsForDefinition,
4622
- filterStringArray,
4623
4816
  findUiLauncherById,
4624
4817
  flow,
4625
- getAllProcessGraphs,
4626
4818
  getExternalActionArmingId,
4627
4819
  getExternalActionTransitionTrigger,
4628
4820
  getExternalSourceTransitionId,
4629
4821
  getProcessGraph,
4630
4822
  getProcessTurnGraph,
4631
- getReachableTurnIdsForProcessGraph,
4632
4823
  getTurnTransitionsForProcessGraph,
4633
4824
  hasErrorCode,
4634
4825
  hasProcessGraph,
@@ -4642,6 +4833,7 @@ export {
4642
4833
  isTurnAvailableForProcessGraph,
4643
4834
  listLlmTurnIdsForProcessGraph,
4644
4835
  llmTurn,
4836
+ matchesPatch,
4645
4837
  matchesRepository,
4646
4838
  normalizeLeafOutcomeCaptureResult,
4647
4839
  normalizeRepositoryFeedback,
@@ -4658,18 +4850,14 @@ export {
4658
4850
  piWorker,
4659
4851
  presentRepositoryIssueWatcherConfig,
4660
4852
  projectParameters,
4661
- queuedInstructionAction,
4662
4853
  repositoryFeedbackBatch,
4663
4854
  repositoryGitArgs,
4664
4855
  repositoryGitSubprocessEnv,
4665
4856
  repositoryHttpsUrl,
4666
4857
  resolveHumanTurnView,
4667
4858
  resolveLlmTurnRestorePrimaryLeafAfterTurn,
4668
- resolveLlmTurnStartSelection,
4669
4859
  resolveProviderOptions,
4670
4860
  resolveRepositoryProjectBinding,
4671
- resolveTurnAvailableToolNames as resolveTurnActiveToolNames,
4672
- resolveTurnAvailableToolNames,
4673
4861
  revisionAction,
4674
4862
  routeTurnOutcomes,
4675
4863
  sanitizeWorkerSubprocessEnv,
@@ -4679,16 +4867,10 @@ export {
4679
4867
  stringArg,
4680
4868
  structuralStateCodec,
4681
4869
  toProcessGraphView,
4682
- validateAutomaticTurnDefinition,
4683
- validateExternalTurnDefinition,
4684
- validateHumanTurnDefinition,
4685
4870
  validateLeafOutcomeCaptureResult,
4686
- validateLlmTurnDefinition,
4687
- validatePiBuiltInToolArray,
4688
4871
  validateProcessGraphEntryTurns,
4689
4872
  validateProcessGraphProducts,
4690
4873
  validateProcessGraphTurnTransitions,
4691
- validateProcessLeafOutcomeDefinition,
4692
4874
  validateToolCallRendererDefinition,
4693
4875
  validateTurnDefinition
4694
4876
  };