@crewx/workflow 0.3.22-rc.192 → 0.3.22-rc.193
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/dist/cli.d.ts +1 -1
- package/dist/cli.js +17 -1190
- package/dist/src/card-state.d.ts +1 -1
- package/dist/src/card-state.js +1 -121
- package/dist/src/engine.d.ts +1 -1
- package/dist/src/engine.js +1 -379
- package/dist/src/failure.d.ts +1 -1
- package/dist/src/failure.js +1 -122
- package/dist/src/file-lock.d.ts +1 -1
- package/dist/src/file-lock.js +1 -97
- package/dist/src/list-view.d.ts +1 -1
- package/dist/src/list-view.js +3 -188
- package/dist/src/mermaid.d.ts +1 -1
- package/dist/src/mermaid.js +2 -133
- package/dist/src/parent-task-sync.d.ts +1 -1
- package/dist/src/parent-task-sync.js +1 -445
- package/dist/src/retry-policy.d.ts +1 -1
- package/dist/src/retry-policy.js +1 -140
- package/dist/src/run-manager.d.ts +1 -1
- package/dist/src/run-manager.js +4 -2165
- package/dist/src/types.d.ts +1 -1
- package/dist/src/types.js +1 -5
- package/dist/src/utils/output-format.d.ts +1 -1
- package/dist/src/utils/output-format.js +12 -206
- package/dist/src/utils/shell-security.d.ts +1 -1
- package/dist/src/utils/shell-security.js +1 -138
- package/dist/src/workflow-persistence.d.ts +1 -1
- package/dist/src/workflow-persistence.js +1 -224
- package/package.json +4 -4
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/src/card-state.d.ts.map +0 -1
- package/dist/src/card-state.js.map +0 -1
- package/dist/src/engine.d.ts.map +0 -1
- package/dist/src/engine.js.map +0 -1
- package/dist/src/failure.d.ts.map +0 -1
- package/dist/src/failure.js.map +0 -1
- package/dist/src/file-lock.d.ts.map +0 -1
- package/dist/src/file-lock.js.map +0 -1
- package/dist/src/list-view.d.ts.map +0 -1
- package/dist/src/list-view.js.map +0 -1
- package/dist/src/mermaid.d.ts.map +0 -1
- package/dist/src/mermaid.js.map +0 -1
- package/dist/src/parent-task-sync.d.ts.map +0 -1
- package/dist/src/parent-task-sync.js.map +0 -1
- package/dist/src/retry-policy.d.ts.map +0 -1
- package/dist/src/retry-policy.js.map +0 -1
- package/dist/src/run-manager.d.ts.map +0 -1
- package/dist/src/run-manager.js.map +0 -1
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js.map +0 -1
- package/dist/src/utils/output-format.d.ts.map +0 -1
- package/dist/src/utils/output-format.js.map +0 -1
- package/dist/src/utils/shell-security.d.ts.map +0 -1
- package/dist/src/utils/shell-security.js.map +0 -1
- package/dist/src/workflow-persistence.d.ts.map +0 -1
- package/dist/src/workflow-persistence.js.map +0 -1
package/dist/src/failure.js
CHANGED
|
@@ -1,122 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getStableCauseMessage = getStableCauseMessage;
|
|
4
|
-
exports.createWorkflowFailureError = createWorkflowFailureError;
|
|
5
|
-
exports.getWorkflowFailureCode = getWorkflowFailureCode;
|
|
6
|
-
exports.classifyWorkflowFailure = classifyWorkflowFailure;
|
|
7
|
-
exports.buildNodeFailure = buildNodeFailure;
|
|
8
|
-
exports.buildEvidencePreview = buildEvidencePreview;
|
|
9
|
-
exports.sanitizeLocalRunError = sanitizeLocalRunError;
|
|
10
|
-
exports.readNodeAttempt = readNodeAttempt;
|
|
11
|
-
const sdk_1 = require("@crewx/sdk");
|
|
12
|
-
const STABLE_CAUSE_MESSAGES = {
|
|
13
|
-
CLI_UNRESOLVABLE: 'CrewX CLI executable could not be resolved.',
|
|
14
|
-
SPAWN_FAILED: 'The node process could not be started.',
|
|
15
|
-
NODE_TIMEOUT: 'The node execution exceeded its timeout.',
|
|
16
|
-
NODE_EXIT_NONZERO: 'The node process exited with a non-zero status.',
|
|
17
|
-
OUTPUT_INVALID: 'The node output did not match the required format.',
|
|
18
|
-
CONFIG_INVALID: 'The workflow node configuration is invalid.',
|
|
19
|
-
INTERRUPTED: 'The node execution was interrupted.',
|
|
20
|
-
CANCELLED: 'The workflow run was cancelled.',
|
|
21
|
-
UNKNOWN: 'The node execution failed.',
|
|
22
|
-
};
|
|
23
|
-
const PERSISTED_FAILURE_CODES = new Set(Object.keys(STABLE_CAUSE_MESSAGES));
|
|
24
|
-
function getStableCauseMessage(code) {
|
|
25
|
-
return STABLE_CAUSE_MESSAGES[code];
|
|
26
|
-
}
|
|
27
|
-
function createWorkflowFailureError(code, message) {
|
|
28
|
-
const error = new Error(message);
|
|
29
|
-
error.code = code;
|
|
30
|
-
return error;
|
|
31
|
-
}
|
|
32
|
-
function getWorkflowFailureCode(error) {
|
|
33
|
-
if (!error || typeof error !== 'object')
|
|
34
|
-
return undefined;
|
|
35
|
-
const code = error.code;
|
|
36
|
-
return typeof code === 'string' && PERSISTED_FAILURE_CODES.has(code)
|
|
37
|
-
? code
|
|
38
|
-
: undefined;
|
|
39
|
-
}
|
|
40
|
-
function classifyWorkflowFailure(input) {
|
|
41
|
-
const typedCode = input.errorCode;
|
|
42
|
-
if (typedCode === 'CLI_UNRESOLVABLE')
|
|
43
|
-
return 'CLI_UNRESOLVABLE';
|
|
44
|
-
if (typedCode === 'CONFIG_INVALID')
|
|
45
|
-
return 'CONFIG_INVALID';
|
|
46
|
-
if (typedCode === 'OUTPUT_INVALID')
|
|
47
|
-
return 'OUTPUT_INVALID';
|
|
48
|
-
if (typedCode === 'CANCELLED')
|
|
49
|
-
return 'CANCELLED';
|
|
50
|
-
if (typedCode === 'INTERRUPTED')
|
|
51
|
-
return 'INTERRUPTED';
|
|
52
|
-
if (typedCode === 'UNKNOWN')
|
|
53
|
-
return 'UNKNOWN';
|
|
54
|
-
const processResult = input.process;
|
|
55
|
-
if (!processResult)
|
|
56
|
-
return 'UNKNOWN';
|
|
57
|
-
if (processResult.errorOrigin === 'spawn')
|
|
58
|
-
return 'SPAWN_FAILED';
|
|
59
|
-
if (processResult.timedOut)
|
|
60
|
-
return 'NODE_TIMEOUT';
|
|
61
|
-
if (processResult.signal !== null)
|
|
62
|
-
return 'INTERRUPTED';
|
|
63
|
-
if (processResult.errorOrigin === 'post_spawn' || processResult.errorOrigin === 'stdin') {
|
|
64
|
-
return 'UNKNOWN';
|
|
65
|
-
}
|
|
66
|
-
if (typeof processResult.status === 'number' && processResult.status !== 0) {
|
|
67
|
-
return 'NODE_EXIT_NONZERO';
|
|
68
|
-
}
|
|
69
|
-
return 'UNKNOWN';
|
|
70
|
-
}
|
|
71
|
-
function buildNodeFailure(input) {
|
|
72
|
-
const exitCode = input.causeCode === 'NODE_EXIT_NONZERO' && typeof input.exitCode === 'number'
|
|
73
|
-
? input.exitCode
|
|
74
|
-
: null;
|
|
75
|
-
const signal = input.causeCode === 'INTERRUPTED' ? input.signal : null;
|
|
76
|
-
return {
|
|
77
|
-
failedNode: input.failedNode,
|
|
78
|
-
attempt: input.attempt,
|
|
79
|
-
causeCode: input.causeCode,
|
|
80
|
-
causeMessage: getStableCauseMessage(input.causeCode),
|
|
81
|
-
exitCode,
|
|
82
|
-
evidencePreview: buildEvidencePreview({
|
|
83
|
-
causeCode: input.causeCode,
|
|
84
|
-
exitCode,
|
|
85
|
-
signal,
|
|
86
|
-
errorOrigin: input.errorOrigin,
|
|
87
|
-
timedOut: input.timedOut ?? false,
|
|
88
|
-
}),
|
|
89
|
-
occurredAt: input.occurredAt ?? new Date().toISOString(),
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
function buildEvidencePreview(input) {
|
|
93
|
-
switch (input.causeCode) {
|
|
94
|
-
case 'NODE_EXIT_NONZERO':
|
|
95
|
-
return typeof input.exitCode === 'number' ? `exit code: ${input.exitCode}` : null;
|
|
96
|
-
case 'NODE_TIMEOUT':
|
|
97
|
-
return input.timedOut ? 'timeout' : null;
|
|
98
|
-
case 'SPAWN_FAILED':
|
|
99
|
-
return input.errorOrigin === 'spawn' ? 'origin: spawn' : null;
|
|
100
|
-
case 'INTERRUPTED':
|
|
101
|
-
return input.signal === null ? null : `signal: ${input.signal}`;
|
|
102
|
-
case 'UNKNOWN':
|
|
103
|
-
return input.errorOrigin === 'post_spawn' || input.errorOrigin === 'stdin'
|
|
104
|
-
? `origin: ${input.errorOrigin}`
|
|
105
|
-
: null;
|
|
106
|
-
default:
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function sanitizeLocalRunError(raw, fallback) {
|
|
111
|
-
try {
|
|
112
|
-
return (0, sdk_1.redactTechnicalMessage)(raw) ?? fallback;
|
|
113
|
-
}
|
|
114
|
-
catch {
|
|
115
|
-
return fallback;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
function readNodeAttempt(run, nodeId) {
|
|
119
|
-
const attempt = run.node_attempts?.[nodeId];
|
|
120
|
-
return typeof attempt === 'number' && Number.isInteger(attempt) && attempt > 0 ? attempt : 1;
|
|
121
|
-
}
|
|
122
|
-
//# sourceMappingURL=failure.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getStableCauseMessage=n;exports.createWorkflowFailureError=d;exports.getWorkflowFailureCode=a;exports.classifyWorkflowFailure=c;exports.buildNodeFailure=N;exports.buildEvidencePreview=i;exports.sanitizeLocalRunError=l;exports.readNodeAttempt=E;const s=require("@crewx/sdk");const o={CLI_UNRESOLVABLE:"CrewX CLI executable could not be resolved.",SPAWN_FAILED:"The node process could not be started.",NODE_TIMEOUT:"The node execution exceeded its timeout.",NODE_EXIT_NONZERO:"The node process exited with a non-zero status.",OUTPUT_INVALID:"The node output did not match the required format.",CONFIG_INVALID:"The workflow node configuration is invalid.",INTERRUPTED:"The node execution was interrupted.",CANCELLED:"The workflow run was cancelled.",UNKNOWN:"The node execution failed."};const u=new Set(Object.keys(o));function n(e){return o[e]}function d(e,r){const t=new Error(r);t.code=e;return t}function a(e){if(!e||typeof e!=="object")return void 0;const r=e.code;return typeof r==="string"&&u.has(r)?r:void 0}function c(e){const r=e.errorCode;if(r==="CLI_UNRESOLVABLE")return"CLI_UNRESOLVABLE";if(r==="CONFIG_INVALID")return"CONFIG_INVALID";if(r==="OUTPUT_INVALID")return"OUTPUT_INVALID";if(r==="CANCELLED")return"CANCELLED";if(r==="INTERRUPTED")return"INTERRUPTED";if(r==="UNKNOWN")return"UNKNOWN";const t=e.process;if(!t)return"UNKNOWN";if(t.errorOrigin==="spawn")return"SPAWN_FAILED";if(t.timedOut)return"NODE_TIMEOUT";if(t.signal!==null)return"INTERRUPTED";if(t.errorOrigin==="post_spawn"||t.errorOrigin==="stdin"){return"UNKNOWN"}if(typeof t.status==="number"&&t.status!==0){return"NODE_EXIT_NONZERO"}return"UNKNOWN"}function N(e){const r=e.causeCode==="NODE_EXIT_NONZERO"&&typeof e.exitCode==="number"?e.exitCode:null;const t=e.causeCode==="INTERRUPTED"?e.signal:null;return{failedNode:e.failedNode,attempt:e.attempt,causeCode:e.causeCode,causeMessage:n(e.causeCode),exitCode:r,evidencePreview:i({causeCode:e.causeCode,exitCode:r,signal:t,errorOrigin:e.errorOrigin,timedOut:e.timedOut??false}),occurredAt:e.occurredAt??new Date().toISOString()}}function i(e){switch(e.causeCode){case"NODE_EXIT_NONZERO":return typeof e.exitCode==="number"?`exit code: ${e.exitCode}`:null;case"NODE_TIMEOUT":return e.timedOut?"timeout":null;case"SPAWN_FAILED":return e.errorOrigin==="spawn"?"origin: spawn":null;case"INTERRUPTED":return e.signal===null?null:`signal: ${e.signal}`;case"UNKNOWN":return e.errorOrigin==="post_spawn"||e.errorOrigin==="stdin"?`origin: ${e.errorOrigin}`:null;default:return null}}function l(e,r){try{return(0,s.redactTechnicalMessage)(e)??r}catch{return r}}function E(e,r){const t=e.node_attempts?.[r];return typeof t==="number"&&Number.isInteger(t)&&t>0?t:1}
|
package/dist/src/file-lock.d.ts
CHANGED
package/dist/src/file-lock.js
CHANGED
|
@@ -1,97 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.FileLock = void 0;
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const DEFAULT_TIMEOUT_MS = 10000;
|
|
39
|
-
const RETRY_INTERVAL_MS = 50;
|
|
40
|
-
const STALE_THRESHOLD_MS = 30000;
|
|
41
|
-
class FileLock {
|
|
42
|
-
constructor(filePath) {
|
|
43
|
-
this.lockDir = filePath + '.lock';
|
|
44
|
-
}
|
|
45
|
-
acquire(timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
46
|
-
const deadline = Date.now() + timeoutMs;
|
|
47
|
-
while (Date.now() < deadline) {
|
|
48
|
-
try {
|
|
49
|
-
fs.mkdirSync(this.lockDir);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
catch (e) {
|
|
53
|
-
if (e.code !== 'EEXIST')
|
|
54
|
-
throw e;
|
|
55
|
-
this.removeIfStale();
|
|
56
|
-
const until = Date.now() + RETRY_INTERVAL_MS + Math.random() * RETRY_INTERVAL_MS;
|
|
57
|
-
while (Date.now() < until) { }
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
throw new Error(`FileLock timeout after ${timeoutMs}ms: ${this.lockDir}`);
|
|
61
|
-
}
|
|
62
|
-
async acquireAsync(timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
63
|
-
const deadline = Date.now() + timeoutMs;
|
|
64
|
-
while (Date.now() < deadline) {
|
|
65
|
-
try {
|
|
66
|
-
fs.mkdirSync(this.lockDir);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
if (e.code !== 'EEXIST')
|
|
71
|
-
throw e;
|
|
72
|
-
this.removeIfStale();
|
|
73
|
-
await new Promise(resolve => setTimeout(resolve, RETRY_INTERVAL_MS + Math.random() * RETRY_INTERVAL_MS));
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
throw new Error(`FileLock timeout after ${timeoutMs}ms: ${this.lockDir}`);
|
|
77
|
-
}
|
|
78
|
-
release() {
|
|
79
|
-
try {
|
|
80
|
-
fs.rmdirSync(this.lockDir);
|
|
81
|
-
}
|
|
82
|
-
catch {
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
removeIfStale() {
|
|
86
|
-
try {
|
|
87
|
-
const stat = fs.statSync(this.lockDir);
|
|
88
|
-
if (Date.now() - stat.mtimeMs > STALE_THRESHOLD_MS) {
|
|
89
|
-
fs.rmdirSync(this.lockDir);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
catch {
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
exports.FileLock = FileLock;
|
|
97
|
-
//# sourceMappingURL=file-lock.js.map
|
|
1
|
+
"use strict";var l=exports&&exports.__createBinding||(Object.create?(function(n,e,i,t){if(t===void 0)t=i;var r=Object.getOwnPropertyDescriptor(e,i);if(!r||("get"in r?!e.__esModule:r.writable||r.configurable)){r={enumerable:true,get:function(){return e[i]}}}Object.defineProperty(n,t,r)}):(function(n,e,i,t){if(t===void 0)t=i;n[t]=e[i]}));var u=exports&&exports.__setModuleDefault||(Object.create?(function(n,e){Object.defineProperty(n,"default",{enumerable:true,value:e})}):function(n,e){n["default"]=e});var s=exports&&exports.__importStar||(function(){var n=function(e){n=Object.getOwnPropertyNames||function(i){var t=[];for(var r in i)if(Object.prototype.hasOwnProperty.call(i,r))t[t.length]=r;return t};return n(e)};return function(e){if(e&&e.__esModule)return e;var i={};if(e!=null){for(var t=n(e),r=0;r<t.length;r++)if(t[r]!=="default")l(i,e,t[r])}u(i,e);return i}})();Object.defineProperty(exports,"__esModule",{value:true});exports.FileLock=void 0;const c=s(require("fs"));const a=1e4;const o=50;const f=3e4;class h{constructor(e){this.lockDir=e+".lock"}acquire(e=a){const i=Date.now()+e;while(Date.now()<i){try{c.mkdirSync(this.lockDir);return}catch(t){if(t.code!=="EEXIST")throw t;this.removeIfStale();const r=Date.now()+o+Math.random()*o;while(Date.now()<r){}}}throw new Error(`FileLock timeout after ${e}ms: ${this.lockDir}`)}async acquireAsync(e=a){const i=Date.now()+e;while(Date.now()<i){try{c.mkdirSync(this.lockDir);return}catch(t){if(t.code!=="EEXIST")throw t;this.removeIfStale();await new Promise(r=>setTimeout(r,o+Math.random()*o))}}throw new Error(`FileLock timeout after ${e}ms: ${this.lockDir}`)}release(){try{c.rmdirSync(this.lockDir)}catch{}}removeIfStale(){try{const e=c.statSync(this.lockDir);if(Date.now()-e.mtimeMs>f){c.rmdirSync(this.lockDir)}}catch{}}}exports.FileLock=h;
|
package/dist/src/list-view.d.ts
CHANGED
package/dist/src/list-view.js
CHANGED
|
@@ -1,188 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.loadWorkflowDirectory = loadWorkflowDirectory;
|
|
37
|
-
exports.loadWorkflowPaths = loadWorkflowPaths;
|
|
38
|
-
exports.readWorkflowConfig = readWorkflowConfig;
|
|
39
|
-
exports.readWorkflowList = readWorkflowList;
|
|
40
|
-
exports.createWorkflowListPromptResolver = createWorkflowListPromptResolver;
|
|
41
|
-
exports.formatWorkflowList = formatWorkflowList;
|
|
42
|
-
const fs = __importStar(require("fs"));
|
|
43
|
-
const path = __importStar(require("path"));
|
|
44
|
-
const yaml = __importStar(require("js-yaml"));
|
|
45
|
-
const knowledge_core_1 = require("@crewx/knowledge-core");
|
|
46
|
-
const GIT_ROOT_ENV_KEYS = new Set([
|
|
47
|
-
'GIT_DIR',
|
|
48
|
-
'GIT_WORK_TREE',
|
|
49
|
-
'GIT_COMMON_DIR',
|
|
50
|
-
'GIT_CEILING_DIRECTORIES',
|
|
51
|
-
'GIT_DISCOVERY_ACROSS_FILESYSTEM',
|
|
52
|
-
]);
|
|
53
|
-
function hasGitRootOverride(env) {
|
|
54
|
-
return Object.keys(env).some(key => GIT_ROOT_ENV_KEYS.has(key));
|
|
55
|
-
}
|
|
56
|
-
function loadWorkflowDirectory(dir) {
|
|
57
|
-
if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory()) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
const files = fs.readdirSync(dir).filter(f => f.endsWith('.yaml') || f.endsWith('.yml'));
|
|
61
|
-
const workflows = [];
|
|
62
|
-
for (const file of files) {
|
|
63
|
-
const filePath = path.join(dir, file);
|
|
64
|
-
try {
|
|
65
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
66
|
-
const doc = yaml.load(content);
|
|
67
|
-
if (!doc?.workflows || typeof doc.workflows !== 'object')
|
|
68
|
-
continue;
|
|
69
|
-
for (const [id, spec] of Object.entries(doc.workflows)) {
|
|
70
|
-
workflows.push({ id, filePath, spec });
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
catch {
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return workflows;
|
|
77
|
-
}
|
|
78
|
-
function loadWorkflowPaths(paths, cwd) {
|
|
79
|
-
const all = [];
|
|
80
|
-
const seenIds = new Set();
|
|
81
|
-
for (const dir of paths) {
|
|
82
|
-
const absDir = path.resolve(cwd, dir);
|
|
83
|
-
const workflows = loadWorkflowDirectory(absDir);
|
|
84
|
-
if (!workflows)
|
|
85
|
-
continue;
|
|
86
|
-
for (const wf of workflows) {
|
|
87
|
-
if (!seenIds.has(wf.id)) {
|
|
88
|
-
seenIds.add(wf.id);
|
|
89
|
-
all.push(wf);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return all;
|
|
94
|
-
}
|
|
95
|
-
function readWorkflowConfig(configPath) {
|
|
96
|
-
try {
|
|
97
|
-
const raw = fs.readFileSync(configPath, 'utf8');
|
|
98
|
-
const config = yaml.load(raw);
|
|
99
|
-
const settings = config?.settings;
|
|
100
|
-
const wf = settings?.workflow ?? {};
|
|
101
|
-
return { paths: wf.paths ?? ['workflows'] };
|
|
102
|
-
}
|
|
103
|
-
catch {
|
|
104
|
-
return { paths: ['workflows'] };
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
function readWorkflowList(options) {
|
|
108
|
-
const configPath = path.resolve(options.cwd, options.env.CREWX_CONFIG ?? options.configPath ?? 'crewx.yaml');
|
|
109
|
-
const { paths } = readWorkflowConfig(configPath);
|
|
110
|
-
return { paths, workflows: loadWorkflowPaths(paths, options.cwd) };
|
|
111
|
-
}
|
|
112
|
-
function createWorkflowListPromptResolver(configPath) {
|
|
113
|
-
const hostCwd = process.cwd();
|
|
114
|
-
return (argv, ctx) => {
|
|
115
|
-
if (argv.length !== 3 || argv[0] !== 'crewx' || argv[1] !== 'workflow' || argv[2] !== 'list')
|
|
116
|
-
return undefined;
|
|
117
|
-
const hostPath = ctx.cwd === hostCwd ? configPath : undefined;
|
|
118
|
-
if (ctx.env.CREWX_CONFIG === '')
|
|
119
|
-
return undefined;
|
|
120
|
-
if (!ctx.env.CREWX_CONFIG) {
|
|
121
|
-
if (hostPath && path.resolve(ctx.cwd, hostPath) !== path.resolve(ctx.cwd, 'crewx.yaml'))
|
|
122
|
-
return undefined;
|
|
123
|
-
if (hasGitRootOverride(ctx.env))
|
|
124
|
-
return undefined;
|
|
125
|
-
if (!fs.existsSync(path.join(ctx.cwd, '.git'))) {
|
|
126
|
-
let parent = path.dirname(ctx.cwd);
|
|
127
|
-
while (parent !== path.dirname(parent)) {
|
|
128
|
-
if (fs.existsSync(path.join(parent, '.git')))
|
|
129
|
-
return undefined;
|
|
130
|
-
parent = path.dirname(parent);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
if (!ctx.env.CREWX_CONFIG && !hostPath && !fs.existsSync(path.resolve(ctx.cwd, 'crewx.yaml')))
|
|
135
|
-
return undefined;
|
|
136
|
-
return formatWorkflowList({ ...readWorkflowList({ ...ctx, configPath: hostPath }), jsonMode: false }) + '\n';
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
function formatWorkflowList({ paths, workflows, jsonMode }) {
|
|
140
|
-
const lines = [];
|
|
141
|
-
if (workflows.length === 0) {
|
|
142
|
-
const msg = `No workflow YAML files found in: ${paths.join(', ')}`;
|
|
143
|
-
if (jsonMode) {
|
|
144
|
-
lines.push(JSON.stringify({ success: true, message: msg, workflows: [] }));
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
lines.push(`\u2139\uFE0F ${msg}`);
|
|
148
|
-
}
|
|
149
|
-
return lines.join('\n');
|
|
150
|
-
}
|
|
151
|
-
if (jsonMode) {
|
|
152
|
-
lines.push(JSON.stringify({
|
|
153
|
-
success: true,
|
|
154
|
-
workflows: workflows.map(wf => {
|
|
155
|
-
const meta = wf.spec.metadata ?? {};
|
|
156
|
-
const nodeCount = wf.spec.nodes ? Object.keys(wf.spec.nodes).length : 0;
|
|
157
|
-
return {
|
|
158
|
-
id: wf.id,
|
|
159
|
-
name: meta.name ?? wf.id,
|
|
160
|
-
description: meta.description ?? '',
|
|
161
|
-
node_count: nodeCount,
|
|
162
|
-
file: wf.filePath,
|
|
163
|
-
};
|
|
164
|
-
}),
|
|
165
|
-
}, null, 2));
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
lines.push('📋 Workflows');
|
|
169
|
-
workflows.forEach((wf, i) => {
|
|
170
|
-
const meta = wf.spec.metadata ?? {};
|
|
171
|
-
const nodeCount = wf.spec.nodes ? Object.keys(wf.spec.nodes).length : 0;
|
|
172
|
-
const descLine = meta.description ? `\n \uD83D\uDCDD ${meta.description.trim().split('\n')[0]}` : '';
|
|
173
|
-
lines.push(` ${i + 1}. ${wf.id} \u2014 ${meta.name ?? wf.id} (${nodeCount} nodes)\n \uD83D\uDCC1 ${wf.filePath}${descLine}`);
|
|
174
|
-
});
|
|
175
|
-
const listCtx = {
|
|
176
|
-
commandId: 'workflow.list',
|
|
177
|
-
params: {},
|
|
178
|
-
resultIds: workflows.slice(0, 3).map(w => w.id),
|
|
179
|
-
resultCount: workflows.length,
|
|
180
|
-
};
|
|
181
|
-
const listActions = (0, knowledge_core_1.generateNextActions)(listCtx);
|
|
182
|
-
const listBlock = (0, knowledge_core_1.formatActions)(listActions);
|
|
183
|
-
if (listBlock)
|
|
184
|
-
lines.push(listBlock);
|
|
185
|
-
}
|
|
186
|
-
return lines.join('\n');
|
|
187
|
-
}
|
|
188
|
-
//# sourceMappingURL=list-view.js.map
|
|
1
|
+
"use strict";var v=exports&&exports.__createBinding||(Object.create?(function(r,n,o,e){if(e===void 0)e=o;var t=Object.getOwnPropertyDescriptor(n,o);if(!t||("get"in t?!n.__esModule:t.writable||t.configurable)){t={enumerable:true,get:function(){return n[o]}}}Object.defineProperty(r,e,t)}):(function(r,n,o,e){if(e===void 0)e=o;r[e]=n[o]}));var I=exports&&exports.__setModuleDefault||(Object.create?(function(r,n){Object.defineProperty(r,"default",{enumerable:true,value:n})}):function(r,n){r["default"]=n});var d=exports&&exports.__importStar||(function(){var r=function(n){r=Object.getOwnPropertyNames||function(o){var e=[];for(var t in o)if(Object.prototype.hasOwnProperty.call(o,t))e[e.length]=t;return e};return r(n)};return function(n){if(n&&n.__esModule)return n;var o={};if(n!=null){for(var e=r(n),t=0;t<e.length;t++)if(e[t]!=="default")v(o,n,e[t])}I(o,n);return o}})();Object.defineProperty(exports,"__esModule",{value:true});exports.loadWorkflowDirectory=_;exports.loadWorkflowPaths=p;exports.readWorkflowConfig=y;exports.readWorkflowList=O;exports.createWorkflowListPromptResolver=j;exports.formatWorkflowList=g;const u=d(require("fs"));const f=d(require("path"));const w=d(require("js-yaml"));const h=require("@crewx/knowledge-core");const S=new Set(["GIT_DIR","GIT_WORK_TREE","GIT_COMMON_DIR","GIT_CEILING_DIRECTORIES","GIT_DISCOVERY_ACROSS_FILESYSTEM"]);function W(r){return Object.keys(r).some(n=>S.has(n))}function _(r){if(!u.existsSync(r)||!u.statSync(r).isDirectory()){return null}const n=u.readdirSync(r).filter(e=>e.endsWith(".yaml")||e.endsWith(".yml"));const o=[];for(const e of n){const t=f.join(r,e);try{const s=u.readFileSync(t,"utf-8");const c=w.load(s);if(!c?.workflows||typeof c.workflows!=="object")continue;for(const[i,l]of Object.entries(c.workflows)){o.push({id:i,filePath:t,spec:l})}}catch{}}return o}function p(r,n){const o=[];const e=new Set;for(const t of r){const s=f.resolve(n,t);const c=_(s);if(!c)continue;for(const i of c){if(!e.has(i.id)){e.add(i.id);o.push(i)}}}return o}function y(r){try{const n=u.readFileSync(r,"utf8");const o=w.load(n);const e=o?.settings;const t=e?.workflow??{};return{paths:t.paths??["workflows"]}}catch{return{paths:["workflows"]}}}function O(r){const n=f.resolve(r.cwd,r.env.CREWX_CONFIG??r.configPath??"crewx.yaml");const{paths:o}=y(n);return{paths:o,workflows:p(o,r.cwd)}}function j(r){const n=process.cwd();return(o,e)=>{if(o.length!==3||o[0]!=="crewx"||o[1]!=="workflow"||o[2]!=="list")return void 0;const t=e.cwd===n?r:void 0;if(e.env.CREWX_CONFIG==="")return void 0;if(!e.env.CREWX_CONFIG){if(t&&f.resolve(e.cwd,t)!==f.resolve(e.cwd,"crewx.yaml"))return void 0;if(W(e.env))return void 0;if(!u.existsSync(f.join(e.cwd,".git"))){let s=f.dirname(e.cwd);while(s!==f.dirname(s)){if(u.existsSync(f.join(s,".git")))return void 0;s=f.dirname(s)}}}if(!e.env.CREWX_CONFIG&&!t&&!u.existsSync(f.resolve(e.cwd,"crewx.yaml")))return void 0;return g({...O({...e,configPath:t}),jsonMode:false})+"\n"}}function g({paths:r,workflows:n,jsonMode:o}){const e=[];if(n.length===0){const t=`No workflow YAML files found in: ${r.join(", ")}`;if(o){e.push(JSON.stringify({success:true,message:t,workflows:[]}))}else{e.push(`\u2139\uFE0F ${t}`)}return e.join("\n")}if(o){e.push(JSON.stringify({success:true,workflows:n.map(t=>{const s=t.spec.metadata??{};const c=t.spec.nodes?Object.keys(t.spec.nodes).length:0;return{id:t.id,name:s.name??t.id,description:s.description??"",node_count:c,file:t.filePath}})},null,2))}else{e.push("\u{1F4CB} Workflows");n.forEach((i,l)=>{const a=i.spec.metadata??{};const m=i.spec.nodes?Object.keys(i.spec.nodes).length:0;const C=a.description?`
|
|
2
|
+
\u{1F4DD} ${a.description.trim().split("\n")[0]}`:"";e.push(` ${l+1}. ${i.id} \u2014 ${a.name??i.id} (${m} nodes)
|
|
3
|
+
\u{1F4C1} ${i.filePath}${C}`)});const t={commandId:"workflow.list",params:{},resultIds:n.slice(0,3).map(i=>i.id),resultCount:n.length};const s=(0,h.generateNextActions)(t);const c=(0,h.formatActions)(s);if(c)e.push(c)}return e.join("\n")}
|
package/dist/src/mermaid.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ import type { WorkflowSpec } from './types';
|
|
|
2
2
|
export declare function safeNodeId(nodeId: string): string;
|
|
3
3
|
export declare function escapeMermaidLabel(s: string): string;
|
|
4
4
|
export declare function toMermaid(spec: WorkflowSpec): string;
|
|
5
|
-
|
|
5
|
+
|
package/dist/src/mermaid.js
CHANGED
|
@@ -1,133 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
exports.safeNodeId = safeNodeId;
|
|
4
|
-
exports.escapeMermaidLabel = escapeMermaidLabel;
|
|
5
|
-
exports.toMermaid = toMermaid;
|
|
6
|
-
const MERMAID_RESERVED = new Set([
|
|
7
|
-
'end', 'subgraph', 'direction', 'click', 'style', 'classDef', 'class', 'linkStyle',
|
|
8
|
-
]);
|
|
9
|
-
function safeNodeId(nodeId) {
|
|
10
|
-
return MERMAID_RESERVED.has(nodeId) ? `node_${nodeId}` : nodeId;
|
|
11
|
-
}
|
|
12
|
-
function escapeMermaidLabel(s) {
|
|
13
|
-
return s
|
|
14
|
-
.replace(/"/g, '#quot;')
|
|
15
|
-
.replace(/</g, '#lt;')
|
|
16
|
-
.replace(/>/g, '#gt;')
|
|
17
|
-
.replace(/\{/g, '#123;')
|
|
18
|
-
.replace(/\}/g, '#125;')
|
|
19
|
-
.replace(/`/g, '#96;')
|
|
20
|
-
.slice(0, 50);
|
|
21
|
-
}
|
|
22
|
-
function buildLabel(nodeId, node) {
|
|
23
|
-
if (node.type === 'end')
|
|
24
|
-
return 'END';
|
|
25
|
-
if (node.type === 'error')
|
|
26
|
-
return 'ERROR';
|
|
27
|
-
let subtitle = '';
|
|
28
|
-
if (node.agent) {
|
|
29
|
-
subtitle = `@${escapeMermaidLabel(node.agent)}`;
|
|
30
|
-
}
|
|
31
|
-
else if (node.type === 'skill_task' && node.skill) {
|
|
32
|
-
subtitle = `skill:${escapeMermaidLabel(node.skill)}`;
|
|
33
|
-
}
|
|
34
|
-
else if (node.type === 'shell_task' && node.command && node.command[0]) {
|
|
35
|
-
subtitle = `$ ${escapeMermaidLabel(node.command[0])}`;
|
|
36
|
-
}
|
|
37
|
-
const desc = node.description ?? node.input?.split('\n')[0]?.trim() ?? '';
|
|
38
|
-
const escapedDesc = escapeMermaidLabel(desc);
|
|
39
|
-
const idPart = subtitle
|
|
40
|
-
? `${escapeMermaidLabel(nodeId)}(${subtitle})`
|
|
41
|
-
: escapeMermaidLabel(nodeId);
|
|
42
|
-
if (!escapedDesc || escapedDesc === escapeMermaidLabel(nodeId)) {
|
|
43
|
-
return `*${idPart}*`;
|
|
44
|
-
}
|
|
45
|
-
return `*${idPart}*\n${escapedDesc}`;
|
|
46
|
-
}
|
|
47
|
-
function wrapShape(nodeId, label, type) {
|
|
48
|
-
const safe = safeNodeId(nodeId);
|
|
49
|
-
if (type === 'end' || type === 'error') {
|
|
50
|
-
return `${safe}(("${label}"))`;
|
|
51
|
-
}
|
|
52
|
-
const q = `"\`${label}\`"`;
|
|
53
|
-
switch (type) {
|
|
54
|
-
case 'branch':
|
|
55
|
-
return `${safe}{${q}}`;
|
|
56
|
-
case 'expression':
|
|
57
|
-
return `${safe}{{${q}}}`;
|
|
58
|
-
case 'parallel':
|
|
59
|
-
return `${safe}[/${q}/]`;
|
|
60
|
-
case 'join':
|
|
61
|
-
return `${safe}[\\${q}\\]`;
|
|
62
|
-
case 'skill_task':
|
|
63
|
-
return `${safe}[[${q}]]`;
|
|
64
|
-
case 'shell_task':
|
|
65
|
-
return `${safe}[(${q})]`;
|
|
66
|
-
default:
|
|
67
|
-
return `${safe}[${q}]`;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
const NODE_STYLES = {
|
|
71
|
-
approval: 'fill:#e0f2fe,stroke:#93c5fd,color:#1e3a5f',
|
|
72
|
-
expression: 'fill:#fef3c7,stroke:#f59e0b,color:#78350f',
|
|
73
|
-
error: 'fill:#fee2e2,stroke:#f87171,color:#7f1d1d',
|
|
74
|
-
};
|
|
75
|
-
function toMermaid(spec) {
|
|
76
|
-
const lines = ['flowchart TD'];
|
|
77
|
-
const nodes = spec.nodes;
|
|
78
|
-
for (const [nodeId, node] of Object.entries(nodes)) {
|
|
79
|
-
const label = buildLabel(nodeId, node);
|
|
80
|
-
lines.push(` ${wrapShape(nodeId, label, node.type)}`);
|
|
81
|
-
}
|
|
82
|
-
lines.push('');
|
|
83
|
-
for (const [nodeId, node] of Object.entries(nodes)) {
|
|
84
|
-
const src = safeNodeId(nodeId);
|
|
85
|
-
if (node.next) {
|
|
86
|
-
lines.push(` ${src} --> ${safeNodeId(node.next)}`);
|
|
87
|
-
}
|
|
88
|
-
if (node.type === 'branch' && node.branches && !Array.isArray(node.branches)) {
|
|
89
|
-
for (const [condLabel, target] of Object.entries(node.branches)) {
|
|
90
|
-
const edgeLabel = escapeMermaidLabel(condLabel === 'true' ? 'Approve' : condLabel === 'false' ? 'Reject' : condLabel);
|
|
91
|
-
lines.push(` ${src} -->|${edgeLabel}| ${safeNodeId(target)}`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (node.type === 'parallel' && Array.isArray(node.branches)) {
|
|
95
|
-
for (const branchId of node.branches) {
|
|
96
|
-
lines.push(` ${src} --> ${safeNodeId(branchId)}`);
|
|
97
|
-
}
|
|
98
|
-
if (node.join) {
|
|
99
|
-
for (const branchId of node.branches) {
|
|
100
|
-
const branchNode = nodes[branchId];
|
|
101
|
-
if (!branchNode?.next) {
|
|
102
|
-
lines.push(` ${safeNodeId(branchId)} --> ${safeNodeId(node.join)}`);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
if (node.type === 'approval') {
|
|
108
|
-
if (node.on_approve) {
|
|
109
|
-
lines.push(` ${src} -->|${escapeMermaidLabel('Approve')}| ${safeNodeId(node.on_approve)}`);
|
|
110
|
-
}
|
|
111
|
-
if (node.on_reject) {
|
|
112
|
-
lines.push(` ${src} -->|${escapeMermaidLabel('Reject')}| ${safeNodeId(node.on_reject)}`);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
const nodesByType = new Map();
|
|
117
|
-
for (const [nodeId, node] of Object.entries(nodes)) {
|
|
118
|
-
const list = nodesByType.get(node.type) ?? [];
|
|
119
|
-
list.push(safeNodeId(nodeId));
|
|
120
|
-
nodesByType.set(node.type, list);
|
|
121
|
-
}
|
|
122
|
-
lines.push('');
|
|
123
|
-
for (const [type, style] of Object.entries(NODE_STYLES)) {
|
|
124
|
-
lines.push(` classDef ${type} ${style}`);
|
|
125
|
-
}
|
|
126
|
-
for (const [type, ids] of nodesByType) {
|
|
127
|
-
if (NODE_STYLES[type]) {
|
|
128
|
-
lines.push(` class ${ids.join(',')} ${type}`);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return lines.join('\n');
|
|
132
|
-
}
|
|
133
|
-
//# sourceMappingURL=mermaid.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.safeNodeId=o;exports.escapeMermaidLabel=a;exports.toMermaid=d;const u=new Set(["end","subgraph","direction","click","style","classDef","class","linkStyle"]);function o(c){return u.has(c)?`node_${c}`:c}function a(c){return c.replace(/"/g,"#quot;").replace(/</g,"#lt;").replace(/>/g,"#gt;").replace(/\{/g,"#123;").replace(/\}/g,"#125;").replace(/`/g,"#96;").slice(0,50)}function h(c,r){if(r.type==="end")return"END";if(r.type==="error")return"ERROR";let t="";if(r.agent){t=`@${a(r.agent)}`}else if(r.type==="skill_task"&&r.skill){t=`skill:${a(r.skill)}`}else if(r.type==="shell_task"&&r.command&&r.command[0]){t=`$ ${a(r.command[0])}`}const n=r.description??r.input?.split("\n")[0]?.trim()??"";const s=a(n);const e=t?`${a(c)}(${t})`:a(c);if(!s||s===a(c)){return`*${e}*`}return`*${e}*
|
|
2
|
+
${s}`}function b(c,r,t){const n=o(c);if(t==="end"||t==="error"){return`${n}(("${r}"))`}const s=`"\`${r}\`"`;switch(t){case"branch":return`${n}{${s}}`;case"expression":return`${n}{{${s}}}`;case"parallel":return`${n}[/${s}/]`;case"join":return`${n}[\\${s}\\]`;case"skill_task":return`${n}[[${s}]]`;case"shell_task":return`${n}[(${s})]`;default:return`${n}[${s}]`}}const p={approval:"fill:#e0f2fe,stroke:#93c5fd,color:#1e3a5f",expression:"fill:#fef3c7,stroke:#f59e0b,color:#78350f",error:"fill:#fee2e2,stroke:#f87171,color:#7f1d1d"};function d(c){const r=["flowchart TD"];const t=c.nodes;for(const[s,e]of Object.entries(t)){const i=h(s,e);r.push(` ${b(s,i,e.type)}`)}r.push("");for(const[s,e]of Object.entries(t)){const i=o(s);if(e.next){r.push(` ${i} --> ${o(e.next)}`)}if(e.type==="branch"&&e.branches&&!Array.isArray(e.branches)){for(const[l,f]of Object.entries(e.branches)){const $=a(l==="true"?"Approve":l==="false"?"Reject":l);r.push(` ${i} -->|${$}| ${o(f)}`)}}if(e.type==="parallel"&&Array.isArray(e.branches)){for(const l of e.branches){r.push(` ${i} --> ${o(l)}`)}if(e.join){for(const l of e.branches){const f=t[l];if(!f?.next){r.push(` ${o(l)} --> ${o(e.join)}`)}}}}if(e.type==="approval"){if(e.on_approve){r.push(` ${i} -->|${a("Approve")}| ${o(e.on_approve)}`)}if(e.on_reject){r.push(` ${i} -->|${a("Reject")}| ${o(e.on_reject)}`)}}}const n=new Map;for(const[s,e]of Object.entries(t)){const i=n.get(e.type)??[];i.push(o(s));n.set(e.type,i)}r.push("");for(const[s,e]of Object.entries(p)){r.push(` classDef ${s} ${e}`)}for(const[s,e]of n){if(p[s]){r.push(` class ${e.join(",")} ${s}`)}}return r.join("\n")}
|
|
@@ -136,4 +136,4 @@ export declare function previewWorkflowParentRepair(options: PreviewWorkflowPare
|
|
|
136
136
|
export declare function createWorkflowParentPersistSink(options: WorkflowParentPersistSinkOptions): (run: RunExecution) => WorkflowParentPersistResult;
|
|
137
137
|
export declare function reconcileWorkflowParentTasks(options: ReconcileWorkflowParentTasksOptions): WorkflowParentReconciliationResult;
|
|
138
138
|
export declare function reconcileWorkflowParentRunFiles(options: ReconcileWorkflowParentRunFilesOptions): WorkflowParentReconciliationResult;
|
|
139
|
-
|
|
139
|
+
|