@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.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { cn, __publicField } from './chunk-47MF6JUW.js';
2
2
  import { createContext, memo, useRef, useEffect, useCallback, useMemo, useState, useLayoutEffect, forwardRef, useId, lazy, useContext, useSyncExternalStore, Fragment as Fragment$1, Suspense, Children } from 'react';
3
- import { ChevronDownIcon, AlertTriangle, ChevronDown, ChevronRight, RefreshCw, CreditCard, File as File$1, FileImage, FileAudio, FileVideo, FileText, FileCode, FileArchive, FileSpreadsheet, PlugZapIcon, ChevronRightIcon, ArrowLeftIcon, Loader2Icon, InboxIcon, Loader2, AlertCircle, Pause, Play, Ban, TargetIcon, CalendarClockIcon, UsersIcon, Pen, Eraser, Type, Bot, MousePointer2, Hand, Maximize2, Undo2, Redo2, CheckIcon, CopyIcon, DownloadIcon, Maximize2Icon, MessageSquareIcon, ZapIcon, FolderOpenIcon, UploadIcon, RefreshCwIcon, AlertCircleIcon, ExternalLinkIcon, ClipboardCheckIcon, ShieldAlertIcon, TimerIcon, CircleDotIcon, ChevronLeftIcon, XIcon, Trash2Icon, SquareIcon, ArrowDownIcon, RotateCcwIcon, MousePointer2Icon, TrashIcon, ImageIcon, FileTextIcon, Clock, ArrowRight, ListTreeIcon, PenLineIcon, TerminalIcon, SparklesIcon, ClockIcon, PaperclipIcon, CloudIcon, HardDriveIcon, GlobeIcon, FolderIcon, IdCardIcon, PlusIcon, ShrinkIcon, FileIcon, MinusIcon, SearchIcon, CircleDot, XCircle, CheckCircle2, ArrowUpIcon, CircleCheckIcon, ThumbsUpIcon, ThumbsDownIcon, BookOpenIcon, GitBranchIcon, ActivityIcon, EyeIcon, ListTodoIcon, BotIcon, ListIcon, FileEditIcon, WrenchIcon, FileCodeIcon, CodeIcon, FileArchiveIcon, FileVideoIcon, FileAudioIcon, FileImageIcon, FileChartLineIcon, FileSpreadsheetIcon, XCircleIcon, CheckCircle2Icon, Code, CircleXIcon, SkullIcon, CheckCircleIcon, CircleIcon } from 'lucide-react';
3
+ import { ChevronDownIcon, AlertTriangle, ChevronDown, ChevronRight, RefreshCw, CreditCard, File as File$1, FileImage, FileAudio, FileVideo, FileText, FileCode, FileArchive, FileSpreadsheet, PlugZapIcon, ChevronRightIcon, ArrowLeftIcon, Loader2Icon, InboxIcon, Loader2, AlertCircle, Pause, Play, Ban, TargetIcon, CalendarClockIcon, UsersIcon, Pen, Eraser, Type, MousePointer2, Hand, Maximize2, Undo2, Redo2, CheckIcon, CopyIcon, DownloadIcon, Maximize2Icon, MessageSquareIcon, ZapIcon, FolderOpenIcon, UploadIcon, RefreshCwIcon, AlertCircleIcon, ExternalLinkIcon, ClipboardCheckIcon, ShieldAlertIcon, TimerIcon, CircleDotIcon, ChevronLeftIcon, XIcon, Trash2Icon, SquareIcon, ArrowDownIcon, RotateCcwIcon, MousePointer2Icon, TrashIcon, ImageIcon, FileTextIcon, Clock, ArrowRight, ListTreeIcon, PenLineIcon, TerminalIcon, SparklesIcon, ClockIcon, PaperclipIcon, CloudIcon, HardDriveIcon, GlobeIcon, FolderIcon, IdCardIcon, PlusIcon, ShrinkIcon, FileIcon, MinusIcon, SearchIcon, CircleDot, XCircle, CheckCircle2, ArrowUpIcon, CircleCheckIcon, ThumbsUpIcon, ThumbsDownIcon, BookOpenIcon, GitBranchIcon, ActivityIcon, EyeIcon, ListTodoIcon, BotIcon, ListIcon, FileEditIcon, WrenchIcon, FileCodeIcon, CodeIcon, FileArchiveIcon, FileVideoIcon, FileAudioIcon, FileImageIcon, FileChartLineIcon, FileSpreadsheetIcon, XCircleIcon, CheckCircle2Icon, Code, CircleXIcon, SkullIcon, CheckCircleIcon, CircleIcon } from 'lucide-react';
4
4
  import { cva } from 'class-variance-authority';
5
5
  import { Collapsible as Collapsible$1, Slot, Tooltip as Tooltip$1, Checkbox as Checkbox$1, Label as Label$1, Progress as Progress$1, Tabs as Tabs$1, Dialog as Dialog$1, ScrollArea as ScrollArea$1, Popover as Popover$1 } from 'radix-ui';
6
6
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -15577,6 +15577,24 @@ function mapSelected(doc, edit) {
15577
15577
  objects: doc.objects.map((o) => o.selected ? edit(o) : o)
15578
15578
  };
15579
15579
  }
15580
+ 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";
15581
+ var RABBIT_MARK_BOX = {
15582
+ x: 14.4021,
15583
+ y: 11.93,
15584
+ h: 109.058
15585
+ };
15586
+ function RabbitMark({ className }) {
15587
+ return /* @__PURE__ */ jsx(
15588
+ "svg",
15589
+ {
15590
+ className,
15591
+ viewBox: "14.4021 11.93 95.1813 109.058",
15592
+ fill: "currentColor",
15593
+ "aria-hidden": "true",
15594
+ children: /* @__PURE__ */ jsx("path", { d: RABBIT_MARK_PATH })
15595
+ }
15596
+ );
15597
+ }
15580
15598
 
15581
15599
  // src/components/whiteboard/render.ts
15582
15600
  var TEXT_GLYPH_ADVANCE = 0.6;
@@ -15788,6 +15806,13 @@ function paintArtifactFrame(ctx, obj) {
15788
15806
  ctx.strokeRect(obj.x, obj.y, obj.w, obj.h);
15789
15807
  ctx.restore();
15790
15808
  }
15809
+ var rabbit;
15810
+ function rabbitPath() {
15811
+ if (rabbit === void 0) {
15812
+ rabbit = typeof Path2D === "undefined" ? null : new Path2D(RABBIT_MARK_PATH);
15813
+ }
15814
+ return rabbit;
15815
+ }
15791
15816
  function paintSlot(ctx, obj) {
15792
15817
  ctx.save();
15793
15818
  ctx.setLineDash([8, 6]);
@@ -15797,10 +15822,19 @@ function paintSlot(ctx, obj) {
15797
15822
  ctx.fillRect(obj.x, obj.y, obj.w, obj.h);
15798
15823
  ctx.strokeRect(obj.x, obj.y, obj.w, obj.h);
15799
15824
  const glyph = Math.max(12, Math.min(obj.h * 0.5, obj.w * 0.3, 40));
15800
- ctx.font = `${glyph}px system-ui, sans-serif`;
15801
- ctx.textBaseline = "top";
15802
- ctx.fillStyle = "rgba(180, 83, 9, 0.9)";
15803
- ctx.fillText("\u{1F916}", obj.x + glyph * 0.3, obj.y + (obj.h - glyph) / 2);
15825
+ const mark = rabbitPath();
15826
+ if (mark) {
15827
+ const scale = glyph / RABBIT_MARK_BOX.h;
15828
+ ctx.save();
15829
+ ctx.translate(
15830
+ obj.x + glyph * 0.3 - RABBIT_MARK_BOX.x * scale,
15831
+ obj.y + (obj.h - glyph) / 2 - RABBIT_MARK_BOX.y * scale
15832
+ );
15833
+ ctx.scale(scale, scale);
15834
+ ctx.fillStyle = "rgba(180, 83, 9, 0.9)";
15835
+ ctx.fill(mark);
15836
+ ctx.restore();
15837
+ }
15804
15838
  if (obj.hint) {
15805
15839
  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));
15806
15840
  ctx.font = `italic ${size2}px system-ui, sans-serif`;
@@ -15889,7 +15923,6 @@ function renderDoc(ctx, doc, view, size2, services, dpr = 1) {
15889
15923
  // src/components/whiteboard/atlas.ts
15890
15924
  var MAX_ATLAS_WIDTH = 2048;
15891
15925
  var MAX_ATLAS_HEIGHT = 1536;
15892
- var HOTSPOT_GRID = 8;
15893
15926
  var MIN_CAPTURE_SPAN = 600;
15894
15927
  var CAPTURE_MARGIN = 0.25;
15895
15928
  var MAX_CAPTURE_SPAN_W = MAX_ATLAS_WIDTH;
@@ -15991,32 +16024,6 @@ function planAtlas(doc, latest, view, viewport, services) {
15991
16024
  }
15992
16025
  };
15993
16026
  }
15994
- function occupancyCells(doc, sourceRect, services) {
15995
- if (sourceRect.w <= 0 || sourceRect.h <= 0) return [];
15996
- const seen = /* @__PURE__ */ new Set();
15997
- const cells = [];
15998
- const cellW = sourceRect.w / OCCUPANCY_GRID;
15999
- const cellH = sourceRect.h / OCCUPANCY_GRID;
16000
- for (const obj of doc.objects) {
16001
- if (obj.kind === "slot") continue;
16002
- const b = objectBounds(obj, services);
16003
- if (!b) continue;
16004
- const c0 = Math.floor((b.x - sourceRect.x) / cellW);
16005
- const c1 = Math.floor((b.x + b.w - sourceRect.x) / cellW);
16006
- const r0 = Math.floor((b.y - sourceRect.y) / cellH);
16007
- const r1 = Math.floor((b.y + b.h - sourceRect.y) / cellH);
16008
- for (let r = Math.max(0, r0); r <= Math.min(OCCUPANCY_GRID - 1, r1); r++) {
16009
- for (let c = Math.max(0, c0); c <= Math.min(OCCUPANCY_GRID - 1, c1); c++) {
16010
- const key = r * OCCUPANCY_GRID + c;
16011
- if (seen.has(key)) continue;
16012
- seen.add(key);
16013
- cells.push([c, r]);
16014
- }
16015
- }
16016
- }
16017
- cells.sort((a, b) => a[1] - b[1] || a[0] - b[0]);
16018
- return cells;
16019
- }
16020
16027
  var AGENT_OBJECT_LIMIT = 8;
16021
16028
  function objectLabel(obj) {
16022
16029
  const raw = obj.kind === "text" ? obj.text : obj.kind === "formula" ? obj.latex : obj.kind === "artifact" ? `artifact ${obj.artifactId}` : obj.kind;
@@ -16251,6 +16258,14 @@ function cropRegions(marks, unit) {
16251
16258
  }
16252
16259
  return regions;
16253
16260
  }
16261
+ function fillBackdrop(ctx, w, h) {
16262
+ ctx.save();
16263
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
16264
+ ctx.globalCompositeOperation = "destination-over";
16265
+ ctx.fillStyle = "#ffffff";
16266
+ ctx.fillRect(0, 0, w, h);
16267
+ ctx.restore();
16268
+ }
16254
16269
  function buildRegionCrop(doc, region, services, unit) {
16255
16270
  const margin = Math.max(unit * 0.6, 8);
16256
16271
  const area = grow(region.rect, margin);
@@ -16264,9 +16279,6 @@ function buildRegionCrop(doc, region, services, unit) {
16264
16279
  const canvas = services.createCanvas(size2.w, size2.h);
16265
16280
  const ctx = canvas.getContext("2d");
16266
16281
  if (!ctx) return null;
16267
- ctx.setTransform(1, 0, 0, 1, 0, 0);
16268
- ctx.fillStyle = "#ffffff";
16269
- ctx.fillRect(0, 0, size2.w, size2.h);
16270
16282
  renderDoc(
16271
16283
  ctx,
16272
16284
  { ...doc, objects: doc.objects.map((o) => ({ ...o, selected: false })) },
@@ -16274,6 +16286,7 @@ function buildRegionCrop(doc, region, services, unit) {
16274
16286
  size2,
16275
16287
  services
16276
16288
  );
16289
+ fillBackdrop(ctx, size2.w, size2.h);
16277
16290
  return { ids: region.ids, canvas, scale: Math.round(scale * 100) / 100 };
16278
16291
  }
16279
16292
  function contentBeyond(doc, sourceRect, services) {
@@ -16286,36 +16299,10 @@ function contentBeyond(doc, sourceRect, services) {
16286
16299
  if (content.x < sourceRect.x) out.push("left");
16287
16300
  return out;
16288
16301
  }
16289
- function mapHotspots(sourceRect, points) {
16290
- if (sourceRect.w <= 0 || sourceRect.h <= 0) return [];
16291
- const cells = [];
16292
- for (const p of points) {
16293
- if (p.x < sourceRect.x || p.x > sourceRect.x + sourceRect.w || p.y < sourceRect.y || p.y > sourceRect.y + sourceRect.h) {
16294
- continue;
16295
- }
16296
- const col = clamp(
16297
- Math.floor((p.x - sourceRect.x) / sourceRect.w * HOTSPOT_GRID),
16298
- 0,
16299
- HOTSPOT_GRID - 1
16300
- );
16301
- const row = clamp(
16302
- Math.floor((p.y - sourceRect.y) / sourceRect.h * HOTSPOT_GRID),
16303
- 0,
16304
- HOTSPOT_GRID - 1
16305
- );
16306
- const last = cells[cells.length - 1];
16307
- if (last && last[0] === col && last[1] === row) continue;
16308
- cells.push([col, row]);
16309
- }
16310
- return cells;
16311
- }
16312
16302
  function buildAtlas(doc, plan, services, marks = []) {
16313
16303
  const canvas = services.createCanvas(plan.imageSize.w, plan.imageSize.h);
16314
16304
  const ctx = canvas.getContext("2d");
16315
16305
  if (!ctx) return canvas;
16316
- ctx.setTransform(1, 0, 0, 1, 0, 0);
16317
- ctx.fillStyle = "#ffffff";
16318
- ctx.fillRect(0, 0, plan.imageSize.w, plan.imageSize.h);
16319
16306
  renderDoc(
16320
16307
  ctx,
16321
16308
  // Selection chrome is interface, not content: the model must not see
@@ -16339,6 +16326,7 @@ function buildAtlas(doc, plan, services, marks = []) {
16339
16326
  13,
16340
16327
  1.5
16341
16328
  );
16329
+ fillBackdrop(ctx, plan.imageSize.w, plan.imageSize.h);
16342
16330
  return canvas;
16343
16331
  }
16344
16332
  function paintGridOverlay(ctx, size2) {
@@ -16389,7 +16377,7 @@ var USER_ACTIONS = [
16389
16377
  hint: "Give a clue toward the answer, never the answer itself."
16390
16378
  }
16391
16379
  ];
16392
- function atlasMetadata(plan, latest, hotspots, extras) {
16380
+ function atlasMetadata(plan, latest, extras) {
16393
16381
  const meta = {
16394
16382
  sourceRect: plan.sourceRect,
16395
16383
  imageScale: plan.imageScale,
@@ -16398,20 +16386,11 @@ function atlasMetadata(plan, latest, hotspots, extras) {
16398
16386
  mode: extras.mode === "deep" ? "deep" : "sketch"
16399
16387
  };
16400
16388
  if (latest) meta.latestInput = latest;
16401
- if (hotspots.length > 0) meta.hotspots = hotspots;
16402
16389
  if (extras.selection) meta.selection = extras.selection;
16403
16390
  if (extras.typedInput?.trim()) meta.typedInput = extras.typedInput.trim();
16404
16391
  if (extras.inkHeight && extras.inkHeight > 0) {
16405
16392
  meta.inkHeight = Math.round(extras.inkHeight);
16406
16393
  }
16407
- if (extras.occupied?.length) {
16408
- meta.occupied = extras.occupied;
16409
- meta.occupancyGrid = OCCUPANCY_GRID;
16410
- meta.cellSize = {
16411
- w: round2(plan.sourceRect.w / OCCUPANCY_GRID),
16412
- h: round2(plan.sourceRect.h / OCCUPANCY_GRID)
16413
- };
16414
- }
16415
16394
  if (extras.beyond?.length) meta.beyond = extras.beyond;
16416
16395
  if (extras.marks?.length) {
16417
16396
  meta.marks = extras.marks.map((m) => ({
@@ -17103,7 +17082,7 @@ var TOOLS = [
17103
17082
  { id: "text", label: "Text", Icon: Type },
17104
17083
  // Where the agent should answer: click to place an answer box, or
17105
17084
  // drag one. The id stays "slot" -- that is what the object is.
17106
- { id: "slot", label: "Answer box", Icon: Bot },
17085
+ { id: "slot", label: "Answer box", Icon: RabbitMark },
17107
17086
  { id: "select", label: "Select", Icon: MousePointer2 },
17108
17087
  { id: "pan", label: "Pan", Icon: Hand }
17109
17088
  ];
@@ -17281,7 +17260,6 @@ function WhiteboardSurface({
17281
17260
  const cursorRef = useRef(null);
17282
17261
  const resize = useRef(null);
17283
17262
  const gestureBaseline = useRef(null);
17284
- const hotspotsRef = useRef([]);
17285
17263
  const typedRef = useRef([]);
17286
17264
  const dirtyRef = useRef(null);
17287
17265
  const seenAtLastAsk = useRef(/* @__PURE__ */ new Set());
@@ -17532,7 +17510,6 @@ function WhiteboardSurface({
17532
17510
  return () => cancelAnimationFrame(id);
17533
17511
  }, [paint]);
17534
17512
  const noteDirty = useCallback((pt) => {
17535
- hotspotsRef.current.push(pt);
17536
17513
  const d = dirtyRef.current;
17537
17514
  dirtyRef.current = d ? {
17538
17515
  x: Math.min(d.x, pt.x),
@@ -17859,14 +17836,12 @@ function WhiteboardSurface({
17859
17836
  )
17860
17837
  });
17861
17838
  const atlas = buildAtlas(doc, plan, services, marks);
17862
- const hotspots = mapHotspots(plan.sourceRect, hotspotsRef.current);
17863
17839
  const legible = (unit ?? 40) * plan.imageScale >= 180;
17864
17840
  const crops = legible ? [] : cropRegions(marks, unit ?? 40).map((r) => buildRegionCrop(doc, r, services, unit ?? 40)).filter((c) => c !== null);
17865
17841
  const extras = {
17866
17842
  mode,
17867
17843
  action,
17868
17844
  inkHeight: unit,
17869
- occupied: occupancyCells(doc, plan.sourceRect, services),
17870
17845
  beyond: contentBeyond(doc, plan.sourceRect, services),
17871
17846
  marks,
17872
17847
  crops: crops.map((c, i) => ({
@@ -17884,7 +17859,6 @@ function WhiteboardSurface({
17884
17859
  const b = objectBounds(selected, services);
17885
17860
  if (b) extras.selection = b;
17886
17861
  }
17887
- hotspotsRef.current = [];
17888
17862
  dirtyRef.current = null;
17889
17863
  typedRef.current = [];
17890
17864
  const text = question;
@@ -17899,7 +17873,7 @@ function WhiteboardSurface({
17899
17873
  }))
17900
17874
  ],
17901
17875
  void 0,
17902
- { whiteboard: atlasMetadata(plan, latest, hotspots, extras) }
17876
+ { whiteboard: atlasMetadata(plan, latest, extras) }
17903
17877
  );
17904
17878
  },
17905
17879
  [doc, view, size2, services, question, runtime, deep]