@leitwerk-dev/showcase-processes 0.1.8 → 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.
@@ -1,6 +1,5 @@
1
1
  import { execFileSync } from "node:child_process";
2
2
  import { setTimeout as delay } from "node:timers/promises";
3
- import { createReviewSubject } from "@leitwerk-dev/domain";
4
3
  import {
5
4
  type AutomaticOutcomeBuilder,
6
5
  type Codec,
@@ -10,6 +9,7 @@ import {
10
9
  type HumanFlowBuilder,
11
10
  parseStructuralProcessState,
12
11
  type StructuralProcessState,
12
+ structuralStateCodec,
13
13
  } from "@leitwerk-dev/process-sdk";
14
14
  import { fileExternal } from "./file-external.js";
15
15
  import { filesystemWatcherSource } from "./filesystem-watcher.js";
@@ -59,15 +59,6 @@ const promptProcessParamsCodec: Codec<PromptProcessParams> = {
59
59
  },
60
60
  };
61
61
 
62
- const structuralStateCodec: Codec<StructuralProcessState> = {
63
- parse(value) {
64
- return parseStructuralProcessState(value);
65
- },
66
- serialize(value) {
67
- return value;
68
- },
69
- };
70
-
71
62
  const poemCreatorStateCodec: Codec<PoemCreatorState> = {
72
63
  parse(value) {
73
64
  const structural = parseStructuralProcessState(value);
@@ -115,6 +106,30 @@ function buildPromptTitleSourceFields(prompt: string, label = "Prompt") {
115
106
  return [{ label, value: prompt }] as const;
116
107
  }
117
108
 
109
+ function promptLaunchResolution(options: {
110
+ processId: string;
111
+ startTurnId: string;
112
+ defaultPrompt?: () => string;
113
+ titleLabel?: string;
114
+ }) {
115
+ return {
116
+ resolveDefaults: () => ({ prompt: options.defaultPrompt?.() ?? "" }),
117
+ resolveLaunchConfig(input: Record<string, unknown>) {
118
+ const validated = validateLaunchInput(input, options.defaultPrompt?.());
119
+ if (!validated.ok) return validated;
120
+ return {
121
+ ok: true as const,
122
+ launchConfig: {
123
+ processId: options.processId,
124
+ params: { prompt: validated.prompt },
125
+ titleSourceFields: buildPromptTitleSourceFields(validated.prompt, options.titleLabel),
126
+ startTurnId: options.startTurnId,
127
+ },
128
+ };
129
+ },
130
+ };
131
+ }
132
+
118
133
  function clearReviewRefs(state: PoemCreatorState["semanticEntryRefs"]) {
119
134
  return {
120
135
  ...state,
@@ -125,7 +140,6 @@ function clearReviewRefs(state: PoemCreatorState["semanticEntryRefs"]) {
125
140
  function patchPoemCreatorState(
126
141
  state: PoemCreatorState,
127
142
  input: {
128
- reviewSubject?: PoemCreatorState["reviewSubject"];
129
143
  latestReviewMarkdown?: PoemCreatorState["latestReviewMarkdown"];
130
144
  latestReviewSummary?: PoemCreatorState["latestReviewSummary"];
131
145
  latestReviewOutcome?: PoemCreatorState["latestReviewOutcome"];
@@ -135,7 +149,6 @@ function patchPoemCreatorState(
135
149
  ): PoemCreatorState {
136
150
  const nextState: PoemCreatorState = {
137
151
  ...state,
138
- ...("reviewSubject" in input ? { reviewSubject: input.reviewSubject ?? null } : {}),
139
152
  ...("latestReviewMarkdown" in input
140
153
  ? { latestReviewMarkdown: input.latestReviewMarkdown ?? null }
141
154
  : {}),
@@ -250,9 +263,6 @@ const poemTurnIds = {
250
263
  poemReviewFeedback: "poem_review_feedback",
251
264
  } as const;
252
265
 
253
- const poemDraftReviewSubject = { kind: "plan" } as const;
254
- const poemFeedbackReviewSubject = { kind: "implementation" } as const;
255
-
256
266
  const poemRevisionForm: FormDefinition = {
257
267
  id: poemCreatorActionIds.requestRevision,
258
268
  title: "Request poem revision",
@@ -299,7 +309,7 @@ export const singlePromptProcess = flow
299
309
  .turn(
300
310
  flow
301
311
  .llm<PromptProcessParams, StructuralProcessState>("run_single_prompt")
302
- .description("Run a single operator-provided prompt and finish on turn end")
312
+ .description("Run Prompt")
303
313
  .tools("read", "bash", "edit", "write")
304
314
  .prompt(async (ctx) => buildSinglePromptInstruction(ctx.params.prompt))
305
315
  .end("completed")
@@ -339,26 +349,10 @@ export const singlePromptProcess = flow
339
349
  ],
340
350
  submitLabel: "Run Prompt",
341
351
  },
342
- resolveDefaults() {
343
- return {
344
- prompt: "",
345
- };
346
- },
347
- resolveLaunchConfig(input) {
348
- const validated = validateLaunchInput(input);
349
- if (!validated.ok) {
350
- return validated;
351
- }
352
- return {
353
- ok: true,
354
- launchConfig: {
355
- processId: "single_prompt_process",
356
- params: { prompt: validated.prompt },
357
- titleSourceFields: buildPromptTitleSourceFields(validated.prompt),
358
- startTurnId: "run_single_prompt",
359
- },
360
- };
361
- },
352
+ ...promptLaunchResolution({
353
+ processId: "single_prompt_process",
354
+ startTurnId: "run_single_prompt",
355
+ }),
362
356
  },
363
357
  })
364
358
  .define();
@@ -375,7 +369,7 @@ export const singlePromptWithToolProcess = flow
375
369
  .turn(
376
370
  flow
377
371
  .llm<PromptProcessParams, StructuralProcessState>("run_single_prompt_with_tool")
378
- .description("Run a single operator-provided prompt and require the done tool")
372
+ .description("Run Prompt")
379
373
  .tools("read", "bash", "edit", "write")
380
374
  .prompt(async (ctx) => buildSinglePromptWithToolInstruction(ctx.params.prompt))
381
375
  .outcomeTool("done", (tool) =>
@@ -419,26 +413,10 @@ export const singlePromptWithToolProcess = flow
419
413
  ],
420
414
  submitLabel: "Run Prompt + Tool",
421
415
  },
422
- resolveDefaults() {
423
- return {
424
- prompt: "",
425
- };
426
- },
427
- resolveLaunchConfig(input) {
428
- const validated = validateLaunchInput(input);
429
- if (!validated.ok) {
430
- return validated;
431
- }
432
- return {
433
- ok: true,
434
- launchConfig: {
435
- processId: "single_prompt_with_tool_process",
436
- params: { prompt: validated.prompt },
437
- titleSourceFields: buildPromptTitleSourceFields(validated.prompt),
438
- startTurnId: "run_single_prompt_with_tool",
439
- },
440
- };
441
- },
416
+ ...promptLaunchResolution({
417
+ processId: "single_prompt_with_tool_process",
418
+ startTurnId: "run_single_prompt_with_tool",
419
+ }),
442
420
  },
443
421
  })
444
422
  .define();
@@ -650,7 +628,7 @@ export const singlePromptExternalCompleteProcess = flow
650
628
  .turn(
651
629
  flow
652
630
  .llm<PromptProcessParams, StructuralProcessState>("run_single_prompt")
653
- .description("Run a single operator-provided prompt and finish on turn end")
631
+ .description("Run Prompt")
654
632
  .tools("read", "bash", "edit", "write")
655
633
  .prompt(async (ctx) => buildSinglePromptInstruction(ctx.params.prompt))
656
634
  .end("completed")
@@ -703,34 +681,18 @@ export const singlePromptExternalCompleteProcess = flow
703
681
  ],
704
682
  submitLabel: "Run Prompt",
705
683
  },
706
- resolveDefaults() {
707
- return {
708
- prompt: "",
709
- };
710
- },
711
- resolveLaunchConfig(input) {
712
- const validated = validateLaunchInput(input);
713
- if (!validated.ok) {
714
- return validated;
715
- }
716
- return {
717
- ok: true,
718
- launchConfig: {
719
- processId: "single_prompt_external_complete_process",
720
- params: { prompt: validated.prompt },
721
- titleSourceFields: buildPromptTitleSourceFields(validated.prompt),
722
- startTurnId: "run_single_prompt",
723
- },
724
- };
725
- },
684
+ ...promptLaunchResolution({
685
+ processId: "single_prompt_external_complete_process",
686
+ startTurnId: "run_single_prompt",
687
+ }),
726
688
  },
727
689
  })
728
690
  .define();
729
691
 
730
692
  const poemDraftReviewSpec = flow
731
693
  .human<PromptProcessParams, PoemCreatorState>(poemTurnIds.poemReview)
732
- .description("Human review of the drafted poem on the primary branch")
733
- .reviewProduct("poem-draft", { subject: "plan" })
694
+ .description("Review")
695
+ .reviewProduct("poem-draft")
734
696
  .notesFields([
735
697
  {
736
698
  id: "message",
@@ -746,12 +708,7 @@ const poemDraftReviewSpec = flow
746
708
  .label("Complete poem")
747
709
  .description("Accept the current poem and finish the process.")
748
710
  .acceptanceState("accepted")
749
- .complete()
750
- .effect(({ ctx }) => ({
751
- state: patchPoemCreatorState(ctx.state, {
752
- reviewSubject: null,
753
- }),
754
- })),
711
+ .complete(),
755
712
  )
756
713
  .action(poemCreatorActionIds.requestRevision, (action) =>
757
714
  action
@@ -773,7 +730,6 @@ const poemDraftReviewSpec = flow
773
730
  .to(poemTurnIds.reviewPoemDraft)
774
731
  .effect(({ ctx }) => ({
775
732
  state: patchPoemCreatorState(ctx.state, {
776
- reviewSubject: createReviewSubject(poemFeedbackReviewSubject.kind),
777
733
  latestReviewMarkdown: null,
778
734
  latestReviewSummary: null,
779
735
  latestReviewOutcome: null,
@@ -798,8 +754,8 @@ const poemDraftReviewSpec = flow
798
754
 
799
755
  const poemReviewFeedbackSpec = flow
800
756
  .human<PromptProcessParams, PoemCreatorState>(poemTurnIds.poemReviewFeedback)
801
- .description("Human review of the LLM review output")
802
- .reviewProduct("message", { subject: "implementation" })
757
+ .description("Review Feedback")
758
+ .reviewProduct("message")
803
759
  .notesFields([
804
760
  {
805
761
  id: "message",
@@ -837,7 +793,6 @@ const poemReviewFeedbackSpec = flow
837
793
  .to(poemTurnIds.poemReview)
838
794
  .effect(({ ctx }) => ({
839
795
  state: patchPoemCreatorState(ctx.state, {
840
- reviewSubject: createReviewSubject(poemDraftReviewSubject.kind),
841
796
  latestReviewMarkdown: null,
842
797
  latestReviewSummary: null,
843
798
  latestReviewOutcome: null,
@@ -863,7 +818,7 @@ export const poemCreatorProcess = flow
863
818
  .turn(
864
819
  flow
865
820
  .llm<PromptProcessParams, PoemCreatorState>(poemTurnIds.draftPoem)
866
- .description("Draft poem")
821
+ .description("Draft Poem")
867
822
  .fullPrimary()
868
823
  .continueFromPrimaryLeaf()
869
824
  .optionalConsume("message")
@@ -877,7 +832,6 @@ export const poemCreatorProcess = flow
877
832
  .to(poemTurnIds.poemReview)
878
833
  .state(({ ctx }) =>
879
834
  patchPoemCreatorState(ctx.state, {
880
- reviewSubject: createReviewSubject(poemDraftReviewSubject.kind),
881
835
  latestReviewMarkdown: null,
882
836
  latestReviewSummary: null,
883
837
  latestReviewOutcome: null,
@@ -889,10 +843,9 @@ export const poemCreatorProcess = flow
889
843
  .turn(
890
844
  flow
891
845
  .llm<PromptProcessParams, PoemCreatorState>(poemTurnIds.reviewPoemDraft)
892
- .description("Review poem")
846
+ .description("Assess Poem")
893
847
  .rootBranchReview()
894
848
  .continueFromReviewBranch()
895
- .reviews(createReviewSubject("plan"))
896
849
  .consume("poem-draft")
897
850
  .optionalConsume("message")
898
851
  .buildPrompt(async (ctx) => {
@@ -909,6 +862,7 @@ export const poemCreatorProcess = flow
909
862
  .outcomeTool("no_issues", (tool) =>
910
863
  tool
911
864
  .description("The poem is ready to publish")
865
+ .resultSummary("summary")
912
866
  .requiredString("summary", "Short confirmation summary")
913
867
  .markdown("review", {
914
868
  description: "Concise review opinion confirming the poem is ready",
@@ -917,7 +871,6 @@ export const poemCreatorProcess = flow
917
871
  .to(poemTurnIds.poemReview)
918
872
  .state(({ ctx, event }) =>
919
873
  patchPoemCreatorState(ctx.state, {
920
- reviewSubject: createReviewSubject(poemDraftReviewSubject.kind),
921
874
  latestReviewMarkdown: null,
922
875
  latestReviewSummary:
923
876
  typeof event.params.summary === "string" ? event.params.summary : null,
@@ -928,6 +881,7 @@ export const poemCreatorProcess = flow
928
881
  .outcomeTool("leave_feedback", (tool) =>
929
882
  tool
930
883
  .description("Leave concise feedback for the human reviewer")
884
+ .resultSummary("summary")
931
885
  .requiredString("summary", "Short summary of the feedback")
932
886
  .markdown("message", {
933
887
  description: "Concise plain-text feedback describing what to improve",
@@ -936,7 +890,6 @@ export const poemCreatorProcess = flow
936
890
  .to(poemTurnIds.poemReviewFeedback)
937
891
  .state(({ ctx, event }) =>
938
892
  patchPoemCreatorState(ctx.state, {
939
- reviewSubject: createReviewSubject(poemFeedbackReviewSubject.kind),
940
893
  latestReviewMarkdown:
941
894
  typeof event.params.message === "string"
942
895
  ? event.params.message
@@ -983,26 +936,12 @@ export const poemCreatorProcess = flow
983
936
  ],
984
937
  submitLabel: "Create Poem",
985
938
  },
986
- resolveDefaults() {
987
- return {
988
- prompt: buildDefaultPoemPrompt(),
989
- };
990
- },
991
- resolveLaunchConfig(input) {
992
- const validated = validateLaunchInput(input, buildDefaultPoemPrompt());
993
- if (!validated.ok) {
994
- return validated;
995
- }
996
- return {
997
- ok: true,
998
- launchConfig: {
999
- processId: "poem_creator_process",
1000
- params: { prompt: validated.prompt },
1001
- titleSourceFields: buildPromptTitleSourceFields(validated.prompt, "Poem Prompt"),
1002
- startTurnId: poemTurnIds.draftPoem,
1003
- },
1004
- };
1005
- },
939
+ ...promptLaunchResolution({
940
+ processId: "poem_creator_process",
941
+ startTurnId: poemTurnIds.draftPoem,
942
+ defaultPrompt: buildDefaultPoemPrompt,
943
+ titleLabel: "Poem Prompt",
944
+ }),
1006
945
  },
1007
946
  })
1008
947
  .watcher({
@@ -1,198 +0,0 @@
1
- import { consumeTriggerFile, createPollLoop, emptyPollResult, parseDurationMs, readTriggerFile, } from "@leitwerk-dev/watcher-utils";
2
- export const FILE_EXTERNAL_PRESENCE_KIND = "@leitwerk-dev/showcase-processes.file.presence";
3
- export const FILE_EXTERNAL_INSTRUCTION_KIND = "@leitwerk-dev/showcase-processes.file.instruction";
4
- function normalizeConfig(input) {
5
- return {
6
- path: input.path,
7
- pollInterval: input.pollInterval,
8
- consume: input.consume,
9
- };
10
- }
11
- function interpolateTemplate(template, values) {
12
- return template.replace(/\{([a-zA-Z0-9_]+)\}/g, (match, key) => values[key] ?? match);
13
- }
14
- function resolveFileConfig(input, ctx) {
15
- return {
16
- ...input,
17
- path: interpolateTemplate(input.path, { instanceId: ctx.process.id }),
18
- };
19
- }
20
- function fileLabel(kind, path) {
21
- return kind === "presence" ? `File present: ${path}` : `File instruction: ${path}`;
22
- }
23
- export const fileExternal = {
24
- presence(input) {
25
- const config = normalizeConfig(input);
26
- return {
27
- kind: FILE_EXTERNAL_PRESENCE_KIND,
28
- label: fileLabel("presence", config.path),
29
- description: `Fires when ${config.path} exists`,
30
- config,
31
- inputMode: "none",
32
- resolve(ctx) {
33
- return resolveFileConfig(config, ctx);
34
- },
35
- };
36
- },
37
- instruction(input) {
38
- const config = normalizeConfig(input);
39
- return {
40
- kind: FILE_EXTERNAL_INSTRUCTION_KIND,
41
- label: fileLabel("instruction", config.path),
42
- description: `Reads ${config.path} as instruction text`,
43
- config,
44
- inputMode: "instruction",
45
- resolve(ctx) {
46
- return resolveFileConfig(config, ctx);
47
- },
48
- };
49
- },
50
- };
51
- function parseFileConfig(value) {
52
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
53
- return null;
54
- }
55
- const record = value;
56
- if (typeof record.path !== "string" || record.path.trim() === "") {
57
- return null;
58
- }
59
- return {
60
- path: record.path,
61
- pollInterval: typeof record.pollInterval === "string" ? record.pollInterval : "1s",
62
- consume: record.consume === "keep" ? "keep" : "delete",
63
- };
64
- }
65
- async function maybeConsume(config) {
66
- if (config.consume === "delete") {
67
- await consumeTriggerFile(config.path);
68
- }
69
- }
70
- function createDueTracker() {
71
- const nextDueAtByKey = new Map();
72
- return {
73
- isDue(key, pollInterval, nowMs = Date.now()) {
74
- const nextDueAt = nextDueAtByKey.get(key) ?? 0;
75
- if (nextDueAt > nowMs) {
76
- return false;
77
- }
78
- const intervalMs = parseDurationMs(pollInterval, 1_000);
79
- nextDueAtByKey.set(key, nowMs + intervalMs);
80
- return true;
81
- },
82
- prune(activeKeys) {
83
- for (const key of [...nextDueAtByKey.keys()]) {
84
- if (!activeKeys.has(key)) {
85
- nextDueAtByKey.delete(key);
86
- }
87
- }
88
- },
89
- };
90
- }
91
- function resolveArmedFileConfig(armed, resolveAlias) {
92
- const parsed = parseFileConfig(armed.resolved) ?? parseFileConfig(armed.source.config);
93
- return parsed ? resolveAlias(parsed) : null;
94
- }
95
- async function pollArmedFileSource(armed, resolveConfig, isDue, activeKeys, result) {
96
- const config = resolveArmedFileConfig(armed, resolveConfig);
97
- if (!config) {
98
- result.errors.push(`${armed.id}:invalid_config`);
99
- return null;
100
- }
101
- const key = `${armed.instanceId}:${armed.id}`;
102
- activeKeys.add(key);
103
- if (!isDue(key, config.pollInterval)) {
104
- return null;
105
- }
106
- const file = await readTriggerFile(config.path);
107
- if (!file.exists) {
108
- return null;
109
- }
110
- return { config, file };
111
- }
112
- async function firePresenceSources(deps, result, resolveConfig, isDue, activeKeys) {
113
- for (const armed of deps.externalSources.listArmed(FILE_EXTERNAL_PRESENCE_KIND)) {
114
- const target = await pollArmedFileSource(armed, resolveConfig, isDue, activeKeys, result);
115
- if (!target) {
116
- continue;
117
- }
118
- const { config } = target;
119
- const fired = await deps.externalSources.fire({
120
- instanceId: armed.instanceId,
121
- armingId: armed.id,
122
- event: { path: config.path, pollInterval: config.pollInterval },
123
- mergeKey: config.path,
124
- });
125
- if (!fired.ok) {
126
- result.errors.push(`${armed.id}:${fired.code ?? fired.error ?? "fire_failed"}`);
127
- continue;
128
- }
129
- await maybeConsume(config);
130
- result.created.push(armed.id);
131
- }
132
- }
133
- async function fireInstructionSources(deps, result, resolveConfig, isDue, activeKeys) {
134
- for (const armed of deps.externalSources.listArmed(FILE_EXTERNAL_INSTRUCTION_KIND)) {
135
- const target = await pollArmedFileSource(armed, resolveConfig, isDue, activeKeys, result);
136
- if (!target) {
137
- continue;
138
- }
139
- const { config, file } = target;
140
- const instruction = file.content.trim();
141
- if (!instruction) {
142
- continue;
143
- }
144
- const fired = await deps.externalSources.fire({
145
- instanceId: armed.instanceId,
146
- armingId: armed.id,
147
- input: { instruction },
148
- event: { path: config.path, pollInterval: config.pollInterval },
149
- mergeKey: config.path,
150
- });
151
- if (!fired.ok) {
152
- result.errors.push(`${armed.id}:${fired.code ?? fired.error ?? "fire_failed"}`);
153
- continue;
154
- }
155
- await maybeConsume(config);
156
- result.created.push(armed.id);
157
- }
158
- }
159
- export function createFileExternalSourceProvider(deps, aliases = {}) {
160
- function applyAlias(config) {
161
- const exact = aliases[config.path];
162
- if (exact) {
163
- return { ...config, path: exact };
164
- }
165
- for (const [template, replacement] of Object.entries(aliases)) {
166
- if (!replacement || !template.includes("{instanceId}")) {
167
- continue;
168
- }
169
- const [prefix, suffix = ""] = template.split("{instanceId}");
170
- if (!prefix || !config.path.startsWith(prefix) || !config.path.endsWith(suffix)) {
171
- continue;
172
- }
173
- const instanceId = config.path.slice(prefix.length, config.path.length - suffix.length);
174
- return {
175
- ...config,
176
- path: replacement.includes("{instanceId}")
177
- ? interpolateTemplate(replacement, { instanceId })
178
- : replacement,
179
- };
180
- }
181
- return config;
182
- }
183
- const due = createDueTracker();
184
- return createPollLoop({
185
- pollInterval: () => "50ms",
186
- isEnabled: () => true,
187
- defaultIntervalMs: 50,
188
- async pollOnce() {
189
- const result = emptyPollResult();
190
- const activeKeys = new Set();
191
- await firePresenceSources(deps, result, applyAlias, due.isDue, activeKeys);
192
- await fireInstructionSources(deps, result, applyAlias, due.isDue, activeKeys);
193
- due.prune(activeKeys);
194
- return result;
195
- },
196
- });
197
- }
198
- //# sourceMappingURL=file-external.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-external.js","sourceRoot":"","sources":["../src/file-external.ts"],"names":[],"mappings":"AAKA,OAAO,EACN,kBAAkB,EAClB,cAAc,EACd,eAAe,EAEf,eAAe,EACf,eAAe,GACf,MAAM,6BAA6B,CAAC;AAUrC,MAAM,CAAC,MAAM,2BAA2B,GAAG,gDAAgD,CAAC;AAC5F,MAAM,CAAC,MAAM,8BAA8B,GAAG,mDAAmD,CAAC;AAElG,SAAS,eAAe,CAAC,KAAwB;IAChD,OAAO;QACN,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,OAAO,EAAE,KAAK,CAAC,OAAO;KACtB,CAAC;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,QAAgB,EAAE,MAA8B;IAC5E,OAAO,QAAQ,CAAC,OAAO,CAAC,sBAAsB,EAAE,CAAC,KAAK,EAAE,GAAW,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC;AAC/F,CAAC;AAED,SAAS,iBAAiB,CACzB,KAAwB,EACxB,GAAgC;IAEhC,OAAO;QACN,GAAG,KAAK;QACR,IAAI,EAAE,mBAAmB,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;KACrE,CAAC;AACH,CAAC;AAED,SAAS,SAAS,C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G,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;YAC3E,MAAM,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;YAC9E,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;YACtB,OAAO,MAAM,CAAC;QACf,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
@@ -1,109 +0,0 @@
1
- import { defineProcessWatcherSource, parseProcessWatcherLaunchModelConfig, } from "@leitwerk-dev/process-sdk";
2
- import { consumeTriggerFile, createPollLoop, emptyPollResult, parseDurationMs, readTriggerFile, } from "@leitwerk-dev/watcher-utils";
3
- function record(value, subject) {
4
- if (!value || typeof value !== "object" || Array.isArray(value)) {
5
- throw new Error(`${subject} must be an object`);
6
- }
7
- return value;
8
- }
9
- function nonEmptyString(value, path) {
10
- if (typeof value !== "string" || value.trim() === "") {
11
- throw new Error(`${path} must be a non-empty string`);
12
- }
13
- return value;
14
- }
15
- export const filesystemWatcherSource = defineProcessWatcherSource({
16
- id: "@leitwerk-dev/showcase-processes.file",
17
- label: "File",
18
- parseConfig(raw) {
19
- const config = record(raw, "watcher config");
20
- if (config.type !== undefined && config.type !== "filesystem") {
21
- throw new Error("type must be 'filesystem' when specified");
22
- }
23
- if (typeof config.enabled !== "boolean") {
24
- throw new Error("enabled must be a boolean");
25
- }
26
- const pollInterval = nonEmptyString(config.poll_interval, "poll_interval");
27
- if (parseDurationMs(pollInterval, -1, { allowHours: true }) <= 0) {
28
- throw new Error("poll_interval must be a positive duration");
29
- }
30
- return {
31
- config: {
32
- pollInterval,
33
- filePath: nonEmptyString(config.file_path, "file_path"),
34
- },
35
- enabled: config.enabled,
36
- launchModelConfig: parseProcessWatcherLaunchModelConfig(config.launch),
37
- };
38
- },
39
- presentConfig(config) {
40
- return {
41
- targetSummary: `File ${config.filePath}`,
42
- details: [
43
- { label: "File path", value: config.filePath, format: "code" },
44
- { label: "Poll interval", value: config.pollInterval },
45
- ],
46
- };
47
- },
48
- });
49
- export function createFilesystemWatcherProvider(deps, logger) {
50
- const watchers = deps.processWatchers?.listBySource(filesystemWatcherSource) ?? [];
51
- const loops = watchers.map((watcher) => createPollLoop({
52
- pollInterval: () => watcher.config.pollInterval,
53
- isEnabled: () => watcher.enabled,
54
- defaultIntervalMs: 1_000,
55
- async pollOnce() {
56
- const result = emptyPollResult();
57
- const file = await readTriggerFile(watcher.config.filePath);
58
- if (!file.exists || file.content.trim() === "")
59
- return result;
60
- const resolved = await watcher.resolveLaunch({
61
- filePath: watcher.config.filePath,
62
- content: file.content.trim(),
63
- });
64
- if (!resolved) {
65
- result.skipped.push(`${watcher.processId}:${watcher.watcherId}`);
66
- return result;
67
- }
68
- const prepared = await deps.launchPlans.prepare(resolved, {
69
- modelConfig: watcher.launchModelConfig,
70
- invalidModelConfig: "omit",
71
- });
72
- if (!prepared.ok) {
73
- result.errors.push(...prepared.errors.map((error) => `${watcher.processId}:${watcher.watcherId}:${error.code}`));
74
- return result;
75
- }
76
- const created = await deps.processLaunches.createProcessFromLaunchPlan(prepared.launchPlan);
77
- const durableProcess = created.ok
78
- ? created.process
79
- : created.stage === "post_commit"
80
- ? created.process
81
- : null;
82
- if (durableProcess) {
83
- await consumeTriggerFile(watcher.config.filePath);
84
- result.created.push(durableProcess.id);
85
- }
86
- if (!created.ok) {
87
- result.errors.push(`${watcher.processId}:${watcher.watcherId}:${created.status}:${String(created.body.error ?? "launch_failed")}`);
88
- logger?.warn?.({
89
- processId: watcher.processId,
90
- watcherId: watcher.watcherId,
91
- filePath: watcher.config.filePath,
92
- status: created.status,
93
- }, "File watcher launch failed");
94
- }
95
- return result;
96
- },
97
- }));
98
- return {
99
- start() {
100
- for (const loop of loops)
101
- loop.start();
102
- },
103
- stop() {
104
- for (const loop of loops)
105
- loop.stop();
106
- },
107
- };
108
- }
109
- //# sourceMappingURL=filesystem-watcher.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"filesystem-watc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