@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.
Files changed (54) hide show
  1. package/CHANGELOG.md +20 -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 +11899 -0
  23. package/dist/index.d.cts +803 -0
  24. package/dist/index.d.ts +803 -0
  25. package/dist/index.js +11852 -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,919 @@
1
+ import { E as PreviewStatus, J as NodeDefinition, K as NodeConfigField, _ as GridStep, h as GridPosition, l as ConnectionDirection, n as BranchType, p as GridConnection, v as GridStepType, y as GridWorkflowDefinition } from "./grid-workflow-dto-C86EArJP.js";
2
+ import { d as WorkflowExecutionContext, s as StepExecutionRecord, t as ConditionEvalDetails } from "./execution-context-YFTRCj0y.js";
3
+ import { i as TemplateIconKey, n as TemplateCategory, t as ExtendedWorkflowTemplate } from "./types-DQcmIuAl.js";
4
+ import { z } from "zod";
5
+ /**
6
+ * 조건 스텝의 설정 타입. 에디터의 설정 패널·점검·요약과 실행기의 조건 평가가 같은 타입을 본다.
7
+ */
8
+ /**
9
+ * 조건 분기 설정
10
+ */
11
+ type ConditionConfig = {
12
+ /** 조건 유형 */
13
+ conditionType: "if-else" | "switch";
14
+ /** 조건 표현식 (if-else용) */
15
+ expression?: string;
16
+ /** 비교 대상 값 (switch용) */
17
+ switchValue?: string;
18
+ /** 비교 연산자 */
19
+ operator?: "equals" | "notEquals" | "contains" | "startsWith" | "endsWith" | "greaterThan" | "lessThan" | "isEmpty" | "isNotEmpty";
20
+ /** 비교 값 */
21
+ compareValue?: unknown;
22
+ /** 왼쪽 피연산자 (변수 참조) */
23
+ leftOperand?: string;
24
+ /** 오른쪽 피연산자 (리터럴 또는 변수) */
25
+ rightOperand?: unknown;
26
+ /** 조건 그룹 (중첩 AND/OR 논리) — 설정 시 expression/leftOperand보다 우선 */
27
+ conditionGroup?: ConditionGroup;
28
+ };
29
+ /**
30
+ * 단일 조건
31
+ */
32
+ type SingleCondition = {
33
+ leftOperand: string;
34
+ operator: string;
35
+ rightOperand?: unknown;
36
+ };
37
+ /**
38
+ * 조건 그룹 (AND/OR 중첩 지원)
39
+ */
40
+ type ConditionGroup = {
41
+ logic: "and" | "or";
42
+ conditions: Array<SingleCondition | ConditionGroup>;
43
+ };
44
+ declare const gridPositionSchema: z.ZodObject<{
45
+ row: z.ZodNumber;
46
+ col: z.ZodNumber;
47
+ }, z.core.$strip>;
48
+ declare const gridStepTypeSchema: z.ZodEnum<{
49
+ action: "action";
50
+ condition: "condition";
51
+ end: "end";
52
+ errorHandler: "errorHandler";
53
+ forEach: "forEach";
54
+ join: "join";
55
+ loopEnd: "loopEnd";
56
+ parallel: "parallel";
57
+ repeat: "repeat";
58
+ trigger: "trigger";
59
+ tryCatch: "tryCatch";
60
+ while: "while";
61
+ }>;
62
+ declare const branchTypeSchema: z.ZodEnum<{
63
+ case: "case";
64
+ default: "default";
65
+ false: "false";
66
+ true: "true";
67
+ }>;
68
+ declare const gridStepSchema: z.ZodObject<{
69
+ id: z.ZodString;
70
+ position: z.ZodObject<{
71
+ row: z.ZodNumber;
72
+ col: z.ZodNumber;
73
+ }, z.core.$strip>;
74
+ type: z.ZodEnum<{
75
+ action: "action";
76
+ condition: "condition";
77
+ end: "end";
78
+ errorHandler: "errorHandler";
79
+ forEach: "forEach";
80
+ join: "join";
81
+ loopEnd: "loopEnd";
82
+ parallel: "parallel";
83
+ repeat: "repeat";
84
+ trigger: "trigger";
85
+ tryCatch: "tryCatch";
86
+ while: "while";
87
+ }>;
88
+ label: z.ZodString;
89
+ nodeDefinitionId: z.ZodOptional<z.ZodString>;
90
+ nodeDefinition: z.ZodOptional<z.ZodUnknown>;
91
+ config: z.ZodDefault<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
92
+ continueOnError: z.ZodOptional<z.ZodBoolean>;
93
+ }, z.core.$strip>;
94
+ declare const gridConnectionSchema: z.ZodObject<{
95
+ id: z.ZodString;
96
+ fromStepId: z.ZodString;
97
+ toStepId: z.ZodString;
98
+ fromPosition: z.ZodObject<{
99
+ row: z.ZodNumber;
100
+ col: z.ZodNumber;
101
+ }, z.core.$strip>;
102
+ toPosition: z.ZodObject<{
103
+ row: z.ZodNumber;
104
+ col: z.ZodNumber;
105
+ }, z.core.$strip>;
106
+ label: z.ZodOptional<z.ZodString>;
107
+ condition: z.ZodOptional<z.ZodString>;
108
+ branchType: z.ZodOptional<z.ZodEnum<{
109
+ case: "case";
110
+ default: "default";
111
+ false: "false";
112
+ true: "true";
113
+ }>>;
114
+ branchValue: z.ZodOptional<z.ZodString>;
115
+ }, z.core.$strip>;
116
+ declare const gridWorkflowDefinitionSchema: z.ZodObject<{
117
+ gridSize: z.ZodDefault<z.ZodNumber>;
118
+ steps: z.ZodArray<z.ZodObject<{
119
+ id: z.ZodString;
120
+ position: z.ZodObject<{
121
+ row: z.ZodNumber;
122
+ col: z.ZodNumber;
123
+ }, z.core.$strip>;
124
+ type: z.ZodEnum<{
125
+ action: "action";
126
+ condition: "condition";
127
+ end: "end";
128
+ errorHandler: "errorHandler";
129
+ forEach: "forEach";
130
+ join: "join";
131
+ loopEnd: "loopEnd";
132
+ parallel: "parallel";
133
+ repeat: "repeat";
134
+ trigger: "trigger";
135
+ tryCatch: "tryCatch";
136
+ while: "while";
137
+ }>;
138
+ label: z.ZodString;
139
+ nodeDefinitionId: z.ZodOptional<z.ZodString>;
140
+ nodeDefinition: z.ZodOptional<z.ZodUnknown>;
141
+ config: z.ZodDefault<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
142
+ continueOnError: z.ZodOptional<z.ZodBoolean>;
143
+ }, z.core.$strip>>;
144
+ connections: z.ZodArray<z.ZodObject<{
145
+ id: z.ZodString;
146
+ fromStepId: z.ZodString;
147
+ toStepId: z.ZodString;
148
+ fromPosition: z.ZodObject<{
149
+ row: z.ZodNumber;
150
+ col: z.ZodNumber;
151
+ }, z.core.$strip>;
152
+ toPosition: z.ZodObject<{
153
+ row: z.ZodNumber;
154
+ col: z.ZodNumber;
155
+ }, z.core.$strip>;
156
+ label: z.ZodOptional<z.ZodString>;
157
+ condition: z.ZodOptional<z.ZodString>;
158
+ branchType: z.ZodOptional<z.ZodEnum<{
159
+ case: "case";
160
+ default: "default";
161
+ false: "false";
162
+ true: "true";
163
+ }>>;
164
+ branchValue: z.ZodOptional<z.ZodString>;
165
+ }, z.core.$strip>>;
166
+ testParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
167
+ }, z.core.$strip>;
168
+ declare const exportTemplateSchema: z.ZodObject<{
169
+ version: z.ZodDefault<z.ZodString>;
170
+ exportedAt: z.ZodString;
171
+ metadata: z.ZodObject<{
172
+ name: z.ZodString;
173
+ description: z.ZodOptional<z.ZodString>;
174
+ category: z.ZodOptional<z.ZodEnum<{
175
+ ai: "ai";
176
+ basic: "basic";
177
+ marketing: "marketing";
178
+ }>>;
179
+ icon: z.ZodOptional<z.ZodString>;
180
+ author: z.ZodOptional<z.ZodString>;
181
+ }, z.core.$strip>;
182
+ definition: z.ZodObject<{
183
+ gridSize: z.ZodDefault<z.ZodNumber>;
184
+ steps: z.ZodArray<z.ZodObject<{
185
+ id: z.ZodString;
186
+ position: z.ZodObject<{
187
+ row: z.ZodNumber;
188
+ col: z.ZodNumber;
189
+ }, z.core.$strip>;
190
+ type: z.ZodEnum<{
191
+ action: "action";
192
+ condition: "condition";
193
+ end: "end";
194
+ errorHandler: "errorHandler";
195
+ forEach: "forEach";
196
+ join: "join";
197
+ loopEnd: "loopEnd";
198
+ parallel: "parallel";
199
+ repeat: "repeat";
200
+ trigger: "trigger";
201
+ tryCatch: "tryCatch";
202
+ while: "while";
203
+ }>;
204
+ label: z.ZodString;
205
+ nodeDefinitionId: z.ZodOptional<z.ZodString>;
206
+ nodeDefinition: z.ZodOptional<z.ZodUnknown>;
207
+ config: z.ZodDefault<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
208
+ continueOnError: z.ZodOptional<z.ZodBoolean>;
209
+ }, z.core.$strip>>;
210
+ connections: z.ZodArray<z.ZodObject<{
211
+ id: z.ZodString;
212
+ fromStepId: z.ZodString;
213
+ toStepId: z.ZodString;
214
+ fromPosition: z.ZodObject<{
215
+ row: z.ZodNumber;
216
+ col: z.ZodNumber;
217
+ }, z.core.$strip>;
218
+ toPosition: z.ZodObject<{
219
+ row: z.ZodNumber;
220
+ col: z.ZodNumber;
221
+ }, z.core.$strip>;
222
+ label: z.ZodOptional<z.ZodString>;
223
+ condition: z.ZodOptional<z.ZodString>;
224
+ branchType: z.ZodOptional<z.ZodEnum<{
225
+ case: "case";
226
+ default: "default";
227
+ false: "false";
228
+ true: "true";
229
+ }>>;
230
+ branchValue: z.ZodOptional<z.ZodString>;
231
+ }, z.core.$strip>>;
232
+ testParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
233
+ }, z.core.$strip>;
234
+ }, z.core.$strip>;
235
+ type GridPositionInput = z.input<typeof gridPositionSchema>;
236
+ type GridStepInput = z.input<typeof gridStepSchema>;
237
+ type GridConnectionInput = z.input<typeof gridConnectionSchema>;
238
+ type GridWorkflowDefinitionInput = z.input<typeof gridWorkflowDefinitionSchema>;
239
+ type ExportTemplateInput = z.input<typeof exportTemplateSchema>;
240
+ type GridPositionOutput = z.output<typeof gridPositionSchema>;
241
+ type GridStepOutput = z.output<typeof gridStepSchema>;
242
+ type GridConnectionOutput = z.output<typeof gridConnectionSchema>;
243
+ type GridWorkflowDefinitionOutput = z.output<typeof gridWorkflowDefinitionSchema>;
244
+ type ExportTemplateOutput = z.output<typeof exportTemplateSchema>;
245
+ /** 파싱 실패 시의 안전값 — 뷰어는 빈 캔버스를 렌더한다 */
246
+ declare const EMPTY_GRID_WORKFLOW_DEFINITION: GridWorkflowDefinition;
247
+ /**
248
+ * Strict persistence/execution parser. Unlike the display parser below, this
249
+ * never turns corrupt stored JSON into an empty workflow.
250
+ */
251
+ declare function parseGridWorkflowDefinitionStrict(raw: unknown): GridWorkflowDefinition;
252
+ /**
253
+ * 저장된 정의를 **표시용**으로 안전하게 읽는다. 읽지 못하면 빈 캔버스를 돌려주고, 왜 못
254
+ * 읽었는지는 `onFallback`으로 알린다(호스트가 로그에 남긴다).
255
+ *
256
+ * ⚠️ 표시 경로(뷰어·목록) 전용 — 실행 경로는 손상된 정의를 빈 정의로 조용히 바꾸면 안 된다
257
+ * (오실행 위험). 그쪽은 `parseGridWorkflowDefinitionStrict`의 실패를 에러로 다룬다.
258
+ */
259
+ declare function parseGridWorkflowDefinition(raw: unknown, onFallback?: (error: unknown) => void): GridWorkflowDefinition;
260
+ type GridBounds = {
261
+ rows: number;
262
+ cols: number;
263
+ };
264
+ declare const MIN_COLS = 3;
265
+ declare const MIN_ROWS = 6;
266
+ declare const MAX_COLS = 16;
267
+ declare const MAX_ROWS = 64;
268
+ /**
269
+ * 스텝 배치에서 렌더 바운드를 파생한다.
270
+ * 행은 항상 콘텐츠 아래 1행 성장 마진을 포함한다 (세로 흐름 기본).
271
+ */
272
+ declare function deriveGridBounds(steps: GridStep[]): GridBounds;
273
+ /** 두 바운드의 축별 최대값 (파생 바운드 + 수동 확장 floor 병합용) */
274
+ declare function mergeBounds(a: GridBounds, b: GridBounds): GridBounds;
275
+ declare function isWithinBounds(position: GridPosition, bounds: GridBounds): boolean;
276
+ /** 하드캡 검사 — 저장/임포트 검증용 (렌더 바운드와 무관한 절대 상한) */
277
+ declare function isWithinHardCap(position: GridPosition): boolean;
278
+ type Point = {
279
+ x: number;
280
+ y: number;
281
+ };
282
+ type ContentRect = Point & {
283
+ width: number;
284
+ height: number;
285
+ };
286
+ /** 빈 행·열을 제외한 실제 스텝 영역. 화면 맞춤이 글씨를 불필요하게 축소하지 않는다. */
287
+ declare function getStepsRect(steps: readonly GridStep[]): ContentRect | undefined;
288
+ /** 뷰포트 transform (translate 후 scale, origin 0 0) */
289
+ type ViewportTransform = {
290
+ translateX: number;
291
+ translateY: number;
292
+ scale: number;
293
+ };
294
+ declare const IDENTITY_TRANSFORM: ViewportTransform;
295
+ /** 셀 좌상단 좌표 (콘텐츠 좌표계, padding = CELL_GAP/2) */
296
+ declare function getCellOrigin(position: GridPosition): Point;
297
+ /** 셀 중앙 좌표 (콘텐츠 좌표계) */
298
+ declare function getCellCenter(position: GridPosition): Point;
299
+ /**
300
+ * 연결선이 셀 경계에서 시작/끝나도록 가장자리 좌표 계산.
301
+ * 가로/세로 정렬이 아닌 경우(비인접 대각)는 중앙에서 시작/끝.
302
+ */
303
+ declare function getCellEdge(from: GridPosition, to: GridPosition): {
304
+ start: Point;
305
+ end: Point;
306
+ };
307
+ /** 바운드 기반 콘텐츠 픽셀 크기 */
308
+ declare function getContentSize(bounds: GridBounds): {
309
+ width: number;
310
+ height: number;
311
+ };
312
+ /** 콘텐츠 좌표 → 뷰포트 좌표 */
313
+ declare function contentToViewport(point: Point, t: ViewportTransform): Point;
314
+ /** 뷰포트 좌표 → 콘텐츠 좌표 */
315
+ declare function viewportToContent(point: Point, t: ViewportTransform): Point;
316
+ /** 뷰포트 좌표가 가리키는 셀 (바운드 밖이면 null) */
317
+ declare function viewportPointToCell(point: Point, t: ViewportTransform, bounds: GridBounds): GridPosition | null;
318
+ /** 셀의 뷰포트 좌표계 사각형 (액션바 앵커링용) */
319
+ declare function cellToViewportRect(position: GridPosition, t: ViewportTransform): {
320
+ top: number;
321
+ left: number;
322
+ width: number;
323
+ height: number;
324
+ };
325
+ /**
326
+ * 흐름 순서 — 트리거(없으면 맨 위 왼쪽 스텝)부터 연결을 따라 BFS, 닿지 않는 스텝은 위치
327
+ * 순으로 뒤에 붙인다. 목록 미리보기(`orderStepsForPreview`)와 키보드 스텝 이동이 같은 순서를
328
+ * 쓴다 — 예전 키보드 이동은 행→열 순이라 분기가 있으면 흐름과 다르게 움직였다.
329
+ */
330
+ declare function orderStepsByFlow(steps: readonly GridStep[], connections: readonly GridConnection[]): GridStep[];
331
+ /** 같은 행·열에서 그 방향으로 가장 가까운 스텝의 자리 — 사이의 빈 칸을 건너뛴다. */
332
+ declare function findStepInDirection(steps: readonly GridStep[], from: GridPosition, direction: ConnectionDirection): GridPosition | null;
333
+ /** 한 스텝에 붙은 연결을 키보드가 도는 순서 — 나가는 연결 먼저, 그다음 들어오는 연결. */
334
+ declare function listStepConnections(stepId: string, connections: readonly GridConnection[]): GridConnection[];
335
+ /**
336
+ * 연결 순회의 다음 차례. 고른 연결이 없으면 첫 번째(뒤로 돌면 마지막)부터, 끝에서는 처음으로
337
+ * 돌아온다. 붙은 연결이 없으면 null.
338
+ */
339
+ declare function cycleStepConnection(stepId: string, connections: readonly GridConnection[], currentId: string | null, reverse: boolean): GridConnection | null;
340
+ /** 고른 연결에서 지금 스텝의 반대편 자리 — Enter로 연결을 따라갈 때 쓴다. */
341
+ declare function getConnectionFarEnd(connection: GridConnection, fromStepId: string): GridPosition;
342
+ /** 키보드로 고른 연결과, 고를 때의 선택 */
343
+ type ConnectionFocus = {
344
+ connectionId: string;
345
+ selection: GridPosition;
346
+ };
347
+ /**
348
+ * 고른 연결이 **지금도 유효한가**. 유효 조건은 셋이다: 고른 뒤로 선택이 바뀌지 않았고(같은
349
+ * 객체), 선택한 칸에 스텝이 있고, 그 연결이 아직 그 스텝에 붙어 있다.
350
+ *
351
+ * 🔴 선택을 스텝 id로 비교하면 안 된다 — 다른 칸에 갔다가 돌아오면 고른 연결이 되살아나고,
352
+ * 그 상태의 Delete는 스텝이 아니라 연결을 지운다. 선택을 다시 정하는 모든 경로는 새 객체를
353
+ * 만들므로 객체 동일성이 "선택이 한 번도 안 바뀌었다"를 뜻한다.
354
+ */
355
+ declare function resolveConnectionFocus(focus: ConnectionFocus | null, selectedPosition: GridPosition | null, selectedStepId: string | undefined, connections: readonly GridConnection[]): string | null;
356
+ /** `anchor`에 인접한(4-이웃) 첫 빈 셀. 사방이 막혀 있으면 null. */
357
+ declare function findFreeAdjacentCell(anchor: GridPosition, steps: GridStep[]): GridPosition | null;
358
+ /**
359
+ * 여러 앵커 **모두의** 이웃인 첫 빈 셀 — 합류 스텝(두 갈래가 모이는 join·종료) 자리.
360
+ * 이웃이 아니어도 연결은 되지만, 합류 스텝이 모든 앞 스텝 옆에 있으면 선이 가장 짧다.
361
+ * 그런 칸이 없으면 null(호출부가 첫 앵커 기준 배치로 물러난다).
362
+ */
363
+ declare function findFreeCommonNeighbor(anchors: GridPosition[], steps: GridStep[]): GridPosition | null;
364
+ /** 인접 셀이 모두 찼을 때 `anchor`에서 바깥으로 BFS 하며 가장 가까운 빈 셀. */
365
+ declare function findNearestFreeCell(anchor: GridPosition, steps: GridStep[]): GridPosition | null;
366
+ /**
367
+ * 연결 유효성 검사 — 자기 자신·중복·순환. 유효하면 null, 아니면 사용자용 사유 문자열.
368
+ *
369
+ * 🔑 **이웃 칸이 아니어도 연결된다.** 예전에는 이 함수만 이웃 칸을 요구했는데, 사람이 쓰는
370
+ * 연결 모드는 원래 그 검사가 없었고 스텝을 옮기면 떨어진 연결이 그대로 남았다(템플릿 연결의
371
+ * 41%가 비인접이다) — AI 제안 경로만 "이웃이 아니라 연결 못 함"으로 스텝을 연결 없이 남겼다.
372
+ * 떨어진 연결은 `lib/grid-route`가 거터로 돌려 그린다. 사람(연결 모드)과 AI(제안 미리보기·
373
+ * 세션)가 이 함수 **한 벌**을 쓴다.
374
+ */
375
+ declare function validateConnection(from: GridStep, to: GridStep, connections: GridConnection[]): string | null;
376
+ type IsCellOccupied = (position: GridPosition) => boolean;
377
+ /** 두 셀을 잇는 꺾임점 목록(콘텐츠 좌표계). 첫 점은 출발 카드의 변, 끝 점은 도착 카드의 변. */
378
+ declare function routeConnection(from: GridPosition, to: GridPosition, isOccupied: IsCellOccupied): Point[];
379
+ /** 꺾임점을 직선 + 모서리 호로 잇는 SVG path. 구간이 반지름보다 짧으면 호를 줄인다. */
380
+ declare function roundedPath(points: readonly Point[], radius?: number): string;
381
+ /**
382
+ * 분기 라벨이 앉을 자리 — **실제로 그려진 선분 위**다. 예전에는 시작·끝의 직선 중점이라
383
+ * 꺾이는 연결에서는 라벨이 선에서 떨어진 허공에 놓였다.
384
+ */
385
+ declare function routeLabelPoint(points: readonly Point[]): Point;
386
+ /**
387
+ * 라벨 자리가 다른 라벨과 겹칠 때 쓰는 두 번째 자리 — 도착 스텝 쪽 구간. 같은 조건 스텝에서
388
+ * 나간 두 분기가 첫 구간을 함께 쓰면 첫 자리가 같아진다.
389
+ */
390
+ declare function routeLabelFallbackPoint(points: readonly Point[]): Point;
391
+ /** 미리보기 칩에 필요한 최소 스텝 shape. */
392
+ type PreviewStep = Pick<GridStep, "id" | "type" | "label" | "nodeDefinitionId">;
393
+ type OrderedPreviewSteps = {
394
+ /** 시작 스텝(trigger 우선, 없으면 첫 스텝). 스텝이 하나도 없으면 null. */
395
+ start: PreviewStep | null;
396
+ /** 시작/끝을 제외한 중간 스텝들 — 연결 흐름 순서(없으면 위치 순). */
397
+ middle: PreviewStep[];
398
+ /** 끝 스텝(end 우선, 없으면 마지막 스텝). start와 같으면 null. */
399
+ end: PreviewStep | null;
400
+ /** 렌더할 스텝이 전혀 없는지. */
401
+ isEmpty: boolean;
402
+ };
403
+ /**
404
+ * 워크플로우 정의를 미리보기용 시작/중간/끝 스텝으로 정렬한다.
405
+ *
406
+ * 연결(fromStepId→toStepId)을 따라 시작 스텝부터 BFS 순회해 흐름 순서를 만들고,
407
+ * 연결이 없으면 그리드 위치 순으로 fallback한다. 레거시 nodes/edges 정의나 빈
408
+ * 정의는 `isEmpty: true`로 반환한다(미리보기에서 플레이스홀더 처리).
409
+ */
410
+ declare function orderStepsForPreview(definition: unknown): OrderedPreviewSteps;
411
+ declare function findRunBlockers(definition: GridWorkflowDefinition): string[];
412
+ type ConnectionRunStatus = "traversed" | "active" | "muted";
413
+ type RunPathStepState = {
414
+ status: string;
415
+ startedAt?: Date | string;
416
+ };
417
+ type RunPath = {
418
+ connectionStatus: Map<string, ConnectionRunStatus>;
419
+ /** 런이 끝났는데(settled) 한 번도 실행되지 않은 스텝 */
420
+ unreachedStepIds: Set<string>;
421
+ };
422
+ declare function deriveRunPath({ steps, connections, stepStates, settled }: {
423
+ steps: readonly GridStep[];
424
+ connections: readonly GridConnection[];
425
+ stepStates: ReadonlyMap<string, RunPathStepState>;
426
+ /** 런이 종결됐는가(완료·실패·타임아웃). 실행 중이면 false. */
427
+ settled: boolean;
428
+ }): RunPath;
429
+ declare function getStepSummary(step: GridStep): {
430
+ label: string;
431
+ value: string;
432
+ }[];
433
+ /**
434
+ * "이 자동화는 지금 상태로 돌지 않는다" — 저장된 정의에서 **미완성 설정**을 찾는다.
435
+ *
436
+ * 🔴 왜 필요한가: 에디터가 필수 미입력 저장을 막게 됐지만(`lib/config-fields`),
437
+ * **이미 저장된 정의는 그대로 남는다.** 일정 트리거에 실행 시각이 없는 워크플로우는
438
+ * 실행되지 않고, 실행되지 않으므로 실패 기록도 남지 않는다 — 사용자 눈에는 아무 일도
439
+ * 일어나지 않는 자동화로만 보인다. 목록에서 그 사실을 먼저 말해 줘야 한다.
440
+ *
441
+ * 🔑 판정은 **카탈로그 선언에서 파생**한다(`required` + `showWhen`). 여기에 "일정에는
442
+ * 시각이 있어야 한다" 같은 규칙을 다시 적으면 선언과 갈린다.
443
+ */
444
+ type WorkflowSetupProblem = {
445
+ stepId: string;
446
+ stepLabel: string;
447
+ /** 비어 있는 필수 필드의 라벨들 */
448
+ missingLabels: string[];
449
+ /**
450
+ * 분기 구성 오류(중복 case·참 분기 2개 등).
451
+ *
452
+ * 🔑 **오류만 담고 경고는 담지 않는다** — "default 분기가 없다"는 정당한 설계일 수
453
+ * 있고, 그것까지 배지로 띄우면 상시 소음이 된다. 한쪽 분기만 그려서 반대 결과일 때
454
+ * 흐름이 끝나는 것은 **그 런의 상세**가 그 순간에 말해 준다.
455
+ */
456
+ issues?: string[];
457
+ };
458
+ /**
459
+ * 정의 전체에서 "채워야 할 것이 남은" 스텝을 모은다(없으면 빈 배열).
460
+ *
461
+ * ⚠️ 인자가 `unknown`인 것은 의도다 — 이 값은 **DB에 저장된 JSON**이고, 목록·상세가
462
+ * 서로 다른 DTO 타입으로 들고 있다. 모양을 여기서 확인하고 아니면 조용히 빈 배열.
463
+ */
464
+ declare function findWorkflowSetupProblems(definition: unknown): WorkflowSetupProblem[];
465
+ /** `showWhen` 조건을 만족해 화면에 그려지는 필드만 남긴다. */
466
+ declare function visibleConfigFields<T extends NodeConfigField>(fields: readonly T[], config: Record<string, unknown>): T[];
467
+ /** 화면에 보이면서 필수인데 비어 있는 필드 — 저장을 막는 이유가 된다. */
468
+ declare function missingRequiredFields<T extends NodeConfigField>(fields: readonly T[], config: Record<string, unknown>): T[];
469
+ /** AI가 제안한 단일 변경. 채팅 data part를 클라이언트가 staging 한 형태. */
470
+ type WorkflowProposalOp = {
471
+ kind: "add";
472
+ stepId: string;
473
+ stepType: GridStepType;
474
+ label: string;
475
+ nodeDefinitionId?: string;
476
+ config?: Record<string, unknown>;
477
+ afterStepId?: string;
478
+ branchType?: BranchType;
479
+ branchValue?: string;
480
+ /**
481
+ * 이 스텝으로 **함께** 모이는 다른 앞 스텝들(합류) — `afterStepId`와 이것들 모두의
482
+ * 이웃 칸에 놓고 각각에서 연결한다(그런 칸이 없으면 첫 앵커 기준으로 놓고 그래도 잇는다).
483
+ */
484
+ mergeFromStepIds?: string[];
485
+ /**
486
+ * 끼워 넣기 — `afterStepId → insertBeforeStepId` 연결 사이에 이 스텝을 넣는다. 그 연결은
487
+ * `after → 새 스텝 → before`로 바뀌고 분기 표시는 `after → 새 스텝`으로 옮긴다.
488
+ * 위아래로 붙은 두 스텝 사이에는 둘 다의 이웃인 칸이 없으므로(4-이웃) 뒤쪽 연결은 이웃
489
+ * 제약을 면제한다 — 렌더러는 떨어진 연결을 곡선으로 그리고, 사람이 스텝을 옮겨도 같은
490
+ * 연결이 생긴다. 이웃 제약은 손으로 잇는 UX 규칙이지 데이터 불변식이 아니다.
491
+ */
492
+ insertBeforeStepId?: string;
493
+ } | {
494
+ kind: "update";
495
+ stepId: string;
496
+ label?: string;
497
+ config?: Record<string, unknown>;
498
+ /**
499
+ * 노드 종류 교체 — 에디터의 "노드 변경"과 같다. 위치·연결은 그대로, 스텝 종류는 새 노드에서
500
+ * 파생하고 설정은 **병합하지 않고** `config`로 갈아 끼운다(키가 다른 노드의 설정을 섞지 않는다).
501
+ * 삭제 후 추가로 하면 새 스텝이 다른 칸에 놓여 기존 연결을 다시 이을 수 없다.
502
+ */
503
+ nodeDefinitionId?: string;
504
+ /** 교체 시 파생된 스텝 종류 — 서버 세션이 채운다(`stepTypeForNode`) */
505
+ stepType?: GridStepType;
506
+ } | {
507
+ kind: "delete";
508
+ stepId: string;
509
+ } | {
510
+ kind: "connect";
511
+ fromStepId: string;
512
+ toStepId: string;
513
+ branchType?: BranchType;
514
+ branchValue?: string;
515
+ } | {
516
+ kind: "deleteConnection";
517
+ connectionId: string;
518
+ };
519
+ type PreviewGraph = {
520
+ /** committed + added 스텝 (deleted 도 포함 — 표시용, statusByStepId 로 구분) */
521
+ previewSteps: GridStep[];
522
+ previewConnections: GridConnection[];
523
+ /** 변경된 것만 담음(없으면 unchanged) */
524
+ statusByStepId: Map<string, PreviewStatus>;
525
+ statusByConnectionId: Map<string, PreviewStatus>;
526
+ /** 배치 실패·무효 연결 등 비치명적 안내 */
527
+ warnings: string[];
528
+ };
529
+ declare function computePreviewGraph(committedSteps: GridStep[], committedConnections: GridConnection[], ops: WorkflowProposalOp[]): PreviewGraph;
530
+ /** [적용] 시 commit 할 최종 그래프 — deleted 태깅 대상 제거. */
531
+ declare function selectAppliedGraph(preview: PreviewGraph): {
532
+ steps: GridStep[];
533
+ connections: GridConnection[];
534
+ };
535
+ type ProposalOpResult = {
536
+ ok: true;
537
+ /** 미리보기 경고 중 이 op가 새로 만든 것(자동 연결 실패 등) */
538
+ warnings: string[];
539
+ /** 실행 전 점검 이슈 중 이 op가 새로 만든 것 */
540
+ issues: string[];
541
+ /** stage할 op — 서버가 파생한 값(스텝 타입 등)이 채워져 있다 */
542
+ op: WorkflowProposalOp;
543
+ } | {
544
+ ok: false;
545
+ error: string;
546
+ };
547
+ type WorkflowProposalSession = {
548
+ /** op를 적용해 본다. ok면 세션에 누적되고, 아니면 아무것도 바뀌지 않는다. */
549
+ apply: (op: WorkflowProposalOp) => ProposalOpResult;
550
+ /** 지금까지의 제안을 적용했을 때의 그래프(삭제 제외) */
551
+ appliedGraph: () => {
552
+ steps: GridStep[];
553
+ connections: GridConnection[];
554
+ };
555
+ };
556
+ declare function resolveCatalogNode(nodeDefinitionId: string): NodeDefinition | undefined;
557
+ /**
558
+ * 카탈로그 설정 검증 — 모르는 키·보이는 필수 필드 누락. 에디터 저장 버튼과 같은
559
+ * `missingRequiredFields`를 쓴다(숨겨진 필드는 요구하지 않는다).
560
+ */
561
+ declare function validateStepConfig(step: Pick<GridStep, "type" | "nodeDefinitionId" | "config">): string | null;
562
+ declare function createWorkflowProposalSession(input: {
563
+ steps: GridStep[];
564
+ connections: GridConnection[];
565
+ /** 사용자가 아직 적용하지 않은 이전 제안 — 클라이언트 pendingOps 그대로 */
566
+ pendingOps?: WorkflowProposalOp[];
567
+ gridSize?: number;
568
+ }): WorkflowProposalSession;
569
+ declare function buildWorkflowBrief(definition: Pick<GridWorkflowDefinition, "steps" | "connections">, metadata: {
570
+ name: string;
571
+ description?: string;
572
+ }): string;
573
+ /**
574
+ * 유효성 검사 결과
575
+ */
576
+ type ValidationResult = {
577
+ valid: boolean;
578
+ errors: ValidationError[];
579
+ warnings: ValidationWarning[];
580
+ };
581
+ type ValidationError = {
582
+ code: string;
583
+ message: string;
584
+ path?: string;
585
+ stepId?: string;
586
+ connectionId?: string;
587
+ };
588
+ type ValidationWarning = {
589
+ code: string;
590
+ message: string;
591
+ path?: string;
592
+ stepId?: string;
593
+ };
594
+ /**
595
+ * 워크플로우 정의 유효성 검사
596
+ */
597
+ declare function validateWorkflowDefinition(definition: unknown): ValidationResult;
598
+ /**
599
+ * 템플릿 내보내기
600
+ */
601
+ declare function exportTemplate(definition: GridWorkflowDefinition, metadata: {
602
+ name: string;
603
+ description?: string;
604
+ category?: "basic" | "ai" | "marketing";
605
+ icon?: string;
606
+ author?: string;
607
+ }): ExportTemplateOutput;
608
+ /**
609
+ * 템플릿을 JSON 문자열로 직렬화
610
+ */
611
+ declare function serializeTemplate(definition: GridWorkflowDefinition, metadata: {
612
+ name: string;
613
+ description?: string;
614
+ category?: "basic" | "ai" | "marketing";
615
+ icon?: string;
616
+ author?: string;
617
+ }): string;
618
+ /**
619
+ * 템플릿 가져오기 결과
620
+ */
621
+ type ImportResult = {
622
+ success: boolean;
623
+ definition?: GridWorkflowDefinition;
624
+ metadata?: {
625
+ name: string;
626
+ description?: string;
627
+ category?: "basic" | "ai" | "marketing";
628
+ icon?: string;
629
+ author?: string;
630
+ };
631
+ validation: ValidationResult;
632
+ error?: string;
633
+ };
634
+ /**
635
+ * 템플릿 가져오기
636
+ */
637
+ declare function importTemplate(jsonString: string): ImportResult;
638
+ /**
639
+ * AI 생성 스텝의 **부분 출력 스트리밍** 계약 — 서버(핸들러)와 클라이언트(캔버스)가 같은
640
+ * 이름·모양을 쓴다(클라이언트 안전, 순수).
641
+ *
642
+ * 핸들러는 `context.emit(data, { namespace: AI_TEXT_STREAM_NAMESPACE })`로 지금까지의
643
+ * 전체 텍스트를 보내고(조각이 아니라 누적 — 이벤트가 하나 빠져도 화면이 어긋나지 않는다),
644
+ * 캔버스는 실행 중인 카드에 그 텍스트를 흘려 보여 준다. 참조 구현(100ms 스로틀)과 같다.
645
+ */
646
+ declare const AI_TEXT_STREAM_NAMESPACE = "ai-text";
647
+ type AiTextStreamData = {
648
+ kind: "ai-text";
649
+ /** 지금까지 생성된 전체 텍스트 */
650
+ text: string;
651
+ };
652
+ declare function isAiTextStreamData(data: unknown): data is AiTextStreamData;
653
+ /**
654
+ * 스로틀 방출기 — 마지막 값만 기억했다가 간격마다 한 번 보내고, `flush`가 남은 값을
655
+ * 반드시 보낸다(끝 조각이 사라지면 "완료 직전에서 멈춘" 것처럼 보인다).
656
+ */
657
+ declare function createThrottledEmitter<T>(send: (value: T) => Promise<void> | void, intervalMs: number, now?: () => number): {
658
+ push: (value: T) => void;
659
+ flush: () => Promise<void>;
660
+ };
661
+ /**
662
+ * 선택지 분류의 후보 목록 — 한 줄에 하나. 공백 줄·중복은 버린다(모델이 고를 수 없는
663
+ * 값이 목록에 남으면 구조화 출력이 거절된다).
664
+ */
665
+ declare function parseChoiceList(text: string | undefined): string[];
666
+ /**
667
+ * 실패 원인 범주 — 사용자가 **다음에 무엇을 할지**로 가른다.
668
+ * (기술적 분류가 아니라 행동 분류다. "SSRF 차단"은 원인이지만 사용자가 할 일은
669
+ * "주소를 고친다"이므로 `configuration`이다.)
670
+ */
671
+ declare const FAILURE_CAUSES: readonly [
672
+ /** 워크플로우 설정을 고쳐야 한다 (잘못된 값·주소·스키마) */
673
+ "configuration",
674
+ /** 참조한 데이터가 없거나 모양이 다르다 (고객 없음, 배열이 아님) */
675
+ "data",
676
+ /** 상대 서비스 문제 — 우리 설정은 맞다 */
677
+ "external-service",
678
+ /** 일시적 — 다시 실행하면 될 가능성이 높다 */
679
+ "transient",
680
+ /** 플랜 한도·권한 */
681
+ "limit",
682
+ /** 사용자가 멈췄다 */
683
+ "cancelled",
684
+ /** 워크플로우 구조 문제 (트리거 없음·순환·핸들러 미등록) */
685
+ "definition",
686
+ /** 가르지 못했다 — **추측하지 않는다** */
687
+ "unknown"];
688
+ type FailureCause = (typeof FAILURE_CAUSES)[number];
689
+ type FailureTriage = {
690
+ cause: FailureCause;
691
+ /**
692
+ * 사용자가 고칠 수 있는가.
693
+ * 🔑 **없으면 "모른다"이지 false가 아니다** — 결정론 판정은 언제나 채우지만,
694
+ * 모델 판정은 그 축을 확신했을 때만 채운다. false로 적으면 "고칠 수 없다"는
695
+ * 잘못된 조언이 된다.
696
+ */
697
+ userFixable?: boolean;
698
+ /** 그대로 재실행하면 될 가능성이 있는가 (없으면 "모른다") */
699
+ retryLikelyHelps?: boolean;
700
+ /** 이 판정의 출처 — 집계할 때 섞이면 안 된다 */
701
+ source: "deterministic" | "jev";
702
+ /** 판정 근거가 된 사실들 (사용자에게 그대로 보여 준다) */
703
+ evidence: string[];
704
+ /** jev 판정일 때만 — 최빈 답의 확률 */
705
+ confidence?: number;
706
+ };
707
+ /** 결정론 층이 답하지 못한 경우 — 호출측이 모델로 넘길지 정한다. */
708
+ type TriageOutcome = {
709
+ status: "resolved";
710
+ triage: FailureTriage;
711
+ } | {
712
+ status: "needs-model";
713
+ /** 모델에 넘길 상태 — 여기 담긴 것만 넘어간다(PII는 호출측이 이미 마스킹) */
714
+ residual: ResidualFailure;
715
+ };
716
+ type ResidualFailure = {
717
+ stepLabel: string;
718
+ stepType: string;
719
+ /** 노드 종류 — 어떤 통합인지가 판정에 크게 기여한다 */
720
+ nodeKind: string;
721
+ errorMessage: string;
722
+ retryCount: number;
723
+ /** 결정론 층이 이미 확보한 사실 — 모델이 다시 추론할 필요가 없다 */
724
+ facts: string[];
725
+ };
726
+ /**
727
+ * 실패한 스텝 하나를 결정론으로 판정한다.
728
+ *
729
+ * 🔑 순서가 규칙이다 — **더 구체적인 사실이 먼저** 이긴다. 예컨대 미해결 변수가 있으면
730
+ * 그것이 원인일 가능성이 압도적이므로(빈 값이 외부로 나가 422가 된다) `fatal`보다 앞선다.
731
+ */
732
+ declare function triageFailedStep(step: StepExecutionRecord): TriageOutcome;
733
+ /** 런 전체에서 **판정 대상 스텝**을 고른다 — 마지막 실패가 원인이다. */
734
+ declare function findFailedStep(stepRecords: StepExecutionRecord[]): StepExecutionRecord | undefined;
735
+ /** 범주 → 사용자가 읽는 한 줄. 기술 용어가 아니라 **다음 행동**으로 적는다. */
736
+ declare const FAILURE_CAUSE_COPY: Record<FailureCause, {
737
+ label: string;
738
+ hint: string;
739
+ tone: "fix" | "wait" | "unknown";
740
+ }>;
741
+ type StepSpec = {
742
+ id: string;
743
+ type: GridStepType;
744
+ label: string;
745
+ /** nodeDefinitionId — trigger/action/parallel 등. condition/end/join은 생략 */
746
+ node?: string;
747
+ /** [row, col] (0-8). 생략 시 인덱스 기반 자동 배치 {row: index, col: 4} */
748
+ pos?: [number, number];
749
+ config?: Record<string, unknown>;
750
+ };
751
+ type EdgeOptions = {
752
+ branchType?: BranchType;
753
+ branchValue?: string;
754
+ condition?: string;
755
+ label?: string;
756
+ };
757
+ /** [from, to] 또는 [from, to, 분기옵션] */
758
+ type EdgeSpec = [from: string, to: string, options?: EdgeOptions];
759
+ type TemplateSpec = {
760
+ id: string;
761
+ name: string;
762
+ description: string;
763
+ category: TemplateCategory;
764
+ icon: TemplateIconKey;
765
+ featured?: boolean;
766
+ order?: number;
767
+ tags?: string[];
768
+ /** 그리드 크기 (기본 9) */
769
+ gridSize?: number;
770
+ steps: StepSpec[];
771
+ /** 연결. 생략 시 스텝 순서대로 선형 자동 연결 */
772
+ flow?: EdgeSpec[];
773
+ };
774
+ declare function defineTemplate(spec: TemplateSpec): ExtendedWorkflowTemplate;
775
+ /**
776
+ * 조건 평가 결과에 따라 다음 스텝 ID 결정
777
+ */
778
+ declare function resolveBranchPath(conditionStep: GridStep, outgoingConnections: GridConnection[], conditionResult: unknown): string | null;
779
+ /**
780
+ * 분기 연결 검증
781
+ * 조건 스텝의 연결이 올바르게 구성되어 있는지 확인
782
+ */
783
+ declare function validateBranchConnections(conditionStep: GridStep, connections: GridConnection[]): {
784
+ valid: boolean;
785
+ warnings: string[];
786
+ errors: string[];
787
+ };
788
+ /**
789
+ * 분기 타입별 레이블 생성
790
+ */
791
+ declare function getBranchLabel(branchType: BranchType, branchValue?: string): string;
792
+ /**
793
+ * 연결에서 분기 정보 추출
794
+ */
795
+ declare function extractBranchInfo(connection: GridConnection): {
796
+ type: BranchType | undefined;
797
+ value: string | undefined;
798
+ label: string;
799
+ };
800
+ /**
801
+ * 조건 평가 결과 타입
802
+ * boolean: if-else 조건
803
+ * string: switch case 값
804
+ */
805
+ type ConditionResult = boolean | string;
806
+ /**
807
+ * 저장된 조건 설정을 런타임 계약(`ConditionConfig`)으로 정규화한다 — **한 벌**.
808
+ *
809
+ * 🔴 조건의 키가 세 곳에서 갈려 있었다: 카탈로그(`condition-if-else`)는 `condition`,
810
+ * 템플릿도 `condition`, 실행기·검증기는 `expression`/`switchValue`만 읽었다. 그래서
811
+ * 에디터로 만든 조건은 실행 전 점검이 거절하고 실행기는 항상 false로 갔다(2026-09-23 실측).
812
+ * 지금은 카탈로그 키가 런타임 키와 같고, 옛 행·템플릿의 `condition`은 여기서 흡수한다.
813
+ * 평가·검증·화면 요약·설정 패널이 전부 이 함수를 거친다 — 두 곳에 적지 말 것.
814
+ */
815
+ declare function normalizeConditionConfig(raw: Record<string, unknown> | undefined): ConditionConfig;
816
+ /**
817
+ * 조건 평가
818
+ */
819
+ declare function evaluateCondition(config: Record<string, unknown>, context: WorkflowExecutionContext): Promise<ConditionResult>;
820
+ /**
821
+ * 조건식이 **지원 형식**인가 — 치환 전 원문으로 판정한다. 점검(`validateConditionConfig`)과
822
+ * 평가(`evaluateExpression`)가 같은 이 함수를 본다.
823
+ *
824
+ * 🔴 왜 필요한가(2026-09-23, 에이전트 실모델 프로브): "이메일이 @acme.com으로 끝나면"을
825
+ * 받은 모델이 `{{email}} endsWith '@acme.com'`을 썼다. 비교 연산자(`===`·`>` 등)가 없어
826
+ * 평가기의 "단일 값 참/거짓" 폴백으로 떨어졌고, 치환된 문자열은 비어 있지 않으니 **항상
827
+ * 참**이었다 — 모든 고객에게 태그가 붙는다. 점검도 "문제 없음"이었다(키가 채워졌는지만
828
+ * 봤다). 사람이 손으로 적어도 같은 구멍이다. 단일 값은 **`{{변수}}` 하나**일 때만 허용한다.
829
+ */
830
+ declare function findUnsupportedConditionExpression(expression: string): string | null;
831
+ /**
832
+ * 조건 설정 검증
833
+ */
834
+ declare function validateConditionConfig(raw: ConditionConfig | Record<string, unknown>): {
835
+ valid: boolean;
836
+ errors: string[];
837
+ };
838
+ /**
839
+ * 조건 그룹 재귀 평가 (AND/OR)
840
+ */
841
+ declare function evaluateConditionGroup(group: ConditionGroup, context: WorkflowExecutionContext): boolean;
842
+ /**
843
+ * 조건 평가 + 상세 정보 반환 (디버깅용)
844
+ */
845
+ declare function evaluateConditionWithDetails(config: Record<string, unknown>, context: WorkflowExecutionContext): Promise<{
846
+ result: ConditionResult;
847
+ details: ConditionEvalDetails;
848
+ }>;
849
+ /**
850
+ * 문자열 내 모든 변수를 치환
851
+ * @example resolveVariables('Hello {{name}}!', context) => 'Hello John!'
852
+ */
853
+ declare function resolveVariables(template: string, context: WorkflowExecutionContext): string;
854
+ /**
855
+ * AI 프롬프트용 치환 — 작성자가 쓴 프롬프트 문장은 그대로 두고 **치환된 값**의 꺾쇠괄호만
856
+ * `‹` `›`로 바꾼다. 폼 응답·고객 데이터 같은 값이 프롬프트의 `<inquiry>` 같은 데이터 블록을
857
+ * 닫고 지시를 끼워 넣지 못하게 한다.
858
+ */
859
+ declare function resolvePromptVariables(template: string, context: WorkflowExecutionContext): string;
860
+ /**
861
+ * 문자열 내 변수 패턴 존재 여부 확인
862
+ */
863
+ declare function hasVariables(template: string): boolean;
864
+ /**
865
+ * 문자열에서 모든 변수 경로 추출
866
+ */
867
+ declare function extractVariablePaths(template: string): string[];
868
+ /**
869
+ * "값을 가리키는 칸"(데이터 변환 입력·반복 대상 컬렉션)의 참조를 **값 그대로** 해석한다.
870
+ *
871
+ * 🔴 그 칸들은 변수 픽커가 붙어 있어 `{{step-2.output.data}}`가 들어가는데, 실행부는
872
+ * `context.variables[입력]`을 이름 그대로 읽어 **항상** "입력 변수를 찾을 수 없습니다"였다
873
+ * (트리거 페이로드·스텝 출력도 못 읽었다). 문자열로 치환하면 배열·객체가 JSON 문자열이
874
+ * 되므로 `resolveVariables`가 아니라 경로 조회를 쓴다. 토큰 없는 옛 값(`items`)은
875
+ * 같은 조회의 첫 단계(variables)가 그대로 받는다.
876
+ */
877
+ declare function resolveValueReference(reference: string, context: WorkflowExecutionContext): unknown;
878
+ /**
879
+ * 단일 변수 값 해석 (객체 형태로 반환)
880
+ */
881
+ declare function resolveVariableValue<T = unknown>(variablePath: string, context: WorkflowExecutionContext): T | undefined;
882
+ /**
883
+ * 객체 안에서 **해석되지 않은** 변수 경로를 모은다.
884
+ *
885
+ * 미해석 토큰은 빈 문자열로 치환된다(그 동작 자체는 의도적이다 — 선택 변수를
886
+ * 쓰는 워크플로우가 많다). 문제는 **그것이 아무 데도 안 남는다**는 점이다:
887
+ * 수신자가 빈 이메일이 나가도 실행은 초록불이고 런 상세에도 흔적이 없다.
888
+ * 그래서 치환은 그대로 두고, 무엇이 비었는지를 기록으로 남긴다.
889
+ */
890
+ declare function collectUnresolvedVariables(value: unknown, context: WorkflowExecutionContext, seen?: Set<string>): string[];
891
+ /**
892
+ * 객체 내 모든 문자열 필드의 변수 치환
893
+ */
894
+ declare function resolveObjectVariables<T extends Record<string, unknown>>(obj: T, context: WorkflowExecutionContext): T;
895
+ /**
896
+ * 워크플로우 로그용 PII 마스킹.
897
+ *
898
+ * `logging-service.ts`가 input/output을 그대로 metadata로 저장해서
899
+ * `workflowLog.metadata`에 원본 PII가 남고 있었다. 이 모듈이 객체 트리를
900
+ * 한 번 훑어 다음을 가린다:
901
+ *
902
+ * - **키 기반**: `password`, `token`, `secret`, `apiKey`, `authorization`,
903
+ * `cookie`, `creditCard`/`cardNumber` 같은 민감 키는 값을 통째로 `***`로.
904
+ * - **값 기반 패턴**: 문자열 안의 이메일·전화번호·신용카드 번호·`Bearer ...`
905
+ * 토큰을 부분 마스킹.
906
+ *
907
+ * 완전한 PII 분류기는 아니다. 명백한 유출 케이스만 막고, 정밀한 클래스 분류는
908
+ * 별도 도메인 시스템(예: DLP)으로 미룬다.
909
+ */
910
+ /**
911
+ * 문자열 값에서 알려진 PII 패턴을 부분 마스킹.
912
+ */
913
+ declare function maskPiiString(input: string): string;
914
+ /**
915
+ * 객체 트리를 깊이 우선으로 순회하며 PII를 가린다.
916
+ * 순환 참조 / Map / Set / Date 같은 비-plain 값은 안전하게 통과시킨다.
917
+ */
918
+ declare function maskPiiDeep<T>(value: T, depth?: number, seen?: WeakSet<object>): T;
919
+ export { selectAppliedGraph as $, parseGridWorkflowDefinitionStrict as $t, triageFailedStep as A, IDENTITY_TRANSFORM as At, exportTemplate as B, viewportPointToCell as Bt, FAILURE_CAUSE_COPY as C, cycleStepConnection as Ct, ResidualFailure as D, orderStepsByFlow as Dt, FailureTriage as E, listStepConnections as Et, parseChoiceList as F, getCellCenter as Ft, ProposalOpResult as G, MIN_COLS as Gt, serializeTemplate as H, GridBounds as Ht, ImportResult as I, getCellEdge as It, resolveCatalogNode as J, isWithinBounds as Jt, WorkflowProposalSession as K, MIN_ROWS as Kt, ValidationError as L, getCellOrigin as Lt, AiTextStreamData as M, ViewportTransform as Mt, createThrottledEmitter as N, cellToViewportRect as Nt, TriageOutcome as O, resolveConnectionFocus as Ot, isAiTextStreamData as P, contentToViewport as Pt, computePreviewGraph as Q, parseGridWorkflowDefinition as Qt, ValidationResult as R, getContentSize as Rt, defineTemplate as S, ConnectionFocus as St, FailureCause as T, getConnectionFarEnd as Tt, validateWorkflowDefinition as U, MAX_COLS as Ut, importTemplate as V, viewportToContent as Vt, buildWorkflowBrief as W, MAX_ROWS as Wt, PreviewGraph as X, mergeBounds as Xt, validateStepConfig as Y, isWithinHardCap as Yt, WorkflowProposalOp as Z, EMPTY_GRID_WORKFLOW_DEFINITION as Zt, validateConditionConfig as _, ConditionConfig as _n, routeLabelPoint as _t, hasVariables as a, GridPositionOutput as an, ConnectionRunStatus as at, resolveBranchPath as b, findNearestFreeCell as bt, resolveValueReference as c, GridWorkflowDefinitionInput as cn, deriveRunPath as ct, ConditionResult as d, exportTemplateSchema as dn, PreviewStep as dt, ExportTemplateInput as en, missingRequiredFields as et, evaluateCondition as f, gridConnectionSchema as fn, orderStepsForPreview as ft, normalizeConditionConfig as g, gridWorkflowDefinitionSchema as gn, routeLabelFallbackPoint as gt, findUnsupportedConditionExpression as h, gridStepTypeSchema as hn, routeConnection as ht, extractVariablePaths as i, GridPositionInput as in, getStepSummary as it, AI_TEXT_STREAM_NAMESPACE as j, Point as jt, findFailedStep as k, ContentRect as kt, resolveVariableValue as l, GridWorkflowDefinitionOutput as ln, findRunBlockers as lt, evaluateConditionWithDetails as m, gridStepSchema as mn, roundedPath as mt, maskPiiString as n, GridConnectionInput as nn, WorkflowSetupProblem as nt, resolveObjectVariables as o, GridStepInput as on, RunPath as ot, evaluateConditionGroup as p, gridPositionSchema as pn, IsCellOccupied as pt, createWorkflowProposalSession as q, deriveGridBounds as qt, collectUnresolvedVariables as r, GridConnectionOutput as rn, findWorkflowSetupProblems as rt, resolvePromptVariables as s, GridStepOutput as sn, RunPathStepState as st, maskPiiDeep as t, ExportTemplateOutput as tn, visibleConfigFields as tt, resolveVariables as u, branchTypeSchema as un, OrderedPreviewSteps as ut, extractBranchInfo as v, ConditionGroup as vn, findFreeAdjacentCell as vt, FAILURE_CAUSES as w, findStepInDirection as wt, validateBranchConnections as x, validateConnection as xt, getBranchLabel as y, SingleCondition as yn, findFreeCommonNeighbor as yt, ValidationWarning as z, getStepsRect as zt };