MCPcopy Create free account
hub / github.com/Bitterbot-AI/bitterbot-desktop / readStringArrayParam

Function readStringArrayParam

src/agents/tools/common.ts:145–179  ·  view source on GitHub ↗
(
  params: Record<string, unknown>,
  key: string,
  options: StringParamOptions = {},
)

Source from the content-addressed store, hash-verified

143 options?: StringParamOptions,
144): string[] | undefined;
145export function readStringArrayParam(
146 params: Record<string, unknown>,
147 key: string,
148 options: StringParamOptions = {},
149) {
150 const { required = false, label = key } = options;
151 const raw = params[key];
152 if (Array.isArray(raw)) {
153 const values = raw
154 .filter((entry) => typeof entry === "string")
155 .map((entry) => entry.trim())
156 .filter(Boolean);
157 if (values.length === 0) {
158 if (required) {
159 throw new ToolInputError(`${label} required`);
160 }
161 return undefined;
162 }
163 return values;
164 }
165 if (typeof raw === "string") {
166 const value = raw.trim();
167 if (!value) {
168 if (required) {
169 throw new ToolInputError(`${label} required`);
170 }
171 return undefined;
172 }
173 return [value];
174 }
175 if (required) {
176 throw new ToolInputError(`${label} required`);
177 }
178 return undefined;
179}
180
181export type ReactionParams = {
182 emoji: string;

Callers 11

handleBroadcastActionFunction · 0.85
handlePollActionFunction · 0.85
telegram.tsFile · 0.85
createTaskMonitorToolFunction · 0.85
handleDiscordGuildActionFunction · 0.85
createCompleteToolFunction · 0.85
createSessionsListToolFunction · 0.85

Calls 1

filterMethod · 0.80

Tested by

no test coverage detected