@particle-academy/agent-integrations 0.16.0 → 0.18.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.
@@ -1,4 +1,4 @@
1
- import { ShareControls, AgentCursor, AgentActivityHighlight, AgentPanel } from './chunk-GJSKBUOH.js';
1
+ import { ShareControls, AgentCursor, AgentActivityHighlight, AgentPanel } from './chunk-YEEOTIGY.js';
2
2
  import { createSessionDescriptor, attachSseRelay } from './chunk-CPNOF4HI.js';
3
3
  import { attachInProcess } from './chunk-AFUULW5E.js';
4
4
  import { registerWhiteboardBridge } from './chunk-3QJSOS7G.js';
package/dist/index.cjs CHANGED
@@ -8,8 +8,13 @@ var reactDom = require('react-dom');
8
8
 
9
9
  var __defProp = Object.defineProperty;
10
10
  var __getOwnPropNames = Object.getOwnPropertyNames;
11
- var __esm = (fn, res) => function __init() {
12
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
11
+ var __esm = (fn, res, err) => function __init() {
12
+ if (err) throw err[0];
13
+ try {
14
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
15
+ } catch (e) {
16
+ throw err = [e], e;
17
+ }
13
18
  };
14
19
  var __export = (target, all) => {
15
20
  for (var name in all)
@@ -2940,16 +2945,21 @@ function ShareControls({
2940
2945
  className,
2941
2946
  style
2942
2947
  }) {
2943
- const [tab, setTab] = react.useState("url");
2948
+ const [tab, setTab] = react.useState("prompt");
2944
2949
  if (!session) {
2945
2950
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ["fai-share fai-share--idle", className ?? ""].filter(Boolean).join(" "), style, children: [
2946
2951
  /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "fai-share__start", onClick: onStart, children: "Start shared session" }),
2947
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "fai-share__hint", children: "Generates a session id + secret token. Share the URL with humans, or hand the JSON config to an MCP-capable agent." })
2952
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "fai-share__hint", children: [
2953
+ "Generates a session id + secret token. Hand the ",
2954
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "Agent prompt" }),
2955
+ " to an AI agent, share the URL with humans, or give the JSON config to an MCP-capable client."
2956
+ ] })
2948
2957
  ] });
2949
2958
  }
2950
2959
  const url = buildShareUrl(session, shareBaseUrl);
2951
2960
  const config = buildShareConfig(session);
2952
2961
  const curl = buildCurlRecipe(session);
2962
+ const prompt = buildAgentPrompt(url);
2953
2963
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ["fai-share fai-share--active", className ?? ""].filter(Boolean).join(" "), style, children: [
2954
2964
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fai-share__header", children: [
2955
2965
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
@@ -2970,11 +2980,20 @@ function ShareControls({
2970
2980
  ] })
2971
2981
  ] }),
2972
2982
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fai-share__tabs", role: "tablist", children: [
2983
+ /* @__PURE__ */ jsxRuntime.jsx(TabButton, { tab: "prompt", active: tab, setTab, children: "Agent prompt" }),
2973
2984
  /* @__PURE__ */ jsxRuntime.jsx(TabButton, { tab: "url", active: tab, setTab, children: "URL" }),
2974
2985
  /* @__PURE__ */ jsxRuntime.jsx(TabButton, { tab: "json", active: tab, setTab, children: "JSON" }),
2975
2986
  /* @__PURE__ */ jsxRuntime.jsx(TabButton, { tab: "curl", active: tab, setTab, children: "cURL recipe" })
2976
2987
  ] }),
2977
2988
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fai-share__panel", children: [
2989
+ tab === "prompt" && /* @__PURE__ */ jsxRuntime.jsx(
2990
+ CopyBox,
2991
+ {
2992
+ label: "Paste this straight into an AI agent \u2014 it connects over MCP, no browser",
2993
+ value: prompt,
2994
+ multiline: true
2995
+ }
2996
+ ),
2978
2997
  tab === "url" && /* @__PURE__ */ jsxRuntime.jsx(CopyBox, { label: "Open this URL in another tab to join the session", value: url }),
2979
2998
  tab === "json" && /* @__PURE__ */ jsxRuntime.jsx(
2980
2999
  CopyBox,
@@ -3025,6 +3044,33 @@ function CopyBox({ label, value, multiline }) {
3025
3044
  ] })
3026
3045
  ] });
3027
3046
  }
3047
+ function buildAgentPrompt(url) {
3048
+ return [
3049
+ `You're joining a live Human+ co-browsing session on a web app. This is an MCP`,
3050
+ `(Model Context Protocol) session \u2014 NOT a website to visit. Do NOT open the URL`,
3051
+ `in a browser and do NOT use any browser/Playwright tool. You drive the real,`,
3052
+ `running app through MCP tools while a human watches and can take over.`,
3053
+ ``,
3054
+ `Session link (carries the session id + token \u2014 treat it as a secret):`,
3055
+ ` ${url}`,
3056
+ ``,
3057
+ `Connect by running the relay client as an MCP server (zero install):`,
3058
+ ` npx -y mcp-relay-client "${url}"`,
3059
+ ``,
3060
+ `That exposes the app's own tools (e.g. page_describe, page_read, nav_visit,`,
3061
+ `page_click, page_set_field, page_submit, plus surface tools like whiteboard_*).`,
3062
+ `Then:`,
3063
+ ` 1. Call page_describe first to see the current page and its interactive handles.`,
3064
+ ` 2. Act only on the STABLE HANDLES the tools return \u2014 never guess DOM selectors.`,
3065
+ ` 3. Navigate with nav_visit, type with page_set_field, click with page_click.`,
3066
+ ` Submits and destructive clicks are staged for the human to confirm.`,
3067
+ ``,
3068
+ `If you can't register an MCP server but can run a shell, drive it directly:`,
3069
+ ` curl -O https://raw.githubusercontent.com/Particle-Academy/mcp-relay-client/main/connect.sh`,
3070
+ ` bash connect.sh "${url}" tools`,
3071
+ ` bash connect.sh "${url}" call page_describe '{}'`
3072
+ ].join("\n");
3073
+ }
3028
3074
  function buildCurlRecipe(session) {
3029
3075
  const base = typeof window !== "undefined" ? `${window.location.protocol}//${window.location.host}` : "http://localhost";
3030
3076
  const inbox = `${base}/agent-relay/${session.id}/inbox?token=${session.token}`;
@@ -3438,6 +3484,76 @@ function CoBrowseCursorLayer({ active = true, zIndex = 2147483e3 }) {
3438
3484
  );
3439
3485
  }
3440
3486
  CoBrowseCursorLayer.displayName = "CoBrowseCursorLayer";
3487
+ function resolveCsrf(explicit) {
3488
+ if (explicit) return explicit;
3489
+ if (typeof document === "undefined") return void 0;
3490
+ return document.querySelector('meta[name="csrf-token"]')?.content;
3491
+ }
3492
+ function SimulateUsersButton({
3493
+ endpoint = "/active-users/simulate",
3494
+ count = 10,
3495
+ label,
3496
+ csrfToken,
3497
+ onTriggered,
3498
+ onError,
3499
+ className,
3500
+ style
3501
+ }) {
3502
+ const [busy, setBusy] = react.useState(false);
3503
+ async function trigger() {
3504
+ if (busy) return;
3505
+ setBusy(true);
3506
+ try {
3507
+ const token = resolveCsrf(csrfToken);
3508
+ const res = await fetch(endpoint, {
3509
+ method: "POST",
3510
+ headers: {
3511
+ "Content-Type": "application/json",
3512
+ "X-Requested-With": "XMLHttpRequest",
3513
+ ...token ? { "X-CSRF-TOKEN": token } : {}
3514
+ },
3515
+ credentials: "same-origin",
3516
+ body: JSON.stringify({ count })
3517
+ });
3518
+ if (!res.ok) throw new Error(`Simulate request failed: ${res.status}`);
3519
+ onTriggered?.();
3520
+ } catch (err) {
3521
+ onError?.(err);
3522
+ } finally {
3523
+ setBusy(false);
3524
+ }
3525
+ }
3526
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3527
+ "button",
3528
+ {
3529
+ type: "button",
3530
+ "data-fai-simulate-users": "",
3531
+ className: ["fai-simulate-users", className ?? ""].filter(Boolean).join(" "),
3532
+ onClick: trigger,
3533
+ disabled: busy,
3534
+ style: {
3535
+ display: "inline-flex",
3536
+ alignItems: "center",
3537
+ gap: 8,
3538
+ padding: "8px 14px",
3539
+ borderRadius: 8,
3540
+ border: "1px solid rgba(139,92,246,0.4)",
3541
+ background: busy ? "rgba(139,92,246,0.15)" : "rgba(139,92,246,0.1)",
3542
+ color: "#7c3aed",
3543
+ font: "inherit",
3544
+ fontSize: 13,
3545
+ fontWeight: 500,
3546
+ cursor: busy ? "progress" : "pointer",
3547
+ opacity: busy ? 0.7 : 1,
3548
+ ...style
3549
+ },
3550
+ children: [
3551
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, children: busy ? "\u23F3" : "\u2728" }),
3552
+ label ?? `Simulate ${count} active users`
3553
+ ]
3554
+ }
3555
+ );
3556
+ }
3441
3557
 
3442
3558
  // src/presence/index.ts
3443
3559
  init_registry();
@@ -3581,6 +3697,7 @@ exports.MicroMcpServer = MicroMcpServer;
3581
3697
  exports.RelayTransport = RelayTransport;
3582
3698
  exports.ScreensActivityBridge = ScreensActivityBridge;
3583
3699
  exports.ShareControls = ShareControls;
3700
+ exports.SimulateUsersButton = SimulateUsersButton;
3584
3701
  exports.SseRelayTransport = SseRelayTransport;
3585
3702
  exports.ToolRegistry = ToolRegistry;
3586
3703
  exports.VscodeMark = VscodeMark;
@@ -3588,6 +3705,7 @@ exports.WrenchMark = WrenchMark;
3588
3705
  exports.attachInProcess = attachInProcess;
3589
3706
  exports.attachRelay = attachRelay;
3590
3707
  exports.attachSseRelay = attachSseRelay;
3708
+ exports.buildAgentPrompt = buildAgentPrompt;
3591
3709
  exports.buildCursorDeeplink = buildCursorDeeplink;
3592
3710
  exports.buildManualConfig = buildManualConfig;
3593
3711
  exports.buildManualConfigSnippet = buildManualConfigSnippet;