@leitwerk-dev/process-sdk 0.1.8 → 0.1.9
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/core-capabilities.d.ts +6 -0
- package/dist/core-capabilities.d.ts.map +1 -1
- package/dist/core-capabilities.js.map +1 -1
- package/dist/define-process.d.ts +23 -10
- package/dist/define-process.d.ts.map +1 -1
- package/dist/define-process.js +182 -144
- package/dist/define-process.js.map +1 -1
- package/dist/{extension-api-CqPGRqc9.d.ts → extension-api-BBcwktmc.d.ts} +30 -10
- package/dist/extension-api.d.ts +8 -1
- package/dist/extension-api.d.ts.map +1 -1
- package/dist/extension-api.js.map +1 -1
- package/dist/flow.d.ts +14 -8
- package/dist/flow.d.ts.map +1 -1
- package/dist/flow.js +115 -35
- package/dist/flow.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/process-graph.d.ts +1 -2
- package/dist/process-graph.d.ts.map +1 -1
- package/dist/process-graph.js +0 -1
- package/dist/process-graph.js.map +1 -1
- package/dist/process-watcher-source.d.ts +3 -1
- package/dist/process-watcher-source.d.ts.map +1 -1
- package/dist/process-watcher-source.js +8 -1
- package/dist/process-watcher-source.js.map +1 -1
- package/dist/state-helpers.d.ts +1 -2
- package/dist/state-helpers.d.ts.map +1 -1
- package/dist/state-helpers.js +1 -3
- package/dist/state-helpers.js.map +1 -1
- package/package.json +4 -4
- package/src/core-capabilities.ts +9 -0
- package/src/define-process.ts +266 -189
- package/src/extension-api.ts +8 -0
- package/src/flow.ts +172 -59
- package/src/index.ts +2 -0
- package/src/process-graph.ts +0 -3
- package/src/process-watcher-source.ts +10 -2
- package/src/state-helpers.ts +0 -5
package/src/extension-api.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
ProcessSemanticEntryRefKey,
|
|
11
11
|
ProcessTurnRecord,
|
|
12
12
|
TurnId,
|
|
13
|
+
TurnProgressReport,
|
|
13
14
|
} from "@leitwerk-dev/domain";
|
|
14
15
|
import type { WatcherPresentationField } from "@leitwerk-dev/protocol";
|
|
15
16
|
import type { CapabilityToken } from "./capabilities.js";
|
|
@@ -100,6 +101,8 @@ export interface ProcessLaunchConfig<TParams = unknown> {
|
|
|
100
101
|
metadata?: Record<string, unknown> | null;
|
|
101
102
|
defaultModelProfileId?: string | null;
|
|
102
103
|
turnConfigs?: Record<string, { modelProfileId?: string | null }>;
|
|
104
|
+
/** Skill ids resolved to active immutable revisions before process creation. */
|
|
105
|
+
skillIds?: readonly string[];
|
|
103
106
|
projects?: readonly ProcessLaunchProjectConfig[];
|
|
104
107
|
}
|
|
105
108
|
|
|
@@ -200,6 +203,7 @@ export interface ProcessLaunchPlan {
|
|
|
200
203
|
titleSourceFields?: readonly ProcessTitleSourceField[];
|
|
201
204
|
projectInputs: readonly ProcessLaunchProjectConfig[];
|
|
202
205
|
startTurnId: TurnId | null;
|
|
206
|
+
skillIds?: readonly string[];
|
|
203
207
|
}
|
|
204
208
|
|
|
205
209
|
export interface ResolvedProcessLauncher<TParams = unknown> {
|
|
@@ -448,6 +452,10 @@ export interface WorkerProcessContext<TParams = unknown, TState = unknown>
|
|
|
448
452
|
readonly turnResultMarkdownByProduct?: Readonly<Record<string, string>>;
|
|
449
453
|
/** Absolute workspace root for the current process instance, when available. */
|
|
450
454
|
readonly workspaceRoot?: string;
|
|
455
|
+
/** Invoke a server-owned integration tool authorized for this automatic turn. */
|
|
456
|
+
callIntegrationTool?(name: string, args: Record<string, unknown>): Promise<unknown>;
|
|
457
|
+
/** Replace the durable operator-facing progress report for this automatic turn attempt. */
|
|
458
|
+
reportProgress?(report: TurnProgressReport): void;
|
|
451
459
|
}
|
|
452
460
|
|
|
453
461
|
export interface WorkerCompleteInput<TOutcome extends string = string> {
|
package/src/flow.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import {
|
|
3
3
|
assertValidProcessProductName,
|
|
4
|
-
createReviewSubject,
|
|
5
4
|
humanizeProcessLabel,
|
|
6
5
|
type ProcessInstance,
|
|
7
6
|
type ProcessProject,
|
|
8
7
|
type ProcessSemanticEntryRefKey,
|
|
9
8
|
type ProcessTurnStartSelection,
|
|
10
9
|
type ProcessTurnTerminalLifecycleStatus,
|
|
11
|
-
type ReviewSubject,
|
|
12
10
|
type TurnId,
|
|
11
|
+
type TurnProgressReport,
|
|
13
12
|
} from "@leitwerk-dev/domain";
|
|
14
13
|
import type {
|
|
15
14
|
AutomaticTurnDefinition,
|
|
@@ -163,6 +162,8 @@ export interface FlowAutomaticRunContext<TParams = unknown, TState = unknown> {
|
|
|
163
162
|
state: TState;
|
|
164
163
|
workspaceRoot?: string;
|
|
165
164
|
repo: FlowRepoLookup;
|
|
165
|
+
callIntegrationTool(name: string, args: Record<string, unknown>): Promise<unknown>;
|
|
166
|
+
reportProgress(report: TurnProgressReport): void;
|
|
166
167
|
}
|
|
167
168
|
|
|
168
169
|
export interface FlowLlmOutcomeEffectContext<TParams = unknown, TState = unknown> {
|
|
@@ -462,6 +463,15 @@ export function createFlowAutomaticRunContext<TParams, TState>(
|
|
|
462
463
|
projects: ctx.projects,
|
|
463
464
|
workspaceRoot: ctx.workspaceRoot,
|
|
464
465
|
}),
|
|
466
|
+
callIntegrationTool(name, args) {
|
|
467
|
+
if (!ctx.callIntegrationTool) {
|
|
468
|
+
throw new Error(`Automatic integration tool '${name}' is unavailable`);
|
|
469
|
+
}
|
|
470
|
+
return ctx.callIntegrationTool(name, args);
|
|
471
|
+
},
|
|
472
|
+
reportProgress(report) {
|
|
473
|
+
ctx.reportProgress?.(report);
|
|
474
|
+
},
|
|
465
475
|
};
|
|
466
476
|
}
|
|
467
477
|
|
|
@@ -798,10 +808,43 @@ export class OutcomeToolBuilder<
|
|
|
798
808
|
TState,
|
|
799
809
|
FlowLlmOutcomeEffectContext<TParams, TState>
|
|
800
810
|
> {
|
|
811
|
+
private stateRouting:
|
|
812
|
+
| {
|
|
813
|
+
branches: Record<string, TurnId>;
|
|
814
|
+
choose: (
|
|
815
|
+
input: FlowOutcomeEffectInput<
|
|
816
|
+
TParams,
|
|
817
|
+
TState,
|
|
818
|
+
FlowLlmOutcomeEffectContext<TParams, TState>
|
|
819
|
+
>,
|
|
820
|
+
) => MaybePromise<string>;
|
|
821
|
+
}
|
|
822
|
+
| undefined;
|
|
823
|
+
|
|
824
|
+
routeByState(
|
|
825
|
+
branches: Record<string, TurnId>,
|
|
826
|
+
choose: (
|
|
827
|
+
input: FlowOutcomeEffectInput<TParams, TState, FlowLlmOutcomeEffectContext<TParams, TState>>,
|
|
828
|
+
) => MaybePromise<string>,
|
|
829
|
+
): this {
|
|
830
|
+
if (this.hasRoute() || this.stateRouting) {
|
|
831
|
+
throw new Error("State-routed outcome cannot declare another route");
|
|
832
|
+
}
|
|
833
|
+
if (Object.keys(branches).length === 0) {
|
|
834
|
+
throw new Error("State-routed outcome must declare at least one branch");
|
|
835
|
+
}
|
|
836
|
+
this.stateRouting = { branches, choose };
|
|
837
|
+
return this;
|
|
838
|
+
}
|
|
839
|
+
|
|
801
840
|
build(): ProcessToolOutcomeSpec<TParams, TState> {
|
|
802
841
|
if (!this.outcomeDescription) {
|
|
803
842
|
throw new Error("LLM outcome tool must declare .description(...)");
|
|
804
843
|
}
|
|
844
|
+
if (this.stateRouting && this.hasRoute()) {
|
|
845
|
+
throw new Error("State-routed outcome cannot declare another route");
|
|
846
|
+
}
|
|
847
|
+
const stateRouting = this.stateRouting;
|
|
805
848
|
return {
|
|
806
849
|
description: this.outcomeDescription,
|
|
807
850
|
parameters: this.parameters,
|
|
@@ -811,7 +854,26 @@ export class OutcomeToolBuilder<
|
|
|
811
854
|
turnResultMarkdownParameter: this.publishedMarkdownParameter,
|
|
812
855
|
}
|
|
813
856
|
: {}),
|
|
814
|
-
...
|
|
857
|
+
...(stateRouting
|
|
858
|
+
? {
|
|
859
|
+
branches: Object.fromEntries(
|
|
860
|
+
Object.entries(stateRouting.branches).map(([branchId, turnId]) => [
|
|
861
|
+
branchId,
|
|
862
|
+
{ to: turnId },
|
|
863
|
+
]),
|
|
864
|
+
),
|
|
865
|
+
choose: (execution: ProcessOutcomeExecution<TParams, TState>) =>
|
|
866
|
+
stateRouting.choose({
|
|
867
|
+
ctx: createFlowLlmOutcomeEffectContext({
|
|
868
|
+
ctx: execution.ctx,
|
|
869
|
+
event: execution.event,
|
|
870
|
+
}),
|
|
871
|
+
event: execution.event,
|
|
872
|
+
turnId: execution.turnId,
|
|
873
|
+
outcome: execution.outcome,
|
|
874
|
+
}),
|
|
875
|
+
}
|
|
876
|
+
: this.buildRouteTarget()),
|
|
815
877
|
...(this.flowEffect ? { effect: wrapLlmOutcomeEffect(this.flowEffect) } : {}),
|
|
816
878
|
};
|
|
817
879
|
}
|
|
@@ -825,10 +887,22 @@ export class AutomaticOutcomeBuilder<
|
|
|
825
887
|
TState,
|
|
826
888
|
FlowAutomaticOutcomeEffectContext<TParams, TState>
|
|
827
889
|
> {
|
|
890
|
+
private waits = false;
|
|
891
|
+
|
|
892
|
+
wait(): this {
|
|
893
|
+
if (this.hasRoute()) throw new Error("Waiting outcome cannot declare another route");
|
|
894
|
+
this.waits = true;
|
|
895
|
+
return this;
|
|
896
|
+
}
|
|
897
|
+
|
|
828
898
|
build(): ProcessToolOutcomeSpec<TParams, TState> {
|
|
829
899
|
if (!this.outcomeDescription) {
|
|
830
900
|
throw new Error("Automatic outcome must declare .description(...)");
|
|
831
901
|
}
|
|
902
|
+
if (this.waits && this.hasRoute()) {
|
|
903
|
+
throw new Error("Waiting outcome cannot declare another route");
|
|
904
|
+
}
|
|
905
|
+
const effect = this.flowEffect ? wrapAutomaticOutcomeEffect(this.flowEffect) : undefined;
|
|
832
906
|
return {
|
|
833
907
|
description: this.outcomeDescription,
|
|
834
908
|
parameters: this.parameters,
|
|
@@ -839,7 +913,8 @@ export class AutomaticOutcomeBuilder<
|
|
|
839
913
|
}
|
|
840
914
|
: {}),
|
|
841
915
|
...this.buildRouteTarget(),
|
|
842
|
-
...(this.
|
|
916
|
+
...(this.waits ? { wait: true as const } : {}),
|
|
917
|
+
...(effect ? { effect } : {}),
|
|
843
918
|
};
|
|
844
919
|
}
|
|
845
920
|
}
|
|
@@ -1012,7 +1087,6 @@ export class LlmFlowBuilder<
|
|
|
1012
1087
|
private questionsEnabled = false;
|
|
1013
1088
|
private startFrom: LlmTurnDefinition<string, TParams, TState>["startFrom"] | undefined;
|
|
1014
1089
|
private restorePrimaryLeafAfterTurn: boolean | undefined;
|
|
1015
|
-
private reviewSubject: ReviewSubject | undefined;
|
|
1016
1090
|
private consumedProductNames: string[] = [];
|
|
1017
1091
|
private optionalConsumedProductNames: string[] = [];
|
|
1018
1092
|
private publishedResult: {
|
|
@@ -1149,11 +1223,6 @@ export class LlmFlowBuilder<
|
|
|
1149
1223
|
return this;
|
|
1150
1224
|
}
|
|
1151
1225
|
|
|
1152
|
-
reviews(subject: ReviewSubject): this {
|
|
1153
|
-
this.reviewSubject = subject;
|
|
1154
|
-
return this;
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
1226
|
consume<TProductName extends string>(
|
|
1158
1227
|
productName: TProductName,
|
|
1159
1228
|
): LlmFlowBuilder<TParams, TState, TConsumedProducts | TProductName> {
|
|
@@ -1299,13 +1368,18 @@ export class LlmFlowBuilder<
|
|
|
1299
1368
|
for (const [outcomeId, builder] of this.outcomeToolBuilders) {
|
|
1300
1369
|
outcomes[outcomeId] = builder.build();
|
|
1301
1370
|
}
|
|
1302
|
-
const
|
|
1303
|
-
(
|
|
1371
|
+
const outcomePublishedProducts = new Set(
|
|
1372
|
+
Object.values(outcomes)
|
|
1373
|
+
.map((outcome) => outcome.publishedProduct)
|
|
1374
|
+
.filter((productName): productName is string => typeof productName === "string"),
|
|
1304
1375
|
);
|
|
1376
|
+
const hasOutcomePublishedProduct = outcomePublishedProducts.size > 0;
|
|
1305
1377
|
let turnEnd: ProcessTurnEndSpec<TParams, TState, string> | undefined;
|
|
1306
|
-
let resultSemanticRef: "plan" | "review" | undefined =
|
|
1378
|
+
let resultSemanticRef: "plan" | "review" | undefined = outcomePublishedProducts.has("review")
|
|
1307
1379
|
? "review"
|
|
1308
|
-
:
|
|
1380
|
+
: outcomePublishedProducts.has("plan")
|
|
1381
|
+
? "plan"
|
|
1382
|
+
: undefined;
|
|
1309
1383
|
let turnResultMarkdown: LlmTurnDefinition<string, TParams, TState>["turnResultMarkdown"];
|
|
1310
1384
|
let publishedProduct: string | undefined;
|
|
1311
1385
|
|
|
@@ -1363,7 +1437,6 @@ export class LlmFlowBuilder<
|
|
|
1363
1437
|
|
|
1364
1438
|
return {
|
|
1365
1439
|
...definition,
|
|
1366
|
-
...(this.reviewSubject ? { reviewSubject: this.reviewSubject } : {}),
|
|
1367
1440
|
...(Object.keys(outcomes).length > 0 ? { outcomes } : {}),
|
|
1368
1441
|
...(turnEnd ? { turnEnd } : {}),
|
|
1369
1442
|
...(turnResultMarkdown ? { turnResultMarkdown } : {}),
|
|
@@ -1379,6 +1452,37 @@ export class LlmFlowBuilder<
|
|
|
1379
1452
|
}
|
|
1380
1453
|
}
|
|
1381
1454
|
|
|
1455
|
+
type ExternalActionBuilderMap<TParams, TState> = Map<
|
|
1456
|
+
string,
|
|
1457
|
+
ExternalActionBuilder<TParams, TState, unknown, Record<string, unknown>>
|
|
1458
|
+
>;
|
|
1459
|
+
|
|
1460
|
+
function addExternalAction<TParams, TState, TEvent, TInput extends Record<string, unknown>>(input: {
|
|
1461
|
+
builders: ExternalActionBuilderMap<TParams, TState>;
|
|
1462
|
+
turnId: TurnId;
|
|
1463
|
+
turnKind: "Automatic" | "Human";
|
|
1464
|
+
externalActionId: string;
|
|
1465
|
+
source: ExternalActionSource<TParams, TState, TEvent, TInput>;
|
|
1466
|
+
configure: (
|
|
1467
|
+
external: ExternalActionBuilder<TParams, TState, TEvent, TInput>,
|
|
1468
|
+
) => ExternalActionBuilder<TParams, TState, TEvent, TInput> | undefined;
|
|
1469
|
+
}): void {
|
|
1470
|
+
if (input.builders.has(input.externalActionId)) {
|
|
1471
|
+
throw new Error(
|
|
1472
|
+
`${input.turnKind} turn '${input.turnId}' declares duplicate external action '${input.externalActionId}'`,
|
|
1473
|
+
);
|
|
1474
|
+
}
|
|
1475
|
+
const builder = new ExternalActionBuilder(input.externalActionId, input.source);
|
|
1476
|
+
input.configure(builder);
|
|
1477
|
+
input.builders.set(input.externalActionId, builder as ExternalActionBuilder<TParams, TState>);
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
function buildExternalActions<TParams, TState>(
|
|
1481
|
+
builders: ExternalActionBuilderMap<TParams, TState>,
|
|
1482
|
+
) {
|
|
1483
|
+
return Object.fromEntries([...builders].map(([id, builder]) => [id, builder.build()]));
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1382
1486
|
export class AutomaticFlowBuilder<TParams = unknown, TState = unknown>
|
|
1383
1487
|
implements FlowAutomaticTurn<TParams, TState, string>
|
|
1384
1488
|
{
|
|
@@ -1388,6 +1492,8 @@ export class AutomaticFlowBuilder<TParams = unknown, TState = unknown>
|
|
|
1388
1492
|
| ((ctx: FlowAutomaticRunContext<TParams, TState>) => MaybePromise<WorkerCompleteInput<string>>)
|
|
1389
1493
|
| null = null;
|
|
1390
1494
|
private outcomeBuilders = new Map<string, AutomaticOutcomeBuilder<TParams, TState>>();
|
|
1495
|
+
private availableIntegrationTools: readonly string[] = [];
|
|
1496
|
+
private externalActionBuilders: ExternalActionBuilderMap<TParams, TState> = new Map();
|
|
1391
1497
|
|
|
1392
1498
|
constructor(turnId: TurnId) {
|
|
1393
1499
|
this.turnId = turnId;
|
|
@@ -1415,6 +1521,32 @@ export class AutomaticFlowBuilder<TParams = unknown, TState = unknown>
|
|
|
1415
1521
|
return this;
|
|
1416
1522
|
}
|
|
1417
1523
|
|
|
1524
|
+
integrationTools(...tools: readonly string[]): this {
|
|
1525
|
+
this.availableIntegrationTools = tools.map((tool) => tool.trim());
|
|
1526
|
+
return this;
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
externalAction<
|
|
1530
|
+
TEvent = unknown,
|
|
1531
|
+
TInput extends Record<string, unknown> = Record<string, unknown>,
|
|
1532
|
+
>(
|
|
1533
|
+
externalActionId: string,
|
|
1534
|
+
source: ExternalActionSource<TParams, TState, TEvent, TInput>,
|
|
1535
|
+
configure: (
|
|
1536
|
+
external: ExternalActionBuilder<TParams, TState, TEvent, TInput>,
|
|
1537
|
+
) => ExternalActionBuilder<TParams, TState, TEvent, TInput> | undefined,
|
|
1538
|
+
): this {
|
|
1539
|
+
addExternalAction({
|
|
1540
|
+
builders: this.externalActionBuilders,
|
|
1541
|
+
turnId: this.turnId,
|
|
1542
|
+
turnKind: "Automatic",
|
|
1543
|
+
externalActionId,
|
|
1544
|
+
source,
|
|
1545
|
+
configure,
|
|
1546
|
+
});
|
|
1547
|
+
return this;
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1418
1550
|
outcome(
|
|
1419
1551
|
id: string,
|
|
1420
1552
|
configure: (
|
|
@@ -1451,6 +1583,12 @@ export class AutomaticFlowBuilder<TParams = unknown, TState = unknown>
|
|
|
1451
1583
|
return {
|
|
1452
1584
|
kind: "automatic",
|
|
1453
1585
|
description: this.turnDescription,
|
|
1586
|
+
...(this.availableIntegrationTools.length > 0
|
|
1587
|
+
? { integrationTools: this.availableIntegrationTools }
|
|
1588
|
+
: {}),
|
|
1589
|
+
...(this.externalActionBuilders.size > 0
|
|
1590
|
+
? { externalActions: buildExternalActions(this.externalActionBuilders) }
|
|
1591
|
+
: {}),
|
|
1454
1592
|
outcomes,
|
|
1455
1593
|
run: (ctx) => runFn(createFlowAutomaticRunContext(ctx)),
|
|
1456
1594
|
};
|
|
@@ -1657,6 +1795,11 @@ export class ExternalActionBuilder<
|
|
|
1657
1795
|
return this;
|
|
1658
1796
|
}
|
|
1659
1797
|
|
|
1798
|
+
when(condition: NonNullable<ProcessHumanTurnExternalActionSpec<TParams, TState>["when"]>): this {
|
|
1799
|
+
this.spec.when = condition;
|
|
1800
|
+
return this;
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1660
1803
|
to(turnId: TurnId): this {
|
|
1661
1804
|
this.spec.to = turnId;
|
|
1662
1805
|
return this;
|
|
@@ -1680,6 +1823,11 @@ export class ExternalActionBuilder<
|
|
|
1680
1823
|
return this;
|
|
1681
1824
|
}
|
|
1682
1825
|
|
|
1826
|
+
effect(effect: ExternalSourceEffect<TParams, TState, TEvent, TInput>): this {
|
|
1827
|
+
this.spec.effect = effect;
|
|
1828
|
+
return this;
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1683
1831
|
build(): ProcessHumanTurnExternalActionSpec<TParams, TState, TEvent, TInput> {
|
|
1684
1832
|
return this.spec as ProcessHumanTurnExternalActionSpec<TParams, TState, TEvent, TInput>;
|
|
1685
1833
|
}
|
|
@@ -1689,17 +1837,13 @@ export class HumanFlowBuilder<TParams = unknown, TState = unknown>
|
|
|
1689
1837
|
implements FlowHumanTurn<TParams, TState>
|
|
1690
1838
|
{
|
|
1691
1839
|
private turnDescription: string | null = null;
|
|
1692
|
-
private reviewSubject: ReviewSubject | null = null;
|
|
1693
1840
|
private reviewProductName: string | undefined;
|
|
1694
1841
|
private reviewSemanticRef: ProcessSemanticEntryRefKey | undefined;
|
|
1695
1842
|
private operatorAttentionValue: HumanTurnOperatorAttention | undefined;
|
|
1696
1843
|
private turnCommentary: string | undefined;
|
|
1697
1844
|
private notes: HumanTurnDefinition<TParams, TState>["notesFields"] | undefined;
|
|
1698
1845
|
private actions = new Map<string, HumanActionBuilder<TParams, TState>>();
|
|
1699
|
-
private externalActionBuilders = new Map
|
|
1700
|
-
string,
|
|
1701
|
-
ExternalActionBuilder<TParams, TState, unknown, Record<string, unknown>>
|
|
1702
|
-
>();
|
|
1846
|
+
private externalActionBuilders: ExternalActionBuilderMap<TParams, TState> = new Map();
|
|
1703
1847
|
|
|
1704
1848
|
constructor(private readonly turnId: TurnId) {}
|
|
1705
1849
|
|
|
@@ -1714,7 +1858,6 @@ export class HumanFlowBuilder<TParams = unknown, TState = unknown>
|
|
|
1714
1858
|
return {
|
|
1715
1859
|
kind: "human",
|
|
1716
1860
|
description: this.turnDescription,
|
|
1717
|
-
...(this.reviewSubject ? { reviewSubject: this.reviewSubject } : {}),
|
|
1718
1861
|
...(this.reviewProductName ? { reviewProduct: this.reviewProductName } : {}),
|
|
1719
1862
|
...(this.reviewSemanticRef ? { reviewSemanticRef: this.reviewSemanticRef } : {}),
|
|
1720
1863
|
...(this.operatorAttentionValue ? { operatorAttention: this.operatorAttentionValue } : {}),
|
|
@@ -1724,14 +1867,7 @@ export class HumanFlowBuilder<TParams = unknown, TState = unknown>
|
|
|
1724
1867
|
[...this.actions.entries()].map(([actionId, builder]) => [actionId, builder.build()]),
|
|
1725
1868
|
),
|
|
1726
1869
|
...(this.externalActionBuilders.size > 0
|
|
1727
|
-
? {
|
|
1728
|
-
externalActions: Object.fromEntries(
|
|
1729
|
-
[...this.externalActionBuilders.entries()].map(([actionId, builder]) => [
|
|
1730
|
-
actionId,
|
|
1731
|
-
builder.build(),
|
|
1732
|
-
]),
|
|
1733
|
-
),
|
|
1734
|
-
}
|
|
1870
|
+
? { externalActions: buildExternalActions(this.externalActionBuilders) }
|
|
1735
1871
|
: {}),
|
|
1736
1872
|
};
|
|
1737
1873
|
}
|
|
@@ -1741,21 +1877,9 @@ export class HumanFlowBuilder<TParams = unknown, TState = unknown>
|
|
|
1741
1877
|
return this;
|
|
1742
1878
|
}
|
|
1743
1879
|
|
|
1744
|
-
|
|
1745
|
-
this.reviewSubject = typeof subject === "string" ? createReviewSubject(subject) : subject;
|
|
1746
|
-
this.reviewProductName = undefined;
|
|
1747
|
-
this.reviewSemanticRef = typeof subject === "string" && subject === "plan" ? "plan" : undefined;
|
|
1748
|
-
return this;
|
|
1749
|
-
}
|
|
1750
|
-
|
|
1751
|
-
reviewProduct(
|
|
1752
|
-
productName: string,
|
|
1753
|
-
options: { subject: ReviewSubject | "plan" | "implementation" },
|
|
1754
|
-
): this {
|
|
1880
|
+
reviewProduct(productName: string): this {
|
|
1755
1881
|
const normalized = normalizeProductName(productName);
|
|
1756
1882
|
this.reviewProductName = normalized;
|
|
1757
|
-
this.reviewSubject =
|
|
1758
|
-
typeof options.subject === "string" ? createReviewSubject(options.subject) : options.subject;
|
|
1759
1883
|
this.reviewSemanticRef =
|
|
1760
1884
|
normalized === "plan" ? "plan" : normalized === "review" ? "review" : undefined;
|
|
1761
1885
|
return this;
|
|
@@ -1801,25 +1925,14 @@ export class HumanFlowBuilder<TParams = unknown, TState = unknown>
|
|
|
1801
1925
|
external: ExternalActionBuilder<TParams, TState, TEvent, TInput>,
|
|
1802
1926
|
) => ExternalActionBuilder<TParams, TState, TEvent, TInput> | undefined,
|
|
1803
1927
|
): this {
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
}
|
|
1809
|
-
const builder = new ExternalActionBuilder<TParams, TState, TEvent, TInput>(
|
|
1928
|
+
addExternalAction({
|
|
1929
|
+
builders: this.externalActionBuilders,
|
|
1930
|
+
turnId: this.turnId,
|
|
1931
|
+
turnKind: "Human",
|
|
1810
1932
|
externalActionId,
|
|
1811
1933
|
source,
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
this.externalActionBuilders.set(
|
|
1815
|
-
externalActionId,
|
|
1816
|
-
builder as unknown as ExternalActionBuilder<
|
|
1817
|
-
TParams,
|
|
1818
|
-
TState,
|
|
1819
|
-
unknown,
|
|
1820
|
-
Record<string, unknown>
|
|
1821
|
-
>,
|
|
1822
|
-
);
|
|
1934
|
+
configure,
|
|
1935
|
+
});
|
|
1823
1936
|
return this;
|
|
1824
1937
|
}
|
|
1825
1938
|
}
|
package/src/index.ts
CHANGED
|
@@ -101,6 +101,8 @@ export {
|
|
|
101
101
|
type ProcessHumanTurnActionSpec,
|
|
102
102
|
type ProcessHumanTurnExternalActionSpec,
|
|
103
103
|
type ProcessLifecycleEffects,
|
|
104
|
+
type ProcessOutcomeBranchSelector,
|
|
105
|
+
type ProcessOutcomeBranchSpec,
|
|
104
106
|
type ProcessOutcomeEffect,
|
|
105
107
|
type ProcessOutcomeExecution,
|
|
106
108
|
type ProcessPatchEffect,
|
package/src/process-graph.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type {
|
|
|
2
2
|
ProcessSemanticEntryRefKey,
|
|
3
3
|
ProcessTurnTransition,
|
|
4
4
|
ProcessTurnType,
|
|
5
|
-
ReviewSubject,
|
|
6
5
|
SerializedProcessGraph,
|
|
7
6
|
TurnId,
|
|
8
7
|
} from "@leitwerk-dev/domain";
|
|
@@ -18,7 +17,6 @@ export interface ProcessGraphTurnView {
|
|
|
18
17
|
turnType: ProcessTurnType;
|
|
19
18
|
description: string;
|
|
20
19
|
transitions: readonly ProcessTurnTransition[];
|
|
21
|
-
reviewSubject?: ReviewSubject;
|
|
22
20
|
reviewProduct?: string;
|
|
23
21
|
resultSemanticRef?: ProcessSemanticEntryRefKey;
|
|
24
22
|
publishedProduct?: string;
|
|
@@ -102,7 +100,6 @@ function toTurnView(
|
|
|
102
100
|
turnType: toTurnType(definition),
|
|
103
101
|
description: definition.description,
|
|
104
102
|
transitions: getProcessTurnTransitions(binding),
|
|
105
|
-
...(definition.reviewSubject ? { reviewSubject: { ...definition.reviewSubject } } : {}),
|
|
106
103
|
...(definition.kind === "human" && definition.reviewProduct
|
|
107
104
|
? { reviewProduct: definition.reviewProduct }
|
|
108
105
|
: {}),
|
|
@@ -16,9 +16,16 @@ function nonEmptyString(value: unknown, path: string): string {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/** Parse the shared launch-model fragment nested inside extension-owned watcher config. */
|
|
19
|
-
export function parseProcessWatcherLaunchModelConfig(
|
|
20
|
-
|
|
19
|
+
export function parseProcessWatcherLaunchModelConfig(
|
|
20
|
+
value: unknown,
|
|
21
|
+
): LaunchModelConfigInput & { skillIds: string[] } {
|
|
22
|
+
if (value === undefined) return { defaultModelProfileId: null, turnConfigs: {}, skillIds: [] };
|
|
21
23
|
const launch = record(value, "launch");
|
|
24
|
+
const rawSkills = launch.skills === undefined ? [] : launch.skills;
|
|
25
|
+
if (!Array.isArray(rawSkills)) throw new Error("launch.skills must be an array");
|
|
26
|
+
const skillIds = rawSkills.map((skill, index) => nonEmptyString(skill, `launch.skills.${index}`));
|
|
27
|
+
if (new Set(skillIds).size !== skillIds.length)
|
|
28
|
+
throw new Error("launch.skills contains duplicates");
|
|
22
29
|
const rawTurns =
|
|
23
30
|
launch.turn_configs === undefined ? {} : record(launch.turn_configs, "launch.turn_configs");
|
|
24
31
|
return {
|
|
@@ -40,6 +47,7 @@ export function parseProcessWatcherLaunchModelConfig(value: unknown): LaunchMode
|
|
|
40
47
|
];
|
|
41
48
|
}),
|
|
42
49
|
),
|
|
50
|
+
skillIds,
|
|
43
51
|
};
|
|
44
52
|
}
|
|
45
53
|
|
package/src/state-helpers.ts
CHANGED
|
@@ -5,21 +5,17 @@ import {
|
|
|
5
5
|
type ProcessSemanticEntryRefs,
|
|
6
6
|
parseProcessProductRefs,
|
|
7
7
|
parseProcessSemanticEntryRefs,
|
|
8
|
-
parseReviewSubject,
|
|
9
|
-
type ReviewSubject,
|
|
10
8
|
} from "@leitwerk-dev/domain";
|
|
11
9
|
|
|
12
10
|
export interface StructuralProcessState {
|
|
13
11
|
semanticEntryRefs: ProcessSemanticEntryRefs;
|
|
14
12
|
productRefs: ProcessProductRefs;
|
|
15
|
-
reviewSubject: ReviewSubject | null;
|
|
16
13
|
}
|
|
17
14
|
|
|
18
15
|
export function createEmptyStructuralProcessState(): StructuralProcessState {
|
|
19
16
|
return {
|
|
20
17
|
semanticEntryRefs: createEmptyProcessSemanticEntryRefs(),
|
|
21
18
|
productRefs: createEmptyProcessProductRefs(),
|
|
22
|
-
reviewSubject: null,
|
|
23
19
|
};
|
|
24
20
|
}
|
|
25
21
|
|
|
@@ -31,6 +27,5 @@ export function parseStructuralProcessState(value: unknown): StructuralProcessSt
|
|
|
31
27
|
return {
|
|
32
28
|
semanticEntryRefs: parseProcessSemanticEntryRefs(record.semanticEntryRefs),
|
|
33
29
|
productRefs: parseProcessProductRefs(record.productRefs),
|
|
34
|
-
reviewSubject: parseReviewSubject(record.reviewSubject),
|
|
35
30
|
};
|
|
36
31
|
}
|