( state: AutomationStateMetadata | null | undefined, )
| 114 | let currentMetadata: SessionExternalMetadata = {} |
| 115 | |
| 116 | function normalizeAutomationState( |
| 117 | state: AutomationStateMetadata | null | undefined, |
| 118 | ): AutomationStateMetadata | null { |
| 119 | if (!state || state.enabled !== true) { |
| 120 | return null |
| 121 | } |
| 122 | |
| 123 | return { |
| 124 | enabled: true, |
| 125 | phase: |
| 126 | state.phase === 'standby' || state.phase === 'sleeping' |
| 127 | ? state.phase |
| 128 | : null, |
| 129 | next_tick_at: |
| 130 | typeof state.next_tick_at === 'number' ? state.next_tick_at : null, |
| 131 | sleep_until: |
| 132 | typeof state.sleep_until === 'number' ? state.sleep_until : null, |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | function automationStateKey(state: AutomationStateMetadata | null): string { |
| 137 | return JSON.stringify(state) |
no outgoing calls
no test coverage detected