@leitwerk-dev/process-sdk 0.1.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.
- package/dist/LICENSE +13 -0
- package/dist/browser-ui-extension.d.ts +27 -0
- package/dist/browser-ui-extension.d.ts.map +1 -0
- package/dist/browser-ui-extension.js +2 -0
- package/dist/browser-ui-extension.js.map +1 -0
- package/dist/capabilities.d.ts +9 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +7 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/chunk-5RJZ2E7D.js +58 -0
- package/dist/chunk-5RJZ2E7D.js.map +1 -0
- package/dist/chunk-ITPH65G6.js +197 -0
- package/dist/chunk-ITPH65G6.js.map +1 -0
- package/dist/chunk-LIIP7FMU.js +48 -0
- package/dist/chunk-LIIP7FMU.js.map +1 -0
- package/dist/codecs.d.ts +3 -0
- package/dist/codecs.d.ts.map +1 -0
- package/dist/codecs.js +9 -0
- package/dist/codecs.js.map +1 -0
- package/dist/commit-message.d.ts +7 -0
- package/dist/commit-message.d.ts.map +1 -0
- package/dist/commit-message.js +3 -0
- package/dist/commit-message.js.map +1 -0
- package/dist/core-capabilities.d.ts +393 -0
- package/dist/core-capabilities.d.ts.map +1 -0
- package/dist/core-capabilities.js +6 -0
- package/dist/core-capabilities.js.map +1 -0
- package/dist/define-process.d.ts +269 -0
- package/dist/define-process.d.ts.map +1 -0
- package/dist/define-process.js +1040 -0
- package/dist/define-process.js.map +1 -0
- package/dist/event-bus.d.ts +3 -0
- package/dist/event-bus.d.ts.map +1 -0
- package/dist/event-bus.js +31 -0
- package/dist/event-bus.js.map +1 -0
- package/dist/extension-api-CnlL69Tu.d.ts +1281 -0
- package/dist/extension-api.d.ts +425 -0
- package/dist/extension-api.d.ts.map +1 -0
- package/dist/extension-api.js +5 -0
- package/dist/extension-api.js.map +1 -0
- package/dist/flow.d.ts +456 -0
- package/dist/flow.d.ts.map +1 -0
- package/dist/flow.js +1557 -0
- package/dist/flow.js.map +1 -0
- package/dist/form-contract.d.ts +2 -0
- package/dist/form-contract.d.ts.map +1 -0
- package/dist/form-contract.js +2 -0
- package/dist/form-contract.js.map +1 -0
- package/dist/fs-utils.d.ts +3 -0
- package/dist/fs-utils.d.ts.map +1 -0
- package/dist/fs-utils.js +23 -0
- package/dist/fs-utils.js.map +1 -0
- package/dist/git-binary.d.ts +11 -0
- package/dist/git-binary.d.ts.map +1 -0
- package/dist/git-binary.js +38 -0
- package/dist/git-binary.js.map +1 -0
- package/dist/graph-fragments.d.ts +23 -0
- package/dist/graph-fragments.d.ts.map +1 -0
- package/dist/graph-fragments.js +57 -0
- package/dist/graph-fragments.js.map +1 -0
- package/dist/host-capabilities.d.ts +12 -0
- package/dist/host-capabilities.d.ts.map +1 -0
- package/dist/host-capabilities.js +42 -0
- package/dist/host-capabilities.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/launcher-contract.d.ts +2 -0
- package/dist/launcher-contract.d.ts.map +1 -0
- package/dist/launcher-contract.js +2 -0
- package/dist/launcher-contract.js.map +1 -0
- package/dist/leaf-outcome-renderer.d.ts +48 -0
- package/dist/leaf-outcome-renderer.d.ts.map +1 -0
- package/dist/leaf-outcome-renderer.js +69 -0
- package/dist/leaf-outcome-renderer.js.map +1 -0
- package/dist/leaf-outcomes.d.ts +5 -0
- package/dist/leaf-outcomes.d.ts.map +1 -0
- package/dist/leaf-outcomes.js +52 -0
- package/dist/leaf-outcomes.js.map +1 -0
- package/dist/model-provider.d.ts +210 -0
- package/dist/model-provider.d.ts.map +1 -0
- package/dist/model-provider.js +171 -0
- package/dist/model-provider.js.map +1 -0
- package/dist/pi-config.d.ts +59 -0
- package/dist/pi-config.d.ts.map +1 -0
- package/dist/pi-config.js +182 -0
- package/dist/pi-config.js.map +1 -0
- package/dist/process-definition-internals.d.ts +7 -0
- package/dist/process-definition-internals.d.ts.map +1 -0
- package/dist/process-definition-internals.js +25 -0
- package/dist/process-definition-internals.js.map +1 -0
- package/dist/process-flow-view.d.ts +20 -0
- package/dist/process-flow-view.d.ts.map +1 -0
- package/dist/process-flow-view.js +418 -0
- package/dist/process-flow-view.js.map +1 -0
- package/dist/process-graph.d.ts +45 -0
- package/dist/process-graph.d.ts.map +1 -0
- package/dist/process-graph.js +213 -0
- package/dist/process-graph.js.map +1 -0
- package/dist/process-launcher-builder.d.ts +9 -0
- package/dist/process-launcher-builder.d.ts.map +1 -0
- package/dist/process-launcher-builder.js +43 -0
- package/dist/process-launcher-builder.js.map +1 -0
- package/dist/process-watcher-builder.d.ts +10 -0
- package/dist/process-watcher-builder.d.ts.map +1 -0
- package/dist/process-watcher-builder.js +40 -0
- package/dist/process-watcher-builder.js.map +1 -0
- package/dist/registry-utils.d.ts +8 -0
- package/dist/registry-utils.d.ts.map +1 -0
- package/dist/registry-utils.js +18 -0
- package/dist/registry-utils.js.map +1 -0
- package/dist/repository-git-env.d.ts +8 -0
- package/dist/repository-git-env.d.ts.map +1 -0
- package/dist/repository-git-env.js +26 -0
- package/dist/repository-git-env.js.map +1 -0
- package/dist/review-flow.d.ts +10 -0
- package/dist/review-flow.d.ts.map +1 -0
- package/dist/review-flow.js +44 -0
- package/dist/review-flow.js.map +1 -0
- package/dist/runtime-internals.d.ts +3 -0
- package/dist/runtime-internals.d.ts.map +1 -0
- package/dist/runtime-internals.js +3 -0
- package/dist/runtime-internals.js.map +1 -0
- package/dist/server-events.d.ts +84 -0
- package/dist/server-events.d.ts.map +1 -0
- package/dist/server-events.js +2 -0
- package/dist/server-events.js.map +1 -0
- package/dist/server-process-builder.d.ts +11 -0
- package/dist/server-process-builder.d.ts.map +1 -0
- package/dist/server-process-builder.js +52 -0
- package/dist/server-process-builder.js.map +1 -0
- package/dist/state-helpers.d.ts +9 -0
- package/dist/state-helpers.d.ts.map +1 -0
- package/dist/state-helpers.js +20 -0
- package/dist/state-helpers.js.map +1 -0
- package/dist/subprocess-env.d.ts +12 -0
- package/dist/subprocess-env.d.ts.map +1 -0
- package/dist/subprocess-env.js +34 -0
- package/dist/subprocess-env.js.map +1 -0
- package/dist/tool-renderers.d.ts +10 -0
- package/dist/tool-renderers.d.ts.map +1 -0
- package/dist/tool-renderers.js +63 -0
- package/dist/tool-renderers.js.map +1 -0
- package/dist/turn-semantics.d.ts +22 -0
- package/dist/turn-semantics.d.ts.map +1 -0
- package/dist/turn-semantics.js +339 -0
- package/dist/turn-semantics.js.map +1 -0
- package/dist/types.d.ts +295 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +12 -0
- package/dist/types.js.map +1 -0
- package/dist/ui-process-builder.d.ts +9 -0
- package/dist/ui-process-builder.d.ts.map +1 -0
- package/dist/ui-process-builder.js +30 -0
- package/dist/ui-process-builder.js.map +1 -0
- package/dist/worker-process-builder.d.ts +10 -0
- package/dist/worker-process-builder.d.ts.map +1 -0
- package/dist/worker-process-builder.js +22 -0
- package/dist/worker-process-builder.js.map +1 -0
- package/package.json +72 -0
- package/src/browser-ui-extension.ts +32 -0
- package/src/capabilities.ts +16 -0
- package/src/codecs.ts +10 -0
- package/src/commit-message.ts +9 -0
- package/src/core-capabilities.ts +526 -0
- package/src/define-process.ts +1879 -0
- package/src/event-bus.ts +35 -0
- package/src/extension-api.ts +600 -0
- package/src/flow.ts +2268 -0
- package/src/form-contract.ts +11 -0
- package/src/fs-utils.ts +28 -0
- package/src/git-binary.ts +40 -0
- package/src/graph-fragments.ts +110 -0
- package/src/host-capabilities.ts +60 -0
- package/src/index.ts +468 -0
- package/src/launcher-contract.ts +8 -0
- package/src/leaf-outcome-renderer.ts +112 -0
- package/src/leaf-outcomes.ts +74 -0
- package/src/model-provider.ts +461 -0
- package/src/pi-config.ts +268 -0
- package/src/process-definition-internals.ts +46 -0
- package/src/process-flow-view.ts +479 -0
- package/src/process-graph.ts +309 -0
- package/src/process-launcher-builder.ts +59 -0
- package/src/process-watcher-builder.ts +72 -0
- package/src/registry-utils.ts +31 -0
- package/src/repository-git-env.ts +35 -0
- package/src/review-flow.ts +66 -0
- package/src/runtime-internals.ts +7 -0
- package/src/server-events.ts +105 -0
- package/src/server-process-builder.ts +90 -0
- package/src/state-helpers.ts +36 -0
- package/src/subprocess-env.ts +48 -0
- package/src/tool-renderers.ts +92 -0
- package/src/turn-semantics.ts +554 -0
- package/src/types.ts +391 -0
- package/src/ui-process-builder.ts +46 -0
- package/src/worker-process-builder.ts +33 -0
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Actor,
|
|
3
|
+
InputKind,
|
|
4
|
+
InputSource,
|
|
5
|
+
LaunchModelConfigInput,
|
|
6
|
+
ProcessEvent,
|
|
7
|
+
ProcessInputTarget,
|
|
8
|
+
ProcessInstance,
|
|
9
|
+
ProcessLifecycleStatus,
|
|
10
|
+
ProcessProject,
|
|
11
|
+
TurnId,
|
|
12
|
+
WorkerErrorClass,
|
|
13
|
+
} from "@leitwerk-dev/domain";
|
|
14
|
+
import type {
|
|
15
|
+
KnownDurableWsFrameType,
|
|
16
|
+
KnownEphemeralWsFrameType,
|
|
17
|
+
LauncherModelConfigPreview,
|
|
18
|
+
LauncherModelConfigSchema,
|
|
19
|
+
ProcessActionModelPreview,
|
|
20
|
+
ProcessWatcherType,
|
|
21
|
+
WsPayloadByType,
|
|
22
|
+
} from "@leitwerk-dev/protocol";
|
|
23
|
+
import { createCapabilityToken } from "./capabilities.js";
|
|
24
|
+
import type {
|
|
25
|
+
ExternalActionSource,
|
|
26
|
+
FormDefinition,
|
|
27
|
+
LauncherContext,
|
|
28
|
+
ProcessLaunchConfig,
|
|
29
|
+
ProcessLauncherService,
|
|
30
|
+
ProcessLaunchPlan,
|
|
31
|
+
RepositoryCredentialRegistrar,
|
|
32
|
+
} from "./extension-api.js";
|
|
33
|
+
|
|
34
|
+
export interface ProcessCreateInputLike {
|
|
35
|
+
processId?: ProcessInstance["processId"];
|
|
36
|
+
selectedTurnId?: ProcessInstance["selectedTurnId"];
|
|
37
|
+
lifecycleStatus?: ProcessInstance["lifecycleStatus"];
|
|
38
|
+
title?: string | null;
|
|
39
|
+
externalId?: string | null;
|
|
40
|
+
externalUrl?: string | null;
|
|
41
|
+
metadata?: Record<string, unknown> | null;
|
|
42
|
+
defaultModelProfileId?: string | null;
|
|
43
|
+
turnConfigsJson?: string | null;
|
|
44
|
+
selectedTurnModelProfileId?: string | null;
|
|
45
|
+
paramsJson?: string | null;
|
|
46
|
+
stateJson?: string | null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface ProcessRepoLike {
|
|
50
|
+
create(input: ProcessCreateInputLike): ProcessInstance;
|
|
51
|
+
getById(id: string): ProcessInstance | null;
|
|
52
|
+
listAll(): ProcessInstance[];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface ProcessProjectRepoLike {
|
|
56
|
+
/** Server-provided project mutation service. Implementations should emit project.updated after committed writes. */
|
|
57
|
+
create(input: {
|
|
58
|
+
instanceId: string;
|
|
59
|
+
key: string;
|
|
60
|
+
repoLocator: string;
|
|
61
|
+
baseBranch: string;
|
|
62
|
+
workBranch?: string | null;
|
|
63
|
+
externalId?: string | null;
|
|
64
|
+
externalUrl?: string | null;
|
|
65
|
+
metadata?: Record<string, unknown> | null;
|
|
66
|
+
pipelineStatus?: string | null;
|
|
67
|
+
}): ProcessProject;
|
|
68
|
+
getByInstanceAndKey(instanceId: string, key: string): ProcessProject | null;
|
|
69
|
+
update(
|
|
70
|
+
id: string,
|
|
71
|
+
input: {
|
|
72
|
+
baseBranch?: string;
|
|
73
|
+
workBranch?: string | null;
|
|
74
|
+
externalId?: string | null;
|
|
75
|
+
externalUrl?: string | null;
|
|
76
|
+
metadata?: Record<string, unknown> | null;
|
|
77
|
+
pipelineStatus?: string | null;
|
|
78
|
+
},
|
|
79
|
+
): ProcessProject | null;
|
|
80
|
+
listByInstance(instanceId: string): ProcessProject[];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface ProcessEventRepoLike {
|
|
84
|
+
create(input: { instanceId: string; eventType: string; data?: Record<string, unknown> }): unknown;
|
|
85
|
+
listByInstance(instanceId: string, limit?: number): ProcessEvent[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface BroadcasterLike {
|
|
89
|
+
sendDurable<T extends KnownDurableWsFrameType>(
|
|
90
|
+
type: T,
|
|
91
|
+
payload: WsPayloadByType[T],
|
|
92
|
+
instanceId?: string,
|
|
93
|
+
): void;
|
|
94
|
+
sendEphemeral?<T extends KnownEphemeralWsFrameType>(
|
|
95
|
+
type: T,
|
|
96
|
+
payload: WsPayloadByType[T],
|
|
97
|
+
instanceId?: string,
|
|
98
|
+
): void;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export type LaunchModelConfigInputLike = LaunchModelConfigInput;
|
|
102
|
+
export type LauncherModelConfigSchemaLike = LauncherModelConfigSchema;
|
|
103
|
+
export type LauncherModelConfigPreviewLike = LauncherModelConfigPreview;
|
|
104
|
+
|
|
105
|
+
export interface LauncherModelConfigServiceLike {
|
|
106
|
+
getSchema(launcherId: string): Promise<LauncherModelConfigSchemaLike | null>;
|
|
107
|
+
preview(
|
|
108
|
+
launcherId: string,
|
|
109
|
+
launcherInput: Record<string, unknown>,
|
|
110
|
+
opts?: { modelConfig?: LaunchModelConfigInputLike },
|
|
111
|
+
): Promise<LauncherModelConfigPreviewLike | null>;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Stable, machine-readable codes returned while preparing a launch. */
|
|
115
|
+
export type LaunchPlanPreparationIssueCode =
|
|
116
|
+
| "process_id_mismatch"
|
|
117
|
+
| "invalid_turn_configs_json"
|
|
118
|
+
| "unknown_model_profile"
|
|
119
|
+
| "model_profile_not_allowed"
|
|
120
|
+
| "unknown_llm_turn"
|
|
121
|
+
| "selected_turn_model_requires_selected_turn"
|
|
122
|
+
| "selected_turn_model_requires_llm_turn"
|
|
123
|
+
| "model_required";
|
|
124
|
+
|
|
125
|
+
/** Complete, presentation-safe diagnostic returned while preparing a launch. */
|
|
126
|
+
export interface LaunchPlanPreparationIssue {
|
|
127
|
+
readonly code: LaunchPlanPreparationIssueCode;
|
|
128
|
+
readonly message: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export type LaunchPlanPreparationResultLike =
|
|
132
|
+
| {
|
|
133
|
+
ok: true;
|
|
134
|
+
launchPlan: ProcessLaunchPlan;
|
|
135
|
+
modelConfig: LaunchModelConfigInputLike;
|
|
136
|
+
warnings: readonly LaunchPlanPreparationIssue[];
|
|
137
|
+
}
|
|
138
|
+
| {
|
|
139
|
+
ok: false;
|
|
140
|
+
/** Normalized durable plan retained when a scheduled launch is blocked. */
|
|
141
|
+
launchPlan: ProcessLaunchPlan;
|
|
142
|
+
modelConfig: LaunchModelConfigInputLike;
|
|
143
|
+
errors: readonly LaunchPlanPreparationIssue[];
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export interface ProcessLaunchPlanServiceLike {
|
|
147
|
+
prepare(
|
|
148
|
+
launchPlan: ProcessLaunchPlan,
|
|
149
|
+
opts?: {
|
|
150
|
+
modelConfig?: LaunchModelConfigInputLike;
|
|
151
|
+
replaceModelConfig?: boolean;
|
|
152
|
+
invalidModelConfig?: "reject" | "omit";
|
|
153
|
+
},
|
|
154
|
+
): Promise<LaunchPlanPreparationResultLike>;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface HandoffDedupKeyRecordLike {
|
|
158
|
+
key: string;
|
|
159
|
+
instanceId: string;
|
|
160
|
+
createdAt: string;
|
|
161
|
+
metadata: Record<string, unknown>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface HandoffDedupKeyServiceLike {
|
|
165
|
+
getByKey(key: string): HandoffDedupKeyRecordLike | null;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface WorkerSupervisorLike {
|
|
169
|
+
spawnWorker(instanceId: string): Promise<unknown>;
|
|
170
|
+
getWorker(instanceId: string): unknown | undefined;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface ProcessEngineResultLike {
|
|
174
|
+
ok: boolean;
|
|
175
|
+
code?: string;
|
|
176
|
+
message?: string;
|
|
177
|
+
process?: ProcessInstance | null;
|
|
178
|
+
stage?: "pre_commit" | "post_commit";
|
|
179
|
+
data?: unknown;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface DeferredProcessActivationExpected {
|
|
183
|
+
processId: string;
|
|
184
|
+
lifecycleStatus: ProcessLifecycleStatus;
|
|
185
|
+
selectedTurnId: TurnId | null;
|
|
186
|
+
title: string | null;
|
|
187
|
+
paramsJson: string | null;
|
|
188
|
+
projectId: string;
|
|
189
|
+
projectKey: string;
|
|
190
|
+
repoLocator: string;
|
|
191
|
+
baseBranch: string;
|
|
192
|
+
workBranch: string | null;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface DeferredProcessActivationSnapshot extends DeferredProcessActivationExpected {
|
|
196
|
+
instanceId: string;
|
|
197
|
+
processMetadata: Record<string, unknown> | null;
|
|
198
|
+
projectMetadata: Record<string, unknown> | null;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface DeferredProcessActivationSnapshotQuery {
|
|
202
|
+
projectKey: string;
|
|
203
|
+
instanceId?: string;
|
|
204
|
+
processId?: string;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export type DeferredProcessActivationSnapshotResult =
|
|
208
|
+
| { outcome: "ready"; snapshots: DeferredProcessActivationSnapshot[] }
|
|
209
|
+
| { outcome: "process_not_found" }
|
|
210
|
+
| { outcome: "project_not_found" };
|
|
211
|
+
|
|
212
|
+
export interface DeferredProcessActivationEvent {
|
|
213
|
+
eventType: string;
|
|
214
|
+
data?: Record<string, unknown>;
|
|
215
|
+
level: "info" | "warn" | "error";
|
|
216
|
+
message: string;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface PreparedDeferredProcessActivation {
|
|
220
|
+
expected: DeferredProcessActivationExpected;
|
|
221
|
+
workBranch: string;
|
|
222
|
+
paramsJson: string;
|
|
223
|
+
projectMetadata: Record<string, unknown> | null;
|
|
224
|
+
selectedTurnId: TurnId;
|
|
225
|
+
event: DeferredProcessActivationEvent;
|
|
226
|
+
actor?: Actor;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export type DeferredProcessActivationOutcome =
|
|
230
|
+
| "activated"
|
|
231
|
+
| "already_activated"
|
|
232
|
+
| "stale"
|
|
233
|
+
| "not_applicable"
|
|
234
|
+
| "project_not_found"
|
|
235
|
+
| "invalid_selected_turn";
|
|
236
|
+
|
|
237
|
+
export interface DeferredProcessActivationFailure {
|
|
238
|
+
expected: DeferredProcessActivationExpected;
|
|
239
|
+
errorClass: WorkerErrorClass;
|
|
240
|
+
event: DeferredProcessActivationEvent;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export type ProcessActionExecutionSource = "ui" | "external" | "scheduled";
|
|
244
|
+
export type ProcessActionExecutionOrigin = "web_ui" | "external_interface" | "scheduled";
|
|
245
|
+
|
|
246
|
+
export interface ProcessActionSummaryLike {
|
|
247
|
+
id: string;
|
|
248
|
+
label: string;
|
|
249
|
+
description?: string | null;
|
|
250
|
+
form?: FormDefinition;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export type ActionExecutionFailureStageLike = "pre_commit" | "post_commit";
|
|
254
|
+
|
|
255
|
+
export type ActionExecutionResultLike =
|
|
256
|
+
| {
|
|
257
|
+
ok: true;
|
|
258
|
+
process: ProcessInstance | null;
|
|
259
|
+
data?: Record<string, unknown>;
|
|
260
|
+
error?: undefined;
|
|
261
|
+
code?: undefined;
|
|
262
|
+
stage?: undefined;
|
|
263
|
+
}
|
|
264
|
+
| {
|
|
265
|
+
ok: false;
|
|
266
|
+
stage: "pre_commit";
|
|
267
|
+
error: string;
|
|
268
|
+
code?: string;
|
|
269
|
+
process?: undefined;
|
|
270
|
+
data?: undefined;
|
|
271
|
+
}
|
|
272
|
+
| {
|
|
273
|
+
ok: false;
|
|
274
|
+
stage: "post_commit";
|
|
275
|
+
process: ProcessInstance;
|
|
276
|
+
error: string;
|
|
277
|
+
code?: string;
|
|
278
|
+
data?: Record<string, unknown>;
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
export interface ProcessActionServiceLike {
|
|
282
|
+
listVisibleActions(instanceId: string): readonly ProcessActionSummaryLike[];
|
|
283
|
+
executeAction(
|
|
284
|
+
instanceId: string,
|
|
285
|
+
actionId: string,
|
|
286
|
+
input: Record<string, unknown>,
|
|
287
|
+
opts?: {
|
|
288
|
+
source?: ProcessActionExecutionSource;
|
|
289
|
+
origin?: ProcessActionExecutionOrigin;
|
|
290
|
+
nextTurnModelProfileId?: string | null;
|
|
291
|
+
actor?: Actor;
|
|
292
|
+
},
|
|
293
|
+
): Promise<ActionExecutionResultLike>;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export interface ExternalSourceArmingLike {
|
|
297
|
+
/** Process-local arming id. Durable arming identity is { instanceId, id }. */
|
|
298
|
+
id: string;
|
|
299
|
+
instanceId: string;
|
|
300
|
+
processId: string;
|
|
301
|
+
turnId: string;
|
|
302
|
+
externalActionId: string;
|
|
303
|
+
source: ExternalActionSource;
|
|
304
|
+
resolved: unknown;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export interface ExternalSourceFireInput {
|
|
308
|
+
instanceId: string;
|
|
309
|
+
armingId: string;
|
|
310
|
+
input?: Record<string, unknown>;
|
|
311
|
+
event?: Record<string, unknown>;
|
|
312
|
+
mergeKey?: string | null;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export interface ExternalSourceServiceLike {
|
|
316
|
+
listArmed(kind: string): readonly ExternalSourceArmingLike[];
|
|
317
|
+
fire(input: ExternalSourceFireInput): Promise<ActionExecutionResultLike>;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export type ProcessLaunchFailureStageLike = "pre_commit" | "post_commit";
|
|
321
|
+
|
|
322
|
+
export type ProcessLaunchExecutionResultLike =
|
|
323
|
+
| { ok: true; process: ProcessInstance; projects: ProcessProject[]; reused: boolean }
|
|
324
|
+
| {
|
|
325
|
+
ok: false;
|
|
326
|
+
stage: "pre_commit";
|
|
327
|
+
status: number;
|
|
328
|
+
body: Record<string, unknown>;
|
|
329
|
+
}
|
|
330
|
+
| {
|
|
331
|
+
ok: false;
|
|
332
|
+
stage: "post_commit";
|
|
333
|
+
status: number;
|
|
334
|
+
body: Record<string, unknown>;
|
|
335
|
+
process: ProcessInstance;
|
|
336
|
+
projects: ProcessProject[];
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
export interface ProcessLaunchConfigExecutionInput {
|
|
340
|
+
launcherId: string;
|
|
341
|
+
launchConfig: ProcessLaunchConfig;
|
|
342
|
+
handoffDedupKey?: string | null;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export interface ProcessLaunchExecutorLike {
|
|
346
|
+
createProcessFromLaunchConfig(
|
|
347
|
+
input: ProcessLaunchConfigExecutionInput,
|
|
348
|
+
opts?: { actor?: Actor },
|
|
349
|
+
): Promise<ProcessLaunchExecutionResultLike>;
|
|
350
|
+
createProcessFromLaunchPlan(
|
|
351
|
+
launchPlan: ProcessLaunchPlan,
|
|
352
|
+
opts?: { actor?: Actor },
|
|
353
|
+
): Promise<ProcessLaunchExecutionResultLike>;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export interface LauncherRecentValuesServiceLike {
|
|
357
|
+
list(launcherId: string): Record<string, readonly string[]>;
|
|
358
|
+
record(launcherId: string, launcherInput: Record<string, unknown>): void;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export interface QueuedProcessInputLike {
|
|
362
|
+
source: InputSource;
|
|
363
|
+
kind: InputKind;
|
|
364
|
+
bodyMarkdown: string;
|
|
365
|
+
target?: ProcessInputTarget | null;
|
|
366
|
+
actor?: Actor;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export interface ProcessEngineLike {
|
|
370
|
+
getDeferredProcessActivationSnapshots(
|
|
371
|
+
query: DeferredProcessActivationSnapshotQuery,
|
|
372
|
+
): DeferredProcessActivationSnapshotResult;
|
|
373
|
+
activateDeferredProcess(
|
|
374
|
+
instanceId: string,
|
|
375
|
+
prepared: PreparedDeferredProcessActivation,
|
|
376
|
+
): Promise<ProcessEngineResultLike & { data?: { outcome: DeferredProcessActivationOutcome } }>;
|
|
377
|
+
parkDeferredProcessActivationFailure(
|
|
378
|
+
instanceId: string,
|
|
379
|
+
failure: DeferredProcessActivationFailure,
|
|
380
|
+
): Promise<
|
|
381
|
+
ProcessEngineResultLike & {
|
|
382
|
+
data?: {
|
|
383
|
+
outcome: "parked" | "stale" | "not_applicable" | "project_not_found";
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
>;
|
|
387
|
+
startProcess(instanceId: string, startTurnId: TurnId): Promise<ProcessEngineResultLike>;
|
|
388
|
+
abortProcess(instanceId: string, opts?: { actor?: Actor }): Promise<ProcessEngineResultLike>;
|
|
389
|
+
retryProcess(
|
|
390
|
+
instanceId: string,
|
|
391
|
+
opts?: { nextTurnModelProfileId?: string | null; actor?: Actor },
|
|
392
|
+
): Promise<ProcessEngineResultLike>;
|
|
393
|
+
continueFailedTurn(
|
|
394
|
+
instanceId: string,
|
|
395
|
+
turnRecordId: string,
|
|
396
|
+
options?: { prompt?: string | null; nextTurnModelProfileId?: string | null; actor?: Actor },
|
|
397
|
+
): Promise<ProcessEngineResultLike>;
|
|
398
|
+
queueInputs(
|
|
399
|
+
instanceId: string,
|
|
400
|
+
inputs: readonly QueuedProcessInputLike[],
|
|
401
|
+
opts?: { dispatchErrorMessage?: string; actor?: Actor },
|
|
402
|
+
): Promise<ProcessEngineResultLike>;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
export interface ComponentConfigLike {
|
|
406
|
+
repo: string;
|
|
407
|
+
default_branch: string;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
export interface ProcessWatcherConfigLike {
|
|
411
|
+
type: ProcessWatcherType;
|
|
412
|
+
[key: string]: unknown;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export interface RegisteredProcessWatcherLike {
|
|
416
|
+
processId: string;
|
|
417
|
+
processDisplayName: string;
|
|
418
|
+
watcherId: string;
|
|
419
|
+
watcherLabel: string;
|
|
420
|
+
watcherDescription: string;
|
|
421
|
+
type: ProcessWatcherType;
|
|
422
|
+
enabled: boolean;
|
|
423
|
+
pollInterval: string;
|
|
424
|
+
configPath: string;
|
|
425
|
+
config: ProcessWatcherConfigLike;
|
|
426
|
+
launchModelConfig: LaunchModelConfigInputLike;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
export interface ResolvedProcessWatcherStartLike {
|
|
430
|
+
watcher: RegisteredProcessWatcherLike;
|
|
431
|
+
launchPlan: ProcessLaunchPlan;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
export interface ProcessWatcherServiceLike {
|
|
435
|
+
listAll(): readonly RegisteredProcessWatcherLike[];
|
|
436
|
+
listByType(type: ProcessWatcherType): readonly RegisteredProcessWatcherLike[];
|
|
437
|
+
resolveLaunch(
|
|
438
|
+
processId: string,
|
|
439
|
+
watcherId: string,
|
|
440
|
+
payload: unknown,
|
|
441
|
+
ctx?: LauncherContext,
|
|
442
|
+
): Promise<ResolvedProcessWatcherStartLike | null>;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export interface ProcessQuestionServiceLike {
|
|
446
|
+
listOpen(instanceId?: string): readonly import("@leitwerk-dev/domain").ProcessQuestionRequest[];
|
|
447
|
+
submitAnswers(
|
|
448
|
+
instanceId: string,
|
|
449
|
+
requestId: string,
|
|
450
|
+
draft: readonly import("@leitwerk-dev/domain").QuestionAnswerDraft[],
|
|
451
|
+
actor: Actor,
|
|
452
|
+
): Promise<
|
|
453
|
+
| { ok: true; request: import("@leitwerk-dev/domain").ProcessQuestionRequest }
|
|
454
|
+
| {
|
|
455
|
+
ok: false;
|
|
456
|
+
code: "not_found" | "not_current" | "invalid";
|
|
457
|
+
message: string;
|
|
458
|
+
request?: import("@leitwerk-dev/domain").ProcessQuestionRequest;
|
|
459
|
+
}
|
|
460
|
+
>;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
export interface CoreServerSetupDeps {
|
|
464
|
+
serverBaseUrl: string;
|
|
465
|
+
processWorkspacesDir?: string;
|
|
466
|
+
components: Record<string, ComponentConfigLike>;
|
|
467
|
+
/** Typed by consuming extensions via watcher-utils ExternalWriteLogRepoLike. */
|
|
468
|
+
externalWrites: unknown;
|
|
469
|
+
processes: ProcessRepoLike;
|
|
470
|
+
projects: ProcessProjectRepoLike;
|
|
471
|
+
events: ProcessEventRepoLike;
|
|
472
|
+
broadcaster: BroadcasterLike;
|
|
473
|
+
commands: ProcessEngineLike;
|
|
474
|
+
processActions: ProcessActionServiceLike;
|
|
475
|
+
externalSources: ExternalSourceServiceLike;
|
|
476
|
+
getSupervisor: () => WorkerSupervisorLike | undefined;
|
|
477
|
+
launcherService: ProcessLauncherService;
|
|
478
|
+
launcherRecentValues: LauncherRecentValuesServiceLike;
|
|
479
|
+
launcherModelConfigs: LauncherModelConfigServiceLike;
|
|
480
|
+
launchPlans: ProcessLaunchPlanServiceLike;
|
|
481
|
+
processLaunches: ProcessLaunchExecutorLike;
|
|
482
|
+
handoffDedupKeys?: HandoffDedupKeyServiceLike;
|
|
483
|
+
processWatchers?: ProcessWatcherServiceLike;
|
|
484
|
+
processModelSelection?: ProcessModelSelectionServiceLike;
|
|
485
|
+
/** Durable active-turn questions for trusted operator-channel extensions. */
|
|
486
|
+
processQuestions?: ProcessQuestionServiceLike;
|
|
487
|
+
/** Registration boundary for secret-backed repository credential extensions. */
|
|
488
|
+
repositoryCredentials: RepositoryCredentialRegistrar;
|
|
489
|
+
/** Server-owned managed result images, available to trusted delivery extensions. */
|
|
490
|
+
resultImages?: {
|
|
491
|
+
get(instanceId: string, turnRecordId: string, imageId: string): Promise<Uint8Array | null>;
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
export type ProcessActionModelPreviewLike = ProcessActionModelPreview;
|
|
496
|
+
|
|
497
|
+
export type ProcessModelSelectionPreviewFailureCode =
|
|
498
|
+
| "process_not_found"
|
|
499
|
+
| "instance_tree_unavailable";
|
|
500
|
+
|
|
501
|
+
export type ProcessModelSelectionPreviewResultLike =
|
|
502
|
+
| ProcessActionModelPreviewLike
|
|
503
|
+
| { kind: "operational_failure"; code: ProcessModelSelectionPreviewFailureCode };
|
|
504
|
+
|
|
505
|
+
export interface ModelProfileOptionSummaryLike {
|
|
506
|
+
id: string;
|
|
507
|
+
label: string;
|
|
508
|
+
description: string;
|
|
509
|
+
availability: "available" | "unavailable" | "stale";
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
export interface ProcessModelSelectionServiceLike {
|
|
513
|
+
listAvailableProfiles(instanceId: string): readonly ModelProfileOptionSummaryLike[] | null;
|
|
514
|
+
preview(
|
|
515
|
+
instanceId: string,
|
|
516
|
+
actionId: string,
|
|
517
|
+
input: Record<string, unknown>,
|
|
518
|
+
): Promise<ProcessModelSelectionPreviewResultLike>;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
export const coreHostCapabilities = {
|
|
522
|
+
serverSetup: createCapabilityToken<CoreServerSetupDeps>("core:serverSetup"),
|
|
523
|
+
processModelSelection: createCapabilityToken<ProcessModelSelectionServiceLike>(
|
|
524
|
+
"core:processModelSelection",
|
|
525
|
+
),
|
|
526
|
+
} as const;
|