@reopt-ai/opt-workflow 0.0.0-stage → 0.1.1
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/CHANGELOG.md +20 -0
- package/LICENSE +21 -0
- package/README.md +213 -2
- package/dist/ai-stream-APc3uCiQ.js +389 -0
- package/dist/ai-stream-B_lk9_Rf.cjs +628 -0
- package/dist/branch-resolver-BDi6Wu6m.js +589 -0
- package/dist/branch-resolver-D_wM183Q.cjs +714 -0
- package/dist/core-CtqBb-6v.d.cts +919 -0
- package/dist/core-z3nXmUBj.d.ts +919 -0
- package/dist/core.cjs +301 -0
- package/dist/core.d.cts +5 -0
- package/dist/core.d.ts +5 -0
- package/dist/core.js +184 -0
- package/dist/define-template-Bmn96lF_.cjs +74 -0
- package/dist/define-template-BvGNB5Tv.js +69 -0
- package/dist/end-node-ids-D6WBaCLm.cjs +109 -0
- package/dist/end-node-ids-p85jFEcP.js +86 -0
- package/dist/execution-context-DVeybULC.d.cts +258 -0
- package/dist/execution-context-YFTRCj0y.d.ts +258 -0
- package/dist/grid-workflow-dto-C86EArJP.d.cts +300 -0
- package/dist/grid-workflow-dto-C86EArJP.d.ts +300 -0
- package/dist/index.cjs +11899 -0
- package/dist/index.d.cts +803 -0
- package/dist/index.d.ts +803 -0
- package/dist/index.js +11852 -0
- package/dist/mock.cjs +7295 -0
- package/dist/mock.d.cts +88 -0
- package/dist/mock.d.ts +88 -0
- package/dist/mock.js +7287 -0
- package/dist/node-definitions-C-GMfjMm.js +797 -0
- package/dist/node-definitions-pS1Zp1dK.cjs +940 -0
- package/dist/nodes-D_a8ZkRp.d.cts +50 -0
- package/dist/nodes-myp8R2zo.d.ts +50 -0
- package/dist/nodes.cjs +36 -0
- package/dist/nodes.d.cts +3 -0
- package/dist/nodes.d.ts +3 -0
- package/dist/nodes.js +4 -0
- package/dist/shadcn-bridge.css +72 -0
- package/dist/simulate.cjs +6 -0
- package/dist/simulate.d.cts +111 -0
- package/dist/simulate.d.ts +111 -0
- package/dist/simulate.js +1 -0
- package/dist/step-type-for-node-Blf5DKrp.js +228 -0
- package/dist/step-type-for-node-D9sdHfWA.cjs +281 -0
- package/dist/styles.css +4 -0
- package/dist/test-executor-C2AvI73G.cjs +342 -0
- package/dist/test-executor-DpT3qXIT.js +313 -0
- package/dist/types-Bj0VWFny.d.cts +126 -0
- package/dist/types-C5744w6f.d.cts +184 -0
- package/dist/types-DQcmIuAl.d.ts +126 -0
- package/dist/types-dVHX2CyI.d.ts +184 -0
- package/dist/workflow-preview-B0kul6f-.js +1742 -0
- package/dist/workflow-preview-CZzXKXqK.cjs +2065 -0
- package/package.json +119 -4
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Y as NodeOutputField, _ as GridStep, p as GridConnection, v as GridStepType, y as GridWorkflowDefinition } from "./grid-workflow-dto-C86EArJP.cjs";
|
|
2
|
+
/** 서버가 넘기는 런 한 건의 최소 표본 — 입력·출력은 싣지 않는다(크고, 세는 데 필요 없다). */
|
|
3
|
+
type RunStepSample = {
|
|
4
|
+
steps: {
|
|
5
|
+
stepId: string;
|
|
6
|
+
status: string;
|
|
7
|
+
startedAt?: string;
|
|
8
|
+
duration?: number;
|
|
9
|
+
}[];
|
|
10
|
+
};
|
|
11
|
+
type StepMetric = {
|
|
12
|
+
/** 이 스텝이 실제로 시작된 런 수 */
|
|
13
|
+
entered: number;
|
|
14
|
+
completed: number;
|
|
15
|
+
failed: number;
|
|
16
|
+
/** 끝난(완료·실패) 실행의 평균 소요(ms). 소요 기록이 하나도 없으면 null */
|
|
17
|
+
averageDurationMs: number | null;
|
|
18
|
+
};
|
|
19
|
+
type WorkflowStepMetrics = {
|
|
20
|
+
/** 집계에 쓴 런 수(종결된 런만) */
|
|
21
|
+
runCount: number;
|
|
22
|
+
steps: Map<string, StepMetric>;
|
|
23
|
+
/** 연결 id → 지나간 런 수 */
|
|
24
|
+
connections: Map<string, number>;
|
|
25
|
+
};
|
|
26
|
+
declare function aggregateStepMetrics({ steps, connections, runs }: {
|
|
27
|
+
steps: readonly GridStep[];
|
|
28
|
+
connections: readonly GridConnection[];
|
|
29
|
+
runs: readonly RunStepSample[];
|
|
30
|
+
}): WorkflowStepMetrics;
|
|
31
|
+
/** 분모가 0이면 비율은 없다(0%가 아니다). */
|
|
32
|
+
declare function formatShare(part: number, whole: number): string | null;
|
|
33
|
+
declare function formatDurationMs(ms: number): string;
|
|
34
|
+
/** engine/variable-resolver.ts 의 VARIABLE_PATTERN과 동일해야 한다 (테스트로 고정) */
|
|
35
|
+
declare const VARIABLE_TOKEN_PATTERN: RegExp;
|
|
36
|
+
type VariableTreeItem = {
|
|
37
|
+
/** 삽입할 전체 토큰 — 예: `{{customer.email}}`, `{{step-1.output.messageId}}` */
|
|
38
|
+
token: string;
|
|
39
|
+
label: string;
|
|
40
|
+
type: NodeOutputField["type"];
|
|
41
|
+
description?: string;
|
|
42
|
+
example?: string;
|
|
43
|
+
};
|
|
44
|
+
type VariableTreeGroup = {
|
|
45
|
+
id: string;
|
|
46
|
+
heading: string;
|
|
47
|
+
items: VariableTreeItem[];
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* 현재 스텝의 상류(조상) 스텝 목록 — 연결 그래프 역방향 BFS.
|
|
51
|
+
* 자기 자신은 제외하며, 그래프 순서(트리거에서 가까운 순)와 무관하게
|
|
52
|
+
* 방문 순서대로 반환한다.
|
|
53
|
+
*/
|
|
54
|
+
declare function getUpstreamSteps(currentStepId: string, steps: GridStep[], connections: GridConnection[]): GridStep[];
|
|
55
|
+
/** 출력 필드를 하위 경로까지 편다 — 픽커와 AI 에이전트 프롬프트가 같은 경로를 쓴다. */
|
|
56
|
+
declare function flattenFields(fields: NodeOutputField[], prefix: string): Array<NodeOutputField & {
|
|
57
|
+
path: string;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* 변수 픽커에 보여줄 그룹 목록.
|
|
61
|
+
* 그룹 순서: 트리거 페이로드 → 상류 스텝 출력(가까운 순) → 특수 변수.
|
|
62
|
+
*/
|
|
63
|
+
declare function buildVariableTree(params: {
|
|
64
|
+
currentStepId: string | null;
|
|
65
|
+
steps: GridStep[];
|
|
66
|
+
connections: GridConnection[];
|
|
67
|
+
extraGroups?: readonly VariableTreeGroup[];
|
|
68
|
+
}): VariableTreeGroup[];
|
|
69
|
+
type VariableRefIssue = {
|
|
70
|
+
token: string;
|
|
71
|
+
message: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* 문자열 config 값의 `{{stepId.output.*}}` 참조 중 상류에 없는 스텝을 가리키는
|
|
75
|
+
* 것을 찾는다 (스텝 삭제/재배선으로 깨진 참조의 정적 검출).
|
|
76
|
+
* 트리거 페이로드·런타임 변수 참조는 정적으로 판별할 수 없으므로 건드리지 않는다.
|
|
77
|
+
*/
|
|
78
|
+
declare function findBrokenStepRefs(value: string, params: {
|
|
79
|
+
currentStepId: string | null;
|
|
80
|
+
steps: GridStep[];
|
|
81
|
+
connections: GridConnection[];
|
|
82
|
+
}): VariableRefIssue[];
|
|
83
|
+
/**
|
|
84
|
+
* 나가는 연결을 여럿 가질 수 있는 스텝 — 조건은 분기 타입으로, 병렬은 브랜치로 갈래를
|
|
85
|
+
* 나눈다. 그 밖의 스텝은 실행기가 **첫 번째 연결만** 따라간다(`engine/graph-traversal.ts`).
|
|
86
|
+
* 에디터는 두 번째 연결을 막지 않으므로, 그린 연결이 조용히 무시되는 자리를 점검이 말해야 한다.
|
|
87
|
+
*/
|
|
88
|
+
declare const MULTI_OUTGOING_STEP_TYPES: ReadonlySet<GridStepType>;
|
|
89
|
+
type WorkflowPreflightIssue = {
|
|
90
|
+
id: string;
|
|
91
|
+
severity: "error" | "warning";
|
|
92
|
+
message: string;
|
|
93
|
+
stepId?: string;
|
|
94
|
+
target: "config" | "connections" | "canvas";
|
|
95
|
+
};
|
|
96
|
+
/** 임포트의 구조 검사와 목록의 설정 검사를 편집 중 정의에도 적용한다. */
|
|
97
|
+
declare function getWorkflowPreflight(definition: GridWorkflowDefinition): WorkflowPreflightIssue[];
|
|
98
|
+
type TemplateCategory = "all" | "basic" | "ai" | "marketing";
|
|
99
|
+
/**
|
|
100
|
+
* 템플릿 아이콘 키 — 카탈로그(`components/templates/template-catalog.tsx`)의
|
|
101
|
+
* iconMap이 이 union을 Record 키로 사용하므로, 키를 추가하면 카탈로그가
|
|
102
|
+
* 컴파일 에러로 매핑 누락을 강제한다 (조용한 PlusIcon 폴백 방지).
|
|
103
|
+
*/
|
|
104
|
+
type TemplateIconKey = "plus" | "mail" | "git-branch" | "calendar" | "sparkles" | "bot" | "clipboard-list" | "clipboard-check" | "route" | "webhook";
|
|
105
|
+
type TemplateMetadata = {
|
|
106
|
+
id: string;
|
|
107
|
+
name: string;
|
|
108
|
+
description: string;
|
|
109
|
+
category: TemplateCategory;
|
|
110
|
+
icon: TemplateIconKey;
|
|
111
|
+
featured?: boolean;
|
|
112
|
+
/** 카탈로그 정렬 가중치 (작을수록 먼저, 미지정은 뒤) */
|
|
113
|
+
order?: number;
|
|
114
|
+
/** 자유 태그 — 카테고리 외 부가 facet (예: "nurture", "ops") */
|
|
115
|
+
tags?: string[];
|
|
116
|
+
/** 트리거 노드 id — 정의에서 파생(작성자가 직접 쓰지 않음). 트리거 타입 facet용 */
|
|
117
|
+
triggerType?: string;
|
|
118
|
+
};
|
|
119
|
+
type TemplateDefinition = {
|
|
120
|
+
id: string;
|
|
121
|
+
definition: GridWorkflowDefinition;
|
|
122
|
+
};
|
|
123
|
+
type ExtendedWorkflowTemplate = TemplateMetadata & {
|
|
124
|
+
definition: GridWorkflowDefinition;
|
|
125
|
+
};
|
|
126
|
+
export { formatShare as S, RunStepSample as _, TemplateMetadata as a, aggregateStepMetrics as b, getWorkflowPreflight as c, VariableTreeGroup as d, VariableTreeItem as f, getUpstreamSteps as g, flattenFields as h, TemplateIconKey as i, VARIABLE_TOKEN_PATTERN as l, findBrokenStepRefs as m, TemplateCategory as n, MULTI_OUTGOING_STEP_TYPES as o, buildVariableTree as p, TemplateDefinition as r, WorkflowPreflightIssue as s, ExtendedWorkflowTemplate as t, VariableRefIssue as u, StepMetric as v, formatDurationMs as x, WorkflowStepMetrics as y };
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { _ as RunStepSample, d as VariableTreeGroup, s as WorkflowPreflightIssue, t as ExtendedWorkflowTemplate } from "./types-Bj0VWFny.cjs";
|
|
2
|
+
import { s as StepExecutionRecord } from "./execution-context-DVeybULC.cjs";
|
|
3
|
+
import { K as NodeConfigField, _ as GridStep, p as GridConnection, y as GridWorkflowDefinition } from "./grid-workflow-dto-C86EArJP.cjs";
|
|
4
|
+
import { ComponentType, ReactNode } from "react";
|
|
5
|
+
/**
|
|
6
|
+
* 알림 통로. 에디터의 훅·패널은 화면에 무엇을 띄울지 모르고 "무슨 일이 있었는지"만 말한다.
|
|
7
|
+
* 호스트가 `onNotify`를 주면 그쪽으로(스튜디오의 토스터 등), 안 주면 에디터가 자기 알림 줄에 그린다.
|
|
8
|
+
*
|
|
9
|
+
* 한 화면에 에디터가 여럿일 수 있다. 에디터의 훅과 패널은 **자기 에디터의 통로**(`createNoticeChannel`,
|
|
10
|
+
* `useWorkflowToast`)로 말한다 — 실행 완료처럼 늦게 오는 알림도 일을 시작한 에디터에 뜬다.
|
|
11
|
+
* 통로 없이 부르는 `toast`(에디터 밖의 호출)만 "지금 쓰고 있는 에디터"를 찾는다 — 포커스가 있는
|
|
12
|
+
* 에디터, 없으면 마지막으로 조작한 에디터.
|
|
13
|
+
*/
|
|
14
|
+
type WorkflowNoticeKind = "success" | "error" | "info" | "warning";
|
|
15
|
+
type WorkflowNotice = {
|
|
16
|
+
kind: WorkflowNoticeKind;
|
|
17
|
+
message: string;
|
|
18
|
+
/** 알림에 붙는 한 번짜리 동작(예: 되돌리기). */
|
|
19
|
+
action?: {
|
|
20
|
+
label: string;
|
|
21
|
+
onClick: () => void;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
type WorkflowNoticeSink = (notice: WorkflowNotice) => void;
|
|
25
|
+
type NoticeOptions = {
|
|
26
|
+
action?: WorkflowNotice["action"];
|
|
27
|
+
};
|
|
28
|
+
type WorkflowToast = Record<WorkflowNoticeKind, (message: string, options?: NoticeOptions) => void>;
|
|
29
|
+
/**
|
|
30
|
+
* 호스트 계약 — 에디터가 바깥 세계에 부탁하는 것 전부.
|
|
31
|
+
*
|
|
32
|
+
* 에디터는 저장소·실행 엔진·인증을 모른다. 필요한 일은 이 계약으로만 부탁하고, **없는 능력은
|
|
33
|
+
* 화면에서 사라진다**: `runner`가 없으면 실행·디버그가 없고(테스트 모드의 시뮬레이션은 남는다),
|
|
34
|
+
* `runs`가 없으면 누적 지표·런 재생이 없다. 호스트는 가진 것만 주면 된다.
|
|
35
|
+
*/
|
|
36
|
+
type WorkflowHost = {
|
|
37
|
+
/** 저장된 문서의 id. 아직 저장 전이면 없다 — 그동안 실행은 "먼저 저장" 안내가 된다. */
|
|
38
|
+
workflowId?: string;
|
|
39
|
+
/** 실행 — 시작·재개·이벤트 스트림. */
|
|
40
|
+
runner?: WorkflowRunner;
|
|
41
|
+
/** 지난 실행 조회 — 런 재생과 스텝별 누적 지표. */
|
|
42
|
+
runs?: WorkflowRunsSource;
|
|
43
|
+
/** 커스텀 설정 필드. 키는 `NodeFieldDefinition.type`(또는 `editorType`)이다. */
|
|
44
|
+
fields?: Readonly<Record<string, WorkflowFieldRenderer>>;
|
|
45
|
+
/** 빈 캔버스에서 고를 템플릿. */
|
|
46
|
+
templates?: readonly ExtendedWorkflowTemplate[];
|
|
47
|
+
/**
|
|
48
|
+
* 템플릿을 적용하기 직전에 스텝을 손본다(예: 지금 문서가 이미 고른 대상을 새 트리거에 옮긴다).
|
|
49
|
+
*/
|
|
50
|
+
prepareTemplate?: (template: ExtendedWorkflowTemplate, current: {
|
|
51
|
+
steps: readonly GridStep[];
|
|
52
|
+
}) => GridStep[];
|
|
53
|
+
/**
|
|
54
|
+
* 문서와 **함께 저장되는** 호스트 쪽 값(예: 소속). 에디터는 내용을 모르고, 값이 바뀌면
|
|
55
|
+
* "저장 안 됨"으로 보고 `onSave`의 세 번째 인자로 그대로 돌려준다. JSON으로 직렬화할 수
|
|
56
|
+
* 있어야 한다.
|
|
57
|
+
*/
|
|
58
|
+
saveContext?: unknown;
|
|
59
|
+
/**
|
|
60
|
+
* 호스트 확장 **훅**. 지금 그래프(와 편집 중인 설정)를 받아 변수·점검·안내를 더한다 —
|
|
61
|
+
* 트리거 설정에 따라 달라지는 변수(폼의 질문 목록 등)가 이 길로 들어온다.
|
|
62
|
+
*
|
|
63
|
+
* 🔴 훅이다. 참조가 렌더마다 바뀌면 안 된다(모듈 최상위 함수로 둘 것).
|
|
64
|
+
*/
|
|
65
|
+
useExtension?: (context: WorkflowExtensionContext) => WorkflowEditorExtension;
|
|
66
|
+
/** 알림을 호스트의 토스터로 보낸다. 없으면 에디터가 자기 알림 줄에 그린다. */
|
|
67
|
+
onNotify?: WorkflowNoticeSink;
|
|
68
|
+
/** 저장하지 않은 변경이 생기거나 사라질 때. 호스트 라우터의 이탈 확인에 쓴다. */
|
|
69
|
+
onDirtyChange?: (dirty: boolean) => void;
|
|
70
|
+
/** 표시 경로에서 손상된 정의를 빈 캔버스로 바꿔 읽었을 때 등, 사람이 볼 필요는 없는 사실. */
|
|
71
|
+
onDiagnostic?: (event: {
|
|
72
|
+
code: string;
|
|
73
|
+
detail?: unknown;
|
|
74
|
+
}) => void;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* 실행 이벤트 통로. 브라우저의 `EventSource`가 그대로 이 모양이다 — 서버 호스트는
|
|
78
|
+
* `new EventSource(url)`을 돌려주면 되고, 메모리 호스트는 같은 모양의 객체를 만든다.
|
|
79
|
+
* `onmessage`의 `data`는 `ExecutionEvent`의 JSON이다.
|
|
80
|
+
*/
|
|
81
|
+
type RunEventStream = {
|
|
82
|
+
onmessage: ((event: {
|
|
83
|
+
data: string;
|
|
84
|
+
}) => void) | null;
|
|
85
|
+
onerror: ((event?: unknown) => void) | null;
|
|
86
|
+
close: () => void;
|
|
87
|
+
};
|
|
88
|
+
type RunStartResult = {
|
|
89
|
+
ok: true;
|
|
90
|
+
runId: string;
|
|
91
|
+
} | {
|
|
92
|
+
ok: false;
|
|
93
|
+
error?: string;
|
|
94
|
+
};
|
|
95
|
+
type RunRequestResult = {
|
|
96
|
+
ok: true;
|
|
97
|
+
} | {
|
|
98
|
+
ok: false;
|
|
99
|
+
error?: string;
|
|
100
|
+
};
|
|
101
|
+
type WorkflowRunner = {
|
|
102
|
+
/** 실행 한 건을 예약하고 id를 받는다. 아직 돌지 않는다. */
|
|
103
|
+
start: (input: {
|
|
104
|
+
workflowId: string;
|
|
105
|
+
params?: Record<string, unknown>;
|
|
106
|
+
dryRun?: boolean;
|
|
107
|
+
}) => Promise<RunStartResult>;
|
|
108
|
+
/**
|
|
109
|
+
* 예약한 실행을 돌린다.
|
|
110
|
+
*
|
|
111
|
+
* 🔑 에디터는 이벤트 스트림이 `connected`를 보낸 **뒤에** 이것을 부른다. 스트림을 열자마자
|
|
112
|
+
* 부르면 빠른 스텝의 결과가 구독 전에 지나가 사라진다 — 그래서 스트림 구현은 구독이 실제로
|
|
113
|
+
* 성립한 뒤에 `connected`를 보내야 한다(HTTP 연결이 열린 시점이 아니다).
|
|
114
|
+
*/
|
|
115
|
+
run: (input: {
|
|
116
|
+
runId: string;
|
|
117
|
+
workflowId: string;
|
|
118
|
+
params?: Record<string, unknown>;
|
|
119
|
+
dryRun?: boolean;
|
|
120
|
+
breakpoints?: string[];
|
|
121
|
+
}) => Promise<RunRequestResult>;
|
|
122
|
+
/** 중단점에서 멈춘 실행을 잇는다. 없으면 디버그 재개 버튼이 없다. */
|
|
123
|
+
resume?: (input: {
|
|
124
|
+
runId: string;
|
|
125
|
+
command: "continue" | "step-over";
|
|
126
|
+
}) => Promise<void> | void;
|
|
127
|
+
/**
|
|
128
|
+
* 이벤트 스트림을 연다. `startIndex`가 있으면 그 순번부터 다시 받는다(이어받기) —
|
|
129
|
+
* 끊겼다 다시 붙을 때 에디터가 마지막으로 받은 순번 + 1을 준다.
|
|
130
|
+
*/
|
|
131
|
+
openEventStream: (input: {
|
|
132
|
+
workflowId: string;
|
|
133
|
+
runId: string;
|
|
134
|
+
startIndex?: number;
|
|
135
|
+
}) => RunEventStream;
|
|
136
|
+
};
|
|
137
|
+
/** 지난 실행 한 건 — 캔버스 재생에 필요한 만큼. */
|
|
138
|
+
type WorkflowRunDetail = {
|
|
139
|
+
id: string;
|
|
140
|
+
status: string;
|
|
141
|
+
startedAt?: Date | string | number | null;
|
|
142
|
+
duration: number | null;
|
|
143
|
+
stepRecords: StepExecutionRecord[];
|
|
144
|
+
};
|
|
145
|
+
type WorkflowRunsSource = {
|
|
146
|
+
detail?: (runId: string) => Promise<WorkflowRunDetail | null>;
|
|
147
|
+
/**
|
|
148
|
+
* 스텝별 누적 지표의 재료. 🔑 런이 없으면 빈 배열, **모르면 null**이다 — 화면은 null일 때
|
|
149
|
+
* 숫자를 적지 않는다(0회와 "모름"은 다른 사실이다).
|
|
150
|
+
*/
|
|
151
|
+
stepSamples?: (workflowId: string) => Promise<{
|
|
152
|
+
runs: RunStepSample[];
|
|
153
|
+
windowDays: number;
|
|
154
|
+
} | null>;
|
|
155
|
+
};
|
|
156
|
+
type WorkflowFieldRendererProps = {
|
|
157
|
+
field: NodeConfigField;
|
|
158
|
+
value: unknown;
|
|
159
|
+
onChange: (value: unknown) => void;
|
|
160
|
+
/** 이 필드가 속한 스텝의 노드 id와 지금 설정 — 다른 칸의 값에 따라 달라지는 필드를 위해. */
|
|
161
|
+
nodeId: string | undefined;
|
|
162
|
+
config: Record<string, unknown>;
|
|
163
|
+
/** 저장 전 문서 전체 — 앞 스텝의 출력을 참조하는 필드를 위해. */
|
|
164
|
+
definition: GridWorkflowDefinition;
|
|
165
|
+
};
|
|
166
|
+
type WorkflowFieldRenderer = ComponentType<WorkflowFieldRendererProps>;
|
|
167
|
+
type WorkflowExtensionContext = {
|
|
168
|
+
steps: readonly GridStep[];
|
|
169
|
+
connections: readonly GridConnection[];
|
|
170
|
+
/** 설정 패널이 열려 있으면 그 스텝의 편집 중 값(아직 문서에 반영 전). */
|
|
171
|
+
draft?: {
|
|
172
|
+
nodeId: string | undefined;
|
|
173
|
+
config: Record<string, unknown>;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
type WorkflowEditorExtension = {
|
|
177
|
+
/** 변수 픽커에 더할 그룹 — 트리거 페이로드 바로 다음에 놓인다. */
|
|
178
|
+
variableGroups?: VariableTreeGroup[];
|
|
179
|
+
/** 실행 전 점검에 더할 문제. */
|
|
180
|
+
preflightIssues?: WorkflowPreflightIssue[];
|
|
181
|
+
/** 설정 패널의 필드 아래에 그릴 안내(불러오기 실패, 어떤 원본을 쓰는지 등). */
|
|
182
|
+
configNotice?: ReactNode;
|
|
183
|
+
};
|
|
184
|
+
export { WorkflowExtensionContext as a, WorkflowHost as c, WorkflowRunsSource as d, WorkflowNotice as f, WorkflowToast as h, WorkflowEditorExtension as i, WorkflowRunDetail as l, WorkflowNoticeSink as m, RunRequestResult as n, WorkflowFieldRenderer as o, WorkflowNoticeKind as p, RunStartResult as r, WorkflowFieldRendererProps as s, RunEventStream as t, WorkflowRunner as u };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Y as NodeOutputField, _ as GridStep, p as GridConnection, v as GridStepType, y as GridWorkflowDefinition } from "./grid-workflow-dto-C86EArJP.js";
|
|
2
|
+
/** 서버가 넘기는 런 한 건의 최소 표본 — 입력·출력은 싣지 않는다(크고, 세는 데 필요 없다). */
|
|
3
|
+
type RunStepSample = {
|
|
4
|
+
steps: {
|
|
5
|
+
stepId: string;
|
|
6
|
+
status: string;
|
|
7
|
+
startedAt?: string;
|
|
8
|
+
duration?: number;
|
|
9
|
+
}[];
|
|
10
|
+
};
|
|
11
|
+
type StepMetric = {
|
|
12
|
+
/** 이 스텝이 실제로 시작된 런 수 */
|
|
13
|
+
entered: number;
|
|
14
|
+
completed: number;
|
|
15
|
+
failed: number;
|
|
16
|
+
/** 끝난(완료·실패) 실행의 평균 소요(ms). 소요 기록이 하나도 없으면 null */
|
|
17
|
+
averageDurationMs: number | null;
|
|
18
|
+
};
|
|
19
|
+
type WorkflowStepMetrics = {
|
|
20
|
+
/** 집계에 쓴 런 수(종결된 런만) */
|
|
21
|
+
runCount: number;
|
|
22
|
+
steps: Map<string, StepMetric>;
|
|
23
|
+
/** 연결 id → 지나간 런 수 */
|
|
24
|
+
connections: Map<string, number>;
|
|
25
|
+
};
|
|
26
|
+
declare function aggregateStepMetrics({ steps, connections, runs }: {
|
|
27
|
+
steps: readonly GridStep[];
|
|
28
|
+
connections: readonly GridConnection[];
|
|
29
|
+
runs: readonly RunStepSample[];
|
|
30
|
+
}): WorkflowStepMetrics;
|
|
31
|
+
/** 분모가 0이면 비율은 없다(0%가 아니다). */
|
|
32
|
+
declare function formatShare(part: number, whole: number): string | null;
|
|
33
|
+
declare function formatDurationMs(ms: number): string;
|
|
34
|
+
/** engine/variable-resolver.ts 의 VARIABLE_PATTERN과 동일해야 한다 (테스트로 고정) */
|
|
35
|
+
declare const VARIABLE_TOKEN_PATTERN: RegExp;
|
|
36
|
+
type VariableTreeItem = {
|
|
37
|
+
/** 삽입할 전체 토큰 — 예: `{{customer.email}}`, `{{step-1.output.messageId}}` */
|
|
38
|
+
token: string;
|
|
39
|
+
label: string;
|
|
40
|
+
type: NodeOutputField["type"];
|
|
41
|
+
description?: string;
|
|
42
|
+
example?: string;
|
|
43
|
+
};
|
|
44
|
+
type VariableTreeGroup = {
|
|
45
|
+
id: string;
|
|
46
|
+
heading: string;
|
|
47
|
+
items: VariableTreeItem[];
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* 현재 스텝의 상류(조상) 스텝 목록 — 연결 그래프 역방향 BFS.
|
|
51
|
+
* 자기 자신은 제외하며, 그래프 순서(트리거에서 가까운 순)와 무관하게
|
|
52
|
+
* 방문 순서대로 반환한다.
|
|
53
|
+
*/
|
|
54
|
+
declare function getUpstreamSteps(currentStepId: string, steps: GridStep[], connections: GridConnection[]): GridStep[];
|
|
55
|
+
/** 출력 필드를 하위 경로까지 편다 — 픽커와 AI 에이전트 프롬프트가 같은 경로를 쓴다. */
|
|
56
|
+
declare function flattenFields(fields: NodeOutputField[], prefix: string): Array<NodeOutputField & {
|
|
57
|
+
path: string;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* 변수 픽커에 보여줄 그룹 목록.
|
|
61
|
+
* 그룹 순서: 트리거 페이로드 → 상류 스텝 출력(가까운 순) → 특수 변수.
|
|
62
|
+
*/
|
|
63
|
+
declare function buildVariableTree(params: {
|
|
64
|
+
currentStepId: string | null;
|
|
65
|
+
steps: GridStep[];
|
|
66
|
+
connections: GridConnection[];
|
|
67
|
+
extraGroups?: readonly VariableTreeGroup[];
|
|
68
|
+
}): VariableTreeGroup[];
|
|
69
|
+
type VariableRefIssue = {
|
|
70
|
+
token: string;
|
|
71
|
+
message: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* 문자열 config 값의 `{{stepId.output.*}}` 참조 중 상류에 없는 스텝을 가리키는
|
|
75
|
+
* 것을 찾는다 (스텝 삭제/재배선으로 깨진 참조의 정적 검출).
|
|
76
|
+
* 트리거 페이로드·런타임 변수 참조는 정적으로 판별할 수 없으므로 건드리지 않는다.
|
|
77
|
+
*/
|
|
78
|
+
declare function findBrokenStepRefs(value: string, params: {
|
|
79
|
+
currentStepId: string | null;
|
|
80
|
+
steps: GridStep[];
|
|
81
|
+
connections: GridConnection[];
|
|
82
|
+
}): VariableRefIssue[];
|
|
83
|
+
/**
|
|
84
|
+
* 나가는 연결을 여럿 가질 수 있는 스텝 — 조건은 분기 타입으로, 병렬은 브랜치로 갈래를
|
|
85
|
+
* 나눈다. 그 밖의 스텝은 실행기가 **첫 번째 연결만** 따라간다(`engine/graph-traversal.ts`).
|
|
86
|
+
* 에디터는 두 번째 연결을 막지 않으므로, 그린 연결이 조용히 무시되는 자리를 점검이 말해야 한다.
|
|
87
|
+
*/
|
|
88
|
+
declare const MULTI_OUTGOING_STEP_TYPES: ReadonlySet<GridStepType>;
|
|
89
|
+
type WorkflowPreflightIssue = {
|
|
90
|
+
id: string;
|
|
91
|
+
severity: "error" | "warning";
|
|
92
|
+
message: string;
|
|
93
|
+
stepId?: string;
|
|
94
|
+
target: "config" | "connections" | "canvas";
|
|
95
|
+
};
|
|
96
|
+
/** 임포트의 구조 검사와 목록의 설정 검사를 편집 중 정의에도 적용한다. */
|
|
97
|
+
declare function getWorkflowPreflight(definition: GridWorkflowDefinition): WorkflowPreflightIssue[];
|
|
98
|
+
type TemplateCategory = "all" | "basic" | "ai" | "marketing";
|
|
99
|
+
/**
|
|
100
|
+
* 템플릿 아이콘 키 — 카탈로그(`components/templates/template-catalog.tsx`)의
|
|
101
|
+
* iconMap이 이 union을 Record 키로 사용하므로, 키를 추가하면 카탈로그가
|
|
102
|
+
* 컴파일 에러로 매핑 누락을 강제한다 (조용한 PlusIcon 폴백 방지).
|
|
103
|
+
*/
|
|
104
|
+
type TemplateIconKey = "plus" | "mail" | "git-branch" | "calendar" | "sparkles" | "bot" | "clipboard-list" | "clipboard-check" | "route" | "webhook";
|
|
105
|
+
type TemplateMetadata = {
|
|
106
|
+
id: string;
|
|
107
|
+
name: string;
|
|
108
|
+
description: string;
|
|
109
|
+
category: TemplateCategory;
|
|
110
|
+
icon: TemplateIconKey;
|
|
111
|
+
featured?: boolean;
|
|
112
|
+
/** 카탈로그 정렬 가중치 (작을수록 먼저, 미지정은 뒤) */
|
|
113
|
+
order?: number;
|
|
114
|
+
/** 자유 태그 — 카테고리 외 부가 facet (예: "nurture", "ops") */
|
|
115
|
+
tags?: string[];
|
|
116
|
+
/** 트리거 노드 id — 정의에서 파생(작성자가 직접 쓰지 않음). 트리거 타입 facet용 */
|
|
117
|
+
triggerType?: string;
|
|
118
|
+
};
|
|
119
|
+
type TemplateDefinition = {
|
|
120
|
+
id: string;
|
|
121
|
+
definition: GridWorkflowDefinition;
|
|
122
|
+
};
|
|
123
|
+
type ExtendedWorkflowTemplate = TemplateMetadata & {
|
|
124
|
+
definition: GridWorkflowDefinition;
|
|
125
|
+
};
|
|
126
|
+
export { formatShare as S, RunStepSample as _, TemplateMetadata as a, aggregateStepMetrics as b, getWorkflowPreflight as c, VariableTreeGroup as d, VariableTreeItem as f, getUpstreamSteps as g, flattenFields as h, TemplateIconKey as i, VARIABLE_TOKEN_PATTERN as l, findBrokenStepRefs as m, TemplateCategory as n, MULTI_OUTGOING_STEP_TYPES as o, buildVariableTree as p, TemplateDefinition as r, WorkflowPreflightIssue as s, ExtendedWorkflowTemplate as t, VariableRefIssue as u, StepMetric as v, formatDurationMs as x, WorkflowStepMetrics as y };
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { _ as RunStepSample, d as VariableTreeGroup, s as WorkflowPreflightIssue, t as ExtendedWorkflowTemplate } from "./types-DQcmIuAl.js";
|
|
2
|
+
import { s as StepExecutionRecord } from "./execution-context-YFTRCj0y.js";
|
|
3
|
+
import { K as NodeConfigField, _ as GridStep, p as GridConnection, y as GridWorkflowDefinition } from "./grid-workflow-dto-C86EArJP.js";
|
|
4
|
+
import { ComponentType, ReactNode } from "react";
|
|
5
|
+
/**
|
|
6
|
+
* 알림 통로. 에디터의 훅·패널은 화면에 무엇을 띄울지 모르고 "무슨 일이 있었는지"만 말한다.
|
|
7
|
+
* 호스트가 `onNotify`를 주면 그쪽으로(스튜디오의 토스터 등), 안 주면 에디터가 자기 알림 줄에 그린다.
|
|
8
|
+
*
|
|
9
|
+
* 한 화면에 에디터가 여럿일 수 있다. 에디터의 훅과 패널은 **자기 에디터의 통로**(`createNoticeChannel`,
|
|
10
|
+
* `useWorkflowToast`)로 말한다 — 실행 완료처럼 늦게 오는 알림도 일을 시작한 에디터에 뜬다.
|
|
11
|
+
* 통로 없이 부르는 `toast`(에디터 밖의 호출)만 "지금 쓰고 있는 에디터"를 찾는다 — 포커스가 있는
|
|
12
|
+
* 에디터, 없으면 마지막으로 조작한 에디터.
|
|
13
|
+
*/
|
|
14
|
+
type WorkflowNoticeKind = "success" | "error" | "info" | "warning";
|
|
15
|
+
type WorkflowNotice = {
|
|
16
|
+
kind: WorkflowNoticeKind;
|
|
17
|
+
message: string;
|
|
18
|
+
/** 알림에 붙는 한 번짜리 동작(예: 되돌리기). */
|
|
19
|
+
action?: {
|
|
20
|
+
label: string;
|
|
21
|
+
onClick: () => void;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
type WorkflowNoticeSink = (notice: WorkflowNotice) => void;
|
|
25
|
+
type NoticeOptions = {
|
|
26
|
+
action?: WorkflowNotice["action"];
|
|
27
|
+
};
|
|
28
|
+
type WorkflowToast = Record<WorkflowNoticeKind, (message: string, options?: NoticeOptions) => void>;
|
|
29
|
+
/**
|
|
30
|
+
* 호스트 계약 — 에디터가 바깥 세계에 부탁하는 것 전부.
|
|
31
|
+
*
|
|
32
|
+
* 에디터는 저장소·실행 엔진·인증을 모른다. 필요한 일은 이 계약으로만 부탁하고, **없는 능력은
|
|
33
|
+
* 화면에서 사라진다**: `runner`가 없으면 실행·디버그가 없고(테스트 모드의 시뮬레이션은 남는다),
|
|
34
|
+
* `runs`가 없으면 누적 지표·런 재생이 없다. 호스트는 가진 것만 주면 된다.
|
|
35
|
+
*/
|
|
36
|
+
type WorkflowHost = {
|
|
37
|
+
/** 저장된 문서의 id. 아직 저장 전이면 없다 — 그동안 실행은 "먼저 저장" 안내가 된다. */
|
|
38
|
+
workflowId?: string;
|
|
39
|
+
/** 실행 — 시작·재개·이벤트 스트림. */
|
|
40
|
+
runner?: WorkflowRunner;
|
|
41
|
+
/** 지난 실행 조회 — 런 재생과 스텝별 누적 지표. */
|
|
42
|
+
runs?: WorkflowRunsSource;
|
|
43
|
+
/** 커스텀 설정 필드. 키는 `NodeFieldDefinition.type`(또는 `editorType`)이다. */
|
|
44
|
+
fields?: Readonly<Record<string, WorkflowFieldRenderer>>;
|
|
45
|
+
/** 빈 캔버스에서 고를 템플릿. */
|
|
46
|
+
templates?: readonly ExtendedWorkflowTemplate[];
|
|
47
|
+
/**
|
|
48
|
+
* 템플릿을 적용하기 직전에 스텝을 손본다(예: 지금 문서가 이미 고른 대상을 새 트리거에 옮긴다).
|
|
49
|
+
*/
|
|
50
|
+
prepareTemplate?: (template: ExtendedWorkflowTemplate, current: {
|
|
51
|
+
steps: readonly GridStep[];
|
|
52
|
+
}) => GridStep[];
|
|
53
|
+
/**
|
|
54
|
+
* 문서와 **함께 저장되는** 호스트 쪽 값(예: 소속). 에디터는 내용을 모르고, 값이 바뀌면
|
|
55
|
+
* "저장 안 됨"으로 보고 `onSave`의 세 번째 인자로 그대로 돌려준다. JSON으로 직렬화할 수
|
|
56
|
+
* 있어야 한다.
|
|
57
|
+
*/
|
|
58
|
+
saveContext?: unknown;
|
|
59
|
+
/**
|
|
60
|
+
* 호스트 확장 **훅**. 지금 그래프(와 편집 중인 설정)를 받아 변수·점검·안내를 더한다 —
|
|
61
|
+
* 트리거 설정에 따라 달라지는 변수(폼의 질문 목록 등)가 이 길로 들어온다.
|
|
62
|
+
*
|
|
63
|
+
* 🔴 훅이다. 참조가 렌더마다 바뀌면 안 된다(모듈 최상위 함수로 둘 것).
|
|
64
|
+
*/
|
|
65
|
+
useExtension?: (context: WorkflowExtensionContext) => WorkflowEditorExtension;
|
|
66
|
+
/** 알림을 호스트의 토스터로 보낸다. 없으면 에디터가 자기 알림 줄에 그린다. */
|
|
67
|
+
onNotify?: WorkflowNoticeSink;
|
|
68
|
+
/** 저장하지 않은 변경이 생기거나 사라질 때. 호스트 라우터의 이탈 확인에 쓴다. */
|
|
69
|
+
onDirtyChange?: (dirty: boolean) => void;
|
|
70
|
+
/** 표시 경로에서 손상된 정의를 빈 캔버스로 바꿔 읽었을 때 등, 사람이 볼 필요는 없는 사실. */
|
|
71
|
+
onDiagnostic?: (event: {
|
|
72
|
+
code: string;
|
|
73
|
+
detail?: unknown;
|
|
74
|
+
}) => void;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* 실행 이벤트 통로. 브라우저의 `EventSource`가 그대로 이 모양이다 — 서버 호스트는
|
|
78
|
+
* `new EventSource(url)`을 돌려주면 되고, 메모리 호스트는 같은 모양의 객체를 만든다.
|
|
79
|
+
* `onmessage`의 `data`는 `ExecutionEvent`의 JSON이다.
|
|
80
|
+
*/
|
|
81
|
+
type RunEventStream = {
|
|
82
|
+
onmessage: ((event: {
|
|
83
|
+
data: string;
|
|
84
|
+
}) => void) | null;
|
|
85
|
+
onerror: ((event?: unknown) => void) | null;
|
|
86
|
+
close: () => void;
|
|
87
|
+
};
|
|
88
|
+
type RunStartResult = {
|
|
89
|
+
ok: true;
|
|
90
|
+
runId: string;
|
|
91
|
+
} | {
|
|
92
|
+
ok: false;
|
|
93
|
+
error?: string;
|
|
94
|
+
};
|
|
95
|
+
type RunRequestResult = {
|
|
96
|
+
ok: true;
|
|
97
|
+
} | {
|
|
98
|
+
ok: false;
|
|
99
|
+
error?: string;
|
|
100
|
+
};
|
|
101
|
+
type WorkflowRunner = {
|
|
102
|
+
/** 실행 한 건을 예약하고 id를 받는다. 아직 돌지 않는다. */
|
|
103
|
+
start: (input: {
|
|
104
|
+
workflowId: string;
|
|
105
|
+
params?: Record<string, unknown>;
|
|
106
|
+
dryRun?: boolean;
|
|
107
|
+
}) => Promise<RunStartResult>;
|
|
108
|
+
/**
|
|
109
|
+
* 예약한 실행을 돌린다.
|
|
110
|
+
*
|
|
111
|
+
* 🔑 에디터는 이벤트 스트림이 `connected`를 보낸 **뒤에** 이것을 부른다. 스트림을 열자마자
|
|
112
|
+
* 부르면 빠른 스텝의 결과가 구독 전에 지나가 사라진다 — 그래서 스트림 구현은 구독이 실제로
|
|
113
|
+
* 성립한 뒤에 `connected`를 보내야 한다(HTTP 연결이 열린 시점이 아니다).
|
|
114
|
+
*/
|
|
115
|
+
run: (input: {
|
|
116
|
+
runId: string;
|
|
117
|
+
workflowId: string;
|
|
118
|
+
params?: Record<string, unknown>;
|
|
119
|
+
dryRun?: boolean;
|
|
120
|
+
breakpoints?: string[];
|
|
121
|
+
}) => Promise<RunRequestResult>;
|
|
122
|
+
/** 중단점에서 멈춘 실행을 잇는다. 없으면 디버그 재개 버튼이 없다. */
|
|
123
|
+
resume?: (input: {
|
|
124
|
+
runId: string;
|
|
125
|
+
command: "continue" | "step-over";
|
|
126
|
+
}) => Promise<void> | void;
|
|
127
|
+
/**
|
|
128
|
+
* 이벤트 스트림을 연다. `startIndex`가 있으면 그 순번부터 다시 받는다(이어받기) —
|
|
129
|
+
* 끊겼다 다시 붙을 때 에디터가 마지막으로 받은 순번 + 1을 준다.
|
|
130
|
+
*/
|
|
131
|
+
openEventStream: (input: {
|
|
132
|
+
workflowId: string;
|
|
133
|
+
runId: string;
|
|
134
|
+
startIndex?: number;
|
|
135
|
+
}) => RunEventStream;
|
|
136
|
+
};
|
|
137
|
+
/** 지난 실행 한 건 — 캔버스 재생에 필요한 만큼. */
|
|
138
|
+
type WorkflowRunDetail = {
|
|
139
|
+
id: string;
|
|
140
|
+
status: string;
|
|
141
|
+
startedAt?: Date | string | number | null;
|
|
142
|
+
duration: number | null;
|
|
143
|
+
stepRecords: StepExecutionRecord[];
|
|
144
|
+
};
|
|
145
|
+
type WorkflowRunsSource = {
|
|
146
|
+
detail?: (runId: string) => Promise<WorkflowRunDetail | null>;
|
|
147
|
+
/**
|
|
148
|
+
* 스텝별 누적 지표의 재료. 🔑 런이 없으면 빈 배열, **모르면 null**이다 — 화면은 null일 때
|
|
149
|
+
* 숫자를 적지 않는다(0회와 "모름"은 다른 사실이다).
|
|
150
|
+
*/
|
|
151
|
+
stepSamples?: (workflowId: string) => Promise<{
|
|
152
|
+
runs: RunStepSample[];
|
|
153
|
+
windowDays: number;
|
|
154
|
+
} | null>;
|
|
155
|
+
};
|
|
156
|
+
type WorkflowFieldRendererProps = {
|
|
157
|
+
field: NodeConfigField;
|
|
158
|
+
value: unknown;
|
|
159
|
+
onChange: (value: unknown) => void;
|
|
160
|
+
/** 이 필드가 속한 스텝의 노드 id와 지금 설정 — 다른 칸의 값에 따라 달라지는 필드를 위해. */
|
|
161
|
+
nodeId: string | undefined;
|
|
162
|
+
config: Record<string, unknown>;
|
|
163
|
+
/** 저장 전 문서 전체 — 앞 스텝의 출력을 참조하는 필드를 위해. */
|
|
164
|
+
definition: GridWorkflowDefinition;
|
|
165
|
+
};
|
|
166
|
+
type WorkflowFieldRenderer = ComponentType<WorkflowFieldRendererProps>;
|
|
167
|
+
type WorkflowExtensionContext = {
|
|
168
|
+
steps: readonly GridStep[];
|
|
169
|
+
connections: readonly GridConnection[];
|
|
170
|
+
/** 설정 패널이 열려 있으면 그 스텝의 편집 중 값(아직 문서에 반영 전). */
|
|
171
|
+
draft?: {
|
|
172
|
+
nodeId: string | undefined;
|
|
173
|
+
config: Record<string, unknown>;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
type WorkflowEditorExtension = {
|
|
177
|
+
/** 변수 픽커에 더할 그룹 — 트리거 페이로드 바로 다음에 놓인다. */
|
|
178
|
+
variableGroups?: VariableTreeGroup[];
|
|
179
|
+
/** 실행 전 점검에 더할 문제. */
|
|
180
|
+
preflightIssues?: WorkflowPreflightIssue[];
|
|
181
|
+
/** 설정 패널의 필드 아래에 그릴 안내(불러오기 실패, 어떤 원본을 쓰는지 등). */
|
|
182
|
+
configNotice?: ReactNode;
|
|
183
|
+
};
|
|
184
|
+
export { WorkflowExtensionContext as a, WorkflowHost as c, WorkflowRunsSource as d, WorkflowNotice as f, WorkflowToast as h, WorkflowEditorExtension as i, WorkflowRunDetail as l, WorkflowNoticeSink as m, RunRequestResult as n, WorkflowFieldRenderer as o, WorkflowNoticeKind as p, RunStartResult as r, WorkflowFieldRendererProps as s, RunEventStream as t, WorkflowRunner as u };
|