---
title: サンプル
description: ビルドしてそのまま使えるサンプルの Package。
---

[subako-function-examples](https://github.com/subako-ai/subako-function-examples) には、完成した Package がまとめてあります。どれも独立したプロジェクトで、Subako にアップロードできる Bundle をビルドします。自分の Package を作るときの出発点にちょうどよく、ほとんどはそのまま Grant しても役に立ちます。[クイックスタート](/ja/functions/quickstart)では anydoc をビルドして付与します。

## Rust

どれも Rust テンプレートをもとに、[subako-function-sdk](/ja/functions/rust) で書かれています。

| サンプル | Tool | 内容 |
| --- | --- | --- |
| [anydoc](https://github.com/subako-ai/subako-function-examples/tree/main/rust/anydoc) | `convert_to_markdown` | Volume にある Word、PowerPoint、Excel、OpenDocument、RTF、EPUB、CSV、テキストベースの PDF ファイルを Markdown に変換します。 |
| [python](https://github.com/subako-ai/subako-function-examples/tree/main/rust/python) | `run_python` | WebAssembly にコンパイルした CPython で、Python のコードやスクリプトを実行します。`urllib.request` で HTTPS 通信ができ、pygal でグラフを描けます。 |
| [bashkit](https://github.com/subako-ai/subako-function-examples/tree/main/rust/bashkit) | `run_bash` | bash スクリプトを実行します。パイプ、約 145 個の組み込みコマンド、Volume のファイル、機能を絞った `curl` が使えます。 |
| [typst](https://github.com/subako-ai/subako-function-examples/tree/main/rust/typst) | `render_pdf` | Package の Asset に含まれるテンプレートを使って、Typst や Markdown を PDF に組版します。 |
| [quickjs](https://github.com/subako-ai/subako-function-examples/tree/main/rust/quickjs) | `run_javascript` | QuickJS で JavaScript を実行します。`fetch` と Volume のファイルが使えます。 |
| [pptx](https://github.com/subako-ai/subako-function-examples/tree/main/rust/pptx) | `create_pptx` | PptxGenJS を使って、JavaScript から PowerPoint のスライドを作ります。 |
| [html](https://github.com/subako-ai/subako-function-examples/tree/main/rust/html) | `render_html` | HTML を PNG に描画します。Agent は自分で書いた HTML のレイアウトを確認できます。viewport からはみ出した要素も示されます。 |
| [github](https://github.com/subako-ai/subako-function-examples/tree/main/rust/github) | `github_api`、`read_file`、… | GitHub の情報を読み取ります。読み取り専用の任意の REST パス、ファイルとディレクトリを扱え、リポジトリ全体を Volume にダウンロードすることもできます。必要なら Vault のトークンを使えます。 |

```bash
cd rust/anydoc
cargo test
./package.sh                      # dist/<name>.tar.gz
```

## Go

Go テンプレートをもとに、[subako-function-sdk-go](/ja/functions/go) で書かれています。

| サンプル | Tool | 内容 |
| --- | --- | --- |
| [xlsx](https://github.com/subako-ai/subako-function-examples/tree/main/go/xlsx) | `create_xlsx`、`read_xlsx` | 数式、固定したヘッダー行、列幅、数値の書式を含む Excel のワークブックを Volume に書き出します。読み込むときは数式を計算した状態で返します。 |

```bash
cd go/xlsx
go test ./...
bash package.sh                   # dist/xlsx.tar.gz
```

## SDK のリポジトリにあるサンプル

各 SDK のリポジトリにも、GitHub を使うサンプルがあります。リポジトリのスターと issue を取得し、オーナーのアバターを Volume に保存してモデルに見せるものです。

- [Go](https://github.com/subako-ai/subako-function-sdk-go/tree/main/examples/github)
- [TypeScript](https://github.com/subako-ai/subako-function-sdk-typescript/tree/main/examples/github)、および[同じ Tool を公式の MCP SDK で書いたもの](https://github.com/subako-ai/subako-function-sdk-typescript/tree/main/examples/github-mcp)

## サンプルを Grant する

ほとんどのサンプルは、**許可** にするだけで使えます。Agent に残させたいファイルがある場合は、**Function に Data (/volume/data) を用意する** もオンにします。ネットワークに接続するもの (python、bashkit、quickjs、github) では、呼び出す Host を Grant の[ネットワーク](/ja/functions/granting#ネットワーク)で許可する必要があります。github は、`https://api.github.com` 向けの [Credential](/ja/functions/granting#credential) を通して Vault からトークンを受け取ります。各サンプルに必要な設定は、それぞれの README に書かれています。
