@upmade/core 0.6.2 → 0.7.0-preview.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 (83) hide show
  1. package/LICENSE.md +21 -21
  2. package/README.md +13 -13
  3. package/dist/cjs/index.cjs +1166 -224
  4. package/dist/cjs/index.cjs.map +4 -4
  5. package/dist/esm/index.mjs +1166 -224
  6. package/dist/esm/index.mjs.map +4 -4
  7. package/dist/types/classes/agent/agent-tool-schemas.d.ts.map +1 -1
  8. package/dist/types/classes/agent/agent.class.d.ts +28 -5
  9. package/dist/types/classes/agent/agent.class.d.ts.map +1 -1
  10. package/dist/types/classes/chat/chat-session.class.d.ts +22 -3
  11. package/dist/types/classes/chat/chat-session.class.d.ts.map +1 -1
  12. package/dist/types/classes/core/core.class.d.ts +8 -0
  13. package/dist/types/classes/core/core.class.d.ts.map +1 -1
  14. package/dist/types/classes/core/viewport.class.d.ts.map +1 -1
  15. package/dist/types/classes/managers/agent-broadcast.manager.d.ts +1 -1
  16. package/dist/types/classes/managers/agent-broadcast.manager.d.ts.map +1 -1
  17. package/dist/types/classes/managers/agent.manager.d.ts +99 -6
  18. package/dist/types/classes/managers/agent.manager.d.ts.map +1 -1
  19. package/dist/types/classes/managers/agentic-action-run.class.d.ts +20 -1
  20. package/dist/types/classes/managers/agentic-action-run.class.d.ts.map +1 -1
  21. package/dist/types/classes/managers/agentic-action.manager.d.ts +10 -0
  22. package/dist/types/classes/managers/agentic-action.manager.d.ts.map +1 -1
  23. package/dist/types/classes/managers/agentic-cursor.manager.d.ts +11 -1
  24. package/dist/types/classes/managers/agentic-cursor.manager.d.ts.map +1 -1
  25. package/dist/types/classes/managers/object-config.manager.d.ts +4 -3
  26. package/dist/types/classes/managers/object-config.manager.d.ts.map +1 -1
  27. package/dist/types/classes/managers/object-titlebar.manager.d.ts +23 -1
  28. package/dist/types/classes/managers/object-titlebar.manager.d.ts.map +1 -1
  29. package/dist/types/classes/managers/remote-agent.manager.d.ts +2 -2
  30. package/dist/types/classes/managers/remote-agent.manager.d.ts.map +1 -1
  31. package/dist/types/classes/registries/icon-registry.class.d.ts +3 -0
  32. package/dist/types/classes/registries/icon-registry.class.d.ts.map +1 -1
  33. package/dist/types/classes/structures/object-map.structure.d.ts +17 -1
  34. package/dist/types/classes/structures/object-map.structure.d.ts.map +1 -1
  35. package/dist/types/constants/version.d.ts +1 -1
  36. package/dist/types/constants/version.d.ts.map +1 -1
  37. package/dist/types/helpers/cursor-label-action.helper.d.ts +15 -0
  38. package/dist/types/helpers/cursor-label-action.helper.d.ts.map +1 -0
  39. package/dist/types/helpers/object-config.helper.d.ts +11 -0
  40. package/dist/types/helpers/object-config.helper.d.ts.map +1 -0
  41. package/dist/types/helpers/object-titlebar.helper.d.ts +8 -0
  42. package/dist/types/helpers/object-titlebar.helper.d.ts.map +1 -1
  43. package/dist/types/helpers/selection-label.helper.d.ts +15 -0
  44. package/dist/types/helpers/selection-label.helper.d.ts.map +1 -0
  45. package/dist/types/helpers/viewport-overlay.helper.d.ts +14 -0
  46. package/dist/types/helpers/viewport-overlay.helper.d.ts.map +1 -1
  47. package/dist/types/index.d.ts +4 -0
  48. package/dist/types/index.d.ts.map +1 -1
  49. package/dist/types/interfaces/agent.interface.d.ts +46 -4
  50. package/dist/types/interfaces/agent.interface.d.ts.map +1 -1
  51. package/dist/types/interfaces/agentic-cursor.interface.d.ts +21 -1
  52. package/dist/types/interfaces/agentic-cursor.interface.d.ts.map +1 -1
  53. package/dist/types/interfaces/chat-box.interface.d.ts +23 -4
  54. package/dist/types/interfaces/chat-box.interface.d.ts.map +1 -1
  55. package/dist/types/interfaces/chat-session.interface.d.ts +10 -2
  56. package/dist/types/interfaces/chat-session.interface.d.ts.map +1 -1
  57. package/dist/types/interfaces/cursor-label.interface.d.ts +43 -0
  58. package/dist/types/interfaces/cursor-label.interface.d.ts.map +1 -0
  59. package/dist/types/interfaces/engine-host.interface.d.ts +4 -0
  60. package/dist/types/interfaces/engine-host.interface.d.ts.map +1 -1
  61. package/dist/types/interfaces/localization.interface.d.ts +22 -0
  62. package/dist/types/interfaces/localization.interface.d.ts.map +1 -1
  63. package/dist/types/interfaces/menu-item.interface.d.ts +9 -0
  64. package/dist/types/interfaces/menu-item.interface.d.ts.map +1 -1
  65. package/dist/types/interfaces/object-config.interface.d.ts +6 -0
  66. package/dist/types/interfaces/object-config.interface.d.ts.map +1 -1
  67. package/dist/types/interfaces/remote-cursor.interface.d.ts +2 -0
  68. package/dist/types/interfaces/remote-cursor.interface.d.ts.map +1 -1
  69. package/dist/types/interfaces/theme.interface.d.ts +26 -0
  70. package/dist/types/interfaces/theme.interface.d.ts.map +1 -1
  71. package/dist/types/interfaces/user.interface.d.ts +6 -0
  72. package/dist/types/interfaces/user.interface.d.ts.map +1 -1
  73. package/dist/types/locales/de-locale.d.ts.map +1 -1
  74. package/dist/types/locales/en-locale.d.ts.map +1 -1
  75. package/dist/types/locales/es-locale.d.ts.map +1 -1
  76. package/dist/types/locales/fr-locale.d.ts.map +1 -1
  77. package/dist/types/locales/it-locale.d.ts.map +1 -1
  78. package/dist/types/locales/nl-locale.d.ts.map +1 -1
  79. package/dist/types/locales/pl-locale.d.ts.map +1 -1
  80. package/dist/types/locales/pt-locale.d.ts.map +1 -1
  81. package/dist/types/themes/dark-theme.d.ts.map +1 -1
  82. package/dist/types/themes/light-theme.d.ts.map +1 -1
  83. package/package.json +79 -79
@@ -5762,16 +5762,23 @@ function dropPoint(doc3, pos, slice) {
5762
5762
  for (let pass = 1; pass <= (slice.openStart == 0 && slice.size ? 2 : 1); pass++) {
5763
5763
  for (let d2 = $pos.depth; d2 >= 0; d2--) {
5764
5764
  let bias = d2 == $pos.depth ? 0 : $pos.pos <= ($pos.start(d2 + 1) + $pos.end(d2 + 1)) / 2 ? -1 : 1;
5765
- let insertPos = $pos.index(d2) + (bias > 0 ? 1 : 0);
5766
- let parent = $pos.node(d2), fits = false;
5767
- if (pass == 1) {
5768
- fits = parent.canReplace(insertPos, insertPos, content);
5769
- } else {
5770
- let wrapping = parent.contentMatchAt(insertPos).findWrapping(content.firstChild.type);
5771
- fits = wrapping && parent.canReplaceWith(insertPos, insertPos, wrapping[0]);
5765
+ for (let attempt = 0; attempt < 2; attempt++) {
5766
+ if (attempt) {
5767
+ if (!bias)
5768
+ break;
5769
+ bias = -bias;
5770
+ }
5771
+ let insertPos = $pos.index(d2) + (bias > 0 ? 1 : 0);
5772
+ let parent = $pos.node(d2), fits = false;
5773
+ if (pass == 1) {
5774
+ fits = parent.canReplace(insertPos, insertPos, content);
5775
+ } else {
5776
+ let wrapping = parent.contentMatchAt(insertPos).findWrapping(content.firstChild.type);
5777
+ fits = wrapping && parent.canReplaceWith(insertPos, insertPos, wrapping[0]);
5778
+ }
5779
+ if (fits)
5780
+ return bias == 0 ? $pos.pos : bias < 0 ? $pos.before(d2 + 1) : $pos.after(d2 + 1);
5772
5781
  }
5773
- if (fits)
5774
- return bias == 0 ? $pos.pos : bias < 0 ? $pos.before(d2 + 1) : $pos.after(d2 + 1);
5775
5782
  }
5776
5783
  }
5777
5784
  return null;
@@ -14006,6 +14013,9 @@ var lightTheme = {
14006
14013
  focusRingColor: "#333333",
14007
14014
  fontFamily: "sans-serif",
14008
14015
  iconColor: "currentColor",
14016
+ primaryColor: "#0a0a0a",
14017
+ primaryHoverColor: "#2a2a2a",
14018
+ primaryTextColor: "#ffffff",
14009
14019
  scrollbarThumbColor: "#ebebeb",
14010
14020
  textPrimary: "#000000",
14011
14021
  textSecondary: "#333333"
@@ -14016,12 +14026,12 @@ var lightTheme = {
14016
14026
  tabBackgroundHover: "rgba(0, 0, 0, 0.05)",
14017
14027
  tabBackgroundSelected: "#ffffff",
14018
14028
  tabLabelMaxWidth: "10rem",
14019
- tabShadowSelected: "0 1px 3px rgba(0, 0, 0, 0.1)",
14029
+ tabShadowSelected: "0 1px 2px rgba(16, 16, 24, 0.08), 0 2px 6px rgba(16, 16, 24, 0.06)",
14020
14030
  tabTextColor: "#666666",
14021
14031
  tabTextColorSelected: "#000000"
14022
14032
  },
14023
14033
  text: {
14024
- selectionBackgroundColor: "#007AFF",
14034
+ selectionBackgroundColor: "#FF6AB5",
14025
14035
  selectionColor: "#ffffff"
14026
14036
  },
14027
14037
  textInput: {
@@ -14032,18 +14042,18 @@ var lightTheme = {
14032
14042
  hoverBorderColor: "#cccccc",
14033
14043
  labelColor: "#333333",
14034
14044
  placeholderColor: "#999999",
14035
- selectionBackground: "#007AFF",
14045
+ selectionBackground: "#FF6AB5",
14036
14046
  selectionColor: "#ffffff",
14037
14047
  suffixBackground: "#f5f5f5",
14038
14048
  suffixColor: "#666666",
14039
14049
  textColor: "#333333"
14040
14050
  },
14041
14051
  selection: {
14042
- borderColor: "#007AFF",
14043
- boxBackgroundColor: "rgba(0, 122, 255, 0.2)",
14044
- boxBorderColor: "rgba(0, 122, 255, 0.5)",
14052
+ borderColor: "#FF6AB5",
14053
+ boxBackgroundColor: "rgba(255, 106, 181, 0.2)",
14054
+ boxBorderColor: "rgba(255, 106, 181, 0.5)",
14045
14055
  handleColor: "#ffffff",
14046
- handleStrokeColor: "#007AFF"
14056
+ handleStrokeColor: "#FF6AB5"
14047
14057
  },
14048
14058
  checkerboard: {
14049
14059
  colorDark: "#cccccc",
@@ -14053,7 +14063,7 @@ var lightTheme = {
14053
14063
  activeBackgroundColor: "hsl(0, 0%, 0%, 8.6%)",
14054
14064
  backgroundColor: "#ffffff",
14055
14065
  border: "1px solid #ebebeb",
14056
- boxShadow: "0 0 3px rgba(0, 0, 0, 0.08)",
14066
+ boxShadow: "0 1px 2px rgba(16, 16, 24, 0.04), 0 8px 24px rgba(16, 16, 24, 0.07)",
14057
14067
  color: "#000000",
14058
14068
  hoverBackgroundColor: "hsl(0, 0%, 0%, 4.3%)"
14059
14069
  },
@@ -14065,7 +14075,7 @@ var lightTheme = {
14065
14075
  contextMenu: {
14066
14076
  backgroundColor: "#ffffff",
14067
14077
  border: "1px solid #ebebeb",
14068
- boxShadow: "0 1px 6px rgba(0, 0, 0, 0.12)",
14078
+ boxShadow: "0 1px 2px rgba(16, 16, 24, 0.05), 0 6px 16px rgba(16, 16, 24, 0.07)",
14069
14079
  dividerColor: "rgba(0, 0, 0, 0.1)",
14070
14080
  itemActiveBackgroundColor: "hsl(0, 0%, 0%, 8.6%)",
14071
14081
  itemColor: "#333333",
@@ -14075,23 +14085,34 @@ var lightTheme = {
14075
14085
  toolbar: {
14076
14086
  backgroundColor: "#ffffff",
14077
14087
  border: "1px solid #ebebeb",
14078
- boxShadow: "0 0 3px rgba(0, 0, 0, 0.08)",
14088
+ boxShadow: "0 1px 2px rgba(16, 16, 24, 0.04), 0 8px 24px rgba(16, 16, 24, 0.07)",
14079
14089
  controlActiveBackgroundColor: "hsl(0, 0%, 0%, 8.6%)",
14080
14090
  controlColor: "#000000",
14081
14091
  controlHoverBackgroundColor: "hsl(0, 0%, 0%, 4.3%)",
14082
- controlSelectedBackgroundColor: "#007AFF",
14092
+ controlSelectedBackgroundColor: "#0a0a0a",
14083
14093
  controlSelectedColor: "#ffffff",
14084
14094
  separatorColor: "#ebebeb"
14085
14095
  },
14096
+ button: {
14097
+ primaryActiveBackgroundColor: "#000000",
14098
+ primaryBackgroundColor: "#0a0a0a",
14099
+ primaryHoverBackgroundColor: "#2a2a2a",
14100
+ textActiveBackgroundColor: "rgba(0, 0, 0, 0.1)",
14101
+ textColor: "#0a0a0a",
14102
+ textHoverBackgroundColor: "rgba(0, 0, 0, 0.05)"
14103
+ },
14086
14104
  currentUserDialog: {
14087
14105
  emailColor: "#666666",
14106
+ logoutButtonActiveBackgroundColor: "#000000",
14107
+ logoutButtonBackgroundColor: "#0a0a0a",
14108
+ logoutButtonHoverBackgroundColor: "#2a2a2a",
14088
14109
  nameColor: "#333333"
14089
14110
  },
14090
14111
  dialog: {
14091
14112
  backdropColor: "rgba(0, 0, 0, 0.4)",
14092
14113
  backgroundColor: "#ffffff",
14093
14114
  border: "1px solid #ebebeb",
14094
- boxShadow: "0 4px 24px rgba(0, 0, 0, 0.15)",
14115
+ boxShadow: "0 1px 2px rgba(16, 16, 24, 0.04), 0 14px 36px rgba(16, 16, 24, 0.12)",
14095
14116
  closeButtonActiveBackground: "hsl(0, 0%, 0%, 8.6%)",
14096
14117
  closeButtonBackground: "transparent",
14097
14118
  closeButtonColor: "#333333",
@@ -14103,7 +14124,7 @@ var lightTheme = {
14103
14124
  },
14104
14125
  object: {
14105
14126
  borderRadius: "12px",
14106
- boxShadow: "0 1px 2px rgba(20, 18, 31, 0.06), 0 12px 32px -12px rgba(20, 18, 31, 0.22)"
14127
+ boxShadow: "0 1px 2px rgba(16, 16, 24, 0.04), 0 14px 36px rgba(16, 16, 24, 0.12)"
14107
14128
  },
14108
14129
  objectAppear: {
14109
14130
  animationDuration: "600ms",
@@ -14112,7 +14133,7 @@ var lightTheme = {
14112
14133
  stagger: "110ms"
14113
14134
  },
14114
14135
  image: {
14115
- dropShadow: "drop-shadow(0 1px 1px rgba(20, 18, 31, 0.06)) drop-shadow(0 8px 12px rgba(20, 18, 31, 0.14))"
14136
+ dropShadow: "drop-shadow(0 1px 2px rgba(16, 16, 24, 0.04)) drop-shadow(0 14px 36px rgba(16, 16, 24, 0.12))"
14116
14137
  },
14117
14138
  loadingPlaceholder: {
14118
14139
  animationDuration: "1.6s",
@@ -14131,29 +14152,29 @@ var lightTheme = {
14131
14152
  subtitleColor: "#666666"
14132
14153
  },
14133
14154
  dropdown: {
14134
- accentColor: "#007bff",
14155
+ accentColor: "#0a0a0a",
14135
14156
  background: "#ffffff",
14136
14157
  borderColor: "#dbdbdb",
14137
14158
  borderRadius: "6px",
14138
14159
  hoverBorderColor: "#cccccc",
14139
14160
  hoverBackgroundColor: "#f0f0f0",
14140
14161
  menuBorderRadius: "6px",
14141
- selectedBackgroundColor: "#007bff1a",
14162
+ selectedBackgroundColor: "rgba(0, 0, 0, 0.06)",
14142
14163
  textColor: "#333333"
14143
14164
  },
14144
14165
  elementHighlight: {
14145
- backgroundColor: "rgba(0, 122, 255, 0.12)",
14146
- color: "#007AFF",
14166
+ backgroundColor: "rgba(255, 106, 181, 0.12)",
14167
+ color: "#FF6AB5",
14147
14168
  labelTextColor: "#ffffff"
14148
14169
  },
14149
14170
  engine: {
14150
14171
  backgroundColor: "#ffffff"
14151
14172
  },
14152
14173
  snap: {
14153
- indicatorFill: "rgba(59, 130, 246, 0.3)",
14154
- indicatorFillInactive: "rgba(59, 130, 246, 0.18)",
14155
- indicatorStroke: "#007bff",
14156
- indicatorStrokeInactive: "rgba(59, 130, 246, 0.5)",
14174
+ indicatorFill: "rgba(255, 106, 181, 0.3)",
14175
+ indicatorFillInactive: "rgba(255, 106, 181, 0.18)",
14176
+ indicatorStroke: "#FF6AB5",
14177
+ indicatorStrokeInactive: "rgba(255, 106, 181, 0.5)",
14157
14178
  lineStroke: "rgba(0, 0, 0, 0.2)"
14158
14179
  },
14159
14180
  fontSize: {
@@ -14181,14 +14202,14 @@ var lightTheme = {
14181
14202
  menuItemDisabledColor: "#aaaaaa",
14182
14203
  menuItemFocusOutline: "2px solid #333333",
14183
14204
  menuItemHoverBackgroundColor: "hsl(0, 0%, 0%, 4.3%)",
14184
- menuItemSelectedBackgroundColor: "#007AFF",
14205
+ menuItemSelectedBackgroundColor: "#0a0a0a",
14185
14206
  menuItemSelectedColor: "#ffffff",
14186
- menuItemSelectedHoverBackgroundColor: "#007AFF"
14207
+ menuItemSelectedHoverBackgroundColor: "#0a0a0a"
14187
14208
  },
14188
14209
  menu: {
14189
14210
  backgroundColor: "#ffffff",
14190
14211
  border: "1px solid #ebebeb",
14191
- boxShadow: "0 0 3px rgba(0, 0, 0, 0.08)",
14212
+ boxShadow: "0 1px 2px rgba(16, 16, 24, 0.04), 0 8px 24px rgba(16, 16, 24, 0.07)",
14192
14213
  itemButtonHoverBackgroundColor: "hsl(0, 0%, 0%, 4.3%)",
14193
14214
  itemChildOpenBackgroundColor: "hsl(0, 0%, 0%, 3%)",
14194
14215
  itemColor: "#333333",
@@ -14197,19 +14218,19 @@ var lightTheme = {
14197
14218
  itemInputBorderColorOnSelected: "#ffffff",
14198
14219
  itemInputCaretColor: "#333333",
14199
14220
  itemInputCaretColorOnSelected: "#ffffff",
14200
- itemInputSelectionColor: "#007aff",
14221
+ itemInputSelectionColor: "#FF6AB5",
14201
14222
  itemInputSelectionColorOnSelected: "rgba(255, 255, 255, 0.55)",
14202
14223
  itemInputSelectionTextColor: "#ffffff",
14203
14224
  itemInputSelectionTextColorOnSelected: "#ffffff",
14204
14225
  itemOverlayBackgroundColor: "hsl(0, 0%, 0%, 4.3%)",
14205
- itemSelectedBackgroundColor: "#007aff",
14226
+ itemSelectedBackgroundColor: "#0a0a0a",
14206
14227
  itemSelectedColor: "#ffffff"
14207
14228
  },
14208
14229
  moreMenu: {
14209
14230
  backgroundColor: "#ffffff",
14210
14231
  border: "1px solid #ebebeb",
14211
14232
  borderRadius: "12px",
14212
- boxShadow: "0 0 3px rgba(0, 0, 0, 0.08)",
14233
+ boxShadow: "0 1px 2px rgba(16, 16, 24, 0.04), 0 8px 24px rgba(16, 16, 24, 0.07)",
14213
14234
  buttonActiveBackgroundColor: "hsl(0, 0%, 0%, 8.6%)",
14214
14235
  buttonColor: "#000000",
14215
14236
  buttonHoverBackgroundColor: "hsl(0, 0%, 0%, 4.3%)",
@@ -14219,7 +14240,7 @@ var lightTheme = {
14219
14240
  backgroundColor: "#ffffff",
14220
14241
  border: "1px solid #e5e7eb",
14221
14242
  borderRadius: "12px",
14222
- boxShadow: "0 8px 20px rgba(15, 23, 42, 0.08)",
14243
+ boxShadow: "0 1px 2px rgba(16, 16, 24, 0.05), 0 6px 16px rgba(16, 16, 24, 0.07)",
14223
14244
  color: "#111827",
14224
14245
  dismissButtonActiveBackgroundColor: "#e5e7eb",
14225
14246
  dismissButtonBackgroundColor: "transparent",
@@ -14258,7 +14279,7 @@ var lightTheme = {
14258
14279
  hoverBorderColor: "#cccccc",
14259
14280
  inputBackground: "#ffffff",
14260
14281
  labelColor: "#666666",
14261
- selectionBackground: "#007AFF",
14282
+ selectionBackground: "#FF6AB5",
14262
14283
  selectionColor: "#ffffff",
14263
14284
  spinnerActiveBackground: "hsl(0, 0%, 0%, 8.6%)",
14264
14285
  spinnerBackground: "transparent",
@@ -14268,8 +14289,8 @@ var lightTheme = {
14268
14289
  textColor: "#333333"
14269
14290
  },
14270
14291
  opacitySlider: {
14271
- activeColor: "#007AFF",
14272
- thumbBorderColor: "#007AFF",
14292
+ activeColor: "#0a0a0a",
14293
+ thumbBorderColor: "#0a0a0a",
14273
14294
  thumbColor: "#ffffff",
14274
14295
  trackColor: "#e0e0e0"
14275
14296
  },
@@ -14305,18 +14326,18 @@ var lightTheme = {
14305
14326
  revokeButtonColor: "#dc3545",
14306
14327
  revokeButtonHoverBackground: "#dc3545",
14307
14328
  revokeButtonHoverColor: "#ffffff",
14308
- selectionColor: "#cce5ff"
14329
+ selectionColor: "#ffd6eb"
14309
14330
  },
14310
14331
  slideToggle: {
14311
14332
  thumbColor: "#fff",
14312
14333
  thumbSize: "18px",
14313
- trackCheckedColor: "#007AFF",
14334
+ trackCheckedColor: "#0a0a0a",
14314
14335
  trackColor: "#ccc"
14315
14336
  },
14316
14337
  splitButton: {
14317
14338
  backgroundColor: "#ffffff",
14318
14339
  border: "1px solid #ebebeb",
14319
- boxShadow: "0 0 3px rgba(0, 0, 0, 0.08)",
14340
+ boxShadow: "0 1px 2px rgba(16, 16, 24, 0.04), 0 8px 24px rgba(16, 16, 24, 0.07)",
14320
14341
  color: "#000000",
14321
14342
  dividerBackgroundColor: "#ebebeb",
14322
14343
  hoverBackgroundColor: "hsl(0, 0%, 0%, 4.3%)"
@@ -14328,7 +14349,7 @@ var lightTheme = {
14328
14349
  tooltip: {
14329
14350
  backgroundColor: "#ffffff",
14330
14351
  border: "1px solid #ebebeb",
14331
- boxShadow: "0 1px 6px rgba(0, 0, 0, 0.12)",
14352
+ boxShadow: "0 1px 2px rgba(16, 16, 24, 0.05), 0 6px 16px rgba(16, 16, 24, 0.07)",
14332
14353
  color: "#000000"
14333
14354
  },
14334
14355
  utilityPanel: {
@@ -14338,39 +14359,44 @@ var lightTheme = {
14338
14359
  separatorColor: "hsl(0, 0%, 0%, 8%)"
14339
14360
  },
14340
14361
  watermark: {
14341
- background: "rgba(255, 255, 255, 0.6)",
14342
- boxShadow: "0 1px 2px rgba(0, 0, 0, 0.12)",
14343
- color: "rgba(60, 60, 60, 0.75)"
14362
+ background: "rgba(255, 255, 255, 0.9)",
14363
+ boxShadow: "0 1px 2px rgba(16, 16, 24, 0.05), 0 6px 16px rgba(16, 16, 24, 0.07)",
14364
+ color: "#52525b",
14365
+ logoColor: "#000000"
14344
14366
  },
14345
14367
  chatBox: {
14368
+ accentColor: "#FF6AB5",
14346
14369
  backgroundColor: "#ffffff",
14347
14370
  border: "1px solid #e4e4e7",
14348
- borderRadius: "20px",
14349
- boxShadow: "0 4px 8px rgba(20, 18, 31, 0.04), 0 18px 36px -14px rgba(20, 18, 31, 0.2)",
14350
- buttonBackgroundColor: "#4A7DFF",
14371
+ borderRadius: "16px",
14372
+ boxShadow: "0 1px 2px rgba(16, 16, 24, 0.04), 0 8px 24px rgba(16, 16, 24, 0.07)",
14373
+ buttonBackgroundColor: "#0a0a0a",
14374
+ buttonBorderRadius: "10px",
14375
+ buttonInset: "4px",
14351
14376
  buttonColor: "#ffffff",
14352
- buttonHoverBackgroundColor: "#3A6AE8",
14353
- caretColor: "#4A7DFF",
14377
+ buttonHoverBackgroundColor: "#2a2a2a",
14378
+ caretColor: "#FF6AB5",
14354
14379
  caretWidth: "2px",
14355
- chipBoxShadow: "0 4px 12px -6px rgba(20, 18, 31, 0.18)",
14380
+ chipBoxShadow: "0 1px 2px rgba(16, 16, 24, 0.05), 0 6px 16px rgba(16, 16, 24, 0.07)",
14356
14381
  chipMutedTextColor: "#71717a",
14357
- selectionBackgroundColor: "#4A7DFF",
14382
+ collapsedPaddingY: "8px",
14383
+ selectionBackgroundColor: "#FF6AB5",
14358
14384
  selectionColor: "#ffffff",
14359
14385
  scrollbarThumbColor: "#d4d4d4",
14360
- fontSize: "15px",
14361
- inputBackgroundColor: "#f3f4f6",
14362
- inputBorderRadius: "14px",
14363
- inputMinHeight: "88px",
14364
- padding: "6px",
14365
- placeholderColor: "#9ca3af",
14386
+ fontSize: "16px",
14387
+ inputBackgroundColor: "transparent",
14388
+ inputBorderRadius: "12px",
14389
+ inputMinHeight: "0px",
14390
+ padding: "4px",
14391
+ placeholderColor: "#8d8d8d",
14366
14392
  textColor: "#0a0a0a",
14367
- width: "480px"
14393
+ width: "420px"
14368
14394
  },
14369
14395
  zoomPanel: {
14370
14396
  backgroundColor: "#ffffff",
14371
14397
  border: "1px solid #ebebeb",
14372
14398
  borderRadius: "12px",
14373
- boxShadow: "0 0 3px rgba(0, 0, 0, 0.08)",
14399
+ boxShadow: "0 1px 2px rgba(16, 16, 24, 0.04), 0 8px 24px rgba(16, 16, 24, 0.07)",
14374
14400
  buttonActiveBackgroundColor: "hsl(0, 0%, 0%, 8.6%)",
14375
14401
  buttonBorderRadius: "8px",
14376
14402
  buttonHoverBackgroundColor: "hsl(0, 0%, 0%, 4.3%)",
@@ -14380,13 +14406,13 @@ var lightTheme = {
14380
14406
  padding: "4px"
14381
14407
  },
14382
14408
  titlebar: {
14383
- activeBackgroundColor: "#e0efff",
14409
+ activeBackgroundColor: "#ffe8f4",
14384
14410
  activeBorder: "none",
14385
14411
  activeBoxShadow: "none",
14386
- activeButtonFilledBackgroundColor: "#007aff",
14387
- activeIconColor: "#007aff",
14388
- activeMutedTextColor: "rgba(0, 122, 255, 0.6)",
14389
- activeTextColor: "#007aff",
14412
+ activeButtonFilledBackgroundColor: "#FF6AB5",
14413
+ activeIconColor: "#FF6AB5",
14414
+ activeMutedTextColor: "rgba(255, 106, 181, 0.6)",
14415
+ activeTextColor: "#FF6AB5",
14390
14416
  backgroundColor: "#f2f2f2",
14391
14417
  border: "none",
14392
14418
  borderRadius: "8px",
@@ -14398,7 +14424,7 @@ var lightTheme = {
14398
14424
  buttonOutlineColor: "currentColor",
14399
14425
  buttonPressedBackgroundColor: "rgba(0, 0, 0, 0.1)",
14400
14426
  buttonSize: "22px",
14401
- focusRing: "2px solid #007aff",
14427
+ focusRing: "2px solid #FF6AB5",
14402
14428
  fontFamily: "var(--upmade-global-font-family, sans-serif)",
14403
14429
  fontSize: "12px",
14404
14430
  fontWeight: "400",
@@ -14412,7 +14438,7 @@ var lightTheme = {
14412
14438
  mutedTextColor: "#9a9a9a",
14413
14439
  offset: "6px",
14414
14440
  paddingX: "6px",
14415
- selectionBackgroundColor: "#007aff",
14441
+ selectionBackgroundColor: "#FF6AB5",
14416
14442
  selectionColor: "#ffffff",
14417
14443
  textColor: "#5f5f5f",
14418
14444
  titleFontWeight: "600",
@@ -14421,7 +14447,7 @@ var lightTheme = {
14421
14447
  titlebarMenu: {
14422
14448
  backgroundColor: "#ffffff",
14423
14449
  border: "1px solid #ebebeb",
14424
- boxShadow: "0 1px 6px rgba(0, 0, 0, 0.12)",
14450
+ boxShadow: "0 1px 2px rgba(16, 16, 24, 0.05), 0 6px 16px rgba(16, 16, 24, 0.07)",
14425
14451
  itemColor: "#333333",
14426
14452
  itemHoverBackgroundColor: "hsl(0, 0%, 0%, 4.3%)"
14427
14453
  }
@@ -14764,9 +14790,10 @@ var darkTheme = {
14764
14790
  separatorColor: "hsl(0, 0%, 100%, 12%)"
14765
14791
  },
14766
14792
  watermark: {
14767
- background: "rgba(40, 40, 40, 0.6)",
14768
- boxShadow: "0 1px 2px rgba(0, 0, 0, 0.35)",
14769
- color: "rgba(220, 220, 220, 0.8)"
14793
+ background: "rgba(40, 40, 40, 0.9)",
14794
+ boxShadow: "0 1px 3px rgba(0, 0, 0, 0.35)",
14795
+ color: "#d4d4d8",
14796
+ logoColor: "#ffffff"
14770
14797
  },
14771
14798
  chatBox: {
14772
14799
  backgroundColor: "#2a2a2a",
@@ -26851,6 +26878,8 @@ var defaultIcons = {
26851
26878
  shapeTriangle: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3L22 21H2L12 3Z"/></svg>',
26852
26879
  image: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>',
26853
26880
  imageOff: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-image-off-icon lucide-image-off"><line x1="2" x2="22" y1="2" y2="22"/><path d="M10.41 10.41a2 2 0 1 1-2.83-2.83"/><line x1="13.5" x2="6" y1="13.5" y2="21"/><line x1="18" x2="21" y1="12" y2="15"/><path d="M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59"/><path d="M21 15V5a2 2 0 0 0-2-2H9"/></svg>',
26881
+ bot: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-bot-icon lucide-bot"><path d="M12 8V4H8"/><rect width="16" height="12" x="4" y="8" rx="2"/><path d="M2 14h2"/><path d="M20 14h2"/><path d="M15 13v2"/><path d="M9 13v2"/></svg>',
26882
+ atSign: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-at-sign-icon lucide-at-sign"><circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"/></svg>',
26854
26883
  chevronDown: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>',
26855
26884
  chevronUp: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m18 15-6-6-6 6"/></svg>',
26856
26885
  chevronLeft: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-left-icon lucide-chevron-left"><path d="m15 18-6-6 6-6"/></svg>',
@@ -26864,6 +26893,7 @@ var defaultIcons = {
26864
26893
  sendToBack: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-down-to-line-icon lucide-arrow-down-to-line"><path d="M12 17V3"/><path d="m6 11 6 6 6-6"/><path d="M19 21H5"/></svg>',
26865
26894
  selectAll: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-square-mouse-pointer-icon lucide-square-mouse-pointer"><path d="M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z"/><path d="M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6"/></svg>',
26866
26895
  download: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-download-icon lucide-download"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>',
26896
+ file: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-file-icon lucide-file"><path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/></svg>',
26867
26897
  upload: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-upload-icon lucide-upload"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/></svg>',
26868
26898
  undo: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-undo-icon lucide-undo"><path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/></svg>',
26869
26899
  redo: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-redo-icon lucide-redo"><path d="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"/></svg>',
@@ -27022,6 +27052,33 @@ var UpmadeToolConfigHelper = class {
27022
27052
  };
27023
27053
 
27024
27054
  // src/helpers/object-titlebar.helper.ts
27055
+ var UPMADE_OBJECT_TYPE_TERMS = {
27056
+ UpmadeShape: "objectType.shape",
27057
+ UpmadeText: "objectType.text",
27058
+ UpmadeImage: "objectType.image",
27059
+ UpmadePath: "objectType.path",
27060
+ UpmadeLine: "objectType.line",
27061
+ UpmadeGroup: "objectType.group",
27062
+ UpmadeIframeObject: "objectType.iframe",
27063
+ UpmadeDynamicObject: "objectType.dynamic"
27064
+ };
27065
+ function resolveObjectTitle(object2, resolver, translate, onError) {
27066
+ if (resolver) {
27067
+ try {
27068
+ const title = resolver(object2);
27069
+ if (typeof title === "string" && title.length > 0) {
27070
+ return title;
27071
+ }
27072
+ } catch (error) {
27073
+ onError?.(error);
27074
+ }
27075
+ }
27076
+ if (typeof object2.name === "string" && object2.name.length > 0) {
27077
+ return object2.name;
27078
+ }
27079
+ return translate(UPMADE_OBJECT_TYPE_TERMS[object2.__class__] ?? "objectType.object");
27080
+ }
27081
+ __name(resolveObjectTitle, "resolveObjectTitle");
27025
27082
  var UPMADE_TITLEBAR_DEFAULT_HEIGHT = 28;
27026
27083
  var UPMADE_TITLEBAR_DEFAULT_OFFSET = 6;
27027
27084
  var UPMADE_TITLEBAR_DEFAULT_HIDE_BELOW_WIDTH = 40;
@@ -27095,6 +27152,67 @@ var UpmadeObjectTitlebarHelper = class _UpmadeObjectTitlebarHelper {
27095
27152
  }
27096
27153
  };
27097
27154
 
27155
+ // src/helpers/selection-label.helper.ts
27156
+ function getSelectionTopLeft(objects) {
27157
+ let minX = Infinity;
27158
+ let minY = Infinity;
27159
+ for (const object2 of objects) {
27160
+ if (!object2) continue;
27161
+ const polygon = object2.rotatedPolygon;
27162
+ for (const corner of [polygon.topLeft, polygon.topRight, polygon.bottomRight, polygon.bottomLeft]) {
27163
+ if (corner.x < minX) minX = corner.x;
27164
+ if (corner.y < minY) minY = corner.y;
27165
+ }
27166
+ }
27167
+ return Number.isFinite(minX) && Number.isFinite(minY) ? { x: minX, y: minY } : null;
27168
+ }
27169
+ __name(getSelectionTopLeft, "getSelectionTopLeft");
27170
+ function getSelectionLabelPoint(core, objects) {
27171
+ const topLeft = getSelectionTopLeft(objects);
27172
+ if (!topLeft) {
27173
+ return null;
27174
+ }
27175
+ const titlebars = core.objectTitlebarManager;
27176
+ const scale = core.store?.state?.scale || 1;
27177
+ let lift2 = 0;
27178
+ if (titlebars?.isEnabled) {
27179
+ const tolerance = 1 / scale;
27180
+ for (const object2 of objects) {
27181
+ if (!object2 || Math.abs(object2.rotatedBoundingBox.y - topLeft.y) > tolerance) continue;
27182
+ lift2 = Math.max(lift2, titlebars.getTitlebarLift(object2));
27183
+ }
27184
+ }
27185
+ return { x: topLeft.x, y: topLeft.y - lift2 / scale };
27186
+ }
27187
+ __name(getSelectionLabelPoint, "getSelectionLabelPoint");
27188
+
27189
+ // src/helpers/object-config.helper.ts
27190
+ function resolveObjectConfigOption(config, key, object2, fallback, onError) {
27191
+ const value = config?.[key];
27192
+ if (value === void 0) {
27193
+ return fallback;
27194
+ }
27195
+ if (typeof value !== "function") {
27196
+ return value === true;
27197
+ }
27198
+ try {
27199
+ const result = value(object2);
27200
+ if (result && typeof result.then === "function") {
27201
+ onError?.(key, "it must be synchronous; promises are not supported.");
27202
+ return fallback;
27203
+ }
27204
+ return typeof result === "boolean" ? result : fallback;
27205
+ } catch (error) {
27206
+ onError?.(key, error);
27207
+ return fallback;
27208
+ }
27209
+ }
27210
+ __name(resolveObjectConfigOption, "resolveObjectConfigOption");
27211
+ function isObjectReferenceable(config, object2, onError) {
27212
+ return resolveObjectConfigOption(config, "isReferenceable", object2, true, onError);
27213
+ }
27214
+ __name(isObjectReferenceable, "isObjectReferenceable");
27215
+
27098
27216
  // src/helpers/partial-json.helper.ts
27099
27217
  var INCOMPLETE = /* @__PURE__ */ Symbol("incomplete");
27100
27218
  var InvalidJson = class extends Error {
@@ -34163,10 +34281,30 @@ var EN_LOCALE = {
34163
34281
  "zoom.zoomOut": "Zoom out",
34164
34282
  // Chat box
34165
34283
  "chatBox.placeholder": "Ask the AI...",
34284
+ "chatBox.agentPlaceholder": "Message {name}...",
34285
+ "chatBox.removeAgent": "Remove agent",
34286
+ "chatBox.agentWorking": "working",
34166
34287
  "chatBox.submit": "Send",
34167
34288
  "chatBox.stop": "Stop",
34289
+ "chatBox.thinking": "Thinking...",
34290
+ "chatBox.addAgent": "Add agent",
34291
+ "chatBox.agentMenu.close": "Close",
34168
34292
  "chatBox.removeChip": "Remove",
34169
34293
  "chatBox.moreChips": "more",
34294
+ "chatBox.menu": "Add",
34295
+ "chatBox.menu.agent": "Agents",
34296
+ "chatBox.menu.agent.pink": "Pink",
34297
+ "chatBox.menu.agent.green": "Green",
34298
+ "chatBox.menu.agent.yellow": "Yellow",
34299
+ "agentCursor.notice.userSelected": "Selected by you",
34300
+ "agentCursor.notice.userInteraction": "In use by you",
34301
+ "chatBox.menu.back": "Back",
34302
+ "chatBox.menu.selection": "Objects",
34303
+ "chatBox.menu.file": "File",
34304
+ "chatBox.menu.mention": "Mention",
34305
+ "chatBox.mention.empty": "Nothing on the board to mention",
34306
+ "chatBox.mention.noMatch": "No matches",
34307
+ "chatBox.agentMentions": "Agents to mention",
34170
34308
  // Utility panel
34171
34309
  "utility.undo": "Undo",
34172
34310
  "utility.redo": "Redo",
@@ -34295,10 +34433,30 @@ var DE_LOCALE = {
34295
34433
  "zoom.zoomOut": "Verkleinern",
34296
34434
  // Chat box
34297
34435
  "chatBox.placeholder": "Frag die KI...",
34436
+ "chatBox.agentPlaceholder": "Nachricht an {name}...",
34437
+ "chatBox.removeAgent": "Agent entfernen",
34438
+ "chatBox.agentWorking": "arbeitet",
34298
34439
  "chatBox.submit": "Senden",
34299
34440
  "chatBox.stop": "Stoppen",
34441
+ "chatBox.thinking": "Denkt nach...",
34442
+ "chatBox.addAgent": "Agent hinzuf\xFCgen",
34443
+ "chatBox.agentMenu.close": "Schlie\xDFen",
34300
34444
  "chatBox.removeChip": "Entfernen",
34301
34445
  "chatBox.moreChips": "weitere",
34446
+ "chatBox.menu": "Hinzuf\xFCgen",
34447
+ "chatBox.menu.agent": "Agenten",
34448
+ "chatBox.menu.agent.pink": "Pink",
34449
+ "chatBox.menu.agent.green": "Gr\xFCn",
34450
+ "chatBox.menu.agent.yellow": "Gelb",
34451
+ "agentCursor.notice.userSelected": "Von dir ausgew\xE4hlt",
34452
+ "agentCursor.notice.userInteraction": "Von dir in Bearbeitung",
34453
+ "chatBox.menu.back": "Zur\xFCck",
34454
+ "chatBox.menu.selection": "Objekte",
34455
+ "chatBox.menu.file": "Datei",
34456
+ "chatBox.menu.mention": "Erw\xE4hnen",
34457
+ "chatBox.mention.empty": "Nichts auf dem Board zum Erw\xE4hnen",
34458
+ "chatBox.mention.noMatch": "Keine Treffer",
34459
+ "chatBox.agentMentions": "Agenten zum Erw\xE4hnen",
34302
34460
  // Utility panel
34303
34461
  "utility.undo": "R\xFCckg\xE4ngig",
34304
34462
  "utility.redo": "Wiederholen",
@@ -34427,10 +34585,30 @@ var FR_LOCALE = {
34427
34585
  "zoom.zoomOut": "Zoom arri\xE8re",
34428
34586
  // Chat box
34429
34587
  "chatBox.placeholder": "Demandez \xE0 l'IA...",
34588
+ "chatBox.agentPlaceholder": "Message \xE0 {name}...",
34589
+ "chatBox.removeAgent": "Retirer l'agent",
34590
+ "chatBox.agentWorking": "au travail",
34430
34591
  "chatBox.submit": "Envoyer",
34431
34592
  "chatBox.stop": "Arr\xEAter",
34593
+ "chatBox.thinking": "R\xE9flexion...",
34594
+ "chatBox.addAgent": "Ajouter un agent",
34595
+ "chatBox.agentMenu.close": "Fermer",
34432
34596
  "chatBox.removeChip": "Retirer",
34433
34597
  "chatBox.moreChips": "de plus",
34598
+ "chatBox.menu": "Ajouter",
34599
+ "chatBox.menu.agent": "Agents",
34600
+ "chatBox.menu.agent.pink": "Rose",
34601
+ "chatBox.menu.agent.green": "Vert",
34602
+ "chatBox.menu.agent.yellow": "Jaune",
34603
+ "agentCursor.notice.userSelected": "S\xE9lectionn\xE9 par vous",
34604
+ "agentCursor.notice.userInteraction": "Utilis\xE9 par vous",
34605
+ "chatBox.menu.back": "Retour",
34606
+ "chatBox.menu.selection": "Objets",
34607
+ "chatBox.menu.file": "Fichier",
34608
+ "chatBox.menu.mention": "Mentionner",
34609
+ "chatBox.mention.empty": "Rien \xE0 mentionner sur le tableau",
34610
+ "chatBox.mention.noMatch": "Aucun r\xE9sultat",
34611
+ "chatBox.agentMentions": "Agents \xE0 mentionner",
34434
34612
  // Utility panel
34435
34613
  "utility.undo": "Annuler",
34436
34614
  "utility.redo": "R\xE9tablir",
@@ -34559,10 +34737,30 @@ var PT_LOCALE = {
34559
34737
  "zoom.zoomOut": "Diminuir zoom",
34560
34738
  // Chat box
34561
34739
  "chatBox.placeholder": "Pergunte \xE0 IA...",
34740
+ "chatBox.agentPlaceholder": "Mensagem para {name}...",
34741
+ "chatBox.removeAgent": "Remover agente",
34742
+ "chatBox.agentWorking": "trabalhando",
34562
34743
  "chatBox.submit": "Enviar",
34563
34744
  "chatBox.stop": "Parar",
34745
+ "chatBox.thinking": "Pensando...",
34746
+ "chatBox.addAgent": "Adicionar agente",
34747
+ "chatBox.agentMenu.close": "Fechar",
34564
34748
  "chatBox.removeChip": "Remover",
34565
34749
  "chatBox.moreChips": "mais",
34750
+ "chatBox.menu": "Adicionar",
34751
+ "chatBox.menu.agent": "Agentes",
34752
+ "chatBox.menu.agent.pink": "Rosa",
34753
+ "chatBox.menu.agent.green": "Verde",
34754
+ "chatBox.menu.agent.yellow": "Amarelo",
34755
+ "agentCursor.notice.userSelected": "Selecionado por voc\xEA",
34756
+ "agentCursor.notice.userInteraction": "Em uso por voc\xEA",
34757
+ "chatBox.menu.back": "Voltar",
34758
+ "chatBox.menu.selection": "Objetos",
34759
+ "chatBox.menu.file": "Arquivo",
34760
+ "chatBox.menu.mention": "Mencionar",
34761
+ "chatBox.mention.empty": "Nada no quadro para mencionar",
34762
+ "chatBox.mention.noMatch": "Nenhum resultado",
34763
+ "chatBox.agentMentions": "Agentes para mencionar",
34566
34764
  // Utility panel
34567
34765
  "utility.undo": "Desfazer",
34568
34766
  "utility.redo": "Refazer",
@@ -34691,10 +34889,30 @@ var ES_LOCALE = {
34691
34889
  "zoom.zoomOut": "Alejar",
34692
34890
  // Chat box
34693
34891
  "chatBox.placeholder": "Pregunta a la IA...",
34892
+ "chatBox.agentPlaceholder": "Mensaje para {name}...",
34893
+ "chatBox.removeAgent": "Quitar agente",
34894
+ "chatBox.agentWorking": "trabajando",
34694
34895
  "chatBox.submit": "Enviar",
34695
34896
  "chatBox.stop": "Detener",
34897
+ "chatBox.thinking": "Pensando...",
34898
+ "chatBox.addAgent": "A\xF1adir agente",
34899
+ "chatBox.agentMenu.close": "Cerrar",
34696
34900
  "chatBox.removeChip": "Quitar",
34697
34901
  "chatBox.moreChips": "m\xE1s",
34902
+ "chatBox.menu": "A\xF1adir",
34903
+ "chatBox.menu.agent": "Agentes",
34904
+ "chatBox.menu.agent.pink": "Rosa",
34905
+ "chatBox.menu.agent.green": "Verde",
34906
+ "chatBox.menu.agent.yellow": "Amarillo",
34907
+ "agentCursor.notice.userSelected": "Seleccionado por ti",
34908
+ "agentCursor.notice.userInteraction": "En uso por ti",
34909
+ "chatBox.menu.back": "Atr\xE1s",
34910
+ "chatBox.menu.selection": "Objetos",
34911
+ "chatBox.menu.file": "Archivo",
34912
+ "chatBox.menu.mention": "Mencionar",
34913
+ "chatBox.mention.empty": "Nada en el tablero para mencionar",
34914
+ "chatBox.mention.noMatch": "Sin coincidencias",
34915
+ "chatBox.agentMentions": "Agentes para mencionar",
34698
34916
  // Utility panel
34699
34917
  "utility.undo": "Deshacer",
34700
34918
  "utility.redo": "Rehacer",
@@ -34823,10 +35041,30 @@ var PL_LOCALE = {
34823
35041
  "zoom.zoomOut": "Pomniejsz",
34824
35042
  // Chat box
34825
35043
  "chatBox.placeholder": "Zapytaj AI...",
35044
+ "chatBox.agentPlaceholder": "Wiadomo\u015B\u0107 do {name}...",
35045
+ "chatBox.removeAgent": "Usu\u0144 agenta",
35046
+ "chatBox.agentWorking": "pracuje",
34826
35047
  "chatBox.submit": "Wy\u015Blij",
34827
35048
  "chatBox.stop": "Zatrzymaj",
35049
+ "chatBox.thinking": "My\u015Bl\u0119...",
35050
+ "chatBox.addAgent": "Dodaj agenta",
35051
+ "chatBox.agentMenu.close": "Zamknij",
34828
35052
  "chatBox.removeChip": "Usu\u0144",
34829
35053
  "chatBox.moreChips": "wi\u0119cej",
35054
+ "chatBox.menu": "Dodaj",
35055
+ "chatBox.menu.agent": "Agenci",
35056
+ "chatBox.menu.agent.pink": "R\xF3\u017Cowy",
35057
+ "chatBox.menu.agent.green": "Zielony",
35058
+ "chatBox.menu.agent.yellow": "\u017B\xF3\u0142ty",
35059
+ "agentCursor.notice.userSelected": "Zaznaczone przez ciebie",
35060
+ "agentCursor.notice.userInteraction": "U\u017Cywane przez ciebie",
35061
+ "chatBox.menu.back": "Wstecz",
35062
+ "chatBox.menu.selection": "Obiekty",
35063
+ "chatBox.menu.file": "Plik",
35064
+ "chatBox.menu.mention": "Wzmianka",
35065
+ "chatBox.mention.empty": "Nic do wspomnienia na tablicy",
35066
+ "chatBox.mention.noMatch": "Brak wynik\xF3w",
35067
+ "chatBox.agentMentions": "Agenci do wspomnienia",
34830
35068
  // Utility panel
34831
35069
  "utility.undo": "Cofnij",
34832
35070
  "utility.redo": "Pon\xF3w",
@@ -34955,10 +35193,30 @@ var NL_LOCALE = {
34955
35193
  "zoom.zoomOut": "Uitzoomen",
34956
35194
  // Chat box
34957
35195
  "chatBox.placeholder": "Vraag het de AI...",
35196
+ "chatBox.agentPlaceholder": "Bericht aan {name}...",
35197
+ "chatBox.removeAgent": "Agent verwijderen",
35198
+ "chatBox.agentWorking": "aan het werk",
34958
35199
  "chatBox.submit": "Versturen",
34959
35200
  "chatBox.stop": "Stoppen",
35201
+ "chatBox.thinking": "Aan het denken...",
35202
+ "chatBox.addAgent": "Agent toevoegen",
35203
+ "chatBox.agentMenu.close": "Sluiten",
34960
35204
  "chatBox.removeChip": "Verwijderen",
34961
35205
  "chatBox.moreChips": "meer",
35206
+ "chatBox.menu": "Toevoegen",
35207
+ "chatBox.menu.agent": "Agenten",
35208
+ "chatBox.menu.agent.pink": "Roze",
35209
+ "chatBox.menu.agent.green": "Groen",
35210
+ "chatBox.menu.agent.yellow": "Geel",
35211
+ "agentCursor.notice.userSelected": "Door jou geselecteerd",
35212
+ "agentCursor.notice.userInteraction": "Door jou in gebruik",
35213
+ "chatBox.menu.back": "Terug",
35214
+ "chatBox.menu.selection": "Objecten",
35215
+ "chatBox.menu.file": "Bestand",
35216
+ "chatBox.menu.mention": "Vermelden",
35217
+ "chatBox.mention.empty": "Niets op het bord om te vermelden",
35218
+ "chatBox.mention.noMatch": "Geen resultaten",
35219
+ "chatBox.agentMentions": "Agenten om te vermelden",
34962
35220
  // Utility panel
34963
35221
  "utility.undo": "Ongedaan maken",
34964
35222
  "utility.redo": "Opnieuw uitvoeren",
@@ -35087,10 +35345,30 @@ var IT_LOCALE = {
35087
35345
  "zoom.zoomOut": "Riduci",
35088
35346
  // Chat box
35089
35347
  "chatBox.placeholder": "Chiedi all'IA...",
35348
+ "chatBox.agentPlaceholder": "Messaggio a {name}...",
35349
+ "chatBox.removeAgent": "Rimuovi agente",
35350
+ "chatBox.agentWorking": "al lavoro",
35090
35351
  "chatBox.submit": "Invia",
35091
35352
  "chatBox.stop": "Interrompi",
35353
+ "chatBox.thinking": "Sto pensando...",
35354
+ "chatBox.addAgent": "Aggiungi agente",
35355
+ "chatBox.agentMenu.close": "Chiudi",
35092
35356
  "chatBox.removeChip": "Rimuovi",
35093
35357
  "chatBox.moreChips": "altri",
35358
+ "chatBox.menu": "Aggiungi",
35359
+ "chatBox.menu.agent": "Agenti",
35360
+ "chatBox.menu.agent.pink": "Rosa",
35361
+ "chatBox.menu.agent.green": "Verde",
35362
+ "chatBox.menu.agent.yellow": "Giallo",
35363
+ "agentCursor.notice.userSelected": "Selezionato da te",
35364
+ "agentCursor.notice.userInteraction": "In uso da te",
35365
+ "chatBox.menu.back": "Indietro",
35366
+ "chatBox.menu.selection": "Oggetti",
35367
+ "chatBox.menu.file": "File",
35368
+ "chatBox.menu.mention": "Menziona",
35369
+ "chatBox.mention.empty": "Niente da menzionare sulla lavagna",
35370
+ "chatBox.mention.noMatch": "Nessun risultato",
35371
+ "chatBox.agentMentions": "Agenti da menzionare",
35094
35372
  // Utility panel
35095
35373
  "utility.undo": "Annulla",
35096
35374
  "utility.redo": "Ripristina",
@@ -35350,16 +35628,6 @@ var UPMADE_TITLEBAR_EDITABLE_TITLE_ATTRIBUTE = "data-upmade-titlebar-editable-ti
35350
35628
  var UPMADE_TITLEBAR_TITLE_INPUT_ATTRIBUTE = "data-upmade-titlebar-title-input";
35351
35629
  var DEFAULT_LEFT_ELEMENTS = [{ id: "title", type: "title" }];
35352
35630
  var SECTIONS = ["left", "center", "right"];
35353
- var OBJECT_TYPE_TERMS = {
35354
- UpmadeShape: "objectType.shape",
35355
- UpmadeText: "objectType.text",
35356
- UpmadeImage: "objectType.image",
35357
- UpmadePath: "objectType.path",
35358
- UpmadeLine: "objectType.line",
35359
- UpmadeGroup: "objectType.group",
35360
- UpmadeIframeObject: "objectType.iframe",
35361
- UpmadeDynamicObject: "objectType.dynamic"
35362
- };
35363
35631
  var UPMADE_OBJECT_TYPE_ICONS = {
35364
35632
  UpmadeShape: "shapes",
35365
35633
  UpmadeText: "type",
@@ -35448,7 +35716,43 @@ var UpmadeObjectTitlebarManager = class {
35448
35716
  * a selected object (nested groups resolve selection to their direct parent).
35449
35717
  */
35450
35718
  getActiveOwnerIds(candidates) {
35451
- const selectedIds = this._core.store.selectionGroup?.objectIds ?? [];
35719
+ return this.collectOwnerChain(this._core.store.selectionGroup?.objectIds ?? [], candidates);
35720
+ }
35721
+ /**
35722
+ * Returns the color of the agent (local or a collaborator's) that has each titlebar owner selected, or an object
35723
+ * in it, by the rules of `getActiveOwnerIds`. When several agents have selected the same owner, the first wins.
35724
+ */
35725
+ getAgentOwnerColors(candidates) {
35726
+ const colors = /* @__PURE__ */ new Map();
35727
+ for (const cursor of this.getAgentCursors()) {
35728
+ for (const id2 of this.collectOwnerChain(cursor.selectedObjectIds, candidates)) {
35729
+ if (!colors.has(id2)) {
35730
+ colors.set(id2, cursor.color);
35731
+ }
35732
+ }
35733
+ }
35734
+ return colors;
35735
+ }
35736
+ /**
35737
+ * Screen distance from the top edge of `object` to the top of the titlebar it shows on its own, or `0` when it
35738
+ * shows none. Agents' labels sit above a selection, so they move up by this much to sit above its titlebar.
35739
+ */
35740
+ getTitlebarLift(object2) {
35741
+ if (this.getOwnTitlebar(object2).length === 0) {
35742
+ return 0;
35743
+ }
35744
+ const host = this._core.engine?.host;
35745
+ const { height, offset } = this.getMetrics(host && typeof getComputedStyle === "function" ? getComputedStyle(host) : null);
35746
+ return height + offset;
35747
+ }
35748
+ /** The visible agents' cursors with a selection, local ones first. */
35749
+ getAgentCursors() {
35750
+ const local = this._core.agenticCursorManager?.getAll() ?? [];
35751
+ const remote = this._core.remoteAgentManager?.getAll() ?? [];
35752
+ return [...local, ...remote].filter((cursor) => cursor.visible && cursor.selectedObjectIds.length > 0);
35753
+ }
35754
+ /** The given objects and the groups that contain them (nested groups resolve to their direct parent). */
35755
+ collectOwnerChain(selectedIds, candidates) {
35452
35756
  const active = /* @__PURE__ */ new Set();
35453
35757
  if (selectedIds.length === 0) {
35454
35758
  return active;
@@ -35505,16 +35809,21 @@ var UpmadeObjectTitlebarManager = class {
35505
35809
  if (!config || this.getOwners([object2]).length === 0) {
35506
35810
  return [];
35507
35811
  }
35508
- const isActive = this.getActiveOwnerIds(this.withNestedGroups(object2)).has(object2.id);
35812
+ const withNested = this.withNestedGroups(object2);
35813
+ const isActive = this.getActiveOwnerIds(withNested).has(object2.id);
35814
+ const isAgentSelected = this.getAgentOwnerColors(withNested).has(object2.id);
35509
35815
  const anchor2 = UpmadeObjectTitlebarHelper.getAnchor(object2, this._core.store.state, config.rotation ?? "follow");
35510
- return this.isShown(object2, isActive, anchor2.width, config) ? [{ owner: object2, isActive }] : [];
35816
+ return this.isShown(object2, isActive || isAgentSelected, anchor2.width, config) ? [{ owner: object2, isActive }] : [];
35511
35817
  }
35512
- /** The visibility rules: a titlebar being edited stays visible until the edit ends. */
35513
- isShown(owner, isActive, width, config) {
35818
+ /**
35819
+ * The visibility rules: a titlebar being edited stays visible until the edit ends. With `visibility: 'active'`,
35820
+ * `isSelected` also counts an agent's selection, so an agent's titlebar highlight shows.
35821
+ */
35822
+ isShown(owner, isSelected, width, config) {
35514
35823
  if (this._editingTitle?.ownerId === owner.id) {
35515
35824
  return true;
35516
35825
  }
35517
- return (config.visibility !== "active" || isActive) && width >= (config.hideBelowWidth ?? UPMADE_TITLEBAR_DEFAULT_HIDE_BELOW_WIDTH);
35826
+ return (config.visibility !== "active" || isSelected) && width >= (config.hideBelowWidth ?? UPMADE_TITLEBAR_DEFAULT_HIDE_BELOW_WIDTH);
35518
35827
  }
35519
35828
  /** The object and the groups nested in it, so that a selected descendant makes it active. */
35520
35829
  withNestedGroups(object2) {
@@ -35545,13 +35854,15 @@ var UpmadeObjectTitlebarManager = class {
35545
35854
  const viewport = { scale: state.scale, translateX: state.translateX, translateY: state.translateY };
35546
35855
  const owners = this.getOwners(candidates);
35547
35856
  const activeOwnerIds = this.getActiveOwnerIds(candidates);
35857
+ const agentColors = this.getAgentOwnerColors(candidates);
35548
35858
  const titlebars = [];
35549
35859
  const editing = this._editingTitle;
35550
35860
  for (const owner of owners) {
35551
35861
  const isActive = activeOwnerIds.has(owner.id);
35862
+ const agentColor = agentColors.get(owner.id);
35552
35863
  const isEditing = editing?.ownerId === owner.id;
35553
35864
  const anchor2 = UpmadeObjectTitlebarHelper.getAnchor(owner, viewport, config.rotation ?? "follow");
35554
- if (!this.isShown(owner, isActive, anchor2.width, config)) {
35865
+ if (!this.isShown(owner, isActive || agentColor !== void 0, anchor2.width, config)) {
35555
35866
  continue;
35556
35867
  }
35557
35868
  const context = this.createContext(owner, isActive, anchor2.width);
@@ -35565,6 +35876,7 @@ var UpmadeObjectTitlebarManager = class {
35565
35876
  owner,
35566
35877
  context,
35567
35878
  isActive,
35879
+ ...agentColor !== void 0 ? { agentColor } : {},
35568
35880
  transform: UpmadeObjectTitlebarHelper.getTransform(anchor2, viewport.scale),
35569
35881
  width: anchor2.width,
35570
35882
  editingElementId: isEditedElementShown ? editing.elementId : void 0,
@@ -35615,21 +35927,7 @@ var UpmadeObjectTitlebarManager = class {
35615
35927
  }
35616
35928
  /** Resolves an object's title: config resolver, then object name, then a localized type label. */
35617
35929
  resolveTitle(owner) {
35618
- const resolver = this.config?.title;
35619
- if (resolver) {
35620
- try {
35621
- const title = resolver(owner);
35622
- if (typeof title === "string" && title.length > 0) {
35623
- return title;
35624
- }
35625
- } catch (error) {
35626
- this.warnOnce("title", error);
35627
- }
35628
- }
35629
- if (typeof owner.name === "string" && owner.name.length > 0) {
35630
- return owner.name;
35631
- }
35632
- return this.translate(OBJECT_TYPE_TERMS[owner.__class__] ?? "objectType.object");
35930
+ return resolveObjectTitle(owner, this.config?.title, this.translate, (error) => this.warnOnce("title", error));
35633
35931
  }
35634
35932
  /**
35635
35933
  * Finds the object whose titlebar surface was pressed. Presses on titlebar controls return `null`
@@ -36039,6 +36337,10 @@ var UpmadeObjectConfigManager = class {
36039
36337
  isResizable(object2) {
36040
36338
  return this.allowsAll(object2, (unit) => unit.isResizable !== false && this.evaluate("isResizable", unit, true));
36041
36339
  }
36340
+ /** Whether the object can be referenced in the chat, e.g. as a chat box chip. Defaults to `true`. */
36341
+ isReferenceable(object2) {
36342
+ return this.evaluate("isReferenceable", object2, true);
36343
+ }
36042
36344
  /** Applies a check to an object and everything a transform of it also transforms. */
36043
36345
  allowsAll(object2, check) {
36044
36346
  if (object2 instanceof UpmadeSelectionGroup) {
@@ -36055,26 +36357,9 @@ var UpmadeObjectConfigManager = class {
36055
36357
  }
36056
36358
  return true;
36057
36359
  }
36058
- /** Resolves one option for one object. Only a synchronous boolean counts; failures are reported once. */
36360
+ /** Resolves one option for one object; failures are reported once. */
36059
36361
  evaluate(key, object2, fallback) {
36060
- const value = this.config?.[key];
36061
- if (value === void 0) {
36062
- return fallback;
36063
- }
36064
- if (typeof value !== "function") {
36065
- return value === true;
36066
- }
36067
- try {
36068
- const result = value(object2);
36069
- if (result && typeof result.then === "function") {
36070
- this.warnOnce(key, "it must be synchronous; promises are not supported.");
36071
- return fallback;
36072
- }
36073
- return typeof result === "boolean" ? result : fallback;
36074
- } catch (error) {
36075
- this.warnOnce(key, error);
36076
- return fallback;
36077
- }
36362
+ return resolveObjectConfigOption(this.config, key, object2, fallback, (failedKey, error) => this.warnOnce(failedKey, error));
36078
36363
  }
36079
36364
  warnOnce(key, error) {
36080
36365
  if (this._warnedKeys.has(key)) {
@@ -36085,6 +36370,13 @@ var UpmadeObjectConfigManager = class {
36085
36370
  }
36086
36371
  };
36087
36372
 
36373
+ // src/interfaces/cursor-label.interface.ts
36374
+ var UPMADE_REMOVE_AGENT_CURSOR_ACTION = Object.freeze({
36375
+ id: "remove",
36376
+ icon: "x",
36377
+ label: "Send agent back"
36378
+ });
36379
+
36088
36380
  // src/helpers/user-color.helper.ts
36089
36381
  var UpmadeUserColorHelper = class {
36090
36382
  static {
@@ -40065,7 +40357,7 @@ var AGENT_TOOL_SPECS = {
40065
40357
  },
40066
40358
  select: {
40067
40359
  name: "select",
40068
- description: "Makes top-level objects your selection, shown in your color. Never changes the user's selection.",
40360
+ description: "Makes top-level objects your selection, shown in your color. Never changes the user's selection. Your selection lasts while you work on it: acting on objects outside it clears it, and objects you create become your selection.",
40069
40361
  params: { objectIds: req(ids), additive: opt(bool("Add to your selection instead of replacing it.")) },
40070
40362
  actors: AGENT_ONLY,
40071
40363
  describeObjects: false,
@@ -41136,6 +41428,8 @@ var UpmadeAgent = class {
41136
41428
  _name;
41137
41429
  _color;
41138
41430
  _avatarUrl;
41431
+ _cursorIcon;
41432
+ _cursorActions;
41139
41433
  _speed;
41140
41434
  _broadcast;
41141
41435
  _status;
@@ -41154,6 +41448,8 @@ var UpmadeAgent = class {
41154
41448
  this._name = options.name;
41155
41449
  this._color = options.color || UpmadeUserColorHelper.generateColorFromName(options.name);
41156
41450
  this._avatarUrl = options.avatarUrl;
41451
+ this._cursorIcon = options.cursorIcon || null;
41452
+ this._cursorActions = options.cursorActions ? [...options.cursorActions] : [UPMADE_REMOVE_AGENT_CURSOR_ACTION];
41157
41453
  this._speed = options.speed;
41158
41454
  this._broadcast = options.broadcast ?? true;
41159
41455
  this._status = options.status || null;
@@ -41191,6 +41487,29 @@ var UpmadeAgent = class {
41191
41487
  this._avatarUrl = url;
41192
41488
  this.notifyChange();
41193
41489
  }
41490
+ /**
41491
+ * Icon shown before the name on the cursor label: SVG markup or an image URL. `null` (the default) shows a circle in the agent's color.
41492
+ */
41493
+ get cursorIcon() {
41494
+ return this._cursorIcon;
41495
+ }
41496
+ set cursorIcon(icon) {
41497
+ this._cursorIcon = icon || null;
41498
+ this._core?.agenticCursorManager.refresh(this.id);
41499
+ this.notifyChange();
41500
+ }
41501
+ /**
41502
+ * Buttons after the name or status on the cursor label. Defaults to `[UPMADE_REMOVE_AGENT_CURSOR_ACTION]`: an "X"
41503
+ * that sends the agent back behind its chip in the editor's chat box (`sendHome()`), or removes it without one.
41504
+ * `[]` shows none. Clicks call the action's `onClick` and emit the engine's `cursorLabelAction`.
41505
+ */
41506
+ get cursorActions() {
41507
+ return this._cursorActions;
41508
+ }
41509
+ set cursorActions(actions) {
41510
+ this._cursorActions = actions ? [...actions] : [];
41511
+ this._core?.agenticCursorManager.refresh(this.id);
41512
+ }
41194
41513
  /** Same as `avatarUrl` (`IUpmadeUser`). */
41195
41514
  get profileImageUrl() {
41196
41515
  return this._avatarUrl;
@@ -41248,7 +41567,7 @@ var UpmadeAgent = class {
41248
41567
  };
41249
41568
  }
41250
41569
  // ─── Presence ───────────────────────────────────────────────────────────────
41251
- /** Shows a status message below the cursor label; `null` or `''` hides it. */
41570
+ /** Shows what the agent is doing in place of its name on the cursor label; `null` or `''` shows the name again. */
41252
41571
  setStatus(status) {
41253
41572
  this._status = status || null;
41254
41573
  this._core?.agenticCursorManager.refresh(this.id);
@@ -41274,6 +41593,9 @@ var UpmadeAgent = class {
41274
41593
  */
41275
41594
  async moveTo(target2, options = {}) {
41276
41595
  const core = this.requireCore();
41596
+ if (core.agentManager.isLeaving(this.id)) {
41597
+ return { completed: false };
41598
+ }
41277
41599
  return core.agenticCursorManager.move(this.id, target2, { ...options, speed: options.speed ?? this._speed });
41278
41600
  }
41279
41601
  /** Releases the cursor from the object it sticks to. It stays where it is. */
@@ -41292,6 +41614,9 @@ var UpmadeAgent = class {
41292
41614
  */
41293
41615
  async perform(action, options = {}) {
41294
41616
  const core = this.requireCore();
41617
+ if (core.agentManager.isLeaving(this.id)) {
41618
+ return { completed: false, reason: "agent-removed" };
41619
+ }
41295
41620
  const task = this._task;
41296
41621
  if (task?.cancelled) {
41297
41622
  return this.settle(action, { completed: false, reason: "aborted" }, task);
@@ -41317,7 +41642,10 @@ var UpmadeAgent = class {
41317
41642
  interactWithElement(target2, interaction, options = {}) {
41318
41643
  return this.perform({ type: "interactWithElement", target: target2, interaction }, options);
41319
41644
  }
41320
- /** Selects top-level objects for the agent. Never changes the user's selection. */
41645
+ /**
41646
+ * Selects top-level objects for the agent. Never changes the user's selection. The selection lasts while the agent
41647
+ * works on it: an action on anything outside it clears it, and objects an action creates become the selection.
41648
+ */
41321
41649
  select(objectIds, options = {}) {
41322
41650
  const { additive, ...actionOptions } = options;
41323
41651
  return this.perform({ type: "select", objectIds, ...additive !== void 0 ? { additive } : {} }, actionOptions);
@@ -41505,7 +41833,7 @@ var UpmadeAgent = class {
41505
41833
  listeners.add(listener);
41506
41834
  return () => listeners.delete(listener);
41507
41835
  }
41508
- /** How the agent is shown in avatar stacks and `agentsChange`. */
41836
+ /** How the agent is reported in `agentsChange`. */
41509
41837
  toPresence() {
41510
41838
  const state = this.state;
41511
41839
  return {
@@ -41519,6 +41847,7 @@ var UpmadeAgent = class {
41519
41847
  visible: state.visible,
41520
41848
  activeAction: state.activeAction,
41521
41849
  queueLength: state.queueLength,
41850
+ ...this._core?.agentManager.isLeaving(this.id) ? { isLeaving: true } : {},
41522
41851
  isRemote: false
41523
41852
  };
41524
41853
  }
@@ -41527,11 +41856,16 @@ var UpmadeAgent = class {
41527
41856
  get _owner() {
41528
41857
  return this._core;
41529
41858
  }
41530
- /** Creates the cursor in `core` and starts listening. Throws if the cursor can't be created. @internal */
41859
+ /**
41860
+ * Creates the cursor in `core` and starts listening. Returns whether the cursor starts behind the home (the chat box).
41861
+ * Throws if the cursor can't be created. @internal
41862
+ */
41531
41863
  _attach(core) {
41532
41864
  const initial = this._initialPosition;
41533
41865
  const start = initial && canStartAt(core, initial) ? core.agenticCursorManager.resolveTarget(initial) : null;
41534
- const position = start && Number.isFinite(start.x) && Number.isFinite(start.y) ? initial : void 0;
41866
+ const ownStart = start && Number.isFinite(start.x) && Number.isFinite(start.y) ? initial : void 0;
41867
+ const home = ownStart ? null : core.agentManager.getHomePoint(this.id);
41868
+ const position = ownStart ?? home ?? void 0;
41535
41869
  const agent2 = this;
41536
41870
  const cursor = {
41537
41871
  id: this.id,
@@ -41542,6 +41876,12 @@ var UpmadeAgent = class {
41542
41876
  get color() {
41543
41877
  return agent2._color;
41544
41878
  },
41879
+ get cursorIcon() {
41880
+ return agent2._cursorIcon;
41881
+ },
41882
+ get cursorActions() {
41883
+ return agent2._cursorActions;
41884
+ },
41545
41885
  get status() {
41546
41886
  return agent2._status;
41547
41887
  },
@@ -41588,6 +41928,7 @@ var UpmadeAgent = class {
41588
41928
  })
41589
41929
  ];
41590
41930
  this.notifyChange();
41931
+ return !!home;
41591
41932
  }
41592
41933
  /** Removes the cursor (its running action is rolled back) and stops listening. @internal */
41593
41934
  _detach() {
@@ -41603,6 +41944,10 @@ var UpmadeAgent = class {
41603
41944
  this.notifyChange();
41604
41945
  this.emit("removed", void 0);
41605
41946
  }
41947
+ /** Emits `'sent-home'`: the agent was sent back behind its chip and stopped working. @internal */
41948
+ _sentHome() {
41949
+ this.emit("sent-home", void 0);
41950
+ }
41606
41951
  // ─── Internals ──────────────────────────────────────────────────────────────
41607
41952
  setVisible(visible) {
41608
41953
  this._visible = visible;
@@ -41629,7 +41974,7 @@ var UpmadeAgent = class {
41629
41974
  }
41630
41975
  const state = this.state;
41631
41976
  const { position: _position, ...rest } = state;
41632
- const key = JSON.stringify([rest, this._name, this._color, this._avatarUrl, this._broadcast]);
41977
+ const key = JSON.stringify([rest, this._name, this._color, this._avatarUrl, this._cursorIcon, this._broadcast]);
41633
41978
  if (key === this._lastStateKey) {
41634
41979
  return;
41635
41980
  }
@@ -41652,6 +41997,14 @@ var UpmadeAgentManager = class {
41652
41997
  _changeListeners = /* @__PURE__ */ new Set();
41653
41998
  _changeScheduled = false;
41654
41999
  _disposed = false;
42000
+ /** Reports the boxes of the home agents come out from behind and go back behind (the editor's chat box), or `null`. */
42001
+ _homeRectProvider = null;
42002
+ /** Agents flying home before they are removed, with what resolves once they are gone and their flight. */
42003
+ _leaving = /* @__PURE__ */ new Map();
42004
+ /** Agents whose cursor waits behind their chip in the home, with the point it was put at last. */
42005
+ _parked = /* @__PURE__ */ new Map();
42006
+ /** Stops following the chips of parked agents every frame. */
42007
+ _stopFollowingChips = null;
41655
42008
  constructor(core) {
41656
42009
  this._core = core;
41657
42010
  }
@@ -41662,6 +42015,193 @@ var UpmadeAgentManager = class {
41662
42015
  /** Called by the engine when it disconnects (`true`) or connects (`false`). @internal */
41663
42016
  setDisposed(disposed) {
41664
42017
  this._disposed = disposed;
42018
+ if (disposed) {
42019
+ Array.from(this._leaving.keys()).forEach((id2) => this.finishLeaving(id2));
42020
+ }
42021
+ }
42022
+ // ─── Home ───────────────────────────────────────────────────────────────────
42023
+ /**
42024
+ * Reports the home agents come out from behind when added and go back behind when removed, e.g. the editor's chat
42025
+ * box: its box, or with an agent ID the box of that agent's chip in it. Agents appear at, and fly back to, the center
42026
+ * of their chip. `null` (the default) keeps agents appearing at the viewport center and disappearing where they are.
42027
+ */
42028
+ get homeRectProvider() {
42029
+ return this._homeRectProvider;
42030
+ }
42031
+ /**
42032
+ * Sets what reports the home's boxes, see `homeRectProvider`. The engine sets it from its `agentHome` element, so
42033
+ * that reading the DOM stays out of the core. @internal
42034
+ */
42035
+ setHomeRectProvider(provider) {
42036
+ this._homeRectProvider = provider ?? null;
42037
+ }
42038
+ /**
42039
+ * The home's box, relative to the engine's host element (the coordinates cursors are drawn in), or `null` when there
42040
+ * is no home or it is not shown. With `agentId`, the box of that agent's chip in the home when it shows, else the
42041
+ * home's box.
42042
+ */
42043
+ getHomeRect(agentId) {
42044
+ const rect = this._homeRectProvider?.(agentId) ?? null;
42045
+ if (!rect || !(rect.right > rect.left) || !(rect.bottom > rect.top)) {
42046
+ return null;
42047
+ }
42048
+ return { left: rect.left, top: rect.top, right: rect.right, bottom: rect.bottom };
42049
+ }
42050
+ /**
42051
+ * Where agents appear and leave, in world coordinates: the center of the agent's chip in the home, or of the home
42052
+ * while the chip doesn't show; `null` without a home.
42053
+ */
42054
+ getHomePoint(agentId) {
42055
+ const rect = this.getHomeRect(agentId);
42056
+ const state = this._core.store?.state;
42057
+ if (!rect || !state || !(state.scale > 0)) {
42058
+ return null;
42059
+ }
42060
+ const x2 = (rect.left + rect.right) / 2;
42061
+ const y2 = (rect.top + rect.bottom) / 2;
42062
+ return { x: (x2 - state.translateX) / state.scale, y: (y2 - state.translateY) / state.scale };
42063
+ }
42064
+ /**
42065
+ * Sends an agent back behind its chip in the home (in the editor: its chip above the chat box), e.g. with the "X" on
42066
+ * its cursor label. It stops working: its running action is rolled back, its queued actions and a running `task()`
42067
+ * end with `'aborted'`, and a chat session running a prompt for it stops (the agent emits `'sent-home'`). It lets go
42068
+ * of its selection and its cursor flies to the center of its chip, where it waits, hidden behind the home, until
42069
+ * its next action takes it straight to where that happens. The agent stays added: `remove()` removes it.
42070
+ * Returns `false`, and does nothing, without a home, for an agent that is not added and for one on its way out.
42071
+ */
42072
+ sendHome(agentOrId) {
42073
+ const id2 = typeof agentOrId === "string" ? agentOrId : agentOrId?.id;
42074
+ const agent2 = id2 !== void 0 ? this._agents.get(id2) : void 0;
42075
+ if (!agent2 || typeof agentOrId !== "string" && agentOrId !== agent2 || this._leaving.has(agent2.id) || this._disposed) {
42076
+ return false;
42077
+ }
42078
+ const cursors = this._core.agenticCursorManager;
42079
+ const home = cursors.get(agent2.id) ? this.getHomePoint(agent2.id) : null;
42080
+ if (!home) {
42081
+ return false;
42082
+ }
42083
+ const start = this.getIdleLabelPoint(agent2);
42084
+ agent2.cancel();
42085
+ this._core.agenticActionManager.setSelection(agent2.id, []);
42086
+ agent2._sentHome();
42087
+ this.flyHome(agent2, home, start);
42088
+ return true;
42089
+ }
42090
+ /**
42091
+ * Where an idle agent with a selection shows itself: its labels at the selection's top-left corner (its arrow is
42092
+ * hidden meanwhile). A flight home starts there rather than at the hidden arrow, e.g. at the far corner of the shape
42093
+ * it just drew. `null` for a busy agent, whose arrow shows, and for one without a selection.
42094
+ */
42095
+ getIdleLabelPoint(agent2) {
42096
+ const cursor = this._core.agenticCursorManager.get(agent2.id);
42097
+ const ids2 = this._core.agenticActionManager.getSelection(agent2.id);
42098
+ const objects = this._core.store?.objects;
42099
+ if (!cursor || cursor.isMoving || cursor.activeAction || cursor.queueLength > 0 || ids2.length === 0 || !objects) {
42100
+ return null;
42101
+ }
42102
+ const point2 = getSelectionLabelPoint(this._core, ids2.map((id2) => objects.findById(id2)));
42103
+ return point2 && Number.isFinite(point2.x) && Number.isFinite(point2.y) ? point2 : null;
42104
+ }
42105
+ /**
42106
+ * Flies an agent's cursor to its chip in the home and parks it there, unless a new action or move takes over on the
42107
+ * way. With `start`, the flight starts there (see `getIdleLabelPoint`).
42108
+ */
42109
+ flyHome(agent2, home, start) {
42110
+ this._parked.delete(agent2.id);
42111
+ const cursors = this._core.agenticCursorManager;
42112
+ if (start) {
42113
+ cursors.setPosition(agent2.id, start);
42114
+ }
42115
+ cursors.move(agent2.id, home, { speed: agent2.speed }).then((result) => {
42116
+ if (result.completed && this._agents.get(agent2.id) === agent2 && !this._leaving.has(agent2.id)) {
42117
+ this.park(agent2);
42118
+ }
42119
+ }).catch(() => void 0);
42120
+ }
42121
+ /** The user's selection as last seen, by its object IDs, to tell when it changes. */
42122
+ _userSelectionKey = "";
42123
+ /** Stops watching the user's selection. */
42124
+ _stopWatchingUserSelection = null;
42125
+ /** Watches the user's selection, once per frame while agents are added (frames run while their cursors exist). */
42126
+ watchUserSelection() {
42127
+ this._stopWatchingUserSelection ??= this._core.agenticCursorManager.onBeforeFrame(() => this.yieldToUserSelection());
42128
+ }
42129
+ /**
42130
+ * The user selected objects an agent has selected: the agent lets go of its selection and its cursor flies back to
42131
+ * its chip in the home, where it waits until its next action (without a home, it stays where it is). Unlike
42132
+ * `sendHome()`, the agent does not stop: a running action on those objects ends as the user took them over
42133
+ * (`'user-selected'`), and a chat session running a prompt for it goes on. Checked whenever the user's selection
42134
+ * changes, for the objects in it then.
42135
+ */
42136
+ yieldToUserSelection() {
42137
+ const ids2 = this._core.store.selectionGroup?.objectIds ?? [];
42138
+ const key = ids2.join("\0");
42139
+ if (key === this._userSelectionKey) {
42140
+ return;
42141
+ }
42142
+ this._userSelectionKey = key;
42143
+ if (ids2.length === 0 || this._disposed) {
42144
+ return;
42145
+ }
42146
+ const selected = new Set(ids2);
42147
+ const actions = this._core.agenticActionManager;
42148
+ for (const agent2 of this._agents.values()) {
42149
+ if (this._leaving.has(agent2.id) || !actions.getSelection(agent2.id).some((id2) => selected.has(id2))) {
42150
+ continue;
42151
+ }
42152
+ const start = this.getIdleLabelPoint(agent2);
42153
+ actions.setSelection(agent2.id, []);
42154
+ const home = this._core.agenticCursorManager.get(agent2.id) ? this.getHomePoint(agent2.id) : null;
42155
+ if (home && !this._parked.has(agent2.id)) {
42156
+ this.flyHome(agent2, home, start);
42157
+ }
42158
+ }
42159
+ }
42160
+ /** Whether the agent's cursor waits behind its chip in the home. */
42161
+ isHome(agentOrId) {
42162
+ return this._parked.has(typeof agentOrId === "string" ? agentOrId : agentOrId?.id);
42163
+ }
42164
+ /**
42165
+ * Keeps the agent's cursor on the center of its chip in the home, hidden behind it, also while the chip moves, the
42166
+ * view pans or zooms, or the chip only shows after the agent was added (the cursor waits at the home's center
42167
+ * until then). It stays until anything else moves the cursor, e.g. its next action.
42168
+ */
42169
+ park(agent2) {
42170
+ const cursors = this._core.agenticCursorManager;
42171
+ const cursor = cursors.get(agent2.id);
42172
+ if (!cursor) return;
42173
+ this._parked.set(agent2.id, { ...cursor.position });
42174
+ this._stopFollowingChips ??= cursors.onBeforeFrame(() => this.followChips());
42175
+ this.followChips();
42176
+ cursors.requestFrames();
42177
+ }
42178
+ /** Puts the cursors of parked agents on their chips; lets go of those that something else moved. */
42179
+ followChips() {
42180
+ const cursors = this._core.agenticCursorManager;
42181
+ this._parked.forEach((placed, id2) => {
42182
+ const cursor = cursors.get(id2);
42183
+ if (!cursor || !this._agents.has(id2) || this._leaving.has(id2) || cursor.isMoving || cursor.attachedTo || cursor.position.x !== placed.x || cursor.position.y !== placed.y) {
42184
+ this._parked.delete(id2);
42185
+ return;
42186
+ }
42187
+ const point2 = this.getHomePoint(id2);
42188
+ if (point2 && Number.isFinite(point2.x) && Number.isFinite(point2.y) && (point2.x !== placed.x || point2.y !== placed.y)) {
42189
+ cursors.setPosition(id2, point2);
42190
+ this._parked.set(id2, { x: point2.x, y: point2.y });
42191
+ }
42192
+ });
42193
+ if (this._parked.size === 0 && this._stopFollowingChips) {
42194
+ this._stopFollowingChips();
42195
+ this._stopFollowingChips = null;
42196
+ }
42197
+ }
42198
+ /** Whether the agent is flying home to be removed. */
42199
+ isLeaving(agentOrId) {
42200
+ return this._leaving.has(typeof agentOrId === "string" ? agentOrId : agentOrId?.id);
42201
+ }
42202
+ /** Resolves once the agent is removed (at once when it is not leaving). */
42203
+ whenRemoved(agentOrId) {
42204
+ return this._leaving.get(typeof agentOrId === "string" ? agentOrId : agentOrId?.id)?.done ?? Promise.resolve();
41665
42205
  }
41666
42206
  /**
41667
42207
  * Adds an agent and shows its cursor. Adding the same agent again does nothing.
@@ -41674,6 +42214,7 @@ var UpmadeAgentManager = class {
41674
42214
  }
41675
42215
  const existing = this._agents.get(agent2.id);
41676
42216
  if (existing === agent2) {
42217
+ this.stopLeaving(agent2.id);
41677
42218
  return agent2;
41678
42219
  }
41679
42220
  if (existing) {
@@ -41686,28 +42227,98 @@ var UpmadeAgentManager = class {
41686
42227
  }
41687
42228
  owner.agentManager.remove(agent2);
41688
42229
  }
41689
- agent2._attach(this._core);
42230
+ const startsAtHome = agent2._attach(this._core);
41690
42231
  this._agents.set(agent2.id, agent2);
41691
42232
  this._agentSubscriptions.set(agent2.id, agent2.on("change", () => this.scheduleChange()));
41692
42233
  this.scheduleChange();
42234
+ this.watchUserSelection();
42235
+ if (startsAtHome) {
42236
+ this.park(agent2);
42237
+ }
41693
42238
  return agent2;
41694
42239
  }
41695
42240
  /**
41696
- * Removes an agent: its running action is rolled back, queued actions resolve with `'agent-removed'`,
41697
- * and its cursor and history are dropped. Returns `false` if the agent was not added.
42241
+ * Removes an agent: its running action is rolled back, queued actions resolve with `'agent-removed'`, and its
42242
+ * cursor and history are dropped. An agent parked at its chip goes at once. Otherwise, with a home (the editor's
42243
+ * chat box), the cursor first flies back behind it, and
42244
+ * the agent is removed when it arrives (`whenRemoved()`); it accepts no actions meanwhile. `immediate` removes it at
42245
+ * once. Returns `false` if the agent was not added.
41698
42246
  */
41699
- remove(agentOrId) {
42247
+ remove(agentOrId, options = {}) {
41700
42248
  const id2 = typeof agentOrId === "string" ? agentOrId : agentOrId?.id;
41701
42249
  const agent2 = id2 !== void 0 ? this._agents.get(id2) : void 0;
41702
42250
  if (!agent2 || typeof agentOrId !== "string" && agentOrId !== agent2) {
41703
42251
  return false;
41704
42252
  }
42253
+ if (this._leaving.has(agent2.id)) {
42254
+ if (options.immediate) this.finishLeaving(agent2.id);
42255
+ return true;
42256
+ }
42257
+ const cursor = this._core.agenticCursorManager.get(agent2.id);
42258
+ const parked = this._parked.has(agent2.id) && !cursor?.isMoving;
42259
+ const home = !options.immediate && !this._disposed && !parked && cursor?.visible ? this.getHomePoint(agent2.id) : null;
42260
+ if (!home) {
42261
+ this.detach(agent2);
42262
+ return true;
42263
+ }
42264
+ let resolve;
42265
+ const done = new Promise((r3) => resolve = r3);
42266
+ const leaving = { done, resolve, target: home, flight: 0, stopFollowing: null };
42267
+ const start = this.getIdleLabelPoint(agent2);
42268
+ this._leaving.set(agent2.id, leaving);
42269
+ this._core.agenticActionManager.cancel(agent2.id, "agent-removed");
42270
+ this._core.agenticActionManager.setSelection(agent2.id, []);
42271
+ this.scheduleChange();
42272
+ this._parked.delete(agent2.id);
42273
+ const cursors = this._core.agenticCursorManager;
42274
+ if (start) {
42275
+ cursors.setPosition(agent2.id, start);
42276
+ }
42277
+ this.flyLeaving(agent2, leaving, home);
42278
+ leaving.stopFollowing = cursors.onBeforeFrame(() => {
42279
+ if (this._leaving.get(agent2.id) !== leaving) return;
42280
+ const point2 = this.getHomePoint(agent2.id);
42281
+ if (point2 && Number.isFinite(point2.x) && Number.isFinite(point2.y) && Math.hypot(point2.x - leaving.target.x, point2.y - leaving.target.y) > 0.5) {
42282
+ this.flyLeaving(agent2, leaving, point2);
42283
+ }
42284
+ });
42285
+ return true;
42286
+ }
42287
+ /** Flies a leaving agent's cursor to `target`, its chip, and removes the agent once it lands there. */
42288
+ flyLeaving(agent2, leaving, target2) {
42289
+ leaving.target = target2;
42290
+ const flight = ++leaving.flight;
42291
+ this._core.agenticCursorManager.move(agent2.id, target2, { speed: agent2.speed }).catch(() => void 0).then(() => {
42292
+ if (this._leaving.get(agent2.id) === leaving && leaving.flight === flight) this.finishLeaving(agent2.id);
42293
+ });
42294
+ }
42295
+ /** Removes an agent that was flying home, if it still is. */
42296
+ finishLeaving(id2) {
42297
+ const leaving = this._leaving.get(id2);
42298
+ if (!leaving) return;
42299
+ this._leaving.delete(id2);
42300
+ leaving.stopFollowing?.();
42301
+ const agent2 = this._agents.get(id2);
42302
+ if (agent2) this.detach(agent2);
42303
+ leaving.resolve();
42304
+ }
42305
+ /** Keeps an agent that was flying home. */
42306
+ stopLeaving(id2) {
42307
+ const leaving = this._leaving.get(id2);
42308
+ if (!leaving) return;
42309
+ this._leaving.delete(id2);
42310
+ leaving.stopFollowing?.();
42311
+ this._core.agenticCursorManager.stopAnimation(id2);
42312
+ this.scheduleChange();
42313
+ leaving.resolve();
42314
+ }
42315
+ detach(agent2) {
41705
42316
  this._agents.delete(agent2.id);
42317
+ this._parked.delete(agent2.id);
41706
42318
  this._agentSubscriptions.get(agent2.id)?.();
41707
42319
  this._agentSubscriptions.delete(agent2.id);
41708
42320
  agent2._detach();
41709
42321
  this.scheduleChange();
41710
- return true;
41711
42322
  }
41712
42323
  get(id2) {
41713
42324
  return this._agents.get(id2) ?? null;
@@ -41715,12 +42326,12 @@ var UpmadeAgentManager = class {
41715
42326
  getAll() {
41716
42327
  return Array.from(this._agents.values());
41717
42328
  }
41718
- /** The added agents as shown in the avatar stack. */
42329
+ /** The added agents as reported in `agentsChange`. */
41719
42330
  getPresences() {
41720
42331
  return this.getAll().map((agent2) => agent2.toPresence());
41721
42332
  }
41722
42333
  /**
41723
- * Subscribes to changes of the agent list and of what the avatar stack shows (name, color, avatar,
42334
+ * Subscribes to changes of the agent list and of what is shown of them (name, color, avatar,
41724
42335
  * status, visibility, activity). Coalesced to one call per microtask; never called for plain motion.
41725
42336
  */
41726
42337
  onChange(listener) {
@@ -41798,6 +42409,7 @@ var UpmadeAgentBroadcaster = class {
41798
42409
  name: agent2.name,
41799
42410
  color: cursor.color,
41800
42411
  ...agent2.avatarUrl ? { avatarUrl: agent2.avatarUrl } : {},
42412
+ ...cursor.cursorIcon ? { cursorIcon: cursor.cursorIcon } : {},
41801
42413
  status,
41802
42414
  visible: cursor.visible,
41803
42415
  activeAction: cursor.activeAction,
@@ -41864,7 +42476,7 @@ var UpmadeAgentBroadcaster = class {
41864
42476
  }
41865
42477
  };
41866
42478
  function structureOf(payload) {
41867
- return JSON.stringify(payload.map((agent2) => [agent2.id, agent2.name, agent2.color, agent2.avatarUrl ?? null, agent2.visible]));
42479
+ return JSON.stringify(payload.map((agent2) => [agent2.id, agent2.name, agent2.color, agent2.avatarUrl ?? null, agent2.cursorIcon ?? null, agent2.visible]));
41868
42480
  }
41869
42481
  __name(structureOf, "structureOf");
41870
42482
  function round2(value) {
@@ -41872,6 +42484,83 @@ function round2(value) {
41872
42484
  }
41873
42485
  __name(round2, "round");
41874
42486
 
42487
+ // src/helpers/viewport-overlay.helper.ts
42488
+ var UPMADE_CURSOR_ICON_MAX_LENGTH = 8192;
42489
+ var UpmadeViewportOverlayHelper = class _UpmadeViewportOverlayHelper {
42490
+ static {
42491
+ __name(this, "UpmadeViewportOverlayHelper");
42492
+ }
42493
+ static worldToScreen(state, worldX, worldY) {
42494
+ return {
42495
+ x: worldX * state.scale + state.translateX,
42496
+ y: worldY * state.scale + state.translateY
42497
+ };
42498
+ }
42499
+ static isInViewport(state, screenX, screenY) {
42500
+ return screenX >= 0 && screenX <= state.viewportWidth && screenY >= 0 && screenY <= state.viewportHeight;
42501
+ }
42502
+ /** Clamps an off-screen point to the viewport edge, returning the nearest edge and the direction to the point. */
42503
+ static clampToEdge(state, screenX, screenY, padding) {
42504
+ const { viewportWidth, viewportHeight } = state;
42505
+ const clampedX = Math.max(padding, Math.min(viewportWidth - padding, screenX));
42506
+ const clampedY = Math.max(padding, Math.min(viewportHeight - padding, screenY));
42507
+ const distLeft = clampedX - padding;
42508
+ const distRight = viewportWidth - padding - clampedX;
42509
+ const distTop = clampedY - padding;
42510
+ const distBottom = viewportHeight - padding - clampedY;
42511
+ let edge = "top";
42512
+ const minDist = Math.min(distLeft, distRight, distTop, distBottom);
42513
+ if (minDist === distLeft) edge = "left";
42514
+ else if (minDist === distRight) edge = "right";
42515
+ else if (minDist === distTop) edge = "top";
42516
+ else edge = "bottom";
42517
+ const angle = Math.atan2(screenY - clampedY, screenX - clampedX);
42518
+ return { x: clampedX, y: clampedY, angle, edge };
42519
+ }
42520
+ static getInitials(name) {
42521
+ const parts = name.trim().split(/\s+/);
42522
+ if (parts.length === 0 || parts.length === 1 && parts[0].length <= 1) {
42523
+ return name;
42524
+ }
42525
+ if (parts.length === 1) {
42526
+ return parts[0][0].toUpperCase();
42527
+ }
42528
+ return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();
42529
+ }
42530
+ /**
42531
+ * The image source of a cursor icon (`IUpmadeUser.cursorIcon`, `UpmadeAgentOptions.cursorIcon`), or `null` when
42532
+ * there is none or it is not usable. SVG markup becomes a `data:` URL; image URLs are accepted when they are
42533
+ * http(s), `data:image/` or relative. Icons are always drawn as images, never as markup, so an icon that comes
42534
+ * from a collaborator cannot run scripts or reach the page.
42535
+ */
42536
+ static getCursorIconSrc(icon) {
42537
+ if (typeof icon !== "string") {
42538
+ return null;
42539
+ }
42540
+ const value = icon.trim();
42541
+ if (value.length === 0 || value.length > UPMADE_CURSOR_ICON_MAX_LENGTH) {
42542
+ return null;
42543
+ }
42544
+ if (value.startsWith("<")) {
42545
+ const svgTag = /<svg\b[^>]*>/i.exec(value);
42546
+ if (!svgTag) {
42547
+ return null;
42548
+ }
42549
+ const markup = /\sxmlns\s*=/i.test(svgTag[0]) ? value : value.slice(0, svgTag.index) + svgTag[0].replace(/^<svg\b/i, '<svg xmlns="http://www.w3.org/2000/svg"') + value.slice(svgTag.index + svgTag[0].length);
42550
+ return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(markup)}`;
42551
+ }
42552
+ return _UpmadeViewportOverlayHelper.isSafeImageUrl(value, UPMADE_CURSOR_ICON_MAX_LENGTH) ? value : null;
42553
+ }
42554
+ /** Whether a URL is http(s), `data:image/` or relative, so a collaborator cannot point images at other schemes. */
42555
+ static isSafeImageUrl(value, maxLength = 2048) {
42556
+ if (typeof value !== "string" || value.length === 0 || value.length > maxLength) {
42557
+ return false;
42558
+ }
42559
+ const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(value.trim())?.[1]?.toLowerCase();
42560
+ return scheme === void 0 || scheme === "http" || scheme === "https" || scheme === "data" && /^data:image\//i.test(value.trim());
42561
+ }
42562
+ };
42563
+
41875
42564
  // src/classes/managers/remote-agent.manager.ts
41876
42565
  var MAX_NAME_LENGTH = 100;
41877
42566
  var UpmadeRemoteAgentManager = class {
@@ -41947,6 +42636,7 @@ var UpmadeRemoteAgentManager = class {
41947
42636
  name: entry.agent.name,
41948
42637
  color: entry.agent.color,
41949
42638
  ...entry.agent.avatarUrl ? { avatarUrl: entry.agent.avatarUrl } : {},
42639
+ ...entry.agent.cursorIcon ? { cursorIcon: entry.agent.cursorIcon } : {},
41950
42640
  status: entry.agent.status ?? void 0,
41951
42641
  visible: entry.agent.visible,
41952
42642
  position: { ...entry.rendered },
@@ -41961,7 +42651,7 @@ var UpmadeRemoteAgentManager = class {
41961
42651
  canRedo: false
41962
42652
  }));
41963
42653
  }
41964
- /** Remote agents as shown in avatar stacks. */
42654
+ /** Remote agents as reported in `agentsChange`. */
41965
42655
  getPresences() {
41966
42656
  return Array.from(this._entries.values()).map((entry) => ({
41967
42657
  id: entry.agent.id,
@@ -41986,7 +42676,7 @@ var UpmadeRemoteAgentManager = class {
41986
42676
  isClaimed(objectId, kind) {
41987
42677
  return this._claimed.has(objectId) || kind === "target" && this._selected.has(objectId);
41988
42678
  }
41989
- /** Subscribes to structural changes (agents added or removed, name, color, status, activity, selection). */
42679
+ /** Subscribes to structural changes (agents added or removed, name, color, icon, status, activity, selection). */
41990
42680
  onChange(listener) {
41991
42681
  this._changeListeners.add(listener);
41992
42682
  return () => this._changeListeners.delete(listener);
@@ -42086,7 +42776,9 @@ function parseAgent(raw) {
42086
42776
  id: value["id"].slice(0, MAX_NAME_LENGTH),
42087
42777
  name: value["name"].slice(0, MAX_NAME_LENGTH),
42088
42778
  color: value["color"].slice(0, MAX_NAME_LENGTH),
42089
- ...isSafeImageUrl(value["avatarUrl"]) ? { avatarUrl: value["avatarUrl"] } : {},
42779
+ ...UpmadeViewportOverlayHelper.isSafeImageUrl(value["avatarUrl"]) ? { avatarUrl: value["avatarUrl"] } : {},
42780
+ // Only icons the overlay can draw (as an image, never as markup).
42781
+ ...UpmadeViewportOverlayHelper.getCursorIconSrc(value["cursorIcon"]) ? { cursorIcon: value["cursorIcon"] } : {},
42090
42782
  status: typeof value["status"] === "string" && value["status"] ? value["status"].slice(0, AGENT_BROADCAST_MAX_STATUS_LENGTH) : null,
42091
42783
  visible: value["visible"] !== false,
42092
42784
  activeAction: typeof value["activeAction"] === "string" ? value["activeAction"] : null,
@@ -42136,14 +42828,6 @@ function parseHostUser(raw) {
42136
42828
  };
42137
42829
  }
42138
42830
  __name(parseHostUser, "parseHostUser");
42139
- function isSafeImageUrl(value) {
42140
- if (typeof value !== "string" || value.length === 0 || value.length > 2048) {
42141
- return false;
42142
- }
42143
- const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(value.trim())?.[1]?.toLowerCase();
42144
- return scheme === void 0 || scheme === "http" || scheme === "https" || scheme === "data" && /^data:image\//i.test(value.trim());
42145
- }
42146
- __name(isSafeImageUrl, "isSafeImageUrl");
42147
42831
 
42148
42832
  // src/interfaces/chat-session.interface.ts
42149
42833
  var UPMADE_CHAT_PROTOCOL_VERSION = 1;
@@ -42634,6 +43318,12 @@ var DEFAULT_MAX_STEPS = 25;
42634
43318
  var DEFAULT_THINKING_STATUS = "Thinking\u2026";
42635
43319
  var STOPPED_OUTPUT = JSON.stringify({ completed: false, reason: "aborted", hint: "The user stopped the response. Do not retry unless asked." });
42636
43320
  var INTERRUPTED_OUTPUT = JSON.stringify({ completed: false, reason: "aborted", hint: "The tool call was interrupted and did not run." });
43321
+ var BLOCKED_OUTPUT = JSON.stringify({
43322
+ completed: false,
43323
+ reason: "aborted",
43324
+ hint: "Not run: an earlier call met objects the user is working on, so the response ended there."
43325
+ });
43326
+ var BLOCKING_REASONS = /* @__PURE__ */ new Set(["user-selected", "user-interaction"]);
42637
43327
  var busyAgents = /* @__PURE__ */ new WeakSet();
42638
43328
  var busyCores = /* @__PURE__ */ new WeakSet();
42639
43329
  function isUpmadeChatSession(value) {
@@ -42649,7 +43339,7 @@ var RunEnd = class {
42649
43339
  __name(this, "RunEnd");
42650
43340
  }
42651
43341
  };
42652
- var UpmadeChatSession = class {
43342
+ var UpmadeChatSession = class _UpmadeChatSession {
42653
43343
  static {
42654
43344
  __name(this, "UpmadeChatSession");
42655
43345
  }
@@ -42671,6 +43361,8 @@ var UpmadeChatSession = class {
42671
43361
  _pendingDetach = false;
42672
43362
  /** Why the running prompt was ended from outside. */
42673
43363
  _endReason = null;
43364
+ /** Sessions of `forAgent()`, per agent ID. They are bound wherever this session is. */
43365
+ _agentSessions = /* @__PURE__ */ new Map();
42674
43366
  _listeners = /* @__PURE__ */ new Map();
42675
43367
  constructor(options) {
42676
43368
  if (!options || typeof options.transport !== "function") {
@@ -42768,6 +43460,42 @@ var UpmadeChatSession = class {
42768
43460
  stop() {
42769
43461
  this.endRun("stopped");
42770
43462
  }
43463
+ /**
43464
+ * A session in which the model acts as `agent`: it has this session's options (transport, system, context, tools,
43465
+ * canvas tools, steps, instant, thinking status, eager tool calls) but its own conversation, which starts empty or
43466
+ * with `options.messages` (used only when the session is created, e.g. to restore it from `messages`).
43467
+ * The same agent always gets the same session, so each agent keeps its conversation; this session's own agent gets
43468
+ * this session. Agents are told apart by ID: for a new instance of an agent (e.g. added again after it was removed),
43469
+ * a new session replaces the earlier one (which is unbound) and continues its conversation. It is bound to
43470
+ * whichever editor this session is bound to, and unbound with it (a running prompt then ends with `'detached'`).
43471
+ * Creating one emits `'agent-session'`; `agentSessions` lists them. The editor uses it to run a prompt sent with
43472
+ * an agent chip.
43473
+ */
43474
+ forAgent(agent2, options = {}) {
43475
+ if (agent2 === this._options.agent) {
43476
+ return this;
43477
+ }
43478
+ const earlier = this._agentSessions.get(agent2.id);
43479
+ if (earlier?.agent === agent2) {
43480
+ return earlier;
43481
+ }
43482
+ earlier?._detach();
43483
+ const { messages: _messages, ...parentOptions } = this._options;
43484
+ const session = new _UpmadeChatSession({ ...parentOptions, agent: agent2, messages: options.messages ?? (earlier ? [...earlier.messages] : []) });
43485
+ this._agentSessions.set(agent2.id, session);
43486
+ if (this._core) {
43487
+ session._attach(this._core);
43488
+ if (this._pendingDetach) {
43489
+ session._detachWhenIdle();
43490
+ }
43491
+ }
43492
+ this.emit("agent-session", session);
43493
+ return session;
43494
+ }
43495
+ /** The sessions of `forAgent()`, one per agent ID. Subscribe to `'agent-session'` to hear of new ones. */
43496
+ get agentSessions() {
43497
+ return Array.from(this._agentSessions.values());
43498
+ }
42771
43499
  /** Subscribes to an event; returns a function that unsubscribes. */
42772
43500
  on(event, listener) {
42773
43501
  let listeners = this._listeners.get(event);
@@ -42793,18 +43521,32 @@ var UpmadeChatSession = class {
42793
43521
  /** Binds the session to an editor core. Working as the user, it registers its actor there. @internal */
42794
43522
  _attach(core) {
42795
43523
  this._pendingDetach = false;
42796
- if (this._core === core) {
42797
- return;
42798
- }
42799
- this._detach();
42800
- this._core = core;
42801
- if (!this._options.agent) {
42802
- this._userActor = new UpmadeUserActor();
42803
- this._userActor._attach(core);
43524
+ if (this._core !== core) {
43525
+ this._detach();
43526
+ this._core = core;
43527
+ if (!this._options.agent) {
43528
+ this._userActor = new UpmadeUserActor();
43529
+ this._userActor._attach(core);
43530
+ }
42804
43531
  }
43532
+ this._agentSessions.forEach((session) => session._attach(core));
42805
43533
  }
42806
- /** Unbinds the session: a running prompt ends with `'detached'`. @internal */
43534
+ /** Unbinds the session and its `forAgent()` sessions: running prompts end with `'detached'`. @internal */
42807
43535
  _detach() {
43536
+ this._agentSessions.forEach((session) => session._detach());
43537
+ this.detachSelf();
43538
+ }
43539
+ /** Unbinds the session and its `forAgent()` sessions, each once its running prompt ends (right away when idle). @internal */
43540
+ _detachWhenIdle() {
43541
+ this._agentSessions.forEach((session) => session._detachWhenIdle());
43542
+ if (!this._running) {
43543
+ this.detachSelf();
43544
+ return;
43545
+ }
43546
+ this._pendingDetach = true;
43547
+ }
43548
+ detachSelf() {
43549
+ this._pendingDetach = false;
42808
43550
  if (!this._core) {
42809
43551
  return;
42810
43552
  }
@@ -42813,14 +43555,6 @@ var UpmadeChatSession = class {
42813
43555
  this._userActor = null;
42814
43556
  this._core = null;
42815
43557
  }
42816
- /** Unbinds the session once its running prompt ends (right away when idle). @internal */
42817
- _detachWhenIdle() {
42818
- if (!this._running) {
42819
- this._detach();
42820
- return;
42821
- }
42822
- this._pendingDetach = true;
42823
- }
42824
43558
  // ─── Loop ───────────────────────────────────────────────────────────────────
42825
43559
  /** Ends the running prompt: the abort reaches the transport and the running action, which is rolled back. */
42826
43560
  endRun(reason) {
@@ -42830,7 +43564,7 @@ var UpmadeChatSession = class {
42830
43564
  this._endReason ??= reason;
42831
43565
  this._abort.abort();
42832
43566
  }
42833
- /** Ends the run when the workspace goes away or the agent is removed. */
43567
+ /** Ends the run when the workspace goes away or the agent is removed, and stops it when the agent is sent home. */
42834
43568
  watchRun(core) {
42835
43569
  const unsubscribers = [];
42836
43570
  const map = core.store?.objects;
@@ -42840,6 +43574,7 @@ var UpmadeChatSession = class {
42840
43574
  const agent2 = this._options.agent;
42841
43575
  if (agent2) {
42842
43576
  unsubscribers.push(agent2.on("removed", () => this.endRun("detached")));
43577
+ unsubscribers.push(agent2.on("sent-home", () => this.endRun("stopped")));
42843
43578
  }
42844
43579
  return () => unsubscribers.forEach((unsubscribe) => unsubscribe());
42845
43580
  }
@@ -42863,7 +43598,14 @@ var UpmadeChatSession = class {
42863
43598
  stoppedOutput: STOPPED_OUTPUT,
42864
43599
  interruptedOutput: INTERRUPTED_OUTPUT,
42865
43600
  report: /* @__PURE__ */ __name((update) => this.emit("tool-call", update), "report"),
42866
- run: /* @__PURE__ */ __name((call, onRunning, handle) => this.runCall(call, byName, signal, onRunning, handle), "run"),
43601
+ run: /* @__PURE__ */ __name(async (call, onRunning, handle) => {
43602
+ const outcome = await this.runCall(call, byName, signal, onRunning, handle);
43603
+ if (this._options.agent && isBlockedByUser(outcome.result.output)) {
43604
+ answer.halt(BLOCKED_OUTPUT);
43605
+ this.endRun("blocked");
43606
+ }
43607
+ return outcome;
43608
+ }, "run"),
42867
43609
  begin: /* @__PURE__ */ __name((call) => {
42868
43610
  const tool = byName.get(call.name);
42869
43611
  return tool?.begin ? tool.begin({ signal, toolCallId: call.id }) : null;
@@ -43074,8 +43816,7 @@ var UpmadeChatSession = class {
43074
43816
  const waiters = this._idleWaiters.splice(0);
43075
43817
  waiters.forEach((resolve) => resolve());
43076
43818
  if (this._pendingDetach) {
43077
- this._pendingDetach = false;
43078
- this._detach();
43819
+ this.detachSelf();
43079
43820
  }
43080
43821
  }
43081
43822
  emit(event, payload) {
@@ -43101,7 +43842,7 @@ function toUserMessage(input) {
43101
43842
  }
43102
43843
  __name(toUserMessage, "toUserMessage");
43103
43844
  function describeChips(chips) {
43104
- const lines = chips.map((chip) => {
43845
+ const lines = chips.filter((chip) => !chip.agentId).map((chip) => {
43105
43846
  const name = chip.detail ? `${chip.label} \u203A ${chip.detail}` : chip.label;
43106
43847
  const refs = [chip.objectId ? `objectId: ${chip.objectId}` : null, chip.selector ? `element: ${chip.selector}` : null].filter(Boolean);
43107
43848
  return `- ${name}${refs.length > 0 ? ` (${refs.join(", ")})` : ""}`;
@@ -43148,6 +43889,18 @@ function isAsyncIterable(value) {
43148
43889
  return typeof value === "object" && value !== null && typeof value[Symbol.asyncIterator] === "function";
43149
43890
  }
43150
43891
  __name(isAsyncIterable, "isAsyncIterable");
43892
+ function isBlockedByUser(output) {
43893
+ if (typeof output !== "string" || !output.includes('"reason"')) {
43894
+ return false;
43895
+ }
43896
+ try {
43897
+ const parsed = JSON.parse(output);
43898
+ return parsed?.completed === false && typeof parsed.reason === "string" && BLOCKING_REASONS.has(parsed.reason);
43899
+ } catch {
43900
+ return false;
43901
+ }
43902
+ }
43903
+ __name(isBlockedByUser, "isBlockedByUser");
43151
43904
 
43152
43905
  // src/classes/chat/scripted-transport.ts
43153
43906
  function createScriptedTransport(steps, options = {}) {
@@ -43634,7 +44387,7 @@ var CURRENT_APP_STATE_SCHEMA_VERSION = 2;
43634
44387
  var CURRENT_WORKSPACE_SCHEMA_VERSION = 3;
43635
44388
 
43636
44389
  // src/constants/version.ts
43637
- var UPMADE_VERSION = "0.6.2";
44390
+ var UPMADE_VERSION = "0.7.0-preview.0";
43638
44391
 
43639
44392
  // src/configs/default-engine-config.ts
43640
44393
  var DEFAULT_ENGINE_CONFIG = {
@@ -44270,6 +45023,7 @@ var UpmadeAgentOrigin = class {
44270
45023
  };
44271
45024
 
44272
45025
  // src/classes/structures/object-map.structure.ts
45026
+ var USER_STATUS_MAX_LENGTH = 200;
44273
45027
  var UpmadeObjectMap = class _UpmadeObjectMap {
44274
45028
  static {
44275
45029
  __name(this, "UpmadeObjectMap");
@@ -44465,9 +45219,20 @@ var UpmadeObjectMap = class _UpmadeObjectMap {
44465
45219
  this._awareness.setLocalStateField("user", {
44466
45220
  id: user.id,
44467
45221
  displayName,
44468
- color: user.color || UpmadeUserColorHelper.generateColorFromName(displayName)
45222
+ color: user.color || UpmadeUserColorHelper.generateColorFromName(displayName),
45223
+ ...UpmadeViewportOverlayHelper.getCursorIconSrc(user.cursorIcon) ? { cursorIcon: user.cursorIcon } : {}
44469
45224
  });
44470
45225
  }
45226
+ /**
45227
+ * Shares what the local user is doing (e.g. `'typing…'`) with collaborators, who see it in place of the user's
45228
+ * name on their cursor label (awareness field `status`). `null` or `''` removes it. Cut to 200 characters.
45229
+ */
45230
+ setLocalStatus(status) {
45231
+ if (!this._awareness || this._headless) {
45232
+ return;
45233
+ }
45234
+ this._awareness.setLocalStateField("status", status ? status.slice(0, USER_STATUS_MAX_LENGTH) : null);
45235
+ }
44471
45236
  /**
44472
45237
  * Shares the agents of this client with collaborators (awareness field `agents`); `null` or an
44473
45238
  * empty list removes the field. No-op without awareness and for background maps.
@@ -45238,6 +46003,40 @@ var UpmadeObjectMap = class _UpmadeObjectMap {
45238
46003
  }
45239
46004
  }
45240
46005
  }
46006
+ /**
46007
+ * Removes an object the local user started but did not finish, as if it had never been made,
46008
+ * e.g. a brush stroke whose first finger turned out to be the start of a pinch-zoom.
46009
+ *
46010
+ * Unlike `remove()`, which records the removal as an undo step of its own (so undo would bring
46011
+ * the half-made object back), the deletion joins the still open undo step that recorded the
46012
+ * object's insertion. Yjs never restores what was created and deleted in the same step. If that
46013
+ * step holds nothing else, it is dropped, so the next undo reverts the user's previous action.
46014
+ *
46015
+ * @param objectId - The ID of the object to discard
46016
+ */
46017
+ discard(objectId) {
46018
+ if (!this._idMap.has(objectId)) {
46019
+ return;
46020
+ }
46021
+ this.quadtree.remove((o3) => o3.id === objectId);
46022
+ this._idMap.delete(objectId);
46023
+ if (this._localActiveDrawingObjectId === objectId) {
46024
+ this._localActiveDrawingObjectId = null;
46025
+ }
46026
+ if (this._objectsMap?.has(objectId)) {
46027
+ const undoManager = this._undoManager;
46028
+ const stackLength = undoManager?.undoStack.length ?? 0;
46029
+ const origin = this.writeOrigin;
46030
+ this._ydoc?.transact(() => {
46031
+ this._objectsMap?.delete(objectId);
46032
+ }, origin);
46033
+ const top = undoManager?.undoStack[stackLength - 1];
46034
+ if (undoManager && top && origin === "local" && this._transactionDepth === 0 && this._temporaryItemsCount === 0 && undoManager.undoStack.length === stackLength && Y5.equalDeleteSets(top.insertions, top.deletions)) {
46035
+ undoManager.undoStack.pop();
46036
+ }
46037
+ }
46038
+ this.markUndoBoundary();
46039
+ }
45241
46040
  /**
45242
46041
  * Filters objects in the quadtree based on a predicate function.
45243
46042
  *
@@ -47263,6 +48062,7 @@ var UpmadeEasingHelper = class _UpmadeEasingHelper {
47263
48062
  var AGENTIC_CURSOR_DEFAULT_SPEED = 1200;
47264
48063
  var AGENTIC_CURSOR_MIN_DURATION = 250;
47265
48064
  var AGENTIC_CURSOR_MAX_DURATION = 1200;
48065
+ var UPMADE_AGENTIC_CURSOR_NOTICE_MS = 4e3;
47266
48066
  var UpmadeAgenticCursorManager = class {
47267
48067
  static {
47268
48068
  __name(this, "UpmadeAgenticCursorManager");
@@ -47277,6 +48077,8 @@ var UpmadeAgenticCursorManager = class {
47277
48077
  _historyProvider = null;
47278
48078
  _frameDemand = null;
47279
48079
  _rafId = null;
48080
+ /** The last notice key handed out. */
48081
+ _noticeKey = 0;
47280
48082
  constructor(core) {
47281
48083
  this._core = core;
47282
48084
  }
@@ -47318,7 +48120,8 @@ var UpmadeAgenticCursorManager = class {
47318
48120
  hostMoveGeneration: 0,
47319
48121
  trackedElement,
47320
48122
  moveToken: 0,
47321
- cancelLookup: null
48123
+ cancelLookup: null,
48124
+ notice: null
47322
48125
  };
47323
48126
  this._cursors.set(id2, entry);
47324
48127
  this.emitChange(id2);
@@ -47425,6 +48228,25 @@ var UpmadeAgenticCursorManager = class {
47425
48228
  entry.queueLength = queueLength;
47426
48229
  this.emitChange(id2);
47427
48230
  }
48231
+ /**
48232
+ * Shows on the agent's label why it could not do what it was about to, e.g. that the user has the object selected, for
48233
+ * `UPMADE_AGENTIC_CURSOR_NOTICE_MS`; `null` clears it. Each notice gets a new `key`, so the label draws attention to
48234
+ * it again, also for the same reason. @internal
48235
+ */
48236
+ setNotice(id2, notice) {
48237
+ const entry = this._cursors.get(id2);
48238
+ if (!entry) return;
48239
+ clearTimeout(entry.noticeTimer);
48240
+ entry.noticeTimer = void 0;
48241
+ if (!notice) {
48242
+ if (!entry.notice) return;
48243
+ entry.notice = null;
48244
+ } else {
48245
+ entry.notice = { reason: notice.reason, objectIds: [...notice.objectIds], key: ++this._noticeKey };
48246
+ entry.noticeTimer = setTimeout(() => this.setNotice(id2, null), UPMADE_AGENTIC_CURSOR_NOTICE_MS);
48247
+ }
48248
+ this.emitChange(id2);
48249
+ }
47428
48250
  /** Sets the provider of `canUndo` / `canRedo` for snapshots. @internal */
47429
48251
  setHistoryProvider(provider) {
47430
48252
  this._historyProvider = provider;
@@ -47446,6 +48268,7 @@ var UpmadeAgenticCursorManager = class {
47446
48268
  this.supersede(entry);
47447
48269
  this.finishAnimation(entry, false);
47448
48270
  this.setTrackedElement(entry, null);
48271
+ clearTimeout(entry.noticeTimer);
47449
48272
  this._cursors.delete(id2);
47450
48273
  this.emitChange(id2);
47451
48274
  if (!this.needsFrames()) this.stopLoop();
@@ -47602,6 +48425,7 @@ var UpmadeAgenticCursorManager = class {
47602
48425
  /** Stops the animation loop and resolves pending moves. Cursors are kept. */
47603
48426
  cleanup() {
47604
48427
  this._cursors.forEach((entry) => {
48428
+ clearTimeout(entry.noticeTimer);
47605
48429
  this.supersede(entry);
47606
48430
  this.finishAnimation(entry, false);
47607
48431
  this.releaseUnattachedElement(entry);
@@ -47814,8 +48638,10 @@ var UpmadeAgenticCursorManager = class {
47814
48638
  id: entry.id,
47815
48639
  name: entry.appearance.name,
47816
48640
  color: entry.appearance.color,
48641
+ ...entry.appearance.cursorIcon ? { cursorIcon: entry.appearance.cursorIcon } : {},
47817
48642
  status: entry.appearance.status || void 0,
47818
48643
  visible: entry.appearance.visible,
48644
+ ...entry.appearance.cursorActions?.length ? { cursorActions: [...entry.appearance.cursorActions] } : {},
47819
48645
  position: { ...entry.position },
47820
48646
  attachedTo: entry.attachedTo ? { ...entry.attachedTo, offset: { ...entry.attachedTo.offset } } : null,
47821
48647
  isMoving: entry.animation !== null,
@@ -47825,7 +48651,8 @@ var UpmadeAgenticCursorManager = class {
47825
48651
  activeAction: entry.activeAction,
47826
48652
  queueLength: entry.queueLength,
47827
48653
  canUndo: history.canUndo,
47828
- canRedo: history.canRedo
48654
+ canRedo: history.canRedo,
48655
+ ...entry.notice ? { notice: { ...entry.notice, objectIds: [...entry.notice.objectIds] } } : {}
47829
48656
  };
47830
48657
  }
47831
48658
  emitChange(id2) {
@@ -47919,6 +48746,23 @@ var UpmadeAgenticActionRun = class {
47919
48746
  applyingHistory = false;
47920
48747
  /** An abort that arrived while `applyingHistory` was set. */
47921
48748
  heldAbort = null;
48749
+ /**
48750
+ * Agents: whether the action works outside the agent's selection, so its first press clears the selection,
48751
+ * like a person's click elsewhere. Decided when the action starts.
48752
+ */
48753
+ deselectOnPress = false;
48754
+ /**
48755
+ * Agents: the explicit selection the action cleared on its first press; restored if the action ends without
48756
+ * keeping changes. `null` when the action left the selection alone.
48757
+ */
48758
+ clearedSelection = null;
48759
+ /** Whether the cursor has pressed in this run. */
48760
+ hasPressed = false;
48761
+ /**
48762
+ * Whether `displayIds` are shown as selected. Like a person's selection, they show once the cursor presses on
48763
+ * the objects (not while it flies there), or when the executor shows objects on purpose (`display()`).
48764
+ */
48765
+ displaying = false;
47922
48766
  /** Whether the action changed anything. */
47923
48767
  hasMutated = false;
47924
48768
  /** Whether the outcome is decided. */
@@ -48114,10 +48958,15 @@ var UpmadeAgenticActionRun = class {
48114
48958
  this.stop("agent-moved");
48115
48959
  }
48116
48960
  }
48117
- /** Presses the cursor, after re-checking for conflicts. */
48961
+ /** Presses the cursor, after re-checking for conflicts. The first press shows the targets as selected. */
48118
48962
  async press() {
48119
48963
  this.assertActive();
48120
48964
  this.host.checkpoint(this);
48965
+ if (!this.hasPressed) {
48966
+ this.hasPressed = true;
48967
+ this.displaying = true;
48968
+ this.host.handleFirstPress(this);
48969
+ }
48121
48970
  if (this.instant) {
48122
48971
  return;
48123
48972
  }
@@ -48229,6 +49078,7 @@ var UpmadeAgenticActionRun = class {
48229
49078
  /** Shows other objects as selected while the action runs, e.g. a group once it is created. */
48230
49079
  display(objectIds) {
48231
49080
  this.displayIds = [...objectIds];
49081
+ this.displaying = true;
48232
49082
  this.host.showSelection(this.cursorId);
48233
49083
  }
48234
49084
  /** Replaces objects in the agent's selection, e.g. grouped objects by their group. Others stay selected. */
@@ -48291,6 +49141,7 @@ var UpmadeAgenticActionRun = class {
48291
49141
  };
48292
49142
 
48293
49143
  // src/classes/managers/agentic-action.manager.ts
49144
+ var SELECTION_RULE_EXEMPT_ACTIONS = /* @__PURE__ */ new Set(["select", "clearSelection", "undo", "redo"]);
48294
49145
  var KEEP_REASONS = /* @__PURE__ */ new Set(["user-selected", "user-interaction"]);
48295
49146
  var SILENT_REASONS = /* @__PURE__ */ new Set(["workspace-changed", "engine-disconnected"]);
48296
49147
  var UpmadeAgenticActionManager = class {
@@ -48478,6 +49329,15 @@ var UpmadeAgenticActionManager = class {
48478
49329
  }
48479
49330
  run.settled = true;
48480
49331
  const cursors = this._core.agenticCursorManager;
49332
+ if (run.actorKind === "agent" && outcome.kind === "abort" && (outcome.reason === "user-selected" || outcome.reason === "user-interaction")) {
49333
+ const notice = { reason: outcome.reason, objectIds: outcome.objectIds ?? [] };
49334
+ if (!run.executing && notice.objectIds.length > 0 && cursors.resolveTarget({ objectId: notice.objectIds[0] })) {
49335
+ const cursorId = run.cursorId;
49336
+ void cursors.fly(cursorId, { objectId: notice.objectIds[0] }, { speed: run.options.speed, attach: false, ...run.instant ? { duration: 0 } : {} }).then((result) => result.completed && cursors.setNotice(cursorId, notice));
49337
+ } else {
49338
+ cursors.setNotice(run.cursorId, notice);
49339
+ }
49340
+ }
48481
49341
  if (run.isFlying && cursors.getHostMoveGeneration(run.cursorId) === run.hostMoveGeneration) {
48482
49342
  cursors.stopAnimation(run.cursorId);
48483
49343
  }
@@ -48497,6 +49357,7 @@ var UpmadeAgenticActionManager = class {
48497
49357
  const reason = outcome.kind === "abort" ? outcome.reason : null;
48498
49358
  const keep = outcome.kind === "commit" || reason !== null && KEEP_REASONS.has(reason);
48499
49359
  let events = null;
49360
+ const createdIds = /* @__PURE__ */ new Set();
48500
49361
  try {
48501
49362
  if (run.hasMutated && run.origin && map && map.isReady) {
48502
49363
  const canWrite = !map.isInsideYjsCallback;
@@ -48506,6 +49367,9 @@ var UpmadeAgenticActionManager = class {
48506
49367
  if (keep) {
48507
49368
  map.stopAgentCapturing(run.cursorId);
48508
49369
  const recording = run.origin.takeRecording();
49370
+ recording.forEach((existedBefore, id2) => {
49371
+ if (!existedBefore) createdIds.add(id2);
49372
+ });
48509
49373
  if (map.getAgentUndoStackLength(run.cursorId) > run.undoLengthAtStart) {
48510
49374
  map.tagLastAgentStackItem(run.cursorId, Array.from(recording.keys()).filter((id2) => !run.selectionObjectIds.has(id2)));
48511
49375
  if (run.actorKind === "user") {
@@ -48538,6 +49402,13 @@ var UpmadeAgenticActionManager = class {
48538
49402
  run.suspendedRedo = null;
48539
49403
  }
48540
49404
  run.runSettleHooks();
49405
+ if (outcome.kind === "commit") {
49406
+ if (run.deselectOnPress) this.applyDeselect(run);
49407
+ this.selectCreatedObjects(run, map, outcome.objectIds, createdIds);
49408
+ } else if (run.clearedSelection && !(keep && run.hasMutated) && this.getSelection(run.cursorId).length === 0) {
49409
+ const existing = map ? run.clearedSelection.filter((id2) => !!map.findById(id2) && !this.isClaimedByOther(id2, run.cursorId, "target")) : [];
49410
+ if (existing.length > 0) this.setSelection(run.cursorId, existing);
49411
+ }
48541
49412
  if (outcome.kind === "commit" && run.finalAttachment) {
48542
49413
  cursors.attach(run.cursorId, run.finalAttachment);
48543
49414
  }
@@ -48670,6 +49541,7 @@ var UpmadeAgenticActionManager = class {
48670
49541
  }
48671
49542
  run.map = map;
48672
49543
  this.bindMap(map);
49544
+ cursors.setNotice(run.cursorId, null);
48673
49545
  run.hostMoveGeneration = cursors.getHostMoveGeneration(run.cursorId);
48674
49546
  cursors.stopAnimation(run.cursorId);
48675
49547
  this.updateActivity(run.cursorId);
@@ -48709,6 +49581,7 @@ var UpmadeAgenticActionManager = class {
48709
49581
  const object2 = map.findById(id2);
48710
49582
  if (object2) run.knownInstances.set(id2, object2);
48711
49583
  });
49584
+ this.deselectIfWorkingElsewhere(run, preparation);
48712
49585
  this.showSelection(run.cursorId);
48713
49586
  const objectIds = await run.executor.execute(run, run.action);
48714
49587
  if (!run.settled) {
@@ -48886,9 +49759,70 @@ var UpmadeAgenticActionManager = class {
48886
49759
  showSelection(cursorId) {
48887
49760
  const explicit = this._selections.get(cursorId)?.ids ?? [];
48888
49761
  const running = this._running.get(cursorId);
48889
- const shown = running && !running.settled && running.executing ? [...explicit, ...running.displayIds] : [...explicit];
49762
+ const shown = running && !running.settled && running.executing && running.displaying ? [...explicit, ...running.displayIds] : [...explicit];
48890
49763
  this._core.agenticCursorManager.setSelectedObjectIds(cursorId, Array.from(new Set(shown)));
48891
49764
  }
49765
+ // ─── Selection rule ─────────────────────────────────────────────────────────
49766
+ //
49767
+ // An agent's selection lasts as long as the agent works on it, like a person's:
49768
+ // - an action on objects that are all in the selection keeps it (move, resize, style, type into it, click it);
49769
+ // - an action on anything else, or one that creates objects (on empty canvas), clears it when its cursor first
49770
+ // presses, like a click elsewhere; if the action then keeps nothing, the selection comes back;
49771
+ // - a `select` that replaces the selection clears the old one on its press too, and shows the new one;
49772
+ // - an action that creates objects selects them once it completes (copies, a new group, a drawn shape or line);
49773
+ // - `select`, `clearSelection`, `undo` and `redo` manage the selection themselves; moving the cursor never changes it.
49774
+ // Actors working as the user don't follow the rule: their selection is the user's own.
49775
+ /** Decides, as the action starts, whether its first press clears the agent's selection: when it works outside it. */
49776
+ deselectIfWorkingElsewhere(run, preparation) {
49777
+ if (run.actorKind !== "agent") return;
49778
+ const selection = this._selections.get(run.cursorId);
49779
+ if (!selection) return;
49780
+ if (run.action.type === "select") {
49781
+ run.deselectOnPress = !run.action.additive;
49782
+ return;
49783
+ }
49784
+ if (SELECTION_RULE_EXEMPT_ACTIONS.has(run.action.type)) return;
49785
+ if (run.action.type === "interactWithElement" && (run.action.interaction.type === "hover" || run.action.interaction.type === "scroll")) return;
49786
+ const touched = this.getTouchedObjectIds(run, preparation);
49787
+ if (touched.length > 0 && touched.every((id2) => selection.expanded.has(id2))) return;
49788
+ run.deselectOnPress = true;
49789
+ }
49790
+ /** The run's cursor pressed for the first time: a pending deselect applies, and its targets show as selected. @internal */
49791
+ handleFirstPress(run) {
49792
+ if (run.deselectOnPress) {
49793
+ this.applyDeselect(run);
49794
+ }
49795
+ this.showSelection(run.cursorId);
49796
+ }
49797
+ /** Clears the agent's selection for a run working elsewhere, remembering it in case the run keeps nothing. */
49798
+ applyDeselect(run) {
49799
+ run.deselectOnPress = false;
49800
+ const ids2 = this.getSelection(run.cursorId);
49801
+ if (ids2.length === 0) return;
49802
+ run.clearedSelection = ids2;
49803
+ this.setSelection(run.cursorId, []);
49804
+ }
49805
+ /** The objects an action works on, for the selection rule. */
49806
+ getTouchedObjectIds(run, preparation) {
49807
+ if (preparation.targetIds.length > 0) return preparation.targetIds;
49808
+ if (preparation.checkLevel !== "existence") return [];
49809
+ const action = run.action;
49810
+ if (action.type === "click" && !isElementTarget(action.target) && !isObjectTarget(action.target) && run.map) {
49811
+ const hit = hitTestTopMost(run.map, action.target);
49812
+ return hit ? [hit.id] : [];
49813
+ }
49814
+ return preparation.referenceIds;
49815
+ }
49816
+ /** Makes the top-level objects a completed agent action created its selection. */
49817
+ selectCreatedObjects(run, map, objectIds, createdIds) {
49818
+ if (run.actorKind !== "agent" || SELECTION_RULE_EXEMPT_ACTIONS.has(run.action.type) || !map || createdIds.size === 0) return;
49819
+ const created = objectIds.filter((id2) => {
49820
+ if (!createdIds.has(id2)) return false;
49821
+ const object2 = map.findById(id2);
49822
+ return !!object2 && !isSelectionObject(object2) && isTopLevel(map, id2);
49823
+ });
49824
+ if (created.length > 0) this.setSelection(run.cursorId, created);
49825
+ }
48892
49826
  /** Drops deleted objects from explicit selections. */
48893
49827
  pruneSelections() {
48894
49828
  if (this._selections.size === 0) {
@@ -49141,6 +50075,7 @@ var UpmadeCore = class {
49141
50075
  _editorId;
49142
50076
  /** Current user for awareness broadcasting */
49143
50077
  _user;
50078
+ _userStatus = null;
49144
50079
  /**
49145
50080
  * Gets the Upmade engine instance.
49146
50081
  * @returns The engine component managing rendering and events
@@ -49290,6 +50225,18 @@ var UpmadeCore = class {
49290
50225
  this._store.setLocalUserId(user?.id ?? null);
49291
50226
  this._store.objects?.setLocalUser(user);
49292
50227
  }
50228
+ /** What the current user is doing, as collaborators see it on the user's cursor label; `null` when nothing. */
50229
+ get userStatus() {
50230
+ return this._userStatus;
50231
+ }
50232
+ /**
50233
+ * Shows what the current user is doing (e.g. `'typing…'` or a message) to collaborators: their editors show it
50234
+ * in place of the user's name on the cursor label, like an agent's status. `null` or `''` shows the name again.
50235
+ */
50236
+ setUserStatus(status) {
50237
+ this._userStatus = status || null;
50238
+ this._store.objects?.setLocalStatus(this._userStatus);
50239
+ }
49293
50240
  /**
49294
50241
  * Creates a new UpmadeCore instance.
49295
50242
  * Initializes the store with default configuration and sets up all managers.
@@ -49469,6 +50416,9 @@ var UpmadeCore = class {
49469
50416
  if (this._user) {
49470
50417
  objectsMap.setLocalUser(this._user);
49471
50418
  }
50419
+ if (this._userStatus) {
50420
+ objectsMap.setLocalStatus(this._userStatus);
50421
+ }
49472
50422
  this._remoteAgentManager.clear();
49473
50423
  this._agentBroadcaster.reset();
49474
50424
  objectsMap.onAwarenessChange((states) => {
@@ -50921,9 +51871,10 @@ var UpmadeViewport = class _UpmadeViewport {
50921
51871
  }
50922
51872
  if (activePointers.length === 2) {
50923
51873
  this._core.store.objects?.clearCursorPosition();
50924
- const currentPath = this._core.store.currentPath;
50925
- if (currentPath) {
50926
- this._core.store.objects.remove((obj) => obj.id === currentPath.id);
51874
+ const drawingObjectId = this._core.store.objects?.localActiveDrawingObjectId;
51875
+ const drawingObject = drawingObjectId ? this._core.store.objects.findById(drawingObjectId) : void 0;
51876
+ if (drawingObject instanceof UpmadePath) {
51877
+ this._core.store.objects.discard(drawingObject.id);
50927
51878
  }
50928
51879
  if (this._core.store.state.isSelecting) {
50929
51880
  this._core.store.state.isSelecting = false;
@@ -52520,49 +53471,29 @@ var UpmadeSvgExportHelper = class {
52520
53471
  }
52521
53472
  };
52522
53473
 
52523
- // src/helpers/viewport-overlay.helper.ts
52524
- var UpmadeViewportOverlayHelper = class {
52525
- static {
52526
- __name(this, "UpmadeViewportOverlayHelper");
52527
- }
52528
- static worldToScreen(state, worldX, worldY) {
52529
- return {
52530
- x: worldX * state.scale + state.translateX,
52531
- y: worldY * state.scale + state.translateY
52532
- };
52533
- }
52534
- static isInViewport(state, screenX, screenY) {
52535
- return screenX >= 0 && screenX <= state.viewportWidth && screenY >= 0 && screenY <= state.viewportHeight;
52536
- }
52537
- /** Clamps an off-screen point to the viewport edge, returning the nearest edge and the direction to the point. */
52538
- static clampToEdge(state, screenX, screenY, padding) {
52539
- const { viewportWidth, viewportHeight } = state;
52540
- const clampedX = Math.max(padding, Math.min(viewportWidth - padding, screenX));
52541
- const clampedY = Math.max(padding, Math.min(viewportHeight - padding, screenY));
52542
- const distLeft = clampedX - padding;
52543
- const distRight = viewportWidth - padding - clampedX;
52544
- const distTop = clampedY - padding;
52545
- const distBottom = viewportHeight - padding - clampedY;
52546
- let edge = "top";
52547
- const minDist = Math.min(distLeft, distRight, distTop, distBottom);
52548
- if (minDist === distLeft) edge = "left";
52549
- else if (minDist === distRight) edge = "right";
52550
- else if (minDist === distTop) edge = "top";
52551
- else edge = "bottom";
52552
- const angle = Math.atan2(screenY - clampedY, screenX - clampedX);
52553
- return { x: clampedX, y: clampedY, angle, edge };
52554
- }
52555
- static getInitials(name) {
52556
- const parts = name.trim().split(/\s+/);
52557
- if (parts.length === 0 || parts.length === 1 && parts[0].length <= 1) {
52558
- return name;
52559
- }
52560
- if (parts.length === 1) {
52561
- return parts[0][0].toUpperCase();
53474
+ // src/helpers/cursor-label-action.helper.ts
53475
+ var UPMADE_OVERLAY_CONTROL_ATTRIBUTE = "data-upmade-overlay-control";
53476
+ function isOverlayControlEvent(event) {
53477
+ return (event.composedPath?.() ?? []).some(
53478
+ (target2) => typeof target2.hasAttribute === "function" && target2.hasAttribute(UPMADE_OVERLAY_CONTROL_ATTRIBUTE)
53479
+ );
53480
+ }
53481
+ __name(isOverlayControlEvent, "isOverlayControlEvent");
53482
+ function runCursorLabelAction(core, action, event) {
53483
+ try {
53484
+ if (action.onClick) {
53485
+ action.onClick(event);
53486
+ } else if (event.cursorKind === "agent" && event.agentId && action.id === UPMADE_REMOVE_AGENT_CURSOR_ACTION.id) {
53487
+ if (!core.agentManager.sendHome(event.agentId)) {
53488
+ core.agentManager.remove(event.agentId);
53489
+ }
52562
53490
  }
52563
- return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();
53491
+ } catch (error) {
53492
+ console.error("[Upmade] A cursor label action failed:", error);
52564
53493
  }
52565
- };
53494
+ core.engine?.emitCursorLabelAction?.(event);
53495
+ }
53496
+ __name(runCursorLabelAction, "runCursorLabelAction");
52566
53497
 
52567
53498
  // src/helpers/wheel.helper.ts
52568
53499
  var UpmadeWheelHelper = class {
@@ -52721,10 +53652,14 @@ export {
52721
53652
  UPMADE_AGENT_BRAND,
52722
53653
  UPMADE_CHAT_PROTOCOL_VERSION,
52723
53654
  UPMADE_CHAT_SESSION_BRAND,
53655
+ UPMADE_CURSOR_ICON_MAX_LENGTH,
52724
53656
  UPMADE_DEFAULT_OBJECT_TITLEBAR,
52725
53657
  UPMADE_OBJECT_APPEAR_MAX_BATCH,
52726
53658
  UPMADE_OBJECT_APPEAR_MAX_STAGGER_INDEX,
52727
53659
  UPMADE_OBJECT_TYPE_ICONS,
53660
+ UPMADE_OBJECT_TYPE_TERMS,
53661
+ UPMADE_OVERLAY_CONTROL_ATTRIBUTE,
53662
+ UPMADE_REMOVE_AGENT_CURSOR_ACTION,
52728
53663
  UPMADE_ROTATION_HANDLE_DISTANCE,
52729
53664
  UPMADE_TITLEBAR_CONTROL_ATTRIBUTE,
52730
53665
  UPMADE_TITLEBAR_DEFAULT_HEIGHT,
@@ -52799,8 +53734,12 @@ export {
52799
53734
  darkTheme,
52800
53735
  defaultIcons,
52801
53736
  formatAgentToolResult,
53737
+ getSelectionLabelPoint,
53738
+ getSelectionTopLeft,
52802
53739
  hasRemoteSyncProvider,
52803
53740
  isLegacyClassName,
53741
+ isObjectReferenceable,
53742
+ isOverlayControlEvent,
52804
53743
  isUpmadeAgent,
52805
53744
  isUpmadeChatSession,
52806
53745
  lightTheme,
@@ -52808,7 +53747,10 @@ export {
52808
53747
  normalizeLegacyClassName,
52809
53748
  parsePartialJson,
52810
53749
  resolveColor,
53750
+ resolveObjectConfigOption,
53751
+ resolveObjectTitle,
52811
53752
  resolveTextToolAvailableFonts,
53753
+ runCursorLabelAction,
52812
53754
  runMigrations,
52813
53755
  toLegacyDocumentName,
52814
53756
  toLegacyDocumentNames