@lukstei/dsh-yaml-workflow 0.0.0-stage → 0.2.2-rc.5.4
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/LICENSE +21 -0
- package/README.md +452 -2
- package/cordis.patch.yml +4 -0
- package/dist/client.js +1746 -0
- package/dist/index.js +3495 -0
- package/examples/gate.yml +4 -0
- package/examples/parametrized-wf.yml +20 -0
- package/examples/wf.yml +3 -0
- package/package.json +114 -3
- package/src/boolean.ts +96 -0
- package/src/client/WorkflowCommandCard.tsx +217 -0
- package/src/client/WorkflowErrorCard.tsx +99 -0
- package/src/client/WorkflowMarkdown.tsx +28 -0
- package/src/client/WorkflowMarkdownResult.tsx +86 -0
- package/src/client/WorkflowPrintStep.tsx +46 -0
- package/src/client/WorkflowResumeButton.tsx +159 -0
- package/src/client/WorkflowStepRow.tsx +106 -0
- package/src/client/WorkflowStyles.tsx +10 -0
- package/src/client/actions.ts +113 -0
- package/src/client/context.ts +30 -0
- package/src/client/dsh.d.ts +33 -0
- package/src/client/icons.tsx +91 -0
- package/src/client/index.tsx +186 -0
- package/src/client/store.ts +655 -0
- package/src/client/styles.ts +340 -0
- package/src/effects.ts +696 -0
- package/src/fold.ts +201 -0
- package/src/index.ts +468 -0
- package/src/parser.ts +1146 -0
- package/src/requests.ts +85 -0
- package/src/rules.ts +647 -0
- package/src/runner.ts +1955 -0
- package/src/skill.ts +67 -0
- package/src/transitions.ts +357 -0
- package/src/types.ts +604 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: "Parametrized Deployment Workflow"
|
|
2
|
+
args:
|
|
3
|
+
environment:
|
|
4
|
+
type: choice
|
|
5
|
+
choices: [staging, production]
|
|
6
|
+
default: staging
|
|
7
|
+
description: "Deployment target environment"
|
|
8
|
+
version:
|
|
9
|
+
type: string
|
|
10
|
+
description: "Semantic version tag to deploy"
|
|
11
|
+
instructions:
|
|
12
|
+
type: string
|
|
13
|
+
description: "Additional operational notes"
|
|
14
|
+
default: "Run smoke tests before proceeding"
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- name: "Announce target"
|
|
18
|
+
print: "Preparing deployment of version {{args.version}} to {{args.environment}}"
|
|
19
|
+
- name: "Deployment execution"
|
|
20
|
+
prompt: "Deploy {{args.version}} to {{args.environment}}. Operational notes: {{args.instructions}}"
|
package/examples/wf.yml
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,117 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lukstei/dsh-yaml-workflow",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.2-rc.5.4",
|
|
4
|
+
"description": "Execute sequential prompt workflows from YAML",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./src/index.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./src/index.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./client": "./dist/client.js",
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"src",
|
|
18
|
+
"dist",
|
|
19
|
+
"examples",
|
|
20
|
+
"README.md",
|
|
21
|
+
"cordis.patch.yml",
|
|
22
|
+
"!src/**/*.spec.*",
|
|
23
|
+
"!src/**/*.test.*",
|
|
24
|
+
"!src/**/*.stories.*",
|
|
25
|
+
"!src/**/stories",
|
|
26
|
+
"!src/**/*.e2e.*",
|
|
27
|
+
"!src/**/__snapshots__",
|
|
28
|
+
"!src/**/fixtures",
|
|
29
|
+
"!src/e2e"
|
|
30
|
+
],
|
|
31
|
+
"dsh": {
|
|
32
|
+
"bundle": {
|
|
33
|
+
"patch": "./cordis.patch.yml"
|
|
34
|
+
},
|
|
35
|
+
"client": {
|
|
36
|
+
"platform": "web",
|
|
37
|
+
"immediately": true,
|
|
38
|
+
"inject": [
|
|
39
|
+
"@deepseek-ai/dsh-api-session-controller",
|
|
40
|
+
"@deepseek-ai/dsh-client-ui-chat",
|
|
41
|
+
"@deepseek-ai/dsh-client-ui-slots",
|
|
42
|
+
"@deepseek-ai/dsh-client-ui-conversation"
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"yaml": "^2.7.0",
|
|
48
|
+
"zod": "4.6.6"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@deepseek-ai/cordis": "4.1.0",
|
|
52
|
+
"@deepseek-ai/dsh-agent": "0.2.2-rc.5",
|
|
53
|
+
"@deepseek-ai/dsh-api-session-controller": "0.2.2-rc.5",
|
|
54
|
+
"@deepseek-ai/dsh-client-store": "0.2.2-rc.5",
|
|
55
|
+
"@deepseek-ai/dsh-client-ui-chat": "0.2.2-rc.5",
|
|
56
|
+
"@deepseek-ai/dsh-client-ui-conversation": "0.2.2-rc.5",
|
|
57
|
+
"@deepseek-ai/dsh-client-ui-renderer": "0.2.2-rc.5",
|
|
58
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.5",
|
|
59
|
+
"@deepseek-ai/dsh-commands": "0.2.2-rc.5",
|
|
60
|
+
"@deepseek-ai/dsh-llm": "0.2.2-rc.5",
|
|
61
|
+
"@deepseek-ai/dsh-session": "0.2.2-rc.5",
|
|
62
|
+
"@deepseek-ai/dsh-session-projection": "0.2.2-rc.5",
|
|
63
|
+
"@deepseek-ai/dsh-session-title": "0.2.2-rc.5",
|
|
64
|
+
"@deepseek-ai/dsh-subagent": "0.2.2-rc.5",
|
|
65
|
+
"@deepseek-ai/dsh-tools": "0.2.2-rc.5",
|
|
66
|
+
"@ladle/react": "^5.1.1",
|
|
67
|
+
"@types/node": "^26.0.0",
|
|
68
|
+
"@types/react": "^19.3.0",
|
|
69
|
+
"@vitest/coverage-v8": "5.0.5",
|
|
70
|
+
"immer": "^10.2.0",
|
|
71
|
+
"react": "^19.3.1",
|
|
72
|
+
"react-dom": "^19.3.1",
|
|
73
|
+
"tsdown": "^0.23.0",
|
|
74
|
+
"typescript": "^7.0.2",
|
|
75
|
+
"vitest": "5.0.5",
|
|
76
|
+
"zustand": "^4.5.7"
|
|
77
|
+
},
|
|
78
|
+
"peerDependencies": {
|
|
79
|
+
"@deepseek-ai/cordis": "*",
|
|
80
|
+
"@deepseek-ai/dsh-agent": "*",
|
|
81
|
+
"@deepseek-ai/dsh-api-session-controller": "*",
|
|
82
|
+
"@deepseek-ai/dsh-client-ui-chat": "*",
|
|
83
|
+
"@deepseek-ai/dsh-client-ui-conversation": "*",
|
|
84
|
+
"@deepseek-ai/dsh-client-ui-slots": "*",
|
|
85
|
+
"@deepseek-ai/dsh-commands": "*",
|
|
86
|
+
"@deepseek-ai/dsh-llm": "*",
|
|
87
|
+
"@deepseek-ai/dsh-session": "*",
|
|
88
|
+
"@deepseek-ai/dsh-session-projection": "*",
|
|
89
|
+
"@deepseek-ai/dsh-session-title": "*",
|
|
90
|
+
"@deepseek-ai/dsh-skill": "*",
|
|
91
|
+
"@deepseek-ai/dsh-subagent": "*",
|
|
92
|
+
"@deepseek-ai/dsh-tools": "*",
|
|
93
|
+
"react": "*"
|
|
94
|
+
},
|
|
95
|
+
"license": "MIT",
|
|
96
|
+
"repository": {
|
|
97
|
+
"type": "git",
|
|
98
|
+
"url": "git+https://github.com/lukstei/dsh-plugins.git",
|
|
99
|
+
"directory": "packages/dsh-yaml-workflow"
|
|
100
|
+
},
|
|
101
|
+
"publishConfig": {
|
|
102
|
+
"access": "public"
|
|
103
|
+
},
|
|
104
|
+
"scripts": {
|
|
105
|
+
"build": "tsdown --config tsdown.config.ts --logLevel error",
|
|
106
|
+
"dev": "tsdown --config tsdown.config.ts --watch",
|
|
107
|
+
"check": "biome check --reporter=concise .",
|
|
108
|
+
"typecheck": "tsc --noEmit",
|
|
109
|
+
"test": "pnpm run build && vitest run --reporter=minimal",
|
|
110
|
+
"test:e2e": "vitest run --config vitest.e2e.config.ts --coverage --reporter=minimal",
|
|
111
|
+
"test:watch": "vitest",
|
|
112
|
+
"test:update": "vitest run -u",
|
|
113
|
+
"verify": "pnpm --silent run check && pnpm --silent run build && pnpm --silent run typecheck && pnpm --silent run test && pnpm --silent run test:e2e",
|
|
114
|
+
"ladle": "ladle serve",
|
|
115
|
+
"ladle:build": "ladle build"
|
|
116
|
+
}
|
|
6
117
|
}
|
package/src/boolean.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PURPOSE: Pure boolean parsing, template interpolation, and gate resolution helper functions.
|
|
3
|
+
* ALLOWED: Pure computation, string parsing, template interpolation.
|
|
4
|
+
* FORBIDDEN: No I/O, no framework dependencies, no side effects.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Converts a boolean, string, or unknown value into a strict boolean (true/false) or undefined if not a boolean representation.
|
|
9
|
+
* CONTRACT:
|
|
10
|
+
* - Input: unknown value (boolean, string, undefined, null, etc.).
|
|
11
|
+
* - Output: boolean true for true / "true" (case-insensitive), false for false / "false" (case-insensitive), undefined otherwise.
|
|
12
|
+
*/
|
|
13
|
+
export function parseBoolean(value: unknown): boolean | undefined {
|
|
14
|
+
if (typeof value === "boolean") return value;
|
|
15
|
+
if (typeof value === "string") {
|
|
16
|
+
const trimmed = value.trim().toLowerCase();
|
|
17
|
+
if (trimmed === "true") return true;
|
|
18
|
+
if (trimmed === "false") return false;
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Interpolates {{args.<name>}} and {{outputs.<name>}} template variables in a text string.
|
|
25
|
+
* CONTRACT:
|
|
26
|
+
* - Input: raw template string, args map, and optional outputs map.
|
|
27
|
+
* - Output: string with all {{args.*}} and {{outputs.*}} variables replaced.
|
|
28
|
+
* - Throws: Error if an {{args.*}} variable is unresolvable.
|
|
29
|
+
*/
|
|
30
|
+
export function interpolateTemplate(
|
|
31
|
+
template: string,
|
|
32
|
+
args: Record<string, string>,
|
|
33
|
+
outputs?: Record<string, string | readonly string[]>,
|
|
34
|
+
context?: { readonly item?: string },
|
|
35
|
+
): string {
|
|
36
|
+
let result = template.replace(
|
|
37
|
+
/\{\{args\.([a-zA-Z0-9_-]+)\}\}/g,
|
|
38
|
+
(_match, key: string) => {
|
|
39
|
+
const value = args[key];
|
|
40
|
+
if (value === undefined) {
|
|
41
|
+
throw new Error(`Unresolved workflow argument: {{args.${key}}}`);
|
|
42
|
+
}
|
|
43
|
+
return value;
|
|
44
|
+
},
|
|
45
|
+
);
|
|
46
|
+
if (context?.item !== undefined) {
|
|
47
|
+
result = result.replace(/\{\{item\}\}/g, context.item);
|
|
48
|
+
}
|
|
49
|
+
if (outputs !== undefined) {
|
|
50
|
+
result = result.replace(
|
|
51
|
+
/\{\{outputs\.([a-zA-Z0-9_-]+)\}\}/g,
|
|
52
|
+
(_match, key: string) => {
|
|
53
|
+
const val = outputs[key];
|
|
54
|
+
if (val === undefined) return String(val);
|
|
55
|
+
if (Array.isArray(val)) {
|
|
56
|
+
if (val.length === 0) return "";
|
|
57
|
+
return val.map((item) => `- ${item}`).join("\n");
|
|
58
|
+
}
|
|
59
|
+
return String(val);
|
|
60
|
+
},
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Resolves a step gate declaration (boolean, templated string, or explicit description) into an active gate criteria string, or undefined if inactive.
|
|
68
|
+
* CONTRACT:
|
|
69
|
+
* - Input: gate (string | boolean | undefined), args map, optional outputs map, optional fallback stepName.
|
|
70
|
+
* - Output: resolved gate description string if active, or undefined if inactive (false, "false", empty, or undefined).
|
|
71
|
+
*/
|
|
72
|
+
export function resolveGate(
|
|
73
|
+
gate: string | boolean | undefined,
|
|
74
|
+
args: Record<string, string> = {},
|
|
75
|
+
outputs?: Record<string, string | readonly string[]>,
|
|
76
|
+
stepName?: string,
|
|
77
|
+
): string | undefined {
|
|
78
|
+
if (gate === undefined) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
if (typeof gate === "boolean") {
|
|
82
|
+
return gate ? stepName || "Gate" : undefined;
|
|
83
|
+
}
|
|
84
|
+
const interpolated = interpolateTemplate(gate, args, outputs).trim();
|
|
85
|
+
if (interpolated === "") {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
const interpolatedBool = parseBoolean(interpolated);
|
|
89
|
+
if (interpolatedBool === false) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
if (interpolatedBool === true) {
|
|
93
|
+
return stepName || "Gate";
|
|
94
|
+
}
|
|
95
|
+
return interpolated;
|
|
96
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PURPOSE: Interactive workflow card view for wf-state chat nodes in conversation feed.
|
|
3
|
+
* ALLOWED: React rendering, clipboard actions, status badge derivations.
|
|
4
|
+
* FORBIDDEN: Direct agent manipulation, inline filesystem operations.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { ChatNodeViewProps } from "@deepseek-ai/dsh-client-ui-chat/client";
|
|
8
|
+
import type React from "react";
|
|
9
|
+
import { useState } from "react";
|
|
10
|
+
import { resolveGate } from "../boolean.ts";
|
|
11
|
+
import type { WorkflowInvocation, WorkflowRun } from "../types.ts";
|
|
12
|
+
import { CheckIcon, CopyIcon } from "./icons.tsx";
|
|
13
|
+
import { WorkflowStyles } from "./WorkflowStyles.tsx";
|
|
14
|
+
|
|
15
|
+
export type WorkflowCommandCardProps = Pick<
|
|
16
|
+
ChatNodeViewProps<"wf-state">,
|
|
17
|
+
"node"
|
|
18
|
+
>;
|
|
19
|
+
|
|
20
|
+
export interface PausedGateDetails {
|
|
21
|
+
readonly gate?: string;
|
|
22
|
+
readonly nextStepLabel: string;
|
|
23
|
+
readonly isInterrupted?: boolean;
|
|
24
|
+
readonly targetName?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Derives paused gate criteria and next step preview from a workflow run.
|
|
29
|
+
* CONTRACT:
|
|
30
|
+
* - Inputs: WorkflowRun object.
|
|
31
|
+
* - Outputs: PausedGateDetails with gate and nextStepLabel, or undefined if not paused.
|
|
32
|
+
*/
|
|
33
|
+
export function getPausedGateDetails(
|
|
34
|
+
run: WorkflowRun,
|
|
35
|
+
): PausedGateDetails | undefined {
|
|
36
|
+
if (run.state.status !== "paused") {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
const isInterrupted = run.state.pauseReason === "interrupted";
|
|
40
|
+
const currentStep = run.workflow.steps[run.state.stepIndex];
|
|
41
|
+
const rawGate =
|
|
42
|
+
!isInterrupted &&
|
|
43
|
+
(currentStep?.kind === "prompt" || currentStep?.kind === "subagent")
|
|
44
|
+
? currentStep.gate
|
|
45
|
+
: undefined;
|
|
46
|
+
|
|
47
|
+
const gate = resolveGate(
|
|
48
|
+
rawGate,
|
|
49
|
+
run.invocation.resolvedArgs,
|
|
50
|
+
run.state.outputs,
|
|
51
|
+
currentStep?.name,
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const targetIndex = isInterrupted
|
|
55
|
+
? run.state.stepIndex
|
|
56
|
+
: run.state.stepIndex + 1;
|
|
57
|
+
const targetStep =
|
|
58
|
+
targetIndex < run.workflow.steps.length
|
|
59
|
+
? run.workflow.steps[targetIndex]
|
|
60
|
+
: undefined;
|
|
61
|
+
const targetName = targetStep?.name;
|
|
62
|
+
const nextStepLabel = targetStep
|
|
63
|
+
? `Step ${targetIndex + 1} of ${run.workflow.steps.length}: ${targetName}`
|
|
64
|
+
: "Workflow complete on resume";
|
|
65
|
+
|
|
66
|
+
return { gate, nextStepLabel, isInterrupted, targetName };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Purpose: Recover the copyable command from recorded invocation input.
|
|
71
|
+
* Contract:
|
|
72
|
+
* - Inputs: A workflow invocation, including historical records without rawInput.
|
|
73
|
+
* - Outputs: Original /wf command, or undefined when its input was not recorded.
|
|
74
|
+
* - Throws: None.
|
|
75
|
+
* @internal Exported for direct regression testing.
|
|
76
|
+
*/
|
|
77
|
+
export function resolveWorkflowCommand(
|
|
78
|
+
invocation: WorkflowInvocation,
|
|
79
|
+
): string | undefined {
|
|
80
|
+
// edge case: resolved arguments cannot reconstruct historical mapped choices.
|
|
81
|
+
if (invocation.rawInput === undefined) return undefined;
|
|
82
|
+
return `/wf ${invocation.rawInput.trim()}`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Purpose: Workflow status card component mounted in conversation.chat.node slot.
|
|
87
|
+
* Contract:
|
|
88
|
+
* - Inputs: WorkflowCommandCardProps containing 'wf-state' chat node.
|
|
89
|
+
* - Outputs: React JSX element rendering status badges, command string, and gate details.
|
|
90
|
+
* - Throws: None.
|
|
91
|
+
*/
|
|
92
|
+
export function WorkflowCommandCard({
|
|
93
|
+
node,
|
|
94
|
+
}: WorkflowCommandCardProps): React.JSX.Element {
|
|
95
|
+
const run = node.data;
|
|
96
|
+
const { invocation, state } = run;
|
|
97
|
+
const status = state.status;
|
|
98
|
+
const targetPath = invocation.targetPath;
|
|
99
|
+
|
|
100
|
+
const isPaused = status === "paused";
|
|
101
|
+
const isAborted = status === "aborted";
|
|
102
|
+
const isRunning = status === "running";
|
|
103
|
+
const isSuccess = status === "completed";
|
|
104
|
+
const [copied, setCopied] = useState(false);
|
|
105
|
+
|
|
106
|
+
const pausedDetails = isPaused ? getPausedGateDetails(run) : undefined;
|
|
107
|
+
|
|
108
|
+
const formattedArgs = Object.entries(invocation.resolvedArgs)
|
|
109
|
+
.map(([k, v]) => (v.includes(" ") ? `${k}="${v}"` : `${k}=${v}`))
|
|
110
|
+
.join(" ");
|
|
111
|
+
|
|
112
|
+
const rawCommand = resolveWorkflowCommand(invocation);
|
|
113
|
+
|
|
114
|
+
const handleCopy = () => {
|
|
115
|
+
if (rawCommand === undefined) return;
|
|
116
|
+
navigator.clipboard
|
|
117
|
+
.writeText(rawCommand)
|
|
118
|
+
.then(() => {
|
|
119
|
+
setCopied(true);
|
|
120
|
+
setTimeout(() => setCopied(false), 2000);
|
|
121
|
+
})
|
|
122
|
+
.catch(() => {});
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const cardState = isRunning
|
|
126
|
+
? "running"
|
|
127
|
+
: isPaused
|
|
128
|
+
? "paused"
|
|
129
|
+
: isAborted
|
|
130
|
+
? "aborted"
|
|
131
|
+
: isSuccess
|
|
132
|
+
? "completed"
|
|
133
|
+
: "idle";
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<>
|
|
137
|
+
<WorkflowStyles />
|
|
138
|
+
<div className="dsh-wf-card" data-state={cardState}>
|
|
139
|
+
<div className="dsh-wf-header">
|
|
140
|
+
<div className="dsh-wf-title-group">
|
|
141
|
+
<span className="dsh-wf-command-badge">/wf</span>
|
|
142
|
+
{targetPath && (
|
|
143
|
+
<span className="dsh-wf-args" title={targetPath}>
|
|
144
|
+
{targetPath}
|
|
145
|
+
</span>
|
|
146
|
+
)}
|
|
147
|
+
<button
|
|
148
|
+
type="button"
|
|
149
|
+
className="dsh-wf-copy-btn"
|
|
150
|
+
data-copied={copied}
|
|
151
|
+
onClick={handleCopy}
|
|
152
|
+
disabled={rawCommand === undefined}
|
|
153
|
+
title={
|
|
154
|
+
rawCommand === undefined
|
|
155
|
+
? "Original command was not recorded"
|
|
156
|
+
: copied
|
|
157
|
+
? "Copied"
|
|
158
|
+
: "Copy command"
|
|
159
|
+
}
|
|
160
|
+
aria-label={copied ? "Copied" : "Copy command"}
|
|
161
|
+
>
|
|
162
|
+
{copied ? <CheckIcon /> : <CopyIcon />}
|
|
163
|
+
</button>
|
|
164
|
+
</div>
|
|
165
|
+
|
|
166
|
+
<div className="dsh-wf-status">
|
|
167
|
+
{isRunning && (
|
|
168
|
+
<span className="dsh-wf-badge-running">
|
|
169
|
+
<span className="dsh-wf-pulse-dot" />
|
|
170
|
+
Running...
|
|
171
|
+
</span>
|
|
172
|
+
)}
|
|
173
|
+
{isPaused && <span className="dsh-wf-badge-paused">❚❚ Paused</span>}
|
|
174
|
+
{isAborted && (
|
|
175
|
+
<span className="dsh-wf-badge-aborted">
|
|
176
|
+
{state.error ? "✕ Failed" : "✕ Aborted"}
|
|
177
|
+
</span>
|
|
178
|
+
)}
|
|
179
|
+
{isSuccess && <span className="dsh-wf-badge-success">✓ Done</span>}
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
|
|
183
|
+
{formattedArgs && (
|
|
184
|
+
<div className="dsh-wf-body" data-input="true">
|
|
185
|
+
{formattedArgs}
|
|
186
|
+
</div>
|
|
187
|
+
)}
|
|
188
|
+
|
|
189
|
+
{pausedDetails && (
|
|
190
|
+
<div className="dsh-wf-body" data-paused="true">
|
|
191
|
+
{pausedDetails.gate && (
|
|
192
|
+
<div className="dsh-wf-gate-line">
|
|
193
|
+
Paused at gate: {pausedDetails.gate}
|
|
194
|
+
</div>
|
|
195
|
+
)}
|
|
196
|
+
<div className="dsh-wf-next-line">
|
|
197
|
+
{pausedDetails.isInterrupted ? "Resume: " : "Next: "}
|
|
198
|
+
{pausedDetails.nextStepLabel}
|
|
199
|
+
</div>
|
|
200
|
+
<div className="dsh-wf-hint-line">
|
|
201
|
+
Press Resume to proceed, or enter feedback in the prompt input to
|
|
202
|
+
pass instructions.
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
)}
|
|
206
|
+
|
|
207
|
+
{isAborted && (
|
|
208
|
+
<div className="dsh-wf-body" data-error="true">
|
|
209
|
+
{state.error
|
|
210
|
+
? `Workflow failed at step ${state.stepIndex + 1} of ${run.workflow.steps.length}: ${state.error}`
|
|
211
|
+
: `Workflow discarded at step ${state.stepIndex + 1} of ${run.workflow.steps.length}`}
|
|
212
|
+
</div>
|
|
213
|
+
)}
|
|
214
|
+
</div>
|
|
215
|
+
</>
|
|
216
|
+
);
|
|
217
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PURPOSE: Render an error card for failed workflow slash-commands in conversation chat.
|
|
3
|
+
* ALLOWED: React rendering, clipboard actions, reading command outcome and arguments.
|
|
4
|
+
* FORBIDDEN: Direct agent manipulation, inline filesystem operations.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { ChatNodeViewProps } from "@deepseek-ai/dsh-client-ui-chat/client";
|
|
8
|
+
import type React from "react";
|
|
9
|
+
import { useState } from "react";
|
|
10
|
+
import { CheckIcon, CopyIcon } from "./icons.tsx";
|
|
11
|
+
import { WorkflowStyles } from "./WorkflowStyles.tsx";
|
|
12
|
+
|
|
13
|
+
export interface WorkflowErrorChatData {
|
|
14
|
+
readonly name?: string;
|
|
15
|
+
readonly args?: string | null;
|
|
16
|
+
readonly text: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type WorkflowErrorCardProps = Pick<
|
|
20
|
+
ChatNodeViewProps<"wf-error">,
|
|
21
|
+
"node"
|
|
22
|
+
>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Reconstructs the original slash command invocation string from error chat data.
|
|
26
|
+
*/
|
|
27
|
+
export function resolveErrorCommand(data: {
|
|
28
|
+
readonly name?: string;
|
|
29
|
+
readonly args?: string | null;
|
|
30
|
+
}): string {
|
|
31
|
+
const rawArgs = typeof data.args === "string" ? data.args.trim() : "";
|
|
32
|
+
const commandBadge = data.name ? `/${data.name}` : "/wf";
|
|
33
|
+
return rawArgs.length > 0 ? `${commandBadge} ${rawArgs}` : commandBadge;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Purpose: Renders a failed workflow command card in the conversation.chat.node slot.
|
|
38
|
+
* Contract:
|
|
39
|
+
* - Inputs: WorkflowErrorCardProps containing 'wf-error' chat node.
|
|
40
|
+
* - Outputs: React JSX element rendering error details.
|
|
41
|
+
* - Throws: None.
|
|
42
|
+
*/
|
|
43
|
+
export function WorkflowErrorCard({
|
|
44
|
+
node,
|
|
45
|
+
}: WorkflowErrorCardProps): React.JSX.Element {
|
|
46
|
+
const data = node.data;
|
|
47
|
+
const rawArgs = typeof data.args === "string" ? data.args.trim() : "";
|
|
48
|
+
const errorText = data.text;
|
|
49
|
+
const commandBadge = data.name ? `/${data.name}` : "/wf";
|
|
50
|
+
const rawCommand = resolveErrorCommand(data);
|
|
51
|
+
const [copied, setCopied] = useState(false);
|
|
52
|
+
|
|
53
|
+
const handleCopy = () => {
|
|
54
|
+
navigator.clipboard
|
|
55
|
+
.writeText(rawCommand)
|
|
56
|
+
.then(() => {
|
|
57
|
+
setCopied(true);
|
|
58
|
+
setTimeout(() => setCopied(false), 2000);
|
|
59
|
+
})
|
|
60
|
+
.catch(() => {});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<>
|
|
65
|
+
<WorkflowStyles />
|
|
66
|
+
<div className="dsh-wf-card" data-state="aborted">
|
|
67
|
+
<div className="dsh-wf-header">
|
|
68
|
+
<div className="dsh-wf-title-group">
|
|
69
|
+
<span className="dsh-wf-command-badge">{commandBadge}</span>
|
|
70
|
+
{rawArgs.length > 0 && (
|
|
71
|
+
<span className="dsh-wf-args" title={rawArgs}>
|
|
72
|
+
{rawArgs}
|
|
73
|
+
</span>
|
|
74
|
+
)}
|
|
75
|
+
<button
|
|
76
|
+
type="button"
|
|
77
|
+
className="dsh-wf-copy-btn"
|
|
78
|
+
data-copied={copied ? "true" : "false"}
|
|
79
|
+
onClick={handleCopy}
|
|
80
|
+
title={copied ? "Copied" : "Copy command"}
|
|
81
|
+
aria-label={copied ? "Copied" : "Copy command"}
|
|
82
|
+
>
|
|
83
|
+
{copied ? <CheckIcon /> : <CopyIcon />}
|
|
84
|
+
</button>
|
|
85
|
+
</div>
|
|
86
|
+
<div className="dsh-wf-status">
|
|
87
|
+
<span className="dsh-wf-badge-aborted">✕ Failed</span>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
{errorText && (
|
|
92
|
+
<div className="dsh-wf-body" data-error="true">
|
|
93
|
+
{errorText}
|
|
94
|
+
</div>
|
|
95
|
+
)}
|
|
96
|
+
</div>
|
|
97
|
+
</>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { PropsRenderFactories } from "@deepseek-ai/dsh-client-ui-slots";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
|
|
4
|
+
export interface WorkflowMarkdownProps extends PropsRenderFactories {
|
|
5
|
+
readonly text: string;
|
|
6
|
+
readonly className?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Purpose: Render markdown through DSH's shared Markdown factory.
|
|
11
|
+
* Contract:
|
|
12
|
+
* - Inputs: text string, optional className, and renderFactorySlot.
|
|
13
|
+
* - Outputs: Markdown-rendered block.
|
|
14
|
+
*/
|
|
15
|
+
export function WorkflowMarkdown({
|
|
16
|
+
text,
|
|
17
|
+
className,
|
|
18
|
+
renderFactorySlot,
|
|
19
|
+
}: WorkflowMarkdownProps): React.JSX.Element {
|
|
20
|
+
return (
|
|
21
|
+
<div className={className}>
|
|
22
|
+
{renderFactorySlot("conversation.chat.reasoning.content", {
|
|
23
|
+
text,
|
|
24
|
+
running: false,
|
|
25
|
+
})}
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { CommandRowProps } from "@deepseek-ai/dsh-client-ui-chat/client";
|
|
2
|
+
import type { PropsRenderFactories } from "@deepseek-ai/dsh-client-ui-slots";
|
|
3
|
+
import type React from "react";
|
|
4
|
+
import { CopyIcon } from "./icons.tsx";
|
|
5
|
+
import { WorkflowMarkdown } from "./WorkflowMarkdown.tsx";
|
|
6
|
+
import { WorkflowStyles } from "./WorkflowStyles.tsx";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Purpose: Render workflow command outcomes through DSH's shared Markdown factory.
|
|
10
|
+
* Contract:
|
|
11
|
+
* - Inputs: Command lifecycle fields and the framework's factory renderer.
|
|
12
|
+
* - Outputs: An always-visible result body with a command header and copy action.
|
|
13
|
+
* - Throws: Clipboard failures propagate to the browser.
|
|
14
|
+
*/
|
|
15
|
+
export function WorkflowMarkdownResult({
|
|
16
|
+
node,
|
|
17
|
+
renderFactorySlot,
|
|
18
|
+
}: {
|
|
19
|
+
node: Pick<CommandRowProps["node"], "name" | "args" | "outcome">;
|
|
20
|
+
} & PropsRenderFactories): React.JSX.Element {
|
|
21
|
+
const { outcome } = node;
|
|
22
|
+
const state =
|
|
23
|
+
outcome === null
|
|
24
|
+
? "running"
|
|
25
|
+
: outcome.kind === "error"
|
|
26
|
+
? "aborted"
|
|
27
|
+
: "completed";
|
|
28
|
+
const command = node.name === null ? "" : `/${node.name}`;
|
|
29
|
+
const rawArgs =
|
|
30
|
+
typeof node.args === "string" && node.args.trim().length > 0
|
|
31
|
+
? node.args.startsWith(" ")
|
|
32
|
+
? node.args
|
|
33
|
+
: ` ${node.args}`
|
|
34
|
+
: "";
|
|
35
|
+
const rawCommand = command ? `${command}${rawArgs}` : "";
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
<WorkflowStyles />
|
|
40
|
+
<div className="dsh-wf-card" data-state={state}>
|
|
41
|
+
<div className="dsh-wf-header">
|
|
42
|
+
<div className="dsh-wf-title-group">
|
|
43
|
+
<span className="dsh-wf-command-badge">{command}</span>
|
|
44
|
+
{node.args && (
|
|
45
|
+
<span className="dsh-wf-args" title={node.args}>
|
|
46
|
+
{node.args}
|
|
47
|
+
</span>
|
|
48
|
+
)}
|
|
49
|
+
</div>
|
|
50
|
+
<span
|
|
51
|
+
className={`dsh-wf-badge-${state === "completed" ? "success" : state}`}
|
|
52
|
+
>
|
|
53
|
+
{outcome === null
|
|
54
|
+
? "Running…"
|
|
55
|
+
: outcome.kind === "error"
|
|
56
|
+
? "Failed"
|
|
57
|
+
: "Done"}
|
|
58
|
+
</span>
|
|
59
|
+
<button
|
|
60
|
+
type="button"
|
|
61
|
+
className="dsh-wf-copy-btn"
|
|
62
|
+
title="Copy command"
|
|
63
|
+
aria-label="Copy command"
|
|
64
|
+
onClick={() => navigator.clipboard.writeText(rawCommand)}
|
|
65
|
+
>
|
|
66
|
+
<CopyIcon />
|
|
67
|
+
</button>
|
|
68
|
+
</div>
|
|
69
|
+
{outcome !== null && outcome.text !== undefined && (
|
|
70
|
+
<WorkflowMarkdown
|
|
71
|
+
className="dsh-wf-markdown-body"
|
|
72
|
+
text={
|
|
73
|
+
outcome.kind === "error"
|
|
74
|
+
? outcome.text
|
|
75
|
+
.split("\n")
|
|
76
|
+
.map((line) => ` ${line}`)
|
|
77
|
+
.join("\n")
|
|
78
|
+
: outcome.text
|
|
79
|
+
}
|
|
80
|
+
renderFactorySlot={renderFactorySlot}
|
|
81
|
+
/>
|
|
82
|
+
)}
|
|
83
|
+
</div>
|
|
84
|
+
</>
|
|
85
|
+
);
|
|
86
|
+
}
|