@leitwerk-dev/showcase-processes 0.2.0 → 0.3.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/README.md +10 -0
- package/dist/file-external.d.ts +14 -1
- package/dist/file-external.d.ts.map +1 -1
- package/dist/filesystem-watcher.d.ts +12 -1
- package/dist/filesystem-watcher.d.ts.map +1 -1
- package/dist/index.d.ts +2 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +53 -54
- package/dist/index.js.map +1 -1
- package/dist/poem-leaf-outcome.d.ts +31 -0
- package/dist/poem-leaf-outcome.d.ts.map +1 -1
- package/dist/process-definition.d.ts +21 -8
- package/dist/process-definition.d.ts.map +1 -1
- package/dist/testing/harness.d.ts +13 -0
- package/dist/testing/harness.d.ts.map +1 -0
- package/dist/trigger-files.d.ts +15 -0
- package/dist/trigger-files.d.ts.map +1 -0
- package/dist/turns/external-complete.d.ts +5 -0
- package/dist/turns/external-complete.d.ts.map +1 -1
- package/dist/turns/poem-creator.d.ts +12 -0
- package/dist/turns/poem-creator.d.ts.map +1 -1
- package/dist/turns/run-single-prompt.d.ts +6 -0
- package/dist/turns/run-single-prompt.d.ts.map +1 -1
- package/dist/ui/assets/leaf-outcome-element.js +12 -0
- package/dist/ui/assets/leaf-outcome-element.js.map +1 -1
- package/dist/ui/assets/poem-leaf-outcome-element.js +12 -0
- package/dist/ui/assets/poem-leaf-outcome-element.js.map +1 -1
- package/package.json +4 -4
- package/src/file-external.ts +13 -7
- package/src/filesystem-watcher.ts +14 -7
- package/src/index.ts +15 -10
- package/src/poem-leaf-outcome.ts +31 -0
- package/src/process-definition.ts +31 -5
- package/src/testing/harness.ts +105 -0
- package/src/trigger-files.ts +47 -0
- package/src/turns/external-complete.ts +5 -0
- package/src/turns/poem-creator.ts +12 -0
- package/src/turns/run-single-prompt.ts +6 -0
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
type AutomaticOutcomeBuilder,
|
|
5
5
|
type Codec,
|
|
6
6
|
createEmptyStructuralProcessState,
|
|
7
|
+
type ExtensionProcessDefinition,
|
|
7
8
|
type FormDefinition,
|
|
8
9
|
flow,
|
|
9
10
|
type HumanFlowBuilder,
|
|
@@ -34,13 +35,19 @@ import {
|
|
|
34
35
|
buildSinglePromptWithToolInstruction,
|
|
35
36
|
} from "./turns/run-single-prompt.js";
|
|
36
37
|
|
|
38
|
+
/** @internal */
|
|
37
39
|
interface PromptProcessParams {
|
|
40
|
+
/** @internal */
|
|
38
41
|
prompt: string;
|
|
39
42
|
}
|
|
40
43
|
|
|
44
|
+
/** @internal */
|
|
41
45
|
interface PoemCreatorState extends StructuralProcessState {
|
|
46
|
+
/** @internal */
|
|
42
47
|
latestReviewMarkdown: string | null;
|
|
48
|
+
/** @internal */
|
|
43
49
|
latestReviewSummary: string | null;
|
|
50
|
+
/** @internal */
|
|
44
51
|
latestReviewOutcome: "no_issues" | "leave_feedback" | null;
|
|
45
52
|
}
|
|
46
53
|
|
|
@@ -297,7 +304,11 @@ const poemReviewChangesForm: FormDefinition = {
|
|
|
297
304
|
submitLabel: "Request review changes",
|
|
298
305
|
};
|
|
299
306
|
|
|
300
|
-
|
|
307
|
+
/** @internal */
|
|
308
|
+
export const singlePromptProcess: ExtensionProcessDefinition<
|
|
309
|
+
PromptProcessParams,
|
|
310
|
+
StructuralProcessState
|
|
311
|
+
> = flow
|
|
301
312
|
.process<PromptProcessParams, StructuralProcessState>("single_prompt_process")
|
|
302
313
|
.displayName("Single Prompt")
|
|
303
314
|
.entry("run_single_prompt")
|
|
@@ -357,7 +368,11 @@ export const singlePromptProcess = flow
|
|
|
357
368
|
})
|
|
358
369
|
.define();
|
|
359
370
|
|
|
360
|
-
|
|
371
|
+
/** @internal */
|
|
372
|
+
export const singlePromptWithToolProcess: ExtensionProcessDefinition<
|
|
373
|
+
PromptProcessParams,
|
|
374
|
+
StructuralProcessState
|
|
375
|
+
> = flow
|
|
361
376
|
.process<PromptProcessParams, StructuralProcessState>("single_prompt_with_tool_process")
|
|
362
377
|
.displayName("Single Prompt + Done Tool")
|
|
363
378
|
.entry("run_single_prompt_with_tool")
|
|
@@ -455,7 +470,7 @@ function defineK8sSmokeProcess(args: {
|
|
|
455
470
|
defaultPrompt: string;
|
|
456
471
|
titleLabel: string;
|
|
457
472
|
run: SmokeRunFn;
|
|
458
|
-
}) {
|
|
473
|
+
}): ExtensionProcessDefinition<PromptProcessParams, StructuralProcessState> {
|
|
459
474
|
const promptField = args.promptField;
|
|
460
475
|
const resolveLaunchConfig = promptField
|
|
461
476
|
? (input: Record<string, unknown>) => {
|
|
@@ -544,6 +559,7 @@ function defineK8sSmokeProcess(args: {
|
|
|
544
559
|
.define();
|
|
545
560
|
}
|
|
546
561
|
|
|
562
|
+
/** @internal */
|
|
547
563
|
export const k8sSmokeProcess = defineK8sSmokeProcess({
|
|
548
564
|
processId: "k8s_smoke_process",
|
|
549
565
|
displayName: "Kubernetes Smoke",
|
|
@@ -570,6 +586,7 @@ export const k8sSmokeProcess = defineK8sSmokeProcess({
|
|
|
570
586
|
}),
|
|
571
587
|
});
|
|
572
588
|
|
|
589
|
+
/** @internal */
|
|
573
590
|
export const k8sSmokeSpecializedProcess = defineK8sSmokeProcess({
|
|
574
591
|
processId: "k8s_smoke_specialized_process",
|
|
575
592
|
displayName: "Kubernetes Specialized Smoke",
|
|
@@ -594,6 +611,7 @@ export const k8sSmokeSpecializedProcess = defineK8sSmokeProcess({
|
|
|
594
611
|
},
|
|
595
612
|
});
|
|
596
613
|
|
|
614
|
+
/** @internal */
|
|
597
615
|
export const k8sSmokeLongProcess = defineK8sSmokeProcess({
|
|
598
616
|
processId: "k8s_smoke_long_process",
|
|
599
617
|
displayName: "Kubernetes Long Smoke",
|
|
@@ -616,7 +634,11 @@ export const k8sSmokeLongProcess = defineK8sSmokeProcess({
|
|
|
616
634
|
},
|
|
617
635
|
});
|
|
618
636
|
|
|
619
|
-
|
|
637
|
+
/** @internal */
|
|
638
|
+
export const singlePromptExternalCompleteProcess: ExtensionProcessDefinition<
|
|
639
|
+
PromptProcessParams,
|
|
640
|
+
StructuralProcessState
|
|
641
|
+
> = flow
|
|
620
642
|
.process<PromptProcessParams, StructuralProcessState>("single_prompt_external_complete_process")
|
|
621
643
|
.displayName("Single Prompt + External Complete")
|
|
622
644
|
.entry("run_single_prompt")
|
|
@@ -801,7 +823,7 @@ const poemReviewFeedbackSpec = flow
|
|
|
801
823
|
})),
|
|
802
824
|
).definition;
|
|
803
825
|
|
|
804
|
-
|
|
826
|
+
const poemCreatorProcessDefinition = flow
|
|
805
827
|
.process<PromptProcessParams, PoemCreatorState>("poem_creator_process")
|
|
806
828
|
.displayName("Poem Creator")
|
|
807
829
|
.entry(poemTurnIds.draftPoem)
|
|
@@ -961,3 +983,7 @@ export const poemCreatorProcess = flow
|
|
|
961
983
|
},
|
|
962
984
|
})
|
|
963
985
|
.define();
|
|
986
|
+
|
|
987
|
+
/** @internal */
|
|
988
|
+
export const poemCreatorProcess: ExtensionProcessDefinition<PromptProcessParams, PoemCreatorState> =
|
|
989
|
+
poemCreatorProcessDefinition;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { fixtureModelProviders } from "@leitwerk-dev/test-support";
|
|
2
|
+
import {
|
|
3
|
+
createExtensionIntegrationHarness,
|
|
4
|
+
type ExtensionIntegrationHarness,
|
|
5
|
+
type ExtensionIntegrationHarnessOptions,
|
|
6
|
+
} from "@leitwerk-dev/test-support/integration";
|
|
7
|
+
import singlePromptExtension from "../index.js";
|
|
8
|
+
|
|
9
|
+
export function createShowcaseHarness(options: Partial<ExtensionIntegrationHarnessOptions> = {}) {
|
|
10
|
+
return createExtensionIntegrationHarness({
|
|
11
|
+
extensions: [
|
|
12
|
+
singlePromptExtension,
|
|
13
|
+
{
|
|
14
|
+
manifest: { id: "showcase-fixture-providers", version: "1" },
|
|
15
|
+
modelProviders: fixtureModelProviders(
|
|
16
|
+
{ id: "anthropic", modelId: "claude-sonnet-4-20250514", server: true },
|
|
17
|
+
{ id: "ollama", modelId: "qwen2.5-coder:14b", server: true },
|
|
18
|
+
),
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
models: [
|
|
22
|
+
{
|
|
23
|
+
id: "claude_fast",
|
|
24
|
+
thinkingLevel: "medium",
|
|
25
|
+
provider: "anthropic",
|
|
26
|
+
modelId: "claude-sonnet-4-20250514",
|
|
27
|
+
},
|
|
28
|
+
{ id: "local_qwen", thinkingLevel: "low", provider: "ollama", modelId: "qwen2.5-coder:14b" },
|
|
29
|
+
],
|
|
30
|
+
defaultModel: "claude_fast",
|
|
31
|
+
script(_id, _prompt, observation) {
|
|
32
|
+
const names = new Set(observation.tools.map((tool) => tool.name));
|
|
33
|
+
if (names.has("no_issues"))
|
|
34
|
+
return {
|
|
35
|
+
tools: [
|
|
36
|
+
{ name: "no_issues", arguments: { review: "## Review\n\nReady.", summary: "Ready" } },
|
|
37
|
+
],
|
|
38
|
+
};
|
|
39
|
+
if (names.has("done"))
|
|
40
|
+
return {
|
|
41
|
+
tools: [
|
|
42
|
+
{
|
|
43
|
+
name: "done",
|
|
44
|
+
arguments: { summary: "Completed", markdown: "# Result\n\nCompleted." },
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
tools: [
|
|
50
|
+
{
|
|
51
|
+
name: "markdown_result",
|
|
52
|
+
arguments: {
|
|
53
|
+
markdown:
|
|
54
|
+
"# Cloud Dusk\n\nEvening servers hum in amber light,\nScaled dreams unfolding into night.",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
...options,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Keep HTTP assertions on the supported request interface. */
|
|
65
|
+
export async function http(test: ExtensionIntegrationHarness, url: string, init: RequestInit = {}) {
|
|
66
|
+
const response = await test.request({
|
|
67
|
+
url,
|
|
68
|
+
method: (init.method ?? "GET") as "GET" | "POST" | "DELETE",
|
|
69
|
+
...(init.body ? { payload: JSON.parse(String(init.body)) } : {}),
|
|
70
|
+
});
|
|
71
|
+
return { status: response.statusCode, json: response.json };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Observe asynchronous launch admission without exposing server state. */
|
|
75
|
+
export async function launchRequest(
|
|
76
|
+
test: ExtensionIntegrationHarness,
|
|
77
|
+
url: string,
|
|
78
|
+
init: RequestInit,
|
|
79
|
+
): Promise<{ status: number; json(): unknown }> {
|
|
80
|
+
const admitted = await test.request({
|
|
81
|
+
method: "POST",
|
|
82
|
+
url,
|
|
83
|
+
headers: { "idempotency-key": crypto.randomUUID() },
|
|
84
|
+
payload: { ...JSON.parse(String(init.body)), schedule: { mode: "now" } },
|
|
85
|
+
});
|
|
86
|
+
if (admitted.statusCode !== 202) return { status: admitted.statusCode, json: admitted.json };
|
|
87
|
+
const { launchRunId } = admitted.json<{ launchRunId: string }>();
|
|
88
|
+
const deadline = Date.now() + 12000;
|
|
89
|
+
for (;;) {
|
|
90
|
+
const response = await test.request({ url: `/api/launch-runs/${launchRunId}` });
|
|
91
|
+
const { launchRun } = response.json<{
|
|
92
|
+
launchRun: { status: string; instanceId: string | null };
|
|
93
|
+
}>();
|
|
94
|
+
if (launchRun.instanceId) {
|
|
95
|
+
const snapshot = test.process(launchRun.instanceId).snapshot();
|
|
96
|
+
return {
|
|
97
|
+
status: launchRun.status === "failed" ? 200 : 201,
|
|
98
|
+
json: () => ({ process: snapshot.process, projects: snapshot.projects }),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (launchRun.status === "failed" || Date.now() >= deadline)
|
|
102
|
+
throw new Error(`Launch did not commit: ${response.body}`);
|
|
103
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { readFile, unlink } from "node:fs/promises";
|
|
2
|
+
|
|
3
|
+
/** @internal */
|
|
4
|
+
export type TriggerFileReadResult =
|
|
5
|
+
| {
|
|
6
|
+
/** @internal */
|
|
7
|
+
exists: false;
|
|
8
|
+
}
|
|
9
|
+
| {
|
|
10
|
+
/** @internal */
|
|
11
|
+
exists: true;
|
|
12
|
+
/** @internal */
|
|
13
|
+
content: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** @internal */
|
|
17
|
+
function errorCode(error: unknown): string | null {
|
|
18
|
+
if (typeof error !== "object" || error === null || !("code" in error)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const code = (error as { code?: unknown }).code;
|
|
22
|
+
return typeof code === "string" ? code : null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** @internal */
|
|
26
|
+
export async function readTriggerFile(filePath: string): Promise<TriggerFileReadResult> {
|
|
27
|
+
try {
|
|
28
|
+
return { exists: true, content: await readFile(filePath, "utf8") };
|
|
29
|
+
} catch (error) {
|
|
30
|
+
if (errorCode(error) === "ENOENT") {
|
|
31
|
+
return { exists: false };
|
|
32
|
+
}
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** @internal */
|
|
38
|
+
export async function consumeTriggerFile(filePath: string): Promise<void> {
|
|
39
|
+
try {
|
|
40
|
+
await unlink(filePath);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if (errorCode(error) === "ENOENT") {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
/** @internal */
|
|
1
2
|
export const externalCompleteActionId = "complete_external_prompt";
|
|
3
|
+
/** @internal */
|
|
2
4
|
export const externalPromptCompletionTurnId = "await_external_prompt_completion";
|
|
5
|
+
/** @internal */
|
|
3
6
|
export const externalPromptCompletionTurnDescription =
|
|
4
7
|
"Wait for an external completion trigger after the single prompt finishes";
|
|
8
|
+
/** @internal */
|
|
5
9
|
export const externalPromptCompletionTriggerLabel = "Configured prompt-complete file";
|
|
10
|
+
/** @internal */
|
|
6
11
|
export const externalPromptCompletionTriggerDescription =
|
|
7
12
|
"Write any content to the configured prompt-complete trigger file (default: /tmp/complete-prompt) to complete the process. The file is removed after a successful completion.";
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import type { ToolCallRendererDefinition } from "@leitwerk-dev/process-sdk";
|
|
2
2
|
|
|
3
|
+
/** @internal */
|
|
3
4
|
export const poemCreatorActionIds = {
|
|
5
|
+
/** @internal */
|
|
4
6
|
completePoem: "complete_poem",
|
|
7
|
+
/** @internal */
|
|
5
8
|
requestRevision: "request_poem_revision",
|
|
9
|
+
/** @internal */
|
|
6
10
|
runAutoReview: "run_poem_auto_review",
|
|
11
|
+
/** @internal */
|
|
7
12
|
acceptReview: "accept_poem_review",
|
|
13
|
+
/** @internal */
|
|
8
14
|
requestReviewChanges: "request_poem_review_changes",
|
|
15
|
+
/** @internal */
|
|
9
16
|
dismissReview: "dismiss_poem_review",
|
|
10
17
|
} as const;
|
|
11
18
|
|
|
@@ -19,11 +26,13 @@ function formatGermanyDay(now: Date): string {
|
|
|
19
26
|
}).format(now);
|
|
20
27
|
}
|
|
21
28
|
|
|
29
|
+
/** @internal */
|
|
22
30
|
export function buildDefaultPoemPrompt(now = new Date()): string {
|
|
23
31
|
const germanyDay = formatGermanyDay(now);
|
|
24
32
|
return `Write a short poem in Markdown that is either inspired by ${germanyDay} in Germany or by the craft of building cloud software. Keep it vivid, warm, and concise.`;
|
|
25
33
|
}
|
|
26
34
|
|
|
35
|
+
/** @internal */
|
|
27
36
|
export function buildDraftPoemInstruction(promptText: string): string {
|
|
28
37
|
return `Write a short poem in Markdown that clearly responds to the operator's prompt.
|
|
29
38
|
|
|
@@ -39,6 +48,7 @@ Requirements:
|
|
|
39
48
|
- only the primary branch should write or revise the poem directly`;
|
|
40
49
|
}
|
|
41
50
|
|
|
51
|
+
/** @internal */
|
|
42
52
|
export function buildRevisePoemInstruction(revisionGuidance: string): string {
|
|
43
53
|
return `Continue from the current poem on this branch and revise it according to this request:
|
|
44
54
|
|
|
@@ -47,6 +57,7 @@ ${revisionGuidance}
|
|
|
47
57
|
Preserve the parts of the current poem that the request does not ask you to change. Return the complete revised poem in the same Markdown format.`;
|
|
48
58
|
}
|
|
49
59
|
|
|
60
|
+
/** @internal */
|
|
50
61
|
export function buildReviewPoemInstruction(promptText: string, poemDraftMarkdown: string): string {
|
|
51
62
|
return `Review the latest poem draft against the operator's prompt.
|
|
52
63
|
|
|
@@ -64,6 +75,7 @@ If the poem is strong, relevant, and well-formed Markdown, call no_issues with a
|
|
|
64
75
|
If the poem misses the prompt, needs revision, or is awkwardly structured, call leave_feedback with a brief summary and concise plain-text feedback.`;
|
|
65
76
|
}
|
|
66
77
|
|
|
78
|
+
/** @internal */
|
|
67
79
|
export const leaveFeedbackToolRenderer: ToolCallRendererDefinition = {
|
|
68
80
|
toolName: "leave_feedback",
|
|
69
81
|
title: "Feedback",
|
|
@@ -4,12 +4,14 @@ import {
|
|
|
4
4
|
REQUIRED_MARKDOWN_RESULT_TURN_RESULT,
|
|
5
5
|
} from "@leitwerk-dev/process-sdk";
|
|
6
6
|
|
|
7
|
+
/** @internal */
|
|
7
8
|
export function buildSinglePromptInstruction(promptText: string): string {
|
|
8
9
|
return `Run the following one-shot operator prompt exactly once.
|
|
9
10
|
|
|
10
11
|
${promptText}`;
|
|
11
12
|
}
|
|
12
13
|
|
|
14
|
+
/** @internal */
|
|
13
15
|
export function buildSinglePromptWithToolInstruction(promptText: string): string {
|
|
14
16
|
return `Run the following one-shot operator prompt exactly once.
|
|
15
17
|
|
|
@@ -18,6 +20,7 @@ ${promptText}
|
|
|
18
20
|
When you are done, call the done tool with a short summary of the result.`;
|
|
19
21
|
}
|
|
20
22
|
|
|
23
|
+
/** @internal */
|
|
21
24
|
export function createRunSinglePromptTurn(promptText: string): LlmTurnDefinition<"completed"> {
|
|
22
25
|
return llmTurn({
|
|
23
26
|
description: "Run a single operator-provided prompt and finish on turn end",
|
|
@@ -36,6 +39,7 @@ export function createRunSinglePromptTurn(promptText: string): LlmTurnDefinition
|
|
|
36
39
|
});
|
|
37
40
|
}
|
|
38
41
|
|
|
42
|
+
/** @internal */
|
|
39
43
|
export function createRunSinglePromptWithToolTurn(promptText: string): LlmTurnDefinition<"done"> {
|
|
40
44
|
return llmTurn({
|
|
41
45
|
description: "Run a single operator-provided prompt and require the done tool",
|
|
@@ -61,10 +65,12 @@ export function createRunSinglePromptWithToolTurn(promptText: string): LlmTurnDe
|
|
|
61
65
|
});
|
|
62
66
|
}
|
|
63
67
|
|
|
68
|
+
/** @internal */
|
|
64
69
|
export const runSinglePrompt = createRunSinglePromptTurn(
|
|
65
70
|
"Run the operator-provided single prompt.",
|
|
66
71
|
);
|
|
67
72
|
|
|
73
|
+
/** @internal */
|
|
68
74
|
export const runSinglePromptWithTool = createRunSinglePromptWithToolTurn(
|
|
69
75
|
"Run the operator-provided single prompt.",
|
|
70
76
|
);
|