@lukstei/dsh-yaml-workflow 0.0.0-stage → 0.2.2-rc.5.3
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,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PURPOSE: Output row component for wf-print chat nodes in chat feed.
|
|
3
|
+
* ALLOWED: React rendering.
|
|
4
|
+
* FORBIDDEN: State, network, direct DOM manipulation.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { ChatNodeViewProps } from "@deepseek-ai/dsh-client-ui-chat/client";
|
|
8
|
+
import type { PropsRenderFactories } from "@deepseek-ai/dsh-client-ui-slots";
|
|
9
|
+
import type { SessionId } from "@deepseek-ai/dsh-session/types";
|
|
10
|
+
import type React from "react";
|
|
11
|
+
import { WorkflowMarkdown } from "./WorkflowMarkdown.tsx";
|
|
12
|
+
import { WorkflowStyles } from "./WorkflowStyles.tsx";
|
|
13
|
+
|
|
14
|
+
export interface WorkflowPrintChatData {
|
|
15
|
+
readonly text: string;
|
|
16
|
+
readonly runId: string;
|
|
17
|
+
readonly sessionId: SessionId;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type WorkflowPrintStepProps = Pick<
|
|
21
|
+
ChatNodeViewProps<"wf-print">,
|
|
22
|
+
"node"
|
|
23
|
+
> &
|
|
24
|
+
PropsRenderFactories;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Markdown-rendered print output row mounted in conversation.chat.node slot.
|
|
28
|
+
* CONTRACT:
|
|
29
|
+
* - Input: ChatNodeViewProps with node containing WorkflowPrintChatData and factory renderer.
|
|
30
|
+
* - Output: Markdown-rendered text block.
|
|
31
|
+
*/
|
|
32
|
+
export function WorkflowPrintStep({
|
|
33
|
+
node,
|
|
34
|
+
renderFactorySlot,
|
|
35
|
+
}: WorkflowPrintStepProps): React.JSX.Element {
|
|
36
|
+
return (
|
|
37
|
+
<>
|
|
38
|
+
<WorkflowStyles />
|
|
39
|
+
<WorkflowMarkdown
|
|
40
|
+
className="dsh-wf-print-step"
|
|
41
|
+
text={node.data.text}
|
|
42
|
+
renderFactorySlot={renderFactorySlot}
|
|
43
|
+
/>
|
|
44
|
+
</>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PURPOSE: React composer toolbar button for resuming paused or interrupted workflows.
|
|
3
|
+
* ALLOWED: React rendering, event callbacks, context consumption.
|
|
4
|
+
* FORBIDDEN: Direct DOM manipulation, inline store state.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type {} from "@deepseek-ai/dsh-client-ui-conversation/client";
|
|
8
|
+
import type { PropsRuntime } from "@deepseek-ai/dsh-client-ui-slots";
|
|
9
|
+
import type React from "react";
|
|
10
|
+
import type { WorkflowRun } from "../types.ts";
|
|
11
|
+
import {
|
|
12
|
+
resolveResumeCommand,
|
|
13
|
+
sendDiscardCommand,
|
|
14
|
+
sendResumeCommand,
|
|
15
|
+
} from "./actions.ts";
|
|
16
|
+
import { useWorkflowClientContext } from "./context.ts";
|
|
17
|
+
import { DiscardIcon, ResumePlayIcon } from "./icons.tsx";
|
|
18
|
+
import { useWorkflowState } from "./store.ts";
|
|
19
|
+
import { getPausedGateDetails } from "./WorkflowCommandCard.tsx";
|
|
20
|
+
import { WorkflowStyles } from "./WorkflowStyles.tsx";
|
|
21
|
+
|
|
22
|
+
export type WorkflowResumeButtonProps = Pick<
|
|
23
|
+
PropsRuntime<"conversation.input.right">,
|
|
24
|
+
"sessionId" | "useInput" | "inputActions"
|
|
25
|
+
>;
|
|
26
|
+
|
|
27
|
+
export interface ResumeButtonDetails {
|
|
28
|
+
readonly label: string;
|
|
29
|
+
readonly tooltip: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Derives contextual button label and tooltip for the resume button.
|
|
34
|
+
* CONTRACT:
|
|
35
|
+
* - Inputs: WorkflowRun (or undefined), and optional draft string.
|
|
36
|
+
* - Outputs: ResumeButtonDetails with label and tooltip, or undefined if not resumable.
|
|
37
|
+
*/
|
|
38
|
+
export function getResumeButtonDetails(
|
|
39
|
+
run: WorkflowRun | undefined,
|
|
40
|
+
draft = "",
|
|
41
|
+
): ResumeButtonDetails | undefined {
|
|
42
|
+
if (!run) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
const details = getPausedGateDetails(run);
|
|
46
|
+
if (!details) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const { gate, isInterrupted, targetName } = details;
|
|
51
|
+
const hasDraft = draft.trim().length > 0;
|
|
52
|
+
|
|
53
|
+
const label = targetName
|
|
54
|
+
? hasDraft
|
|
55
|
+
? `Resume with feedback: ${targetName}`
|
|
56
|
+
: `Resume: ${targetName}`
|
|
57
|
+
: hasDraft
|
|
58
|
+
? "Resume with feedback (Complete)"
|
|
59
|
+
: "Resume (Complete)";
|
|
60
|
+
|
|
61
|
+
const tooltip = isInterrupted
|
|
62
|
+
? `Resume workflow at current step: ${targetName ?? "Step"}${hasDraft ? ". Feedback will be sent as user instructions." : ""}`
|
|
63
|
+
: `Resume workflow${gate ? ` (Gate: ${gate})` : ""} → Next: ${targetName ?? "Complete"}${hasDraft ? ". Feedback will be sent as user instructions." : ""}`;
|
|
64
|
+
|
|
65
|
+
return { label, tooltip };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Purpose: Resume and discard controls in the session composer toolbar.
|
|
70
|
+
* Contract:
|
|
71
|
+
* - Inputs: Canonical session input props.
|
|
72
|
+
* - Outputs: Toolbar controls while the workflow is paused, otherwise null.
|
|
73
|
+
* - Errors: Reports dispatch failures without consuming unadmitted drafts.
|
|
74
|
+
*/
|
|
75
|
+
export function WorkflowResumeButton({
|
|
76
|
+
sessionId,
|
|
77
|
+
useInput,
|
|
78
|
+
inputActions,
|
|
79
|
+
}: WorkflowResumeButtonProps): React.JSX.Element | null {
|
|
80
|
+
const ctx = useWorkflowClientContext();
|
|
81
|
+
const draft = useInput((state) => state.draft);
|
|
82
|
+
const run = useWorkflowState(sessionId);
|
|
83
|
+
|
|
84
|
+
const details = getResumeButtonDetails(run, draft);
|
|
85
|
+
if (!details) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const handleResume = async () => {
|
|
90
|
+
try {
|
|
91
|
+
const commandToSend = resolveResumeCommand(draft);
|
|
92
|
+
const binding = ctx.sessions.binding(sessionId);
|
|
93
|
+
if (!binding) throw new Error(`Session "${sessionId}" is not active`);
|
|
94
|
+
const draftRev = inputActions.captureInsertion().draftRev;
|
|
95
|
+
const clearDraft = () => {
|
|
96
|
+
if (inputActions.captureInsertion().draftRev === draftRev) {
|
|
97
|
+
inputActions.setDraft("");
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const unsubscribe = binding.eventSource.subscribe(() => {
|
|
101
|
+
const { change } = binding.eventSource.getSnapshot();
|
|
102
|
+
if (change.kind !== "append") return;
|
|
103
|
+
const admitted = change.entries.some(
|
|
104
|
+
({ event }) =>
|
|
105
|
+
event.type === "command/run" &&
|
|
106
|
+
event.data.name === "wf-resume" &&
|
|
107
|
+
event.data.args === commandToSend.slice("/wf-resume".length),
|
|
108
|
+
);
|
|
109
|
+
if (!admitted) return;
|
|
110
|
+
unsubscribe();
|
|
111
|
+
clearDraft();
|
|
112
|
+
});
|
|
113
|
+
try {
|
|
114
|
+
await sendResumeCommand(ctx, sessionId, commandToSend);
|
|
115
|
+
clearDraft();
|
|
116
|
+
} finally {
|
|
117
|
+
unsubscribe();
|
|
118
|
+
}
|
|
119
|
+
} catch (err: unknown) {
|
|
120
|
+
console.error("Failed to resume workflow:", err);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const handleDiscard = async () => {
|
|
125
|
+
try {
|
|
126
|
+
await sendDiscardCommand(ctx, sessionId);
|
|
127
|
+
} catch (err: unknown) {
|
|
128
|
+
console.error("Failed to discard workflow:", err);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<>
|
|
134
|
+
<WorkflowStyles />
|
|
135
|
+
<div className="dsh-wf-toolbar-group">
|
|
136
|
+
<button
|
|
137
|
+
type="button"
|
|
138
|
+
className="dsh-wf-resume-btn"
|
|
139
|
+
onClick={handleResume}
|
|
140
|
+
title={details.tooltip}
|
|
141
|
+
aria-label={details.tooltip}
|
|
142
|
+
>
|
|
143
|
+
<ResumePlayIcon />
|
|
144
|
+
<span className="dsh-wf-resume-btn-label">{details.label}</span>
|
|
145
|
+
</button>
|
|
146
|
+
<button
|
|
147
|
+
type="button"
|
|
148
|
+
className="dsh-wf-discard-btn"
|
|
149
|
+
onClick={handleDiscard}
|
|
150
|
+
title="Discard workflow"
|
|
151
|
+
aria-label="Discard workflow"
|
|
152
|
+
>
|
|
153
|
+
<DiscardIcon />
|
|
154
|
+
<span className="dsh-wf-discard-btn-label">Discard</span>
|
|
155
|
+
</button>
|
|
156
|
+
</div>
|
|
157
|
+
</>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PURPOSE: Progress row component for wf-step chat nodes in chat feed.
|
|
3
|
+
* ALLOWED: React rendering.
|
|
4
|
+
* FORBIDDEN: State, network, direct DOM manipulation.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { ChatNodeViewProps } from "@deepseek-ai/dsh-client-ui-chat/client";
|
|
8
|
+
import type { SessionId } from "@deepseek-ai/dsh-session/types";
|
|
9
|
+
import type React from "react";
|
|
10
|
+
import type { WorkflowRun } from "../types.ts";
|
|
11
|
+
import { CheckIcon } from "./icons.tsx";
|
|
12
|
+
import { useWorkflowRunState } from "./store.ts";
|
|
13
|
+
import { WorkflowStyles } from "./WorkflowStyles.tsx";
|
|
14
|
+
|
|
15
|
+
export interface WorkflowStepChatData {
|
|
16
|
+
readonly stepIndex: number;
|
|
17
|
+
readonly label: string;
|
|
18
|
+
readonly kind: "success" | "error";
|
|
19
|
+
readonly sessionId: SessionId;
|
|
20
|
+
readonly runId: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type StepStatus = "running" | "done" | "paused" | "aborted" | "error";
|
|
24
|
+
|
|
25
|
+
export type WorkflowStepRowProps = Pick<ChatNodeViewProps<"wf-step">, "node">;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Purpose: Derives step execution status from workflow run state and node data.
|
|
29
|
+
* Contract:
|
|
30
|
+
* - Inputs: stepData object containing stepIndex and kind, optional WorkflowRun.
|
|
31
|
+
* - Outputs: StepStatus enum representing current execution lifecycle.
|
|
32
|
+
* - Throws: None.
|
|
33
|
+
*/
|
|
34
|
+
export function deriveStepStatus(
|
|
35
|
+
stepData: WorkflowStepChatData,
|
|
36
|
+
run?: WorkflowRun,
|
|
37
|
+
): StepStatus {
|
|
38
|
+
if (run) {
|
|
39
|
+
const { status, stepIndex: activeStepIndex, error } = run.state;
|
|
40
|
+
if (status === "completed" || stepData.stepIndex < activeStepIndex) {
|
|
41
|
+
return "done";
|
|
42
|
+
}
|
|
43
|
+
if (status === "aborted") {
|
|
44
|
+
return error ? "error" : "aborted";
|
|
45
|
+
}
|
|
46
|
+
if (status === "paused") {
|
|
47
|
+
return "paused";
|
|
48
|
+
}
|
|
49
|
+
if (stepData.kind === "error") {
|
|
50
|
+
return error ? "error" : "aborted";
|
|
51
|
+
}
|
|
52
|
+
return "running";
|
|
53
|
+
}
|
|
54
|
+
if (stepData.kind === "error") {
|
|
55
|
+
return "error";
|
|
56
|
+
}
|
|
57
|
+
return "done";
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Step progress row mounted in conversation.chat.node slot.
|
|
62
|
+
* CONTRACT:
|
|
63
|
+
* - Input: ChatNodeViewProps with node containing WorkflowStepChatData.
|
|
64
|
+
* - Output: formatted row with step status icon, label, and lifecycle badge.
|
|
65
|
+
*/
|
|
66
|
+
export function WorkflowStepRow({
|
|
67
|
+
node,
|
|
68
|
+
}: WorkflowStepRowProps): React.JSX.Element {
|
|
69
|
+
const run = useWorkflowRunState(node.data.runId);
|
|
70
|
+
const status = deriveStepStatus(node.data, run);
|
|
71
|
+
const errorMessage =
|
|
72
|
+
status === "error" && run?.state.error ? run.state.error : undefined;
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<>
|
|
76
|
+
<WorkflowStyles />
|
|
77
|
+
<div className="dsh-wf-step-row" data-kind="step" data-status={status}>
|
|
78
|
+
<span
|
|
79
|
+
className="dsh-wf-step-icon"
|
|
80
|
+
data-status={status}
|
|
81
|
+
aria-hidden="true"
|
|
82
|
+
>
|
|
83
|
+
{status === "running" && <span className="dsh-wf-pulse-dot" />}
|
|
84
|
+
{status === "done" && <CheckIcon />}
|
|
85
|
+
{status === "paused" && "\u275a\u275a"}
|
|
86
|
+
{status === "aborted" && "\u2715"}
|
|
87
|
+
{status === "error" && "\u2715"}
|
|
88
|
+
</span>
|
|
89
|
+
<span className="dsh-wf-step-label">{node.data.label}</span>
|
|
90
|
+
{status === "running" && (
|
|
91
|
+
<span className="dsh-wf-badge-running">Running...</span>
|
|
92
|
+
)}
|
|
93
|
+
{status === "paused" && (
|
|
94
|
+
<span className="dsh-wf-badge-paused">Paused</span>
|
|
95
|
+
)}
|
|
96
|
+
{status === "aborted" && (
|
|
97
|
+
<span className="dsh-wf-badge-aborted">Discarded</span>
|
|
98
|
+
)}
|
|
99
|
+
{status === "error" && (
|
|
100
|
+
<span className="dsh-wf-badge-aborted">✕ Failed</span>
|
|
101
|
+
)}
|
|
102
|
+
</div>
|
|
103
|
+
{errorMessage && <div className="dsh-wf-step-error">{errorMessage}</div>}
|
|
104
|
+
</>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PURPOSE: Pure command formatting and asynchronous Cordis conversation actions.
|
|
3
|
+
* ALLOWED: Command string manipulation, conversation dispatching, store optimism.
|
|
4
|
+
* FORBIDDEN: UI rendering, React state.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { SessionId } from "@deepseek-ai/dsh-session/types";
|
|
8
|
+
import type { WorkflowStatus } from "../types.ts";
|
|
9
|
+
import type { WorkflowClientContext } from "./context.ts";
|
|
10
|
+
import {
|
|
11
|
+
getWorkflowState,
|
|
12
|
+
setWorkflowRunState,
|
|
13
|
+
setWorkflowState,
|
|
14
|
+
} from "./store.ts";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Resolves a draft string into an executable /wf-resume command invocation.
|
|
18
|
+
* CONTRACT:
|
|
19
|
+
* - Input: optional draft string.
|
|
20
|
+
* - Output: formatted command string (defaults to '/wf-resume', or '/wf-resume <draft>').
|
|
21
|
+
*/
|
|
22
|
+
export function resolveResumeCommand(draft?: string): string {
|
|
23
|
+
const trimmedDraft = (draft || "").trim();
|
|
24
|
+
if (trimmedDraft.length === 0) {
|
|
25
|
+
return "/wf-resume";
|
|
26
|
+
}
|
|
27
|
+
if (/^\/wf-resume(\s+.*)?$/.test(trimmedDraft)) {
|
|
28
|
+
return trimmedDraft;
|
|
29
|
+
}
|
|
30
|
+
return `/wf-resume ${trimmedDraft}`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Internal helper to dispatch a workflow slash command with optimistic store update and rollback.
|
|
35
|
+
*/
|
|
36
|
+
async function dispatchWorkflowCommand(
|
|
37
|
+
ctx: WorkflowClientContext,
|
|
38
|
+
sessionId: SessionId,
|
|
39
|
+
command: string,
|
|
40
|
+
optimisticStatus: WorkflowStatus,
|
|
41
|
+
): Promise<void> {
|
|
42
|
+
const current = getWorkflowState(sessionId);
|
|
43
|
+
if (current) {
|
|
44
|
+
setWorkflowState(
|
|
45
|
+
sessionId,
|
|
46
|
+
{
|
|
47
|
+
...current,
|
|
48
|
+
state: {
|
|
49
|
+
...current.state,
|
|
50
|
+
status: optimisticStatus,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
current.invocation.runId,
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
const binding = ctx.sessions.binding(sessionId);
|
|
59
|
+
if (!binding) {
|
|
60
|
+
throw new Error(`Session "${sessionId}" is not active`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const result = await binding.session.command(command);
|
|
64
|
+
if (!result.ok) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
`Command "${command}" failed: ${result.error.code}: ${result.error.message}`,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
if (!result.value.matched) {
|
|
70
|
+
throw new Error(`The host offers no ${command} command`);
|
|
71
|
+
}
|
|
72
|
+
} catch (err: unknown) {
|
|
73
|
+
if (current) {
|
|
74
|
+
const active = getWorkflowState(sessionId);
|
|
75
|
+
if (active && active.invocation.runId === current.invocation.runId) {
|
|
76
|
+
setWorkflowState(sessionId, current, current.invocation.runId);
|
|
77
|
+
} else {
|
|
78
|
+
setWorkflowRunState(current.invocation.runId, current);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
throw err;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Purpose: Dispatches a resume slash command to the host and sets optimistic running state.
|
|
87
|
+
* Contract:
|
|
88
|
+
* - Inputs: Cordis WorkflowClientContext, sessionId, and optional command string.
|
|
89
|
+
* - Outputs: Promise resolving when command is admitted and executed by host.
|
|
90
|
+
* - Throws: Error when session is not active or command execution fails.
|
|
91
|
+
*/
|
|
92
|
+
export async function sendResumeCommand(
|
|
93
|
+
ctx: WorkflowClientContext,
|
|
94
|
+
sessionId: SessionId,
|
|
95
|
+
command = "/wf-resume",
|
|
96
|
+
): Promise<void> {
|
|
97
|
+
await dispatchWorkflowCommand(ctx, sessionId, command, "running");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Purpose: Dispatches an abort slash command to the host and sets optimistic aborted state.
|
|
102
|
+
* Contract:
|
|
103
|
+
* - Inputs: Cordis WorkflowClientContext, sessionId, and optional command string.
|
|
104
|
+
* - Outputs: Promise resolving when command is admitted and executed by host.
|
|
105
|
+
* - Throws: Error when session is not active or command execution fails.
|
|
106
|
+
*/
|
|
107
|
+
export async function sendDiscardCommand(
|
|
108
|
+
ctx: WorkflowClientContext,
|
|
109
|
+
sessionId: SessionId,
|
|
110
|
+
command = "/wf-abort",
|
|
111
|
+
): Promise<void> {
|
|
112
|
+
await dispatchWorkflowCommand(ctx, sessionId, command, "aborted");
|
|
113
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PURPOSE: React Context container and hook for Cordis ClientContext injection.
|
|
3
|
+
* ALLOWED: createContext, useContext.
|
|
4
|
+
* FORBIDDEN: State manipulation, UI rendering.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { Context as CordisContext } from "@deepseek-ai/cordis";
|
|
8
|
+
import type { ISessions } from "@deepseek-ai/dsh-api-session-controller/client";
|
|
9
|
+
import { createContext, useContext } from "react";
|
|
10
|
+
|
|
11
|
+
export type WorkflowClientContext = Omit<CordisContext, "sessions"> & {
|
|
12
|
+
readonly sessions: ISessions;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const WorkflowClientContext =
|
|
16
|
+
createContext<WorkflowClientContext | null>(null);
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Accesses the Cordis ClientContext from the nearest WorkflowClientContext provider.
|
|
20
|
+
* CONTRACT:
|
|
21
|
+
* - Output: WorkflowClientContext.
|
|
22
|
+
* - Throws: Error if accessed outside WorkflowClientContext.Provider.
|
|
23
|
+
*/
|
|
24
|
+
export function useWorkflowClientContext(): WorkflowClientContext {
|
|
25
|
+
const ctx = useContext(WorkflowClientContext);
|
|
26
|
+
if (!ctx) {
|
|
27
|
+
throw new Error("WorkflowClientContext must be provided");
|
|
28
|
+
}
|
|
29
|
+
return ctx;
|
|
30
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { CommandRowProps } from "@deepseek-ai/dsh-client-ui-chat/client";
|
|
2
|
+
import type {} from "@deepseek-ai/dsh-client-ui-conversation/client";
|
|
3
|
+
import type {} from "@deepseek-ai/dsh-client-ui-renderer/client";
|
|
4
|
+
import type { WorkflowRun } from "../types.ts";
|
|
5
|
+
import type { WorkflowErrorChatData } from "./WorkflowErrorCard.tsx";
|
|
6
|
+
import type { WorkflowPrintChatData } from "./WorkflowPrintStep.tsx";
|
|
7
|
+
import type { WorkflowStepChatData } from "./WorkflowStepRow.tsx";
|
|
8
|
+
|
|
9
|
+
declare module "@deepseek-ai/dsh-client-ui-chat/client" {
|
|
10
|
+
interface ChatNodeDataMap {
|
|
11
|
+
"wf-state": WorkflowRun;
|
|
12
|
+
"wf-step": WorkflowStepChatData;
|
|
13
|
+
"wf-print": WorkflowPrintChatData;
|
|
14
|
+
"wf-error": WorkflowErrorChatData;
|
|
15
|
+
"wf-list": Pick<CommandRowProps["node"], "name" | "args" | "outcome">;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type { WorkflowCommandCardProps } from "./WorkflowCommandCard.tsx";
|
|
20
|
+
export type {
|
|
21
|
+
WorkflowErrorCardProps,
|
|
22
|
+
WorkflowErrorChatData,
|
|
23
|
+
} from "./WorkflowErrorCard.tsx";
|
|
24
|
+
export type { WorkflowMarkdownProps } from "./WorkflowMarkdown.tsx";
|
|
25
|
+
export type {
|
|
26
|
+
WorkflowPrintChatData,
|
|
27
|
+
WorkflowPrintStepProps,
|
|
28
|
+
} from "./WorkflowPrintStep.tsx";
|
|
29
|
+
export type { WorkflowResumeButtonProps } from "./WorkflowResumeButton.tsx";
|
|
30
|
+
export type {
|
|
31
|
+
WorkflowStepChatData,
|
|
32
|
+
WorkflowStepRowProps,
|
|
33
|
+
} from "./WorkflowStepRow.tsx";
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PURPOSE: Shared SVG icon primitives for workflow runner UI components.
|
|
3
|
+
* ALLOWED: Pure SVG rendering.
|
|
4
|
+
* FORBIDDEN: State, network, styles.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type React from "react";
|
|
8
|
+
|
|
9
|
+
export function CopyIcon(): React.JSX.Element {
|
|
10
|
+
return (
|
|
11
|
+
<svg
|
|
12
|
+
width="12"
|
|
13
|
+
height="12"
|
|
14
|
+
viewBox="0 0 24 24"
|
|
15
|
+
fill="none"
|
|
16
|
+
stroke="currentColor"
|
|
17
|
+
strokeWidth="2"
|
|
18
|
+
strokeLinecap="round"
|
|
19
|
+
strokeLinejoin="round"
|
|
20
|
+
aria-hidden="true"
|
|
21
|
+
>
|
|
22
|
+
<rect width="14" height="14" x="8" y="8" rx="2" ry="2" />
|
|
23
|
+
<path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />
|
|
24
|
+
</svg>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function CheckIcon(): React.JSX.Element {
|
|
29
|
+
return (
|
|
30
|
+
<svg
|
|
31
|
+
width="12"
|
|
32
|
+
height="12"
|
|
33
|
+
viewBox="0 0 24 24"
|
|
34
|
+
fill="none"
|
|
35
|
+
stroke="currentColor"
|
|
36
|
+
strokeWidth="2"
|
|
37
|
+
strokeLinecap="round"
|
|
38
|
+
strokeLinejoin="round"
|
|
39
|
+
aria-hidden="true"
|
|
40
|
+
>
|
|
41
|
+
<polyline points="20 6 9 17 4 12" />
|
|
42
|
+
</svg>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Purpose: Renders a 12x12 play polygon icon for the workflow resume button.
|
|
48
|
+
* Contract:
|
|
49
|
+
* - Inputs: None.
|
|
50
|
+
* - Outputs: React JSX SVG element.
|
|
51
|
+
* - Throws: None.
|
|
52
|
+
*/
|
|
53
|
+
export function ResumePlayIcon(): React.JSX.Element {
|
|
54
|
+
return (
|
|
55
|
+
<svg
|
|
56
|
+
width="12"
|
|
57
|
+
height="12"
|
|
58
|
+
viewBox="0 0 24 24"
|
|
59
|
+
fill="currentColor"
|
|
60
|
+
aria-hidden="true"
|
|
61
|
+
>
|
|
62
|
+
<polygon points="6 4 20 12 6 20 6 4" />
|
|
63
|
+
</svg>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Purpose: Renders a 12x12 cross icon for the workflow discard button.
|
|
69
|
+
* Contract:
|
|
70
|
+
* - Inputs: None.
|
|
71
|
+
* - Outputs: React JSX SVG element.
|
|
72
|
+
* - Throws: None.
|
|
73
|
+
*/
|
|
74
|
+
export function DiscardIcon(): React.JSX.Element {
|
|
75
|
+
return (
|
|
76
|
+
<svg
|
|
77
|
+
width="12"
|
|
78
|
+
height="12"
|
|
79
|
+
viewBox="0 0 24 24"
|
|
80
|
+
fill="none"
|
|
81
|
+
stroke="currentColor"
|
|
82
|
+
strokeWidth="2"
|
|
83
|
+
strokeLinecap="round"
|
|
84
|
+
strokeLinejoin="round"
|
|
85
|
+
aria-hidden="true"
|
|
86
|
+
>
|
|
87
|
+
<line x1="18" y1="6" x2="6" y2="18" />
|
|
88
|
+
<line x1="6" y1="6" x2="18" y2="18" />
|
|
89
|
+
</svg>
|
|
90
|
+
);
|
|
91
|
+
}
|