@cntyclub/agent-react 0.12.0 → 0.13.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.
@@ -5,6 +5,17 @@ export interface AgentWidgetProps {
5
5
  /** Controlled open state (optional). */
6
6
  open?: boolean;
7
7
  onOpenChange?: (open: boolean) => void;
8
+ /**
9
+ * How the panel is presented:
10
+ * - `"floating"` (default): a launcher button + a popup/fullscreen panel,
11
+ * positioned by the widget itself (fixed to a screen corner).
12
+ * - `"docked"`: no launcher; the panel fills its parent element so the host
13
+ * can place it in the layout (e.g. a resizable side pane on desktop, or a
14
+ * fullscreen overlay on smaller screens). Open state is controlled by the
15
+ * host via `open`/`onOpenChange`. Page-follow navigation stays enabled so
16
+ * the agent can drive the main view alongside the chat.
17
+ */
18
+ presentation?: "floating" | "docked";
8
19
  }
9
20
  /**
10
21
  * The embeddable Agent Mode widget.
@@ -19,5 +30,5 @@ export interface AgentWidgetProps {
19
30
  * corner; size morph between popup and fullscreen). All colors come from the
20
31
  * host app's UI-kit theme tokens.
21
32
  */
22
- export declare function AgentWidget({ config, onOpenChange, open: controlledOpen }: AgentWidgetProps): React.JSX.Element;
33
+ export declare function AgentWidget({ config, onOpenChange, open: controlledOpen, presentation, }: AgentWidgetProps): React.JSX.Element;
23
34
  //# sourceMappingURL=agent-widget.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-widget.d.ts","sourceRoot":"","sources":["../../src/components/agent-widget.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,UAAU,CAAC;AAK1D,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,WAAW,CAAC;IACpB,wCAAwC;IACxC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACxC;AAQD;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,gBAAgB,qBAqR3F"}
1
+ {"version":3,"file":"agent-widget.d.ts","sourceRoot":"","sources":["../../src/components/agent-widget.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,UAAU,CAAC;AAK1D,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,WAAW,CAAC;IACpB,wCAAwC;IACxC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC;;;;;;;;;OASG;IACH,YAAY,CAAC,EAAE,UAAU,GAAG,QAAQ,CAAC;CACtC;AAQD;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,EAC1B,MAAM,EACN,YAAY,EACZ,IAAI,EAAE,cAAc,EACpB,YAAyB,GAC1B,EAAE,gBAAgB,qBA2TlB"}
package/dist/index.js CHANGED
@@ -2120,10 +2120,16 @@ function isUnreadable(message) {
2120
2120
  if (message.id.startsWith("streaming-")) return false;
2121
2121
  return message.role === "assistant" || message.role === "tool";
2122
2122
  }
2123
- function AgentWidget({ config, onOpenChange, open: controlledOpen }) {
2123
+ function AgentWidget({
2124
+ config,
2125
+ onOpenChange,
2126
+ open: controlledOpen,
2127
+ presentation = "floating"
2128
+ }) {
2124
2129
  const behavior = config.behavior ?? {};
2125
2130
  const position = config.appearance?.position ?? "bottom-right";
2126
2131
  const isControlled = controlledOpen !== void 0;
2132
+ const isDocked = presentation === "docked";
2127
2133
  const storageKey2 = `cc-agent-open:${config.clientId}`;
2128
2134
  const [uncontrolledOpen, setUncontrolledOpen] = React11.useState(false);
2129
2135
  const open = controlledOpen ?? uncontrolledOpen;
@@ -2154,7 +2160,8 @@ function AgentWidget({ config, onOpenChange, open: controlledOpen }) {
2154
2160
  const { messages, pendingApprovals, resolveApproval, resolvingApprovalId, sending } = chat;
2155
2161
  const bootRef = React11.useRef(false);
2156
2162
  React11.useEffect(() => {
2157
- if (isControlled || bootRef.current) return;
2163
+ if (bootRef.current) return;
2164
+ if (isControlled && !isDocked) return;
2158
2165
  bootRef.current = true;
2159
2166
  let cancelled = false;
2160
2167
  void (async () => {
@@ -2164,17 +2171,19 @@ function AgentWidget({ config, onOpenChange, open: controlledOpen }) {
2164
2171
  if (list.length) await chat.openConversation(list[0].id);
2165
2172
  if (cancelled) return;
2166
2173
  }
2167
- let shouldOpen = behavior.initialOpen ?? false;
2168
- if (behavior.persistOpenState) {
2169
- try {
2170
- const stored = window.localStorage.getItem(storageKey2);
2171
- if (stored !== null) shouldOpen = stored === "1";
2172
- } catch {
2174
+ if (!isControlled) {
2175
+ let shouldOpen = behavior.initialOpen ?? false;
2176
+ if (behavior.persistOpenState) {
2177
+ try {
2178
+ const stored = window.localStorage.getItem(storageKey2);
2179
+ if (stored !== null) shouldOpen = stored === "1";
2180
+ } catch {
2181
+ }
2182
+ }
2183
+ if (shouldOpen) {
2184
+ setUncontrolledOpen(true);
2185
+ onOpenChange?.(true);
2173
2186
  }
2174
- }
2175
- if (shouldOpen) {
2176
- setUncontrolledOpen(true);
2177
- onOpenChange?.(true);
2178
2187
  }
2179
2188
  setBootstrapDone(true);
2180
2189
  })();
@@ -2244,7 +2253,7 @@ function AgentWidget({ config, onOpenChange, open: controlledOpen }) {
2244
2253
  setAgentMode(false);
2245
2254
  }, [setOpen]);
2246
2255
  const transformOrigin = position === "bottom-left" ? "bottom left" : "bottom right";
2247
- const launcherHidden = open || config.appearance?.hideLauncher;
2256
+ const launcherHidden = open || config.appearance?.hideLauncher || isDocked;
2248
2257
  return /* @__PURE__ */ jsxs(TooltipProvider, { children: [
2249
2258
  /* @__PURE__ */ jsx(AnimatePresence, { children: !launcherHidden ? /* @__PURE__ */ jsxs(
2250
2259
  motion.div,
@@ -2289,7 +2298,32 @@ function AgentWidget({ config, onOpenChange, open: controlledOpen }) {
2289
2298
  },
2290
2299
  "agent-launcher"
2291
2300
  ) : null }),
2292
- /* @__PURE__ */ jsx(AnimatePresence, { children: open ? /* @__PURE__ */ jsx(
2301
+ isDocked ? /* @__PURE__ */ jsx(AnimatePresence, { children: open ? /* @__PURE__ */ jsx(
2302
+ motion.div,
2303
+ {
2304
+ initial: { opacity: 0, x: 28 },
2305
+ animate: { opacity: 1, x: 0 },
2306
+ exit: { opacity: 0, x: 28 },
2307
+ transition: { type: "spring", stiffness: 260, damping: 30 },
2308
+ className: "flex h-full w-full flex-col overflow-hidden bg-background",
2309
+ children: /* @__PURE__ */ jsx(
2310
+ AgentPanel,
2311
+ {
2312
+ agentMode: false,
2313
+ canToggleAgentMode: false,
2314
+ chat,
2315
+ className: "flex-1",
2316
+ config,
2317
+ newMessageAnchorId: anchorId,
2318
+ onAlwaysApprove: alwaysApprove.setAlwaysApprove,
2319
+ onClose: closePanel,
2320
+ onToggleAgentMode: () => {
2321
+ }
2322
+ }
2323
+ )
2324
+ },
2325
+ "agent-docked"
2326
+ ) : null }) : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(AnimatePresence, { children: open ? /* @__PURE__ */ jsx(
2293
2327
  motion.div,
2294
2328
  {
2295
2329
  layout: true,
@@ -2329,7 +2363,7 @@ function AgentWidget({ config, onOpenChange, open: controlledOpen }) {
2329
2363
  )
2330
2364
  },
2331
2365
  "agent-panel"
2332
- ) : null })
2366
+ ) : null }) })
2333
2367
  ] });
2334
2368
  }
2335
2369
  function StatusChip({