@ftai/ftai-plugin-ft-bot 0.1.0 → 0.4.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.
package/README.md CHANGED
@@ -1,20 +1,26 @@
1
1
  # Ft Bot for FtAi Desktop
2
2
 
3
- An installable FtAi Desktop plugin (`@ftai/ftai-plugin-ft-bot`) that connects the **cloud WeCom bot** to this computer. Its English/Chinese settings page downloads and verifies the native runner, pairs it, shows connection and desktop permission status, and lets the user disconnect, reconnect, or update.
3
+ An installable FtAi Desktop plugin (`@ftai/ftai-plugin-ft-bot`) that connects the **cloud WeCom bot** to this computer. Its English/Chinese settings page downloads and verifies the native runner and its bundled agent-browser CLI, connects with your FtAi account, shows connection and desktop permission status, and lets the user disconnect, reconnect, or update.
4
4
 
5
- Version 0.1.0 requires [FtAi plugin contract 2.1](https://ftai.chat/desktop/docs/plugins/) and Ft Bot runner protocol 4. The cloud bot keeps its `run_command`, file/browser tools and `desktop` tool, and gains `local_chat` to create, resume, read and cancel persistent chats in FtAi through `ctx.agents`. Commands retain cancellation, secret redaction and replay protection. The plugin does not register duplicate tools in FtAi's own chats.
5
+ Version 0.4.0 requires FtAi plugin contract 2.1 and Ft Bot runner protocol 7. The cloud bot can run commands, work with files and browsers, control the desktop, read and monitor local WeCom messages on a Mac, and manage persistent local FtAi chats through `ctx.agents`. Commands retain cancellation, secret redaction and replay protection. The plugin does not register duplicate tools in FtAi's own chats. [FtAi plugin contract](https://ftai.chat/desktop/docs/plugins/)
6
6
 
7
7
  ## Use
8
8
 
9
- 1. Use an FtAi Desktop build supporting contract 2.1 and install `@ftai/ftai-plugin-ft-bot@0.1.0` in its plugin settings. The package must be published to an npm registry first; see **Build and verify** below.
10
- 2. Open the plugin's settings. Ask the WeCom bot to connect this computer, paste its one-use pairing code, and choose **Pair and connect**. The plugin uses `https://ftai.chat/ft-bot/api` by default, downloads and verifies the runner, and connects.
11
- 3. Ask the bot to use this computer now, make it the default for future runs, or both. A current-run switch affects subsequent operations immediately; already-started operations keep their original computer. Pairing alone does not select it.
9
+ 1. Use an FtAi Desktop build supporting contract 2.1 and install `@ftai/ftai-plugin-ft-bot@0.4.0` in its plugin settings after the package is published to your registry.
10
+ 2. Sign in to FtAi with the bot's company and your linked WeCom account. In the plugin settings, choose **Connect with FtAi**. If FtAi prompts for permission to read `FTAI_USER_TOKEN`, allow it in credential permissions and retry. If the gateway cannot match your account, message the bot from WeCom and retry. The plugin uses `https://ftai.chat/ft-bot/api` by default, downloads and verifies the runner, and registers this computer.
11
+ 3. The bot uses the computer's hostname by default. You can ask it to rename the computer in a private chat. Ask the bot to use this computer now, make it the default for future runs, or both. A current-run switch applies to subsequent operations. Already-started operations finish on their original computer.
12
12
  4. On macOS, use **Request macOS permissions**, then allow the runner in Screen & System Audio Recording and Accessibility. Disconnect/reconnect after changing grants. On Windows, keep the interactive user logged in and the desktop unlocked.
13
13
 
14
- For a self-hosted deployment, change **Advanced → Server URL** to the URL returned by your bot. Leaving it blank uses the default; saved custom URLs are retained. Deploy the matching gateway and runner release together using the existing runner publication pipeline: all runners must use protocol 4, and the plugin requires stdio bridge version 2.
14
+ For a self-hosted deployment, set **Advanced → Server URL** to the gateway's public URL before connecting. **Connect with FtAi** sends the account credential to that gateway for enrollment. A blank URL uses the default. Custom URLs can include a path prefix. If the gateway cannot match your account after you have contacted the bot, ask its operator to check the configured FtAi company and WeCom identity lookup. See [gateway setup](../README.md#enable-the-gateway).
15
+
16
+ Deploy the matching gateway and runner release together using the existing runner publication pipeline: runners use protocol 7, and the plugin requires stdio bridge version 3. Update older runner binaries before using this plugin.
15
17
 
16
18
  Commands run on Windows (PowerShell), macOS and Linux (Bash). Desktop control supports Windows/macOS: display discovery, screenshots, clicks, double/right clicks, mouse movement, dragging, scrolling, Unicode text and key chords. Linux retains command/file/browser access without native desktop control. UAC/secure desktops and macOS permission restrictions still apply.
17
19
 
20
+ On macOS, ask the bot to work in a specific app while you use another. It can read the app's accessible controls, press a button, edit a text field and capture a single window. [Background app control](../README.md#desktop-control-on-windows-and-macos)
21
+
22
+ In a private WeCom bot chat, you can also ask to read or monitor a paired Mac’s local WeCom messages. Supported filters include direct messages, personal mentions and group-wide mentions. [Local WeCom setup and examples](../README.md#read-and-monitor-local-wecom-messages)
23
+
18
24
  ## Local chats
19
25
 
20
26
  After selecting this computer, ask the WeCom bot to create a local FtAi chat in a project directory, continue a saved chat by its session ID, or check its replies. The `local_chat` tool accepts an `action` with these fields:
@@ -35,19 +41,21 @@ Runner operation IDs prevent transport retries from duplicating prompts. After a
35
41
 
36
42
  ## Connection and storage
37
43
 
38
- - Pairing connects immediately and remembers the enabled state. The runner reconnects while the plugin and FtAi **host** are running, including when the host continues in the background after the window closes. **Disconnect** persists across host restarts.
44
+ - Account enrollment connects immediately and remembers the enabled state. The runner reconnects while the plugin and FtAi **host** are running, including when the host continues in the background after the window closes. **Disconnect** persists across host restarts.
39
45
  - Disabling/uninstalling the plugin or stopping/crashing its host closes the runner's stdin. The runner then cancels supervised work and exits. No login service or inbound listening port is installed. Completed actions cannot be undone.
40
46
  - The runner has the OS account's access to files, credentials, tools, apps and networking. Tool output, screenshots and requested local chat text reach the cloud bot; attachments use its existing storage. FtAi's local-chat permissions apply to local chat turns; they do not govern commands and desktop input performed directly by the cloud bot.
41
- - This plugin has its own pairing/state directory: `~/.local/share/ft-bot-desktop-plugin` on macOS/Linux, `%LOCALAPPDATA%\ft-bot-desktop-plugin` on Windows. Credentials and the replay journal are in its `runner` subdirectory, protected by the native runner's permissions/ACLs. `config.json` contains the gateway, executable path and enabled preference, never the pairing code or bearer token.
42
- - Each pairing code can be redeemed once. The gateway issues the bearer token and stores only its hash. If the response is lost or the token cannot be saved, request a new code and revoke any unused computer entry through the bot. A paired instance belongs to one gateway. To change gateways, disconnect, revoke the old computer through the bot, and remove this plugin's `runner/credentials.json` and `config.json` while the plugin is disabled. Work files are retained. Uninstalling does not delete local state.
43
- - **Download update** stops current work, verifies the gateway's current binary, checks its plugin interface and resumes if enabled. Failed downloads leave the previous executable intact. Old revision directories remain available; macOS may need permission grants for a new executable path.
44
- - Downloads stay on the configured gateway, require HTTPS (loopback HTTP is allowed for development), reject redirects, and verify the expected platform filename, size and checksum.
47
+ - The plugin stores its state in `~/.local/share/ft-bot-desktop-plugin` on macOS/Linux and `%LOCALAPPDATA%\ft-bot-desktop-plugin` on Windows. Device credentials and the replay journal are in its `runner` subdirectory, protected by the native runner's permissions/ACLs. `config.json` contains the gateway, executable path and enabled preference.
48
+ - **Connect with FtAi** resolves `ctx.credentials.resolve('FTAI_USER_TOKEN')` anew for each attempt, respecting FtAi's credential grants. The account token goes from the plugin host over private stdin to the native runner and then in a Bearer header to the selected gateway; it never reaches the settings page, command arguments or persisted plugin state. Redirects are rejected. The gateway verifies the ES256 signature, millisecond expiry, current session and configured company, then matches the verified WeCom identity to an enabled bot user. Only the newly issued device token is saved. Logging out of FtAi does not revoke an enrolled device: disconnect or revoke it through the bot.
49
+ - The gateway issues a device token once per enrollment and stores its hash. If the response is lost or saving fails, retry **Connect with FtAi** and revoke any unused computer entry through the bot.
50
+ - Each registration belongs to one gateway. To change gateways, disconnect, revoke the old computer through the bot, and remove this plugin's `runner/credentials.json` and `config.json` while the plugin is disabled. Work files are retained. Uninstalling preserves local state.
51
+ - **Download update** stops current work, verifies and extracts the gateway's current runner ZIP, checks its plugin interface and resumes if enabled. A failed download preserves the installed release. Each release installs under `bin/<runner-version>+<short-sha>/` in the plugin state directory. The suffix uses the first eight hex digits of the release commit. macOS may ask for permission again when the executable path changes.
52
+ - Downloads stay on the configured gateway, require HTTPS (loopback HTTP is allowed for development), reject redirects, and verify the expected platform ZIP filename, size and SHA-256 before installing its runner and tools.
45
53
 
46
54
  ## Build and verify
47
55
 
48
- Requires Node.js 22.12+ and pnpm. The lockfile fixes development dependencies; the installed plugin has **no third-party runtime dependencies or installation scripts**. FtAi supplies its SDK, Cordis and shared React runtime.
56
+ Requires Node.js 22.12+ and pnpm. The plugin uses `fflate` to extract runner ZIPs. The lockfile pins the dependencies. FtAi supplies its SDK, Cordis and shared React runtime.
49
57
 
50
- The supplied FtAi checkout exposes contract 2.1, but `@ftai/plugin-sdk@2.1.0` is not yet published to npm. Build tools therefore use the published 2.0 SDK with a small, type-only snapshot of the needed 2.1 agent interfaces in `src/chat-host.ts`. The runtime still requires 2.1; there is no fallback for older hosts. The snapshot and actual source runtime can be checked without modifying the FtAi checkout or calling a model:
58
+ The supplied FtAi checkout exposes contract 2.1, but `@ftai/plugin-sdk@2.1.0` is not yet published to npm. Build tools therefore use the published 2.0 SDK with small, type-only snapshots of the needed 2.1 agent and credential interfaces in `src/chat-host.ts` and `src/credential-host.ts`. The runtime still requires 2.1; there is no fallback for older hosts. The snapshots and actual agent runtime can be checked without modifying the FtAi checkout or calling a model:
51
59
 
52
60
  ```sh
53
61
  # After pnpm build, from desktop-plugin:
@@ -68,7 +76,7 @@ The archive contains `lib/index.js`, `lib/client.js`, `lib/remote.js`, shared de
68
76
  pnpm publish --access public
69
77
  ```
70
78
 
71
- Integration tests use the real native runner, an isolated loopback mock gateway and a recorded FtAi agent service. They require no MySQL, model credentials or GUI input and cover pairing, authentication, commands, desktop status, cancellation, host crash cleanup, connection preferences, local chat creation/resumption/reading, prompt replay protection and ownership cleanup:
79
+ Integration tests use the real native runner, an isolated loopback mock gateway and recorded FtAi agent/credential services. They require no MySQL, model credentials or GUI input and cover account enrollment on custom gateways, missing credential grants, fresh credential resolution, redirects, secret handling, authentication, commands, desktop status, cancellation, host crash cleanup, connection preferences, local chat creation/resumption/reading, prompt replay protection and ownership cleanup.
72
80
 
73
81
  ```sh
74
82
  # From the repository root:
@@ -87,6 +95,6 @@ Use the [official local-registry workflow](https://ftai.chat/desktop/docs/plugin
87
95
  For development, set these environment variables **before starting the FtAi host**:
88
96
 
89
97
  - `FT_BOT_PLUGIN_HOME`: an absolute, isolated plugin state directory; use a separate one for each test instance.
90
- - `FT_BOT_RUNNER_BINARY`: an absolute path to the freshly built runner; skips download while preserving pairing and all lifecycle behavior.
98
+ - `FT_BOT_RUNNER_BINARY` points to the freshly built runner by absolute path and skips the download. For browser actions, keep the matching release’s `ft-bot-tools` directory beside the executable.
91
99
 
92
- Verify a pair/connect/disconnect cycle, plugin disable/re-enable, host exit, and macOS permission grants in that instance. Create a chat, read its reply, resume its session ID with another prompt, and check local approval handling and cancellation. Real chat turns require a configured model; recorded host tests do not establish model or provider availability. Real screenshot/input validation needs an unlocked desktop and the OS permissions; automated tests do not click or type into your applications.
100
+ Verify **Connect with FtAi**, disconnect and reconnect, plugin disable/re-enable, host exit, and macOS permission grants in that instance. Create a chat, read its reply, resume its session ID with another prompt, and check local approval handling and cancellation. Real chat turns require a configured model; recorded host tests do not establish model or provider availability. Real screenshot/input validation needs an unlocked desktop and the OS permissions; automated tests do not click or type into your applications.
package/lib/client.js CHANGED
@@ -1,5 +1,5 @@
1
1
  window.__ModuleLoader__.load({ id: "@ftai/ftai-plugin-ft-bot", factory: (require) => { var module = { exports: {} }; var exports = module.exports;
2
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react"),t=require("@ftai/client-app"),n=require("react/jsx-runtime");var r={outline:{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},filled:{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`currentColor`,stroke:`none`}},i=((t,n,i,a)=>{let o=(0,e.forwardRef)(({color:i=`currentColor`,size:o=24,stroke:s=2,title:c,className:l,children:u,...d},f)=>(0,e.createElement)(`svg`,{ref:f,...r[t],width:o,height:o,className:[`tabler-icon`,`tabler-icon-${n}`,l].join(` `),strokeWidth:s,stroke:i,...d},[c&&(0,e.createElement)(`title`,{key:`svg-title`},c),...a.map(([t,n])=>(0,e.createElement)(t,n)),...Array.isArray(u)?u:[u]]));return o.displayName=`${i}`,o})(`outline`,`device-desktop`,`DeviceDesktop`,[[`path`,{d:`M3 5a1 1 0 0 1 1 -1h16a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-10`,key:`svg-0`}],[`path`,{d:`M7 20h10`,key:`svg-1`}],[`path`,{d:`M9 16v4`,key:`svg-2`}],[`path`,{d:`M15 16v4`,key:`svg-3`}]]);function a(r,i){return function(){let{t:a}=(0,t.useMessages)(r),[o,s]=(0,e.useState)(null),[c,l]=(0,e.useState)(null),[u,d]=(0,e.useState)(``),[f,p]=(0,e.useState)(!1),[m,h]=(0,e.useState)(null),g=(0,e.useRef)(!1),_=(0,e.useRef)(0),v=(0,e.useRef)(!1);(0,e.useEffect)(()=>{g.current=!0;let e=!1,t=async()=>{if(v.current||e)return;e=!0;let t=_.current;try{let e=await i.status();if(!g.current||t!==_.current)return;e.ok?s(e.value):h(e.error.message)}catch(e){g.current&&t===_.current&&h(String(e))}finally{e=!1}};t();let n=setInterval(()=>{t()},2e3);return()=>{g.current=!1,_.current++,clearInterval(n)}},[]);let y=async e=>{if(v.current)return;v.current=!0;let t=++_.current;p(!0),h(null);try{let n=await e();if(!g.current||t!==_.current)return;n.ok?s(n.value):h(n.error.message)}catch(e){g.current&&t===_.current&&h(String(e))}finally{v.current=!1,g.current&&t===_.current&&p(!1)}},b=f||!o||o.busy,x=!!o?.computer?.device_id,S=o?.enabled&&(o.connection===`error`||o.connection===`stopped`),C=m||o?.error;return(0,n.jsxs)(t.SettingsPage,{title:a(`title`),description:a(`description`),children:[(0,n.jsx)(`p`,{className:`ft-bot-note`,children:a(`access`)}),!o&&(0,n.jsx)(`p`,{role:`status`,children:a(`waiting`)}),C&&(0,n.jsxs)(`div`,{className:`ft-bot-error`,role:`alert`,children:[(0,n.jsx)(`p`,{children:a(`failed`)}),(0,n.jsx)(`pre`,{children:C})]}),!x&&(0,n.jsx)(t.SettingsGroup,{children:(0,n.jsx)(t.SettingsRow,{title:a(`pairing`),description:a(`instructions`),children:(0,n.jsxs)(`form`,{className:`ft-bot-form`,onSubmit:e=>{e.preventDefault();let t=u;d(``),y(()=>i.pair((c??o?.server??``).trim(),t))},children:[(0,n.jsxs)(`label`,{children:[a(`code`),(0,n.jsx)(t.Input,{type:`password`,value:u,autoComplete:`off`,onChange:e=>d(e.target.value),required:!0,disabled:b,maxLength:256})]}),(0,n.jsxs)(`details`,{className:`ft-bot-advanced`,children:[(0,n.jsx)(`summary`,{children:a(`advanced`)}),(0,n.jsxs)(`label`,{children:[a(`gateway`),(0,n.jsx)(t.Input,{type:`url`,value:c??o?.server??`https://ftai.chat/ft-bot/api`,placeholder:`https://ftai.chat/ft-bot/api`,onChange:e=>l(e.target.value),disabled:b})]}),(0,n.jsx)(`p`,{className:`ft-bot-note`,children:a(`gatewayHelp`)})]}),(0,n.jsx)(t.Button,{type:`submit`,disabled:b||!u.trim(),children:a(f?`pairingBusy`:`pair`)})]})})}),x&&(0,n.jsx)(t.SettingsGroup,{children:(0,n.jsxs)(t.SettingsRow,{title:a(`connection`),description:a(`lifetime`),action:(0,n.jsx)(t.Button,{variant:`outline`,size:`sm`,disabled:b,onClick:()=>{y(()=>i.setEnabled(S||!o?.enabled))},children:S?a(`retry`):o?.enabled?a(`disconnect`):a(`connect`)}),children:[(0,n.jsx)(`p`,{role:`status`,children:a(`state.${o.connection}`)}),(0,n.jsxs)(`p`,{className:`ft-bot-note`,children:[a(`computer`),`: `,(0,n.jsx)(`code`,{children:o.computer.device_id})]}),(0,n.jsx)(`p`,{className:`ft-bot-note`,children:a(`select`)})]})}),o?.installed&&(0,n.jsxs)(t.SettingsGroup,{children:[(0,n.jsx)(t.SettingsRow,{title:a(`chats`),description:a(`chatsHelp`)}),(0,n.jsxs)(t.SettingsRow,{title:a(`desktop`),description:a(`desktopHelp`),action:(0,n.jsx)(t.Button,{variant:`outline`,size:`sm`,disabled:b,onClick:()=>{y(()=>i.refresh())},children:a(`diagnostics`)}),children:[o.computer?.platform===`macos`&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`p`,{className:`ft-bot-note`,children:a(`permissionsHelp`)}),(0,n.jsx)(t.Button,{variant:`outline`,size:`sm`,disabled:b,onClick:()=>{y(()=>i.requestPermissions())},children:a(`permissions`)})]}),(0,n.jsxs)(`details`,{className:`ft-bot-diagnostics`,children:[(0,n.jsx)(`summary`,{children:a(`details`)}),(0,n.jsx)(`pre`,{children:JSON.stringify(o.computer?.desktop??{},null,2)})]})]}),(0,n.jsx)(t.SettingsRow,{title:a(`update`),description:a(`updateHelp`),action:(0,n.jsx)(t.Button,{variant:`outline`,size:`sm`,disabled:b||!o.server,onClick:()=>{y(()=>i.updateRunner())},children:a(f?`working`:`updateAction`)})})]})]})}}var o={title:`Ft Bot`,description:`Connect your WeCom bot to this computer.`,access:`The bot runs with your OS account’s file, credential, app and network access. Command output, screenshots and requested local chat text are sent to the cloud bot. Disconnect here or disable this plugin to stop access.`,pairing:`Pair this computer`,instructions:`Ask your bot to connect this computer, then paste its one-use pairing code here.`,advanced:`Advanced`,gateway:`Server URL`,gatewayHelp:`Change this only if your bot uses a different server. Leave blank to use the default.`,code:`One-use pairing code`,pair:`Pair and connect`,pairingBusy:`Downloading and pairing…`,connection:`Connection`,lifetime:`Reconnects while this plugin is enabled and the FtAi host is running, including in the background. Disconnect is remembered across restarts.`,connect:`Connect`,disconnect:`Disconnect`,retry:`Reconnect`,state:{stopped:`Disconnected`,connecting:`Connecting…`,connected:`Connected`,reconnecting:`Reconnecting — check the gateway and access in the bot`,error:`Connection failed`},computer:`Computer ID`,select:`Ask the bot to select this computer. New bot conversations then use it; existing jobs keep their current computer.`,chats:`Local FtAi chats`,chatsHelp:`Ask the bot to create a local chat, resume one by its session ID, or read its replies. Chats use FtAi’s default model and permissions; answer approvals and questions in FtAi. Disconnecting releases attached chats and stops their current turns. Their history stays saved.`,desktop:`Desktop access`,desktopHelp:`Windows and macOS support screenshots, clicks, dragging, scrolling, typing and keyboard shortcuts. Keep the account logged in and the desktop unlocked. Native desktop control is unavailable on Linux.`,permissions:`Request macOS permissions`,permissionsHelp:`Allow the runner in System Settings → Privacy & Security → Screen & System Audio Recording and Accessibility. After changing permissions, disconnect and reconnect.`,diagnostics:`Refresh diagnostics`,details:`Desktop diagnostics`,update:`Update runner`,updateHelp:`Downloads the gateway’s current runner and verifies its SHA-256. Updating temporarily stops active work. macOS may require granting desktop permissions again.`,updateAction:`Download update`,waiting:`Waiting for the plugin host…`,failed:`The operation failed. Check the details below.`,working:`Working…`},s={title:`Ft Bot`,description:`将企业微信中的机器人连接到这台电脑。`,access:`机器人以当前系统账户的权限访问文件、凭据、应用和网络。命令输出、截图及请求读取的本地会话文本会发送给云端机器人。可在这里断开连接,或停用插件来停止访问。`,pairing:`配对这台电脑`,instructions:`请机器人连接这台电脑,然后在这里粘贴它提供的一次性配对码。`,advanced:`高级设置`,gateway:`服务器地址`,gatewayHelp:`仅当机器人使用其他服务器时修改。留空则使用默认地址。`,code:`一次性配对码`,pair:`配对并连接`,pairingBusy:`正在下载并配对…`,connection:`连接`,lifetime:`插件启用且 FtAi 宿主运行时(包括后台运行)会自动重连。主动断开后,重启也不会自动连接。`,connect:`连接`,disconnect:`断开连接`,retry:`重新连接`,state:{stopped:`已断开`,connecting:`正在连接…`,connected:`已连接`,reconnecting:`正在重连,请检查网关及机器人中的访问权限`,error:`连接失败`},computer:`电脑 ID`,select:`请机器人选择这台电脑。新的机器人会话将使用它,已有任务继续使用原来的电脑。`,chats:`本地 FtAi 会话`,chatsHelp:`请机器人创建本地会话、通过会话 ID 继续已有会话,或读取回复。会话使用 FtAi 的默认模型和权限;请在 FtAi 中处理审批和提问。断开连接会释放已连接的会话并停止其当前轮次,历史记录仍会保留。`,desktop:`桌面访问`,desktopHelp:`Windows 和 macOS 支持截图、点击、拖拽、滚动、输入文字和快捷键。请保持账户登录及桌面解锁。Linux 不支持原生桌面控制。`,permissions:`请求 macOS 权限`,permissionsHelp:`在系统设置 → 隐私与安全性 → 屏幕与系统录音、辅助功能中允许运行程序。修改权限后,请断开并重新连接。`,diagnostics:`刷新诊断`,details:`桌面诊断信息`,update:`更新运行程序`,updateHelp:`下载网关当前版本并校验 SHA-256。更新会暂时停止当前工作,macOS 更新后可能需要重新授予桌面权限。`,updateAction:`下载更新`,waiting:`正在等待插件宿主…`,failed:`操作失败,请查看下方详情。`,working:`正在处理…`},c={meta:{title:`Ft Bot`,description:`Local computer access for your WeCom bot.`}},l={meta:{title:`Ft Bot`,description:`让企业微信中的机器人访问本地电脑。`}},u=`@ftai/ftai-plugin-ft-bot`,d=[`ftaiFeatures`,`remote`];function f(e){let t=e.ftaiFeatures.createMessageScope({"en-US":o,"zh-CN":s});e.inject([`remote.ftBot`],e=>{let n=a(t,e.remote.ftBot),r=()=>(t.locale()===`zh-CN`?l:c).meta;e.ftaiFeatures.register({id:`ft-bot`,name:()=>r().title,description:()=>r().description,settings:{label:()=>r().title,icon:i,group:`integrations`,order:90,component:n}})})}exports.apply=f,exports.inject=d,exports.name=u;
2
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react"),t=require("@ftai/client-app"),n=require("react/jsx-runtime");var r={outline:{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},filled:{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`currentColor`,stroke:`none`}},i=((t,n,i,a)=>{let o=(0,e.forwardRef)(({color:i=`currentColor`,size:o=24,stroke:s=2,title:c,className:l,children:u,...d},f)=>(0,e.createElement)(`svg`,{ref:f,...r[t],width:o,height:o,className:[`tabler-icon`,`tabler-icon-${n}`,l].join(` `),strokeWidth:s,stroke:i,...d},[c&&(0,e.createElement)(`title`,{key:`svg-title`},c),...a.map(([t,n])=>(0,e.createElement)(t,n)),...Array.isArray(u)?u:[u]]));return o.displayName=`${i}`,o})(`outline`,`device-desktop`,`DeviceDesktop`,[[`path`,{d:`M3 5a1 1 0 0 1 1 -1h16a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-10`,key:`svg-0`}],[`path`,{d:`M7 20h10`,key:`svg-1`}],[`path`,{d:`M9 16v4`,key:`svg-2`}],[`path`,{d:`M15 16v4`,key:`svg-3`}]]);function a(r,i){return function(){let{t:a}=(0,t.useMessages)(r),[o,s]=(0,e.useState)(null),[c,l]=(0,e.useState)(null),[u,d]=(0,e.useState)(!1),[f,p]=(0,e.useState)(null),m=(0,e.useRef)(!1),h=(0,e.useRef)(0),g=(0,e.useRef)(!1);(0,e.useEffect)(()=>{m.current=!0;let e=!1,t=async()=>{if(g.current||e)return;e=!0;let t=h.current;try{let e=await i.status();if(!m.current||t!==h.current)return;e.ok?s(e.value):p(e.error.message)}catch(e){m.current&&t===h.current&&p(String(e))}finally{e=!1}};t();let n=setInterval(()=>{t()},2e3);return()=>{m.current=!1,h.current++,clearInterval(n)}},[]);let _=async e=>{if(g.current)return;g.current=!0;let t=++h.current;d(!0),p(null);try{let n=await e();if(!m.current||t!==h.current)return;n.ok?s(n.value):p(n.error.message)}catch(e){m.current&&t===h.current&&p(String(e))}finally{g.current=!1,m.current&&t===h.current&&d(!1)}},v=u||!o||o.busy,y=!!o?.computer?.device_id,b=o?.enabled&&(o.connection===`error`||o.connection===`stopped`),x=f||o?.error;return(0,n.jsxs)(t.SettingsPage,{title:a(`title`),description:a(`description`),children:[(0,n.jsx)(`p`,{className:`ft-bot-note`,children:a(`access`)}),!o&&(0,n.jsx)(`p`,{role:`status`,children:a(`waiting`)}),x&&(0,n.jsxs)(`div`,{className:`ft-bot-error`,role:`alert`,children:[(0,n.jsx)(`p`,{children:a(`failed`)}),(0,n.jsx)(`pre`,{children:x})]}),!y&&(0,n.jsx)(t.SettingsGroup,{children:(0,n.jsx)(t.SettingsRow,{title:a(`connectComputer`),description:a(`accountHelp`),children:(0,n.jsxs)(`form`,{className:`ft-bot-form`,onSubmit:e=>{e.preventDefault(),_(()=>i.connectAccount((c??o?.server??``).trim()))},children:[(0,n.jsx)(t.Button,{type:`submit`,disabled:v,children:a(u?`working`:`connectAccount`)}),(0,n.jsxs)(`details`,{className:`ft-bot-advanced`,children:[(0,n.jsx)(`summary`,{children:a(`advanced`)}),(0,n.jsxs)(`label`,{children:[a(`gateway`),(0,n.jsx)(t.Input,{type:`url`,value:c??o?.server??`https://ftai.chat/ft-bot/api`,placeholder:`https://ftai.chat/ft-bot/api`,onChange:e=>l(e.target.value),disabled:v})]}),(0,n.jsx)(`p`,{className:`ft-bot-note`,children:a(`gatewayHelp`)})]})]})})}),y&&(0,n.jsx)(t.SettingsGroup,{children:(0,n.jsxs)(t.SettingsRow,{title:a(`connection`),description:a(`lifetime`),action:(0,n.jsx)(t.Button,{variant:`outline`,size:`sm`,disabled:v,onClick:()=>{_(()=>i.setEnabled(b||!o?.enabled))},children:b?a(`retry`):o?.enabled?a(`disconnect`):a(`connect`)}),children:[(0,n.jsx)(`p`,{role:`status`,children:a(`state.${o.connection}`)}),(0,n.jsxs)(`p`,{className:`ft-bot-note`,children:[a(`computer`),`: `,(0,n.jsx)(`code`,{children:o.computer.device_id})]}),(0,n.jsx)(`p`,{className:`ft-bot-note`,children:a(`select`)})]})}),o?.installed&&(0,n.jsxs)(t.SettingsGroup,{children:[(0,n.jsx)(t.SettingsRow,{title:a(`chats`),description:a(`chatsHelp`)}),(0,n.jsxs)(t.SettingsRow,{title:a(`desktop`),description:a(`desktopHelp`),action:(0,n.jsx)(t.Button,{variant:`outline`,size:`sm`,disabled:v,onClick:()=>{_(()=>i.refresh())},children:a(`diagnostics`)}),children:[o.computer?.platform===`macos`&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`p`,{className:`ft-bot-note`,children:a(`permissionsHelp`)}),(0,n.jsx)(t.Button,{variant:`outline`,size:`sm`,disabled:v,onClick:()=>{_(()=>i.requestPermissions())},children:a(`permissions`)})]}),(0,n.jsxs)(`details`,{className:`ft-bot-diagnostics`,children:[(0,n.jsx)(`summary`,{children:a(`details`)}),(0,n.jsx)(`pre`,{children:JSON.stringify(o.computer?.desktop??{},null,2)})]})]}),(0,n.jsx)(t.SettingsRow,{title:a(`update`),description:a(`updateHelp`),action:(0,n.jsx)(t.Button,{variant:`outline`,size:`sm`,disabled:v||!o.server,onClick:()=>{_(()=>i.updateRunner())},children:a(u?`working`:`updateAction`)})})]})]})}}var o={title:`Ft Bot`,description:`Connect your WeCom bot to this computer.`,access:`The bot runs with your OS account’s file, credential, app and network access. Command output, screenshots and requested local chat text are sent to the cloud bot. Disconnect here or disable this plugin to stop access.`,connectComputer:`Connect this computer`,accountHelp:`Use your signed-in FtAi account. Allow credential access in FtAi if prompted, then retry. Use the same company and WeCom account as your bot.`,connectAccount:`Connect with FtAi`,advanced:`Advanced`,gateway:`Server URL`,gatewayHelp:`Connect with FtAi sends your account credential to this server to register the computer. Change it for a self-hosted bot; leave blank to use the default.`,connection:`Connection`,lifetime:`Reconnects while this plugin is enabled and the FtAi host is running, including in the background. Disconnect is remembered across restarts.`,connect:`Connect`,disconnect:`Disconnect`,retry:`Reconnect`,state:{stopped:`Disconnected`,connecting:`Connecting…`,connected:`Connected`,reconnecting:`Reconnecting — check the gateway and access in the bot`,error:`Connection failed`},computer:`Computer ID`,select:`In a private chat, ask the bot to rename this computer or make it the default for new conversations. Existing jobs keep their current computer.`,chats:`Local FtAi chats`,chatsHelp:`Ask the bot to create a local chat, resume one by its session ID, or read its replies. Chats use FtAi’s default model and permissions; answer approvals and questions in FtAi. Disconnecting releases attached chats and stops their current turns. Their history stays saved.`,desktop:`Desktop access`,desktopHelp:`Windows and macOS support screenshots, clicks, dragging, scrolling, typing and keyboard shortcuts. On macOS, the bot can also operate accessible controls in one app while you work in another. Keep the account logged in and the desktop unlocked. Native desktop control is unavailable on Linux.`,permissions:`Request macOS permissions`,permissionsHelp:`Allow the runner in System Settings → Privacy & Security → Screen & System Audio Recording and Accessibility. After changing permissions, disconnect and reconnect.`,diagnostics:`Refresh diagnostics`,details:`Desktop diagnostics`,update:`Update runner`,updateHelp:`Downloads the gateway’s current runner and verifies its SHA-256. Updating temporarily stops active work. macOS may require granting desktop permissions again.`,updateAction:`Download update`,waiting:`Waiting for the plugin host…`,failed:`The operation failed. Check the details below.`,working:`Working…`},s={title:`Ft Bot`,description:`将企业微信中的机器人连接到这台电脑。`,access:`机器人以当前系统账户的权限访问文件、凭据、应用和网络。命令输出、截图及请求读取的本地会话文本会发送给云端机器人。可在这里断开连接,或停用插件来停止访问。`,connectComputer:`连接这台电脑`,accountHelp:`使用已登录的 FtAi 账号。如提示授权读取凭据,请在 FtAi 中允许后重试。请选择与机器人一致的公司及企业微信账号。`,connectAccount:`通过 FtAi 连接`,advanced:`高级设置`,gateway:`服务器地址`,gatewayHelp:`通过 FtAi 连接时,会将账号凭据发送到此服务器以注册电脑。自建机器人可修改此地址,留空则使用默认地址。`,connection:`连接`,lifetime:`插件启用且 FtAi 宿主运行时(包括后台运行)会自动重连。主动断开后,重启也不会自动连接。`,connect:`连接`,disconnect:`断开连接`,retry:`重新连接`,state:{stopped:`已断开`,connecting:`正在连接…`,connected:`已连接`,reconnecting:`正在重连,请检查网关及机器人中的访问权限`,error:`连接失败`},computer:`电脑 ID`,select:`在私聊中,你可以让机器人给这台电脑改名,或将它设为新会话的默认电脑。已有任务继续使用原来的电脑。`,chats:`本地 FtAi 会话`,chatsHelp:`请机器人创建本地会话、通过会话 ID 继续已有会话,或读取回复。会话使用 FtAi 的默认模型和权限;请在 FtAi 中处理审批和提问。断开连接会释放已连接的会话并停止其当前轮次,历史记录仍会保留。`,desktop:`桌面访问`,desktopHelp:`Windows 和 macOS 支持截图、点击、拖拽、滚动、输入文字和快捷键。在 macOS 上,机器人还可通过辅助功能操作指定应用,你可以继续使用其他应用。请保持账户登录及桌面解锁。Linux 不支持原生桌面控制。`,permissions:`请求 macOS 权限`,permissionsHelp:`在系统设置 → 隐私与安全性 → 屏幕与系统录音、辅助功能中允许运行程序。修改权限后,请断开并重新连接。`,diagnostics:`刷新诊断`,details:`桌面诊断信息`,update:`更新运行程序`,updateHelp:`下载网关当前版本并校验 SHA-256。更新会暂时停止当前工作,macOS 更新后可能需要重新授予桌面权限。`,updateAction:`下载更新`,waiting:`正在等待插件宿主…`,failed:`操作失败,请查看下方详情。`,working:`正在处理…`},c={meta:{title:`Ft Bot`,description:`Local computer access for your WeCom bot.`}},l={meta:{title:`Ft Bot`,description:`让企业微信中的机器人访问本地电脑。`}},u=`@ftai/ftai-plugin-ft-bot`,d=[`ftaiFeatures`,`remote`];function f(e){let t=e.ftaiFeatures.createMessageScope({"en-US":o,"zh-CN":s});e.inject([`remote.ftBot`],e=>{let n=a(t,e.remote.ftBot),r=()=>(t.locale()===`zh-CN`?l:c).meta;e.ftaiFeatures.register({id:`ft-bot`,name:()=>r().title,description:()=>r().description,settings:{label:()=>r().title,icon:i,group:`integrations`,order:90,component:n}})})}exports.apply=f,exports.inject=d,exports.name=u;
3
3
  if (typeof document !== "undefined") {
4
4
  const style = document.createElement("style");
5
5
  style.setAttribute("data-plugin", "@ftai/ftai-plugin-ft-bot");
package/lib/client.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":["forwardRef","createElement","useMessages","useState","useRef","SettingsPage","SettingsGroup","SettingsRow","Input","Button","_Fragment","meta","enUS","zhCN","zhMeta","enMeta","react","_ftai_client_app","react_jsx_runtime","defaultAttributes","IconDeviceDesktop","Component","rest","type","size","iconName","className","stroke","color","title","iconNode","tag","attrs","children","iconNamePascal","\"d\"","\"key\"","createSettings","messages","status","setStatus","server","setServer","code","setCode","pending","setPending","error","setError","active","generation","inFlight","polling","poll","owner","result","remote","timer","run","call","busy","paired","retry","failure","t","event","pairingCode","en_US_default","zh_CN_default$1","en_default","\"title\"","\"description\"","zh_CN_default","name","inject","apply","ctx","Page","scoped","meta"],"sources":["../node_modules/.pnpm/@tabler+icons-react@3.46.0_react@18.3.1/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.mjs","../node_modules/.pnpm/@tabler+icons-react@3.46.0_react@18.3.1/node_modules/@tabler/icons-react/dist/esm/createReactComponent.mjs","../node_modules/.pnpm/@tabler+icons-react@3.46.0_react@18.3.1/node_modules/@tabler/icons-react/dist/esm/icons/IconDeviceDesktop.mjs","../src/types.ts","../src/client/Settings.tsx","../src/client/i18n/en-US.ts","../src/client/i18n/zh-CN.ts","../locale/en.json","../locale/zh-CN.json","../src/client/index.ts"],"sourcesContent":["/**\n * @license @tabler/icons-react v3.46.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nvar defaultAttributes = {\n outline: {\n xmlns: \"http://www.w3.org/2000/svg\",\n width: 24,\n height: 24,\n viewBox: \"0 0 24 24\",\n fill: \"none\",\n stroke: \"currentColor\",\n strokeWidth: 2,\n strokeLinecap: \"round\",\n strokeLinejoin: \"round\"\n },\n filled: {\n xmlns: \"http://www.w3.org/2000/svg\",\n width: 24,\n height: 24,\n viewBox: \"0 0 24 24\",\n fill: \"currentColor\",\n stroke: \"none\"\n }\n};\n\nexport { defaultAttributes as default };\n//# sourceMappingURL=defaultAttributes.mjs.map\n","/**\n * @license @tabler/icons-react v3.46.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport { forwardRef, createElement } from 'react';\nimport defaultAttributes from './defaultAttributes.mjs';\n\nconst createReactComponent = (type, iconName, iconNamePascal, iconNode) => {\n const Component = forwardRef(\n ({ color = \"currentColor\", size = 24, stroke = 2, title, className, children, ...rest }, ref) => createElement(\n \"svg\",\n {\n ref,\n ...defaultAttributes[type],\n width: size,\n height: size,\n className: [`tabler-icon`, `tabler-icon-${iconName}`, className].join(\" \"),\n ...type === \"filled\" ? {\n fill: color\n } : {\n strokeWidth: stroke,\n stroke: color\n },\n ...rest\n },\n [\n title && createElement(\"title\", { key: \"svg-title\" }, title),\n ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),\n ...Array.isArray(children) ? children : [children]\n ]\n )\n );\n Component.displayName = `${iconNamePascal}`;\n return Component;\n};\n\nexport { createReactComponent as default };\n//# sourceMappingURL=createReactComponent.mjs.map\n","/**\n * @license @tabler/icons-react v3.46.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createReactComponent from '../createReactComponent.mjs';\n\nconst __iconNode = [[\"path\", { \"d\": \"M3 5a1 1 0 0 1 1 -1h16a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-10\", \"key\": \"svg-0\" }], [\"path\", { \"d\": \"M7 20h10\", \"key\": \"svg-1\" }], [\"path\", { \"d\": \"M9 16v4\", \"key\": \"svg-2\" }], [\"path\", { \"d\": \"M15 16v4\", \"key\": \"svg-3\" }]];\nconst IconDeviceDesktop = createReactComponent(\"outline\", \"device-desktop\", \"DeviceDesktop\", __iconNode);\n\nexport { __iconNode, IconDeviceDesktop as default };\n//# sourceMappingURL=IconDeviceDesktop.mjs.map\n","export const DEFAULT_GATEWAY = 'https://ftai.chat/ft-bot/api'\n\nexport type Connection = 'stopped' | 'connecting' | 'connected' | 'reconnecting' | 'error'\n\nexport interface ComputerStatus {\n bridge: number\n protocol: number\n platform: string\n arch: string\n server: string | null\n device_id: string | null\n desktop: Record<string, unknown>\n}\n\nexport interface PluginStatus {\n server: string\n installed: boolean\n enabled: boolean\n busy: boolean\n connection: Connection\n computer: ComputerStatus | null\n error: string | null\n}\n\nimport type {} from '@ftai/plugin-sdk/host'\n\ndeclare module '@ftai/plugin-sdk/host' {\n interface RemoteErrorDetailsMap {\n 'ft-bot/operation-failed': { reason: string }\n }\n}\n","import { useEffect, useRef, useState } from 'react'\nimport { Button, Input, SettingsGroup, SettingsPage, SettingsRow, useMessages } from '@ftai/plugin-sdk/app'\nimport type { MessageScope } from '@ftai/plugin-sdk/features'\nimport type { RemoteNamespaceMap, RemoteResult } from '@ftai/plugin-sdk/remote'\nimport type {} from '@ftai/ftai-plugin-ft-bot/remote'\nimport { DEFAULT_GATEWAY, type PluginStatus } from '../types.ts'\n\nexport function createSettings(messages: MessageScope, remote: RemoteNamespaceMap['ftBot']) {\n return function Settings() {\n const { t } = useMessages(messages)\n const [status, setStatus] = useState<PluginStatus | null>(null)\n const [server, setServer] = useState<string | null>(null)\n const [code, setCode] = useState('')\n const [pending, setPending] = useState(false)\n const [error, setError] = useState<string | null>(null)\n const active = useRef(false)\n const generation = useRef(0)\n const inFlight = useRef(false)\n\n useEffect(() => {\n active.current = true\n let polling = false\n const poll = async () => {\n if (inFlight.current || polling) return\n polling = true\n const owner = generation.current\n try {\n const result = await remote.status()\n if (!active.current || owner !== generation.current) return\n if (result.ok) setStatus(result.value)\n else setError(result.error.message)\n } catch (error) {\n if (active.current && owner === generation.current) setError(String(error))\n } finally { polling = false }\n }\n void poll()\n const timer = setInterval(() => { void poll() }, 2000)\n return () => { active.current = false; generation.current++; clearInterval(timer) }\n }, [])\n\n const run = async (call: () => Promise<RemoteResult<PluginStatus>>) => {\n if (inFlight.current) return\n inFlight.current = true\n const owner = ++generation.current\n setPending(true)\n setError(null)\n try {\n const result = await call()\n if (!active.current || owner !== generation.current) return\n if (result.ok) setStatus(result.value)\n else setError(result.error.message)\n } catch (error) {\n if (active.current && owner === generation.current) setError(String(error))\n } finally {\n inFlight.current = false\n if (active.current && owner === generation.current) setPending(false)\n }\n }\n\n const busy = pending || !status || status.busy\n const paired = Boolean(status?.computer?.device_id)\n const retry = status?.enabled && (status.connection === 'error' || status.connection === 'stopped')\n const failure = error || status?.error\n return <SettingsPage title={t('title')} description={t('description')}>\n <p className=\"ft-bot-note\">{t('access')}</p>\n {!status && <p role=\"status\">{t('waiting')}</p>}\n {failure && <div className=\"ft-bot-error\" role=\"alert\"><p>{t('failed')}</p><pre>{failure}</pre></div>}\n {!paired && <SettingsGroup>\n <SettingsRow title={t('pairing')} description={t('instructions')}>\n <form className=\"ft-bot-form\" onSubmit={event => {\n event.preventDefault()\n const pairingCode = code\n setCode('')\n void run(() => remote.pair((server ?? status?.server ?? '').trim(), pairingCode))\n }}>\n <label>{t('code')}<Input type=\"password\" value={code} autoComplete=\"off\"\n onChange={event => setCode(event.target.value)} required disabled={busy} maxLength={256} /></label>\n <details className=\"ft-bot-advanced\">\n <summary>{t('advanced')}</summary>\n <label>{t('gateway')}<Input type=\"url\" value={server ?? status?.server ?? DEFAULT_GATEWAY}\n placeholder={DEFAULT_GATEWAY} onChange={event => setServer(event.target.value)} disabled={busy} /></label>\n <p className=\"ft-bot-note\">{t('gatewayHelp')}</p>\n </details>\n <Button type=\"submit\" disabled={busy || !code.trim()}>{pending ? t('pairingBusy') : t('pair')}</Button>\n </form>\n </SettingsRow>\n </SettingsGroup>}\n {paired && <SettingsGroup>\n <SettingsRow title={t('connection')} description={t('lifetime')}\n action={<Button variant=\"outline\" size=\"sm\" disabled={busy}\n onClick={() => { void run(() => remote.setEnabled(retry || !status?.enabled)) }}>\n {retry ? t('retry') : status?.enabled ? t('disconnect') : t('connect')}\n </Button>}>\n <p role=\"status\">{t(`state.${status!.connection}`)}</p>\n <p className=\"ft-bot-note\">{t('computer')}: <code>{status!.computer!.device_id}</code></p>\n <p className=\"ft-bot-note\">{t('select')}</p>\n </SettingsRow>\n </SettingsGroup>}\n {status?.installed && <SettingsGroup>\n <SettingsRow title={t('chats')} description={t('chatsHelp')} />\n <SettingsRow title={t('desktop')} description={t('desktopHelp')}\n action={<Button variant=\"outline\" size=\"sm\" disabled={busy}\n onClick={() => { void run(() => remote.refresh()) }}>{t('diagnostics')}</Button>}>\n {status.computer?.platform === 'macos' && <>\n <p className=\"ft-bot-note\">{t('permissionsHelp')}</p>\n <Button variant=\"outline\" size=\"sm\" disabled={busy}\n onClick={() => { void run(() => remote.requestPermissions()) }}>{t('permissions')}</Button>\n </>}\n <details className=\"ft-bot-diagnostics\"><summary>{t('details')}</summary>\n <pre>{JSON.stringify(status.computer?.desktop ?? {}, null, 2)}</pre>\n </details>\n </SettingsRow>\n <SettingsRow title={t('update')} description={t('updateHelp')}\n action={<Button variant=\"outline\" size=\"sm\" disabled={busy || !status.server}\n onClick={() => { void run(() => remote.updateRunner()) }}>{pending ? t('working') : t('updateAction')}</Button>} />\n </SettingsGroup>}\n </SettingsPage>\n }\n}\n","export default {\n title: 'Ft Bot',\n description: 'Connect your WeCom bot to this computer.',\n access: 'The bot runs with your OS account’s file, credential, app and network access. Command output, screenshots and requested local chat text are sent to the cloud bot. Disconnect here or disable this plugin to stop access.',\n pairing: 'Pair this computer',\n instructions: 'Ask your bot to connect this computer, then paste its one-use pairing code here.',\n advanced: 'Advanced',\n gateway: 'Server URL',\n gatewayHelp: 'Change this only if your bot uses a different server. Leave blank to use the default.',\n code: 'One-use pairing code',\n pair: 'Pair and connect',\n pairingBusy: 'Downloading and pairing…',\n connection: 'Connection',\n lifetime: 'Reconnects while this plugin is enabled and the FtAi host is running, including in the background. Disconnect is remembered across restarts.',\n connect: 'Connect', disconnect: 'Disconnect', retry: 'Reconnect',\n state: {\n stopped: 'Disconnected', connecting: 'Connecting…', connected: 'Connected',\n reconnecting: 'Reconnecting — check the gateway and access in the bot', error: 'Connection failed',\n },\n computer: 'Computer ID',\n select: 'Ask the bot to select this computer. New bot conversations then use it; existing jobs keep their current computer.',\n chats: 'Local FtAi chats',\n chatsHelp: 'Ask the bot to create a local chat, resume one by its session ID, or read its replies. Chats use FtAi’s default model and permissions; answer approvals and questions in FtAi. Disconnecting releases attached chats and stops their current turns. Their history stays saved.',\n desktop: 'Desktop access',\n desktopHelp: 'Windows and macOS support screenshots, clicks, dragging, scrolling, typing and keyboard shortcuts. Keep the account logged in and the desktop unlocked. Native desktop control is unavailable on Linux.',\n permissions: 'Request macOS permissions',\n permissionsHelp: 'Allow the runner in System Settings → Privacy & Security → Screen & System Audio Recording and Accessibility. After changing permissions, disconnect and reconnect.',\n diagnostics: 'Refresh diagnostics',\n details: 'Desktop diagnostics',\n update: 'Update runner',\n updateHelp: 'Downloads the gateway’s current runner and verifies its SHA-256. Updating temporarily stops active work. macOS may require granting desktop permissions again.',\n updateAction: 'Download update',\n waiting: 'Waiting for the plugin host…',\n failed: 'The operation failed. Check the details below.',\n working: 'Working…',\n}\n","export default {\n title: 'Ft Bot',\n description: '将企业微信中的机器人连接到这台电脑。',\n access: '机器人以当前系统账户的权限访问文件、凭据、应用和网络。命令输出、截图及请求读取的本地会话文本会发送给云端机器人。可在这里断开连接,或停用插件来停止访问。',\n pairing: '配对这台电脑',\n instructions: '请机器人连接这台电脑,然后在这里粘贴它提供的一次性配对码。',\n advanced: '高级设置',\n gateway: '服务器地址',\n gatewayHelp: '仅当机器人使用其他服务器时修改。留空则使用默认地址。',\n code: '一次性配对码',\n pair: '配对并连接',\n pairingBusy: '正在下载并配对…',\n connection: '连接',\n lifetime: '插件启用且 FtAi 宿主运行时(包括后台运行)会自动重连。主动断开后,重启也不会自动连接。',\n connect: '连接', disconnect: '断开连接', retry: '重新连接',\n state: {\n stopped: '已断开', connecting: '正在连接…', connected: '已连接',\n reconnecting: '正在重连,请检查网关及机器人中的访问权限', error: '连接失败',\n },\n computer: '电脑 ID',\n select: '请机器人选择这台电脑。新的机器人会话将使用它,已有任务继续使用原来的电脑。',\n chats: '本地 FtAi 会话',\n chatsHelp: '请机器人创建本地会话、通过会话 ID 继续已有会话,或读取回复。会话使用 FtAi 的默认模型和权限;请在 FtAi 中处理审批和提问。断开连接会释放已连接的会话并停止其当前轮次,历史记录仍会保留。',\n desktop: '桌面访问',\n desktopHelp: 'Windows 和 macOS 支持截图、点击、拖拽、滚动、输入文字和快捷键。请保持账户登录及桌面解锁。Linux 不支持原生桌面控制。',\n permissions: '请求 macOS 权限',\n permissionsHelp: '在系统设置 → 隐私与安全性 → 屏幕与系统录音、辅助功能中允许运行程序。修改权限后,请断开并重新连接。',\n diagnostics: '刷新诊断',\n details: '桌面诊断信息',\n update: '更新运行程序',\n updateHelp: '下载网关当前版本并校验 SHA-256。更新会暂时停止当前工作,macOS 更新后可能需要重新授予桌面权限。',\n updateAction: '下载更新',\n waiting: '正在等待插件宿主…',\n failed: '操作失败,请查看下方详情。',\n working: '正在处理…',\n}\n","{ \"meta\": { \"title\": \"Ft Bot\", \"description\": \"Local computer access for your WeCom bot.\" } }\n","{ \"meta\": { \"title\": \"Ft Bot\", \"description\": \"让企业微信中的机器人访问本地电脑。\" } }\n","import type { Context } from 'cordis'\nimport type {} from '@ftai/plugin-sdk/features'\nimport type {} from '@ftai/plugin-sdk/remote'\nimport type {} from '@ftai/ftai-plugin-ft-bot/remote'\nimport { IconDeviceDesktop } from '@tabler/icons-react'\nimport { createSettings } from './Settings.tsx'\nimport enUS from './i18n/en-US.ts'\nimport zhCN from './i18n/zh-CN.ts'\nimport enMeta from '../../locale/en.json'\nimport zhMeta from '../../locale/zh-CN.json'\nimport './style.css'\n\nexport const name = '@ftai/ftai-plugin-ft-bot'\nexport const inject = ['ftaiFeatures', 'remote']\n\nexport function apply(ctx: Context) {\n const messages = ctx.ftaiFeatures.createMessageScope({ 'en-US': enUS, 'zh-CN': zhCN })\n ctx.inject(['remote.ftBot'], scoped => {\n const Page = createSettings(messages, scoped.remote.ftBot)\n const meta = () => (messages.locale() === 'zh-CN' ? zhMeta : enMeta).meta\n scoped.ftaiFeatures.register({\n id: 'ft-bot', name: () => meta().title, description: () => meta().description,\n settings: { label: () => meta().title, icon: IconDeviceDesktop, group: 'integrations', order: 90, component: Page },\n })\n })\n}\n"],"ignoreList":[0,1,2],"mappings":";A,uJAOA,IAAImB,EAAoB,CACtB,QAAS,CACP,MAAO,6BACP,MAAO,GACP,OAAQ,GACR,QAAS,YACT,KAAM,OACN,OAAQ,eACR,YAAa,EACb,cAAe,QACf,eAAgB,OAClB,EACA,OAAQ,CACN,MAAO,6BACP,MAAO,GACP,OAAQ,GACR,QAAS,YACT,KAAM,eACN,OAAQ,MACV,CACF,EEjBMC,IDAwB,EAAM,EAAU,EAAgB,IAAa,CACzE,IAAMC,GAAA,EAAYrB,EAAAA,WA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AAS,sBACT,OAAQ,gBACR,WAAY,iKACZ,aAAc,kBACd,QAAS,+BACT,OAAQ,iDACR,QAAS,UACX,ECnCAC,EAAe,CACb,MAAO,SACP,YAAa,qBACb,OAAQ,+EACR,QAAS,SACT,aAAc,gCACd,SAAU,OACV,QAAS,QACT,YAAa,6BACb,KAAM,SACN,KAAM,QACN,YAAa,WACb,WAAY,KACZ,SAAU,iDACV,QAAS,KAAM,WAAY,OAAQ,MAAO,OAC1C,MAAO,CACL,QAAS,MAAO,WAAY,QAAS,UAAW,MAChD,aAAc,uBAAwB,MAAO,MAC/C,EACA,SAAU,QACV,OAAQ,wCACR,MAAO,aACP,UAAW,sGACX,QAAS,OACT,YAAa,uEACb,YAAa,cACb,gBAAiB,uDACjB,YAAa,OACb,QAAS,SACT,OAAQ,SACR,WAAY,yDACZ,aAAc,OACd,QAAS,YACT,OAAQ,gBACR,QAAS,OACX,E,4IGvBaK,EAAO,2BACPC,EAAS,CAAC,eAAgB,QAAQ,EAE/C,SAAgBC,EAAM,EAAc,CAClC,IAAMrC,EAAWsC,EAAI,aAAa,mBAAmB,CAAE,QAAShE,EAAM,QAASC,CAAK,CAAC,EACrF+D,EAAI,OAAO,CAAC,cAAc,EAAG,GAAU,CACrC,IAAMC,EAAOxC,EAAeC,EAAUwC,EAAO,OAAO,KAAK,EACnDC,OAAczC,EAAS,OAAO,IAAM,QAAUxB,EAASC,EAAAA,CAAQ,KACrE+D,EAAO,aAAa,SAAS,CAC3B,GAAI,SAAU,SAAYC,EAAK,CAAC,CAAC,MAAO,gBAAmBA,EAAK,CAAC,CAAC,YAClE,SAAU,CAAE,UAAaA,EAAK,CAAC,CAAC,MAAO,KAAM3D,EAAmB,MAAO,eAAgB,MAAO,GAAI,UAAWyD,CAAK,CACpH,CAAC,CACH,CAAC,CACH,C"}
1
+ {"version":3,"file":"client.js","names":["forwardRef","createElement","useMessages","useState","useRef","SettingsPage","SettingsGroup","SettingsRow","Button","Input","_Fragment","meta","enUS","zhCN","zhMeta","enMeta","react","_ftai_client_app","react_jsx_runtime","defaultAttributes","IconDeviceDesktop","Component","rest","type","size","iconName","className","stroke","color","title","iconNode","tag","attrs","children","iconNamePascal","\"d\"","\"key\"","createSettings","messages","status","setStatus","server","setServer","pending","setPending","error","setError","active","generation","inFlight","polling","poll","owner","result","remote","timer","run","call","busy","registered","retry","failure","t","event","en_US_default","zh_CN_default$1","en_default","\"title\"","\"description\"","zh_CN_default","name","inject","apply","ctx","Page","scoped","meta"],"sources":["../node_modules/.pnpm/@tabler+icons-react@3.46.0_react@18.3.1/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.mjs","../node_modules/.pnpm/@tabler+icons-react@3.46.0_react@18.3.1/node_modules/@tabler/icons-react/dist/esm/createReactComponent.mjs","../node_modules/.pnpm/@tabler+icons-react@3.46.0_react@18.3.1/node_modules/@tabler/icons-react/dist/esm/icons/IconDeviceDesktop.mjs","../src/types.ts","../src/client/Settings.tsx","../src/client/i18n/en-US.ts","../src/client/i18n/zh-CN.ts","../locale/en.json","../locale/zh-CN.json","../src/client/index.ts"],"sourcesContent":["/**\n * @license @tabler/icons-react v3.46.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nvar defaultAttributes = {\n outline: {\n xmlns: \"http://www.w3.org/2000/svg\",\n width: 24,\n height: 24,\n viewBox: \"0 0 24 24\",\n fill: \"none\",\n stroke: \"currentColor\",\n strokeWidth: 2,\n strokeLinecap: \"round\",\n strokeLinejoin: \"round\"\n },\n filled: {\n xmlns: \"http://www.w3.org/2000/svg\",\n width: 24,\n height: 24,\n viewBox: \"0 0 24 24\",\n fill: \"currentColor\",\n stroke: \"none\"\n }\n};\n\nexport { defaultAttributes as default };\n//# sourceMappingURL=defaultAttributes.mjs.map\n","/**\n * @license @tabler/icons-react v3.46.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport { forwardRef, createElement } from 'react';\nimport defaultAttributes from './defaultAttributes.mjs';\n\nconst createReactComponent = (type, iconName, iconNamePascal, iconNode) => {\n const Component = forwardRef(\n ({ color = \"currentColor\", size = 24, stroke = 2, title, className, children, ...rest }, ref) => createElement(\n \"svg\",\n {\n ref,\n ...defaultAttributes[type],\n width: size,\n height: size,\n className: [`tabler-icon`, `tabler-icon-${iconName}`, className].join(\" \"),\n ...type === \"filled\" ? {\n fill: color\n } : {\n strokeWidth: stroke,\n stroke: color\n },\n ...rest\n },\n [\n title && createElement(\"title\", { key: \"svg-title\" }, title),\n ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),\n ...Array.isArray(children) ? children : [children]\n ]\n )\n );\n Component.displayName = `${iconNamePascal}`;\n return Component;\n};\n\nexport { createReactComponent as default };\n//# sourceMappingURL=createReactComponent.mjs.map\n","/**\n * @license @tabler/icons-react v3.46.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createReactComponent from '../createReactComponent.mjs';\n\nconst __iconNode = [[\"path\", { \"d\": \"M3 5a1 1 0 0 1 1 -1h16a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-10\", \"key\": \"svg-0\" }], [\"path\", { \"d\": \"M7 20h10\", \"key\": \"svg-1\" }], [\"path\", { \"d\": \"M9 16v4\", \"key\": \"svg-2\" }], [\"path\", { \"d\": \"M15 16v4\", \"key\": \"svg-3\" }]];\nconst IconDeviceDesktop = createReactComponent(\"outline\", \"device-desktop\", \"DeviceDesktop\", __iconNode);\n\nexport { __iconNode, IconDeviceDesktop as default };\n//# sourceMappingURL=IconDeviceDesktop.mjs.map\n","export const DEFAULT_GATEWAY = 'https://ftai.chat/ft-bot/api'\n\nexport type Connection = 'stopped' | 'connecting' | 'connected' | 'reconnecting' | 'error'\n\nexport interface ComputerStatus {\n bridge: number\n protocol: number\n platform: string\n arch: string\n server: string | null\n device_id: string | null\n desktop: Record<string, unknown>\n}\n\nexport interface PluginStatus {\n server: string\n installed: boolean\n enabled: boolean\n busy: boolean\n connection: Connection\n computer: ComputerStatus | null\n error: string | null\n}\n\nimport type {} from '@ftai/plugin-sdk/host'\n\ndeclare module '@ftai/plugin-sdk/host' {\n interface RemoteErrorDetailsMap {\n 'ft-bot/operation-failed': { reason: string }\n }\n}\n","import { useEffect, useRef, useState } from 'react'\nimport { Button, Input, SettingsGroup, SettingsPage, SettingsRow, useMessages } from '@ftai/plugin-sdk/app'\nimport type { MessageScope } from '@ftai/plugin-sdk/features'\nimport type { RemoteNamespaceMap, RemoteResult } from '@ftai/plugin-sdk/remote'\nimport type {} from '@ftai/ftai-plugin-ft-bot/remote'\nimport { DEFAULT_GATEWAY, type PluginStatus } from '../types.ts'\n\nexport function createSettings(messages: MessageScope, remote: RemoteNamespaceMap['ftBot']) {\n return function Settings() {\n const { t } = useMessages(messages)\n const [status, setStatus] = useState<PluginStatus | null>(null)\n const [server, setServer] = useState<string | null>(null)\n const [pending, setPending] = useState(false)\n const [error, setError] = useState<string | null>(null)\n const active = useRef(false)\n const generation = useRef(0)\n const inFlight = useRef(false)\n\n useEffect(() => {\n active.current = true\n let polling = false\n const poll = async () => {\n if (inFlight.current || polling) return\n polling = true\n const owner = generation.current\n try {\n const result = await remote.status()\n if (!active.current || owner !== generation.current) return\n if (result.ok) setStatus(result.value)\n else setError(result.error.message)\n } catch (error) {\n if (active.current && owner === generation.current) setError(String(error))\n } finally { polling = false }\n }\n void poll()\n const timer = setInterval(() => { void poll() }, 2000)\n return () => { active.current = false; generation.current++; clearInterval(timer) }\n }, [])\n\n const run = async (call: () => Promise<RemoteResult<PluginStatus>>) => {\n if (inFlight.current) return\n inFlight.current = true\n const owner = ++generation.current\n setPending(true)\n setError(null)\n try {\n const result = await call()\n if (!active.current || owner !== generation.current) return\n if (result.ok) setStatus(result.value)\n else setError(result.error.message)\n } catch (error) {\n if (active.current && owner === generation.current) setError(String(error))\n } finally {\n inFlight.current = false\n if (active.current && owner === generation.current) setPending(false)\n }\n }\n\n const busy = pending || !status || status.busy\n const registered = Boolean(status?.computer?.device_id)\n const retry = status?.enabled && (status.connection === 'error' || status.connection === 'stopped')\n const failure = error || status?.error\n return <SettingsPage title={t('title')} description={t('description')}>\n <p className=\"ft-bot-note\">{t('access')}</p>\n {!status && <p role=\"status\">{t('waiting')}</p>}\n {failure && <div className=\"ft-bot-error\" role=\"alert\"><p>{t('failed')}</p><pre>{failure}</pre></div>}\n {!registered && <SettingsGroup>\n <SettingsRow title={t('connectComputer')} description={t('accountHelp')}>\n <form className=\"ft-bot-form\" onSubmit={event => {\n event.preventDefault()\n void run(() => remote.connectAccount((server ?? status?.server ?? '').trim()))\n }}>\n <Button type=\"submit\" disabled={busy}>{pending ? t('working') : t('connectAccount')}</Button>\n <details className=\"ft-bot-advanced\">\n <summary>{t('advanced')}</summary>\n <label>{t('gateway')}<Input type=\"url\" value={server ?? status?.server ?? DEFAULT_GATEWAY}\n placeholder={DEFAULT_GATEWAY} onChange={event => setServer(event.target.value)} disabled={busy} /></label>\n <p className=\"ft-bot-note\">{t('gatewayHelp')}</p>\n </details>\n </form>\n </SettingsRow>\n </SettingsGroup>}\n {registered && <SettingsGroup>\n <SettingsRow title={t('connection')} description={t('lifetime')}\n action={<Button variant=\"outline\" size=\"sm\" disabled={busy}\n onClick={() => { void run(() => remote.setEnabled(retry || !status?.enabled)) }}>\n {retry ? t('retry') : status?.enabled ? t('disconnect') : t('connect')}\n </Button>}>\n <p role=\"status\">{t(`state.${status!.connection}`)}</p>\n <p className=\"ft-bot-note\">{t('computer')}: <code>{status!.computer!.device_id}</code></p>\n <p className=\"ft-bot-note\">{t('select')}</p>\n </SettingsRow>\n </SettingsGroup>}\n {status?.installed && <SettingsGroup>\n <SettingsRow title={t('chats')} description={t('chatsHelp')} />\n <SettingsRow title={t('desktop')} description={t('desktopHelp')}\n action={<Button variant=\"outline\" size=\"sm\" disabled={busy}\n onClick={() => { void run(() => remote.refresh()) }}>{t('diagnostics')}</Button>}>\n {status.computer?.platform === 'macos' && <>\n <p className=\"ft-bot-note\">{t('permissionsHelp')}</p>\n <Button variant=\"outline\" size=\"sm\" disabled={busy}\n onClick={() => { void run(() => remote.requestPermissions()) }}>{t('permissions')}</Button>\n </>}\n <details className=\"ft-bot-diagnostics\"><summary>{t('details')}</summary>\n <pre>{JSON.stringify(status.computer?.desktop ?? {}, null, 2)}</pre>\n </details>\n </SettingsRow>\n <SettingsRow title={t('update')} description={t('updateHelp')}\n action={<Button variant=\"outline\" size=\"sm\" disabled={busy || !status.server}\n onClick={() => { void run(() => remote.updateRunner()) }}>{pending ? t('working') : t('updateAction')}</Button>} />\n </SettingsGroup>}\n </SettingsPage>\n }\n}\n","export default {\n title: 'Ft Bot',\n description: 'Connect your WeCom bot to this computer.',\n access: 'The bot runs with your OS account’s file, credential, app and network access. Command output, screenshots and requested local chat text are sent to the cloud bot. Disconnect here or disable this plugin to stop access.',\n connectComputer: 'Connect this computer',\n accountHelp: 'Use your signed-in FtAi account. Allow credential access in FtAi if prompted, then retry. Use the same company and WeCom account as your bot.',\n connectAccount: 'Connect with FtAi',\n advanced: 'Advanced',\n gateway: 'Server URL',\n gatewayHelp: 'Connect with FtAi sends your account credential to this server to register the computer. Change it for a self-hosted bot; leave blank to use the default.',\n connection: 'Connection',\n lifetime: 'Reconnects while this plugin is enabled and the FtAi host is running, including in the background. Disconnect is remembered across restarts.',\n connect: 'Connect', disconnect: 'Disconnect', retry: 'Reconnect',\n state: {\n stopped: 'Disconnected', connecting: 'Connecting…', connected: 'Connected',\n reconnecting: 'Reconnecting — check the gateway and access in the bot', error: 'Connection failed',\n },\n computer: 'Computer ID',\n select: 'In a private chat, ask the bot to rename this computer or make it the default for new conversations. Existing jobs keep their current computer.',\n chats: 'Local FtAi chats',\n chatsHelp: 'Ask the bot to create a local chat, resume one by its session ID, or read its replies. Chats use FtAi’s default model and permissions; answer approvals and questions in FtAi. Disconnecting releases attached chats and stops their current turns. Their history stays saved.',\n desktop: 'Desktop access',\n desktopHelp: 'Windows and macOS support screenshots, clicks, dragging, scrolling, typing and keyboard shortcuts. On macOS, the bot can also operate accessible controls in one app while you work in another. Keep the account logged in and the desktop unlocked. Native desktop control is unavailable on Linux.',\n permissions: 'Request macOS permissions',\n permissionsHelp: 'Allow the runner in System Settings → Privacy & Security → Screen & System Audio Recording and Accessibility. After changing permissions, disconnect and reconnect.',\n diagnostics: 'Refresh diagnostics',\n details: 'Desktop diagnostics',\n update: 'Update runner',\n updateHelp: 'Downloads the gateway’s current runner and verifies its SHA-256. Updating temporarily stops active work. macOS may require granting desktop permissions again.',\n updateAction: 'Download update',\n waiting: 'Waiting for the plugin host…',\n failed: 'The operation failed. Check the details below.',\n working: 'Working…',\n}\n","export default {\n title: 'Ft Bot',\n description: '将企业微信中的机器人连接到这台电脑。',\n access: '机器人以当前系统账户的权限访问文件、凭据、应用和网络。命令输出、截图及请求读取的本地会话文本会发送给云端机器人。可在这里断开连接,或停用插件来停止访问。',\n connectComputer: '连接这台电脑',\n accountHelp: '使用已登录的 FtAi 账号。如提示授权读取凭据,请在 FtAi 中允许后重试。请选择与机器人一致的公司及企业微信账号。',\n connectAccount: '通过 FtAi 连接',\n advanced: '高级设置',\n gateway: '服务器地址',\n gatewayHelp: '通过 FtAi 连接时,会将账号凭据发送到此服务器以注册电脑。自建机器人可修改此地址,留空则使用默认地址。',\n connection: '连接',\n lifetime: '插件启用且 FtAi 宿主运行时(包括后台运行)会自动重连。主动断开后,重启也不会自动连接。',\n connect: '连接', disconnect: '断开连接', retry: '重新连接',\n state: {\n stopped: '已断开', connecting: '正在连接…', connected: '已连接',\n reconnecting: '正在重连,请检查网关及机器人中的访问权限', error: '连接失败',\n },\n computer: '电脑 ID',\n select: '在私聊中,你可以让机器人给这台电脑改名,或将它设为新会话的默认电脑。已有任务继续使用原来的电脑。',\n chats: '本地 FtAi 会话',\n chatsHelp: '请机器人创建本地会话、通过会话 ID 继续已有会话,或读取回复。会话使用 FtAi 的默认模型和权限;请在 FtAi 中处理审批和提问。断开连接会释放已连接的会话并停止其当前轮次,历史记录仍会保留。',\n desktop: '桌面访问',\n desktopHelp: 'Windows 和 macOS 支持截图、点击、拖拽、滚动、输入文字和快捷键。在 macOS 上,机器人还可通过辅助功能操作指定应用,你可以继续使用其他应用。请保持账户登录及桌面解锁。Linux 不支持原生桌面控制。',\n permissions: '请求 macOS 权限',\n permissionsHelp: '在系统设置 → 隐私与安全性 → 屏幕与系统录音、辅助功能中允许运行程序。修改权限后,请断开并重新连接。',\n diagnostics: '刷新诊断',\n details: '桌面诊断信息',\n update: '更新运行程序',\n updateHelp: '下载网关当前版本并校验 SHA-256。更新会暂时停止当前工作,macOS 更新后可能需要重新授予桌面权限。',\n updateAction: '下载更新',\n waiting: '正在等待插件宿主…',\n failed: '操作失败,请查看下方详情。',\n working: '正在处理…',\n}\n","{ \"meta\": { \"title\": \"Ft Bot\", \"description\": \"Local computer access for your WeCom bot.\" } }\n","{ \"meta\": { \"title\": \"Ft Bot\", \"description\": \"让企业微信中的机器人访问本地电脑。\" } }\n","import type { Context } from 'cordis'\nimport type {} from '@ftai/plugin-sdk/features'\nimport type {} from '@ftai/plugin-sdk/remote'\nimport type {} from '@ftai/ftai-plugin-ft-bot/remote'\nimport { IconDeviceDesktop } from '@tabler/icons-react'\nimport { createSettings } from './Settings.tsx'\nimport enUS from './i18n/en-US.ts'\nimport zhCN from './i18n/zh-CN.ts'\nimport enMeta from '../../locale/en.json'\nimport zhMeta from '../../locale/zh-CN.json'\nimport './style.css'\n\nexport const name = '@ftai/ftai-plugin-ft-bot'\nexport const inject = ['ftaiFeatures', 'remote']\n\nexport function apply(ctx: Context) {\n const messages = ctx.ftaiFeatures.createMessageScope({ 'en-US': enUS, 'zh-CN': zhCN })\n ctx.inject(['remote.ftBot'], scoped => {\n const Page = createSettings(messages, scoped.remote.ftBot)\n const meta = () => (messages.locale() === 'zh-CN' ? zhMeta : enMeta).meta\n scoped.ftaiFeatures.register({\n id: 'ft-bot', name: () => meta().title, description: () => meta().description,\n settings: { label: () => meta().title, icon: IconDeviceDesktop, group: 'integrations', order: 90, component: Page },\n })\n })\n}\n"],"ignoreList":[0,1,2],"mappings":";A,uJAOA,IAAImB,EAAoB,CACtB,QAAS,CACP,MAAO,6BACP,MAAO,GACP,OAAQ,GACR,QAAS,YACT,KAAM,OACN,OAAQ,eACR,YAAa,EACb,cAAe,QACf,eAAgB,OAClB,EACA,OAAQ,CACN,MAAO,6BACP,MAAO,GACP,OAAQ,GACR,QAAS,YACT,KAAM,eACN,OAAQ,MACV,CACF,EEjBMC,IDAwB,EAAM,EAAU,EAAgB,IAAa,CACzE,IAAMC,GAAA,EAAYrB,EAAAA,WAAAA,EACf,CAAE,QAAQ,eAAgB,OAAO,GAAI,SAAS,EAAG,QAAO,YAAW,WAAU,GAAGsB,GAAQ,KAAA,EAAQrB,EAAAA,cAAAA,CAC/F,MACA,CACE,MACA,GAAGkB,EAAkBI,GACrB,MAAOC,EACP,OAAQA,EACR,UAAW,CAAC,cAAe,eAAeC,IAAYC,CAAS,CAAC,CAAC,KAAK,GAAG,EAIvE,YAAaC,EACb,OAAQC,EAEV,GAAGN,CACL,EACA,CACEO,IAAA,EAAS5B,EAAAA,cAAAA,CAAc,QAAS,CAAE,IAAK,WAAY,EAAG4B,CAAK,EAC3D,GAAGC,EAAS,KAAK,CAACC,EAAKC,MAAA,EAAW/B,EAAAA,cAAAA,CAAc8B,EAAKC,CAAK,CAAC,EAC3D,GAAG,MAAM,QAAQC,CAAQ,EAAIA,EAAW,CAACA,CAAQ,CACnD,CACF,CACF,EAEA,MADA,GAAU,YAAc,GAAGC,IACpBb,CACT,EC3B0B,CAAqB,UAAW,iBAAkB,gBAAiB,CADzE,CAAC,OAAQ,CAAEc,EAAK,iFAAkFC,IAAO,OAAQ,CAAC,EAAG,CAAC,OAAQ,CAAED,EAAK,WAAYC,IAAO,OAAQ,CAAC,EAAG,CAAC,OAAQ,CAAED,EAAK,UAAWC,IAAO,OAAQ,CAAC,EAAG,CAAC,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,QAAS,sBACT,OAAQ,gBACR,WAAY,iKACZ,aAAc,kBACd,QAAS,+BACT,OAAQ,iDACR,QAAS,UACX,ECjCAC,EAAe,CACb,MAAO,SACP,YAAa,qBACb,OAAQ,+EACR,gBAAiB,SACjB,YAAa,+DACb,eAAgB,aAChB,SAAU,OACV,QAAS,QACT,YAAa,wDACb,WAAY,KACZ,SAAU,iDACV,QAAS,KAAM,WAAY,OAAQ,MAAO,OAC1C,MAAO,CACL,QAAS,MAAO,WAAY,QAAS,UAAW,MAChD,aAAc,uBAAwB,MAAO,MAC/C,EACA,SAAU,QACV,OAAQ,mDACR,MAAO,aACP,UAAW,sGACX,QAAS,OACT,YAAa,+GACb,YAAa,cACb,gBAAiB,uDACjB,YAAa,OACb,QAAS,SACT,OAAQ,SACR,WAAY,yDACZ,aAAc,OACd,QAAS,YACT,OAAQ,gBACR,QAAS,OACX,E,4IGrBaK,EAAO,2BACPC,EAAS,CAAC,eAAgB,QAAQ,EAE/C,SAAgBC,EAAM,EAAc,CAClC,IAAMlC,EAAWmC,EAAI,aAAa,mBAAmB,CAAE,QAAS7D,EAAM,QAASC,CAAK,CAAC,EACrF4D,EAAI,OAAO,CAAC,cAAc,EAAG,GAAU,CACrC,IAAMC,EAAOrC,EAAeC,EAAUqC,EAAO,OAAO,KAAK,EACnDC,OAActC,EAAS,OAAO,IAAM,QAAUxB,EAASC,EAAAA,CAAQ,KACrE4D,EAAO,aAAa,SAAS,CAC3B,GAAI,SAAU,SAAYC,EAAK,CAAC,CAAC,MAAO,gBAAmBA,EAAK,CAAC,CAAC,YAClE,SAAU,CAAE,UAAaA,EAAK,CAAC,CAAC,MAAO,KAAMxD,EAAmB,MAAO,eAAgB,MAAO,GAAI,UAAWsD,CAAK,CACpH,CAAC,CACH,CAAC,CACH,C"}
@@ -22,7 +22,7 @@ export declare class Controller {
22
22
  private startRunner;
23
23
  private stopRunner;
24
24
  private operate;
25
- pair(server: string, code: string): Promise<PluginStatus>;
25
+ connectAccount(server: string, resolveToken: () => Promise<string | undefined>): Promise<PluginStatus>;
26
26
  private download;
27
27
  updateRunner(): Promise<PluginStatus>;
28
28
  setEnabled(enabled: boolean): Promise<PluginStatus>;
package/lib/controller.js CHANGED
@@ -1,4 +1,4 @@
1
- import { homedir } from 'node:os';
1
+ import { homedir, hostname } from 'node:os';
2
2
  import { isAbsolute, join } from 'node:path';
3
3
  import { chmod, mkdir, readFile, rename, writeFile } from 'node:fs/promises';
4
4
  import { randomUUID } from 'node:crypto';
@@ -108,7 +108,7 @@ export class Controller {
108
108
  this.snapshot.computer = await this.request({ type: 'status' });
109
109
  const server = this.snapshot.computer.server;
110
110
  if (this.snapshot.computer.device_id && server && this.config.server && gateway(server) !== this.config.server) {
111
- throw new Error('Saved pairing belongs to another gateway.');
111
+ throw new Error('This computer is registered with another gateway.');
112
112
  }
113
113
  }
114
114
  startRunner() {
@@ -116,7 +116,7 @@ export class Controller {
116
116
  if (this.running)
117
117
  return;
118
118
  if (!this.snapshot.computer?.device_id)
119
- throw new Error('Pair this computer first.');
119
+ throw new Error('Choose Connect with FtAi first.');
120
120
  this.snapshot.connection = 'connecting';
121
121
  const runner = launchRunner(this.executable(), join(this.directory, 'runner'), { type: 'run' }, status => {
122
122
  if (this.running === runner)
@@ -164,16 +164,19 @@ export class Controller {
164
164
  }
165
165
  return this.getStatus();
166
166
  }
167
- async pair(server, code) {
167
+ async connectAccount(server, resolveToken) {
168
168
  return this.operate(async () => {
169
169
  server = gateway(server.trim() || DEFAULT_GATEWAY);
170
- if (typeof code !== 'string' || !code.trim() || code.length > 256)
171
- throw new Error('Enter the pairing code from the bot.');
172
170
  if (this.snapshot.computer?.device_id)
173
- throw new Error('This computer is already paired.');
171
+ throw new Error('This computer is already registered.');
172
+ const token = await resolveToken();
173
+ this.alive();
174
+ if (!token)
175
+ throw new Error('Sign in to FtAi, allow Ft Bot to read FTAI_USER_TOKEN in credential permissions, then retry.');
174
176
  if (!this.snapshot.installed)
175
177
  await this.download(server);
176
- this.snapshot.computer = await this.request({ type: 'pair', server, code });
178
+ const name = Array.from(hostname().replace(/\p{Cc}/gu, '').trim()).slice(0, 64).join('') || 'Computer';
179
+ this.snapshot.computer = await this.request({ type: 'enroll', server, token, name });
177
180
  await this.save({ ...this.config, server, enabled: true });
178
181
  this.startRunner();
179
182
  });
@@ -196,7 +199,7 @@ export class Controller {
196
199
  async updateRunner() {
197
200
  return this.operate(async () => {
198
201
  if (!this.config.server)
199
- throw new Error('Pair with a gateway first.');
202
+ throw new Error('Choose Connect with FtAi first.');
200
203
  await this.stopRunner();
201
204
  try {
202
205
  await this.download(this.config.server);
@@ -214,7 +217,7 @@ export class Controller {
214
217
  if (enabled) {
215
218
  await this.inspect();
216
219
  if (!this.snapshot.computer?.device_id)
217
- throw new Error('Pair this computer first.');
220
+ throw new Error('Choose Connect with FtAi first.');
218
221
  }
219
222
  await this.save({ ...this.config, enabled });
220
223
  if (enabled)
@@ -1 +1 @@
1
- {"version":3,"file":"controller.js","sourceRoot":"","sources":["../src/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,EAAE,eAAe,EAAqB,MAAM,YAAY,CAAA;AAM/D,MAAM,UAAU,cAAc;IAC5B,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAA;IACzE,IAAI,OAAO,CAAC,QAAQ,KAA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=credential-host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential-host.js","sourceRoot":"","sources":["../src/credential-host.ts"],"names":[],"mappings":""}
package/lib/download.d.ts CHANGED
@@ -1,8 +1,13 @@
1
- export declare const PROTOCOL = 4;
1
+ export declare const PROTOCOL = 7;
2
2
  export declare function gateway(value: string): string;
3
3
  export declare function artifactFor(manifest: unknown, platform?: NodeJS.Platform, arch?: NodeJS.Architecture): {
4
4
  revision: string;
5
+ revisionFile: string;
6
+ target: string;
5
7
  filename: string;
8
+ tools: string;
9
+ runner: string;
10
+ browser: string;
6
11
  sha256: string;
7
12
  bytes: number;
8
13
  };
package/lib/download.js CHANGED
@@ -1,7 +1,10 @@
1
- import { createHash, randomUUID } from 'node:crypto';
2
- import { mkdir, open, rename, rm } from 'node:fs/promises';
1
+ import { createHash } from 'node:crypto';
2
+ import { mkdir, mkdtemp, readFile, rename, rm, writeFile } from 'node:fs/promises';
3
3
  import { join } from 'node:path';
4
- export const PROTOCOL = 4;
4
+ import { unzipSync } from 'fflate';
5
+ export const PROTOCOL = 7;
6
+ const maxPackageBytes = 256 * 1024 * 1024;
7
+ const runnerVersionPattern = /^\d+\.\d+\.\d+(-[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*)?(\+[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*)?$/;
5
8
  export function gateway(value) {
6
9
  const url = new URL(value.trim());
7
10
  if ((url.protocol !== 'https:' && !(url.protocol === 'http:' && ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname)))
@@ -21,18 +24,24 @@ export function artifactFor(manifest, platform = process.platform, arch = proces
21
24
  throw new Error(`Unsupported computer: ${platform}/${arch}`);
22
25
  const data = manifest;
23
26
  if (!data || typeof data.revision !== 'string' || !/^[a-f0-9]{40}$/.test(data.revision)
27
+ || typeof data.runner_version !== 'string' || !runnerVersionPattern.test(data.runner_version)
24
28
  || data.protocol !== PROTOCOL || !Array.isArray(data.artifacts)) {
25
- throw new Error('The gateway must publish runner protocol 4 binaries.');
29
+ throw new Error(`The gateway must publish runner protocol ${PROTOCOL} packages.`);
26
30
  }
27
- const filename = `ft-bot-runner-${target}${platform === 'win32' ? '.exe' : ''}`;
31
+ const filename = `ft-bot-runner-${target}.zip`;
28
32
  const matches = data.artifacts.filter((item) => item?.target === target);
29
33
  const artifact = matches[0];
30
34
  if (matches.length !== 1 || artifact.filename !== filename || typeof artifact.sha256 !== 'string'
31
35
  || !/^[a-f0-9]{64}$/.test(artifact.sha256) || !Number.isSafeInteger(artifact.bytes)
32
- || artifact.bytes <= 0 || artifact.bytes > 256 * 1024 * 1024) {
36
+ || artifact.bytes <= 0 || artifact.bytes > maxPackageBytes) {
33
37
  throw new Error('Invalid runner download metadata.');
34
38
  }
35
- return { revision: data.revision, filename, sha256: artifact.sha256, bytes: artifact.bytes };
39
+ const extension = platform === 'win32' ? '.exe' : '';
40
+ const separator = data.runner_version.includes('+') ? '.' : '+';
41
+ const bundleVersion = `${data.runner_version}${separator}${data.revision.slice(0, 8)}`;
42
+ const tools = `${bundleVersion}/ft-bot-tools`;
43
+ return { revision: data.revision, revisionFile: `${bundleVersion}/REVISION`, target, filename, tools, runner: `${bundleVersion}/ft-bot-runner${extension}`,
44
+ browser: `${tools}/agent-browser${extension}`, sha256: artifact.sha256, bytes: artifact.bytes };
36
45
  }
37
46
  async function fetchFile(url, signal) {
38
47
  // Keep downloads on the selected HTTPS gateway; never follow a downgrade or redirect.
@@ -41,44 +50,64 @@ async function fetchFile(url, signal) {
41
50
  throw new Error(`Runner download failed (HTTP ${response.status}).`);
42
51
  return response;
43
52
  }
44
- export async function downloadRunner(server, directory, signal) {
45
- const base = `${gateway(server)}/runner/downloads`;
46
- const response = await fetchFile(`${base}/latest.json`, signal);
53
+ async function readLimited(response, limit) {
47
54
  const chunks = [];
48
55
  let size = 0;
49
56
  for await (const chunk of response.body) {
50
57
  size += chunk.length;
51
- if (size > 64 * 1024)
52
- throw new Error('Runner manifest is too large.');
58
+ if (size > limit)
59
+ throw new Error('Runner download exceeds its declared size limit.');
53
60
  chunks.push(chunk);
54
61
  }
55
- const artifact = artifactFor(JSON.parse(Buffer.concat(chunks).toString('utf8')));
56
- const folder = join(directory, artifact.revision);
57
- await mkdir(folder, { recursive: true, mode: 0o700 });
58
- const temporary = join(folder, `.download-${randomUUID()}`);
59
- const destination = join(folder, artifact.filename);
60
- const file = await open(temporary, 'wx', 0o700);
62
+ return Buffer.concat(chunks, size);
63
+ }
64
+ export async function downloadRunner(server, directory, signal) {
65
+ const base = `${gateway(server)}/runner/downloads`;
66
+ const manifest = await readLimited(await fetchFile(`${base}/latest.json`, signal), 64 * 1024);
67
+ const artifact = artifactFor(JSON.parse(manifest.toString('utf8')));
68
+ const url = `${base}/${artifact.revision}/${artifact.filename}`;
69
+ const zip = await readLimited(await fetchFile(url, signal), artifact.bytes);
70
+ if (zip.length !== artifact.bytes || createHash('sha256').update(zip).digest('hex') !== artifact.sha256) {
71
+ throw new Error('Runner checksum mismatch.');
72
+ }
73
+ const files = [artifact.revisionFile, `${artifact.tools}/LICENSE.txt`, artifact.browser, artifact.runner];
74
+ const missing = new Set(files);
75
+ let expanded = 0;
76
+ const contents = unzipSync(zip, { filter(entry) {
77
+ expanded += entry.originalSize;
78
+ if (!missing.delete(entry.name) || !entry.originalSize || expanded > maxPackageBytes) {
79
+ throw new Error('Invalid runner package contents.');
80
+ }
81
+ return true;
82
+ } });
83
+ if (missing.size)
84
+ throw new Error('Incomplete runner package.');
85
+ if (!Buffer.from(contents[artifact.revisionFile]).equals(Buffer.from(artifact.revision + '\n'))) {
86
+ throw new Error('Incorrect release revision in runner package.');
87
+ }
88
+ await mkdir(join(directory, artifact.tools), { recursive: true, mode: 0o700 });
89
+ const stage = await mkdtemp(join(directory, '.download-'));
61
90
  try {
62
- const binary = await fetchFile(`${base}/${artifact.revision}/${artifact.filename}`, signal);
63
- const hash = createHash('sha256');
64
- let bytes = 0;
65
- for await (const chunk of binary.body) {
66
- bytes += chunk.length;
67
- if (bytes > artifact.bytes)
68
- throw new Error('Runner download exceeds its declared size.');
69
- hash.update(chunk);
70
- await file.writeFile(chunk);
91
+ await mkdir(join(stage, artifact.tools), { recursive: true, mode: 0o700 });
92
+ for (const name of files) {
93
+ await writeFile(join(stage, name), contents[name], { mode: name === artifact.runner || name === artifact.browser ? 0o700 : 0o600 });
94
+ }
95
+ signal.throwIfAborted();
96
+ // Activate the runner last. Windows may lock an identical, running executable.
97
+ for (const name of files) {
98
+ const destination = join(directory, name);
99
+ try {
100
+ await rename(join(stage, name), destination);
101
+ }
102
+ catch (error) {
103
+ if (process.platform !== 'win32' || !(await readFile(destination)).equals(contents[name]))
104
+ throw error;
105
+ }
71
106
  }
72
- if (bytes !== artifact.bytes || hash.digest('hex') !== artifact.sha256)
73
- throw new Error('Runner checksum mismatch.');
74
- await file.sync();
75
- await file.close();
76
- await rename(temporary, destination);
77
- return destination;
107
+ return join(directory, artifact.runner);
78
108
  }
79
109
  finally {
80
- await file.close();
81
- await rm(temporary, { force: true });
110
+ await rm(stage, { recursive: true, force: true });
82
111
  }
83
112
  }
84
113
  //# sourceMappingURL=download.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"download.js","sourceRoot":"","sources":["../src/download.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAA;AAEzB,MAAM,UAAU,OAAO,CAAC,KAAa;IACnC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;IACjC,IAAI,CAAC,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,QAAQ,KAAK,OAA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QAC1E,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAE,EAAE,EAAE,IAAI,EAAE,IAAI,KAAK,QAAQ,CAAC,MAAM,IAAI,IAAI,KAAK,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAA;QACtI,CAAC;QACD,MAAM,CAAC,cAAc,EAAE,CAAA;QACvB,+EAA+E;QAC/E,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;YACzC,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,WAAW,CAAC,CAAA;YAC9C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,CAAC,CAAC,MAAM,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAE,CAAC;oBAAE,MAAM,KAAK,CAAA;YACzG,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IACzC,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IACnD,CAAC;AACH,CAAC"}
package/lib/index.d.ts CHANGED
@@ -10,10 +10,11 @@ declare module 'cordis' {
10
10
  export declare class FtBot extends TypertRemoteService {
11
11
  static inject: string[];
12
12
  private controller;
13
+ private readonly credentials;
13
14
  constructor(ctx: Context);
14
15
  private perform;
15
16
  status(): PluginStatus;
16
- pair(server: string, code: string): Promise<PluginStatus>;
17
+ connectAccount(server: string): Promise<PluginStatus>;
17
18
  setEnabled(enabled: boolean): Promise<PluginStatus>;
18
19
  updateRunner(): Promise<PluginStatus>;
19
20
  refresh(): Promise<PluginStatus>;
package/lib/index.js CHANGED
@@ -39,7 +39,7 @@ let FtBot = (() => {
39
39
  let _classSuper = TypertRemoteService;
40
40
  let _instanceExtraInitializers = [];
41
41
  let _status_decorators;
42
- let _pair_decorators;
42
+ let _connectAccount_decorators;
43
43
  let _setEnabled_decorators;
44
44
  let _updateRunner_decorators;
45
45
  let _refresh_decorators;
@@ -48,23 +48,25 @@ let FtBot = (() => {
48
48
  static {
49
49
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
50
50
  _status_decorators = [Remote];
51
- _pair_decorators = [Remote];
51
+ _connectAccount_decorators = [Remote];
52
52
  _setEnabled_decorators = [Remote];
53
53
  _updateRunner_decorators = [Remote];
54
54
  _refresh_decorators = [Remote];
55
55
  _requestPermissions_decorators = [Remote];
56
56
  __esDecorate(this, null, _status_decorators, { kind: "method", name: "status", static: false, private: false, access: { has: obj => "status" in obj, get: obj => obj.status }, metadata: _metadata }, null, _instanceExtraInitializers);
57
- __esDecorate(this, null, _pair_decorators, { kind: "method", name: "pair", static: false, private: false, access: { has: obj => "pair" in obj, get: obj => obj.pair }, metadata: _metadata }, null, _instanceExtraInitializers);
57
+ __esDecorate(this, null, _connectAccount_decorators, { kind: "method", name: "connectAccount", static: false, private: false, access: { has: obj => "connectAccount" in obj, get: obj => obj.connectAccount }, metadata: _metadata }, null, _instanceExtraInitializers);
58
58
  __esDecorate(this, null, _setEnabled_decorators, { kind: "method", name: "setEnabled", static: false, private: false, access: { has: obj => "setEnabled" in obj, get: obj => obj.setEnabled }, metadata: _metadata }, null, _instanceExtraInitializers);
59
59
  __esDecorate(this, null, _updateRunner_decorators, { kind: "method", name: "updateRunner", static: false, private: false, access: { has: obj => "updateRunner" in obj, get: obj => obj.updateRunner }, metadata: _metadata }, null, _instanceExtraInitializers);
60
60
  __esDecorate(this, null, _refresh_decorators, { kind: "method", name: "refresh", static: false, private: false, access: { has: obj => "refresh" in obj, get: obj => obj.refresh }, metadata: _metadata }, null, _instanceExtraInitializers);
61
61
  __esDecorate(this, null, _requestPermissions_decorators, { kind: "method", name: "requestPermissions", static: false, private: false, access: { has: obj => "requestPermissions" in obj, get: obj => obj.requestPermissions }, metadata: _metadata }, null, _instanceExtraInitializers);
62
62
  if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
63
63
  }
64
- static inject = ['agents'];
64
+ static inject = ['agents', 'credentials'];
65
65
  controller = __runInitializers(this, _instanceExtraInitializers);
66
+ credentials;
66
67
  constructor(ctx) {
67
68
  super(ctx, 'ftBot');
69
+ this.credentials = ctx.credentials;
68
70
  ctx.effect(() => {
69
71
  const chats = new Chats(ctx.agents);
70
72
  this.controller = new Controller(stateDirectory(), undefined, chats);
@@ -81,7 +83,9 @@ let FtBot = (() => {
81
83
  }
82
84
  }
83
85
  status() { return this.controller.getStatus(); }
84
- pair(server, code) { return this.perform(() => this.controller.pair(server, code)); }
86
+ connectAccount(server) {
87
+ return this.perform(() => this.controller.connectAccount(server, async () => (await this.credentials.resolve('FTAI_USER_TOKEN'))?.value));
88
+ }
85
89
  setEnabled(enabled) { return this.perform(() => this.controller.setEnabled(enabled)); }
86
90
  updateRunner() { return this.perform(() => this.controller.updateRunner()); }
87
91
  refresh() { return this.perform(() => this.controller.refresh()); }
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAChF,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AA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AAM,EAC7D,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAA;QAC5E,CAAC;QAGD,UAAU,CAAC,OAAgB,IAA2B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAA,CAAC,CAAC;QAGtH,YAAY,KAA4B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC,CAAA,CAAC,CAAC;QAGnG,OAAO,KAA4B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAA,CAAC,CAAC;QAGzF,kBAAkB,KAA4B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,kBAAkB,EAAE,CAAC,CAAA,CAAC,CAAC;;;SA1CpG,KAAK;AA6ClB,eAAe,KAAK,CAAA"}
package/lib/remote.d.ts CHANGED
@@ -11,7 +11,7 @@ type Stream<F> = ((...args: Args<F>) => RemoteStream<Item<F>>) & ((...args: [...
11
11
 
12
12
  declare module '@ftai/plugin-sdk/remote' {
13
13
  interface RemoteNamespaceMap {
14
- 'ftBot': { status: Call<FtBot['status']>; pair: Call<FtBot['pair']>; setEnabled: Call<FtBot['setEnabled']>; updateRunner: Call<FtBot['updateRunner']>; refresh: Call<FtBot['refresh']>; requestPermissions: Call<FtBot['requestPermissions']> }
14
+ 'ftBot': { status: Call<FtBot['status']>; connectAccount: Call<FtBot['connectAccount']>; setEnabled: Call<FtBot['setEnabled']>; updateRunner: Call<FtBot['updateRunner']>; refresh: Call<FtBot['refresh']>; requestPermissions: Call<FtBot['requestPermissions']> }
15
15
  }
16
16
  }
17
17
 
package/lib/remote.js CHANGED
@@ -11,7 +11,7 @@ export default Object.freeze({
11
11
  "params": []
12
12
  },
13
13
  {
14
- "name": "pair",
14
+ "name": "connectAccount",
15
15
  "stream": false,
16
16
  "params": [
17
17
  {
@@ -20,13 +20,6 @@ export default Object.freeze({
20
20
  "schema": {
21
21
  "type": "string"
22
22
  }
23
- },
24
- {
25
- "name": "code",
26
- "optional": false,
27
- "schema": {
28
- "type": "string"
29
- }
30
23
  }
31
24
  ]
32
25
  },
package/lib/runner.d.ts CHANGED
@@ -1,10 +1,13 @@
1
1
  import type { ComputerStatus, Connection } from './types.ts';
2
2
  import type { ChatPort } from './chats.ts';
3
- export interface RunnerRequest {
4
- type: 'status' | 'pair' | 'permissions' | 'run';
5
- server?: string;
6
- code?: string;
7
- }
3
+ export type RunnerRequest = {
4
+ type: 'status' | 'permissions' | 'run';
5
+ } | {
6
+ type: 'enroll';
7
+ server: string;
8
+ token: string;
9
+ name: string;
10
+ };
8
11
  export declare function launchRunner(executable: string, state: string, request: RunnerRequest, onConnection?: (status: Connection) => void, chats?: ChatPort): {
9
12
  done: Promise<unknown>;
10
13
  stop(): Promise<void>;
package/lib/runner.js CHANGED
@@ -5,7 +5,7 @@ export function launchRunner(executable, state, request, onConnection = () => {
5
5
  const child = spawn(executable, ['--state-dir', state, 'plugin'], {
6
6
  stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true,
7
7
  });
8
- // Codes go over stdin, never argv, logs or the renderer's persisted preferences.
8
+ // Credentials go over stdin, never argv, logs or the renderer's persisted preferences.
9
9
  child.stdin.on('error', () => { });
10
10
  child.stdin.write(`${JSON.stringify(request)}\n`);
11
11
  if (request.type !== 'run')
@@ -133,7 +133,7 @@ export function launchRunner(executable, state, request, onConnection = () => {
133
133
  }
134
134
  export function computerStatus(value) {
135
135
  const status = value;
136
- if (!status || status.bridge !== 2 || status.protocol !== PROTOCOL || typeof status.platform !== 'string'
136
+ if (!status || status.bridge !== 3 || status.protocol !== PROTOCOL || typeof status.platform !== 'string'
137
137
  || typeof status.arch !== 'string' || !(status.device_id === null || typeof status.device_id === 'string')
138
138
  || !(status.server === null || typeof status.server === 'string') || !status.desktop || typeof status.desktop !== 'object') {
139
139
  throw new Error('The runner does not support this plugin. Download the current runner from the gateway.');
package/lib/runner.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AASxC,MAAM,UAAU,YAAY,CAAC,UAAkB,EAAE,KAAa,EAAE,OAAsB,EACpF,eAA6C,GAAG,EAAE,GAAE,CAAC,EAAE,KAAgB;IACvE,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC,aAAa,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE;QAChE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI;KACnD,CAAC,CAAA;IACF,iFAAiF;IACjF,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;IACjC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACjD,IAAI,OAAO,CAAC,IAAI,KAAK,KAAK;QAAE,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,CAAA;IAC7C,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAA;IACrB,IAAI,KAAc,CAAA;IAClB,IAAI,QAAQ,GAAG,KAAK,CAAA;IACpB,IAAI,OAA0B,CAAA;IAC9B,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,MAAM,MAAM,GAAG,IAAI,GAA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,KAAK,QAAQ;WACpG,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,KAAK,IAAI,IAAI,OAAO,MAAM,CAAC,SAAS,KAAK,QAAQ,CAAC;WACvG,CAAC,CAAC,MAAM,CAAC,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC7H,MAAM,IAAI,KAAK,CAAC,wFAAwF,CAAC,CAAA;IAC3G,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ftai/ftai-plugin-ft-bot",
3
- "version": "0.1.0",
3
+ "version": "0.4.0",
4
4
  "description": "Local computer access for Ft Bot.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -34,11 +34,6 @@
34
34
  ]
35
35
  }
36
36
  },
37
- "scripts": {
38
- "build": "tsc -p tsconfig.json && ftai-plugin-remote && tsc -p tsconfig.client.json && vite build",
39
- "test": "node --test tests/*.test.mjs",
40
- "test:integration": "node --test tests/integration.mjs"
41
- },
42
37
  "devDependencies": {
43
38
  "@ftai/plugin-sdk": "2.0.0",
44
39
  "@tabler/icons-react": "3.46.0",
@@ -54,5 +49,13 @@
54
49
  },
55
50
  "engines": {
56
51
  "node": ">=22.12"
52
+ },
53
+ "dependencies": {
54
+ "fflate": "^0.8.3"
55
+ },
56
+ "scripts": {
57
+ "build": "tsc -p tsconfig.json && ftai-plugin-remote && tsc -p tsconfig.client.json && vite build",
58
+ "test": "node --test tests/*.test.mjs",
59
+ "test:integration": "node --test tests/integration.mjs"
57
60
  }
58
- }
61
+ }