@bolloon/bolloon-agent 0.3.51 → 0.3.52

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 (2) hide show
  1. package/dist/web/client.js +54 -0
  2. package/package.json +4 -1
@@ -1544,6 +1544,57 @@
1544
1544
  var newChannelBtn = document.getElementById("new-channel-btn");
1545
1545
  var newChannelInput = document.getElementById("new-channel-input");
1546
1546
  var channelNameEl = document.getElementById("channel-name");
1547
+ var rokidBridge = null;
1548
+ var rokidBridgeStatus = "unavailable";
1549
+ function getRokidBridge() {
1550
+ if (typeof window === "undefined") return null;
1551
+ return window.Capacitor?.Plugins?.RokidBridge || null;
1552
+ }
1553
+ function publishRokidStatus(status, detail = {}) {
1554
+ rokidBridgeStatus = status;
1555
+ if (typeof window !== "undefined") {
1556
+ window.__bolloonRokidStatus = { status, ...detail };
1557
+ window.dispatchEvent(new CustomEvent("bolloon:rokid-status", { detail: window.__bolloonRokidStatus }));
1558
+ }
1559
+ }
1560
+ async function initRokidBridge() {
1561
+ const bridge = getRokidBridge();
1562
+ if (!bridge) {
1563
+ publishRokidStatus("unavailable");
1564
+ return;
1565
+ }
1566
+ rokidBridge = bridge;
1567
+ try {
1568
+ await bridge.addListener?.("rokidEvent", (event) => {
1569
+ if (event?.type === "connected") publishRokidStatus("connected", { device: event.device });
1570
+ else if (event?.type === "disconnected") publishRokidStatus("disconnected", { reason: event.reason });
1571
+ else if (event?.type === "error") publishRokidStatus("error", { error: event.error || event.message });
1572
+ window.dispatchEvent(new CustomEvent("bolloon:rokid-event", { detail: event }));
1573
+ });
1574
+ const result = await bridge.connect?.();
1575
+ publishRokidStatus("connected", { deviceId: result?.deviceId, mode: result?.mode });
1576
+ } catch (error) {
1577
+ publishRokidStatus("error", { error: error?.message || String(error) });
1578
+ console.warn("[Rokid] bridge unavailable:", error);
1579
+ }
1580
+ }
1581
+ function sendRokidText(text, metadata = {}) {
1582
+ if (!rokidBridge || !text) return;
1583
+ Promise.resolve(rokidBridge.sendMessage?.({
1584
+ text,
1585
+ channelId: currentChannelId || void 0,
1586
+ metadata
1587
+ })).catch((error) => {
1588
+ publishRokidStatus("error", { error: error?.message || String(error) });
1589
+ });
1590
+ }
1591
+ if (typeof window !== "undefined") {
1592
+ window.BolloonRokid = {
1593
+ connect: initRokidBridge,
1594
+ sendMessage: sendRokidText,
1595
+ getStatus: () => ({ status: rokidBridgeStatus })
1596
+ };
1597
+ }
1547
1598
  var eventSources = /* @__PURE__ */ new Map();
1548
1599
  var currentChannelId = null;
1549
1600
  var activeChannelId = null;
@@ -2823,6 +2874,7 @@ ${data.error || "channel not found"}`, "error");
2823
2874
  MR_replaceStreamingText?.(data.content || "");
2824
2875
  MR_finalizeTimelineAsMessage(getRendererCtx());
2825
2876
  }
2877
+ sendRokidText(data.content || "", { source: "ai" });
2826
2878
  } else if (data.type === "reply-preview") {
2827
2879
  const previewContent = data.content || "";
2828
2880
  const oldPreviews = container.querySelectorAll(".message-ai.preview");
@@ -2896,6 +2948,7 @@ ${data.error || "channel not found"}`, "error");
2896
2948
  setSendMode("abort");
2897
2949
  const container = messagesContainers.get(currentChannelId) || messagesEl;
2898
2950
  addMessage2(text, "user", true, container);
2951
+ sendRokidText(text, { source: "user" });
2899
2952
  if (container) container.scrollTop = container.scrollHeight;
2900
2953
  if (currentPreviewBubble) {
2901
2954
  currentPreviewBubble.remove();
@@ -3983,6 +4036,7 @@ ${data.error || "channel not found"}`, "error");
3983
4036
  }
3984
4037
  }
3985
4038
  async function init() {
4039
+ void initRokidBridge();
3986
4040
  const themeData = await loadTheme();
3987
4041
  currentAgentId = themeData.agentId || `agent_${generateId().substring(0, 8)}`;
3988
4042
  if (!themeData.agentId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bolloon/bolloon-agent",
3
- "version": "0.3.51",
3
+ "version": "0.3.52",
4
4
  "type": "module",
5
5
  "description": "P2P AI Document Agent - 全局安装后执行 `bolloon` 启动产品",
6
6
  "main": "dist/cli-entry.js",
@@ -29,6 +29,8 @@
29
29
  "build:main": "tsc && node scripts/copy-constraint-runtime.mjs",
30
30
  "build:cli": "node scripts/build-cli.js",
31
31
  "build:web": "npx tsx scripts/build-web.ts",
32
+ "build:rokid-sdk": "npm --prefix ../rokid run build",
33
+ "test:rokid-sdk": "npm --prefix ../rokid test",
32
34
  "build:electron": "tsc -p tsconfig.electron.json",
33
35
  "build:all": "npm run build:main && npm run build:web && npm run build:electron && npm run build:cli",
34
36
  "start": "node dist/index.js",
@@ -55,6 +57,7 @@
55
57
  "dependencies": {
56
58
  "@bolloon/bolloon-agent": "^0.3.22",
57
59
  "@bolloon/constraint-runtime": "0.1.0",
60
+ "@capacitor/android": "^8.4.1",
58
61
  "@capacitor/core": "^8.4.1",
59
62
  "@capacitor/ios": "^8.4.2",
60
63
  "@chainsafe/libp2p-noise": "^17.0.0",