@blade-hq/agent-react 2612.0.0-beta.90 → 2612.0.0-beta.91

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 (43) hide show
  1. package/README.md +2 -5
  2. package/dist/SessionPluginConfigForm-Y657MKRX.js +9 -0
  3. package/dist/{chunk-5FK33U4M.js → chunk-5ESAKOUV.js} +2 -2
  4. package/dist/{chunk-NS55ESUC.js → chunk-74FML2TR.js} +4 -4
  5. package/dist/{chunk-2GP2S3IR.js → chunk-DL7XZGQS.js} +8205 -8397
  6. package/dist/chunk-DL7XZGQS.js.map +1 -0
  7. package/dist/{chunk-3XWKS2YP.js → chunk-L75DNQ3N.js} +5 -6
  8. package/dist/{chunk-PRDGUQTE.js → chunk-Q2JZ5FBP.js} +3 -3
  9. package/dist/{chunk-T42PKMOI.js → chunk-R2WN24PN.js} +31 -15
  10. package/dist/chunk-R2WN24PN.js.map +1 -0
  11. package/dist/{chunk-JBVJMUJA.js → chunk-R6TH36MS.js} +7 -7
  12. package/dist/{chunk-WMWYGB2C.js → chunk-SEJUZPT5.js} +1 -15
  13. package/dist/chunk-SEJUZPT5.js.map +1 -0
  14. package/dist/{chunk-A5WYUMNB.js → chunk-UKJ2UI4S.js} +4 -4
  15. package/dist/{chunk-NRAHM3CD.js → chunk-ZRMO4P2Y.js} +1160 -1591
  16. package/dist/chunk-ZRMO4P2Y.js.map +1 -0
  17. package/dist/components/DeviceConnection.d.ts +5 -1
  18. package/dist/connectors.js +3 -3
  19. package/dist/embed/entry.d.ts +0 -2
  20. package/dist/index.d.ts +0 -2
  21. package/dist/index.js +9 -15
  22. package/dist/internal.js +10 -16
  23. package/dist/internal.js.map +1 -1
  24. package/dist/questions.js +4 -4
  25. package/dist/rich-input.js +7 -7
  26. package/dist/style.full.css +1 -1
  27. package/dist/tool-details.js +5 -5
  28. package/package.json +2 -2
  29. package/public-api.md +2 -36
  30. package/dist/SessionPluginConfigForm-FROO3XEW.js +0 -9
  31. package/dist/chunk-2GP2S3IR.js.map +0 -1
  32. package/dist/chunk-NRAHM3CD.js.map +0 -1
  33. package/dist/chunk-T42PKMOI.js.map +0 -1
  34. package/dist/chunk-WMWYGB2C.js.map +0 -1
  35. package/dist/components/ActionApprovals.d.ts +0 -16
  36. package/dist/components/action-approval-format.d.ts +0 -35
  37. /package/dist/{SessionPluginConfigForm-FROO3XEW.js.map → SessionPluginConfigForm-Y657MKRX.js.map} +0 -0
  38. /package/dist/{chunk-5FK33U4M.js.map → chunk-5ESAKOUV.js.map} +0 -0
  39. /package/dist/{chunk-NS55ESUC.js.map → chunk-74FML2TR.js.map} +0 -0
  40. /package/dist/{chunk-3XWKS2YP.js.map → chunk-L75DNQ3N.js.map} +0 -0
  41. /package/dist/{chunk-PRDGUQTE.js.map → chunk-Q2JZ5FBP.js.map} +0 -0
  42. /package/dist/{chunk-JBVJMUJA.js.map → chunk-R6TH36MS.js.map} +0 -0
  43. /package/dist/{chunk-A5WYUMNB.js.map → chunk-UKJ2UI4S.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MarkdownContent
3
- } from "./chunk-NS55ESUC.js";
3
+ } from "./chunk-74FML2TR.js";
4
4
  import {
5
5
  cn,
6
6
  extractToolFilePath,
@@ -9,10 +9,10 @@ import {
9
9
  useBladeClient,
10
10
  useHighlightedCode,
11
11
  useOptionalBladeClient
12
- } from "./chunk-PRDGUQTE.js";
12
+ } from "./chunk-Q2JZ5FBP.js";
13
13
  import {
14
14
  dist_exports2 as dist_exports
15
- } from "./chunk-2GP2S3IR.js";
15
+ } from "./chunk-DL7XZGQS.js";
16
16
  import {
17
17
  ChevronLeft,
18
18
  ChevronRight,
@@ -29,7 +29,7 @@ import {
29
29
  Plus,
30
30
  RotateCcw,
31
31
  X
32
- } from "./chunk-WMWYGB2C.js";
32
+ } from "./chunk-SEJUZPT5.js";
33
33
  import {
34
34
  __export
35
35
  } from "./chunk-PR4QN5HX.js";
@@ -27401,7 +27401,6 @@ function getRenderer(toolName) {
27401
27401
  }
27402
27402
 
27403
27403
  export {
27404
- randomId,
27405
27404
  McpAppFrame,
27406
27405
  McpAppMessageContext,
27407
27406
  McpAppCard,
@@ -27441,4 +27440,4 @@ export {
27441
27440
  * MIT Licensed
27442
27441
  *)
27443
27442
  */
27444
- //# sourceMappingURL=chunk-3XWKS2YP.js.map
27443
+ //# sourceMappingURL=chunk-L75DNQ3N.js.map
@@ -5,7 +5,7 @@ import {
5
5
  DialogContent,
6
6
  DialogTitle,
7
7
  clsx
8
- } from "./chunk-2GP2S3IR.js";
8
+ } from "./chunk-DL7XZGQS.js";
9
9
  import {
10
10
  Check,
11
11
  ChevronDown,
@@ -13,7 +13,7 @@ import {
13
13
  CircleDot,
14
14
  ListChecks,
15
15
  LoaderCircle
16
- } from "./chunk-WMWYGB2C.js";
16
+ } from "./chunk-SEJUZPT5.js";
17
17
 
18
18
  // src/context.tsx
19
19
  import { createContext, useContext } from "react";
@@ -4154,4 +4154,4 @@ export {
4154
4154
  AccountConnectorRules,
4155
4155
  BrowserConnectionDialog
4156
4156
  };
4157
- //# sourceMappingURL=chunk-PRDGUQTE.js.map
4157
+ //# sourceMappingURL=chunk-Q2JZ5FBP.js.map
@@ -19,10 +19,10 @@ import {
19
19
  dist_exports3 as dist_exports2,
20
20
  dist_exports5 as dist_exports3,
21
21
  dist_exports6 as dist_exports4
22
- } from "./chunk-2GP2S3IR.js";
22
+ } from "./chunk-DL7XZGQS.js";
23
23
  import {
24
24
  LoaderCircle
25
- } from "./chunk-WMWYGB2C.js";
25
+ } from "./chunk-SEJUZPT5.js";
26
26
 
27
27
  // src/components/DeviceConnection.tsx
28
28
  import { useEffect, useRef, useState } from "react";
@@ -1433,7 +1433,7 @@ function permissionNoticeKey(name, connection, permissions) {
1433
1433
  for (let index = 0; index < scopes.length; index++) hash = Math.imul(hash ^ scopes.charCodeAt(index), 16777619);
1434
1434
  return `blade-connector-notice:${name}:${JSON.stringify([connection.connection_id ?? "", connection.app_id ?? ""])}:${(hash >>> 0).toString(16)}`;
1435
1435
  }
1436
- function DeviceConnection({ read, act, diagnostics, onChanged, bindDelivery = false, onDisable, initialPage = "connection", authorizationCapabilities, autoAuthorize = false, detail }) {
1436
+ function DeviceConnection({ read, act, diagnostics, onChanged, bindDelivery = false, onDisable, initialPage = "connection", authorizationCapabilities, autoAuthorize = false, detail, authorizationDescription, onAuthorizationDismiss }) {
1437
1437
  const [view, setView] = useState(null);
1438
1438
  const [selected, setSelected] = useState([]);
1439
1439
  const [page, setPage] = useState(initialPage);
@@ -1450,6 +1450,19 @@ function DeviceConnection({ read, act, diagnostics, onChanged, bindDelivery = fa
1450
1450
  const flow = useRef(null);
1451
1451
  const linking = useRef(false);
1452
1452
  const newConnection = useRef(false);
1453
+ async function readConnection() {
1454
+ let timer;
1455
+ try {
1456
+ return await Promise.race([
1457
+ callbacks.current.read(),
1458
+ new Promise((_, reject) => {
1459
+ timer = setTimeout(() => reject(new Error("Connection read timed out")), 15e3);
1460
+ })
1461
+ ]);
1462
+ } finally {
1463
+ clearTimeout(timer);
1464
+ }
1465
+ }
1453
1466
  function accept(value) {
1454
1467
  if (value.permissions && !value.permissions.some((item) => item.app_status === "missing")) {
1455
1468
  try {
@@ -1467,12 +1480,15 @@ function DeviceConnection({ read, act, diagnostics, onChanged, bindDelivery = fa
1467
1480
  if (flow.current && (newConnection.current || flow.current.bootstrap) && value.selected_capabilities !== void 0) {
1468
1481
  flow.current.capabilities = value.selected_capabilities;
1469
1482
  }
1483
+ if (flow.current && value.authorization_url && matchesRequestedAuthorization(value)) {
1484
+ flow.current.capabilities = [.../* @__PURE__ */ new Set([...flow.current.capabilities, ...value.authorization_result?.capabilities ?? []])];
1485
+ }
1470
1486
  if (!initialized.current) {
1471
1487
  initialized.current = true;
1472
1488
  setSelected(value.app_id ? value.selected_capabilities ?? [] : defaultCapabilities(value.capabilities ?? []));
1473
1489
  if (!activationKnown) newConnection.current = !value.app_id;
1474
1490
  linking.current = value.phase === "app";
1475
- if (["app", "user", "permissions"].includes(value.phase) && value.authorization_url || value.current_step?.state === "verifying" && value.current_step.action === "poll") flow.current = { enable: newConnection.current || value.enabled !== false, capabilities: value.selected_capabilities ?? [], focus: value.selected_capabilities ?? [], bootstrap: !value.app_id || newConnection.current };
1491
+ if (["app", "user", "permissions"].includes(value.phase) && value.authorization_url || value.current_step?.state === "verifying" && value.current_step.action === "poll") flow.current = { enable: newConnection.current || value.enabled !== false, capabilities: [.../* @__PURE__ */ new Set([...value.selected_capabilities ?? [], ...value.authorization_result?.capabilities ?? []])], focus: value.authorization_result?.capabilities ?? value.selected_capabilities ?? [], bootstrap: !value.app_id || newConnection.current };
1476
1492
  if (!flow.current && matchesRequestedAuthorization(value) && value.app_id && value.authorization_result && value.authorization_result.status !== "complete" && value.authorization_result.capabilities.length) {
1477
1493
  const focus = value.authorization_result.capabilities;
1478
1494
  flow.current = { enable: newConnection.current || value.enabled !== false, capabilities: [.../* @__PURE__ */ new Set([...value.selected_capabilities ?? [], ...focus])], focus };
@@ -1482,7 +1498,7 @@ function DeviceConnection({ read, act, diagnostics, onChanged, bindDelivery = fa
1482
1498
  }
1483
1499
  useEffect(() => {
1484
1500
  live.current = true;
1485
- void callbacks.current.read().then((value) => {
1501
+ void readConnection().then((value) => {
1486
1502
  if (live.current) accept(value);
1487
1503
  }).catch(() => {
1488
1504
  if (live.current) setError("\u8BFB\u53D6\u8FDE\u63A5\u72B6\u6001\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002");
@@ -1491,10 +1507,11 @@ function DeviceConnection({ read, act, diagnostics, onChanged, bindDelivery = fa
1491
1507
  live.current = false;
1492
1508
  };
1493
1509
  }, []);
1494
- const matchesRequestedAuthorization = (value) => !authorizationCapabilities?.length || !!value.authorization_result && [...value.authorization_result.capabilities].sort().join(" ") === [...authorizationCapabilities].sort().join(" ");
1510
+ const matchesRequestedAuthorization = (value) => !authorizationCapabilities?.length || !!value.authorization_result && authorizationCapabilities.every((id) => value.authorization_result.capabilities.includes(id));
1495
1511
  const canCompleteInitial = (value) => value.activation_pending === true && !authorizationCapabilities?.length && !!value.app_id && !value.error && (value.capabilities ?? []).some((item) => (value.selected_capabilities ?? []).includes(item.id) && item.status === "available");
1496
1512
  const canReceive = (value) => (value.capabilities ?? []).some((item) => (value.selected_capabilities ?? selected).includes(item.id) && item.id.startsWith("bot_receive_") && (item.status === "available" || item.status === "unknown" && item.evidence === "platform_scope_query"));
1497
- const isWaiting = (value) => matchesRequestedAuthorization(value) && (["app", "user", "permissions"].includes(value.phase) && Boolean(value.authorization_url) || value.current_step?.state === "verifying" && value.current_step.action === "poll");
1513
+ const isExpired = (value) => !!value.expires_at && value.expires_at <= Date.now() / 1e3;
1514
+ const isWaiting = (value) => !isExpired(value) && matchesRequestedAuthorization(value) && (["app", "user", "permissions"].includes(value.phase) && Boolean(value.authorization_url) || value.current_step?.state === "verifying" && value.current_step.action === "poll");
1498
1515
  async function changed() {
1499
1516
  try {
1500
1517
  await callbacks.current.onChanged();
@@ -1562,7 +1579,7 @@ function DeviceConnection({ read, act, diagnostics, onChanged, bindDelivery = fa
1562
1579
  } catch {
1563
1580
  if (live.current) setError("\u672C\u6B21\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u5DF2\u6709\u6388\u6743\u7EE7\u7EED\u4FDD\u7559\u3002\u8BF7\u91CD\u8BD5\u5F53\u524D\u9879\u76EE\uFF0C\u6216\u67E5\u770B\u8FDE\u63A5\u5E2E\u52A9\u3002");
1564
1581
  try {
1565
- const current = await callbacks.current.read();
1582
+ const current = await readConnection();
1566
1583
  if (live.current) accept(current);
1567
1584
  } catch {
1568
1585
  }
@@ -1597,7 +1614,7 @@ function DeviceConnection({ read, act, diagnostics, onChanged, bindDelivery = fa
1597
1614
  useEffect(() => {
1598
1615
  if (!authorizationCapabilities?.length && !autoAuthorize || !view || automaticStarted.current) return;
1599
1616
  automaticStarted.current = true;
1600
- if (!isWaiting(view) && !(matchesRequestedAuthorization(view) && view.authorization_result?.mode === "manual")) start(authorizationCapabilities);
1617
+ if (!isWaiting(view) && !(!isExpired(view) && matchesRequestedAuthorization(view) && view.authorization_result?.mode === "manual" && (!authorizationCapabilities?.length || view.authorization_result.capabilities.length === authorizationCapabilities.length))) start(authorizationCapabilities);
1601
1618
  }, [view, authorizationCapabilities, autoAuthorize]);
1602
1619
  const initialCompletionStarted = useRef(false);
1603
1620
  useEffect(() => {
@@ -1617,7 +1634,7 @@ function DeviceConnection({ read, act, diagnostics, onChanged, bindDelivery = fa
1617
1634
  setBusy(true);
1618
1635
  setError("");
1619
1636
  try {
1620
- const value = await callbacks.current.read();
1637
+ const value = await readConnection();
1621
1638
  if (live.current) {
1622
1639
  if (view?.catalog_unavailable && !value.app_id) initialized.current = false;
1623
1640
  accept(value);
@@ -1706,7 +1723,7 @@ function DeviceConnection({ read, act, diagnostics, onChanged, bindDelivery = fa
1706
1723
  const back = /* @__PURE__ */ jsx6("button", { type: "button", className: "text-xs underline opacity-70", disabled: busy, onClick: () => setPage(view?.app_id ? "connection" : "select"), children: "\u8FD4\u56DE\u98DE\u4E66" });
1707
1724
  const authorizationContent = /* @__PURE__ */ jsx6(Fragment, { children: (autoAuthorize || authorizationCapabilities?.length) && busy && !waiting && !error && !view?.error ? /* @__PURE__ */ jsx6("output", { className: "block text-sm", children: "\u6B63\u5728\u5904\u7406\u98DE\u4E66\u6388\u6743\u2026" }) : waiting ? /* @__PURE__ */ jsxs5("div", { className: "space-y-4 rounded-xl border border-[color-mix(in_srgb,currentColor_18%,transparent)] p-5 text-center", children: [
1708
1725
  /* @__PURE__ */ jsx6("h4", { className: "font-medium", children: view?.phase === "app" ? "\u5728\u98DE\u4E66\u9009\u62E9\u6216\u521B\u5EFA\u5E94\u7528" : view?.phase === "permissions" ? "\u5728\u98DE\u4E66\u786E\u8BA4\u5E76\u5F00\u901A\u6743\u9650" : "\u8BF7\u5728\u98DE\u4E66\u786E\u8BA4\u672C\u6B21\u6388\u6743" }),
1709
- /* @__PURE__ */ jsx6("p", { className: "text-xs opacity-70", children: view?.current_step?.message || "\u5B8C\u6210\u5F53\u524D\u6B65\u9AA4\u540E\u81EA\u52A8\u7EE7\u7EED\uFF0C\u5DF2\u6709\u80FD\u529B\u59CB\u7EC8\u4FDD\u7559\u3002" }),
1726
+ /* @__PURE__ */ jsx6("p", { className: "text-xs opacity-70", children: authorizationDescription || view?.current_step?.message || "\u5B8C\u6210\u5F53\u524D\u6B65\u9AA4\u540E\u81EA\u52A8\u7EE7\u7EED\uFF0C\u5DF2\u6709\u80FD\u529B\u59CB\u7EC8\u4FDD\u7559\u3002" }),
1710
1727
  url ? /* @__PURE__ */ jsxs5(Fragment, { children: [
1711
1728
  new TextEncoder().encode(url).length <= 2200 ? /* @__PURE__ */ jsx6(QRCodeSVG, { value: url, size: 180, marginSize: 4, title: "\u98DE\u4E66\u6388\u6743\u4E8C\u7EF4\u7801", className: "mx-auto rounded-lg bg-white" }) : /* @__PURE__ */ jsx6("p", { className: "text-xs opacity-70", children: "\u6388\u6743\u9879\u76EE\u8F83\u591A\uFF0C\u8BF7\u6253\u5F00\u98DE\u4E66\u6388\u6743\u9875\u9762\u7EE7\u7EED\u3002" }),
1712
1729
  /* @__PURE__ */ jsx6("a", { href: url, target: "_blank", rel: "noopener noreferrer", className: "block text-sm underline", children: "\u6253\u5F00\u98DE\u4E66\u6388\u6743\u9875\u9762" })
@@ -1717,7 +1734,7 @@ function DeviceConnection({ read, act, diagnostics, onChanged, bindDelivery = fa
1717
1734
  ] }),
1718
1735
  /* @__PURE__ */ jsxs5("div", { className: "flex flex-wrap justify-center gap-3", children: [
1719
1736
  /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: () => void run("poll", view?.attempt_id ? { attempt_id: view.attempt_id } : {}), children: busy ? "\u6B63\u5728\u786E\u8BA4\u2026" : "\u6211\u5DF2\u5B8C\u6210\u6388\u6743" }),
1720
- /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: () => void run("cancel", view?.attempt_id ? { attempt_id: view.attempt_id } : {}), children: "\u6682\u65F6\u53D6\u6D88" }),
1737
+ /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: () => onAuthorizationDismiss ? onAuthorizationDismiss() : void run("cancel", view?.attempt_id ? { attempt_id: view.attempt_id } : {}), children: "\u6682\u65F6\u53D6\u6D88" }),
1721
1738
  !url && !verifying && /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: retryCurrent, children: "\u91CD\u8BD5\u672C\u6B21\u6388\u6743" })
1722
1739
  ] }),
1723
1740
  view?.phase === "permissions" && /* @__PURE__ */ jsx6("button", { type: "button", className: "text-xs underline", disabled: busy, onClick: finishExisting, children: "\u5148\u4F7F\u7528\u5DF2\u5F00\u901A\u80FD\u529B\uFF0C\u5176\u4ED6\u7A0D\u540E\u5904\u7406" })
@@ -1898,7 +1915,7 @@ function DeviceConnection({ read, act, diagnostics, onChanged, bindDelivery = fa
1898
1915
  /* @__PURE__ */ jsx6("p", { children: view.error.message }),
1899
1916
  view.error.next_action && /* @__PURE__ */ jsx6("p", { children: view.error.next_action }),
1900
1917
  !waiting && view.app_id && /* @__PURE__ */ jsxs5("div", { className: "flex flex-wrap gap-3", children: [
1901
- /* @__PURE__ */ jsx6("button", { type: "button", className: "text-xs underline", disabled: busy, onClick: retryCurrent, children: "\u91CD\u8BD5\u5F53\u524D\u6388\u6743" }),
1918
+ /* @__PURE__ */ jsx6("button", { type: "button", className: "text-xs underline", disabled: busy, onClick: () => view.error?.code === "AUTHORIZATION_IN_PROGRESS" ? start(authorizationCapabilities) : retryCurrent(), children: view.error.code === "AUTHORIZATION_IN_PROGRESS" ? "\u91CD\u65B0\u5F00\u59CB\u672C\u6B21\u6388\u6743" : "\u91CD\u8BD5\u5F53\u524D\u6388\u6743" }),
1902
1919
  /* @__PURE__ */ jsx6("button", { type: "button", className: "text-xs underline", disabled: busy, onClick: finishExisting, children: "\u5148\u4F7F\u7528\u5DF2\u5F00\u901A\u80FD\u529B\uFF0C\u5176\u4ED6\u7A0D\u540E\u5904\u7406" })
1903
1920
  ] })
1904
1921
  ] }),
@@ -2396,7 +2413,6 @@ function ConnectorConnection({ type, ...props }) {
2396
2413
  }
2397
2414
 
2398
2415
  export {
2399
- Badge,
2400
2416
  DeviceConnection,
2401
2417
  ConnectorConnection
2402
2418
  };
@@ -2414,4 +2430,4 @@ qrcode.react/lib/esm/index.js:
2414
2430
  * SPDX-License-Identifier: ISC
2415
2431
  *)
2416
2432
  */
2417
- //# sourceMappingURL=chunk-T42PKMOI.js.map
2433
+ //# sourceMappingURL=chunk-R2WN24PN.js.map