Skip to content

Commit 4b05e5c

Browse files
committed
fix: address PR review findings - types and defensive guards
- Add BehaviorFlagKey type export to types/index.ts (fixes Vercel build error: 'BehaviorFlagKey' not exported from types) - getSharedServiceDomain: add typeof string guard before accepting a serviceDomains entry; prevents TypeError if JSON has a non-string value calling .replace() on a Badge label (high severity) - matchesBehaviorFlags: skip entries where expected is undefined; with Partial<Record<BehaviorFlagKey, boolean>> a key can be undefined to mean "don't filter", but the old code compared !== expected which incorrectly excluded tools (low severity) Made-with: Cursor
1 parent 25484fe commit 4b05e5c

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

app/_components/toolkit-docs/components/available-tools-table.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,11 @@ function matchesBehaviorFlags(
535535
): boolean {
536536
for (const [key, expected] of Object.entries(behaviorFlags) as [
537537
BehaviorFlagKey,
538-
boolean,
538+
boolean | undefined,
539539
][]) {
540+
if (expected === undefined) {
541+
continue;
542+
}
540543
if (tool.metadata?.behavior?.[key] !== expected) {
541544
return false;
542545
}

app/_components/toolkit-docs/components/toolkit-page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export function getSharedServiceDomain(
232232
}
233233

234234
const domain = serviceDomains[0];
235-
if (!domain) {
235+
if (!domain || typeof domain !== "string") {
236236
return null;
237237
}
238238

app/_components/toolkit-docs/types/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ export type ToolMetadataBehavior = {
197197
openWorld?: boolean;
198198
};
199199

200+
export type BehaviorFlagKey =
201+
| "readOnly"
202+
| "destructive"
203+
| "idempotent"
204+
| "openWorld";
205+
200206
export type ToolMetadata = {
201207
classification: ToolMetadataClassification;
202208
behavior: ToolMetadataBehavior;

0 commit comments

Comments
 (0)