* Resolves canonical pair ids (e.g. `tableId`, `knowledgeBaseId`) from a tool's * raw params, filling them in from their basic/advanced selector subblock source * values when the canonical key isn't already present. * * Selector subblocks persist their value under the subblock id (e.g. * `table
( params: Record<string, any>, canonicalGroups: CanonicalGroup[], blockType: string, canonicalModes?: Record<string, 'basic' | 'advanced'> )
| 488 | * @returns The params with canonical resource ids resolved (non-destructive) |
| 489 | */ |
| 490 | function resolveCanonicalResourceParams( |
| 491 | params: Record<string, any>, |
| 492 | canonicalGroups: CanonicalGroup[], |
| 493 | blockType: string, |
| 494 | canonicalModes?: Record<string, 'basic' | 'advanced'> |
| 495 | ): Record<string, any> { |
| 496 | if (canonicalGroups.length === 0) return params |
| 497 | const resolved = { ...params } |
| 498 | for (const group of canonicalGroups) { |
| 499 | const existing = resolved[group.canonicalId] |
| 500 | if (existing !== undefined && existing !== null && existing !== '') continue |
| 501 | // Route through the canonical SOT: an explicit scoped override wins, else the value heuristic - |
| 502 | // no `?? 'basic'` (which ignored an advanced-only value when basic was empty). |
| 503 | const explicitMode = canonicalModes?.[`${blockType}:${group.canonicalId}`] |
| 504 | const chosen = resolveActiveCanonicalValue( |
| 505 | group, |
| 506 | params, |
| 507 | explicitMode ? { [group.canonicalId]: explicitMode } : undefined |
| 508 | ) |
| 509 | if (chosen !== undefined) resolved[group.canonicalId] = chosen |
| 510 | } |
| 511 | return resolved |
| 512 | } |
| 513 | |
| 514 | /** |
| 515 | * Transforms a block tool into a provider tool config with operation selection |
no test coverage detected