@agent-os-lab/agent-game-runtime-sdk
v0.1.4
Published
Transport and Presence APIs for AgentOS game integrations. This independently installable package contains no game-specific configuration, persistence, or rendering behavior.
Readme
Agent Game Runtime SDK
Transport and Presence APIs for AgentOS game integrations. This independently installable package contains no game-specific configuration, persistence, or rendering behavior.
bun add @agent-os-lab/agent-game-runtime-sdkRuntime owns only token exchange, WebSocket messages, neutral AgentPresence data, and Presence list helpers.
A single Runtime connection provides one Presence stream that can feed multiple games: the application maps each neutral record into each game's input contract. It neither knows which games consume the stream nor owns, loads, saves, or persists Office configuration.
Browser client
Browser code calls a same-origin BFF at /api/agent-game-runtime-token by default.
import { AgentGameRuntimeBrowserClient, subscribeAgentPresenceList } from "@agent-os-lab/agent-game-runtime-sdk";
const client = new AgentGameRuntimeBrowserClient({
baseUrl: "",
subtenantId: "workspace-a",
accessToken: async () => getApplicationSessionToken(),
});
const presence = await subscribeAgentPresenceList(client, {
onAgentsChange(agents) {
officeGame.update(agents.map(mapPresenceToOfficeInput));
strategyGame.update(agents.map(mapPresenceToStrategyInput));
},
});
presence.refresh();
presence.close();The names above are application pseudocode, not imports from a concrete Game package. accessToken authenticates the browser request to the BFF; it is not the short-lived WebSocket token. The BFF determines tenant scope from trusted authentication.
Trusted server client
import { AgentGameRuntimeServerClient } from "@agent-os-lab/agent-game-runtime-sdk";
const client = new AgentGameRuntimeServerClient({
baseUrl: process.env.AGENT_GAME_RUNTIME_BASE_URL!,
apiKey: process.env.AGENTOS_API_KEY!,
subtenantId: process.env.AGENTOS_SUBTENANT_ID,
});Keep apiKey on the server. The default service token path is /api/v1/game-runtime-token. See USAGE.md for token, scope, message, and lifecycle details.
