Skip to content

SDK API Reference

パッケージ@consenger/[email protected]
Protocolcompanion.plugin.v1
実行環境Browser
状態公開 alpha

API

API用途
createCompanionSDK(options)SDK instance を作成します。game では transport: "auto" を使います。
context(name, definition)companion が読める game state を登録します。
command(name, definition)companion が依頼できる game-owned action を登録します。
observe(type, data, options)通常の gameplay fact を host に報告します。
signal(type, definition)companion に注目してほしい rare moment を定義します。
status()SDK version、protocol、transport、host connection state を返します。
isHostConnected()host initialization 後に true を返します。

Context

ts
companion.context("scene.current", {
  description: "Current scene and objective",
  read: () => ({ scene: "market", objective: "Ask for water" })
});

read が返す値は prompt-visible です。token、hidden answer、private note は含めないでください。

Command

ts
companion.command("dialogue.repeat", {
  title: "Repeat line",
  inputSchema: { type: "object", properties: {}, additionalProperties: false },
  handler: () => ({ ok: true })
});

Command は小さく、player に見える effect にしてください。