Appearance
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
| Service | Example | Description |
|---|---|---|
getPoeApiKey | call("getPoeApiKey", {}) | Get the current user's API key |
systemTools.list | call("systemTools.list", {}) | List tools the LLM can call |
systemTools.call | call("systemTools.call", { toolName, toolInput }) | Execute a tool |
env.get | call("env.get", {}) | Get environment variables |
store.callAction | call("store.callAction", { storeTypeId, storeInstanceId, actionName, actionInput }) | Call an action on another store |
store.getSchema | call("store.getSchema", { storeTypeId }) | Get another store's schema |
blob.put | call("blob.put", { content: btoa("hello") }) | Store content (base64) |
blob.get | call("blob.get", { hash }) | Retrieve stored content |
blob.has | call("blob.has", { hash }) | Check if a blob exists |
apps.publish | call("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(),
});