@humain/ui 2.1.62 → 2.1.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/organisms/ai/AIToolCall/AIToolCall.d.ts +9 -3
- package/dist/components/organisms/ai/AIToolRun/index.d.ts +1 -1
- package/dist/components/organisms/ai/AIToolRun/validation.d.ts +24 -3
- package/dist/components/organisms/ai/_shared/format-ai-duration.d.ts +1 -0
- package/dist/components/organisms/ai/_shared/workflow-step-renderer.d.ts +1 -0
- package/dist/index.js +52 -52
- package/dist/index151.js +1 -1
- package/dist/index174.js +10 -333
- package/dist/index174.js.map +1 -1
- package/dist/index175.js +310 -137
- package/dist/index175.js.map +1 -1
- package/dist/index176.js +148 -174
- package/dist/index176.js.map +1 -1
- package/dist/index177.js +186 -78
- package/dist/index177.js.map +1 -1
- package/dist/index178.js +74 -124
- package/dist/index178.js.map +1 -1
- package/dist/index179.js +133 -1
- package/dist/index179.js.map +1 -0
- package/dist/index180.js +2 -201
- package/dist/index181.js +201 -0
- package/dist/{index180.js.map → index181.js.map} +1 -1
- package/dist/index183.js +130 -166
- package/dist/index183.js.map +1 -1
- package/dist/index184.js +195 -983
- package/dist/index184.js.map +1 -1
- package/dist/index185.js +1069 -369
- package/dist/index185.js.map +1 -1
- package/dist/index186.js +395 -197
- package/dist/index186.js.map +1 -1
- package/dist/index187.js +198 -243
- package/dist/index187.js.map +1 -1
- package/dist/index188.js +263 -3
- package/dist/index188.js.map +1 -1
- package/dist/index189.js +3 -209
- package/dist/index189.js.map +1 -1
- package/dist/index190.js +190 -777
- package/dist/index190.js.map +1 -1
- package/dist/index191.js +771 -252
- package/dist/index191.js.map +1 -1
- package/dist/index192.js +250 -65
- package/dist/index192.js.map +1 -1
- package/dist/index193.js +72 -523
- package/dist/index193.js.map +1 -1
- package/dist/index194.js +537 -144
- package/dist/index194.js.map +1 -1
- package/dist/index195.js +139 -720
- package/dist/index195.js.map +1 -1
- package/dist/index196.js +707 -167
- package/dist/index196.js.map +1 -1
- package/dist/index197.js +175 -151
- package/dist/index197.js.map +1 -1
- package/dist/index198.js +152 -487
- package/dist/index198.js.map +1 -1
- package/dist/index199.js +472 -225
- package/dist/index199.js.map +1 -1
- package/dist/index200.js +236 -260
- package/dist/index200.js.map +1 -1
- package/dist/index201.js +265 -215
- package/dist/index201.js.map +1 -1
- package/dist/index202.js +207 -307
- package/dist/index202.js.map +1 -1
- package/dist/index203.js +302 -135
- package/dist/index203.js.map +1 -1
- package/dist/index204.js +140 -271
- package/dist/index204.js.map +1 -1
- package/dist/index205.js +263 -253
- package/dist/index205.js.map +1 -1
- package/dist/index206.js +244 -137
- package/dist/index206.js.map +1 -1
- package/dist/index207.js +100 -238
- package/dist/index207.js.map +1 -1
- package/dist/index208.js +278 -74
- package/dist/index208.js.map +1 -1
- package/dist/index209.js +56 -97
- package/dist/index209.js.map +1 -1
- package/dist/index210.js +142 -47
- package/dist/index210.js.map +1 -1
- package/dist/index211.js +38 -84
- package/dist/index211.js.map +1 -1
- package/dist/index212.js +72 -252
- package/dist/index212.js.map +1 -1
- package/dist/index213.js +274 -26
- package/dist/index213.js.map +1 -1
- package/dist/index214.js +29 -94
- package/dist/index214.js.map +1 -1
- package/dist/index215.js +98 -25
- package/dist/index215.js.map +1 -1
- package/dist/index216.js +20 -565
- package/dist/index216.js.map +1 -1
- package/dist/index217.js +564 -17
- package/dist/index217.js.map +1 -1
- package/dist/index218.js +20 -23
- package/dist/index218.js.map +1 -1
- package/dist/index219.js +20 -95
- package/dist/index219.js.map +1 -1
- package/dist/index220.js +92 -88
- package/dist/index220.js.map +1 -1
- package/dist/index221.js +97 -29
- package/dist/index221.js.map +1 -1
- package/dist/index222.js +24 -470
- package/dist/index222.js.map +1 -1
- package/dist/index223.js +446 -196
- package/dist/index223.js.map +1 -1
- package/dist/index224.js +199 -729
- package/dist/index224.js.map +1 -1
- package/dist/index225.js +750 -61
- package/dist/index225.js.map +1 -1
- package/dist/index226.js +58 -181
- package/dist/index226.js.map +1 -1
- package/dist/index227.js +175 -259
- package/dist/index227.js.map +1 -1
- package/dist/index228.js +246 -172
- package/dist/index228.js.map +1 -1
- package/dist/index229.js +195 -32
- package/dist/index229.js.map +1 -1
- package/dist/index230.js +12 -40
- package/dist/index230.js.map +1 -1
- package/dist/index231.js +23 -26
- package/dist/index231.js.map +1 -1
- package/dist/index232.js +45 -22
- package/dist/index232.js.map +1 -1
- package/dist/index233.js +27 -48
- package/dist/index233.js.map +1 -1
- package/dist/index234.js +52 -26
- package/dist/index234.js.map +1 -1
- package/dist/index235.js +40 -225
- package/dist/index235.js.map +1 -1
- package/dist/index236.js +217 -39
- package/dist/index236.js.map +1 -1
- package/dist/index237.js +50 -0
- package/dist/index237.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/wc/AIToolCall.js +218 -0
- package/dist/wc/AIToolCall.js.map +1 -0
- package/dist/wc/hf-ai-tool-call.js +34 -219
- package/dist/wc/hf-ai-tool-call.js.map +1 -1
- package/dist/wc/hf-ai-tool-run.js +673 -576
- package/dist/wc/hf-ai-tool-run.js.map +1 -1
- package/dist/wc/workflow-step-renderer.js +94 -86
- package/dist/wc/workflow-step-renderer.js.map +1 -1
- package/dist/wc-react/AIToolCall.js +218 -0
- package/dist/wc-react/AIToolCall.js.map +1 -0
- package/dist/wc-react/hf-ai-tool-call.js +32 -217
- package/dist/wc-react/hf-ai-tool-call.js.map +1 -1
- package/dist/wc-react/hf-ai-tool-run.js +698 -601
- package/dist/wc-react/hf-ai-tool-run.js.map +1 -1
- package/dist/wc-react/workflow-step-renderer.js +76 -68
- package/dist/wc-react/workflow-step-renderer.js.map +1 -1
- package/package.json +1 -1
- package/skills/humain-ui/SKILL.md +1 -1
- package/skills/humain-ui-wc/SKILL.md +1 -1
- package/skills/humain-ui-wc.skill +0 -0
- package/skills/humain-ui.skill +0 -0
- package/dist/index182.js +0 -143
- package/dist/index182.js.map +0 -1
- package/dist/wc/wrench.js +0 -10
- package/dist/wc/wrench.js.map +0 -1
- package/dist/wc-react/wrench.js +0 -10
- package/dist/wc-react/wrench.js.map +0 -1
package/dist/index184.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index184.js","names":[],"sources":["../src/components/organisms/ai/AIToolRun/validation.ts"],"sourcesContent":["import { assertNever } from '@/lib/utils';\nimport type { SourceData } from '../AISource';\n\nexport type AIToolRunStatus =\n | 'ready'\n | 'running'\n | 'paused'\n | 'completed'\n | 'error';\n\nexport interface AIToolRunProgress {\n value: number;\n label?: string;\n meta?: string;\n}\n\nexport interface AIToolRunSource extends SourceData {\n id: string;\n}\n\ninterface AIToolRunToolCallSummaryBase {\n toolCallId: string;\n toolName: string;\n}\n\nexport type AIToolRunToolCallSummary =\n | (AIToolRunToolCallSummaryBase & {\n status: 'pending';\n error?: never;\n })\n | (AIToolRunToolCallSummaryBase & {\n status: 'running';\n error?: never;\n })\n | (AIToolRunToolCallSummaryBase & {\n status: 'success';\n error?: never;\n })\n | (AIToolRunToolCallSummaryBase & {\n status: 'error';\n error: string;\n });\n\ntype AIToolRunSummaryAt<S extends AIToolRunToolCallSummary['status']> = Extract<\n AIToolRunToolCallSummary,\n { status: S }\n>;\n\ninterface AIToolRunStepBase<S extends AIToolRunToolCallSummary['status']> {\n toolCall: AIToolRunSummaryAt<S>;\n title?: string;\n description?: string;\n}\n\nexport type AIToolRunStep =\n | (AIToolRunStepBase<'pending'> & {\n progress?: never;\n sourceIds?: never;\n currentSourceId?: never;\n durationMs?: never;\n })\n | (AIToolRunStepBase<'running'> & {\n progress?: AIToolRunProgress;\n sourceIds?: readonly string[];\n currentSourceId?: string;\n durationMs?: never;\n })\n | (AIToolRunStepBase<'success'> & {\n durationMs?: number;\n sourceIds?: readonly string[];\n progress?: never;\n currentSourceId?: never;\n })\n | (AIToolRunStepBase<'error'> & {\n sourceIds?: readonly string[];\n progress?: never;\n currentSourceId?: never;\n durationMs?: never;\n });\n\nexport type AIToolRunActionKind =\n | 'start'\n | 'pause'\n | 'resume'\n | 'retry'\n | 'dismiss'\n | 'custom';\n\ninterface AIToolRunActionBase {\n id: string;\n disabled?: boolean;\n loading?: boolean;\n}\n\nexport type AIToolRunAction =\n | (AIToolRunActionBase & {\n kind: Exclude<AIToolRunActionKind, 'custom'>;\n label?: string;\n })\n | (AIToolRunActionBase & {\n kind: 'custom';\n label: string;\n });\n\ninterface AIToolRunSnapshotBase {\n runId: string;\n header: {\n title: string;\n description?: string;\n metadata?: readonly { label: string; value: string }[];\n };\n steps: readonly AIToolRunStep[];\n sources?: readonly AIToolRunSource[];\n actions?: readonly AIToolRunAction[];\n}\n\nexport type AIToolRunSnapshot =\n | (AIToolRunSnapshotBase & {\n status: 'ready' | 'completed';\n progress?: never;\n activeStepId?: never;\n error?: never;\n })\n | (AIToolRunSnapshotBase & {\n status: 'running' | 'paused';\n progress?: AIToolRunProgress;\n activeStepId?: string;\n error?: never;\n })\n | (AIToolRunSnapshotBase & {\n status: 'error';\n progress?: AIToolRunProgress;\n activeStepId?: never;\n error: { message: string };\n });\n\nexport interface AIToolRunActionEvent {\n runId: string;\n actionId: string;\n kind: AIToolRunActionKind;\n}\n\ntype ValidationIssue = {\n path: string;\n message: string;\n};\n\nexport type AIToolRunValidationResult =\n | { valid: true; value: AIToolRunSnapshot }\n | { valid: false; issues: readonly ValidationIssue[] };\n\nconst ROOT_KEYS = new Set([\n 'runId',\n 'status',\n 'header',\n 'steps',\n 'sources',\n 'actions',\n 'progress',\n 'activeStepId',\n 'error',\n]);\nconst HEADER_KEYS = new Set(['title', 'description', 'metadata']);\nconst METADATA_KEYS = new Set(['label', 'value']);\nconst PROGRESS_KEYS = new Set(['value', 'label', 'meta']);\nconst ROOT_ERROR_KEYS = new Set(['message']);\nconst SOURCE_KEYS = new Set([\n 'id',\n 'url',\n 'title',\n 'description',\n 'favicon',\n 'siteName',\n]);\nconst ACTION_KEYS = new Set(['id', 'kind', 'label', 'disabled', 'loading']);\nconst STEP_KEYS = new Set([\n 'toolCall',\n 'title',\n 'description',\n 'progress',\n 'sourceIds',\n 'currentSourceId',\n 'durationMs',\n]);\nconst TOOL_CALL_KEYS = new Set(['toolCallId', 'toolName', 'status', 'error']);\n\nconst TOOL_STATUSES = {\n error: true,\n pending: true,\n running: true,\n success: true,\n} as const satisfies Record<AIToolRunToolCallSummary['status'], true>;\n\nconst RUN_STATUSES = {\n completed: true,\n error: true,\n paused: true,\n ready: true,\n running: true,\n} as const satisfies Record<AIToolRunStatus, true>;\n\nconst ACTION_KINDS = {\n custom: true,\n dismiss: true,\n pause: true,\n resume: true,\n retry: true,\n start: true,\n} as const satisfies Record<AIToolRunActionKind, true>;\n\nconst ACTIONS_BY_STATUS = {\n ready: ['start', 'dismiss', 'custom'],\n running: ['pause', 'dismiss', 'custom'],\n paused: ['resume', 'dismiss', 'custom'],\n completed: ['dismiss', 'custom'],\n error: ['retry', 'dismiss', 'custom'],\n} as const satisfies Record<AIToolRunStatus, readonly AIToolRunActionKind[]>;\n\nconst STEP_KEYS_BY_STATUS = {\n pending: new Set(['toolCall', 'title', 'description']),\n running: new Set([\n 'toolCall',\n 'title',\n 'description',\n 'progress',\n 'sourceIds',\n 'currentSourceId',\n ]),\n success: new Set([\n 'toolCall',\n 'title',\n 'description',\n 'durationMs',\n 'sourceIds',\n ]),\n error: new Set(['toolCall', 'title', 'description', 'sourceIds']),\n} as const satisfies Record<\n AIToolRunToolCallSummary['status'],\n ReadonlySet<string>\n>;\n\nconst TOOL_CALL_KEYS_BY_STATUS = {\n pending: new Set(['toolCallId', 'toolName', 'status']),\n running: new Set(['toolCallId', 'toolName', 'status']),\n success: new Set(['toolCallId', 'toolName', 'status']),\n error: new Set(['toolCallId', 'toolName', 'status', 'error']),\n} as const satisfies Record<\n AIToolRunToolCallSummary['status'],\n ReadonlySet<string>\n>;\n\nconst MAX_JSON_DEPTH = 100;\nconst MAX_JSON_NODES = 10_000;\nconst MAX_VALIDATION_ISSUES = 100;\nconst INSPECTION_FAILURE_MESSAGE = 'Value could not be inspected safely';\nconst INVALID_FIELD = Symbol('invalid-shape-field');\n\ntype InvalidField = typeof INVALID_FIELD;\n\ntype ContainerKind = 'array' | 'record' | 'other' | 'uninspectable';\n\ntype JsonWalkFrame =\n | { kind: 'visit'; value: unknown; path: string; depth: number }\n | { kind: 'leave'; value: object };\n\ninterface ArrayItem {\n index: number;\n value: unknown;\n}\n\ninterface ValidatedToolCall {\n toolCallId: string;\n status: AIToolRunToolCallSummary['status'];\n}\n\ninterface ValidatedStep {\n toolCall: ValidatedToolCall;\n sourceIds?: readonly string[];\n currentSourceId?: string;\n}\n\ninterface ValidatedAction {\n id: string;\n kind: AIToolRunActionKind;\n}\n\nfunction addIssue(\n issues: ValidationIssue[],\n path: string,\n message: string,\n): void {\n if (issues.length < MAX_VALIDATION_ISSUES) {\n issues.push({ path, message });\n }\n}\n\nfunction hasIssuesSince(\n issues: readonly ValidationIssue[],\n issueCount: number,\n): boolean {\n return issues.length > issueCount || issues.length >= MAX_VALIDATION_ISSUES;\n}\n\nfunction addInspectionIssue(issues: ValidationIssue[], path: string): void {\n addIssue(issues, path, INSPECTION_FAILURE_MESSAGE);\n}\n\nfunction getContainerKind(\n value: unknown,\n path: string,\n issues: ValidationIssue[],\n): ContainerKind {\n if (value === null || typeof value !== 'object') return 'other';\n\n try {\n const prototype = Reflect.getPrototypeOf(value);\n if (Array.isArray(value)) {\n return prototype === Array.prototype ? 'array' : 'other';\n }\n return prototype === Object.prototype || prototype === null\n ? 'record'\n : 'other';\n } catch {\n addInspectionIssue(issues, path);\n return 'uninspectable';\n }\n}\n\nfunction getOwnKeys(\n value: object,\n path: string,\n issues: ValidationIssue[],\n): readonly PropertyKey[] | undefined {\n try {\n return Reflect.ownKeys(value);\n } catch {\n addInspectionIssue(issues, path);\n return undefined;\n }\n}\n\nfunction getOwnPropertyDescriptor(\n value: object,\n key: PropertyKey,\n path: string,\n issues: ValidationIssue[],\n): PropertyDescriptor | null | undefined {\n try {\n return Reflect.getOwnPropertyDescriptor(value, key);\n } catch {\n addInspectionIssue(issues, path);\n return null;\n }\n}\n\nfunction readEnumerableDataDescriptor(\n _value: object,\n _key: PropertyKey,\n descriptor: PropertyDescriptor,\n path: string,\n issues: ValidationIssue[],\n): { valid: true; value: unknown } | { valid: false } {\n if (!descriptor.enumerable || !Object.hasOwn(descriptor, 'value')) {\n addIssue(issues, path, 'Value must be an own enumerable data property');\n return { valid: false };\n }\n\n return { valid: true, value: descriptor.value };\n}\n\ninterface ReflectedPropertyDescriptor {\n descriptor: PropertyDescriptor;\n isOwn: boolean;\n}\n\ninterface DescriptorPropertyInspection extends ReflectedPropertyDescriptor {\n kind: 'descriptor';\n}\n\ntype PropertyInspection =\n | DescriptorPropertyInspection\n | { kind: 'absent' }\n | { kind: 'synthetic' };\n\nfunction findReflectedPropertyDescriptor(\n value: object,\n key: PropertyKey,\n path: string,\n issues: ValidationIssue[],\n): ReflectedPropertyDescriptor | null | undefined {\n const visited = new Set<object>();\n let current: object | null = value;\n let isOwn = true;\n\n while (current !== null) {\n if (visited.has(current)) {\n addInspectionIssue(issues, path);\n return null;\n }\n visited.add(current);\n\n const descriptor = getOwnPropertyDescriptor(current, key, path, issues);\n if (descriptor === null) return null;\n if (descriptor !== undefined) {\n if (isOwn) {\n const ownKeys = getOwnKeys(value, path, issues);\n if (!ownKeys) return null;\n if (!ownKeys.includes(key)) {\n addIssue(\n issues,\n path,\n 'Own property must be exposed by Reflect.ownKeys',\n );\n return null;\n }\n }\n return { descriptor, isOwn };\n }\n\n try {\n current = Reflect.getPrototypeOf(current);\n } catch {\n addInspectionIssue(issues, path);\n return null;\n }\n isOwn = false;\n }\n\n return undefined;\n}\n\nfunction inspectProperty(\n value: object,\n key: PropertyKey,\n path: string,\n issues: ValidationIssue[],\n): PropertyInspection | undefined {\n const descriptor = findReflectedPropertyDescriptor(value, key, path, issues);\n if (descriptor === null) return undefined;\n if (descriptor !== undefined) return { kind: 'descriptor', ...descriptor };\n\n let present: boolean;\n try {\n present = Reflect.has(value, key);\n } catch {\n addInspectionIssue(issues, path);\n return undefined;\n }\n if (present) return { kind: 'synthetic' };\n\n let visibleValue: unknown;\n try {\n visibleValue = Reflect.get(value, key);\n } catch {\n addInspectionIssue(issues, path);\n return undefined;\n }\n\n return present || visibleValue !== undefined\n ? { kind: 'synthetic' }\n : { kind: 'absent' };\n}\n\nfunction readShapeField(\n value: Record<string, unknown>,\n key: string,\n path: string,\n issues: ValidationIssue[],\n): unknown | InvalidField {\n const inspection = inspectProperty(value, key, path, issues);\n if (!inspection) return INVALID_FIELD;\n\n if (inspection.kind === 'absent') {\n return undefined;\n }\n\n if (inspection.kind === 'synthetic' || !inspection.isOwn) {\n addIssue(issues, path, 'Value must be an own enumerable data property');\n return INVALID_FIELD;\n }\n\n const field = readEnumerableDataDescriptor(\n value,\n key,\n inspection.descriptor,\n path,\n issues,\n );\n return field.valid ? field.value : INVALID_FIELD;\n}\n\nfunction readRequiredField(\n value: Record<string, unknown>,\n key: string,\n path: string,\n issues: ValidationIssue[],\n): unknown | InvalidField {\n return readShapeField(value, key, path, issues);\n}\n\nfunction readOptionalField(\n value: Record<string, unknown>,\n key: string,\n path: string,\n issues: ValidationIssue[],\n): unknown | InvalidField {\n return readShapeField(value, key, path, issues);\n}\n\nfunction isInvalidField(value: unknown): value is InvalidField {\n return value === INVALID_FIELD;\n}\n\nfunction getOwnEnumerableDataKeys(\n value: Record<string, unknown>,\n path: string,\n issues: ValidationIssue[],\n): readonly string[] | undefined {\n const keys = getOwnKeys(value, path, issues);\n if (!keys) return undefined;\n if (keys.length > MAX_JSON_NODES) {\n addIssue(issues, path, 'Value exceeds the maximum JSON node limit');\n return undefined;\n }\n\n const stringKeys: string[] = [];\n for (const key of keys) {\n const keyPath = typeof key === 'string' ? `${path}.${key}` : path;\n const descriptor = getOwnPropertyDescriptor(value, key, keyPath, issues);\n if (descriptor === null) return undefined;\n if (descriptor === undefined) {\n addInspectionIssue(issues, keyPath);\n return undefined;\n }\n if (typeof key !== 'string') {\n addIssue(issues, path, 'Symbol keys are not JSON-safe');\n continue;\n }\n if (\n !readEnumerableDataDescriptor(value, key, descriptor, keyPath, issues)\n .valid\n ) {\n continue;\n }\n stringKeys.push(key);\n }\n\n return stringKeys;\n}\n\nfunction isArrayIndexKey(key: string): number | undefined {\n const index = Number(key);\n if (\n !Number.isInteger(index) ||\n index < 0 ||\n index >= 2 ** 32 - 1 ||\n String(index) !== key\n ) {\n return undefined;\n }\n return index;\n}\n\nfunction readArrayLength(\n _value: readonly unknown[],\n descriptor: PropertyDescriptor,\n path: string,\n issues: ValidationIssue[],\n): number | undefined {\n if (\n descriptor.enumerable ||\n !Object.hasOwn(descriptor, 'value') ||\n typeof descriptor.value !== 'number' ||\n !Number.isInteger(descriptor.value) ||\n descriptor.value < 0 ||\n descriptor.value > 2 ** 32 - 1\n ) {\n addIssue(issues, path, 'Array length must be a valid data property');\n return undefined;\n }\n\n return descriptor.value;\n}\n\nfunction readArrayItems(\n value: readonly unknown[],\n path: string,\n issues: ValidationIssue[],\n): readonly ArrayItem[] | undefined {\n const issueCount = issues.length;\n const keys = getOwnKeys(value, path, issues);\n if (!keys) return undefined;\n if (keys.length > MAX_JSON_NODES + 1) {\n addIssue(issues, path, 'Value exceeds the maximum JSON node limit');\n return undefined;\n }\n\n let length: number | undefined;\n const items = new Map<number, unknown>();\n\n for (const key of keys) {\n const keyPath = typeof key === 'string' ? `${path}.${key}` : path;\n const descriptor = getOwnPropertyDescriptor(value, key, keyPath, issues);\n if (descriptor === null) return undefined;\n if (descriptor === undefined) {\n addInspectionIssue(issues, keyPath);\n return undefined;\n }\n if (typeof key !== 'string') {\n addIssue(issues, path, 'Symbol keys are not JSON-safe');\n continue;\n }\n if (key === 'length') {\n length = readArrayLength(value, descriptor, path, issues);\n continue;\n }\n\n const index = isArrayIndexKey(key);\n if (index === undefined) {\n addIssue(issues, keyPath, 'Arrays must not contain custom properties');\n continue;\n }\n\n const item = readEnumerableDataDescriptor(\n value,\n key,\n descriptor,\n `${path}[${index}]`,\n issues,\n );\n if (item.valid) {\n items.set(index, item.value);\n }\n }\n\n if (length === undefined) {\n if (!hasIssuesSince(issues, issueCount)) {\n addInspectionIssue(issues, path);\n }\n return undefined;\n }\n if (length > MAX_JSON_NODES) {\n addIssue(issues, path, 'Array length exceeds the maximum JSON node limit');\n return undefined;\n }\n\n const orderedItems = [...items.entries()].sort(\n ([left], [right]) => left - right,\n );\n let expectedIndex = 0;\n for (const [index] of orderedItems) {\n if (index !== expectedIndex) {\n addIssue(\n issues,\n `${path}[${expectedIndex}]`,\n 'Array holes are not JSON-safe',\n );\n return undefined;\n }\n expectedIndex += 1;\n }\n if (expectedIndex !== length) {\n addIssue(\n issues,\n `${path}[${expectedIndex}]`,\n 'Array holes are not JSON-safe',\n );\n return undefined;\n }\n if (hasIssuesSince(issues, issueCount)) return undefined;\n\n return orderedItems.map(([index, item]) => ({ index, value: item }));\n}\n\nfunction readObjectChildren(\n value: Record<string, unknown>,\n path: string,\n issues: ValidationIssue[],\n): readonly { path: string; value: unknown }[] | undefined {\n const issueCount = issues.length;\n const keys = getOwnKeys(value, path, issues);\n if (!keys) return undefined;\n if (keys.length > MAX_JSON_NODES) {\n addIssue(issues, path, 'Value exceeds the maximum JSON node limit');\n return undefined;\n }\n\n const children: Array<{ path: string; value: unknown }> = [];\n for (const key of keys) {\n const keyPath = typeof key === 'string' ? `${path}.${key}` : path;\n const descriptor = getOwnPropertyDescriptor(value, key, keyPath, issues);\n if (descriptor === null) return undefined;\n if (descriptor === undefined) {\n addInspectionIssue(issues, keyPath);\n return undefined;\n }\n if (typeof key !== 'string') {\n addIssue(issues, path, 'Symbol keys are not JSON-safe');\n continue;\n }\n\n const child = readEnumerableDataDescriptor(\n value,\n key,\n descriptor,\n keyPath,\n issues,\n );\n if (child.valid) {\n children.push({ path: keyPath, value: child.value });\n }\n }\n\n return hasIssuesSince(issues, issueCount) ? undefined : children;\n}\n\nfunction rejectUnknownKeys(\n value: Record<string, unknown>,\n allowed: ReadonlySet<string>,\n path: string,\n issues: ValidationIssue[],\n): void {\n const keys = getOwnEnumerableDataKeys(value, path, issues);\n if (!keys) return;\n for (const key of keys) {\n if (!allowed.has(key)) {\n addIssue(issues, `${path}.${key}`, `Unknown key \"${key}\"`);\n }\n }\n}\n\nfunction rejectDisallowedKeys(\n value: Record<string, unknown>,\n known: ReadonlySet<string>,\n allowed: ReadonlySet<string>,\n path: string,\n issues: ValidationIssue[],\n): void {\n for (const key of known) {\n if (!allowed.has(key)) {\n const inspection = inspectProperty(value, key, `${path}.${key}`, issues);\n if (!inspection) return;\n if (inspection.kind === 'absent') continue;\n addIssue(\n issues,\n `${path}.${key}`,\n 'Field is not allowed for this status',\n );\n }\n }\n}\n\nfunction rejectPresentKeys(\n value: Record<string, unknown>,\n keys: readonly string[],\n path: string,\n issues: ValidationIssue[],\n): void {\n for (const key of keys) {\n const inspection = inspectProperty(value, key, `${path}.${key}`, issues);\n if (!inspection) return;\n if (inspection.kind === 'absent') continue;\n addIssue(issues, `${path}.${key}`, 'Field is not allowed for this status');\n }\n}\n\nfunction isFiniteNumber(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value);\n}\n\nfunction hasSafeToJSON(\n value: object,\n path: string,\n issues: ValidationIssue[],\n): boolean {\n const descriptor = findReflectedPropertyDescriptor(\n value,\n 'toJSON',\n path,\n issues,\n );\n if (descriptor === null) return false;\n if (descriptor !== undefined) {\n addIssue(issues, path, 'Value must not define toJSON');\n return false;\n }\n\n return true;\n}\n\nfunction validateJsonSafe(\n value: unknown,\n path: string,\n issues: ValidationIssue[],\n): void {\n const ancestors = new Set<object>();\n const stack: JsonWalkFrame[] = [{ kind: 'visit', value, path, depth: 0 }];\n let nodeCount = 0;\n\n while (stack.length > 0 && issues.length < MAX_VALIDATION_ISSUES) {\n const frame = stack.pop();\n if (!frame) break;\n if (frame.kind === 'leave') {\n ancestors.delete(frame.value);\n continue;\n }\n\n if (frame.depth > MAX_JSON_DEPTH) {\n addIssue(\n issues,\n frame.path,\n 'Value exceeds the maximum JSON depth limit',\n );\n continue;\n }\n nodeCount += 1;\n if (nodeCount > MAX_JSON_NODES) {\n addIssue(issues, frame.path, 'Value exceeds the maximum JSON node limit');\n break;\n }\n\n const currentValue = frame.value;\n if (\n currentValue === undefined ||\n typeof currentValue === 'function' ||\n typeof currentValue === 'symbol' ||\n typeof currentValue === 'bigint'\n ) {\n addIssue(issues, frame.path, 'Value must be JSON-safe');\n continue;\n }\n if (typeof currentValue === 'number' && !isFiniteNumber(currentValue)) {\n addIssue(issues, frame.path, 'Number must be finite');\n continue;\n }\n if (currentValue === null || typeof currentValue !== 'object') continue;\n if (ancestors.has(currentValue)) {\n addIssue(issues, frame.path, 'Value must not contain cycles');\n continue;\n }\n\n const containerKind = getContainerKind(currentValue, frame.path, issues);\n if (containerKind === 'uninspectable') continue;\n if (containerKind === 'other') {\n addIssue(\n issues,\n frame.path,\n 'Value must contain only plain objects and arrays',\n );\n continue;\n }\n if (!hasSafeToJSON(currentValue, frame.path, issues)) continue;\n\n ancestors.add(currentValue);\n stack.push({ kind: 'leave', value: currentValue });\n if (containerKind === 'array') {\n const children = readArrayItems(\n currentValue as readonly unknown[],\n frame.path,\n issues,\n );\n if (!children) continue;\n for (let index = children.length - 1; index >= 0; index -= 1) {\n const child = children[index];\n stack.push({\n kind: 'visit',\n value: child.value,\n path: `${frame.path}[${child.index}]`,\n depth: frame.depth + 1,\n });\n }\n continue;\n }\n\n const children = readObjectChildren(\n currentValue as Record<string, unknown>,\n frame.path,\n issues,\n );\n if (!children) continue;\n for (let index = children.length - 1; index >= 0; index -= 1) {\n const child = children[index];\n stack.push({\n kind: 'visit',\n value: child.value,\n path: child.path,\n depth: frame.depth + 1,\n });\n }\n }\n}\n\nconst INVALID_JSON_SNAPSHOT = Symbol('invalid-json-snapshot');\n\ntype InvalidJsonSnapshot = typeof INVALID_JSON_SNAPSHOT;\n\nfunction captureJsonSnapshot(\n value: unknown,\n path: string,\n issues: ValidationIssue[],\n): unknown | InvalidJsonSnapshot {\n const ancestors = new Set<object>();\n const snapshots = new Map<object, object>();\n let nodeCount = 0;\n\n function capture(\n currentValue: unknown,\n currentPath: string,\n depth: number,\n ): unknown | InvalidJsonSnapshot {\n if (issues.length >= MAX_VALIDATION_ISSUES) {\n return INVALID_JSON_SNAPSHOT;\n }\n if (depth > MAX_JSON_DEPTH) {\n addIssue(\n issues,\n currentPath,\n 'Value exceeds the maximum JSON depth limit',\n );\n return INVALID_JSON_SNAPSHOT;\n }\n\n nodeCount += 1;\n if (nodeCount > MAX_JSON_NODES) {\n addIssue(\n issues,\n currentPath,\n 'Value exceeds the maximum JSON node limit',\n );\n return INVALID_JSON_SNAPSHOT;\n }\n\n if (\n currentValue === undefined ||\n typeof currentValue === 'function' ||\n typeof currentValue === 'symbol' ||\n typeof currentValue === 'bigint'\n ) {\n addIssue(issues, currentPath, 'Value must be JSON-safe');\n return INVALID_JSON_SNAPSHOT;\n }\n if (typeof currentValue === 'number' && !isFiniteNumber(currentValue)) {\n addIssue(issues, currentPath, 'Number must be finite');\n return INVALID_JSON_SNAPSHOT;\n }\n if (currentValue === null || typeof currentValue !== 'object') {\n return currentValue;\n }\n if (ancestors.has(currentValue)) {\n addIssue(issues, currentPath, 'Value must not contain cycles');\n return INVALID_JSON_SNAPSHOT;\n }\n\n const containerKind = getContainerKind(currentValue, currentPath, issues);\n if (containerKind === 'uninspectable') return INVALID_JSON_SNAPSHOT;\n if (containerKind === 'other') {\n addIssue(\n issues,\n currentPath,\n 'Value must contain only plain objects and arrays',\n );\n return INVALID_JSON_SNAPSHOT;\n }\n if (!hasSafeToJSON(currentValue, currentPath, issues)) {\n return INVALID_JSON_SNAPSHOT;\n }\n\n const existingSnapshot = snapshots.get(currentValue);\n if (existingSnapshot !== undefined) return existingSnapshot;\n\n ancestors.add(currentValue);\n try {\n if (containerKind === 'array') {\n const items = readArrayItems(\n currentValue as readonly unknown[],\n currentPath,\n issues,\n );\n if (!items) return INVALID_JSON_SNAPSHOT;\n\n const snapshot: unknown[] = new Array(items.length);\n snapshots.set(currentValue, snapshot);\n for (const item of items) {\n const capturedItem = capture(\n item.value,\n `${currentPath}[${item.index}]`,\n depth + 1,\n );\n if (capturedItem === INVALID_JSON_SNAPSHOT) {\n return INVALID_JSON_SNAPSHOT;\n }\n snapshot[item.index] = capturedItem;\n }\n return snapshot;\n }\n\n const children = readObjectChildren(\n currentValue as Record<string, unknown>,\n currentPath,\n issues,\n );\n if (!children) return INVALID_JSON_SNAPSHOT;\n\n const snapshot = Object.create(null) as Record<string, unknown>;\n snapshots.set(currentValue, snapshot);\n for (const child of children) {\n const key = child.path.slice(currentPath.length + 1);\n const capturedChild = capture(child.value, child.path, depth + 1);\n if (capturedChild === INVALID_JSON_SNAPSHOT) {\n return INVALID_JSON_SNAPSHOT;\n }\n Object.defineProperty(snapshot, key, {\n configurable: true,\n enumerable: true,\n value: capturedChild,\n writable: true,\n });\n }\n return snapshot;\n } finally {\n ancestors.delete(currentValue);\n }\n }\n\n return capture(value, path, 0);\n}\n\nfunction requireRecord(\n value: unknown,\n path: string,\n issues: ValidationIssue[],\n): Record<string, unknown> | undefined {\n if (isInvalidField(value)) return undefined;\n const containerKind = getContainerKind(value, path, issues);\n if (containerKind !== 'record') {\n if (containerKind !== 'uninspectable') {\n addIssue(issues, path, 'Value must be a plain object');\n }\n return undefined;\n }\n return value as Record<string, unknown>;\n}\n\nfunction requireString(\n value: unknown,\n path: string,\n issues: ValidationIssue[],\n): string | undefined {\n if (isInvalidField(value)) return undefined;\n if (typeof value !== 'string') {\n addIssue(issues, path, 'Value must be a string');\n return undefined;\n }\n return value;\n}\n\nfunction requireNonEmptyString(\n value: unknown,\n path: string,\n issues: ValidationIssue[],\n): string | undefined {\n const stringValue = requireString(value, path, issues);\n if (stringValue !== undefined && stringValue.length === 0) {\n addIssue(issues, path, 'Value must not be empty');\n return undefined;\n }\n return stringValue;\n}\n\nfunction requireNonWhitespaceString(\n value: unknown,\n path: string,\n issues: ValidationIssue[],\n): string | undefined {\n const stringValue = requireString(value, path, issues);\n if (stringValue !== undefined && stringValue.trim().length === 0) {\n addIssue(issues, path, 'Value must be non-whitespace');\n return undefined;\n }\n return stringValue;\n}\n\nfunction requireBoolean(\n value: unknown,\n path: string,\n issues: ValidationIssue[],\n): boolean | undefined {\n if (isInvalidField(value)) return undefined;\n if (typeof value !== 'boolean') {\n addIssue(issues, path, 'Value must be a boolean');\n return undefined;\n }\n return value;\n}\n\nfunction requireNumber(\n value: unknown,\n path: string,\n issues: ValidationIssue[],\n): number | undefined {\n if (isInvalidField(value)) return undefined;\n if (typeof value !== 'number') {\n addIssue(issues, path, 'Value must be a number');\n return undefined;\n }\n return value;\n}\n\nfunction requireArray(\n value: unknown,\n path: string,\n issues: ValidationIssue[],\n): readonly unknown[] | undefined {\n if (isInvalidField(value)) return undefined;\n try {\n if (Array.isArray(value)) return value;\n } catch {\n addInspectionIssue(issues, path);\n return undefined;\n }\n\n addIssue(issues, path, 'Value must be an array');\n return undefined;\n}\n\nfunction requireRunStatus(\n value: unknown,\n path: string,\n issues: ValidationIssue[],\n): AIToolRunStatus | undefined {\n if (isInvalidField(value)) return undefined;\n if (typeof value !== 'string' || !Object.hasOwn(RUN_STATUSES, value)) {\n addIssue(issues, path, 'Value must be a supported run status');\n return undefined;\n }\n return value as AIToolRunStatus;\n}\n\nfunction requireToolStatus(\n value: unknown,\n path: string,\n issues: ValidationIssue[],\n): AIToolRunToolCallSummary['status'] | undefined {\n if (isInvalidField(value)) return undefined;\n if (typeof value !== 'string' || !Object.hasOwn(TOOL_STATUSES, value)) {\n addIssue(issues, path, 'Value is not allowed as a tool status');\n return undefined;\n }\n return value as AIToolRunToolCallSummary['status'];\n}\n\nfunction requireActionKind(\n value: unknown,\n path: string,\n issues: ValidationIssue[],\n): AIToolRunActionKind | undefined {\n if (isInvalidField(value)) return undefined;\n if (typeof value !== 'string' || !Object.hasOwn(ACTION_KINDS, value)) {\n addIssue(issues, path, 'Value must be an allowed action kind');\n return undefined;\n }\n return value as AIToolRunActionKind;\n}\n\nfunction validateProgress(\n value: unknown,\n path: string,\n issues: ValidationIssue[],\n): void {\n const progress = requireRecord(value, path, issues);\n if (!progress) return;\n\n rejectUnknownKeys(progress, PROGRESS_KEYS, path, issues);\n const progressValue = requireNumber(\n readRequiredField(progress, 'value', `${path}.value`, issues),\n `${path}.value`,\n issues,\n );\n if (\n progressValue !== undefined &&\n (progressValue < 0 || progressValue > 100)\n ) {\n addIssue(issues, `${path}.value`, 'Value must be between 0 and 100');\n }\n const label = readOptionalField(progress, 'label', `${path}.label`, issues);\n if (label !== undefined && !isInvalidField(label)) {\n requireNonWhitespaceString(label, `${path}.label`, issues);\n }\n const meta = readOptionalField(progress, 'meta', `${path}.meta`, issues);\n if (meta !== undefined && !isInvalidField(meta)) {\n requireString(meta, `${path}.meta`, issues);\n }\n}\n\nfunction validateStringArray(\n value: unknown,\n path: string,\n issues: ValidationIssue[],\n): readonly string[] | undefined {\n const issueCount = issues.length;\n const values = requireArray(value, path, issues);\n if (!values) return undefined;\n const items = readArrayItems(values, path, issues);\n if (!items) return undefined;\n\n const strings: string[] = [];\n for (const item of items) {\n const stringValue = requireString(\n item.value,\n `${path}[${item.index}]`,\n issues,\n );\n if (stringValue !== undefined) {\n strings.push(stringValue);\n }\n }\n return hasIssuesSince(issues, issueCount) ? undefined : strings;\n}\n\nfunction validateToolCall(\n value: unknown,\n path: string,\n issues: ValidationIssue[],\n): ValidatedToolCall | undefined {\n const issueCount = issues.length;\n const toolCall = requireRecord(value, path, issues);\n if (!toolCall) return undefined;\n\n rejectUnknownKeys(toolCall, TOOL_CALL_KEYS, path, issues);\n const toolCallId = requireNonEmptyString(\n readRequiredField(toolCall, 'toolCallId', `${path}.toolCallId`, issues),\n `${path}.toolCallId`,\n issues,\n );\n requireNonWhitespaceString(\n readRequiredField(toolCall, 'toolName', `${path}.toolName`, issues),\n `${path}.toolName`,\n issues,\n );\n const status = requireToolStatus(\n readRequiredField(toolCall, 'status', `${path}.status`, issues),\n `${path}.status`,\n issues,\n );\n if (!status) return undefined;\n\n rejectDisallowedKeys(\n toolCall,\n TOOL_CALL_KEYS,\n TOOL_CALL_KEYS_BY_STATUS[status],\n path,\n issues,\n );\n if (status === 'error') {\n const error = readRequiredField(toolCall, 'error', `${path}.error`, issues);\n if (error === undefined) {\n addIssue(\n issues,\n `${path}.error`,\n 'Value is required for error tool calls',\n );\n } else if (!isInvalidField(error)) {\n requireNonWhitespaceString(error, `${path}.error`, issues);\n }\n }\n\n if (hasIssuesSince(issues, issueCount) || !toolCallId) return undefined;\n return { toolCallId, status };\n}\n\nfunction validateStep(\n value: unknown,\n path: string,\n issues: ValidationIssue[],\n): ValidatedStep | undefined {\n const issueCount = issues.length;\n const step = requireRecord(value, path, issues);\n if (!step) return undefined;\n\n rejectUnknownKeys(step, STEP_KEYS, path, issues);\n const title = readOptionalField(step, 'title', `${path}.title`, issues);\n if (title !== undefined && !isInvalidField(title)) {\n requireString(title, `${path}.title`, issues);\n }\n const description = readOptionalField(\n step,\n 'description',\n `${path}.description`,\n issues,\n );\n if (description !== undefined && !isInvalidField(description)) {\n requireString(description, `${path}.description`, issues);\n }\n\n const toolCall = validateToolCall(\n readRequiredField(step, 'toolCall', `${path}.toolCall`, issues),\n `${path}.toolCall`,\n issues,\n );\n if (!toolCall) return undefined;\n const { status } = toolCall;\n\n rejectDisallowedKeys(\n step,\n STEP_KEYS,\n STEP_KEYS_BY_STATUS[status],\n path,\n issues,\n );\n const progress = readOptionalField(\n step,\n 'progress',\n `${path}.progress`,\n issues,\n );\n if (progress !== undefined && !isInvalidField(progress)) {\n validateProgress(progress, `${path}.progress`, issues);\n }\n const sourceIdsField = readOptionalField(\n step,\n 'sourceIds',\n `${path}.sourceIds`,\n issues,\n );\n const sourceIds =\n sourceIdsField === undefined || isInvalidField(sourceIdsField)\n ? undefined\n : validateStringArray(sourceIdsField, `${path}.sourceIds`, issues);\n\n const currentSourceIdField = readOptionalField(\n step,\n 'currentSourceId',\n `${path}.currentSourceId`,\n issues,\n );\n const currentSourceId =\n currentSourceIdField === undefined || isInvalidField(currentSourceIdField)\n ? undefined\n : requireString(currentSourceIdField, `${path}.currentSourceId`, issues);\n\n const durationMsField = readOptionalField(\n step,\n 'durationMs',\n `${path}.durationMs`,\n issues,\n );\n if (durationMsField !== undefined && !isInvalidField(durationMsField)) {\n const durationMs = requireNumber(\n durationMsField,\n `${path}.durationMs`,\n issues,\n );\n if (durationMs !== undefined && durationMs < 0) {\n addIssue(issues, `${path}.durationMs`, 'Value must be non-negative');\n }\n }\n\n if (hasIssuesSince(issues, issueCount)) return undefined;\n return {\n toolCall,\n ...(sourceIds === undefined ? {} : { sourceIds }),\n ...(currentSourceId === undefined ? {} : { currentSourceId }),\n };\n}\n\nfunction validateSource(\n value: unknown,\n path: string,\n issues: ValidationIssue[],\n): string | undefined {\n const issueCount = issues.length;\n const source = requireRecord(value, path, issues);\n if (!source) return undefined;\n\n rejectUnknownKeys(source, SOURCE_KEYS, path, issues);\n const id = requireNonEmptyString(\n readRequiredField(source, 'id', `${path}.id`, issues),\n `${path}.id`,\n issues,\n );\n requireNonWhitespaceString(\n readRequiredField(source, 'url', `${path}.url`, issues),\n `${path}.url`,\n issues,\n );\n for (const key of ['title', 'description', 'favicon', 'siteName'] as const) {\n const field = readOptionalField(source, key, `${path}.${key}`, issues);\n if (field !== undefined && !isInvalidField(field)) {\n requireString(field, `${path}.${key}`, issues);\n }\n }\n\n return hasIssuesSince(issues, issueCount) || !id ? undefined : id;\n}\n\nfunction validateSources(\n value: unknown,\n path: string,\n issues: ValidationIssue[],\n): Set<string> {\n const sourceIds = new Set<string>();\n const sources = requireArray(value, path, issues);\n if (!sources) return sourceIds;\n\n const sourceItems = readArrayItems(sources, path, issues);\n if (!sourceItems) return sourceIds;\n\n for (const item of sourceItems) {\n const sourcePath = `${path}[${item.index}]`;\n const sourceId = validateSource(item.value, sourcePath, issues);\n if (!sourceId) continue;\n if (sourceIds.has(sourceId)) {\n addIssue(issues, `${sourcePath}.id`, 'duplicate source ID');\n continue;\n }\n sourceIds.add(sourceId);\n }\n return sourceIds;\n}\n\nfunction validateAction(\n value: unknown,\n path: string,\n issues: ValidationIssue[],\n): ValidatedAction | undefined {\n const issueCount = issues.length;\n const action = requireRecord(value, path, issues);\n if (!action) return undefined;\n\n rejectUnknownKeys(action, ACTION_KEYS, path, issues);\n const id = requireNonEmptyString(\n readRequiredField(action, 'id', `${path}.id`, issues),\n `${path}.id`,\n issues,\n );\n const kind = requireActionKind(\n readRequiredField(action, 'kind', `${path}.kind`, issues),\n `${path}.kind`,\n issues,\n );\n if (!kind) return undefined;\n\n const label =\n kind === 'custom'\n ? readRequiredField(action, 'label', `${path}.label`, issues)\n : readOptionalField(action, 'label', `${path}.label`, issues);\n if (kind === 'custom' && label === undefined) {\n addIssue(issues, `${path}.label`, 'Value is required for custom actions');\n } else if (label !== undefined && !isInvalidField(label)) {\n requireNonWhitespaceString(label, `${path}.label`, issues);\n }\n const disabled = readOptionalField(\n action,\n 'disabled',\n `${path}.disabled`,\n issues,\n );\n if (disabled !== undefined && !isInvalidField(disabled)) {\n requireBoolean(disabled, `${path}.disabled`, issues);\n }\n const loading = readOptionalField(\n action,\n 'loading',\n `${path}.loading`,\n issues,\n );\n if (loading !== undefined && !isInvalidField(loading)) {\n requireBoolean(loading, `${path}.loading`, issues);\n }\n\n return hasIssuesSince(issues, issueCount) || !id ? undefined : { id, kind };\n}\n\nfunction validateActions(\n value: unknown,\n path: string,\n status: AIToolRunStatus | undefined,\n issues: ValidationIssue[],\n): void {\n const actions = requireArray(value, path, issues);\n if (!actions) return;\n\n const actionItems = readArrayItems(actions, path, issues);\n if (!actionItems) return;\n\n const actionIds = new Set<string>();\n for (const item of actionItems) {\n const actionPath = `${path}[${item.index}]`;\n const action = validateAction(item.value, actionPath, issues);\n if (!action) continue;\n if (actionIds.has(action.id)) {\n addIssue(issues, `${actionPath}.id`, 'duplicate action ID');\n } else {\n actionIds.add(action.id);\n }\n if (\n status &&\n !(ACTIONS_BY_STATUS[status] as readonly AIToolRunActionKind[]).includes(\n action.kind,\n )\n ) {\n addIssue(\n issues,\n `${actionPath}.kind`,\n `Action kind \"${action.kind}\" is not allowed for ${status} runs`,\n );\n }\n }\n}\n\nfunction validateLifecycle(\n status: AIToolRunStatus,\n steps: readonly ValidatedStep[],\n issues: ValidationIssue[],\n): void {\n const statuses = steps.map((step) => step.toolCall.status);\n switch (status) {\n case 'ready':\n if (statuses.some((stepStatus) => stepStatus !== 'pending')) {\n addIssue(issues, '$.steps', 'Ready runs allow pending steps only');\n }\n return;\n case 'running':\n case 'paused':\n if (\n statuses.some(\n (stepStatus) =>\n stepStatus !== 'pending' &&\n stepStatus !== 'running' &&\n stepStatus !== 'success',\n ) ||\n !statuses.includes('running')\n ) {\n addIssue(\n issues,\n '$.steps',\n `${status} runs require at least one running step and allow pending, running, or success only`,\n );\n }\n return;\n case 'completed':\n if (\n steps.length === 0 ||\n statuses.some((stepStatus) => stepStatus !== 'success')\n ) {\n addIssue(\n issues,\n '$.steps',\n 'Completed runs require a non-empty all-success step list',\n );\n }\n return;\n case 'error':\n if (\n statuses.some(\n (stepStatus) =>\n stepStatus !== 'pending' &&\n stepStatus !== 'success' &&\n stepStatus !== 'error',\n )\n ) {\n addIssue(\n issues,\n '$.steps',\n 'Error runs allow pending, success, or error steps only',\n );\n }\n return;\n default:\n assertNever(status);\n }\n}\n\nfunction validateSourceReferences(\n steps: readonly ValidatedStep[],\n sourceIds: ReadonlySet<string>,\n issues: ValidationIssue[],\n): void {\n for (const [stepIndex, step] of steps.entries()) {\n const sourceIdPath = `$.steps[${stepIndex}].sourceIds`;\n const stepSourceIds = step.sourceIds;\n if (stepSourceIds) {\n for (const [sourceIndex, sourceId] of stepSourceIds.entries()) {\n if (!sourceIds.has(sourceId)) {\n addIssue(\n issues,\n `${sourceIdPath}[${sourceIndex}]`,\n 'Unknown source reference',\n );\n }\n }\n }\n\n const currentSourceId = step.currentSourceId;\n if (currentSourceId === undefined) continue;\n const currentSourcePath = `$.steps[${stepIndex}].currentSourceId`;\n if (!sourceIds.has(currentSourceId)) {\n addIssue(issues, currentSourcePath, 'Unknown current source reference');\n } else if (!stepSourceIds?.includes(currentSourceId)) {\n addIssue(\n issues,\n currentSourcePath,\n 'Current source ID must be included in sourceIds',\n );\n }\n }\n}\n\nfunction validateActiveStepReference(\n status: AIToolRunStatus | undefined,\n activeStepId: string | undefined,\n steps: readonly ValidatedStep[],\n issues: ValidationIssue[],\n): void {\n if (\n (status !== 'running' && status !== 'paused') ||\n activeStepId === undefined\n ) {\n return;\n }\n\n if (\n !steps.some(\n (step) =>\n step.toolCall.status === 'running' &&\n step.toolCall.toolCallId === activeStepId,\n )\n ) {\n addIssue(\n issues,\n '$.activeStepId',\n 'Active step ID must reference a running step',\n );\n }\n}\n\nfunction validateMetadata(\n value: unknown,\n path: string,\n issues: ValidationIssue[],\n): void {\n const metadata = requireArray(value, path, issues);\n if (!metadata) return;\n\n const metadataItems = readArrayItems(metadata, path, issues);\n if (!metadataItems) return;\n\n for (const item of metadataItems) {\n const itemPath = `${path}[${item.index}]`;\n const record = requireRecord(item.value, itemPath, issues);\n if (!record) continue;\n rejectUnknownKeys(record, METADATA_KEYS, itemPath, issues);\n requireNonWhitespaceString(\n readRequiredField(record, 'label', `${itemPath}.label`, issues),\n `${itemPath}.label`,\n issues,\n );\n requireString(\n readRequiredField(record, 'value', `${itemPath}.value`, issues),\n `${itemPath}.value`,\n issues,\n );\n }\n}\n\nfunction validateHeader(\n value: unknown,\n path: string,\n issues: ValidationIssue[],\n): void {\n const header = requireRecord(value, path, issues);\n if (!header) return;\n\n rejectUnknownKeys(header, HEADER_KEYS, path, issues);\n requireNonWhitespaceString(\n readRequiredField(header, 'title', `${path}.title`, issues),\n `${path}.title`,\n issues,\n );\n const description = readOptionalField(\n header,\n 'description',\n `${path}.description`,\n issues,\n );\n if (description !== undefined && !isInvalidField(description)) {\n requireString(description, `${path}.description`, issues);\n }\n const metadata = readOptionalField(\n header,\n 'metadata',\n `${path}.metadata`,\n issues,\n );\n if (metadata !== undefined && !isInvalidField(metadata)) {\n validateMetadata(metadata, `${path}.metadata`, issues);\n }\n}\n\nfunction validateStateFields(\n status: AIToolRunStatus,\n snapshot: Record<string, unknown>,\n issues: ValidationIssue[],\n): string | undefined {\n switch (status) {\n case 'ready':\n case 'completed':\n rejectPresentKeys(\n snapshot,\n ['progress', 'activeStepId', 'error'],\n '$',\n issues,\n );\n return undefined;\n case 'running':\n case 'paused': {\n rejectPresentKeys(snapshot, ['error'], '$', issues);\n const progress = readOptionalField(\n snapshot,\n 'progress',\n '$.progress',\n issues,\n );\n if (progress !== undefined && !isInvalidField(progress)) {\n validateProgress(progress, '$.progress', issues);\n }\n const activeStepId = readOptionalField(\n snapshot,\n 'activeStepId',\n '$.activeStepId',\n issues,\n );\n return activeStepId === undefined || isInvalidField(activeStepId)\n ? undefined\n : requireString(activeStepId, '$.activeStepId', issues);\n }\n case 'error': {\n rejectPresentKeys(snapshot, ['activeStepId'], '$', issues);\n const progress = readOptionalField(\n snapshot,\n 'progress',\n '$.progress',\n issues,\n );\n if (progress !== undefined && !isInvalidField(progress)) {\n validateProgress(progress, '$.progress', issues);\n }\n const error = requireRecord(\n readRequiredField(snapshot, 'error', '$.error', issues),\n '$.error',\n issues,\n );\n if (!error) return undefined;\n rejectUnknownKeys(error, ROOT_ERROR_KEYS, '$.error', issues);\n requireNonWhitespaceString(\n readRequiredField(error, 'message', '$.error.message', issues),\n '$.error.message',\n issues,\n );\n return undefined;\n }\n default:\n assertNever(status);\n }\n}\n\nexport function validateAIToolRunSnapshot(\n value: unknown,\n): AIToolRunValidationResult {\n const issues: ValidationIssue[] = [];\n\n try {\n const capturedValue = captureJsonSnapshot(value, '$', issues);\n if (issues.length > 0) {\n return { valid: false, issues };\n }\n if (capturedValue === INVALID_JSON_SNAPSHOT) {\n return {\n valid: false,\n issues: [{ path: '$', message: INSPECTION_FAILURE_MESSAGE }],\n };\n }\n\n validateJsonSafe(capturedValue, '$', issues);\n if (issues.length > 0) {\n return { valid: false, issues };\n }\n\n const snapshot = requireRecord(capturedValue, '$', issues);\n if (!snapshot) {\n return { valid: false, issues };\n }\n\n rejectUnknownKeys(snapshot, ROOT_KEYS, '$', issues);\n const status = requireRunStatus(\n readRequiredField(snapshot, 'status', '$.status', issues),\n '$.status',\n issues,\n );\n const activeStepId = status\n ? validateStateFields(status, snapshot, issues)\n : undefined;\n\n requireNonEmptyString(\n readRequiredField(snapshot, 'runId', '$.runId', issues),\n '$.runId',\n issues,\n );\n validateHeader(\n readRequiredField(snapshot, 'header', '$.header', issues),\n '$.header',\n issues,\n );\n\n const steps = requireArray(\n readRequiredField(snapshot, 'steps', '$.steps', issues),\n '$.steps',\n issues,\n );\n const validatedSteps: ValidatedStep[] = [];\n let stepsAreValid = false;\n if (steps) {\n const stepItems = readArrayItems(steps, '$.steps', issues);\n if (stepItems) {\n const toolCallIds = new Set<string>();\n for (const item of stepItems) {\n const validatedStep = validateStep(\n item.value,\n `$.steps[${item.index}]`,\n issues,\n );\n if (!validatedStep) continue;\n if (toolCallIds.has(validatedStep.toolCall.toolCallId)) {\n addIssue(\n issues,\n `$.steps[${item.index}].toolCall.toolCallId`,\n 'duplicate tool-call ID',\n );\n } else {\n toolCallIds.add(validatedStep.toolCall.toolCallId);\n }\n validatedSteps.push(validatedStep);\n }\n stepsAreValid = validatedSteps.length === stepItems.length;\n if (status && stepsAreValid) {\n validateLifecycle(status, validatedSteps, issues);\n }\n }\n }\n\n const sources = readOptionalField(snapshot, 'sources', '$.sources', issues);\n const sourceIds =\n sources === undefined || isInvalidField(sources)\n ? new Set<string>()\n : validateSources(sources, '$.sources', issues);\n if (stepsAreValid) {\n validateSourceReferences(validatedSteps, sourceIds, issues);\n validateActiveStepReference(status, activeStepId, validatedSteps, issues);\n }\n\n const actions = readOptionalField(snapshot, 'actions', '$.actions', issues);\n if (actions !== undefined && !isInvalidField(actions)) {\n validateActions(actions, '$.actions', status, issues);\n }\n\n if (issues.length > 0) {\n return { valid: false, issues };\n }\n return { valid: true, value: capturedValue as AIToolRunSnapshot };\n } catch {\n return {\n valid: false,\n issues: [{ path: '$', message: INSPECTION_FAILURE_MESSAGE }],\n };\n }\n}\n"],"mappings":";;AAuJA,IAAM,4BAAY,IAAI,IAAI;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,IAAM,8BAAc,IAAI,IAAI;CAAC;CAAS;CAAe;AAAU,CAAC;AAChE,IAAM,gCAAgB,IAAI,IAAI,CAAC,SAAS,OAAO,CAAC;AAChD,IAAM,gCAAgB,IAAI,IAAI;CAAC;CAAS;CAAS;AAAM,CAAC;AACxD,IAAM,kCAAkB,IAAI,IAAI,CAAC,SAAS,CAAC;AAC3C,IAAM,8BAAc,IAAI,IAAI;CAC1B;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,IAAM,8BAAc,IAAI,IAAI;CAAC;CAAM;CAAQ;CAAS;CAAY;AAAS,CAAC;AAC1E,IAAM,4BAAY,IAAI,IAAI;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,IAAM,iCAAiB,IAAI,IAAI;CAAC;CAAc;CAAY;CAAU;AAAO,CAAC;AAE5E,IAAM,gBAAgB;CACpB,OAAO;CACP,SAAS;CACT,SAAS;CACT,SAAS;AACX;AAEA,IAAM,eAAe;CACnB,WAAW;CACX,OAAO;CACP,QAAQ;CACR,OAAO;CACP,SAAS;AACX;AAEA,IAAM,eAAe;CACnB,QAAQ;CACR,SAAS;CACT,OAAO;CACP,QAAQ;CACR,OAAO;CACP,OAAO;AACT;AAEA,IAAM,oBAAoB;CACxB,OAAO;EAAC;EAAS;EAAW;CAAQ;CACpC,SAAS;EAAC;EAAS;EAAW;CAAQ;CACtC,QAAQ;EAAC;EAAU;EAAW;CAAQ;CACtC,WAAW,CAAC,WAAW,QAAQ;CAC/B,OAAO;EAAC;EAAS;EAAW;CAAQ;AACtC;AAEA,IAAM,s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gB,aACpB,KAAK,OACL,WAAW,KAAK,MAAM,IACtB,MACF;KACA,IAAI,CAAC,eAAe;KACpB,IAAI,YAAY,IAAI,cAAc,SAAS,UAAU,GACnD,SACE,QACA,WAAW,KAAK,MAAM,wBACtB,wBACF;UAEA,YAAY,IAAI,cAAc,SAAS,UAAU;KAEnD,eAAe,KAAK,aAAa;IACnC;IACA,gBAAgB,eAAe,WAAW,UAAU;IACpD,IAAI,UAAU,eACZ,kBAAkB,QAAQ,gBAAgB,MAAM;GAEpD;EACF;EAEA,MAAM,UAAU,kBAAkB,UAAU,WAAW,aAAa,MAAM;EAC1E,MAAM,YACJ,YAAY,KAAA,KAAa,eAAe,OAAO,oBAC3C,IAAI,IAAY,IAChB,gBAAgB,SAAS,aAAa,MAAM;EAClD,IAAI,eAAe;GACjB,yBAAyB,gBAAgB,WAAW,MAAM;GAC1D,4BAA4B,QAAQ,cAAc,gBAAgB,MAAM;EAC1E;EAEA,MAAM,UAAU,kBAAkB,UAAU,WAAW,aAAa,MAAM;EAC1E,IAAI,YAAY,KAAA,KAAa,CAAC,eAAe,OAAO,GAClD,gBAAgB,SAAS,aAAa,QAAQ,MAAM;EAGtD,IAAI,OAAO,SAAS,GAClB,OAAO;GAAE,OAAO;GAAO;EAAO;EAEhC,OAAO;GAAE,OAAO;GAAM,OAAO;EAAmC;CAClE,QAAQ;EACN,OAAO;GACL,OAAO;GACP,QAAQ,CAAC;IAAE,MAAM;IAAK,SAAS;GAA2B,CAAC;EAC7D;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index184.js","names":[],"sources":["../src/components/organisms/ai/AIToolCall/AIToolCall.tsx"],"sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority';\nimport {\n AlertCircle,\n Check,\n ChevronDown,\n ChevronRight,\n Clock,\n Code,\n Wrench,\n} from 'lucide-react';\nimport { AnimatePresence, motion } from 'motion/react';\nimport * as React from 'react';\nimport { AICodeBlock } from '@/components/organisms/ai/AICodeBlock';\nimport { useControllableState } from '@/hooks/use-controllable-state';\nimport { cn } from '@/lib/utils';\n\n// =============================================================================\n// Variants\n// =============================================================================\n\nconst toolCallVariants = cva(\n 'overflow-hidden rounded-xl border transition-colors',\n {\n variants: {\n status: {\n pending: 'border-border bg-muted',\n running: 'border-primary bg-primary/10',\n success: 'border-success/50 bg-success/10',\n error: 'border-destructive/50 bg-destructive/10',\n },\n },\n defaultVariants: {\n status: 'pending',\n },\n },\n);\n\nconst statusIconVariants = cva('size-4', {\n variants: {\n status: {\n pending: 'text-muted-foreground',\n running: 'text-primary animate-spin motion-reduce:animate-none',\n success: 'text-success',\n error: 'text-destructive',\n },\n },\n defaultVariants: {\n status: 'pending',\n },\n});\n\n// =============================================================================\n// Types\n// =============================================================================\n\nexport type ToolCallStatus = 'pending' | 'running' | 'success' | 'error';\n\nexport interface ToolCallPart {\n /** Unique tool call ID */\n toolCallId: string;\n /** Tool name */\n toolName: string;\n /** Tool input/arguments */\n args?: Record<string, unknown>;\n /** Tool output/result */\n result?: unknown;\n /** Tool status */\n status?: ToolCallStatus;\n /** Error message if status is error */\n error?: string;\n}\n\n// =============================================================================\n// Status Icon Component\n// =============================================================================\n\ninterface StatusIconProps {\n status: ToolCallStatus;\n className?: string;\n}\n\nfunction StatusIcon({ status, className }: StatusIconProps) {\n const iconClass = cn(statusIconVariants({ status }), className);\n\n switch (status) {\n case 'running':\n return <Clock className={iconClass} />;\n case 'success':\n return (\n <Check\n className={cn(\n iconClass,\n 'delight-check-bounce motion-reduce:!animate-none',\n )}\n />\n );\n case 'error':\n return (\n <AlertCircle\n className={cn(iconClass, 'delight-shake motion-reduce:!animate-none')}\n />\n );\n default:\n return <Wrench className={iconClass} />;\n }\n}\n\nStatusIcon.displayName = 'StatusIcon';\n\n// =============================================================================\n// Tool Call Header\n// =============================================================================\n\ninterface AIToolCallHeaderProps {\n toolName: string;\n status: ToolCallStatus;\n isOpen: boolean;\n onToggle: () => void;\n className?: string;\n}\n\nfunction AIToolCallHeader({\n toolName,\n status,\n isOpen,\n onToggle,\n className,\n}: AIToolCallHeaderProps) {\n const statusLabel = {\n pending: 'Pending',\n running: 'Running...',\n success: 'Completed',\n error: 'Failed',\n };\n\n return (\n <button\n type=\"button\"\n onClick={onToggle}\n aria-expanded={isOpen}\n className={cn(\n 'flex items-center justify-between w-full px-4 py-3 transition-colors hover:bg-foreground/5 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring',\n className,\n )}\n >\n <div className=\"flex items-center gap-3\">\n <StatusIcon status={status} aria-hidden=\"true\" />\n <div className=\"flex flex-col items-start\">\n <span className=\"text-sm font-medium text-foreground\">\n {toolName}\n </span>\n <span className=\"text-xs text-text-quaternary\">\n {statusLabel[status]}\n </span>\n </div>\n </div>\n {isOpen ? (\n <ChevronDown\n className=\"size-4 text-muted-foreground\"\n aria-hidden=\"true\"\n />\n ) : (\n <ChevronRight\n className=\"size-4 text-muted-foreground rtl:rotate-180\"\n aria-hidden=\"true\"\n />\n )}\n </button>\n );\n}\n\nAIToolCallHeader.displayName = 'AIToolCallHeader';\n\n// =============================================================================\n// Tool Call Section\n// =============================================================================\n\ninterface ToolCallSectionProps {\n title: string;\n icon: React.ReactNode;\n children: React.ReactNode;\n className?: string;\n}\n\nfunction ToolCallSection({\n title,\n icon,\n children,\n className,\n}: ToolCallSectionProps) {\n return (\n <div className={cn('space-y-2', className)}>\n <div className=\"flex items-center gap-2 text-xs font-medium text-text-quaternary uppercase tracking-wide\">\n {icon}\n {title}\n </div>\n {children}\n </div>\n );\n}\n\nToolCallSection.displayName = 'ToolCallSection';\n\n// =============================================================================\n// Main AIToolCall Component\n// =============================================================================\n\nexport interface AIToolCallProps extends VariantProps<typeof toolCallVariants> {\n /** Tool call data */\n toolPart: ToolCallPart;\n /** Whether to expand by default */\n defaultOpen?: boolean;\n /** Controlled open state */\n open?: boolean;\n /** Callback when open state changes */\n onOpenChange?: (open: boolean) => void;\n /** Additional class name */\n className?: string;\n}\n\nfunction formatValue(value: unknown): string {\n if (typeof value === 'string') return value;\n return JSON.stringify(value, null, 2);\n}\n\nfunction AIToolCall({\n toolPart,\n defaultOpen = false,\n open: controlledOpen,\n onOpenChange,\n className,\n}: AIToolCallProps) {\n const [isOpen, setIsOpen] = useControllableState({\n value: controlledOpen,\n defaultValue: defaultOpen,\n onChange: onOpenChange,\n });\n\n const status = toolPart.status || 'pending';\n\n const handleToggle = () => {\n setIsOpen(!isOpen);\n };\n\n return (\n <div\n data-slot=\"ai-tool-call\"\n className={cn(toolCallVariants({ status }), className)}\n >\n <AIToolCallHeader\n toolName={toolPart.toolName}\n status={status}\n isOpen={isOpen}\n onToggle={handleToggle}\n />\n\n <AnimatePresence>\n {isOpen && (\n <motion.div\n initial={{ height: 0, opacity: 0 }}\n animate={{ height: 'auto', opacity: 1 }}\n exit={{ height: 0, opacity: 0 }}\n transition={{ duration: 0.2 }}\n className=\"overflow-hidden\"\n >\n <div className=\"px-4 pb-4 space-y-4\">\n {/* Tool Call ID */}\n <div className=\"text-xs text-muted-foreground font-mono\">\n ID: {toolPart.toolCallId}\n </div>\n\n {/* Input Section */}\n {toolPart.args && Object.keys(toolPart.args).length > 0 && (\n <ToolCallSection\n title=\"Input\"\n icon={<Code className=\"size-3\" />}\n >\n <AICodeBlock\n code={formatValue(toolPart.args)}\n language=\"json\"\n showHeader={false}\n showCopyButton={true}\n size=\"sm\"\n />\n </ToolCallSection>\n )}\n\n {/* Output Section */}\n {toolPart.result !== undefined && (\n <ToolCallSection\n title=\"Output\"\n icon={<Code className=\"size-3\" />}\n >\n <AICodeBlock\n code={formatValue(toolPart.result)}\n language=\"json\"\n showHeader={false}\n showCopyButton={true}\n size=\"sm\"\n />\n </ToolCallSection>\n )}\n\n {/* Error Section */}\n {toolPart.error && (\n <div className=\"p-3 rounded-lg bg-destructive/20 border border-destructive/50\">\n <div className=\"flex items-start gap-2\">\n <AlertCircle className=\"size-4 text-destructive mt-0.5 shrink-0\" />\n <p className=\"text-sm text-destructive\">{toolPart.error}</p>\n </div>\n </div>\n )}\n </div>\n </motion.div>\n )}\n </AnimatePresence>\n </div>\n );\n}\n\nAIToolCall.displayName = 'AIToolCall';\n\n// =============================================================================\n// Tool Call List Component\n// =============================================================================\n\nexport interface AIToolCallListProps {\n /** Array of tool calls */\n toolCalls: readonly ToolCallPart[];\n /** Whether to expand all by default */\n defaultAllOpen?: boolean;\n /** Tool-call IDs to expand initially in uncontrolled mode */\n defaultOpenToolCallIds?: readonly string[];\n /** Controlled expanded tool-call IDs */\n openToolCallIds?: readonly string[];\n /** Called with expanded IDs in current tool-call order */\n onOpenToolCallIdsChange?: (ids: readonly string[]) => void;\n /** Additional class name */\n className?: string;\n}\n\nfunction normalizeOpenToolCallIds(\n ids: readonly string[],\n toolCalls: readonly ToolCallPart[],\n): string[] {\n const requested = new Set(ids);\n return toolCalls.flatMap((toolCall) =>\n requested.has(toolCall.toolCallId) ? [toolCall.toolCallId] : [],\n );\n}\n\nfunction areToolCallIdsEqual(\n left: readonly string[],\n right: readonly string[],\n): boolean {\n return (\n left.length === right.length &&\n left.every((id, index) => id === right[index])\n );\n}\n\nfunction AIToolCallList({\n toolCalls,\n defaultAllOpen = false,\n defaultOpenToolCallIds = [],\n openToolCallIds: controlledOpenToolCallIds,\n onOpenToolCallIdsChange,\n className,\n}: AIToolCallListProps) {\n const isControlled = controlledOpenToolCallIds !== undefined;\n const [uncontrolledOpenToolCallIds, setUncontrolledOpenToolCallIds] =\n React.useState<readonly string[]>(() =>\n normalizeOpenToolCallIds(\n defaultAllOpen\n ? toolCalls.map((toolCall) => toolCall.toolCallId)\n : defaultOpenToolCallIds,\n toolCalls,\n ),\n );\n const rawOpenToolCallIds = isControlled\n ? controlledOpenToolCallIds\n : uncontrolledOpenToolCallIds;\n const visibleOpenToolCallIds = normalizeOpenToolCallIds(\n rawOpenToolCallIds,\n toolCalls,\n );\n const openSet = new Set(visibleOpenToolCallIds);\n\n React.useLayoutEffect(() => {\n if (isControlled) return;\n setUncontrolledOpenToolCallIds((current) => {\n const normalized = normalizeOpenToolCallIds(current, toolCalls);\n return areToolCallIdsEqual(current, normalized) ? current : normalized;\n });\n }, [isControlled, toolCalls]);\n\n const setToolCallOpen = (toolCallId: string, open: boolean) => {\n const next = new Set(visibleOpenToolCallIds);\n if (open) next.add(toolCallId);\n else next.delete(toolCallId);\n const normalized = normalizeOpenToolCallIds([...next], toolCalls);\n if (!isControlled) {\n setUncontrolledOpenToolCallIds(normalized);\n }\n onOpenToolCallIdsChange?.([...normalized]);\n };\n\n return (\n <div data-slot=\"ai-tool-call-list\" className={cn('space-y-2', className)}>\n {toolCalls.map((toolCall) => (\n <AIToolCall\n key={toolCall.toolCallId}\n toolPart={toolCall}\n open={openSet.has(toolCall.toolCallId)}\n onOpenChange={(open) => setToolCallOpen(toolCall.toolCallId, open)}\n />\n ))}\n </div>\n );\n}\n\nAIToolCallList.displayName = 'AIToolCallList';\n\nexport {\n AIToolCall,\n AIToolCallHeader,\n AIToolCallList,\n StatusIcon,\n statusIconVariants,\n ToolCallSection,\n toolCallVariants,\n};\n"],"mappings":";;;;;;;;;AAoBA,IAAM,mBAAmB,IACvB,uDACA;CACE,UAAU,EACR,QAAQ;EACN,SAAS;EACT,SAAS;EACT,SAAS;EACT,OAAO;CACT,EACF;CACA,iBAAiB,EACf,QAAQ,UACV;AACF,CACF;AAEA,IAAM,qBAAqB,IAAI,UAAU;CACvC,UAAU,EACR,QAAQ;EACN,SAAS;EACT,SAAS;EACT,SAAS;EACT,OAAO;CACT,EACF;CACA,iBAAiB,EACf,QAAQ,UACV;AACF,CAAC;AAgCD,SAAS,WAAW,EAAE,QAAQ,aAA8B;CAC1D,MAAM,YAAY,GAAG,mBAAmB,EAAE,OAAO,CAAC,GAAG,SAAS;CAE9D,QAAQ,QAAR;EACE,KAAK,WACH,OAAO,oBAAC,OAAD,EAAO,WAAW,UAAY,CAAA;EACvC,KAAK,WACH,OACE,oBAAC,OAAD,EACE,WAAW,GACT,WACA,kDACF,EACD,CAAA;EAEL,KAAK,SAC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