@reopt-ai/opt-workflow 0.0.0-stage → 0.1.0

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/LICENSE +21 -0
  3. package/README.md +213 -2
  4. package/dist/ai-stream-APc3uCiQ.js +389 -0
  5. package/dist/ai-stream-B_lk9_Rf.cjs +628 -0
  6. package/dist/branch-resolver-BDi6Wu6m.js +589 -0
  7. package/dist/branch-resolver-D_wM183Q.cjs +714 -0
  8. package/dist/core-CtqBb-6v.d.cts +919 -0
  9. package/dist/core-z3nXmUBj.d.ts +919 -0
  10. package/dist/core.cjs +301 -0
  11. package/dist/core.d.cts +5 -0
  12. package/dist/core.d.ts +5 -0
  13. package/dist/core.js +184 -0
  14. package/dist/define-template-Bmn96lF_.cjs +74 -0
  15. package/dist/define-template-BvGNB5Tv.js +69 -0
  16. package/dist/end-node-ids-D6WBaCLm.cjs +109 -0
  17. package/dist/end-node-ids-p85jFEcP.js +86 -0
  18. package/dist/execution-context-DVeybULC.d.cts +258 -0
  19. package/dist/execution-context-YFTRCj0y.d.ts +258 -0
  20. package/dist/grid-workflow-dto-C86EArJP.d.cts +300 -0
  21. package/dist/grid-workflow-dto-C86EArJP.d.ts +300 -0
  22. package/dist/index.cjs +11873 -0
  23. package/dist/index.d.cts +794 -0
  24. package/dist/index.d.ts +794 -0
  25. package/dist/index.js +11828 -0
  26. package/dist/mock.cjs +7295 -0
  27. package/dist/mock.d.cts +88 -0
  28. package/dist/mock.d.ts +88 -0
  29. package/dist/mock.js +7287 -0
  30. package/dist/node-definitions-C-GMfjMm.js +797 -0
  31. package/dist/node-definitions-pS1Zp1dK.cjs +940 -0
  32. package/dist/nodes-D_a8ZkRp.d.cts +50 -0
  33. package/dist/nodes-myp8R2zo.d.ts +50 -0
  34. package/dist/nodes.cjs +36 -0
  35. package/dist/nodes.d.cts +3 -0
  36. package/dist/nodes.d.ts +3 -0
  37. package/dist/nodes.js +4 -0
  38. package/dist/shadcn-bridge.css +72 -0
  39. package/dist/simulate.cjs +6 -0
  40. package/dist/simulate.d.cts +111 -0
  41. package/dist/simulate.d.ts +111 -0
  42. package/dist/simulate.js +1 -0
  43. package/dist/step-type-for-node-Blf5DKrp.js +228 -0
  44. package/dist/step-type-for-node-D9sdHfWA.cjs +281 -0
  45. package/dist/styles.css +4 -0
  46. package/dist/test-executor-C2AvI73G.cjs +342 -0
  47. package/dist/test-executor-DpT3qXIT.js +313 -0
  48. package/dist/types-Bj0VWFny.d.cts +126 -0
  49. package/dist/types-C5744w6f.d.cts +184 -0
  50. package/dist/types-DQcmIuAl.d.ts +126 -0
  51. package/dist/types-dVHX2CyI.d.ts +184 -0
  52. package/dist/workflow-preview-B0kul6f-.js +1742 -0
  53. package/dist/workflow-preview-CZzXKXqK.cjs +2065 -0
  54. package/package.json +119 -4
@@ -0,0 +1,300 @@
1
+ import { ComponentType } from "react";
2
+ /**
3
+ * 노드 아이콘 — `className`을 받는 컴포넌트면 된다. 특정 아이콘 라이브러리에 묶지 않는다
4
+ * (호스트와 모듈의 아이콘 패키지 버전이 달라도 주입할 수 있어야 한다).
5
+ */
6
+ type NodeIcon = ComponentType<{
7
+ className?: string;
8
+ }>;
9
+ /** 노드 카테고리 — 런타임 레지스트리의 분류. 화면 그룹은 `editorCategory`다. */
10
+ type NodeCategory = "trigger" | "communication" | "crm" | "integration" | "ai" | "flow" | "utility" | "control";
11
+ /**
12
+ * 필드 타입. 앞의 것들은 에디터가 직접 그린다. `json`·`code`·`variable`·`multiselect`는 의미
13
+ * 타입이라 `editorType`으로 그릴 컨트롤을 정해야 한다. 그 밖의 문자열은 **호스트가 등록한
14
+ * 필드 렌더러**의 이름이다(`WorkflowHost.fields`).
15
+ */
16
+ type FieldType = "text" | "email" | "number" | "select" | "multiselect" | "textarea" | "code" | "json" | "boolean" | "variable" | (string & {});
17
+ /** UI 필드 정의 — 에디터와 런타임이 같은 선언을 쓴다. */
18
+ type NodeFieldDefinition = {
19
+ /** 필드 키 (config 객체의 키) */
20
+ key: string;
21
+ /** 필드 라벨 */
22
+ label: string;
23
+ /** 필드 타입 */
24
+ type: FieldType;
25
+ /** 필수 여부 */
26
+ required?: boolean;
27
+ /** 플레이스홀더 */
28
+ placeholder?: string;
29
+ /** 기본값 */
30
+ defaultValue?: unknown;
31
+ /** 도움말 텍스트 */
32
+ helpText?: string;
33
+ /** select/multiselect 옵션 */
34
+ options?: Array<{
35
+ label: string;
36
+ value: string;
37
+ }>;
38
+ /**
39
+ * 이 필드를 **설정 패널에 열지 않는다**(값은 다른 경로가 채운다). 캔버스 연결이 채우는
40
+ * 스텝 ID 목록 등에 쓴다.
41
+ */
42
+ hiddenInEditor?: boolean;
43
+ /** 조건부 표시 (다른 필드 값에 따라) */
44
+ showWhen?: {
45
+ field: string;
46
+ value: unknown;
47
+ };
48
+ /** 유효성 검사 규칙 */
49
+ validation?: {
50
+ min?: number;
51
+ max?: number;
52
+ pattern?: string;
53
+ message?: string;
54
+ };
55
+ };
56
+ /** Browser-safe metadata shared by the editor and the executable node. */
57
+ type NodeContract = {
58
+ id: string;
59
+ name: string;
60
+ description: string;
61
+ icon: NodeIcon;
62
+ color: string;
63
+ category: NodeCategory;
64
+ /** Editor grouping is independent of the runtime registry category. */
65
+ editorCategory: string;
66
+ comingSoon?: boolean;
67
+ /** 이 노드로 새 스텝을 만들 때의 첫 설정값(예: "아직 대상을 고르지 않음"을 뜻하는 null). */
68
+ initialConfig?: Record<string, unknown>;
69
+ fields: Array<NodeFieldDefinition & {
70
+ /** Rendering substitute for semantic types such as json/code/variable. */
71
+ editorType?: string;
72
+ }>;
73
+ };
74
+ type NodeConfigFieldOption = NonNullable<NodeFieldDefinition["options"]>[number];
75
+ type NodeConfigField = Pick<NodeFieldDefinition, "key" | "label" | "required" | "options" | "placeholder" | "helpText" | "showWhen"> & {
76
+ type: "text" | "email" | "number" | "select" | "textarea" | "boolean" |
77
+ /** 호스트가 등록한 필드 렌더러의 이름(`WorkflowHost.fields`). */
78
+ (string & {});
79
+ };
80
+ /**
81
+ * 노드 출력(또는 트리거 페이로드) 필드 메타 — 변수 픽커가 "이전 스텝이 어떤
82
+ * 값을 내놓는지"를 보여주기 위한 클라이언트 안전 스키마.
83
+ * 실제 값 형태의 단일 진실 공급원은 lib/nodes/* 의 Result 타입이며,
84
+ * lib/node-definitions/output-schemas.ts 가 이를 미러한다(드리프트 테스트로 고정).
85
+ */
86
+ type NodeOutputField = {
87
+ key: string;
88
+ label: string;
89
+ type: "string" | "number" | "boolean" | "object" | "array";
90
+ description?: string;
91
+ /** 픽커 미리보기용 예시 값 */
92
+ example?: string;
93
+ /** object 타입의 하위 필드 (점 표기 경로로 펼쳐짐) */
94
+ children?: NodeOutputField[];
95
+ };
96
+ type NodeDefinition = {
97
+ id: string;
98
+ type: "trigger" | "action" | "condition";
99
+ name: string;
100
+ description: string;
101
+ icon: NodeIcon;
102
+ color: string;
103
+ category: string;
104
+ /** 외부 서비스 미연동 등으로 아직 사용할 수 없는 노드 — 에디터에서 비활성 표시 */
105
+ comingSoon?: boolean;
106
+ /** 이 노드로 새 스텝을 만들 때의 첫 설정값. 없으면 빈 설정이다. */
107
+ initialConfig?: Record<string, unknown>;
108
+ config?: {
109
+ fields: NodeConfigField[];
110
+ };
111
+ };
112
+ /**
113
+ * 노드 카탈로그 — 에디터의 피커·설정 패널·점검·AI 제안이 전부 여기서 읽는다.
114
+ *
115
+ * 내장 범용 노드(반복·병렬·대기·HTTP 등)는 모듈이 넣고, 제품 고유 노드는 호스트가
116
+ * `registerNodeContracts`로 더한다. 등록은 **덧붙이기**이고 같은 `종류:id`를 다시 넣으면
117
+ * 그 자리를 갈아 끼운다(HMR·재마운트에서 중복이 쌓이지 않는다). 배열 객체는 바뀌지 않는다 —
118
+ * 이미 import한 쪽이 등록 뒤의 내용을 본다.
119
+ */
120
+ /** 내장 트리거 — 수동·일정·웹훅. 제품 이벤트 트리거는 호스트가 더한다. */
121
+ declare const builtInTriggerContracts: readonly NodeContract[];
122
+ /**
123
+ * 내장 액션·제어 노드. 반복·병렬은 캔버스가 구조로 아는 종류라(마커 짝짓기·브랜치 채우기)
124
+ * 모듈이 갖고, 대기·HTTP·데이터 변환은 어떤 제품에서도 뜻이 같은 범용 액션이다.
125
+ */
126
+ declare const builtInActionContracts: readonly NodeContract[];
127
+ declare const triggerDefinitions: NodeDefinition[];
128
+ declare const actionDefinitions: NodeDefinition[];
129
+ type NodeContractRegistration = {
130
+ triggers?: readonly NodeContract[];
131
+ actions?: readonly NodeContract[];
132
+ /**
133
+ * `append`(기본)는 지금 카탈로그에 더한다. `replace`는 준 목록이 **그 종류의 카탈로그 전체**가
134
+ * 된다 — 피커에 보이는 순서까지 호스트가 정하고 싶을 때 쓴다. 내장 노드를 남기려면
135
+ * `builtInTriggerContracts`·`builtInActionContracts`에서 골라 목록에 함께 넣는다.
136
+ * 🔴 반복·병렬 마커(forEach·while·repeat·loopEnd·parallel·join)는 캔버스가 구조로 아는
137
+ * 노드다. `replace`로 빼면 그 스텝을 놓을 수 없다.
138
+ */
139
+ mode?: "append" | "replace";
140
+ /**
141
+ * 이 등록의 주인(에디터 하나). 주면 **그 주인에게만 보이는** 노드가 된다 — 전역 카탈로그의
142
+ * 순서와 내용은 건드리지 않는다(`replace`도 그 주인의 목록만 정한다). 에디터가 `nodes` prop을
143
+ * 등록할 때 쓴다. 호스트가 직접 부를 때는 비운다(전역).
144
+ */
145
+ scope?: NodeCatalogScope;
146
+ };
147
+ /** 카탈로그 범위의 정체 — 에디터마다 하나. 값이 아니라 참조로 구분한다. */
148
+ type NodeCatalogScope = object;
149
+ declare function registerNodeContracts({ triggers, actions, mode, scope }: NodeContractRegistration): void;
150
+ /** 카탈로그가 바뀔 때마다 오르는 숫자 — `useSyncExternalStore`의 스냅샷으로 쓴다. */
151
+ declare function getNodeCatalogVersion(): number;
152
+ declare function subscribeNodeCatalog(listener: () => void): () => void;
153
+ /** 트리거 + 액션. 호출할 때마다 지금의 카탈로그를 읽는다. */
154
+ declare function listNodeDefinitions(): NodeDefinition[];
155
+ declare function getNodeDefinition(id: string): NodeDefinition | undefined;
156
+ declare const GRID_SIZE = 9;
157
+ declare const CELL_WIDTH = 248;
158
+ declare const CELL_HEIGHT = 136;
159
+ declare const CELL_GAP = 40;
160
+ declare const CELL_PITCH_X: number;
161
+ declare const CELL_PITCH_Y: number;
162
+ declare const MAX_STEPS = 200;
163
+ declare const MAX_GRID_ROWS = 64;
164
+ declare const MAX_GRID_COLS = 16;
165
+ type GridStepType = "trigger" | "condition" | "action" | "end" | "parallel" | "join" | "forEach" | "while" | "repeat" | "loopEnd" | "tryCatch" | "errorHandler";
166
+ type GridPosition = {
167
+ row: number;
168
+ col: number;
169
+ };
170
+ type ConnectionDirection = "up" | "down" | "left" | "right";
171
+ type BranchType = "true" | "false" | "case" | "default";
172
+ type ConditionType = "if-else" | "switch";
173
+ declare const BRANCH_TYPE_COLORS: Record<BranchType, {
174
+ stroke: string;
175
+ fill: string;
176
+ label: string;
177
+ }>;
178
+ type GridStep = {
179
+ id: string;
180
+ position: GridPosition;
181
+ type: GridStepType;
182
+ label: string;
183
+ nodeDefinitionId?: string;
184
+ nodeDefinition?: NodeDefinition;
185
+ config: Record<string, unknown>;
186
+ /**
187
+ * 이 스텝이 실패해도 **다음 스텝으로 계속 진행**한다.
188
+ *
189
+ * 🔑 기본값은 중단이다 — 자동화가 절반만 돌고 성공으로 보고하는 것이 더 위험하다.
190
+ * 켜는 것은 사용자의 명시적 선택이고, 켜도 **스텝 기록은 실패로 남는다**(런 상세에서
191
+ * 자동으로 펼쳐진다). "계속 진행"은 실패를 지우는 것이 아니라 흐름을 잇는 것이다.
192
+ *
193
+ * ⚠️ 실행 중단(취소·예산 소진·전체 타임아웃)에는 적용되지 않는다 — 그것들은 스텝의
194
+ * 실패가 아니라 런의 종료 조건이다.
195
+ */
196
+ continueOnError?: boolean;
197
+ };
198
+ type GridConnection = {
199
+ id: string;
200
+ fromStepId: string;
201
+ toStepId: string;
202
+ fromPosition: GridPosition;
203
+ toPosition: GridPosition;
204
+ label?: string;
205
+ condition?: string;
206
+ branchType?: BranchType;
207
+ branchValue?: string;
208
+ };
209
+ type GridWorkflowDefinition = {
210
+ steps: GridStep[];
211
+ connections: GridConnection[];
212
+ gridSize: number;
213
+ /**
214
+ * 테스트 실행에 쓰는 트리거 샘플 페이로드(`{{params.*}}`) — 워크플로우와 함께 저장한다.
215
+ * 참조 구현의 입력 노드 `sample`과 같은 뜻: 매번 다시 치지 않고 "실행"이 한 번에 된다.
216
+ */
217
+ testParams?: Record<string, unknown>;
218
+ };
219
+ type GridWorkflowDto = {
220
+ id: string;
221
+ name: string;
222
+ description?: string;
223
+ status: "draft" | "active" | "inactive";
224
+ definition: GridWorkflowDefinition;
225
+ createdAt: Date;
226
+ updatedAt: Date;
227
+ };
228
+ type GridSelectionState = {
229
+ selectedCell: GridPosition | null;
230
+ selectedStepId: string | null;
231
+ };
232
+ type ConnectionModeState = {
233
+ isActive: boolean;
234
+ startPosition: GridPosition | null;
235
+ startStepId: string | null;
236
+ };
237
+ type GridEditorState = {
238
+ steps: GridStep[];
239
+ connections: GridConnection[];
240
+ selection: GridSelectionState;
241
+ connectionMode: ConnectionModeState;
242
+ isLoading: boolean;
243
+ isSaving: boolean;
244
+ error: string | null;
245
+ };
246
+ type HistoryActionType = "ADD_STEP" | "UPDATE_STEP" | "DELETE_STEP" | "ADD_CONNECTION" | "DELETE_CONNECTION" | "MOVE_STEP";
247
+ type HistoryItem = {
248
+ type: HistoryActionType;
249
+ timestamp: number;
250
+ previousState: {
251
+ steps: GridStep[];
252
+ connections: GridConnection[];
253
+ };
254
+ currentState: {
255
+ steps: GridStep[];
256
+ connections: GridConnection[];
257
+ };
258
+ };
259
+ type PreviewStatus = "added" | "updated" | "deleted";
260
+ type GridCellState = {
261
+ position: GridPosition;
262
+ step: GridStep | null;
263
+ isSelected: boolean;
264
+ isConnectionStart: boolean;
265
+ isConnectedTo: boolean;
266
+ /** 연결 모드에서 이 스텝으로는 이을 수 없다(이미 연결·순환) — 흐리게 그린다 */
267
+ isConnectionBlocked?: boolean;
268
+ hasConnectionUp: boolean;
269
+ hasConnectionDown: boolean;
270
+ hasConnectionLeft: boolean;
271
+ hasConnectionRight: boolean;
272
+ hasBreakpoint?: boolean;
273
+ problemCount?: number;
274
+ isCurrentlyExecuting?: boolean;
275
+ /** AI 제안 미리보기 중 이 셀 스텝의 변경 상태 (없으면 unchanged) */
276
+ previewStatus?: PreviewStatus;
277
+ };
278
+ type WorkflowTemplate = {
279
+ id: string;
280
+ name: string;
281
+ description: string;
282
+ definition: GridWorkflowDefinition;
283
+ };
284
+ declare const STEP_TYPE_COLORS: Record<GridStepType, {
285
+ bg: string;
286
+ border: string;
287
+ text: string;
288
+ }>;
289
+ declare function positionToIndex(position: GridPosition): number;
290
+ declare function indexToPosition(index: number): GridPosition;
291
+ declare function isSamePosition(a: GridPosition | null, b: GridPosition | null): boolean;
292
+ /** 절대 상한(하드캡) 검사 — 렌더 바운드 검사는 lib/grid-bounds.isWithinBounds */
293
+ declare function isValidPosition(position: GridPosition): boolean;
294
+ declare function getAdjacentPosition(position: GridPosition, direction: ConnectionDirection): GridPosition | null;
295
+ declare function getConnectionDirection(from: GridPosition, to: GridPosition): ConnectionDirection | null;
296
+ declare function hasCycle(connections: GridConnection[], newConnection?: {
297
+ fromStepId: string;
298
+ toStepId: string;
299
+ }): boolean;
300
+ export { NodeFieldDefinition as $, getConnectionDirection as A, builtInActionContracts as B, MAX_GRID_COLS as C, STEP_TYPE_COLORS as D, PreviewStatus as E, positionToIndex as F, triggerDefinitions as G, getNodeCatalogVersion as H, getNodeDefinition as I, NodeDefinition as J, NodeConfigField as K, listNodeDefinitions as L, indexToPosition as M, isSamePosition as N, WorkflowTemplate as O, isValidPosition as P, NodeContract as Q, NodeContractRegistration as R, HistoryItem as S, MAX_STEPS as T, registerNodeContracts as U, builtInTriggerContracts as V, subscribeNodeCatalog as W, FieldType as X, NodeOutputField as Y, NodeCategory as Z, GridStep as _, CELL_PITCH_X as a, GridWorkflowDto as b, ConditionType as c, GRID_SIZE as d, NodeIcon as et, GridCellState as f, GridSelectionState as g, GridPosition as h, CELL_HEIGHT as i, hasCycle as j, getAdjacentPosition as k, ConnectionDirection as l, GridEditorState as m, BranchType as n, CELL_PITCH_Y as o, GridConnection as p, NodeConfigFieldOption as q, CELL_GAP as r, CELL_WIDTH as s, BRANCH_TYPE_COLORS as t, ConnectionModeState as u, GridStepType as v, MAX_GRID_ROWS as w, HistoryActionType as x, GridWorkflowDefinition as y, actionDefinitions as z };