@leitwerk-dev/process-sdk 0.1.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/dist/{chunk-TRQJ5PRM.js → chunk-TA4KO53Q.js} +1 -5
  2. package/dist/chunk-TA4KO53Q.js.map +1 -0
  3. package/dist/{chunk-5RJZ2E7D.js → chunk-WFY2WWZE.js} +2 -6
  4. package/dist/{chunk-5RJZ2E7D.js.map → chunk-WFY2WWZE.js.map} +1 -1
  5. package/dist/core-capabilities.d.ts +70 -34
  6. package/dist/core-capabilities.d.ts.map +1 -1
  7. package/dist/define-process.d.ts +17 -49
  8. package/dist/define-process.d.ts.map +1 -1
  9. package/dist/{extension-api-BBcwktmc.d.ts → extension-api-CcqZCYJx.d.ts} +136 -70
  10. package/dist/extension-api.d.ts +115 -7
  11. package/dist/extension-api.d.ts.map +1 -1
  12. package/dist/external-action-source.d.ts +7 -0
  13. package/dist/external-action-source.d.ts.map +1 -0
  14. package/dist/external-source-poll.d.ts +15 -0
  15. package/dist/external-source-poll.d.ts.map +1 -0
  16. package/dist/flow.d.ts +80 -104
  17. package/dist/flow.d.ts.map +1 -1
  18. package/dist/fs-utils.d.ts +2 -0
  19. package/dist/fs-utils.d.ts.map +1 -1
  20. package/dist/git-binary.js +25 -33
  21. package/dist/git-binary.js.map +1 -1
  22. package/dist/index.d.ts +21 -9
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +4694 -29
  25. package/dist/index.js.map +1 -1
  26. package/dist/integration-http.d.ts +21 -0
  27. package/dist/integration-http.d.ts.map +1 -0
  28. package/dist/json-data.d.ts +3 -0
  29. package/dist/json-data.d.ts.map +1 -0
  30. package/dist/leaf-outcome-renderer.js +74 -64
  31. package/dist/leaf-outcome-renderer.js.map +1 -1
  32. package/dist/leaf-outcomes.d.ts.map +1 -1
  33. package/dist/model-provider.d.ts.map +1 -1
  34. package/dist/pi-config.d.ts +1 -5
  35. package/dist/pi-config.d.ts.map +1 -1
  36. package/dist/pi-config.js +20 -180
  37. package/dist/pi-config.js.map +1 -1
  38. package/dist/process-flow-view.d.ts.map +1 -1
  39. package/dist/process-graph.d.ts.map +1 -1
  40. package/dist/process-watcher-source.d.ts.map +1 -1
  41. package/dist/project-binding.d.ts +9 -0
  42. package/dist/project-binding.d.ts.map +1 -0
  43. package/dist/registry-utils.d.ts.map +1 -1
  44. package/dist/repository-feedback.d.ts +29 -0
  45. package/dist/repository-feedback.d.ts.map +1 -0
  46. package/dist/repository-git-env.d.ts +2 -0
  47. package/dist/repository-git-env.d.ts.map +1 -1
  48. package/dist/repository-http.d.ts +19 -0
  49. package/dist/repository-http.d.ts.map +1 -0
  50. package/dist/repository-https.d.ts +3 -0
  51. package/dist/repository-https.d.ts.map +1 -0
  52. package/dist/repository-issue-watcher.d.ts +31 -0
  53. package/dist/repository-issue-watcher.d.ts.map +1 -0
  54. package/dist/repository-source-config.d.ts +32 -0
  55. package/dist/repository-source-config.d.ts.map +1 -0
  56. package/dist/repository-types.d.ts +36 -0
  57. package/dist/repository-types.d.ts.map +1 -0
  58. package/dist/review-flow.js +12 -43
  59. package/dist/review-flow.js.map +1 -1
  60. package/dist/runtime-internals.js +18 -2
  61. package/dist/runtime-internals.js.map +1 -1
  62. package/dist/state-helpers.d.ts +2 -0
  63. package/dist/state-helpers.d.ts.map +1 -1
  64. package/dist/subprocess-env.d.ts +1 -0
  65. package/dist/subprocess-env.d.ts.map +1 -1
  66. package/dist/tool-arguments.d.ts +7 -0
  67. package/dist/tool-arguments.d.ts.map +1 -0
  68. package/dist/turn-semantics.d.ts +5 -6
  69. package/dist/turn-semantics.d.ts.map +1 -1
  70. package/dist/types.d.ts +5 -15
  71. package/dist/types.d.ts.map +1 -1
  72. package/package.json +6 -5
  73. package/src/core-capabilities.ts +81 -37
  74. package/src/define-process.ts +190 -313
  75. package/src/extension-api.ts +142 -6
  76. package/src/external-action-source.ts +12 -0
  77. package/src/external-source-poll.ts +49 -0
  78. package/src/flow.ts +332 -664
  79. package/src/fs-utils.ts +17 -2
  80. package/src/index.ts +54 -13
  81. package/src/integration-http.ts +58 -0
  82. package/src/json-data.ts +25 -0
  83. package/src/leaf-outcomes.ts +1 -9
  84. package/src/model-provider.ts +10 -23
  85. package/src/pi-config.ts +1 -6
  86. package/src/process-flow-view.ts +32 -88
  87. package/src/process-graph.ts +25 -51
  88. package/src/process-watcher-source.ts +3 -6
  89. package/src/project-binding.ts +36 -0
  90. package/src/registry-utils.ts +1 -5
  91. package/src/repository-feedback.ts +59 -0
  92. package/src/repository-git-env.ts +34 -0
  93. package/src/repository-http.ts +71 -0
  94. package/src/repository-https.ts +22 -0
  95. package/src/repository-issue-watcher.ts +92 -0
  96. package/src/repository-source-config.ts +60 -0
  97. package/src/repository-types.ts +25 -0
  98. package/src/state-helpers.ts +8 -4
  99. package/src/subprocess-env.ts +6 -0
  100. package/src/tool-arguments.ts +37 -0
  101. package/src/turn-semantics.ts +31 -75
  102. package/src/types.ts +5 -15
  103. package/dist/browser-ui-extension.js +0 -2
  104. package/dist/browser-ui-extension.js.map +0 -1
  105. package/dist/capabilities.js +0 -7
  106. package/dist/capabilities.js.map +0 -1
  107. package/dist/chunk-TRQJ5PRM.js.map +0 -1
  108. package/dist/codecs.js +0 -9
  109. package/dist/codecs.js.map +0 -1
  110. package/dist/commit-message.js +0 -3
  111. package/dist/commit-message.js.map +0 -1
  112. package/dist/core-capabilities.js +0 -6
  113. package/dist/core-capabilities.js.map +0 -1
  114. package/dist/define-process.js +0 -1078
  115. package/dist/define-process.js.map +0 -1
  116. package/dist/event-bus.js +0 -31
  117. package/dist/event-bus.js.map +0 -1
  118. package/dist/extension-api.js +0 -5
  119. package/dist/extension-api.js.map +0 -1
  120. package/dist/flow.js +0 -1645
  121. package/dist/flow.js.map +0 -1
  122. package/dist/form-contract.js +0 -2
  123. package/dist/form-contract.js.map +0 -1
  124. package/dist/fs-utils.js +0 -23
  125. package/dist/fs-utils.js.map +0 -1
  126. package/dist/graph-fragments.js +0 -57
  127. package/dist/graph-fragments.js.map +0 -1
  128. package/dist/host-capabilities.js +0 -42
  129. package/dist/host-capabilities.js.map +0 -1
  130. package/dist/launcher-contract.js +0 -2
  131. package/dist/launcher-contract.js.map +0 -1
  132. package/dist/leaf-outcomes.js +0 -52
  133. package/dist/leaf-outcomes.js.map +0 -1
  134. package/dist/model-provider.js +0 -171
  135. package/dist/model-provider.js.map +0 -1
  136. package/dist/process-definition-internals.js +0 -25
  137. package/dist/process-definition-internals.js.map +0 -1
  138. package/dist/process-flow-view.js +0 -418
  139. package/dist/process-flow-view.js.map +0 -1
  140. package/dist/process-graph.js +0 -212
  141. package/dist/process-graph.js.map +0 -1
  142. package/dist/process-launcher-builder.js +0 -43
  143. package/dist/process-launcher-builder.js.map +0 -1
  144. package/dist/process-watcher-builder.js +0 -40
  145. package/dist/process-watcher-builder.js.map +0 -1
  146. package/dist/process-watcher-source.js +0 -52
  147. package/dist/process-watcher-source.js.map +0 -1
  148. package/dist/registry-utils.js +0 -18
  149. package/dist/registry-utils.js.map +0 -1
  150. package/dist/repository-git-env.js +0 -26
  151. package/dist/repository-git-env.js.map +0 -1
  152. package/dist/server-events.js +0 -2
  153. package/dist/server-events.js.map +0 -1
  154. package/dist/server-process-builder.js +0 -52
  155. package/dist/server-process-builder.js.map +0 -1
  156. package/dist/state-helpers.js +0 -18
  157. package/dist/state-helpers.js.map +0 -1
  158. package/dist/subprocess-env.js +0 -34
  159. package/dist/subprocess-env.js.map +0 -1
  160. package/dist/tool-renderers.js +0 -63
  161. package/dist/tool-renderers.js.map +0 -1
  162. package/dist/turn-semantics.js +0 -365
  163. package/dist/turn-semantics.js.map +0 -1
  164. package/dist/types.js +0 -23
  165. package/dist/types.js.map +0 -1
  166. package/dist/ui-process-builder.js +0 -30
  167. package/dist/ui-process-builder.js.map +0 -1
  168. package/dist/worker-process-builder.js +0 -22
  169. package/dist/worker-process-builder.js.map +0 -1
@@ -1,4 +1,5 @@
1
1
  import type {
2
+ Actor,
2
3
  InputKind,
3
4
  InputSource,
4
5
  LaunchModelConfigInput,
@@ -116,6 +117,32 @@ export type UiLauncherConfigResolution<TParams = unknown> =
116
117
  errors: readonly LauncherValidationError[];
117
118
  };
118
119
 
120
+ export interface LaunchPreparationContext<TParams = unknown> {
121
+ readonly signal: AbortSignal;
122
+ readonly launchConfig: ProcessLaunchConfig<TParams>;
123
+ readonly logger: {
124
+ info(message: string): void;
125
+ warn(message: string): void;
126
+ };
127
+ }
128
+
129
+ export interface LaunchPreparationCheck<TParams = unknown> {
130
+ readonly id: string;
131
+ readonly label: string;
132
+ run(ctx: LaunchPreparationContext<TParams>): Promise<void>;
133
+ }
134
+
135
+ /** A launcher check may throw this error to expose bounded operator-safe remediation. */
136
+ export class SafeLaunchPreparationError extends Error {
137
+ constructor(
138
+ message: string,
139
+ readonly safeSummary: string,
140
+ ) {
141
+ super(message);
142
+ this.name = "SafeLaunchPreparationError";
143
+ }
144
+ }
145
+
119
146
  export interface UiLauncherDefinition<TParams = unknown> {
120
147
  card: LauncherCardMetadata;
121
148
  launchConfigSchema: LauncherSchemaDefinition;
@@ -136,6 +163,10 @@ export interface UiLauncherDefinition<TParams = unknown> {
136
163
  previousInput: Record<string, unknown>,
137
164
  ctx: LauncherContext,
138
165
  ): Record<string, unknown> | Promise<Record<string, unknown>>;
166
+ preparationChecks?(
167
+ input: Record<string, unknown>,
168
+ launchConfig: ProcessLaunchConfig<TParams>,
169
+ ): readonly LaunchPreparationCheck<TParams>[];
139
170
  resolveLaunchConfig(
140
171
  input: Record<string, unknown>,
141
172
  ctx: LauncherContext,
@@ -171,6 +202,10 @@ export interface ProcessWatcherDefinition<TParams = unknown, TEvent = unknown, T
171
202
  description: string;
172
203
  source: ProcessWatcherSource<TConfig, TEvent>;
173
204
  matches?(event: TEvent, ctx: LauncherContext): boolean | Promise<boolean>;
205
+ preparationChecks?(
206
+ event: TEvent,
207
+ launchConfig: ProcessLaunchConfig<TParams>,
208
+ ): readonly LaunchPreparationCheck<TParams>[];
174
209
  resolveLaunchConfig(
175
210
  event: TEvent,
176
211
  ctx: LauncherContext,
@@ -239,6 +274,11 @@ export interface ProcessLauncherService {
239
274
  previousInput: Record<string, unknown>,
240
275
  ctx?: LauncherContext,
241
276
  ): Promise<Record<string, unknown>>;
277
+ resolvePreparationChecks?(
278
+ launcherId: string,
279
+ input: Record<string, unknown>,
280
+ launchConfig: ProcessLaunchConfig,
281
+ ): readonly LaunchPreparationCheck[];
242
282
  resolveUiLauncher(
243
283
  launcherId: string,
244
284
  input: Record<string, unknown>,
@@ -382,6 +422,12 @@ export type ExternalSourceEffect<
382
422
  ctx: ExternalSourceEffectContext<TParams, TState, TEvent, TInput>,
383
423
  ) => ProcessEffectPlan<TState> | Promise<ProcessEffectPlan<TState> | undefined> | undefined;
384
424
 
425
+ export interface ExternalEventDescription {
426
+ summary: string;
427
+ markdown?: string;
428
+ links?: import("@leitwerk-dev/domain").TurnProgressLink[];
429
+ }
430
+
385
431
  export interface ExternalActionSource<
386
432
  TParams = unknown,
387
433
  TState = unknown,
@@ -391,6 +437,8 @@ export interface ExternalActionSource<
391
437
  kind: string;
392
438
  label?: string;
393
439
  description?: string;
440
+ /** Pure description captured when the event is consumed. */
441
+ describeEvent?(event: _TEvent): ExternalEventDescription;
394
442
  /**
395
443
  * Extension-owned opaque config. Core may persist, hash, and display it, but must not
396
444
  * interpret provider-specific fields.
@@ -452,9 +500,11 @@ export interface WorkerProcessContext<TParams = unknown, TState = unknown>
452
500
  readonly turnResultMarkdownByProduct?: Readonly<Record<string, string>>;
453
501
  /** Absolute workspace root for the current process instance, when available. */
454
502
  readonly workspaceRoot?: string;
455
- /** Invoke a server-owned integration tool authorized for this automatic turn. */
503
+ /** Durable output produced by this LLM turn's preparation phase, when declared. */
504
+ readonly prepared?: unknown;
505
+ /** Invoke a server-owned integration tool authorized for this automatic turn or LLM preparation. */
456
506
  callIntegrationTool?(name: string, args: Record<string, unknown>): Promise<unknown>;
457
- /** Replace the durable operator-facing progress report for this automatic turn attempt. */
507
+ /** Replace the durable operator-facing progress report for this turn attempt. */
458
508
  reportProgress?(report: TurnProgressReport): void;
459
509
  }
460
510
 
@@ -462,6 +512,7 @@ export interface WorkerCompleteInput<TOutcome extends string = string> {
462
512
  outcome: TOutcome;
463
513
  params?: Record<string, unknown>;
464
514
  markdown?: string | null;
515
+ resultSummary?: string;
465
516
  }
466
517
 
467
518
  export interface WorkerRunHandle<TParams = unknown, TState = unknown> {
@@ -513,7 +564,7 @@ export interface ProcessTurnBinding<TTurn = TurnDefinition> {
513
564
  definition: TTurn;
514
565
  }
515
566
 
516
- export type RepositoryCredentialKind = "git_ssh";
567
+ export type RepositoryCredentialKind = "git_ssh" | "git_https";
517
568
 
518
569
  /** Non-secret, code-defined repository authentication request. */
519
570
  export interface RepositoryCredentialRequirement {
@@ -536,15 +587,31 @@ export interface GitSshCredentialMaterial {
536
587
  readonly knownHosts: string;
537
588
  }
538
589
 
539
- export interface RepositoryCredentialProvider {
540
- readonly kind: RepositoryCredentialKind;
541
- resolve(credentialRef: string): GitSshCredentialMaterial | null;
590
+ export interface GitHttpsCredentialMaterial {
591
+ /** HTTPS origin authorized by the credential-owning extension. */
592
+ readonly origin: string;
593
+ readonly username: string;
594
+ readonly password: string;
542
595
  }
543
596
 
597
+ export type RepositoryCredentialProvider =
598
+ | { readonly kind: "git_ssh"; resolve(credentialRef: string): GitSshCredentialMaterial | null }
599
+ | {
600
+ readonly kind: "git_https";
601
+ resolve(credentialRef: string): GitHttpsCredentialMaterial | null;
602
+ };
603
+
544
604
  export interface RepositoryCredentialRegistrar {
545
605
  register(provider: RepositoryCredentialProvider): void;
546
606
  }
547
607
 
608
+ export interface ProcessRuntimeCapabilities {
609
+ /** Install repository-declared development tools with mise before accepting work. */
610
+ readonly developmentTools?: boolean;
611
+ /** Require a Docker CLI connected to a private or explicitly acknowledged daemon. */
612
+ readonly docker?: boolean;
613
+ }
614
+
548
615
  export interface ExtensionProcessDefinition<TParams = unknown, TState = unknown> {
549
616
  id: string;
550
617
  displayName: string;
@@ -563,6 +630,18 @@ export interface ExtensionProcessDefinition<TParams = unknown, TState = unknown>
563
630
  paramsCodec: Codec<TParams>;
564
631
  stateCodec: Codec<TState>;
565
632
  initialState(params: TParams): TState;
633
+ /** Process-owned runtime capabilities. All capabilities default to disabled. */
634
+ runtime?: ProcessRuntimeCapabilities;
635
+ /**
636
+ * Server-only Kubernetes process-volume size, derived from extension configuration.
637
+ * Explicit process storage_size wins; undefined uses the runner default.
638
+ * Called before provisioning on worker starts. Must be synchronous and side-effect free;
639
+ * repeated calls never resize or replace an existing volume.
640
+ */
641
+ resolveStorageSize?(input: {
642
+ params: TParams;
643
+ projects: readonly ProcessProject[];
644
+ }): string | undefined;
566
645
  /** Runtime-only requirements; references are non-secret and remain in opaque params JSON. */
567
646
  repositoryCredentials?(input: {
568
647
  params: TParams;
@@ -595,11 +674,66 @@ export interface ServerExtensionLogger {
595
674
  error?(payload: Record<string, unknown>, message?: string): void;
596
675
  }
597
676
 
677
+ export interface TicketCreationDestinationSummary {
678
+ /** Adapter-owned opaque identifier. Browsers must not construct or interpret it. */
679
+ readonly id: string;
680
+ readonly displayName: string;
681
+ readonly group?: string;
682
+ readonly description?: string;
683
+ }
684
+
685
+ export interface TicketCreationDestinationList {
686
+ readonly destinations: readonly TicketCreationDestinationSummary[];
687
+ readonly warnings?: readonly string[];
688
+ }
689
+
690
+ export interface TicketCreationDestinationSnapshot {
691
+ readonly summary: TicketCreationDestinationSummary;
692
+ /** Adapter-owned, JSON-serializable immutable destination state. */
693
+ readonly data: unknown;
694
+ /** Untrusted destination context included in the ticket agent prompt. */
695
+ readonly agentContext?: string;
696
+ }
697
+
698
+ export interface TicketCreationDestinationContext {
699
+ readonly actor: Actor;
700
+ }
701
+
702
+ export interface TicketCreationDestinationProvider {
703
+ list(ctx: TicketCreationDestinationContext): Promise<TicketCreationDestinationList>;
704
+ resolve(
705
+ ctx: TicketCreationDestinationContext & { destinationId: string },
706
+ ): Promise<TicketCreationDestinationSnapshot>;
707
+ /** Rejects stale, renamed, transferred, or otherwise invalid snapshots. */
708
+ validate(snapshot: TicketCreationDestinationSnapshot): Promise<void>;
709
+ }
710
+
711
+ export interface TicketCreationCapability {
712
+ readonly kind: "ticket_creation";
713
+ readonly displayName: string;
714
+ /** Extension-owned process launched by the generic derived-ticket route. */
715
+ readonly processId: string;
716
+ /** Entry turn selected when the derived process starts. */
717
+ readonly startTurnId: TurnId;
718
+ /** RFC 6901 JSON Pointer into the tool arguments. */
719
+ readonly titlePath?: string;
720
+ /** RFC 6901 JSON Pointer into the tool arguments. */
721
+ readonly descriptionPath?: string;
722
+ readonly destinations?: TicketCreationDestinationProvider;
723
+ }
724
+
725
+ export interface TicketCreationReceipt {
726
+ readonly externalId: string;
727
+ readonly url: string;
728
+ readonly result?: unknown;
729
+ }
730
+
598
731
  export interface IntegrationToolExecutionContext {
599
732
  readonly process: ProcessInstance;
600
733
  readonly projects: readonly ProcessProject[];
601
734
  readonly turn: ProcessTurnRecord;
602
735
  readonly project: ProcessProject | null;
736
+ readonly ticketDestination?: TicketCreationDestinationSnapshot;
603
737
  /** Stable for a single Pi tool call, including reconnect/replay. */
604
738
  readonly idempotencyKey: string;
605
739
  /** Aborted when the worker stops waiting for this tool call. */
@@ -610,6 +744,8 @@ export interface IntegrationToolDefinition<TArgs = Record<string, unknown>> {
610
744
  readonly name: string;
611
745
  readonly description: string;
612
746
  readonly parameters: Record<string, unknown>;
747
+ /** Sanitized discovery metadata; credentials and adapter configuration never belong here. */
748
+ readonly capability?: TicketCreationCapability;
613
749
  parse?(value: unknown): TArgs;
614
750
  execute(ctx: IntegrationToolExecutionContext, args: TArgs): Promise<unknown>;
615
751
  }
@@ -0,0 +1,12 @@
1
+ import type { ExternalActionSource } from "./extension-api.js";
2
+
3
+ /** Define a resolver-based source with no provider input. */
4
+ export function defineExternalActionSource<TConfig>(
5
+ metadata: Pick<ExternalActionSource, "kind" | "label" | "description" | "describeEvent">,
6
+ ) {
7
+ return function source<TParams, TState>(
8
+ resolve: (ctx: { params: TParams; state: TState }) => TConfig,
9
+ ): ExternalActionSource<TParams, TState> {
10
+ return { ...metadata, config: {}, inputMode: "none", resolve };
11
+ };
12
+ }
@@ -0,0 +1,49 @@
1
+ import type {
2
+ ExternalObservationInput,
3
+ ExternalSourceArmingLike,
4
+ ExternalSourceServiceLike,
5
+ } from "./core-capabilities.js";
6
+
7
+ type Arming = Pick<ExternalSourceArmingLike, "id" | "instanceId" | "generation">;
8
+
9
+ /** Report one poll's effects without choosing events, scheduling, or subscription policy. */
10
+ export function createExternalSourcePollReporter(
11
+ sources: ExternalSourceServiceLike,
12
+ result: { created: string[]; errors: string[] },
13
+ options: { forwardGeneration?: boolean } = {},
14
+ ) {
15
+ return {
16
+ async poll(kind: string, read: (armed: ExternalSourceArmingLike) => Promise<void>) {
17
+ for (const armed of sources.listArmed(kind)) {
18
+ try {
19
+ await read(armed);
20
+ } catch (error) {
21
+ result.errors.push(
22
+ `${armed.id}:${error instanceof Error ? error.message : "poll_failed"}`,
23
+ );
24
+ }
25
+ }
26
+ },
27
+ async fire(armed: Arming, event: Record<string, unknown>, mergeKey: string): Promise<boolean> {
28
+ const fired = await sources.fire({
29
+ instanceId: armed.instanceId,
30
+ armingId: armed.id,
31
+ ...(options.forwardGeneration && armed.generation ? { generation: armed.generation } : {}),
32
+ event,
33
+ mergeKey,
34
+ });
35
+ if (fired.ok) result.created.push(armed.id);
36
+ else result.errors.push(`${armed.id}:fire_failed`);
37
+ return fired.ok;
38
+ },
39
+ observe(armed: Arming, input: Pick<ExternalObservationInput, "observation" | "refreshError">) {
40
+ if (sources.observe && armed.generation)
41
+ return sources.observe({
42
+ instanceId: armed.instanceId,
43
+ armingId: armed.id,
44
+ generation: armed.generation,
45
+ ...input,
46
+ });
47
+ },
48
+ };
49
+ }