






























1+import {
2+optionalNonNegativeIntegerSchema,
3+optionalPositiveIntegerSchema,
4+} from "openclaw/plugin-sdk/channel-actions";
5+import {
6+readNonNegativeIntegerParam,
7+readPositiveIntegerParam,
8+} from "openclaw/plugin-sdk/param-readers";
19import { Type } from "typebox";
210import type { OpenClawPluginApi } from "../runtime-api.js";
311import {
@@ -65,13 +73,9 @@ function readOptionalTrimmedString(value: unknown, fieldName: string): string |
6573}
66746775function readOptionalNumber(value: unknown, fieldName: string): number | undefined {
68-if (value === undefined) {
69-return undefined;
70-}
71-if (typeof value !== "number" || !Number.isInteger(value)) {
72-throw new Error(`${fieldName} must be an integer`);
73-}
74-return value;
76+return readNonNegativeIntegerParam({ [fieldName]: value }, fieldName, {
77+message: `${fieldName} must be a non-negative integer`,
78+});
7579}
76807781function readOptionalBoolean(value: unknown, fieldName: string): boolean | undefined {
@@ -230,13 +234,13 @@ export function createLobsterTool(api: OpenClawPluginApi, options?: LobsterToolO
230234"Relative working directory (optional). Must stay within the gateway working directory.",
231235}),
232236),
233-timeoutMs: Type.Optional(Type.Number()),
234-maxStdoutBytes: Type.Optional(Type.Number()),
237+timeoutMs: optionalPositiveIntegerSchema(),
238+maxStdoutBytes: optionalPositiveIntegerSchema(),
235239flowControllerId: Type.Optional(Type.String()),
236240flowGoal: Type.Optional(Type.String()),
237241flowStateJson: Type.Optional(Type.String()),
238242flowId: Type.Optional(Type.String()),
239-flowExpectedRevision: Type.Optional(Type.Number()),
243+flowExpectedRevision: optionalNonNegativeIntegerSchema(),
240244flowCurrentStep: Type.Optional(Type.String()),
241245flowWaitingStep: Type.Optional(Type.String()),
242246}),
@@ -250,9 +254,8 @@ export function createLobsterTool(api: OpenClawPluginApi, options?: LobsterToolO
250254}
251255252256const cwd = resolveLobsterCwd(params.cwd);
253-const timeoutMs = typeof params.timeoutMs === "number" ? params.timeoutMs : 20_000;
254-const maxStdoutBytes =
255-typeof params.maxStdoutBytes === "number" ? params.maxStdoutBytes : 512_000;
257+const timeoutMs = readPositiveIntegerParam(params, "timeoutMs") ?? 20_000;
258+const maxStdoutBytes = readPositiveIntegerParam(params, "maxStdoutBytes") ?? 512_000;
256259257260if (api.runtime?.version && api.logger?.debug) {
258261api.logger.debug(`lobster plugin runtime=${api.runtime.version}`);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。