-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathtoolkit-page.tsx
More file actions
791 lines (717 loc) · 23.8 KB
/
Copy pathtoolkit-page.tsx
File metadata and controls
791 lines (717 loc) · 23.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
"use client";
import { Badge, Button } from "@arcadeai/design-system";
import { ArrowDown, ArrowUp, KeyRound } from "lucide-react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import ReactMarkdown from "react-markdown";
import ScopePicker from "../../scope-picker";
import ToolFooter from "../../tool-footer";
import {
getPackageName,
TOOL_METADATA_FALLBACK_STYLE,
TOOL_METADATA_SERVICE_DOMAIN_STYLES,
} from "../constants";
import { getSharedServiceDomain } from "./toolkit-page-utils";
export { getSharedServiceDomain } from "./toolkit-page-utils";
// Scroll detection thresholds
const SCROLL_SHOW_BUTTONS_THRESHOLD = 300;
const SCROLL_BOTTOM_THRESHOLD = 100;
// Intersection observer thresholds for TOC highlighting
const TOC_OBSERVER_THRESHOLD_MIN = 0.1;
const TOC_OBSERVER_THRESHOLD_MID = 0.5;
// Scroll padding for TOC item visibility
const TOC_SCROLL_PADDING = 20;
import type {
ToolDefinition,
ToolkitCategory,
ToolkitPageProps,
ToolkitType,
} from "../types";
import { AvailableToolsTable, toToolAnchorId } from "./available-tools-table";
import {
DocumentationChunkRenderer,
hasChunksAt,
headerToAnchorId,
sortChunksDeterministically,
} from "./documentation-chunk-renderer";
import { PageActionsBar } from "./page-actions";
import { ToolSection } from "./tool-section";
import { ToolkitHeader } from "./toolkit-header";
/**
* Floating buttons to scroll to top/bottom of the page.
* Only shows when user has scrolled past a threshold.
*/
function ScrollToButtons() {
const [showButtons, setShowButtons] = useState(false);
const [atBottom, setAtBottom] = useState(false);
useEffect(() => {
const handleScroll = () => {
const scrollTop = window.scrollY;
const windowHeight = window.innerHeight;
const documentHeight = document.documentElement.scrollHeight;
// Show buttons after scrolling past threshold
setShowButtons(scrollTop > SCROLL_SHOW_BUTTONS_THRESHOLD);
// Check if near bottom (within threshold)
setAtBottom(
scrollTop + windowHeight >= documentHeight - SCROLL_BOTTOM_THRESHOLD
);
};
window.addEventListener("scroll", handleScroll, { passive: true });
handleScroll(); // Initial check
return () => window.removeEventListener("scroll", handleScroll);
}, []);
const scrollToTop = () => {
window.scrollTo({ top: 0, behavior: "smooth" });
};
const scrollToBottom = () => {
window.scrollTo({
top: document.documentElement.scrollHeight,
behavior: "smooth",
});
};
if (!showButtons) {
return null;
}
return (
<div className="fixed right-6 bottom-6 z-50 flex flex-col gap-2 xl:right-80 2xl:right-80">
<Button
aria-label="Scroll to top"
className="h-10 w-10 rounded-full shadow-lg backdrop-blur-sm"
onClick={scrollToTop}
size="sm"
title="Scroll to top"
variant="outline"
>
<ArrowUp className="h-5 w-5" />
</Button>
{!atBottom && (
<Button
aria-label="Scroll to bottom"
className="h-10 w-10 rounded-full shadow-lg backdrop-blur-sm"
onClick={scrollToBottom}
size="sm"
title="Scroll to bottom"
variant="outline"
>
<ArrowDown className="h-5 w-5" />
</Button>
)}
</div>
);
}
export function buildPipPackageName(toolkitId: string): string {
return getPackageName(toolkitId);
}
export const TOOLKIT_PAGE_OVERVIEW_LINK = {
id: "overview",
label: "Overview",
href: "#overview",
} as const;
export const TOOLKIT_PAGE_AVAILABLE_TOOLS_LINK = {
id: "available-tools",
label: "Available tools",
href: "#available-tools",
} as const;
export const TOOLKIT_PAGE_SELECTED_TOOLS_LINK = {
id: "selected-tools",
label: "Selected tools",
href: "#selected-tools",
} as const;
export const TOOLKIT_PAGE_GET_BUILDING_LINK = {
id: "get-building",
label: "Get building",
href: "#get-building",
} as const;
// Regex for removing leading ## from headers (used for display label extraction)
const HEADER_PREFIX_REGEX = /^#+\s*/;
/**
* Extracts section links from documentation chunks that have headers.
* Chunks are sorted deterministically before extraction to ensure consistent TOC order.
*/
export function extractChunkSectionLinks(
chunks: ReadonlyArray<{
header?: string;
priority?: number;
content?: string;
}>
): Array<{ id: string; label: string; href: string }> {
const links: Array<{ id: string; label: string; href: string }> = [];
const seenIds = new Set<string>();
// Sort chunks deterministically before extracting links
const sortedChunks = sortChunksDeterministically(
chunks as Parameters<typeof sortChunksDeterministically>[0]
);
for (const chunk of sortedChunks) {
if (chunk.header) {
const id = headerToAnchorId(chunk.header);
if (!seenIds.has(id)) {
seenIds.add(id);
links.push({
id,
label: chunk.header.replace(HEADER_PREFIX_REGEX, ""), // Remove ## prefix for display
href: `#${id}`,
});
}
}
}
return links;
}
export function buildObservedSectionIds(
tools: ReadonlyArray<{ qualifiedName: string }>,
documentationChunks: ReadonlyArray<{ header?: string }> = []
): string[] {
const ids: string[] = [
TOOLKIT_PAGE_OVERVIEW_LINK.id,
TOOLKIT_PAGE_AVAILABLE_TOOLS_LINK.id,
TOOLKIT_PAGE_SELECTED_TOOLS_LINK.id,
];
// Add custom section IDs from documentation chunks
const chunkSections = extractChunkSectionLinks(documentationChunks);
for (const section of chunkSections) {
ids.push(section.id);
}
for (const tool of tools) {
ids.push(toToolAnchorId(tool.qualifiedName));
}
ids.push(TOOLKIT_PAGE_GET_BUILDING_LINK.id);
return ids;
}
function inferToolkitType(toolkitId: string, type: ToolkitType): ToolkitType {
if (toolkitId.toLowerCase().endsWith("api") && type === "arcade") {
return "arcade_starter";
}
return type;
}
function toTitleCaseCategory(category: ToolkitCategory): string {
return category
.split("-")
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
.join(" ");
}
/**
* Breadcrumb bar like older integration pages.
*
* Note: preview pages are dynamic, so we render this in-page.
*/
function BreadcrumbBar({
label,
category,
}: {
label: string;
category: ToolkitCategory;
}) {
return (
<nav className="mb-6 flex flex-wrap items-center gap-2 text-muted-foreground text-sm">
<a className="hover:text-brand-accent" href="/en/resources">
Resources
</a>
<span className="text-muted-foreground/40">›</span>
<a className="hover:text-brand-accent" href="/en/resources/integrations">
Integrations
</a>
<span className="text-muted-foreground/40">›</span>
<span className="text-muted-foreground">
{toTitleCaseCategory(category)}
</span>
<span className="text-muted-foreground/40">›</span>
<span className="font-medium text-foreground">{label}</span>
</nav>
);
}
/**
* Right sidebar that lists the tools on the page.
* Structure: Fixed header/footer with scrollable middle tool list.
* Auto-scrolls and highlights the currently visible section.
*/
function ToolsOnThisPage({
tools,
selectedTools,
documentationChunks = [],
}: {
tools: ToolDefinition[];
selectedTools: Set<string>;
documentationChunks?: ReadonlyArray<{ header?: string }>;
}) {
const [activeId, setActiveId] = useState<string | null>(null);
const toolListRef = useRef<HTMLDivElement>(null);
const itemRefs = useRef<Map<string, HTMLAnchorElement>>(new Map());
const [query, setQuery] = useState("");
// Extract custom section links from documentation chunks
const customSections = useMemo(
() => extractChunkSectionLinks(documentationChunks),
[documentationChunks]
);
// Build list of all section IDs to observe
const sectionIds = useMemo(
() => buildObservedSectionIds(tools, documentationChunks),
[tools, documentationChunks]
);
const filteredTools = useMemo(() => {
const q = query.trim().toLowerCase();
if (q.length === 0) {
return tools;
}
return tools.filter((tool) => tool.qualifiedName.toLowerCase().includes(q));
}, [tools, query]);
const selectedToolsList = useMemo(
() => tools.filter((tool) => selectedTools.has(tool.name)),
[tools, selectedTools]
);
// Intersection Observer to track visible sections
useEffect(() => {
// Track visibility state for all sections
const visibleSections = new Map<string, number>();
// Helper: find section closest to top of viewport
const findClosestSection = (): string | null => {
let closestId: string | null = null;
let closestTop = Number.POSITIVE_INFINITY;
for (const [id, top] of visibleSections) {
if (top >= 0 && top < closestTop) {
closestTop = top;
closestId = id;
}
}
// Fallback: use topmost visible section if none below viewport top
if (!closestId && visibleSections.size > 0) {
const sorted = [...visibleSections.entries()].sort(
(a, b) => a[1] - b[1]
);
return sorted[0][0];
}
return closestId;
};
// Helper: update visibility map from observer entries
const updateVisibilityMap = (entries: IntersectionObserverEntry[]) => {
for (const entry of entries) {
if (entry.isIntersecting) {
visibleSections.set(entry.target.id, entry.boundingClientRect.top);
} else {
visibleSections.delete(entry.target.id);
}
}
};
const observer = new IntersectionObserver(
(entries) => {
updateVisibilityMap(entries);
const closestId = findClosestSection();
if (closestId) {
setActiveId(closestId);
}
},
{
rootMargin: "-80px 0px -50% 0px",
threshold: [0, TOC_OBSERVER_THRESHOLD_MIN, TOC_OBSERVER_THRESHOLD_MID],
}
);
// Observe all sections
for (const id of sectionIds) {
const element = document.getElementById(id);
if (element) {
observer.observe(element);
}
}
return () => observer.disconnect();
}, [sectionIds]);
// Auto-scroll tool list to keep active item visible
useEffect(() => {
if (!(activeId && toolListRef.current)) {
return;
}
const activeItem = itemRefs.current.get(activeId);
if (!activeItem) {
return;
}
const container = toolListRef.current;
const itemTop = activeItem.offsetTop - container.offsetTop;
const itemHeight = activeItem.offsetHeight;
const containerScrollTop = container.scrollTop;
const containerHeight = container.clientHeight;
// Check if item is outside visible area
if (itemTop < containerScrollTop + TOC_SCROLL_PADDING) {
container.scrollTo({
top: Math.max(0, itemTop - TOC_SCROLL_PADDING),
behavior: "smooth",
});
} else if (
itemTop + itemHeight >
containerScrollTop + containerHeight - TOC_SCROLL_PADDING
) {
container.scrollTo({
top: itemTop + itemHeight - containerHeight + TOC_SCROLL_PADDING,
behavior: "smooth",
});
}
}, [activeId]);
const setItemRef = useCallback((id: string, el: HTMLAnchorElement | null) => {
if (el) {
itemRefs.current.set(id, el);
} else {
itemRefs.current.delete(id);
}
}, []);
const getLinkClasses = (id: string) => {
const isActive = activeId === id;
return isActive
? "text-brand-accent font-medium border-l-2 border-brand-accent -ml-[2px] pl-[14px]"
: "text-muted-foreground hover:text-brand-accent";
};
return (
<aside className="fixed top-28 right-0 hidden w-80 flex-col border-muted/60 border-l bg-background xl:flex 2xl:w-80 dark:border-neutral-dark-high/30 dark:bg-neutral-dark/40">
{/* Header section */}
<div className="px-6 pt-6 pb-4">
<h2 className="font-semibold text-foreground text-sm">On this page</h2>
<div className="mt-4 space-y-3">
<input
aria-label="Search tools on this page"
className="w-full rounded-lg border border-muted/60 bg-background px-3 py-2 text-sm transition-colors placeholder:text-muted-foreground/70 focus:border-brand-accent focus:outline-none dark:border-neutral-dark-high dark:bg-neutral-dark/60"
onChange={(event) => setQuery(event.target.value)}
placeholder="Search tools..."
type="search"
value={query}
/>
<div className="text-muted-foreground text-xs">
{filteredTools.length} of {tools.length} tools
</div>
</div>
{/* Navigation links */}
<div className="mt-4 space-y-2">
<a
className={`block text-sm transition-colors ${getLinkClasses(TOOLKIT_PAGE_OVERVIEW_LINK.id)}`}
href={TOOLKIT_PAGE_OVERVIEW_LINK.href}
ref={(el) => setItemRef(TOOLKIT_PAGE_OVERVIEW_LINK.id, el)}
>
{TOOLKIT_PAGE_OVERVIEW_LINK.label}
</a>
{/* Custom documentation sections */}
{customSections.map((section) => (
<a
className={`block pl-3 text-sm transition-colors ${getLinkClasses(section.id)}`}
href={section.href}
key={section.id}
ref={(el) => setItemRef(section.id, el)}
>
{section.label}
</a>
))}
<a
className={`block text-sm transition-colors ${getLinkClasses(TOOLKIT_PAGE_AVAILABLE_TOOLS_LINK.id)}`}
href={TOOLKIT_PAGE_AVAILABLE_TOOLS_LINK.href}
ref={(el) => setItemRef(TOOLKIT_PAGE_AVAILABLE_TOOLS_LINK.id, el)}
>
{TOOLKIT_PAGE_AVAILABLE_TOOLS_LINK.label}
</a>
<a
className={`block text-sm transition-colors ${getLinkClasses(TOOLKIT_PAGE_SELECTED_TOOLS_LINK.id)}`}
href={TOOLKIT_PAGE_SELECTED_TOOLS_LINK.href}
ref={(el) => setItemRef(TOOLKIT_PAGE_SELECTED_TOOLS_LINK.id, el)}
>
{TOOLKIT_PAGE_SELECTED_TOOLS_LINK.label} ({selectedToolsList.length}
)
</a>
</div>
</div>
{/* Divider + Scrollable tool list (constrained height) */}
<div className="border-muted/60 border-t dark:border-neutral-dark-high/30">
<div
className="max-h-[50vh] overflow-y-auto px-6 py-3"
ref={toolListRef}
>
<div className="space-y-1">
{filteredTools.map((tool) => {
const hasSecrets =
(tool.secretsInfo?.length ?? 0) > 0 ||
(tool.secrets?.length ?? 0) > 0;
const toolId = toToolAnchorId(tool.qualifiedName);
return (
<a
className={`flex items-center gap-2 py-1 pl-3 text-sm transition-colors ${getLinkClasses(toolId)}`}
href={`#${toolId}`}
key={tool.qualifiedName}
ref={(el) => setItemRef(toolId, el)}
title={tool.qualifiedName}
>
<span className="truncate">{tool.qualifiedName}</span>
{hasSecrets && (
<KeyRound className="h-3.5 w-3.5 shrink-0 text-amber-400" />
)}
</a>
);
})}
</div>
</div>
</div>
{/* Footer section */}
<div className="border-muted/60 border-t px-6 py-4 dark:border-neutral-dark-high/20">
<a
className={`block text-sm transition-colors ${getLinkClasses(TOOLKIT_PAGE_GET_BUILDING_LINK.id)}`}
href={TOOLKIT_PAGE_GET_BUILDING_LINK.href}
ref={(el) => setItemRef(TOOLKIT_PAGE_GET_BUILDING_LINK.id, el)}
>
{TOOLKIT_PAGE_GET_BUILDING_LINK.label}
</a>
</div>
</aside>
);
}
/**
* ToolkitPage
*
* Composes the full toolkit documentation page from JSON data.
*/
export function ToolkitPage({ data }: ToolkitPageProps) {
useEffect(() => {
document.documentElement.dataset.pageKind = "toolkit";
return () => {
delete document.documentElement.dataset.pageKind;
};
}, []);
const tools = data.tools ?? [];
const documentationChunks = data.documentationChunks ?? [];
const [selectedTools, setSelectedTools] = useState<Set<string>>(new Set());
const selectionTools = tools.map((tool) => {
const secrets =
(tool.secrets ?? []).length > 0
? (tool.secrets ?? [])
: (tool.secretsInfo ?? []).map((secret) => secret.name);
return {
name: tool.name,
scopes: tool.auth?.scopes ?? [],
secrets,
// Full tool definition for enhanced copy functionality
qualifiedName: tool.qualifiedName,
fullyQualifiedName: tool.fullyQualifiedName,
description: tool.description,
parameters: tool.parameters,
output: tool.output,
};
});
const shouldShowSelection = tools.length > 0;
// Compute tool stats
const toolStats = {
total: tools.length,
withScopes: tools.filter((tool) => (tool.auth?.scopes ?? []).length > 0)
.length,
withSecrets: tools.filter(
(tool) =>
(tool.secretsInfo?.length ?? 0) > 0 || (tool.secrets?.length ?? 0) > 0
).length,
};
const showToolFooter = !hasChunksAt(documentationChunks, "footer", "replace");
const pipPackageName = data.pipPackageName ?? buildPipPackageName(data.id);
const metadata = useMemo(
() => ({
...data.metadata,
type: inferToolkitType(data.id, data.metadata?.type),
}),
[data.id, data.metadata]
);
const sharedServiceDomain = useMemo(
() => getSharedServiceDomain(tools),
[tools]
);
const handleScopeSelectionChange = (toolNames: string[]) => {
setSelectedTools(new Set(toolNames));
};
const toggleToolSelection = (toolName: string) => {
setSelectedTools((prevSelected) => {
const nextSelected = new Set(prevSelected);
if (nextSelected.has(toolName)) {
nextSelected.delete(toolName);
} else {
nextSelected.add(toolName);
}
return nextSelected;
});
};
return (
<div className="w-full">
{/* Overview section */}
<section className="scroll-mt-20" id={TOOLKIT_PAGE_OVERVIEW_LINK.id}>
<BreadcrumbBar category={data.metadata?.category} label={data.label} />
<PageActionsBar toolkitId={data.id} />
<h1 className="mb-6 font-bold text-4xl text-foreground tracking-tight">
{data.label}
</h1>
{sharedServiceDomain && (
<div className="mb-5 flex flex-wrap items-center gap-2">
<span className="text-muted-foreground text-xs uppercase tracking-wider">
Service domain
</span>
<Badge
className={`font-mono text-xs uppercase tracking-wide ${
TOOL_METADATA_SERVICE_DOMAIN_STYLES[sharedServiceDomain] ??
TOOL_METADATA_FALLBACK_STYLE
}`}
variant="outline"
>
{sharedServiceDomain.replace(/_/g, " ").toUpperCase()}
</Badge>
</div>
)}
<ToolkitHeader
auth={data.auth}
description={data.description}
id={data.id}
label={data.label}
metadata={metadata}
toolStats={toolStats}
version={data.version}
/>
<DocumentationChunkRenderer
chunks={documentationChunks}
location="header"
position="before"
/>
<DocumentationChunkRenderer
chunks={documentationChunks}
location="description"
position="before"
/>
<DocumentationChunkRenderer
chunks={documentationChunks}
location="description"
position="after"
/>
<DocumentationChunkRenderer
chunks={documentationChunks}
location="header"
position="replace"
/>
<DocumentationChunkRenderer
chunks={documentationChunks}
location="header"
position="after"
/>
{data.summary && (
<div className="prose prose-sm dark:prose-invert mt-6 max-w-none text-foreground">
<ReactMarkdown>{data.summary}</ReactMarkdown>
</div>
)}
<DocumentationChunkRenderer
chunks={documentationChunks}
location="auth"
position="before"
/>
<DocumentationChunkRenderer
chunks={documentationChunks}
location="auth"
position="after"
/>
</section>
<DocumentationChunkRenderer
chunks={documentationChunks}
location="before_available_tools"
position="before"
/>
<DocumentationChunkRenderer
chunks={documentationChunks}
location="before_available_tools"
position="after"
/>
<DocumentationChunkRenderer
chunks={documentationChunks}
location="custom_section"
position="before"
/>
<DocumentationChunkRenderer
chunks={documentationChunks}
location="custom_section"
position="after"
/>
<div className="mt-10 scroll-mt-20" id="available-tools">
<h2 className="flex items-center gap-3 font-semibold text-2xl">
<span className="rounded-lg bg-brand-accent/10 p-2">
<svg
aria-hidden="true"
className="h-5 w-5 text-brand-accent"
fill="none"
focusable="false"
stroke="currentColor"
strokeWidth="2"
viewBox="0 0 24 24"
>
<path
d="M4 6h16M4 12h16M4 18h7"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
</span>
Available tools
<span className="ml-2 text-muted-foreground text-sm">
({tools.length})
</span>
</h2>
</div>
<AvailableToolsTable
onToggleSelection={toggleToolSelection}
selectedTools={selectedTools}
showSelection={shouldShowSelection}
tools={tools.map((tool) => ({
name: tool.name,
qualifiedName: tool.qualifiedName,
description: tool.description,
secrets: tool.secrets,
secretsInfo: tool.secretsInfo,
scopes: tool.auth?.scopes ?? [],
metadata: tool.metadata,
}))}
/>
<DocumentationChunkRenderer
chunks={documentationChunks}
location="after_available_tools"
position="before"
/>
<DocumentationChunkRenderer
chunks={documentationChunks}
location="after_available_tools"
position="after"
/>
{shouldShowSelection && (
<section
className="mt-10 scroll-mt-20"
id={TOOLKIT_PAGE_SELECTED_TOOLS_LINK.id}
>
<ScopePicker
onSelectedToolsChange={handleScopeSelectionChange}
selectedTools={Array.from(selectedTools)}
tools={selectionTools}
/>
</section>
)}
{tools.map((tool) => (
<ToolSection
isSelected={selectedTools.has(tool.name)}
key={tool.qualifiedName}
onToggleSelection={toggleToolSelection}
showSelection={shouldShowSelection}
tool={tool}
/>
))}
<section className="mt-10 scroll-mt-20" id="get-building">
<DocumentationChunkRenderer
chunks={documentationChunks}
location="footer"
position="before"
/>
{showToolFooter && <ToolFooter pipPackageName={pipPackageName} />}
<DocumentationChunkRenderer
chunks={documentationChunks}
location="footer"
position="replace"
/>
<DocumentationChunkRenderer
chunks={documentationChunks}
location="footer"
position="after"
/>
</section>
<ToolsOnThisPage
documentationChunks={documentationChunks}
selectedTools={selectedTools}
tools={tools}
/>
<ScrollToButtons />
</div>
);
}
export default ToolkitPage;