@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
package/dist/client.js
ADDED
|
@@ -0,0 +1,1746 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "@lukstei/dsh-yaml-workflow",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
let react = require("react");
|
|
8
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
+
`
|
|
10
|
+
# YAML Workflow Skill
|
|
11
|
+
|
|
12
|
+
Author, validate, and execute multi-step prompt workflows defined in YAML files.
|
|
13
|
+
Workflows provide sequential agent orchestration, typed argument interpolation, human review gates, zero-token status printing, and delegated subagent execution.
|
|
14
|
+
|
|
15
|
+
## Commands
|
|
16
|
+
|
|
17
|
+
- \`/wf <workflow.yaml> [key=value ...] [instructions]\`: Execute a workflow.
|
|
18
|
+
- \`/wf-resume [instructions]\`: Resume an interrupted workflow or continue from a human review gate.
|
|
19
|
+
- \`/wf-abort\`: Discard an active or paused workflow.
|
|
20
|
+
- \`/wf-list\`: Discover and list workflows in project (\`.agents/wf\`) and user (\`~/.agents/wf\`) directories.
|
|
21
|
+
- \`/wf-validate <workflow.yaml> [key=value ...]\`: Validate syntax and argument coverage without running.
|
|
22
|
+
|
|
23
|
+
## Agent Tools
|
|
24
|
+
|
|
25
|
+
- \`wf_validate\`: Validate a workflow file programmatically without executing it:
|
|
26
|
+
\`\`\`json
|
|
27
|
+
{ "target": "deploy.yaml", "args": "env=production version=1.0.0" }
|
|
28
|
+
\`\`\`
|
|
29
|
+
- \`save_output\`: Save a declared output value during a workflow prompt step:
|
|
30
|
+
- For string output: \`{ "name": "tag", "value": "v1.2.0" }\`
|
|
31
|
+
- For list output: \`{ "name": "items", "value": "[\\"item1\\", \\"item2\\"]" }\`
|
|
32
|
+
|
|
33
|
+
## Workflow File Schema
|
|
34
|
+
|
|
35
|
+
\`\`\`yaml
|
|
36
|
+
name: "Deploy Service"
|
|
37
|
+
description: "Build and deploy service to target environment"
|
|
38
|
+
args:
|
|
39
|
+
env:
|
|
40
|
+
type: string
|
|
41
|
+
description: "Target environment (staging | production)"
|
|
42
|
+
required: true
|
|
43
|
+
dryRun:
|
|
44
|
+
type: bool
|
|
45
|
+
default: false
|
|
46
|
+
steps:
|
|
47
|
+
- kind: prompt
|
|
48
|
+
name: "Prepare"
|
|
49
|
+
prompt: "Prepare deployment artifacts for {{args.env}}."
|
|
50
|
+
outputs:
|
|
51
|
+
release_tag:
|
|
52
|
+
type: string
|
|
53
|
+
description: "Computed release tag"
|
|
54
|
+
|
|
55
|
+
- kind: print
|
|
56
|
+
name: "Status"
|
|
57
|
+
text: "Artifact ready: {{outputs.release_tag}}"
|
|
58
|
+
|
|
59
|
+
- name: "Approval"
|
|
60
|
+
gate: "Approve deployment to {{args.env}} with tag {{outputs.release_tag}}?"
|
|
61
|
+
|
|
62
|
+
- kind: prompt
|
|
63
|
+
name: "Deploy"
|
|
64
|
+
prompt: "Execute deployment for {{outputs.release_tag}}."
|
|
65
|
+
\`\`\`
|
|
66
|
+
|
|
67
|
+
## Best Practices
|
|
68
|
+
|
|
69
|
+
1. **Always Validate First**: Before running or scheduling a workflow, test it with the \`wf_validate\` tool to catch schema errors, missing arguments, or invalid template references.
|
|
70
|
+
2. **Output Recording**: Prompt steps with declared outputs require calling \`save_output\` for each output before completing the turn.
|
|
71
|
+
`.trim();
|
|
72
|
+
// src/fold.ts
|
|
73
|
+
const WORKFLOW_EVENT_NAME = "wf-event";
|
|
74
|
+
function isValidInitPayload(payload) {
|
|
75
|
+
return payload.action === "init" && Boolean(payload.workflow && payload.invocation && payload.invocation.runId === payload.runId);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Purpose: Pure fold over session command/run events to derive the latest workflow run.
|
|
79
|
+
* Contract:
|
|
80
|
+
* - Inputs: events array in chronological log order, optional targetRunId string.
|
|
81
|
+
* - Outputs: latest WorkflowRun if a workflow was initiated, or null.
|
|
82
|
+
* - Throws: None.
|
|
83
|
+
*/
|
|
84
|
+
function foldWorkflowState(events, targetRunId) {
|
|
85
|
+
let current = null;
|
|
86
|
+
for (const { type, data } of events) {
|
|
87
|
+
if (type !== "command/run") continue;
|
|
88
|
+
if (!data || typeof data !== "object") continue;
|
|
89
|
+
const cmd = data;
|
|
90
|
+
if (cmd.name !== "wf-event" || typeof cmd.args !== "string") continue;
|
|
91
|
+
try {
|
|
92
|
+
const payload = JSON.parse(cmd.args);
|
|
93
|
+
if (!payload.runId) continue;
|
|
94
|
+
if (targetRunId && payload.runId !== targetRunId) continue;
|
|
95
|
+
if (isValidInitPayload(payload)) current = {
|
|
96
|
+
workflow: payload.workflow,
|
|
97
|
+
invocation: payload.invocation,
|
|
98
|
+
state: {
|
|
99
|
+
stepIndex: 0,
|
|
100
|
+
status: "running"
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
else if (payload.action === "state" && current && payload.runId === current.invocation.runId) {
|
|
104
|
+
const { action: _, sessionId: _sessionId, runId: _runId, ...delta } = payload;
|
|
105
|
+
const nextState = {
|
|
106
|
+
...current.state,
|
|
107
|
+
...delta
|
|
108
|
+
};
|
|
109
|
+
if (delta.status !== void 0 && delta.status !== "aborted") delete nextState.error;
|
|
110
|
+
current = {
|
|
111
|
+
workflow: current.workflow,
|
|
112
|
+
invocation: current.invocation,
|
|
113
|
+
state: nextState
|
|
114
|
+
};
|
|
115
|
+
} else if (payload.action === "output" && current && payload.runId === current.invocation.runId) {
|
|
116
|
+
const outputValue = payload.outputType === "list" ? JSON.parse(payload.value) : payload.value;
|
|
117
|
+
const nextOutputs = {
|
|
118
|
+
...current.state.outputs ?? {},
|
|
119
|
+
[payload.name]: outputValue
|
|
120
|
+
};
|
|
121
|
+
const nextState = {
|
|
122
|
+
...current.state,
|
|
123
|
+
outputs: nextOutputs
|
|
124
|
+
};
|
|
125
|
+
current = {
|
|
126
|
+
workflow: current.workflow,
|
|
127
|
+
invocation: current.invocation,
|
|
128
|
+
state: nextState
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
} catch {}
|
|
132
|
+
}
|
|
133
|
+
return current;
|
|
134
|
+
}
|
|
135
|
+
// src/client/context.ts
|
|
136
|
+
const WorkflowClientContext = (0, react.createContext)(null);
|
|
137
|
+
/**
|
|
138
|
+
* Accesses the Cordis ClientContext from the nearest WorkflowClientContext provider.
|
|
139
|
+
* CONTRACT:
|
|
140
|
+
* - Output: WorkflowClientContext.
|
|
141
|
+
* - Throws: Error if accessed outside WorkflowClientContext.Provider.
|
|
142
|
+
*/
|
|
143
|
+
function useWorkflowClientContext() {
|
|
144
|
+
const ctx = (0, react.useContext)(WorkflowClientContext);
|
|
145
|
+
if (!ctx) throw new Error("WorkflowClientContext must be provided");
|
|
146
|
+
return ctx;
|
|
147
|
+
}
|
|
148
|
+
// ../../node_modules/.pnpm/@deepseek-ai+dsh-brand@0.2.2-rc.5_@deepseek-ai+cordis@4.1.0/node_modules/@deepseek-ai/dsh-brand/lib/index.js
|
|
149
|
+
/**
|
|
150
|
+
* Duplicate-install-safe nominal primitive helpers.
|
|
151
|
+
*
|
|
152
|
+
* A brand makes structurally identical strings or numbers non-interchangeable
|
|
153
|
+
* at the type level: a `SessionId` cannot be passed where a `ToolCallId` is
|
|
154
|
+
* expected, and an event sequence cannot be passed as a log offset. Comparison,
|
|
155
|
+
* logging, and serialization retain the underlying primitive behavior.
|
|
156
|
+
*
|
|
157
|
+
* This package owns no concrete domain value and keeps no runtime identity or mutable
|
|
158
|
+
* state, so independently installed copies produce interchangeable values.
|
|
159
|
+
*
|
|
160
|
+
* @module @deepseek-ai/dsh-brand
|
|
161
|
+
*/
|
|
162
|
+
/**
|
|
163
|
+
* Apply a compile-time string brand without changing the value.
|
|
164
|
+
* @param value - string admitted by the domain that owns the target brand.
|
|
165
|
+
* @returns the same string with the requested compile-time brand.
|
|
166
|
+
*/
|
|
167
|
+
function brandString(value) {
|
|
168
|
+
return value;
|
|
169
|
+
}
|
|
170
|
+
// ../../node_modules/.pnpm/@deepseek-ai+dsh-session@0.2.2-rc.5_@deepseek-ai+cordis@4.1.0_@deepseek-ai+dsh-error@0._93b5b71f35bf79ee6eda07b634b3ef9f/node_modules/@deepseek-ai/dsh-session/lib/types/types.js
|
|
171
|
+
/**
|
|
172
|
+
* Brand a string as a {@link SessionId}.
|
|
173
|
+
* @param id - the raw session id string.
|
|
174
|
+
* @returns the same string with the session-id brand.
|
|
175
|
+
*/
|
|
176
|
+
function SessionId(id) {
|
|
177
|
+
return brandString(id);
|
|
178
|
+
}
|
|
179
|
+
// src/client/store.ts
|
|
180
|
+
const workflowRuns = /* @__PURE__ */ new Map();
|
|
181
|
+
const activeSessionRuns = /* @__PURE__ */ new Map();
|
|
182
|
+
const activeSessionSeq = /* @__PURE__ */ new Map();
|
|
183
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
184
|
+
/**
|
|
185
|
+
* Purpose: Retrieves the cached workflow run for a given run ID.
|
|
186
|
+
* Contract:
|
|
187
|
+
* - Inputs: runId string.
|
|
188
|
+
* - Outputs: WorkflowRun if present in store, or undefined.
|
|
189
|
+
* - Throws: None.
|
|
190
|
+
*/
|
|
191
|
+
function getWorkflowRunState(runId) {
|
|
192
|
+
return workflowRuns.get(runId);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Purpose: Retrieves the cached active workflow run for a given session.
|
|
196
|
+
* Contract:
|
|
197
|
+
* - Inputs: non-null sessionId of type SessionId.
|
|
198
|
+
* - Outputs: WorkflowRun if present in store, or undefined.
|
|
199
|
+
* - Throws: None.
|
|
200
|
+
*/
|
|
201
|
+
function getWorkflowState(sessionId) {
|
|
202
|
+
const activeRunId = activeSessionRuns.get(sessionId);
|
|
203
|
+
if (activeRunId) return workflowRuns.get(activeRunId);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Purpose: Updates or sets workflow run for a session and runId, notifying subscribers.
|
|
207
|
+
* Contract:
|
|
208
|
+
* - Inputs: non-null sessionId of type SessionId, WorkflowRun object, runId string, optional seq.
|
|
209
|
+
* - Outputs: void.
|
|
210
|
+
* - Throws: None.
|
|
211
|
+
*/
|
|
212
|
+
function setWorkflowState(sessionId, run, runId, seq) {
|
|
213
|
+
workflowRuns.set(runId, run);
|
|
214
|
+
const lastSeq = activeSessionSeq.get(sessionId);
|
|
215
|
+
if (seq === void 0 || lastSeq === void 0 || seq >= lastSeq) {
|
|
216
|
+
activeSessionRuns.set(sessionId, runId);
|
|
217
|
+
if (seq !== void 0) activeSessionSeq.set(sessionId, seq);
|
|
218
|
+
}
|
|
219
|
+
for (const listener of listeners) listener();
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Purpose: Updates or sets cached workflow run without modifying active session run, notifying subscribers.
|
|
223
|
+
* Contract:
|
|
224
|
+
* - Inputs: runId string, WorkflowRun object.
|
|
225
|
+
* - Outputs: void.
|
|
226
|
+
* - Throws: None.
|
|
227
|
+
*/
|
|
228
|
+
function setWorkflowRunState(runId, run) {
|
|
229
|
+
workflowRuns.set(runId, run);
|
|
230
|
+
for (const listener of listeners) listener();
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Purpose: Subscribes a listener callback to workflow store modifications.
|
|
234
|
+
* Contract:
|
|
235
|
+
* - Inputs: listener callback function.
|
|
236
|
+
* - Outputs: Cleanup unregister function.
|
|
237
|
+
* - Throws: None.
|
|
238
|
+
*/
|
|
239
|
+
function subscribeWorkflowState(listener) {
|
|
240
|
+
listeners.add(listener);
|
|
241
|
+
return () => {
|
|
242
|
+
listeners.delete(listener);
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Purpose: React hook subscribing to reactive workflow run for a specific run ID.
|
|
247
|
+
* Contract:
|
|
248
|
+
* - Inputs: runId string.
|
|
249
|
+
* - Outputs: WorkflowRun or undefined.
|
|
250
|
+
* - Throws: None.
|
|
251
|
+
*/
|
|
252
|
+
function useWorkflowRunState(runId) {
|
|
253
|
+
return (0, react.useSyncExternalStore)(subscribeWorkflowState, () => getWorkflowRunState(runId), () => getWorkflowRunState(runId));
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Purpose: React hook subscribing to reactive workflow run for a given session.
|
|
257
|
+
* Contract:
|
|
258
|
+
* - Inputs: non-null sessionId of type SessionId.
|
|
259
|
+
* - Outputs: WorkflowRun or undefined.
|
|
260
|
+
* - Throws: None.
|
|
261
|
+
*/
|
|
262
|
+
function useWorkflowState(sessionId) {
|
|
263
|
+
return (0, react.useSyncExternalStore)(subscribeWorkflowState, () => getWorkflowState(sessionId), () => getWorkflowState(sessionId));
|
|
264
|
+
}
|
|
265
|
+
const workflowStateDefinition = {
|
|
266
|
+
kind: "wf-state",
|
|
267
|
+
target: "chat",
|
|
268
|
+
match(event) {
|
|
269
|
+
if (event.type === "command/run") {
|
|
270
|
+
const data = event.data;
|
|
271
|
+
if (data?.name === "wf-event" && typeof data.args === "string") try {
|
|
272
|
+
const payload = JSON.parse(data.args);
|
|
273
|
+
if (payload.action === "init" && typeof payload.runId === "string") return {
|
|
274
|
+
id: payload.runId,
|
|
275
|
+
role: "start"
|
|
276
|
+
};
|
|
277
|
+
if ((payload.action === "state" || payload.action === "output") && typeof payload.runId === "string") return {
|
|
278
|
+
id: payload.runId,
|
|
279
|
+
role: "update"
|
|
280
|
+
};
|
|
281
|
+
} catch {
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return null;
|
|
286
|
+
},
|
|
287
|
+
start(context, match) {
|
|
288
|
+
const run = foldWorkflowState([match.event], context.id);
|
|
289
|
+
if (!run) throw new Error(`Failed to fold workflow state for event ${match.event.seq}`);
|
|
290
|
+
const data = match.event.data;
|
|
291
|
+
setWorkflowState(JSON.parse(data.args).sessionId, run, context.id, match.event.seq);
|
|
292
|
+
return run;
|
|
293
|
+
},
|
|
294
|
+
update(context, match) {
|
|
295
|
+
const run = foldWorkflowState(context.matches.map((m) => m.event), context.id);
|
|
296
|
+
if (run) {
|
|
297
|
+
const data = match.event.data;
|
|
298
|
+
setWorkflowState(JSON.parse(data.args).sessionId, run, context.id, match.event.seq);
|
|
299
|
+
return run;
|
|
300
|
+
}
|
|
301
|
+
return context.state;
|
|
302
|
+
},
|
|
303
|
+
buildViewNode(context) {
|
|
304
|
+
if (!context.state) return null;
|
|
305
|
+
const startMatch = context.start;
|
|
306
|
+
return {
|
|
307
|
+
key: context.key,
|
|
308
|
+
kind: "wf-state",
|
|
309
|
+
id: context.id,
|
|
310
|
+
target: "chat",
|
|
311
|
+
anchorSeq: startMatch ? startMatch.event.seq : 0,
|
|
312
|
+
location: startMatch ? startMatch.location : { kind: "unresolved" },
|
|
313
|
+
visibility: "visible",
|
|
314
|
+
groupTree: "process",
|
|
315
|
+
data: context.state
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
const workflowStepDefinition = {
|
|
320
|
+
kind: "wf-step",
|
|
321
|
+
target: "chat",
|
|
322
|
+
match(event) {
|
|
323
|
+
if (event.type === "command/run") {
|
|
324
|
+
const data = event.data;
|
|
325
|
+
if (data?.name === "wf-event" && typeof data.args === "string") try {
|
|
326
|
+
const payload = JSON.parse(data.args);
|
|
327
|
+
if (payload.action === "step" && typeof payload.runId === "string") return {
|
|
328
|
+
id: payload.id,
|
|
329
|
+
role: "start"
|
|
330
|
+
};
|
|
331
|
+
} catch {
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return null;
|
|
336
|
+
},
|
|
337
|
+
start(_context, match) {
|
|
338
|
+
const data = match.event.data;
|
|
339
|
+
const payload = JSON.parse(data.args);
|
|
340
|
+
return {
|
|
341
|
+
stepIndex: payload.stepIndex,
|
|
342
|
+
label: payload.label,
|
|
343
|
+
kind: payload.kind,
|
|
344
|
+
sessionId: payload.sessionId,
|
|
345
|
+
runId: payload.runId
|
|
346
|
+
};
|
|
347
|
+
},
|
|
348
|
+
update(context, match) {
|
|
349
|
+
const data = match.event.data;
|
|
350
|
+
if (data?.args && typeof data.args === "string") try {
|
|
351
|
+
const payload = JSON.parse(data.args);
|
|
352
|
+
return {
|
|
353
|
+
stepIndex: payload.stepIndex,
|
|
354
|
+
label: payload.label,
|
|
355
|
+
kind: payload.kind,
|
|
356
|
+
sessionId: payload.sessionId,
|
|
357
|
+
runId: payload.runId
|
|
358
|
+
};
|
|
359
|
+
} catch {}
|
|
360
|
+
return context.state;
|
|
361
|
+
},
|
|
362
|
+
buildViewNode(context) {
|
|
363
|
+
if (context.state === void 0) return null;
|
|
364
|
+
const startMatch = context.start;
|
|
365
|
+
return {
|
|
366
|
+
key: context.key,
|
|
367
|
+
kind: "wf-step",
|
|
368
|
+
id: context.id,
|
|
369
|
+
target: "chat",
|
|
370
|
+
anchorSeq: startMatch ? startMatch.event.seq : 0,
|
|
371
|
+
location: startMatch ? startMatch.location : { kind: "unresolved" },
|
|
372
|
+
visibility: "visible",
|
|
373
|
+
groupTree: "process",
|
|
374
|
+
data: context.state
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
const workflowPrintDefinition = {
|
|
379
|
+
kind: "wf-print",
|
|
380
|
+
target: "chat",
|
|
381
|
+
match(event) {
|
|
382
|
+
if (event.type === "command/run") {
|
|
383
|
+
const data = event.data;
|
|
384
|
+
if (data?.name === "wf-event" && typeof data.args === "string") try {
|
|
385
|
+
const payload = JSON.parse(data.args);
|
|
386
|
+
if (payload.action === "print" && typeof payload.runId === "string") return {
|
|
387
|
+
id: payload.id,
|
|
388
|
+
role: "start"
|
|
389
|
+
};
|
|
390
|
+
} catch {
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return null;
|
|
395
|
+
},
|
|
396
|
+
start(_context, match) {
|
|
397
|
+
const data = match.event.data;
|
|
398
|
+
const payload = JSON.parse(data.args);
|
|
399
|
+
return {
|
|
400
|
+
id: payload.id,
|
|
401
|
+
text: payload.text,
|
|
402
|
+
runId: payload.runId,
|
|
403
|
+
sessionId: payload.sessionId
|
|
404
|
+
};
|
|
405
|
+
},
|
|
406
|
+
update(context) {
|
|
407
|
+
return context.state;
|
|
408
|
+
},
|
|
409
|
+
buildViewNode(context) {
|
|
410
|
+
if (context.state === void 0) return null;
|
|
411
|
+
const startMatch = context.start;
|
|
412
|
+
return {
|
|
413
|
+
key: context.key,
|
|
414
|
+
kind: "wf-print",
|
|
415
|
+
id: context.id,
|
|
416
|
+
target: "chat",
|
|
417
|
+
anchorSeq: startMatch ? startMatch.event.seq : 0,
|
|
418
|
+
location: startMatch ? startMatch.location : { kind: "unresolved" },
|
|
419
|
+
visibility: "visible",
|
|
420
|
+
groupTree: "process",
|
|
421
|
+
data: context.state
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
const trackedWfCommandIds = /* @__PURE__ */ new Set();
|
|
426
|
+
const workflowErrorDefinition = {
|
|
427
|
+
kind: "wf-error",
|
|
428
|
+
target: "chat",
|
|
429
|
+
match(event) {
|
|
430
|
+
if (event.type === "command/run") {
|
|
431
|
+
const data = event.data;
|
|
432
|
+
if ((data?.name === "wf" || data?.name === "wf-resume" || data?.name === "wf-abort") && data.commandId) {
|
|
433
|
+
const id = String(data.commandId);
|
|
434
|
+
trackedWfCommandIds.add(id);
|
|
435
|
+
return {
|
|
436
|
+
id,
|
|
437
|
+
role: "start"
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
if (event.type === "command/done") {
|
|
442
|
+
const data = event.data;
|
|
443
|
+
if (data?.commandId && trackedWfCommandIds.has(String(data.commandId))) {
|
|
444
|
+
const id = String(data.commandId);
|
|
445
|
+
trackedWfCommandIds.delete(id);
|
|
446
|
+
return {
|
|
447
|
+
id,
|
|
448
|
+
role: "update"
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
return null;
|
|
453
|
+
},
|
|
454
|
+
start(_context, match) {
|
|
455
|
+
const data = match.event.data;
|
|
456
|
+
return {
|
|
457
|
+
commandId: String(data.commandId),
|
|
458
|
+
name: data.name,
|
|
459
|
+
args: data.args,
|
|
460
|
+
outcome: null
|
|
461
|
+
};
|
|
462
|
+
},
|
|
463
|
+
update(context, match) {
|
|
464
|
+
const data = match.event.data;
|
|
465
|
+
return {
|
|
466
|
+
...context.state,
|
|
467
|
+
outcome: {
|
|
468
|
+
kind: data.kind,
|
|
469
|
+
text: data.text
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
},
|
|
473
|
+
buildViewNode(context) {
|
|
474
|
+
if (context.state?.outcome?.kind !== "error") return null;
|
|
475
|
+
const startMatch = context.start;
|
|
476
|
+
return {
|
|
477
|
+
key: context.key,
|
|
478
|
+
kind: "wf-error",
|
|
479
|
+
id: context.id,
|
|
480
|
+
target: "chat",
|
|
481
|
+
anchorSeq: startMatch ? startMatch.event.seq : 0,
|
|
482
|
+
location: startMatch ? startMatch.location : { kind: "unresolved" },
|
|
483
|
+
visibility: "visible",
|
|
484
|
+
groupTree: "process",
|
|
485
|
+
data: {
|
|
486
|
+
name: context.state.name,
|
|
487
|
+
args: context.state.args,
|
|
488
|
+
text: context.state.outcome.text ?? "Command failed"
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
function workflowRequestEvent(event) {
|
|
494
|
+
if (event.type === "command/done" && event.data.kind === "error") return {
|
|
495
|
+
kind: "settled",
|
|
496
|
+
runId: event.data.commandId
|
|
497
|
+
};
|
|
498
|
+
if (event.type !== "command/run" || event.data.name !== "wf-event" || event.data.args === void 0) return void 0;
|
|
499
|
+
let payload;
|
|
500
|
+
try {
|
|
501
|
+
payload = JSON.parse(event.data.args);
|
|
502
|
+
} catch {
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
if (typeof payload !== "object" || payload === null || !("action" in payload) || !("runId" in payload) || typeof payload.runId !== "string") return void 0;
|
|
506
|
+
if (payload.action === "init" || payload.action === "request-failed") return {
|
|
507
|
+
kind: "settled",
|
|
508
|
+
runId: payload.runId
|
|
509
|
+
};
|
|
510
|
+
if (payload.action !== "request" || !("rawInput" in payload) || typeof payload.rawInput !== "string" || !("sessionId" in payload) || typeof payload.sessionId !== "string") return void 0;
|
|
511
|
+
return {
|
|
512
|
+
kind: "request",
|
|
513
|
+
runId: payload.runId,
|
|
514
|
+
rawInput: payload.rawInput,
|
|
515
|
+
sessionId: SessionId(payload.sessionId)
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
const workflowRequestDefinition = {
|
|
519
|
+
kind: "wf-request",
|
|
520
|
+
target: "chat",
|
|
521
|
+
match(event) {
|
|
522
|
+
const request = workflowRequestEvent(event);
|
|
523
|
+
if (request === void 0) return null;
|
|
524
|
+
return {
|
|
525
|
+
id: request.runId,
|
|
526
|
+
role: request.kind === "request" ? "start" : "update"
|
|
527
|
+
};
|
|
528
|
+
},
|
|
529
|
+
start(_context, { event }) {
|
|
530
|
+
const request = workflowRequestEvent(event);
|
|
531
|
+
if (request === void 0 || request.kind !== "request") throw new Error("wf-request requires a request event to start");
|
|
532
|
+
return {
|
|
533
|
+
status: "queued",
|
|
534
|
+
output: {
|
|
535
|
+
text: `Workflow queued:\n\n /wf ${request.rawInput.trim().replaceAll("\n", "\n ")}`,
|
|
536
|
+
runId: request.runId,
|
|
537
|
+
sessionId: request.sessionId
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
},
|
|
541
|
+
update(context, match) {
|
|
542
|
+
return match.role === "start" ? context.state : {
|
|
543
|
+
...context.state,
|
|
544
|
+
status: "settled"
|
|
545
|
+
};
|
|
546
|
+
},
|
|
547
|
+
buildViewNode(context) {
|
|
548
|
+
if (context.state === void 0) return null;
|
|
549
|
+
const first = context.matches[0];
|
|
550
|
+
return {
|
|
551
|
+
key: context.key,
|
|
552
|
+
kind: "wf-print",
|
|
553
|
+
id: context.id,
|
|
554
|
+
target: "chat",
|
|
555
|
+
anchorSeq: first.event.seq,
|
|
556
|
+
location: first.location,
|
|
557
|
+
visibility: context.state.status === "queued" ? "visible" : "hidden",
|
|
558
|
+
groupTree: "process",
|
|
559
|
+
data: context.state.output
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
const workflowListDefinition = {
|
|
564
|
+
kind: "wf-list",
|
|
565
|
+
target: "chat",
|
|
566
|
+
match(event) {
|
|
567
|
+
if (event.type === "command/run" && event.data.name === "wf-list") return {
|
|
568
|
+
id: event.data.commandId,
|
|
569
|
+
role: "start"
|
|
570
|
+
};
|
|
571
|
+
if (event.type === "command/done") return {
|
|
572
|
+
id: event.data.commandId,
|
|
573
|
+
role: "update"
|
|
574
|
+
};
|
|
575
|
+
return null;
|
|
576
|
+
},
|
|
577
|
+
start(_context, { event }) {
|
|
578
|
+
if (event.type !== "command/run") throw new Error("wf-list requires command/run to start");
|
|
579
|
+
return {
|
|
580
|
+
name: event.data.name,
|
|
581
|
+
args: event.data.args === void 0 ? null : event.data.args,
|
|
582
|
+
outcome: null
|
|
583
|
+
};
|
|
584
|
+
},
|
|
585
|
+
update(context, { event }) {
|
|
586
|
+
if (event.type !== "command/done") return context.state;
|
|
587
|
+
return {
|
|
588
|
+
...context.state,
|
|
589
|
+
outcome: {
|
|
590
|
+
kind: event.data.kind,
|
|
591
|
+
text: event.data.text
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
},
|
|
595
|
+
buildViewNode(context) {
|
|
596
|
+
if (context.state === void 0) return null;
|
|
597
|
+
const first = context.matches[0];
|
|
598
|
+
return {
|
|
599
|
+
key: context.key,
|
|
600
|
+
kind: "wf-list",
|
|
601
|
+
id: context.id,
|
|
602
|
+
target: "chat",
|
|
603
|
+
anchorSeq: first.event.seq,
|
|
604
|
+
location: first.location,
|
|
605
|
+
visibility: "visible",
|
|
606
|
+
groupTree: "process",
|
|
607
|
+
data: context.state
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
/**
|
|
612
|
+
* Purpose: Registers workflow request, state, step, print, error, and list conversation nodes on Cordis uiConversation service.
|
|
613
|
+
* Contract:
|
|
614
|
+
* - Inputs: ClientContext with uiConversation service.
|
|
615
|
+
* - Outputs: Cleanup unregister function.
|
|
616
|
+
* - Throws: None.
|
|
617
|
+
*/
|
|
618
|
+
function registerWorkflowChatNodes(ctx) {
|
|
619
|
+
const unregisterRequest = ctx.uiConversation.events.register(workflowRequestDefinition);
|
|
620
|
+
const unregisterState = ctx.uiConversation.events.register(workflowStateDefinition);
|
|
621
|
+
const unregisterStep = ctx.uiConversation.events.register(workflowStepDefinition);
|
|
622
|
+
const unregisterPrint = ctx.uiConversation.events.register(workflowPrintDefinition);
|
|
623
|
+
const unregisterError = ctx.uiConversation.events.register(workflowErrorDefinition);
|
|
624
|
+
const unregisterList = ctx.uiConversation.events.register(workflowListDefinition);
|
|
625
|
+
return () => {
|
|
626
|
+
unregisterRequest();
|
|
627
|
+
unregisterState();
|
|
628
|
+
unregisterStep();
|
|
629
|
+
unregisterPrint();
|
|
630
|
+
unregisterError();
|
|
631
|
+
unregisterList();
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
// src/boolean.ts
|
|
635
|
+
/**
|
|
636
|
+
* PURPOSE: Pure boolean parsing, template interpolation, and gate resolution helper functions.
|
|
637
|
+
* ALLOWED: Pure computation, string parsing, template interpolation.
|
|
638
|
+
* FORBIDDEN: No I/O, no framework dependencies, no side effects.
|
|
639
|
+
*/
|
|
640
|
+
/**
|
|
641
|
+
* Converts a boolean, string, or unknown value into a strict boolean (true/false) or undefined if not a boolean representation.
|
|
642
|
+
* CONTRACT:
|
|
643
|
+
* - Input: unknown value (boolean, string, undefined, null, etc.).
|
|
644
|
+
* - Output: boolean true for true / "true" (case-insensitive), false for false / "false" (case-insensitive), undefined otherwise.
|
|
645
|
+
*/
|
|
646
|
+
function parseBoolean(value) {
|
|
647
|
+
if (typeof value === "boolean") return value;
|
|
648
|
+
if (typeof value === "string") {
|
|
649
|
+
const trimmed = value.trim().toLowerCase();
|
|
650
|
+
if (trimmed === "true") return true;
|
|
651
|
+
if (trimmed === "false") return false;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Interpolates {{args.<name>}} and {{outputs.<name>}} template variables in a text string.
|
|
656
|
+
* CONTRACT:
|
|
657
|
+
* - Input: raw template string, args map, and optional outputs map.
|
|
658
|
+
* - Output: string with all {{args.*}} and {{outputs.*}} variables replaced.
|
|
659
|
+
* - Throws: Error if an {{args.*}} variable is unresolvable.
|
|
660
|
+
*/
|
|
661
|
+
function interpolateTemplate(template, args, outputs, context) {
|
|
662
|
+
let result = template.replace(/\{\{args\.([a-zA-Z0-9_-]+)\}\}/g, (_match, key) => {
|
|
663
|
+
const value = args[key];
|
|
664
|
+
if (value === void 0) throw new Error(`Unresolved workflow argument: {{args.${key}}}`);
|
|
665
|
+
return value;
|
|
666
|
+
});
|
|
667
|
+
if (context?.item !== void 0) result = result.replace(/\{\{item\}\}/g, context.item);
|
|
668
|
+
if (outputs !== void 0) result = result.replace(/\{\{outputs\.([a-zA-Z0-9_-]+)\}\}/g, (_match, key) => {
|
|
669
|
+
const val = outputs[key];
|
|
670
|
+
if (val === void 0) return String(val);
|
|
671
|
+
if (Array.isArray(val)) {
|
|
672
|
+
if (val.length === 0) return "";
|
|
673
|
+
return val.map((item) => `- ${item}`).join("\n");
|
|
674
|
+
}
|
|
675
|
+
return String(val);
|
|
676
|
+
});
|
|
677
|
+
return result;
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* Resolves a step gate declaration (boolean, templated string, or explicit description) into an active gate criteria string, or undefined if inactive.
|
|
681
|
+
* CONTRACT:
|
|
682
|
+
* - Input: gate (string | boolean | undefined), args map, optional outputs map, optional fallback stepName.
|
|
683
|
+
* - Output: resolved gate description string if active, or undefined if inactive (false, "false", empty, or undefined).
|
|
684
|
+
*/
|
|
685
|
+
function resolveGate(gate, args = {}, outputs, stepName) {
|
|
686
|
+
if (gate === void 0) return;
|
|
687
|
+
if (typeof gate === "boolean") return gate ? stepName || "Gate" : void 0;
|
|
688
|
+
const interpolated = interpolateTemplate(gate, args, outputs).trim();
|
|
689
|
+
if (interpolated === "") return;
|
|
690
|
+
const interpolatedBool = parseBoolean(interpolated);
|
|
691
|
+
if (interpolatedBool === false) return;
|
|
692
|
+
if (interpolatedBool === true) return stepName || "Gate";
|
|
693
|
+
return interpolated;
|
|
694
|
+
}
|
|
695
|
+
// src/client/icons.tsx
|
|
696
|
+
function CopyIcon() {
|
|
697
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
698
|
+
width: "12",
|
|
699
|
+
height: "12",
|
|
700
|
+
viewBox: "0 0 24 24",
|
|
701
|
+
fill: "none",
|
|
702
|
+
stroke: "currentColor",
|
|
703
|
+
strokeWidth: "2",
|
|
704
|
+
strokeLinecap: "round",
|
|
705
|
+
strokeLinejoin: "round",
|
|
706
|
+
"aria-hidden": "true",
|
|
707
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
|
|
708
|
+
width: "14",
|
|
709
|
+
height: "14",
|
|
710
|
+
x: "8",
|
|
711
|
+
y: "8",
|
|
712
|
+
rx: "2",
|
|
713
|
+
ry: "2"
|
|
714
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" })]
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
function CheckIcon() {
|
|
718
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
719
|
+
width: "12",
|
|
720
|
+
height: "12",
|
|
721
|
+
viewBox: "0 0 24 24",
|
|
722
|
+
fill: "none",
|
|
723
|
+
stroke: "currentColor",
|
|
724
|
+
strokeWidth: "2",
|
|
725
|
+
strokeLinecap: "round",
|
|
726
|
+
strokeLinejoin: "round",
|
|
727
|
+
"aria-hidden": "true",
|
|
728
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("polyline", { points: "20 6 9 17 4 12" })
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Purpose: Renders a 12x12 play polygon icon for the workflow resume button.
|
|
733
|
+
* Contract:
|
|
734
|
+
* - Inputs: None.
|
|
735
|
+
* - Outputs: React JSX SVG element.
|
|
736
|
+
* - Throws: None.
|
|
737
|
+
*/
|
|
738
|
+
function ResumePlayIcon() {
|
|
739
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
740
|
+
width: "12",
|
|
741
|
+
height: "12",
|
|
742
|
+
viewBox: "0 0 24 24",
|
|
743
|
+
fill: "currentColor",
|
|
744
|
+
"aria-hidden": "true",
|
|
745
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("polygon", { points: "6 4 20 12 6 20 6 4" })
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* Purpose: Renders a 12x12 cross icon for the workflow discard button.
|
|
750
|
+
* Contract:
|
|
751
|
+
* - Inputs: None.
|
|
752
|
+
* - Outputs: React JSX SVG element.
|
|
753
|
+
* - Throws: None.
|
|
754
|
+
*/
|
|
755
|
+
function DiscardIcon() {
|
|
756
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
757
|
+
width: "12",
|
|
758
|
+
height: "12",
|
|
759
|
+
viewBox: "0 0 24 24",
|
|
760
|
+
fill: "none",
|
|
761
|
+
stroke: "currentColor",
|
|
762
|
+
strokeWidth: "2",
|
|
763
|
+
strokeLinecap: "round",
|
|
764
|
+
strokeLinejoin: "round",
|
|
765
|
+
"aria-hidden": "true",
|
|
766
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("line", {
|
|
767
|
+
x1: "18",
|
|
768
|
+
y1: "6",
|
|
769
|
+
x2: "6",
|
|
770
|
+
y2: "18"
|
|
771
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("line", {
|
|
772
|
+
x1: "6",
|
|
773
|
+
y1: "6",
|
|
774
|
+
x2: "18",
|
|
775
|
+
y2: "18"
|
|
776
|
+
})]
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
// src/client/styles.ts
|
|
780
|
+
const WORKFLOW_CARD_CSS = `
|
|
781
|
+
.dsh-wf-card,
|
|
782
|
+
.dsh-wf-card * {
|
|
783
|
+
box-sizing: border-box;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
.dsh-wf-card {
|
|
787
|
+
display: flex;
|
|
788
|
+
flex-direction: column;
|
|
789
|
+
border: 0.5px solid var(--dsw-alias-border-l1, rgba(255, 255, 255, 0.12));
|
|
790
|
+
border-radius: var(--dsw-radius-md, 6px);
|
|
791
|
+
background: var(--dsw-alias-surface-raised, rgba(255, 255, 255, 0.03));
|
|
792
|
+
color: var(--dsw-alias-label-primary, inherit);
|
|
793
|
+
margin: 4px 0;
|
|
794
|
+
overflow: hidden;
|
|
795
|
+
font-size: var(--dsh-content-font-size-secondary, 13px);
|
|
796
|
+
line-height: 1.5;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
.dsh-wf-header {
|
|
800
|
+
display: flex;
|
|
801
|
+
align-items: center;
|
|
802
|
+
justify-content: space-between;
|
|
803
|
+
padding: 8px 12px;
|
|
804
|
+
gap: 8px;
|
|
805
|
+
background: transparent;
|
|
806
|
+
width: 100%;
|
|
807
|
+
min-width: 0;
|
|
808
|
+
font: inherit;
|
|
809
|
+
color: inherit;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
.dsh-wf-title-group {
|
|
813
|
+
display: flex;
|
|
814
|
+
align-items: center;
|
|
815
|
+
gap: 8px;
|
|
816
|
+
min-width: 0;
|
|
817
|
+
flex: 1;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
.dsh-wf-command-badge {
|
|
821
|
+
display: inline-flex;
|
|
822
|
+
align-items: center;
|
|
823
|
+
font-family: var(--dsw-font-mono, monospace);
|
|
824
|
+
font-size: 12px;
|
|
825
|
+
line-height: 1.4;
|
|
826
|
+
font-weight: 600;
|
|
827
|
+
color: var(--dsw-alias-label-primary, inherit);
|
|
828
|
+
flex-shrink: 0;
|
|
829
|
+
user-select: text;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
.dsh-wf-args {
|
|
833
|
+
color: var(--dsw-alias-label-secondary, #a1a1aa);
|
|
834
|
+
font-family: var(--dsw-font-mono, monospace);
|
|
835
|
+
font-size: 12px;
|
|
836
|
+
line-height: 1.4;
|
|
837
|
+
overflow: hidden;
|
|
838
|
+
text-overflow: ellipsis;
|
|
839
|
+
white-space: nowrap;
|
|
840
|
+
user-select: text;
|
|
841
|
+
min-width: 0;
|
|
842
|
+
flex-shrink: 1;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
.dsh-wf-copy-btn {
|
|
846
|
+
display: inline-flex;
|
|
847
|
+
align-items: center;
|
|
848
|
+
justify-content: center;
|
|
849
|
+
width: 20px;
|
|
850
|
+
height: 20px;
|
|
851
|
+
padding: 0;
|
|
852
|
+
background: transparent;
|
|
853
|
+
border: 0.5px solid var(--dsw-alias-border-l1, rgba(255, 255, 255, 0.12));
|
|
854
|
+
border-radius: var(--dsw-radius-sm, 4px);
|
|
855
|
+
color: var(--dsw-alias-label-secondary, #a1a1aa);
|
|
856
|
+
cursor: pointer;
|
|
857
|
+
user-select: none;
|
|
858
|
+
flex-shrink: 0;
|
|
859
|
+
transition: all 0.15s ease;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
.dsh-wf-copy-btn:hover {
|
|
863
|
+
background: var(--dsw-alias-surface-hover, rgba(255, 255, 255, 0.08));
|
|
864
|
+
color: var(--dsw-alias-label-primary, inherit);
|
|
865
|
+
border-color: var(--dsw-alias-border-l2, rgba(255, 255, 255, 0.2));
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
.dsh-wf-copy-btn[data-copied="true"] {
|
|
869
|
+
color: var(--dsw-alias-state-success-primary, #10b981);
|
|
870
|
+
border-color: var(--dsw-alias-state-success-primary, #10b981);
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
.dsh-wf-status {
|
|
874
|
+
display: inline-flex;
|
|
875
|
+
align-items: center;
|
|
876
|
+
gap: 6px;
|
|
877
|
+
font-size: 12px;
|
|
878
|
+
line-height: 1.4;
|
|
879
|
+
flex-shrink: 0;
|
|
880
|
+
user-select: none;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
.dsh-wf-badge-running {
|
|
884
|
+
color: var(--dsw-alias-label-secondary, #a1a1aa);
|
|
885
|
+
display: inline-flex;
|
|
886
|
+
align-items: center;
|
|
887
|
+
gap: 6px;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
.dsh-wf-pulse-dot {
|
|
891
|
+
width: 6px;
|
|
892
|
+
height: 6px;
|
|
893
|
+
border-radius: 50%;
|
|
894
|
+
background: var(--dsw-alias-state-business-primary, #3b82f6);
|
|
895
|
+
animation: dsh-wf-pulse 1.4s ease-in-out infinite;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
@keyframes dsh-wf-pulse {
|
|
899
|
+
0%, 100% { opacity: 0.4; transform: scale(0.9); }
|
|
900
|
+
50% { opacity: 1; transform: scale(1.1); }
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
.dsh-wf-badge-success {
|
|
904
|
+
color: var(--dsw-alias-state-success-primary, #10b981);
|
|
905
|
+
font-weight: 500;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
.dsh-wf-badge-paused {
|
|
909
|
+
color: var(--dsw-alias-state-warning-primary, #f59e0b);
|
|
910
|
+
font-weight: 500;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
.dsh-wf-badge-aborted {
|
|
914
|
+
color: var(--dsw-alias-state-error-primary, #ef4444);
|
|
915
|
+
font-weight: 500;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
.dsh-wf-body {
|
|
919
|
+
border-top: 0.5px solid var(--dsw-alias-border-l1, rgba(255, 255, 255, 0.08));
|
|
920
|
+
background: var(--dsw-alias-markdown-code-block, rgba(0, 0, 0, 0.15));
|
|
921
|
+
padding: 8px 12px;
|
|
922
|
+
font-family: var(--dsw-font-mono, monospace);
|
|
923
|
+
font-size: 12px;
|
|
924
|
+
white-space: pre-wrap;
|
|
925
|
+
word-break: break-word;
|
|
926
|
+
max-height: 240px;
|
|
927
|
+
overflow-y: auto;
|
|
928
|
+
color: var(--dsw-alias-label-secondary, inherit);
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
.dsh-wf-body[data-paused="true"] {
|
|
932
|
+
color: var(--dsw-alias-state-warning-primary, #f59e0b);
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
.dsh-wf-gate-line {
|
|
936
|
+
margin-bottom: 4px;
|
|
937
|
+
line-height: 1.4;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
.dsh-wf-next-line {
|
|
941
|
+
margin-bottom: 4px;
|
|
942
|
+
line-height: 1.4;
|
|
943
|
+
color: var(--dsw-alias-label-primary, inherit);
|
|
944
|
+
font-weight: 500;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
.dsh-wf-hint-line {
|
|
948
|
+
font-size: 11px;
|
|
949
|
+
color: var(--dsw-alias-label-secondary, #a1a1aa);
|
|
950
|
+
font-style: italic;
|
|
951
|
+
margin-top: 6px;
|
|
952
|
+
padding-top: 6px;
|
|
953
|
+
border-top: 0.5px dashed var(--dsw-alias-border-l1, rgba(255, 255, 255, 0.08));
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
.dsh-wf-body[data-error="true"] {
|
|
957
|
+
color: var(--dsw-alias-state-error-primary, #ef4444);
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
.dsh-wf-step-row {
|
|
961
|
+
display: flex;
|
|
962
|
+
align-items: center;
|
|
963
|
+
gap: 8px;
|
|
964
|
+
padding: 4px 8px;
|
|
965
|
+
margin: 6px 0 2px 0;
|
|
966
|
+
font-size: 12px;
|
|
967
|
+
color: var(--dsw-alias-label-secondary, #a1a1aa);
|
|
968
|
+
font-family: var(--dsw-font-mono, monospace);
|
|
969
|
+
user-select: none;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
.dsh-wf-step-row[data-status="running"] {
|
|
973
|
+
color: var(--dsw-alias-label-primary, inherit);
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
.dsh-wf-step-icon {
|
|
977
|
+
display: inline-flex;
|
|
978
|
+
align-items: center;
|
|
979
|
+
justify-content: center;
|
|
980
|
+
font-weight: 700;
|
|
981
|
+
font-size: 14px;
|
|
982
|
+
width: 14px;
|
|
983
|
+
height: 14px;
|
|
984
|
+
flex-shrink: 0;
|
|
985
|
+
color: var(--dsw-alias-state-business-primary, #3b82f6);
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
.dsh-wf-step-icon[data-status="done"] {
|
|
989
|
+
color: var(--dsw-alias-state-success-primary, #10b981);
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
.dsh-wf-step-icon[data-status="paused"] {
|
|
993
|
+
color: var(--dsw-alias-state-warning-primary, #f59e0b);
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
.dsh-wf-step-icon[data-status="aborted"],
|
|
997
|
+
.dsh-wf-step-icon[data-status="error"] {
|
|
998
|
+
color: var(--dsw-alias-state-error-primary, #ef4444);
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
.dsh-wf-step-label {
|
|
1002
|
+
font-weight: 500;
|
|
1003
|
+
letter-spacing: 0.02em;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
.dsh-wf-step-error {
|
|
1007
|
+
margin: 2px 0 6px 26px;
|
|
1008
|
+
padding: 6px 10px;
|
|
1009
|
+
background: var(--dsw-alias-markdown-code-block, rgba(0, 0, 0, 0.15));
|
|
1010
|
+
border-left: 2px solid var(--dsw-alias-state-error-primary, #ef4444);
|
|
1011
|
+
border-radius: 0 var(--dsw-radius-sm, 4px) var(--dsw-radius-sm, 4px) 0;
|
|
1012
|
+
font-family: var(--dsw-font-mono, monospace);
|
|
1013
|
+
font-size: 12px;
|
|
1014
|
+
line-height: 1.5;
|
|
1015
|
+
color: var(--dsw-alias-state-error-primary, #ef4444);
|
|
1016
|
+
white-space: pre-wrap;
|
|
1017
|
+
word-break: break-word;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
.dsh-wf-print-step {
|
|
1021
|
+
margin: 2px 0 6px 16px;
|
|
1022
|
+
padding: 6px 10px;
|
|
1023
|
+
background: var(--dsw-alias-markdown-code-block, rgba(0, 0, 0, 0.15));
|
|
1024
|
+
border-left: 2px solid var(--dsw-alias-state-business-primary, #3b82f6);
|
|
1025
|
+
border-radius: 0 var(--dsw-radius-sm, 4px) var(--dsw-radius-sm, 4px) 0;
|
|
1026
|
+
font-size: 12px;
|
|
1027
|
+
line-height: 1.5;
|
|
1028
|
+
color: var(--dsw-alias-label-primary, inherit);
|
|
1029
|
+
min-width: 0;
|
|
1030
|
+
overflow-x: auto;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
.dsh-wf-resume-btn {
|
|
1034
|
+
display: inline-flex;
|
|
1035
|
+
align-items: center;
|
|
1036
|
+
gap: 5px;
|
|
1037
|
+
height: 28px;
|
|
1038
|
+
padding: 0 10px;
|
|
1039
|
+
background: var(--dsw-alias-surface-raised, rgba(255, 255, 255, 0.08));
|
|
1040
|
+
border: 0.5px solid var(--dsw-alias-state-warning-primary, #f59e0b);
|
|
1041
|
+
border-radius: var(--dsw-radius-sm, 6px);
|
|
1042
|
+
color: var(--dsw-alias-state-warning-primary, #f59e0b);
|
|
1043
|
+
font-family: inherit;
|
|
1044
|
+
font-size: 12px;
|
|
1045
|
+
font-weight: 500;
|
|
1046
|
+
cursor: pointer;
|
|
1047
|
+
user-select: none;
|
|
1048
|
+
flex-shrink: 0;
|
|
1049
|
+
transition: all 0.15s ease;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
.dsh-wf-resume-btn:hover {
|
|
1053
|
+
background: var(--dsw-alias-state-warning-primary, #f59e0b);
|
|
1054
|
+
color: #000000;
|
|
1055
|
+
border-color: var(--dsw-alias-state-warning-primary, #f59e0b);
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
.dsh-wf-resume-btn:active {
|
|
1059
|
+
transform: scale(0.97);
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
.dsh-wf-resume-btn-label {
|
|
1063
|
+
line-height: 1;
|
|
1064
|
+
max-width: 240px;
|
|
1065
|
+
overflow: hidden;
|
|
1066
|
+
text-overflow: ellipsis;
|
|
1067
|
+
white-space: nowrap;
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
.dsh-wf-toolbar-group {
|
|
1071
|
+
display: inline-flex;
|
|
1072
|
+
align-items: center;
|
|
1073
|
+
gap: 6px;
|
|
1074
|
+
flex-shrink: 0;
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
.dsh-wf-discard-btn {
|
|
1078
|
+
box-sizing: border-box;
|
|
1079
|
+
display: inline-flex;
|
|
1080
|
+
align-items: center;
|
|
1081
|
+
justify-content: center;
|
|
1082
|
+
gap: 4px;
|
|
1083
|
+
height: 28px;
|
|
1084
|
+
padding: 0 10px;
|
|
1085
|
+
border: 0.5px solid var(--dsw-alias-border-l3, rgba(255, 255, 255, 0.16));
|
|
1086
|
+
border-radius: var(--dsw-radius-sm, 6px);
|
|
1087
|
+
background: transparent;
|
|
1088
|
+
color: var(--dsw-alias-label-secondary, #a1a1aa);
|
|
1089
|
+
font-family: inherit;
|
|
1090
|
+
font-size: 12px;
|
|
1091
|
+
line-height: 18px;
|
|
1092
|
+
font-weight: 500;
|
|
1093
|
+
cursor: pointer;
|
|
1094
|
+
user-select: none;
|
|
1095
|
+
flex-shrink: 0;
|
|
1096
|
+
transition: background-color 100ms ease, border-color 100ms ease, color 100ms ease;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
.dsh-wf-discard-btn:hover:not(:disabled) {
|
|
1100
|
+
background: var(--dsw-alias-interactive-bg-hover, rgba(255, 255, 255, 0.08));
|
|
1101
|
+
color: var(--dsw-alias-state-error-primary, #ef4444);
|
|
1102
|
+
border-color: var(--dsw-alias-state-error-primary, #ef4444);
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
.dsh-wf-discard-btn:active:not(:disabled) {
|
|
1106
|
+
transform: scale(0.97);
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
.dsh-wf-discard-btn-label {
|
|
1110
|
+
line-height: 1;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
.dsh-wf-markdown-body {
|
|
1114
|
+
border-top: 0.5px solid var(--dsw-alias-border-l1, rgba(255, 255, 255, 0.08));
|
|
1115
|
+
padding: 10px 14px;
|
|
1116
|
+
min-width: 0;
|
|
1117
|
+
overflow-x: auto;
|
|
1118
|
+
}
|
|
1119
|
+
`;
|
|
1120
|
+
// src/client/WorkflowStyles.tsx
|
|
1121
|
+
function WorkflowStyles() {
|
|
1122
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", {
|
|
1123
|
+
href: "dsh-workflow-runner",
|
|
1124
|
+
precedence: "default",
|
|
1125
|
+
children: WORKFLOW_CARD_CSS
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
// src/client/WorkflowCommandCard.tsx
|
|
1129
|
+
/**
|
|
1130
|
+
* Derives paused gate criteria and next step preview from a workflow run.
|
|
1131
|
+
* CONTRACT:
|
|
1132
|
+
* - Inputs: WorkflowRun object.
|
|
1133
|
+
* - Outputs: PausedGateDetails with gate and nextStepLabel, or undefined if not paused.
|
|
1134
|
+
*/
|
|
1135
|
+
function getPausedGateDetails(run) {
|
|
1136
|
+
if (run.state.status !== "paused") return;
|
|
1137
|
+
const isInterrupted = run.state.pauseReason === "interrupted";
|
|
1138
|
+
const currentStep = run.workflow.steps[run.state.stepIndex];
|
|
1139
|
+
const gate = resolveGate(!isInterrupted && (currentStep?.kind === "prompt" || currentStep?.kind === "subagent") ? currentStep.gate : void 0, run.invocation.resolvedArgs, run.state.outputs, currentStep?.name);
|
|
1140
|
+
const targetIndex = isInterrupted ? run.state.stepIndex : run.state.stepIndex + 1;
|
|
1141
|
+
const targetStep = targetIndex < run.workflow.steps.length ? run.workflow.steps[targetIndex] : void 0;
|
|
1142
|
+
const targetName = targetStep?.name;
|
|
1143
|
+
return {
|
|
1144
|
+
gate,
|
|
1145
|
+
nextStepLabel: targetStep ? `Step ${targetIndex + 1} of ${run.workflow.steps.length}: ${targetName}` : "Workflow complete on resume",
|
|
1146
|
+
isInterrupted,
|
|
1147
|
+
targetName
|
|
1148
|
+
};
|
|
1149
|
+
}
|
|
1150
|
+
/**
|
|
1151
|
+
* Purpose: Recover the copyable command from recorded invocation input.
|
|
1152
|
+
* Contract:
|
|
1153
|
+
* - Inputs: A workflow invocation, including historical records without rawInput.
|
|
1154
|
+
* - Outputs: Original /wf command, or undefined when its input was not recorded.
|
|
1155
|
+
* - Throws: None.
|
|
1156
|
+
* @internal Exported for direct regression testing.
|
|
1157
|
+
*/
|
|
1158
|
+
function resolveWorkflowCommand(invocation) {
|
|
1159
|
+
if (invocation.rawInput === void 0) return void 0;
|
|
1160
|
+
return `/wf ${invocation.rawInput.trim()}`;
|
|
1161
|
+
}
|
|
1162
|
+
/**
|
|
1163
|
+
* Purpose: Workflow status card component mounted in conversation.chat.node slot.
|
|
1164
|
+
* Contract:
|
|
1165
|
+
* - Inputs: WorkflowCommandCardProps containing 'wf-state' chat node.
|
|
1166
|
+
* - Outputs: React JSX element rendering status badges, command string, and gate details.
|
|
1167
|
+
* - Throws: None.
|
|
1168
|
+
*/
|
|
1169
|
+
function WorkflowCommandCard({ node }) {
|
|
1170
|
+
const run = node.data;
|
|
1171
|
+
const { invocation, state } = run;
|
|
1172
|
+
const status = state.status;
|
|
1173
|
+
const targetPath = invocation.targetPath;
|
|
1174
|
+
const isPaused = status === "paused";
|
|
1175
|
+
const isAborted = status === "aborted";
|
|
1176
|
+
const isRunning = status === "running";
|
|
1177
|
+
const isSuccess = status === "completed";
|
|
1178
|
+
const [copied, setCopied] = (0, react.useState)(false);
|
|
1179
|
+
const pausedDetails = isPaused ? getPausedGateDetails(run) : void 0;
|
|
1180
|
+
const formattedArgs = Object.entries(invocation.resolvedArgs).map(([k, v]) => v.includes(" ") ? `${k}="${v}"` : `${k}=${v}`).join(" ");
|
|
1181
|
+
const rawCommand = resolveWorkflowCommand(invocation);
|
|
1182
|
+
const handleCopy = () => {
|
|
1183
|
+
if (rawCommand === void 0) return;
|
|
1184
|
+
navigator.clipboard.writeText(rawCommand).then(() => {
|
|
1185
|
+
setCopied(true);
|
|
1186
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
1187
|
+
}).catch(() => {});
|
|
1188
|
+
};
|
|
1189
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorkflowStyles, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1190
|
+
className: "dsh-wf-card",
|
|
1191
|
+
"data-state": isRunning ? "running" : isPaused ? "paused" : isAborted ? "aborted" : isSuccess ? "completed" : "idle",
|
|
1192
|
+
children: [
|
|
1193
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1194
|
+
className: "dsh-wf-header",
|
|
1195
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1196
|
+
className: "dsh-wf-title-group",
|
|
1197
|
+
children: [
|
|
1198
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1199
|
+
className: "dsh-wf-command-badge",
|
|
1200
|
+
children: "/wf"
|
|
1201
|
+
}),
|
|
1202
|
+
targetPath && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1203
|
+
className: "dsh-wf-args",
|
|
1204
|
+
title: targetPath,
|
|
1205
|
+
children: targetPath
|
|
1206
|
+
}),
|
|
1207
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1208
|
+
type: "button",
|
|
1209
|
+
className: "dsh-wf-copy-btn",
|
|
1210
|
+
"data-copied": copied,
|
|
1211
|
+
onClick: handleCopy,
|
|
1212
|
+
disabled: rawCommand === void 0,
|
|
1213
|
+
title: rawCommand === void 0 ? "Original command was not recorded" : copied ? "Copied" : "Copy command",
|
|
1214
|
+
"aria-label": copied ? "Copied" : "Copy command",
|
|
1215
|
+
children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckIcon, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyIcon, {})
|
|
1216
|
+
})
|
|
1217
|
+
]
|
|
1218
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1219
|
+
className: "dsh-wf-status",
|
|
1220
|
+
children: [
|
|
1221
|
+
isRunning && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1222
|
+
className: "dsh-wf-badge-running",
|
|
1223
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "dsh-wf-pulse-dot" }), "Running..."]
|
|
1224
|
+
}),
|
|
1225
|
+
isPaused && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1226
|
+
className: "dsh-wf-badge-paused",
|
|
1227
|
+
children: "❚❚ Paused"
|
|
1228
|
+
}),
|
|
1229
|
+
isAborted && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1230
|
+
className: "dsh-wf-badge-aborted",
|
|
1231
|
+
children: state.error ? "✕ Failed" : "✕ Aborted"
|
|
1232
|
+
}),
|
|
1233
|
+
isSuccess && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1234
|
+
className: "dsh-wf-badge-success",
|
|
1235
|
+
children: "✓ Done"
|
|
1236
|
+
})
|
|
1237
|
+
]
|
|
1238
|
+
})]
|
|
1239
|
+
}),
|
|
1240
|
+
formattedArgs && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1241
|
+
className: "dsh-wf-body",
|
|
1242
|
+
"data-input": "true",
|
|
1243
|
+
children: formattedArgs
|
|
1244
|
+
}),
|
|
1245
|
+
pausedDetails && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1246
|
+
className: "dsh-wf-body",
|
|
1247
|
+
"data-paused": "true",
|
|
1248
|
+
children: [
|
|
1249
|
+
pausedDetails.gate && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1250
|
+
className: "dsh-wf-gate-line",
|
|
1251
|
+
children: ["Paused at gate: ", pausedDetails.gate]
|
|
1252
|
+
}),
|
|
1253
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1254
|
+
className: "dsh-wf-next-line",
|
|
1255
|
+
children: [pausedDetails.isInterrupted ? "Resume: " : "Next: ", pausedDetails.nextStepLabel]
|
|
1256
|
+
}),
|
|
1257
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1258
|
+
className: "dsh-wf-hint-line",
|
|
1259
|
+
children: "Press Resume to proceed, or enter feedback in the prompt input to pass instructions."
|
|
1260
|
+
})
|
|
1261
|
+
]
|
|
1262
|
+
}),
|
|
1263
|
+
isAborted && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1264
|
+
className: "dsh-wf-body",
|
|
1265
|
+
"data-error": "true",
|
|
1266
|
+
children: state.error ? `Workflow failed at step ${state.stepIndex + 1} of ${run.workflow.steps.length}: ${state.error}` : `Workflow discarded at step ${state.stepIndex + 1} of ${run.workflow.steps.length}`
|
|
1267
|
+
})
|
|
1268
|
+
]
|
|
1269
|
+
})] });
|
|
1270
|
+
}
|
|
1271
|
+
// src/client/WorkflowErrorCard.tsx
|
|
1272
|
+
/**
|
|
1273
|
+
* Reconstructs the original slash command invocation string from error chat data.
|
|
1274
|
+
*/
|
|
1275
|
+
function resolveErrorCommand(data) {
|
|
1276
|
+
const rawArgs = typeof data.args === "string" ? data.args.trim() : "";
|
|
1277
|
+
const commandBadge = data.name ? `/${data.name}` : "/wf";
|
|
1278
|
+
return rawArgs.length > 0 ? `${commandBadge} ${rawArgs}` : commandBadge;
|
|
1279
|
+
}
|
|
1280
|
+
/**
|
|
1281
|
+
* Purpose: Renders a failed workflow command card in the conversation.chat.node slot.
|
|
1282
|
+
* Contract:
|
|
1283
|
+
* - Inputs: WorkflowErrorCardProps containing 'wf-error' chat node.
|
|
1284
|
+
* - Outputs: React JSX element rendering error details.
|
|
1285
|
+
* - Throws: None.
|
|
1286
|
+
*/
|
|
1287
|
+
function WorkflowErrorCard({ node }) {
|
|
1288
|
+
const data = node.data;
|
|
1289
|
+
const rawArgs = typeof data.args === "string" ? data.args.trim() : "";
|
|
1290
|
+
const errorText = data.text;
|
|
1291
|
+
const commandBadge = data.name ? `/${data.name}` : "/wf";
|
|
1292
|
+
const rawCommand = resolveErrorCommand(data);
|
|
1293
|
+
const [copied, setCopied] = (0, react.useState)(false);
|
|
1294
|
+
const handleCopy = () => {
|
|
1295
|
+
navigator.clipboard.writeText(rawCommand).then(() => {
|
|
1296
|
+
setCopied(true);
|
|
1297
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
1298
|
+
}).catch(() => {});
|
|
1299
|
+
};
|
|
1300
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorkflowStyles, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1301
|
+
className: "dsh-wf-card",
|
|
1302
|
+
"data-state": "aborted",
|
|
1303
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1304
|
+
className: "dsh-wf-header",
|
|
1305
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1306
|
+
className: "dsh-wf-title-group",
|
|
1307
|
+
children: [
|
|
1308
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1309
|
+
className: "dsh-wf-command-badge",
|
|
1310
|
+
children: commandBadge
|
|
1311
|
+
}),
|
|
1312
|
+
rawArgs.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1313
|
+
className: "dsh-wf-args",
|
|
1314
|
+
title: rawArgs,
|
|
1315
|
+
children: rawArgs
|
|
1316
|
+
}),
|
|
1317
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1318
|
+
type: "button",
|
|
1319
|
+
className: "dsh-wf-copy-btn",
|
|
1320
|
+
"data-copied": copied ? "true" : "false",
|
|
1321
|
+
onClick: handleCopy,
|
|
1322
|
+
title: copied ? "Copied" : "Copy command",
|
|
1323
|
+
"aria-label": copied ? "Copied" : "Copy command",
|
|
1324
|
+
children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckIcon, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyIcon, {})
|
|
1325
|
+
})
|
|
1326
|
+
]
|
|
1327
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1328
|
+
className: "dsh-wf-status",
|
|
1329
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1330
|
+
className: "dsh-wf-badge-aborted",
|
|
1331
|
+
children: "✕ Failed"
|
|
1332
|
+
})
|
|
1333
|
+
})]
|
|
1334
|
+
}), errorText && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1335
|
+
className: "dsh-wf-body",
|
|
1336
|
+
"data-error": "true",
|
|
1337
|
+
children: errorText
|
|
1338
|
+
})]
|
|
1339
|
+
})] });
|
|
1340
|
+
}
|
|
1341
|
+
// src/client/WorkflowMarkdown.tsx
|
|
1342
|
+
/**
|
|
1343
|
+
* Purpose: Render markdown through DSH's shared Markdown factory.
|
|
1344
|
+
* Contract:
|
|
1345
|
+
* - Inputs: text string, optional className, and renderFactorySlot.
|
|
1346
|
+
* - Outputs: Markdown-rendered block.
|
|
1347
|
+
*/
|
|
1348
|
+
function WorkflowMarkdown({ text, className, renderFactorySlot }) {
|
|
1349
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1350
|
+
className,
|
|
1351
|
+
children: renderFactorySlot("conversation.chat.reasoning.content", {
|
|
1352
|
+
text,
|
|
1353
|
+
running: false
|
|
1354
|
+
})
|
|
1355
|
+
});
|
|
1356
|
+
}
|
|
1357
|
+
// src/client/WorkflowMarkdownResult.tsx
|
|
1358
|
+
/**
|
|
1359
|
+
* Purpose: Render workflow command outcomes through DSH's shared Markdown factory.
|
|
1360
|
+
* Contract:
|
|
1361
|
+
* - Inputs: Command lifecycle fields and the framework's factory renderer.
|
|
1362
|
+
* - Outputs: An always-visible result body with a command header and copy action.
|
|
1363
|
+
* - Throws: Clipboard failures propagate to the browser.
|
|
1364
|
+
*/
|
|
1365
|
+
function WorkflowMarkdownResult({ node, renderFactorySlot }) {
|
|
1366
|
+
const { outcome } = node;
|
|
1367
|
+
const state = outcome === null ? "running" : outcome.kind === "error" ? "aborted" : "completed";
|
|
1368
|
+
const command = node.name === null ? "" : `/${node.name}`;
|
|
1369
|
+
const rawArgs = typeof node.args === "string" && node.args.trim().length > 0 ? node.args.startsWith(" ") ? node.args : ` ${node.args}` : "";
|
|
1370
|
+
const rawCommand = command ? `${command}${rawArgs}` : "";
|
|
1371
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorkflowStyles, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1372
|
+
className: "dsh-wf-card",
|
|
1373
|
+
"data-state": state,
|
|
1374
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1375
|
+
className: "dsh-wf-header",
|
|
1376
|
+
children: [
|
|
1377
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1378
|
+
className: "dsh-wf-title-group",
|
|
1379
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1380
|
+
className: "dsh-wf-command-badge",
|
|
1381
|
+
children: command
|
|
1382
|
+
}), node.args && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1383
|
+
className: "dsh-wf-args",
|
|
1384
|
+
title: node.args,
|
|
1385
|
+
children: node.args
|
|
1386
|
+
})]
|
|
1387
|
+
}),
|
|
1388
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1389
|
+
className: `dsh-wf-badge-${state === "completed" ? "success" : state}`,
|
|
1390
|
+
children: outcome === null ? "Running…" : outcome.kind === "error" ? "Failed" : "Done"
|
|
1391
|
+
}),
|
|
1392
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1393
|
+
type: "button",
|
|
1394
|
+
className: "dsh-wf-copy-btn",
|
|
1395
|
+
title: "Copy command",
|
|
1396
|
+
"aria-label": "Copy command",
|
|
1397
|
+
onClick: () => navigator.clipboard.writeText(rawCommand),
|
|
1398
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyIcon, {})
|
|
1399
|
+
})
|
|
1400
|
+
]
|
|
1401
|
+
}), outcome !== null && outcome.text !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorkflowMarkdown, {
|
|
1402
|
+
className: "dsh-wf-markdown-body",
|
|
1403
|
+
text: outcome.kind === "error" ? outcome.text.split("\n").map((line) => ` ${line}`).join("\n") : outcome.text,
|
|
1404
|
+
renderFactorySlot
|
|
1405
|
+
})]
|
|
1406
|
+
})] });
|
|
1407
|
+
}
|
|
1408
|
+
// src/client/WorkflowPrintStep.tsx
|
|
1409
|
+
/**
|
|
1410
|
+
* Markdown-rendered print output row mounted in conversation.chat.node slot.
|
|
1411
|
+
* CONTRACT:
|
|
1412
|
+
* - Input: ChatNodeViewProps with node containing WorkflowPrintChatData and factory renderer.
|
|
1413
|
+
* - Output: Markdown-rendered text block.
|
|
1414
|
+
*/
|
|
1415
|
+
function WorkflowPrintStep({ node, renderFactorySlot }) {
|
|
1416
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorkflowStyles, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorkflowMarkdown, {
|
|
1417
|
+
className: "dsh-wf-print-step",
|
|
1418
|
+
text: node.data.text,
|
|
1419
|
+
renderFactorySlot
|
|
1420
|
+
})] });
|
|
1421
|
+
}
|
|
1422
|
+
// src/client/actions.ts
|
|
1423
|
+
/**
|
|
1424
|
+
* Resolves a draft string into an executable /wf-resume command invocation.
|
|
1425
|
+
* CONTRACT:
|
|
1426
|
+
* - Input: optional draft string.
|
|
1427
|
+
* - Output: formatted command string (defaults to '/wf-resume', or '/wf-resume <draft>').
|
|
1428
|
+
*/
|
|
1429
|
+
function resolveResumeCommand(draft) {
|
|
1430
|
+
const trimmedDraft = (draft || "").trim();
|
|
1431
|
+
if (trimmedDraft.length === 0) return "/wf-resume";
|
|
1432
|
+
if (/^\/wf-resume(\s+.*)?$/.test(trimmedDraft)) return trimmedDraft;
|
|
1433
|
+
return `/wf-resume ${trimmedDraft}`;
|
|
1434
|
+
}
|
|
1435
|
+
/**
|
|
1436
|
+
* Internal helper to dispatch a workflow slash command with optimistic store update and rollback.
|
|
1437
|
+
*/
|
|
1438
|
+
async function dispatchWorkflowCommand(ctx, sessionId, command, optimisticStatus) {
|
|
1439
|
+
const current = getWorkflowState(sessionId);
|
|
1440
|
+
if (current) setWorkflowState(sessionId, {
|
|
1441
|
+
...current,
|
|
1442
|
+
state: {
|
|
1443
|
+
...current.state,
|
|
1444
|
+
status: optimisticStatus
|
|
1445
|
+
}
|
|
1446
|
+
}, current.invocation.runId);
|
|
1447
|
+
try {
|
|
1448
|
+
const binding = ctx.sessions.binding(sessionId);
|
|
1449
|
+
if (!binding) throw new Error(`Session "${sessionId}" is not active`);
|
|
1450
|
+
const result = await binding.session.command(command);
|
|
1451
|
+
if (!result.ok) throw new Error(`Command "${command}" failed: ${result.error.code}: ${result.error.message}`);
|
|
1452
|
+
if (!result.value.matched) throw new Error(`The host offers no ${command} command`);
|
|
1453
|
+
} catch (err) {
|
|
1454
|
+
if (current) {
|
|
1455
|
+
const active = getWorkflowState(sessionId);
|
|
1456
|
+
if (active && active.invocation.runId === current.invocation.runId) setWorkflowState(sessionId, current, current.invocation.runId);
|
|
1457
|
+
else setWorkflowRunState(current.invocation.runId, current);
|
|
1458
|
+
}
|
|
1459
|
+
throw err;
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
/**
|
|
1463
|
+
* Purpose: Dispatches a resume slash command to the host and sets optimistic running state.
|
|
1464
|
+
* Contract:
|
|
1465
|
+
* - Inputs: Cordis WorkflowClientContext, sessionId, and optional command string.
|
|
1466
|
+
* - Outputs: Promise resolving when command is admitted and executed by host.
|
|
1467
|
+
* - Throws: Error when session is not active or command execution fails.
|
|
1468
|
+
*/
|
|
1469
|
+
async function sendResumeCommand(ctx, sessionId, command = "/wf-resume") {
|
|
1470
|
+
await dispatchWorkflowCommand(ctx, sessionId, command, "running");
|
|
1471
|
+
}
|
|
1472
|
+
/**
|
|
1473
|
+
* Purpose: Dispatches an abort slash command to the host and sets optimistic aborted state.
|
|
1474
|
+
* Contract:
|
|
1475
|
+
* - Inputs: Cordis WorkflowClientContext, sessionId, and optional command string.
|
|
1476
|
+
* - Outputs: Promise resolving when command is admitted and executed by host.
|
|
1477
|
+
* - Throws: Error when session is not active or command execution fails.
|
|
1478
|
+
*/
|
|
1479
|
+
async function sendDiscardCommand(ctx, sessionId, command = "/wf-abort") {
|
|
1480
|
+
await dispatchWorkflowCommand(ctx, sessionId, command, "aborted");
|
|
1481
|
+
}
|
|
1482
|
+
// src/client/WorkflowResumeButton.tsx
|
|
1483
|
+
/**
|
|
1484
|
+
* Derives contextual button label and tooltip for the resume button.
|
|
1485
|
+
* CONTRACT:
|
|
1486
|
+
* - Inputs: WorkflowRun (or undefined), and optional draft string.
|
|
1487
|
+
* - Outputs: ResumeButtonDetails with label and tooltip, or undefined if not resumable.
|
|
1488
|
+
*/
|
|
1489
|
+
function getResumeButtonDetails(run, draft = "") {
|
|
1490
|
+
if (!run) return;
|
|
1491
|
+
const details = getPausedGateDetails(run);
|
|
1492
|
+
if (!details) return;
|
|
1493
|
+
const { gate, isInterrupted, targetName } = details;
|
|
1494
|
+
const hasDraft = draft.trim().length > 0;
|
|
1495
|
+
return {
|
|
1496
|
+
label: targetName ? hasDraft ? `Resume with feedback: ${targetName}` : `Resume: ${targetName}` : hasDraft ? "Resume with feedback (Complete)" : "Resume (Complete)",
|
|
1497
|
+
tooltip: isInterrupted ? `Resume workflow at current step: ${targetName ?? "Step"}${hasDraft ? ". Feedback will be sent as user instructions." : ""}` : `Resume workflow${gate ? ` (Gate: ${gate})` : ""} → Next: ${targetName ?? "Complete"}${hasDraft ? ". Feedback will be sent as user instructions." : ""}`
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1500
|
+
/**
|
|
1501
|
+
* Purpose: Resume and discard controls in the session composer toolbar.
|
|
1502
|
+
* Contract:
|
|
1503
|
+
* - Inputs: Canonical session input props.
|
|
1504
|
+
* - Outputs: Toolbar controls while the workflow is paused, otherwise null.
|
|
1505
|
+
* - Errors: Reports dispatch failures without consuming unadmitted drafts.
|
|
1506
|
+
*/
|
|
1507
|
+
function WorkflowResumeButton({ sessionId, useInput, inputActions }) {
|
|
1508
|
+
const ctx = useWorkflowClientContext();
|
|
1509
|
+
const draft = useInput((state) => state.draft);
|
|
1510
|
+
const details = getResumeButtonDetails(useWorkflowState(sessionId), draft);
|
|
1511
|
+
if (!details) return null;
|
|
1512
|
+
const handleResume = async () => {
|
|
1513
|
+
try {
|
|
1514
|
+
const commandToSend = resolveResumeCommand(draft);
|
|
1515
|
+
const binding = ctx.sessions.binding(sessionId);
|
|
1516
|
+
if (!binding) throw new Error(`Session "${sessionId}" is not active`);
|
|
1517
|
+
const draftRev = inputActions.captureInsertion().draftRev;
|
|
1518
|
+
const clearDraft = () => {
|
|
1519
|
+
if (inputActions.captureInsertion().draftRev === draftRev) inputActions.setDraft("");
|
|
1520
|
+
};
|
|
1521
|
+
const unsubscribe = binding.eventSource.subscribe(() => {
|
|
1522
|
+
const { change } = binding.eventSource.getSnapshot();
|
|
1523
|
+
if (change.kind !== "append") return;
|
|
1524
|
+
if (!change.entries.some(({ event }) => event.type === "command/run" && event.data.name === "wf-resume" && event.data.args === commandToSend.slice(10))) return;
|
|
1525
|
+
unsubscribe();
|
|
1526
|
+
clearDraft();
|
|
1527
|
+
});
|
|
1528
|
+
try {
|
|
1529
|
+
await sendResumeCommand(ctx, sessionId, commandToSend);
|
|
1530
|
+
clearDraft();
|
|
1531
|
+
} finally {
|
|
1532
|
+
unsubscribe();
|
|
1533
|
+
}
|
|
1534
|
+
} catch (err) {
|
|
1535
|
+
console.error("Failed to resume workflow:", err);
|
|
1536
|
+
}
|
|
1537
|
+
};
|
|
1538
|
+
const handleDiscard = async () => {
|
|
1539
|
+
try {
|
|
1540
|
+
await sendDiscardCommand(ctx, sessionId);
|
|
1541
|
+
} catch (err) {
|
|
1542
|
+
console.error("Failed to discard workflow:", err);
|
|
1543
|
+
}
|
|
1544
|
+
};
|
|
1545
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorkflowStyles, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1546
|
+
className: "dsh-wf-toolbar-group",
|
|
1547
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1548
|
+
type: "button",
|
|
1549
|
+
className: "dsh-wf-resume-btn",
|
|
1550
|
+
onClick: handleResume,
|
|
1551
|
+
title: details.tooltip,
|
|
1552
|
+
"aria-label": details.tooltip,
|
|
1553
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResumePlayIcon, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1554
|
+
className: "dsh-wf-resume-btn-label",
|
|
1555
|
+
children: details.label
|
|
1556
|
+
})]
|
|
1557
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1558
|
+
type: "button",
|
|
1559
|
+
className: "dsh-wf-discard-btn",
|
|
1560
|
+
onClick: handleDiscard,
|
|
1561
|
+
title: "Discard workflow",
|
|
1562
|
+
"aria-label": "Discard workflow",
|
|
1563
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DiscardIcon, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1564
|
+
className: "dsh-wf-discard-btn-label",
|
|
1565
|
+
children: "Discard"
|
|
1566
|
+
})]
|
|
1567
|
+
})]
|
|
1568
|
+
})] });
|
|
1569
|
+
}
|
|
1570
|
+
// src/client/WorkflowStepRow.tsx
|
|
1571
|
+
/**
|
|
1572
|
+
* Purpose: Derives step execution status from workflow run state and node data.
|
|
1573
|
+
* Contract:
|
|
1574
|
+
* - Inputs: stepData object containing stepIndex and kind, optional WorkflowRun.
|
|
1575
|
+
* - Outputs: StepStatus enum representing current execution lifecycle.
|
|
1576
|
+
* - Throws: None.
|
|
1577
|
+
*/
|
|
1578
|
+
function deriveStepStatus(stepData, run) {
|
|
1579
|
+
if (run) {
|
|
1580
|
+
const { status, stepIndex: activeStepIndex, error } = run.state;
|
|
1581
|
+
if (status === "completed" || stepData.stepIndex < activeStepIndex) return "done";
|
|
1582
|
+
if (status === "aborted") return error ? "error" : "aborted";
|
|
1583
|
+
if (status === "paused") return "paused";
|
|
1584
|
+
if (stepData.kind === "error") return error ? "error" : "aborted";
|
|
1585
|
+
return "running";
|
|
1586
|
+
}
|
|
1587
|
+
if (stepData.kind === "error") return "error";
|
|
1588
|
+
return "done";
|
|
1589
|
+
}
|
|
1590
|
+
/**
|
|
1591
|
+
* Step progress row mounted in conversation.chat.node slot.
|
|
1592
|
+
* CONTRACT:
|
|
1593
|
+
* - Input: ChatNodeViewProps with node containing WorkflowStepChatData.
|
|
1594
|
+
* - Output: formatted row with step status icon, label, and lifecycle badge.
|
|
1595
|
+
*/
|
|
1596
|
+
function WorkflowStepRow({ node }) {
|
|
1597
|
+
const run = useWorkflowRunState(node.data.runId);
|
|
1598
|
+
const status = deriveStepStatus(node.data, run);
|
|
1599
|
+
const errorMessage = status === "error" && run?.state.error ? run.state.error : void 0;
|
|
1600
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1601
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorkflowStyles, {}),
|
|
1602
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1603
|
+
className: "dsh-wf-step-row",
|
|
1604
|
+
"data-kind": "step",
|
|
1605
|
+
"data-status": status,
|
|
1606
|
+
children: [
|
|
1607
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1608
|
+
className: "dsh-wf-step-icon",
|
|
1609
|
+
"data-status": status,
|
|
1610
|
+
"aria-hidden": "true",
|
|
1611
|
+
children: [
|
|
1612
|
+
status === "running" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "dsh-wf-pulse-dot" }),
|
|
1613
|
+
status === "done" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckIcon, {}),
|
|
1614
|
+
status === "paused" && "❚❚",
|
|
1615
|
+
status === "aborted" && "✕",
|
|
1616
|
+
status === "error" && "✕"
|
|
1617
|
+
]
|
|
1618
|
+
}),
|
|
1619
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1620
|
+
className: "dsh-wf-step-label",
|
|
1621
|
+
children: node.data.label
|
|
1622
|
+
}),
|
|
1623
|
+
status === "running" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1624
|
+
className: "dsh-wf-badge-running",
|
|
1625
|
+
children: "Running..."
|
|
1626
|
+
}),
|
|
1627
|
+
status === "paused" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1628
|
+
className: "dsh-wf-badge-paused",
|
|
1629
|
+
children: "Paused"
|
|
1630
|
+
}),
|
|
1631
|
+
status === "aborted" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1632
|
+
className: "dsh-wf-badge-aborted",
|
|
1633
|
+
children: "Discarded"
|
|
1634
|
+
}),
|
|
1635
|
+
status === "error" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1636
|
+
className: "dsh-wf-badge-aborted",
|
|
1637
|
+
children: "✕ Failed"
|
|
1638
|
+
})
|
|
1639
|
+
]
|
|
1640
|
+
}),
|
|
1641
|
+
errorMessage && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1642
|
+
className: "dsh-wf-step-error",
|
|
1643
|
+
children: errorMessage
|
|
1644
|
+
})
|
|
1645
|
+
] });
|
|
1646
|
+
}
|
|
1647
|
+
// src/client/index.tsx
|
|
1648
|
+
const inject = [
|
|
1649
|
+
"slots",
|
|
1650
|
+
"conversation",
|
|
1651
|
+
"uiConversation",
|
|
1652
|
+
"sessions"
|
|
1653
|
+
];
|
|
1654
|
+
/**
|
|
1655
|
+
* Applies workflow runner client plugin to the Cordis client container.
|
|
1656
|
+
* CONTRACT:
|
|
1657
|
+
* - Input: Cordis ClientContext instance with injected slots, conversation, uiConversation, and sessions services.
|
|
1658
|
+
* - Output: void (registers slots and effects).
|
|
1659
|
+
*/
|
|
1660
|
+
function apply(ctx) {
|
|
1661
|
+
ctx.effect(() => registerWorkflowChatNodes(ctx), "workflow-runner: chat-nodes");
|
|
1662
|
+
ctx.effect(() => ctx.slots.inject("conversation.chat.node", () => {
|
|
1663
|
+
const unregisterState = ctx.slots.register({
|
|
1664
|
+
name: "conversation.chat.node",
|
|
1665
|
+
key: "wf-state"
|
|
1666
|
+
}, WorkflowCommandCard);
|
|
1667
|
+
const unregisterStep = ctx.slots.register({
|
|
1668
|
+
name: "conversation.chat.node",
|
|
1669
|
+
key: "wf-step"
|
|
1670
|
+
}, WorkflowStepRow);
|
|
1671
|
+
const unregisterPrint = ctx.slots.register({
|
|
1672
|
+
name: "conversation.chat.node",
|
|
1673
|
+
key: "wf-print"
|
|
1674
|
+
}, WorkflowPrintStep);
|
|
1675
|
+
const unregisterError = ctx.slots.register({
|
|
1676
|
+
name: "conversation.chat.node",
|
|
1677
|
+
key: "wf-error"
|
|
1678
|
+
}, WorkflowErrorCard);
|
|
1679
|
+
const unregisterList = ctx.slots.register({
|
|
1680
|
+
name: "conversation.chat.node",
|
|
1681
|
+
key: "wf-list"
|
|
1682
|
+
}, (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorkflowMarkdownResult, {
|
|
1683
|
+
node: props.node.data,
|
|
1684
|
+
renderFactorySlot: props.renderFactorySlot
|
|
1685
|
+
}));
|
|
1686
|
+
return () => {
|
|
1687
|
+
unregisterState();
|
|
1688
|
+
unregisterStep();
|
|
1689
|
+
unregisterPrint();
|
|
1690
|
+
unregisterError();
|
|
1691
|
+
unregisterList();
|
|
1692
|
+
};
|
|
1693
|
+
}), "workflow-runner: chat.node");
|
|
1694
|
+
ctx.effect(() => ctx.slots.inject("conversation.chat.commandview", () => {
|
|
1695
|
+
const unregisterWf = ctx.slots.register({
|
|
1696
|
+
name: "conversation.chat.commandview",
|
|
1697
|
+
key: "wf"
|
|
1698
|
+
}, () => null);
|
|
1699
|
+
const unregisterResume = ctx.slots.register({
|
|
1700
|
+
name: "conversation.chat.commandview",
|
|
1701
|
+
key: "wf-resume"
|
|
1702
|
+
}, () => null);
|
|
1703
|
+
const unregisterAbort = ctx.slots.register({
|
|
1704
|
+
name: "conversation.chat.commandview",
|
|
1705
|
+
key: "wf-abort"
|
|
1706
|
+
}, () => null);
|
|
1707
|
+
const unregisterEvent = ctx.slots.register({
|
|
1708
|
+
name: "conversation.chat.commandview",
|
|
1709
|
+
key: WORKFLOW_EVENT_NAME
|
|
1710
|
+
}, () => null);
|
|
1711
|
+
const unregisterList = ctx.slots.register({
|
|
1712
|
+
name: "conversation.chat.commandview",
|
|
1713
|
+
key: "wf-list"
|
|
1714
|
+
}, () => null);
|
|
1715
|
+
const unregisterValidate = ctx.slots.register({
|
|
1716
|
+
name: "conversation.chat.commandview",
|
|
1717
|
+
key: "wf-validate"
|
|
1718
|
+
}, WorkflowMarkdownResult);
|
|
1719
|
+
return () => {
|
|
1720
|
+
unregisterWf();
|
|
1721
|
+
unregisterResume();
|
|
1722
|
+
unregisterAbort();
|
|
1723
|
+
unregisterEvent();
|
|
1724
|
+
unregisterList();
|
|
1725
|
+
unregisterValidate();
|
|
1726
|
+
};
|
|
1727
|
+
}), "workflow-runner: commandview-custom");
|
|
1728
|
+
ctx.effect(() => ctx.slots.inject("conversation.input.right", () => {
|
|
1729
|
+
const unregisterResume = ctx.slots.register({
|
|
1730
|
+
name: "conversation.input.right",
|
|
1731
|
+
id: "wf-resume",
|
|
1732
|
+
order: 50
|
|
1733
|
+
}, (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorkflowClientContext.Provider, {
|
|
1734
|
+
value: ctx,
|
|
1735
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorkflowResumeButton, { ...props })
|
|
1736
|
+
}));
|
|
1737
|
+
return () => {
|
|
1738
|
+
unregisterResume();
|
|
1739
|
+
};
|
|
1740
|
+
}), "workflow-runner: input.right");
|
|
1741
|
+
}
|
|
1742
|
+
exports.apply = apply;
|
|
1743
|
+
exports.inject = inject;
|
|
1744
|
+
return module.exports;
|
|
1745
|
+
}
|
|
1746
|
+
});
|