Files
wehub-resource-sync e30e75b5d4
Code Quality / Oxlint + Oxfmt (push) Waiting to run
Code Quality / Template Sync (push) Waiting to run
Code Quality / Build Changed Packages (push) Waiting to run
Code Quality / Test Changed Packages (push) Waiting to run
Deploy Expo Example / Deploy Production (push) Waiting to run
Deploy Ink Example / Deploy Production (push) Waiting to run
Python Tests / pytest (assistant-stream, 3.10) (push) Waiting to run
Python Tests / pytest (assistant-stream, 3.12) (push) Waiting to run
Python Tests / pytest (assistant-ui-sync-server-api, 3.10) (push) Waiting to run
Python Tests / pytest (assistant-ui-sync-server-api, 3.12) (push) Waiting to run
Deploy Shadcn Registry / Deploy Production (push) Waiting to run
Template Metrics / LOC + Bundle Size (push) Waiting to run
Changesets / Create Version PR (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:40:13 +08:00

32 lines
852 B
TypeScript

type TextPartLike = { type: string; text?: string };
type ToolCallPartLike = { type: string; toolName?: string };
export function getTextLength(parts: readonly TextPartLike[]): number {
let length = 0;
for (const part of parts) {
if (part.type !== "text" || !part.text) continue;
length += part.text.length;
}
return length;
}
export function countToolCalls(parts: readonly { type: string }[]): number {
let count = 0;
for (const part of parts) {
if (part.type === "tool-call") count += 1;
}
return count;
}
export function getToolCallToolNames(
parts: readonly ToolCallPartLike[],
): string[] {
const toolNames: string[] = [];
for (const part of parts) {
if (part.type !== "tool-call") continue;
if (typeof part.toolName !== "string") continue;
toolNames.push(part.toolName);
}
return toolNames;
}