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
getPoeApiKeycall("getPoeApiKey", {})Get the current user's API key
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)

Usage in an Action

typescript
import type { InferActionHandlers } from "poe-apps-sdk/v1/backend.js";
import type { PlatformCaller } from "@poe/synced-store-platform-caller";

type TodoActions = InferActionHandlers<typeof todoSchema, PlatformCaller>;

const actions: TodoActions = {
  generateWithAI: async (ctx, input) => {
    const { apiKey } = await ctx.platform.call("getPoeApiKey", {});
    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/synced-store-platform-caller-mock-impl";

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

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