silkio-flowchart 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 (55) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +38 -3
  3. package/dist/FlowEdge.d.ts +45 -0
  4. package/dist/FlowEdge.js +390 -0
  5. package/dist/Shape.d.ts +48 -0
  6. package/dist/Shape.js +118 -0
  7. package/dist/ai-protocol.d.ts +146 -0
  8. package/dist/ai-protocol.js +578 -0
  9. package/dist/ai-report.d.ts +3 -0
  10. package/dist/ai-report.js +83 -0
  11. package/dist/ai.d.ts +6 -0
  12. package/dist/ai.js +7 -0
  13. package/dist/auto-layout.d.ts +15 -0
  14. package/dist/auto-layout.js +248 -0
  15. package/dist/commands.d.ts +106 -0
  16. package/dist/commands.js +264 -0
  17. package/dist/data.d.ts +24 -0
  18. package/dist/data.js +1 -0
  19. package/dist/edge-router.d.ts +24 -0
  20. package/dist/edge-router.js +22 -0
  21. package/dist/editing.d.ts +32 -0
  22. package/dist/editing.js +148 -0
  23. package/dist/flow-layout-capability.d.ts +7 -0
  24. package/dist/flow-layout-capability.js +2 -0
  25. package/dist/flowchart.d.ts +115 -0
  26. package/dist/flowchart.js +1425 -0
  27. package/dist/geometry.d.ts +98 -0
  28. package/dist/geometry.js +310 -0
  29. package/dist/history-codec.d.ts +47 -0
  30. package/dist/history-codec.js +410 -0
  31. package/dist/hover.d.ts +22 -0
  32. package/dist/hover.js +96 -0
  33. package/dist/index.d.ts +22 -0
  34. package/dist/index.js +18 -0
  35. package/dist/interactions.d.ts +51 -0
  36. package/dist/interactions.js +636 -0
  37. package/dist/model.d.ts +58 -0
  38. package/dist/model.js +233 -0
  39. package/dist/overlay.d.ts +60 -0
  40. package/dist/overlay.js +242 -0
  41. package/dist/quick-create.d.ts +12 -0
  42. package/dist/quick-create.js +29 -0
  43. package/dist/selection.d.ts +8 -0
  44. package/dist/selection.js +31 -0
  45. package/dist/session.d.ts +68 -0
  46. package/dist/session.js +4 -0
  47. package/dist/shape-registry.d.ts +17 -0
  48. package/dist/shape-registry.js +36 -0
  49. package/dist/shapes.d.ts +56 -0
  50. package/dist/shapes.js +291 -0
  51. package/dist/snap-capability.d.ts +23 -0
  52. package/dist/snap-capability.js +32 -0
  53. package/dist/snap.d.ts +34 -0
  54. package/dist/snap.js +370 -0
  55. package/package.json +32 -3
@@ -0,0 +1,146 @@
1
+ import type { BuiltinShapeKind, FlowData, ShapeKind } from "./data";
2
+ import type { FlowLayoutOptions } from "./auto-layout";
3
+ import type { PortDir } from "./FlowEdge";
4
+ export type AIFlowRole = "start" | "end" | "decision" | "io" | "process" | "data" | "note";
5
+ export interface AIFlowNode {
6
+ id?: string;
7
+ shape?: ShapeKind;
8
+ role?: AIFlowRole;
9
+ text: string;
10
+ }
11
+ export interface AIFlowEdge {
12
+ from: string;
13
+ to: string;
14
+ text?: string;
15
+ fromDir?: PortDir;
16
+ toDir?: PortDir;
17
+ }
18
+ export interface AIFlowGraph {
19
+ nodes: AIFlowNode[];
20
+ edges: AIFlowEdge[];
21
+ }
22
+ export interface NormalizedFlowNode {
23
+ id: string;
24
+ shape: BuiltinShapeKind;
25
+ text: string;
26
+ }
27
+ export interface NormalizedFlowGraph {
28
+ nodes: NormalizedFlowNode[];
29
+ edges: AIFlowEdge[];
30
+ }
31
+ export interface AIFlowRenderOp {
32
+ op: "render";
33
+ graph: AIFlowGraph;
34
+ }
35
+ export interface AIFlowCreateNodeOp {
36
+ op: "createNode";
37
+ ref: string;
38
+ dir: PortDir;
39
+ shape?: BuiltinShapeKind;
40
+ text?: string;
41
+ }
42
+ export interface AIFlowUpdateEdgeOp {
43
+ op: "updateEdge";
44
+ ref: {
45
+ from: string;
46
+ to: string;
47
+ text?: string;
48
+ };
49
+ from?: string;
50
+ to?: string;
51
+ fromDir?: PortDir;
52
+ toDir?: PortDir;
53
+ text?: string;
54
+ }
55
+ export interface AIFlowReplaceShapeOp {
56
+ op: "replaceShape";
57
+ ref: string;
58
+ shape: BuiltinShapeKind;
59
+ }
60
+ export interface AIFlowSetNodeTextOp {
61
+ op: "setNodeText";
62
+ ref: string;
63
+ text: string;
64
+ }
65
+ export interface AIFlowRemoveNodeOp {
66
+ op: "removeNode";
67
+ ref: string;
68
+ }
69
+ export interface AIFlowRemoveEdgeOp {
70
+ op: "removeEdge";
71
+ ref: string | {
72
+ from: string;
73
+ to: string;
74
+ text?: string;
75
+ };
76
+ }
77
+ export interface AIFlowUndoOp {
78
+ op: "undo";
79
+ }
80
+ export interface AIFlowRedoOp {
81
+ op: "redo";
82
+ }
83
+ export interface AIFlowHistoryOp {
84
+ op: "history";
85
+ }
86
+ export interface AIFlowAnswerOp {
87
+ op: "answer";
88
+ text: string;
89
+ }
90
+ export type AIFlowOp = AIFlowRenderOp | AIFlowCreateNodeOp | AIFlowUpdateEdgeOp | AIFlowReplaceShapeOp | AIFlowSetNodeTextOp | AIFlowRemoveNodeOp | AIFlowRemoveEdgeOp | AIFlowUndoOp | AIFlowRedoOp | AIFlowHistoryOp | AIFlowAnswerOp;
91
+ export interface AIFlowSelection {
92
+ nodes: AIFlowNode[];
93
+ edges: AIFlowEdge[];
94
+ }
95
+ export interface AIFlowHistoryState {
96
+ canUndo: boolean;
97
+ canRedo: boolean;
98
+ undoCount: number;
99
+ redoCount: number;
100
+ }
101
+ export interface AIFlowTurn {
102
+ role: "user" | "assistant";
103
+ text: string;
104
+ }
105
+ export interface AIFlowEditRequest {
106
+ prompt: string;
107
+ graph: AIFlowGraph;
108
+ selection: AIFlowSelection;
109
+ historyState: AIFlowHistoryState;
110
+ history: AIFlowTurn[];
111
+ }
112
+ export type AIFlowGenerate = (req: AIFlowEditRequest) => Promise<AIFlowOp[] | AIFlowGraph | string>;
113
+ export interface AIFlowRunOptions {
114
+ history?: AIFlowTurn[];
115
+ layout?: FlowLayoutOptions;
116
+ }
117
+ export interface AIFlowRunResult {
118
+ graph: AIFlowGraph;
119
+ data: FlowData;
120
+ answer?: string;
121
+ applied: number;
122
+ steps: AIFlowStep[];
123
+ }
124
+ export interface AIFlowStep {
125
+ op: AIFlowOp;
126
+ label: string;
127
+ status: "applied" | "skipped";
128
+ }
129
+ export declare function inferFlowShape(node: {
130
+ shape?: unknown;
131
+ role?: unknown;
132
+ text: string;
133
+ }): BuiltinShapeKind;
134
+ export declare function toSemanticGraph(data: FlowData): AIFlowGraph;
135
+ export declare function mergeFlowGeometry(current: FlowData, laid: FlowData): FlowData;
136
+ export declare function normalizeAIFlowGraph(raw: unknown): NormalizedFlowGraph;
137
+ export declare function normalizeAIFlowOps(raw: unknown): AIFlowOp[];
138
+ export declare function parseAIFlowOps(raw: AIFlowOp[] | AIFlowGraph | string): {
139
+ ops: AIFlowOp[];
140
+ answer?: string;
141
+ };
142
+ export declare function parseAIFlowResponse(raw: AIFlowGraph | string): {
143
+ graph?: AIFlowGraph;
144
+ answer?: string;
145
+ };
146
+ export declare function defaultAIFlowPrompt(req: AIFlowEditRequest): string;