Bedrock Engineer を Windows 用にビルドする

# はじめに

[Bedrock Engineer は AWS Japan の SA が開発した Amazon Bedrock を活用した AI アシスタントです。](https://github.com/aws-samples/bedrock-engineer/blob/main/README-ja.md) 大規模な言語モデルと実際のファイルシステム操作、Web検索などを含む機能が実装されており、ソフトウェア開発、調査、検索といったタスクに利用できます。

Mac、Windows、Linux のネイティブアプリで利用できます。Mac は直接ダウンロードできますが、Windows で利用する場合はビルドが必要です。WSL2 などの Linux 環境でビルドを行い、インストーラーの exe を利用して手元の Windows で活用できます。

ビルド、インストール、利用の手順を紹介します。



# Windows 用にビルド

Bedrock Engineer の GitHub Repository を clone します。

```
git clone https://github.com/aws-samples/bedrock-engineer.git
```



clone したディレクトリに移動します。

```
bedrock-engineer.git
```



Windows 用にビルドしますが、後述のエラーが発生します。(Google 検索にひっかかりやすいように、以下の Error メッセージを記載します。)

```
npm install
npm run build:win
```



こんなエラーメッセージです。

```
  ⨯ wine is required, please see https://electron.build/multi-platform-build#linux  
  ⨯ /home/ec2-user/workdir/git/bedrock-engineer/node_modules/app-builder-bin/linux/x64/app-builder process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:
1  failedTask=build stackTrace=Error: /home/ec2-user/workdir/git/bedrock-engineer/node_modules/app-builder-bin/linux/x64/app-builder process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:
1
    at ChildProcess.<anonymous> (/home/ec2-user/workdir/git/bedrock-engineer/node_modules/builder-util/src/util.ts:252:14)
    at Object.onceWrapper (node:events:632:26)
    at ChildProcess.emit (node:events:517:28)
    at maybeClose (node:internal/child_process:1098:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:303:5)
From previous event:
    at processImmediate (node:internal/timers:476:21)
From previous event:
    at WinPackager.signApp (/home/ec2-user/workdir/git/bedrock-engineer/node_modules/app-builder-lib/src/winPackager.ts:384:27)
    at WinPackager.doSignAfterPack (/home/ec2-user/workdir/git/bedrock-engineer/node_modules/app-builder-lib/src/platformPackager.ts:336:32)
    at WinPackager.doPack (/home/ec2-user/workdir/git/bedrock-engineer/node_modules/app-builder-lib/src/platformPackager.ts:321:7)
    at WinPackager.pack (/home/ec2-user/workdir/git/bedrock-engineer/node_modules/app-builder-lib/src/platformPackager.ts:140:5)
    at Packager.doBuild (/home/ec2-user/workdir/git/bedrock-engineer/node_modules/app-builder-lib/src/packager.ts:445:9)
    at executeFinally (/home/ec2-user/workdir/git/bedrock-engineer/node_modules/builder-util/src/promise.ts:12:14)
    at Packager._build (/home/ec2-user/workdir/git/bedrock-engineer/node_modules/app-builder-lib/src/packager.ts:379:31)
    at Packager.build (/home/ec2-user/workdir/git/bedrock-engineer/node_modules/app-builder-lib/src/packager.ts:340:12)
    at executeFinally (/home/ec2-user/workdir/git/bedrock-engineer/node_modules/builder-util/src/promise.ts:12:14)
```



[Wine という名前の Linux で Windows アプリを動作させるためのプログラム](https://gitlab.winehq.org/wine/wine) が Build に必要というエラーです。ビルド環境にインストールしてもいいんですが、インストールが手間なので、[コンテナイメージでビルド](https://www.electron.build/multi-platform-build#docker)します。`electronuserland/builder:wine` という wine がインストールされているイメージが公開されています。

以下のコマンドで、wine が導入されているコンテナイメージを起動して、ターミナル対話モードで実行します。-v オプションでローカルディレクトリ (Bedrock Engineer のディレクトリ) を /project にマウントを指定しています。

```
docker run --rm -ti \
 --env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS_TAG|TRAVIS|TRAVIS_REPO_|TRAVIS_BUILD_|TRAVIS_BRANCH|TRAVIS_PULL_REQUEST_|APPVEYOR_|CSC_|GH_|GITHUB_|BT_|AWS_|STRIP|BUILD_') \
 --env ELECTRON_CACHE="/root/.cache/electron" \
 --env ELECTRON_BUILDER_CACHE="/root/.cache/electron-builder" \
 -v ${PWD}:/project \
 -v ${PWD##*/}-node-modules:/project/node_modules \
 -v ~/.cache/electron:/root/.cache/electron \
 -v ~/.cache/electron-builder:/root/.cache/electron-builder \
 electronuserland/builder:wine
```



実行例 : コンテナイメージ上で対話用のターミナルが動作しています。

```
$ docker run --rm -ti \
 --env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS_TAG|TRAVIS|TRAVIS_REPO_|TRAVIS_BUILD_|TRAVIS_BRANCH|TRAVIS_PULL_REQUEST_|APPVEYOR_|CSC_|GH_|GITHUB_|BT_|AWS_|STRIP|BUILD_') \
 --env ELECTRON_CACHE="/root/.cache/electron" \
 --env ELECTRON_BUILDER_CACHE="/root/.cache/electron-builder" \
 -v ${PWD}:/project \
 -v ${PWD##*/}-node-modules:/project/node_modules \
 -v ~/.cache/electron:/root/.cache/electron \
 -v ~/.cache/electron-builder:/root/.cache/electron-builder \
 electronuserland/builder:wine
root@527fd38e9f76:/project# 
```



コンテナの中身はこんな感じです。

```
root@527fd38e9f76:/project# pwd
/project
root@527fd38e9f76:/project# 
root@527fd38e9f76:/project# ls -la
total 1232
drwxr-xr-x. 12 1000 1000   16384 Apr 29 03:42 .
drwxr-xr-x.  1 root root      18 Apr 29 03:55 ..
drwxr-xr-x.  3 1000 1000      20 Apr 29 03:40 .bedrock-engineer
-rw-r--r--.  1 1000 1000     154 Apr 29 03:40 .editorconfig
-rw-r--r--.  1 1000 1000     344 Apr 29 03:40 .env.example
-rw-r--r--.  1 1000 1000      33 Apr 29 03:40 .eslintignore
-rw-r--r--.  1 1000 1000     643 Apr 29 03:40 .eslintrc.cjs
drwxr-xr-x.  8 1000 1000     163 Apr 29 03:41 .git
drwxr-xr-x.  4 1000 1000      45 Apr 29 03:40 .github
-rw-r--r--.  1 1000 1000      71 Apr 29 03:40 .gitignore
-rw-r--r--.  1 1000 1000      65 Apr 29 03:40 .prettierignore
-rw-r--r--.  1 1000 1000      66 Apr 29 03:40 .prettierrc.yaml
drwxr-xr-x.  2 1000 1000      69 Apr 29 03:40 .vscode
-rw-r--r--.  1 1000 1000     309 Apr 29 03:40 CODE_OF_CONDUCT.md
-rw-r--r--.  1 1000 1000    3296 Apr 29 03:40 CONTRIBUTING.md
-rw-r--r--.  1 1000 1000     947 Apr 29 03:40 LICENSE
-rw-r--r--.  1 1000 1000   21182 Apr 29 03:40 README-ja.md
-rw-r--r--.  1 1000 1000   17083 Apr 29 03:40 README.md
drwxr-xr-x.  2 1000 1000   16384 Apr 29 03:40 assets
drwxr-xr-x.  3 1000 1000      95 Apr 29 03:40 build
-rw-r--r--.  1 1000 1000     102 Apr 29 03:40 dev-app-update.yml
drwxr-xr-x.  3 1000 1000      88 Apr 29 03:43 dist
-rw-r--r--.  1 1000 1000    1466 Apr 29 03:40 electron-builder.yml
-rw-r--r--.  1 1000 1000     806 Apr 29 03:40 electron.vite.config.ts
-rw-r--r--.  1 1000 1000     342 Apr 29 03:40 jest.config.js
-rw-r--r--.  1 1000 1000     457 Apr 29 03:40 jest.integration.config.js
-rw-r--r--.  1 1000 1000     412 Apr 29 03:40 jest.integration.setup.js
drwxr-xr-x.  2 root root       6 Apr 29 03:54 node_modules
drwxr-xr-x.  5 1000 1000      49 Apr 29 03:42 out
-rw-r--r--.  1 1000 1000 1085732 Apr 29 03:41 package-lock.json
-rw-r--r--.  1 1000 1000    4483 Apr 29 03:40 package.json
drwxr-xr-x.  8 1000 1000      88 Apr 29 03:40 src
-rw-r--r--.  1 1000 1000     831 Apr 29 03:40 tailwind.config.js
-rw-r--r--.  1 1000 1000     171 Apr 29 03:40 tsconfig.json
-rw-r--r--.  1 1000 1000     312 Apr 29 03:40 tsconfig.node.json
-rw-r--r--.  1 1000 1000     251 Apr 29 03:40 tsconfig.test.json
-rw-r--r--.  1 1000 1000     472 Apr 29 03:40 tsconfig.web.json
```



npm install で依存関係を解決します。

```
npm install
```



Windows 用に build を行います。

```
npm run build:win
```



実行例

```
root@527fd38e9f76:/project# npm run build:win

> bedrock-engineer@1.8.2 build:win
> npm run build && electron-builder --win


> bedrock-engineer@1.8.2 build
> npm run typecheck && electron-vite build


> bedrock-engineer@1.8.2 typecheck
> npm run typecheck:node && npm run typecheck:web


> bedrock-engineer@1.8.2 typecheck:node
> tsc --noEmit -p tsconfig.node.json --composite false


> bedrock-engineer@1.8.2 typecheck:web
> tsc --noEmit -p tsconfig.web.json --composite false

vite v6.2.6 building SSR bundle for production...
✓ 25 modules transformed.
out/main/chunks/icon-BBVBlp6x.ico  367.81 kB
out/main/index.js                  154.18 kB
✓ built in 378ms
vite v6.2.6 building SSR bundle for production...
✓ 37 modules transformed.
out/preload/index.js  216.00 kB
✓ built in 348ms
vite v6.2.6 building for production...
node_modules/lottie-web/build/player/lottie.js (17010:32): Use of eval in "node_modules/lottie-web/build/player/lottie.js" is strongly discouraged as it poses security risks and may cause issues with minification.
✓ 4451 modules transformed.
../../out/renderer/index.html                                           0.56 kB
../../out/renderer/assets/index-Dxjo5_yx.css                          169.65 kB
../../out/renderer/assets/clone-DFwBy8Z7.js                             0.18 kB
../../out/renderer/assets/channel-BQV46iu5.js                           0.19 kB
../../out/renderer/assets/init-ZxktEp_H.js                              0.26 kB
../../out/renderer/assets/chunk-OQCM5LHU-CxHM2lOK.js                    0.36 kB
../../out/renderer/assets/chunk-2RYQ3QTB-CDhqR9cX.js                    0.37 kB
../../out/renderer/assets/stateDiagram-v2-KR4XTQLW-DF3IusmR.js          0.65 kB
../../out/renderer/assets/infoDiagram-YGJTP6AA-x2TJ6JFu.js              1.05 kB
../../out/renderer/assets/json-xZIzGcYy.js                              1.12 kB
../../out/renderer/assets/base-80a1f760-D1YFJys_.js                     1.21 kB
../../out/renderer/assets/chunk-WZBIATSK-CpvEsdGz.js                    1.48 kB
../../out/renderer/assets/ordinal-DSZU4PqD.js                           2.18 kB
../../out/renderer/assets/chunk-XVOYOM2C-BNIoInf2.js                    3.14 kB
../../out/renderer/assets/_basePickBy-COXUUIR_.js                       6.04 kB
../../out/renderer/assets/diagram-QS5GVLUX-BLpO8uNI.js                  6.56 kB
../../out/renderer/assets/arc-CyQAwFNI.js                               6.94 kB
../../out/renderer/assets/pieDiagram-OZX6XH5M-oJG3k2g2.js               9.09 kB
../../out/renderer/assets/graph-DPaJQt8E.js                            10.77 kB
../../out/renderer/assets/classDiagram-4BHYIK4I-DiYCByBp.js            15.29 kB
../../out/renderer/assets/stateDiagram-WG76EWPK-njGIY6Zd.js            19.63 kB
../../out/renderer/assets/linear-PXTxVqZI.js                           20.19 kB
../../out/renderer/assets/chunk-MKAIFKW5-CMc1ud-h.js                   20.35 kB
../../out/renderer/assets/dagre-C4YA43F3-DaV4b-is.js                   21.54 kB
../../out/renderer/assets/consoleHook-59e792cb-I6Zyk5nx.js             23.52 kB
../../out/renderer/assets/_baseUniq-SkQeyV-D.js                        30.20 kB
../../out/renderer/assets/classDiagram-v2-SPY6V32O-LFRSdTOb.js         32.78 kB
../../out/renderer/assets/journeyDiagram-G5LC7W2K-3f9JnY0o.js          43.00 kB
../../out/renderer/assets/sankeyDiagram-KMMQDL5K-Do_hF_cd.js           43.76 kB
../../out/renderer/assets/timeline-definition-KYQAIZUX-DWV8DWzb.js     45.79 kB
../../out/renderer/assets/requirementDiagram-FPZB6IJI-Cc40Euim.js      46.35 kB
../../out/renderer/assets/chunk-GWHMDDHB-D3Adk5bN.js                   46.43 kB
../../out/renderer/assets/gitGraphDiagram-UL5UFKDR-7A2z-4vf.js         47.60 kB
../../out/renderer/assets/erDiagram-62CBQV5Y-DEwv0urH.js               56.35 kB
../../out/renderer/assets/index-B9TSl8wa.js                            56.51 kB
../../out/renderer/assets/layout-Ba0h0bzl.js                           58.58 kB
../../out/renderer/assets/quadrantDiagram-VG34DGKC-DCtm5ykU.js         61.27 kB
../../out/renderer/assets/chunk-NQF7MJAO-Cs0n9-6A.js                   63.96 kB
../../out/renderer/assets/chunk-BAVOGKFW-BWOrpDSb.js                   65.30 kB
../../out/renderer/assets/blockDiagram-SLEYNUNN-gnkcIQgp.js            67.45 kB
../../out/renderer/assets/xychartDiagram-TMT7NLBN-DlBmMzqw.js          71.03 kB
../../out/renderer/assets/flowDiagram-44NOAMKU-BXeyKSFe.js             91.22 kB
../../out/renderer/assets/c4Diagram-THADGKDP-BOeHnjJH.js              118.56 kB
../../out/renderer/assets/ganttDiagram-ASEIQ4P5-BpG2OW39.js           120.93 kB
../../out/renderer/assets/sequenceDiagram-K7U7U2PU-CiqBomlF.js        150.86 kB
../../out/renderer/assets/index-BSbabn7a.js                           205.92 kB
../../out/renderer/assets/index-599aeaf7-DiKDwdbW.js                  245.28 kB
../../out/renderer/assets/mindmap-definition-26FWEE7H-U8fW-iuH.js     248.49 kB
../../out/renderer/assets/architectureDiagram-WQGLKCSC-DlL-gs6_.js    414.12 kB
../../out/renderer/assets/katex-C-jAQc2m.js                           488.79 kB
../../out/renderer/assets/gitGraph-YCYPL57B-DDJMng7b.js               596.10 kB
../../out/renderer/assets/cytoscape.esm-Ckc4o23s.js                   826.45 kB
../../out/renderer/assets/index-CdVg7XZ6.js                         8,275.87 kB
✓ built in 23.80s
  • electron-builder  version=24.13.3 os=6.1.132-147.221.amzn2023.x86_64
  • loaded configuration  file=/project/electron-builder.yml
  • author is missed in the package.json  appPackageFile=/project/package.json
  • writing effective config  file=dist/builder-effective-config.yaml
  • skipped dependencies rebuild  reason=npmRebuild is set to false
  • packaging       platform=win32 arch=x64 electron=31.0.2 appOutDir=dist/win-unpacked
  • building        target=nsis file=dist/bedrock-engineer-1.8.2-setup.exe archs=x64 oneClick=true perMachine=false
  • downloading     url=https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-3.0.4.1/nsis-3.0.4.1.7z size=1.3 MB parts=1
  • downloaded      url=https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-3.0.4.1/nsis-3.0.4.1.7z duration=1.838s
  • downloading     url=https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-resources-3.4.1/nsis-resources-3.4.1.7z size=731 kB parts=1
  • downloaded      url=https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-resources-3.4.1/nsis-resources-3.4.1.7z duration=1.3s
  • building block map  blockMapFile=dist/bedrock-engineer-1.8.2-setup.exe.blockmap
root@527fd38e9f76:/project# 
```



ホスト側のボリュームをコンテナ環境の `/project` にマウントしているので、ホスト側の `/dist` ディレクトリに Windows 用のインストーラーファイル `bedrock-engineer-1.8.2-setup.exe` が出来ています。166 MB ほどあります。

```
$ ls -la dist/
total 169544
drwxr-xr-x.  3 ec2-user ec2-user     16384 Apr 29 03:59 .
drwxr-xr-x. 12 ec2-user ec2-user     16384 Apr 29 03:56 ..
-rw-r--r--.  1 root     root     173359270 Apr 29 03:59 bedrock-engineer-1.8.2-setup.exe
-rw-r--r--.  1 root     root        182158 Apr 29 03:59 bedrock-engineer-1.8.2-setup.exe.blockmap
-rw-r--r--.  1 ec2-user ec2-user      7556 Apr 29 03:59 builder-debug.yml
-rw-r--r--.  1 ec2-user ec2-user      1537 Apr 29 03:57 builder-effective-config.yaml
-rw-r--r--.  1 root     root           361 Apr 29 03:59 latest.yml
drwxr-xr-x.  4 ec2-user ec2-user     16384 Apr 29 03:57 win-unpacked
```



この exe ファイルを Windows 環境で実行すると、Setup が始まりインストールされます。

![image-20250429141742845.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1002774/4ece9081-58cf-4a31-9d27-18266e6b61c8.png)



Bedrock Engineer が起動しました。

![image-20250429141830717.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1002774/890a546d-9c38-4dea-a1c7-bb78728f8bc9.png)



# Tavily を利用した Web Rearch Agent を入れる

Tavily は、AI エージェント用に設計された検索エンジンおよび検索 API です。Free Plan だと毎月 1000 回の API コールが利用できる無料枠があり、クレジットカードは必要なく利用できます。

Tavily のページで、API Key を確認します。コピーして控えておきます。

![image-20250429154815886.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1002774/914b2b48-6a97-4399-b17a-537e6146c35b.png)



以下の設定画面で API を設定します。

![image-20250429155052133.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1002774/ac8daf3f-0511-4b22-8ca4-39b43310e15b.png)



Agent Directory から Web Deep Researcher を選択します。

![image-20250429150959933.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1002774/d393bf85-d2dc-41c2-b403-eba51f546d1f.png)



Add を押します。

![image-20250429151119157.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1002774/ce4b1acc-bb04-4706-a033-f9781794a78e.png)



Chat の画面で、左上の Agent 選択欄を押します。

![image-20250429151138913.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1002774/3db39600-5127-47f1-993c-00ef039909f8.png)



インストールされている Web Deep Researcher を選択します。

![image-20250429151154736.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1002774/dbee9f5b-f3c9-494f-b97e-1e2828a024c5.png)



以下のような質問をしてみます。

> Redshift Serverless で Reserved Instance 的な割引プランは利用できますか？

![image-20250429155246673.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1002774/e1afb5df-c42f-4c57-8762-8902f972aadd.png)



2025 年 4 月に公開された新しいプランについて教えてくれています。Tavily でしっかり検索できていることがわかります。

![image-20250429155417367.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1002774/96b5a3be-094a-45b8-8f3b-7dd454621968.png)