@invergent/agent-chat-react 2.15.1 → 2.15.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -15905,6 +15905,24 @@ function mapSelected(doc, edit) {
15905
15905
  objects: doc.objects.map((o) => o.selected ? edit(o) : o)
15906
15906
  };
15907
15907
  }
15908
+ var RABBIT_MARK_PATH = "M49.71,46.83c0,.23.02.45.07.67,2.1.49,4.16,1.07,6.18,1.74.58-.64.94-1.48.94-2.42,0-1.98-1.61-3.59-3.59-3.59s-3.59,1.61-3.59,3.59M33.95,78.3c3.1-5.1,6.72-8.89,11.64-12.21.61-.42,1.24-.8,1.88-1.17.44-.25.61-.66.58-1.05,0-.53-.49-.91-.93-1.12-1.34-.62-2.72-1.5-4.06-2.54-1.57-1.22-3.01-2.59-4.36-4.06-.95-1.04-2.02-2.38-3-3.81-.81-1.18-.63-2.77.43-3.73,1.1-1,2.26-1.92,3.48-2.76.36-.25.72-.49,1.1-.73,2.43-1.55,5.05-2.79,7.79-3.7,3.23-1.07,6.62-1.66,10.03-1.74.59-.35,1.19-.69,1.8-1.01,1.66-.88,3.38-1.62,5.17-2.21,1.58-.54,3.2-.95,4.85-1.24,3.28-.59,6.64-.7,9.95-.32,1.23.14,2.45.34,3.68.62,2.87.64,5.59,1.62,8.09,2.9.54.27.71.95.36,1.45-1.58,2.22-3.46,4.25-5.5,6.05-3.01,2.65-6.51,4.75-10.26,6.17-2.32.88-4.75,1.53-7.22,1.91-.62.1-.78.9-.24,1.22,0,0,.01,0,.02.01,6.97,4.05,13.1,9.22,18.36,15.32.72.83,1.42,1.68,2.1,2.53,3.36,4.22,6.23,8.82,8.56,13.68,1.8,3.73,3.27,7.63,4.39,11.62.73,2.6,1.34,5.24,1.76,7.91.11.76-.87,1.16-1.3.53-1.15-1.69-2.31-3.35-3.61-4.93-1.2-1.46-2.46-2.86-3.75-4.24-5.44-5.8-11.84-10.7-18.84-14.48-7.32-3.94-15.09-6.38-23.44-6.53-2.23-.04-4.46.08-6.68.3-4.05.43-8.02,1.28-11.93,2.4-.03,0-.05.01-.08.02,0,0-.01,0-.02,0-.07.02-.14.03-.21.03-.53,0-.91-.6-.61-1.09M50.95,12.97c-1.31,1.16-2.2,2.71-2.9,4.29-1.66,3.74-2.85,7.74-3.52,11.77-.32,1.92-.56,3.87-1.28,5.69-.17.44-.37.87-.6,1.28-1.18,2.1-3.37,3.19-5.6,3.86-4.96,1.47-10.14,1.97-15.25,2.65-2.37.31-8.03,1.12-7.34,4.69.46,2.36,2.26,4.16,4.08,5.6,2.66,2.11,5.44,4.09,8.33,5.88,1.87,1.15,3.85,2.11,5.6,3.44,1.74,1.33,3.15,3.05,3.58,5.25.22,1.16-.18,2.35-1,3.2-1.57,1.63-3,3.41-4.25,5.29-1.32,2.1-2.38,4.35-3.25,6.65-.59,1.44.97,2.98,2.41,2.37.53-.21,1.07-.41,1.61-.61,2.26-.82,4.68.73,4.93,3.12.17,1.61.38,3.17.63,4.57.46,2.57,3.14,3.63,5.32,1.41,2.84-2.88,4.66-6.31,7.84-8.86,2.53-2.03,6.26-4.17,9.71-3.59,3.17.56,6.27,1.52,9.23,2.85,5.32,2.32,10.36,5.29,14.95,8.86,9.17,7.1,16.56,16.51,21.27,27.1.93,2.07,4.03,1.44,4.1-.83.55-17.71-5.72-35.46-17.11-49.01-2.87-3.42-6.07-6.65-9.59-9.44-.88-.8-1.54-1.7-1.38-2.93.38-2.97,2-4.32,4.04-5.85,2.51-1.89,5.02-3.85,7.16-6.21.03-.03.06-.06.09-.1,1.24-1.37,2.38-2.83,3.4-4.37,1.2-1.81.6-4.26-1.3-5.31,0,0-.96-.52-1.45-.76-2.72-1.34-5.61-2.36-8.6-3.03-2.76-.62-5.58-.93-8.38-.93-2.38,0-4.76.22-7.09.67-1.96.37-3.97-.31-5.25-1.84-.28-.34-.54-.69-.79-1.04-.58-.84-1.09-1.71-1.63-2.58-1.29-2.06-1.87-3.63-2.89-5.84-1.06-2.29-1.85-4.73-3.26-6.86-.73-1.11-1.53-1.54-2.32-1.54s-1.54.41-2.24,1.02";
15909
+ var RABBIT_MARK_BOX = {
15910
+ x: 14.4021,
15911
+ y: 11.93,
15912
+ h: 109.058
15913
+ };
15914
+ function RabbitMark({ className }) {
15915
+ return /* @__PURE__ */ jsxRuntime.jsx(
15916
+ "svg",
15917
+ {
15918
+ className,
15919
+ viewBox: "14.4021 11.93 95.1813 109.058",
15920
+ fill: "currentColor",
15921
+ "aria-hidden": "true",
15922
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: RABBIT_MARK_PATH })
15923
+ }
15924
+ );
15925
+ }
15908
15926
 
15909
15927
  // src/components/whiteboard/render.ts
15910
15928
  var TEXT_GLYPH_ADVANCE = 0.6;
@@ -16116,6 +16134,13 @@ function paintArtifactFrame(ctx, obj) {
16116
16134
  ctx.strokeRect(obj.x, obj.y, obj.w, obj.h);
16117
16135
  ctx.restore();
16118
16136
  }
16137
+ var rabbit;
16138
+ function rabbitPath() {
16139
+ if (rabbit === void 0) {
16140
+ rabbit = typeof Path2D === "undefined" ? null : new Path2D(RABBIT_MARK_PATH);
16141
+ }
16142
+ return rabbit;
16143
+ }
16119
16144
  function paintSlot(ctx, obj) {
16120
16145
  ctx.save();
16121
16146
  ctx.setLineDash([8, 6]);
@@ -16125,10 +16150,19 @@ function paintSlot(ctx, obj) {
16125
16150
  ctx.fillRect(obj.x, obj.y, obj.w, obj.h);
16126
16151
  ctx.strokeRect(obj.x, obj.y, obj.w, obj.h);
16127
16152
  const glyph = Math.max(12, Math.min(obj.h * 0.5, obj.w * 0.3, 40));
16128
- ctx.font = `${glyph}px system-ui, sans-serif`;
16129
- ctx.textBaseline = "top";
16130
- ctx.fillStyle = "rgba(180, 83, 9, 0.9)";
16131
- ctx.fillText("\u{1F916}", obj.x + glyph * 0.3, obj.y + (obj.h - glyph) / 2);
16153
+ const mark = rabbitPath();
16154
+ if (mark) {
16155
+ const scale = glyph / RABBIT_MARK_BOX.h;
16156
+ ctx.save();
16157
+ ctx.translate(
16158
+ obj.x + glyph * 0.3 - RABBIT_MARK_BOX.x * scale,
16159
+ obj.y + (obj.h - glyph) / 2 - RABBIT_MARK_BOX.y * scale
16160
+ );
16161
+ ctx.scale(scale, scale);
16162
+ ctx.fillStyle = "rgba(180, 83, 9, 0.9)";
16163
+ ctx.fill(mark);
16164
+ ctx.restore();
16165
+ }
16132
16166
  if (obj.hint) {
16133
16167
  const size2 = Math.max(10, Math.min(obj.h * 0.3, (obj.w - glyph * 1.6) / Math.max(obj.hint.length, 1) / 0.6, 22));
16134
16168
  ctx.font = `italic ${size2}px system-ui, sans-serif`;
@@ -16217,7 +16251,6 @@ function renderDoc(ctx, doc, view, size2, services, dpr = 1) {
16217
16251
  // src/components/whiteboard/atlas.ts
16218
16252
  var MAX_ATLAS_WIDTH = 2048;
16219
16253
  var MAX_ATLAS_HEIGHT = 1536;
16220
- var HOTSPOT_GRID = 8;
16221
16254
  var MIN_CAPTURE_SPAN = 600;
16222
16255
  var CAPTURE_MARGIN = 0.25;
16223
16256
  var MAX_CAPTURE_SPAN_W = MAX_ATLAS_WIDTH;
@@ -16319,32 +16352,6 @@ function planAtlas(doc, latest, view, viewport, services) {
16319
16352
  }
16320
16353
  };
16321
16354
  }
16322
- function occupancyCells(doc, sourceRect, services) {
16323
- if (sourceRect.w <= 0 || sourceRect.h <= 0) return [];
16324
- const seen = /* @__PURE__ */ new Set();
16325
- const cells = [];
16326
- const cellW = sourceRect.w / OCCUPANCY_GRID;
16327
- const cellH = sourceRect.h / OCCUPANCY_GRID;
16328
- for (const obj of doc.objects) {
16329
- if (obj.kind === "slot") continue;
16330
- const b = objectBounds(obj, services);
16331
- if (!b) continue;
16332
- const c0 = Math.floor((b.x - sourceRect.x) / cellW);
16333
- const c1 = Math.floor((b.x + b.w - sourceRect.x) / cellW);
16334
- const r0 = Math.floor((b.y - sourceRect.y) / cellH);
16335
- const r1 = Math.floor((b.y + b.h - sourceRect.y) / cellH);
16336
- for (let r = Math.max(0, r0); r <= Math.min(OCCUPANCY_GRID - 1, r1); r++) {
16337
- for (let c = Math.max(0, c0); c <= Math.min(OCCUPANCY_GRID - 1, c1); c++) {
16338
- const key = r * OCCUPANCY_GRID + c;
16339
- if (seen.has(key)) continue;
16340
- seen.add(key);
16341
- cells.push([c, r]);
16342
- }
16343
- }
16344
- }
16345
- cells.sort((a, b) => a[1] - b[1] || a[0] - b[0]);
16346
- return cells;
16347
- }
16348
16355
  var AGENT_OBJECT_LIMIT = 8;
16349
16356
  function objectLabel(obj) {
16350
16357
  const raw = obj.kind === "text" ? obj.text : obj.kind === "formula" ? obj.latex : obj.kind === "artifact" ? `artifact ${obj.artifactId}` : obj.kind;
@@ -16579,6 +16586,14 @@ function cropRegions(marks, unit) {
16579
16586
  }
16580
16587
  return regions;
16581
16588
  }
16589
+ function fillBackdrop(ctx, w, h) {
16590
+ ctx.save();
16591
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
16592
+ ctx.globalCompositeOperation = "destination-over";
16593
+ ctx.fillStyle = "#ffffff";
16594
+ ctx.fillRect(0, 0, w, h);
16595
+ ctx.restore();
16596
+ }
16582
16597
  function buildRegionCrop(doc, region, services, unit) {
16583
16598
  const margin = Math.max(unit * 0.6, 8);
16584
16599
  const area = grow(region.rect, margin);
@@ -16592,9 +16607,6 @@ function buildRegionCrop(doc, region, services, unit) {
16592
16607
  const canvas = services.createCanvas(size2.w, size2.h);
16593
16608
  const ctx = canvas.getContext("2d");
16594
16609
  if (!ctx) return null;
16595
- ctx.setTransform(1, 0, 0, 1, 0, 0);
16596
- ctx.fillStyle = "#ffffff";
16597
- ctx.fillRect(0, 0, size2.w, size2.h);
16598
16610
  renderDoc(
16599
16611
  ctx,
16600
16612
  { ...doc, objects: doc.objects.map((o) => ({ ...o, selected: false })) },
@@ -16602,6 +16614,7 @@ function buildRegionCrop(doc, region, services, unit) {
16602
16614
  size2,
16603
16615
  services
16604
16616
  );
16617
+ fillBackdrop(ctx, size2.w, size2.h);
16605
16618
  return { ids: region.ids, canvas, scale: Math.round(scale * 100) / 100 };
16606
16619
  }
16607
16620
  function contentBeyond(doc, sourceRect, services) {
@@ -16614,36 +16627,10 @@ function contentBeyond(doc, sourceRect, services) {
16614
16627
  if (content.x < sourceRect.x) out.push("left");
16615
16628
  return out;
16616
16629
  }
16617
- function mapHotspots(sourceRect, points) {
16618
- if (sourceRect.w <= 0 || sourceRect.h <= 0) return [];
16619
- const cells = [];
16620
- for (const p of points) {
16621
- if (p.x < sourceRect.x || p.x > sourceRect.x + sourceRect.w || p.y < sourceRect.y || p.y > sourceRect.y + sourceRect.h) {
16622
- continue;
16623
- }
16624
- const col = clamp(
16625
- Math.floor((p.x - sourceRect.x) / sourceRect.w * HOTSPOT_GRID),
16626
- 0,
16627
- HOTSPOT_GRID - 1
16628
- );
16629
- const row = clamp(
16630
- Math.floor((p.y - sourceRect.y) / sourceRect.h * HOTSPOT_GRID),
16631
- 0,
16632
- HOTSPOT_GRID - 1
16633
- );
16634
- const last = cells[cells.length - 1];
16635
- if (last && last[0] === col && last[1] === row) continue;
16636
- cells.push([col, row]);
16637
- }
16638
- return cells;
16639
- }
16640
16630
  function buildAtlas(doc, plan, services, marks = []) {
16641
16631
  const canvas = services.createCanvas(plan.imageSize.w, plan.imageSize.h);
16642
16632
  const ctx = canvas.getContext("2d");
16643
16633
  if (!ctx) return canvas;
16644
- ctx.setTransform(1, 0, 0, 1, 0, 0);
16645
- ctx.fillStyle = "#ffffff";
16646
- ctx.fillRect(0, 0, plan.imageSize.w, plan.imageSize.h);
16647
16634
  renderDoc(
16648
16635
  ctx,
16649
16636
  // Selection chrome is interface, not content: the model must not see
@@ -16667,6 +16654,7 @@ function buildAtlas(doc, plan, services, marks = []) {
16667
16654
  13,
16668
16655
  1.5
16669
16656
  );
16657
+ fillBackdrop(ctx, plan.imageSize.w, plan.imageSize.h);
16670
16658
  return canvas;
16671
16659
  }
16672
16660
  function paintGridOverlay(ctx, size2) {
@@ -16717,7 +16705,7 @@ var USER_ACTIONS = [
16717
16705
  hint: "Give a clue toward the answer, never the answer itself."
16718
16706
  }
16719
16707
  ];
16720
- function atlasMetadata(plan, latest, hotspots, extras) {
16708
+ function atlasMetadata(plan, latest, extras) {
16721
16709
  const meta = {
16722
16710
  sourceRect: plan.sourceRect,
16723
16711
  imageScale: plan.imageScale,
@@ -16726,20 +16714,11 @@ function atlasMetadata(plan, latest, hotspots, extras) {
16726
16714
  mode: extras.mode === "deep" ? "deep" : "sketch"
16727
16715
  };
16728
16716
  if (latest) meta.latestInput = latest;
16729
- if (hotspots.length > 0) meta.hotspots = hotspots;
16730
16717
  if (extras.selection) meta.selection = extras.selection;
16731
16718
  if (extras.typedInput?.trim()) meta.typedInput = extras.typedInput.trim();
16732
16719
  if (extras.inkHeight && extras.inkHeight > 0) {
16733
16720
  meta.inkHeight = Math.round(extras.inkHeight);
16734
16721
  }
16735
- if (extras.occupied?.length) {
16736
- meta.occupied = extras.occupied;
16737
- meta.occupancyGrid = OCCUPANCY_GRID;
16738
- meta.cellSize = {
16739
- w: round2(plan.sourceRect.w / OCCUPANCY_GRID),
16740
- h: round2(plan.sourceRect.h / OCCUPANCY_GRID)
16741
- };
16742
- }
16743
16722
  if (extras.beyond?.length) meta.beyond = extras.beyond;
16744
16723
  if (extras.marks?.length) {
16745
16724
  meta.marks = extras.marks.map((m) => ({
@@ -17434,7 +17413,7 @@ var TOOLS = [
17434
17413
  { id: "text", label: "Text", Icon: lucideReact.Type },
17435
17414
  // Where the agent should answer: click to place an answer box, or
17436
17415
  // drag one. The id stays "slot" -- that is what the object is.
17437
- { id: "slot", label: "Answer box", Icon: lucideReact.Bot },
17416
+ { id: "slot", label: "Answer box", Icon: RabbitMark },
17438
17417
  { id: "select", label: "Select", Icon: lucideReact.MousePointer2 },
17439
17418
  { id: "pan", label: "Pan", Icon: lucideReact.Hand }
17440
17419
  ];
@@ -17612,7 +17591,6 @@ function WhiteboardSurface({
17612
17591
  const cursorRef = react.useRef(null);
17613
17592
  const resize = react.useRef(null);
17614
17593
  const gestureBaseline = react.useRef(null);
17615
- const hotspotsRef = react.useRef([]);
17616
17594
  const typedRef = react.useRef([]);
17617
17595
  const dirtyRef = react.useRef(null);
17618
17596
  const seenAtLastAsk = react.useRef(/* @__PURE__ */ new Set());
@@ -17863,7 +17841,6 @@ function WhiteboardSurface({
17863
17841
  return () => cancelAnimationFrame(id);
17864
17842
  }, [paint]);
17865
17843
  const noteDirty = react.useCallback((pt) => {
17866
- hotspotsRef.current.push(pt);
17867
17844
  const d = dirtyRef.current;
17868
17845
  dirtyRef.current = d ? {
17869
17846
  x: Math.min(d.x, pt.x),
@@ -18190,14 +18167,12 @@ function WhiteboardSurface({
18190
18167
  )
18191
18168
  });
18192
18169
  const atlas = buildAtlas(doc, plan, services, marks);
18193
- const hotspots = mapHotspots(plan.sourceRect, hotspotsRef.current);
18194
18170
  const legible = (unit ?? 40) * plan.imageScale >= 180;
18195
18171
  const crops = legible ? [] : cropRegions(marks, unit ?? 40).map((r) => buildRegionCrop(doc, r, services, unit ?? 40)).filter((c) => c !== null);
18196
18172
  const extras = {
18197
18173
  mode,
18198
18174
  action,
18199
18175
  inkHeight: unit,
18200
- occupied: occupancyCells(doc, plan.sourceRect, services),
18201
18176
  beyond: contentBeyond(doc, plan.sourceRect, services),
18202
18177
  marks,
18203
18178
  crops: crops.map((c, i) => ({
@@ -18215,7 +18190,6 @@ function WhiteboardSurface({
18215
18190
  const b = objectBounds(selected, services);
18216
18191
  if (b) extras.selection = b;
18217
18192
  }
18218
- hotspotsRef.current = [];
18219
18193
  dirtyRef.current = null;
18220
18194
  typedRef.current = [];
18221
18195
  const text = question;
@@ -18230,7 +18204,7 @@ function WhiteboardSurface({
18230
18204
  }))
18231
18205
  ],
18232
18206
  void 0,
18233
- { whiteboard: atlasMetadata(plan, latest, hotspots, extras) }
18207
+ { whiteboard: atlasMetadata(plan, latest, extras) }
18234
18208
  );
18235
18209
  },
18236
18210
  [doc, view, size2, services, question, runtime, deep]