



















11import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
22import type { OpenClawPluginApi } from "../api.js";
3-import { WorkboardStore, type PersistedWorkboardCard } from "./store.js";
3+import { WorkboardStore } from "./store.js";
44import { WORKBOARD_STATUSES, type WorkboardCard } from "./types.js";
5566const READ_SCOPE = "operator.read" as const;
@@ -64,10 +64,7 @@ export function registerWorkboardGatewayMethods(params: {
6464}) {
6565const { api } = params;
6666const store =
67-params.store ??
68-WorkboardStore.open((options) =>
69-api.runtime.state.openKeyedStore<PersistedWorkboardCard>(options),
70-);
67+params.store ?? WorkboardStore.open((options) => api.runtime.state.openKeyedStore(options));
71687269api.registerGatewayMethod(
7370"workboard.cards.list",
@@ -407,6 +404,44 @@ export function registerWorkboardGatewayMethods(params: {
407404{ scope: READ_SCOPE },
408405);
409406407+api.registerGatewayMethod(
408+"workboard.boards.upsert",
409+async ({ params: requestParams, respond }) => {
410+try {
411+respond(true, { board: await store.upsertBoard(requestParams) });
412+} catch (error) {
413+respondError(respond, error);
414+}
415+},
416+{ scope: WRITE_SCOPE },
417+);
418+419+api.registerGatewayMethod(
420+"workboard.boards.archive",
421+async ({ params: requestParams, respond }) => {
422+try {
423+respond(true, {
424+board: await store.archiveBoard(requestParams.id, requestParams.archived),
425+});
426+} catch (error) {
427+respondError(respond, error);
428+}
429+},
430+{ scope: WRITE_SCOPE },
431+);
432+433+api.registerGatewayMethod(
434+"workboard.boards.delete",
435+async ({ params: requestParams, respond }) => {
436+try {
437+respond(true, await store.deleteBoard(requestParams.id));
438+} catch (error) {
439+respondError(respond, error);
440+}
441+},
442+{ scope: WRITE_SCOPE },
443+);
444+410445api.registerGatewayMethod(
411446"workboard.cards.stats",
412447async ({ params: requestParams, respond }) => {
@@ -419,6 +454,85 @@ export function registerWorkboardGatewayMethods(params: {
419454{ scope: READ_SCOPE },
420455);
421456457+api.registerGatewayMethod(
458+"workboard.cards.runs",
459+async ({ params: requestParams, respond }) => {
460+try {
461+const result = await store.runs(readId(requestParams));
462+respond(true, { ...result, card: redactClaimToken(result.card) });
463+} catch (error) {
464+respondError(respond, error);
465+}
466+},
467+{ scope: READ_SCOPE },
468+);
469+470+api.registerGatewayMethod(
471+"workboard.cards.specify",
472+async ({ params: requestParams, respond }) => {
473+try {
474+respond(true, {
475+card: redactClaimToken(await store.specify(readId(requestParams), requestParams, null)),
476+});
477+} catch (error) {
478+respondError(respond, error);
479+}
480+},
481+{ scope: WRITE_SCOPE },
482+);
483+484+api.registerGatewayMethod(
485+"workboard.cards.decompose",
486+async ({ params: requestParams, respond }) => {
487+try {
488+const result = await store.decompose(readId(requestParams), requestParams, null);
489+respond(true, {
490+parent: redactClaimToken(result.parent),
491+children: result.children.map(redactClaimToken),
492+});
493+} catch (error) {
494+respondError(respond, error);
495+}
496+},
497+{ scope: WRITE_SCOPE },
498+);
499+500+api.registerGatewayMethod(
501+"workboard.notifications.subscribe",
502+async ({ params: requestParams, respond }) => {
503+try {
504+respond(true, { subscription: await store.subscribeNotifications(requestParams) });
505+} catch (error) {
506+respondError(respond, error);
507+}
508+},
509+{ scope: WRITE_SCOPE },
510+);
511+512+api.registerGatewayMethod(
513+"workboard.notifications.list",
514+async ({ params: requestParams, respond }) => {
515+try {
516+respond(true, await store.listNotificationSubscriptions(requestParams));
517+} catch (error) {
518+respondError(respond, error);
519+}
520+},
521+{ scope: READ_SCOPE },
522+);
523+524+api.registerGatewayMethod(
525+"workboard.notifications.delete",
526+async ({ params: requestParams, respond }) => {
527+try {
528+respond(true, await store.deleteNotificationSubscription(readId(requestParams)));
529+} catch (error) {
530+respondError(respond, error);
531+}
532+},
533+{ scope: WRITE_SCOPE },
534+);
535+422536api.registerGatewayMethod(
423537"workboard.cards.archive",
424538async ({ params: requestParams, respond }) => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。