Skip to content

Platform Capabilities

Platform capabilities are server-side services available in actions via ctx.platform.call(). They provide AI, blob storage, env vars, and cross-store calls.

Platform capabilities are only available in actions, not mutators. Mutators run on both client and server, so they can't access server-only services. If you need an AI call or external API triggered by a client interaction, use a mutator to create a placeholder, then ctx.enqueueAction(...) to do the server-only work.

Available Services

ServiceExampleDescription
poe.botStream.opencall("poe.botStream.open", { botName, queryRequest })Open a trusted Poe Bot API stream without exposing API keys to app code
systemTools.listcall("systemTools.list", {})List tools the LLM can call
systemTools.callcall("systemTools.call", { toolName, toolInput })Execute a tool
env.getcall("env.get", {})Get environment variables
store.callActioncall("store.callAction", { storeTypeId, storeInstanceId, actionName, actionInput })Call an action on another store
store.getSchemacall("store.getSchema", { storeTypeId })Get another store's schema
blob.putcall("blob.put", { content: btoa("hello") })Store content (base64)
blob.getcall("blob.get", { hash })Retrieve stored content
blob.hascall("blob.has", { hash })Check if a blob exists
apps.publishcall("apps.publish", { handle, files })Publish an app from inline file contents (files is Record<string, string>, must include index.html)
setSpaceTitlecall("setSpaceTitle", { title: "Alice vs Bob" })Set the user-facing title of the current app instance (null clears the rename). Fans out to every member's manager.

Usage in an Action

typescript
import type { InferActionHandlers, PlatformCaller } from "poe-tiles-sdk/v1/backend.js";

type TodoActions = InferActionHandlers<typeof todoSchema, PlatformCaller>;

const actions: TodoActions = {
  generateWithAI: async (ctx, input) => {
    const stream = await ctx.platform.call("poe.botStream.open", {
      botName: "GPT-4o-mini",
      queryRequest: {
        version: "1.0",
        type: "query",
        query: [{ role: "user", content: input.prompt }],
        user_id: "",
        conversation_id: crypto.randomUUID(),
        message_id: crypto.randomUUID(),
      },
    });
    await stream.cancel(); // parse the stream in real AI-driven actions
    const { hash } = await ctx.platform.call("blob.put", { content: btoa("cached result") });
    // ...
  },
};

Pass PlatformCaller as the second type parameter to InferActionHandlers for full autocomplete on ctx.platform.call().

Testing

typescript
import { createMockPlatformCaller } from "poe-tiles-sdk/v1/test-utils.js";

// Unit tests
const runner = createLocalStoreFunctionRunner({
  ...myBackendConfig,
  createPlatformCaller: () => createMockPlatformCaller(),
});

// E2E tests
const server = new TestServer({
  createPlatformCaller: () => createMockPlatformCaller(),
});