(args: unknown)
| 2606 | } |
| 2607 | |
| 2608 | function computerUseSemanticSignature(args: unknown): string | undefined { |
| 2609 | if (!args || typeof args !== 'object' || Array.isArray(args)) return undefined; |
| 2610 | const record = args as Record<string, unknown>; |
| 2611 | if ( |
| 2612 | record.action !== 'click_element' && |
| 2613 | record.action !== 'set_value' && |
| 2614 | record.action !== 'select_text' && |
| 2615 | record.action !== 'secondary_action' |
| 2616 | ) |
| 2617 | return undefined; |
| 2618 | try { |
| 2619 | const elementIdentity = stableElementIdentity(record.element_identity); |
| 2620 | return stableHash({ |
| 2621 | action: record.action, |
| 2622 | app: record.app, |
| 2623 | window_id: record.window_id, |
| 2624 | ...(elementIdentity === undefined |
| 2625 | ? { element_id: record.element_id } |
| 2626 | : { element_identity: elementIdentity }), |
| 2627 | value: record.value, |
| 2628 | text: record.text, |
| 2629 | }); |
| 2630 | } catch { |
| 2631 | return undefined; |
| 2632 | } |
| 2633 | } |
| 2634 | |
| 2635 | function stableElementIdentity(value: unknown): unknown { |
| 2636 | if (!value || typeof value !== 'object' || Array.isArray(value)) return value; |
no test coverage detected