24 lines
1.1 KiB
TypeScript
24 lines
1.1 KiB
TypeScript
/**
|
|
* Hello-World example plugin source.
|
|
*
|
|
* Plugin authors write TypeScript / AssemblyScript / Rust against the
|
|
* `@toolctrl/plugin-sdk` types, then compile to a single `.wasm` binary
|
|
* with their toolchain of choice (wasm-pack, AssemblyScript's `asc`,
|
|
* etc.). The host runtime treats the .wasm as opaque — only its
|
|
* exports (`handleHello` here) and the `plugin.toml` manifest matter.
|
|
*
|
|
* Building this file to WASM is intentionally outside the scope of
|
|
* the foundation: the `toolctrl plugin build` CLI is deferred (see
|
|
* `docs/improvement-plan/06-plugin-system/wasm-sandbox.md` Deviations).
|
|
* Operators wanting a working hello-world today can hand-compile via
|
|
* AssemblyScript or use any other WASM toolchain that produces a flat
|
|
* function export — the runtime contract is just `(arg) -> result`.
|
|
*/
|
|
|
|
import { defineHook } from "../../src/index.js";
|
|
|
|
export const handleHello = defineHook<{ name: string }, { greeting: string }>((input, ctx) => {
|
|
ctx.log.info({ name: input.name }, "hello-plugin.invoked");
|
|
return { greeting: `Hello, ${input.name}!` };
|
|
});
|