docs: clarify actor accept schemas

This commit is contained in:
Ubuntu 2026-06-08 18:46:44 +00:00
parent f475f156d0
commit ba04c18741
6 changed files with 12 additions and 9 deletions

View File

@ -104,7 +104,9 @@ cat > GreeterActor.mjs <<'EOF'
import { MatrixActor } from '@open-matrix/sdk'; import { MatrixActor } from '@open-matrix/sdk';
export default class GreeterActor extends MatrixActor { export default class GreeterActor extends MatrixActor {
static accepts = { echo: {} }; static accepts = {
echo: { description: 'Echo a message', message: 'string' },
};
onEcho(payload = {}) { onEcho(payload = {}) {
return { return {
ok: true, ok: true,
@ -130,8 +132,9 @@ Expected result: the actor run command prints JSON with `ok: true` and the
`echo` result from `GreeterActor`. `echo` result from `GreeterActor`.
Handler names are part of the Matrix actor contract: `static accepts = { echo: Handler names are part of the Matrix actor contract: `static accepts = { echo:
{} }` maps to `onEcho(payload)`. Do not implement `echo(payload)` directly; the ... }` maps to `onEcho(payload)`. Do not implement `echo(payload)` directly; the
CLI rejects that shape before it connects to the broker. CLI rejects that shape before it connects to the broker. Include parameter
fields such as `message: 'string'` so agents can construct valid payloads.
If you need the HiveCast browser proof and `pnpm doctor:hivecast` reports If you need the HiveCast browser proof and `pnpm doctor:hivecast` reports
missing Chromium: missing Chromium:
@ -170,7 +173,7 @@ import {
class EchoActor extends MatrixActor { class EchoActor extends MatrixActor {
static accepts = { static accepts = {
echo: {}, echo: { description: 'Echo a message', message: 'string' },
}; };
onEcho(payload: { message?: string }) { onEcho(payload: { message?: string }) {

View File

@ -9,7 +9,7 @@ import {
class FreshServerEchoActor extends MatrixActor { class FreshServerEchoActor extends MatrixActor {
static accepts = { static accepts = {
echo: {}, echo: { description: 'Echo a message', message: 'string' },
getStatus: {}, getStatus: {},
}; };

View File

@ -8,7 +8,7 @@ import type { HiveCastActorCredential } from '@open-matrix/sdk';
class FreshBrowserEchoActor extends MatrixActor { class FreshBrowserEchoActor extends MatrixActor {
static accepts = { static accepts = {
echo: {}, echo: { description: 'Echo a message', message: 'string' },
getStatus: {}, getStatus: {},
}; };

View File

@ -38,7 +38,7 @@ function hiveCastActorCredentialPlugin(): Plugin {
actorId: 'FreshBrowserEchoActor', actorId: 'FreshBrowserEchoActor',
packageId: 'matrix-sdk-demo-fresh-web-page', packageId: 'matrix-sdk-demo-fresh-web-page',
runtimeId: `fresh-web-${process.pid}`, runtimeId: `fresh-web-${process.pid}`,
accepts: { echo: {}, getStatus: {} }, accepts: { echo: { description: 'Echo a message', message: 'string' }, getStatus: {} },
ttlSeconds: 300, ttlSeconds: 300,
}); });
sendJson(res, 200, credential); sendJson(res, 200, credential);

View File

@ -2,7 +2,7 @@ import { MatrixActor } from '@open-matrix/core';
export class GreeterActor extends MatrixActor { export class GreeterActor extends MatrixActor {
static accepts = { static accepts = {
echo: {}, echo: { description: 'Echo a message', message: 'string' },
getStatus: {}, getStatus: {},
}; };

View File

@ -29,7 +29,7 @@ const credential = await exchangeHiveCastActorCredential({
apiKey: process.env.MATRIX_API_KEY!, apiKey: process.env.MATRIX_API_KEY!,
}, { }, {
mount: 'fresh.server.echo', mount: 'fresh.server.echo',
accepts: { echo: {} }, accepts: { echo: { description: 'Echo a message', message: 'string' } },
}); });
``` ```