Skip to main content

Build your first plugin and see it on a chart

You will have a plugin of your own, myplugin, loaded in a headless kernel. It answers a verb, keeps a node and adds an indicator that draws under a chart. The plugin is three files: a manifest, a Python program and a TypeScript script.

You need Taji built from source (Build from source), jq, the network (the keyless kernel reads Yahoo's delayed bars), and Taji's Python, which runs the plugin:

bash engine/crates/taji/scripts/python.sh .python
cargo build -p taji-open

.python is Taji's interpreter with its SDK; TAJI_PYTHON names another. Every command runs from the repository root, in one shell.

1. Write the manifest​

A plugin is a directory holding taji-plugin.toml and its program. The manifest says what the plugin registers, and Taji checks the program against it:

taji-plugin.toml
id = "myplugin"
name = "My plugin"
version = "0.1.0"
taji = ">=0.7, <0.8"

[process]
run = ["myplugin.py"]
python = {}

[[kernel.verbs]]
route = "myplugin/say"
name = "myplugin_say"
description = "Tell my plugin some text: it answers `{said}` and keeps it as its node `myplugin`."
schema = { type = "object", properties = { text = { type = "string" } }, required = ["text"] }
scopes = ["local", "agent", "page"]

[[kernel.nodes]]
path = "myplugin"
description = "the last text my plugin was told"

[[kernel.indicators]]
name = "bar_range"
source = "indicators/bar_range.ts"
  1. id, name, version, taji name the plugin and the contract range it speaks; this build's contract is 0.7.0.
  2. [process] makes it a process plugin: run is the program, and python = {} gives it the standard library and the SDK. { lock = "requirements.lock" } instead adds exactly the hashed wheels a lock file lists.
  3. [[kernel.verbs]] declares myplugin/say, a call with a JSON Schema for its arguments, open to the local, agent and page tokens.
  4. [[kernel.nodes]] declares myplugin, state the plugin sets and anyone reads at GET /read/myplugin.
  5. [[kernel.indicators]] adds a script indicator, bar_range, to the chart's catalog. source is a path inside the plugin's directory.

The fields are all in the manifest reference.

2. Write the program​

The program registers exactly the verbs the manifest declares; the SDK refuses to start otherwise:

myplugin.py
import taji

p = taji.plugin()


@p.verb("myplugin/say")
def say(args, bindings):
text = args.get("text")
if not isinstance(text, str):
raise taji.Refused(400, "bad_args", "`text` is a string")
p.set("myplugin", {"text": text})
return {"said": text}


p.run()
  1. taji.plugin() reads the manifest beside the program.
  2. @p.verb("myplugin/say") handles the verb. A plain function runs on a thread; an async def works too.
  3. taji.Refused answers its own status and error. Any other exception answers 500 python, its traceback in the plugin's log, except one whose class is named RateLimited, which answers 429 rate_limited.
  4. p.set sets the node, and the return value is the answer.
  5. p.run() speaks taji-plugin/1, JSON lines on stdio, until the kernel stops it. print goes to the plugin's log, never to the protocol.
  • The SDK's API is documented in packages/taji-py/src/taji/__init__.py, including how to test a plugin with no kernel: plugins/pyecho/test_pyecho.py calls p.handle with one line the kernel would send.
  • plugins/echo is the same plugin in Rust: plugins/echo/src/main.rs calls taji_sdk::serve with its manifest.

3. Add the indicator​

The script is one module whose default export is indicator({…}) from @taji/indicators, as in your first indicator. Bar range plots each bar's high-to-low range as a percent of its close, and a 20-bar average of it:

indicators/bar_range.ts
import { indicator, input, plot, ta } from "@taji/indicators";

export default indicator({
name: "Bar range",
pane: "own",
inputs: { length: input.int(20, { min: 2 }) },
plots: { range: plot.columns({ title: "Range %" }), avg: plot.line({ title: "Average", color: "#ff9800" }) },
setup: ({ inputs }) => ({ avg: ta.sma(inputs.length) }),
next(bar, s) {
const range = ((bar.high - bar.low) / bar.close) * 100;
return { range, avg: s.avg.next(range) };
},
});
  1. pane: "own" draws it in a pane under the price.
  2. plots are a column per bar and an orange line.
  3. next runs once per bar and returns one number per plot.
  • The kernel compiles and runs the script on its own lane, never in your plugin's process.
  • The manifest row's name is the catalog name, so a chart binds it as bar_range.

4. Boot a kernel with your plugin​

Copy the plugin into a plugins directory, then boot a headless kernel on throwaway state with TAJI_PLUGINS naming that directory. TAJI_WIRE=0 takes a free port. get and v call the wire, which authenticates every request by x-taji-token:

W=$(mktemp -d)
mkdir -p "$W/plugins" && cp -R docs/plugins/examples/first-plugin/myplugin "$W/plugins/"
boot() {
mkdir -p "$W/state" "$W/store" "$W/home"
export TAJI_NO_UPDATE_CHECK=1 TAJI_NO_REPORT=1 TAJI_STATE_DIR=$W/state TAJI_STORE_DIR=$W/store TAJI_HOME=$W/home
TAJI_PLUGINS=$W/plugins TAJI_HEADLESS=1 TAJI_WIRE=0 target/debug/taji > "$W/boot.log" 2>&1 &
until [ -s "$W/state/wire-token" ] && curl -sf -o /dev/null -H "x-taji-token: $(cat "$W/state/wire-token")" "localhost:$(cat "$W/state/wire-port")/"; do sleep 1; done
PORT=$(cat "$W/state/wire-port"); TOKEN=$(cat "$W/state/wire-token")
}
get() { curl -s -H "x-taji-token: $TOKEN" "localhost:$PORT/$1"; echo; }
v() { curl -s -H "x-taji-token: $TOKEN" -H 'content-type: application/json' -X POST "localhost:$PORT/verb/$1" --data-binary "$2"; echo; }
boot
get read/plugins | jq '.[] | select(.id == "myplugin") | {enabled, source, sandbox, indicators}'

You see your plugin's row: enabled is true, source is dev (a TAJI_PLUGINS plugin), sandbox names the confinement it runs under (seatbelt on macOS, bubblewrap on Linux, processcontainer on Windows), and indicators is ["bar_range"].

  • The kernel checked the manifest and compiled the script at boot. The program has not started yet: a process plugin starts at its first call.

5. Call the verb and read the node​

v myplugin/say '{"text":"hello"}'
get read/myplugin

You see the verb's answer, then the node:

{
"said": "hello"
}
{
"text": "hello"
}

Captured 2026-12-04 on a headless kernel.

  • Your program started, answered {"said": "hello"} and set its node. Its log is $W/state/plugins/myplugin/log.
  • Your agent finds the same verb over MCP through describe, and may call it because the manifest opens it to the agent token.

6. Draw the indicator on the chart​

The kernel opens a desk with a daily chart of equity:SPY; pane 1 is that chart. Bind bar_range to it:

DESK=$(get "" | jq -r .active)
v desk/$DESK/chart/1/add_indicator '{"pane_id":1,"definition":"bar_range","params":{}}'

You see the binding's node, whose last segment is its id, and seq, the number of the /ws/live frame that carries the change:

{
"node": "desk/01a24253-67b5-70b2-b759-8b7f233f1e79/chart/indicators/01a24253-6a01-7702-b21e-26c8cac4b15f",
"seq": 1796409091864211
}

The window, were it open, now draws Bar range in its own pane under SPY:

A daily SPY chart with a Bar range pane under it: a blue column per bar for its range as a percent of the close, and an orange 20-bar average line

Captured 2026-12-04 on a headless kernel reading a made-up daily series for SPY.

  • params: {} takes the defaults, so the legend reads Bar range 20.
  • The binding names the bare bar_range, so it follows your plugin's script.

7. Stop the kernel​

v ui/quit '{}'
wait
rm -rf "$W"
  • The kernel stops your plugin's process with it.

If something goes wrong​

  • boot never returns. The kernel did not start: read $W/boot.log, and check that target/debug/taji exists.
  • Your row reads enabled: false. Taji refused the plugin, and reason says why: a source that is absolute, climbs out with .. or is missing, a script that does not compile, or an indicator name another plugin registers. A manifest that does not parse gets no row at all; its error is in $W/state/taji.log.
  • reason starts no sandbox:. This machine lacks the confinement Taji needs. A debug kernel started with TAJI_UNSANDBOXED=1 runs plugins unconfined; a release kernel ignores it.
  • A verb answers unknown_route. The kernel seated no plugin with that route: read the row's reason.
  • A verb answers 500 python. Your program raised: the traceback is in $W/state/plugins/myplugin/log.

Next​