@studio8collective/patent-render 1.0.0 → 1.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.
package/dist/index.d.ts CHANGED
@@ -884,6 +884,373 @@ declare const PatentDocument: z.ZodObject<{
884
884
  explodeLines: z.ZodDefault<z.ZodBoolean>;
885
885
  sheetLabel: z.ZodOptional<z.ZodString>;
886
886
  chat: z.ZodDefault<z.ZodArray<z.ZodUnknown>>;
887
+ run: z.ZodCatch<z.ZodOptional<z.ZodObject<{
888
+ id: z.ZodString;
889
+ kind: z.ZodEnum<{
890
+ new: "new";
891
+ edit: "edit";
892
+ }>;
893
+ request: z.ZodString;
894
+ preferences: z.ZodOptional<z.ZodObject<{
895
+ figureType: z.ZodOptional<z.ZodEnum<{
896
+ flowchart: "flowchart";
897
+ blockDiagram: "blockDiagram";
898
+ mechanical2d: "mechanical2d";
899
+ uiScreen: "uiScreen";
900
+ perspective3d: "perspective3d";
901
+ circuit: "circuit";
902
+ chemical: "chemical";
903
+ }>>;
904
+ style: z.ZodDefault<z.ZodEnum<{
905
+ standard: "standard";
906
+ detailed: "detailed";
907
+ minimal: "minimal";
908
+ }>>;
909
+ }, z.core.$strip>>;
910
+ selection: z.ZodDefault<z.ZodArray<z.ZodString>>;
911
+ chatLength: z.ZodDefault<z.ZodNumber>;
912
+ plan: z.ZodOptional<z.ZodObject<{
913
+ figureType: z.ZodEnum<{
914
+ flowchart: "flowchart";
915
+ blockDiagram: "blockDiagram";
916
+ mechanical2d: "mechanical2d";
917
+ uiScreen: "uiScreen";
918
+ perspective3d: "perspective3d";
919
+ circuit: "circuit";
920
+ chemical: "chemical";
921
+ }>;
922
+ view: z.ZodString;
923
+ summary: z.ZodString;
924
+ spec: z.ZodDefault<z.ZodString>;
925
+ components: z.ZodArray<z.ZodObject<{
926
+ numeral: z.ZodString;
927
+ name: z.ZodString;
928
+ description: z.ZodOptional<z.ZodString>;
929
+ reused: z.ZodDefault<z.ZodBoolean>;
930
+ }, z.core.$strip>>;
931
+ layers: z.ZodArray<z.ZodObject<{
932
+ id: z.ZodString;
933
+ name: z.ZodString;
934
+ }, z.core.$strip>>;
935
+ notes: z.ZodDefault<z.ZodArray<z.ZodString>>;
936
+ }, z.core.$strip>>;
937
+ steps: z.ZodDefault<z.ZodArray<z.ZodObject<{
938
+ label: z.ZodString;
939
+ status: z.ZodEnum<{
940
+ done: "done";
941
+ active: "active";
942
+ }>;
943
+ }, z.core.$strip>>>;
944
+ edits: z.ZodDefault<z.ZodNumber>;
945
+ before: z.ZodObject<{
946
+ jurisdiction: z.ZodEnum<{
947
+ uspto: "uspto";
948
+ pct: "pct";
949
+ epo: "epo";
950
+ ipo: "ipo";
951
+ }>;
952
+ sheet: z.ZodObject<{
953
+ size: z.ZodDefault<z.ZodEnum<{
954
+ a4: "a4";
955
+ letter: "letter";
956
+ }>>;
957
+ orientation: z.ZodDefault<z.ZodEnum<{
958
+ portrait: "portrait";
959
+ landscape: "landscape";
960
+ }>>;
961
+ }, z.core.$strip>;
962
+ layers: z.ZodArray<z.ZodObject<{
963
+ id: z.ZodString;
964
+ name: z.ZodString;
965
+ visible: z.ZodDefault<z.ZodBoolean>;
966
+ locked: z.ZodDefault<z.ZodBoolean>;
967
+ explode: z.ZodOptional<z.ZodObject<{
968
+ dx: z.ZodNumber;
969
+ dy: z.ZodNumber;
970
+ }, z.core.$strip>>;
971
+ items: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
972
+ type: z.ZodLiteral<"line">;
973
+ a: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
974
+ b: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
975
+ stroke: z.ZodDefault<z.ZodObject<{
976
+ width: z.ZodDefault<z.ZodNumber>;
977
+ style: z.ZodDefault<z.ZodEnum<{
978
+ solid: "solid";
979
+ dashed: "dashed";
980
+ centre: "centre";
981
+ phantom: "phantom";
982
+ }>>;
983
+ }, z.core.$strip>>;
984
+ id: z.ZodString;
985
+ name: z.ZodOptional<z.ZodString>;
986
+ rotation: z.ZodDefault<z.ZodNumber>;
987
+ locked: z.ZodDefault<z.ZodBoolean>;
988
+ hidden: z.ZodDefault<z.ZodBoolean>;
989
+ }, z.core.$strip>, z.ZodObject<{
990
+ type: z.ZodLiteral<"polyline">;
991
+ points: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
992
+ closed: z.ZodDefault<z.ZodBoolean>;
993
+ fill: z.ZodDefault<z.ZodEnum<{
994
+ none: "none";
995
+ black: "black";
996
+ white: "white";
997
+ }>>;
998
+ stroke: z.ZodDefault<z.ZodObject<{
999
+ width: z.ZodDefault<z.ZodNumber>;
1000
+ style: z.ZodDefault<z.ZodEnum<{
1001
+ solid: "solid";
1002
+ dashed: "dashed";
1003
+ centre: "centre";
1004
+ phantom: "phantom";
1005
+ }>>;
1006
+ }, z.core.$strip>>;
1007
+ id: z.ZodString;
1008
+ name: z.ZodOptional<z.ZodString>;
1009
+ rotation: z.ZodDefault<z.ZodNumber>;
1010
+ locked: z.ZodDefault<z.ZodBoolean>;
1011
+ hidden: z.ZodDefault<z.ZodBoolean>;
1012
+ }, z.core.$strip>, z.ZodObject<{
1013
+ type: z.ZodLiteral<"path">;
1014
+ d: z.ZodString;
1015
+ fill: z.ZodDefault<z.ZodEnum<{
1016
+ none: "none";
1017
+ black: "black";
1018
+ white: "white";
1019
+ }>>;
1020
+ stroke: z.ZodDefault<z.ZodObject<{
1021
+ width: z.ZodDefault<z.ZodNumber>;
1022
+ style: z.ZodDefault<z.ZodEnum<{
1023
+ solid: "solid";
1024
+ dashed: "dashed";
1025
+ centre: "centre";
1026
+ phantom: "phantom";
1027
+ }>>;
1028
+ }, z.core.$strip>>;
1029
+ id: z.ZodString;
1030
+ name: z.ZodOptional<z.ZodString>;
1031
+ rotation: z.ZodDefault<z.ZodNumber>;
1032
+ locked: z.ZodDefault<z.ZodBoolean>;
1033
+ hidden: z.ZodDefault<z.ZodBoolean>;
1034
+ }, z.core.$strip>, z.ZodObject<{
1035
+ type: z.ZodLiteral<"rect">;
1036
+ x: z.ZodNumber;
1037
+ y: z.ZodNumber;
1038
+ w: z.ZodNumber;
1039
+ h: z.ZodNumber;
1040
+ radius: z.ZodDefault<z.ZodNumber>;
1041
+ fill: z.ZodDefault<z.ZodEnum<{
1042
+ none: "none";
1043
+ black: "black";
1044
+ white: "white";
1045
+ }>>;
1046
+ stroke: z.ZodDefault<z.ZodObject<{
1047
+ width: z.ZodDefault<z.ZodNumber>;
1048
+ style: z.ZodDefault<z.ZodEnum<{
1049
+ solid: "solid";
1050
+ dashed: "dashed";
1051
+ centre: "centre";
1052
+ phantom: "phantom";
1053
+ }>>;
1054
+ }, z.core.$strip>>;
1055
+ id: z.ZodString;
1056
+ name: z.ZodOptional<z.ZodString>;
1057
+ rotation: z.ZodDefault<z.ZodNumber>;
1058
+ locked: z.ZodDefault<z.ZodBoolean>;
1059
+ hidden: z.ZodDefault<z.ZodBoolean>;
1060
+ }, z.core.$strip>, z.ZodObject<{
1061
+ type: z.ZodLiteral<"ellipse">;
1062
+ cx: z.ZodNumber;
1063
+ cy: z.ZodNumber;
1064
+ rx: z.ZodNumber;
1065
+ ry: z.ZodNumber;
1066
+ fill: z.ZodDefault<z.ZodEnum<{
1067
+ none: "none";
1068
+ black: "black";
1069
+ white: "white";
1070
+ }>>;
1071
+ stroke: z.ZodDefault<z.ZodObject<{
1072
+ width: z.ZodDefault<z.ZodNumber>;
1073
+ style: z.ZodDefault<z.ZodEnum<{
1074
+ solid: "solid";
1075
+ dashed: "dashed";
1076
+ centre: "centre";
1077
+ phantom: "phantom";
1078
+ }>>;
1079
+ }, z.core.$strip>>;
1080
+ id: z.ZodString;
1081
+ name: z.ZodOptional<z.ZodString>;
1082
+ rotation: z.ZodDefault<z.ZodNumber>;
1083
+ locked: z.ZodDefault<z.ZodBoolean>;
1084
+ hidden: z.ZodDefault<z.ZodBoolean>;
1085
+ }, z.core.$strip>, z.ZodObject<{
1086
+ type: z.ZodLiteral<"arc">;
1087
+ cx: z.ZodNumber;
1088
+ cy: z.ZodNumber;
1089
+ r: z.ZodNumber;
1090
+ start: z.ZodNumber;
1091
+ end: z.ZodNumber;
1092
+ stroke: z.ZodDefault<z.ZodObject<{
1093
+ width: z.ZodDefault<z.ZodNumber>;
1094
+ style: z.ZodDefault<z.ZodEnum<{
1095
+ solid: "solid";
1096
+ dashed: "dashed";
1097
+ centre: "centre";
1098
+ phantom: "phantom";
1099
+ }>>;
1100
+ }, z.core.$strip>>;
1101
+ id: z.ZodString;
1102
+ name: z.ZodOptional<z.ZodString>;
1103
+ rotation: z.ZodDefault<z.ZodNumber>;
1104
+ locked: z.ZodDefault<z.ZodBoolean>;
1105
+ hidden: z.ZodDefault<z.ZodBoolean>;
1106
+ }, z.core.$strip>, z.ZodObject<{
1107
+ type: z.ZodLiteral<"text">;
1108
+ x: z.ZodNumber;
1109
+ y: z.ZodNumber;
1110
+ text: z.ZodString;
1111
+ size: z.ZodDefault<z.ZodNumber>;
1112
+ anchor: z.ZodDefault<z.ZodEnum<{
1113
+ start: "start";
1114
+ end: "end";
1115
+ middle: "middle";
1116
+ }>>;
1117
+ id: z.ZodString;
1118
+ name: z.ZodOptional<z.ZodString>;
1119
+ rotation: z.ZodDefault<z.ZodNumber>;
1120
+ locked: z.ZodDefault<z.ZodBoolean>;
1121
+ hidden: z.ZodDefault<z.ZodBoolean>;
1122
+ }, z.core.$strip>, z.ZodObject<{
1123
+ type: z.ZodLiteral<"numeral">;
1124
+ n: z.ZodString;
1125
+ at: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
1126
+ target: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
1127
+ leader: z.ZodDefault<z.ZodEnum<{
1128
+ none: "none";
1129
+ straight: "straight";
1130
+ curved: "curved";
1131
+ }>>;
1132
+ underline: z.ZodDefault<z.ZodBoolean>;
1133
+ size: z.ZodDefault<z.ZodNumber>;
1134
+ id: z.ZodString;
1135
+ name: z.ZodOptional<z.ZodString>;
1136
+ rotation: z.ZodDefault<z.ZodNumber>;
1137
+ locked: z.ZodDefault<z.ZodBoolean>;
1138
+ hidden: z.ZodDefault<z.ZodBoolean>;
1139
+ }, z.core.$strip>, z.ZodObject<{
1140
+ type: z.ZodLiteral<"figLabel">;
1141
+ x: z.ZodNumber;
1142
+ y: z.ZodNumber;
1143
+ size: z.ZodDefault<z.ZodNumber>;
1144
+ id: z.ZodString;
1145
+ name: z.ZodOptional<z.ZodString>;
1146
+ rotation: z.ZodDefault<z.ZodNumber>;
1147
+ locked: z.ZodDefault<z.ZodBoolean>;
1148
+ hidden: z.ZodDefault<z.ZodBoolean>;
1149
+ }, z.core.$strip>, z.ZodObject<{
1150
+ type: z.ZodLiteral<"connector">;
1151
+ from: z.ZodUnion<readonly [z.ZodObject<{
1152
+ itemId: z.ZodString;
1153
+ }, z.core.$strip>, z.ZodObject<{
1154
+ point: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
1155
+ }, z.core.$strip>]>;
1156
+ to: z.ZodUnion<readonly [z.ZodObject<{
1157
+ itemId: z.ZodString;
1158
+ }, z.core.$strip>, z.ZodObject<{
1159
+ point: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
1160
+ }, z.core.$strip>]>;
1161
+ routing: z.ZodDefault<z.ZodEnum<{
1162
+ straight: "straight";
1163
+ curved: "curved";
1164
+ orthogonal: "orthogonal";
1165
+ }>>;
1166
+ fromSide: z.ZodOptional<z.ZodEnum<{
1167
+ top: "top";
1168
+ bottom: "bottom";
1169
+ left: "left";
1170
+ right: "right";
1171
+ }>>;
1172
+ toSide: z.ZodOptional<z.ZodEnum<{
1173
+ top: "top";
1174
+ bottom: "bottom";
1175
+ left: "left";
1176
+ right: "right";
1177
+ }>>;
1178
+ arrow: z.ZodDefault<z.ZodEnum<{
1179
+ none: "none";
1180
+ start: "start";
1181
+ end: "end";
1182
+ both: "both";
1183
+ }>>;
1184
+ arrowStyle: z.ZodDefault<z.ZodEnum<{
1185
+ filled: "filled";
1186
+ open: "open";
1187
+ }>>;
1188
+ label: z.ZodOptional<z.ZodString>;
1189
+ stroke: z.ZodDefault<z.ZodObject<{
1190
+ width: z.ZodDefault<z.ZodNumber>;
1191
+ style: z.ZodDefault<z.ZodEnum<{
1192
+ solid: "solid";
1193
+ dashed: "dashed";
1194
+ centre: "centre";
1195
+ phantom: "phantom";
1196
+ }>>;
1197
+ }, z.core.$strip>>;
1198
+ id: z.ZodString;
1199
+ name: z.ZodOptional<z.ZodString>;
1200
+ rotation: z.ZodDefault<z.ZodNumber>;
1201
+ locked: z.ZodDefault<z.ZodBoolean>;
1202
+ hidden: z.ZodDefault<z.ZodBoolean>;
1203
+ }, z.core.$strip>, z.ZodObject<{
1204
+ type: z.ZodLiteral<"hatch">;
1205
+ points: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1206
+ angle: z.ZodDefault<z.ZodNumber>;
1207
+ spacing: z.ZodDefault<z.ZodNumber>;
1208
+ lineWidth: z.ZodDefault<z.ZodNumber>;
1209
+ id: z.ZodString;
1210
+ name: z.ZodOptional<z.ZodString>;
1211
+ rotation: z.ZodDefault<z.ZodNumber>;
1212
+ locked: z.ZodDefault<z.ZodBoolean>;
1213
+ hidden: z.ZodDefault<z.ZodBoolean>;
1214
+ }, z.core.$strip>, z.ZodObject<{
1215
+ type: z.ZodLiteral<"sectionLine">;
1216
+ a: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
1217
+ b: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
1218
+ label: z.ZodString;
1219
+ stroke: z.ZodDefault<z.ZodObject<{
1220
+ width: z.ZodDefault<z.ZodNumber>;
1221
+ style: z.ZodDefault<z.ZodEnum<{
1222
+ solid: "solid";
1223
+ dashed: "dashed";
1224
+ centre: "centre";
1225
+ phantom: "phantom";
1226
+ }>>;
1227
+ }, z.core.$strip>>;
1228
+ id: z.ZodString;
1229
+ name: z.ZodOptional<z.ZodString>;
1230
+ rotation: z.ZodDefault<z.ZodNumber>;
1231
+ locked: z.ZodDefault<z.ZodBoolean>;
1232
+ hidden: z.ZodDefault<z.ZodBoolean>;
1233
+ }, z.core.$strip>], "type">>>;
1234
+ }, z.core.$strip>>;
1235
+ numerals: z.ZodRecord<z.ZodString, z.ZodString>;
1236
+ lettering: z.ZodObject<{
1237
+ numeralWeight: z.ZodDefault<z.ZodEnum<{
1238
+ regular: "regular";
1239
+ bold: "bold";
1240
+ }>>;
1241
+ figLabel: z.ZodDefault<z.ZodEnum<{
1242
+ "sans-bold": "sans-bold";
1243
+ "serif-italic": "serif-italic";
1244
+ }>>;
1245
+ }, z.core.$strip>;
1246
+ view: z.ZodEnum<{
1247
+ composite: "composite";
1248
+ exploded: "exploded";
1249
+ }>;
1250
+ explodeLines: z.ZodBoolean;
1251
+ sheetLabel: z.ZodOptional<z.ZodString>;
1252
+ }, z.core.$strip>;
1253
+ }, z.core.$strip>>>;
887
1254
  }, z.core.$strip>;
888
1255
  type PatentDocument = z.infer<typeof PatentDocument>;
889
1256
  /**
@@ -1013,6 +1380,46 @@ declare const GenerationPrefs: z.ZodObject<{
1013
1380
  }, z.core.$strip>;
1014
1381
  type GenerationPrefs = z.infer<typeof GenerationPrefs>;
1015
1382
 
1383
+ /** Sent with a request that continues an interrupted run. */
1384
+ declare const RunResume: z.ZodObject<{
1385
+ kind: z.ZodEnum<{
1386
+ new: "new";
1387
+ edit: "edit";
1388
+ }>;
1389
+ request: z.ZodString;
1390
+ plan: z.ZodOptional<z.ZodObject<{
1391
+ figureType: z.ZodEnum<{
1392
+ flowchart: "flowchart";
1393
+ blockDiagram: "blockDiagram";
1394
+ mechanical2d: "mechanical2d";
1395
+ uiScreen: "uiScreen";
1396
+ perspective3d: "perspective3d";
1397
+ circuit: "circuit";
1398
+ chemical: "chemical";
1399
+ }>;
1400
+ view: z.ZodString;
1401
+ summary: z.ZodString;
1402
+ spec: z.ZodDefault<z.ZodString>;
1403
+ components: z.ZodArray<z.ZodObject<{
1404
+ numeral: z.ZodString;
1405
+ name: z.ZodString;
1406
+ description: z.ZodOptional<z.ZodString>;
1407
+ reused: z.ZodDefault<z.ZodBoolean>;
1408
+ }, z.core.$strip>>;
1409
+ layers: z.ZodArray<z.ZodObject<{
1410
+ id: z.ZodString;
1411
+ name: z.ZodString;
1412
+ }, z.core.$strip>>;
1413
+ notes: z.ZodDefault<z.ZodArray<z.ZodString>>;
1414
+ }, z.core.$strip>>;
1415
+ steps: z.ZodDefault<z.ZodArray<z.ZodString>>;
1416
+ }, z.core.$strip>;
1417
+ type RunResume = z.infer<typeof RunResume>;
1418
+ interface InterruptionStep {
1419
+ label: string;
1420
+ status: "done" | "stopped";
1421
+ }
1422
+
1016
1423
  /**
1017
1424
  * Wire contract between the PatentRender client and its server handler.
1018
1425
  * Imported by both sides, so it must stay free of server-only code.
@@ -1032,6 +1439,8 @@ interface PatentRenderRequestBody {
1032
1439
  context?: PatentContext;
1033
1440
  /** Figure type and drawing style picked in the composer. */
1034
1441
  preferences?: GenerationPrefs;
1442
+ /** Set when this request continues a run that was interrupted. */
1443
+ resume?: RunResume;
1035
1444
  }
1036
1445
 
1037
1446
  interface Margins {
@@ -1190,6 +1599,23 @@ interface Attachment {
1190
1599
  url: string;
1191
1600
  file?: File;
1192
1601
  }
1602
+ /** An assistant run that was cut off, as shown on the recovery card. */
1603
+ interface InterruptedRun {
1604
+ id: string;
1605
+ /** "planning": nothing drawn, plan lost. "drawing": a new figure. "edit": a change to an existing one. */
1606
+ kind: "planning" | "drawing" | "edit";
1607
+ request: string;
1608
+ /** Images sent with the request. */
1609
+ attachments: Attachment[];
1610
+ steps: InterruptionStep[];
1611
+ /** Earlier steps not listed in `steps`. */
1612
+ hiddenSteps: number;
1613
+ edits: number;
1614
+ /** Items on the sheet that this run added. */
1615
+ drawn: number;
1616
+ }
1617
+ /** "edit" hands the request back to the composer; the rest act on the figure. */
1618
+ type InterruptedAction = "continue" | "retry" | "restart" | "undo" | "edit" | "dismiss";
1193
1619
  interface ChatDockProps {
1194
1620
  messages: ChatUIMessage[];
1195
1621
  status: AgentStatus;
@@ -1203,6 +1629,9 @@ interface ChatDockProps {
1203
1629
  onCollapsedChange?: (collapsed: boolean) => void;
1204
1630
  /** Number of items currently selected on the canvas; sent as context with edits. */
1205
1631
  selectionCount?: number;
1632
+ /** A run that was cut off; shows the recovery card. */
1633
+ interrupted?: InterruptedRun | null;
1634
+ onInterrupted?: (action: InterruptedAction) => void;
1206
1635
  className?: string;
1207
1636
  }
1208
1637
 
@@ -1225,6 +1654,8 @@ interface PatentRenderShellProps {
1225
1654
  agentStatus?: AgentStatus;
1226
1655
  onEmbed?: (result: EmbedResult) => void | Promise<void>;
1227
1656
  onCancel?: () => void;
1657
+ /** Called before onCancel when the user closes the editor while the assistant is working. */
1658
+ onInterrupt?: () => void;
1228
1659
  onChange?: (doc: PatentDocument) => void;
1229
1660
  className?: string;
1230
1661
  }
@@ -1234,6 +1665,8 @@ interface PatentRenderEditorProps {
1234
1665
  agentStatus?: AgentStatus;
1235
1666
  onEmbed?: (result: EmbedResult) => void | Promise<void>;
1236
1667
  onCancel?: () => void;
1668
+ /** Called before onCancel when the user closes the editor while the assistant is working. */
1669
+ onInterrupt?: () => void;
1237
1670
  onChange?: (doc: PatentDocument) => void;
1238
1671
  className?: string;
1239
1672
  /** Start in a given editor state (stories, tests). */
@@ -1248,8 +1681,17 @@ interface PatentRenderEditorProps {
1248
1681
  */
1249
1682
  declare function PatentRenderEditor(props: PatentRenderEditorProps): react.JSX.Element;
1250
1683
  /** The editor layout. Must be rendered inside <EditorProvider>. */
1251
- declare function PatentRenderShell({ chat, agentStatus, onEmbed, onCancel, onChange, className }: PatentRenderShellProps): react.JSX.Element;
1684
+ declare function PatentRenderShell({ chat, agentStatus, onEmbed, onCancel, onInterrupt, onChange, className }: PatentRenderShellProps): react.JSX.Element;
1252
1685
 
1686
+ /** Why `onChange` fired, so hosts can debounce edits and save the rest at once. */
1687
+ interface SaveInfo {
1688
+ /**
1689
+ * "edit": the drawing changed; safe to debounce.
1690
+ * "run": an assistant run started, moved on or ended; save now so it can be recovered.
1691
+ * "close": the page is being closed or hidden; save now or lose it.
1692
+ */
1693
+ reason: "edit" | "run" | "close";
1694
+ }
1253
1695
  interface PatentRenderProps {
1254
1696
  /** Route where the host mounted createPatentRenderHandler(), e.g. "/api/patent-render". */
1255
1697
  endpoint: string;
@@ -1265,8 +1707,13 @@ interface PatentRenderProps {
1265
1707
  context?: PatentContext;
1266
1708
  onEmbed: (result: EmbedResult) => void | Promise<void>;
1267
1709
  onCancel?: () => void;
1268
- /** Autosave hook: the full document including chat history. */
1269
- onChange?: (doc: PatentDocument) => void;
1710
+ /**
1711
+ * Autosave hook: the full document including chat history and any unfinished
1712
+ * assistant run. Pass the saved document back as `document` to offer recovery.
1713
+ */
1714
+ onChange?: (doc: PatentDocument, info: SaveInfo) => void;
1715
+ /** True while the assistant is working. Use it to confirm before closing your dialog. */
1716
+ onBusyChange?: (busy: boolean) => void;
1270
1717
  /**
1271
1718
  * Server action that renders a 300 dpi PNG (pass `exportPatentPng` from the
1272
1719
  * server entry). When omitted, the embed result has no PNG.
@@ -1292,4 +1739,4 @@ interface RenderOptions {
1292
1739
  /** Export-ready SVG: hidden layers/items excluded, no editor attributes. */
1293
1740
  declare function renderSvg(doc: PatentDocument, opts?: Omit<RenderOptions, "editorAttrs">): string;
1294
1741
 
1295
- export { type AgentStatus, type ComplianceReport, EditorProvider, type EmbedResult, FigurePlan, FigureType, type Issue, Item, JurisdictionId, Layer, PROFILES, Patch, type PatentContext, PatentDocument, PatentRender, PatentRenderEditor, type PatentRenderEditorProps, type PatentRenderProps, type PatentRenderRequestBody, PatentRenderShell, createDocument, normalizeDocument, renderSvg, useEditor, validate };
1742
+ export { type AgentStatus, type ComplianceReport, EditorProvider, type EmbedResult, FigurePlan, FigureType, type Issue, Item, JurisdictionId, Layer, PROFILES, Patch, type PatentContext, PatentDocument, PatentRender, PatentRenderEditor, type PatentRenderEditorProps, type PatentRenderProps, type PatentRenderRequestBody, PatentRenderShell, type SaveInfo, createDocument, normalizeDocument, renderSvg, useEditor, validate };