# Hello, in five languages

Each folder under `hello/` is one complete extension that registers a tool named
`hello`. Ask octet to say hello to someone and the model gets `Hello, <name>!`.

All five were built and run against octet v0.10.0 (a source build) on Linux x86_64,
through the real host with a scripted model. The names tried were `octet` and
`Ada "Lovelace" \ ☃ café`. macOS and Windows were not tested.

Every extension is a folder with an `extension.toml` manifest and an entrypoint. Put
the folders in one directory and start octet with:

```sh
octet --extension-dir /absolute/path/to/my-extensions --enable-extension hello-python
```

Use `hello-typescript`, `hello-rust`, `hello-cpp` or `hello-perl` for the others. The
manifests ask for no filesystem, process or network access. That is consent metadata for
the host, not an OS sandbox: an extension runs with your permissions, so read one before
you enable it.

`/absolute/path/to/octet` below means your octet source checkout, where the SDKs live.

## Python

Save `python/extension.py` and `python/extension.toml` in a folder named `hello-python`.
In the manifest, set `args` to the saved `extension.py` and `PYTHONPATH` to
`/absolute/path/to/octet/sdk/python`. The Python SDK has no dependencies.

## TypeScript

Save `typescript/extension.ts` in a folder named `hello-typescript`. Needs Node 22.19 or
newer. From that folder:

```sh
npm init --yes
npm pkg set type=module
npm pack /absolute/path/to/octet/sdk/typescript/process --pack-destination . --ignore-scripts
npm install --offline --ignore-scripts ./skaft-software-octet-extension-sdk-*.tgz
./node_modules/.bin/octet-extension manifest extension.ts --name hello-typescript --version 0.1.0 --out extension.toml
```

The command writes the manifest and a launcher. Regenerate them if you move the folder.

## Rust

Save `rust/main.rs` and `rust/Cargo.toml`, and set the `octet-extension` path in
`Cargo.toml` to `/absolute/path/to/octet/sdk/rust`. Run `cargo build`. Save
`rust/extension.toml` in a folder named `hello-rust` and set `command` to the built
`target/debug/hello-rust`.

## C++

The C++ header wraps the same runtime as the Rust SDK, so build that runtime library
first, then compile and link `cpp/main.cpp`:

```sh
cargo build --manifest-path /absolute/path/to/octet/sdk/rust/Cargo.toml --lib
g++ -std=c++17 -I/absolute/path/to/octet/sdk/c/include -I/absolute/path/to/octet/sdk/cpp/include \
  main.cpp /absolute/path/to/octet/sdk/rust/target/debug/liboctet_extension.a \
  -lpthread -ldl -lm -lrt -lutil -o hello-cpp
```

Those link flags are for Linux. Save `cpp/extension.toml` in a folder named `hello-cpp` and
set `command` to the built `hello-cpp`. There is also a plain C interface in
`sdk/c`.

## Perl, with no SDK

An extension is a process that reads JSON requests, one per line, on stdin and writes
responses on stdout. `perl/extension.pl` does that with Perl's core `JSON::PP` and speaks
the simplest protocol version, API 0.1. Save it and `perl/extension.toml` in a folder named
`hello-perl` and set `args` to the saved `extension.pl`. Any language that can read and
write lines of JSON can do the same; the other four just use an SDK for the plumbing.
