The open source coding agent.
TypeScript
share page tool args
Jay Ve20093678f21
diff --git a/packages/web/src/components/Share.tsx b/packages/web/src/components/Share.tsxindex 11c52f17ae0..4a88ef6d0bd 100644--- a/packages/web/src/components/Share.tsx+++ b/packages/web/src/components/Share.tsx@@ -92,16 +92,30 @@ function formatDuration(ms: number): string {return `${ms}ms`}-// Converts `{a:{b:{c:1}}` to `[['a.b.c', 1]]`+// Converts nested objects/arrays into [path, value] pairs.+// E.g. {a:{b:{c:1}}, d:[{e:2}, 3]} => [["a.b.c",1], ["d[0].e",2], ["d[1]",3]]function flattenToolArgs(obj: any, prefix: string = ""): Array<[string, any]> {const entries: Array<[string, any]> = []for (const [key, value] of Object.entries(obj)) {const path = prefix ? `${prefix}.${key}` : key- if (value !== null && typeof value === "object" && !Array.isArray(value)) {- entries.push(...flattenToolArgs(value, path))- } else {+ if (value !== null && typeof value === "object") {+ if (Array.isArray(value)) {+ value.forEach((item, index) => {+ const arrayPath = `${path}[${index}]`+ if (item !== null && typeof item === "object") {+ entries.push(...flattenToolArgs(item, arrayPath))+ } else {+ entries.push([arrayPath, item])+ }+ })+ }+ else {+ entries.push(...flattenToolArgs(value, path))+ }+ }+ else {entries.push([path, value])}}